CommandRelay is a production-oriented gateway for remote terminal control of long-running coding sessions.
CommandRelay is oriented around an SSH-first operating model:
- Run the gateway on the machine that owns the terminal runtime.
- Keep runtime state in
tmuxso sessions survive client disconnects. - Reach the gateway from remote clients over an SSH transport path (for example, tunnel + WebSocket) while CommandRelay enforces terminal control policy.
ghostty is an optional local terminal UI. It is not the control backend for remote lane ownership, replay, or policy enforcement.
Web and native clients use the same v1 envelope and core flow:
list_sessionsattach(paneId, lastSeq)outputstream with orderedstreamSeqreplay behavior- guarded input:
enable_input->input->disable_input
Safety controls:
- read-only by default
- explicit input enable per client
- global input kill switch
- pane writer-lane ownership arbitration
- message/input rate limits and max input bytes
- audit logging for auth/input/policy events
Remote Web / Native Client
|
| SSH transport path + WS (/ws)
v
+----------------------------------------+
| CommandRelay Gateway (Node/TS) |
| - auth + policy |
| - replay + stream sequencing |
| - input lane arbitration |
+----------------------+-----------------+
|
v
+------------------+
| tmux runtime |
| panes: %1, %2... |
+------------------+
Local optional UI: Ghostty (operator convenience only)
+------------------------------------------------------+
| Session Tab: "backend-api" |
| +--------------------------+ +----------------------+ |
| | Pane %1 (read-only) | | Pane %2 (writer) | |
| | replay + live output | | input explicitly on | |
| +--------------------------+ +----------------------+ |
| Notifications: lane conflict, input enabled, |
| kill switch active, reconnect + replay complete |
+------------------------------------------------------+
The proxy packages (@commandrelay/*, @termina/proxy-*) are a parallel product track for outbound HTTP/proxy reuse.
They are not mandatory for the core terminal-control path (list/attach/replay/input) and should be treated as adjacent infrastructure, not a prerequisite for SSH + tmux operation.
npm install
npm run check
npm startOptional SSH startup wiring (remote profile orchestration contract):
export COMMANDRELAY_TRANSPORT_MODE=ssh
export COMMANDRELAY_SSH_PROFILE=primary
export COMMANDRELAY_SSH_TARGET="dev@relay-host"
export COMMANDRELAY_SSH_COMMAND=ssh
export COMMANDRELAY_SSH_PORT=22
export COMMANDRELAY_SSH_CONNECT_TIMEOUT_SECONDS=8
export COMMANDRELAY_SSH_STRICT_HOST_KEY_CHECKING=true
npm startCurrent runtime data path remains the WS server (/ws) plus tmux runtime control.
In ssh mode, the bridge runs tmux operations on the remote target over SSH after startup preflight passes.
SSH runtime execution is non-interactive (-T, BatchMode=yes); when strict host key checking is disabled, runtime uses UserKnownHostsFile=/dev/null to suppress known_hosts writes.
ssh mode is tmux-only: set COMMANDRELAY_RUNTIME_BACKENDS=tmux.
Default local endpoints (current runtime path):
GET http://127.0.0.1:8787/healthhttp://127.0.0.1:8787/app/(when static app hosting is enabled)ws://127.0.0.1:8787/ws
| Variable | Purpose |
|---|---|
COMMANDRELAY_AUTH_TOKEN |
Token auth for non-loopback binds |
COMMANDRELAY_RUNTIME_BACKENDS |
Runtime backends (tmux default, optional tmux,cmux). Must be tmux when COMMANDRELAY_TRANSPORT_MODE=ssh. |
COMMANDRELAY_CMUX_COMMAND |
Optional cmux command/path override |
COMMANDRELAY_TRANSPORT_MODE |
Startup transport selector (ws default, ssh enables remote tmux execution over SSH) |
COMMANDRELAY_SSH_PROFILE |
SSH profile name (primary when unset). If set, must be non-empty and match [A-Za-z0-9._-]+. |
COMMANDRELAY_SSH_TARGET |
SSH target (required in ssh mode) in [user@]host format, where host is name or bracketed IPv6 ([2001:db8::1]). |
COMMANDRELAY_SSH_COMMAND |
SSH executable/command override used for preflight and runtime SSH execution (ssh default). |
COMMANDRELAY_SSH_PORT |
SSH target port override (22 default) |
COMMANDRELAY_SSH_CONNECT_TIMEOUT_SECONDS |
SSH connect/runtime command timeout in seconds (8 default, allowed 1..60). |
COMMANDRELAY_SSH_STRICT_HOST_KEY_CHECKING |
SSH strict host key checking policy (true default) |
COMMANDRELAY_INPUT_KILL_SWITCH |
Global input disable switch |
COMMANDRELAY_ALLOW_INPUT_OVERRIDE |
Allow/deny forced lane takeover |
COMMANDRELAY_MAX_INPUT_BYTES |
Max input payload size |
COMMANDRELAY_MAX_MSG_PER_MIN |
Per-client message rate limit |
COMMANDRELAY_MAX_INPUT_PER_MIN |
Per-client input rate limit |
COMMANDRELAY_STRICT_PROTOCOL_PARSING |
Strict v1 envelope parsing |
COMMANDRELAY_AUDIT_LOG |
Audit JSONL path |
docs/protocol-v1.md- normative wire contractdocs/security.md- controls and threat notesdocs/operations.md- deployment and operator runbookdocs/roadmap-native.md- web/native parity roadmapdocs/proxy-ecosystem-roadmap.md- proxy package track
MIT.