(
context: StreamingContext,
toolCallId: string,
toolName: string,
args: Record<string, unknown> | undefined,
existing: ToolCallState | undefined,
ui: { title?: string; phaseLabel?: string; hidden?: boolean }
)
| 413 | } |
| 414 | |
| 415 | function registerMainToolCall( |
| 416 | context: StreamingContext, |
| 417 | toolCallId: string, |
| 418 | toolName: string, |
| 419 | args: Record<string, unknown> | undefined, |
| 420 | existing: ToolCallState | undefined, |
| 421 | ui: { title?: string; phaseLabel?: string; hidden?: boolean } |
| 422 | ): void { |
| 423 | const hideFromUi = isToolHiddenInUi(toolName) || ui.hidden === true |
| 424 | if (existing) { |
| 425 | if (args && !existing.params) existing.params = args |
| 426 | applyToolDisplay(existing) |
| 427 | if (hideFromUi) { |
| 428 | removeToolCallContentBlock(context, toolCallId) |
| 429 | return |
| 430 | } |
| 431 | if ( |
| 432 | !hideFromUi && |
| 433 | !context.contentBlocks.some((b) => b.type === 'tool_call' && b.toolCall?.id === toolCallId) |
| 434 | ) { |
| 435 | addContentBlock(context, { type: 'tool_call', toolCall: existing }) |
| 436 | } |
| 437 | } else { |
| 438 | const created: ToolCallState = { |
| 439 | id: toolCallId, |
| 440 | name: toolName, |
| 441 | status: 'pending', |
| 442 | params: args, |
| 443 | startTime: Date.now(), |
| 444 | } |
| 445 | applyToolDisplay(created) |
| 446 | context.toolCalls.set(toolCallId, created) |
| 447 | if (!hideFromUi) { |
| 448 | addContentBlock(context, { type: 'tool_call', toolCall: created }) |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | async function dispatchToolExecution( |
| 454 | toolCall: ToolCallState, |
no test coverage detected