( state: EventHandlerState, event: PrintModeToolResult, )
| 450 | } |
| 451 | |
| 452 | const handleToolResult = ( |
| 453 | state: EventHandlerState, |
| 454 | event: PrintModeToolResult, |
| 455 | ) => { |
| 456 | const askUserResult = (event.output?.[0] as any)?.value |
| 457 | state.message.updater.updateAiMessageBlocks((blocks) => |
| 458 | transformAskUserBlocks(blocks, { |
| 459 | toolCallId: event.toolCallId, |
| 460 | resultValue: askUserResult, |
| 461 | }), |
| 462 | ) |
| 463 | |
| 464 | const firstOutput = event.output?.[0] |
| 465 | const firstOutputValue = |
| 466 | firstOutput && 'value' in firstOutput ? firstOutput.value : undefined |
| 467 | const isSpawnAgentsResult = |
| 468 | Array.isArray(firstOutputValue) && |
| 469 | firstOutputValue.some((v: any) => v?.agentName || v?.agentType) |
| 470 | |
| 471 | if (isSpawnAgentsResult && Array.isArray(firstOutputValue)) { |
| 472 | handleSpawnAgentsResult(state, event.toolCallId, firstOutputValue) |
| 473 | return |
| 474 | } |
| 475 | |
| 476 | state.message.updater.updateAiMessageBlocks((blocks) => |
| 477 | updateToolBlockWithOutput(blocks, { |
| 478 | toolCallId: event.toolCallId, |
| 479 | toolOutput: event.output, |
| 480 | }), |
| 481 | ) |
| 482 | |
| 483 | updateStreamingAgents(state, { remove: event.toolCallId }) |
| 484 | } |
| 485 | |
| 486 | const handleFinish = (state: EventHandlerState, event: PrintModeFinish) => { |
| 487 | if (typeof event.totalCost === 'number' && state.onTotalCost) { |
no test coverage detected