Skip to main content

Module claude_relay

Module claude_relay 

Source
Expand description

Claude relays: the degraded tier’s door into a Claude Code session that supercode does not control.

A Claude session answers a message by copying its from into SendMessage. For that answer to come back, the message must come FROM a live Claude peer. A relay is that peer: a Claude Code runtime that supercode hosts like any other (runtimes.start in the machine daemon’s harness serve, registered in the live-runtime registry), named sc-<name>-on-<machine>, sending on one session’s behalf. Nothing here runs its own process supervisor or writes Claude’s private socket frame.

Three rules earn their place here:

  1. No model runs. A relay’s API is supercode’s own deterministic endpoint (crate::relay_endpoint), which answers a send turn with a SendMessage of the queued pair. Every send is queued first, and a PreToolUse hook (supercode message gate) still denies any tool call but a SendMessage of exactly that pair.
  2. Receipts come from Claude, through hooks. A PostToolUse hook writes Claude’s own SendMessage result beside the queue; a denied call and a turn that ends without sending write theirs too. The sender waits on that file, not on the model’s words.
  3. Inbound mail never reaches the model. Claude hands every inbound peer envelope and idle or delivery notice to the relay’s UserPromptSubmit hook byte-exact; the hook files it in the represented session’s mailbox and blocks the prompt, so no model turn runs for it (measured: duration_api_ms: 0).

A relay’s busy/idle is its own; its name carries the sc- prefix and every turn ends with RELAY_STATUS_LINE.

Structs§

NativeEnvelope
A native peer envelope as Claude delivered it to a relay.
QueuedSend
The one send a relay is allowed to make next.
RelayPaths
Files of one relay, all in its own directory (also its working directory, which holds no project settings).
RelaySpec
Everything needed to start one relay.

Enums§

RelayEvent
One inbound prompt, as Claude handed it to a relay’s hook.
RelayReceipt
Outcome of one relayed send, as the sender reads it.

Constants§

RELAY_MODEL
Model name a relay’s requests carry. The relay endpoint answers them without any model.
RELAY_NAME_PREFIX
Prefix marking a registry name as a relay rather than a session.
RELAY_STATUS_LINE
Text every relay turn ends with. Claude quotes a session’s last line in its idle notices, so this is where the correction reaches the agent.
SEND_TIMEOUT
How long a send waits for Claude’s own receipt.

Functions§

ensure_machine_daemon
Start this OS user’s machine daemon when it is not answering. It hosts relays (in its harness serve) and the idle watcher.
file_inbound_prompt
File one inbound prompt in represented’s mailbox. last_sent maps a Claude session name to the newest message this relay sent it, for
gate_decision
Decide one PreToolUse hook call. None allows it; Some(reason) denies.
gate_denial
The hook’s JSON answer for a denial.
inbound_block
The UserPromptSubmit answer that keeps a prompt from the model.
is_inbound_prompt
Whether a prompt Claude handed the relay is inbound mail (a peer envelope or a notice) rather than its host’s own send turn.
machine_rpc
One harness.v1 call into this machine’s daemon (supercode teams rpc), starting the daemon when it is not running.
parse_inbound_text
Recognize an inbound peer envelope or notice in the text Claude handed a relay.
read_receipt
Read a receipt the relay’s hooks wrote: Claude’s own SendMessage result, a gate denial, or a turn that ended without sending.
relay_arguments
Arguments of the Claude Code runtime a relay runs as.
relay_environment
Environment of a relay: its API is the relay endpoint at endpoint, and its API key names its directory there. The key also keeps account connectors (MCP servers) out of the relay.
relay_name
Registry name of the relay that represents name on machine.
relay_settings
Settings document installing a relay’s hooks.
resolve_native_sender
The live Claude session behind a native uds: sender address.
send_through_relay
Send message to the Claude session named to, from sender through its relay: start the relay as a hosted runtime when it is not running, queue the send, hand it the send turn through the runtime’s own door, and wait for Claude’s receipt.
send_turn
The host turn asking a relay to make one send.
supercode_program
The supercode program that the relay hooks and the machine daemon run: this process when it is supercode (the CLI, supercode harness serve),