# tmux

> tmux as an iii worker — list, create, rename and kill sessions and windows and move windows between sessions, see which pane runs Claude Code or Codex (working, waiting for you, idle), which runs `iii compose` and every listening port by process and pane, plus a Console page whose terminal is a live tmux client.

| field | value |
|-------|-------|
| version | 0.2.11 |
| type | binary |
| license | Apache-2.0 |
| repo | https://github.com/iii-hq/workers |
| supported_targets | x86_64-apple-darwin, aarch64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-unknown-linux-musl, armv7-unknown-linux-gnueabihf |
| author | iii |

## installation

```sh
iii call compose::add worker=tmux@0.2.11
```

## configuration

```yaml
- max_terminals: 8
  poll_interval_ms: 1000
  ports_interval_ms: 3000
  terminal_idle_timeout_ms: 30000
  tmux_binary: tmux
```

## dependencies

- `ade` @ `latest`
- `configuration` @ `latest`

## readme

# tmux

tmux as an iii worker. It lists every tmux session, window and pane on the
host, creates, renames and kills sessions and windows, moves windows between
sessions, and tells you what is running where: which pane holds Claude Code
or Codex and whether that agent is working, waiting for you or idle, which
pane runs `iii compose` and on which port its engine listens, and every TCP
port your processes listen on, traced back to the pane that started them. It
reads how much of their weekly allowance Claude Code and Codex have used, and
runs Claude Code on several accounts, moving a pane from one to another
between turns. Its Console page embeds a terminal that is a real tmux client:
what you type goes straight into the session, and the screen updates as tmux
draws it, the same way a second terminal attached with `tmux attach` would.

## Install

```bash
iii call compose::add worker=tmux
```

The worker drives the `tmux` binary installed on the host (Linux or macOS) and
talks to the same tmux server you use from your terminal. Without tmux it still
starts and reports `available: false`, and `tmux::install` can put it there.

## Installing tmux

```bash
iii call tmux::install               # starts or joins the install, answers at once
iii call tmux::install::status       # poll until succeeded or failed
```

| Computer | What runs, in order |
|---|---|
| macOS | Homebrew when `brew` is there (never as root), otherwise MacPorts as root or with `sudo -n`; then the official build |
| Linux, as root or with `sudo -n` | The first of `apt-get` (after `apt-get update`), `dnf`, `pacman` (never `-Sy`, so a stale or empty database falls through), `zypper`, `apk`; then the official build |
| Linux, no root and no passwordless sudo | The official build |
| Linux on a processor with no official build (armv7) | Only a package manager, and without root or sudo the error says what to ask an administrator to run |

Nothing ever waits for a password or for an answer. The official build is
[`tmux/tmux-builds`](https://github.com/tmux/tmux-builds) 3.7c for Linux and
macOS on x86_64 and arm64, pinned by SHA-256 in this worker's source. It goes
to `~/.local/bin/tmux`: checked before it is unpacked, asked `-V` before it
lands there, moved atomically. A file already at that path is never replaced.

An attempt only counts when tmux then resolves, answers `-V` and starts a
server on a private socket of its own, and one that reports a failure counts
when tmux works anyway. A package manager that fails falls through to the
official build, and the failure's `log` says so. With tmux already there the
install changes nothing: it makes the same check and answers `succeeded` with
`method: null`. An install never talks to your tmux server.

The answer of both functions:

```json
{ "state": "running", "step": "downloading", "label": "Downloading tmux…",
  "hints": ["From the tmux project's official builds", "tmux 3.7c"],
  "progress": 0.42, "method": "prebuilt", "path": null, "version": null,
  "error": null, "log": [] }
```

`state` is `idle`, `running`, `succeeded` or `failed`; `step` is `checking`,
`updating`, `downloading`, `verifying`, `installing` or `finishing`; `method` is
`apt`, `dnf`, `pacman`, `zypper`, `apk`, `homebrew`, `macports` or `prebuilt`.
`label` and `hints` are the words to show while it runs, `error` is one
sentence, and `log` is empty until a failure, when it holds every command and
its output. A worker that restarted mid-install answers `idle`.

`tmux::status` says `installable: true` when tmux is missing and this can try:
Linux or macOS, with `tmux_binary` left as plain `tmux`, on a processor with an
official build or a computer with one of those package managers.

A daemon's `PATH` is often short, so plain `tmux` is also looked for after
`PATH` in `~/.local/bin`, `/opt/homebrew/bin`, `/usr/local/bin`,
`/home/linuxbrew/.linuxbrew/bin` and `/opt/local/bin`.

On a system with no terminfo entry for `xterm-256color` (Alpine without
`ncurses-terminfo-base`), the official build can run every command but can't
attach a terminal, so the install also writes that one entry to
`~/.terminfo/x/xterm-256color`.

`tmux --install-tmux` runs the same install with no engine and exits: the steps
and the log on stderr, the final status as the last line of stdout.

## Quickstart

Open the **tmux** page in the Console to browse sessions, open one in the
terminal, and see the **Ports** tab. From code or an agent:

```bash
# Every session → window → pane, with agent / compose / port status
iii call tmux::sessions::list

# A new session running a dev server, then a second window in it
iii call tmux::sessions::create name=api cwd=~/code/api command="pnpm dev"
iii call tmux::windows::create session=api name=logs

# Who listens on which port, and which compose stacks are up
iii call tmux::ports::list
```

Names are taken as typed: tmux 2.7 and later read `#` in a session or window
name as a format (`#{…}`, or `#(…)`, which runs a command), so the worker
doubles it there, and only there. A name shaped like an id (`$2`, `@3`, `%4`)
is refused, since a session is named by its id or its name. A session named
like that outside the worker never stands in for the session with that id:
when `$2` is one session's id and another's name the call is refused, saying
which session to rename. Refusals are one sentence, `There is no pane %9.`
rather than tmux's `can't find pane: %9`.

A new window without `cwd` starts in the directory its session was created
in. tmux older than 3.2 can't tell a session's directory, so there it starts in
the home folder.

A pane whose program ends closes, as in tmux, and so does its window and its
session when it was their last. With `remain_on_exit: true`,
`tmux::sessions::create`, `tmux::windows::create` and `tmux::panes::split`
keep the new pane on screen once its program ends, `dead` in the listing, for
`tmux::panes::respawn` to start again. The pane first runs a placeholder,
then remain-on-exit is turned on and the command starts in its place, so even
a command that fails at once stays. It is the pane's own option from tmux
3.0; on tmux 2.x, which has no pane options, every pane of its window stays.

```bash
iii call tmux::windows::create session=api name=build command="npm run build" remain_on_exit=true
```

A pane running an agent and a pane running `iii compose` look like this in
`tmux::sessions::list`:

```json
{ "id": "%3", "command": "claude",
  "agent": { "id": "claude", "label": "Claude Code", "state": "waiting", "since_ms": 1791936000000,
             "title": "Fix the login redirect" } }
{ "id": "%7", "command": "iii:c:default",
  "compose": { "namespace": "default", "pid": 2759592 },
  "ports": [ { "port": 49135, "role": "engine", "process": "iii:e:default" },
             { "port": 3111, "role": "worker", "worker": "http" },
             { "port": 3114, "role": "worker", "worker": "ade" } ] }
```

Agent state comes from the pane's last lines: a permission or choice prompt is
`waiting`, Claude Code's `esc to interrupt` line is `working`. Claude Code and
Codex also count as `working` while their sub-agents run after the main turn
ended, which their screen does not show; the worker reads what they record on
disk (Claude Code's `~/.claude/sessions/<pid>.json` and each sub-agent's meta
file and transcript, the `rollout-*.jsonl` files Codex holds open) and lists
those sub-agents in `subagents`:

```json
{ "id": "%9", "command": "codex",
  "agent": { "id": "codex", "label": "Codex", "state": "working", "since_ms": 1792698537000,
             "title": null,
             "subagents": [ { "id": "01a16528-d646", "description": "review/tests", "kind": null,
                              "depth": 1, "since_ms": 1792698537000 } ] } }
```

The Console page shows the count on the agent's badge and a row per sub-agent
under its window. A sub-agent has no pane of its own: selecting its row opens
its transcript, which `tmux::subagents::transcript` returns from the same
files. That is the task it was given, what it wrote and reasoned, and the
tools it called with what they returned, oldest first, while it runs and
after it finished:

```bash
iii call tmux::subagents::transcript pane=%9 subagent=01a16528-d646
```

```json
{ "pane_id": "%9", "agent": "codex", "subagent_id": "01a16528-d646", "working": true,
  "prompt": "Message Type: NEW_TASK\nTask name: /root/review/tests\n…",
  "items": [ { "kind": "tool_call", "at_ms": 1792698540000, "text": "cargo test",
               "tool": "shell", "error": false },
             { "kind": "tool_result", "at_ms": 1792698551000, "text": "test result: ok…",
               "tool": "shell", "error": false } ],
  "truncated": false }
```

Item kinds are `user` (a later message from the main agent), `text`,
`thinking` (when the agent records it in clear), `tool_call` and
`tool_result`. Each text is cut at 4 000 characters, and only the last 4 MiB
of a long transcript are read, plus its task. Codex keeps a sub-agent's task
encrypted, so there the prompt shows only its name and sender.

The agent's
`title` is the session title it put on its pane (Claude Code's conversation
topic) without the ✳ or spinner in front; it is null while the pane shows
tmux's default title, the host name. Selecting a window
(`tmux::windows::select`) works like tmux itself: every client attached to
that session, your own terminal included, switches to it.

`tmux::windows::move` moves a window to another session, or next to one of
its windows. The window keeps its id, panes and programs:

```bash
# After the last window of `work`
iii call tmux::windows::move session=api window=@3 target_session=work
# Just before (or after) window 0 of `work`; in the window's own session this reorders it
iii call tmux::windows::move session=work window=@3 target_session=work before=0
```

```json
{ "session_id": "$2", "window_id": "@3", "window_index": 0, "source_session_closed": false }
```

Without `before` or `after` the window goes after the session's last window,
even when an index between two windows is free (tmux's own `move-window -t
work:` would take that gap): from tmux 3.2 that is `move-window -a` after the
last window, decided by tmux in one step; before 3.2 the worker names the
index after the last one, and should another client take it first the answer
says to move it again. `before` and `after` are tmux's `move-window -b` and
`-a`: the window takes its neighbour's index (or the next one), and the
windows from there up to the first free index move up one, so a window past a
gap keeps its index. Both need tmux 3.2 or later, and an older tmux gets one
sentence saying so: `-b` came in 3.2, and before it `-a` put the window after
the session's current window whatever the target, and inside one session
ended the tmux 2.6 and 3.0a server. The
destination's current window stays as it was, and a session's current window
reordered inside it stays current. When the window was the last one of its
session, tmux closes that session and `source_session_closed` is true; with
tmux's default `detach-on-destroy on`, clients attached there (a Console
terminal too) end, so switch a terminal to the target session first. The
window already in the target session without `before`/`after`, both at once,
or a window next to itself are refused in one sentence.

Panes work the same way. `tmux::panes::select` makes a pane active, for every
client looking at that window. `zoom` sets the window's zoom and never toggles
it the way prefix `z` does: `zoom: true` zooms the window on that pane (or keeps
it zoomed there), `zoom: false` unzooms it, and without `zoom` the window keeps
its zoom, moved to that pane. A window with one pane can't zoom, and the
answer's `zoomed` stays false. tmux itself only toggles a zoom, so this is a
read and then a toggle, not one step: another client can zoom or unzoom the
window in between. The worker reads the zoom again after toggling, toggles
once more if it doesn't match, and the answer says what it ended as.
`tmux::panes::capture` returns a pane's visible
screen with its colour escapes, its size and cursor:

```bash
iii call tmux::panes::select pane=%3 zoom=true
iii call tmux::panes::capture pane=%3
```

`tmux::panes::split` puts a new pane to the `right` of a pane or `below` it. It
starts in that pane's current directory unless `cwd` says otherwise, runs the
default shell unless `command` does, and becomes the active pane unless
`select: false`; `remain_on_exit: true` keeps it once its program ends (see
above). `tmux::panes::kill` kills a pane and its program; when that was
its window's last pane the window closes too (`window_closed`), and when that
window was its session's last, the session (`session_closed`).
`tmux::panes::respawn` starts a pane's program again in the same pane, the
command it was started with unless `command`. A pane whose program still runs
is refused unless `kill: true`; one kept on screen after its program ended
(tmux's `remain-on-exit`) is dead and restarts without it.

```bash
iii call tmux::panes::split pane=%3 direction=below command="npm test" select=false
iii call tmux::panes::respawn pane=%7 kill=true
iii call tmux::panes::kill pane=%7
```

```json
{ "session_id": "$1", "window_id": "@4", "pane_id": "%7" }
{ "pane_id": "%7" }
{ "killed": true, "window_closed": false, "session_closed": false }
```

## Claude Code accounts and usage

The worker reads how much of their weekly allowance Claude Code and Codex
have used, and keeps several Claude Code accounts side by side. One of them
is the **global** account: the one signed in to `~/.claude`, which every
Claude Code that isn't pinned uses, plain `claude` typed in any shell
included. Switching it works like `/login`: the sign-ins change places, and
every session on `~/.claude` uses the new account with its next message,
keeping its conversation, with no restart. A pane can also be pinned to one
account; pinned panes move between accounts between turns, resuming their
conversation.

```bash
# Accounts, their usage and reset times, Codex's usage, the rules and any suggestion
iii call tmux::usage::read                    # refresh=true reads again now
iii call tmux::accounts::list

# A second account, then sign it in: open the link it answers, paste the code the page shows
iii call tmux::accounts::add name=Personal color=green
iii call tmux::accounts::login_start account=personal
iii call tmux::accounts::login_code login_id=<login_id> 'code=<code#state>'

# A window running Claude Code on that account, or following the global one
iii call tmux::windows::create --json '{"session":"work","claude":{"account":"personal"}}'
iii call tmux::windows::create --json '{"session":"work","claude":{"account":"global","skip_permissions":true}}'

# Make a pane follow the global account, make another account global
iii call tmux::panes::account pane=%5 account=global
iii call tmux::accounts::global account=personal
```

### Accounts

Every account has a folder under `~/.local/share/iii/claude-accounts`
(`$XDG_DATA_HOME/iii/claude-accounts` when that is set), `default` included
(`…/claude-accounts/default`), listed with its name, colour and what it
shares in `accounts.json` there (0600, written whole, then renamed into
place; its `revision` goes up by one on each change the worker makes).
`default` is the account `~/.claude` was signed in to when accounts began.
Without `accounts.json` there is one account, `default`, on `~/.claude`, and
the worker changes nothing.

An account's sign-in (its chain of tokens) lives in exactly one place: in
`~/.claude` while it is the global account, in its own folder otherwise.
Two copies of one chain would part on the first token refresh, and Claude
Code would sign the losing copy out, so the worker always moves a sign-in,
never copies it. Each folder's `.claude.json` keeps the account's profile
(`oauthAccount`), which is how the worker knows who is signed in where.

`tmux::accounts::add` takes a `name` (no two alike, case aside), a `color`
token (`blue`, `green`, `violet`, `orange` or `pink`; the apps draw anything
else gray) and `shared`. The id is the name as a slug (`[a-z0-9-]`, at most 32
characters, never `default` or `global`); a folder of that name left in the
accounts folder is never reused, the id gets `-2`. The new folder is 0700 and
signed out.

`shared` names what the account's folder takes from `~/.claude` through
symbolic links (all four groups unless it says otherwise; `default` shares
all four):

| Group | Links |
|---|---|
| `settings` | `settings.json`, `CLAUDE.md`, `keybindings.json` |
| `extensions` | `skills/`, `agents/`, `commands/`, `output-styles/` |
| `plugins` | `plugins/`, and the user's MCP servers (`mcpServers` of `~/.claude.json`) copied once into the new account's `.claude.json` |
| `conversations` | `projects/`, `history.jsonl`, `todos/`, `plans/` |

A link is made only for what exists in `~/.claude`, and never in place of a
file or folder of the account's own; links missing are made again when the
worker starts and on each update or sign-in. `.credentials.json`,
`.claude.json`, `sessions/`, `statsig/` and `shell-snapshots/` are never
linked. `tmux::accounts::update` renames, recolours or changes the groups:
dropping one removes only the worker's own links into `~/.claude`.

An account signs in through `tmux::accounts::login_start` and
`tmux::accounts::login_code` ([Signing in](#signing-in)). The worker never
signs in, refreshes or signs out by itself.

`tmux::accounts::remove` takes an account off the list; not `default`, not
the global one, not one a switch waits to make global. Claude Code panes on
its folder keep running. `delete_files: true` deletes its folder too, only
when it is a real folder directly inside the accounts folder (a link is never
followed out of it), and is refused while Claude Code runs on it (a pane,
or a sign-in from the app, until its Claude Code is gone), while any pane is
being moved, or when tmux could not list its panes; it looks at the
processes again first, never at a scan from a few seconds before.

### Signing in

`tmux::accounts::login_start` (`account`, `browser`) runs `claude auth login`
for an account in a terminal of the worker's own, which no tmux session
shows: on the account's folder (`CLAUDE_CONFIG_DIR=<folder>`), or on
`~/.claude` for the global account (without `CLAUDE_CONFIG_DIR`), with
`--email` when the account's profile has one. It answers once Claude Code
printed its sign-in link, with `login_id`, `account`, `url`, `expires_at_ms`,
`browser`, and `email` and `browser_url` when there are. `url` is the link
that works on any device: the page ends showing a code, which the person
copies back. A new `login_start` for the same account ends the one under
way; of two started at once, the later one stays and the other answers
`gone`. Claude Code runs in the worker's home folder, with the worker's
`HOME`. While a switch of the global account is left half-way and not
settled yet, no sign-in starts on `~/.claude` or on the two accounts it
moves (`failed`, try again in a moment).

`browser` says where a browser may open:

- `none` (the default): nowhere. Claude Code runs with the worker's own
  `BROWSER`, a script in a temporary folder (0700) that notes the link and
  opens nothing, and with that folder's `open` and `xdg-open` first on its
  `PATH`, so it never opens a browser on the worker's computer. The person
  opens `url` wherever they are and pastes the code.
- `host`: the browser of the computer the worker runs on, for someone
  sitting at it (the Mac app's "This Mac"). The link Claude Code opens goes
  to the worker's own `$BROWSER`, else `open` (macOS) or `xdg-open` (with
  `DISPLAY` or `WAYLAND_DISPLAY` set, as Claude Code itself asks), and
  comes back as `browser_url`: it returns to Claude Code's listener on
  `127.0.0.1` and signs in by itself, with no code. `url` and a code work
  too. Only `login_start`'s answer carries `browser_url` (the list and the
  feed, which need no approval, never do), and `host` fails when nothing on
  that computer opens a browser.

`tmux::accounts::login_code` (`login_id`, `code`) types the code into that
terminal. Whitespace anywhere in it is dropped (a code copied over two
lines); one without its two halves around `#` is refused as `invalid_code`
before it reaches Claude Code, and the sign-in keeps waiting. It waits up to
60 seconds for Claude Code and answers `{"state": "done", "account"}`, the
account read again, or an error; of two calls at once, one types its code
and the other waits for that outcome. `done` means a new sign-in is where it
belongs: in the account's folder, or on `~/.claude` and taken in as the
global account (looked for three times, a second apart); Claude Code saying
it signed in while the sign-in there is still the one from before is
`failed`.
Whoever signed in stands, even someone other than the email the page was
filled with: `account` shows who. A code Anthropic refuses ends the sign-in
(Claude Code exits): another `login_start` gives a new link, and only a code
from that link works with it. `tmux::accounts::login_cancel` (`login_id`)
ends one and answers `{}`, also when it is over or unknown. A sign-in not
finished within 10 minutes ends as `expired`, and a code typed after that
is `expired` too. While a code is being checked, Claude Code may be saving
the sign-in, so neither the 10 minutes, a cancel nor `login_code` giving up
stops it before 15 more seconds; its own outcome stands when it comes by
then. With `host`, the 10 minutes running out gets the same 15 seconds: the
person may have just come back from the page. Claude Code is stopped with
SIGTERM, and with SIGKILL 3 seconds later if it is still there. Removing an
account ends its sign-in.

Errors come as one JSON object in the error's message, `{"code",
"message"}`:

| `code` | When |
|---|---|
| `invalid_code` | not shaped like a code; nothing typed, the sign-in keeps waiting |
| `rejected` | Anthropic refused the code (Claude Code's own sentence); the sign-in is over |
| `expired` | 10 minutes went by |
| `gone` | cancelled, replaced by a newer `login_start` for the account (that start's own answer too), the account removed, the worker stopping, or unknown; the message says which |
| `failed` | Claude Code is not installed, could not start, printed no link within 45 seconds, ended without signing in (the person cancelled on the page: its sentence) or as if signed in with no new sign-in to show; `host` with no browser to open; a switch left half-way on the places it would sign in |

`tmux::accounts::list` and the feed's `usage.claude` carry `logins`: the
sign-ins under way and those that ended in the last minute, each with
`login_id`, `account`, `state` (`waiting_code`, `checking`, `done`, `failed`
or `expired`), `url`, `expires_at_ms`, `browser`, and `email` and `error`
when there are. A cancelled one leaves the list at once. A sign-in on
`~/.claude` to someone else is a sign-in by hand there: it makes that
account global ([below](#the-global-account)). While a sign-in runs on
`~/.claude` or on an account's folder, `tmux::accounts::global` refuses to
switch the global account away from or to the accounts it involves
(`signing_in`), and the rules and a waiting switch go on once it is over:
a swap would move sign-ins where Claude Code is about to save one. A
cancelled sign-in counts until its Claude Code is gone (one checking a code
gets its 15 seconds to save it).

The code and the tokens are never logged, kept or answered; the worker's
log shows a link without its `state`, `code_challenge` and `login_hint`, and
Claude Code's output stays in memory only while the sign-in runs. On macOS
Claude Code keeps the sign-in in the login Keychain and, when that Keychain
is locked, does not fall back to a file: the worker has to run in the
person's logged-in session (a LaunchAgent, or a terminal there), not as a
LaunchDaemon or from an ssh session, or the sign-in fails.

### The global account

The global account is whoever is signed in to `~/.claude`: its
`.credentials.json` (on macOS the login Keychain item `Claude Code-credentials`)
and the `oauthAccount` profile in `~/.claude.json`. `tmux::accounts::global`
makes another signed-in account global by swapping sign-ins, under Claude
Code's own locks and in its order, so a Claude Code renewing its token never
sees half a swap:

1. The locks: `~/.claude/.oauth_refresh.lock`, `~/.claude.lock`,
   `~/.claude/.storage-write.lock`, then the same in the two account folders
   (directories made with `mkdir`, as Claude Code's lock library makes them;
   one older than its stale period is taken over). If Claude Code holds one
   for more than 10 seconds, nothing changes and the call fails with `busy`.
2. The old global account's newest sign-in (it may have been renewed while it
   was global) goes from `~/.claude` to its folder; the new one's goes from its
   folder into `~/.claude`, and is removed from its folder. A sign-in is the
   store's keys that belong to the Anthropic account, the ones Claude Code's
   logout removes, each moved if present: `claudeAiOauth`, `designOauth` and
   `cloudSessionsOauth` (three token chains Claude Code revokes together),
   `organizationUuid`, `trustedDeviceToken`,
   `trustedDeviceEnrolledAfterRefusalAtMs` and `enterpriseGateway`. Every
   other key stays where it is: `mcpOAuth` holds
   sign-ins to MCP servers, which are yours, not the Claude account's, and
   stays in `~/.claude`. Files are written to a temporary file (0600), synced
   and renamed. On macOS the Keychain item is written the way Claude Code
   writes it (`security -i`, the secret on standard input). A store over
   4032 bytes goes as arguments instead, hex-encoded with its tokens, where
   another process of yours could see it while `security` runs: the same as
   Claude Code does, and only for a store over 4 KB. A plaintext
   `~/.claude/.credentials.json`, when there is one, gets the same change.
   The locks are touched before every store call, and a swap that has held
   them for 8 seconds (a Keychain that hangs) stops safely.
3. Under `~/.claude.json.lock`, the old account's profile is kept in its
   folder's `.claude.json`, the new one's goes into `~/.claude.json`, and the
   keys `/login` clears (the old account's cached models, organisation
   defaults, usage and status readings) are cleared.
4. `accounts.json` says the new account is global, with `last_switch`.

No network is used while a lock is held, and nothing is ever signed out or
revoked. Before it starts, the worker writes `swap.json` in the accounts
folder (0600, no tokens: the first 16 hex digits of the SHA-256 of each
refresh token, so it can tell which sign-in is where). A swap left half-way
(the worker stopped, or a write failed: a full disk, a Keychain that timed
out) is settled from what the stores really hold, never from the step it
noted: with the new sign-in in `~/.claude` it is finished; with the old one
still there it is finished, or undone when the switch already answered with
an error; with any other sign-in there (someone signed in by hand meanwhile)
nothing is touched and the sign-in by hand is taken in as below. This
happens at start, within 2 seconds while the worker runs, and before any
switch. The locks a stopped swap left are the worker's own when they are
still the directories it made (device, inode and birth time, or, where the
file system keeps no birth time, touched within its own swap): those go at
once, and anything else is waited out as stale (up to 60 seconds). A stale
lock is moved aside (`<lock>.stale-<id>`) before it is removed. What was
moved goes back when it is not the lock judged stale (a new lock, even one
given the same inode, has new modification and birth times; the old one
may have been touched again), unless something new took its place; what
was moved aside and left goes once stale, at start and before each lock is
taken. The worker releases a lock only while it is still the one it
touched last. A swap and its settling hold `swap.lock` in the accounts
folder (an `flock`, let go of when the process ends) so that a second
worker on the same accounts leaves a swap that runs alone. One switch,
recovery or move runs at a time, and a new Claude Code pane (`claude` on
`tmux::windows::create`, `tmux::sessions::create`) waits for the one running
too: nothing starts on a folder whose sign-in is moving, and nothing plans
on what a swap half-way shows. While a swap left half-way can't be settled
yet, a new Claude Code pane on `~/.claude` or on either account it moves is
refused ("A switch of the global account left half-way is being settled;
try again in a moment."), and no pane moves. Once a call has its turn, its
work (a new Claude Code pane included) runs to the end on its own, even
when the caller goes away (a timeout, a disconnect): a switch is never left
half-way by a call that stopped waiting, and no other one starts before it
is over. A switch or a move needs tmux to list every pane: when it can't
(a timeout), nothing is switched or moved and the error says so. An
account a swap involves (running, or left half-way) can't be removed. A session that
fetched the old profile right before the swap
and writes it back within a minute gets the new one put back. Claude Code
has a feature gate (`tengu_bubbly_fountain`, off today) that would stop a
running session whose account changes; when `~/.claude.json` shows it on,
the switch is refused with `owner_check_on`.

Every Claude Code on `~/.claude` that isn't pinned switches with its next
request (`following`): on Linux at once (Claude Code looks at
`.credentials.json` on every request), on macOS within 30 seconds (Claude
Code keeps what it read from the Keychain that long; `switch_delay_s` in the
snapshot). Pinned panes:

- Pinned to the **new** account (they run on its folder, whose sign-in has to
  move): idle ones are stopped before the swap and started again on
  `~/.claude` after it, still pinned (`restarted`). While one is working or
  waiting, the switch waits: the answer is `state: "waiting"` with
  `waiting_for`, the snapshot carries `pending_global`, and the worker
  finishes the switch within seconds of the last of them going idle. Another
  switch replaces a waiting one; switching to the account that is global
  now cancels it. A Claude Code on that folder the worker can't stop and
  restart (inside another program, sharing a window before tmux 3.0, its
  pane running another program now) refuses the switch with `blocked` and
  `blocked_by`. One started by hand in a shell that does not take the
  terminal back once Claude Code has stopped does not: its folder is free
  then, so the switch goes on, and the pane says it was stopped and not
  started again (`move_error`). When the conversation can't be made visible
  on `~/.claude` (it holds a longer copy), Claude Code starts there with a
  new conversation and `move_error` says so; it never starts again on its
  folder, whose sign-in is in `~/.claude` now. A waiting switch that fails
  in a way that may pass (a lock Claude Code holds, a write that failed, a
  Claude Code slow to stop) is tried again a few times over about a minute,
  and one that meets a sign-in from the app waits for it to end;
  one that can't happen (the account was signed out or removed, a pane
  can't be restarted, `owner_check_on`), or still fails after those tries,
  is called off: `pending_global` goes, and the panes it waited for (and
  any in the way) say why in `move_error` ("The switch to Personal was
  called off: …").
- Pinned to the **old** account (they ran on `~/.claude`): idle ones restart
  on its folder (`restarted`); working ones finish their turn on `~/.claude`,
  now as the new account, and then restart on its folder (`after_turn`).
  One whose Claude Code takes longer than 10 seconds to stop starts again
  on its folder once it ends. One that can't be moved (inside another
  program, sharing a window before tmux 3.0, in copy mode) stays on
  `~/.claude`, so it runs as the new account: it follows the global account
  from then on, counted in `following`, and its `move_error` says so.
- Pinned to any other account: untouched.

Errors come as one JSON object in the error's message, `{"code", "message",
"blocked_by"?}`: `not_signed_in`, `busy`, `blocked`, `owner_check_on`,
`signing_in` (a sign-in from the app runs on `~/.claude` or on either
account's folder) or `failed`.

Someone signing in by hand on `~/.claude` (`/login`, or `claude auth login`
without `CLAUDE_CONFIG_DIR`) changes the global account the same way: the
worker notices within about 2 seconds, makes a known account global
(`last_switch.reason: "login"`) or adds an unknown one, named after its
profile and sharing all four groups, and makes it global (`"login_new"`).
Signing out there by hand leaves the global account as it is, signed out.
A sign-in by hand replaces the global account's only copy of its sign-in
(it lives in `~/.claude` while global), so the account that was global
reads signed out until it signs in again; switching through
`tmux::accounts::global` keeps both. So the panes on `~/.claude` pinned to
the account that was global, which now run as the new one and can't go to
its folder, follow the global account from then on, counted in
`last_switch.following` with the others. For a minute after a switch, the old
account's profile written back over the slot by a session that fetched it
just before is put right, but only while the slot still holds the new
account's sign-in (the one the switch wrote, or one Claude Code renewed it
to); with any other sign-in it is a `/login` and handled as above.

**From 0.3.0.** 0.3.0 kept the global account in tmux's global
environment instead. The first start of this version takes the account
signed in to `~/.claude` as global (`last_switch.reason: "upgrade"`, usually
`default`), gives `default` its folder, pins the panes that followed the
global account onto the folder they run on, and removes the account folder
0.3.0 put in tmux's global `CLAUDE_CONFIG_DIR` (nothing else of tmux's
environment is touched, then or later). Shells opened while 0.3.0 had set it
still carry it in their environment: plain `claude` there runs on that
folder until the shell is closed (`unset CLAUDE_CONFIG_DIR` fixes one).

### Windows on an account

`tmux::windows::create` and `tmux::sessions::create` take
`claude: { account, skip_permissions }` instead of `command`; `account` is
`global` (the default) or an account id. The worker builds the command, marks
the pane, and answers it as `runs`:

| Account | Command |
|---|---|
| `global`, or pinned to the account that is global now | `claude` |
| pinned to any other account | `env CLAUDE_CONFIG_DIR=<folder> claude` |

When the pane's session or tmux's global environment sets
`CLAUDE_CONFIG_DIR`, `claude` becomes `env -u CLAUDE_CONFIG_DIR claude`, and
`runs` says so. The pane's `remain-on-exit` is set as asked, on or off.

`skip_permissions: true` adds `--dangerously-skip-permissions`: Claude Code
then runs commands and changes files without asking. It is never on unless
asked, and is refused when the worker runs as root, where Claude Code refuses
it (`runs_as_root` in the accounts snapshot).

Marks are tmux user options of the pane: `@iii_claude_account` (`global` or
an account id), `@iii_skip_permissions` (`1`) and `@iii_claude_pending` (the
account a move waits to reach). tmux before 3.0 has no pane options, so there
they are options of the pane's window, and a window with more than one Claude
Code pane can't keep an account per pane: its panes are not movable there.
Another pane in a window running Claude Code carries that pane's marks, not
its own, so it gets no `claude` object there, and nothing done to it changes
that pane's account or its waiting move.
Each pane running Claude Code has a
`claude` object in `tmux::sessions::list`: the `account` its process uses (read
from that process's `CLAUDE_CONFIG_DIR`: `~/.claude` is the global account,
so a `claude` started by hand counts too), `config_dir`, `follow` (`global`
on `~/.claude` and not pinned, `pinned` with an account mark, `manual` when
started by hand on an account's folder),
`pending`, `skip_permissions` (the process's own arguments:
`--dangerously-skip-permissions` or `--permission-mode bypassPermissions`;
a mark left from an earlier process in the pane never counts), `session_id`, `movable` with
`not_movable_reason` when it is false, and `move_error` when its last move
failed (cleared by its next account change).

### Moving a pane

`tmux::panes::account` with `account: global` makes a pane follow the global
account (it runs on `~/.claude`), with an account id pins it there (on
`~/.claude` while that account is global, on its folder otherwise; pinning a
pane on `~/.claude` to the account that is global now restarts nothing).
When Claude Code has to run elsewhere for that, the account must be signed
in, and the pane moves:

1. Right before, the worker looks again: the pane must still run the same
   program, with the same Claude Code process under it (its session
   record's start time must be known and be the process's own), in the same
   conversation, with the status `idle`. Otherwise nothing is stopped and
   the move waits for the turn (`after_turn`) or fails.
2. Claude Code gets SIGTERM and up to 10 seconds to end; it saves and runs
   its `SessionEnd` hooks first. A pane the worker started is kept on screen
   meanwhile with a temporary `remain-on-exit`, put back as it was
   afterwards (unset stays unset). When Claude Code takes longer, the move
   fails, but the pane keeps `remain-on-exit` until Claude Code does end;
   then Claude Code starts again on the account it ran on, resuming its
   conversation, and `remain-on-exit` is put back. Started by hand in a
   shell, it just gives the shell the terminal back.
3. The target folder is made to see the conversation: if its
   `projects/<project>/<session>.jsonl` is not the same file (accounts sharing
   conversations link the same folder), the transcript and its `<session>/`
   folder are copied there. A copy already there is only replaced by a longer
   or equally long and newer one; when the account has a longer copy, Claude
   Code starts again on the account it ran on, resuming the conversation, and
   the move fails.
4. Claude Code starts again there with `--resume <session>` (and
   `--dangerously-skip-permissions` again when it had it), the place named
   in the command: `env CLAUDE_CONFIG_DIR=<folder> claude …`, or `env -u
   CLAUDE_CONFIG_DIR claude …` for `~/.claude`. A pane the worker started is
   respawned in place. Claude Code started by hand in a
   shell is started again by typing into that shell (`C-e`, `C-u`, the
   command, Enter), only once the shell has the terminal back within 3
   seconds and still has it right before typing; otherwise nothing is typed,
   the pane is marked as the move would have marked it, and the move fails
   (`move_error`). A shell pane in copy mode is refused before anything is
   stopped, since the keys would go to copy mode. A shell started with `-c` (also `-lc`, `-ec`,
   `--command`) runs one command and ends: its pane is respawned instead.

While a pane moves, a change of its account (`tmux::panes::account`) answers
"This pane is being moved already.".

A pane moves only when Claude Code's own status is `idle`. Working, waiting
for a permission answer, running a background command or with no status, it
answers `after_turn`: the pending mark is set, and the worker moves it within
2 seconds of its turn ending, also after a worker restart (the mark is
tmux's). A waiting move that can no longer happen (its account was removed
or signed out, the pane can't move) is dropped and the pane says why in
`move_error`. Each waiting move is looked at again right before it runs: one
cancelled or changed meanwhile is left to the next round, and a round whose
look at tmux failed changes nothing. Choosing the account it runs on changes no process and cancels
a waiting move (`cancelled`).

`tmux::accounts::move_idle` moves every idle pane using account `from` (its
folder, or `~/.claude` when it is global) to `to` and pins it there: those
that follow the global account, are pinned to `from` or were started by
hand, never one pinned elsewhere.

### Usage readings

Claude Code's usage comes from `GET https://api.anthropic.com/api/oauth/usage`,
the endpoint Claude Code reads its own usage from, with the account's sign-in
(`Authorization: Bearer`, `anthropic-beta: oauth-2025-04-20`), read from
where it lives now: `~/.claude` for the global account, its folder for the
others. It answers each
window (`five_hour`, `seven_day`, per-model weeks) as `utilization` from 0 to
100 with its `resets_at`. The sign-in is `<folder>/.credentials.json` on
Linux; on macOS it is in the login Keychain, a generic password whose account
is `$USER` and whose service is `Claude Code-credentials` for `~/.claude` and
`Claude Code-credentials-<first 8 hex digits of sha256(folder)>` for an
account's folder (the folder exactly as put in `CLAUDE_CONFIG_DIR`,
NFC-normalised, as Claude Code hashes it), with the file as fallback. The worker only reads it: it never
refreshes a token, never sends one anywhere but that endpoint, and never logs
or returns one. An expired sign-in is not used (`token_expired: true`, the
last reading kept; an account that isn't global ages out like this, since
nobody renews its token, and becoming global renews it on its first
request); a window whose reset time has passed reads 0 %
(`reset_since_read`). The reading Claude Code itself left in `.claude.json`
(`cachedUsageUtilization`) is used when it is newer.

