feat: 添加运行模式类型定义

- 添加 RunMode 类型(plan/ask/agent/auto)
- 添加 PlanConfirmEvent、ToolConfirmEvent 类型
- DialogRequest 使用 mode 字段替代 toolMode/planMode
This commit is contained in:
XiaoFeng
2025-12-30 20:42:11 +08:00
parent bd7a85b705
commit 91fadf591f

View File

@ -5,6 +5,15 @@
// ============== 对话请求/响应 ============== // ============== 对话请求/响应 ==============
/**
* 运行模式类型
* - plan: 只读模式,只能查询分析
* - ask: 逐个确认,每个写操作需确认
* - agent: 智能体自主(默认)
* - auto: 完全自动
*/
export type RunMode = 'plan' | 'ask' | 'agent' | 'auto';
/** /**
* 对话请求 * 对话请求
* POST /api/dialog/stream * POST /api/dialog/stream
@ -16,8 +25,8 @@ export interface DialogRequest {
message: string; message: string;
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
/** 工具模式 */ /** 运行模式 */
toolMode: 'ASK' | 'AGENT'; mode: RunMode;
} }
// ============== SSE 事件类型 ============== // ============== SSE 事件类型 ==============
@ -26,6 +35,8 @@ export interface DialogRequest {
export type SSEEventType = export type SSEEventType =
| 'text_delta' // 文本增量 | 'text_delta' // 文本增量
| 'tool_call' // 客户端工具调用请求 | 'tool_call' // 客户端工具调用请求
| 'tool_confirm' // 工具确认请求Ask 模式)
| 'plan_confirm' // 计划确认请求Plan 模式)
| 'tool_start' // 工具开始执行 | 'tool_start' // 工具开始执行
| 'tool_complete' // 工具执行完成 | 'tool_complete' // 工具执行完成
| 'tool_error' // 工具执行错误 | 'tool_error' // 工具执行错误
@ -63,6 +74,32 @@ export interface ToolErrorEvent {
error: string; error: string;
} }
/** tool_confirm 事件数据Ask 模式确认请求) */
export interface ToolConfirmEvent {
/** 确认ID用于匹配响应 */
confirmId: number;
/** 工具名称 */
toolName: string;
/** 工具输入参数 */
toolInput: Record<string, unknown>;
/** 时间戳 */
timestamp: number;
}
/** plan_confirm 事件数据Plan 模式计划确认) */
export interface PlanConfirmEvent {
/** 确认ID */
confirmId: number;
/** 计划标题 */
title: string;
/** 执行步骤列表 */
steps: string[];
/** 计划摘要 */
summary: string;
/** 时间戳 */
timestamp: number;
}
/** ask_user 事件数据 */ /** ask_user 事件数据 */
export interface AskUserEvent { export interface AskUserEvent {
askId: string; askId: string;
@ -229,6 +266,21 @@ export interface ToolResultResponse {
error?: string; error?: string;
} }
// ============== 工具确认响应 ==============
/**
* 工具确认响应请求
* POST /api/tool/confirm
*/
export interface ToolConfirmResponse {
/** 确认ID与 ToolConfirmEvent.confirmId 对应 */
confirmId: number;
/** 任务ID */
taskId: string;
/** 是否批准执行 */
approved: boolean;
}
// ============== 辅助类型 ============== // ============== 辅助类型 ==============
/** 后端工具名称 */ /** 后端工具名称 */