agent-ssh 0.3.6

Arrange agent terminal layouts and reconnect through provider attachment plans
Documentation

agent-ssh

Arrange agent terminal layouts and reconnect through provider attachment plans. agent-ssh is the command. The repository is ignition-is-go/agent-ssh.

See the experimental attachment contract for version 2 terminal layouts, provider resolution, and machine-readable restore plans.

Save the current Windows Terminal layout

agent-ssh save
agent-ssh load --plan
agent-ssh load

agent-ssh save "$HOME\agents-before-restart.json"
agent-ssh load "$HOME\agents-before-restart.json" --plan
agent-ssh load "$HOME\agents-before-restart.json"

Without PATH, save writes to %LOCALAPPDATA%/agent-ssh/snapshots on Windows. load selects the newest managed snapshot there. On Unix the directory is $XDG_STATE_HOME/agent-ssh/snapshots, or $HOME/.local/state/agent-ssh/snapshots when XDG_STATE_HOME is empty or relative. Managed names use a sortable UTC epoch timestamp taken after capture: snapshot-<20-digit-seconds>-<9-digit-nanoseconds>.json. Newest means the greatest filename timestamp, not file modification or completion time. Unrelated files, directories and symbolic links are ignored. A corrupt or incomplete newest snapshot blocks loading; it never silently selects an older one. An explicit save PATH is a named export and does not become the default load target. There is no mutable latest pointer. Provide PATH to load a different recovery file.

save discovers the current tab membership, pane geometry, local Codex conversation IDs and remote tmux attachments. It never overwrites an existing file. Restore opens a fresh window with those tab boundaries and normalized split proportions. It does not rearrange existing interfaces.

Capture briefly selects tabs and changes console-title metadata. Keep keyboard and mouse idle until capture completes. Our generated SSH profiles must accept application titles; see profile configuration. Custom profiles that suppress titles cannot be captured through this identity channel. A Terminal process with multiple windows is currently unsupported.

Version 3 snapshots retain every observed pane. restorable: false and an unavailable target identify missing recovery support. In that case save writes the observations, reports the affected panes and exits unsuccessfully. File existence alone does not mean recovery is ready. Restore blocks before opening any terminal if any target is unavailable. --plan reports the gaps without launching agents.

Local Codex recovery requires an explicit resume UUID and working directory in the live command arguments. Restore refuses to resume an already-running local conversation or when another local Codex process has an unknown binding. Remote recovery attaches an exact existing tmux session name on its captured socket. It follows that logical name if someone deliberately recreates it; it does not reserve the original process incarnation. Agents launched directly under older SSH shells without a tmux attachment are reported unavailable. Save does not migrate or adopt them.

Bare, single-process PowerShell panes become explicit fresh-shell targets. Their memory and current directory cannot be captured. They reopen in your home directory, or the directory supplied with save --shell-directory PATH. Other running shell commands are unsupported.

Use save --window HWND to select an observed Terminal window, and --remote-program PATH when target-side agent-ssh is not on PATH. Remote hosts need the version that provides tmux clients --json. Snapshot files contain trusted executable paths and recovery arguments; restore only files you trust. A PC restart preserves remote tmux runtimes while they remain running on the remote host. Local Codex resumes stored conversation history rather than process memory.

Attach to an existing tmux session

Unix-side tmux inspection and attachment use the independent tmux-session package:

agent-ssh tmux list --json
agent-ssh tmux attach pulse-agent
agent-ssh tmux --socket /run/user/1000/tmux.sock list --json

On Windows, select an SSH host with Unix agent-ssh 0.3.5 installed:

agent-ssh tmux list --on pulse-admin --json
agent-ssh tmux attach pulse-agent --on pulse-admin
agent-ssh tmux list --on pulse-admin --remote-program /root/.cargo/bin/agent-ssh --json

--socket selects a path on the execution host. Session names are literal names, not tmux selectors or prefix searches. Attachment fails if the exact name is absent and never creates a session or agent. The SSH path executes the installed target-side command without a raw-tmux fallback.

The upstream library supplies session queries and exact-name lookup. Its published API captures command output and has no inherited-terminal attachment operation. After a successful lookup, this application hands the terminal to native tmux attach-session on the captured socket. Cancelling that attachment does not terminate the tmux session. Availability can change between lookup and handoff; this is a logical named attachment, not a lease on a process incarnation.

