mirror of
https://github.com/dtzp555-max/olp.git
synced 2026-07-22 13:35:10 +00:00
Adds `proc.stdin.on('error', ...)` guard in anthropic.mjs, codex.mjs, and
mistral.mjs before any stdin.write() / stdin.end() call. Prevents a
fast-failing CLI (auth error, bad model, oversized prompt) from crashing the
single-process daemon via an unhandled EPIPE on the Node stdin Writable.
The ChildProcess 'error' event fires on the spawned process itself; it does
NOT catch errors on the stdin Writable. The stdin Writable emits its own
'error' event which, without a listener, propagates as an unhandled exception
and crashes the daemon.
Authority (ALIGNMENT.md Rule 1 + Rule 5):
- anthropic: claude CLI v2.1.104 observed behaviour — fast-failing spawn
(e.g. auth error, bad model) closes stdin before OLP finishes writing;
Node stdin Writable surfaces EPIPE. ALIGNMENT.md Rule 2: no CLI operation
changed; guard is a Node stream safety net only.
Port source: OCP server.mjs:777-784.
- codex: Codex CLI reference https://developers.openai.com/codex/cli/reference
— same mechanism; stdin path via `-` positional documented in reference
§ "Use '-' to pipe the prompt from stdin." ALIGNMENT.md Rule 2 applies.
- mistral: Mistral Vibe CLI https://docs.mistral.ai/mistral-vibe/terminal/quickstart
— vibe --prompt reads from args not stdin, but stdin.end() can still
surface EPIPE if the process exits before the fd is flushed.
ALIGNMENT.md Rule 2: no CLI operation changed.
A `typeof proc.stdin.on === 'function'` guard is included to protect
test-injected mock stdin objects (plain objects without .on()) from
breaking the EventEmitter call.
Co-Authored-By: Claude <claude-sonnet-4-6> <noreply@anthropic.com>