|
| 1 | +# tmux-bridge: agent-to-agent comms in deva containers |
| 2 | + |
| 3 | +deva ships two tmux bridge layers. They compose. |
| 4 | + |
| 5 | + Layer 1 deva-bridge-tmux kernel boundary |
| 6 | + (scripts/deva-bridge-tmux) container tmux client -> host tmux server |
| 7 | + socat TCP tunnel via host.docker.internal:41555 |
| 8 | + |
| 9 | + Layer 2 tmux-bridge semantic CLI |
| 10 | + (scripts/tmux-bridge) read/type/keys/label/envelope |
| 11 | + vendored from smux for agents to drive each other's panes |
| 12 | + |
| 13 | +Layer 1 is the plumbing that lets the container see host tmux at all. Layer 2 |
| 14 | +is what agents actually call. |
| 15 | + |
| 16 | +## Security |
| 17 | + |
| 18 | +Both layers are privileged host bridges. If you run them, the container can |
| 19 | +execute arbitrary commands on the host tmux server (send-keys, run-shell, |
| 20 | +scrollback). This is deliberate for trusted dev workflows. Do not enable on |
| 21 | +untrusted code. |
| 22 | + |
| 23 | +## Quick start |
| 24 | + |
| 25 | +Host (macOS): |
| 26 | + |
| 27 | + deva-bridge-tmux-host # expose host tmux over TCP:41555 |
| 28 | + |
| 29 | +Container (inside a deva agent): |
| 30 | + |
| 31 | + deva-bridge-tmux # start socat; creates /tmp/host-tmux.sock |
| 32 | + tmux -S /tmp/host-tmux.sock attach # optional: attach to host session |
| 33 | + |
| 34 | +From another pane (or the same container, any agent CLI that can shell out): |
| 35 | + |
| 36 | + tmux-bridge list # see all panes |
| 37 | + tmux-bridge name %1 planner # label a pane |
| 38 | + tmux-bridge read planner 50 # read last 50 lines |
| 39 | + tmux-bridge message planner "found 3 issues in auth.py" |
| 40 | + tmux-bridge type planner "rerun tests" |
| 41 | + tmux-bridge keys planner Enter |
| 42 | + |
| 43 | +## Socket detection |
| 44 | + |
| 45 | +`tmux-bridge` auto-detects the tmux server socket in this order: |
| 46 | + |
| 47 | +1. `$TMUX_BRIDGE_SOCKET` env var (explicit override) |
| 48 | +2. `$TMUX` (set automatically when you are inside a tmux pane) |
| 49 | +3. Scan `/tmp/tmux-<uid>/*` for a server that owns `$TMUX_PANE` |
| 50 | +4. Default tmux server |
| 51 | + |
| 52 | +For deva containers talking to host tmux via the layer-1 bridge, attach to |
| 53 | +tmux first (step 2 fires) or set the override: |
| 54 | + |
| 55 | + export TMUX_BRIDGE_SOCKET=/tmp/host-tmux.sock |
| 56 | + |
| 57 | +## Read-before-act guard |
| 58 | + |
| 59 | +`tmux-bridge` enforces that agents `read` a pane before they can `type`, |
| 60 | +`message`, or `keys` into it. This is the main safety net against "agent |
| 61 | +blindly hallucinates into the wrong pane." |
| 62 | + |
| 63 | +The guard is a sentinel at `/tmp/tmux-bridge-read-<pane_id>`. Reading sets |
| 64 | +it; any write clears it. So the contract is: |
| 65 | + |
| 66 | +1. `tmux-bridge read <target>` — look at the pane's current state |
| 67 | +2. `tmux-bridge type <target> "..."` — act on what you saw |
| 68 | +3. To act again, read again. |
| 69 | + |
| 70 | +## Diagnostics |
| 71 | + |
| 72 | + tmux-bridge doctor |
| 73 | + |
| 74 | +Prints env vars, detected socket, visible panes, and a pass/fail summary. |
| 75 | +Run this first when things go wrong. |
| 76 | + |
| 77 | +## Provenance |
| 78 | + |
| 79 | +`scripts/tmux-bridge` is vendored byte-for-byte from upstream smux |
| 80 | +(github.com/ShawnPana/smux). See `scripts/tmux-bridge.VENDORED` for the |
| 81 | +pinned commit and SHA256. License is MIT, reproduced in |
| 82 | +`scripts/THIRD_PARTY_LICENSES/smux-LICENSE`. |
| 83 | + |
| 84 | +`scripts/deva-bridge-tmux` and `scripts/deva-bridge-tmux-host` are deva's |
| 85 | +own work (see `docs/devlog/20260108-deva-bridge-tmux.org`). |
0 commit comments