MCPcopy Index your code
hub / github.com/codeaashu/claude-code / buildToolNameMap

Function buildToolNameMap

src/utils/toolResultStorage.ts:536–549  ·  view source on GitHub ↗

* Walk messages and build tool_use_id → tool_name from assistant tool_use * blocks. tool_use always precedes its tool_result (model calls, then result * arrives), so by the time budget enforcement sees a result, its name is known.

(messages: Message[])

Source from the content-addressed store, hash-verified

534 * arrives), so by the time budget enforcement sees a result, its name is known.
535 */
536function buildToolNameMap(messages: Message[]): Map<string, string> {
537 const map = new Map<string, string>()
538 for (const message of messages) {
539 if (message.type !== 'assistant') continue
540 const content = message.message.content
541 if (!Array.isArray(content)) continue
542 for (const block of content) {
543 if (block.type === 'tool_use') {
544 map.set(block.id, block.name)
545 }
546 }
547 }
548 return map
549}
550
551/**
552 * Extract candidate tool_result blocks from a single user message: blocks

Callers 1

enforceToolResultBudgetFunction · 0.85

Calls 1

setMethod · 0.45

Tested by

no test coverage detected