* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.
(
value: unknown,
name: string
)
| 2781 | * valid (or undefined), or a ToolResult with the error. |
| 2782 | */ |
| 2783 | private validateOptionalPath( |
| 2784 | value: unknown, |
| 2785 | name: string |
| 2786 | ): string | undefined | ToolResult { |
| 2787 | if (value === undefined || value === null) return undefined; |
| 2788 | if (typeof value !== 'string') { |
| 2789 | return this.errorResult(`${name} must be a string`); |
| 2790 | } |
| 2791 | if (value.length > MAX_PATH_LENGTH) { |
| 2792 | return this.errorResult( |
| 2793 | `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})` |
| 2794 | ); |
| 2795 | } |
| 2796 | return value; |
| 2797 | } |
| 2798 | |
| 2799 | /** |
| 2800 | * Cached git worktree/index mismatch for a tool call's effective project. |