* Type predicate: Check if a message is a collapsible tool use.
( msg: RenderableMessage, tools: Tools, )
| 404 | * Type predicate: Check if a message is a collapsible tool use. |
| 405 | */ |
| 406 | function isCollapsibleToolUse( |
| 407 | msg: RenderableMessage, |
| 408 | tools: Tools, |
| 409 | ): msg is CollapsibleMessage { |
| 410 | if (msg.type === 'assistant') { |
| 411 | const content = msg.message.content[0] |
| 412 | return ( |
| 413 | content?.type === 'tool_use' && |
| 414 | isToolSearchOrRead(content.name, content.input, tools) |
| 415 | ) |
| 416 | } |
| 417 | if (msg.type === 'grouped_tool_use') { |
| 418 | const firstContent = msg.messages[0]?.message.content[0] |
| 419 | return ( |
| 420 | firstContent?.type === 'tool_use' && |
| 421 | isToolSearchOrRead(msg.toolName, firstContent.input, tools) |
| 422 | ) |
| 423 | } |
| 424 | return false |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Type predicate: Check if a message is a tool result for collapsible tools. |
no test coverage detected