* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.
(
value: unknown,
name: string
)
| 1180 | * valid (or undefined), or a ToolResult with the error. |
| 1181 | */ |
| 1182 | private validateOptionalPath( |
| 1183 | value: unknown, |
| 1184 | name: string |
| 1185 | ): string | undefined | ToolResult { |
| 1186 | if (value === undefined || value === null) return undefined; |
| 1187 | if (typeof value !== 'string') { |
| 1188 | return this.errorResult(`${name} must be a string`); |
| 1189 | } |
| 1190 | if (value.length > MAX_PATH_LENGTH) { |
| 1191 | return this.errorResult( |
| 1192 | `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})` |
| 1193 | ); |
| 1194 | } |
| 1195 | return value; |
| 1196 | } |
| 1197 | |
| 1198 | /** |
| 1199 | * Cached git worktree/index mismatch for a tool call's effective project. |