Skip to main content

openbutler_protocol/
lib.rs

1//! Wire contract between OpenButler clients and the background host.
2//!
3//! This crate is the single source of truth for the daemon IPC protocol:
4//! envelope rules, framing, and the data structures that travel on the wire.
5//! It is extracted from the TypeScript implementation (openbutler-005,
6//! `src/daemon-protocol.ts`, `src/daemon-frames.ts` and companions, as read
7//! 2026-11-16) and pinned by the JSON vectors under `conformance/`.
8//!
9//! The crate is pure data plus the frame decoder: no I/O, no sockets, no
10//! runtime. Both the Rust daemon and the Rust CLI depend on it, and the
11//! TypeScript implementation is cross-checked against the same vectors.
12//!
13//! Layout: shared leaves live at the root (`action`, `auth`, `constants`,
14//! `util`, `error`, `frame`, `envelope`, `payload`, `endpoint`); domains that carry
15//! several
16//! authorities live in their own folder — [`session`] (record, run state,
17//! patches, transcript entries, reads, attach) and [`runtime`] (status,
18//! runtime view).
19//!
20//! The contract rules and the build live in `README.md`.
21
22pub mod action;
23pub mod audit;
24pub mod auth;
25pub mod backend;
26pub mod constants;
27pub mod endpoint;
28pub mod envelope;
29pub mod error;
30pub mod eventlog;
31pub mod frame;
32pub mod ledger;
33pub mod payload;
34pub mod runtime;
35pub mod screen;
36pub mod session;
37pub mod sidecar;
38pub mod util;
39
40// Historical module paths stay valid: these now live inside their domain
41// folder, re-exported here so no caller changes.
42pub use runtime::status;
43pub use screen::{ScreenLine, Tone};
44pub use session::{attach, entry};
45
46pub use action::{ACTIONS, Action, CommandExposure, Exposure, find, is_known};
47pub use audit::{AUDIT_SCHEMA, AuditRecord, chain_hash, walk_chain};
48pub use auth::{
49    AUTH_FAILED, LOGIN_FAILED, LOGIN_THROTTLED, NO_ACCOUNT, PAIR_FAILED,
50    REMOTE_FIRST_FRAME_REFUSED, SESSION_REFUSED, TOO_MANY_DEVICES,
51};
52pub use backend::{BACKEND_TARGET_VERSION, BackendTarget};
53pub use constants::{
54    DAEMON_PROTOCOL_VERSION, INLINE_IMAGE_MEDIA_TYPES, MAX_ADMISSION_FRAME_BYTES,
55    MAX_DAEMON_FRAME_BYTES, MAX_SESSION_TOKEN_LENGTH, SESSION_TOKEN_BYTES,
56};
57pub use entry::{SessionEntry, SessionEntryMeta, SessionProject};
58pub use envelope::{
59    DaemonEvent, DaemonNotification, DaemonRequest, DaemonResponse, validate_event,
60    validate_request, validate_response,
61};
62pub use error::{FrameError, ValidationError};
63pub use eventlog::{EVENTS, LogEvent, LogLevel, LogRecord};
64pub use frame::FrameDecoder;
65pub use runtime::{ApprovalMode, DaemonStatus, LocalClientKind, RuntimeViewData};
66pub use session::{
67    AttachResult, EntriesRangeRequest, InlineAttachment, SessionEntriesPatch, SessionEntriesRange,
68    SessionListAnswer, SessionPatch, SessionRecordWindow, SessionSearchAnswer, SessionSearchMatch,
69    SessionSearchRequest, SessionSnapshotData, SessionSummary, SessionView,
70};