diff --git a/src/agent/tools/exec.ts b/src/agent/tools/exec.ts index 11338593..cf77d83f 100644 --- a/src/agent/tools/exec.ts +++ b/src/agent/tools/exec.ts @@ -47,7 +47,7 @@ export function createExecTool(defaultCwd?: string): AgentTool' to check output, 'process status ' to check status, 'process stop ' to terminate.", parameters: ExecSchema, - execute: async (_toolCallId, args, signal) => { + execute: async (_toolCallId, args, signal, onUpdate) => { const { command, cwd, timeoutMs, yieldMs = DEFAULT_YIELD_MS } = args as ExecArgs; const effectiveCwd = cwd || defaultCwd; @@ -67,6 +67,29 @@ export function createExecTool(defaultCwd?: string): AgentTool { + if (!onUpdate || yielded) return; + const entry = PROCESS_REGISTRY.get(processId); + if (!entry) return; + onUpdate({ + content: [{ type: "text", text: entry.tailBuffer || "(running...)" }], + details: { + output: entry.tailBuffer, + exitCode: null, + truncated: false, + processId, + }, + }); + }; + + // Listen to stdout/stderr to trigger onUpdate (data collection is handled by registerProcess) + if (onUpdate) { + child.stdout?.on("data", emitUpdate); + child.stderr?.on("data", emitUpdate); + } + // Timeout handling (hard kill) if (timeoutMs && timeoutMs > 0) { timeout = setTimeout(() => {