diff --git a/packages/coding-agent/src/core/vercel-ai-stream.ts b/packages/coding-agent/src/core/vercel-ai-stream.ts index f087b253..728b5eb7 100644 --- a/packages/coding-agent/src/core/vercel-ai-stream.ts +++ b/packages/coding-agent/src/core/vercel-ai-stream.ts @@ -95,6 +95,36 @@ export function createVercelStreamListener( id: `text_${inner.contentIndex}`, }); return; + case "toolcall_start": { + const content = inner.partial.content[inner.contentIndex]; + if (content?.type === "toolCall") { + writeChunk(response, { + type: "tool-input-start", + toolCallId: content.id, + toolName: content.name, + }); + } + return; + } + case "toolcall_delta": { + const content = inner.partial.content[inner.contentIndex]; + if (content?.type === "toolCall") { + writeChunk(response, { + type: "tool-input-delta", + toolCallId: content.id, + inputTextDelta: inner.delta, + }); + } + return; + } + case "toolcall_end": + writeChunk(response, { + type: "tool-input-available", + toolCallId: inner.toolCall.id, + toolName: inner.toolCall.name, + input: inner.toolCall.arguments, + }); + return; } return; } @@ -102,6 +132,22 @@ export function createVercelStreamListener( case "turn_end": writeChunk(response, { type: "finish-step" }); return; + + case "tool_execution_end": + if (event.isError) { + writeChunk(response, { + type: "tool-output-error", + toolCallId: event.toolCallId, + errorText: typeof event.result === "string" ? event.result : JSON.stringify(event.result), + }); + } else { + writeChunk(response, { + type: "tool-output-available", + toolCallId: event.toolCallId, + output: typeof event.result === "string" ? event.result : JSON.stringify(event.result), + }); + } + return; } }; }