1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! JSON Stream Parsing Module
//!
//! Functions for parsing NDJSON (newline-delimited JSON)
//! streams from Claude, Codex, Gemini, and `OpenCode` CLI tools.
//!
//! NDJSON is a format where each line contains a complete JSON object.
//! Agent CLIs emit NDJSON streams for real-time event processing.
//!
//! This module uses serde for JSON parsing, which is ~100x faster
//! than spawning jq for each event.
//!
//! # Key Types
//!
//! - [`ClaudeParser`] - Parser for Claude CLI NDJSON output
//! - [`CodexParser`] - Parser for `OpenAI` Codex CLI NDJSON output
//! - [`GeminiParser`] - Parser for Google Gemini CLI NDJSON output
//! - [`OpenCodeParser`] - Parser for `OpenCode` CLI NDJSON output
//!
//! Parser selection is controlled by [`crate::agents::JsonParserType`].
//!
//! # Module Structure
//!
//! - [`types`] - Shared types and event structures
//! - [`claude`] - Claude CLI output parser (with streaming support)
//! - [`codex`] - `OpenAI` Codex CLI output parser (with streaming support)
//! - [`gemini`] - Google Gemini CLI output parser (with streaming support)
//! - [`opencode`] - `OpenCode` CLI output parser (with streaming support)
//! - [`health`] - Parser health monitoring and graceful degradation
//! - [`printer`] - Test utilities for output verification (`test-utils` feature)
//!
//! # Streaming Support
//!
//! All parsers now support delta streaming for real-time content display:
//! - **Claude**: Full streaming with `DeltaAccumulator` for text and thinking deltas
//! - **Gemini**: Streaming with delta flag support for message content
//! - **Codex**: Streaming for `agent_message` and reasoning item types
//! - **`OpenCode`**: Streaming for text events
//!
//! In verbose mode, parsers show full accumulated content. In normal mode,
//! they show real-time deltas for immediate feedback.
//!
//! ## Verbosity Levels
//!
//! The parsers respect the configured verbosity level:
//! - **Quiet (0)**: Minimal output, aggressive truncation
//! - **Normal (1)**: Balanced output with moderate truncation, shows real-time deltas
//! - **Verbose (2)**: Default - shows more detail including tool inputs and full accumulated text
//! - **Full (3)**: No truncation, show all content
//! - **Debug (4)**: Maximum verbosity, includes raw JSON output
//!
//! # Internal Modules
//!
//! The `stream_classifier` module is internal and handles automatic detection
//! of streaming vs. non-streaming output. It is not exposed in the public API.
//!
//! For detailed streaming contract documentation, see `README.md` in this directory.
pub use TerminalMode;
pub type ClaudeParser = ClaudeParser;
pub type CodexParser = CodexParser;
pub type GeminiParser = GeminiParser;
pub type OpenCodeParser = OpenCodeParser;