Skip to content

About

Drive tmux and Herdr workspaces, panes, and coding agents from one JSON CLI (Rust)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

multiplexer-driver

multiplexer-driver is a command-line tool that controls tmux, Herdr, cmux, tuios, and hc. It gives scripts and coding agents one set of commands for workspaces, panes, and the agents that run in them. Every result is JSON.

Install

Prebuilt binaries are fully static on Linux (musl) and exist for Linux and macOS on x86_64 and aarch64, and for Windows on x86_64. Install the latest release on Linux or macOS with:

curl --proto '=https' --tlsv1.2 -LsSf \
  https://github.com/photuris/multiplexer-driver/releases/latest/download/multiplexer-driver-installer.sh | sh

On Windows, run this in PowerShell:

powershell -ExecutionPolicy Bypass -c "irm https://github.com/photuris/multiplexer-driver/releases/latest/download/multiplexer-driver-installer.ps1 | iex"

The installer puts the binary in ~/.local/bin (%USERPROFILE%\.local\bin on Windows) and adds it to your PATH if needed. Pass --no-modify-path to leave your shell profile alone.

Or download an archive from the releases page and check it against sha256.sum.

To build from source (Rust 1.98 or later):

cargo install --git https://github.com/photuris/multiplexer-driver --locked

Releases

Tag a version (git tag v0.2.0 && git push origin v0.2.0) after you bump version in Cargo.toml. The dist workflow in .github/workflows/release.yml builds every target and publishes the release. A pull request builds the same artifacts without publishing them.

Quickstart

These commands use a tmux server that has the socket name md-demo.

export MULTIPLEXER_DRIVER_HARNESS=tmux MULTIPLEXER_DRIVER_SESSION=md-demo
tmux -L md-demo new-session -d -s demo -c /tmp
WS=$(multiplexer-driver workspace list | head -1 | jq -r .workspace_id)
H=$(multiplexer-driver pane spawn --name demo-1 --workspace "$WS" \
  --cwd /tmp -- bash | jq -r .handle)
multiplexer-driver pane prompt "$H" --text 'echo hello'
multiplexer-driver pane read "$H" --lines 5
multiplexer-driver pane kill "$H"

Commands

workspace list | create | close | tag
pane      list | spawn | split | read | prompt | rename | interrupt |
          kill | status | wait
agent     resume-args
notify
raw

Run multiplexer-driver <noun> --help for the flags, defaults, and one example of each command.

Global flags:

Flag Environment variable Meaning
--harness <tmux|herdr|cmux|tuios|hc> MULTIPLEXER_DRIVER_HARNESS Harness to drive. Required for workspace, pane, and raw.
--session <name> MULTIPLEXER_DRIVER_SESSION A Herdr session name, a tmux -L socket name, a cmux socket path, a tuios session name, or an hc session name (HC_SESSION).
--pretty Indent single-object output. Lists stay JSON Lines.
--log-level <level> RUST_LOG debug, info, warn (default), or error.

A flag overrides its environment variable.

Output contract

  • A single result is one JSON document followed by a newline. The document is compact unless you pass --pretty.
  • A list is JSON Lines: one record per line, with no wrapping array.
  • stdout holds data only. Diagnostics go to stderr.
  • Output is UTF-8 with no byte order mark and \n line endings.
  • Field names use snake_case. A nullable field is always present with the value null.
  • On failure, the last line on stderr is one JSON object: {"error":{"type":"not_found","message":"pane %9 not found"}}.

Exit codes

Code type Meaning
0 Success
1 unexpected Bug, unparseable harness output, anything else
2 usage Bad flags, missing argument, bad input file
3 harness_unavailable Binary not on PATH, server not running, session socket missing
4 not_found Target workspace or pane does not exist
5 unsupported Operation not available on this harness
6 start_failed Pane exists, command did not start (handle on stdout)
7 timeout pane wait reached its timeout
130 SIGINT. The shell reports 130. No record is printed.

Harness notes

tmux. A handle is a tmux pane ID such as %12. The tool stores labels and agent kinds in tmux user options that start with @md-. tmux does not know what an agent is doing. pane status and pane wait need --patterns to report a status. Without patterns, the status is unknown and the confidence is none.

