(input: unknown, action?: ToolAction)
| 137 | }; |
| 138 | |
| 139 | const extractPathFromInput = (input: unknown, action?: ToolAction): string | undefined => { |
| 140 | if (!input || typeof input !== 'object') return undefined; |
| 141 | const record = input as Record<string, unknown>; |
| 142 | const candidateKeys = [ |
| 143 | 'filePath', |
| 144 | 'file_path', |
| 145 | 'filepath', |
| 146 | 'path', |
| 147 | 'targetPath', |
| 148 | 'target_path', |
| 149 | 'target', |
| 150 | 'targets', |
| 151 | 'fullPath', |
| 152 | 'full_path', |
| 153 | 'destination', |
| 154 | 'destinationPath', |
| 155 | 'outputPath', |
| 156 | 'output_path', |
| 157 | 'glob', |
| 158 | 'pattern', |
| 159 | 'directory', |
| 160 | 'dir', |
| 161 | 'filename', |
| 162 | 'name', |
| 163 | ]; |
| 164 | |
| 165 | for (const key of candidateKeys) { |
| 166 | if (key in record) { |
| 167 | const candidate = record[key]; |
| 168 | const result = pickFirstString(candidate); |
| 169 | if (result) { |
| 170 | return result; |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (Array.isArray(record.targets)) { |
| 176 | for (const target of record.targets as unknown[]) { |
| 177 | const candidate = pickFirstString(target); |
| 178 | if (candidate) { |
| 179 | return candidate; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (!action || action === 'Executed') { |
| 185 | const commandKeys = ['command', 'cmd', 'shellCommand', 'shell_command']; |
| 186 | for (const key of commandKeys) { |
| 187 | if (key in record) { |
| 188 | const candidate = pickFirstString(record[key]); |
| 189 | if (candidate) { |
| 190 | return candidate; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | return undefined; |
no test coverage detected