Expand description
Top-level stream-json message shapes.
Every line the claude --output-format stream-json binary emits is one
of these variants. SDKโs AssistantMessage, UserMessage,
SystemMessage (plus task-lifecycle + mirror-error subclasses),
ResultMessage, and RateLimitEvent.
Re-exportsยง
use serde::de::Deserializer;๐use serde::ser::Serializer;๐use serde::Deserialize;๐use serde::Deserialize;๐use serde::Serialize;๐use serde::Serialize;๐use serde_json::Value;๐use crate::content::ContentBlock;๐use crate::runtime::TerminalReason;๐
Structsยง
- Assistant
Envelope - The Anthropic-API-shaped envelope inside an
Assistantmessage. - Compact
Metadata ๐Repr - The subset of
compact_boundaryโscompact_metadataforge reads, plus every sibling field it does not: the counts and the preserved segment cross verbatim so a lossless read reaches whoever draws them. - Generic
System ๐Repr - Rate
Limit Info - Rate-limit snapshot emitted inside a
Message::RateLimitEvent. - Stop
Hook Info - Per-hook entry inside a
stop_hook_summarysystem event (#273). Wire fields are camelCase (durationMs); the renderer reads thecommandtext for the expanded body. - Task
Update Patch - Patch payload carried by
Message::TaskUpdated. Fields are optional because the CLI emits patches that update only the changed fields.statusis the free-form wire string (e.g."completed","running","killed") - keeping it asStringrather than an enum lets the reducer accept future statuses without a forge-primitives bump. - Task
Usage - Usage counters reported inside task-progress and task-notification frames.
- Usage
- Token-usage accounting.
- User
Envelope - Envelope inside a
Usermessage.
Enumsยง
- Assistant
Message Error - Classification of a failure the CLI attributes to an assistant turn.
AssistantMessageErrorunion. - Message
- One stream-json message.
- Message
Repr ๐ - Rate
Limit Status - Rate-limit window status. Wire literal:
"allowed" | "allowed_warning" | "rejected". - Rate
Limit Type - Which rate-limit window applies.
- Stop
Reason - Anthropic APIโs stop-reason enum.
- System
Repr ๐ - A transient decode shim: serde tries the typed shape, then the generic
one, and the value is moved once into a
Message. Never stored or cloned, so the byte gap between its arms - whatlarge_enum_variantmeasures - is paid nowhere, and boxing the typed arm instead would add an allocation per lifecycle frame. - Task
Notification Status - Terminal status of a sub-agent
Taskreported viaMessage::TaskNotification. Wire literal:"completed" | "failed" | "stopped". - Typed
System ๐Repr - Workflow
Progress Event - Workflowโs per-event snapshot of the workflowโs
phase + agent state, ridden via
Message::TaskProgressโsworkflow_progressfield.
Functionsยง
- deserialize_
user_ ๐content - names_
a_ dispatch - Whether a
parent_tool_use_idnames the dispatch a frame ran under. Set and non-empty: the wire spells โno dispatchโ as null, and every fold that reads the field guards on the same thing. - null_
as_ ๐zero - Read a counter that may arrive as an explicit
null. - ran_
under_ a_ dispatch - Whether
messageran under a sub-agent dispatch, the chatโs own skip rule: such a frame is card material, so a chat read that carried it would spend its frame budget on a row no page draws.
Type Aliasesยง
- Extras
- Wire fields forge does not model, kept verbatim so a decode is lossless:
what the CLI sent crosses to whoever draws the raw frame even when
nothing here reads it. Reachable through
Messageโs variants and the values they nest.