A small runtime that keeps coding-agent terminals alive, reads their screens and reports their state. Every lane docks in a shed and keeps running there, across restarts and machines.
Status: experimental, unreleased (0.0.0). The v0.1 commands below work; build and install from source with
scripts/install.sh. Built to be one runtime option for herdsman (runtime = "shed") next to herdr.
herdsman drives a fleet of coding agents. It needs only a few things from a terminal runtime:
- run a program in a terminal that keeps running when nobody watches;
- read the screen;
- send text and keys;
- wait until it stops working;
- list what runs;
- do the same on another machine over SSH.
herdr does all of this and much more (a full TUI, layouts, plugins). shed is the small, headless version, shaped around lanes:
- State is reported, not guessed. A program reports
working / blocked / done / error(and an optional note), through a CLI call, the socket or an OSC escape. shed stores and streams it. Screen-scraping is only a fallback. - Lanes are first-class. A terminal carries labels (
fleet,issue,role,round) and a worktree. List, wait and events filter by them. - No UI to keep in sync. herdsman's board is the UI;
shed watchis a read-only list and preview, and any terminal canattach. - One version everywhere. Client and server are the same binary. A mismatch is refused with a clear message instead of half-working (herdr's old-server/new-client gap).
- Process hygiene built in. Closing a terminal ends its whole process tree. Per-terminal memory and CPU are reported, so a forgotten dev server or language server is visible.
shed is the core runtime under the agents. Its job:
- terminals and ACP sessions, kept alive and reported on;
- machines over SSH,
execandfile.*; - host and process stats;
- the server as a user service, and its self-update;
- accounts and credentials, the token proxy, usage monitoring, and every provider fact as catalog data (#256, the accounts ADR).
The v0.1 commands:
| Command | What it does |
|---|---|
shed account add|ls|login|answer|status|rm|use |
The accounts shed keeps on this host: add <provider> <name> [--folder DIR] [--token-file FILE] makes one (or adopts a folder), login runs its login on a redacted screen (type the code), login --token its setup-token command, saving the token it prints for runs on other machines, login --remote signs in from any device (no browser on the host: it prints the sign-in link and asks for the code or callback address), answer <provider> <name> <answer> hands a running remote login its answer (docs/accounts/login.md), status reads it now, ls lists them (the preferred one marked) and rm signs one out and removes it (docs/accounts/store.md). use <provider> <name> makes a ready named account the one auto picks first and moves every live auto and default lane to it; use <provider> --clear drops the preference (docs/accounts/accounts.md). |
shed run --acp <agent>, shed agents, shed approve, shed cancel |
ACP agents as structured terminals; see below. |
shed attach <t> |
Take over the terminal interactively; Ctrl+\ detaches. |
shed events [--label k=v] [--since N] |
Stream starts, state changes, exits, kills and resource moves as JSON lines; --since replays those still kept (the last 4,096 besides agent text chunks); a client too far behind is dropped with a lagged line. |
shed exec [--on M] [--cwd D] [--timeout S] [-i] -- CMD… / shed file read|write [--on M] PATH |
Run a program without a terminal and get exactly the bytes it wrote to stdout and stderr and its exit code; nothing it started outlives it. -i feeds it stdin. file read prints a file, file write replaces it with stdin (temp file and rename, mode kept). A reply over 8 MiB is an error, never cut. |
shed flow report [--since 7d] |
Each flow's table as it runs beside today's code (#309): rows fired, facts never seen, never rows that fired, stuck reasons, and the shadow disagreements since --since by class; --on <machine> asks that machine, shed doctor shows the last 24 h's count. |
shed get <t> |
One terminal as JSON. |
shed install [--force] / shed uninstall / shed doctor |
Write that job's file and (re)start the server under it, so the running server is this binary (uninstall prints how to unload it); check the job, socket, log, and that the server runs this binary's build. |
shed kill <t> / shed rm <t> |
End the process tree; remove a finished terminal. |
shed ls [--label k=v] [--json] |
List terminals: name, labels, cwd, state, pid tree, RSS/CPU, age. |
shed --on <machine> … / shed machine add|ls|rm |
The same commands on another host over SSH (key login only). The server holds a link to each machine, so its terminals also show as <machine>/<name> in ls and events and take get, read, send, keys, kill, wait, approve and cancel, and --on <machine> run --acp starts an agent installed there; machine ls --json shows each link. |
shed machine stats [--on M] [--since T] |
Load per CPU, memory pressure, swap, free disk, uptime and terminals by state; one sample a minute kept 24 h. An unreachable machine answers offline (last seen) within 5 s. |
shed proxy keys|revoke |
The token proxy's per-run keys: keys lists them, newest first, with their terminal, account and state (never a key); revoke <id> stops one signing at once (docs/accounts/token-proxy.md). |
shed read <t> [--lines N] [--screen|--history] |
The current screen, or scrollback, as plain text. |
shed run [--name N] [--label k=v…] [--cwd D] [--keep] [--size RxC] [--mem-max SIZE] -- <cmd…> |
Start a terminal. --keep: a lost program is replaced by a shell. --size: rows by columns, default $SHED_SIZE of shed serve, else 50x200. --mem-max (200M, 4G; default $SHED_MEM_MAX of shed serve, else none): on Linux with a user systemd that has the memory controller the program gets its own scope with MemoryMax; elsewhere the sampler ends the largest process the agent started after two samples over, a guard against sustained use that a fast allocation can pass between samples. Either is a mem-limit event; shed doctor says which. |
shed script [--on M] (-f FILE | -) [--check] [--timeout S] [--role R] |
Run a program in shed's JavaScript subset on the server, so many dependent calls and a filter are one round trip (skill/script/SKILL.md). It prints the program's logs, then what it returned; an error prints its name, line and column and exits 1. --check only parses and compiles: nothing runs and no call is made. A call that acts goes through the guard in the server's [script] config, and is refused without one. |
shed secret set|ls|rm |
shed's own secrets on the main host (a VM provider's key): set <NAME> saves the value it reads from stdin, never from an argument; ls lists them by name with when each was saved, never a value; rm <NAME> removes one, and twice is once (docs/hosts/secrets.md). |
shed send <t> <text> [--no-paste] [--no-enter] [--draft-wait S] / shed keys <t> enter esc ctrl+c… |
Paste text then press enter (bracketed when the program asks for it), or press keys. Sends go in whole, one at a time, and wait while a person attached has an unsent line (60 s by default, then the send fails and writes nothing). |
shed serve |
The per-user server (launchd/systemd user job). Owns the PTYs, the state and the socket. |
shed state <t> working|blocked|done|error [--note TEXT] |
Report state (also via $SHED + OSC 7501-compatible escape). |
shed top [<t> [--full]] |
The terminals by memory use, largest first, an ACP agent's split into AGENT and WORK (what it started), then a totals line; with <t>, that terminal's processes over 50 MB by name (the command line with --full). |
shed wait <t> [--until working|idle|done|blocked] [--output RE] [--timeout S] |
Block until the state or output matches. |
shed watch [--label k=v] |
A live list of the terminals beside a read-only preview of the selected one; Enter attaches, Ctrl+\ comes back, / filters, q quits. |
Persistence: the server keeps PTYs alive while it runs. On server restart, kept terminals come back as shells in
their last cwd (never re-running a task). State and labels are saved to a small JSON file (atomic writes).
Each terminal keeps at most 5,000 lines and 8 MiB of scrollback (oldest whole lines go first) and appends its raw
output to a log beside the state file, kept under 16 MiB; after a restart, read and a kept terminal's new shell
start from only the last 8 MiB of that log.
The API is a Unix socket with JSON-RPC (documented schema). The CLI is a thin client. shed connect carries the
protocol over stdin/stdout for SSH.
shed is one of three repos. The other two own these jobs, and shed never does them:
- drover, the workflow driver: no workflow, issue, queue, lane, review, gate or merge logic, no worktree management, and no screens JSON or backend API for its screens.
- cooee, the bots and chat: no chat, bot or user-facing UI.
Also out of scope:
- No TUI layouts, tabs, splits, themes or plugins.
- No agent-brand detection. Programs report their state; a screen-text fallback is optional and per-harness.
- No Windows in v0.1.
- No host setup. A shed machine is only a place shed can run an agent: the link, processes, and their CPU and memory. shed installs no toolchain, manages no build cache (sccache, pnpm's store, cargo targets) and cleans no disk beyond its own state folder, where its pruning of exited terminals and ACP sessions stays. Host setup is the runners repo's, for build and CI machines; a lane's cache env is drover's.
- Rust, ≤ 6,700 non-test lines in
src/(CI-enforced, like herdsman). - Few dependencies: a PTY crate, a VT parser for the screen, serde/serde_json, clap. tokio for the server and the ACP bridge (decision 0004).
- Fast: every CLI call that doesn't wait is < 20 ms locally.
- Public repo: placeholders only in docs and tests, no setup-specific names.
Many agents speak the Agent Client Protocol (ACP): prompts, tool calls, approvals and the final reply as JSON-RPC messages instead of screen text (an idea from Codync). shed runs them as a second kind of terminal, through the same API:
| Command | What it does |
|---|---|
shed agents / shed agents add <id> / shed agents rm <id> |
The installed ACP agents. add installs the version the ACP registry lists now (its binary, npx or uvx entry), pinned; nothing upgrades it. |
shed run --acp <id> [--policy allow|deny|ask] [--resume S] [--cwd D] [--label k=v…] |
Start the agent's ACP adapter on stdio: initialize, session/new (no MCP servers), or with --resume session/load of session S (shed get's session.id). |
shed send <t> <text> |
session/prompt; the state is working until the turn ends, then done (note: the stop reason). |
shed approve <t> <option> |
Answer a permission request (state blocked); --policy answers them instead. |
shed cancel <t> / shed keys <t> esc |
session/cancel. |
shed model <t> <id> |
Switch the model (one of shed get's session.models) through the agent's model config option. |
shed read <t> |
The transcript as text: prompts, one line per tool call, final replies. |
shed events adds turn, text, tool_call, plan, mode, approval_request, approved, reply and session, and
shed wait --until done is exact. The PTY mode stays for agents without ACP. run --account runs an agent on one of
shed's accounts; see docs/accounts/accounts.md.
herdsman gets a runtime = "herdr" | "shed" setting (see herdsman's runtime spike). Lanes then:
- run with
shed run --label fleet=… --label issue=… --label role=…; - report state through the harness hook (
shed state … working|done|blocked); - are read with
shed read; - are watched with
shed eventsinstead of polling.
shed/
├── crates/
│ ├── shed-proto/ # the API types (serde) + JSON-RPC method list; the generated docs/protocol.md comes from here
│ ├── shed-core/ # terminals, screen model (VT parser), state machine, persistence, process trees; no sockets
│ ├── shed-server/ # the per-user server: socket, JSON-RPC, events stream, machines over SSH
│ └── shed/ # the CLI binary (thin client + `shed serve`)
├── tests/ # end-to-end: real PTYs, a fake agent that reports state
├── docs/ # architecture.md, protocol.md, decisions/
└── xtask/ or justfile # `just check` runs every CI gate locally
- Shipping: one binary, with a library-first core. The binary crate holds only argument parsing and wiring.
- Dependency direction is enforced in CI (a small
cargo metadatacheck):shed-corenever depends on the server or CLI crates. docs/holdsarchitecture.md(one page, with a diagram),protocol.md(generated from the types),decisions/(short ADRs, one per real choice).
- Formatting:
cargo fmt --check. - Lints:
cargo clippy --all-targets -- -D warningswithclippy::pedanticon. Everyallowcarries a reason, at most 10 in the workspace. - No unsafe:
#![forbid(unsafe_code)]in every crate, except a single, reviewed PTY module (shed) with a// SAFETY:note per block. - Tests:
cargo test --workspace(unit tests next to the code; integration tests intests/; golden files for every protocol message and CLI output). New behaviour comes with a test that fails without it. - Dependencies:
cargo deny check(licences: MIT/Apache/BSD/ISC only; advisories; no duplicate major versions) and a lockfile committed; Dependabot weekly, grouped. - Docs:
cargo doc --no-deps -D warnings(every public item documented). - Size: per-file and per-function size rules in
.drover/arch.toml, plus a soft per-PR line budget stated in the PR. - MSRV: pinned in
rust-toolchain.tomland the workspacerust-version; CI tests MSRV and stable. - Platforms: macOS (arm64) and Linux (x86_64, arm64) in the CI matrix.
- Errors:
thiserrorerror enums in library crates, andanyhowonly in the binary. - No panics: no
unwrap()/expect()outside tests and proven invariants (each with a comment). - No async by default: add it only for a measured need, and write that down as an ADR.
- Logging: structured logs with a level (
--log json|text); secrets are never logged (redaction tested). - Configuration: one TOML file with a documented schema and defaults; unknown keys are an error with a hint.
mainis protected: changes land by PR with green CI and a review.- The PR template asks for: what changed, a
## For humanssection (2–4 plain lines), tests, the line count, and "not verified". - No AI co-author or "generated with" trailers.
- Versioning: SemVer, with a
CHANGELOG.md(Keep a Changelog). Releases are tagged builds with checksums (GitHub Actions);cargo installworks from the repo. - Install:
scripts/install.sh [BIN_DIR](just install) builds shed and, on macOS, signs every build with the self-signed identityherdsman-localthat herdsman and cooee share (herdsman's signing-identity script creates it once), so a Keychain item that trusts one shed build trusts the next; with no identity it keeps the installed binary and exits 1. When the service job is installed, an install restarts the server (shed installstops and startsdev.shed.serve, ending its terminals), so the binary and the running server are the same build.shed --versionprints the build's git sha; a client and server of different protocols refuse each other at once. - Repo files:
LICENSE(MIT OR Apache-2.0),SECURITY.md(private reporting),CONTRIBUTING.md(how to run the gates locally:just check), and issue templates for bug and feature. - Public-repo hygiene: placeholders only in docs, tests and fixtures; a CI check bans setup-specific names; secret scanning on push; secret-shaped test fixtures are built at runtime.
- ✅ M0, the skeleton: the workspace layout above, every CI gate green on an empty
hellocommand, plus the PR template, LICENSE, SECURITY, CONTRIBUTING and justfile. Nothing else lands before M0. - M1, local core:
serve,run,ls,get,read,send/keys,kill/rm,attach, process-tree cleanup, the socket API, persistence. - M2, state:
state,wait,events, OSC reporting, the per-terminal resource report. - M3, machines:
--on,machine add/ls/rm,connect, the same-version check. - M4, herdsman integration: the
runtime = "shed"adapter in herdsman, tried on one fleet.