Skip to content

Commit c84b470

Browse files
committed
Capture stderr from the child codex-acp
1 parent 417cb8a commit c84b470

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/packages/ai/acp/codex.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ export class CodexAcpAgent implements AcpAgent {
13861386

13871387
const HOME = process.env.COCALC_ORIGINAL_HOME ?? process.env.HOME;
13881388
const child = spawn(binary, args, {
1389-
stdio: ["pipe", "pipe", "inherit"],
1389+
stdio: ["pipe", "pipe", "pipe"],
13901390
env: { ...process.env, HOME, ...options.env },
13911391
cwd: options.cwd ?? process.cwd(),
13921392
});
@@ -1396,6 +1396,17 @@ export class CodexAcpAgent implements AcpAgent {
13961396
child.once("error", reject);
13971397
});
13981398

1399+
// Capture stderr from the child so ACP noise doesn't go to the main console.
1400+
child.stderr?.setEncoding("utf8");
1401+
child.stderr?.on("data", (chunk) => {
1402+
const text = chunk.toString();
1403+
if (text.trim().length === 0) return;
1404+
log.warn("acp.child.stderr", { text: text.trimEnd() });
1405+
});
1406+
child.stderr?.on("error", (err) => {
1407+
log.warn("acp.child.stderr_error", { err });
1408+
});
1409+
13991410
const output = Writable.toWeb(
14001411
child.stdin,
14011412
) as unknown as WritableStream<Uint8Array>;

0 commit comments

Comments
 (0)