Readings are kept at most 5 minutes old while someone watches (a
`tmux::usage::read` call or an observer of `tmux::on-changed` in the last 10
minutes); `refresh: true` reads again at once, at most once a minute per
account. With nobody watching, the worker reads nothing, not even locally
(sign-in files, the Keychain, profiles, Codex's records), unless
`accounts.json` exists and an account other than the global one is signed in
(one that could take over); it looks at who is signed in once when it starts
with `accounts.json`. Then it reads only the global account, every 10
minutes, while the rules are not `off`, and the others when the global one
runs low. A call that moves a pane or switches the global account
(`tmux::panes::account`, `tmux::accounts::global`, `move_idle`) reads the
sign-in of the account it goes to, and that one alone.

A 429 pauses an account's readings for 15 minutes; a 401 counts the sign-in
as expired until its token changes (or the worker starts again); any other
failure is tried again after a minute. The latest readings, without tokens,
are kept in `~/.cache/iii/tmux/usage.json` (`~/Library/Caches/iii/tmux/usage.json`
on macOS).

Codex's usage is read from what Codex records: the newest `token_count` event
of its sessions under `~/.codex/sessions` (the last 4 MB of each file, newest
first, until one is found; at most 8 MB a look), whose windows are told apart by
their length (300 minutes, 10080 minutes) and whose `resets_at` is in seconds.
It comes with the plan and credits; Codex has one account.

### When the global account runs low

`tmux::accounts::rules` sets what the worker does when the global account
reaches `at` (`week_80`, `week_90` or `limit`; `five_hour: true` also counts a
full 5-hour window). With `mode: suggest` the snapshot carries a
`suggestion` (`{ id, from, to, reason, following }`) naming the account to
switch to: the first of `order` that is signed in and has room, otherwise the
one with most room this week (an account whose sign-in expired only when no
other has room). `tmux::accounts::dismiss` answers "Not now": no suggestion
from that account for that reason until its window resets or it runs lower
(week 80 % → 90 % → 5-hour window full → week limit). With `mode: switch` the
worker switches by itself, the app open or not, the same way a person does
(never to an account with Claude Code working on its folder: the next one
instead), and leaves `last_switch` (`auto: true`) for the app; `back_after_reset` (in mode `switch` only, and while it stays
on) switches back once the old account's window resets, unless someone made
another account global since. A switch someone makes leaves `last_switch`
too, with `auto: false` and no `reason`. A switch of the rules happens only on the `accounts.json` they
decided on (any change written meanwhile, even back to the same global
account, drops it until the next look). Until changed, the rules suggest at
`week_90`; `mode: off` stops them.

```bash
iii call tmux::accounts::rules --json '{"mode":"switch","at":"week_90","order":["personal"],"back_after_reset":true}'
iii call tmux::accounts::dismiss suggestion=default:week_90:personal
```

### For tests and demos

| Variable | Replaces |
|---|---|
| `III_CLAUDE_HOME` | `~/.claude`, the global account's place; its `.claude.json` is then the one next to it, in its parent folder, as `~/.claude.json` is next to `~/.claude`. Claude Code started on it finds it through its own `HOME`: give the tmux server the `HOME` that holds it, or panes on the global account use that `HOME`'s `~/.claude` |
| `III_CLAUDE_ACCOUNTS_DIR` | the accounts folder |
| `III_CLAUDE_USAGE_URL` | `https://api.anthropic.com` for the usage endpoint; loopback addresses only, so a sign-in never goes to another host |
| `III_CLAUDE_LOGIN_TTL_S` | the 10 minutes a sign-in may take (10 to 600 seconds) |
| `CODEX_HOME` | `~/.codex` (Codex's own variable) |

[`demo/`](demo/) runs this worker in a container of its own (its own tmux
server, a fake `claude` and `codex`, three fake accounts and a mock usage
endpoint) against an engine on the host: `demo/run.sh <engine-port>`, then
`demo/seed.sh`, `demo/usage.sh` to change what the mock answers and
`demo/state.sh` to make a fake Claude Code work, wait, go idle or hit its
limit, and `demo/ask.sh` to send one a message: it reads its sign-in again,
as Claude Code does, and answers with the account it used (`/login <id>`
typed into it signs in as that account). Its `claude auth login` behaves
like Claude Code's: the code `demo-ok#<anything>` signs the account in as its
own person (`demo-ok:<id>#…` as account `<id>`), any other code is refused
and ends the sign-in, and `demo/login.sh <engine-port> browser
[demo-ok|demo-ok:<id>|deny]` plays the browser on the worker's computer
coming back to it (`deny`: the person cancelled on the page; the
container's `BROWSER` only notes the link, so `browser: "host"` works there);
`demo/run.sh <engine-port> --login-ttl <seconds>` shortens the 10 minutes. Nothing in it reads the host's own Claude Code or Codex, and its
scripts that write files or call tmux refuse to run outside the container
(they need `/.dockerenv` and `DEMO_CONTAINER=1`, which the image sets).

## Configuration

```yaml
tmux_binary: tmux            # name on PATH or absolute path (never this worker's own binary)
socket_name: null            # tmux -L <name>; null = your default tmux server
socket_path: null            # tmux -S <path>; wins over socket_name
poll_interval_ms: 1000       # live feed cadence for sessions and agent state
ports_interval_ms: 3000      # process and listening-port re-scan cadence
busy_window_ms: 2000         # agents without working patterns: "working" while the pane changed this recently
command_timeout_ms: 5000     # one tmux command
max_terminals: 8             # concurrent Console terminals (each one is a tmux client)
terminal_idle_timeout_ms: 30000  # detach a Console terminal its page stopped heart-beating
agents:                      # first match wins; patterns are case-insensitive regexes over the pane's last lines
  - id: claude
    label: Claude Code
    process: [claude]
    working_patterns: ["esc to interrupt"]
    waiting_patterns: ["❯\\s*1\\.\\s*Yes", "Do you want to proceed\\?", "Enter to select"]
```

The built-in list also recognises `codex`, `opencode` and `gemini`; see
[`src/config.rs`](src/config.rs). Edit the configuration from the page's
settings action or with `configuration::set`.

## Observable functions

| Function | Args | Delivery | Event |
|---|---|---|---|
| `tmux::on-changed` | none; the overview has no field to filter on | iii's default delivery; once a new observer is accepted, the worker calls the function with the current overview for that observer alone (metadata `{ for_observer: <observer id> }`), delivered like every other call | `Overview { sessions, ports, usage }`: the shapes `tmux::sessions::list`, `tmux::ports::list` and `tmux::usage::read` return (`usage` is absent from workers before 0.3) |

`tmux::on-changed` is private: only this worker calls it, whenever sessions,
windows, panes, agent states, compose stacks, listening ports, Claude Code
accounts or usage readings change. The
worker polls tmux only while something observes it.

Overviews can arrive out of order: each one is its own call, and iii doesn't
order deliveries across calls, so two sent milliseconds apart (a mutation's
and the next poll's) may land the other way round, and nothing re-sends until
something changes again. Keep the overview with the highest
`sessions.generated_at_ms` (and `ports.generated_at_ms`) and drop an older one
that comes after it; the same rule settles a `list` answer racing a push.

```ts
iii.registerFunction('my-worker::on-tmux', async ({ output: { sessions, ports } }) => {
  // compare agent states with the previous overview
})
iii.observe({ function_id: 'tmux::on-changed', capture: ['output'] }, 'my-worker::on-tmux')
```

The Console page's terminal functions, `tmux::terminal::open`, `write`,
`resize`, `switch`, `replay`, `redraw`, `close` and `upload`, cannot be
observed (`NOT_OBSERVABLE`): `open` returns the terminal's access key, every
other call carries it, `write` carries what is typed into the terminal and
`upload` the file being pasted.

`tmux::terminal::upload` is how a file is pasted into a terminal. It only
writes a file: `data` (base64, any type, at most 12 MiB decoded) goes to a new
folder of its own in the cache folder of the user this worker runs as, under
`name` made safe, and the answer is that file's absolute path. It types
nothing into the terminal; the page pastes the path itself, and Claude Code and
Codex then attach it (an image as `[Image #1]`; Codex only when the paste is
that path alone and its model takes images); any other program just receives
the path as text.

```json
{ "path": "/home/me/.cache/iii/tmux/uploads/20261110-161648-0a1b2c3d/Quarterly-report.pdf",
  "bytes": 48213, "mime": "application/pdf" }
```

| Computer | Folder |
|---|---|
| Linux | `$XDG_CACHE_HOME/iii/tmux/uploads` when that's an absolute path, otherwise `~/.cache/iii/tmux/uploads` |
| macOS | `~/Library/Caches/iii/tmux/uploads` |

Each upload gets its own folder, `<UTC yyyymmdd-hhmmss>-<8 hex>`, so its name
survives. The name keeps only its base name, made one token a shell or Codex
reads whole: characters outside `A-Z a-z 0-9 . _ -` become `-` (no spaces),
runs collapse, no leading dot, at most 100 bytes with its extension kept, and
`file` when nothing is left (`../x` is `x`, `My report (1).pdf` is
`My-report-1.pdf`). A PNG, JPEG, GIF or WebP, told by its first bytes, gets the
extension its content has (`photo.HEIC` that is a JPEG is `photo.jpg`), so
agents read it as an image; `mime` in the answer is then that type, otherwise
the request's, otherwise `application/octet-stream`.

The folders are readable by this user only (0700) and so is each file (0600),
never executable. Every folder on the way below the cache folder (`iii`,
`tmux`, `uploads`) is made one at a time and has to be a real folder of this
user that no other user can write to, never a symbolic link; a folder of ours
that is wider is narrowed. A file is written whole to a temporary file and
then linked under its name, so a kill or a full disk never leaves a cut-short
file there. Uploads older than 7 days are removed when the worker starts and
on each upload, then the oldest while all of them add up to more than 256 MiB;
nothing but folders of that name pattern is touched. They are not removed
right away because Codex reads a file only when the message it is attached to
is sent.

## skills

This version ships 1 skill file for agents, also browsable on the worker page:

- [`SKILL.md`](https://iii.dev/registry/workers/tmux?tab=skills&skill=SKILL.md&version=0.2.11)

### SKILL.md

# tmux

The tmux worker drives the `tmux` binary on the host and reads the same tmux
server the person uses in their terminal. It reports every session, window
and pane with the foreground command, working directory and title, and adds
what tmux itself does not know: the agent CLI running in a pane (matched in
the pane's process tree) with a working / waiting / idle state read from the
pane's last lines, the `iii compose` daemon running in a pane with its
engine's WebSocket port and its workers' ports, and every TCP port this
user's processes listen on, each traced back to the pane that started it.

It also reads how much of their weekly and 5-hour allowance Claude Code and
Codex have used, and keeps several Claude Code accounts, each a config folder
of its own (`CLAUDE_CONFIG_DIR`); `default` is `~/.claude`. The global
account is the one plain `claude` gets in a new tmux window (tmux's global
environment). A Claude Code pane follows the global account, is pinned to
one, or was started by hand (`manual`); `sessions::list` says which, per pane,
under `claude`.

Changes are tmux's own semantics. Selecting a window switches every client
attached to that session, the person's terminal included. Creating a window
makes it current unless `select: false` is passed. Killing a session or
window kills the programs in it. The Console page's terminal is a real tmux
client that only the Console drives.

## When to Use

- A person asks which Claude Code or Codex sessions are running, which of
  them is busy, or which one is waiting for an answer or an approval.
- A person asks whether `iii compose` is up, on which port the engine
  listens, or which ports the http, ade or other workers use.
- A person asks what is listening on a port, or which tmux window started a
  server.
- A person wants a new tmux session or window, optionally running a command
  in a given directory, or wants one renamed, moved to another session or
  closed.
- A person asks how much Claude Code or Codex usage is left this week, when
  it resets, or which account has the most room.
- A person wants Claude Code started on a given account, a running Claude
  Code moved to another account, or another account made global.

## Boundaries

- Read functions (`status`, `sessions::list`, `ports::list`,
  `install::status`, `usage::read`, `accounts::list`) are allowed by default. Creating, renaming, selecting,
  moving, splitting, respawning and killing change the person's tmux and are
  approval-gated. Killing a session, window or pane, and `panes::respawn` with
  `kill: true`, end whatever runs there, so name what will stop before asking.
  Moving a session's last window closes that session, and the person's
  terminals attached to it end, so say so too. `panes::select` is
  approval-gated too: a zoom shows on every client looking at that window.
- `panes::capture` returns whatever is on a pane's screen, which can include
  anything the person typed or a program printed; it needs approval and its
  text should not be repeated beyond what the question needs.
- `subagents::transcript` returns a sub-agent's conversation, tool calls and
  their output; it needs approval for the same reason.
- `usage::read` and `accounts::list` carry each account's email and
  organization but never a token. Everything
  else under `accounts::` and `panes::account` is approval-gated: a move ends
  Claude Code in that pane (SIGTERM) and starts it again on the other account,
  resuming its conversation, so name the panes that will restart; `global`
  moves every idle pane that follows the global account unless
  `move: new_only`. `rules` with `mode: switch` lets the worker change the
  global account by itself later. `remove` with `delete_files` deletes that
  account's folder, its sign-in included. `login_start` gives the person a
  sign-in link and `login_code` types the code they copied from it; never
  sign in for them, never ask for or repeat a code, and leave `browser` at
  `none` unless the person sits at the worker's computer.
- Starting Claude Code with `claude.skip_permissions: true` lets it run
  commands and change or delete files without asking. Only do it when the
  person asks for it, and say so before asking for approval.
- The worker reads Claude Code's sign-in only to ask its usage; it never
  refreshes, prints or returns a token.
- The worker never types into panes, except to move Claude Code started by
  hand in a shell: once that shell has the terminal back, it types the
  command that starts it on the other account into it (nothing otherwise).
  A move only goes to a signed-in account. `tmux::terminal::*` is the Console
  page's own terminal: it is denied to agents and cannot be observed
  (`NOT_OBSERVABLE`), since its calls carry the terminal's access key and
  what the person types. Its `upload` only writes a file the person pastes
  to a folder of its own under their cache folder (`~/.cache/iii/tmux/uploads`
  or `~/Library/Caches/iii/tmux/uploads`, kept 7 days) and answers the path;
  the page pastes that path, the worker types nothing.
- Agent state is a reading of the screen: `waiting` means a prompt that needs
  the person is visible, not that the agent's process is blocked. Patterns
  live in the worker configuration and can be tuned per agent.
- Ports are TCP listeners of this user's processes only, and tmux locations
  only exist for processes started inside tmux.
- tmux is Unix-only; on a host without tmux, `status` reports
  `available: false` and the lists come back empty. `installable: true` there
  means `install` can try.
- `install` puts the tmux program on the computer and can run the system's
  package manager as root, so it needs approval; say so before asking. It never
  waits for a password: without root or passwordless sudo it uses tmux's
  official build in `~/.local/bin`. It runs in the background, and it never
  talks to the person's tmux server. Only install tmux when the person asks.

## Functions

- `tmux::status` — whether tmux is installed, its version and path, and whether a server is running.
- `tmux::sessions::list` — every session → window → pane with command, cwd, title, size, agent state and session title, compose daemon and ports.
- `tmux::sessions::create` — start a detached session with an optional name, directory, first window name and command; `remain_on_exit: true` keeps its pane, dead, once the command ends.
- `tmux::sessions::rename` / `tmux::sessions::kill` — rename or kill a session by id (`$5`) or exact name.
- `tmux::windows::create` — add a window to a session with an optional name, directory, command and `select`; `remain_on_exit: true` keeps its pane once the command ends.
- `tmux::windows::select` — make a window current in its session (every attached client follows).
- `tmux::windows::rename` / `tmux::windows::kill` — rename or kill a window by id (`@3`) or index.
- `tmux::windows::move` — move a window to another session (after its last window) or next to one of its windows (`before` / `after`, tmux 3.2 or later, which also reorder it inside its own session); it keeps its id and programs, and moving a session's last window closes that session (`source_session_closed`).
- `tmux::panes::select` — make a pane (`%5`) active; `zoom: true` zooms the window on it, `zoom: false` unzooms, no `zoom` keeps the window's zoom; it never toggles, and a one-pane window can't zoom (every client of that window follows).
- `tmux::panes::split` — split a pane `right` or `below`, in its current directory unless `cwd`, with the default shell unless `command`, active unless `select: false`; `remain_on_exit: true` keeps it once its program ends.
- `tmux::panes::kill` — kill a pane and its program; `window_closed` / `session_closed` say when that closed its window and session.
- `tmux::panes::respawn` — start a pane's program again (its own command unless `command`); a running one needs `kill: true`, a dead one (`remain_on_exit`) doesn't.
- `tmux::panes::capture` — a pane's visible screen with colour escapes, its size, cursor and alternate-screen flag.
- `tmux::subagents::transcript` — what one sub-agent of a pane's Claude Code or Codex has done (`pane`, `subagent` from `agent.subagents[].id`): its task, messages, reasoning, tool calls and results, oldest first.
- `tmux::ports::list` — listening TCP ports with process, iii role, worker, compose namespace and pane, plus each `iii compose` stack.
- `tmux::install` — install the tmux program on this computer in the background (package manager, else tmux's official build); answers at once, and starting during a run joins it.
- `tmux::usage::read` — Claude Code's accounts with each one's 5-hour window, week and per-model weeks (used %, reset time), Codex's plan, windows and credits, the global account, the rules and any suggestion; `refresh: true` reads again now (at most once a minute per account).
- `tmux::accounts::list` — the Claude Code accounts (name, colour, folder, email, plan, signed in, panes running on it, usage), the global one, the rules, the suggestion and the latest switch.
- `tmux::accounts::add` / `update` / `remove` — add an account (`name`, `color`, `shared` groups linked from `~/.claude`), rename, recolour or change what it shares, take it off the list (`delete_files` deletes its folder; never `default` or the global one).
- `tmux::accounts::login_start` / `login_code` / `login_cancel` — sign an account in: `login_start` runs `claude auth login` for it in a hidden terminal and answers the link (`url`) the person opens; `login_code` types the code the page showed them (`{state: "done", account}`, or `invalid_code`, `rejected`, `expired`, `gone`, `failed`); `browser: host` opens the worker computer's own browser, which signs in with no code. Sign-ins under way are in `accounts::list` as `logins`; while one runs (until its Claude Code is gone), `global` refuses to switch the accounts it involves (`signing_in`) and `remove` keeps the account's folder.
- `tmux::accounts::global` — make an account global; `move`: `idle_now_working_after` (default) or `new_only`. Answers the panes `moved`, `after_turn` and `stayed`.
- `tmux::panes::account` — `global` makes a pane follow the global account, an account id pins it; Claude Code moves there now when idle, after its turn otherwise (`after_turn`); the account it runs on cancels a waiting move.
- `tmux::accounts::move_idle` — move the idle Claude Code panes of account `from` to `to`, pinned there.
- `tmux::accounts::rules` / `tmux::accounts::dismiss` — what to do when the global account runs low (`off`, `suggest`, `switch`; threshold, order, switch back after the reset); "Not now" on a suggestion.
- `tmux::windows::create` / `tmux::sessions::create` with `claude: { account, skip_permissions }` instead of `command` — start Claude Code on `global` or an account; the answer's `runs` is the exact command.
- `tmux::install::status` — where that install is: `idle`, `running` with its step and words, `succeeded` with path and version, or `failed` with one sentence and the log.

## Reacting to tmux

Observe `tmux::on-changed` instead of polling `sessions::list` when something
must react to tmux: an agent that finishes a turn (`working` → `idle`), one
that starts waiting for the person, a compose stack that comes up, a session
that appears or goes away. Each observer receives the full overview
(`sessions` and `ports`, the same shapes the two list functions return) once
when it is added and then only when something changed; the worker polls tmux
only while the function is observed. It takes no args. Overviews can arrive
out of order, so keep the one with the highest `sessions.generated_at_ms`.

Register a handler, then observe the function with it:

```ts
iii.registerFunction('my-worker::on-tmux', async ({ output: { sessions, ports } }) => {
  // compare agent states with the previous overview
})
iii.observe({ function_id: 'tmux::on-changed', capture: ['output'] }, 'my-worker::on-tmux')
```

## api reference

```json
{
  "functions": [
    {
      "description": "Add a Claude Code account: a config folder of its own (CLAUDE_CONFIG_DIR) under the accounts folder, sharing with ~/.claude what `shared` names (settings, extensions, plugins, conversations; all of them by default) through links. It starts signed out: tmux::accounts::login_start signs it in.",
      "metadata": {},
      "name": "tmux::accounts::add",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "color": {
            "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
            "type": "string"
          },
          "name": {
            "description": "What people call it, e.g. `Personal`; its id is made from it.",
            "type": "string"
          },
          "shared": {
            "default": null,
            "description": "What it shares with ~/.claude: `settings` (settings.json, CLAUDE.md, keybindings.json), `extensions` (skills, agents, commands, output styles), `plugins` (plugins, and a copy of the MCP servers), `conversations` (projects, history, todos, plans). Default: all four.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          }
        },
        "required": [
          "color",
          "name"
        ],
        "title": "AddAccountInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          }
        },
        "properties": {
          "account": {
            "$ref": "#/definitions/ClaudeAccount"
          }
        },
        "required": [
          "account"
        ],
        "title": "AccountOutput",
        "type": "object"
      }
    },
    {
      "description": "\"Not now\" on a suggestion to switch the global account: no suggestion from that account for that reason until its window resets or it runs lower (week 80 % → 90 % → 5-hour window full → week limit).",
      "metadata": {},
      "name": "tmux::accounts::dismiss",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "suggestion": {
            "description": "The suggestion's `id`.",
            "type": "string"
          }
        },
        "required": [
          "suggestion"
        ],
        "title": "DismissInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Nothing to return.",
        "title": "EmptyOutput",
        "type": "object"
      }
    },
    {
      "description": "Make a Claude Code account the global one (it must be signed in), like /login: its sign-in moves into ~/.claude and the old global account's goes to that account's folder. Every Claude Code on ~/.claude that isn't pinned, started by the worker or by hand, uses the new account with its next message, without a restart (`following`; within `switch_delay_s` seconds on macOS). Windows pinned to the new account are restarted on ~/.claude and windows pinned to the old one on its folder, resuming their conversations (`restarted`; working ones after their turn: `after_turn`). While a window pinned to the new account is in a turn, the switch waits (`state: waiting`, `waiting_for`, the snapshot's `pending_global`) and the worker finishes it once they are idle (a failure that may pass is tried again; one that can't calls it off, and the panes it waited for say why in `move_error`); another switch replaces it, switching to the current global account cancels it. A window pinned to the old account that can't be moved stays on ~/.claude and follows the new account from then on (counted in `following`, with a `move_error`). Errors are one JSON object `{code, message, blocked_by?}` with `code` `not_signed_in`, `busy` (Claude Code is renewing its sign-in), `blocked` (a Claude Code on that account's folder can't be restarted: `blocked_by`), `owner_check_on`, `signing_in` (a sign-in from tmux::accounts::login_start runs on ~/.claude or on either account's folder: finish or cancel it first; the rules and a waiting switch go on after it) or `failed` (anything else).",
      "metadata": {},
      "name": "tmux::accounts::global",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "description": "Account id.",
            "type": "string"
          }
        },
        "required": [
          "account"
        ],
        "title": "GlobalInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "GlobalState": {
            "description": "`switched` (the account is global now) or `waiting` (for `waiting_for`).",
            "enum": [
              "switched",
              "waiting"
            ],
            "type": "string"
          }
        },
        "properties": {
          "after_turn": {
            "description": "Panes pinned to the old account that restart on its folder once their turn ends.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "following": {
            "description": "Claude Code panes on ~/.claude that aren't pinned: they use the new account with their next message.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "global": {
            "description": "The global account now (the old one while the switch waits).",
            "type": "string"
          },
          "restarted": {
            "description": "Pinned panes restarted now (the new account's on ~/.claude, the old one's on its folder).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "state": {
            "$ref": "#/definitions/GlobalState"
          },
          "waiting_for": {
            "description": "Panes on the new account's folder the switch waits for.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "after_turn",
          "following",
          "global",
          "restarted",
          "state",
          "waiting_for"
        ],
        "title": "GlobalOutput",
        "type": "object"
      }
    },
    {
      "description": "The Claude Code accounts on this computer: each one's name, colour, config folder, email, plan, whether it is signed in, the Claude Code panes using it and its latest usage reading; which one is global (the sign-in of ~/.claude, what every Claude Code that isn't pinned uses, plain `claude` included); a switch waiting for windows to finish their turn (`pending_global`), how long a session may take to notice a switch (`switch_delay_s`), the rules for when the global account runs low, any suggestion and the latest switch. Without `accounts.json` there is one account, `default`.",
      "metadata": {},
      "name": "tmux::accounts::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountSwitch": {
            "description": "The latest change of the global account.",
            "properties": {
              "after_turn": {
                "description": "Panes pinned to the old global account that restart on its folder when their turn ends.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "at_ms": {
                "description": "When it happened.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "auto": {
                "description": "The worker switched by itself (rules mode `switch`).",
                "type": "boolean"
              },
              "back_at_ms": {
                "description": "With `back_after_reset`: when `from`'s window resets and the worker switches back.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "following": {
                "default": 0,
                "description": "Claude Code panes on the slot that switched with it, on their next message.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account before.",
                "type": "string"
              },
              "reason": {
                "default": null,
                "description": "`week_80`, `week_90`, `limit`, `five_hour` or `back` for an automatic switch; `login` (someone signed in to a known account with `/login`), `login_new` (to a new one, added then), `upgrade` (the worker took the slot's sign-in for global when it was updated); null when someone switched.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "restarted": {
                "default": [],
                "description": "Pinned panes restarted: the new global account's (now on the slot) and the old one's (now on its folder).",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "to": {
                "description": "The global account after.",
                "type": "string"
              }
            },
            "required": [
              "after_turn",
              "at_ms",
              "auto",
              "from",
              "to"
            ],
            "type": "object"
          },
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeLogin": {
            "description": "A sign-in of a Claude Code account from the app (claude-login-ui).",
            "properties": {
              "account": {
                "description": "The account signing in.",
                "type": "string"
              },
              "browser": {
                "$ref": "#/definitions/LoginBrowser"
              },
              "email": {
                "description": "The email the sign-in page is filled with (the account's).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/LoginError"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "With `failed` and `expired`: why."
              },
              "expires_at_ms": {
                "description": "When the link stops working and Claude Code is stopped.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "login_id": {
                "description": "Pass it to `tmux::accounts::login_code` and `login_cancel`.",
                "type": "string"
              },
              "state": {
                "$ref": "#/definitions/LoginState"
              },
              "url": {
                "description": "The sign-in page to open on any device: it shows the code to paste.",
                "type": "string"
              }
            },
            "required": [
              "account",
              "browser",
              "expires_at_ms",
              "login_id",
              "state",
              "url"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          },
          "LoginError": {
            "description": "Why a sign-in failed, as `tmux::accounts::login_code` answers it.",
            "properties": {
              "code": {
                "description": "`rejected` (Anthropic didn't accept the code; Claude Code ended), `expired`, `gone` or `failed`.",
                "type": "string"
              },
              "message": {
                "description": "One sentence.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "LoginState": {
            "description": "Where a sign-in is.",
            "oneOf": [
              {
                "description": "Claude Code shows the link and waits for the code.",
                "enum": [
                  "waiting_code"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code is checking a code with Anthropic.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Signed in.",
                "enum": [
                  "done"
                ],
                "type": "string"
              },
              {
                "description": "It ended without a sign-in (`error` says why).",
                "enum": [
                  "failed"
                ],
                "type": "string"
              },
              {
                "description": "The link's 10 minutes ran out; Claude Code was stopped.",
                "enum": [
                  "expired"
                ],
                "type": "string"
              }
            ]
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          },
          "PendingGlobal": {
            "description": "A switch of the global account waiting for windows to finish their turn (agent-accounts G4).",
            "properties": {
              "account": {
                "description": "The account becoming global.",
                "type": "string"
              },
              "at_ms": {
                "description": "When it was asked for.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "by": {
                "description": "`person` or `rule`.",
                "type": "string"
              },
              "waiting_for": {
                "description": "The Claude Code panes on its folder still working or waiting.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "account",
              "at_ms",
              "by",
              "waiting_for"
            ],
            "type": "object"
          },
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "Suggestion": {
            "description": "Another account suggested for global.",
            "properties": {
              "at_ms": {
                "description": "When the reason was first seen.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "following": {
                "description": "Claude Code panes on the slot that are not pinned: they switch with the global account.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account.",
                "type": "string"
              },
              "id": {
                "description": "Pass it to `tmux::accounts::dismiss`.",
                "type": "string"
              },
              "reason": {
                "description": "`week_80`, `week_90`, `limit` or `five_hour`.",
                "type": "string"
              },
              "to": {
                "description": "The account suggested.",
                "type": "string"
              }
            },
            "required": [
              "at_ms",
              "following",
              "from",
              "id",
              "reason",
              "to"
            ],
            "type": "object"
          },
          "SwitchRules": {
            "description": "The rules for the global account (agent-accounts D14).",
            "properties": {
              "at": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Threshold"
                  }
                ],
                "default": "week_90",
                "description": "`week_80`, `week_90` or `limit`."
              },
              "back_after_reset": {
                "default": false,
                "description": "After switching away by itself, switch back once that account's window resets.",
                "type": "boolean"
              },
              "five_hour": {
                "default": false,
                "description": "Also act when the 5-hour window reaches 100 %.",
                "type": "boolean"
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/RulesMode"
                  }
                ],
                "default": "suggest",
                "description": "`off`, `suggest` or `switch`."
              },
              "order": {
                "default": [],
                "description": "Accounts to try first, in order; then the one with most room this week.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "Claude Code's accounts as the worker sees them.",
        "properties": {
          "accounts": {
            "description": "The default account first, then the others in the order they were added.",
            "items": {
              "$ref": "#/definitions/ClaudeAccount"
            },
            "type": "array"
          },
          "available": {
            "description": "A `claude` binary is on PATH or `~/.claude` exists.",
            "type": "boolean"
          },
          "global": {
            "description": "Id of the global account: the sign-in of the slot (`~/.claude`), what plain `claude` uses anywhere.",
            "type": "string"
          },
          "last_switch": {
            "anyOf": [
              {
                "$ref": "#/definitions/AccountSwitch"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "The latest change of the global account."
          },
          "logins": {
            "default": [],
            "description": "Sign-ins under way (`tmux::accounts::login_start`), and those that ended in the last minute, oldest first.",
            "items": {
              "$ref": "#/definitions/ClaudeLogin"
            },
            "type": "array"
          },
          "managed": {
            "description": "The accounts registry exists (an account was added or a setting saved).",
            "type": "boolean"
          },
          "pending_global": {
            "anyOf": [
              {
                "$ref": "#/definitions/PendingGlobal"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "A switch of the global account that waits for windows on the new account's folder to finish their turn."
          },
          "rules": {
            "allOf": [
              {
                "$ref": "#/definitions/SwitchRules"
              }
            ],
            "description": "The rules for the global account."
          },
          "runs_as_root": {
            "description": "The worker runs as root, where Claude Code refuses `--dangerously-skip-permissions`.",
            "type": "boolean"
          },
          "suggestion": {
            "anyOf": [
              {
                "$ref": "#/definitions/Suggestion"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Another account suggested for global, while the global one is low."
          },
          "switch_delay_s": {
            "default": 0,
            "description": "How long a running Claude Code may take to notice a switch, in seconds: 0 on Linux (its next message), 30 on macOS (the Keychain).",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "accounts",
          "available",
          "global",
          "managed",
          "rules",
          "runs_as_root"
        ],
        "title": "ClaudeSnapshot",
        "type": "object"
      }
    },
    {
      "description": "Stop a sign-in under way (tmux::accounts::login_start): Claude Code is stopped and the sign-in leaves the feed's `logins`; a tmux::accounts::login_code waiting on it answers `gone`. Nothing happens for one that is over or unknown.",
      "metadata": {},
      "name": "tmux::accounts::login_cancel",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "login_id": {
            "description": "From tmux::accounts::login_start.",
            "type": "string"
          }
        },
        "required": [
          "login_id"
        ],
        "title": "LoginCancelInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Nothing to return.",
        "title": "EmptyOutput",
        "type": "object"
      }
    },
    {
      "description": "Pass the code from the sign-in page to a sign-in under way (tmux::accounts::login_start): its whitespace is taken out, and a code without Claude Code's shape (`<code>#<state>`) is refused (`invalid_code`) without reaching Claude Code. Then waits up to a minute for Claude Code to check it with Anthropic and answers `{state: \"done\", account}` (the account signed in; on ~/.claude the global one, which may be another account than asked for when the person signed in to it), or an error, one JSON object `{code, message}`: `invalid_code` (the sign-in still waits), `rejected` (Anthropic didn't accept the code; Claude Code ended, so a new link is needed: a code only works with the link it came from), `expired` (the 10 minutes ran out, also for a code typed after them), `gone` (no such sign-in, cancelled, replaced, its account removed, or over) or `failed` (anything else). A second call while a code is checked waits for the same outcome; a call after the sign-in ended answers how it ended while it is listed, then `gone`. `done` means a new sign-in is where it belongs (the account's folder, or ~/.claude taken in as the global account); Claude Code saying it signed in while the one there is still the one from before is `failed`. The code is never logged or kept.",
      "metadata": {},
      "name": "tmux::accounts::login_code",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "code": {
            "description": "The code the sign-in page shows (`<code>#<state>`), as copied: whitespace is taken out.",
            "type": "string"
          },
          "login_id": {
            "description": "From tmux::accounts::login_start.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "login_id"
        ],
        "title": "LoginCodeInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "LoginDone": {
            "description": "Always `done`: anything else is an error.",
            "enum": [
              "done"
            ],
            "type": "string"
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          }
        },
        "properties": {
          "account": {
            "allOf": [
              {
                "$ref": "#/definitions/ClaudeAccount"
              }
            ],
            "description": "The account signed in, as tmux::accounts::list shows it."
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/definitions/LoginDone"
              }
            ],
            "description": "`done`."
          }
        },
        "required": [
          "account",
          "state"
        ],
        "title": "LoginCodeOutput",
        "type": "object"
      }
    },
    {
      "description": "Start signing a Claude Code account in: runs `claude auth login` (with `--email` when the account has one) on the account's folder, or on ~/.claude for the global account, in a hidden terminal (no tmux window), and answers with the sign-in link (`url`) once Claude Code printed it. The page it opens shows a code to pass to tmux::accounts::login_code. `browser`: `none` (the default) keeps Claude Code from opening a browser on this computer; `host` lets it, for an app running on this computer: coming back from that page finishes the sign-in with no code (`browser_url` is the link it opened; only this answer carries it, never the feed or tmux::accounts::list). `host` fails when nothing here can open a browser (no BROWSER, and no xdg-open with a display). The link works for 10 minutes (`expires_at_ms`); then Claude Code is stopped (a code being checked, or with `host` a return from the page, gets 15 seconds more to finish). A new start for the same account cancels the one under way, and one still starting answers `gone`. While a sign-in runs (or its Claude Code is still there), switching the global account away from or to the accounts it involves is refused (`signing_in`); while a switch left half-way is being settled, no sign-in starts on ~/.claude or on its two accounts. The feed's `logins` shows every sign-in under way (`waiting_code`, `checking`) and those that ended in the last minute (`done`, `failed`, `expired`). Signing in to another account on ~/.claude makes that one global (added when it is new). On macOS, Claude Code keeps the sign-in in the login Keychain, which only a worker running in the user's GUI session (a LaunchAgent, not an SSH or background shell) can write. Errors are one JSON object `{code, message}`: `failed`, or `gone` when a later start for the account replaced this one (or the account was removed, or the worker is stopping).",
      "metadata": {},
      "name": "tmux::accounts::login_start",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "account": {
            "description": "Account id (`default` for the one `~/.claude` had at first).",
            "type": "string"
          },
          "browser": {
            "anyOf": [
              {
                "$ref": "#/definitions/LoginBrowser"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "`none` (the default): no browser opens on this computer; `host`: Claude Code opens it here."
          }
        },
        "required": [
          "account"
        ],
        "title": "LoginStartInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "account": {
            "description": "The account signing in.",
            "type": "string"
          },
          "browser": {
            "allOf": [
              {
                "$ref": "#/definitions/LoginBrowser"
              }
            ],
            "description": "`none` or `host`."
          },
          "browser_url": {
            "description": "With `browser: host`, the link Claude Code opened in this computer's browser, whose return finishes the sign-in with no code (it works on this computer only).",
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "description": "The email the page is filled with (the account's), when it has one.",
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at_ms": {
            "description": "When the link stops working and Claude Code is stopped (10 minutes).",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "login_id": {
            "description": "Pass it to tmux::accounts::login_code and login_cancel.",
            "type": "string"
          },
          "url": {
            "description": "The sign-in page, for any device: it shows the code to paste.",
            "type": "string"
          }
        },
        "required": [
          "account",
          "browser",
          "expires_at_ms",
          "login_id",
          "url"
        ],
        "title": "LoginStartOutput",
        "type": "object"
      }
    },
    {
      "description": "Move the idle Claude Code panes using account `from` (on its folder, or on ~/.claude when it is the global one) to account `to` and pin them there, resuming their conversations: those that follow the global account, are pinned to `from` or were started by hand (never those pinned elsewhere, nor working or waiting ones).",
      "metadata": {},
      "name": "tmux::accounts::move_idle",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "from": {
            "description": "Account id they run on.",
            "type": "string"
          },
          "to": {
            "description": "Account id to move them to.",
            "type": "string"
          }
        },
        "required": [
          "from",
          "to"
        ],
        "title": "MoveIdleInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "moved": {
            "description": "Panes moved.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "moved"
        ],
        "title": "MoveIdleOutput",
        "type": "object"
      }
    },
    {
      "description": "Take a Claude Code account off the list. Not the default account, the global one, nor one a switch waits to make global. Claude Code panes on its folder keep running. A sign-in of it from the app stops. With delete_files, its folder (sign-in, history of its own) is deleted too, never what its links point at; refused while Claude Code runs on it (a pane, or a sign-in until its Claude Code is gone).",
      "metadata": {},
      "name": "tmux::accounts::remove",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "description": "Account id.",
            "type": "string"
          },
          "delete_files": {
            "default": false,
            "description": "Delete its folder too (default false: the folder stays where it was).",
            "type": "boolean"
          }
        },
        "required": [
          "account"
        ],
        "title": "RemoveAccountInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Nothing to return.",
        "title": "EmptyOutput",
        "type": "object"
      }
    },
    {
      "description": "Change the rules for when the global Claude Code account runs low (what is left out stays): mode `off`, `suggest` (a suggestion in the feed) or `switch` (the worker makes another account global by itself, even with the app closed, and leaves `last_switch`; never one with Claude Code working on its folder); `at` `week_80`, `week_90` or `limit`; `five_hour` also acts when the 5-hour window is full; `back_after_reset` switches back once the old account's window resets; `order` the accounts to try first, then the one with most room this week.",
      "metadata": {},
      "name": "tmux::accounts::rules",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "The rules to change; what is left out stays.",
        "properties": {
          "at": {
            "anyOf": [
              {
                "$ref": "#/definitions/Threshold"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "`week_80`, `week_90` or `limit`."
          },
          "back_after_reset": {
            "default": null,
            "description": "Switch back once the old account's window resets.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "five_hour": {
            "default": null,
            "description": "Also act when the 5-hour window is full.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "mode": {
            "anyOf": [
              {
                "$ref": "#/definitions/RulesMode"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "`off`, `suggest` or `switch`."
          },
          "order": {
            "default": null,
            "description": "Account ids to try first, in order.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          }
        },
        "title": "RulesInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "SwitchRules": {
            "description": "The rules for the global account (agent-accounts D14).",
            "properties": {
              "at": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Threshold"
                  }
                ],
                "default": "week_90",
                "description": "`week_80`, `week_90` or `limit`."
              },
              "back_after_reset": {
                "default": false,
                "description": "After switching away by itself, switch back once that account's window resets.",
                "type": "boolean"
              },
              "five_hour": {
                "default": false,
                "description": "Also act when the 5-hour window reaches 100 %.",
                "type": "boolean"
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/RulesMode"
                  }
                ],
                "default": "suggest",
                "description": "`off`, `suggest` or `switch`."
              },
              "order": {
                "default": [],
                "description": "Accounts to try first, in order; then the one with most room this week.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "rules": {
            "$ref": "#/definitions/SwitchRules"
          }
        },
        "required": [
          "rules"
        ],
        "title": "RulesOutput",
        "type": "object"
      }
    },
    {
      "description": "Rename or recolour a Claude Code account, or change what it shares with ~/.claude (links are made for groups added and the worker's links removed for groups dropped; files of the account's own are never touched).",
      "metadata": {},
      "name": "tmux::accounts::update",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "description": "Account id.",
            "type": "string"
          },
          "color": {
            "default": null,
            "description": "New colour: `blue`, `green`, `violet`, `orange` or `pink`.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "default": null,
            "description": "New name.",
            "type": [
              "string",
              "null"
            ]
          },
          "shared": {
            "default": null,
            "description": "What it shares from now on (see tmux::accounts::add). Not for `default`.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          }
        },
        "required": [
          "account"
        ],
        "title": "UpdateAccountInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          }
        },
        "properties": {
          "account": {
            "$ref": "#/definitions/ClaudeAccount"
          }
        },
        "required": [
          "account"
        ],
        "title": "AccountOutput",
        "type": "object"
      }
    },
    {
      "description": "Returns this worker instance's effective configuration entry ID, without its value.",
      "metadata": {
        "internal": true
      },
      "name": "tmux::configuration-id",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Empty user request. Ignore transport metadata such as `_caller_worker_id`, which the engine adds to routed calls; no payload field selects the entry.",
        "title": "ConfigurationIdentityRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Only the entry ID is exposed; configuration values and secrets stay in the service.",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "title": "ConfigurationIdentityResponse",
        "type": "object"
      }
    },
    {
      "description": "Install the tmux program on this computer, in the background, and answer at once: the system's package manager when this user may run it without a password (Homebrew, MacPorts, apt, dnf, pacman, zypper, apk), otherwise tmux's official build into ~/.local/bin. Starting during a run joins it. Poll tmux::install::status.",
      "metadata": {},
      "name": "tmux::install",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "InstallMethod": {
            "oneOf": [
              {
                "description": "`apt-get`.",
                "enum": [
                  "apt"
                ],
                "type": "string"
              },
              {
                "description": "`dnf`.",
                "enum": [
                  "dnf"
                ],
                "type": "string"
              },
              {
                "description": "`pacman`.",
                "enum": [
                  "pacman"
                ],
                "type": "string"
              },
              {
                "description": "`zypper`.",
                "enum": [
                  "zypper"
                ],
                "type": "string"
              },
              {
                "description": "`apk`.",
                "enum": [
                  "apk"
                ],
                "type": "string"
              },
              {
                "description": "Homebrew's `brew`.",
                "enum": [
                  "homebrew"
                ],
                "type": "string"
              },
              {
                "description": "MacPorts' `port`.",
                "enum": [
                  "macports"
                ],
                "type": "string"
              },
              {
                "description": "The tmux project's official build, into `~/.local/bin`.",
                "enum": [
                  "prebuilt"
                ],
                "type": "string"
              }
            ]
          },
          "InstallState": {
            "oneOf": [
              {
                "description": "No install ran since the worker started.",
                "enum": [
                  "idle"
                ],
                "type": "string"
              },
              {
                "description": "An install is going on.",
                "enum": [
                  "running"
                ],
                "type": "string"
              },
              {
                "description": "tmux is installed and resolves.",
                "enum": [
                  "succeeded"
                ],
                "type": "string"
              },
              {
                "description": "Every way to install it failed.",
                "enum": [
                  "failed"
                ],
                "type": "string"
              }
            ]
          },
          "InstallStep": {
            "oneOf": [
              {
                "description": "Looking at the computer.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Refreshing the package manager's list.",
                "enum": [
                  "updating"
                ],
                "type": "string"
              },
              {
                "description": "Fetching the official build.",
                "enum": [
                  "downloading"
                ],
                "type": "string"
              },
              {
                "description": "Comparing the download with its checksum.",
                "enum": [
                  "verifying"
                ],
                "type": "string"
              },
              {
                "description": "A package manager or the official build is putting tmux in place.",
                "enum": [
                  "installing"
                ],
                "type": "string"
              },
              {
                "description": "Checking that tmux resolves.",
                "enum": [
                  "finishing"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "Where an install is. `tmux::install` and `tmux::install::status` both answer this.",
        "properties": {
          "error": {
            "description": "Why it failed, one sentence for people.",
            "type": [
              "string",
              "null"
            ]
          },
          "hints": {
            "description": "True facts about the step, to alternate with the label.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "label": {
            "description": "What to show for that step, e.g. `Downloading tmux…`.",
            "type": [
              "string",
              "null"
            ]
          },
          "log": {
            "description": "Empty unless the state is `failed`: every command and its output.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "method": {
            "anyOf": [
              {
                "$ref": "#/definitions/InstallMethod"
              },
              {
                "type": "null"
              }
            ],
            "description": "The way being tried, or the one that worked. Null when tmux was already there."
          },
          "path": {
            "description": "Where tmux is, once it resolves.",
            "type": [
              "string",
              "null"
            ]
          },
          "progress": {
            "description": "0 to 1, while the step knows how far it is.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/definitions/InstallState"
              }
            ],
            "description": "`idle` also answers a worker that restarted mid-install."
          },
          "step": {
            "anyOf": [
              {
                "$ref": "#/definitions/InstallStep"
              },
              {
                "type": "null"
              }
            ],
            "description": "The step a running install is on."
          },
          "version": {
            "description": "Its version, once it resolves.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "hints",
          "log",
          "state"
        ],
        "title": "InstallStatus",
        "type": "object"
      }
    },
    {
      "description": "Where tmux::install is: idle (nothing ran since the worker started), running with its step, label and hints, succeeded with the path and version, or failed with one sentence and the log.",
      "metadata": {},
      "name": "tmux::install::status",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "InstallMethod": {
            "oneOf": [
              {
                "description": "`apt-get`.",
                "enum": [
                  "apt"
                ],
                "type": "string"
              },
              {
                "description": "`dnf`.",
                "enum": [
                  "dnf"
                ],
                "type": "string"
              },
              {
                "description": "`pacman`.",
                "enum": [
                  "pacman"
                ],
                "type": "string"
              },
              {
                "description": "`zypper`.",
                "enum": [
                  "zypper"
                ],
                "type": "string"
              },
              {
                "description": "`apk`.",
                "enum": [
                  "apk"
                ],
                "type": "string"
              },
              {
                "description": "Homebrew's `brew`.",
                "enum": [
                  "homebrew"
                ],
                "type": "string"
              },
              {
                "description": "MacPorts' `port`.",
                "enum": [
                  "macports"
                ],
                "type": "string"
              },
              {
                "description": "The tmux project's official build, into `~/.local/bin`.",
                "enum": [
                  "prebuilt"
                ],
                "type": "string"
              }
            ]
          },
          "InstallState": {
            "oneOf": [
              {
                "description": "No install ran since the worker started.",
                "enum": [
                  "idle"
                ],
                "type": "string"
              },
              {
                "description": "An install is going on.",
                "enum": [
                  "running"
                ],
                "type": "string"
              },
              {
                "description": "tmux is installed and resolves.",
                "enum": [
                  "succeeded"
                ],
                "type": "string"
              },
              {
                "description": "Every way to install it failed.",
                "enum": [
                  "failed"
                ],
                "type": "string"
              }
            ]
          },
          "InstallStep": {
            "oneOf": [
              {
                "description": "Looking at the computer.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Refreshing the package manager's list.",
                "enum": [
                  "updating"
                ],
                "type": "string"
              },
              {
                "description": "Fetching the official build.",
                "enum": [
                  "downloading"
                ],
                "type": "string"
              },
              {
                "description": "Comparing the download with its checksum.",
                "enum": [
                  "verifying"
                ],
                "type": "string"
              },
              {
                "description": "A package manager or the official build is putting tmux in place.",
                "enum": [
                  "installing"
                ],
                "type": "string"
              },
              {
                "description": "Checking that tmux resolves.",
                "enum": [
                  "finishing"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "Where an install is. `tmux::install` and `tmux::install::status` both answer this.",
        "properties": {
          "error": {
            "description": "Why it failed, one sentence for people.",
            "type": [
              "string",
              "null"
            ]
          },
          "hints": {
            "description": "True facts about the step, to alternate with the label.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "label": {
            "description": "What to show for that step, e.g. `Downloading tmux…`.",
            "type": [
              "string",
              "null"
            ]
          },
          "log": {
            "description": "Empty unless the state is `failed`: every command and its output.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "method": {
            "anyOf": [
              {
                "$ref": "#/definitions/InstallMethod"
              },
              {
                "type": "null"
              }
            ],
            "description": "The way being tried, or the one that worked. Null when tmux was already there."
          },
          "path": {
            "description": "Where tmux is, once it resolves.",
            "type": [
              "string",
              "null"
            ]
          },
          "progress": {
            "description": "0 to 1, while the step knows how far it is.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "state": {
            "allOf": [
              {
                "$ref": "#/definitions/InstallState"
              }
            ],
            "description": "`idle` also answers a worker that restarted mid-install."
          },
          "step": {
            "anyOf": [
              {
                "$ref": "#/definitions/InstallStep"
              },
              {
                "type": "null"
              }
            ],
            "description": "The step a running install is on."
          },
          "version": {
            "description": "Its version, once it resolves.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "hints",
          "log",
          "state"
        ],
        "title": "InstallStatus",
        "type": "object"
      }
    },
    {
      "description": "Live tmux overview: the full state (sessions, windows, panes with agent/compose/port status, compose stacks and listening ports), sent to each observer when it is added and called again whenever it changes. Takes no args.",
      "metadata": {},
      "name": "tmux::on-changed",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountSwitch": {
            "description": "The latest change of the global account.",
            "properties": {
              "after_turn": {
                "description": "Panes pinned to the old global account that restart on its folder when their turn ends.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "at_ms": {
                "description": "When it happened.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "auto": {
                "description": "The worker switched by itself (rules mode `switch`).",
                "type": "boolean"
              },
              "back_at_ms": {
                "description": "With `back_after_reset`: when `from`'s window resets and the worker switches back.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "following": {
                "default": 0,
                "description": "Claude Code panes on the slot that switched with it, on their next message.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account before.",
                "type": "string"
              },
              "reason": {
                "default": null,
                "description": "`week_80`, `week_90`, `limit`, `five_hour` or `back` for an automatic switch; `login` (someone signed in to a known account with `/login`), `login_new` (to a new one, added then), `upgrade` (the worker took the slot's sign-in for global when it was updated); null when someone switched.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "restarted": {
                "default": [],
                "description": "Pinned panes restarted: the new global account's (now on the slot) and the old one's (now on its folder).",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "to": {
                "description": "The global account after.",
                "type": "string"
              }
            },
            "required": [
              "after_turn",
              "at_ms",
              "auto",
              "from",
              "to"
            ],
            "type": "object"
          },
          "AddressFamily": {
            "enum": [
              "ipv4",
              "ipv6"
            ],
            "type": "string"
          },
          "AgentState": {
            "oneOf": [
              {
                "description": "The agent is running a turn.",
                "enum": [
                  "working"
                ],
                "type": "string"
              },
              {
                "description": "The agent shows a prompt that needs you.",
                "enum": [
                  "waiting"
                ],
                "type": "string"
              },
              {
                "description": "The agent waits for a new message.",
                "enum": [
                  "idle"
                ],
                "type": "string"
              }
            ]
          },
          "AgentStatus": {
            "properties": {
              "id": {
                "description": "Matcher id from the configuration, e.g. `claude`.",
                "type": "string"
              },
              "label": {
                "description": "Display name, e.g. `Claude Code`.",
                "type": "string"
              },
              "pid": {
                "description": "Pid of the agent process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "since_ms": {
                "description": "When the agent entered `state`.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "state": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AgentState"
                  }
                ],
                "description": "What the agent is doing."
              },
              "subagents": {
                "default": [],
                "description": "Sub-agents working right now, oldest first. Their work keeps `state` at `working` after the agent's own turn ended. Claude Code and Codex report them; other agents always list none.",
                "items": {
                  "$ref": "#/definitions/SubagentStatus"
                },
                "type": "array"
              },
              "title": {
                "default": null,
                "description": "The agent's session title: the pane title without the agent's status glyph (Claude Code's ✳ or spinner). Null when the pane only shows tmux's default title (the host name) or nothing.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "label",
              "pid",
              "since_ms",
              "state"
            ],
            "type": "object"
          },
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeLogin": {
            "description": "A sign-in of a Claude Code account from the app (claude-login-ui).",
            "properties": {
              "account": {
                "description": "The account signing in.",
                "type": "string"
              },
              "browser": {
                "$ref": "#/definitions/LoginBrowser"
              },
              "email": {
                "description": "The email the sign-in page is filled with (the account's).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/LoginError"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "With `failed` and `expired`: why."
              },
              "expires_at_ms": {
                "description": "When the link stops working and Claude Code is stopped.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "login_id": {
                "description": "Pass it to `tmux::accounts::login_code` and `login_cancel`.",
                "type": "string"
              },
              "state": {
                "$ref": "#/definitions/LoginState"
              },
              "url": {
                "description": "The sign-in page to open on any device: it shows the code to paste.",
                "type": "string"
              }
            },
            "required": [
              "account",
              "browser",
              "expires_at_ms",
              "login_id",
              "state",
              "url"
            ],
            "type": "object"
          },
          "ClaudeSnapshot": {
            "description": "Claude Code's accounts as the worker sees them.",
            "properties": {
              "accounts": {
                "description": "The default account first, then the others in the order they were added.",
                "items": {
                  "$ref": "#/definitions/ClaudeAccount"
                },
                "type": "array"
              },
              "available": {
                "description": "A `claude` binary is on PATH or `~/.claude` exists.",
                "type": "boolean"
              },
              "global": {
                "description": "Id of the global account: the sign-in of the slot (`~/.claude`), what plain `claude` uses anywhere.",
                "type": "string"
              },
              "last_switch": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AccountSwitch"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest change of the global account."
              },
              "logins": {
                "default": [],
                "description": "Sign-ins under way (`tmux::accounts::login_start`), and those that ended in the last minute, oldest first.",
                "items": {
                  "$ref": "#/definitions/ClaudeLogin"
                },
                "type": "array"
              },
              "managed": {
                "description": "The accounts registry exists (an account was added or a setting saved).",
                "type": "boolean"
              },
              "pending_global": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PendingGlobal"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "A switch of the global account that waits for windows on the new account's folder to finish their turn."
              },
              "rules": {
                "allOf": [
                  {
                    "$ref": "#/definitions/SwitchRules"
                  }
                ],
                "description": "The rules for the global account."
              },
              "runs_as_root": {
                "description": "The worker runs as root, where Claude Code refuses `--dangerously-skip-permissions`.",
                "type": "boolean"
              },
              "suggestion": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Suggestion"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Another account suggested for global, while the global one is low."
              },
              "switch_delay_s": {
                "default": 0,
                "description": "How long a running Claude Code may take to notice a switch, in seconds: 0 on Linux (its next message), 30 on macOS (the Keychain).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "accounts",
              "available",
              "global",
              "managed",
              "rules",
              "runs_as_root"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "CodexCredits": {
            "description": "Codex's credits.",
            "properties": {
              "balance": {
                "description": "The balance as Codex reports it, e.g. `62500.0000000000`.",
                "type": "string"
              },
              "unlimited": {
                "description": "Credits are unlimited.",
                "type": "boolean"
              }
            },
            "required": [
              "balance",
              "unlimited"
            ],
            "type": "object"
          },
          "CodexUsage": {
            "description": "Codex's usage, from the newest session it recorded (agent-accounts D13).",
            "properties": {
              "as_of_ms": {
                "description": "When Codex recorded it.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "credits": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/CodexCredits"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Credits, when the plan has them."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The 5-hour window, when the plan has one."
              },
              "plan": {
                "default": null,
                "description": "The ChatGPT plan, e.g. `pro`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ComposeEngine": {
            "properties": {
              "pid": {
                "description": "Engine pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the engine listens on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              },
              "ws_port": {
                "description": "The engine WebSocket port workers connect to.",
                "format": "uint16",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "ComposeRef": {
            "properties": {
              "namespace": {
                "description": "Compose daemon namespace.",
                "type": "string"
              },
              "pid": {
                "description": "Compose daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "namespace",
              "pid"
            ],
            "type": "object"
          },
          "ComposeStack": {
            "properties": {
              "compose_file": {
                "description": "Compose file the daemon serves, when known.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "engine": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeEngine"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The engine the daemon started, if it manages one."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the daemon runs in."
              },
              "namespace": {
                "description": "Daemon namespace (`iii:c:<namespace>`).",
                "type": "string"
              },
              "pid": {
                "description": "Daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "project_dir": {
                "description": "Daemon working directory.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "workers": {
                "description": "Workers the daemon started.",
                "items": {
                  "$ref": "#/definitions/ComposeWorker"
                },
                "type": "array"
              }
            },
            "required": [
              "namespace",
              "pid",
              "workers"
            ],
            "type": "object"
          },
          "ComposeWorker": {
            "properties": {
              "name": {
                "description": "Worker name.",
                "type": "string"
              },
              "pid": {
                "description": "Top-most pid of the worker's process tree.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the worker's processes listen on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            },
            "required": [
              "name",
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Follow": {
            "description": "How a pane's Claude Code account is chosen (agent-accounts G12).",
            "oneOf": [
              {
                "description": "Runs on the global slot (`~/.claude`) and is not pinned, started by the worker or by hand: it switches with the global account on its next message.",
                "enum": [
                  "global"
                ],
                "type": "string"
              },
              {
                "description": "Pinned to an account: on its folder, or on the slot while that account is global (it restarts on its folder when the global one changes).",
                "enum": [
                  "pinned"
                ],
                "type": "string"
              },
              {
                "description": "Started by hand on an account's folder (`CLAUDE_CONFIG_DIR` set): no mark.",
                "enum": [
                  "manual"
                ],
                "type": "string"
              }
            ]
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "Listener": {
            "description": "One TCP socket in LISTEN state.",
            "properties": {
              "address": {
                "description": "Bound address, e.g. `0.0.0.0` or `::1`.",
                "type": "string"
              },
              "compose": {
                "description": "Compose namespace the process belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "family": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AddressFamily"
                  }
                ],
                "description": "IPv4 or IPv6."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the process descends from."
              },
              "pid": {
                "description": "Owning process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "port": {
                "description": "Port number.",
                "format": "uint16",
                "minimum": 0,
                "type": "integer"
              },
              "process": {
                "description": "Owning process name.",
                "type": "string"
              },
              "role": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ListenerRole"
                  }
                ],
                "description": "What kind of process owns the socket."
              },
              "worker": {
                "description": "iii worker name, when known.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "address",
              "family",
              "pid",
              "port",
              "process",
              "role"
            ],
            "type": "object"
          },
          "ListenerRole": {
            "oneOf": [
              {
                "description": "An iii engine (its WebSocket and built-in listeners).",
                "enum": [
                  "engine"
                ],
                "type": "string"
              },
              {
                "description": "An iii worker.",
                "enum": [
                  "worker"
                ],
                "type": "string"
              },
              {
                "description": "An `iii compose` daemon.",
                "enum": [
                  "compose"
                ],
                "type": "string"
              },
              {
                "description": "Anything else.",
                "enum": [
                  "other"
                ],
                "type": "string"
              }
            ]
          },
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          },
          "LoginError": {
            "description": "Why a sign-in failed, as `tmux::accounts::login_code` answers it.",
            "properties": {
              "code": {
                "description": "`rejected` (Anthropic didn't accept the code; Claude Code ended), `expired`, `gone` or `failed`.",
                "type": "string"
              },
              "message": {
                "description": "One sentence.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "LoginState": {
            "description": "Where a sign-in is.",
            "oneOf": [
              {
                "description": "Claude Code shows the link and waits for the code.",
                "enum": [
                  "waiting_code"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code is checking a code with Anthropic.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Signed in.",
                "enum": [
                  "done"
                ],
                "type": "string"
              },
              {
                "description": "It ended without a sign-in (`error` says why).",
                "enum": [
                  "failed"
                ],
                "type": "string"
              },
              {
                "description": "The link's 10 minutes ran out; Claude Code was stopped.",
                "enum": [
                  "expired"
                ],
                "type": "string"
              }
            ]
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          },
          "Pane": {
            "properties": {
              "active": {
                "description": "The window's active pane.",
                "type": "boolean"
              },
              "agent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AgentStatus"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The agent CLI running in this pane, if any."
              },
              "claude": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneClaude"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The Claude Code account the pane runs on and how it follows the global one. Present when the pane runs Claude Code or carries an account mark; absent otherwise and from workers before 0.3."
              },
              "command": {
                "description": "Foreground process name.",
                "type": "string"
              },
              "compose": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The `iii compose` daemon running in this pane, if any."
              },
              "cwd": {
                "description": "Current directory.",
                "type": "string"
              },
              "dead": {
                "description": "The pane's process exited and the pane is kept.",
                "type": "boolean"
              },
              "height": {
                "description": "Height in rows.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Pane id, e.g. `%5`.",
                "type": "string"
              },
              "index": {
                "description": "Pane index inside the window.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "pid": {
                "description": "Pid of the process tmux started in the pane.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Listening sockets owned by processes started from this pane.",
                "items": {
                  "$ref": "#/definitions/Listener"
                },
                "type": "array"
              },
              "title": {
                "description": "Pane title set by the program.",
                "type": "string"
              },
              "width": {
                "description": "Width in columns.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "active",
              "command",
              "cwd",
              "dead",
              "height",
              "id",
              "index",
              "pid",
              "ports",
              "title",
              "width"
            ],
            "type": "object"
          },
          "PaneClaude": {
            "description": "The Claude Code account of one pane (agent-accounts D4, D5).",
            "properties": {
              "account": {
                "default": null,
                "description": "Id of the account the running Claude Code uses: the global account on the slot (`~/.claude`), else the account whose folder its `CLAUDE_CONFIG_DIR` names. Null when that folder is no registered account (see `config_dir`) or Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "config_dir": {
                "default": null,
                "description": "The config folder the running Claude Code uses, `~` for the home folder. Null when Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "follow": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Follow"
                  }
                ],
                "description": "`global`, `pinned` or `manual`."
              },
              "movable": {
                "description": "The worker can move this pane to another account.",
                "type": "boolean"
              },
              "move_error": {
                "description": "Why the last move of this pane (one that waited for its turn, or a switch of the global account) failed, in one sentence; cleared by the next account change of the pane.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "not_movable_reason": {
                "description": "Why it can't, in one sentence, when `movable` is false.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "pending": {
                "default": null,
                "description": "The account the pane moves to when its turn ends (`global`: the slot).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "default": null,
                "description": "Claude Code's session id, which a move resumes.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "skip_permissions": {
                "description": "Claude Code runs without permission prompts (`--dangerously-skip-permissions` or `--permission-mode bypassPermissions`).",
                "type": "boolean"
              }
            },
            "required": [
              "follow",
              "movable",
              "skip_permissions"
            ],
            "type": "object"
          },
          "PaneRef": {
            "description": "Where a process runs in tmux.",
            "properties": {
              "pane_id": {
                "description": "Pane id.",
                "type": "string"
              },
              "session": {
                "description": "Session name.",
                "type": "string"
              },
              "session_id": {
                "description": "Session id.",
                "type": "string"
              },
              "window_id": {
                "description": "Window id.",
                "type": "string"
              },
              "window_index": {
                "description": "Window index.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "pane_id",
              "session",
              "session_id",
              "window_id",
              "window_index"
            ],
            "type": "object"
          },
          "PendingGlobal": {
            "description": "A switch of the global account waiting for windows to finish their turn (agent-accounts G4).",
            "properties": {
              "account": {
                "description": "The account becoming global.",
                "type": "string"
              },
              "at_ms": {
                "description": "When it was asked for.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "by": {
                "description": "`person` or `rule`.",
                "type": "string"
              },
              "waiting_for": {
                "description": "The Claude Code panes on its folder still working or waiting.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "account",
              "at_ms",
              "by",
              "waiting_for"
            ],
            "type": "object"
          },
          "PortsSnapshot": {
            "description": "Listening ports and the `iii compose` stacks that own them.",
            "properties": {
              "composes": {
                "description": "Running `iii compose` daemons.",
                "items": {
                  "$ref": "#/definitions/ComposeStack"
                },
                "type": "array"
              },
              "error": {
                "description": "Why the scan failed, if it did.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "listeners": {
                "description": "Every TCP listening socket of this user's processes, sorted by port.",
                "items": {
                  "$ref": "#/definitions/Listener"
                },
                "type": "array"
              },
              "supported": {
                "description": "This platform has a port scanner.",
                "type": "boolean"
              }
            },
            "required": [
              "composes",
              "generated_at_ms",
              "listeners",
              "supported"
            ],
            "type": "object"
          },
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "Session": {
            "properties": {
              "activity_at_ms": {
                "description": "Last activity in any of its windows.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "attached": {
                "description": "tmux clients attached, console terminals included.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "console_attached": {
                "description": "How many attached clients are console terminals.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at_ms": {
                "description": "When the session was created.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Session id, e.g. `$5`.",
                "type": "string"
              },
              "name": {
                "description": "Session name.",
                "type": "string"
              },
              "windows": {
                "description": "Windows sorted by index.",
                "items": {
                  "$ref": "#/definitions/Window"
                },
                "type": "array"
              }
            },
            "required": [
              "activity_at_ms",
              "attached",
              "console_attached",
              "created_at_ms",
              "id",
              "name",
              "windows"
            ],
            "type": "object"
          },
          "SessionsSnapshot": {
            "description": "Every session with its windows and panes.",
            "properties": {
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "sessions": {
                "description": "Sessions sorted by name.",
                "items": {
                  "$ref": "#/definitions/Session"
                },
                "type": "array"
              },
              "tmux": {
                "allOf": [
                  {
                    "$ref": "#/definitions/TmuxInfo"
                  }
                ],
                "description": "tmux availability and server."
              }
            },
            "required": [
              "generated_at_ms",
              "sessions",
              "tmux"
            ],
            "type": "object"
          },
          "SubagentStatus": {
            "description": "A sub-agent at work under an agent CLI.",
            "properties": {
              "depth": {
                "description": "1 for a sub-agent of the main agent, 2 for one of its sub-agents, ….",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "description": {
                "description": "What it was asked to do: Claude Code's task description, Codex's task path under the main agent (`review/tests`).",
                "type": "string"
              },
              "id": {
                "description": "Stable within the agent's session: Claude Code's agent id, Codex's thread id.",
                "type": "string"
              },
              "kind": {
                "description": "Claude Code's agent type (`general-purpose`, `Explore`, `fork`) or Codex's agent role; null when the agent names none.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "since_ms": {
                "description": "When it started its current task.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "depth",
              "description",
              "id",
              "since_ms"
            ],
            "type": "object"
          },
          "Suggestion": {
            "description": "Another account suggested for global.",
            "properties": {
              "at_ms": {
                "description": "When the reason was first seen.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "following": {
                "description": "Claude Code panes on the slot that are not pinned: they switch with the global account.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account.",
                "type": "string"
              },
              "id": {
                "description": "Pass it to `tmux::accounts::dismiss`.",
                "type": "string"
              },
              "reason": {
                "description": "`week_80`, `week_90`, `limit` or `five_hour`.",
                "type": "string"
              },
              "to": {
                "description": "The account suggested.",
                "type": "string"
              }
            },
            "required": [
              "at_ms",
              "following",
              "from",
              "id",
              "reason",
              "to"
            ],
            "type": "object"
          },
          "SwitchRules": {
            "description": "The rules for the global account (agent-accounts D14).",
            "properties": {
              "at": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Threshold"
                  }
                ],
                "default": "week_90",
                "description": "`week_80`, `week_90` or `limit`."
              },
              "back_after_reset": {
                "default": false,
                "description": "After switching away by itself, switch back once that account's window resets.",
                "type": "boolean"
              },
              "five_hour": {
                "default": false,
                "description": "Also act when the 5-hour window reaches 100 %.",
                "type": "boolean"
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/RulesMode"
                  }
                ],
                "default": "suggest",
                "description": "`off`, `suggest` or `switch`."
              },
              "order": {
                "default": [],
                "description": "Accounts to try first, in order; then the one with most room this week.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          },
          "TmuxInfo": {
            "description": "Whether a usable tmux exists and which server this worker talks to.",
            "properties": {
              "available": {
                "description": "A usable tmux binary was found.",
                "type": "boolean"
              },
              "error": {
                "description": "Why tmux is unavailable, or the last listing error.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "installable": {
                "default": false,
                "description": "tmux is missing and `tmux::install` can try: a supported OS, the configured binary is plain `tmux`, not a path or another name, and this processor has an official build or this computer a package manager.",
                "type": "boolean"
              },
              "path": {
                "description": "Resolved tmux binary.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "server_running": {
                "description": "A tmux server is running on that socket.",
                "type": "boolean"
              },
              "socket_path": {
                "description": "Server socket, known while the server runs.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "version": {
                "description": "tmux version, e.g. `3.6`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "available",
              "server_running"
            ],
            "type": "object"
          },
          "UsageSnapshot": {
            "description": "Claude Code accounts and the weekly usage of Claude Code and Codex.",
            "properties": {
              "claude": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ClaudeSnapshot"
                  }
                ],
                "description": "Claude Code's accounts and their usage."
              },
              "codex": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/CodexUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Codex's usage, when Codex recorded any."
              },
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "claude",
              "generated_at_ms"
            ],
            "type": "object"
          },
          "Window": {
            "properties": {
              "active": {
                "description": "This is the session's current window.",
                "type": "boolean"
              },
              "activity_at_ms": {
                "description": "Last output in the window.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "bell": {
                "description": "A bell rang in the window.",
                "type": "boolean"
              },
              "id": {
                "description": "Window id, e.g. `@3` (unique on the server).",
                "type": "string"
              },
              "index": {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "name": {
                "description": "Window name.",
                "type": "string"
              },
              "panes": {
                "description": "Panes sorted by index.",
                "items": {
                  "$ref": "#/definitions/Pane"
                },
                "type": "array"
              },
              "zoomed": {
                "description": "A pane is zoomed.",
                "type": "boolean"
              }
            },
            "required": [
              "active",
              "activity_at_ms",
              "bell",
              "id",
              "index",
              "name",
              "panes",
              "zoomed"
            ],
            "type": "object"
          }
        },
        "description": "What `tmux::on-changed` returns: the payload of the live feed.",
        "properties": {
          "ports": {
            "allOf": [
              {
                "$ref": "#/definitions/PortsSnapshot"
              }
            ],
            "description": "Listening ports and compose stacks."
          },
          "sessions": {
            "allOf": [
              {
                "$ref": "#/definitions/SessionsSnapshot"
              }
            ],
            "description": "Sessions, windows, panes and their status."
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/definitions/UsageSnapshot"
              },
              {
                "type": "null"
              }
            ],
            "description": "Claude Code accounts and the weekly usage of Claude Code and Codex. Absent from workers before 0.3."
          }
        },
        "required": [
          "ports",
          "sessions"
        ],
        "title": "Overview",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountSwitch": {
            "description": "The latest change of the global account.",
            "properties": {
              "after_turn": {
                "description": "Panes pinned to the old global account that restart on its folder when their turn ends.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "at_ms": {
                "description": "When it happened.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "auto": {
                "description": "The worker switched by itself (rules mode `switch`).",
                "type": "boolean"
              },
              "back_at_ms": {
                "description": "With `back_after_reset`: when `from`'s window resets and the worker switches back.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "following": {
                "default": 0,
                "description": "Claude Code panes on the slot that switched with it, on their next message.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account before.",
                "type": "string"
              },
              "reason": {
                "default": null,
                "description": "`week_80`, `week_90`, `limit`, `five_hour` or `back` for an automatic switch; `login` (someone signed in to a known account with `/login`), `login_new` (to a new one, added then), `upgrade` (the worker took the slot's sign-in for global when it was updated); null when someone switched.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "restarted": {
                "default": [],
                "description": "Pinned panes restarted: the new global account's (now on the slot) and the old one's (now on its folder).",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "to": {
                "description": "The global account after.",
                "type": "string"
              }
            },
            "required": [
              "after_turn",
              "at_ms",
              "auto",
              "from",
              "to"
            ],
            "type": "object"
          },
          "AddressFamily": {
            "enum": [
              "ipv4",
              "ipv6"
            ],
            "type": "string"
          },
          "AgentState": {
            "oneOf": [
              {
                "description": "The agent is running a turn.",
                "enum": [
                  "working"
                ],
                "type": "string"
              },
              {
                "description": "The agent shows a prompt that needs you.",
                "enum": [
                  "waiting"
                ],
                "type": "string"
              },
              {
                "description": "The agent waits for a new message.",
                "enum": [
                  "idle"
                ],
                "type": "string"
              }
            ]
          },
          "AgentStatus": {
            "properties": {
              "id": {
                "description": "Matcher id from the configuration, e.g. `claude`.",
                "type": "string"
              },
              "label": {
                "description": "Display name, e.g. `Claude Code`.",
                "type": "string"
              },
              "pid": {
                "description": "Pid of the agent process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "since_ms": {
                "description": "When the agent entered `state`.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "state": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AgentState"
                  }
                ],
                "description": "What the agent is doing."
              },
              "subagents": {
                "default": [],
                "description": "Sub-agents working right now, oldest first. Their work keeps `state` at `working` after the agent's own turn ended. Claude Code and Codex report them; other agents always list none.",
                "items": {
                  "$ref": "#/definitions/SubagentStatus"
                },
                "type": "array"
              },
              "title": {
                "default": null,
                "description": "The agent's session title: the pane title without the agent's status glyph (Claude Code's ✳ or spinner). Null when the pane only shows tmux's default title (the host name) or nothing.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "label",
              "pid",
              "since_ms",
              "state"
            ],
            "type": "object"
          },
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeLogin": {
            "description": "A sign-in of a Claude Code account from the app (claude-login-ui).",
            "properties": {
              "account": {
                "description": "The account signing in.",
                "type": "string"
              },
              "browser": {
                "$ref": "#/definitions/LoginBrowser"
              },
              "email": {
                "description": "The email the sign-in page is filled with (the account's).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/LoginError"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "With `failed` and `expired`: why."
              },
              "expires_at_ms": {
                "description": "When the link stops working and Claude Code is stopped.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "login_id": {
                "description": "Pass it to `tmux::accounts::login_code` and `login_cancel`.",
                "type": "string"
              },
              "state": {
                "$ref": "#/definitions/LoginState"
              },
              "url": {
                "description": "The sign-in page to open on any device: it shows the code to paste.",
                "type": "string"
              }
            },
            "required": [
              "account",
              "browser",
              "expires_at_ms",
              "login_id",
              "state",
              "url"
            ],
            "type": "object"
          },
          "ClaudeSnapshot": {
            "description": "Claude Code's accounts as the worker sees them.",
            "properties": {
              "accounts": {
                "description": "The default account first, then the others in the order they were added.",
                "items": {
                  "$ref": "#/definitions/ClaudeAccount"
                },
                "type": "array"
              },
              "available": {
                "description": "A `claude` binary is on PATH or `~/.claude` exists.",
                "type": "boolean"
              },
              "global": {
                "description": "Id of the global account: the sign-in of the slot (`~/.claude`), what plain `claude` uses anywhere.",
                "type": "string"
              },
              "last_switch": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AccountSwitch"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest change of the global account."
              },
              "logins": {
                "default": [],
                "description": "Sign-ins under way (`tmux::accounts::login_start`), and those that ended in the last minute, oldest first.",
                "items": {
                  "$ref": "#/definitions/ClaudeLogin"
                },
                "type": "array"
              },
              "managed": {
                "description": "The accounts registry exists (an account was added or a setting saved).",
                "type": "boolean"
              },
              "pending_global": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PendingGlobal"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "A switch of the global account that waits for windows on the new account's folder to finish their turn."
              },
              "rules": {
                "allOf": [
                  {
                    "$ref": "#/definitions/SwitchRules"
                  }
                ],
                "description": "The rules for the global account."
              },
              "runs_as_root": {
                "description": "The worker runs as root, where Claude Code refuses `--dangerously-skip-permissions`.",
                "type": "boolean"
              },
              "suggestion": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Suggestion"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Another account suggested for global, while the global one is low."
              },
              "switch_delay_s": {
                "default": 0,
                "description": "How long a running Claude Code may take to notice a switch, in seconds: 0 on Linux (its next message), 30 on macOS (the Keychain).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "accounts",
              "available",
              "global",
              "managed",
              "rules",
              "runs_as_root"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "CodexCredits": {
            "description": "Codex's credits.",
            "properties": {
              "balance": {
                "description": "The balance as Codex reports it, e.g. `62500.0000000000`.",
                "type": "string"
              },
              "unlimited": {
                "description": "Credits are unlimited.",
                "type": "boolean"
              }
            },
            "required": [
              "balance",
              "unlimited"
            ],
            "type": "object"
          },
          "CodexUsage": {
            "description": "Codex's usage, from the newest session it recorded (agent-accounts D13).",
            "properties": {
              "as_of_ms": {
                "description": "When Codex recorded it.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "credits": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/CodexCredits"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Credits, when the plan has them."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The 5-hour window, when the plan has one."
              },
              "plan": {
                "default": null,
                "description": "The ChatGPT plan, e.g. `pro`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ComposeEngine": {
            "properties": {
              "pid": {
                "description": "Engine pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the engine listens on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              },
              "ws_port": {
                "description": "The engine WebSocket port workers connect to.",
                "format": "uint16",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "ComposeRef": {
            "properties": {
              "namespace": {
                "description": "Compose daemon namespace.",
                "type": "string"
              },
              "pid": {
                "description": "Compose daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "namespace",
              "pid"
            ],
            "type": "object"
          },
          "ComposeStack": {
            "properties": {
              "compose_file": {
                "description": "Compose file the daemon serves, when known.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "engine": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeEngine"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The engine the daemon started, if it manages one."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the daemon runs in."
              },
              "namespace": {
                "description": "Daemon namespace (`iii:c:<namespace>`).",
                "type": "string"
              },
              "pid": {
                "description": "Daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "project_dir": {
                "description": "Daemon working directory.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "workers": {
                "description": "Workers the daemon started.",
                "items": {
                  "$ref": "#/definitions/ComposeWorker"
                },
                "type": "array"
              }
            },
            "required": [
              "namespace",
              "pid",
              "workers"
            ],
            "type": "object"
          },
          "ComposeWorker": {
            "properties": {
              "name": {
                "description": "Worker name.",
                "type": "string"
              },
              "pid": {
                "description": "Top-most pid of the worker's process tree.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the worker's processes listen on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            },
            "required": [
              "name",
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Follow": {
            "description": "How a pane's Claude Code account is chosen (agent-accounts G12).",
            "oneOf": [
              {
                "description": "Runs on the global slot (`~/.claude`) and is not pinned, started by the worker or by hand: it switches with the global account on its next message.",
                "enum": [
                  "global"
                ],
                "type": "string"
              },
              {
                "description": "Pinned to an account: on its folder, or on the slot while that account is global (it restarts on its folder when the global one changes).",
                "enum": [
                  "pinned"
                ],
                "type": "string"
              },
              {
                "description": "Started by hand on an account's folder (`CLAUDE_CONFIG_DIR` set): no mark.",
                "enum": [
                  "manual"
                ],
                "type": "string"
              }
            ]
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "Listener": {
            "description": "One TCP socket in LISTEN state.",
            "properties": {
              "address": {
                "description": "Bound address, e.g. `0.0.0.0` or `::1`.",
                "type": "string"
              },
              "compose": {
                "description": "Compose namespace the process belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "family": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AddressFamily"
                  }
                ],
                "description": "IPv4 or IPv6."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the process descends from."
              },
              "pid": {
                "description": "Owning process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "port": {
                "description": "Port number.",
                "format": "uint16",
                "minimum": 0,
                "type": "integer"
              },
              "process": {
                "description": "Owning process name.",
                "type": "string"
              },
              "role": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ListenerRole"
                  }
                ],
                "description": "What kind of process owns the socket."
              },
              "worker": {
                "description": "iii worker name, when known.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "address",
              "family",
              "pid",
              "port",
              "process",
              "role"
            ],
            "type": "object"
          },
          "ListenerRole": {
            "oneOf": [
              {
                "description": "An iii engine (its WebSocket and built-in listeners).",
                "enum": [
                  "engine"
                ],
                "type": "string"
              },
              {
                "description": "An iii worker.",
                "enum": [
                  "worker"
                ],
                "type": "string"
              },
              {
                "description": "An `iii compose` daemon.",
                "enum": [
                  "compose"
                ],
                "type": "string"
              },
              {
                "description": "Anything else.",
                "enum": [
                  "other"
                ],
                "type": "string"
              }
            ]
          },
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          },
          "LoginError": {
            "description": "Why a sign-in failed, as `tmux::accounts::login_code` answers it.",
            "properties": {
              "code": {
                "description": "`rejected` (Anthropic didn't accept the code; Claude Code ended), `expired`, `gone` or `failed`.",
                "type": "string"
              },
              "message": {
                "description": "One sentence.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "LoginState": {
            "description": "Where a sign-in is.",
            "oneOf": [
              {
                "description": "Claude Code shows the link and waits for the code.",
                "enum": [
                  "waiting_code"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code is checking a code with Anthropic.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Signed in.",
                "enum": [
                  "done"
                ],
                "type": "string"
              },
              {
                "description": "It ended without a sign-in (`error` says why).",
                "enum": [
                  "failed"
                ],
                "type": "string"
              },
              {
                "description": "The link's 10 minutes ran out; Claude Code was stopped.",
                "enum": [
                  "expired"
                ],
                "type": "string"
              }
            ]
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          },
          "Pane": {
            "properties": {
              "active": {
                "description": "The window's active pane.",
                "type": "boolean"
              },
              "agent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AgentStatus"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The agent CLI running in this pane, if any."
              },
              "claude": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneClaude"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The Claude Code account the pane runs on and how it follows the global one. Present when the pane runs Claude Code or carries an account mark; absent otherwise and from workers before 0.3."
              },
              "command": {
                "description": "Foreground process name.",
                "type": "string"
              },
              "compose": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The `iii compose` daemon running in this pane, if any."
              },
              "cwd": {
                "description": "Current directory.",
                "type": "string"
              },
              "dead": {
                "description": "The pane's process exited and the pane is kept.",
                "type": "boolean"
              },
              "height": {
                "description": "Height in rows.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Pane id, e.g. `%5`.",
                "type": "string"
              },
              "index": {
                "description": "Pane index inside the window.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "pid": {
                "description": "Pid of the process tmux started in the pane.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Listening sockets owned by processes started from this pane.",
                "items": {
                  "$ref": "#/definitions/Listener"
                },
                "type": "array"
              },
              "title": {
                "description": "Pane title set by the program.",
                "type": "string"
              },
              "width": {
                "description": "Width in columns.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "active",
              "command",
              "cwd",
              "dead",
              "height",
              "id",
              "index",
              "pid",
              "ports",
              "title",
              "width"
            ],
            "type": "object"
          },
          "PaneClaude": {
            "description": "The Claude Code account of one pane (agent-accounts D4, D5).",
            "properties": {
              "account": {
                "default": null,
                "description": "Id of the account the running Claude Code uses: the global account on the slot (`~/.claude`), else the account whose folder its `CLAUDE_CONFIG_DIR` names. Null when that folder is no registered account (see `config_dir`) or Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "config_dir": {
                "default": null,
                "description": "The config folder the running Claude Code uses, `~` for the home folder. Null when Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "follow": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Follow"
                  }
                ],
                "description": "`global`, `pinned` or `manual`."
              },
              "movable": {
                "description": "The worker can move this pane to another account.",
                "type": "boolean"
              },
              "move_error": {
                "description": "Why the last move of this pane (one that waited for its turn, or a switch of the global account) failed, in one sentence; cleared by the next account change of the pane.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "not_movable_reason": {
                "description": "Why it can't, in one sentence, when `movable` is false.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "pending": {
                "default": null,
                "description": "The account the pane moves to when its turn ends (`global`: the slot).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "default": null,
                "description": "Claude Code's session id, which a move resumes.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "skip_permissions": {
                "description": "Claude Code runs without permission prompts (`--dangerously-skip-permissions` or `--permission-mode bypassPermissions`).",
                "type": "boolean"
              }
            },
            "required": [
              "follow",
              "movable",
              "skip_permissions"
            ],
            "type": "object"
          },
          "PaneRef": {
            "description": "Where a process runs in tmux.",
            "properties": {
              "pane_id": {
                "description": "Pane id.",
                "type": "string"
              },
              "session": {
                "description": "Session name.",
                "type": "string"
              },
              "session_id": {
                "description": "Session id.",
                "type": "string"
              },
              "window_id": {
                "description": "Window id.",
                "type": "string"
              },
              "window_index": {
                "description": "Window index.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "pane_id",
              "session",
              "session_id",
              "window_id",
              "window_index"
            ],
            "type": "object"
          },
          "PendingGlobal": {
            "description": "A switch of the global account waiting for windows to finish their turn (agent-accounts G4).",
            "properties": {
              "account": {
                "description": "The account becoming global.",
                "type": "string"
              },
              "at_ms": {
                "description": "When it was asked for.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "by": {
                "description": "`person` or `rule`.",
                "type": "string"
              },
              "waiting_for": {
                "description": "The Claude Code panes on its folder still working or waiting.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "account",
              "at_ms",
              "by",
              "waiting_for"
            ],
            "type": "object"
          },
          "PortsSnapshot": {
            "description": "Listening ports and the `iii compose` stacks that own them.",
            "properties": {
              "composes": {
                "description": "Running `iii compose` daemons.",
                "items": {
                  "$ref": "#/definitions/ComposeStack"
                },
                "type": "array"
              },
              "error": {
                "description": "Why the scan failed, if it did.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "listeners": {
                "description": "Every TCP listening socket of this user's processes, sorted by port.",
                "items": {
                  "$ref": "#/definitions/Listener"
                },
                "type": "array"
              },
              "supported": {
                "description": "This platform has a port scanner.",
                "type": "boolean"
              }
            },
            "required": [
              "composes",
              "generated_at_ms",
              "listeners",
              "supported"
            ],
            "type": "object"
          },
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "Session": {
            "properties": {
              "activity_at_ms": {
                "description": "Last activity in any of its windows.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "attached": {
                "description": "tmux clients attached, console terminals included.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "console_attached": {
                "description": "How many attached clients are console terminals.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at_ms": {
                "description": "When the session was created.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Session id, e.g. `$5`.",
                "type": "string"
              },
              "name": {
                "description": "Session name.",
                "type": "string"
              },
              "windows": {
                "description": "Windows sorted by index.",
                "items": {
                  "$ref": "#/definitions/Window"
                },
                "type": "array"
              }
            },
            "required": [
              "activity_at_ms",
              "attached",
              "console_attached",
              "created_at_ms",
              "id",
              "name",
              "windows"
            ],
            "type": "object"
          },
          "SessionsSnapshot": {
            "description": "Every session with its windows and panes.",
            "properties": {
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "sessions": {
                "description": "Sessions sorted by name.",
                "items": {
                  "$ref": "#/definitions/Session"
                },
                "type": "array"
              },
              "tmux": {
                "allOf": [
                  {
                    "$ref": "#/definitions/TmuxInfo"
                  }
                ],
                "description": "tmux availability and server."
              }
            },
            "required": [
              "generated_at_ms",
              "sessions",
              "tmux"
            ],
            "type": "object"
          },
          "SubagentStatus": {
            "description": "A sub-agent at work under an agent CLI.",
            "properties": {
              "depth": {
                "description": "1 for a sub-agent of the main agent, 2 for one of its sub-agents, ….",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "description": {
                "description": "What it was asked to do: Claude Code's task description, Codex's task path under the main agent (`review/tests`).",
                "type": "string"
              },
              "id": {
                "description": "Stable within the agent's session: Claude Code's agent id, Codex's thread id.",
                "type": "string"
              },
              "kind": {
                "description": "Claude Code's agent type (`general-purpose`, `Explore`, `fork`) or Codex's agent role; null when the agent names none.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "since_ms": {
                "description": "When it started its current task.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "depth",
              "description",
              "id",
              "since_ms"
            ],
            "type": "object"
          },
          "Suggestion": {
            "description": "Another account suggested for global.",
            "properties": {
              "at_ms": {
                "description": "When the reason was first seen.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "following": {
                "description": "Claude Code panes on the slot that are not pinned: they switch with the global account.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account.",
                "type": "string"
              },
              "id": {
                "description": "Pass it to `tmux::accounts::dismiss`.",
                "type": "string"
              },
              "reason": {
                "description": "`week_80`, `week_90`, `limit` or `five_hour`.",
                "type": "string"
              },
              "to": {
                "description": "The account suggested.",
                "type": "string"
              }
            },
            "required": [
              "at_ms",
              "following",
              "from",
              "id",
              "reason",
              "to"
            ],
            "type": "object"
          },
          "SwitchRules": {
            "description": "The rules for the global account (agent-accounts D14).",
            "properties": {
              "at": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Threshold"
                  }
                ],
                "default": "week_90",
                "description": "`week_80`, `week_90` or `limit`."
              },
              "back_after_reset": {
                "default": false,
                "description": "After switching away by itself, switch back once that account's window resets.",
                "type": "boolean"
              },
              "five_hour": {
                "default": false,
                "description": "Also act when the 5-hour window reaches 100 %.",
                "type": "boolean"
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/RulesMode"
                  }
                ],
                "default": "suggest",
                "description": "`off`, `suggest` or `switch`."
              },
              "order": {
                "default": [],
                "description": "Accounts to try first, in order; then the one with most room this week.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          },
          "TmuxInfo": {
            "description": "Whether a usable tmux exists and which server this worker talks to.",
            "properties": {
              "available": {
                "description": "A usable tmux binary was found.",
                "type": "boolean"
              },
              "error": {
                "description": "Why tmux is unavailable, or the last listing error.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "installable": {
                "default": false,
                "description": "tmux is missing and `tmux::install` can try: a supported OS, the configured binary is plain `tmux`, not a path or another name, and this processor has an official build or this computer a package manager.",
                "type": "boolean"
              },
              "path": {
                "description": "Resolved tmux binary.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "server_running": {
                "description": "A tmux server is running on that socket.",
                "type": "boolean"
              },
              "socket_path": {
                "description": "Server socket, known while the server runs.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "version": {
                "description": "tmux version, e.g. `3.6`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "available",
              "server_running"
            ],
            "type": "object"
          },
          "UsageSnapshot": {
            "description": "Claude Code accounts and the weekly usage of Claude Code and Codex.",
            "properties": {
              "claude": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ClaudeSnapshot"
                  }
                ],
                "description": "Claude Code's accounts and their usage."
              },
              "codex": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/CodexUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Codex's usage, when Codex recorded any."
              },
              "generated_at_ms": {
                "description": "When the snapshot was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "claude",
              "generated_at_ms"
            ],
            "type": "object"
          },
          "Window": {
            "properties": {
              "active": {
                "description": "This is the session's current window.",
                "type": "boolean"
              },
              "activity_at_ms": {
                "description": "Last output in the window.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "bell": {
                "description": "A bell rang in the window.",
                "type": "boolean"
              },
              "id": {
                "description": "Window id, e.g. `@3` (unique on the server).",
                "type": "string"
              },
              "index": {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "name": {
                "description": "Window name.",
                "type": "string"
              },
              "panes": {
                "description": "Panes sorted by index.",
                "items": {
                  "$ref": "#/definitions/Pane"
                },
                "type": "array"
              },
              "zoomed": {
                "description": "A pane is zoomed.",
                "type": "boolean"
              }
            },
            "required": [
              "active",
              "activity_at_ms",
              "bell",
              "id",
              "index",
              "name",
              "panes",
              "zoomed"
            ],
            "type": "object"
          }
        },
        "description": "What `tmux::on-changed` returns: the payload of the live feed.",
        "properties": {
          "ports": {
            "allOf": [
              {
                "$ref": "#/definitions/PortsSnapshot"
              }
            ],
            "description": "Listening ports and compose stacks."
          },
          "sessions": {
            "allOf": [
              {
                "$ref": "#/definitions/SessionsSnapshot"
              }
            ],
            "description": "Sessions, windows, panes and their status."
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/definitions/UsageSnapshot"
              },
              {
                "type": "null"
              }
            ],
            "description": "Claude Code accounts and the weekly usage of Claude Code and Codex. Absent from workers before 0.3."
          }
        },
        "required": [
          "ports",
          "sessions"
        ],
        "title": "Overview",
        "type": "object"
      }
    },
    {
      "description": "Internal: re-read the tmux configuration after an operator change.",
      "metadata": {
        "internal": true
      },
      "name": "tmux::on-config-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "What `<worker>::on-config-change` receives: the `Observed` envelope of a `configuration::on-updated` call (captured as output). Advisory only: handlers ignore it and re-fetch the authoritative value, so a direct call can never inject config.",
        "properties": {
          "id": {
            "default": null,
            "description": "Configuration id that changed.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnConfigChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Ack returned by the internal `<worker>::on-config-change` handler.",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnConfigChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "Choose the Claude Code account of a pane: `global` follows the global account (it runs on ~/.claude and switches with it, with no restart), an account id pins the pane there (on ~/.claude while that account is global, on its folder otherwise). When Claude Code has to run elsewhere for that (the account must be signed in), it moves: it stops and starts again there, resuming its conversation (copied there if the account doesn't share conversations). Pinning a pane on ~/.claude to the account that is global now restarts nothing. An idle pane moves now (looked at again right before it stops); one that is working or waiting moves once its turn ends (`after_turn`). Choosing what it already is changes no process, and cancels a move that waits (`cancelled`).",
      "metadata": {},
      "name": "tmux::panes::account",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "account": {
            "description": "`global` (follow the global account) or an account id (pin to it).",
            "type": "string"
          },
          "pane": {
            "description": "Pane id, e.g. `%5`.",
            "type": "string"
          }
        },
        "required": [
          "account",
          "pane"
        ],
        "title": "PaneAccountInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "PaneAccountState": {
            "description": "What became of the pane.",
            "oneOf": [
              {
                "description": "It follows the global account, which it already runs on (or Claude Code is not running).",
                "enum": [
                  "following"
                ],
                "type": "string"
              },
              {
                "description": "It is pinned to the account it already runs on (or Claude Code is not running).",
                "enum": [
                  "pinned"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code was idle and now runs on the account.",
                "enum": [
                  "moved"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code is working or waiting: it moves once its turn ends.",
                "enum": [
                  "after_turn"
                ],
                "type": "string"
              },
              {
                "description": "A move that waited for the turn was called off.",
                "enum": [
                  "cancelled"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "account": {
            "description": "The account it runs on now, or will after its turn.",
            "type": "string"
          },
          "state": {
            "$ref": "#/definitions/PaneAccountState"
          }
        },
        "required": [
          "account",
          "state"
        ],
        "title": "PaneAccountOutput",
        "type": "object"
      }
    },
    {
      "description": "The visible screen of one pane as text with its colour and style escapes (capture-pane -e), plus the pane's size, cursor position and whether a full-screen program has the alternate screen. Read-only.",
      "metadata": {},
      "name": "tmux::panes::capture",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane": {
            "description": "Pane id, e.g. `%5`.",
            "type": "string"
          }
        },
        "required": [
          "pane"
        ],
        "title": "PaneInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "alternate": {
            "description": "The pane shows its alternate screen (a full-screen program).",
            "type": "boolean"
          },
          "cursor_x": {
            "description": "Cursor column, from 0.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "cursor_y": {
            "description": "Cursor row, from 0.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "height": {
            "description": "Height in rows.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "pane_id": {
            "description": "Pane id.",
            "type": "string"
          },
          "text": {
            "description": "The visible screen, one line per row separated by `\\n`, with SGR escapes.",
            "type": "string"
          },
          "width": {
            "description": "Width in columns.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "alternate",
          "cursor_x",
          "cursor_y",
          "height",
          "pane_id",
          "text",
          "width"
        ],
        "title": "PaneCapture",
        "type": "object"
      }
    },
    {
      "description": "Kill a pane and the program running in it. Killing a window's last pane closes the window, and its session's last window closes the session; the answer says which closed.",
      "metadata": {},
      "name": "tmux::panes::kill",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane": {
            "description": "Pane id, e.g. `%5`.",
            "type": "string"
          }
        },
        "required": [
          "pane"
        ],
        "title": "PaneInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "killed": {
            "description": "Always true.",
            "type": "boolean"
          },
          "session_closed": {
            "description": "That window was its session's last, so the session closed.",
            "type": "boolean"
          },
          "window_closed": {
            "description": "It was its window's last pane, so the window closed.",
            "type": "boolean"
          }
        },
        "required": [
          "killed",
          "session_closed",
          "window_closed"
        ],
        "title": "KilledPane",
        "type": "object"
      }
    },
    {
      "description": "Start a pane's program again in the same pane: the command it was started with (or command), in its starting directory (or cwd). A pane whose program is still running is refused unless kill is true, which ends that program first.",
      "metadata": {},
      "name": "tmux::panes::respawn",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "command": {
            "default": null,
            "description": "Shell command to run instead of the one the pane was started with.",
            "type": [
              "string",
              "null"
            ]
          },
          "cwd": {
            "default": null,
            "description": "Working directory, absolute or `~/…`. Defaults to the pane's starting directory.",
            "type": [
              "string",
              "null"
            ]
          },
          "kill": {
            "default": null,
            "description": "End the pane's program first when it is still running (default false).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "pane": {
            "description": "Pane id, e.g. `%5`.",
            "type": "string"
          }
        },
        "required": [
          "pane"
        ],
        "title": "RespawnPaneInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane_id": {
            "description": "Pane id, the same as before.",
            "type": "string"
          }
        },
        "required": [
          "pane_id"
        ],
        "title": "RespawnedPane",
        "type": "object"
      }
    },
    {
      "description": "Make a pane the active pane of its window. zoom sets the window's zoom, it never toggles: true zooms the window on this pane (or keeps it zoomed there), false unzooms it, and without zoom the window keeps its zoom state, moved to this pane. A window with one pane can't zoom: the answer says zoomed false. Like tmux itself, every client looking at that window follows, your terminal included. It does not change the session's current window (tmux::windows::select does).",
      "metadata": {},
      "name": "tmux::panes::select",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane": {
            "description": "Pane id, e.g. `%5`.",
            "type": "string"
          },
          "zoom": {
            "default": null,
            "description": "true zooms the window on this pane, false unzooms it, absent keeps the window's zoom.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "pane"
        ],
        "title": "SelectPaneInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane_id": {
            "description": "Pane id now active in its window.",
            "type": "string"
          },
          "session_id": {
            "description": "Session id the pane was resolved in.",
            "type": "string"
          },
          "window_id": {
            "description": "Window id holding the pane.",
            "type": "string"
          },
          "zoomed": {
            "description": "The window is zoomed on the active pane.",
            "type": "boolean"
          }
        },
        "required": [
          "pane_id",
          "session_id",
          "window_id",
          "zoomed"
        ],
        "title": "SelectedPane",
        "type": "object"
      }
    },
    {
      "description": "Split a pane in two: the new pane goes to its right or below it, starts in that pane's current directory (or cwd) and runs the default shell (or command). It becomes the window's active pane unless select is false. Like tmux, splitting a zoomed window unzooms it. With remain_on_exit, the new pane stays once its program ends, dead, for tmux::panes::respawn to restart it.",
      "metadata": {},
      "name": "tmux::panes::split",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SplitDirection": {
            "description": "Where a split puts the new pane.",
            "oneOf": [
              {
                "description": "To the right of the pane (tmux `split-window -h`).",
                "enum": [
                  "right"
                ],
                "type": "string"
              },
              {
                "description": "Below the pane (tmux `split-window -v`).",
                "enum": [
                  "below"
                ],
                "type": "string"
              }
            ]
          }
        },
        "properties": {
          "command": {
            "default": null,
            "description": "Shell command to run instead of the default shell.",
            "type": [
              "string",
              "null"
            ]
          },
          "cwd": {
            "default": null,
            "description": "Working directory, absolute or `~/…`. Defaults to the split pane's current directory.",
            "type": [
              "string",
              "null"
            ]
          },
          "direction": {
            "allOf": [
              {
                "$ref": "#/definitions/SplitDirection"
              }
            ],
            "description": "Where the new pane goes: `right` or `below`."
          },
          "pane": {
            "description": "Pane id to split, e.g. `%5`.",
            "type": "string"
          },
          "remain_on_exit": {
            "default": false,
            "description": "Keep the new pane once its program ends, shown dead, so tmux::panes::respawn can restart it (default false: tmux closes it). On tmux before 3.0, which has no pane options, every pane of its window is kept.",
            "type": "boolean"
          },
          "select": {
            "default": null,
            "description": "Make the new pane the window's active pane (default true).",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "direction",
          "pane"
        ],
        "title": "SplitPaneInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane_id": {
            "description": "The new pane's id.",
            "type": "string"
          },
          "session_id": {
            "description": "Session id.",
            "type": "string"
          },
          "window_id": {
            "description": "Window id holding both panes.",
            "type": "string"
          }
        },
        "required": [
          "pane_id",
          "session_id",
          "window_id"
        ],
        "title": "NewPane",
        "type": "object"
      }
    },
    {
      "description": "Every TCP port this user's processes listen on, with process, iii role (engine / worker / compose), worker name, compose namespace and the tmux pane the process runs in; plus each running `iii compose` stack with its engine WebSocket port and workers' ports.",
      "metadata": {},
      "name": "tmux::ports::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AddressFamily": {
            "enum": [
              "ipv4",
              "ipv6"
            ],
            "type": "string"
          },
          "ComposeEngine": {
            "properties": {
              "pid": {
                "description": "Engine pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the engine listens on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              },
              "ws_port": {
                "description": "The engine WebSocket port workers connect to.",
                "format": "uint16",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "ComposeStack": {
            "properties": {
              "compose_file": {
                "description": "Compose file the daemon serves, when known.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "engine": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeEngine"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The engine the daemon started, if it manages one."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the daemon runs in."
              },
              "namespace": {
                "description": "Daemon namespace (`iii:c:<namespace>`).",
                "type": "string"
              },
              "pid": {
                "description": "Daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "project_dir": {
                "description": "Daemon working directory.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "workers": {
                "description": "Workers the daemon started.",
                "items": {
                  "$ref": "#/definitions/ComposeWorker"
                },
                "type": "array"
              }
            },
            "required": [
              "namespace",
              "pid",
              "workers"
            ],
            "type": "object"
          },
          "ComposeWorker": {
            "properties": {
              "name": {
                "description": "Worker name.",
                "type": "string"
              },
              "pid": {
                "description": "Top-most pid of the worker's process tree.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Ports the worker's processes listen on.",
                "items": {
                  "format": "uint16",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            },
            "required": [
              "name",
              "pid",
              "ports"
            ],
            "type": "object"
          },
          "Listener": {
            "description": "One TCP socket in LISTEN state.",
            "properties": {
              "address": {
                "description": "Bound address, e.g. `0.0.0.0` or `::1`.",
                "type": "string"
              },
              "compose": {
                "description": "Compose namespace the process belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "family": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AddressFamily"
                  }
                ],
                "description": "IPv4 or IPv6."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the process descends from."
              },
              "pid": {
                "description": "Owning process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "port": {
                "description": "Port number.",
                "format": "uint16",
                "minimum": 0,
                "type": "integer"
              },
              "process": {
                "description": "Owning process name.",
                "type": "string"
              },
              "role": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ListenerRole"
                  }
                ],
                "description": "What kind of process owns the socket."
              },
              "worker": {
                "description": "iii worker name, when known.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "address",
              "family",
              "pid",
              "port",
              "process",
              "role"
            ],
            "type": "object"
          },
          "ListenerRole": {
            "oneOf": [
              {
                "description": "An iii engine (its WebSocket and built-in listeners).",
                "enum": [
                  "engine"
                ],
                "type": "string"
              },
              {
                "description": "An iii worker.",
                "enum": [
                  "worker"
                ],
                "type": "string"
              },
              {
                "description": "An `iii compose` daemon.",
                "enum": [
                  "compose"
                ],
                "type": "string"
              },
              {
                "description": "Anything else.",
                "enum": [
                  "other"
                ],
                "type": "string"
              }
            ]
          },
          "PaneRef": {
            "description": "Where a process runs in tmux.",
            "properties": {
              "pane_id": {
                "description": "Pane id.",
                "type": "string"
              },
              "session": {
                "description": "Session name.",
                "type": "string"
              },
              "session_id": {
                "description": "Session id.",
                "type": "string"
              },
              "window_id": {
                "description": "Window id.",
                "type": "string"
              },
              "window_index": {
                "description": "Window index.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "pane_id",
              "session",
              "session_id",
              "window_id",
              "window_index"
            ],
            "type": "object"
          }
        },
        "description": "Listening ports and the `iii compose` stacks that own them.",
        "properties": {
          "composes": {
            "description": "Running `iii compose` daemons.",
            "items": {
              "$ref": "#/definitions/ComposeStack"
            },
            "type": "array"
          },
          "error": {
            "description": "Why the scan failed, if it did.",
            "type": [
              "string",
              "null"
            ]
          },
          "generated_at_ms": {
            "description": "When the snapshot was taken.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "listeners": {
            "description": "Every TCP listening socket of this user's processes, sorted by port.",
            "items": {
              "$ref": "#/definitions/Listener"
            },
            "type": "array"
          },
          "supported": {
            "description": "This platform has a port scanner.",
            "type": "boolean"
          }
        },
        "required": [
          "composes",
          "generated_at_ms",
          "listeners",
          "supported"
        ],
        "title": "PortsSnapshot",
        "type": "object"
      }
    },
    {
      "description": "Create a detached tmux session (starting the tmux server if needed). Optional name, working directory (default $HOME), first window name and a shell command to run instead of the default shell. With remain_on_exit, the pane stays once its program ends, dead, for tmux::panes::respawn to restart it.",
      "metadata": {},
      "name": "tmux::sessions::create",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ClaudeLaunchInput": {
            "description": "`claude` on tmux::windows::create and tmux::sessions::create.",
            "properties": {
              "account": {
                "default": "global",
                "description": "`global` (the default: it runs on the global account and moves when that changes) or an account id (pinned to it).",
                "type": "string"
              },
              "skip_permissions": {
                "default": false,
                "description": "Start it with --dangerously-skip-permissions (default false). Refused when the host runs as root.",
                "type": "boolean"
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "claude": {
            "anyOf": [
              {
                "$ref": "#/definitions/ClaudeLaunchInput"
              },
              {
                "type": "null"
              }
            ],
            "description": "Start Claude Code on an account in the first window instead of `command` (not both): the worker builds the command (returned as `runs`) and marks the pane with its account."
          },
          "command": {
            "default": null,
            "description": "Shell command to run in the first window instead of the default shell.",
            "type": [
              "string",
              "null"
            ]
          },
          "cwd": {
            "default": null,
            "description": "Working directory, absolute or `~/…`. Defaults to $HOME.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "default": null,
            "description": "Session name; tmux picks a number when omitted. No `:` or `.`.",
            "type": [
              "string",
              "null"
            ]
          },
          "remain_on_exit": {
            "default": false,
            "description": "Keep the pane once its program ends, shown dead, so tmux::panes::respawn can restart it (default false: tmux closes it). On tmux before 3.0, which has no pane options, every pane of its window is kept.",
            "type": "boolean"
          },
          "window_name": {
            "default": null,
            "description": "Name of the first window.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "CreateSessionInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane_id": {
            "description": "First pane id.",
            "type": "string"
          },
          "runs": {
            "description": "With `claude`: the exact command the pane runs.",
            "type": [
              "string",
              "null"
            ]
          },
          "session": {
            "description": "Session name.",
            "type": "string"
          },
          "session_id": {
            "description": "New session id, e.g. `$7`.",
            "type": "string"
          },
          "window_id": {
            "description": "First window id.",
            "type": "string"
          },
          "window_index": {
            "description": "First window index.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "pane_id",
          "session",
          "session_id",
          "window_id",
          "window_index"
        ],
        "title": "CreatedSession",
        "type": "object"
      }
    },
    {
      "description": "Kill a tmux session and every program running in its windows.",
      "metadata": {},
      "name": "tmux::sessions::kill",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          }
        },
        "required": [
          "session"
        ],
        "title": "SessionInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "killed": {
            "description": "Always true.",
            "type": "boolean"
          }
        },
        "required": [
          "killed"
        ],
        "title": "KilledOutput",
        "type": "object"
      }
    },
    {
      "description": "Every tmux session with its windows and panes: foreground command, cwd, title, size, the agent CLI running in the pane (claude, codex, … with state working / waiting / idle), the `iii compose` daemon it runs and the ports its processes listen on.",
      "metadata": {},
      "name": "tmux::sessions::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AddressFamily": {
            "enum": [
              "ipv4",
              "ipv6"
            ],
            "type": "string"
          },
          "AgentState": {
            "oneOf": [
              {
                "description": "The agent is running a turn.",
                "enum": [
                  "working"
                ],
                "type": "string"
              },
              {
                "description": "The agent shows a prompt that needs you.",
                "enum": [
                  "waiting"
                ],
                "type": "string"
              },
              {
                "description": "The agent waits for a new message.",
                "enum": [
                  "idle"
                ],
                "type": "string"
              }
            ]
          },
          "AgentStatus": {
            "properties": {
              "id": {
                "description": "Matcher id from the configuration, e.g. `claude`.",
                "type": "string"
              },
              "label": {
                "description": "Display name, e.g. `Claude Code`.",
                "type": "string"
              },
              "pid": {
                "description": "Pid of the agent process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "since_ms": {
                "description": "When the agent entered `state`.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "state": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AgentState"
                  }
                ],
                "description": "What the agent is doing."
              },
              "subagents": {
                "default": [],
                "description": "Sub-agents working right now, oldest first. Their work keeps `state` at `working` after the agent's own turn ended. Claude Code and Codex report them; other agents always list none.",
                "items": {
                  "$ref": "#/definitions/SubagentStatus"
                },
                "type": "array"
              },
              "title": {
                "default": null,
                "description": "The agent's session title: the pane title without the agent's status glyph (Claude Code's ✳ or spinner). Null when the pane only shows tmux's default title (the host name) or nothing.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "label",
              "pid",
              "since_ms",
              "state"
            ],
            "type": "object"
          },
          "ComposeRef": {
            "properties": {
              "namespace": {
                "description": "Compose daemon namespace.",
                "type": "string"
              },
              "pid": {
                "description": "Compose daemon pid.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "namespace",
              "pid"
            ],
            "type": "object"
          },
          "Follow": {
            "description": "How a pane's Claude Code account is chosen (agent-accounts G12).",
            "oneOf": [
              {
                "description": "Runs on the global slot (`~/.claude`) and is not pinned, started by the worker or by hand: it switches with the global account on its next message.",
                "enum": [
                  "global"
                ],
                "type": "string"
              },
              {
                "description": "Pinned to an account: on its folder, or on the slot while that account is global (it restarts on its folder when the global one changes).",
                "enum": [
                  "pinned"
                ],
                "type": "string"
              },
              {
                "description": "Started by hand on an account's folder (`CLAUDE_CONFIG_DIR` set): no mark.",
                "enum": [
                  "manual"
                ],
                "type": "string"
              }
            ]
          },
          "Listener": {
            "description": "One TCP socket in LISTEN state.",
            "properties": {
              "address": {
                "description": "Bound address, e.g. `0.0.0.0` or `::1`.",
                "type": "string"
              },
              "compose": {
                "description": "Compose namespace the process belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "family": {
                "allOf": [
                  {
                    "$ref": "#/definitions/AddressFamily"
                  }
                ],
                "description": "IPv4 or IPv6."
              },
              "location": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "tmux pane the process descends from."
              },
              "pid": {
                "description": "Owning process.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "port": {
                "description": "Port number.",
                "format": "uint16",
                "minimum": 0,
                "type": "integer"
              },
              "process": {
                "description": "Owning process name.",
                "type": "string"
              },
              "role": {
                "allOf": [
                  {
                    "$ref": "#/definitions/ListenerRole"
                  }
                ],
                "description": "What kind of process owns the socket."
              },
              "worker": {
                "description": "iii worker name, when known.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "address",
              "family",
              "pid",
              "port",
              "process",
              "role"
            ],
            "type": "object"
          },
          "ListenerRole": {
            "oneOf": [
              {
                "description": "An iii engine (its WebSocket and built-in listeners).",
                "enum": [
                  "engine"
                ],
                "type": "string"
              },
              {
                "description": "An iii worker.",
                "enum": [
                  "worker"
                ],
                "type": "string"
              },
              {
                "description": "An `iii compose` daemon.",
                "enum": [
                  "compose"
                ],
                "type": "string"
              },
              {
                "description": "Anything else.",
                "enum": [
                  "other"
                ],
                "type": "string"
              }
            ]
          },
          "Pane": {
            "properties": {
              "active": {
                "description": "The window's active pane.",
                "type": "boolean"
              },
              "agent": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AgentStatus"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The agent CLI running in this pane, if any."
              },
              "claude": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PaneClaude"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The Claude Code account the pane runs on and how it follows the global one. Present when the pane runs Claude Code or carries an account mark; absent otherwise and from workers before 0.3."
              },
              "command": {
                "description": "Foreground process name.",
                "type": "string"
              },
              "compose": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ComposeRef"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The `iii compose` daemon running in this pane, if any."
              },
              "cwd": {
                "description": "Current directory.",
                "type": "string"
              },
              "dead": {
                "description": "The pane's process exited and the pane is kept.",
                "type": "boolean"
              },
              "height": {
                "description": "Height in rows.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Pane id, e.g. `%5`.",
                "type": "string"
              },
              "index": {
                "description": "Pane index inside the window.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "pid": {
                "description": "Pid of the process tmux started in the pane.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "ports": {
                "description": "Listening sockets owned by processes started from this pane.",
                "items": {
                  "$ref": "#/definitions/Listener"
                },
                "type": "array"
              },
              "title": {
                "description": "Pane title set by the program.",
                "type": "string"
              },
              "width": {
                "description": "Width in columns.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "active",
              "command",
              "cwd",
              "dead",
              "height",
              "id",
              "index",
              "pid",
              "ports",
              "title",
              "width"
            ],
            "type": "object"
          },
          "PaneClaude": {
            "description": "The Claude Code account of one pane (agent-accounts D4, D5).",
            "properties": {
              "account": {
                "default": null,
                "description": "Id of the account the running Claude Code uses: the global account on the slot (`~/.claude`), else the account whose folder its `CLAUDE_CONFIG_DIR` names. Null when that folder is no registered account (see `config_dir`) or Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "config_dir": {
                "default": null,
                "description": "The config folder the running Claude Code uses, `~` for the home folder. Null when Claude Code is not running.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "follow": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Follow"
                  }
                ],
                "description": "`global`, `pinned` or `manual`."
              },
              "movable": {
                "description": "The worker can move this pane to another account.",
                "type": "boolean"
              },
              "move_error": {
                "description": "Why the last move of this pane (one that waited for its turn, or a switch of the global account) failed, in one sentence; cleared by the next account change of the pane.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "not_movable_reason": {
                "description": "Why it can't, in one sentence, when `movable` is false.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "pending": {
                "default": null,
                "description": "The account the pane moves to when its turn ends (`global`: the slot).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "session_id": {
                "default": null,
                "description": "Claude Code's session id, which a move resumes.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "skip_permissions": {
                "description": "Claude Code runs without permission prompts (`--dangerously-skip-permissions` or `--permission-mode bypassPermissions`).",
                "type": "boolean"
              }
            },
            "required": [
              "follow",
              "movable",
              "skip_permissions"
            ],
            "type": "object"
          },
          "PaneRef": {
            "description": "Where a process runs in tmux.",
            "properties": {
              "pane_id": {
                "description": "Pane id.",
                "type": "string"
              },
              "session": {
                "description": "Session name.",
                "type": "string"
              },
              "session_id": {
                "description": "Session id.",
                "type": "string"
              },
              "window_id": {
                "description": "Window id.",
                "type": "string"
              },
              "window_index": {
                "description": "Window index.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "pane_id",
              "session",
              "session_id",
              "window_id",
              "window_index"
            ],
            "type": "object"
          },
          "Session": {
            "properties": {
              "activity_at_ms": {
                "description": "Last activity in any of its windows.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "attached": {
                "description": "tmux clients attached, console terminals included.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "console_attached": {
                "description": "How many attached clients are console terminals.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "created_at_ms": {
                "description": "When the session was created.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "id": {
                "description": "Session id, e.g. `$5`.",
                "type": "string"
              },
              "name": {
                "description": "Session name.",
                "type": "string"
              },
              "windows": {
                "description": "Windows sorted by index.",
                "items": {
                  "$ref": "#/definitions/Window"
                },
                "type": "array"
              }
            },
            "required": [
              "activity_at_ms",
              "attached",
              "console_attached",
              "created_at_ms",
              "id",
              "name",
              "windows"
            ],
            "type": "object"
          },
          "SubagentStatus": {
            "description": "A sub-agent at work under an agent CLI.",
            "properties": {
              "depth": {
                "description": "1 for a sub-agent of the main agent, 2 for one of its sub-agents, ….",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "description": {
                "description": "What it was asked to do: Claude Code's task description, Codex's task path under the main agent (`review/tests`).",
                "type": "string"
              },
              "id": {
                "description": "Stable within the agent's session: Claude Code's agent id, Codex's thread id.",
                "type": "string"
              },
              "kind": {
                "description": "Claude Code's agent type (`general-purpose`, `Explore`, `fork`) or Codex's agent role; null when the agent names none.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "since_ms": {
                "description": "When it started its current task.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "depth",
              "description",
              "id",
              "since_ms"
            ],
            "type": "object"
          },
          "TmuxInfo": {
            "description": "Whether a usable tmux exists and which server this worker talks to.",
            "properties": {
              "available": {
                "description": "A usable tmux binary was found.",
                "type": "boolean"
              },
              "error": {
                "description": "Why tmux is unavailable, or the last listing error.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "installable": {
                "default": false,
                "description": "tmux is missing and `tmux::install` can try: a supported OS, the configured binary is plain `tmux`, not a path or another name, and this processor has an official build or this computer a package manager.",
                "type": "boolean"
              },
              "path": {
                "description": "Resolved tmux binary.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "server_running": {
                "description": "A tmux server is running on that socket.",
                "type": "boolean"
              },
              "socket_path": {
                "description": "Server socket, known while the server runs.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "version": {
                "description": "tmux version, e.g. `3.6`.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "available",
              "server_running"
            ],
            "type": "object"
          },
          "Window": {
            "properties": {
              "active": {
                "description": "This is the session's current window.",
                "type": "boolean"
              },
              "activity_at_ms": {
                "description": "Last output in the window.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "bell": {
                "description": "A bell rang in the window.",
                "type": "boolean"
              },
              "id": {
                "description": "Window id, e.g. `@3` (unique on the server).",
                "type": "string"
              },
              "index": {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "name": {
                "description": "Window name.",
                "type": "string"
              },
              "panes": {
                "description": "Panes sorted by index.",
                "items": {
                  "$ref": "#/definitions/Pane"
                },
                "type": "array"
              },
              "zoomed": {
                "description": "A pane is zoomed.",
                "type": "boolean"
              }
            },
            "required": [
              "active",
              "activity_at_ms",
              "bell",
              "id",
              "index",
              "name",
              "panes",
              "zoomed"
            ],
            "type": "object"
          }
        },
        "description": "Every session with its windows and panes.",
        "properties": {
          "generated_at_ms": {
            "description": "When the snapshot was taken.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "sessions": {
            "description": "Sessions sorted by name.",
            "items": {
              "$ref": "#/definitions/Session"
            },
            "type": "array"
          },
          "tmux": {
            "allOf": [
              {
                "$ref": "#/definitions/TmuxInfo"
              }
            ],
            "description": "tmux availability and server."
          }
        },
        "required": [
          "generated_at_ms",
          "sessions",
          "tmux"
        ],
        "title": "SessionsSnapshot",
        "type": "object"
      }
    },
    {
      "description": "Rename a tmux session.",
      "metadata": {},
      "name": "tmux::sessions::rename",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "description": "New name. No `:` or `.`.",
            "type": "string"
          },
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "session"
        ],
        "title": "RenameSessionInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "description": "New name.",
            "type": "string"
          },
          "session_id": {
            "description": "Session id.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "session_id"
        ],
        "title": "RenamedSession",
        "type": "object"
      }
    },
    {
      "description": "Whether tmux is installed, its version and path, and whether a tmux server is running on the configured socket.",
      "metadata": {},
      "name": "tmux::status",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "No parameters.",
        "title": "EmptyInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Whether a usable tmux exists and which server this worker talks to.",
        "properties": {
          "available": {
            "description": "A usable tmux binary was found.",
            "type": "boolean"
          },
          "error": {
            "description": "Why tmux is unavailable, or the last listing error.",
            "type": [
              "string",
              "null"
            ]
          },
          "installable": {
            "default": false,
            "description": "tmux is missing and `tmux::install` can try: a supported OS, the configured binary is plain `tmux`, not a path or another name, and this processor has an official build or this computer a package manager.",
            "type": "boolean"
          },
          "path": {
            "description": "Resolved tmux binary.",
            "type": [
              "string",
              "null"
            ]
          },
          "server_running": {
            "description": "A tmux server is running on that socket.",
            "type": "boolean"
          },
          "socket_path": {
            "description": "Server socket, known while the server runs.",
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "description": "tmux version, e.g. `3.6`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "available",
          "server_running"
        ],
        "title": "TmuxInfo",
        "type": "object"
      }
    },
    {
      "description": "What one sub-agent of the agent in a pane (Claude Code or Codex) has done so far, from the transcript the agent keeps on disk: the task it was given, what it wrote and reasoned, the tools it called and what they returned, oldest first. Works while the sub-agent runs (`working`) and after it finished, as long as the agent runs. Read-only.",
      "metadata": {},
      "name": "tmux::subagents::transcript",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "limit": {
            "default": null,
            "description": "The most items returned, the latest ones: 200 when absent, at most 1000.",
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "pane": {
            "description": "Pane id of the agent, e.g. `%5`.",
            "type": "string"
          },
          "subagent": {
            "description": "The sub-agent's id, from `agent.subagents[].id` in `tmux::sessions::list`.",
            "type": "string"
          }
        },
        "required": [
          "pane",
          "subagent"
        ],
        "title": "TranscriptInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "TranscriptItem": {
            "description": "One step of a sub-agent's transcript.",
            "properties": {
              "at_ms": {
                "description": "When the agent recorded it.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "error": {
                "default": false,
                "description": "The tool reported a failure (`tool_result` only).",
                "type": "boolean"
              },
              "kind": {
                "$ref": "#/definitions/TranscriptItemKind"
              },
              "text": {
                "description": "The text, cut at 4 000 characters (then ending in `…`). A tool call's is its main argument: the command, path, pattern or query, else the whole input as JSON.",
                "type": "string"
              },
              "tool": {
                "description": "The tool's name, on `tool_call` and `tool_result` items.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "kind",
              "text"
            ],
            "type": "object"
          },
          "TranscriptItemKind": {
            "oneOf": [
              {
                "description": "A message to the sub-agent after its task, from the agent that runs it.",
                "enum": [
                  "user"
                ],
                "type": "string"
              },
              {
                "description": "What the sub-agent wrote.",
                "enum": [
                  "text"
                ],
                "type": "string"
              },
              {
                "description": "Its reasoning, when the agent records it in clear.",
                "enum": [
                  "thinking"
                ],
                "type": "string"
              },
              {
                "description": "A tool it called, with the call's main argument.",
                "enum": [
                  "tool_call"
                ],
                "type": "string"
              },
              {
                "description": "What a tool returned.",
                "enum": [
                  "tool_result"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "What one sub-agent has done so far, from the transcript its agent keeps.",
        "properties": {
          "agent": {
            "description": "Matcher id of that agent: `claude` or `codex`.",
            "type": "string"
          },
          "items": {
            "description": "The latest items, oldest first, without the task.",
            "items": {
              "$ref": "#/definitions/TranscriptItem"
            },
            "type": "array"
          },
          "pane_id": {
            "description": "Pane id of the agent running the sub-agent.",
            "type": "string"
          },
          "prompt": {
            "description": "The task it was given, cut at 16 000 characters. Null when the transcript holds none; Codex keeps a sub-agent's task encrypted, so there it shows only the task's name and sender.",
            "type": [
              "string",
              "null"
            ]
          },
          "subagent_id": {
            "description": "The sub-agent's id, as in `agent.subagents`.",
            "type": "string"
          },
          "truncated": {
            "description": "Older items were left out: past `limit`, or before the last 4 MiB of the file.",
            "type": "boolean"
          },
          "working": {
            "description": "The sub-agent is still in its agent's `subagents` list.",
            "type": "boolean"
          }
        },
        "required": [
          "agent",
          "items",
          "pane_id",
          "subagent_id",
          "truncated",
          "working"
        ],
        "title": "SubagentTranscript",
        "type": "object"
      }
    },
    {
      "description": "Detach a console terminal's tmux client. The session keeps running.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::close",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "terminal_id"
        ],
        "title": "TerminalRef",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "closed": {
            "description": "False when the terminal was already gone.",
            "type": "boolean"
          }
        },
        "required": [
          "closed"
        ],
        "title": "CloseResponse",
        "type": "object"
      }
    },
    {
      "description": "Attach a console terminal to a tmux session as a real tmux client running in a PTY. Output is pushed to the page's handler.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::open",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "properties": {
          "cols": {
            "description": "Terminal width in columns (2..=500).",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          },
          "output_function_id": {
            "description": "Browser handler receiving output: `iii::tmux-ui::pty-output::console-<browser id>`.",
            "type": "string"
          },
          "rows": {
            "description": "Terminal height in rows (2..=500).",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          },
          "session": {
            "description": "Session id (`$5`) or exact name to attach to.",
            "type": "string"
          },
          "window": {
            "anyOf": [
              {
                "$ref": "#/definitions/WindowArg"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Window id (`@3`) or index to select before attaching."
          }
        },
        "required": [
          "cols",
          "output_function_id",
          "rows",
          "session"
        ],
        "title": "OpenRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "access_key": {
            "description": "Short-lived credential required by every other call. Never persist it.",
            "type": "string"
          },
          "client_tty": {
            "description": "The tmux client's tty, as `list-clients` shows it.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "description": "Session the client attached to.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle for the other calls.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "session_id",
          "terminal_id"
        ],
        "title": "OpenResponse",
        "type": "object"
      }
    },
    {
      "description": "Ask tmux to repaint the console terminal's whole screen (refresh-client).",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::redraw",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "terminal_id"
        ],
        "title": "TerminalRef",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "description": "Always true.",
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OkResponse",
        "type": "object"
      }
    },
    {
      "description": "Re-send buffered output frames after a sequence, for gap repair.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::replay",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "after_sequence": {
            "description": "Last sequence the page applied; frames after it are returned.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "after_sequence",
          "terminal_id"
        ],
        "title": "ReplayRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "OutputFrame": {
            "properties": {
              "data": {
                "type": "string"
              },
              "sequence": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "data",
              "sequence"
            ],
            "type": "object"
          }
        },
        "properties": {
          "frames": {
            "items": {
              "$ref": "#/definitions/OutputFrame"
            },
            "type": "array"
          },
          "next_sequence": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          }
        },
        "required": [
          "frames",
          "next_sequence",
          "truncated"
        ],
        "title": "Replay",
        "type": "object"
      }
    },
    {
      "description": "Resize a console terminal; also its heartbeat.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::resize",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "cols": {
            "description": "Width in columns (2..=500).",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          },
          "rows": {
            "description": "Height in rows (2..=500).",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "cols",
          "rows",
          "terminal_id"
        ],
        "title": "ResizeRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "cols": {
            "description": "Width applied.",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          },
          "rows": {
            "description": "Height applied.",
            "format": "uint16",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "cols",
          "rows"
        ],
        "title": "ResizeResponse",
        "type": "object"
      }
    },
    {
      "description": "Move only this console terminal's tmux client to another session (switch-client), optionally selecting a window there.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::switch",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "session": {
            "description": "Session id (`$5`) or exact name to move this client to.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          },
          "window": {
            "anyOf": [
              {
                "$ref": "#/definitions/WindowArg"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Window id (`@3`) or index to select there."
          }
        },
        "required": [
          "access_key",
          "session",
          "terminal_id"
        ],
        "title": "SwitchRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "description": "Session the client now shows.",
            "type": "string"
          }
        },
        "required": [
          "session_id"
        ],
        "title": "SwitchResponse",
        "type": "object"
      }
    },
    {
      "description": "Save a file being pasted into a console terminal (any type, base64, at most 12 MiB) in a new folder of its own in the cache folder of the user this worker runs as, under its name made safe, and answer its path for the page to paste. It types nothing; uploads older than 7 days, and the oldest past 256 MiB, are removed.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::upload",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "data": {
            "description": "The file, base64, any type, at most 12 MiB decoded.",
            "type": "string"
          },
          "mime": {
            "default": null,
            "description": "Its type as the page knows it; the answer names what the bytes are when they are a known image.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "The file's name. Only its base name is kept, made one safe token: characters outside `A-Z a-z 0-9 . _ -` become `-`, no leading dot, at most 100 bytes; empty is `file`. A known image (PNG, JPEG, GIF, WebP) gets the extension its content has.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "data",
          "name",
          "terminal_id"
        ],
        "title": "UploadRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "bytes": {
            "description": "Its size in bytes.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "mime": {
            "description": "Its type: what the bytes are when they are a known image, else the request's, else `application/octet-stream`.",
            "type": "string"
          },
          "path": {
            "description": "Absolute path of the new file, to paste into the terminal as text (no spaces in its name).",
            "type": "string"
          }
        },
        "required": [
          "bytes",
          "mime",
          "path"
        ],
        "title": "UploadResponse",
        "type": "object"
      }
    },
    {
      "description": "Write base64 keyboard input to a console terminal's tmux client.",
      "metadata": {
        "internal": true,
        "trace_hidden": true
      },
      "name": "tmux::terminal::write",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Identifies one terminal and proves the caller opened it.",
        "properties": {
          "access_key": {
            "description": "Credential from `open`.",
            "type": "string"
          },
          "data": {
            "description": "Base64 keyboard input, at most 64 KiB decoded.",
            "type": "string"
          },
          "terminal_id": {
            "description": "Terminal handle from `open`.",
            "type": "string"
          }
        },
        "required": [
          "access_key",
          "data",
          "terminal_id"
        ],
        "title": "WriteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "written": {
            "description": "Bytes written to the tmux client.",
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "written"
        ],
        "title": "WriteResponse",
        "type": "object"
      }
    },
    {
      "description": "Serve the tmux worker's injected console UI assets (the target of its ade::ui::asset observers; the console calls it through each asset's observer with {path}).",
      "metadata": {
        "internal": true
      },
      "name": "tmux::ui-content",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Input of the content function: the console asks for one asset by path.",
        "properties": {
          "path": {
            "description": "The asset path from the observer's args (e.g. `state/page.js`).",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "UiContentInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Output of the content function.",
        "properties": {
          "content": {
            "description": "The asset source, verbatim.",
            "type": "string"
          },
          "content_type": {
            "description": "MIME type the console should serve the asset with.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "content_type"
        ],
        "title": "UiContentResult",
        "type": "object"
      }
    },
    {
      "description": "The weekly usage of Claude Code (per account: 5-hour window, week, per-model weeks, each with when it resets) and of Codex (plan, 5-hour window, week, credits), with the Claude Code accounts, the global one, the rules and any suggestion. The same object the live feed carries as `usage`. Readings are at most five minutes old while the app watches; refresh asks again now (at most once a minute per account). Never returns a token.",
      "metadata": {},
      "name": "tmux::usage::read",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "refresh": {
            "default": null,
            "description": "Read every signed-in account again now instead of returning the latest readings (each account at most once a minute).",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "title": "UsageReadInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "AccountSwitch": {
            "description": "The latest change of the global account.",
            "properties": {
              "after_turn": {
                "description": "Panes pinned to the old global account that restart on its folder when their turn ends.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "at_ms": {
                "description": "When it happened.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "auto": {
                "description": "The worker switched by itself (rules mode `switch`).",
                "type": "boolean"
              },
              "back_at_ms": {
                "description": "With `back_after_reset`: when `from`'s window resets and the worker switches back.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "following": {
                "default": 0,
                "description": "Claude Code panes on the slot that switched with it, on their next message.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account before.",
                "type": "string"
              },
              "reason": {
                "default": null,
                "description": "`week_80`, `week_90`, `limit`, `five_hour` or `back` for an automatic switch; `login` (someone signed in to a known account with `/login`), `login_new` (to a new one, added then), `upgrade` (the worker took the slot's sign-in for global when it was updated); null when someone switched.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "restarted": {
                "default": [],
                "description": "Pinned panes restarted: the new global account's (now on the slot) and the old one's (now on its folder).",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "to": {
                "description": "The global account after.",
                "type": "string"
              }
            },
            "required": [
              "after_turn",
              "at_ms",
              "auto",
              "from",
              "to"
            ],
            "type": "object"
          },
          "ClaudeAccount": {
            "description": "A Claude Code account (agent-accounts G1, G2): one sign-in, kept in the global slot while it is global and in its own folder otherwise.",
            "properties": {
              "color": {
                "description": "`blue`, `green`, `violet`, `orange` or `pink`.",
                "type": "string"
              },
              "dir": {
                "description": "Its folder, absolute: `<accounts root>/<id>`. Without `accounts.json`, the one account (`default`) has none, and this is `~/.claude`.",
                "type": "string"
              },
              "dir_display": {
                "description": "Its folder with `~` for the home folder.",
                "type": "string"
              },
              "email": {
                "default": null,
                "description": "The signed-in email.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "id": {
                "description": "`default` for the sign-in `~/.claude` had when accounts began, else a slug of its first name.",
                "type": "string"
              },
              "is_default": {
                "description": "Its id is `default`.",
                "type": "boolean"
              },
              "name": {
                "description": "The name people gave it.",
                "type": "string"
              },
              "organization": {
                "default": null,
                "description": "The organization it belongs to.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "panes": {
                "description": "Claude Code panes using it now (for the global account, every pane on the slot, its followers included).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "plan": {
                "default": null,
                "description": "`pro`, `max`, `team`, `enterprise` or what Claude Code recorded.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "shared": {
                "description": "The groups its folder shares with `~/.claude`: `settings`, `extensions`, `plugins`, `conversations`.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "signed_in": {
                "description": "It holds a Claude sign-in.",
                "type": "boolean"
              },
              "tier": {
                "default": null,
                "description": "The rate-limit tier, e.g. `default_claude_max_20x`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "token_expired": {
                "description": "Its sign-in expired; running Claude Code there renews it.",
                "type": "boolean"
              },
              "usage": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ClaudeUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest usage reading."
              }
            },
            "required": [
              "color",
              "dir",
              "dir_display",
              "id",
              "is_default",
              "name",
              "panes",
              "shared",
              "signed_in",
              "token_expired"
            ],
            "type": "object"
          },
          "ClaudeLogin": {
            "description": "A sign-in of a Claude Code account from the app (claude-login-ui).",
            "properties": {
              "account": {
                "description": "The account signing in.",
                "type": "string"
              },
              "browser": {
                "$ref": "#/definitions/LoginBrowser"
              },
              "email": {
                "description": "The email the sign-in page is filled with (the account's).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "error": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/LoginError"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "With `failed` and `expired`: why."
              },
              "expires_at_ms": {
                "description": "When the link stops working and Claude Code is stopped.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "login_id": {
                "description": "Pass it to `tmux::accounts::login_code` and `login_cancel`.",
                "type": "string"
              },
              "state": {
                "$ref": "#/definitions/LoginState"
              },
              "url": {
                "description": "The sign-in page to open on any device: it shows the code to paste.",
                "type": "string"
              }
            },
            "required": [
              "account",
              "browser",
              "expires_at_ms",
              "login_id",
              "state",
              "url"
            ],
            "type": "object"
          },
          "ClaudeSnapshot": {
            "description": "Claude Code's accounts as the worker sees them.",
            "properties": {
              "accounts": {
                "description": "The default account first, then the others in the order they were added.",
                "items": {
                  "$ref": "#/definitions/ClaudeAccount"
                },
                "type": "array"
              },
              "available": {
                "description": "A `claude` binary is on PATH or `~/.claude` exists.",
                "type": "boolean"
              },
              "global": {
                "description": "Id of the global account: the sign-in of the slot (`~/.claude`), what plain `claude` uses anywhere.",
                "type": "string"
              },
              "last_switch": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/AccountSwitch"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The latest change of the global account."
              },
              "logins": {
                "default": [],
                "description": "Sign-ins under way (`tmux::accounts::login_start`), and those that ended in the last minute, oldest first.",
                "items": {
                  "$ref": "#/definitions/ClaudeLogin"
                },
                "type": "array"
              },
              "managed": {
                "description": "The accounts registry exists (an account was added or a setting saved).",
                "type": "boolean"
              },
              "pending_global": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/PendingGlobal"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "A switch of the global account that waits for windows on the new account's folder to finish their turn."
              },
              "rules": {
                "allOf": [
                  {
                    "$ref": "#/definitions/SwitchRules"
                  }
                ],
                "description": "The rules for the global account."
              },
              "runs_as_root": {
                "description": "The worker runs as root, where Claude Code refuses `--dangerously-skip-permissions`.",
                "type": "boolean"
              },
              "suggestion": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Suggestion"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Another account suggested for global, while the global one is low."
              },
              "switch_delay_s": {
                "default": 0,
                "description": "How long a running Claude Code may take to notice a switch, in seconds: 0 on Linux (its next message), 30 on macOS (the Keychain).",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "accounts",
              "available",
              "global",
              "managed",
              "rules",
              "runs_as_root"
            ],
            "type": "object"
          },
          "ClaudeUsage": {
            "description": "One reading of a Claude Code account's usage.",
            "properties": {
              "as_of_ms": {
                "description": "When this reading was taken.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "error": {
                "default": null,
                "description": "Why the latest attempt to read failed: `rate_limited`, `unauthorized`, `network`, `token_expired`, `not_signed_in`, `unreadable`. The windows are then the last good reading, if any.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "extra": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ExtraUsage"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Usage beyond the plan."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The current 5-hour window."
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, all models."
              },
              "week_models": {
                "default": [],
                "description": "Every per-model weekly window the account has, Opus and Sonnet included.",
                "items": {
                  "$ref": "#/definitions/ModelLimit"
                },
                "type": "array"
              },
              "week_opus": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Opus only."
              },
              "week_sonnet": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week, Sonnet only."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "CodexCredits": {
            "description": "Codex's credits.",
            "properties": {
              "balance": {
                "description": "The balance as Codex reports it, e.g. `62500.0000000000`.",
                "type": "string"
              },
              "unlimited": {
                "description": "Credits are unlimited.",
                "type": "boolean"
              }
            },
            "required": [
              "balance",
              "unlimited"
            ],
            "type": "object"
          },
          "CodexUsage": {
            "description": "Codex's usage, from the newest session it recorded (agent-accounts D13).",
            "properties": {
              "as_of_ms": {
                "description": "When Codex recorded it.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "credits": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/CodexCredits"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "Credits, when the plan has them."
              },
              "five_hour": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The 5-hour window, when the plan has one."
              },
              "plan": {
                "default": null,
                "description": "The ChatGPT plan, e.g. `pro`.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "week": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  },
                  {
                    "type": "null"
                  }
                ],
                "default": null,
                "description": "The week."
              }
            },
            "required": [
              "as_of_ms"
            ],
            "type": "object"
          },
          "ExtraUsage": {
            "description": "Usage beyond the plan.",
            "properties": {
              "enabled": {
                "description": "Extra usage is turned on for the account.",
                "type": "boolean"
              },
              "used_percent": {
                "default": null,
                "description": "How much of its monthly limit is used, 0 to 100, when there is one.",
                "format": "double",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "enabled"
            ],
            "type": "object"
          },
          "Limit": {
            "description": "One usage window of an account.",
            "properties": {
              "reset_since_read": {
                "default": false,
                "description": "The window reset after the reading, so `used_percent` is 0 until the next reading.",
                "type": "boolean"
              },
              "resets_at_ms": {
                "default": null,
                "description": "When the window starts again.",
                "format": "uint64",
                "minimum": 0,
                "type": [
                  "integer",
                  "null"
                ]
              },
              "used_percent": {
                "description": "How much of the window is used, 0 to 100.",
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "used_percent"
            ],
            "type": "object"
          },
          "LoginBrowser": {
            "description": "Who may open the sign-in page on the computer the worker runs on.",
            "oneOf": [
              {
                "description": "Nobody: Claude Code opens no browser; the link is shown elsewhere and the code from the page is pasted back.",
                "enum": [
                  "none"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code opens the browser there, whose return to its local listener finishes the sign-in with no code (the app runs on that computer).",
                "enum": [
                  "host"
                ],
                "type": "string"
              }
            ]
          },
          "LoginError": {
            "description": "Why a sign-in failed, as `tmux::accounts::login_code` answers it.",
            "properties": {
              "code": {
                "description": "`rejected` (Anthropic didn't accept the code; Claude Code ended), `expired`, `gone` or `failed`.",
                "type": "string"
              },
              "message": {
                "description": "One sentence.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "LoginState": {
            "description": "Where a sign-in is.",
            "oneOf": [
              {
                "description": "Claude Code shows the link and waits for the code.",
                "enum": [
                  "waiting_code"
                ],
                "type": "string"
              },
              {
                "description": "Claude Code is checking a code with Anthropic.",
                "enum": [
                  "checking"
                ],
                "type": "string"
              },
              {
                "description": "Signed in.",
                "enum": [
                  "done"
                ],
                "type": "string"
              },
              {
                "description": "It ended without a sign-in (`error` says why).",
                "enum": [
                  "failed"
                ],
                "type": "string"
              },
              {
                "description": "The link's 10 minutes ran out; Claude Code was stopped.",
                "enum": [
                  "expired"
                ],
                "type": "string"
              }
            ]
          },
          "ModelLimit": {
            "description": "A weekly window of one model family (Claude Code's `weekly_scoped` limits).",
            "properties": {
              "limit": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Limit"
                  }
                ],
                "description": "The window."
              },
              "name": {
                "description": "The model's display name, e.g. `Opus`.",
                "type": "string"
              }
            },
            "required": [
              "limit",
              "name"
            ],
            "type": "object"
          },
          "PendingGlobal": {
            "description": "A switch of the global account waiting for windows to finish their turn (agent-accounts G4).",
            "properties": {
              "account": {
                "description": "The account becoming global.",
                "type": "string"
              },
              "at_ms": {
                "description": "When it was asked for.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "by": {
                "description": "`person` or `rule`.",
                "type": "string"
              },
              "waiting_for": {
                "description": "The Claude Code panes on its folder still working or waiting.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "account",
              "at_ms",
              "by",
              "waiting_for"
            ],
            "type": "object"
          },
          "RulesMode": {
            "description": "What the worker does when the global account runs low.",
            "oneOf": [
              {
                "description": "Nothing.",
                "enum": [
                  "off"
                ],
                "type": "string"
              },
              {
                "description": "Suggest another account.",
                "enum": [
                  "suggest"
                ],
                "type": "string"
              },
              {
                "description": "Make another account global by itself.",
                "enum": [
                  "switch"
                ],
                "type": "string"
              }
            ]
          },
          "Suggestion": {
            "description": "Another account suggested for global.",
            "properties": {
              "at_ms": {
                "description": "When the reason was first seen.",
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "following": {
                "description": "Claude Code panes on the slot that are not pinned: they switch with the global account.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "from": {
                "description": "The global account.",
                "type": "string"
              },
              "id": {
                "description": "Pass it to `tmux::accounts::dismiss`.",
                "type": "string"
              },
              "reason": {
                "description": "`week_80`, `week_90`, `limit` or `five_hour`.",
                "type": "string"
              },
              "to": {
                "description": "The account suggested.",
                "type": "string"
              }
            },
            "required": [
              "at_ms",
              "following",
              "from",
              "id",
              "reason",
              "to"
            ],
            "type": "object"
          },
          "SwitchRules": {
            "description": "The rules for the global account (agent-accounts D14).",
            "properties": {
              "at": {
                "allOf": [
                  {
                    "$ref": "#/definitions/Threshold"
                  }
                ],
                "default": "week_90",
                "description": "`week_80`, `week_90` or `limit`."
              },
              "back_after_reset": {
                "default": false,
                "description": "After switching away by itself, switch back once that account's window resets.",
                "type": "boolean"
              },
              "five_hour": {
                "default": false,
                "description": "Also act when the 5-hour window reaches 100 %.",
                "type": "boolean"
              },
              "mode": {
                "allOf": [
                  {
                    "$ref": "#/definitions/RulesMode"
                  }
                ],
                "default": "suggest",
                "description": "`off`, `suggest` or `switch`."
              },
              "order": {
                "default": [],
                "description": "Accounts to try first, in order; then the one with most room this week.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "Threshold": {
            "description": "When the global account counts as low.",
            "oneOf": [
              {
                "description": "80 % of the week.",
                "enum": [
                  "week_80"
                ],
                "type": "string"
              },
              {
                "description": "90 % of the week.",
                "enum": [
                  "week_90"
                ],
                "type": "string"
              },
              {
                "description": "The week's limit.",
                "enum": [
                  "limit"
                ],
                "type": "string"
              }
            ]
          }
        },
        "description": "Claude Code accounts and the weekly usage of Claude Code and Codex.",
        "properties": {
          "claude": {
            "allOf": [
              {
                "$ref": "#/definitions/ClaudeSnapshot"
              }
            ],
            "description": "Claude Code's accounts and their usage."
          },
          "codex": {
            "anyOf": [
              {
                "$ref": "#/definitions/CodexUsage"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Codex's usage, when Codex recorded any."
          },
          "generated_at_ms": {
            "description": "When the snapshot was taken.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "claude",
          "generated_at_ms"
        ],
        "title": "UsageSnapshot",
        "type": "object"
      }
    },
    {
      "description": "Create a window in a tmux session. Optional name, working directory (default: the directory the session was created in), a shell command to run instead of the default shell, and whether to make it the current window (default true). With remain_on_exit, its pane stays once its program ends, dead, for tmux::panes::respawn to restart it.",
      "metadata": {},
      "name": "tmux::windows::create",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ClaudeLaunchInput": {
            "description": "`claude` on tmux::windows::create and tmux::sessions::create.",
            "properties": {
              "account": {
                "default": "global",
                "description": "`global` (the default: it runs on the global account and moves when that changes) or an account id (pinned to it).",
                "type": "string"
              },
              "skip_permissions": {
                "default": false,
                "description": "Start it with --dangerously-skip-permissions (default false). Refused when the host runs as root.",
                "type": "boolean"
              }
            },
            "type": "object"
          }
        },
        "properties": {
          "claude": {
            "anyOf": [
              {
                "$ref": "#/definitions/ClaudeLaunchInput"
              },
              {
                "type": "null"
              }
            ],
            "description": "Start Claude Code on an account instead of `command` (not both): the worker builds the command (returned as `runs`) and marks the pane with its account."
          },
          "command": {
            "default": null,
            "description": "Shell command to run instead of the default shell.",
            "type": [
              "string",
              "null"
            ]
          },
          "cwd": {
            "default": null,
            "description": "Working directory, absolute or `~/…`. Defaults to the directory the session was created in (the home folder on tmux older than 3.2, which can't tell).",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "default": null,
            "description": "Window name. No `:` or `.`.",
            "type": [
              "string",
              "null"
            ]
          },
          "remain_on_exit": {
            "default": false,
            "description": "Keep its pane once its program ends, shown dead, so tmux::panes::respawn can restart it (default false: tmux closes it). On tmux before 3.0, which has no pane options, every pane of the window is kept.",
            "type": "boolean"
          },
          "select": {
            "default": null,
            "description": "Make it the session's current window (default true).",
            "type": [
              "boolean",
              "null"
            ]
          },
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          }
        },
        "required": [
          "session"
        ],
        "title": "CreateWindowInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "pane_id": {
            "description": "Its first pane id.",
            "type": "string"
          },
          "runs": {
            "description": "With `claude`: the exact command the pane runs.",
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "description": "Session id.",
            "type": "string"
          },
          "window_id": {
            "description": "New window id, e.g. `@9`.",
            "type": "string"
          },
          "window_index": {
            "description": "New window index.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "pane_id",
          "session_id",
          "window_id",
          "window_index"
        ],
        "title": "CreatedWindow",
        "type": "object"
      }
    },
    {
      "description": "Kill a tmux window and every program running in its panes.",
      "metadata": {},
      "name": "tmux::windows::kill",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "properties": {
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          },
          "window": {
            "allOf": [
              {
                "$ref": "#/definitions/WindowArg"
              }
            ],
            "description": "Window id (`@3`) or index."
          }
        },
        "required": [
          "session",
          "window"
        ],
        "title": "WindowInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "killed": {
            "description": "Always true.",
            "type": "boolean"
          }
        },
        "required": [
          "killed"
        ],
        "title": "KilledOutput",
        "type": "object"
      }
    },
    {
      "description": "Move a window to another tmux session, after its last window or just before or after one of its windows (`before` / `after`, which need tmux 3.2 or later and also reorder a window inside its own session). The window keeps its id, panes and programs, and the destination session's current window stays as it was. When it was the last window of its session, tmux closes that session.",
      "metadata": {},
      "name": "tmux::windows::move",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "properties": {
          "after": {
            "anyOf": [
              {
                "$ref": "#/definitions/WindowArg"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Put it just after this window of `target_session` (id or index). Needs tmux 3.2 or later. Without `before` or `after` it goes after the session's last window."
          },
          "before": {
            "anyOf": [
              {
                "$ref": "#/definitions/WindowArg"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Put it just before this window of `target_session` (id or index). Needs tmux 3.2 or later."
          },
          "session": {
            "description": "Session id (`$5`) or exact name of the session the window is in.",
            "type": "string"
          },
          "target_session": {
            "description": "Session id (`$5`) or exact name of the session to move it to. Its own session reorders it, with `before` or `after`.",
            "type": "string"
          },
          "window": {
            "allOf": [
              {
                "$ref": "#/definitions/WindowArg"
              }
            ],
            "description": "Window id (`@3`) or index."
          }
        },
        "required": [
          "session",
          "target_session",
          "window"
        ],
        "title": "MoveWindowInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "description": "Id of the session the window is in now.",
            "type": "string"
          },
          "source_session_closed": {
            "description": "It was the last window of its session, so tmux closed that session.",
            "type": "boolean"
          },
          "window_id": {
            "description": "Window id, the same as before the move.",
            "type": "string"
          },
          "window_index": {
            "description": "Its index in that session now.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "session_id",
          "source_session_closed",
          "window_id",
          "window_index"
        ],
        "title": "MovedWindow",
        "type": "object"
      }
    },
    {
      "description": "Rename a tmux window.",
      "metadata": {},
      "name": "tmux::windows::rename",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "properties": {
          "name": {
            "description": "New name. No `:` or `.`.",
            "type": "string"
          },
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          },
          "window": {
            "allOf": [
              {
                "$ref": "#/definitions/WindowArg"
              }
            ],
            "description": "Window id (`@3`) or index."
          }
        },
        "required": [
          "name",
          "session",
          "window"
        ],
        "title": "RenameWindowInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "name": {
            "description": "New name.",
            "type": "string"
          },
          "window_id": {
            "description": "Window id.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "window_id"
        ],
        "title": "RenamedWindow",
        "type": "object"
      }
    },
    {
      "description": "Make a window the current window of its session. Like tmux itself, every client attached to that session (your terminal included) switches to it.",
      "metadata": {},
      "name": "tmux::windows::select",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "WindowArg": {
            "anyOf": [
              {
                "description": "Window index inside the session.",
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              {
                "description": "Window id like `@3`, or an index as text.",
                "type": "string"
              }
            ],
            "description": "A window as callers name it: an id (`\"@3\"`) or an index (`2` or `\"2\"`)."
          }
        },
        "properties": {
          "session": {
            "description": "Session id (`$5`) or exact name.",
            "type": "string"
          },
          "window": {
            "allOf": [
              {
                "$ref": "#/definitions/WindowArg"
              }
            ],
            "description": "Window id (`@3`) or index."
          }
        },
        "required": [
          "session",
          "window"
        ],
        "title": "WindowInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "session_id": {
            "description": "Session id.",
            "type": "string"
          },
          "window_id": {
            "description": "Window id now current.",
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "window_id"
        ],
        "title": "SelectedWindow",
        "type": "object"
      }
    }
  ]
}
```
