MCPcopy Create free account
hub / github.com/Noumena-Network/code / isCollapsibleToolResult

Function isCollapsibleToolResult

src/utils/collapseReadSearch.ts:460–476  ·  view source on GitHub ↗

* Type predicate: Check if a message is a tool result for collapsible tools. * Returns true if ALL tool results in the message are for tracked collapsible tools.

(
  msg: RenderableMessage,
  collapsibleToolUseIds: Set<string>,
)

Source from the content-addressed store, hash-verified

458 * Returns true if ALL tool results in the message are for tracked collapsible tools.
459 */
460function isCollapsibleToolResult(
461 msg: RenderableMessage,
462 collapsibleToolUseIds: Set<string>,
463): msg is CollapsibleMessage {
464 if (msg.type === 'user') {
465 const toolResults = msg.message.content.filter(
466 (c): c is { type: 'tool_result'; tool_use_id: string } =>
467 c.type === 'tool_result',
468 )
469 // Only return true if there are tool results AND all of them are for collapsible tools
470 return (
471 toolResults.length > 0 &&
472 toolResults.every(r => collapsibleToolUseIds.has(r.tool_use_id))
473 )
474 }
475 return false
476}
477
478/**
479 * Get all tool use IDs from a single message (handles grouped tool uses).

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected