* Extract file_path from a tool_use block's input, if present. * Returns undefined when the block is not an Edit/Write tool use or has no file_path.
(block: {
type: string
name?: string
input?: unknown
})
| 230 | * Returns undefined when the block is not an Edit/Write tool use or has no file_path. |
| 231 | */ |
| 232 | function getWrittenFilePath(block: { |
| 233 | type: string |
| 234 | name?: string |
| 235 | input?: unknown |
| 236 | }): string | undefined { |
| 237 | if ( |
| 238 | block.type !== 'tool_use' || |
| 239 | (block.name !== FILE_EDIT_TOOL_NAME && block.name !== FILE_WRITE_TOOL_NAME) |
| 240 | ) { |
| 241 | return undefined |
| 242 | } |
| 243 | const input = block.input |
| 244 | if (typeof input === 'object' && input !== null && 'file_path' in input) { |
| 245 | const fp = (input as { file_path: unknown }).file_path |
| 246 | return typeof fp === 'string' ? fp : undefined |
| 247 | } |
| 248 | return undefined |
| 249 | } |
| 250 | |
| 251 | function extractWrittenPaths(agentMessages: Message[]): string[] { |
| 252 | const paths: string[] = [] |
no outgoing calls
no test coverage detected