Expand description
Codeoid wire protocol — Rust port of src/protocol/types.ts from the daemon.
This crate is pure data: no I/O, no async, no Tokio. It defines serde- compatible types for every message that flows between a Codeoid client and the daemon’s WebSocket server.
§Design notes
- Discriminated unions. TypeScript uses
type: "foo"andkind: "bar"as discriminants. In Rust these map to#[serde(tag = "type")]and#[serde(tag = "kind")]tagged enums. - Forward compatibility. The daemon’s design explicitly says “frontends
ignore unknown kinds”. We mirror that by using
#[serde(other)]on a trailingUnknownvariant and#[serde(flatten)]on extensible metadata maps. Adding new server-side message kinds never breaks an old Rust client — they deserialize intoDaemonMessage::Unknownand the TUI logs + skips them. - Tool state as full replacement.
ToolStateis a tagged enum where each phase carries its own shape. When aSessionMessageDeltaarrives withtool_state_update, replace the wholeToolInfo::state— do not merge fields.
§Versioning
PROTOCOL_VERSION is compared against the protocol_version field the
daemon sends on auth.ok. Mismatch is non-fatal (the daemon’s additive
changes keep old clients working), but the client warns the user so they
can upgrade.
Re-exports§
pub use client::Attachment;pub use client::ClientMessage;pub use client::SearchScope;pub use client::SendPriority;pub use client::SessionImportSource;pub use daemon::AuthOkMsg;pub use daemon::ClaudeConfigAgent;pub use daemon::ClaudeConfigHook;pub use daemon::ClaudeConfigMcpServer;pub use daemon::ClaudeConfigScope;pub use daemon::ClaudeConfigSkill;pub use daemon::DaemonMessage;pub use daemon::ErrorCode;pub use daemon::ModelInfo;pub use daemon::ProviderCommand;pub use daemon::SessionExportCounts;pub use daemon::SessionExportManifest;pub use daemon::SessionExportMetaSlim;pub use daemon::SessionExportPayload;pub use daemon::SessionExportWorkdir;pub use daemon::SessionSearchHit;pub use daemon::SessionSearchSnippet;pub use daemon::SessionUiRequestMsg;pub use daemon::UiRequestMethod;pub use daemon::UiResolvedReason;pub use message::ContentPart;pub use message::IdentityType;pub use message::MessageIdentity;pub use message::MessageRole;pub use message::SessionMessage;pub use message::SessionMessageDelta;pub use session::ForkedFrom;pub use session::SessionInfo;pub use session::SessionMode;pub use session::SessionStatus;pub use session::SessionUsage;pub use session::SessionWorktree;pub use session::Subagent;pub use session::TurnUsage;pub use tool::CancelReason;pub use tool::ConfirmedBy;pub use tool::ToolInfo;pub use tool::ToolPhase;pub use tool::ToolState;
Modules§
- client
- Client → Daemon messages.
- daemon
- Daemon → Client messages.
- message
- Session messages — the unit of observable work. Every prompt, tool call, tool result, and assistant reply flows as one of these.
- session
- Session metadata — the
SessionInfostruct and its satellites. - tool
- Tool invocation state machine.
Constants§
- PROTOCOL_
VERSION - Wire protocol version this crate speaks.