feat: AI 命令执行实时流式推送到工作空间终端

- execWorkspaceCommand 新增 onOutput 回调,stdout/stderr 实时推送
- ipc.ts workspace:execTool 实时转发输出 + 发送 toolDone 完成通知
- 渲染进程 appendToolStreamOutput 流式显示,handleToolDone 显示退出状态
- 去掉 tool-handlers.ts 中的一次性完整输出推送
- 完整流程:用户确认 → 实时输出 → 完成通知 → AI 回复结果
This commit is contained in:
thzxx
2026-04-08 13:06:57 +08:00
parent d150b53116
commit d5e5f5f58a
6 changed files with 70 additions and 51 deletions
+4 -2
View File
@@ -241,8 +241,10 @@ export interface MetonaDesktopAPI {
onExit: (callback: (data: { id: string; code: number | null }) => void) => void;
/** 无超时工具命令执行,用于 AI Tool Calling 集成 */
execTool: (command: string, cwd?: string) => Promise<{ success: boolean; stdout: string; stderr: string; exitCode: number | null; duration: number; userTerminated: boolean; truncated: boolean }>;
/** AI Tool Calling 命令输出 → 同步到工作空间终端 */
onToolOutput: (callback: (data: { command: string; stdout: string; stderr: string; exitCode: number | null }) => void) => void;
/** AI Tool Calling 实时输出推送到工作空间终端 */
onToolOutput: (callback: (data: { command: string; type: 'stdout' | 'stderr'; data: string }) => void) => void;
/** AI Tool Calling 命令执行完毕 */
onToolDone: (callback: (data: { command: string; exitCode: number | null }) => void) => void;
/** 终止当前 AI 工具命令 */
killTool: () => Promise<{ killed: boolean }>;
};