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.
ClaudePeerSettings
The user-settings portion Supercode can inspect without pretending to know a target process’s complete managed/project/CLI precedence stack.
CourierOutput
What a courier process produced.
CourierPlan
Everything one courier invocation needs.
ProcessCourierRunner
Real courier spawner.

Enums§

ClaudeCrossSessionInbound
User-level policy Claude Code applies to messages from other sessions.
ClaudePeerEndpointError
Endpoint parse failure.
ClaudePeerRefusal
Why a message could not be delivered into a live session.
ClaudePeerSettingsError
Failure to read or safely update Claude Code’s user settings.
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_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_revision prevents 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.