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
//! Streaming parser for [Claude Code](https://claude.com/claude-code) session JSONL files.
//!
//! Three modules, all `pub`:
//!
//! - [`usage`] — per-assistant-turn token/cost/tool entries (`UsageEntry`), session
//! summaries (`SessionUsage`), hook executions (`HookExecution`), pricing tables,
//! and project-path encoding compatible with Claude Code's `~/.claude/projects/`
//! directory naming.
//! - [`chat`] — flat, timestamp-ordered `ChatEvent` stream for rendering the
//! conversation (user / assistant / thinking / tool-use / tool-result blocks).
//! - [`activity`] — deterministic classifier that tags each assistant turn with one
//! of 13 categories (Coding, Debugging, Refactor, Testing, Exploration, …).
//!
//! Parsing is streaming (`BufReader::lines()`), tolerates malformed lines, and
//! caps inputs at [`MAX_JSONL_BYTES`] (200MB) so a corrupted or runaway file
//! cannot block a caller.
//!
//! See the crate README for the trust-surface description, the JSONL format
//! notes (split content blocks, `<synthetic>` skip, hook formats), and a usage
//! example.
/// Hard cap on JSONL file size accepted by [`usage::parse_jsonl_entries`] and
/// [`chat::parse_chat_events`].
///
/// Parsing is streaming (`BufReader::lines()`), so memory is O(1) per line —
/// this cap only exists to keep a runaway / corrupted file from blocking the
/// caller indefinitely. Real agent sessions (Task-tool sub-agents) frequently
/// exceed 30MB, so the cap is set generously at 200MB.
pub const MAX_JSONL_BYTES: u64 = 200 * 1024 * 1024;
pub use ;
pub use ;
pub use ;