Watch every coding agent on this machine, and inspect the sessions they leave behind.
Compatibility
Subagents covers start, end, background and nested for Claude Code, Grok Build, Codex CLI, oh-my-pi and AntiGravity CLI.
claude -pwrites no live index entry, so a print-mode run appears in history only.- Grok's
tool_startedcarries no call id, so the current tool is identified by name. Two tools with the same name running at once show as one. - A failed turn is reported as
failed, but Grok records no error message for it, soactivity.erroris usually empty. grok -pregisters as live only whenGROK_TRACK_HEADLESSis set. Otherwise it appears in history only.- Codex does not persist approval requests, so a session blocked on an approval reads as
running. A launched Codex with no prompt yet has no rollout. A/resumeafter watch started appears on its first append. A VS Code thread unloaded without touching another file stays listed until the next event for that pid. - omp writes no transcript until the first reply of a new session ends. That first turn is read from omp's prompt history, which needs SQLite: Node ≥ 22.13, or your own
sqlitereader. Without it a new session readsidleuntil its transcript appears. - A pending
asktool readswaiting. Permission approvals never reach disk, so a session blocked on one readsrunning(omp's default approval mode asks for none). - omp names a run after the terminal on its stdin, in print mode too:
omp -ptyped in a terminal is live and readsinteractive. Piped or detached, it has no terminal and appears in history only. Nothing on disk marks a runheadless. - AntiGravity CLI supports agy 1.5.5 SQLite sessions, including live print runs, approvals/questions, models, tools, turn outcomes and nested/background subagents. SQLite and holder probes are required for live detection. Older binary
.pbhistory uses generated text logs when present, with reduced metadata.kindremains unset because the persisted state does not identify interactive versus print mode. See AntiGravity CLI. - OpenCode 2 sessions go live only through terminal hints: a host that owns the terminal passes the OSC 7501 records the TUI writes. Without them OpenCode is history only. A session goes live on its first turn in that terminal (an idle session never names itself), and
waitingcomes only from those records. Inside tmux the records arrive only with passthrough on. See OpenCode. - OpenCode child sessions (subagents) and
opencode runare not reported live.
Usage
import AllYourAgents, { builtInProviders } from '@markwylde/all-your-agents'; const aya = AllYourAgents({ providers: [...builtInProviders], }); aya.on('session:create', (session) => { console.log(session.harness, session.id, session.pid); }); aya.start();
No polling, ever (ADR 0001). start() watches the files each harness already writes and the processes that write them. Bursts are coalesced per path (about 25 ms quiet, at most 1 s behind). stop() drops every file and process watch. On macOS, where opening one fs.watch can make the others miss an event, each watch re-checks what it covers once after any watch opens or closes (see the ADR); a custom fs can opt in with onWatchChurn.
Install
npm install @markwylde/all-your-agents
Node.js ≥ 20, macOS and Linux. Pass { fs, processes } to observe a remote machine.
Demos
Run straight from source on Node ≥ 22.18 (no build step):
node ./demo/list.ts # every session, live and historical, as a table node ./demo/list.ts --live # only live sessions node ./demo/watch.ts # stream session events as they happen (Ctrl+C to stop)
CLI
all-your-agents is top for coding agents. It lists every live session, puts the ones waiting on you first, and updates as they change. Press H for every session on the machine, finished ones included, and t to read what any of them said.
npx @markwylde/all-your-agents # full-screen live view npx @markwylde/all-your-agents --once # print a table and exit (also when piped) npx @markwylde/all-your-agents --json # print live sessions as JSON and exit npx @markwylde/all-your-agents --all # also show sessions that close while it is open npx @markwylde/all-your-agents --history # start with every session, not only live ones npx @markwylde/all-your-agents --json --history # every session as JSON, live ones first
| Key | Action |
|---|---|
↑ ↓ / k j, Home End, PgUp PgDn |
Move the selection |
Enter |
Details: full title and folder, what it is waiting for, current tool, last error, subagents |
/ |
Filter by title, folder, harness, model, or pid. Esc clears |
s > / <, r |
Next / previous sort column, reverse |
c |
Show or hide closed sessions |
H |
Show or hide history: every session the providers know, in the same table |
t |
Transcript of the selected session: prompts, replies, tools, outcomes. Follows a live session. t or Esc closes |
? h |
Help |
q Ctrl+C |
Quit and restore the terminal |
The screen redraws only when an agent changes, a key is pressed, or the terminal resizes. History is read once when you press H; a transcript is one event stream, closed when you leave it. Times are clock times (14:31:02), not ticking durations, so nothing runs on a timer. NO_COLOR is honoured.
Session object
A live session has a pid when its provider can name the process: always, except an OpenCode session whose terminal shows no single OpenCode process. A session bound through a terminal hint also has terminalId, the host's id for that terminal. Historical and closed sessions have neither. kind is interactive or headless.
import type { Session, SessionActivity, Subagent, Turn, SessionEvent } from '@markwylde/all-your-agents';
session.activity is the current or last turn (tool, lastTurn, error, openSubagents), separate from status. session.subagents() lists launched subagents. transcript() yields Turns; events() tails normalized SessionEvents until you stop iterating or call close() on it (both work while it is waiting) (user, assistant, tool, tool-result, title, turn-end, subagent, subagent-end, error, other). Each item keeps the original record on raw.
Two kinds of waiting. status: 'waiting' means either that the session is blocked on you (a permission prompt, a question), or that its turn is over while a background shell command or monitor it started is still running and will wake it. The second kind always has waitingFor 'shell' or 'monitor', so session.status === 'waiting' && session.waitingFor !== 'shell' && session.waitingFor !== 'monitor' is "needs the user". Such a session is not idle until that work ends; its finished turn is on activity.lastTurn meanwhile. A background subagent on its own leaves the session idle and shows on subagents().
Title precedence, highest first: user (custom title) > harness (generated) > process (session-file name) > prompt (first real user prompt). session:update fires only when the effective title, cwd, or model changes.
Events
| Event | When |
|---|---|
session:create |
A live process owns a conversation that did not already have a journal. |
session:open |
A live process owns a conversation that already had a journal. |
session:status |
Status changed (running | waiting | idle). |
session:update |
Effective title, cwd, or model changed. |
session:activity |
session.activity changed. |
session:close |
The process no longer holds it. pid and terminalId are unset; history remains. |
subagent:start / subagent:end |
A subagent launched or finished. |
ready |
Catch-up from start() finished. |
error |
A provider failed ({ source: 'provider', provider, error }) or one of your listeners threw ({ source: 'listener', event, error }). Never thrown into the library. |
Subscribe before start(). Catch-up events carry { catchUp: true }, then ready, then { catchUp: false }.
A listener that throws never stops updates. Register an error listener to receive the failure; without one it is rethrown asynchronously as an uncaught exception, so it is never lost.
Query
aya.running(); await aya.sessions({ harness, cwd, live, kind, since }); await aya.get(id); await aya.reconcile(pid); // one-shot re-validation; never schedules
since is epoch ms matched against updatedAt (fallback startedAt). kind is interactive | headless. sessions() works without start(). transcript(), events() and subagents() are always served by the provider named in session.provider. Closed sessions stay in memory for the 1000 most recent; older ones come from their provider's history.
Options
AllYourAgents({ providers: [...builtInProviders], fs, // default: local filesystem processes, // default: local ps/proc + kqueue/pidfd via optional koffi sqlite, // default: node:sqlite where the runtime has it; `false` for none debounce: { quietMs: 25, maxLatencyMs: 1000 }, });
reconcile(pid?) is for hosts that already know a process exited (a terminal emulator). Without koffi, processes.watch is unsupported and each provider re-validates on the next change to its live index or on reconcile.
Terminal hints
Some harnesses tell only their terminal which session they are on. A host that owns the PTYs (a terminal emulator) can pass that on:
const terminal = aya.terminals.attach({ id: tab.id, pid: shell.pid }); // pid: the terminal's shell // For each OSC sequence your terminal parser sees in that tab's output: terminal.osc(code, payload); // e.g. (7501, 'state=working:id=ses_…:app=opencode') terminal.close(); // the tab closed
osc takes the OSC code and the payload after <code>;, already split from the stream: no raw bytes, and no escape-sequence parser in the library. Only OSC 7501 program-status records are decoded (state=idle|working|done|blocked|error|clear, with id, app, kind, progress, and base64 title/msg); every other code, a ? query, a malformed payload and anything over 4096 bytes is ignored. The terminal must answer OpenCode's ESC ] 7501 ; ? ST capability query itself, or OpenCode writes no records. Calls are cheap and synchronous, and never start a timer.
Terminals can be attached before start(); their records are kept and delivered when providers start. stop() forgets every attached terminal, and old handles then do nothing. Attaching an id that is already attached closes the earlier handle. Per terminal the library keeps the latest root record and the latest record of each of the 64 most recently updated child ids, so a provider that starts late still sees them. A session bound this way carries terminalId while it is live.
A provider receives the records with ctx.terminals.subscribe(listener): each { terminalId, pid?, state, id?, app?, kind?, progress?, title?, msg? }, and { terminalId, pid?, closed: true } when a handle closes.
Claude Code
Provider id claude-code, harness ClaudeCode. Home is $CLAUDE_CONFIG_DIR if set, otherwise ~/.claude, overridable via claudeCode({ home }).
Live index: <home>/sessions/<pid>.json. Journals: <home>/projects/<encoded-cwd>/<id>.jsonl. Every non-alphanumeric character in the cwd becomes -, so /Users/me/app/.claude/worktrees/x is -Users-me-app--claude-worktrees-x.
Status: busy → running, waiting → waiting, shell → waiting with waitingFor: 'shell' (the turn ended but a background shell will wake the session), idle → idle. Unknown words omit status. model is the model of the latest assistant record in the journal. .key files and the messaging socket are never opened.
Grok Build
Provider id grok-build, harness Grok. Home is $GROK_HOME if set, otherwise ~/.grok, overridable via grokBuild({ home }). All six built-ins are in builtInProviders; pass providers: [claudeCode()] to watch Claude Code only.
Live index: <home>/active_sessions.json, an array of { session_id, pid, cwd, opened_at }. One pid can hold several sessions. grok -p registers only when GROK_TRACK_HEADLESS is set; otherwise print-mode runs appear in history with kind headless. Sessions: <home>/sessions/<encoded-cwd>/<id>/. The cwd is percent-encoded like Rust urlencoding (everything but A-Za-z0-9-._~, so /tmp/foo(bar)! is %2Ftmp%2Ffoo%28bar%29%21); a cwd whose encoding exceeds 255 bytes is found by a one-level lookup for the session id.
Status comes from events.jsonl, Grok's phase log: waiting_for_model, streaming_text, streaming_reasoning, tool_execution → running; permission_prompt → waiting (with the tool named by permission_requested); no open turn → idle, or waiting while a background task is still running, with waitingFor monitor if one of them is a monitor and shell otherwise. Those tasks are the only thing read from updates.jsonl: its _x.ai/session/update rows background_tasks and task_completed; every other row is skipped unparsed. Unknown phases omit status. Titles and model come from summary.json, the conversation from chat_history.jsonl, subagents from subagents/<id>/meta.json. active_sessions.lock, *.tmp, auth.json and the session-search sqlite are never opened.
Codex CLI
Provider id codex-cli, harness Codex. Home is $CODEX_HOME if set, otherwise ~/.codex, overridable via codexCli({ home }). VS Code Codex sessions that share that home are the same provider.
Live sessions are rollout files a process currently has open: <home>/sessions/YYYY/MM/DD/rollout-<timestamp>-<thread-id>.jsonl. There is no pid index. Status comes from persisted turn lifecycle events: task_started → running; task_complete / turn_aborted → idle. Codex does not persist approvals, and has no background work that wakes an ended turn (a unified exec process that outlives its turn is not recorded as running), so waiting is never reported. Titles come from session_index.jsonl then the first user prompt; the conversation from response_item records; subagents from child rollouts with parent_thread_id. A compressed .jsonl.zst thread is listed only when session_index.jsonl has a title for it, so compressed children are not treated as sessions (an unnamed compressed root is omitted). auth.json, state_*.sqlite, ipc/, process_manager/chat_processes.json and history.jsonl are never opened.
A session does not exist until the first prompt writes a rollout. A resume after watch started appears on the first append. A quietly unloaded VS Code thread stays listed until the next event for that pid.
oh-my-pi
Provider id oh-my-pi, harness OhMyPi. Home is ~/.omp (or ~/$PI_CONFIG_DIR), overridable via ohMyPi({ home }). PI_CODING_AGENT_DIR and, once $XDG_DATA_HOME/omp / $XDG_STATE_HOME/omp exist, the XDG locations are followed as omp follows them. Every named profile under <home>/profiles/, or under $XDG_DATA_HOME/omp/profiles / $XDG_STATE_HOME/omp/profiles, is observed too, and a deleted one closes its sessions. Upstream pi (~/.pi) is not.
omp keeps a registry in two parts. Each process writes run/daemons/<project-hash>/clients/<pid>-<uuid>.json at launch and removes it on a clean exit. Each process on a terminal writes agent/terminal-sessions/<tty> naming the session file it is on, rewritten when you switch session (/new, /resume) and marked fresh while that file does not exist yet. The two are joined by the process's controlling terminal, read once per process with processes.tty(pid). A breadcrumb older than the process on its terminal is not that process's, and binds nothing.
Transcripts: agent/sessions/<encoded-cwd>/<timestamp>_<id>.jsonl. The directory name is lossy, so cwd comes from the header. A session kept elsewhere (--session notes/work, --session-dir) is found through agent/custom-session-files/, and is bound from its breadcrumb once its file exists; omp gives a file not named *.jsonl no subagents. Status comes from the last conversation record: a user message, a tool result, or an assistant stopReason of toolUse → running; stop / length → idle; error → idle with the turn failed and its errorMessage; aborted → idle, interrupted. With no turn open, a bash result that omp backgrounded (details.async, state: running) makes that waiting with waitingFor shell until an async-result message or a later result reports the job; a job left by an earlier process is dropped. A turn omp retries after a provider error starts again without a new prompt. Tools come from toolCall blocks and their toolResult; titles from title_change; model from model_change and the latest reply. Subagents run inside the parent process and are read from <session>/<AgentId>.jsonl (nested ones from <session>/<Parent>/<Parent>.<Child>.jsonl): type from session_init.agent, done when the child records a successful yield, background when the task result said it spawned them asynchronously. For a finished session, a child whose transcript never says how it ended takes its parent's report of it, else cancelled.
Only the history table of agent/history.db is read, and only for a session with no transcript yet. agent.db, models.db, logs/, blobs/ and the .lock sidecars are never opened.
AntiGravity CLI (agy)
Provider id antigravity-cli, harness AntiGravity. Exported as antigravityCli({ home }) and included in builtInProviders. The default home is ~/.gemini/antigravity-cli. Supports the SQLite format checked against agy 1.5.5. Requires Node ≥ 22.13 or an injected sqlite reader; without SQLite this provider yields no sessions.
Live roots come from presence/<uuid>.lock with exactly one live process holding the file open. Locks left behind after exit are history only. The holder probe establishes an open descriptor, not executable identity or OS lock ownership; ambiguous holders are ignored. Resume touches the presence file, so it is discovered before another prompt. Process exit closes a session; a silent handle release is found on the next relevant notification or reconcile(pid). Without holder probes, only history is available.
Metadata and history come from conversation_summaries.db and conversations/<uuid>.db. Generation metadata supplies readable model names and associates them with response steps, including model switches within an execution. Step metadata supplies timestamps, tool identities and errors. Executor metadata reports completion, failure and cancellation even when no final response was generated.
Status maps persisted IDLE to idle and RUNNING/BUSY/CANCELING to running. A WAITING step exposes waitingFor: 'approval', 'ask' or 'elicitation' from its requested interaction. An idle summary with not_fully_idle and unfinished background work reports a shell, task or subagent wait. Daemon tasks do not keep an idle conversation waiting. Unknown states remain unset.
Tools appear when their persisted step starts, with results when it finishes. Finalized user/assistant text is emitted once; token fragments and later edits to finalized text are not replayed. Pending tools do not block later conversation records, and background completion is revisited on notifications. Tool-calling responses do not end a turn, even when agy labels their stop reason STOP_PATTERN. Replacing a database ends its transcript stream; open a new stream to read the replacement.
Child summaries and trajectory metadata expose foreground, background and nested subagents, their parent relationships, terminal states and separate transcripts. Child database/WAL writes update the root's subagent activity without requiring a separate child process or presence lock. Membership is validated before reading a child transcript.
Older binary .pb conversations are recovered from brain/<uuid>/.system_generated/logs/transcript_full.jsonl (or transcript.jsonl) where available. This fallback exposes text, not missing tool-call IDs or model/background metadata. Conversations with neither SQLite nor a generated transcript remain unavailable. Reads are bounded to 4 MiB per persisted record and 64 MiB per legacy log; unknown formats are skipped.
Both interactive and print sessions use the same live ownership and storage paths. kind remains unset: a TTY does not reliably distinguish agy -p from interactive mode. The provider needs no hooks or statusline configuration, does not launch agy, and reads no credentials. Database and WAL notifications drive observation without polling.
OpenCode
Provider id opencode, harness OpenCode, exported as opencode({ dataDir }) and included in builtInProviders. Built against OpenCode 2.4.2. The database is $OPENCODE_DB if set, otherwise opencode.db under dataDir, $XDG_DATA_HOME/opencode or ~/.local/share/opencode. Requires Node ≥ 22.13 or an injected sqlite reader; without SQLite this provider yields no sessions.
OpenCode 2 runs one daemon, opencode serve --service, which owns opencode.db and every session. Its TUIs are HTTP clients that never open the database, and nothing on disk links a TUI to the session it shows (its service.json registers the daemon only). So history comes from the database, and live sessions come from terminal hints: a session goes live when an attached terminal's OSC 7501 child record names it, and stays bound to the first terminal that did. Its pid is the one process that holds log/opencode.log (beside the database) open with that terminal's shell's controlling terminal, found once with processes.tty and processes.holders; when there is none, or more than one, pid is absent and terminalId still says where it is. A record naming a session OpenCode has not written yet is held until the database has it. An id OpenCode would hash (ses_ + 16 hex characters of its SHA-256) is matched too.
A session stays live when its child record is cleared (that only means idle again), and while the TUI has switched to another session, since OpenCode reports no switch. It closes when the terminal's root record is cleared (the TUI exited), when the terminal handle closes, or when its pid exits.
Status is waiting while the terminal reports the session blocked, with waitingFor permission, question or auth (else input), and is never in the database; otherwise running while session_v2.time_busy is later than time_idle or the terminal reports it working; otherwise idle. Titles, cwd, model (providerID/id from session_v2.model), turns, tools and outcomes (idle_outcome: succeeded, failed, interrupted) come from session_v2, session_message and session_part, read through the injected reader whenever the database or its WAL changes. Child sessions and opencode run are not reported live. Nothing talks to the daemon, and no credentials, auth.json or kv rows are read.
Testing kit
import { defineConformanceTests, createMemoryHarness } from '@markwylde/all-your-agents/testing'; const { provider, driver } = createMemoryHarness(); defineConformanceTests({ name: 'memory', provider, driver });
createClaudeFixtureDriver(home), createGrokFixtureDriver(home), createCodexFixtureDriver(home), createOmpFixtureDriver(home) and createAntigravityFixtureDriver(home) drive the same kit against those providers. OpenCode is exempt: its live sessions come only from terminal records, not a process file. A driver's optional startBackgroundWait / endBackgroundWait steps turn on the background-wait case; leave them out for a harness that records no such work.
createAntigravityFixtureDriver(home, { settleMs }) writes agy's SQLite summaries, conversation steps and presence locks, and needs Node's built-in node:sqlite. The provider binds a conversation to the one live process holding its presence/<uuid>.lock, so pass driver.processes to report each createLiveSession pid as that holder. Against the real process probe, as an app's end-to-end tests run it, the pid must hold the lock open:
import { createAntigravityFixtureDriver } from '@markwylde/all-your-agents/testing'; const agy = createAntigravityFixtureDriver(join(home, '.gemini', 'antigravity-cli')); const holder = await agy.spawnHolder(id); // or open `await agy.prepareLock(id)` from your own process await agy.createLiveSession({ id, pid: holder.pid, cwd: '/path/to/project', title: 'Fix the build', status: 'busy' }); await holder.stop(); // the session closes and stays listed as history // createLiveSession again with a new holder's pid resumes it; agy.dispose() stops any holders left.
createOpenCodeFixtureDriver({ dataDir }) writes an OpenCode 2 database as the daemon does, and returns the OSC 7501 payloads its TUI writes, so a host can test its terminal hints end to end. Needs Node's built-in node:sqlite.
import { createOpenCodeFixtureDriver } from '@markwylde/all-your-agents/testing'; const oc = createOpenCodeFixtureDriver({ dataDir }); // pass opencode({ dataDir }), or set OPENCODE_DB to oc.db const id = await oc.createSession({ cwd: '/path/to/project', title: 'Fix the build' }); await oc.startTurn(id); // then startTool / finishTool / reply / endTurn, or runTurn(id) const terminal = aya.terminals.attach({ id: 't1', pid: shellPid }); terminal.osc(7501, oc.payloads(id).working); // live, with terminalId 't1' terminal.osc(7501, oc.payloads(id).exit); // the TUI exited: closed
For the session's pid, run something in the terminal that holds await oc.prepareLog() open (for example sh -c 'exec 3>>"$0"; exec sleep 600' <log>), or in unit tests pass oc.processes and declare the TUI with oc.processes.tui(pid, 'pts/3', shellPid).
Non-goals
Launching agents, IPC sockets, inferring status from journals, Windows.