MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / handleToolResult

Function handleToolResult

cli/src/utils/sdk-event-handlers.ts:452–484  ·  view source on GitHub ↗
(
  state: EventHandlerState,
  event: PrintModeToolResult,
)

Source from the content-addressed store, hash-verified

450}
451
452const 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
486const handleFinish = (state: EventHandlerState, event: PrintModeFinish) => {
487 if (typeof event.totalCost === 'number' && state.onTotalCost) {

Callers 1

createEventHandlerFunction · 0.85

Calls 4

transformAskUserBlocksFunction · 0.90
handleSpawnAgentsResultFunction · 0.85
updateStreamingAgentsFunction · 0.85

Tested by

no test coverage detected