One For All Protocol
Pure IPC protocol types for the Unbound daemon - no I/O, no async. This crate defines the shared language between the IPC client (macOS app) and server (daemon). Only data types and serialization, nothing else.
┌──────────────────┐ ┌──────────────────┐
│ macOS App │ │ Daemon │
│ │ Request │ │
│ Request::new() ─┼──► JSON ────────►─┼─► Method match │
│ │ │ │ │
│ Response:: ◄┼── JSON ◄─────────┼── Response:: │
│ from_json() │ Response │ success() │
│ │ │ │
│ Event:: ◄┼── JSON ◄─────────┼── Event::new() │
│ from_json() │ Stream │ │
└──────────────────┘ └──────────────────┘
JSON-RPC-like protocol over Unix domain sockets (NDJSON - one JSON object per line).
use one_for_all_protocol :: { Request , Method };
// Auto-generates UUID v4 request ID
let req = Request :: new ( Method :: SessionList );
// With parameters
let req = Request :: with_params (
Method :: SessionCreate ,
serde_json :: json! ({ "title" : "My Session" , "repository_id" : "repo-1" }),
);
// Serializes to:
// {"id":"550e8400-...","method":"session.create","params":{"title":"My Session",...}}
use one_for_all_protocol :: { Response , error_codes};
// Success
let resp = Response :: success ( & req . id, serde_json :: json! ({ "id" : "sess-1" }));
// Error
let resp = Response :: error ( & req . id, error_codes :: NOT_FOUND , "Session not found" );
// Check
resp . is_success (); // true or false
use one_for_all_protocol :: { Event , EventType };
let event = Event :: new (
EventType :: Message ,
"session-123" . to_string (),
serde_json :: json! ({ "content" : "Hello" }),
42 , // sequence number
);
Method Wire Name HealthhealthShutdownshutdown
Method Wire Name AuthStatusauth.statusAuthLoginauth.loginAuthLogoutauth.logout
Method Wire Name SessionListsession.listSessionCreatesession.createSessionGetsession.getSessionDeletesession.deleteSessionSubscribesession.subscribeSessionUnsubscribesession.unsubscribe
Method Wire Name MessageListmessage.listMessageSendmessage.send
Method Wire Name OutboxStatusoutbox.status
Method Wire Name RepositoryListrepository.listRepositoryAddrepository.addRepositoryRemoverepository.removeRepositoryListFilesrepository.list_filesRepositoryReadFilerepository.read_fileRepositoryReadFileSlicerepository.read_file_sliceRepositoryWriteFilerepository.write_fileRepositoryReplaceFileRangerepository.replace_file_range
Method Wire Name ClaudeSendclaude.sendClaudeStatusclaude.statusClaudeStopclaude.stop
Method Wire Name GitStatusgit.statusGitDiffFilegit.diff_fileGitLoggit.logGitBranchesgit.branchesGitStagegit.stageGitUnstagegit.unstageGitDiscardgit.discard
Method Wire Name GhAuthStatusgh.auth_statusGhPrCreategh.pr_createGhPrViewgh.pr_viewGhPrListgh.pr_listGhPrChecksgh.pr_checksGhPrMergegh.pr_merge
Method Wire Name TerminalRunterminal.runTerminalStatusterminal.statusTerminalStopterminal.stop
EventType Description MessageNew message added to session StreamingChunkReal-time Claude response chunk StatusChangeSession status changed InitialStateState dump on subscribe PingKeepalive TerminalOutputTerminal stdout/stderr TerminalFinishedTerminal process exited ClaudeEventRaw Claude NDJSON event AuthStateChangedLogin/logout state change SessionCreatedNew session created SessionDeletedSession removed
Standard JSON-RPC codes plus custom extensions:
pub mod error_codes {
// Standard JSON-RPC
pub const PARSE_ERROR : i32 = - 32700 ;
pub const INVALID_REQUEST : i32 = - 32600 ;
pub const METHOD_NOT_FOUND : i32 = - 32601 ;
pub const INVALID_PARAMS : i32 = - 32602 ;
pub const INTERNAL_ERROR : i32 = - 32603 ;
// Custom
pub const NOT_AUTHENTICATED : i32 = - 32001 ;
pub const NOT_FOUND : i32 = - 32002 ;
pub const CONFLICT : i32 = - 32003 ;
}
Zero dependencies on I/O or async - Pure data types and serde
UUID v4 correlation - Every request auto-generates an ID for response matching
Exclusive result/error - Responses carry either result or error, never both
Sequence numbers - Events are ordered for resumption after reconnect
Wire-format stability - Method names use serde(rename) for stable JSON keys
cargo test -p one-for-all-protocol
50+ tests covering serialization round-trips, method name mapping, error construction, event formatting, and edge cases.