feat: add usage metadata in acp session/update event

This commit is contained in:
tanzhenxin
2025-12-05 15:40:49 +08:00
parent 3e2a2255ee
commit 3a7b1159ae
12 changed files with 230 additions and 13 deletions

View File

@@ -59,7 +59,7 @@ export class ToolCallEmitter extends BaseEmitter {
await this.sendUpdate({
sessionUpdate: 'tool_call',
toolCallId: params.callId,
status: 'in_progress',
status: params.status || 'pending',
title,
content: [],
locations,
@@ -275,7 +275,14 @@ export class ToolCallEmitter extends BaseEmitter {
// Handle functionResponse parts - stringify the response
if ('functionResponse' in part && part.functionResponse) {
try {
const responseText = JSON.stringify(part.functionResponse.response);
const resp = part.functionResponse.response as Record<
string,
unknown
>;
const responseText =
(resp['output'] as string) ??
(resp['error'] as string) ??
JSON.stringify(resp);
result.push({
type: 'content',
content: { type: 'text', text: responseText },