* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.
(
value: unknown,
name: string
)
| 1702 | * valid (or undefined), or a ToolResult with the error. |
| 1703 | */ |
| 1704 | private validateOptionalPath( |
| 1705 | value: unknown, |
| 1706 | name: string |
| 1707 | ): string | undefined | ToolResult { |
| 1708 | if (value === undefined || value === null) return undefined; |
| 1709 | if (typeof value !== 'string') { |
| 1710 | return this.errorResult(`${name} must be a string`); |
| 1711 | } |
| 1712 | if (value.length > MAX_PATH_LENGTH) { |
| 1713 | return this.errorResult( |
| 1714 | `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})` |
| 1715 | ); |
| 1716 | } |
| 1717 | return value; |
| 1718 | } |
| 1719 | |
| 1720 | /** |
| 1721 | * Cached git worktree/index mismatch for a tool call's effective project. |