Herdr. A handle is a Herdr pane ID such as w1:p2. Use --session to select a Herdr session. Herdr reports status natively, so the tool ignores --patterns.

cmux. A handle is a terminal surface UUID. pane spawn opens a workspace for each agent and rejects --workspace. Status is native when the agent has cmux's hooks: Claude Code through cmux's wrapper, other agents after cmux hooks setup <agent>. Otherwise pane status needs --patterns. pane read --ansi and workspace tag are unsupported. --session is the socket path. To drive cmux from outside a cmux terminal, set automation.socketControlMode to password in ~/.config/cmux/cmux.json. Inside a cmux terminal you do not need it.

tuios. A handle is a window UUID. --session is the tuios session name, passed as -s; unset, the driver uses TUIOS_SESSION inside a tuios pane, else tuios picks the most recent session. The daemon is the one XDG_RUNTIME_DIR selects, so a private daemon needs that variable (and XDG_STATE_HOME) set for the driver. A workspace is a tuios workspace (1 to 9). workspace create and workspace tag are unsupported, pane spawn rejects --workspace, and pane split works only on a session with an attached client and tiling on; otherwise it exits 5 with tuios's own message. Status is native from the pane's agent state. A pane with no reported state falls back to --patterns, else unknown. raw passes its arguments to tuios unchanged and does not add -s. The tuios driver is tested on Linux only.

hc. hc is the core of the Herdr desktop app (tested with 0.1.17). It is separate from the herdr TUI harness above. A handle is an hc terminal address such as t7. --session is the core's session name, passed as HC_SESSION. --name becomes the hc name when it is 1 to 32 characters of a-z, 0-9, -, _, or . that start with a letter or digit. The label always goes in the md.label label, and pane rename changes only that label, never the hc name. hc rejects some names that fit this rule (an id shape such as t7) with invalid_params. The driver then retries the spawn without --name. A workspace is a Herdr app space id, written as the herdr.space label. --workspace is optional. Status is native when the program reports it over OSC 7501. A program that reports nothing falls back to --patterns, else unknown. pane read --ansi, pane split, and every workspace command are unsupported, because the app owns the layout. pane kill kills the terminal, then removes it. pane spawn passes --outlive-parent, so the terminal outlives the caller. raw passes its arguments to hc unchanged and applies --session.

Windows

Windows supports Herdr and hc only. tmux does not run natively on Windows, so --harness tmux fails with harness_unavailable. pane run quotes non-agent commands for PowerShell panes. A pane that runs cmd.exe will not parse them. The quoting rejects an argument that is empty, contains a double quote, or ends with a backslash, because Windows PowerShell 5.1 mangles them. The hc driver passes argv to hc and does no PowerShell quoting. Run docs/windows-smoke.ps1 inside Herdr to check an install. cmux runs on macOS only, so --harness cmux fails with harness_unavailable on other systems.

PowerShell

multiplexer-driver --harness herdr pane list | % { $_ | ConvertFrom-Json }
if ($LASTEXITCODE -ne 0) { "failed with exit code $LASTEXITCODE" }

Raw access

Use raw for any harness command that has no subcommand here. The tool applies --session and prints the harness stdout unchanged. The exception is tuios: raw does not add -s, so a tuios verb runs on the session tuios picks unless you pass the verb's own -s <name>.

multiplexer-driver --harness herdr raw -- tab list --workspace w1

Development

Run these checks before each commit. All must pass.

cargo fmt --check
cargo clippy --all-targets --all-features --locked -- -D warnings
cargo test --locked

The tmux and Herdr integration tests use private servers only. They never touch your own tmux server or a Herdr session that they did not create. cmux has no private server, so its integration test runs in your running app, in workspaces that it creates and names md-test-…. It reads the workspace list first, fails if it cannot, and closes only workspaces that it created. It skips unless cmux ping answers. The tuios integration test starts its own daemon in a private directory (/tmp/tp.XXXXXX), never touches yours, and removes the directory. It needs script (util-linux) to attach a client for the split scenarios, and it skips when tuios is not installed. The hc integration test starts a private core in /tmp/hc.XXXXXX, never touches your own core, and removes the directory. It skips when hc is not installed.

License

MIT. See LICENSE.

About

Drive tmux and Herdr workspaces, panes, and coding agents from one JSON CLI (Rust)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages