MCPcopy Index your code
hub / github.com/TanStack/ai / openToolCall

Function openToolCall

packages/ai-opencode/src/stream/translate.ts:272–306  ·  view source on GitHub ↗
(
    part: Extract<OpencodePart, { type: 'tool' }>,
  )

Source from the content-addressed store, hash-verified

270 }
271
272 function* openToolCall(
273 part: Extract<OpencodePart, { type: 'tool' }>,
274 ): Generator<StreamChunk> {
275 if (openedToolCalls.has(part.callID)) return
276 openedToolCalls.add(part.callID)
277 const toolCallName = resolveToolName(part.tool, ctx.bridgedToolNames)
278 const input = part.state.input ?? {}
279 const args = JSON.stringify(input)
280 yield {
281 type: EventType.TOOL_CALL_START,
282 toolCallId: part.callID,
283 toolCallName,
284 toolName: toolCallName,
285 model,
286 timestamp: now(),
287 }
288 yield {
289 type: EventType.TOOL_CALL_ARGS,
290 toolCallId: part.callID,
291 model,
292 timestamp: now(),
293 delta: args,
294 args,
295 }
296 yield {
297 type: EventType.TOOL_CALL_END,
298 toolCallId: part.callID,
299 toolCallName,
300 toolName: toolCallName,
301 model,
302 timestamp: now(),
303 input,
304 }
305 unresolvedToolCalls.add(part.callID)
306 }
307
308 function* handleToolPart(
309 part: Extract<OpencodePart, { type: 'tool' }>,

Callers 1

handleToolPartFunction · 0.70

Calls 3

hasMethod · 0.80
resolveToolNameFunction · 0.70
nowFunction · 0.70

Tested by

no test coverage detected