Skip to content

Computer use CLI for AI agents

docs: add the reference for all 60 commands and configuration (3/4) (#339)

Lahfire5e72ec8d65e
diff --git a/apps/docs/content/docs/commands/app-window.mdx b/apps/docs/content/docs/commands/app-window.mdx
new file mode 100644
index 000000000..7c8d2f419
--- /dev/null
+++ b/apps/docs/content/docs/commands/app-window.mdx
@@ -0,0 +1,420 @@
+---
+title: App and window commands
+navTitle: App and window
+description: Reference for launch, close-app, list-apps, list-windows, focus-window, resize-window, move-window, minimize, maximize, and restore.
+---
+
+These commands start and stop apps and manage their windows. `--app` takes the name that `list-apps` prints. A window id from `list-windows` is the exact selector when an app has several windows.
+
+The window commands (`resize-window`, `move-window`, `minimize`, `maximize`, `restore`) pick their target the same way:
+
+- `--window-id` selects that window. `--app` can narrow the search but is not required.
+- `--app` alone selects the app, then one of its windows: its only window if it has one, otherwise the visible ones, then the single focused one, then the accessible ones. If that does not settle on one window, the command fails with `AMBIGUOUS_TARGET`.
+- With neither flag, the target is the focused window.
+
+`close-app` and the five window commands return an [OperationReport](/desktop/json-output#operationreport): read `disposition.delivery` to learn what was proved. Lookup failures such as `APP_NOT_FOUND` and `WINDOW_NOT_FOUND` carry `not_delivered`, so they are safe to retry once the name or id is fixed. The examples on this page are real output from GNOME apps on Linux.
+
+## launch
+
+Starts an app, or attaches to a running instance, and returns once its process is running. A running process and a visible window are separate facts, so `window` appears in the result only when the app already has one.
+
+```bash
+agent-desktop launch <APP> [--timeout MS] [--arg VALUE]... [--env KEY=VALUE]... [--cwd PATH] \
+ [--no-attach] [--activate] [--cdp [PORT]]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>APP</code></td><td>required</td><td>Application name, bundle ID, or path. The accepted forms depend on the platform.</td></tr>
+ <tr><td><code>--timeout MS</code></td><td><code>30000</code></td><td>Upper bound for the whole launch.</td></tr>
+ <tr><td><code>--arg VALUE</code></td><td>none</td><td>Command-line argument for the app. Repeatable, order preserved. Write <code>--arg=-x</code> for a value that starts with a hyphen.</td></tr>
+ <tr><td><code>--env KEY=VALUE</code></td><td>none</td><td>Environment variable for the launched process. Repeatable. A repeated key is <code>INVALID_ARGS</code>.</td></tr>
+ <tr><td><code>--cwd PATH</code></td><td>none</td><td>Working directory for the launched process.</td></tr>
+ <tr><td><code>--no-attach</code></td><td>off</td><td>Start a fresh instance instead of attaching to a running one.</td></tr>
+ <tr><td><code>--activate</code></td><td>off</td><td>Bring the app forward so it presents a window, and wait for one up to <code>--timeout</code>. This takes the foreground.</td></tr>
+ <tr><td><code>--cdp [PORT]</code></td><td>off</td><td>Launch with a loopback-only Chrome DevTools Protocol endpoint and verify that it answers. Omit <code>PORT</code>, or pass <code>0</code>, to pick a free port.</td></tr>
+ </tbody>
+</table>
+
+```bash
+agent-desktop launch gtk3-demo
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "launch",
+ "data": {
+ "app": "gtk3-demo",
+ "pid": 21766,
+ "process_instance": "6d91df60:120710",
+ "window": {
+ "accessible": true,
+ "app_name": "gtk3-demo",
+ "bounds": { "height": 656.0, "width": 810.0, "x": 630.0, "y": 0.0 },
+ "id": "w-1.105-org-a11y-atspi-accessible-48",
+ "is_focused": true,
+ "minimized": false,
+ "pid": 21766,
+ "process_instance": "6d91df60:120710",
+ "title": "Application Class",
+ "visible": true
+ }
+ }
+}
+```
+
+The result also carries `cdp` when `--cdp` was verified, `renderer: "chromium"` for a detected Chromium or Electron app, and sometimes a `suggestion`. A missing `window` is not a failure. With `--cdp`, `data.cdp` holds `http_endpoint`, `port`, `product`, and `websocket_url` for a CDP client such as agent-browser.
+
+Errors specific to `launch`:
+
+<table>
+ <thead>
+ <tr><th>Code and detail</th><th>Cause</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>APP_NOT_FOUND</code></td><td>The name does not resolve to an app.</td></tr>
+ <tr><td><code>AMBIGUOUS_TARGET</code></td><td>Several running instances match.</td></tr>
+ <tr><td><code>APP_UNRESPONSIVE</code></td><td>The process exited before it showed a window.</td></tr>
+ <tr><td><code>ACTION_FAILED</code>, <code>details.kind: cdp_requires_fresh_launch</code></td><td><code>--cdp</code> on an app that is already running. <code>launch</code> never quits a running app for you; run <code>close-app</code>, then launch again.</td></tr>
+ <tr><td><code>INVALID_ARGS</code>, <code>details.kind: cdp_port_in_use</code> or <code>cdp_switch_conflict</code></td><td>The named port is bound, or an <code>--arg</code> sets a remote-debugging switch that <code>--cdp</code> owns.</td></tr>
+ <tr><td><code>ACTION_FAILED</code>, <code>details.kind: cdp_endpoint_unavailable</code></td><td>The app started but no verified DevTools endpoint answered. The app stays running.</td></tr>
+ </tbody>
+</table>
+
+Platform limits: the accepted `APP` forms differ by OS. See [macOS](/desktop/platforms/macos#app-naming), [Windows](/desktop/platforms/windows#app-naming), and [Linux](/desktop/platforms/linux#app-naming).
+
+## close-app
+
+Quits an app and all its windows, and succeeds only after the process is seen gone. No command closes a single window: click that window's Close button instead.
+
+```bash
+agent-desktop close-app <APP> [--force]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>APP</code></td><td>required</td><td>Application name as <code>list-apps</code> prints it.</td></tr>
+ <tr><td><code>--force</code></td><td>off</td><td>Terminate the process instead of quitting gracefully.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "close-app",
+ "data": {
+ "action": "close-app",
+ "app": "gtk3-demo",
+ "details": { "evidence": "process_instance_exited" },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "method": "graceful",
+ "steps": [
+ { "label": "terminate_request", "mechanism": "semantic_api", "outcome": "succeeded" },
+ { "label": "process_exit", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }
+ ],
+ "target": {
+ "kind": "app",
+ "name": "gtk3-demo",
+ "process": { "instance": "6d91df60:120710", "pid": 21766 }
+ }
+ }
+}
+```
+
+`method` is `graceful` or `force`. If the app had already exited, the report is `not_delivered` with `details.evidence: "process_instance_not_running"`. Errors specific to `close-app`:
+
+- `APP_NOT_FOUND` when no running app matches, `AMBIGUOUS_TARGET` when several instances share the name.
+- `INVALID_ARGS` for a protected system process, with or without `--force`.
+- A save prompt keeps the app open. Read it with `snapshot --surface sheet`, answer it, then close again.
+
+Platform limits: graceful close needs an X11 client on Linux, and the protected processes differ by OS. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
+
+## list-apps
+
+Lists running GUI apps.
+
+```bash
+agent-desktop list-apps [--app NAME] [--timeout-ms MS]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>all apps</td><td>Filter by name, case-insensitively.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Deadline for the inventory.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "list-apps",
+ "data": {
+ "apps": [
+ {
+ "bundle_id": "org.gnome.Calculator",
+ "name": "gnome-calculator",
+ "pid": 8255,
+ "presentation": "foreground",
+ "process_instance": "6d91df60:28340"
+ }
+ ]
+ }
+}
+```
+
+`presentation` is `foreground` for apps with ordinary windows and `background` for apps with no Dock or taskbar entry. When the platform could not read every process in time, the result adds `complete: false` and a `skipped` array: treat a missing app as unknown, not absent.
+
+`--app` takes the `list-apps` name; Linux also accepts a desktop-entry name. See [Linux](/desktop/platforms/linux#app-naming).
+
+## list-windows
+
+Lists windows. `data` is the array itself.
+
+```bash
+agent-desktop list-windows [--app NAME] [--timeout-ms MS]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>all apps</td><td>Filter to one app by exact, case-insensitive name.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Deadline for the inventory.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "list-windows",
+ "data": [
+ {
+ "accessible": true,
+ "app_name": "gnome-calculator",
+ "bounds": { "height": 616.0, "width": 370.0, "x": 535.0, "y": 142.0 },
+ "id": "w-1.11-org-gnome-Calculator-a11y-948fd89a_9bda_453b_9c10_4a9e9eed3feb",
+ "is_focused": false,
+ "minimized": false,
+ "pid": 8255,
+ "process_instance": "6d91df60:28340",
+ "title": "Calculator",
+ "visible": true
+ }
+ ]
+}
+```
+
+`accessible: false` means semantic commands cannot reach that window; it still accepts screenshots and coordinate input. Errors: `APP_NOT_FOUND` for an unknown `--app`, `APP_UNRESPONSIVE` for a stopped app, and `TIMEOUT` when a busy app left every window unanswered. A timeout is not an empty list.
+
+## focus-window
+
+Brings a window to the front and succeeds only when the OS reports that window as focused on two consecutive reads.
+
+```bash
+agent-desktop focus-window [--window-id ID] [--app NAME] [--title TEXT]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Window id from <code>list-windows</code>.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>none</td><td>Application name.</td></tr>
+ <tr><td><code>--title TEXT</code></td><td>none</td><td>Window title, partial match. Combine with <code>--app</code> to narrow.</td></tr>
+ </tbody>
+</table>
+
+Pass at least one flag; with none the command fails with `INVALID_ARGS`. `data.focused` is the window that holds focus afterward, with the same fields as a `list-windows` entry. When a modal dialog holds the focus, `focused` is the dialog, so read `focused.title` before you act.
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "focus-window",
+ "data": {
+ "focused": {
+ "app_name": "gedit",
+ "id": "w-1.10-org-a11y-atspi-accessible-162",
+ "is_focused": true,
+ "title": "Untitled Document 1 - gedit"
+ }
+ }
+}
+```
+
+The example above is trimmed to four fields. Errors: `WINDOW_NOT_FOUND` when nothing matches, `AMBIGUOUS_TARGET` when several windows still match, and `ACTION_FAILED` when the OS never reports the window focused. The command takes the foreground but does not need `--headed`.
+
+Platform limits: Linux needs X11. See [Linux](/desktop/platforms/linux) and [Windows](/desktop/platforms/windows).
+
+## resize-window
+
+Sets a window's width and height.
+
+```bash
+agent-desktop resize-window --width PX --height PX [--app NAME] [--window-id ID]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--width PX</code>, <code>--height PX</code></td><td>required</td><td>New window size.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>focused app</td><td>Application name.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Window id from <code>list-windows</code>.</td></tr>
+ </tbody>
+</table>
+
+```bash
+agent-desktop resize-window --app gedit --width 800 --height 600
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "resize-window",
+ "data": {
+ "action": "resize-window",
+ "details": {
+ "observed": {
+ "height": 600, "hidden": false, "maximized_horizontal": false,
+ "maximized_vertical": false, "width": 800, "x": 0, "y": 0
+ },
+ "tolerance": 2.0,
+ "units": "pixels",
+ "verification_scope": "window_size"
+ },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "height": 600.0,
+ "steps": [{ "label": "window_resize", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }],
+ "target": {
+ "id": "w-1.10-org-a11y-atspi-accessible-162",
+ "kind": "window",
+ "process": { "instance": "6d91df60:28341", "pid": 8261 },
+ "title": "Untitled Document 1 - gedit"
+ },
+ "width": 800.0
+ }
+}
+```
+
+`delivered_verified` means the adapter read the size back within `details.tolerance`. `details.observed` is a Linux addition. Errors: `INVALID_ARGS` for a non-finite or out-of-range size, `STALE_REF` when the window identity changed before the write, and `ACTION_FAILED` when the window manager clamped or ignored the request. After a failed write, read the bounds before you retry.
+
+Platform limits: the tolerance differs by OS, and on Linux window control uses an X11 client, so Wayland-native windows are refused. See [Linux](/desktop/platforms/linux).
+
+## move-window
+
+Moves a window to screen coordinates.
+
+```bash
+agent-desktop move-window --x=X --y=Y [--app NAME] [--window-id ID]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--x X</code>, <code>--y Y</code></td><td>required</td><td>New position. Write a negative value with <code>=</code>, as in <code>--x=-100</code>.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>focused app</td><td>Application name.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Window id from <code>list-windows</code>.</td></tr>
+ </tbody>
+</table>
+
+The result has the same shape as [`resize-window`](#resize-window), with step label `window_move`, request fields `x` and `y`, and `details.verification_scope: "window_position"`. Errors and platform limits are the same as `resize-window`.
+
+## minimize
+
+Minimizes a window.
+
+```bash
+agent-desktop minimize [--app NAME] [--window-id ID]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>focused app</td><td>Application name.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Window id from <code>list-windows</code>.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "minimize",
+ "data": {
+ "action": "minimize",
+ "details": { "verification_scope": "window_minimized_state" },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "steps": [{ "label": "window_minimize", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }],
+ "target": {
+ "id": "w-1.10-org-a11y-atspi-accessible-162",
+ "kind": "window",
+ "process": { "instance": "6d91df60:28341", "pid": 8261 },
+ "title": "Untitled Document 1 - gedit"
+ }
+ }
+}
+```
+
+A minimized window reports its elements as offscreen, so ref actions on it fail until you [`restore`](#restore) it. A window manager can ignore a minimize sent within about 250 ms of a restore, so read the window state before you retry. Platform limits are the same as `resize-window`.
+
+## maximize
+
+Maximizes a window, or zooms it on macOS. Flags are the same as [`minimize`](#minimize). The step label is `window_maximize`, and a verified report names `details.verification_scope: "window_maximized_state"`.
+
+```bash
+agent-desktop maximize [--app NAME] [--window-id ID]
+```
+
+## restore
+
+Restores a minimized or maximized window. Flags are the same as [`minimize`](#minimize).
+
+```bash
+agent-desktop restore [--app NAME] [--window-id ID]
+```
+
+`restore` has no single read-back across its cases, so a successful report is `delivered_unverified`:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "restore",
+ "data": {
+ "action": "restore",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "window_restore", "mechanism": "semantic_api", "outcome": "succeeded" }],
+ "target": {
+ "id": "w-1.10-org-a11y-atspi-accessible-162",
+ "kind": "window",
+ "process": { "instance": "6d91df60:28341", "pid": 8261 },
+ "title": "Untitled Document 1 - gedit"
+ }
+ }
+}
+```
+
+Check the window with `list-windows` afterward. Platform limits are the same as `resize-window`.
diff --git a/apps/docs/content/docs/commands/batch.mdx b/apps/docs/content/docs/commands/batch.mdx
new file mode 100644
index 000000000..b8f267117
--- /dev/null
+++ b/apps/docs/content/docs/commands/batch.mdx
@@ -0,0 +1,116 @@
+---
+title: batch
+navTitle: Batch
+description: Reference for batch, with the input format, limits, validation, stop-on-error behavior, which commands are refused, and the output shape.
+---
+
+`batch` runs a JSON array of commands in order, in one process. It is bounded, sequential, and non-atomic: a failed entry does not undo earlier ones. When to batch is in [Batching commands](/desktop/guides/batch).
+
+## batch
+
+```bash
+agent-desktop batch JSON [--stop-on-error] [--timeout-ms MS]
+agent-desktop batch '[{"command":"version"},{"command":"wait","args":{"ms":100}}]' --stop-on-error
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>JSON</code></td><td>required</td><td>A JSON array of entries.</td></tr>
+ <tr><td><code>--stop-on-error</code></td><td>off</td><td>Halt after the first entry that fails. Without it, later entries still run.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>60000</code></td><td>Wall-clock budget for the whole batch, at most 86400000. Each entry's own deadlines are capped by what remains.</td></tr>
+ </tbody>
+</table>
+
+### Entry format
+
+<table>
+ <thead>
+ <tr><th>Key</th><th>Required</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>command</code></td><td>yes</td><td>A command name such as <code>click</code> or <code>wait</code>.</td></tr>
+ <tr><td><code>args</code></td><td>no</td><td>The command's arguments. Omit it for a command with no arguments.</td></tr>
+ <tr><td><code>session</code></td><td>no</td><td>Session id for this entry. Without it, the entry uses the batch's own session.</td></tr>
+ </tbody>
+</table>
+
+`args` keys are the CLI flag names with hyphens turned into underscores (`window_id`, `timeout_ms`). A positional argument is named after its placeholder in lowercase (`ref_id`, `text`, `combo`, `app`). Repeatable flags take arrays. `wait` uses flat keys: `ms`, `element`, `predicate`, `value`, `action`, `window`, `text`, `count`, `menu`, `menu_closed`, `notification`, `event`, `window_id`, `app`, `timeout`. `skills`, `session`, and `trace` take their subcommand as `action`, as in `{"command":"session","args":{"action":"list"}}`. Unknown keys anywhere are rejected.
+
+`--headed` and the agent id apply to every entry. A global `--wait-for` does not; put a `wait` entry where you need one.
+
+### Limits
+
+<table>
+ <thead>
+ <tr><th>Limit</th><th>Value</th><th>When exceeded</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>Input size</td><td>1 MiB</td><td><code>INVALID_ARGS</code> before parsing.</td></tr>
+ <tr><td>Entries</td><td>64</td><td><code>INVALID_ARGS</code>.</td></tr>
+ <tr><td>Output size</td><td>4 MiB</td><td>The entry that crosses it becomes an <code>INVALID_ARGS</code> entry with <code>details.result_omitted: true</code>, and the batch stops with <code>stopped.reason: "output_limit"</code>.</td></tr>
+ </tbody>
+</table>
+
+### Validation before the first entry
+
+The whole array is checked before any entry runs, and one bad entry rejects the batch with nothing run:
+
+- The JSON must parse, and every entry must decode against its command's arguments.
+- Each entry gets the preflight a direct call gets: ref syntax (a bare `@e1` is rejected), flag combinations such as `snapshot --root` with `--surface`, and notification identity flags.
+- Each entry needs the permissions its command needs; a missing one returns `PERM_DENIED` for the whole batch.
+- In a multi-agent session, every mutating desktop entry needs an agent id.
+- `batch` (`Batch commands cannot be nested`) and `cursor-overlay` are refused inside a batch.
+
+The rejection names the entry in `details.batch_index` and `details.batch_command`, with `not_delivered`. Checks that need the live desktop, such as a stale ref or a headless physical command, happen when that entry runs and appear as that entry's own error.
+
+### Execution and output
+
+Entries run one at a time through the same dispatch as the CLI, so each entry's `data` or `error` is what a direct call returns. Nothing is retried. The batch itself returns `ok: true` and exit code `0` even when entries fail, so read each entry's `ok`.
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "batch",
+ "data": {
+ "completed_entries": 2,
+ "elapsed_ms": 100,
+ "limits": { "max_entries": 64, "max_input_bytes": 1048576, "max_output_bytes": 4194304 },
+ "not_started_entries": 0,
+ "results": [
+ { "command": "version", "data": { "os": "linux", "target": "x86_64", "version": "1.0.1" }, "execution": "completed", "index": 0, "ok": true, "version": "2.5" },
+ { "command": "wait", "data": { "waited_ms": 100 }, "execution": "completed", "index": 1, "ok": true, "version": "2.5" }
+ ],
+ "semantics": {
+ "atomic": false,
+ "batch_retries": false,
+ "command_retry_contracts": "preserved",
+ "error_disposition": "error.disposition",
+ "order": "sequential",
+ "successful_action_disposition": "data.disposition"
+ },
+ "timeout_ms": 60000,
+ "total_entries": 2
+ }
+}
+```
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>results[]</code></td><td>One envelope per entry, with <code>index</code> and <code>execution</code> (<code>completed</code> or <code>not_started</code>). A <code>not_started</code> entry has <code>not_started_reason</code> and a <code>not_delivered</code> error.</td></tr>
+ <tr><td><code>total_entries</code>, <code>completed_entries</code>, <code>not_started_entries</code></td><td>Counts. Entries after a stop are counted in <code>not_started_entries</code> without a row.</td></tr>
+ <tr><td><code>stopped</code></td><td>Present when the batch ended early: <code>reason</code> is <code>stop_on_error</code>, <code>deadline</code>, <code>output_limit</code>, or <code>pre_action_baseline_failed</code>, with the <code>index</code>.</td></tr>
+ </tbody>
+</table>
+
+- **Deadline.** Before each entry the batch checks `--timeout-ms`. If it expired, that entry is `not_started` with reason `deadline` and the batch stops.
+- **Event waits.** When a `wait` entry with `event` follows another entry, the batch captures the event baseline before that earlier entry runs. If the capture fails, the earlier entry does not start (`pre_action_baseline_failed`).
+- **Sessions.** An entry whose session ended before it starts is `not_started` with reason `session_ended`.
+
+Refs in `args` must already exist when you write the array. A `snapshot` entry inside the batch creates refs you cannot name in later entries, so take the snapshot in a separate call.
diff --git a/apps/docs/content/docs/commands/clipboard.mdx b/apps/docs/content/docs/commands/clipboard.mdx
new file mode 100644
index 000000000..08a76b434
--- /dev/null
+++ b/apps/docs/content/docs/commands/clipboard.mdx
@@ -0,0 +1,103 @@
+---
+title: Clipboard commands
+navTitle: Clipboard
+description: Reference for clipboard-get, clipboard-set, and clipboard-clear, including the text, image, and file-list formats and the result shapes.
+---
+
+The clipboard commands read and write the system clipboard. They need no accessibility permission and no `--headed`. The examples are real output from Linux X11.
+
+## clipboard-get
+
+Reads the clipboard as text, an image, or a list of files.
+
+```bash
+agent-desktop clipboard-get [--format text|auto|image|file-urls] [--out PATH]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--format</code></td><td><code>text</code></td><td><code>text</code>, <code>auto</code> (file references first, then an image, then text), <code>image</code>, or <code>file-urls</code>.</td></tr>
+ <tr><td><code>--out PATH</code></td><td>a private file in the state root</td><td>Where to write image content. Without it the image goes to the active session's <code>clipboard/</code> directory, or to <code>tmp/</code> under the <a href="/desktop/configuration#state-root">state root</a>.</td></tr>
+ </tbody>
+</table>
+
+```json
+{ "version": "2.5", "ok": true, "command": "clipboard-get", "data": { "text": "hello from agent-desktop", "type": "text" } }
+```
+
+An image result is `{ "type": "image", "path", "width", "height" }`, and a file list is `{ "type": "file_urls", "file_urls": [...] }`. Image bytes are never inlined. When the clipboard holds nothing in the requested form, the command still succeeds:
+
+```json
+{ "version": "2.5", "ok": true, "command": "clipboard-get", "data": { "found": false, "type": "text" } }
+```
+
+Check `found` before you read `text`. Errors: `INVALID_ARGS` for an unknown format or an unwritable `--out`, and `PLATFORM_NOT_SUPPORTED` when a platform helper is missing.
+
+## clipboard-set
+
+Writes text, a PNG image, or a list of file paths.
+
+```bash
+agent-desktop clipboard-set TEXT
+agent-desktop clipboard-set --image /tmp/a.png
+agent-desktop clipboard-set --file-url /tmp/a.txt --file-url /tmp/b.txt
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>TEXT</code></td><td>empty text</td><td>Text to write.</td></tr>
+ <tr><td><code>--image PATH</code></td><td>none</td><td>A regular PNG file of at most 64 MiB.</td></tr>
+ <tr><td><code>--file-url PATH</code></td><td>none</td><td>A file path to write as a file reference. Repeatable. Every path must exist.</td></tr>
+ </tbody>
+</table>
+
+One call writes one representation: `--file-url` wins over `--image`, which wins over `TEXT`. The result is an [OperationReport](/desktop/json-output#operationreport) plus the written `type`:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "clipboard-set",
+ "data": {
+ "action": "clipboard-set",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "clipboard_write", "mechanism": "semantic_api", "outcome": "succeeded" }],
+ "target": { "kind": "clipboard" },
+ "type": "text"
+ }
+}
+```
+
+macOS reads the content back and reports `delivered_verified`; Windows and Linux report `delivered_unverified`, so confirm with `clipboard-get`. On Linux X11, a helper process (`agent-desktop-linux-clipboard-owner`) keeps serving the content after the command exits; without it beside the binary, the command returns `PLATFORM_NOT_SUPPORTED`. Errors: `INVALID_ARGS` for a bad `--image` or a missing `--file-url` path, and `TIMEOUT` with `lock_timeout` when another agent holds the input lock.
+
+## clipboard-clear
+
+Empties the clipboard. It takes no arguments.
+
+```bash
+agent-desktop clipboard-clear
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "clipboard-clear",
+ "data": {
+ "action": "clipboard-clear",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "clipboard_write", "mechanism": "semantic_api", "outcome": "succeeded" }],
+ "target": { "kind": "clipboard" }
+ }
+}
+```
+
+Confirm with `clipboard-get`, which then returns `found: false`.
+
+Platform limits: Wayland needs `wl-clipboard`. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
diff --git a/apps/docs/content/docs/commands/index.mdx b/apps/docs/content/docs/commands/index.mdx
new file mode 100644
index 000000000..1af7f095d
--- /dev/null
+++ b/apps/docs/content/docs/commands/index.mdx
@@ -0,0 +1,94 @@
+---
+title: Commands
+navTitle: All commands
+description: All 60 agent-desktop commands by group, with a one-line description and a link to each command's reference entry.
+---
+
+agent-desktop has 60 commands in 11 groups. Every command prints one JSON envelope with `version`, `ok`, `command`, and either `data` or `error`; [JSON output](/desktop/json-output) defines it.
+
+```bash
+agent-desktop --help # list every command
+agent-desktop <command> --help # flags and arguments for one command
+agent-desktop skills get desktop # the agent usage guide compiled into the binary
+```
+
+`--help` prints the flags of the binary you installed. Flags that apply to every command, such as `--headed`, `--session`, `--agent-id`, `--trace`, and the post-action `--wait-for` flags, are documented once in [Configuration](/desktop/configuration).
+
+<table>
+ <thead>
+ <tr><th>Command</th><th>What it does</th></tr>
+ </thead>
+ <tbody>
+ <tr><th colSpan="2">App and window</th></tr>
+ <tr><td><a href="/desktop/commands/app-window#launch"><code>launch</code></a></td><td>Start an app, or attach to a running one, and return once its process is running.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#close-app"><code>close-app</code></a></td><td>Quit an app and all its windows, or end its process with <code>--force</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#list-apps"><code>list-apps</code></a></td><td>List running GUI apps.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#list-windows"><code>list-windows</code></a></td><td>List windows with ids, titles, bounds, and focus state.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#focus-window"><code>focus-window</code></a></td><td>Bring a window to the front and confirm the OS reports it focused.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#resize-window"><code>resize-window</code></a></td><td>Set a window's width and height.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#move-window"><code>move-window</code></a></td><td>Move a window to screen coordinates.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#minimize"><code>minimize</code></a></td><td>Minimize a window.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#maximize"><code>maximize</code></a></td><td>Maximize or zoom a window.</td></tr>
+ <tr><td><a href="/desktop/commands/app-window#restore"><code>restore</code></a></td><td>Restore a minimized or maximized window.</td></tr>
+ <tr><th colSpan="2">Observation</th></tr>
+ <tr><td><a href="/desktop/commands/observation#snapshot"><code>snapshot</code></a></td><td>Capture the accessibility tree as JSON with qualified refs.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#find"><code>find</code></a></td><td>Search for elements by role, name, value, text, description, native id, or state.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#get"><code>get</code></a></td><td>Read one property of a ref: text, value, title, bounds, role, or states.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#is"><code>is</code></a></td><td>Check one state of a ref: visible, enabled, checked, focused, expanded, or selected.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#screenshot"><code>screenshot</code></a></td><td>Capture an app window or a display as an image.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#list-displays"><code>list-displays</code></a></td><td>List displays with bounds, scale factor, and primary flag.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#list-surfaces"><code>list-surfaces</code></a></td><td>List the overlays an app presents now, such as sheets and menus.</td></tr>
+ <tr><td><a href="/desktop/commands/observation#open-system-surface"><code>open-system-surface</code></a></td><td>Raise an OS shell surface and return the window it presents.</td></tr>
+ <tr><th colSpan="2">Interaction</th></tr>
+ <tr><td><a href="/desktop/commands/interaction#click"><code>click</code></a></td><td>Activate an element with its primary action.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#double-click"><code>double-click</code></a></td><td>Double-click an element. Usually needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#triple-click"><code>triple-click</code></a></td><td>Triple-click an element. Needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#right-click"><code>right-click</code></a></td><td>Open an element's context menu.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#type"><code>type</code></a></td><td>Insert text into a text target.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#set-value"><code>set-value</code></a></td><td>Write a value directly through the accessibility value path.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#clear"><code>clear</code></a></td><td>Empty a text target.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#focus"><code>focus</code></a></td><td>Move keyboard focus to an element without clicking it.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#select"><code>select</code></a></td><td>Pick an option in a list, dropdown, or combo box.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#toggle"><code>toggle</code></a></td><td>Flip a checkbox or switch.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#check"><code>check</code></a></td><td>Set a checkbox or switch to checked, idempotently.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#uncheck"><code>uncheck</code></a></td><td>Set a checkbox or switch to unchecked, idempotently.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#expand"><code>expand</code></a></td><td>Expand a disclosure triangle, tree item, or accordion.</td></tr>
+ <tr><td><a href="/desktop/commands/interaction#collapse"><code>collapse</code></a></td><td>Collapse a disclosure triangle, tree item, or accordion.</td></tr>
+ <tr><th colSpan="2">Scroll</th></tr>
+ <tr><td><a href="/desktop/commands/scroll#scroll"><code>scroll</code></a></td><td>Scroll a scroll area in a direction by a number of units.</td></tr>
+ <tr><td><a href="/desktop/commands/scroll#scroll-to"><code>scroll-to</code></a></td><td>Bring an element into the visible area.</td></tr>
+ <tr><th colSpan="2">Keyboard</th></tr>
+ <tr><td><a href="/desktop/commands/keyboard#press"><code>press</code></a></td><td>Send a key combo such as <code>return</code> or <code>ctrl+s</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/keyboard#key-down"><code>key-down</code></a></td><td>Reserved. Fails closed instead of holding a key.</td></tr>
+ <tr><td><a href="/desktop/commands/keyboard#key-up"><code>key-up</code></a></td><td>Reserved. Fails closed instead of releasing a key.</td></tr>
+ <tr><th colSpan="2">Mouse</th></tr>
+ <tr><td><a href="/desktop/commands/mouse#hover"><code>hover</code></a></td><td>Move the cursor to an element's center or to coordinates. Needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#drag"><code>drag</code></a></td><td>Drag from one element or point to another. Needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#mouse-move"><code>mouse-move</code></a></td><td>Move the cursor to screen coordinates. Needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#mouse-click"><code>mouse-click</code></a></td><td>Click at screen coordinates. Needs <code>--headed</code>.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#mouse-down"><code>mouse-down</code></a></td><td>Reserved. Fails closed instead of pressing a button.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#mouse-up"><code>mouse-up</code></a></td><td>Reserved. Fails closed instead of releasing a button.</td></tr>
+ <tr><td><a href="/desktop/commands/mouse#mouse-wheel"><code>mouse-wheel</code></a></td><td>Scroll the mouse wheel at screen coordinates. Needs <code>--headed</code>.</td></tr>
+ <tr><th colSpan="2">Notifications</th></tr>
+ <tr><td><a href="/desktop/commands/notifications#list-notifications"><code>list-notifications</code></a></td><td>List entries in the OS notification surface.</td></tr>
+ <tr><td><a href="/desktop/commands/notifications#dismiss-notification"><code>dismiss-notification</code></a></td><td>Dismiss one notification by index.</td></tr>
+ <tr><td><a href="/desktop/commands/notifications#dismiss-all-notifications"><code>dismiss-all-notifications</code></a></td><td>Dismiss every notification, optionally for one app.</td></tr>
+ <tr><td><a href="/desktop/commands/notifications#notification-action"><code>notification-action</code></a></td><td>Press an action button on a notification.</td></tr>
+ <tr><th colSpan="2">Clipboard</th></tr>
+ <tr><td><a href="/desktop/commands/clipboard#clipboard-get"><code>clipboard-get</code></a></td><td>Read text, an image, or file references from the clipboard.</td></tr>
+ <tr><td><a href="/desktop/commands/clipboard#clipboard-set"><code>clipboard-set</code></a></td><td>Write text, an image, or file references to the clipboard.</td></tr>
+ <tr><td><a href="/desktop/commands/clipboard#clipboard-clear"><code>clipboard-clear</code></a></td><td>Clear the clipboard.</td></tr>
+ <tr><th colSpan="2">Wait</th></tr>
+ <tr><td><a href="/desktop/commands/wait#wait"><code>wait</code></a></td><td>Block until a time, element, window, text, menu, event, or notification condition holds.</td></tr>
+ <tr><th colSpan="2">System</th></tr>
+ <tr><td><a href="/desktop/commands/system#status"><code>status</code></a></td><td>Report adapter health, platform, permissions, and supported surfaces.</td></tr>
+ <tr><td><a href="/desktop/commands/system#permissions"><code>permissions</code></a></td><td>Check, request, or guide the grant of OS permissions.</td></tr>
+ <tr><td><a href="/desktop/commands/system#version"><code>version</code></a></td><td>Print the version, target architecture, and OS.</td></tr>
+ <tr><td><a href="/desktop/commands/system#skills"><code>skills</code></a></td><td>List and read the skills compiled into the binary.</td></tr>
+ <tr><td><a href="/desktop/commands/system#session"><code>session</code></a></td><td>Start, end, list, and clean up sessions.</td></tr>
+ <tr><td><a href="/desktop/commands/system#cursor-overlay"><code>cursor-overlay</code></a></td><td>Configure the presentation-only agent cursor.</td></tr>
+ <tr><td><a href="/desktop/commands/system#trace"><code>trace</code></a></td><td>Read merged session trace timelines.</td></tr>
+ <tr><th colSpan="2">Batch</th></tr>
+ <tr><td><a href="/desktop/commands/batch#batch"><code>batch</code></a></td><td>Run a bounded, sequential, non-atomic list of commands in one process.</td></tr>
+ </tbody>
+</table>
diff --git a/apps/docs/content/docs/commands/interaction.mdx b/apps/docs/content/docs/commands/interaction.mdx
new file mode 100644
index 000000000..092591bd2
--- /dev/null
+++ b/apps/docs/content/docs/commands/interaction.mdx
@@ -0,0 +1,326 @@
+---
+title: Interaction commands
+navTitle: Interaction
+description: Reference for click, double-click, triple-click, right-click, type, set-value, clear, focus, select, toggle, check, uncheck, expand, and collapse.
+---
+
+Every command here acts on one element. Pass the qualified ref from [`snapshot`](/desktop/commands/observation#snapshot) or [`find`](/desktop/commands/observation#find), such as `@s8f3k2p9:e1`; a bare `@e1` is rejected with `INVALID_ARGS`.
+
+By default these commands run headless: semantic accessibility calls that do not take focus, move the cursor, synthesize keys, or use the clipboard. If no semantic path exists, the action fails closed. The global `--headed` flag permits physical input and focus changes; see [Headed mode](/desktop/guides/headed-mode). The examples on this page are real output from GNOME Calculator and GTK Widget Factory on Linux.
+
+## Result shape
+
+Every successful ref action returns an action report in `data`. This is a `click` on a calculator button:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "click",
+ "data": {
+ "action": "click",
+ "details": {
+ "auto_wait": {
+ "lease_contention_count": 0,
+ "lease_hold_ms": 114,
+ "read_only_preflight_attempts": 1,
+ "read_only_resolve_attempts": 1
+ }
+ },
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "Action.DoAction", "mechanism": "semantic_api", "outcome": "succeeded" }],
+ "surfaces": [
+ { "id": "w-1.11-org-gnome-Calculator-a11y-948fd89a_9bda_453b_9c10_4a9e9eed3feb", "title": "Calculator", "type": "window" }
+ ]
+ }
+}
+```
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>action</code></td><td>The command that ran.</td></tr>
+ <tr><td><code>disposition</code></td><td><code>delivery</code> and <code>retry</code>. Repeat an action only when <code>retry</code> is <code>safe</code>. See <a href="/desktop/errors-and-recovery#disposition">Disposition</a>.</td></tr>
+ <tr><td><code>steps</code></td><td>The mechanisms tried: <code>label</code>, <code>outcome</code> (<code>attempted</code>, <code>skipped</code>, or <code>succeeded</code>), <code>mechanism</code> (<code>semantic_api</code> or <code>physical_synthetic</code>), and <code>verified</code> when the step read back its effect.</td></tr>
+ <tr><td><code>post_state</code></td><td>The element's state after the action, for the commands that read it back.</td></tr>
+ <tr><td><code>surfaces</code></td><td>Windows and overlays open once the action settled. Only <code>click</code>, <code>double-click</code>, <code>triple-click</code>, <code>right-click</code>, <code>expand</code>, <code>select</code>, and <code>press</code> report them. A <code>menu</code>, <code>sheet</code>, or <code>alert</code> means the app is waiting on it. See <a href="/desktop/surfaces#know-when-a-surface-opened">Surfaces</a>.</td></tr>
+ <tr><td><code>details</code></td><td><code>auto_wait</code> counters, plus the verification fields below. Later examples on this page omit <code>auto_wait</code>.</td></tr>
+ </tbody>
+</table>
+
+When the target is already in the requested state, nothing is delivered and the report says `not_delivered`, which is safe to repeat.
+
+`set-value`, `clear`, `type`, `check`, `uncheck`, `toggle`, `expand`, and `collapse` run once and then re-read the element:
+
+- A match returns `delivered_verified` with `post_state` and `details.verification_scope`: `element_state` for `check`, `uncheck`, `toggle`, `expand`, and `collapse`, or `element_value` with `application_commit: "not_verified"` for `set-value`, `clear`, and `type`. A verified value proves the element holds it, not that the app committed it.
+- A readable contradiction returns `ACTION_FAILED` with `details.kind: "post_action_verification"`, the observed `post_state`, and the report under `details.after_action`. The action landed, so read `post_state` instead of retrying.
+- An unreadable result still succeeds, as `delivered_unverified` with `details.verification_scope: "unavailable"` and a `verification_reason`: `insufficient_evidence`, `secure_field`, or `postcondition_mismatch`.
+
+## Wait budget
+
+Every command on this page takes `--timeout-ms MS` (default `5000`; `type` adds 30 ms per character), the budget for resolving the ref and waiting for the element to become actionable. Core polls the transient checks (`visible`, `stable`, `enabled`, and, for pointer delivery, `receives_events`) until they pass. The terminal checks (`supported_action`, `policy`, `editable`) cannot be fixed by waiting and fail at once. `--timeout-ms 0` tries once without polling.
+
+A failed check list appears in `error.details.checks`, each with a `status` of `pass`, `fail`, or `unknown` and a `reason`. This is `double-click` on a text entry without `--headed`:
+
+```json
+{
+ "code": "POLICY_DENIED",
+ "message": "Target is not actionable: supported_action (semantic gesture is unavailable and physical fallback is denied)",
+ "details": {
+ "actionable": false,
+ "checks": [
+ { "check": "visible", "status": "pass" },
+ { "check": "stable", "stability": { "samples": 1, "span_ms": 0 }, "status": "pass" },
+ { "check": "enabled", "status": "pass" },
+ { "check": "supported_action", "reason": "semantic gesture is unavailable and physical fallback is denied", "status": "fail" },
+ { "check": "policy", "status": "pass" }
+ ]
+ },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+}
+```
+
+`receives_events` fails with an `occluder` (`role`, `name`, `bounds`) when another element covers the target. To wait for readiness on its own, use [`wait --element REF --predicate actionable`](/desktop/commands/wait#wait).
+
+## Errors shared by ref commands
+
+<table>
+ <thead>
+ <tr><th>Code</th><th>Cause</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>INVALID_ARGS</code></td><td>A bare or malformed ref, or an argument the command rejects.</td></tr>
+ <tr><td><code>SNAPSHOT_NOT_FOUND</code></td><td>The snapshot that owns the ref is missing or pruned.</td></tr>
+ <tr><td><code>STALE_REF</code></td><td>No live element matches the ref's saved identity.</td></tr>
+ <tr><td><code>AMBIGUOUS_TARGET</code></td><td>Several live elements match. A ref action never guesses.</td></tr>
+ <tr><td><code>ACTION_NOT_SUPPORTED</code></td><td>The element does not expose the action.</td></tr>
+ <tr><td><code>POLICY_DENIED</code></td><td>A physical or focus-taking path was needed and headless policy refused it.</td></tr>
+ <tr><td><code>TIMEOUT</code>, <code>details.kind: actionability_timeout</code></td><td>The target never became actionable within <code>--timeout-ms</code>. <code>details.last_report</code> names the failing check.</td></tr>
+ <tr><td><code>ACTION_FAILED</code></td><td>The action was rejected, blocked, or contradicted by the readback.</td></tr>
+ <tr><td><code>APP_UNRESPONSIVE</code></td><td>The app stopped responding.</td></tr>
+ <tr><td><code>PERM_DENIED</code></td><td>Accessibility permission is not granted.</td></tr>
+ </tbody>
+</table>
+
+What each code means and when to retry is in [Errors and recovery](/desktop/errors-and-recovery).
+
+## click
+
+Activates an element with its primary action, such as a press or invoke.
+
+```bash
+agent-desktop click <REF> [--timeout-ms MS]
+```
+
+The result is the one in [Result shape](#result-shape). A click usually ends `delivered_unverified`, because a delivered activation does not prove the app acted on it: verify by reading the UI, and check `data.surfaces`.
+
+Platform limits: semantic everywhere headless; `--headed` tries physical input first on macOS and Linux. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
+
+## double-click
+
+Double-clicks an element. It is a physical gesture, so it needs `--headed` unless the element exposes a semantic open action.
+
+```bash
+agent-desktop --headed double-click <REF> [--timeout-ms MS]
+```
+
+Without `--headed` and a semantic route, it returns `POLICY_DENIED` (see [Wait budget](#wait-budget)). For raw coordinates use `--headed mouse-click --xy X,Y --count 2` ([`mouse-click`](/desktop/commands/mouse#mouse-click)).
+
+Platform limits: macOS tries `AXOpen` headless; Windows and Linux need `--headed`, and Linux needs X11. See [Linux](/desktop/platforms/linux).
+
+## triple-click
+
+Triple-clicks an element, for example to select a line of text. Arguments and errors are the same as [`double-click`](#double-click). For raw coordinates use `--headed mouse-click --xy X,Y --count 3`.
+
+```bash
+agent-desktop --headed triple-click <REF> [--timeout-ms MS]
+```
+
+## right-click
+
+Opens an element's context menu. Afterward, `data.surfaces` lists the open `menu`; read it with `snapshot --surface menu`. For combo boxes and menu buttons, use [`select`](#select) instead.
+
+```bash
+agent-desktop right-click <REF> [--timeout-ms MS]
+```
+
+Headless delivery needs a context-menu action on the element. On a GTK entry without one, it returns `POLICY_DENIED` with `supported_action` failing. On macOS, a right-click can return `APP_UNRESPONSIVE` with an unsafe disposition after a modal menu opened: look before you retry.
+
+Platform limits: Windows always needs `--headed`. See [Windows](/desktop/platforms/windows).
+
+## type
+
+Inserts text into a text target at its insertion point, then reads the field back.
+
+```bash
+agent-desktop type <REF> <TEXT> [--timeout-ms MS]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>TEXT</code></td><td>required</td><td>The text, up to 10,000 bytes. A value that starts with a hyphen is accepted.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code> plus <code>30</code> per character</td><td>Covers resolution, actionability, and delivery. An explicit value wins.</td></tr>
+ </tbody>
+</table>
+
+`type` inserts; it does not replace. After `set-value hello`, `type ' world'` into the same entry produced this, because the insertion point was at the start:
+
+```json
+{
+ "action": "type",
+ "details": { "application_commit": "not_verified", "verification_scope": "element_value" },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "post_state": { "enabled": true, "role": "textfield", "value": " worldhello" },
+ "steps": [{ "label": "EditableText.InsertText", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }]
+}
+```
+
+To set a field's whole content, use [`set-value`](#set-value). Keystroke delivery that settles on other text returns `delivered_unverified` with `verification_reason: "postcondition_mismatch"`; read the field with `get` before you write again.
+
+Platform limits: Windows needs `--headed` and returns `POLICY_DENIED` headless; use `set-value` there. See [Windows](/desktop/platforms/windows).
+
+## set-value
+
+Writes a value directly through the accessibility value path: text fields, text areas, and sliders.
+
+```bash
+agent-desktop set-value <REF> <VALUE> [--timeout-ms MS]
+```
+
+```json
+{
+ "action": "set-value",
+ "details": { "application_commit": "not_verified", "verification_scope": "element_value" },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "post_state": { "enabled": true, "role": "textfield", "value": "hello" },
+ "steps": [{ "label": "EditableText.SetTextContents", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }]
+}
+```
+
+On a slider, the step is `Value.CurrentValue` and `post_state.value` is the new position. A value the app reformats reads as a contradiction and returns `ACTION_FAILED`. An element that exposes no value write returns `ACTION_NOT_SUPPORTED`; for a table cell, activate it and target the editor that appears. A write to a secure field ends `delivered_unverified` with `verification_reason: "secure_field"`.
+
+## clear
+
+Empties a text target and expects an empty value on readback. The result looks like `set-value` with `post_state.value: ""`.
+
+```bash
+agent-desktop clear <REF> [--timeout-ms MS]
+```
+
+## focus
+
+Sets keyboard focus on an element without clicking it.
+
+```bash
+agent-desktop --headed focus <REF> [--timeout-ms MS]
+```
+
+Moving focus can change the foreground, so headless it returns `POLICY_DENIED` on Windows and Linux:
+
+```json
+{
+ "code": "POLICY_DENIED",
+ "message": "Focusing an element moves the keyboard focus of the application",
+ "details": { "foreground_effect": true },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+}
+```
+
+On Linux, a GTK4 app rejects the call with cause `grab_focus_rejected`; use [`focus-window`](/desktop/commands/app-window#focus-window) for its window.
+
+## select
+
+Picks an option by display text in a list, dropdown, or combo box.
+
+```bash
+agent-desktop select <REF> <VALUE> [--timeout-ms MS]
+```
+
+```bash
+agent-desktop select @s30sxlstqzdq8x:e21 Middle
+```
+
+```json
+{
+ "action": "select",
+ "details": {},
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "steps": [{ "label": "Action.DoAction", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }],
+ "surfaces": [{ "id": "w-1.9-org-a11y-atspi-accessible-229", "type": "window" }]
+}
+```
+
+If the control already shows the value, nothing is delivered. A combo box whose accessible name is its current value gets a new identity when the value changes, so the old ref returns `STALE_REF` afterward: find the control again before the next action.
+
+Platform limits: on macOS, dismiss any open menu first. On Linux, a Qt combo refuses headless with `details.kind: pointer_required`, and a GTK4 list refuses with `selection_index_unproven`. See the platform pages.
+
+## toggle
+
+Flips a checkbox or switch. Prefer [`check`](#check) and [`uncheck`](#uncheck), which are idempotent; use `toggle` only when you want the opposite of whatever the state is.
+
+```bash
+agent-desktop toggle <REF> [--timeout-ms MS]
+```
+
+The readback requires the checked state to have changed, and `post_state.states` shows the result. An unreadable or indeterminate state returns `ACTION_FAILED`, and a role that cannot be checked returns `ACTION_NOT_SUPPORTED`.
+
+## check
+
+Sets a checkbox or switch to checked. An element that is already checked delivers nothing.
+
+```bash
+agent-desktop check <REF> [--timeout-ms MS]
+```
+
+```json
+{
+ "action": "check",
+ "details": { "verification_scope": "element_state" },
+ "disposition": { "delivery": "delivered_verified", "retry": "unsafe" },
+ "post_state": { "enabled": true, "role": "checkbox", "states": ["checked"] },
+ "steps": [{ "label": "Action.DoAction", "mechanism": "semantic_api", "outcome": "succeeded", "verified": true }]
+}
+```
+
+Run it again on the same checkbox and the step is skipped:
+
+```json
+{
+ "action": "check",
+ "details": { "verification_scope": "element_state" },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" },
+ "post_state": { "enabled": true, "role": "checkbox", "states": ["checked"] },
+ "steps": [{ "label": "Action.DoAction", "mechanism": "semantic_api", "outcome": "skipped", "verified": true }]
+}
+```
+
+Errors are the same as [`toggle`](#toggle). On Linux, two clicks less than about 250 ms apart on one GTK4 button can act once.
+
+## uncheck
+
+Sets a checkbox or switch to unchecked, idempotently. The result matches `check`, with `checked` absent from `post_state.states`.
+
+```bash
+agent-desktop uncheck <REF> [--timeout-ms MS]
+```
+
+## expand
+
+Expands a disclosure triangle, tree item, or accordion, and verifies that the element reads as expanded (`post_state.states` contains `expanded`). `data.surfaces` can list a menu or popover the expansion opened. A non-expandable element returns `ACTION_NOT_SUPPORTED`.
+
+```bash
+agent-desktop expand <REF> [--timeout-ms MS]
+```
+
+## collapse
+
+Collapses a disclosure triangle, tree item, or accordion, and verifies that `expanded` is gone. Errors are the same as [`expand`](#expand).
+
+```bash
+agent-desktop collapse <REF> [--timeout-ms MS]
+```
diff --git a/apps/docs/content/docs/commands/keyboard.mdx b/apps/docs/content/docs/commands/keyboard.mdx
new file mode 100644
index 000000000..5cf796c17
--- /dev/null
+++ b/apps/docs/content/docs/commands/keyboard.mdx
@@ -0,0 +1,91 @@
+---
+title: Keyboard commands
+navTitle: Keyboard
+description: Reference for press, key-down, and key-up. press sends key combos; the held-input commands fail closed on every platform.
+---
+
+`press` is the only command that delivers keys. `key-down` and `key-up` are reserved names: they validate their argument and then refuse. To insert text into a field, use [`type`](/desktop/commands/interaction#type) or [`set-value`](/desktop/commands/interaction#set-value).
+
+## press
+
+Sends a key combo to the focused window, or to one app.
+
+```bash
+agent-desktop press COMBO [--app NAME] [--window-id ID] [--force]
+agent-desktop press ctrl+shift+z
+agent-desktop press return --app gnome-calculator
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>COMBO</code></td><td>required</td><td>Keys joined with <code>+</code>. The last part is the key; the parts before it are modifiers.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>focused window</td><td>Send the keys to this application. With <code>--headed</code>, its window is focused first. Several instances with the same name return <code>AMBIGUOUS_TARGET</code>.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Target the instance that owns this window.</td></tr>
+ <tr><td><code>--force</code></td><td>off</td><td>Send a combo the platform blocks as dangerous, such as a quit or lock shortcut.</td></tr>
+ </tbody>
+</table>
+
+The combo is lowercased and stripped of spaces, so `Ctrl + A` is `ctrl+a`. Modifiers are `meta` (aliases `cmd`, `command`, `super`, `win`: Command on macOS, the Windows key on Windows, Super on Linux), `ctrl` (`control`), `alt` (`option`), and `shift`. A bare uppercase letter adds Shift. Key names that work everywhere are `return`, `escape`, `tab`, `space`, `delete`, `up`, `down`, `left`, `right`, and `f1` to `f12`. Copy is `cmd+c` on macOS and `ctrl+c` elsewhere.
+
+Keys are physical keyboard input, and `press` does not need `--headed` for an unscoped press. The result is always `delivered_unverified`, because delivery does not prove the shortcut did anything:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "press",
+ "data": {
+ "action": "press",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "XTEST.press_key", "mechanism": "physical_synthetic", "outcome": "succeeded", "verified": false }]
+ }
+}
+```
+
+The step label names the platform mechanism; this one is Linux X11. With [post-action wait flags](/desktop/configuration#post-action-wait-flags), the press report moves under `data.after_action`.
+
+Errors specific to `press`:
+
+- `INVALID_ARGS`: an empty combo, an unknown modifier, or an unknown key (`Unknown key name 'foo'`). Nothing is sent.
+- `POLICY_DENIED`: the platform blocks the combo. The disposition is `not_delivered`. Pass `--force` only when you mean it.
+- `ACTION_FAILED` with `details.cause: "frame_not_active"`: a headless scoped press to an app whose window is not active. Nothing is sent. Bring the window forward, or pass `--headed` if focus changes are permitted.
+- `TIMEOUT` with `details.kind: "wait_timeout"`: a `--wait-for` selector never matched. The keys were already delivered, so do not repeat the press blindly.
+
+Platform limits: each platform has its own key names, blocked combos, and scoped-press rules. See [macOS](/desktop/platforms/macos#keys-and-notifications), [Windows](/desktop/platforms/windows#keys), and [Linux](/desktop/platforms/linux).
+
+## key-down
+
+Reserved name for holding a key down. It never sends input.
+
+```bash
+agent-desktop key-down COMBO [--force]
+```
+
+A held key needs a process that can guarantee its release, and every agent-desktop command is a short-lived process. So on every platform, headless or headed, the command parses the combo (`INVALID_ARGS` if bad), applies the blocked-combo check (`POLICY_DENIED` unless `--force`), and then refuses:
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "key-down",
+ "error": {
+ "code": "ACTION_NOT_SUPPORTED",
+ "message": "key-down is unavailable in stateless mode",
+ "suggestion": "Use the atomic press command; held input requires a daemon-owned transaction that can guarantee release",
+ "disposition": { "delivery": "unknown", "retry": "unknown" }
+ }
+}
+```
+
+Nothing was sent, and the command fails the same way every time. Send the whole chord with [`press`](#press), for example `press shift+tab`.
+
+## key-up
+
+Reserved name for releasing a held key. It follows the same steps as [`key-down`](#key-down) and ends with `ACTION_NOT_SUPPORTED` (`key-up is unavailable in stateless mode`).
+
+```bash
+agent-desktop key-up COMBO [--force]
+```
diff --git a/apps/docs/content/docs/commands/meta.json b/apps/docs/content/docs/commands/meta.json
new file mode 100644
index 000000000..8e395f823
--- /dev/null
+++ b/apps/docs/content/docs/commands/meta.json
@@ -0,0 +1,4 @@
+{
+ "title": "Commands",
+ "pages": ["index", "app-window", "observation", "interaction", "scroll", "keyboard", "mouse", "notifications", "clipboard", "wait", "system", "batch"]
+}
diff --git a/apps/docs/content/docs/commands/mouse.mdx b/apps/docs/content/docs/commands/mouse.mdx
new file mode 100644
index 000000000..1df4800c1
--- /dev/null
+++ b/apps/docs/content/docs/commands/mouse.mdx
@@ -0,0 +1,190 @@
+---
+title: Mouse commands
+navTitle: Mouse
+description: Reference for hover, drag, mouse-move, mouse-click, mouse-down, mouse-up, and mouse-wheel. Cursor movement needs --headed, and the held-button commands fail closed.
+---
+
+Every mouse command moves the real cursor, so each one needs the global `--headed` flag. Without it the command returns `POLICY_DENIED` with `not_delivered` and sends nothing:
+
+```json
+{
+ "code": "POLICY_DENIED",
+ "message": "hover moves the cursor and is disabled in headless mode",
+ "recovery": { "strategy": "request_explicit_policy_then_retry_original", "retryable": true, "requires_fresh_snapshot": false },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+}
+```
+
+Read [Headed mode](/desktop/guides/headed-mode) before you add the flag. Coordinates are absolute screen points written `x,y`; write a negative value with `=` so the shell does not read it as a flag (`--xy=-100,50`). Raw coordinates carry no window identity and never focus an app; a ref target focuses its exact window first. The pointer commands return an [OperationReport](/desktop/json-output#operationreport) with a `pointer` target. The examples are real output from Linux X11.
+
+## hover
+
+Moves the cursor to an element's center or to a point.
+
+```bash
+agent-desktop --headed hover @s8f3k2p9:e5
+agent-desktop --headed hover --xy 640,400
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>REF</code></td><td>none</td><td>Qualified ref. Wins over <code>--xy</code>.</td></tr>
+ <tr><td><code>--xy X,Y</code></td><td>none</td><td>Absolute coordinates. One of <code>REF</code> or <code>--xy</code> is required.</td></tr>
+ <tr><td><code>--duration MS</code></td><td>none</td><td>Reserved. A positive value is rejected; run <code>hover</code>, then <code>wait MS</code>.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Budget for the ref to resolve and become actionable.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "hover",
+ "data": {
+ "action": "mouse-move",
+ "details": { "delivered_events": 1 },
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "pointer_move", "mechanism": "physical_synthetic", "outcome": "succeeded" }],
+ "target": { "kind": "pointer", "point": { "x": 640.0, "y": 400.0 } },
+ "x": 640.0,
+ "y": 400.0
+ }
+}
+```
+
+For a ref, the cursor goes to the center of the live bounds after visibility, stability, and hit-test checks. On macOS the position is read back and the result is `delivered_verified`. Errors: `INVALID_ARGS` for a missing target or bad coordinates; `ACTION_NOT_SUPPORTED` with cause `wayland_session` on Linux Wayland; `ACTION_FAILED` when another element covers the target; the ref errors `STALE_REF`, `AMBIGUOUS_TARGET`, and `SNAPSHOT_NOT_FOUND`.
+
+## drag
+
+Presses at one point, moves to another, and releases.
+
+```bash
+agent-desktop --headed drag --from @s8f3k2p9:e1 --to @s8f3k2p9:e5
+agent-desktop --headed drag --from-xy 100,200 --to-xy 400,500 --drop-delay 800
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--from REF</code>, <code>--from-xy X,Y</code></td><td>required, one of</td><td>Source element or point.</td></tr>
+ <tr><td><code>--to REF</code>, <code>--to-xy X,Y</code></td><td>required, one of</td><td>Destination element or point. The two kinds can be mixed.</td></tr>
+ <tr><td><code>--duration MS</code></td><td>platform default</td><td>Length of the movement, at most 60000.</td></tr>
+ <tr><td><code>--drop-delay MS</code></td><td><code>500</code> (<code>150</code> on Linux)</td><td>Hold over the destination before releasing, so the drop target activates. At most 10000.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Budget for the whole gesture. <code>--duration</code> plus <code>--drop-delay</code> must be below it.</td></tr>
+ <tr><td><code>--wait-for-scope to|from</code></td><td><code>to</code></td><td>Which endpoint's window a post-action <code>--wait-for</code> polls.</td></tr>
+ </tbody>
+</table>
+
+The destination app is never focused first, because raising it could cover the source. The report describes the gesture (`target.kind: "drag"` with `from` and `to`), not its outcome, so verify the moved item with a fresh snapshot. Native cross-app drag and drop can ignore synthetic events. Errors: `INVALID_ARGS` for a missing endpoint or timing that does not fit `--timeout-ms`, `TIMEOUT` when preparation used up the budget, and the errors listed under [`hover`](#hover).
+
+## mouse-move
+
+Moves the cursor to absolute coordinates.
+
+```bash
+agent-desktop --headed mouse-move --xy 700,450
+```
+
+The report matches the [`hover`](#hover) example. On macOS the position is read back (`details.verification_scope: "pointer_position"`).
+
+## mouse-click
+
+Clicks at absolute coordinates.
+
+```bash
+agent-desktop --headed mouse-click --xy 500,300 [--button left|right|middle] [--count N] [--modifiers NAME]...
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--xy X,Y</code></td><td>required</td><td>Absolute coordinates.</td></tr>
+ <tr><td><code>--button</code></td><td><code>left</code></td><td><code>left</code>, <code>right</code>, or <code>middle</code>.</td></tr>
+ <tr><td><code>--count N</code></td><td><code>1</code></td><td>Clicks, 1 to 100. Use 2 for a double click and 3 for a triple click.</td></tr>
+ <tr><td><code>--modifiers NAME</code></td><td>none</td><td>A modifier held during the click: <code>shift</code>, <code>meta</code>, <code>ctrl</code>, <code>alt</code>. Repeat the flag for several.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "mouse-click",
+ "data": {
+ "action": "mouse-click",
+ "count": 1,
+ "details": { "delivered_events": 3 },
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [{ "label": "pointer_click", "mechanism": "physical_synthetic", "outcome": "succeeded" }],
+ "target": { "kind": "pointer", "point": { "x": 1300.0, "y": 880.0 } },
+ "x": 1300.0,
+ "y": 880.0
+ }
+}
+```
+
+`target.point` is where the click was dispatched; it does not prove which app received it. Before you click at bounds read from a snapshot, check `get --property bounds` and its `live` flag.
+
+## mouse-down
+
+Reserved name for pressing and holding a button. It never sends input.
+
+```bash
+agent-desktop --headed mouse-down --xy 500,300 [--button NAME] [--modifiers NAME]...
+```
+
+The first failing check decides the error: a bad argument is `INVALID_ARGS`; headless is `POLICY_DENIED` (`not_delivered`); Linux Wayland is `ACTION_NOT_SUPPORTED` with cause `wayland_session`; everywhere else, `--headed` ends in `ACTION_NOT_SUPPORTED`, `mouse-down is unavailable in stateless mode`, with a disposition of `unknown` and no event sent. Use [`mouse-click`](#mouse-click) or [`drag`](#drag).
+
+## mouse-up
+
+Reserved name for releasing a held button. It fails closed through the same checks as [`mouse-down`](#mouse-down).
+
+```bash
+agent-desktop --headed mouse-up --xy 500,300
+```
+
+## mouse-wheel
+
+Scrolls the mouse wheel at absolute coordinates. Use it for canvases and custom surfaces with no accessibility scroll action; for a scroll area with a ref, use [`scroll`](/desktop/commands/scroll#scroll).
+
+```bash
+agent-desktop --headed mouse-wheel --x 700 --y 400 --dy -2
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--x X</code>, <code>--y Y</code></td><td>required</td><td>Absolute coordinates.</td></tr>
+ <tr><td><code>--dy LINES</code></td><td><code>-3</code> when <code>--dx</code> is 0, else 0</td><td>Vertical lines. Positive scrolls up, negative scrolls down.</td></tr>
+ <tr><td><code>--dx LINES</code></td><td><code>0</code></td><td>Horizontal lines. Positive scrolls right.</td></tr>
+ <tr><td><code>--modifiers NAME</code></td><td>none</td><td>Modifiers held during the scroll; repeatable.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "mouse-wheel",
+ "data": {
+ "action": "mouse-wheel",
+ "details": { "delivered_events": 5 },
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "dx": 0.0,
+ "dy": -2.0,
+ "steps": [{ "label": "pointer_wheel", "mechanism": "physical_synthetic", "outcome": "succeeded" }],
+ "target": { "kind": "pointer", "point": { "x": 700.0, "y": 400.0 } }
+ }
+}
+```
+
+Platform limits for all mouse commands: Linux needs X11. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
diff --git a/apps/docs/content/docs/commands/notifications.mdx b/apps/docs/content/docs/commands/notifications.mdx
new file mode 100644
index 000000000..4b3a19117
--- /dev/null
+++ b/apps/docs/content/docs/commands/notifications.mdx
@@ -0,0 +1,100 @@
+---
+title: Notification commands
+navTitle: Notifications
+description: Reference for list-notifications, dismiss-notification, dismiss-all-notifications, and notification-action on the operating system notification surface.
+---
+
+These commands drive the OS notification surface: Notification Center on macOS, Action Center on Windows, and the GNOME Shell message list on Linux. Command names, arguments, and JSON fields are the same everywhere. Titles and bodies are returned verbatim and are not redacted, so treat them as sensitive.
+
+- **Listing** is read-only. Linux lists without `--headed`, even when the list is closed. On macOS and Windows a headless call works only while the surface is already open; otherwise it returns `POLICY_DENIED`, and `--headed` may open the surface.
+- **Mutations** (`dismiss-notification`, `dismiss-all-notifications`, `notification-action`) always need `--headed`, because they open and focus the notification surface.
+- **Identity guard.** Notifications reorder between listings, so `dismiss-notification` and `notification-action` need `--expected-app` or `--expected-title` copied from the same `list-notifications` result. If the row at `INDEX` no longer matches, nothing is pressed and the command returns `NOTIFICATION_NOT_FOUND`.
+
+To block until a new notification arrives, use [`wait --notification`](/desktop/commands/wait#notification). The JSON examples on this page are built from the command code and tests; notifications could not be exercised in the Linux session the other examples came from, which had no notification service:
+
+```json
+{
+ "code": "PLATFORM_NOT_SUPPORTED",
+ "message": "No notification service is running in this session",
+ "details": { "daemon": "absent", "detail": "no service owns org.freedesktop.Notifications" }
+}
+```
+
+## list-notifications
+
+Lists the notifications on the OS surface.
+
+```bash
+agent-desktop list-notifications [--app NAME] [--text TEXT] [--limit N]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>all apps</td><td>Only notifications from this app, ignoring case.</td></tr>
+ <tr><td><code>--text TEXT</code></td><td>none</td><td>Only notifications that contain this text.</td></tr>
+ <tr><td><code>--limit N</code></td><td>no limit</td><td>Maximum number returned.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "list-notifications",
+ "data": {
+ "count": 1,
+ "notifications": [
+ { "index": 1, "app_name": "Calendar", "title": "Standup in 10 minutes", "body": "Room 4", "actions": ["Snooze", "Open"] }
+ ]
+ }
+}
+```
+
+`index` is 1-based and counts the unfiltered list, so a filtered result can start above 1. `body` and `actions` are omitted when empty. Errors: `POLICY_DENIED` on macOS or Windows with the surface closed, and `PLATFORM_NOT_SUPPORTED` when there is no notification service (on Linux, an owner other than GNOME Shell).
+
+## dismiss-notification
+
+Dismisses one notification by index.
+
+```bash
+agent-desktop --headed dismiss-notification INDEX --expected-app NAME
+agent-desktop --headed dismiss-notification 2 --expected-title "Standup in 10 minutes"
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>INDEX</code></td><td>required</td><td>1-based index from <code>list-notifications</code>.</td></tr>
+ <tr><td><code>--expected-app APP</code>, <code>--expected-title TITLE</code></td><td>at least one</td><td>The app or title the notification at <code>INDEX</code> must have.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>none</td><td>Require the notification to come from this app.</td></tr>
+ </tbody>
+</table>
+
+`data.dismissed` is the removed notification, in the `list-notifications` row shape. Errors: `INVALID_ARGS` without an `--expected-*` flag, `POLICY_DENIED` without `--headed`, and `NOTIFICATION_NOT_FOUND` when the row no longer matches.
+
+## dismiss-all-notifications
+
+Dismisses every notification, or every one from one app.
+
+```bash
+agent-desktop --headed dismiss-all-notifications [--app NAME]
+```
+
+`data.dismissed_count` counts the removed notifications. When some could not be closed, `data.failures` and `data.failed_count` are added.
+
+## notification-action
+
+Presses a named action button on a notification.
+
+```bash
+agent-desktop --headed notification-action INDEX ACTION --expected-app NAME
+```
+
+`ACTION` is a name from the notification's `actions`. The result is an action report, usually `delivered_unverified`: check the effect in the app. Errors: as for `dismiss-notification`, plus `ACTION_NOT_SUPPORTED` when the notification has no button with that name.
+
+Platform limits: GNOME Shell only on Linux, with mutations on X11; see [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
diff --git a/apps/docs/content/docs/commands/observation.mdx b/apps/docs/content/docs/commands/observation.mdx
new file mode 100644
index 000000000..358517ab7
--- /dev/null
+++ b/apps/docs/content/docs/commands/observation.mdx
@@ -0,0 +1,280 @@
+---
+title: Observation commands
+navTitle: Observation
+description: Reference for snapshot, find, get, is, screenshot, list-displays, list-surfaces, and open-system-surface.
+---
+
+Observation commands read UI state. All of them except `open-system-surface` leave the UI as it was, and their errors carry `not_delivered` because nothing was sent to the app.
+
+Concepts behind the flags are explained in [Skeleton and drill-down](/desktop/skeleton-and-drill-down) (`--skeleton`, `--root`, `--max-depth`, partial observations, timeouts, scoped search), [Snapshots and refs](/desktop/snapshots-and-refs) (refs, `-i`, `--compact`, `--include-bounds`, window selection), and [Surfaces](/desktop/surfaces).
+
+## snapshot
+
+Captures an app window's accessibility tree as JSON. Interactive elements get qualified refs that later commands accept.
+
+```bash
+agent-desktop snapshot [--app NAME] [--window-id ID] [-i] [--compact] [--skeleton] \
+ [--root REF] [--surface KIND] [--max-depth N] [--include-bounds] \
+ [--timeout-ms MS] [--force-electron-a11y]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>focused window</td><td>Application to read. See <a href="/desktop/snapshots-and-refs#choose-the-window">Choose the window</a>.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Read one window by id from <code>list-windows</code>.</td></tr>
+ <tr><td><code>-i</code>, <code>--interactive-only</code></td><td>off</td><td>Drop leaves without a ref. See <a href="/desktop/snapshots-and-refs#what-a-snapshot-contains">What a snapshot contains</a>.</td></tr>
+ <tr><td><code>--compact</code></td><td>off</td><td>Collapse single-child unnamed wrappers.</td></tr>
+ <tr><td><code>--include-bounds</code></td><td>off</td><td>Add <code>bounds</code> to each node.</td></tr>
+ <tr><td><code>--skeleton</code></td><td>off</td><td>Clamp depth to 3 and mark cut containers with <code>children_count</code>. See <a href="/desktop/skeleton-and-drill-down#take-a-skeleton">Take a skeleton</a>.</td></tr>
+ <tr><td><code>--root REF</code></td><td>none</td><td>Drill into one ref's subtree and replace that region's refs. Cannot combine with <code>--surface</code> or <code>--wait-for</code>. See <a href="/desktop/skeleton-and-drill-down#drill-into-a-region">Drill into a region</a>.</td></tr>
+ <tr><td><code>--max-depth N</code></td><td><code>10</code></td><td>Maximum depth, up to 50. See <a href="/desktop/skeleton-and-drill-down#depth-with-max-depth">Depth with max-depth</a>.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>3000</code></td><td>Observation deadline. A full snapshot that runs out succeeds with <code>complete: false</code>. See <a href="/desktop/skeleton-and-drill-down#partial-observations">Partial observations</a>.</td></tr>
+ <tr><td><code>--surface KIND</code></td><td><code>window</code></td><td>Read an overlay instead of the window. See <a href="/desktop/surfaces#surface-kinds">Surface kinds</a>.</td></tr>
+ <tr><td><code>--force-electron-a11y</code></td><td>off</td><td>Assume Chromium renderer accessibility is already forced, which skips the activation guidance.</td></tr>
+ </tbody>
+</table>
+
+`data` carries `app`, `window`, `snapshot_id`, `ref_count`, `complete`, and `tree`; [Snapshots and refs](/desktop/snapshots-and-refs) shows a full example. With a post-action `--wait-for` ([Configuration](/desktop/configuration#post-action-wait-flags)), the result adds `elapsed_ms` and `matched_selector`.
+
+Errors specific to `snapshot`: `INVALID_ARGS` for `--root` with `--surface` or `--wait-for`, a bare ref, or `--max-depth` above 50; `WINDOW_NOT_FOUND` when there is no window to read; `AMBIGUOUS_TARGET` when the app has several candidate windows; `PLATFORM_NOT_SUPPORTED` for an unsupported `--surface`; `STALE_REF`, `SNAPSHOT_NOT_FOUND`, or `TIMEOUT` for a `--root` drill. See [What a drill refuses](/desktop/skeleton-and-drill-down#what-a-drill-refuses).
+
+Platform limits: supported surfaces and Chromium settle time differ by OS. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
+
+## find
+
+Searches by role, name, value, text, description, native id, or state, and returns refs you can act on. Use it when you know the target.
+
+```bash
+agent-desktop find [--app NAME] [--window-id ID] [--role ROLE] [--name TEXT] [--value TEXT] \
+ [--text TEXT] [--description TEXT] [--native-id ID] [--exact] \
+ [--state TOKEN[=BOOL]]... [--root REF] [--surface KIND] [--timeout-ms MS] \
+ [--count | --first | --last | --nth N | --limit N]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code>, <code>--window-id ID</code></td><td>focused window</td><td>Which window to search, with the same rules as <code>snapshot</code>.</td></tr>
+ <tr><td><code>--role ROLE</code></td><td>none</td><td>Accessibility role, case-insensitive. <code>textarea</code>, <code>textbox</code>, and <code>searchfield</code> fold to <code>textfield</code>.</td></tr>
+ <tr><td><code>--name TEXT</code></td><td>none</td><td>Accessible name. Fuzzy unless <code>--exact</code>.</td></tr>
+ <tr><td><code>--value TEXT</code></td><td>none</td><td>Current value. Unnamed elements carry their content here.</td></tr>
+ <tr><td><code>--text TEXT</code></td><td>none</td><td>Text in the name, value, or description. Also matches ancestors whose subtree contains it; use <code>--name</code> to match the node itself.</td></tr>
+ <tr><td><code>--description TEXT</code></td><td>none</td><td>Accessible description.</td></tr>
+ <tr><td><code>--native-id ID</code></td><td>none</td><td>Native automation id, such as an <code>AXIdentifier</code> or AutomationId.</td></tr>
+ <tr><td><code>--exact</code></td><td>off</td><td>Case-insensitive equality instead of a fuzzy match.</td></tr>
+ <tr><td><code>--state TOKEN[=BOOL]</code></td><td>none</td><td>Filter by a state, repeatable. A bare token means true. Tokens: <code>focused</code>, <code>disabled</code>, <code>secure</code>, <code>expanded</code>, <code>checked</code>, <code>selected</code>, <code>hidden</code>, <code>busy</code>, <code>modal</code>, <code>required</code>, <code>indeterminate</code>, <code>pressed</code>, <code>readonly</code>, <code>offscreen</code>, <code>invalid</code>, <code>multiselectable</code>, <code>haspopup</code>.</td></tr>
+ <tr><td><code>--root REF</code></td><td>none</td><td>Search one ref's subtree. See <a href="/desktop/skeleton-and-drill-down#scope-a-search">Scope a search</a>.</td></tr>
+ <tr><td><code>--surface KIND</code></td><td><code>window</code></td><td>Search an overlay. Cannot combine with <code>--root</code>.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Traversal deadline.</td></tr>
+ <tr><td><code>--count</code></td><td>off</td><td>Return the match count only.</td></tr>
+ <tr><td><code>--first</code>, <code>--last</code>, <code>--nth N</code></td><td>off</td><td>Return one match: the first, the last, or zero-based index <code>N</code>.</td></tr>
+ <tr><td><code>--limit N</code></td><td><code>50</code></td><td>Return at most <code>N</code> matches. <code>0</code> returns all. Use <code>--limit 2</code> before a mutation to check the match is unique.</td></tr>
+ </tbody>
+</table>
+
+`--count`, `--first`, `--last`, `--nth`, and `--limit` are mutually exclusive. The result shapes and match fields are in [JSON output](/desktop/json-output#find-results).
+
+```bash
+agent-desktop find --app gnome-calculator --role button --name 7 --exact --first
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "find",
+ "data": {
+ "match": {
+ "interactive": true,
+ "name": "7",
+ "path": ["window:Calculator", "group", "group", "group", "group", "group", "group", "group", "group", "group", "group", "group"],
+ "ref_id": "@s3jjre8xzrvo2l:e1",
+ "role": "button",
+ "states": [],
+ "value": null
+ },
+ "snapshot_id": "s3jjre8xzrvo2l"
+ }
+}
+```
+
+When a `--role` filter matches nothing, `roles_present` lists the roles in the searched tree, which tells a wrong role name from an empty screen. Errors specific to `find`: `INVALID_ARGS` for conflicting shaping flags, `--root` with `--surface`, or an unknown `--state` token; `TIMEOUT` with `details.kind: "locator_incomplete"` when the traversal ran out of budget, which does not mean the app hangs. Raise `--timeout-ms` or narrow the search.
+
+## get
+
+Reads one property of a ref.
+
+```bash
+agent-desktop get <REF> [--property text|value|title|bounds|role|states]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>REF</code></td><td>required</td><td>Qualified ref.</td></tr>
+ <tr><td><code>--property</code></td><td><code>text</code></td><td><code>text</code> is what a person reads: the value for <code>textfield</code>, <code>combobox</code>, <code>listbox</code>, <code>datefield</code>, and <code>timefield</code>, and the name for every other role, each falling back to the other. <code>value</code> is the raw value. <code>title</code> is the accessible name. <code>bounds</code>, <code>role</code>, and <code>states</code> are as named.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "get",
+ "data": { "property": "value", "ref": "@s30sxlstqzdq8x:e19", "value": "entry" }
+}
+```
+
+`text`, `value`, `bounds`, and `states` read live state when the adapter can and fall back to the snapshot's saved values otherwise; a missing value is `null`. Only `bounds` reports whether it was live, in `data.live`. When `live` is `false`, the rectangle came from the snapshot and may be out of date, so check it before you pass bounds to `mouse-click`.
+
+Errors specific to `get`: `INVALID_ARGS` for a bare ref or an unknown property, and the ref errors `SNAPSHOT_NOT_FOUND`, `STALE_REF`, and `AMBIGUOUS_TARGET`. See [Snapshots and refs](/desktop/snapshots-and-refs#how-a-ref-resolves).
+
+## is
+
+Checks one boolean state of a ref.
+
+```bash
+agent-desktop is <REF> [--property visible|enabled|checked|focused|expanded|selected]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>REF</code></td><td>required</td><td>Qualified ref.</td></tr>
+ <tr><td><code>--property</code></td><td><code>visible</code></td><td>The state to test.</td></tr>
+ </tbody>
+</table>
+
+```bash
+agent-desktop is @s30sxlstqzdq8x:e45 --property enabled
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "is",
+ "data": { "applicable": true, "property": "enabled", "ref": "@s30sxlstqzdq8x:e45", "result": false }
+}
+```
+
+`applicable: false` means the property does not apply or could not be read, so `result: false` then means unknown, not disabled or unchecked. Errors are the same as [`get`](#get).
+
+## screenshot
+
+Captures an app window or a display as a PNG. A screenshot is evidence for you, not proof that an action worked.
+
+```bash
+agent-desktop screenshot [PATH] [--app NAME] [--window-id ID] [--screen N]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>PATH</code></td><td>none</td><td>Save the image to this file. Without it, the image returns base64-encoded in <code>data.data</code>.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>none</td><td>Capture this app's window.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Capture one window by id.</td></tr>
+ <tr><td><code>--screen N</code></td><td>none</td><td>Capture the display at index <code>N</code> of <code>list-displays</code>, where <code>0</code> is the primary. Cannot combine with <code>--app</code> or <code>--window-id</code>.</td></tr>
+ </tbody>
+</table>
+
+```bash
+agent-desktop screenshot --screen 0 screen.png
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "screenshot",
+ "data": { "format": "png", "height": 900, "path": "/tmp/screen.png", "scale_factor": 1.0, "width": 1440 }
+}
+```
+
+Errors specific to `screenshot`: `PERM_DENIED` without screen-capture permission; `INVALID_ARGS` for `--screen` with a window selector, an out-of-range index, or an unwritable `PATH`; `WINDOW_NOT_FOUND` or `APP_NOT_FOUND` for an unknown target. On Linux, a covered window on a non-compositing window manager fails with `ACTION_FAILED` and `details.reason: "covered"`, and a display capture under a compositing one returns `PLATFORM_NOT_SUPPORTED`.
+
+Platform limits: macOS needs Screen Recording permission, and Wayland asks for portal consent. See [macOS](/desktop/platforms/macos) and [Linux](/desktop/platforms/linux).
+
+## list-displays
+
+Lists connected displays, primary first. It takes no flags.
+
+```bash
+agent-desktop list-displays
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "list-displays",
+ "data": [
+ { "bounds": { "height": 900.0, "width": 1440.0, "x": 0.0, "y": 0.0 }, "id": "screen", "is_primary": true, "scale": 1.0 }
+ ]
+}
+```
+
+Use the array index, not `id`, with `screenshot --screen`.
+
+## list-surfaces
+
+Lists the overlays an app presents now: the values `snapshot --surface` and `find --surface` accept for it.
+
+```bash
+agent-desktop list-surfaces [--app NAME]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--app NAME</code></td><td>focused app</td><td>Application to inspect.</td></tr>
+ </tbody>
+</table>
+
+`data` is `pid` and `surfaces`, each with `id`, `type`, and, when known, `title`, `item_count`, and `unclassified`. [Surfaces](/desktop/surfaces#list-what-is-open) shows an example and explains `unclassified`. Errors: `APP_NOT_FOUND`, `AMBIGUOUS_TARGET` when several instances match, and `TIMEOUT`.
+
+## open-system-surface
+
+Raises an OS shell surface, such as the Start menu or Action Center, and returns the window it presents. A surface that is already present returns without being raised again.
+
+```bash
+agent-desktop --headed open-system-surface --surface KIND
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--surface KIND</code></td><td>required</td><td>The shell surface: <code>start-menu</code>, <code>taskbar</code>, <code>system-tray</code>, <code>system-tray-overflow</code>, or <code>action-center</code>.</td></tr>
+ </tbody>
+</table>
+
+`data` is `surface` and `window`, with the same fields as a [`list-windows`](/desktop/commands/app-window#list-windows) entry. This shape comes from the command's unit test:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "open-system-surface",
+ "data": {
+ "surface": "action-center",
+ "window": { "app_name": "ShellExperienceHost.exe", "id": "w-4242", "is_focused": true, "pid": 99, "title": "Action center" }
+ }
+}
+```
+
+The command takes the foreground, so headless mode refuses it with `POLICY_DENIED` before anything is raised; pass `--headed`. A kind the OS does not expose returns `PLATFORM_NOT_SUPPORTED`, with the alternative in `platform_detail` where one exists. macOS has no shell surfaces, so every call there returns `PLATFORM_NOT_SUPPORTED`. Which kinds open on Windows and Linux is on their platform pages.
diff --git a/apps/docs/content/docs/commands/scroll.mdx b/apps/docs/content/docs/commands/scroll.mdx
new file mode 100644
index 000000000..5f19f097d
--- /dev/null
+++ b/apps/docs/content/docs/commands/scroll.mdx
@@ -0,0 +1,61 @@
+---
+title: Scroll commands
+navTitle: Scroll
+description: Reference for scroll and scroll-to, which move a scroll area or bring an element into view.
+---
+
+Both commands act on a qualified ref and share the [result shape](/desktop/commands/interaction#result-shape), [wait budget](/desktop/commands/interaction#wait-budget), and [shared errors](/desktop/commands/interaction#errors-shared-by-ref-commands) of the interaction commands. `scrollarea` elements get refs so that `scroll` can target them.
+
+## scroll
+
+Scrolls a scroll area in one direction by a number of units.
+
+```bash
+agent-desktop scroll <REF> [--direction up|down|left|right] [--amount N] [--timeout-ms MS]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>REF</code></td><td>required</td><td>Qualified ref of the scroll area.</td></tr>
+ <tr><td><code>--direction</code></td><td><code>down</code></td><td><code>up</code>, <code>down</code>, <code>left</code>, or <code>right</code>.</td></tr>
+ <tr><td><code>--amount N</code></td><td><code>3</code></td><td>Number of scroll units.</td></tr>
+ <tr><td><code>--timeout-ms MS</code></td><td><code>5000</code></td><td>Wait budget.</td></tr>
+ </tbody>
+</table>
+
+macOS and Windows scroll through native accessibility paths headless. On Linux, `scroll` is a physical wheel event, so headless it refuses before sending anything:
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "scroll",
+ "error": {
+ "code": "POLICY_DENIED",
+ "message": "Physical pointer input is disabled by the current interaction policy",
+ "recovery": {
+ "strategy": "request_explicit_policy_then_retry_original",
+ "retryable": true,
+ "requires_fresh_snapshot": false
+ },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+A delivered scroll is usually `delivered_unverified`. Take a fresh snapshot before you act on elements that were offscreen, because scrolling changes positions and a repeated scroll moves the view again. For a canvas or custom surface with no scroll action, use [`mouse-wheel`](/desktop/commands/mouse#mouse-wheel).
+
+Platform limits: Linux needs `--headed` and X11. See [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
+
+## scroll-to
+
+Brings an element into the visible area. Success means a re-read found the element visible.
+
+```bash
+agent-desktop scroll-to <REF> [--timeout-ms MS]
+```
+
+Most ref actions already scroll their target into view first, so you need `scroll-to` mainly to reveal an element before you read it or act on a neighbor. An element without a ref cannot be targeted: scroll its container with `scroll`. When the element's bounds cannot be read, the visibility check never passes and the command ends with `TIMEOUT` (`details.kind: "actionability_timeout"`, a `stable` check reading `live bounds unavailable`). On Windows, an element with no scrollable ancestor fails with `ACTION_FAILED` and `details.kind: "scroll_into_view_unsupported"`.
diff --git a/apps/docs/content/docs/commands/system.mdx b/apps/docs/content/docs/commands/system.mdx
new file mode 100644
index 000000000..0cc67982b
--- /dev/null
+++ b/apps/docs/content/docs/commands/system.mdx
@@ -0,0 +1,206 @@
+---
+title: System commands
+navTitle: System
+description: Reference for status, permissions, version, skills, session, cursor-overlay, and trace.
+---
+
+These commands report adapter and OS state, manage sessions and their traces, and configure the cursor overlay. None of them acts on an application. The examples are real output from Linux.
+
+## status
+
+Shows adapter health, platform, permissions, and the active snapshot and session. It takes no flags.
+
+```bash
+agent-desktop status
+```
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>platform</code>, <code>version</code></td><td>The OS and the agent-desktop version.</td></tr>
+ <tr><td><code>permissions</code></td><td>The object <a href="#permissions"><code>permissions</code></a> returns.</td></tr>
+ <tr><td><code>snapshot_id</code>, <code>ref_count</code></td><td>The latest snapshot in the selected namespace, or <code>null</code>.</td></tr>
+ <tr><td><code>session_id</code>, <code>tracing</code></td><td>The active session, or <code>null</code>, and whether a trace writer is attached.</td></tr>
+ <tr><td><code>artifacts</code></td><td><code>events</code> or <code>full</code>, for an active session only.</td></tr>
+ <tr><td><code>supported_surfaces</code></td><td>Surface kinds this adapter can read. Empty means the accessibility service did not answer. See <a href="/desktop/surfaces">Surfaces</a>.</td></tr>
+ <tr><td><code>state_root</code></td><td>The resolved <a href="/desktop/configuration#state-root">state root</a>.</td></tr>
+ </tbody>
+</table>
+
+[Installation](/desktop/installation#verify-the-install) shows a full result. A missing accessibility service does not fail `status`; it shows as a denied permission and an empty `supported_surfaces`. An invalid `AGENT_DESKTOP_HOME` or `AGENT_DESKTOP_SESSION` returns `INVALID_ARGS`.
+
+## permissions
+
+Reports the OS permission states agent-desktop needs.
+
+```bash
+agent-desktop permissions [--request] [--guide]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--request</code></td><td>off</td><td>Ask the OS to prompt for missing permissions, through a bounded helper so a stalled prompt cannot hang the command. This is the only path that prompts.</td></tr>
+ <tr><td><code>--guide</code></td><td>off</td><td>macOS only. Open System Settings with an on-screen guide and return without waiting. <code>data.guide</code> is <code>started</code>, <code>already_running</code>, or <code>not_needed</code>.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "permissions",
+ "data": {
+ "accessibility": { "state": "granted" },
+ "automation": { "state": "not_required" },
+ "screen_recording": { "state": "not_required" }
+ }
+}
+```
+
+Each state is `granted`, `denied` (with a `suggestion`), `not_required`, or `unknown`. On Windows and Linux, `--guide` returns `PLATFORM_NOT_SUPPORTED`.
+
+## version
+
+Prints the version, CPU architecture, and OS. It takes no flags.
+
+```json
+{ "version": "2.5", "ok": true, "command": "version", "data": { "os": "linux", "target": "x86_64", "version": "1.0.1" } }
+```
+
+The envelope's `version` is the JSON contract version; `data.version` is the release.
+
+## skills
+
+Prints the guides compiled into the binary. Usage, names, and references are on [Skills](/desktop/skills).
+
+```bash
+agent-desktop skills [list]
+agent-desktop skills get NAME [REFERENCE] [--full]
+agent-desktop skills path
+```
+
+## session
+
+Creates, lists, ends, and cleans up sessions. What a session is and how commands select one are on [Sessions](/desktop/sessions).
+
+```bash
+agent-desktop session start [--name LABEL] [--no-trace] [--screenshots] [--cursor [--multi-agent]]
+agent-desktop session end [ID]
+agent-desktop session list
+agent-desktop session gc [--older-than SECONDS] [--ended]
+```
+
+<table>
+ <thead>
+ <tr><th>Subcommand and flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>start --name LABEL</code></td><td>none</td><td>A label of 1 to 128 bytes.</td></tr>
+ <tr><td><code>start --no-trace</code></td><td>off</td><td>Create the session without tracing.</td></tr>
+ <tr><td><code>start --screenshots</code></td><td>off</td><td>Capture pre-action and post-action screenshots and refmap copies. Unredacted. Requires tracing.</td></tr>
+ <tr><td><code>start --cursor</code></td><td>off</td><td>Enable the cursor overlay with its default style.</td></tr>
+ <tr><td><code>start --multi-agent</code></td><td>off</td><td>Give each harness subagent its own cursor. Requires <code>--cursor</code>; desktop actions then need an agent id.</td></tr>
+ <tr><td><code>end [ID]</code></td><td>the active session</td><td>Seal the manifest; running it again on an ended session succeeds. Also stops every cursor overlay in the session.</td></tr>
+ <tr><td><code>gc --older-than SECONDS</code></td><td>none</td><td>Remove only sessions older than this; without <code>--ended</code>, sessions that never ended qualify once stale.</td></tr>
+ <tr><td><code>gc --ended</code></td><td>off</td><td>Remove ended sessions even if they wrote in the last five minutes.</td></tr>
+ </tbody>
+</table>
+
+`start` returns `session_id`, `name`, `trace`, `artifacts`, `created_at`, `next` (the shell line that exports the id), and `activation`; [Sessions](/desktop/sessions#start-list-end-and-clean-up) shows a full result. `end` returns `session_id` and `ended_at`, `list` returns `data.sessions`, and `gc` returns `data.removed`. `--screenshots` with `--no-trace` is `INVALID_ARGS`, and `--multi-agent` without `--cursor` is a parse error.
+
+## cursor-overlay
+
+Configures the presentation-only cursor overlay for a session. The overlay draws an agent cursor, a click ripple, and an element highlight, and never changes what an action does. It needs an active session, and it cannot run inside a [batch](/desktop/commands/batch).
+
+```bash
+agent-desktop --session "$AGENT_DESKTOP_SESSION" cursor-overlay enable [STYLE FLAGS]
+agent-desktop --session "$AGENT_DESKTOP_SESSION" cursor-overlay disable
+```
+
+<table>
+ <thead>
+ <tr><th><code>enable</code> flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--multi-agent</code></td><td>off</td><td>Require an agent id for desktop actions. Rejected together with <code>--agent-id</code>.</td></tr>
+ <tr><td><code>--label TEXT</code>, <code>--max-words N</code></td><td>none, <code>6</code></td><td>Intent text beside the cursor, limited to 1 to 12 words.</td></tr>
+ <tr><td><code>--fill HEX</code>, <code>--rim HEX</code>, <code>--accent HEX</code></td><td><code>#FFFFFF</code>, <code>#111318</code>, <code>#4299FF</code></td><td>Cursor body, outline, and ripple colors.</td></tr>
+ <tr><td><code>--size N</code></td><td><code>1.0</code></td><td>Size multiplier, 0.5 to 4.0.</td></tr>
+ <tr><td><code>--no-ripple</code>, <code>--no-highlight</code></td><td>off</td><td>Turn off the click ripple or the element outline.</td></tr>
+ <tr><td><code>--image PATH</code>, <code>--hotspot X,Y</code></td><td>built-in arrow</td><td>Draw the cursor from a PNG (at most 2 MiB and 1024 pixels per side) with its click point.</td></tr>
+ <tr><td><code>--pointer-image PATH</code>, <code>--pointer-hotspot X,Y</code></td><td>none</td><td>PNG shown over pressable controls, with its click point.</td></tr>
+ <tr><td><code>--travel-ms MIN,MAX</code></td><td><code>90,320</code></td><td>Travel time range for short to long moves.</td></tr>
+ <tr><td><code>--bow N</code>, <code>--overshoot N</code>, <code>--tremor PX</code></td><td><code>1</code>, <code>0.035</code>, <code>1.1</code></td><td>Path curvature (0 to 3), overshoot fraction (0 to 0.15), and tremor in points (0 to 4).</td></tr>
+ <tr><td><code>--dwell-ms N</code></td><td><code>0</code></td><td>Pause on the target before the action, 0 to 300. Maximum travel plus dwell must not exceed 700 ms.</td></tr>
+ <tr><td><code>--motion-seed N</code></td><td>none</td><td>Vary each move deterministically.</td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "cursor-overlay",
+ "data": {
+ "activation": { "environment": "AGENT_DESKTOP_SESSION", "value": "run-1793353372413-23159-0" },
+ "cursor_overlay": {
+ "enabled": true,
+ "max_words": 6,
+ "style": { "accent": "#4299FF", "fill": "#FFFFFF", "highlight": true, "rim": "#111318", "ripple": true, "size": 1.0 }
+ },
+ "next": "export AGENT_DESKTOP_SESSION=run-1793353372413-23159-0",
+ "rendered": true,
+ "session_id": "run-1793353372413-23159-0"
+ }
+}
+```
+
+`rendered: false` means the setting was saved but nothing was drawn, as on Linux Wayland. With `--agent-id`, `enable` saves the style as that agent's profile. `disable` stops every cursor in the session; if teardown cannot be confirmed, the setting is still saved and the error's disposition is `delivery_uncertain`. How headed actions and the overlay interact is in [Headed mode](/desktop/guides/headed-mode#see-where-actions-land).
+
+## trace
+
+Reads the merged trace timeline of the active session. Both actions need an active session and no OS permission. Recording and privacy are in [Traces](/desktop/guides/traces).
+
+```bash
+agent-desktop --session "$AGENT_DESKTOP_SESSION" trace show [--limit N] [--event PREFIX]
+agent-desktop --session "$AGENT_DESKTOP_SESSION" trace export [--out PATH] [--limit N]
+```
+
+<table>
+ <thead>
+ <tr><th>Subcommand and flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>show --limit N</code></td><td><code>500</code></td><td>Return the last N merged events. <code>0</code> returns all.</td></tr>
+ <tr><td><code>show --event PREFIX</code></td><td>none</td><td>Keep only events whose name starts with this prefix, before the limit applies.</td></tr>
+ <tr><td><code>export --out PATH</code></td><td><code>trace-SESSION.html</code> in the session directory</td><td>Output path for a self-contained HTML viewer.</td></tr>
+ <tr><td><code>export --limit N</code></td><td><code>5000</code></td><td>Embed the last N events. <code>0</code> embeds all.</td></tr>
+ </tbody>
+</table>
+
+`show` returns `session_id`, `segments`, `total_events`, `returned_events`, `truncated`, and `events`, plus `matched_events` with `--event` and `warnings` for skipped lines. `export` returns:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "trace",
+ "data": {
+ "bytes": 26611,
+ "event_count": 9,
+ "path": "/tmp/run.html",
+ "returned_events": 9,
+ "screenshots_embedded": 0,
+ "screenshots_skipped": 0,
+ "total_events": 9,
+ "truncated": false
+ }
+}
+```
+
+Without an active session, or with a session that recorded nothing, both return `INVALID_ARGS`.
diff --git a/apps/docs/content/docs/commands/wait.mdx b/apps/docs/content/docs/commands/wait.mdx
new file mode 100644
index 000000000..2a3886a38
--- /dev/null
+++ b/apps/docs/content/docs/commands/wait.mdx
@@ -0,0 +1,174 @@
+---
+title: wait
+navTitle: Wait
+description: Reference for the wait command, with every mode, the element predicates, the event kinds, timeouts and their defaults, and the timeout error details.
+---
+
+`wait` blocks until a condition holds, so you do not need a fixed sleep. Each call uses exactly one mode. When to use `wait` and when to use the post-action `--wait-for` flags is in [Waiting without sleeps](/desktop/guides/waiting); those flags are in [Configuration](/desktop/configuration#post-action-wait-flags). The examples are real output from Linux.
+
+## wait
+
+```bash
+agent-desktop wait MS
+agent-desktop wait --element REF [--predicate NAME] [--value TEXT] [--action NAME]
+agent-desktop wait --window TITLE [--app NAME]
+agent-desktop wait --text TEXT [--count N] [--app NAME]
+agent-desktop wait --menu [--app NAME]
+agent-desktop wait --menu-closed [--app NAME]
+agent-desktop wait --notification [--text TEXT] [--app NAME]
+agent-desktop wait --event KIND [--app NAME] [--window TITLE] [--window-id ID]
+```
+
+<table>
+ <thead>
+ <tr><th>Flag or argument</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>MS</code></td><td>none</td><td>Pause for this many milliseconds.</td></tr>
+ <tr><td><code>--element REF</code></td><td>none</td><td>Wait until the element behind this qualified ref satisfies <code>--predicate</code>.</td></tr>
+ <tr><td><code>--predicate NAME</code></td><td><code>exists</code></td><td><code>exists</code>, <code>enabled</code>, <code>visible</code>, <code>actionable</code>, or <code>value</code>. Requires <code>--element</code>.</td></tr>
+ <tr><td><code>--value TEXT</code></td><td>none</td><td>Expected value for <code>--predicate value</code>. Required there and rejected otherwise.</td></tr>
+ <tr><td><code>--action NAME</code></td><td><code>click</code></td><td>For <code>--predicate actionable</code>: <code>click</code>, <code>type</code>, <code>set-value</code>, or <code>clear</code>.</td></tr>
+ <tr><td><code>--window TITLE</code></td><td>none</td><td>Wait until a window whose title contains this text exists. With <code>--event</code>, it narrows the event to an exact title instead.</td></tr>
+ <tr><td><code>--text TEXT</code></td><td>none</td><td>Wait until this text appears in the app's tree. With <code>--notification</code>, it filters notification text instead.</td></tr>
+ <tr><td><code>--count N</code></td><td>none</td><td>For <code>--text</code>: wait until exactly N nodes match.</td></tr>
+ <tr><td><code>--menu</code>, <code>--menu-closed</code></td><td>off</td><td>Wait until a menu surface is open, or dismissed.</td></tr>
+ <tr><td><code>--notification</code></td><td>off</td><td>Wait until a new notification arrives.</td></tr>
+ <tr><td><code>--event KIND</code></td><td>none</td><td>Wait for a lifecycle signal: <code>window-opened</code>, <code>window-closed</code>, <code>app-launched</code>, <code>app-terminated</code>, <code>focus-changed</code>, <code>surface-appeared</code>, or <code>surface-dismissed</code>.</td></tr>
+ <tr><td><code>--window-id ID</code></td><td>none</td><td>Narrow <code>window-opened</code>, <code>window-closed</code>, or <code>focus-changed</code> to one window.</td></tr>
+ <tr><td><code>--app NAME</code></td><td>none</td><td>Scope a window, text, menu, notification, or event wait to one application. Element and time waits ignore it.</td></tr>
+ <tr><td><code>--timeout MS</code></td><td><code>30000</code></td><td>Timeout for every mode except <code>MS</code>, at most 86400000.</td></tr>
+ </tbody>
+</table>
+
+Flags from two modes, or no mode at all, return `INVALID_ARGS`. The wait polls about every 100 ms and wakes early when the platform signals a change. `wait` never changes the application, so a failed wait leaves nothing half-applied; a successful `--text` wait saves a snapshot.
+
+### Time
+
+`wait MS` sleeps and returns `{ "waited_ms": MS }`. Use it only to space two actions apart when nothing observable marks readiness.
+
+### Element
+
+`--element REF` polls the live element behind a ref until the predicate holds. The ref names its snapshot, so no `--app` is needed. This waits for the calculator display to read `7`:
+
+```bash
+agent-desktop wait --element @s2txcl95uvubmn:e6 --predicate value --value 7 --timeout 5000
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "wait",
+ "data": {
+ "elapsed_ms": 286,
+ "found": true,
+ "observed": { "expected_chars": 1, "matched": true, "value_chars": 1, "value_present": true },
+ "predicate": "value",
+ "ref": "@s2txcl95uvubmn:e6"
+ }
+}
+```
+
+`observed` depends on the predicate: `exists`; `enabled` or `visible` with `applicable`; `actionable` with `checks`; or the value counts above, which never echo the value itself. `actionable` runs the checks the action would run; use `--action type` before typing, because the editability check runs only for editing actions. A ref that does not resolve yet keeps being retried until the timeout.
+
+### Window
+
+`--window TITLE` waits for any window whose title contains `TITLE`, focused or not.
+
+```bash
+agent-desktop wait --window Calculator --app gnome-calculator --timeout 3000
+```
+
+The result is `{ "elapsed_ms", "found": true, "window": WINDOW }`, where `WINDOW` has the fields `list-windows` returns.
+
+### Text
+
+`--text TEXT` snapshots the app's window each poll and looks for the text in node names, values, and descriptions, as a case-insensitive substring.
+
+```bash
+agent-desktop wait --text Calculator --app gnome-calculator --timeout 3000
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "wait",
+ "data": { "elapsed_ms": 112, "found": true, "ref": null, "role": "window", "snapshot_id": "s2uiek94hz3vms", "text": "Calculator" }
+}
+```
+
+`ref` and `role` describe the first match, and `ref` is `null` when that node has no ref. The wait saves its snapshot, so `snapshot_id` is fresh and acts like any snapshot. When an app has several eligible windows, such as a document and its save dialog, the wait returns `AMBIGUOUS_TARGET` before it checks any text: wait for the dialog with `--window` instead.
+
+### Menu
+
+`--menu` waits until a menu surface is open, and `--menu-closed` until it is gone. Both return `{ "elapsed_ms", "found": true }`. On Linux, `--menu-closed` on a menu that never opened is true at once, so wait for `--menu` first.
+
+### Notification
+
+`--notification` takes a baseline of the notification list when it starts and returns the first notification not in it. `--text` and `--app` filter which notifications count. The result is `{ "condition": "notification", "matched": true, "notification": {...}, "elapsed_ms" }`. Headless limits on macOS and Windows are on the [notification commands](/desktop/commands/notifications) page.
+
+### Event
+
+`--event KIND` compares a baseline taken at the start with fresh reads and returns the first matching change, so you need no window id or title in advance. Put the action that causes the event and the wait in one [batch](/desktop/commands/batch): the batch captures the baseline before the action runs. This entry waited for the window of an app the previous entry launched:
+
+```json
+{
+ "command": "wait",
+ "data": {
+ "elapsed_ms": 144,
+ "event": {
+ "app": "gtk3-demo",
+ "kind": "window_opened",
+ "pid": 23270,
+ "title": "Application Class",
+ "window_id": "w-1.167-org-a11y-atspi-accessible-44"
+ },
+ "found": true
+ },
+ "execution": "completed",
+ "index": 1,
+ "ok": true,
+ "version": "2.5"
+}
+```
+
+`event.kind` uses snake_case. Surface events add `surface` and require `--app`; `--window` and `--window-id` apply only to the three window kinds.
+
+`--app` resolves once, at the start, to one process. When no app matches, `app-launched`, `window-opened`, and `surface-appeared` keep polling, so you can race a launch. `app-terminated`, `window-closed`, and `surface-dismissed` return at once with `found: true` and `target_unresolved: true`, which a misspelled `--app` also produces. `focus-changed` returns `APP_NOT_FOUND`.
+
+### Errors
+
+A wait that runs out of time returns `TIMEOUT` with `details.kind: "wait_timeout"`, `details.predicate`, `details.timeout_ms`, and what the wait last saw:
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "wait",
+ "error": {
+ "code": "TIMEOUT",
+ "message": "Window title (7 chars) not found within 1000ms",
+ "recovery": {
+ "strategy": "inspect_state_then_retry_original",
+ "retryable": true,
+ "requires_fresh_snapshot": true,
+ "retry_after_ms": 250
+ },
+ "details": {
+ "app": "gedit",
+ "kind": "wait_timeout",
+ "last_observed": { "count": 1, "titles": ["Untitled Document 1 - gedit"], "truncated": false },
+ "predicate": "window",
+ "timeout_ms": 1000,
+ "title": "Save As"
+ },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+Element waits carry `ref` and `last_observed`; text waits carry `text_chars` and `expected_count` but not the text; event waits carry `baseline_counts`; any mode can carry `last_error`. Other errors: `INVALID_ARGS` for a bad mode combination or a bare ref, the ref errors for `--element`, `APP_UNRESPONSIVE` when the app stops answering, and `PERM_DENIED`.
+
+Platform limits: see [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), and [Linux](/desktop/platforms/linux).
diff --git a/apps/docs/content/docs/configuration.mdx b/apps/docs/content/docs/configuration.mdx
new file mode 100644
index 000000000..08535f9a7
--- /dev/null
+++ b/apps/docs/content/docs/configuration.mdx
@@ -0,0 +1,106 @@
+---
+title: Configuration
+navTitle: Configuration
+description: Global flags, post-action wait flags, environment variables, and the state root where agent-desktop stores snapshots, sessions, and traces.
+---
+
+agent-desktop has no configuration file. Behavior comes from global flags on each command, a few environment variables, and the state root directory where snapshots, sessions, and traces live.
+
+## Global flags
+
+Global flags work before or after the command name, so `agent-desktop --headed click REF` and `agent-desktop click REF --headed` are the same. `agent-desktop --help` lists them.
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th>Default</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--headed</code></td><td>off</td><td>Prefer physical delivery for natural input commands and allow focus and cursor side effects. The default is strict headless semantic delivery. See <a href="/desktop/guides/headed-mode">Headed mode</a>.</td></tr>
+ <tr><td><code>--session ID</code></td><td>none</td><td>Select the snapshot namespace and trace. Overrides <code>AGENT_DESKTOP_SESSION</code>. See <a href="/desktop/sessions">Sessions</a>.</td></tr>
+ <tr><td><code>--agent-id ID</code></td><td>none</td><td>Subagent id within the session. Overrides <code>AGENT_DESKTOP_AGENT_ID</code>. Required for desktop actions in a multi-agent session.</td></tr>
+ <tr><td><code>--trace PATH</code></td><td>off</td><td>Append trace events as JSONL to this file instead of the session's trace. See <a href="/desktop/guides/traces">Traces</a>.</td></tr>
+ <tr><td><code>--trace-strict</code></td><td>off</td><td>Fail when trace setup or a pre-action write fails. Requires <code>--trace</code> or a tracing session.</td></tr>
+ <tr><td><code>--wait-for SELECTOR</code>, <code>-w</code></td><td>none</td><td>After the command, poll until an element matches. See <a href="#post-action-wait-flags">Post-action wait flags</a>.</td></tr>
+ <tr><td><code>--wait-for-gone SELECTOR</code></td><td>none</td><td>After the command, poll until no element matches.</td></tr>
+ <tr><td><code>--wait-timeout MS</code></td><td><code>30000</code></td><td>Longest wait for the two flags above.</td></tr>
+ <tr><td><code>--verbose</code>, <code>-v</code></td><td>off</td><td>Write debug logs to stderr. Stdout stays one JSON envelope.</td></tr>
+ <tr><td><code>--debug</code>, <code>--screenshot PATH.html</code></td><td>off</td><td>Write a visual debug HTML file for <code>snapshot</code> or <code>click</code>. Each requires the other. See <a href="/desktop/guides/traces#make-a-visual-debug-file">Traces</a>.</td></tr>
+ <tr><td><code>--help</code>, <code>-h</code>; <code>--version</code>, <code>-V</code></td><td></td><td>Print help or the version as text. The <code>version</code> command prints it as JSON.</td></tr>
+ </tbody>
+</table>
+
+## Post-action wait flags
+
+`--wait-for`, `--wait-for-gone`, and `--wait-timeout` make a command wait for the UI to show its effect. The command runs first; then the flag polls the accessibility tree until the selector is satisfied or the timeout ends. [Waiting without sleeps](/desktop/guides/waiting) compares them with the [`wait`](/desktop/commands/wait) command.
+
+**Selector.** `role:text`, split at the first `:`. `button` matches by role, `:Saved` by text, and `button:Save` by both. Text is a case-insensitive substring of an element's name, value, or description. An empty selector returns `INVALID_ARGS` before the command runs.
+
+**Commands that accept them.** `snapshot`, `press`, `hover`, `drag`, and every ref action (`click`, `double-click`, `triple-click`, `right-click`, `type`, `set-value`, `clear`, `focus`, `select`, `toggle`, `check`, `uncheck`, `expand`, `collapse`, `scroll`, `scroll-to`). Every other command returns `INVALID_ARGS`. `snapshot --root` cannot combine with them, and a `batch` entry never inherits them.
+
+**Which window is polled.** For `snapshot`, the window it reads. For a ref action, the window of the element you acted on. For `press`, the `--app` or `--window-id` window, else the focused one. For `drag`, the destination window, or the source with `--wait-for-scope from`.
+
+**Results.**
+
+- `--wait-for` succeeds with snapshot data (`snapshot_id`, `ref_count`, `tree`, and so on) plus `elapsed_ms` and `matched_selector`. For an action, the action's own report moves under `data.after_action`.
+- `--wait-for-gone` succeeds with `matched_selector`, `gone: true`, `target_absent: true`, and `elapsed_ms`, with the action's report under `after_action`.
+- On expiry the command fails with `TIMEOUT`, `details.kind: "wait_timeout"`, `details.selector`, and `details.timeout_ms`. After an action, `details.after_action` holds its report, and the error keeps the action's own delivery disposition, so a timeout does not make the action safe to repeat.
+
+```bash
+agent-desktop click @s8f3k2p9:e5 --wait-for ":Saved" --wait-timeout 5000
+agent-desktop click @s8f3k2p9:e5 --wait-for-gone "progressindicator"
+agent-desktop snapshot --app gnome-calculator -w "button:7"
+```
+
+## Environment variables
+
+<table>
+ <thead>
+ <tr><th>Variable</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>AGENT_DESKTOP_HOME</code></td><td>Relocates the <a href="#state-root">state root</a>. Must be an absolute path.</td></tr>
+ <tr><td><code>AGENT_DESKTOP_SESSION</code></td><td>Session id used when <code>--session</code> is not passed. <code>session start</code> prints the line that sets it. An empty value is <code>INVALID_ARGS</code>.</td></tr>
+ <tr><td><code>AGENT_DESKTOP_AGENT_ID</code></td><td>Subagent id used when <code>--agent-id</code> is not passed.</td></tr>
+ <tr><td><code>AGENT_DESKTOP_MACOS_HELPER_PATH</code></td><td>macOS only. Absolute path to the packaged <code>agent-desktop-macos-helper</code>. The npm launcher sets it.</td></tr>
+ <tr><td><code>RUST_LOG</code></td><td>Log filter for stderr logs. A valid value replaces the default level.</td></tr>
+ </tbody>
+</table>
+
+An invalid value returns `INVALID_ARGS` with `not_delivered`, and nothing runs. In PowerShell, set a variable with `$env:AGENT_DESKTOP_HOME = "$env:TEMP\ad-scratch"`. On Linux the adapter also reads the desktop session's `DISPLAY`, `WAYLAND_DISPLAY`, `XDG_RUNTIME_DIR`, and `DBUS_SESSION_BUS_ADDRESS`; see [Linux](/desktop/platforms/linux).
+
+## State root
+
+agent-desktop keeps its state under one directory: `.agent-desktop` in your home directory by default. `agent-desktop status` reports the resolved path as `state_root`. `AGENT_DESKTOP_HOME` replaces the default:
+
+- It must be an absolute path. If it exists, it must be a directory you own and not a symlink.
+- It does not need to exist yet; it is created on first use with mode `0700` on macOS and Linux.
+
+On macOS and Linux the state root must stay private. A root that is group-writable or readable by other users makes commands that write there fail with `INTERNAL`, "private file parent is accessible by group or other users". Run `chmod 700` on it, or let agent-desktop create it. A fresh root per run isolates refs:
+
+```bash
+export AGENT_DESKTOP_HOME="$(mktemp -d)" # absolute and private
+agent-desktop status # data.state_root shows this path
+```
+
+### Layout
+
+```text
+~/.agent-desktop/ state root
+ latest_snapshot_id newest snapshot in the global namespace
+ snapshots/
+ s8f3k2p9/refmap.json one refmap per snapshot
+ tmp/ clipboard-get images outside a session
+ sessions/
+ run-1793352720537-17009-0/ one directory per session
+ session.json manifest
+ latest_snapshot_id
+ snapshots/s8f3k2p9/refmap.json the session's own namespace
+ trace/ JSONL segments, one per process
+ clipboard/ clipboard-get images inside the session
+```
+
+- **Snapshots.** Each snapshot writes `snapshots/<id>/refmap.json`. Size and retention limits are in [Where refs are stored](/desktop/snapshots-and-refs#where-refs-are-stored).
+- **Sessions.** `session start` creates `sessions/<id>/` with its own `snapshots/`, so one session's refs are invisible to another. `session gc` deletes ended sessions with their traces. See [Sessions](/desktop/sessions).
+- **Traces.** A tracing session writes one JSONL segment per process under `trace/`, plus `screens/` and `refmaps/` with `--screenshots`. See [Traces](/desktop/guides/traces).
+
+The cross-process interaction lock lives outside the state root (under `/tmp` on macOS and Linux), so every agent of one user shares it whatever their `AGENT_DESKTOP_HOME`. Files you name yourself, such as a `--trace` path or a screenshot path, are also outside it.
diff --git a/apps/docs/content/docs/meta.json b/apps/docs/content/docs/meta.json
index e9f0098f6..d7c702b4c 100644
--- a/apps/docs/content/docs/meta.json
+++ b/apps/docs/content/docs/meta.json
@@ -10,6 +10,9 @@
"surfaces",
"sessions",
"json-output",
- "errors-and-recovery"
+ "errors-and-recovery",
+ "---Reference---",
+ "...commands",
+ "configuration"
]
}