-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
64 lines (60 loc) · 2.88 KB
/
Copy pathlib.rs
File metadata and controls
64 lines (60 loc) · 2.88 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! 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"` and `kind: "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
//! trailing `Unknown` variant and `#[serde(flatten)]` on extensible metadata
//! maps. Adding new server-side message kinds never breaks an old Rust
//! client — they deserialize into [`DaemonMessage::Unknown`] and the TUI
//! logs + skips them.
//! * **Tool state as full replacement.** [`ToolState`] is a tagged enum where
//! each phase carries its own shape. When a [`SessionMessageDelta`] arrives
//! with `tool_state_update`, replace the whole [`ToolInfo::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.
#![deny(missing_debug_implementations)]
#![warn(clippy::pedantic)]
#![allow(clippy::module_name_repetitions)]
pub mod client;
pub mod daemon;
pub mod message;
pub mod session;
pub mod tool;
pub use client::{
Attachment, ClientMessage, SearchScope, SendPriority, SessionImportSource, SettingPatch,
};
pub use daemon::{
AuthOkMsg, ClaudeConfigAgent, ClaudeConfigHook, ClaudeConfigMcpServer, ClaudeConfigScope,
ClaudeConfigSkill, DaemonMessage, ErrorCode, McpServerStatus, ModelInfo, ProviderCommand,
SecretStatus, SessionExportCounts, SessionExportManifest, SessionExportMetaSlim,
SessionExportPayload, SessionExportWorkdir, SessionSearchHit, SessionSearchSnippet,
SessionUiRequestMsg, SettingError, SettingField, SettingOption, SettingState, SettingsGroup,
SettingsManifest, SettingsSnapshot, SettingsTab, UiRequestMethod, UiResolvedReason,
};
pub use message::{
ContentPart, IdentityType, MessageIdentity, MessageRole, SessionMessage, SessionMessageDelta,
};
pub use session::{
CollaborationConfig, CollaborationRole, CollaborationRoleRef, ForkedFrom, SessionInfo,
SessionMode, SessionStatus, SessionUsage, SessionWorktree, Subagent, TurnUsage,
};
pub use tool::{CancelReason, ConfirmedBy, ToolInfo, ToolPhase, ToolState};
/// Wire protocol version this crate speaks.
///
/// Compared against [`AuthOkMsg::protocol_version`] on connect. Bump this
/// alongside the daemon's `PROTOCOL_VERSION` on any breaking change.
pub const PROTOCOL_VERSION: u32 = 1;