* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.
(
value: unknown,
name: string
)
| 1169 | * valid (or undefined), or a ToolResult with the error. |
| 1170 | */ |
| 1171 | private validateOptionalPath( |
| 1172 | value: unknown, |
| 1173 | name: string |
| 1174 | ): string | undefined | ToolResult { |
| 1175 | if (value === undefined || value === null) return undefined; |
| 1176 | if (typeof value !== 'string') { |
| 1177 | return this.errorResult(`${name} must be a string`); |
| 1178 | } |
| 1179 | if (value.length > MAX_PATH_LENGTH) { |
| 1180 | return this.errorResult( |
| 1181 | `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})` |
| 1182 | ); |
| 1183 | } |
| 1184 | return value; |
| 1185 | } |
| 1186 | |
| 1187 | /** |
| 1188 | * Cached git worktree/index mismatch for a tool call's effective project. |