Skip to main content

protocol/
names.rs

1//! The names both ends of a connection spell the same: the services the server and its session workers expose, and
2//! the error codes clients act on.
3
4/// Chord's own service-control endpoint (packages/chord/src/services/wire.ts `SERVICE_CONTROL_ID`): `catalogue`,
5/// `subscribe`, `unsubscribe`.
6pub const CHORD_SERVICE: &str = "$chord.service";
7
8/// Server-scoped: list, create, attach, remove sessions.
9pub const SESSION_MANAGEMENT: &str = "ultron.session-management";
10/// Server-scoped: the session store as a replicated listing.
11pub const SESSION_DIRECTORY: &str = "ultron.session-directory";
12pub const PRESENTATION_PLUGINS: &str = "ultron.presentation-plugins";
13
14/// Session-scoped (a session worker's).
15pub const AGENT_CONTROLLER: &str = "ultron.agent-controller";
16pub const TRANSCRIPT: &str = "ultron.transcript";
17pub const SESSION_CONTROL: &str = "ultron.session-control";
18pub const EXTENSION_UI: &str = "ultron.extension-ui";
19pub const MODELS: &str = "ultron.models";
20pub const SCHEDULES: &str = "ultron.schedules";
21pub const SESSION_PLUGINS: &str = "ultron.session-plugins";
22pub const LEGACY_EXTENSION_COMMANDS: &str = "ultron.legacy-extension-commands";
23/// A Rust addition: the session actor's operations (`{"op": ...}`).
24pub const SESSION_OPS: &str = "ultron.session-ops";
25
26/// The session's worker went away during the call; the server brings it back.
27pub const WORKER_LOST_CODE: &str = "session_worker_lost";
28/// The session's worker is being restarted; the call may be retried once it is back.
29pub const RECONNECTING_CODE: &str = "session_reconnecting";
30/// The worker is retiring (a newer release took over); the server routes the call to its successor.
31pub const WORKER_RETIRING_CODE: &str = "session_worker_retiring";
32pub const SESSION_NOT_FOUND_CODE: &str = "session_not_found";
33
34/// The code of a call that failed because the session's worker went away: the session is durable, rejoin it.
35pub fn is_lost_code(code: &str) -> bool {
36    code == WORKER_LOST_CODE || code == RECONNECTING_CODE
37}