diff --git a/packages/runtime/src/providers/codebuddy.ts b/packages/runtime/src/providers/codebuddy.ts index 3b5b1de..75f3cda 100644 --- a/packages/runtime/src/providers/codebuddy.ts +++ b/packages/runtime/src/providers/codebuddy.ts @@ -5,6 +5,7 @@ import os from 'node:os'; import path from 'node:path'; import { StringDecoder } from 'node:string_decoder'; import type { ProviderId } from '@wishforge/contracts'; +import { redactSecrets } from '@wishforge/contracts'; import { AGENT_GIT_IDENTITY, ManagedProvider } from './base.js'; import { executeCommand, type CommandExecutor } from '../process.js'; import { PROXY_VARIABLES } from '../sandbox.js'; @@ -469,10 +470,21 @@ export class StreamJsonCliAdapter extends ManagedProvider { pending = lines.pop() ?? ''; lines.forEach(parse); }); - child.stderr.on('data', () => undefined); // Raw diagnostics may contain credentials; do not stream them. + // Raw diagnostics never stream into the run — they may hold credentials — but throwing them away + // entirely leaves a stalled CLI silent. The worker log keeps the tail with secrets removed. + let diagnostics = ''; + const diagnosticsLimit = 8 * 1024; + const reportDiagnostics = () => { + const tail = diagnostics.slice(-4_000).trim(); + if (tail) console.warn(`[${this.dialect.label}] stderr:\n${redactSecrets(redact(tail))}`); + }; + child.stderr.on('data', (chunk: Buffer) => { + if (diagnostics.length < diagnosticsLimit) diagnostics += chunk.toString('utf8'); + }); child.on('error', error => { clearTimeout(timer); reportEstimate(); + reportDiagnostics(); this.finish(run, 'failed', redact(error.message)); }); child.on('close', code => { @@ -480,6 +492,8 @@ export class StreamJsonCliAdapter extends ManagedProvider { run.controller.signal.removeEventListener('abort', abort); parse(pending + decoder.end()); reportEstimate(); + // A run that stopped on its own says why; a failed or canceled one is worth its last words. + if (run.controller.signal.aborted || code !== 0 || failed || !sawSuccess) reportDiagnostics(); if (run.controller.signal.aborted) this.finish(run, 'canceled'); else if (code === 0 && sawSuccess && !failed) this.finish(run, 'completed'); else