Expand description
Live Claude Code peer sessions: registry discovery and message delivery.
Claude Code is the one supported harness whose running interactive
sessions are addressable. Each live process registers
~/.claude/sessions/<pid>.json and binds the Unix socket named in it. The
catalog (crate::catalog) is deliberately about persisted state only, so
nothing there may claim liveness; this module is the separate, explicitly
process-checking half, and its output reaches clients as the
live_endpoint / live_status enrichment on a discovered descriptor.
Two rules earn their place here:
- A registry file is not a live session. These files survive a crash,
so every read re-checks the recorded pid with
kill(pid, 0)and drops the record when the process is gone. - Delivery goes through the COURIER, never the socket. The socket path
is documented, but its wire frame is not, and a foreign process
authenticating to it is not a supported case. Supercode therefore
delivers by spawning a one-shot headless Claude (
claude -p) restricted to the two documented cross-session tools and telling it to relay the text verbatim. If Anthropic ever documents the frame, writing it directly becomes the obvious faster transport and this module is where that would land.
Structs§
- Claude
Peer Delivery - Successful hand-off of one message to a live session.
- Claude
Peer Endpoint - Opaque addressing string published on a discovered descriptor.
- Claude
Peer Refusal Error - A refusal paired with the detail that names it.
- Claude
Peer Session - One live Claude Code session: a registry record whose pid answered
kill(pid, 0)during the read that produced this value. - Claude
Peer Settings - The user-settings portion Supercode can inspect without pretending to know a target process’s complete managed/project/CLI precedence stack.
- Courier
Output - What a courier process produced.
- Courier
Plan - Everything one courier invocation needs.
- Process
Courier Runner - Real courier spawner.
Enums§
- Claude
Cross Session Inbound - User-level policy Claude Code applies to messages from other sessions.
- Claude
Peer Endpoint Error - Endpoint parse failure.
- Claude
Peer Refusal - Why a message could not be delivered into a live session.
- Claude
Peer Settings Error - Failure to read or safely update Claude Code’s user settings.
- Claude
Peer Status - Activity a live Claude Code session reports for itself.
Constants§
- CLAUDE_
PEER_ ENDPOINT_ PREFIX - Scheme prefix of the opaque endpoint published for a live Claude peer.
- COURIER_
MODEL - Model the courier runs on. The courier only reads a listing and relays one string, so it takes the cheapest class available.
- COURIER_
TIMEOUT - Wall-clock ceiling for one courier invocation.
Traits§
- Courier
Runner - Spawner seam for the courier process.
Functions§
- courier_
command - Exact program and arguments spawned for one delivery.
- courier_
prompt - Instruction given to the courier. The text is fenced rather than interpolated into prose so a message that itself looks like an instruction cannot be mistaken for one.
- message_
claude_ peer - Resolve
session_idin the registry and delivertextinto it. - read_
claude_ peer_ settings - Inspect only the user-level inbound setting. The report deliberately does not claim to be Claude’s effective value because managed, project, and command-line settings can have higher precedence in a particular target.
- read_
registry - Read every LIVE session from a Claude registry directory.
- registry_
dir - Directory holding the live-session registry for the configured Claude home.
- update_
claude_ peer_ settings - Set or reset Claude Code’s user-level inbound policy.
expected_revisionprevents an explicit UI action from overwriting settings inspected before another process changed the file. - user_
settings_ path - Claude Code’s user settings file for the configured Claude home.
- write_
claude_ peer_ settings - Explicitly update Claude Code’s user-level inbound policy while preserving every unrelated setting. The write is atomic, refuses symlinks, and aborts when it observes an edit between its initial read and commit.