* Type predicate: Check if a message is a collapsible tool use.
( msg: RenderableMessage, tools: Tools, behavior?: CollapseBehavior, )
| 432 | * Type predicate: Check if a message is a collapsible tool use. |
| 433 | */ |
| 434 | function isCollapsibleToolUse( |
| 435 | msg: RenderableMessage, |
| 436 | tools: Tools, |
| 437 | behavior?: CollapseBehavior, |
| 438 | ): msg is CollapsibleMessage { |
| 439 | if (msg.type === 'assistant') { |
| 440 | const content = msg.message.content[0] |
| 441 | return ( |
| 442 | content?.type === 'tool_use' && |
| 443 | isToolSearchOrRead(content.name, content.input, tools, behavior) |
| 444 | ) |
| 445 | } |
| 446 | if (msg.type === 'grouped_tool_use') { |
| 447 | const firstContent = msg.messages[0]?.message.content[0] |
| 448 | return ( |
| 449 | firstContent?.type === 'tool_use' && |
| 450 | isToolSearchOrRead(msg.toolName, firstContent.input, tools, behavior) |
| 451 | ) |
| 452 | } |
| 453 | return false |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Type predicate: Check if a message is a tool result for collapsible tools. |
no test coverage detected