Repository navigation
Switchboard: remote tmux sessions, pending input, confirmed send, usage, WSL hub - #1
Merged
Merged
Conversation
Design for the fork's additions, milestone by milestone: Linux workstation mode (dedicated hub user, Tailscale Funnel in WSL), remote tmux sessions over SSH through a forced-command dispatcher (the owner's own dev-machine sessions first, via localhost SSH; local transport as the weaker option), list_remote_sessions, remote_status, pending_input, remote_send with two-step confirmation and audit, notification watcher, usage and billing. Includes config schema, module layout, SSH and tmux command templates, spoken result shapes, threat model, hermetic test strategy with fake ssh and fake tmux, and recommendations for the brief's open questions. DESIGN.md links to it; agents/ is ignored for agent scratch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adversarial security and voice-UX review of docs/SWITCHBOARD.md: refuse Claude Code input shortcuts (! bash mode, # memory, unlisted slash commands), recheck for a permission dialog right before Enter, bind confirmations to the Claude Code session id, add a minimum confirm delay and screen-echo / risky-question risk, quote screen text in every result, report unknown send outcomes as unknown, gate usage behind allowUsage and --allow-usage, stop sending claudeHome over SSH, run the summariser without session persistence, keyed audit hash, separate watch.includeQuestion, per-tool deadlines and caches. Adds a Review notes section and the list of owner-only live checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read-only remote tools for Claude Code sessions in tmux on the owner's machines, as designed in docs/SWITCHBOARD.md (milestone M1): - remote config section (machines, ssh, captureLines, summary) with field and cross-field validation and startup warnings; the dev machine over localhost SSH first in config.example.json, and a local transport for same-user setups. - switchboard-remote, the stdlib-only Python 3.8+ dispatcher (verbs version, list, capture): policy only from the forced command's real argv (or a policy file for explicit paths, or the hub for local), request tokens validated, tmux from argv with a fixed environment, allow-list applied before output, registry joined by the tmux field or the process tree. deploy/remote/switchboard-remote is a byte-identical copy. - SSH transport: argv only, -F /dev/null, batch mode, dedicated key, no agent or forwarding, pinned host key, environment from scratch, capped output, process-group kill, fixed error codes. Local transport runs the bundled dispatcher with --policy-from-hub. - inventory with a 15 s list cache, spoken machine and target resolution, ANSI stripping and secret redaction, a claude -p summariser (fixed prompt, no tools or MCP servers, no task settings, --no-session-persistence, heuristic fallback, 60 s cache, token counts to stateDir/usage/summaries.jsonl), tool deadline of syncWaitSeconds - 3 s, and a remote task kind (TaskManager.start_job, claim_slot) for summaries that take longer. - CLI remote-check and remote-dispatcher; server instructions route "what is my session on dev doing" to remote_status. - Tests: fake ssh (checks every hardening option) running the real dispatcher on a fake tmux, fake claude for the summariser, and an optional live test on an isolated tmux -L sb-test-* server. No new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remote job pushes never carry the result (the spoken status holds screen text), also with notify.includeResult: they read "Task N (status of fpga on dev) finished." NotifyTask gets a label. - Tests for the hub-side allow-list with a dispatcher that allows more (forced --sessions '*'): list never names the extra session and remote_status answers it like a nonexistent one. - Inventory.capture checks the captured pane's session against the hub's allow-list; a pane that moved there counts as gone. - Test that SWITCHBOARD_REMOTE_TEST_TMUX is ignored without SWITCHBOARD_REMOTE_TEST=1 (no real tmux reachable, marker file). - A crashed dispatcher (traceback, or non-zero exit without output) maps to "other" instead of dispatcher_missing. - The truncated pane list is spoken; the status label leaves out the window for the session's only Claude Code pane. - Live tmux test passes TMUX_TMPDIR on; docs mention plugins loaded by the summariser in same-user and local mode. - SWITCHBOARD.md, DESIGN.md, REFERENCE.md and README updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pending_input says which Claude Code sessions wait for the owner and what each asks: registry `waiting` (with the dialog or question from the screen, else waitingFor) and idle panes whose last 15 screen lines show a permission dialog or end with a question. Each machine lists and then captures in parallel (at most 6 captures, waiting panes first), within the tool deadline, no summariser. Without a machine it also reads the hub's own registry for sessions outside tmux inside projectRoots. Questions are cleaned, redacted and clipped; permission waits are never offered for approval by voice. The watcher (watch.intervalSeconds, off by default, needs notify.url) runs the same check, pushes once per new wait (screen-only waits after 2 ticks), again only after it was gone, keeps announced keys in stateDir/watch.json so restarts repeat nothing, pushes long finished turns and, optionally, unreachable machines. Pushes carry machine and tmux names only, the redacted question only with watch.includeQuestion, never pane text. notify.py gains send_text. No new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- pending: a permission dialog needs a "Do you want to ...?" line that starts its line, directly followed by a "1. Yes" option and a later "No" option; numbered options alone count only inside a box or directly above the footer and not under an assistant line. Prose questions are questions, finished messages wait for nobody. Dialog titles drop the assistant marker and the upward walk is bounded and stops at assistant lines. waitingFor values that read as status labels are not quoted. - watcher: a long turn ending in a screen-only wait still being confirmed holds its push back a tick and drops it when the wait pushes; failed ticks log only the exception type. - transport: a cancelled call kills its process group at once. - config: the machine name "local" is reserved for the hub's sessions. - docs: clock skew in turn durations, pushes not retried on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Typing into a remote Claude Code pane is two steps. remote_send checks the machine opt-in (allowSend), the pane, the text rules and permission prompts, classifies the risk and keeps an in-memory confirmation bound to the OAuth grant, pane id, pane pid and Claude Code session id; it returns a read-back and sends nothing. remote_send_confirm works once, not sooner than minConfirmSeconds and not after confirmSeconds, needs risky_ok for risky text, lists the machine again and calls the dispatcher's new send verb. Dispatcher 0.2.0: send <paneId> <panePid> <sessionId|none> with the text on stdin, only with --allow-send. It rechecks pane, pid, session, text rules (one shared function, also used by the hub), permission dialogs (registry and a deliberately broad screen heuristic), drafts in the input box and vim normal mode, then load-buffer from stdin, paste-buffer -p -d and, after checking for a dialog again, Enter. A permission answer (opt-in on both sides, a digit only) gets no Enter. The text never reaches an argv or a command string. Risk: built-in English patterns plus riskyPatterns, answers to risky questions, words echoed from screens a tool returned in the last 10 minutes (keyed shingle hashes, no text), permission answers and plain shells. Outcomes are sent, not_sent:<reason>, pasted_no_enter or unknown (connection lost after the request went out). Every confirm that reached the send step is a line in stateDir/audit.jsonl with an HMAC of the text (key in audit.key); the redacted text only with logPrompts. New CLI command: audit [--limit N]. Tests cover injection attempts (quotes, $(), backticks, ;, newlines, tmux key names, option-looking text, 8 KB texts), replay, expiry, client binding (also through HTTP and OAuth), early confirms, the race guard, unknown outcomes and audit content. The optional live tmux test checks real paste behaviour on an isolated -L sb-test server with a bracketed-paste recorder. No new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dispatcher decided on its own, from the screen at send time, whether a
send was a permission answer. A plain "1" read back as a message could
approve a dialog that opened before confirm (no risky_ok, audited as
permissionAnswer false), an answer read back for one dialog could land in
another that replaced it, and an answer whose dialog closed was typed as a
prompt with Enter. The hub also classified with the narrower screen_ask
heuristic than the dispatcher's shows_dialog.
- send now carries the confirmed mode: `message`, or `answer <dialogHash>`
(shell-neutral tokens). The dispatcher refuses a message while a dialog
shows (permission_prompt) and an answer when no dialog or another one
shows (dialog_changed, spoken). Dispatcher 0.3.0; older ones answer
bad_request ("too old for sending").
- dispatcher.dialog_hash identifies the dialog block; the hub captures the
same 40 lines and runs shows_dialog and dialog_hash itself, so its
prepare-time check is at least as broad as the dispatcher's.
- The race guard's second check also compares the Claude Code sessionId.
- The yes phrase names a question:<code> reason's rule.
- maxPending counts per OAuth client; one client never drops or names
another client's confirmation.
- Questions quoted by pending_input (also local registry sessions) feed
ScreenEcho; the echo false positive on re-preparing a sent message is
documented.
Tests cover (a), (b), (c), the broad-heuristic screen, the mode
validation, dialog_hash, the session recheck, per-client confirmations,
the yes phrase and local-session echo. SWITCHBOARD.md, DESIGN.md and
REFERENCE.md updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hours and token cost per Claude Code session, for billing. - Dispatcher 0.4.0 verb `usage <since> <maxMegabytes>`, only with --allow-usage (else not_allowed): reads <claudeHome>/projects/*/<uuid>.jsonl (top level, no symlinks, O_NOFOLLOW, lines up to 1 MB, files up to maxMegabytes, else announced as skipped), skips files the hub already knows (id, size, mtime on stdin) and streams JSON lines: file headers, text-free records (time, kind, model, message and request id, five token counts) and a done line with the gone ids. No text or path leaves the machine. - usage/: strict reading of those lines, per-machine caches in stateDir/usage (0600, 400-day retention), the hub's own Claude Code home read with the dispatcher's parser, summariser runs as project "switchboard", active intervals with the idle gap (at least one minute each), union or sum overlap per project, amount at the hourly rate (default 40 EUR), tokens by type deduplicated per machine, API-equivalent cost from usage.prices or a built-in table of published prices dated 2026-11-03; unpriced models are reported, never guessed. - Tool usage_report (spoken, answers at once from fresh caches, else refreshes until the deadline and continues as a remote task) and `voice-coding-mcp usage` with a table or CSV (formula guard), by project, session or day, --cached, exit 1 when a machine failed. - Config section `usage`; docs (SWITCHBOARD.md, DESIGN.md, REFERENCE.md), config.example.json and the tool list snapshot updated. No new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…up guide - deploy/linux/sb-linux: on, off and status with Tailscale Funnel, modelled on vcm-mac. Layouts: service (dedicated switchboard user under systemd, publicUrl set by the hub user's own CLI) and user (same-user, no sudo). util-linux flock -o for the on/off lock and the pid-file probe; a unit that does not answer /healthz is stopped again; operator hint. - deploy/linux/switchboard.service (hardened, ProtectHome=tmpfs, token in a root-owned env file) and config.switchboard.example.json. - CLI set-public-url: checks the whole config with the new value and rewrites it atomically (mode 600, key order kept). - docs/SETUP-WSL.md: owner guide (user, keys, dev over localhost SSH, other machines, config, Tailscale, unit, pair, voice phrases, turning off, own extensions, same-user mode, extended compromise steps, troubleshooting). - README Switchboard section and third mode; DESIGN, REFERENCE, SWITCHBOARD and DEPLOY updated; CI shellchecks sb-linux. - Tests: sb-linux end to end against fake tailscale, sudo and systemctl with a real server; deploy files consistency; set-public-url; upstream session tools against Linux-shaped registry entries (/run/user and /tmp/cc-socks- <uid> sockets, tmux field, waiting); optional live smoke of the remote tools over the local transport on an isolated tmux -L server. The existing live dispatcher test no longer starts an interactive shell (it raced the shell's login banner). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s copy
SETUP-WSL.md installed the dispatcher (runs as the owner and as every
remote machine user), sb-linux (runs as the owner, calls sudo) and the
systemd unit (read by root) from the hub user's writable checkout, so a
compromised hub user could become the owner, every remote user and root.
- Guide: a new "Your own copy" step: a clone in the owner's home, checked
out detached at a verified commit, never built or run. Steps 5.2, 6.1
and 9 install only from it, read each file before installing (with what
to look for in the 1132-line dispatcher and a sha256sum to compare),
and updates repeat this. The compromise steps now compare the installed
owner and root files with that copy, wipe the hub's checkout and venv
(or remove the user) and re-clone at the verified commit before anything
is reinstalled, and never reinstall from the hub's tree.
- sb-linux: in service mode the hub CLI's stdout and stderr pass through
a control-character filter (exit code kept); SB_LOCKED=1 from the
caller's environment no longer skips the on/off lock (the inner run
checks that its parent is flock and the lock is held).
- SWITCHBOARD.md ("Trusted source for owner and root files"), DESIGN.md
and REFERENCE.md updated; REFERENCE notes that set-public-url rewrites
the file as 2-space indented JSON.
- Tests: the guide never installs owner or root files from /home/switchboard,
every privileged install is from the owner's copy and read first, the
stated file sizes match, the compromise steps wipe before reinstalling;
sb-linux strips escapes on both streams, keeps the exit code, rejects a
forged lock marker, and the user-mode `uv run` default and its pair hint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…JSON
The risk classifier now also searches the NFKC form of a send's text and
of the question it answers, so fullwidth letters ("git push" typed as
fullwidth) no longer slip past the English patterns or riskyPatterns.
Look-alike letters of other scripts are still not caught (documented).
The usage parser's malformed-line test gains a deeply nested JSON line
(RecursionError path).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the Switchboard brief on top of voice-coding-mcp: list_remote_sessions, remote_status, pending_input, remote_send + remote_send_confirm (two-step, risk gating, audit), usage_report + usage CLI, notification watcher, the remote dispatcher (forced-command SSH), and the Linux/WSL hub (deploy/linux/sb-linux, systemd unit, docs/SETUP-WSL.md). Design and threat model: docs/SWITCHBOARD.md. Every milestone was independently reviewed; final gate: 1209 passed, 4 skipped; ruff and mypy --strict clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_011moV3EPNNknRWZQ686AChh