feat(ui): 优化流式输出工具调用渲染
- 添加 tool_start/tool_end WebSocket 事件支持 - 流式消息复用 ChatMessage 组件渲染工具调用卡片 - 修复 AI SDK v5 格式兼容问题(input/output 字段) - 修复会话恢复时 tool-result 格式错误 - 放宽 ToolState schema 中 input 字段类型为 unknown
This commit is contained in:
@@ -877,3 +877,29 @@ export interface FileSearchResponse {
|
||||
};
|
||||
}
|
||||
|
||||
// ============ 流式工具调用事件 ============
|
||||
|
||||
/** 工具开始事件 Payload */
|
||||
export interface ToolStartPayload {
|
||||
/** 工具调用唯一 ID */
|
||||
id: string;
|
||||
/** 工具名称 */
|
||||
toolName: string;
|
||||
/** 调用参数 */
|
||||
arguments: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/** 工具结束事件 Payload */
|
||||
export interface ToolEndPayload {
|
||||
/** 对应 tool_start 的 ID */
|
||||
id: string;
|
||||
/** 执行状态 */
|
||||
status: 'completed' | 'error';
|
||||
/** 执行结果 */
|
||||
result?: unknown;
|
||||
/** 错误信息 */
|
||||
error?: string;
|
||||
/** 执行时长 (ms) */
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user