wcode_protocol/lib.rs
1//! Wire transport for wcode sessions — the socket behind the protocol.
2//!
3//! The kernel defines the *interface* ([`wcode_harness::protocol::Frame`] of
4//! [`Request`]/[`AgentEvent`]) and the in-process actor that speaks it. This
5//! crate adds the *transport*:
6//!
7//! - NDJSON framing ([`read_frame`]/[`write_frame`]),
8//! - a [`serve`] function that re-exposes a session [`SessionHandle`] to remote
9//! clients over a Unix socket,
10//! - a [`Client`] that mirrors the handle's `send`/`ask`/`subscribe` API,
11//! - a [`Backend`] that makes the local and remote paths interchangeable,
12//! - a [`Registry`] — the in-process A2A bus (§8 #3, §10.1): an address book
13//! plus the permitted-set routing that scopes who may message whom.
14//!
15//! The point (design: `docs/interface-protocol-brainstorm.md`, §8): a caller —
16//! the REPL today, the TUI next, another session later — talks to a [`Backend`]
17//! and never knows whether the session is in this process or across a socket.
18//!
19//! [`Request`]: wcode_harness::protocol::Request
20//! [`AgentEvent`]: wcode_harness::event::AgentEvent
21//! [`SessionHandle`]: wcode_harness::actor::SessionHandle
22
23mod backend;
24mod frame;
25mod registry;
26
27pub use backend::{AskError, Backend, Closed};
28pub use frame::{read_frame, write_frame};
29pub use registry::{Registry, RouteError};
30
31#[cfg(unix)]
32mod client;
33mod server;
34#[cfg(unix)]
35mod socket;
36
37#[cfg(unix)]
38pub use client::{Client, FLUSH_TIMEOUT, flush_all};
39pub use server::{DefineArgs, DefineHandler, Root, Roster, serve_stream, serve_stdio};
40#[cfg(unix)]
41pub use server::{serve, serve_at};
42#[cfg(unix)]
43pub use socket::{bind, connect};