From 91fadf591f0dad1f858ebc2dc6fa1465dd7907b7 Mon Sep 17 00:00:00 2001 From: XiaoFeng <117837368+Fzhiyu1@users.noreply.github.com> Date: Tue, 30 Dec 2025 20:42:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 RunMode 类型(plan/ask/agent/auto) - 添加 PlanConfirmEvent、ToolConfirmEvent 类型 - DialogRequest 使用 mode 字段替代 toolMode/planMode --- src/types/api.ts | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/types/api.ts b/src/types/api.ts index 5b8c514..7f3d227 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -5,6 +5,15 @@ // ============== 对话请求/响应 ============== +/** + * 运行模式类型 + * - plan: 只读模式,只能查询分析 + * - ask: 逐个确认,每个写操作需确认 + * - agent: 智能体自主(默认) + * - auto: 完全自动 + */ +export type RunMode = 'plan' | 'ask' | 'agent' | 'auto'; + /** * 对话请求 * POST /api/dialog/stream @@ -16,8 +25,8 @@ export interface DialogRequest { message: string; /** 用户ID */ userId: string; - /** 工具模式 */ - toolMode: 'ASK' | 'AGENT'; + /** 运行模式 */ + mode: RunMode; } // ============== SSE 事件类型 ============== @@ -26,6 +35,8 @@ export interface DialogRequest { export type SSEEventType = | 'text_delta' // 文本增量 | 'tool_call' // 客户端工具调用请求 + | 'tool_confirm' // 工具确认请求(Ask 模式) + | 'plan_confirm' // 计划确认请求(Plan 模式) | 'tool_start' // 工具开始执行 | 'tool_complete' // 工具执行完成 | 'tool_error' // 工具执行错误 @@ -63,6 +74,32 @@ export interface ToolErrorEvent { error: string; } +/** tool_confirm 事件数据(Ask 模式确认请求) */ +export interface ToolConfirmEvent { + /** 确认ID,用于匹配响应 */ + confirmId: number; + /** 工具名称 */ + toolName: string; + /** 工具输入参数 */ + toolInput: Record; + /** 时间戳 */ + timestamp: number; +} + +/** plan_confirm 事件数据(Plan 模式计划确认) */ +export interface PlanConfirmEvent { + /** 确认ID */ + confirmId: number; + /** 计划标题 */ + title: string; + /** 执行步骤列表 */ + steps: string[]; + /** 计划摘要 */ + summary: string; + /** 时间戳 */ + timestamp: number; +} + /** ask_user 事件数据 */ export interface AskUserEvent { askId: string; @@ -229,6 +266,21 @@ export interface ToolResultResponse { error?: string; } +// ============== 工具确认响应 ============== + +/** + * 工具确认响应请求 + * POST /api/tool/confirm + */ +export interface ToolConfirmResponse { + /** 确认ID,与 ToolConfirmEvent.confirmId 对应 */ + confirmId: number; + /** 任务ID */ + taskId: string; + /** 是否批准执行 */ + approved: boolean; +} + // ============== 辅助类型 ============== /** 后端工具名称 */