Skip to content

Computer use CLI for AI agents

docs: document snapshots, refs, skeleton drill-down, and the other core concepts (2/4) (#340)

Lahfirddf817b77242
diff --git a/apps/docs/content/docs/errors-and-recovery.mdx b/apps/docs/content/docs/errors-and-recovery.mdx
new file mode 100644
index 000000000..2932b93a7
--- /dev/null
+++ b/apps/docs/content/docs/errors-and-recovery.mdx
@@ -0,0 +1,116 @@
+---
+title: Errors and recovery
+navTitle: Errors and recovery
+description: The error object, all 16 error codes, delivery and retry dispositions, recovery strategies, and when it is safe to retry.
+---
+
+A failed command prints an envelope with `ok: false` and exits `1` (or `2` for a parse error). Branch on `error.code` and `error.disposition`, never on `message` or `suggestion`, whose wording can change. Before you retry or substitute an action, read `error.disposition.retry`.
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "click",
+ "error": {
+ "code": "SNAPSHOT_NOT_FOUND",
+ "message": "Snapshot 's3tufs86hddhyl' not found",
+ "suggestion": "Re-run a snapshot and retry with a ref from the returned snapshot (CLI: snapshot, then use the printed @<snapshot_id>:eN ref; ...)",
+ "recovery": {
+ "strategy": "refresh_snapshot_then_retry_original",
+ "retryable": true,
+ "requires_fresh_snapshot": true
+ },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+## The error object
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Present</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>code</code></td><td>always</td><td>One of the 16 codes below.</td></tr>
+ <tr><td><code>message</code></td><td>always</td><td>Human-readable text. Not a stable interface.</td></tr>
+ <tr><td><code>disposition</code></td><td>always</td><td>What the failure says about delivery and retry. See <a href="#disposition">Disposition</a>.</td></tr>
+ <tr><td><code>suggestion</code></td><td>when set</td><td>A hint for a person or an agent. Check any command it names before you run it.</td></tr>
+ <tr><td><code>recovery</code></td><td>only when retry is safe</td><td>A declared recovery plan. See <a href="#recovery-strategies">Recovery strategies</a>.</td></tr>
+ <tr><td><code>platform_detail</code></td><td>when set</td><td>The native platform's own error text.</td></tr>
+ <tr><td><code>details</code></td><td>when set</td><td>Structured context. <code>details.kind</code> names the cause for many codes, for example <code>actionability_timeout</code>, <code>wait_timeout</code>, <code>session_ended</code>, or <code>post_action_verification</code>.</td></tr>
+ </tbody>
+</table>
+
+## Error codes
+
+<table>
+ <thead>
+ <tr><th>Code</th><th>What it means</th><th>What to do</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>PERM_DENIED</code></td><td>A required operating system permission is missing, such as Accessibility or Screen Recording.</td><td>Run <code>agent-desktop permissions</code> and grant it. See the <a href="/desktop/platforms/macos">macOS</a>, <a href="/desktop/platforms/windows">Windows</a>, and <a href="/desktop/platforms/linux">Linux</a> pages.</td></tr>
+ <tr><td><code>ELEMENT_NOT_FOUND</code></td><td>No element matched the ref or query.</td><td>Take a fresh snapshot or run <code>find</code> again, then use the new ref.</td></tr>
+ <tr><td><code>APP_NOT_FOUND</code></td><td>The application is not running, or it has no windows.</td><td>Check the name with <code>list-apps</code>. Run <code>launch</code> if it is not running.</td></tr>
+ <tr><td><code>ACTION_FAILED</code></td><td>The action was rejected or blocked, or its observed result contradicted the request.</td><td>Read <code>details</code> and <code>disposition.retry</code>. It never carries <code>recovery</code>.</td></tr>
+ <tr><td><code>ACTION_NOT_SUPPORTED</code></td><td>The target, or this platform for this input, does not expose the requested action.</td><td>Use a different command or element. Repeating it fails the same way.</td></tr>
+ <tr><td><code>STALE_REF</code></td><td>The ref no longer matches a live element.</td><td>Take a fresh snapshot and use the new ref. See <a href="/desktop/snapshots-and-refs">Snapshots and refs</a>.</td></tr>
+ <tr><td><code>AMBIGUOUS_TARGET</code></td><td>Several live elements, windows, or app instances match, and the command refuses to guess.</td><td>Narrow the target with <code>find</code>, <code>--root</code>, or <code>--window-id</code>, then use the new ref. It never carries <code>recovery</code>.</td></tr>
+ <tr><td><code>WINDOW_NOT_FOUND</code></td><td>The requested window does not exist, including a <code>--window-id</code> that matches no window or a closed shell surface.</td><td>Run <code>list-windows --app &lt;name&gt;</code> and use an id it reports.</td></tr>
+ <tr><td><code>PLATFORM_NOT_SUPPORTED</code></td><td>This platform's adapter does not implement the method or surface kind.</td><td>Use another approach. The platform pages list what each OS supports.</td></tr>
+ <tr><td><code>TIMEOUT</code></td><td>A wait expired, the target never became actionable, or a read stayed incomplete until the deadline.</td><td>Read <code>details.kind</code>. Retry only when <code>disposition.retry</code> is <code>safe</code>.</td></tr>
+ <tr><td><code>INVALID_ARGS</code></td><td>An argument is invalid. Also returned for a bare <code>@eN</code> ref and an ended session.</td><td>Fix the input. Repeating the same arguments fails the same way.</td></tr>
+ <tr><td><code>NOTIFICATION_NOT_FOUND</code></td><td>The notification index or identity no longer matches.</td><td>Run <code>list-notifications</code> again.</td></tr>
+ <tr><td><code>SNAPSHOT_NOT_FOUND</code></td><td>The snapshot id is missing, pruned, or belongs to another <a href="/desktop/sessions">session</a> namespace.</td><td>Take a snapshot in the same session scope you act in, then use its refs.</td></tr>
+ <tr><td><code>POLICY_DENIED</code></td><td>Headless mode blocked a physical or headed path.</td><td>Do not switch modes to recover. See <a href="/desktop/guides/headed-mode">Headed mode</a>.</td></tr>
+ <tr><td><code>APP_UNRESPONSIVE</code></td><td>The application stopped responding.</td><td>Wait, take a fresh snapshot, then retry only if <code>disposition.retry</code> is <code>safe</code>.</td></tr>
+ <tr><td><code>INTERNAL</code></td><td>An unexpected error.</td><td>Read <code>message</code>. Retry once only if <code>disposition.retry</code> is <code>safe</code>.</td></tr>
+ </tbody>
+</table>
+
+## Disposition
+
+`disposition` says whether input reached the application, and from that, whether repeating the command is safe. Every error carries it. Commands that act on a target also carry it on success, as `data.disposition`.
+
+<table>
+ <thead>
+ <tr><th><code>delivery</code></th><th><code>retry</code></th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>not_delivered</code></td><td><code>safe</code></td><td>The input never reached the application. Repeating the command cannot duplicate an effect.</td></tr>
+ <tr><td><code>delivery_uncertain</code></td><td><code>unsafe</code></td><td>The input may have landed, and nothing proves either way.</td></tr>
+ <tr><td><code>delivered_unverified</code></td><td><code>unsafe</code></td><td>The input was dispatched, and its effect was not confirmed.</td></tr>
+ <tr><td><code>delivered_verified</code></td><td><code>unsafe</code></td><td>The input was dispatched and the effect was read back. Repeating it would apply it twice.</td></tr>
+ <tr><td><code>unknown</code></td><td><code>unknown</code></td><td>The command established nothing about delivery, for example a <code>TIMEOUT</code> on an operation that may already have landed.</td></tr>
+ </tbody>
+</table>
+
+`retry` follows from `delivery`: only `not_delivered` is `safe`, `unknown` stays `unknown`, and every other value is `unsafe`. A refusal that cannot have delivered anything is stamped `not_delivered`: an argument error, a failure before dispatch, and any error from a read-only command such as `snapshot` or `find`.
+
+**Retry or substitute an action only when `disposition.retry` is `safe`.** When it is `unsafe` or `unknown`, observe first: take a snapshot, read the element with `get` or `is`, or check the app, and decide from what you see. A repeated `click` can submit twice, and a repeated `toggle` undoes itself.
+
+## Recovery strategies
+
+`recovery` appears only when `disposition.retry` is `safe`, the code has a declared plan, and the adapter has not marked the failure non-retryable with `details.retryable: false`. It has `strategy`, `retryable`, `requires_fresh_snapshot`, and, for two codes, `retry_after_ms`.
+
+<table>
+ <thead>
+ <tr><th><code>strategy</code></th><th>Codes</th><th>What the caller does</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>refresh_snapshot_then_retry_original</code></td><td><code>STALE_REF</code>, <code>SNAPSHOT_NOT_FOUND</code></td><td>Take a fresh snapshot (or <code>find</code>), locate the same element, and run the original command again with the new qualified ref.</td></tr>
+ <tr><td><code>inspect_state_then_retry_original</code></td><td><code>TIMEOUT</code>, <code>APP_UNRESPONSIVE</code>, and <code>STALE_REF</code> when <code>details.process_state</code> is <code>exited</code></td><td>Inspect the app first (<code>list-apps</code>, a snapshot, or a <code>wait</code>), wait <code>retry_after_ms</code> if present, then run the original command. For an exited process, launch the app again and take a new snapshot first.</td></tr>
+ <tr><td><code>request_explicit_policy_then_retry_original</code></td><td><code>POLICY_DENIED</code></td><td>Retry only after someone has explicitly chosen the policy the command needs, such as <code>--headed</code> when physical input is intended. Never switch to headed mode on your own to get past the error.</td></tr>
+ </tbody>
+</table>
+
+`STALE_REF` uses `inspect_state_then_retry_original` only when `details.process_state` is `exited`, and `refresh_snapshot_then_retry_original` otherwise. Every other code, such as `ACTION_FAILED`, `INVALID_ARGS`, or `AMBIGUOUS_TARGET`, never carries `recovery`. Follow the "What to do" column instead.
+
+`retry_after_ms` is set only for `TIMEOUT` and `APP_UNRESPONSIVE` (250 ms in this release). `details.retryable` is the adapter's own judgment: `false` means waiting cannot change the outcome, so try a different approach, and it suppresses `recovery` even for a code that would otherwise carry one.
+
+## Decide whether to retry
+
+1. Read `error.code`. For `INVALID_ARGS`, `ACTION_NOT_SUPPORTED`, `PLATFORM_NOT_SUPPORTED`, or `PERM_DENIED`, change the input or the environment. A retry will not help.
+2. Read `error.disposition.retry`. If it is `unsafe` or `unknown`, observe the application before you act again.
+3. If it is `safe` and `recovery` is present, follow the strategy.
+4. If it is `safe` and `recovery` is absent, fix the cause from the code table, then repeat the command, for example with a new ref from `find`.
diff --git a/apps/docs/content/docs/json-output.mdx b/apps/docs/content/docs/json-output.mdx
new file mode 100644
index 000000000..053d63e60
--- /dev/null
+++ b/apps/docs/content/docs/json-output.mdx
@@ -0,0 +1,207 @@
+---
+title: JSON output
+navTitle: JSON output
+description: The response envelope every agent-desktop command prints, its omission rules, the OperationReport shape, find results, exit codes, and the contract versions from 2.1 to 2.5.
+---
+
+Every command prints exactly one JSON envelope on a single line of standard output. Only `--help`, `--version`, and a bare `agent-desktop` print text instead. The contract version is `2.5`. Log output goes to standard error, so a parser can read standard output as one JSON value.
+
+## Envelope
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "click",
+ "data": {
+ "action": "click",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" }
+ }
+}
+```
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Type</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>version</code></td><td>string</td><td>Contract version. Currently <code>"2.5"</code>.</td></tr>
+ <tr><td><code>ok</code></td><td>boolean</td><td><code>true</code> when the command returned a result, <code>false</code> when it returned an error.</td></tr>
+ <tr><td><code>command</code></td><td>string</td><td>The command name, such as <code>click</code> or <code>session</code>.</td></tr>
+ <tr><td><code>data</code></td><td>object</td><td>The result. Present only when <code>ok</code> is <code>true</code>.</td></tr>
+ <tr><td><code>error</code></td><td>object</td><td>The failure. Present only when <code>ok</code> is <code>false</code>. Its fields are in <a href="/desktop/errors-and-recovery">Errors and recovery</a>.</td></tr>
+ </tbody>
+</table>
+
+An error envelope has `error` and no `data`:
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "click",
+ "error": {
+ "code": "INVALID_ARGS",
+ "message": "Invalid ref_id '@e1': expected @<snapshot_id>:e<N>",
+ "suggestion": "Use the snapshot-qualified ref that snapshot prints, for example @s8f3k2p9:e1. A bare @eN ref is not accepted.",
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+`ok: true` means the command returned a delivered or already-satisfied result. It does not mean the application effect happened. Read the result, or observe again, to verify. See [the observe, act, verify loop](/desktop/guides/observe-act-verify).
+
+## Omission rules
+
+- A typed field that is `None` is omitted, and so is an empty array. An error without a suggestion has no `suggestion` key, and a node without children has no `children` key.
+- Snapshot node bounds are omitted unless you pass `--include-bounds`.
+- Some commands build their `data` by hand and write `null` or `[]` for an absent value. `session list` writes `"ended_at": null` for an open session, and `find` matches write `"value": null` and `"states": []`. Treat a missing key, `null`, and an empty array the same way.
+- Ignore keys you do not know. New optional fields can appear without a version change.
+
+## Where data lives
+
+`ref_count` and `tree` sit inside `data`, never at the top level. This snapshot of GNOME Calculator is trimmed to one branch:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "snapshot",
+ "data": {
+ "app": "gnome-calculator",
+ "complete": true,
+ "ref_count": 7,
+ "snapshot_id": "s1vylk49fulgx4",
+ "tree": {
+ "role": "window",
+ "name": "Calculator",
+ "children": [
+ {
+ "available_actions": ["Click", "SetFocus"],
+ "name": "Undo",
+ "native_id": { "kind": "ax_identifier", "value": "undo_button" },
+ "ref_id": "@s1vylk49fulgx4:e3",
+ "role": "button",
+ "states": ["disabled"]
+ }
+ ]
+ }
+ }
+}
+```
+
+A snapshot that runs out of budget still returns `ok: true`, with `"complete": false`, `"truncated": true`, `nodes_observed`, and `"subtree_truncated": true` on each cut node. Read `data.complete` before you treat a tree as whole. Node fields are in [Snapshots and refs](/desktop/snapshots-and-refs), and partial observations in [Skeleton and drill-down](/desktop/skeleton-and-drill-down#partial-observations).
+
+## Action results and disposition
+
+A ref action such as `click`, `type`, or `toggle` returns `data.action` and `data.disposition`, and can add `steps` (each mechanism tried), `post_state`, `surfaces` (surfaces open once the action settled), and `details`. `disposition` has two fields, `delivery` and `retry`; on success, `delivery` is `delivered_verified`, `delivered_unverified`, or `not_delivered` (already satisfied). What each value proves, and when a retry is safe, is in [Errors and recovery](/desktop/errors-and-recovery#disposition).
+
+## OperationReport
+
+Thirteen commands return the adapter's own report as `data`: `mouse-click`, `mouse-move`, `mouse-wheel`, `hover`, `drag`, `clipboard-set`, `clipboard-clear`, `close-app`, `move-window`, `resize-window`, `minimize`, `maximize`, and `restore`. The report is the action result fields (`action`, `disposition`, and `steps`, `post_state`, `surfaces`, or `details` when present) plus a `target`. The command then adds the echoed request fields, such as `from` and `to` for `drag`, without overwriting any field the report already has.
+
+```json
+{
+ "action": "drag",
+ "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" },
+ "steps": [ { "label": "pointer_drag", "outcome": "succeeded", "mechanism": "physical_synthetic" } ],
+ "target": { "kind": "drag", "from": { "x": 10, "y": 20 }, "to": { "x": 80, "y": 20 } },
+ "from": { "x": 10, "y": 20 },
+ "to": { "x": 80, "y": 20 }
+}
+```
+
+<table>
+ <thead>
+ <tr><th><code>target.kind</code></th><th>Fields</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>window</code></td><td><code>id</code>, <code>title</code>, <code>process</code></td></tr>
+ <tr><td><code>app</code></td><td><code>name</code>, <code>process</code></td></tr>
+ <tr><td><code>pointer</code></td><td><code>point</code></td></tr>
+ <tr><td><code>drag</code></td><td><code>from</code>, <code>to</code></td></tr>
+ <tr><td><code>clipboard</code></td><td>none</td></tr>
+ </tbody>
+</table>
+
+The adapter fills in the identity it validated and used. A pointer target is the coordinate it dispatched to and does not prove which application received the input. Request fields such as `x`, `y`, `count`, `width`, or `app` echo your request; they are not observed state. Window reports name their readback in `details.verification_scope` (`window_size`, `window_position`, `window_minimized_state`, or `window_maximized_state`). There are no `clicked`, `moved`, `closed`, or similar flags, because a flag that every successful call carried proved nothing.
+
+A failed `--wait-for` after a delivered operation keeps the operation's own delivery in `error.disposition` and carries the report under `error.details.after_action`.
+
+## Find results
+
+`find` returns one of three shapes, depending on the result-shaping flag. The flags are in [`find`](/desktop/commands/observation#find).
+
+<table>
+ <thead>
+ <tr><th>Flag</th><th><code>data</code></th></tr>
+ </thead>
+ <tbody>
+ <tr><td>none, or <code>--limit N</code></td><td><code>matches</code>, <code>total_matches</code>, <code>truncated</code></td></tr>
+ <tr><td><code>--first</code>, <code>--last</code>, <code>--nth N</code></td><td><code>match</code> (an object, or <code>null</code> when nothing matched)</td></tr>
+ <tr><td><code>--count</code></td><td><code>count</code></td></tr>
+ </tbody>
+</table>
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "find",
+ "data": {
+ "match": {
+ "interactive": true,
+ "name": "7",
+ "path": ["window:Calculator", "group", "group", "group"],
+ "ref_id": "@s3jjre8xzrvo2l:e1",
+ "role": "button",
+ "states": [],
+ "value": null
+ },
+ "snapshot_id": "s3jjre8xzrvo2l"
+ }
+}
+```
+
+Each match carries `ref_id`, `role`, `name`, `value`, `states`, `interactive`, and `path` (trimmed above). A match that earns a ref has a qualified `ref_id`, and the response then includes the `snapshot_id` that holds it. A match with no ref is a context match: its `ref_id` is `null` and it carries `bounds` when the platform reports them, so you can see where it is. An element without an accessible name omits `name`, and its content stays in `value`. When a query with `--role` matches nothing, `roles_present` lists the roles the search did see.
+
+## Exit codes
+
+<table>
+ <thead>
+ <tr><th>Code</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>0</code></td><td>Success, and also help or version display.</td></tr>
+ <tr><td><code>1</code></td><td>A structured error. The envelope is on standard output with <code>ok: false</code>.</td></tr>
+ <tr><td><code>2</code></td><td>A command-line parse error. The envelope is still printed, with <code>INVALID_ARGS</code>.</td></tr>
+ </tbody>
+</table>
+
+```bash
+agent-desktop click @e1 # bare ref: INVALID_ARGS envelope
+echo $? # 1
+agent-desktop click # missing argument: INVALID_ARGS envelope
+echo $? # 2
+```
+
+An argument the parser accepts but the command rejects, such as a bare `@e1`, exits `1`. Exit `2` is only for arguments the parser cannot read.
+
+## Contract versions
+
+Check `version` before you parse. A consumer written for 2.0 or later can treat a higher minor version as the same shape plus the changes below.
+
+<table>
+ <thead>
+ <tr><th>Version</th><th>What changed</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>2.1</td><td>The <code>error.retry_command</code> string is gone, with no alias. Errors carry a structured <code>error.recovery</code> object and an <code>error.disposition</code>. Select a recovery strategy only when <code>disposition.retry</code> is <code>safe</code>, and never run command strings from older envelopes.</td></tr>
+ <tr><td>2.2</td><td>A snapshot that exhausts its budget returns <code>ok: true</code> with <code>complete: false</code>, the observed tree, <code>truncated</code>, <code>nodes_observed</code>, and <code>subtree_truncated</code> on cut nodes, instead of a <code>TIMEOUT</code> error. Snapshot data always carries <code>complete</code>. A <code>--root</code> drill-down still returns <code>TIMEOUT</code> for an incomplete observation.</td></tr>
+ <tr><td>2.3</td><td><code>launch</code> returns <code>app</code>, <code>pid</code>, <code>process_instance</code>, and an optional <code>window</code> instead of a bare window object. An application that shows no window is <code>ok: true</code> with <code>window</code> omitted, not <code>WINDOW_NOT_FOUND</code>.</td></tr>
+ <tr><td>2.4</td><td>Stateful ref actions (<code>set-value</code>, <code>type</code>, <code>clear</code>, <code>check</code>, <code>uncheck</code>, <code>toggle</code>, <code>expand</code>, <code>collapse</code>) read the state back after one delivery attempt and reject an observed contradiction. A readback failure keeps the adapter's code and adds <code>details.kind: "post_action_verification"</code>. Missing evidence stays a successful <code>delivered_unverified</code> with <code>details.verification_scope: "unavailable"</code>.</td></tr>
+ <tr><td>2.5</td><td>Breaking for the thirteen <a href="#operationreport">OperationReport</a> commands. The success flags <code>clicked</code>, <code>moved</code>, <code>scrolled</code>, <code>hovered</code>, <code>dragged</code>, <code>resized</code>, <code>minimized</code>, <code>maximized</code>, <code>restored</code>, <code>closed</code>, <code>cleared</code>, <code>requested</code> (<code>close-app</code>), and the inner <code>ok</code> of <code>clipboard-set</code> are removed. <code>data</code> is the adapter's report with <code>disposition</code>, <code>steps</code>, and <code>target</code>.</td></tr>
+ </tbody>
+</table>
+
+The C library returns the same envelope from its JSON functions. See the [C library overview](/desktop/ffi).
diff --git a/apps/docs/content/docs/meta.json b/apps/docs/content/docs/meta.json
index 229ff0f53..e9f0098f6 100644
--- a/apps/docs/content/docs/meta.json
+++ b/apps/docs/content/docs/meta.json
@@ -3,6 +3,13 @@
"index",
"installation",
"quick-start",
- "skills"
+ "skills",
+ "---Core concepts---",
+ "snapshots-and-refs",
+ "skeleton-and-drill-down",
+ "surfaces",
+ "sessions",
+ "json-output",
+ "errors-and-recovery"
]
}
diff --git a/apps/docs/content/docs/sessions.mdx b/apps/docs/content/docs/sessions.mdx
new file mode 100644
index 000000000..f07d27f1c
--- /dev/null
+++ b/apps/docs/content/docs/sessions.mdx
@@ -0,0 +1,108 @@
+---
+title: Sessions
+navTitle: Sessions
+description: A session is an on-disk namespace for snapshots and traces. How to start, select, and end one, how agent ids work, and how sessions relate to traces and the cursor overlay.
+---
+
+A session is a directory under the state root that owns a set of snapshot refmaps and, when tracing is on, a trace. You use one when several runs, or several agents, share a machine and each needs its own snapshots, or when you want a trace of everything a run did. Without a session, every command uses one global namespace.
+
+## What a session owns
+
+`session start` creates `sessions/<session-id>/` under the [state root](/desktop/configuration#layout), with a `session.json` manifest, its own `snapshots/` namespace, and, when tracing is on, a `trace/` directory. The session id has the form `run-<unix-ms>-<pid>-<counter>`. An id you pass yourself with `--session` must be 1 to 64 letters, digits, `-`, or `_`.
+
+## Start, list, end, and clean up
+
+```bash
+agent-desktop session start --name docs-example # create the session and print its id
+agent-desktop session list # manifests, oldest first
+agent-desktop session end <session-id> # seal the manifest
+agent-desktop session gc --ended # delete ended sessions nothing is using
+```
+
+`session start` returns the id and the line that activates it:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "session",
+ "data": {
+ "activation": {
+ "environment": "AGENT_DESKTOP_SESSION",
+ "value": "run-1793352720537-17009-0"
+ },
+ "artifacts": "events",
+ "created_at": 1793352720537,
+ "name": "docs-example",
+ "next": "export AGENT_DESKTOP_SESSION=run-1793352720537-17009-0",
+ "session_id": "run-1793352720537-17009-0",
+ "trace": "on"
+ }
+}
+```
+
+`session list` returns `data.sessions`, one object per manifest with `session_id`, `name`, `created_at`, `ended_at` (`null` while the session is open), `trace` and `artifacts`. `session end` returns `session_id` and `ended_at`, and you can run it again on a session that already ended. `session gc` returns `data.removed`, the ids it deleted.
+
+Ending a session seals the manifest and stops its trace. After that, every other command that resolves to the ended session fails with `INVALID_ARGS` and `details.kind: "session_ended"`, except `version` and `skills`:
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "snapshot",
+ "error": {
+ "code": "INVALID_ARGS",
+ "message": "Session 'run-1793352720537-17009-0' has ended",
+ "suggestion": "Unset AGENT_DESKTOP_SESSION and omit --session, then run the command or start a new session",
+ "details": { "kind": "session_ended", "session_id": "run-1793352720537-17009-0" },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+`session gc` deletes ended sessions that nothing is using; its retention rules are in [`session`](/desktop/commands/system#session).
+
+## Select a session
+
+A command picks its session in this order:
+
+<table>
+ <thead>
+ <tr><th>Order</th><th>Source</th><th>Notes</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>1</td><td><code>--session &lt;id&gt;</code></td><td>Wins over the environment variable.</td></tr>
+ <tr><td>2</td><td><code>AGENT_DESKTOP_SESSION</code></td><td>An empty value is <code>INVALID_ARGS</code>.</td></tr>
+ <tr><td>3</td><td>none</td><td>The global namespace, stored directly in the state root.</td></tr>
+ </tbody>
+</table>
+
+An id that is not 1 to 64 letters, digits, `-` or `_` fails with `INVALID_ARGS`. A `--session <id>` with no manifest still works as a snapshot namespace, but it writes no trace.
+
+`session start` does not activate the session for later commands. Each command is its own process, so pass the id to every one, or export it once in your shell:
+
+```bash
+export AGENT_DESKTOP_SESSION=$(agent-desktop session start --name docs-example | jq -r '.data.session_id')
+agent-desktop snapshot --app gnome-calculator -i # runs inside the session
+agent-desktop session end "$AGENT_DESKTOP_SESSION"
+```
+
+`session end` with no id ends the session selected by `--session` or `AGENT_DESKTOP_SESSION`. On Windows, `data.next` prints the PowerShell form (`$env:AGENT_DESKTOP_SESSION = '...'`); see [Windows](/desktop/platforms/windows) for quoting rules.
+
+## Snapshot namespaces
+
+A session is also a snapshot namespace. Snapshots taken in a session are saved under that session's directory, and every lookup is confined to the selected namespace. A qualified ref such as `@s8f3k2p9:e1` embeds its snapshot id, but the id is not a cross-session handle. Acting on that ref with a different `--session` (or none) fails with `SNAPSHOT_NOT_FOUND`. Take the snapshot and act on its refs under the same session scope.
+
+Several agents may share one session id. Each should act on refs from its own snapshot, because the session keeps one latest-snapshot pointer. Retention and pruning of refmaps are described in [Snapshots and refs](/desktop/snapshots-and-refs).
+
+## Agent identity
+
+`--agent-id <id>` (or `AGENT_DESKTOP_AGENT_ID`) names the harness subagent that is running a command. The flag wins over the variable. An id is 1 to 64 letters, digits, `-` or `_`, and an invalid id fails with `INVALID_ARGS`. It is scoped by session.
+
+The identity matters in one mode: a session started with `session start --cursor --multi-agent`. There, desktop actions such as `click` and `type` require an agent id and fail with `INVALID_ARGS` without one. Observation, clipboard and session commands do not. Each distinct id gets its own cursor, and a reused id reuses its cursor. Snapshots stay shared by session.
+
+## Sessions, traces, and the cursor overlay
+
+A new session records a trace by default: the manifest has `trace: "on"` and commands append segments under `trace/` until the session ends. `--no-trace` creates a namespace with no trace. `--screenshots` also stores pre-action and post-action screenshots and refmap copies, which can contain private screen content. Reading and exporting traces is covered in [Traces](/desktop/guides/traces).
+
+The agent cursor overlay is configured once per session, either with `session start --cursor` or with `cursor-overlay enable`, and action commands inherit it. Presentation settings, per-agent profiles and platform support are in [`cursor-overlay`](/desktop/commands/system#cursor-overlay).
diff --git a/apps/docs/content/docs/skeleton-and-drill-down.mdx b/apps/docs/content/docs/skeleton-and-drill-down.mdx
new file mode 100644
index 000000000..b24f36f4e
--- /dev/null
+++ b/apps/docs/content/docs/skeleton-and-drill-down.mdx
@@ -0,0 +1,343 @@
+---
+title: Skeleton and drill-down
+navTitle: Skeleton and drill-down
+description: Read a dense app in two passes. Take a shallow skeleton, drill into one region by ref, re-drill after a change, and scope searches the same way.
+---
+
+A dense app, such as an Electron client or an IDE, can expose thousands of accessibility nodes. A full snapshot of it is slow, costs many tokens, and can run out of budget before it finishes. A skeleton snapshot reads only the top levels. You then drill into the one region you need with `snapshot --root`, so the cost follows the region you act on instead of the whole window.
+
+## The loop
+
+<Diagram name="snapshot-loop" title="Skeleton, drill-down, act, verify" aspectRatio="720 / 464" />
+
+1. `snapshot --skeleton -i --compact` reads the window to depth 3. Cut containers carry `children_count`, and drill targets carry a `ref_id`.
+2. Pick a node that has both `children_count` and `ref_id`.
+3. `snapshot --root <ref> -i --compact` reads that region and adds its refs to the same snapshot.
+4. Act with a ref from the drill, such as `click` or `set-value`. See the [interaction commands](/desktop/commands/interaction).
+5. Verify with `wait` or `get` on a ref from the drill, or re-read the region with the same `snapshot --root`. If the action result lists a menu, sheet, or alert in `data.surfaces`, read that [surface](/desktop/surfaces) next.
+6. If another region matters, drill it. If the layout changed, or the root ref itself is `STALE_REF`, take a new skeleton.
+
+Two shortcuts skip the loop: a small app needs only `snapshot -i`, and a known target needs only `find`. See [When to skip the skeleton](#when-to-skip-the-skeleton).
+
+## Take a skeleton
+
+```bash
+agent-desktop snapshot --app gnome-calculator --skeleton -i --compact
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "snapshot",
+ "data": {
+ "app": "gnome-calculator",
+ "complete": true,
+ "ref_count": 2,
+ "snapshot_id": "s2txcl95uvubmn",
+ "window": {
+ "id": "w-1.11-org-gnome-Calculator-a11y-948fd89a_9bda_453b_9c10_4a9e9eed3feb",
+ "title": "Calculator"
+ },
+ "tree": {
+ "role": "window",
+ "name": "Calculator",
+ "native_id": { "kind": "ax_identifier", "value": "MathWindow" },
+ "children": [
+ {
+ "children_count": 2,
+ "native_id": { "kind": "ax_identifier", "value": "___object_3___" },
+ "ref_id": "@s2txcl95uvubmn:e1",
+ "role": "group"
+ },
+ {
+ "children_count": 1,
+ "native_id": { "kind": "ax_identifier", "value": "headerbar" },
+ "ref_id": "@s2txcl95uvubmn:e2",
+ "role": "group"
+ }
+ ]
+ }
+ }
+}
+```
+
+The tree above omits the unnamed wrapper groups between the window and the two drill targets. The calculator's main area is `e1`, and its header bar is `e2`.
+
+`--skeleton` changes two things:
+
+- **Depth is clamped to 3.** The effective depth is the smaller of `--max-depth` and 3, so a bare `--skeleton` reads three levels. Depth counts semantic levels: GTK and web wrappers can make the output nest deeper than three JSON levels.
+- **Cut containers carry `children_count`.** A container at the depth boundary lists no children. It reports how many direct children it did not expand.
+
+Interactive elements inside the first three levels get ordinary refs. `children_count` appears on any node a depth limit cuts, not only under `--skeleton`, and with `-i` agent-desktop keeps a cut container in the output even when it has no ref.
+
+## Find the drill target
+
+A drill target is a node with both a `ref_id` and a `children_count`. Which node carries it depends on how the cut container can be recognized later:
+
+1. **The container is ref-able.** An interactive role or a primary action gives it a normal ref, and that ref is the drill target.
+2. **The container is not ref-able but has identity.** If it has a name, a description, a typed native id, or bounds with an area, it gets a drill ref of its own, as `e1` and `e2` do above. Its available actions are not stored, so use it to drill, not as an action target.
+3. **The container has no usable identity.** The target moves up to the nearest ancestor that qualifies under rule 1 or 2. One ancestor ref covers every unidentified cut container beneath it. The window root is never a target.
+4. **Several candidates sit on one path.** The deepest one wins.
+
+In practice, drill a node that has both `children_count` and `ref_id`. A cut container with `children_count` and no `ref_id` is covered by an ancestor that has one. If no ancestor qualifies, raise `--max-depth` or use `find` to reach what is under it.
+
+## Drill into a region
+
+```bash
+agent-desktop snapshot --root @s2txcl95uvubmn:e1 -i --compact
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "snapshot",
+ "data": {
+ "app": "gnome-calculator",
+ "complete": true,
+ "ref_count": 33,
+ "snapshot_id": "s2txcl95uvubmn",
+ "tree": {
+ "role": "group",
+ "native_id": { "kind": "ax_identifier", "value": "___object_3___" },
+ "children": [
+ {
+ "available_actions": ["RightClick", "SetValue", "TypeText", "SetFocus"],
+ "native_id": { "kind": "ax_identifier", "value": "source_view" },
+ "ref_id": "@s2txcl95uvubmn:e6",
+ "role": "textfield"
+ },
+ {
+ "available_actions": ["Click", "SetFocus"],
+ "description": "Clear Display [Escape]",
+ "name": "C",
+ "native_id": { "kind": "ax_identifier", "value": "calc_clear_button" },
+ "ref_id": "@s2txcl95uvubmn:e8",
+ "role": "button"
+ },
+ {
+ "available_actions": ["Click", "SetFocus"],
+ "name": "7",
+ "native_id": { "kind": "ax_identifier", "value": "calc_7_button" },
+ "ref_id": "@s2txcl95uvubmn:e11",
+ "role": "button"
+ }
+ ]
+ }
+ }
+}
+```
+
+The tree above is trimmed to the display and two of the 31 buttons and fields the drill found (`e3` to `e33`). `--root` takes a qualified ref from an earlier snapshot, `find`, or drill. The command then:
+
+1. Loads that ref's snapshot and its `RefEntry`.
+2. Resolves the entry strictly against the live UI, with the same rules as any [ref action](/desktop/snapshots-and-refs#how-a-ref-resolves).
+3. Reads the element's subtree to `--max-depth` (default 10). `--app` and `--window-id` are not used, because the ref already names its window, and `--skeleton` has no effect.
+4. Allocates refs for the subtree and writes them into the same snapshot, so `snapshot_id` does not change.
+
+The result's root is the drilled element, and `ref_count` is the whole snapshot's count: 2 skeleton refs plus 31 drill refs. New refs continue the snapshot's counter, which is why this drill starts at `e3`. The ref you drilled stays valid.
+
+## Re-drill after a change
+
+Run the same `--root` again to re-read the region after an action. The re-drill replaces that region's refs and leaves every other ref alone.
+
+<Diagram name="redrill-refs" title="A re-drill replaces one region's refs" aspectRatio="720 / 400" />
+
+1. Before: snapshot `s2txcl95uvubmn` holds the skeleton refs `e1` and `e2` and the refs `e3` to `e33` from the drill of `e1`.
+2. You click `e11` (the `7` button) and run `snapshot --root @s2txcl95uvubmn:e1` again.
+3. The re-drill removes the refs that the previous drill of `e1` created: `e3` to `e33`. It keeps `e1` itself and every ref outside its subtree, here `e2`.
+4. The new read allocates `e34` to `e64`. The counter continues, so a number is never reused.
+5. After: the old `e3` to `e33` return `STALE_REF`, and `e1`, `e2`, and refs from other drilled regions still resolve. `ref_count` stays 33.
+
+A re-drill removes refs created by earlier drills of that root, refs from a full snapshot that sit under the root in the same window, and refs from drills nested inside the region. Refs for other regions, other windows, and the drilled root itself survive.
+
+```bash
+agent-desktop get @s2txcl95uvubmn:e2 --property role # outside the region: still resolves
+agent-desktop get @s2txcl95uvubmn:e11 # inside the region: replaced
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "get",
+ "data": { "property": "role", "ref": "@s2txcl95uvubmn:e2", "value": "group" }
+}
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "get",
+ "error": {
+ "code": "STALE_REF",
+ "message": "@s2txcl95uvubmn:e11 not found in current RefMap",
+ "recovery": {
+ "strategy": "refresh_snapshot_then_retry_original",
+ "retryable": true,
+ "requires_fresh_snapshot": true
+ },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+The second envelope omits `suggestion`.
+
+## What a drill refuses
+
+A drill changes a saved snapshot, so it refuses anything that could leave the snapshot half updated.
+
+<table>
+ <thead>
+ <tr><th>Situation</th><th>Result</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>--root</code> with <code>--surface</code></td><td><code>INVALID_ARGS</code>, "--root cannot be combined with --surface". A ref already carries the surface it was captured from. An explicit <code>--surface window</code>, the default, is allowed.</td></tr>
+ <tr><td><code>--root</code> with <code>--wait-for</code> or <code>--wait-for-gone</code></td><td><code>INVALID_ARGS</code>, "--root cannot be combined with --wait-for or --wait-for-gone". Run <code>snapshot</code> without <code>--root</code>, or omit the wait flags.</td></tr>
+ <tr><td>The read of the region is incomplete or misses the deadline</td><td><code>TIMEOUT</code>. The read happens before any write, so the saved snapshot is untouched.</td></tr>
+ <tr><td>The root ref is not in its snapshot, or no live element matches it</td><td><code>STALE_REF</code>. A missing snapshot is <code>SNAPSHOT_NOT_FOUND</code>.</td></tr>
+ <tr><td>The ref's source window is gone</td><td><code>WINDOW_NOT_FOUND</code>. Nothing is saved.</td></tr>
+ </tbody>
+</table>
+
+A drill is all or nothing. It replaces refs inside an existing snapshot, and a partial read could not re-allocate the descendants it removed, so an incomplete read of the region fails with `TIMEOUT` instead of returning a partial tree. Raise `--timeout-ms`, lower `--max-depth`, or drill a smaller region from a deeper ref.
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "snapshot",
+ "error": {
+ "code": "TIMEOUT",
+ "message": "Operation exceeded its deadline",
+ "suggestion": "The target application may be busy or unresponsive",
+ "recovery": {
+ "strategy": "inspect_state_then_retry_original",
+ "retryable": true,
+ "requires_fresh_snapshot": true,
+ "retry_after_ms": 250
+ },
+ "details": { "elapsed_ms": 1, "kind": "deadline", "timeout_ms": 1 },
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+That is `snapshot --root @s2txcl95uvubmn:e1 --timeout-ms 1`. The completeness rule applies to the drill's own read of the region, so you can drill a ref that came from a partial snapshot.
+
+## Scope a search
+
+`find` takes the same two scopes, so you can search a region without reading it:
+
+```bash
+agent-desktop find --root @s2txcl95uvubmn:e1 --role button --name C --exact --first
+agent-desktop find --app gtk3-widget-factory --surface menu --name "Dark Theme" --exact --first
+```
+
+- `find --root <ref>` resolves the ref strictly, then searches only that element's subtree. It needs no `--app`.
+- `find --surface <kind>` searches an overlay instead of the window. See [Surfaces](/desktop/surfaces).
+
+They cannot combine. `find --root <ref> --surface menu` returns `INVALID_ARGS`, "--root cannot be combined with --surface", with the suggestion to run `find --surface` without `--root`, or to drop `--surface`.
+
+A `find` that returns matches saves its own new snapshot, and its refs are qualified with the returned `data.snapshot_id`:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "find",
+ "data": {
+ "match": {
+ "interactive": true,
+ "name": "C",
+ "path": ["group", "group", "group", "group", "group", "group"],
+ "ref_id": "@s3ufwq4n1uswjj:e1",
+ "role": "button",
+ "states": [],
+ "value": null
+ },
+ "snapshot_id": "s3ufwq4n1uswjj"
+ }
+}
+```
+
+It does not change the snapshot of the root ref you searched. `find --count` saves nothing. A search that runs out of budget fails with `TIMEOUT` instead of returning partial matches. The filters are in the [commands reference](/desktop/commands/observation#find).
+
+## Depth with max-depth
+
+`--max-depth` limits how many levels `snapshot` reads. The default is 10, and the largest accepted value is 50:
+
+```json
+{
+ "code": "INVALID_ARGS",
+ "message": "max depth 60 exceeds the supported maximum of 50",
+ "suggestion": "Use a max depth of 50 or less, or drill into a subtree with snapshot --root <ref>"
+}
+```
+
+Depth counts meaningful levels. Under `--skeleton` the depth is the smaller of `--max-depth` and 3. For a drill, `--max-depth` is the depth below the drilled element, so to go deeper than 10 levels, drill a node near the boundary. That is what the `children_count` markers are for.
+
+## When to skip the skeleton
+
+- **A small app.** With fewer than about 50 interactive elements, a full `snapshot -i --compact` is cheaper than two passes. GNOME Calculator, with 40 refs, is in this range; it appears above because its tree is small enough to show.
+- **A known target.** If you know the role or the exact name, `find --role --name --exact` returns the ref in one command.
+- **A surface.** Do not use `--skeleton` with `--surface menu`, `sheet`, `alert`, or `popover`. A surface is already a small, focused tree. The command does not reject the combination, but it only adds a second pass.
+
+## Partial observations
+
+A full snapshot that runs out of budget still succeeds, and returns what it saw:
+
+```bash
+agent-desktop snapshot --app gtk3-widget-factory -i --compact --timeout-ms 50
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "snapshot",
+ "data": {
+ "app": "gtk3-widget-factory",
+ "complete": false,
+ "truncated": true,
+ "nodes_observed": 73,
+ "ref_count": 27,
+ "snapshot_id": "s2ck1chz8ypcwk",
+ "tree": { "role": "window", "subtree_truncated": true, "children": [] }
+ }
+}
+```
+
+The `tree` above is emptied for space; the real one holds the nodes that were read, with `subtree_truncated` on every node whose descendants were cut.
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>complete</code></td><td>On every snapshot. <code>false</code> means the tree is not whole.</td></tr>
+ <tr><td><code>truncated</code>, <code>nodes_observed</code></td><td>Added when <code>complete</code> is <code>false</code>. <code>nodes_observed</code> counts the nodes read.</td></tr>
+ <tr><td><code>subtree_truncated: true</code></td><td>On each node whose descendants the budget cut, so you can walk from the root to every boundary.</td></tr>
+ <tr><td><code>children_count</code></td><td>Set by a depth cut. A node cut by the budget may carry no count, so treat <code>subtree_truncated</code> as the signal.</td></tr>
+ </tbody>
+</table>
+
+Read `complete` instead of waiting for a `TIMEOUT`. Only a full snapshot can be partial; a drill never is. To finish a partial tree, raise `--timeout-ms` or drill the regions you need. Reading the same window with `--timeout-ms 150` returned a complete tree.
+
+A cold Chromium or Electron app can take 10 to 25 seconds to expose its web tree. If a fresh snapshot comes back thin, raise `--timeout-ms` and snapshot again.
+
+## Timeouts
+
+<table>
+ <thead>
+ <tr><th>Command</th><th><code>--timeout-ms</code> default</th><th>At the deadline</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>snapshot</code></td><td>3000</td><td>A partial tree with <code>complete: false</code>.</td></tr>
+ <tr><td><code>snapshot --root</code></td><td>3000, shared by resolving the root and reading it</td><td><code>TIMEOUT</code>. Nothing is saved.</td></tr>
+ <tr><td><code>find</code></td><td>5000</td><td><code>TIMEOUT</code> with no partial matches.</td></tr>
+ </tbody>
+</table>
diff --git a/apps/docs/content/docs/snapshots-and-refs.mdx b/apps/docs/content/docs/snapshots-and-refs.mdx
new file mode 100644
index 000000000..f0118aea8
--- /dev/null
+++ b/apps/docs/content/docs/snapshots-and-refs.mdx
@@ -0,0 +1,199 @@
+---
+title: Snapshots and refs
+navTitle: Snapshots and refs
+description: What a snapshot contains, how refs are allocated and stored, and how a ref resolves back to a live element or goes stale.
+---
+
+A snapshot is one observation of an application window's accessibility tree. agent-desktop saves it with a ref map and gives every actionable element a ref that you pass to later commands.
+
+```bash
+agent-desktop snapshot --app gnome-calculator -i --compact
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "snapshot",
+ "data": {
+ "app": "gnome-calculator",
+ "complete": true,
+ "ref_count": 40,
+ "snapshot_id": "s26u7pv9qta5g4",
+ "window": {
+ "id": "w-1.11-org-gnome-Calculator-a11y-948fd89a_9bda_453b_9c10_4a9e9eed3feb",
+ "title": "Calculator"
+ },
+ "tree": {
+ "role": "window",
+ "name": "Calculator",
+ "native_id": { "kind": "ax_identifier", "value": "MathWindow" },
+ "children": [
+ {
+ "available_actions": ["Click", "SetFocus"],
+ "description": "Clear Display [Escape]",
+ "name": "C",
+ "native_id": { "kind": "ax_identifier", "value": "calc_clear_button" },
+ "ref_id": "@s26u7pv9qta5g4:e6",
+ "role": "button"
+ }
+ ]
+ }
+ }
+}
+```
+
+The tree above is trimmed to one button. The real tree nests it under several unnamed `group` nodes.
+
+## What a snapshot contains
+
+<table>
+ <thead>
+ <tr><th>Field</th><th>Meaning</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>data.app</code>, <code>data.window</code></td><td>The application and the window that was read (<code>id</code>, <code>title</code>).</td></tr>
+ <tr><td><code>data.snapshot_id</code></td><td>The id of the saved snapshot. It is part of every ref.</td></tr>
+ <tr><td><code>data.ref_count</code></td><td>The number of refs the snapshot holds. After a <code>--root</code> drill it counts the whole snapshot, not only the drilled region.</td></tr>
+ <tr><td><code>data.complete</code></td><td>Present on every snapshot. <code>false</code> means the observation ran out of budget. See <a href="/desktop/skeleton-and-drill-down#partial-observations">Partial observations</a>.</td></tr>
+ <tr><td><code>data.truncated</code>, <code>data.nodes_observed</code></td><td>Present only when <code>complete</code> is <code>false</code>.</td></tr>
+ <tr><td><code>data.tree</code></td><td>The root node. Every node nests its <code>children</code>.</td></tr>
+ </tbody>
+</table>
+
+A node always carries `role` and, when they exist, `ref_id`, `name`, `value`, `description`, `native_id`, `states`, `available_actions`, `children_count`, `subtree_truncated`, and `children`. Empty fields are omitted. `bounds` appears only with `--include-bounds`:
+
+```json
+{
+ "available_actions": ["Click", "SetFocus"],
+ "bounds": { "height": 44.0, "width": 64.0, "x": 554.0, "y": 555.0 },
+ "name": "7",
+ "native_id": { "kind": "ax_identifier", "value": "calc_7_button" },
+ "ref_id": "@s2jqig9fk9u6gz:e9",
+ "role": "button"
+}
+```
+
+`children_count` and `subtree_truncated` mark where the tree was cut; [Skeleton and drill-down](/desktop/skeleton-and-drill-down) explains both. Three flags shrink the tree, and the [commands reference](/desktop/commands/observation#snapshot) lists every flag:
+
+- `-i` (`--interactive-only`) drops leaves that have no ref. It keeps nodes that lead to refs and nodes marked with `children_count`.
+- `--compact` collapses a single-child wrapper that has no name, value, description, id, state, or action.
+- `--max-depth` limits depth. The default is 10 and the maximum is 50.
+
+## Choose the window
+
+`snapshot` and `find` read one window. Without `--app` they read the focused window, and `WINDOW_NOT_FOUND` means there is none. With `--app` and no `--window-id`, agent-desktop narrows the app's windows in this order and stops at the first step that leaves exactly one:
+
+1. If the app has only one window, use it.
+2. Keep only visible windows.
+3. Keep only the focused window.
+4. Keep only accessible windows.
+
+If several windows are still left, the command fails with `AMBIGUOUS_TARGET`, and `details.candidates` lists up to 10 of them. Run `list-windows --app <name>` and pass `--window-id`.
+
+## Refs
+
+A ref is an element id with its snapshot id inside it:
+
+```text
+@<snapshot_id>:eN # for example @s26u7pv9qta5g4:e6
+```
+
+Every command accepts only this qualified form. A bare `@e6` fails with `INVALID_ARGS`; `@eN` is the key inside the saved ref map, and agent-desktop never prints it as output. Because each ref names its snapshot, it keeps pointing at its own snapshot when you read several apps or windows in turn.
+
+```json
+{
+ "version": "2.5",
+ "ok": false,
+ "command": "click",
+ "error": {
+ "code": "INVALID_ARGS",
+ "message": "Invalid ref_id '@e1': expected @<snapshot_id>:e<N>",
+ "suggestion": "Use the snapshot-qualified ref that snapshot prints, for example @s8f3k2p9:e1. A bare @eN ref is not accepted.",
+ "disposition": { "delivery": "not_delivered", "retry": "safe" }
+ }
+}
+```
+
+### Which elements get a ref
+
+Refs are allocated depth-first in document order, from `e1` upward, so a parent gets its number before its children. The counter belongs to the snapshot, and a later drill-down continues it instead of reusing numbers.
+
+An element gets a ref when either condition holds:
+
+- Its role is interactive: `button`, `cell`, `checkbox`, `colorwell`, `combobox`, `dockitem`, `incrementor`, `link`, `listbox`, `menubutton`, `menuitem`, `option`, `radiobutton`, `slider`, `switch`, `tab`, `textfield`, or `treeitem`.
+- It advertises a primary action. `scrollarea` (Scroll) and `disclosure` (Expand and Collapse) qualify this way, because `scroll`, `expand`, and `collapse` need a ref to target them. In the example above, the calculator's history pane is a `scrollarea` with a ref.
+
+`SetFocus`, `RightClick`, and `ScrollTo` do not count on their own. Web runtimes advertise them on nearly every node, so counting them would give every inert container a ref and overflow the [ref map size limit](#where-refs-are-stored). Static text and inert containers stay in the tree without a ref. `find` returns them as context matches with `"ref_id": null`.
+
+A container cut off by a skeleton can also receive a ref as a drill target. See [Find the drill target](/desktop/skeleton-and-drill-down#find-the-drill-target).
+
+## What a ref stores
+
+Each ref maps to a `RefEntry`: the evidence needed to find the same element again. The ref map holds evidence, not live objects.
+
+<table>
+ <thead>
+ <tr><th>Group</th><th>Fields</th><th>Used for</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>Process</td><td><code>pid</code>, <code>process_instance</code></td><td>Reject a ref whose process exited or whose pid was reused.</td></tr>
+ <tr><td>Identity</td><td><code>role</code>, <code>name</code>, <code>value</code>, <code>description</code>, <code>native_id</code></td><td>Match the live element. A control's <code>value</code> is never identity for roles whose value changes while you use them, such as <code>textfield</code>, <code>checkbox</code>, and <code>slider</code>.</td></tr>
+ <tr><td>Geometry</td><td><code>bounds</code>, <code>bounds_hash</code>, <code>bounds_space</code></td><td>Tell apart candidates that match equally. For an element with no other identity, a unique matching rectangle can identify it.</td></tr>
+ <tr><td>Capabilities</td><td><code>states</code>, <code>available_actions</code></td><td>What the element offered at snapshot time.</td></tr>
+ <tr><td>Source</td><td><code>source_app</code>, <code>source_window_id</code>, <code>source_window_title</code>, <code>source_window_bounds_hash</code>, <code>source_surface</code></td><td>Tie the ref to its window and surface.</td></tr>
+ <tr><td>Scope</td><td><code>path</code>, <code>root_ref</code>, <code>path_is_absolute</code></td><td>The element's position as child indexes, and which drill-down created the ref.</td></tr>
+ </tbody>
+</table>
+
+## How a ref resolves
+
+A command never reuses a live handle from the snapshot. Every command that takes a ref, including `click`, `get`, `is`, `snapshot --root`, and `find --root`, re-identifies the element from its stored evidence first.
+
+<Diagram name="ref-resolution" title="How a ref resolves, and when it goes stale" aspectRatio="720 / 460" />
+
+1. The command parses `@s26u7pv9qta5g4:e6` into the snapshot id and the key `@e6`. A bare or malformed ref fails with `INVALID_ARGS`.
+2. `RefStore` loads `snapshots/s26u7pv9qta5g4/refmap.json` from the selected session's namespace. A missing snapshot fails with `SNAPSHOT_NOT_FOUND`.
+3. The ref map looks up `@e6` and returns its `RefEntry`. A missing key fails with `STALE_REF`.
+4. The platform adapter resolves the entry strictly against the live UI: it checks the process and the source window, then searches the window's live tree for elements with the stored role and stable identity.
+5. Exactly one match: the command acts on it or reads it. No match: `STALE_REF`. Several matches that nothing separates: `AMBIGUOUS_TARGET`.
+6. After `STALE_REF` or `AMBIGUOUS_TARGET`, take a fresh observation and use the new ref.
+
+The stored position is a hint for where to look, and the identity check decides. Identifier and stable text come first. Geometry identifies an element only when the ref has no identifier and no stable text, and only on a unique rectangle. When several live elements match, the stored bounds can pick one of them; if they cannot, the answer is `AMBIGUOUS_TARGET`.
+
+<table>
+ <thead>
+ <tr><th>Error</th><th>Meaning</th><th>What to do</th></tr>
+ </thead>
+ <tbody>
+ <tr><td><code>STALE_REF</code></td><td>The key is not in the snapshot's ref map, or no live element answers to the stored evidence. The UI changed, the window closed, or a re-drill replaced the ref.</td><td>Take a fresh snapshot, or re-drill the region, and use the new ref. Nothing was sent to the app.</td></tr>
+ <tr><td><code>AMBIGUOUS_TARGET</code></td><td>Several live elements match the stored evidence, and the stored bounds cannot separate them. The same code reports several windows for one <code>--app</code>.</td><td>Narrow the target with <code>find --role --name --exact</code> or <code>--root</code>, then use the new ref.</td></tr>
+ <tr><td><code>SNAPSHOT_NOT_FOUND</code></td><td>No saved snapshot has that id: it was pruned, it belongs to another <a href="/desktop/sessions">session</a>, or the state root differs.</td><td>Take a new snapshot under the same <code>--session</code> and state root as the command that uses it.</td></tr>
+ </tbody>
+</table>
+
+The full `STALE_REF` envelope after a re-drill is in [Skeleton and drill-down](/desktop/skeleton-and-drill-down#re-drill-after-a-change), and every code with its retry rule is in [Errors and recovery](/desktop/errors-and-recovery).
+
+## Refresh after the UI changes
+
+Refs describe one observation. Re-read after anything that can change the tree, and act only on refs from the latest read of the region:
+
+- `snapshot` returns a new snapshot id and a new ref map.
+- `find` with matches also saves a new snapshot, and its `data.snapshot_id` qualifies the refs it returns.
+- `snapshot --root` re-reads one region inside an existing snapshot. See [Skeleton and drill-down](/desktop/skeleton-and-drill-down#re-drill-after-a-change).
+
+An older snapshot stays on disk until it is pruned, and its refs keep resolving while their elements still match. Do not rely on that: after the UI changes, an old ref can fail, or match an element that is no longer the one you meant.
+
+## Where refs are stored
+
+`RefStore` keeps one file per snapshot at `snapshots/<snapshot_id>/refmap.json` under the [state root](/desktop/configuration#state-root). Inside a [session](/desktop/sessions), the same layout sits under `sessions/<session_id>/`, and a lookup never searches another session's snapshots.
+
+<table>
+ <thead>
+ <tr><th>Limit</th><th>Value</th><th>What happens</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>Size of one ref map</td><td>1 MB (1,048,576 bytes)</td><td>The write fails with <code>INTERNAL</code>. Narrow the observation with <code>--skeleton</code>, <code>--max-depth</code>, <code>--root</code>, or a tighter <code>find</code>.</td></tr>
+ <tr><td>Saved snapshots per namespace</td><td>128</td><td>When a save pushes the count past 128, the oldest are removed until 96 remain. The snapshot just written is never removed.</td></tr>
+ </tbody>
+</table>
diff --git a/apps/docs/content/docs/surfaces.mdx b/apps/docs/content/docs/surfaces.mdx
new file mode 100644
index 000000000..da9de5a77
--- /dev/null
+++ b/apps/docs/content/docs/surfaces.mdx
@@ -0,0 +1,160 @@
+---
+title: Surfaces
+navTitle: Surfaces
+description: Observe menus, sheets, alerts, popovers, and OS shell areas separately from the window with --surface, list-surfaces, and open-system-surface.
+---
+
+A surface is a UI layer that you observe separately from the whole window: an open menu, a sheet, a popover, an alert, or an OS shell area such as the taskbar. While an overlay is open, the refs from the window behind it are the wrong target, so read the overlay itself.
+
+```bash
+agent-desktop snapshot --app gtk3-widget-factory --surface menu -i --compact
+agent-desktop find --app gtk3-widget-factory --surface menu --name "Dark Theme" --exact --first
+```
+
+## Surface kinds
+
+`--surface` takes these values on `snapshot` and `find`. The default is `window`. Names with hyphens also accept underscores, such as `system_tray`.
+
+<table>
+ <thead>
+ <tr><th>Group</th><th>Kinds</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>The window and its layers</td><td><code>window</code>, <code>focused</code>, <code>menu</code>, <code>menubar</code>, <code>sheet</code>, <code>popover</code>, <code>alert</code></td></tr>
+ <tr><td>OS shell</td><td><code>desktop</code>, <code>taskbar</code>, <code>system-tray</code>, <code>system-tray-overflow</code>, <code>quick-settings</code>, <code>notification-center</code>, <code>toolbar</code>, <code>dock</code>, <code>spotlight</code>, <code>menu-bar-extras</code>, <code>start-menu</code>, <code>action-center</code></td></tr>
+ </tbody>
+</table>
+
+Each platform supports a subset:
+
+<table>
+ <thead>
+ <tr><th>Platform</th><th>Supported surfaces</th></tr>
+ </thead>
+ <tbody>
+ <tr><td>macOS</td><td><code>window</code>, <code>focused</code>, <code>menu</code>, <code>menubar</code>, <code>sheet</code>, <code>popover</code>, <code>alert</code></td></tr>
+ <tr><td>Windows</td><td><code>window</code>, <code>focused</code>, <code>sheet</code>, <code>menu</code>, <code>start-menu</code>, <code>taskbar</code>, <code>system-tray</code>, <code>system-tray-overflow</code>, <code>action-center</code></td></tr>
+ <tr><td>Linux</td><td><code>window</code>, <code>sheet</code>, <code>alert</code>, <code>menu</code>, plus GNOME Shell kinds the session can resolve</td></tr>
+ </tbody>
+</table>
+
+Per-kind limits are on the platform pages: [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), [Linux](/desktop/platforms/linux).
+
+## Check what is supported
+
+`status` reports `supported_surfaces` for the current machine and session. On a Linux X11 session without GNOME Shell:
+
+```json
+{ "supported_surfaces": ["window", "sheet", "alert", "menu"] }
+```
+
+Read it before you ask for a surface. An unsupported kind fails with `PLATFORM_NOT_SUPPORTED`, with the supported list in `details.supported_surfaces` and your request in `details.requested_surface`. On Linux, an empty `supported_surfaces` means the accessibility bus did not answer, not that the desktop is empty.
+
+## Know when a surface opened
+
+You rarely need to poll for a surface. `click`, `double-click`, `right-click`, `triple-click`, `expand`, `select`, and `press` report the surfaces open after the action in `data.surfaces`. This is the result of clicking the **Menu** button in GTK Widget Factory:
+
+```json
+{
+ "surfaces": [
+ { "id": "w-1.9-org-a11y-atspi-accessible-229", "type": "window" },
+ { "id": "w-1.9-org-a11y-atspi-accessible-229", "item_count": 4, "type": "menu" }
+ ]
+}
+```
+
+A `menu`, `sheet`, or `alert` entry means the app is waiting on that overlay. Observe it next with `snapshot --surface` or `find --surface`. The field is omitted when nothing is open or the read failed.
+
+## Snapshot or search a surface
+
+```bash
+agent-desktop snapshot --app gtk3-widget-factory --surface menu -i --compact
+```
+
+The snapshot of that menu holds six refs and nothing from the window behind it:
+
+```json
+[
+ { "ref_id": "@s2n10v3haasex6:e1", "role": "button", "name": "Get Busy" },
+ { "ref_id": "@s2n10v3haasex6:e2", "role": "checkbox", "name": "Dark Theme" },
+ { "ref_id": "@s2n10v3haasex6:e3", "role": "checkbox", "name": "Slide Pages" },
+ { "ref_id": "@s2n10v3haasex6:e4", "role": "button", "name": "Inspector" },
+ { "ref_id": "@s2n10v3haasex6:e5", "role": "button", "name": "Keyboard Shortcuts" },
+ { "ref_id": "@s2n10v3haasex6:e6", "role": "button", "name": "About Widget Factory" }
+]
+```
+
+To reach one item, `find --surface` is cheaper than a dump:
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "find",
+ "data": {
+ "match": {
+ "interactive": true,
+ "name": "Dark Theme",
+ "path": ["group", "group", "group", "group", "group", "group"],
+ "ref_id": "@svj2992hf8d2k:e1",
+ "role": "checkbox",
+ "states": [],
+ "value": null
+ },
+ "snapshot_id": "svj2992hf8d2k"
+ }
+}
+```
+
+Which window agent-desktop reads depends on the kind:
+
+- `sheet`, `popover`, and `alert`: the app's accessible windows in order, focused first and then visible, and the first that presents one wins. With no `--app`, the frontmost process.
+- `menu`, `menubar`, and `focused`: any window of the app identifies the process, so several open windows are never ambiguous.
+- A shell kind needs no `--app`, because no application owns it.
+- `--window-id` pins the read to one window.
+
+A surface that is not open returns an error. On Linux, a closed menu returns `ELEMENT_NOT_FOUND`:
+
+```json
+{
+ "code": "ELEMENT_NOT_FOUND",
+ "message": "The window does not present an open menu",
+ "suggestion": "Open the menu first, then snapshot the menu surface"
+}
+```
+
+A closed shell surface returns `WINDOW_NOT_FOUND`. `--surface` cannot combine with `--root`, because a ref already carries the surface it was captured from. Do not use `--skeleton` on a surface: it is already small and focused. See [Skeleton and drill-down](/desktop/skeleton-and-drill-down#when-to-skip-the-skeleton).
+
+## List what is open
+
+```bash
+agent-desktop list-surfaces --app gtk3-widget-factory
+```
+
+```json
+{
+ "version": "2.5",
+ "ok": true,
+ "command": "list-surfaces",
+ "data": {
+ "pid": 8258,
+ "surfaces": [
+ { "id": "w-1.9-org-a11y-atspi-accessible-229", "type": "window" },
+ { "id": "w-1.9-org-a11y-atspi-accessible-229", "item_count": 4, "type": "menu" }
+ ]
+ }
+}
+```
+
+`list-surfaces` returns the overlays an app presents now, which are the kinds `snapshot --surface` accepts for it. Shell surfaces belong to the OS and never appear here. An entry can carry `"unclassified": ["sheet"]` or `["menu"]` when the check could not read that window, often because the app was busy. Treat the missing entry as unknown, not absent.
+
+## Open an OS shell surface
+
+`open-system-surface` raises a shell surface and returns the window it presents, in the `w-<id>` form that `list-windows` uses:
+
+```bash
+agent-desktop --headed open-system-surface --surface action-center
+agent-desktop snapshot --surface action-center -i --compact
+```
+
+It takes the foreground, so headless mode refuses it with `POLICY_DENIED`; pass `--headed` (see [Headed mode](/desktop/guides/headed-mode)). An already-present surface returns without being raised again. A kind the OS does not expose returns `PLATFORM_NOT_SUPPORTED`, and `platform_detail` names the alternative. macOS has no shell surfaces; which kinds open on Windows and Linux is on their platform pages.
diff --git a/apps/docs/public/desktop/diagrams/redrill-refs/index.html b/apps/docs/public/desktop/diagrams/redrill-refs/index.html
new file mode 100644
index 000000000..f85075e75
--- /dev/null
+++ b/apps/docs/public/desktop/diagrams/redrill-refs/index.html
@@ -0,0 +1,105 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>A re-drill replaces one region's refs</title>
+<script>
+ var t = new URLSearchParams(location.search).get("theme");
+ if (t === "light" || t === "dark") document.documentElement.setAttribute("data-theme", t);
+ if (window.self === window.top) document.documentElement.setAttribute("data-top", "");
+</script>
+<style>
+ :root {
+ color-scheme: dark;
+ --bg: #000; --panel: #0a0a0a; --node: #111; --border: #5c5c5c;
+ --fg: #ededed; --muted: #8f8f8f; --line: #8f8f8f; --line-strong: #ededed;
+ --hl-fill: #0a2a5e; --hl-ring: #1e5fd6; --hl-icon: #cfe0ff;
+ }
+ @media (prefers-color-scheme: light) {
+ :root:not([data-theme]) {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ }
+ :root[data-theme="light"] {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ html, body { margin: 0; background: transparent; }
+ :root[data-top], :root[data-top] body { background: var(--bg); }
+ svg { display: block; width: 100%; height: auto; font-family: Geist, "Geist Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
+ .box { fill: var(--panel); stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
+ .node { fill: var(--node); }
+ .label.dim { fill: var(--muted); }
+ .label { fill: var(--fg); font-size: 15px; text-anchor: middle; }
+ .sub { fill: var(--muted); font-size: 11.5px; text-anchor: middle; }
+ .head { fill: var(--fg); font-size: 16px; font-weight: 500; }
+ .tag { fill: var(--muted); font-size: 12.5px; text-anchor: middle; }
+ .wire { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; marker-end: url(#arrow); }
+ .wire.strong { stroke: var(--line-strong); }
+ .icon { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
+ .icon.fg { stroke: var(--fg); }
+ .hl { fill: var(--hl-fill); stroke: var(--hl-ring); stroke-width: 1; vector-effect: non-scaling-stroke; }
+ .hl-icon { fill: none; stroke: var(--hl-icon); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
+ #arrow path { fill: none; stroke: var(--line); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
+ .ico { fill: var(--muted); }
+ .ico.fg { fill: var(--fg); }
+ .hl-ico { fill: var(--hl-icon); }
+</style>
+</head>
+<body>
+<svg viewBox="0 0 720 400" role="img" aria-labelledby="t d">
+ <title id="t">A re-drill replaces one region's refs</title>
+ <desc id="d">One RefMap belongs to snapshot s2txcl95uvubmn. It holds the skeleton refs e1 and e2, the refs e3 to e33 from a drill of e1, and refs from drills of other roots. Running snapshot --root on e1 again calls remove_by_root_ref, which removes e3 to e33, then allocates e34 to e64 from the same counter. The skeleton refs, including e1 itself, and the refs of other regions stay valid. The old e3 to e33 now return STALE_REF.</desc>
+ <defs>
+ <marker id="arrow" viewBox="0 0 8 8" refX="6" refY="4" markerWidth="8" markerHeight="8" markerUnits="userSpaceOnUse" orient="auto">
+ <path d="M1.5 1.5 L5.5 4 L1.5 6.5"/>
+ </marker>
+ </defs>
+
+ <path class="wire strong" d="M360 70V126"/>
+ <circle class="hl" cx="360" cy="38" r="30"/>
+ <svg class="hl-ico" x="349" y="27" width="22" height="22" viewBox="0 0 16 16"><path d="M2.73 6.42A5.5 5.5 0 0 1 12.84 5.4l.36.66 1.32-.72-.36-.66A7 7 0 0 0 1.5 5.4V3H0v4.17c0 .42.34.75.75.75h4.18v-1.5h-2.2m10.54 3.16h-2.2v-1.5h4.18c.41 0 .75.33.75.75V13h-1.5v-2.39a7 7 0 0 1-12.64.75l-.36-.66 1.31-.72.36.66a5.5 5.5 0 0 0 10.1-1.06" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" style="text-anchor:start" x="402" y="34">snapshot --root @s2txcl95uvubmn:e1</text>
+ <text class="sub" style="text-anchor:start" x="402" y="51">re-drill after an action</text>
+
+ <rect class="box" x="8" y="84" width="704" height="308" rx="8" style="fill:none"/>
+ <svg class="ico fg" x="28" y="99" width="20" height="20" viewBox="0 0 16 16"><path d="M1.5 3.5h13v2h-13zM1 7H0V2h16v5h-1v5.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5zm1.5 0v5.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V7zM6 9.5h4V11H6z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="head" x="58" y="114">RefMap for snapshot s2txcl95uvubmn</text>
+
+ <rect class="box" x="28" y="132" width="200" height="240" rx="8"/>
+ <svg class="ico" x="44" y="147" width="18" height="18" viewBox="0 0 16 16"><path d="M9 2h6v1.5H9zm0 10h6v1.5H9zm.75-5H9v1.5h6V7H9.75M1 12h2v1.5H1zm.75-10H1v1.5h2V2H1.75M1 7h2v1.5H1zm4.75 5H5v1.5h2V12H5.75M5 2h2v1.5H5zm.75 5H5v1.5h2V7H5.75" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="head" x="70" y="160">skeleton</text>
+ <text class="sub" style="text-anchor:start" x="70" y="178">no root_ref</text>
+ <rect class="box node" x="44" y="246" width="168" height="60" rx="6"/>
+ <text class="label" x="128" y="270">@e1, @e2</text>
+ <text class="sub" x="128" y="287">kept, e1 included</text>
+
+ <rect class="box" x="260" y="132" width="200" height="240" rx="8"/>
+ <svg class="ico" x="276" y="147" width="18" height="18" viewBox="0 0 16 16"><path d="M13.5 4v2h-11V2.5H6l1.33 1q.68.49 1.5.5zM1 6V1h5.17a1 1 0 0 1 .6.2l1.46 1.1a1 1 0 0 0 .6.2H15V6h1l-.17 1.5-.58 5.28A2.5 2.5 0 0 1 12.76 15H3.24a2.5 2.5 0 0 1-2.49-2.22L.17 7.5 0 6zm13 1.5H1.68l.56 5.11a1 1 0 0 0 1 .89h9.52a1 1 0 0 0 1-.89l.56-5.11z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="head" x="302" y="160">drill of @e1</text>
+ <text class="sub" style="text-anchor:start" x="302" y="178">root_ref: @e1</text>
+ <rect class="box node" x="276" y="192" width="168" height="60" rx="6"/>
+ <text class="label dim" x="360" y="216">@e3 … @e33</text>
+ <text class="sub" x="360" y="233">removed: STALE_REF</text>
+ <path class="wire strong" d="M300 258V290"/>
+ <text class="tag" style="text-anchor:start" x="310" y="279">remove_by_root_ref</text>
+ <rect class="box node" x="276" y="296" width="168" height="60" rx="6"/>
+ <text class="label" x="360" y="320">@e34 … @e64</text>
+ <text class="sub" x="360" y="337">new ids, counter continues</text>
+
+ <rect class="box" x="492" y="132" width="200" height="240" rx="8"/>
+ <svg class="ico" x="508" y="147" width="18" height="18" viewBox="0 0 16 16"><path d="m8.35.34 6.25 3.25.4.2v8.42l-.4.2-6.25 3.26-.35.18-.35-.18-6.25-3.25-.4-.21V3.8l.4-.21L7.65.34 8 .15zM2.5 11.3l4.75 2.46V7.81L2.5 5.44zM8.75 7.8v5.95l4.75-2.46V5.44zM3.42 4.22 8 6.52l4.58-2.3L8 1.85z"/></svg>
+ <text class="head" x="534" y="160">other regions</text>
+ <text class="sub" style="text-anchor:start" x="534" y="178">root_ref: another ref</text>
+ <rect class="box node" x="508" y="246" width="168" height="60" rx="6"/>
+ <text class="label" x="592" y="270">their refs</text>
+ <text class="sub" x="592" y="287">kept, still valid</text>
+</svg>
+</body>
+</html>
diff --git a/apps/docs/public/desktop/diagrams/ref-resolution/index.html b/apps/docs/public/desktop/diagrams/ref-resolution/index.html
new file mode 100644
index 000000000..41647c95b
--- /dev/null
+++ b/apps/docs/public/desktop/diagrams/ref-resolution/index.html
@@ -0,0 +1,120 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>How a ref resolves, and when it goes stale</title>
+<script>
+ var t = new URLSearchParams(location.search).get("theme");
+ if (t === "light" || t === "dark") document.documentElement.setAttribute("data-theme", t);
+ if (window.self === window.top) document.documentElement.setAttribute("data-top", "");
+</script>
+<style>
+ :root {
+ color-scheme: dark;
+ --bg: #000; --panel: #0a0a0a; --node: #111; --border: #5c5c5c;
+ --fg: #ededed; --muted: #8f8f8f; --line: #8f8f8f; --line-strong: #ededed;
+ --hl-fill: #0a2a5e; --hl-ring: #1e5fd6; --hl-icon: #cfe0ff;
+ }
+ @media (prefers-color-scheme: light) {
+ :root:not([data-theme]) {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ }
+ :root[data-theme="light"] {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ html, body { margin: 0; background: transparent; }
+ :root[data-top], :root[data-top] body { background: var(--bg); }
+ svg { display: block; width: 100%; height: auto; font-family: Geist, "Geist Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
+ .box { fill: var(--panel); stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
+ .node { fill: var(--node); }
+ .label { fill: var(--fg); font-size: 15px; text-anchor: middle; }
+ .sub { fill: var(--muted); font-size: 11.5px; text-anchor: middle; }
+ .head { fill: var(--fg); font-size: 16px; font-weight: 500; }
+ .tag { fill: var(--muted); font-size: 12.5px; text-anchor: middle; }
+ .wire { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; marker-end: url(#arrow); }
+ .wire.strong { stroke: var(--line-strong); }
+ .icon { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
+ .icon.fg { stroke: var(--fg); }
+ .hl { fill: var(--hl-fill); stroke: var(--hl-ring); stroke-width: 1; vector-effect: non-scaling-stroke; }
+ .hl-icon { fill: none; stroke: var(--hl-icon); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
+ #arrow path { fill: none; stroke: var(--line); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
+ .label, .sub { text-anchor: start; }
+ .tag.start { text-anchor: start; }
+ .ico { fill: var(--muted); }
+ .ico.fg { fill: var(--fg); }
+ .hl-ico { fill: var(--hl-icon); }
+ .label.dim { fill: var(--muted); }
+</style>
+</head>
+<body>
+<svg viewBox="0 0 720 460" role="img" aria-labelledby="t d">
+ <title id="t">How a ref resolves, and when it goes stale</title>
+ <desc id="d">From top to bottom: a command receives a qualified ref. RefStore loads snapshots/snapshot_id/refmap.json, or fails with SNAPSHOT_NOT_FOUND. The ref maps to a RefEntry, or fails with STALE_REF when the key is missing. resolve_element_strict re-identifies the entry in the live tree: exactly one match lets the command act, zero matches is STALE_REF, and two or more is AMBIGUOUS_TARGET. Every failure is fixed by a fresh snapshot and its new ref.</desc>
+ <defs>
+ <marker id="arrow" viewBox="0 0 8 8" refX="6" refY="4" markerWidth="8" markerHeight="8" markerUnits="userSpaceOnUse" orient="auto">
+ <path d="M1.5 1.5 L5.5 4 L1.5 6.5"/>
+ </marker>
+ </defs>
+ <circle class="hl" cx="250" cy="40" r="28"/>
+ <svg class="hl-ico" x="239" y="29" width="22" height="22" viewBox="0 0 16 16"><path d="M8.47 1.47a4.29 4.29 0 1 1 6.06 6.06l-2.5 2.5-1.06-1.06 2.5-2.5a2.79 2.79 0 0 0-3.94-3.94l-2.5 2.5-1.06-1.06zm3.06 4.06-6 6-1.06-1.06 6-6zm-10.06 9a4.3 4.3 0 0 0 6.06 0l2.5-2.5-1.06-1.06-2.5 2.5a2.79 2.79 0 0 1-3.94-3.94l2.5-2.5-1.06-1.06-2.5 2.5a4.3 4.3 0 0 0 0 6.06" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="292" y="36">@&lt;snapshot_id&gt;:eN</text>
+ <text class="sub" x="292" y="53">a qualified ref</text>
+ <path class="wire strong" d="M250 74V90"/>
+ <rect class="box node" x="130" y="96" width="240" height="56" rx="6"/>
+ <svg class="ico" x="146" y="115.0" width="18" height="18" viewBox="0 0 16 16"><path d="M1.5 3.5h13v2h-13zM1 7H0V2h16v5h-1v5.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5zm1.5 0v5.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V7zM6 9.5h4V11H6z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="174" y="120.0">RefStore</text>
+ <text class="sub" x="174" y="137.0">snapshots/&lt;id&gt;/refmap.json</text>
+ <path class="wire" d="M376 124H414"/>
+ <text class="tag" x="395" y="116">gone</text>
+ <rect class="box node" x="420" y="96" width="280" height="56" rx="6"/>
+ <svg class="ico" x="436" y="115.0" width="18" height="18" viewBox="0 0 16 16"><path d="m12.47 13.53.53.53L14.06 13l-.53-.53L9.06 8l4.47-4.47.53-.53L13 1.94l-.53.53L8 6.94 3.53 2.47 3 1.94 1.94 3l.53.53L6.94 8l-4.47 4.47-.53.53L3 14.06l.53-.53L8 9.06z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="464" y="120.0">SNAPSHOT_NOT_FOUND</text>
+ <text class="sub" x="464" y="137.0">pruned, or another session</text>
+ <path class="wire strong" d="M250 158V186"/>
+ <rect class="box node" x="130" y="192" width="240" height="56" rx="6"/>
+ <svg class="ico" x="146" y="211.0" width="18" height="18" viewBox="0 0 16 16"><path d="M9.18 0a1 1 0 0 1 .61.3l4.42 4.4a1 1 0 0 1 .29.71v8.09A2.5 2.5 0 0 1 12 16H4a2.5 2.5 0 0 1-2.5-2.5V0h7.69M3 13.5a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V5.62L8.88 1.5H3zm8.63-1.25H4.5V11h7.13zm0-3H4.5V8h7.13zm-5-3H4.5V5h2.13z"/></svg>
+ <text class="label" x="174" y="216.0">RefEntry</text>
+ <text class="sub" x="174" y="233.0">pid, role, path, identity, bounds</text>
+ <path class="wire" d="M376 220H414"/>
+ <text class="tag" x="395" y="212">no key</text>
+ <rect class="box node" x="420" y="192" width="280" height="56" rx="6"/>
+ <svg class="ico" x="436" y="211.0" width="18" height="18" viewBox="0 0 16 16"><path d="m12.47 13.53.53.53L14.06 13l-.53-.53L9.06 8l4.47-4.47.53-.53L13 1.94l-.53.53L8 6.94 3.53 2.47 3 1.94 1.94 3l.53.53L6.94 8l-4.47 4.47-.53.53L3 14.06l.53-.53L8 9.06z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="464" y="216.0">STALE_REF</text>
+ <text class="sub" x="464" y="233.0">no live element matches</text>
+ <path class="wire strong" d="M250 254V282"/>
+ <rect class="box node" x="130" y="288" width="240" height="56" rx="6"/>
+ <svg class="ico" x="146" y="307.0" width="18" height="18" viewBox="0 0 16 16"><path d="M8.75 0q.01.69.37 1.06.36.42 1.1.74.73.3 1.6.53c.55.14 1.16.29 1.67.46l.51.17v6.57a5.3 5.3 0 0 1-2.81 4.65l-2.84 1.48-.35.19-.35-.19-2.84-1.48A5.3 5.3 0 0 1 2 9.53V2.96l.51-.17c.5-.17 1.12-.32 1.67-.46q.87-.23 1.6-.53.74-.32 1.1-.74.36-.38.37-1.06zM8 2.06a4.5 4.5 0 0 1-1.61 1.11c-.6.26-1.24.45-1.82.6l-1.07.29v5.47c0 1.4.77 2.67 2.01 3.32L8 14.15l2.49-1.3a3.8 3.8 0 0 0 2.01-3.32V4.06q-.48-.14-1.07-.29a13 13 0 0 1-1.82-.6A4.5 4.5 0 0 1 8 2.06M11.06 7l-3.53 3.53c-.3.3-.77.3-1.06 0L4.94 9 6 7.94l1 1 3-3z"/></svg>
+ <text class="label" x="174" y="312.0">resolve_element_strict</text>
+ <text class="sub" x="174" y="329.0">re-identify in the live tree</text>
+ <path class="wire" d="M376 304H382a14 14 0 0 0 14-14V242a14 14 0 0 1 14-14H414"/>
+ <text class="tag start" x="404" y="272">0 matches</text>
+ <path class="wire" d="M376 330H414"/>
+ <text class="tag" x="395" y="348">2+</text>
+ <rect class="box node" x="420" y="288" width="280" height="56" rx="6"/>
+ <svg class="ico" x="436" y="307.0" width="18" height="18" viewBox="0 0 16 16"><path d="m12.47 13.53.53.53L14.06 13l-.53-.53L9.06 8l4.47-4.47.53-.53L13 1.94l-.53.53L8 6.94 3.53 2.47 3 1.94 1.94 3l.53.53L6.94 8l-4.47 4.47-.53.53L3 14.06l.53-.53L8 9.06z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="464" y="312.0">AMBIGUOUS_TARGET</text>
+ <text class="sub" x="464" y="329.0">several elements match</text>
+ <path class="wire strong" d="M250 350V378"/>
+ <text class="tag start" x="260" y="369">exactly one match</text>
+ <rect class="box node" x="130" y="384" width="240" height="56" rx="6"/>
+ <svg class="ico" x="146" y="403.0" width="18" height="18" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-4.47-1.47.53-.53L11 4.94l-.53.53L6.5 9.44l-.97-.97L5 7.94 3.94 9l.53.53 1.5 1.5c.3.3.77.3 1.06 0z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="174" y="408.0">act</text>
+ <text class="sub" x="174" y="425.0">on the resolved element</text>
+ <path class="wire" d="M700 124H712V412H706"/>
+ <path class="wire" d="M700 220H712" style="marker-end:none"/>
+ <path class="wire" d="M700 316H712" style="marker-end:none"/>
+ <rect class="box node" x="420" y="384" width="280" height="56" rx="6"/>
+ <svg class="ico" x="436" y="403.0" width="18" height="18" viewBox="0 0 16 16"><path d="M2.73 6.42A5.5 5.5 0 0 1 12.84 5.4l.36.66 1.32-.72-.36-.66A7 7 0 0 0 1.5 5.4V3H0v4.17c0 .42.34.75.75.75h4.18v-1.5h-2.2m10.54 3.16h-2.2v-1.5h4.18c.41 0 .75.33.75.75V13h-1.5v-2.39a7 7 0 0 1-12.64.75l-.36-.66 1.31-.72.36.66a5.5 5.5 0 0 0 10.1-1.06" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="464" y="408.0">fresh snapshot</text>
+ <text class="sub" x="464" y="425.0">new snapshot_id, new ref</text>
+</svg>
+</body>
+</html>
diff --git a/apps/docs/public/desktop/diagrams/snapshot-loop/index.html b/apps/docs/public/desktop/diagrams/snapshot-loop/index.html
new file mode 100644
index 000000000..ced5e777d
--- /dev/null
+++ b/apps/docs/public/desktop/diagrams/snapshot-loop/index.html
@@ -0,0 +1,98 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Skeleton, drill-down, act, verify</title>
+<script>
+ var t = new URLSearchParams(location.search).get("theme");
+ if (t === "light" || t === "dark") document.documentElement.setAttribute("data-theme", t);
+ if (window.self === window.top) document.documentElement.setAttribute("data-top", "");
+</script>
+<style>
+ :root {
+ color-scheme: dark;
+ --bg: #000; --panel: #0a0a0a; --node: #111; --border: #5c5c5c;
+ --fg: #ededed; --muted: #8f8f8f; --line: #8f8f8f; --line-strong: #ededed;
+ --hl-fill: #0a2a5e; --hl-ring: #1e5fd6; --hl-icon: #cfe0ff;
+ }
+ @media (prefers-color-scheme: light) {
+ :root:not([data-theme]) {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ }
+ :root[data-theme="light"] {
+ color-scheme: light;
+ --bg: #fff; --panel: #fafafa; --node: #fff; --border: #b8b8b8;
+ --fg: #171717; --muted: #666; --line: #7a7a7a; --line-strong: #171717;
+ --hl-fill: #dbe8ff; --hl-ring: #2563eb; --hl-icon: #1d4ed8;
+ }
+ html, body { margin: 0; background: transparent; }
+ :root[data-top], :root[data-top] body { background: var(--bg); }
+ svg { display: block; width: 100%; height: auto; font-family: Geist, "Geist Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
+ .box { fill: var(--panel); stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
+ .node { fill: var(--node); }
+ .label { fill: var(--fg); font-size: 15px; text-anchor: middle; }
+ .sub { fill: var(--muted); font-size: 11.5px; text-anchor: middle; }
+ .head { fill: var(--fg); font-size: 16px; font-weight: 500; }
+ .tag { fill: var(--muted); font-size: 12.5px; text-anchor: middle; }
+ .wire { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; marker-end: url(#arrow); }
+ .wire.strong { stroke: var(--line-strong); }
+ .icon { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
+ .icon.fg { stroke: var(--fg); }
+ .hl { fill: var(--hl-fill); stroke: var(--hl-ring); stroke-width: 1; vector-effect: non-scaling-stroke; }
+ .hl-icon { fill: none; stroke: var(--hl-icon); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
+ #arrow path { fill: none; stroke: var(--line); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
+ .label, .sub { text-anchor: start; }
+ .tag.start { text-anchor: start; }
+ .ico { fill: var(--muted); }
+ .ico.fg { fill: var(--fg); }
+ .hl-ico { fill: var(--hl-icon); }
+ .label.dim { fill: var(--muted); }
+</style>
+</head>
+<body>
+<svg viewBox="0 0 720 464" role="img" aria-labelledby="t d">
+ <title id="t">Skeleton, drill-down, act, verify</title>
+ <desc id="d">From top to bottom: start with snapshot --skeleton, a depth 3 map with children_count on cut branches. Pick a node with a ref and children_count and run snapshot --root on it to read that region into the same snapshot. Act on a ref from the drill, such as click. Verify with wait, get, or a re-drill of the same root. Then loop back to act again or drill another region.</desc>
+ <defs>
+ <marker id="arrow" viewBox="0 0 8 8" refX="6" refY="4" markerWidth="8" markerHeight="8" markerUnits="userSpaceOnUse" orient="auto">
+ <path d="M1.5 1.5 L5.5 4 L1.5 6.5"/>
+ </marker>
+ </defs>
+ <circle class="hl" cx="360" cy="40" r="28"/>
+ <svg class="hl-ico" x="349" y="29" width="22" height="22" viewBox="0 0 16 16"><path d="M8.75 2.8a1.5 1.5 0 1 0-1.5 0V5H7a6 6 0 0 0-5.92 5H0v3h1v3h14v-3h1v-3h-1.08A6 6 0 0 0 9 5h-.25zM7 6.5A4.5 4.5 0 0 0 2.5 11v3.5h11V11A4.5 4.5 0 0 0 9 6.5zm.25 4.75a1.75 1.75 0 1 1-3.5 0 1.75 1.75 0 0 1 3.5 0M10.5 13a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="402" y="36">calling agent</text>
+ <text class="sub" x="402" y="53">starts with a shallow map</text>
+ <path class="wire strong" d="M360 74V94"/>
+ <rect class="box node" x="220" y="100" width="280" height="56" rx="6"/>
+ <svg class="ico" x="236" y="119.0" width="18" height="18" viewBox="0 0 16 16"><path d="M9 2h6v1.5H9zm0 10h6v1.5H9zm.75-5H9v1.5h6V7H9.75M1 12h2v1.5H1zm.75-10H1v1.5h2V2H1.75M1 7h2v1.5H1zm4.75 5H5v1.5h2V12H5.75M5 2h2v1.5H5zm.75 5H5v1.5h2V7H5.75" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="264" y="124.0">snapshot --skeleton</text>
+ <text class="sub" x="264" y="141.0">depth 3, children_count on cut branches</text>
+ <path class="wire strong" d="M360 162V190"/>
+ <text class="tag start" x="370" y="181">pick a node with ref_id and children_count</text>
+ <rect class="box node" x="220" y="196" width="280" height="56" rx="6"/>
+ <svg class="ico" x="236" y="215.0" width="18" height="18" viewBox="0 0 16 16"><path d="M13.5 4v2h-11V2.5H6l1.33 1q.68.49 1.5.5zM1 6V1h5.17a1 1 0 0 1 .6.2l1.46 1.1a1 1 0 0 0 .6.2H15V6h1l-.17 1.5-.58 5.28A2.5 2.5 0 0 1 12.76 15H3.24a2.5 2.5 0 0 1-2.49-2.22L.17 7.5 0 6zm13 1.5H1.68l.56 5.11a1 1 0 0 0 1 .89h9.52a1 1 0 0 0 1-.89l.56-5.11z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="264" y="220.0">snapshot --root &lt;ref&gt;</text>
+ <text class="sub" x="264" y="237.0">same snapshot_id, new refs</text>
+ <path class="wire strong" d="M360 258V286"/>
+ <text class="tag start" x="370" y="277">act on a ref from the drill</text>
+ <rect class="box node" x="220" y="292" width="280" height="56" rx="6"/>
+ <svg class="ico" x="236" y="311.0" width="18" height="18" viewBox="0 0 16 16"><path d="M8.47 1.47a4.29 4.29 0 1 1 6.06 6.06l-2.5 2.5-1.06-1.06 2.5-2.5a2.79 2.79 0 0 0-3.94-3.94l-2.5 2.5-1.06-1.06zm3.06 4.06-6 6-1.06-1.06 6-6zm-10.06 9a4.3 4.3 0 0 0 6.06 0l2.5-2.5-1.06-1.06-2.5 2.5a2.79 2.79 0 0 1-3.94-3.94l2.5-2.5-1.06-1.06-2.5 2.5a4.3 4.3 0 0 0 0 6.06" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="264" y="316.0">click @s…:eN</text>
+ <text class="sub" x="264" y="333.0">or set-value, select, check</text>
+ <path class="wire strong" d="M360 354V382"/>
+ <text class="tag start" x="370" y="373">verify</text>
+ <rect class="box node" x="220" y="388" width="280" height="56" rx="6"/>
+ <svg class="ico" x="236" y="407.0" width="18" height="18" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-4.47-1.47.53-.53L11 4.94l-.53.53L6.5 9.44l-.97-.97L5 7.94 3.94 9l.53.53 1.5 1.5c.3.3.77.3 1.06 0z" fill-rule="evenodd" clip-rule="evenodd"/></svg>
+ <text class="label" x="264" y="412.0">wait, get, or re-drill</text>
+ <text class="sub" x="264" y="429.0">read the result back</text>
+ <path class="wire" d="M506 416H526a14 14 0 0 0 14-14V238a14 14 0 0 0-14-14H506"/>
+ <text class="tag start" x="552" y="316">next action</text>
+ <text class="tag start" x="552" y="333">or region</text>
+</svg>
+</body>
+</html>