Skip to main content

Module stream

Module stream 

Source
Expand description

Normalize caliban TurnEvent NDJSON frames into Prospero EventKinds.

Caliban’s agent worker writes [caliban_agent_core::stream::TurnEvent] records to its stream, each tagged by a PascalCase "type" field (#[serde(tag = "type")]): TurnStart, AssistantTextDelta, AssistantThinkingDelta, ToolCallStart, ToolCallInputDelta, ToolCallEnd, TurnEnd, RunEnd. That enum is the wire contract (ADR-0003) — this module is the only place that knows its shape.

We parse each line into a serde_json::Value (rather than depending on caliban’s crate) so that unknown frame types are skipped, not fatal — forward compatibility with caliban. The trade-off is that a renamed or new variant silently becomes Normalized::Unknown (counted via the unknown_frames metric); recognizes_every_known_turnevent_type below is the guard that fails loudly when the known set drifts.

Structs§

NormalizeOptions
Options controlling normalization.

Enums§

Normalized
Outcome of normalizing one frame.

Constants§

TOOL_RESULT_CAP
Longest tool result, in chars, prospero keeps on a ToolFinished event. Matches caliban’s STREAM_RESULT_TEXT_CAP (8 KiB), so a current caliban’s result_text passes through unchanged; the cap is prospero’s own guarantee that one tool call cannot put an unbounded body into the event stores or SSE.

Functions§

normalize_frame
Normalize a single parsed caliban TurnEvent frame.