🔊 Keep the executor CLI's last words, with secrets removed
Raw stderr never streamed into a run because it may carry credentials, but discarding it left a stalled CLI completely silent — there was no way to tell "cannot reach the gateway" from "still thinking". The tail of stderr now goes to the worker log when a run fails, is canceled or never saw a success, with both the CLI's credential values and the usual key/token shapes removed.
This commit is contained in:
parent
2bd9333089
commit
4fa6b9285c
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user