* Get the tool name, input, and search/read info from a message if it's a collapsible tool use. * Returns null if the message is not a collapsible tool use.
( msg: RenderableMessage, tools: Tools, )
| 288 | * Returns null if the message is not a collapsible tool use. |
| 289 | */ |
| 290 | function getCollapsibleToolInfo( |
| 291 | msg: RenderableMessage, |
| 292 | tools: Tools, |
| 293 | ): { |
| 294 | name: string |
| 295 | input: unknown |
| 296 | isSearch: boolean |
| 297 | isRead: boolean |
| 298 | isList: boolean |
| 299 | isREPL: boolean |
| 300 | isMemoryWrite: boolean |
| 301 | isAbsorbedSilently: boolean |
| 302 | mcpServerName?: string |
| 303 | isBash?: boolean |
| 304 | } | null { |
| 305 | if (msg.type === 'assistant') { |
| 306 | const content = msg.message.content[0] |
| 307 | const info = getSearchOrReadFromContent(content, tools) |
| 308 | if (info && content?.type === 'tool_use') { |
| 309 | return { name: content.name, input: content.input, ...info } |
| 310 | } |
| 311 | } |
| 312 | if (msg.type === 'grouped_tool_use') { |
| 313 | // For grouped tool uses, check the first message's input |
| 314 | const firstContent = msg.messages[0]?.message.content[0] |
| 315 | const info = getSearchOrReadFromContent( |
| 316 | firstContent |
| 317 | ? { type: 'tool_use', name: msg.toolName, input: firstContent.input } |
| 318 | : undefined, |
| 319 | tools, |
| 320 | ) |
| 321 | if (info && firstContent?.type === 'tool_use') { |
| 322 | return { name: msg.toolName, input: firstContent.input, ...info } |
| 323 | } |
| 324 | } |
| 325 | return null |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Check if a message is assistant text that should break a group. |
no test coverage detected