(
context: StreamingContext,
toolCallId: string,
toolName: string,
args: Record<string, unknown> | undefined,
parentToolCallId: string,
ui: { title?: string; phaseLabel?: string; hidden?: boolean },
spanIdentity: { spanId?: string; parentSpanId?: string }
)
| 361 | } |
| 362 | |
| 363 | function registerSubagentToolCall( |
| 364 | context: StreamingContext, |
| 365 | toolCallId: string, |
| 366 | toolName: string, |
| 367 | args: Record<string, unknown> | undefined, |
| 368 | parentToolCallId: string, |
| 369 | ui: { title?: string; phaseLabel?: string; hidden?: boolean }, |
| 370 | spanIdentity: { spanId?: string; parentSpanId?: string } |
| 371 | ): void { |
| 372 | if (!context.subAgentToolCalls[parentToolCallId]) { |
| 373 | context.subAgentToolCalls[parentToolCallId] = [] |
| 374 | } |
| 375 | const hideFromUi = isToolHiddenInUi(toolName) || ui.hidden === true |
| 376 | let toolCall = context.toolCalls.get(toolCallId) |
| 377 | if (toolCall) { |
| 378 | if (!toolCall.name && toolName) toolCall.name = toolName |
| 379 | if (args && !toolCall.params) toolCall.params = args |
| 380 | applyToolDisplay(toolCall) |
| 381 | if (hideFromUi) removeToolCallContentBlock(context, toolCallId) |
| 382 | } else { |
| 383 | toolCall = { |
| 384 | id: toolCallId, |
| 385 | name: toolName, |
| 386 | status: 'pending', |
| 387 | params: args, |
| 388 | startTime: Date.now(), |
| 389 | } |
| 390 | applyToolDisplay(toolCall) |
| 391 | context.toolCalls.set(toolCallId, toolCall) |
| 392 | const parentToolCall = context.toolCalls.get(parentToolCallId) |
| 393 | if (!hideFromUi) { |
| 394 | addContentBlock(context, { |
| 395 | type: 'tool_call', |
| 396 | toolCall, |
| 397 | calledBy: parentToolCall?.name, |
| 398 | parentToolCallId, |
| 399 | ...spanIdentity, |
| 400 | }) |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | const subagentToolCalls = context.subAgentToolCalls[parentToolCallId] |
| 405 | const existingSubagentToolCall = subagentToolCalls.find((tc) => tc.id === toolCallId) |
| 406 | if (existingSubagentToolCall) { |
| 407 | if (!existingSubagentToolCall.name && toolName) existingSubagentToolCall.name = toolName |
| 408 | if (args && !existingSubagentToolCall.params) existingSubagentToolCall.params = args |
| 409 | applyToolDisplay(existingSubagentToolCall) |
| 410 | } else { |
| 411 | subagentToolCalls.push(toolCall) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | function registerMainToolCall( |
| 416 | context: StreamingContext, |
no test coverage detected