fix: AI Tool Calling run_command 输出同步到工作空间终端面板

- handleRunCommand 改用 execWorkspaceCommand 替代 Node exec()
- 执行完成后通过 workspace:toolOutput IPC 事件推送命令和输出
- 渲染进程监听 onToolOutput,在活跃终端显示 AI 命令及结果
- 清理 tool-handlers.ts 中不再需要的 child_process 导入
This commit is contained in:
thzxx
2026-04-08 12:47:28 +08:00
parent 5800aaedd2
commit d5f4112d97
4 changed files with 69 additions and 25 deletions
+5 -1
View File
@@ -60,6 +60,10 @@ contextBridge.exposeInMainWorld('metonaDesktop', {
ipcRenderer.on('workspace:exit', (_: unknown, data: { id: string; code: number | null }) => callback(data));
},
/** 无超时命令执行,用于 AI Tool Calling */
execTool: (command: string, cwd?: string) => ipcRenderer.invoke('workspace:execTool', command, cwd)
execTool: (command: string, cwd?: string) => ipcRenderer.invoke('workspace:execTool', command, cwd),
/** AI Tool Calling 命令输出 → 同步到工作空间终端 */
onToolOutput: (callback: (data: { command: string; stdout: string; stderr: string; exitCode: number | null }) => void) => {
ipcRenderer.on('workspace:toolOutput', (_: unknown, data: { command: string; stdout: string; stderr: string; exitCode: number | null }) => callback(data));
}
}
});