Adds real-time streaming output support to CLI backends, enabling
line-by-line parsing of NDJSON output instead of waiting for the
full response. This brings CLI backends closer to the embedded/API
flow by emitting events as they arrive.
Key changes:
- New streaming execution module (cli-runner/streaming.ts):
- Uses readline to parse NDJSON lines as they arrive
- Extracts session IDs, usage stats, and text from stream
- Supports event type filtering with prefix matching
- Maps CLI-specific events to Clawdbot agent events
- Config extension:
- Added `streaming?: boolean` to enable streaming mode
- Added `streamingEventTypes?: string[]` to filter events
- Claude CLI defaults: stream-json format with --verbose flag
- Codex CLI defaults: streaming enabled with item/turn events
- Event mapping for different CLI formats:
- Claude CLI: tool_use, tool_result, text, result events
- Codex CLI: item.*, turn.completed, thread.completed events
- Debug logging throughout the pipeline:
- Logs raw JSON lines, parsed types, session/usage extraction
- Logs event emission and mapping decisions
- Helps diagnose streaming issues in production
The streaming path is enabled by default for Claude CLI and Codex CLI.
Users can disable it by setting `streaming: false` in their config.
Non-streaming path via runCommandWithTimeout remains available.