Skip to main content

Module messages

Module messages 

Source
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ยง

AssistantEnvelope
The Anthropic-API-shaped envelope inside an Assistant message.
CompactMetadataRepr ๐Ÿ”’
The subset of compact_boundaryโ€™s compact_metadata forge reads, plus every sibling field it does not: the counts and the preserved segment cross verbatim so a lossless read reaches whoever draws them.
GenericSystemRepr ๐Ÿ”’
RateLimitInfo
Rate-limit snapshot emitted inside a Message::RateLimitEvent.
StopHookInfo
Per-hook entry inside a stop_hook_summary system event (#273). Wire fields are camelCase (durationMs); the renderer reads the command text for the expanded body.
TaskUpdatePatch
Patch payload carried by Message::TaskUpdated. Fields are optional because the CLI emits patches that update only the changed fields. status is the free-form wire string (e.g. "completed", "running", "killed") - keeping it as String rather than an enum lets the reducer accept future statuses without a forge-primitives bump.
TaskUsage
Usage counters reported inside task-progress and task-notification frames.
Usage
Token-usage accounting.
UserEnvelope
Envelope inside a User message.

Enumsยง

AssistantMessageError
Classification of a failure the CLI attributes to an assistant turn. AssistantMessageError union.
Message
One stream-json message.
MessageRepr ๐Ÿ”’
RateLimitStatus
Rate-limit window status. Wire literal: "allowed" | "allowed_warning" | "rejected".
RateLimitType
Which rate-limit window applies.
StopReason
Anthropic APIโ€™s stop-reason enum.
SystemRepr ๐Ÿ”’
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 - what large_enum_variant measures - is paid nowhere, and boxing the typed arm instead would add an allocation per lifecycle frame.
TaskNotificationStatus
Terminal status of a sub-agent Task reported via Message::TaskNotification. Wire literal: "completed" | "failed" | "stopped".
TypedSystemRepr ๐Ÿ”’
WorkflowProgressEvent
Workflowโ€™s per-event snapshot of the workflowโ€™s phase + agent state, ridden via Message::TaskProgressโ€™s workflow_progress field.

Functionsยง

deserialize_user_content ๐Ÿ”’
names_a_dispatch
Whether a parent_tool_use_id names 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 message ran 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.