* Count tool uses in an assistant message and add to existing counts.
( message: SDKAssistantMessage, counts: ToolCounts, )
| 107 | * Count tool uses in an assistant message and add to existing counts. |
| 108 | */ |
| 109 | function accumulateToolUses( |
| 110 | message: SDKAssistantMessage, |
| 111 | counts: ToolCounts, |
| 112 | ): void { |
| 113 | const content = message.message.content |
| 114 | if (!Array.isArray(content)) { |
| 115 | return |
| 116 | } |
| 117 | |
| 118 | for (const block of content) { |
| 119 | if (block.type === 'tool_use' && 'name' in block) { |
| 120 | const category = categorizeToolName(block.name as string) |
| 121 | counts[category]++ |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Create a stateful transformer that accumulates tool counts between text messages. |
no test coverage detected