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
//! Streaming utilities for SSE parsing and stream accumulation.
//!
//! Three stages sit between the raw HTTP response and the [`StreamEvent`](crate::StreamEvent)s
//! a caller sees:
//!
//! ```text
//! Raw HTTP body (SSE) ──sse──▶ Stream<wire event>
//! ──accumulator──▶ Vec<StreamEvent>
//! ──driver──▶ Stream<StreamEvent>
//! ```
//!
//! - [`sse`] decodes the SSE wire format, buffering across arbitrary HTTP transport chunk
//! boundaries so an event split mid-JSON (or mid-UTF-8) still parses.
//! - [`accumulator`] and [`anthropic_accumulator`] reassemble the per-event deltas — text,
//! reasoning, and tool call arguments all arrive fragmented — and decide when a complete
//! block can be emitted. One per wire protocol, since only the vocabulary differs.
//! - [`driver`] owns everything that does not: the end-of-transport sentinel, threading the
//! accumulator through the stream, and flattening its batches.
//!
//! The rationale for each stage lives with its code rather than being restated here.
// Real submodules rather than `include!` fragments: `cargo-mutants` walks `mod`
// declarations but does not expand `include!`, so fragment-backed code is invisible to the
// mutation gate. Re-exporting keeps `crate::utils::{StreamAccumulator, parse_sse_stream}`
// unchanged for callers.
pub use StreamAccumulator;
pub use AnthropicAccumulator;
pub use ;
pub use ;