* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.
(
value: unknown,
name: string
)
| 1139 | * valid (or undefined), or a ToolResult with the error. |
| 1140 | */ |
| 1141 | private validateOptionalPath( |
| 1142 | value: unknown, |
| 1143 | name: string |
| 1144 | ): string | undefined | ToolResult { |
| 1145 | if (value === undefined || value === null) return undefined; |
| 1146 | if (typeof value !== 'string') { |
| 1147 | return this.errorResult(`${name} must be a string`); |
| 1148 | } |
| 1149 | if (value.length > MAX_PATH_LENGTH) { |
| 1150 | return this.errorResult( |
| 1151 | `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})` |
| 1152 | ); |
| 1153 | } |
| 1154 | return value; |
| 1155 | } |
| 1156 | |
| 1157 | /** |
| 1158 | * Cached git worktree/index mismatch for a tool call's effective project. |