* Extract the primary file/directory path from a tool_use input. * Handles both `file_path` (Read/Write/Edit) and `path` (Grep/Glob). * `path` may be a string or an array of strings for multi-directory tools.
(toolInput: unknown)
| 74 | * `path` may be a string or an array of strings for multi-directory tools. |
| 75 | */ |
| 76 | function getFilePathFromToolInput(toolInput: unknown): string | undefined { |
| 77 | const input = toolInput as |
| 78 | | { file_path?: string; path?: string | string[]; pattern?: string; glob?: string } |
| 79 | | undefined |
| 80 | if (input?.file_path) { |
| 81 | return input.file_path |
| 82 | } |
| 83 | if (input?.path) { |
| 84 | return Array.isArray(input.path) ? input.path[0] : input.path |
| 85 | } |
| 86 | return undefined |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Check if a search tool use targets memory files by examining its path, pattern, and glob. |
no outgoing calls
no test coverage detected