MCPcopy
hub / github.com/TanStack/ai / emitToolUse

Function emitToolUse

packages/ai-claude-code/src/stream/translate.ts:182–215  ·  view source on GitHub ↗
(block: {
    id: string
    name: string
    input: unknown
  })

Source from the content-addressed store, hash-verified

180 }
181
182 function* emitToolUse(block: {
183 id: string
184 name: string
185 input: unknown
186 }): Generator<StreamChunk> {
187 const toolCallName = stripMcpPrefix(block.name)
188 const args = JSON.stringify(block.input ?? {})
189 yield {
190 type: EventType.TOOL_CALL_START,
191 toolCallId: block.id,
192 toolCallName,
193 toolName: toolCallName,
194 model,
195 timestamp: now(),
196 }
197 yield {
198 type: EventType.TOOL_CALL_ARGS,
199 toolCallId: block.id,
200 model,
201 timestamp: now(),
202 delta: args,
203 args,
204 }
205 yield {
206 type: EventType.TOOL_CALL_END,
207 toolCallId: block.id,
208 toolCallName,
209 toolName: toolCallName,
210 model,
211 timestamp: now(),
212 input: block.input ?? {},
213 }
214 unresolvedToolCalls.add(block.id)
215 }
216
217 function* handleAssistant(
218 message: SdkAssistantMessage,

Callers 1

handleAssistantFunction · 0.85

Calls 2

stripMcpPrefixFunction · 0.85
nowFunction · 0.70

Tested by

no test coverage detected