2 KiB
2 KiB
AGENTS.md — sessions
A remote session manager: a web page on prod that starts Claude Code sessions on the dev box through one locked-down SSH key. Read the README's "Security model" before changing anything that touches the SSH boundary.
Layout
dev/runs on the dev box:sessions_ctl.py(installed as~/.local/bin/sessions-ctl), systemd user units,install.sh.web/runs on prod in a rootless Podman container:app.py,Containerfile, Quadlet unitsessions-web.container.
Stack and conventions
- Python ≥ 3.11, standard library only on both sides. No pip install, so there's no supply chain to audit. Keep it that way unless there's a strong reason.
- The web page has no JavaScript. Plain forms, POST, then a redirect.
sessions-ctlalways prints exactly one JSON object; exit 0/1/2.- The dev port for local work on the web app is 8470, bound to 127.0.0.1.
Preview via
ssh -p 14922 -L 8470:localhost:8470 <dev box>.
Invariants — do not break
- Nothing received over SSH reaches a shell or Claude. No "initial prompt"
feature, no free-text arguments. New remote verbs need validation and a
test in
dev/tests/test_sessions_ctl.py. - Local-only verbs (
delete,refresh-access,_launch) stay out ofREMOTE_VERBS. refresh-accessnever writes an emptyfrom=, and never touches lines other than the one ending insessions-manager.- The session unit keeps
DBUS_SESSION_BUS_ADDRESSpointed at nothing. Otherwise tmux moves claude into its owntmux-spawn-*.scopeand it escapesMemoryMaxand clean stops (checked 2026-09-30 with tmux 3.6). - The container publishes to
127.0.0.1only.
Test
python3 -m unittest discover -s dev/tests
python3 -m unittest discover -s web/tests
To test end to end on the dev box, add a throwaway key with
from="127.0.0.1",restrict,command=".../sessions-ctl --remote" … sessions-selftest,
run the container with --network host and SESSIONS_DEV_HOST=127.0.0.1,
then remove the key line again.