The tmux subcommand does not accept Windows Terminal layout flags. In host lists, use -- before an SSH alias named tmux, save, or load.

Legacy layouts and recovery

# Save selected SSH hosts without opening terminals.
agent-ssh --group production --save-workspace production.json --panes-per-tab 4

# Restore saved attach/resume commands in four-pane grids.
agent-ssh load production.json --window agents
agent-ssh load production.json --panes-per-tab 4 --dry-run

# Regroup 16 EXISTING single-pane tabs, beginning at tab zero.
agent-ssh --regroup 16 --window agents

--regroup moves existing panes without starting or stopping their processes. Run it only against the specified number of single-pane tabs; it is not idempotent. --first-tab selects a zero-based starting tab. Terminal chooses split direction when moving existing panes; restoring a workspace explicitly builds balanced grids. Existing tabs outside the selected range remain in place.

load opens new terminal interfaces. Remote attach commands should reconnect to an existing tmux session; local Codex commands should use an explicit thread ID. Repeating restore can create duplicate interfaces, especially for local agents. A saved workspace retains commands and layout, not process memory or in-flight command state. Restoring does not stop an already-open interface or take over a conversation lock.

Workspace JSON uses version 1, an ordered pane list, and a per-tab pane count:

{
  "version": 1,
  "panes_per_tab": 4,
  "panes": [
    {
      "title": "remote agent",
      "command": ["ssh.exe", "-t", "pulse-admin", "/root/.local/share/agent-sessions/open-agent.sh"]
    },
    {
      "title": "local agent",
      "cwd": "C:\\Work Projects",
      "command": ["codex.cmd", "resume", "EXPLICIT-THREAD-ID"]
    }
  ]
}

Each pane may specify a Windows Terminal profile. Commands are argument arrays, not shell strings. Use only trusted workspace files: restoring executes their commands. Semicolons and line breaks in pane fields are rejected because Windows Terminal interprets semicolons as action separators. Saving to an existing filename is refused. --save-workspace saves selected SSH destinations, not automatic discovery of active agent IDs; provide explicit resume/attach commands for agent recovery.

See Marshal integration for the boundary with the work-in-progress LaunchBackend API.

agent-ssh opens SSH aliases from ~/.ssh/config as balanced pane grids or tabs in Windows Terminal. Groups and colors are declared with comments:

# @group production #E57000
Host app-one
    HostName app-one.example.com

Host app-two
    HostName app-two.example.com
    User deploy

Install

cargo install agent-ssh --version 0.3.0 --locked
agent-ssh --sync

To install from a source checkout, run cargo install --path . --force.

Restart Windows Terminal after the initial sync.

Usage

agent-ssh --group production
agent-ssh --group production --new-window
agent-ssh --group development --tabs
agent-ssh --group production --command uptime
agent-ssh --list
agent-ssh --sync
agent-ssh --group production --dry-run

Inside a grid, Windows Terminal's Alt+Shift+B toggles broadcast input, Alt+Shift+Z zooms the focused pane, and Alt+Arrow moves focus.

Releases

Push a semantic-version tag matching Cargo.toml to create a GitHub Release:

git tag v0.3.0
git push origin v0.3.0

The release workflow verifies the version, runs the full quality suite, builds the Windows executable, and publishes a ZIP plus a SHA-256 checksum.

When releasing a new shared protocol version, publish it before the terminal crate. Skip the first command if that protocol version is already published:

cargo publish -p agent-attachment-protocol
cargo publish -p agent-ssh

Inspect provider-backed layouts

Version 2 layouts retain references and resolve their attachment plans on every restore. Use the provider on the same host as the terminal consumer. A remote producer's local executable path is not a local Windows executable.

agent-ssh load my-layout.json --window agents --plan
agent-ssh load my-layout.json --window agents
agent-ssh load my-layout.json --window agents --allow-partial

Default restore blocks if a provider cannot attach every referenced agent. Partial restore is explicit. Neither mode starts replacement agents or replays prompts. See the ownership decision and acceptance record.

To convert a version 1 recovery file, use the migration tool. It compares both files through the actual CLI before writing and refuses to overwrite an existing destination.

python scripts/migrate_layout.py old-layout.json terminal-layout.json --binary agent-ssh

Pulse Agents 1.82.2 provides the managed attachment-plan and attach commands. Install that provider before using its provider-backed layouts. Existing configured SSH and local recovery commands remain supported.