Skip to main content

Module claude_peer

Module claude_peer 

Source
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:

  1. 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.
  2. 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§

ClaudePeerDelivery
Successful hand-off of one message to a live session.
ClaudePeerEndpoint
Opaque addressing string published on a discovered descriptor.
ClaudePeerRefusalError
A refusal paired with the detail that names it.
ClaudePeerSession
One live Claude Code session: a registry record whose pid answered kill(pid, 0) during the read that produced this value.
CourierOutput
What a courier process produced.
CourierPlan
Everything one courier invocation needs.
ProcessCourierRunner
Real courier spawner.

Enums§

ClaudePeerEndpointError
Endpoint parse failure.
ClaudePeerRefusal
Why a message could not be delivered into a live session.
ClaudePeerStatus
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§

CourierRunner
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_id in the registry and deliver text into it.
read_registry
Read every LIVE session from a Claude registry directory.
registry_dir
Directory holding the live-session registry for the configured Claude home.