Computer use CLI for AI agents
Rust accessibilityaccessibility-apiai-agentsautomationclicomputer-usecomputer-use-agentcomputer-use-agentsdesktop-automationmacosmcprust
docs: add the guides, platform pages, C library docs, and changelog (4/4) (#338)
Lahfira3a1e827175b
diff --git a/apps/docs/content/docs/changelog.mdx b/apps/docs/content/docs/changelog.mdxnew file mode 100644index 000000000..fc7b63c8a--- /dev/null+++ b/apps/docs/content/docs/changelog.mdx@@ -0,0 +1,452 @@+---+title: Changelog+navTitle: Changelog+description: Release history of agent-desktop, from the GitHub releases and CHANGELOG.md.+---++Every release of agent-desktop, newest first. The same history is in [CHANGELOG.md](https://github.com/vercel-labs/agent-desktop/blob/main/CHANGELOG.md) and on [GitHub Releases](https://github.com/vercel-labs/agent-desktop/releases).++## [1.0.1](https://github.com/vercel-labs/agent-desktop/compare/v1.0.0...v1.0.1) (2026-10-27)++### Bug Fixes++* Remove the `version` line from the skills. In 1.0.0 it still said 0.11.1; `agent-desktop version` reports the version.+* Publish npm and GitHub releases automatically when the Cargo workspace version changes on main.+* Remove the custom Homebrew tap, the Scoop bucket, and their package-update pull requests.++## [1.0.0](https://github.com/vercel-labs/agent-desktop/compare/v0.11.1...v1.0.0) (2026-10-27)++### Release++* Add Linux support: the CLI, the C library, and the npm package now run on x86_64 and aarch64 Linux (glibc 2.35 or later) through AT-SPI.+* Release the integrated macOS, Windows, and Linux CLI and C library as 1.0.0.+* Bundle native CLI executables and platform helpers in npm installations, including installations with lifecycle scripts disabled.+* Verify release archives, checksums, and build provenance through the manual release workflow.++## [0.10.1](https://github.com/vercel-labs/agent-desktop/compare/v0.10.0...v0.10.1) (2026-10-18)++### Bug Fixes++* **windows:** let launch take a bare name without .exe ([#276](https://github.com/vercel-labs/agent-desktop/issues/276)) ([483427e](https://github.com/vercel-labs/agent-desktop/commit/483427eb84821a9d0ebc79eb56dd689c04cb15be))++## [0.10.0](https://github.com/vercel-labs/agent-desktop/compare/v0.9.4...v0.10.0) (2026-10-18)++### ⚠ BREAKING CHANGES++* the release carries these contract changes.+ - The C ABI major version is 5. The legacy entrypoints that each have an+ *_exact replacement are removed: ad_list_surfaces, ad_surface_list_count,+ ad_surface_list_get, ad_surface_list_free, ad_list_windows,+ ad_window_list_count, ad_window_list_get, ad_window_list_free,+ ad_launch_app, ad_release_window_fields, ad_get_tree, ad_find, ad_is,+ ad_focus_window, ad_window_op, ad_resolve_element and+ ad_execute_ref_action_with_policy, with the AdSurfaceList and AdWindowList+ handles. AdScreenshotKind loses WINDOW (FULL_SCREEN keeps 2 and 1 is+ rejected); AdScreenshotTarget loses pid; AdExactSurfaceInfo is version 2,+ 48 bytes, with a trailing unclassified field; the snapshot_id argument of+ ad_execute_by_ref and ad_execute_by_ref_timeout and the+ AdWaitPredicate.snapshot_id field are removed, so AdWaitPredicate is 40+ bytes and AdWaitArgs 104. Consumers must rebuild against the regenerated+ header.+ - Bare @eN ref input is removed from every ref-taking CLI command, wait+ --element, snapshot --root, find --root, drag --from/--to, batch entries+ and the FFI. Only the snapshot-qualified @<snapshot_id>:eN is accepted, and+ a bare ref fails with INVALID_ARGS. The --snapshot flag that only qualified+ a bare ref is removed from every command, and batch entries carrying a+ snapshot or snapshot_id field are rejected as unknown fields.+ - get --property text no longer returns the same value as --property value.+ It prefers the value for textfield, combobox, listbox, datefield and+ timefield and falls back to the accessible name; every other role prefers+ the accessible name and falls back to the value. Blank strings count as+ absent. Ask for --property value explicitly to keep the previous answer.+ - An io error whose kind is PermissionDenied answers PERM_DENIED instead of+ INTERNAL, in the CLI envelope and in the FFI envelope, return code and+ last error alike.+ - A ref action whose element is gone no longer ends in TIMEOUT. A+ non-retryable resolution failure answers at once; a retryable one keeps+ polling, and if no later resolution succeeds the action answers the+ recorded STALE_REF or AMBIGUOUS_TARGET at the deadline.++### Features++* support Windows 10 1809+ and Windows Server 2019+ on x64 and ARM64 ([483a31d](https://github.com/vercel-labs/agent-desktop/commit/483a31d036175f54c34ce1fbd2cea762560ab78c))++## [0.9.4](https://github.com/vercel-labs/agent-desktop/compare/v0.9.3...v0.9.4) (2026-09-23)++### Bug Fixes++* sync cargo lock with the 0.9.3 release ([#217](https://github.com/vercel-labs/agent-desktop/issues/217)) ([8c1502e](https://github.com/vercel-labs/agent-desktop/commit/8c1502e43c6c78fe856980f0bb7b3585f877d347))++## [0.9.3](https://github.com/vercel-labs/agent-desktop/compare/v0.9.2...v0.9.3) (2026-09-22)++### Bug Fixes++* harden native accessibility targeting and delivery ([#210](https://github.com/vercel-labs/agent-desktop/issues/210)) ([882c4c4](https://github.com/vercel-labs/agent-desktop/commit/882c4c4695c0db7d75b83f2655ece178591deb6c))++## [0.9.2](https://github.com/vercel-labs/agent-desktop/compare/v0.9.1...v0.9.2) (2026-09-17)++### Bug Fixes++* make headless desktop actions report what actually happened, and add jev-desktop ([#206](https://github.com/vercel-labs/agent-desktop/issues/206)) ([0691eba](https://github.com/vercel-labs/agent-desktop/commit/0691eba25f6a7082b197bc73ad5daa0e3315c976))++## [0.9.1](https://github.com/vercel-labs/agent-desktop/compare/v0.9.0...v0.9.1) (2026-09-13)++### Bug Fixes++* stop the inspector shutdown test failing on an expected reset ([22cad9e](https://github.com/vercel-labs/agent-desktop/commit/22cad9ec21136562ed191a8cfb827dc22378c554))+* **drag:** scope `--wait-for` to the drop target by default, with `--wait-for-scope from|to` ([cefc80a](https://github.com/vercel-labs/agent-desktop/commit/cefc80a89c95b21061573e366e3832bff6baa231))+* preserve `wait_timeout` envelope when an inherited deadline expires ([07913a7](https://github.com/vercel-labs/agent-desktop/commit/07913a7cdb85d79e1708063fd398c9f8571894e9))+* prevent `wait --count` false positives on incomplete snapshots ([319e9c6](https://github.com/vercel-labs/agent-desktop/commit/319e9c6c2e7c175fdec42d19b2f1614b9238a909))+* split acronym boundaries in trace key redaction ([3042e0c](https://github.com/vercel-labs/agent-desktop/commit/3042e0c7a823508fd5417584f0459d428832c8a0))+* **cursor:** gate `agent_id` stamping on multi-agent mode ([58612ea](https://github.com/vercel-labs/agent-desktop/commit/58612eac673a45634e00a651872da043297e68d3))+* skip ended-session batch entries before wait baseline pre-capture ([899ce27](https://github.com/vercel-labs/agent-desktop/commit/899ce2702a68716a7704b7403050dd7f54161208))+* restore cursor overlay lifecycle for keyboard and clipboard actions ([c827cf9](https://github.com/vercel-labs/agent-desktop/commit/c827cf96560629265ea34451a1a66fe839adab8f))+* clear remembered cursor landing when the overlay is hidden ([6adff7a](https://github.com/vercel-labs/agent-desktop/commit/6adff7af0f50344924f8e8874be72ded1b72a8b3))+* reject percent-encoded NUL in `file_url_to_path` ([de5df38](https://github.com/vercel-labs/agent-desktop/commit/de5df38ede3d45ed7e4d438e732724972351dbe4))++## [0.9.0](https://github.com/vercel-labs/agent-desktop/compare/v0.8.5...v0.9.0) (2026-09-12)++### ⚠ BREAKING CHANGES++* the response envelope moves to 2.4. Stateful ref actions can now return ACTION_FAILED for an observed postcondition contradiction, and ActionResult::from_execution takes only action and steps.++### Features++* verify stateful ref actions against fresh platform state ([9bc91bc](https://github.com/vercel-labs/agent-desktop/commit/9bc91bc0ab53139d85e5c10a0ae0b3c3b4bc18b9))++### Bug Fixes++* guard the debug viewer image sink and unpin a flaky test deadline ([fca24f2](https://github.com/vercel-labs/agent-desktop/commit/fca24f2b0259bac83ff17a490052e1f2a9a9496f))+* report unread expand state as unverified rather than failed ([a7131c2](https://github.com/vercel-labs/agent-desktop/commit/a7131c241cce06687b15c53386fd7787d8fbfd72))++## [0.8.5](https://github.com/vercel-labs/agent-desktop/compare/v0.8.4...v0.8.5) (2026-09-06)++### Features++* combine multi-agent cursors with core and macOS optimizations ([#171](https://github.com/vercel-labs/agent-desktop/issues/171)) ([922bb7d](https://github.com/vercel-labs/agent-desktop/commit/922bb7d5b59f2cc8cfaad9896c81fb8fed545bec))++## [0.8.4](https://github.com/vercel-labs/agent-desktop/compare/v0.8.3...v0.8.4) (2026-08-28)++### Features++* rebuild the agent cursor overlay and fix seen-but-unactionable elements ([#145](https://github.com/vercel-labs/agent-desktop/issues/145)) ([5ec2504](https://github.com/vercel-labs/agent-desktop/commit/5ec2504bec0e9face5a69ef25c58bb1273772f2f))++## [0.8.3](https://github.com/vercel-labs/agent-desktop/compare/v0.8.2...v0.8.3) (2026-08-22)++### Features++* harden native automation and add cursor overlay ([#137](https://github.com/vercel-labs/agent-desktop/issues/137)) ([25a0087](https://github.com/vercel-labs/agent-desktop/commit/25a00877726d324c0ee64d84c8d989a5808a66d6))++## [0.8.2](https://github.com/vercel-labs/agent-desktop/compare/v0.8.1...v0.8.2) (2026-08-20)++### Features++* relocate the state root with AGENT_DESKTOP_HOME ([#135](https://github.com/vercel-labs/agent-desktop/issues/135)) ([a336b01](https://github.com/vercel-labs/agent-desktop/commit/a336b01e728893f379918b40157ab25f1c41fa80))++## [0.8.1](https://github.com/vercel-labs/agent-desktop/compare/v0.8.0...v0.8.1) (2026-08-14)++### Features++* drive Chromium apps through a verified DevTools endpoint from launch --cdp ([#129](https://github.com/vercel-labs/agent-desktop/issues/129)) ([366d348](https://github.com/vercel-labs/agent-desktop/commit/366d34803992d0595f31b19c8347bf7b26f5f277))++## [0.8.0](https://github.com/vercel-labs/agent-desktop/compare/v0.7.0...v0.8.0) (2026-08-13)++### ⚠ BREAKING CHANGES++* the response envelope is version 2.3. launch returns \{ app, pid, process_instance, window? \} instead of a bare window object, and an application that presents no window is ok:true with window omitted rather than WINDOW_NOT_FOUND. The C ABI is unchanged: it still writes one window and reports WINDOW_NOT_FOUND when there is none.++### Features++* decide macOS delivery by observation and stop launch waiting on an uncaused event ([#125](https://github.com/vercel-labs/agent-desktop/issues/125)) ([298f1ff](https://github.com/vercel-labs/agent-desktop/commit/298f1ff21530958d765adf3834cdadccd4816a7a))++## [0.7.0](https://github.com/vercel-labs/agent-desktop/compare/v0.6.0...v0.7.0) (2026-08-02)++### ⚠ BREAKING CHANGES++* ENVELOPE_VERSION is now 2.2. `data.complete` is present on every successful snapshot, and a snapshot that exhausts its budget returns `ok: true` with `complete: false` where it previously returned a TIMEOUT error. Callers that branched on TIMEOUT to detect an oversized tree must read `complete` instead.++### Bug Fixes++* return observed trees and stop demanding renderer activation from shallow walks ([#117](https://github.com/vercel-labs/agent-desktop/issues/117)) ([32175e4](https://github.com/vercel-labs/agent-desktop/commit/32175e44c553b350c90c311560ac4d341be71632))++## [0.6.0](https://github.com/vercel-labs/agent-desktop/compare/v0.5.0...v0.6.0) (2026-07-26)++### ⚠ BREAKING CHANGES++* private artifacts on Windows are no longer written through ACL-hardened handles. That hardening guarded refmap, trace, and session files on a platform where no command can produce them, and it had never executed. It returns in Phase 2.1, built on Windows against a CI lane that runs it, under the constraints recorded in `docs/solutions/best-practices/never-ship-platform-code-that-ci-cannot-execute.md`.++### Refactoring++* remove speculative Win32 private-file layer from core, add real Windows/Linux test lanes ([#106](https://github.com/vercel-labs/agent-desktop/issues/106)) ([8ad66b8](https://github.com/vercel-labs/agent-desktop/commit/8ad66b8f2115704eed56e59e2709c4eddf3cffac))+ * deleted 1,062 LOC of Windows-only `unsafe` Win32 file I/O from `agent-desktop-core` and dropped the `windows-sys` dependency; Windows now uses the same portable `std::fs` path as every other non-unix target+ * this is a structural fix, not a downgrade: `std::fs::OpenOptions` defaults `share_mode` to `FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE`, precisely the flag the deleted code omitted and the cause of its sharing-violation failures+ * `cargo test` now runs on windows-latest and ubuntu-latest, so every platform-conditional branch in core is executed on each PR instead of only compiled++### Bug Fixes++* the new platform lanes exposed four pre-existing defects that were unreachable while only macOS ran tests:+ * trace files were opened append-only while `trace.rs` locks that handle; Windows `LockFileEx` rejects append-only handles, so all trace writing failed with `Access is denied`+ * `refs_lock` tests placed lock files directly in `/tmp`, which is root-owned and world-writable, so the private-parent check correctly refused them+ * a trace test interpolated a raw path into a JSON string literal, so Windows paths produced invalid escapes and the event was silently dropped instead of skipped+ * the default `SystemOps::permission_report` returned `Denied`, so CLI preflight reported `PERM_DENIED` on Windows and Linux when the adapter is simply unimplemented; it now reports `Unknown` and surfaces the honest `PLATFORM_NOT_SUPPORTED`, including over the FFI+* the pinned toolchain gained `clippy` and `rustfmt`, which `profile = "minimal"` had omitted++## [0.5.0](https://github.com/vercel-labs/agent-desktop/compare/v0.4.7...v0.5.0) (2026-07-20)++### ⚠ BREAKING CHANGES++* default-on auto-wait changes the timing of every previously-untouched ref-action call (bounded 5000 ms default; `--timeout-ms 0` restores single-shot). `ENVELOPE_VERSION` is now `2.1` (adds the `APP_UNRESPONSIVE` code and process state in error details). FFI ABI major is `3` (append-only struct evolution; `wait --event` is intentionally not exposed over FFI). The legacy string clipboard API is removed in favor of typed content. `key-down`/`key-up` fail closed until daemon-owned held input exists. `close-app` verifies termination and the osascript fallback path is removed. `--text` matching is subtree containment: `find --text X --first` returns the outermost matching container.++### Features++* implement Playwright-grade foundation contract ([3f32272](https://github.com/vercel-labs/agent-desktop/commit/3f322728b44548d2e22f4ee6ef4e6853af4e4550))+ * default-on auto-wait: every ref action waits for actionability (visible, enabled, stable, unoccluded) before dispatching, under a bounded budget+ * live `find` locator plus a serializable `LocatorQuery`, and honest `is --property visible`+ * three-way `hit_test` occlusion gate and core `scroll_into_view` before element actions+ * `list-displays` and honest `--screen` with per-display scale factor; `native_id` identity spine; window-id-first resolution+ * `ProcessState` classification with the `APP_UNRESPONSIVE` code (envelope `2.1`); typed `ActionStep` delivery tier+ * `LaunchOptions` (`--arg`/`--env`/`--cwd`/`--no-attach`); baseline-diff desktop signals via `wait --event`+ * typed clipboard (`Text`/`Image`/`FileUrls`); mouse modifier chords and a `mouse-wheel` primitive+ * capability-supertrait `PlatformAdapter` split with `not_supported()` defaults, so Windows and Linux inherit the contract++## [0.4.7](https://github.com/vercel-labs/agent-desktop/compare/v0.4.6...v0.4.7) (2026-07-02)++### Features++* add trace viewer and replay artifacts ([e3e1872](https://github.com/vercel-labs/agent-desktop/commit/e3e1872ff3088f03f3e50e65ebc9e2b068a17b5f))++## [0.4.6](https://github.com/vercel-labs/agent-desktop/compare/v0.4.5...v0.4.6) (2026-07-02)++### Features++* make sessions the first-class trace container ([35fa914](https://github.com/vercel-labs/agent-desktop/commit/35fa914b52bb0dffb0e630f9d9085789c3f81542))++## [0.4.5](https://github.com/vercel-labs/agent-desktop/compare/v0.4.4...v0.4.5) (2026-06-30)++### Features++* add --wait-for selector polling flags ([#86](https://github.com/vercel-labs/agent-desktop/issues/86)) ([ce23278](https://github.com/vercel-labs/agent-desktop/commit/ce232787b50270d6f590e11bd2b16c7354de623d))++## [0.4.4](https://github.com/vercel-labs/agent-desktop/compare/v0.4.3...v0.4.4) (2026-06-29)++### Features++* **macos,core:** harden adapter and core foundation with caller-controllable guardrails ([#82](https://github.com/vercel-labs/agent-desktop/issues/82)) ([94ce6c5](https://github.com/vercel-labs/agent-desktop/commit/94ce6c551fff4ffd2afc44ab6a9f655b4486da11))++## [0.4.3](https://github.com/vercel-labs/agent-desktop/compare/v0.4.2...v0.4.3) (2026-06-28)++### Bug Fixes++* **macos:** harden retained_handle null guard against release-only CFRetain(null) ([#80](https://github.com/vercel-labs/agent-desktop/issues/80)) ([a708fa0](https://github.com/vercel-labs/agent-desktop/commit/a708fa03326a03dbc82acc7e41bd3ec262a05248))++## [0.4.2](https://github.com/vercel-labs/agent-desktop/compare/v0.4.1...v0.4.2) (2026-06-27)++### Features++* **ffi:** Phase B and C: Python smoke harness, parity gates, build.rs codegen ([#77](https://github.com/vercel-labs/agent-desktop/issues/77)) ([9023f33](https://github.com/vercel-labs/agent-desktop/commit/9023f331b3981a41414ea0f92e2e5120a212e357))++## [0.4.1](https://github.com/vercel-labs/agent-desktop/compare/v0.4.0...v0.4.1) (2026-06-26)++### Features++* complete FFI C-ABI surface (Phase A): load-time ABI handshake, session-scoped adapter, JSON-envelope command entrypoints (version, status, snapshot, wait, execute-by-ref), an optional tracing log callback, and a unified error-envelope contract ([#67](https://github.com/vercel-labs/agent-desktop/issues/67))++## [0.4.0](https://github.com/vercel-labs/agent-desktop/compare/v0.3.1...v0.4.0) (2026-06-24)++### ⚠ BREAKING CHANGES++* the version command no longer accepts --json; it always emits the standard JSON envelope.++### Refactoring++* over-engineering audit cleanup ([#64](https://github.com/vercel-labs/agent-desktop/issues/64)) ([dbb2be6](https://github.com/vercel-labs/agent-desktop/commit/dbb2be639ecc1f979031818259f587f951086b3c))++## [0.3.1](https://github.com/vercel-labs/agent-desktop/compare/v0.3.0...v0.3.1) (2026-06-21)++### Bug Fixes++* harden macos stale ref resolution ([#62](https://github.com/vercel-labs/agent-desktop/issues/62)) ([9f144c2](https://github.com/vercel-labs/agent-desktop/commit/9f144c2cafe3ba0ade479c1b87ecac6cd88adcef))++## [0.3.0](https://github.com/vercel-labs/agent-desktop/compare/v0.2.3...v0.3.0) (2026-06-20)++### ⚠ BREAKING CHANGES++* **ffi:** `AD_POLICY_KIND_PHYSICAL` is now `AD_POLICY_KIND_HEADED` (discriminant `2` unchanged).+* **ffi:** `AdRefEntry` and `AdDragParams` include additional reliability metadata; C ABI consumers must zero-initialize and validate with `AD_REF_ENTRY_SIZE`, `AD_DRAG_PARAMS_SIZE`, and the `ad_*_size()` accessors.+* `close-app` graceful responses now return `{ "method": "graceful", "requested": true }` instead of claiming `closed: true` before the app has exited.++### Features++* add Playwright-grade ref reliability with strict late resolution, session-scoped snapshots, deterministic stale/ambiguous target handling, and skeleton drill-down preservation ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).+* add Playwright-style headed/headless interaction policy: accessibility-first dispatch remains default, while `--headed` enables focused physical fallbacks only when needed ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).+* add retrying wait predicates, JSONL traces with secret redaction, richer actionability reports, and shared CLI/FFI execution through the same resolver/actionability/dispatch ladder ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).++### Bug Fixes++* harden macOS ref actions across focus/window raising, disclosure expansion, scroll, drag, numeric set-value, menu detection, stale-ref recovery, protected-process errors, and close-app confirmation ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).+* fail closed on unsafe fallback ambiguity and stale refs, including symlink-safe refstore/latest-snapshot reads and deadline-bound resolver work ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).++### Performance++* reduce repeated live actionability reads and add deadline-bound resolver behavior, with large-app snapshot and per-command CLI wall-clock gates in the E2E suite ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).++### Tests++* add real-app E2E coverage for headless/headed ref actions, sessions, snapshots, traces, waits, skeleton drill-down, menus, surfaces, drag, expand/collapse, and performance checks ([#54](https://github.com/vercel-labs/agent-desktop/pull/54)).++## [0.2.3](https://github.com/vercel-labs/agent-desktop/compare/v0.2.2...v0.2.3) (2026-06-06)++### Bug Fixes++* harden macos ax window fallback ([3b266fd](https://github.com/vercel-labs/agent-desktop/commit/3b266fdf040bf83438f69a400b032fd12b8715c6))+* resolve fullscreen AX tree retrieval returning ref_count: 0 ([a52b7c7](https://github.com/vercel-labs/agent-desktop/commit/a52b7c704a4d13fdc0d6b72f4080bb0fc118be64))++## [0.2.2](https://github.com/vercel-labs/agent-desktop/compare/v0.2.1...v0.2.2) (2026-06-02)++### Bug Fixes++* **macos:** guard CFArray casts with type-ID check (fixes Mail.app crash) ([#50](https://github.com/vercel-labs/agent-desktop/issues/50)) ([c02cb5e](https://github.com/vercel-labs/agent-desktop/commit/c02cb5ecb7314f053d63937437e5f5ba48de3209))++## [0.2.1](https://github.com/vercel-labs/agent-desktop/compare/v0.2.0...v0.2.1) (2026-05-23)++### Bug Fixes++* stabilize empty accessibility identity refs ([1fb5a7d](https://github.com/vercel-labs/agent-desktop/commit/1fb5a7d51eb798100b4d597c755fee1161e298bf))++## [0.2.0](https://github.com/vercel-labs/agent-desktop/compare/v0.1.14...v0.2.0) (2026-05-20)++### ⚠ BREAKING CHANGES++* chain execution deadlines now return TIMEOUT instead of ACTION_FAILED when the target app does not respond before the chain deadline.++### Refactoring++* unify command execution contracts ([1291a9c](https://github.com/vercel-labs/agent-desktop/commit/1291a9cdbf0566424d38da1eab397d6d4091c06c))++## [0.1.14](https://github.com/vercel-labs/agent-desktop/compare/v0.1.13...v0.1.14) (2026-05-04)++### Features++* bundle skill docs and refactor --help for AI agents ([#36](https://github.com/vercel-labs/agent-desktop/issues/36)) ([b04d6f9](https://github.com/vercel-labs/agent-desktop/commit/b04d6f97317af67648890d2d3b5ead0d27c466c9))++## [0.1.13](https://github.com/vercel-labs/agent-desktop/compare/v0.1.12...v0.1.13) (2026-04-17)++### Features++* **ffi:** ship C-ABI cdylib with review fixes and release pipeline ([#26](https://github.com/vercel-labs/agent-desktop/issues/26)) ([3cffbd6](https://github.com/vercel-labs/agent-desktop/commit/3cffbd67f6b27f42001643bef9fd2530cb7f9003))++## [0.1.12](https://github.com/vercel-labs/agent-desktop/compare/v0.1.11...v0.1.12) (2026-04-16)++### Features++* progressive skeleton traversal with ref-rooted drill-down ([#20](https://github.com/vercel-labs/agent-desktop/issues/20)) ([c17f2fa](https://github.com/vercel-labs/agent-desktop/commit/c17f2fae7abbbe2c914a050fa9e9be5fca9c6af0))++## [0.1.11](https://github.com/vercel-labs/agent-desktop/compare/v0.1.10...v0.1.11) (2026-03-03)++### Bug Fixes++* show skill install prompt on all success paths ([39b2bc6](https://github.com/vercel-labs/agent-desktop/commit/39b2bc63480890f7ed417b2c040eecf80c4628a0))++## [0.1.10](https://github.com/vercel-labs/agent-desktop/compare/v0.1.9...v0.1.10) (2026-03-03)++### Bug Fixes++* fix skill publication authentication in CI ([208af12](https://github.com/vercel-labs/agent-desktop/commit/208af12459fea2255e1c80b8cdc9ac420316d769))++## [0.1.9](https://github.com/vercel-labs/agent-desktop/compare/v0.1.8...v0.1.9) (2026-03-03)++### Features++* scalable skill architecture with publication automation ([#14](https://github.com/vercel-labs/agent-desktop/issues/14)) ([9766520](https://github.com/vercel-labs/agent-desktop/commit/97665203a464e605bc9b156ec90029c5909399be))++## [0.1.8](https://github.com/vercel-labs/agent-desktop/compare/v0.1.7...v0.1.8) (2026-03-01)++### Features++* add electron/web app compatibility for accessibility tree traversal ([a19c1b5](https://github.com/vercel-labs/agent-desktop/commit/a19c1b5132d3b71c5de58886ba51357ffc9bd1e8))+* implement --compact flag to collapse single-child unnamed nodes ([4a300c8](https://github.com/vercel-labs/agent-desktop/commit/4a300c8cb054462ca95fb5160e89e8fce661ec3b))++## [0.1.7](https://github.com/vercel-labs/agent-desktop/compare/v0.1.6...v0.1.7) (2026-02-28)++### Features++* add notification command types, adapter trait, and CLI wiring ([c5b05ba](https://github.com/vercel-labs/agent-desktop/commit/c5b05bab600aafa36c642f21837c44583b36459c))+* add notification management commands (macOS) ([b1fd368](https://github.com/vercel-labs/agent-desktop/commit/b1fd368f195640642adf011b75cca6ecb9e5acc3))+* **macos:** add NC session RAII guard and notification adapter wiring ([0d55c21](https://github.com/vercel-labs/agent-desktop/commit/0d55c21de0f0ea6ea08ccb836e5527c9da513620))+* **macos:** implement dismiss and notification action commands ([53d697d](https://github.com/vercel-labs/agent-desktop/commit/53d697d52248c3fa06797787b1eb549ac2766533))+* **macos:** implement notification list via AX tree traversal ([53549a3](https://github.com/vercel-labs/agent-desktop/commit/53549a384eec67572ee05c31621b8b4174425ab3))++### Bug Fixes++* **macos:** remove AXPress from dismiss action list ([27ef4f3](https://github.com/vercel-labs/agent-desktop/commit/27ef4f34c038c26f5852bf1f6026762a98d0df0a))+* **macos:** restore frontmost app after notification center interaction ([3881bc8](https://github.com/vercel-labs/agent-desktop/commit/3881bc82bdb5a4bb7689f1e1e2237bb745e60c21))+* **macos:** use pgrep and async osascript for NC lifecycle ([9797585](https://github.com/vercel-labs/agent-desktop/commit/979758538fca0145e9245641fb03a0769eed68de))++## [0.1.6](https://github.com/vercel-labs/agent-desktop/compare/v0.1.5...v0.1.6) (2026-02-24)++### Bug Fixes++* handle null bounds in refmap and improve sidebar click resolution ([d4197e8](https://github.com/vercel-labs/agent-desktop/commit/d4197e8f6f6700f2f672d3e1e436ecf24cf82e01))++## [0.1.5](https://github.com/vercel-labs/agent-desktop/compare/v0.1.4...v0.1.5) (2026-02-23)++### Features++* add fallback chains for set-value, clear, focus, scroll-to, type and post-action state hints ([11f8da0](https://github.com/vercel-labs/agent-desktop/commit/11f8da06e84ed67b0e26dbc1946f7a7542e89dcd))+* add structured verbose logging across all layers ([c7316e8](https://github.com/vercel-labs/agent-desktop/commit/c7316e8b5160ab0e6ba554bcd502d4c47adf8b1a))++### Bug Fixes++* add dwell time before drag release for drop target recognition ([2a52d62](https://github.com/vercel-labs/agent-desktop/commit/2a52d62106699b36f62f9af83895f2264b80efb1))++## [0.1.4](https://github.com/vercel-labs/agent-desktop/compare/v0.1.3...v0.1.4) (2026-02-23)++### Features++* add agent-desktop skill for universal AI agent support ([ef45135](https://github.com/vercel-labs/agent-desktop/commit/ef45135087d09a7e065f65d9a0558d1e710cb8bf))+* add Claude Code skills for agent-desktop automation ([ad91cd3](https://github.com/vercel-labs/agent-desktop/commit/ad91cd32cf2de1c1c8dcda4c0dcae37f0022b4c6))++## [0.1.3](https://github.com/vercel-labs/agent-desktop/compare/v0.1.2...v0.1.3) (2026-02-23)++### Bug Fixes++* correct GitHub Release download URL and simplify tag format ([8f66a93](https://github.com/vercel-labs/agent-desktop/commit/8f66a9346e02a751a83ac02313dcec2d9c81bde8))+* include README and CHANGELOG in npm package ([084fc8c](https://github.com/vercel-labs/agent-desktop/commit/084fc8c960527c0d0654028794ec3c4fd2d970c4))++### Performance++* use curl for binary download in postinstall ([ebafb71](https://github.com/vercel-labs/agent-desktop/commit/ebafb71603f5f2b32af8ac5bf6c88df3d6012f70))++## [0.1.2](https://github.com/vercel-labs/agent-desktop/compare/agent-desktop-v0.1.1...agent-desktop-v0.1.2) (2026-02-23)++### Bug Fixes++* use macos-latest for both build targets ([91c7677](https://github.com/vercel-labs/agent-desktop/commit/91c76777cb7ee864b45e14d123c79c08f0c2d5b9))++## [0.1.1](https://github.com/vercel-labs/agent-desktop/compare/agent-desktop-v0.1.0...agent-desktop-v0.1.1) (2026-02-23)++### Features++* 10-step scroll chain, focus guards, enhanced click chain, bounds fix ([595ccb6](https://github.com/vercel-labs/agent-desktop/commit/595ccb6cc45554351ea3e30b95e4ca47bdf4e16b))+* add 19 new commands, AX-first rewrites, LOC compliance ([d3f7e03](https://github.com/vercel-labs/agent-desktop/commit/d3f7e03c67832c652a6125f61fbb7ab2f0801939))+* add 19 new commands, AX-first rewrites, LOC compliance ([eca04e8](https://github.com/vercel-labs/agent-desktop/commit/eca04e839288b121f6f41c6de525a8396d10654c))+* add release automation with GitHub Releases and npm distribution ([18fc50c](https://github.com/vercel-labs/agent-desktop/commit/18fc50cca51f2ed10b6dfb5576602b6ce344bc95))+* add structural hints to splitter columns in snapshots ([48f8470](https://github.com/vercel-labs/agent-desktop/commit/48f8470948b4f636dfa6f4489e4cb6d9f520722c))+* AX-first right-click chain with inline context menu capture ([cddc5d3](https://github.com/vercel-labs/agent-desktop/commit/cddc5d3547f058a78f8b398fa982e39a1fcbf6b1))+* Phase 1 foundation: workspace scaffold, core engine, macOS adapter, 31 commands ([a346f24](https://github.com/vercel-labs/agent-desktop/commit/a346f242c25dfad1c849e6d50f9ab25a42b462d9))+* smart AX-first click chain + macOS crate restructure ([4616c8f](https://github.com/vercel-labs/agent-desktop/commit/4616c8f65f974505b0eedb5485c865d3b905342b))+* surface-targeted snapshot, menu wait, list-surfaces command ([39178b2](https://github.com/vercel-labs/agent-desktop/commit/39178b291602d192de97aa0150c261db1dcc7ca6))++### Bug Fixes++* add menubar surface, fix press --app crash and modifier mapping ([a231962](https://github.com/vercel-labs/agent-desktop/commit/a2319623b4d1d2b6b2f6e1a4ab9a8b8cbbfd02eb))+* address code review findings (double-free, CF leaks, injection) ([2f495ff](https://github.com/vercel-labs/agent-desktop/commit/2f495ffb69be67f3136b076534e078cc31b005c2))+* align error codes with spec (APP_NOT_FOUND, PERM_DENIED) and add -i shorthand ([6dc567a](https://github.com/vercel-labs/agent-desktop/commit/6dc567a4aedff15cf82a82601089cb0b87da4e26))+* ancestor-path cycle detection + CGEvent click fallback ([198d7d7](https://github.com/vercel-labs/agent-desktop/commit/198d7d7d27167044a448b6616fa5c9c0554321bf))+* detect open menus via AXMenuBarItem.AXSelected, not AXMenus attribute ([7f0d610](https://github.com/vercel-labs/agent-desktop/commit/7f0d6103d16969a0abfa84a62b6819dbd0d1cc8e))+* make all 30 commands work end-to-end on macOS ([1d98ab8](https://github.com/vercel-labs/agent-desktop/commit/1d98ab828ce5bcb39e212548ae2f2a052e67aac9))+* remove AXShowDefaultUI from activation chain, fix child walk ([74242f5](https://github.com/vercel-labs/agent-desktop/commit/74242f5040af9c46c98a3f5232dc7567538c28e1))+* resolve all 47 code review findings from Phase 1 audit ([218503a](https://github.com/vercel-labs/agent-desktop/commit/218503a7ebacacd4fbc6b388a6cf5e3bb86af039))+* right-click uses AXShowMenu; context menus detected via focused element ([2c9aee3](https://github.com/vercel-labs/agent-desktop/commit/2c9aee397912d6a903d9ef1e26c786697383ae95))+* suppress dead_code lint on BatchCommand deserializer struct ([608d4aa](https://github.com/vercel-labs/agent-desktop/commit/608d4aaaa195b95626f17aa4bbca2d69609f14cc))+* use simple release strategy for workspace version bumps ([0ab78dd](https://github.com/vercel-labs/agent-desktop/commit/0ab78dde0e1ff702db6c8b667784fa456245b26b))diff --git a/apps/docs/content/docs/commands/app-window.mdx b/apps/docs/content/docs/commands/app-window.mdxindex 7c8d2f419..19a780aba 100644--- a/apps/docs/content/docs/commands/app-window.mdx+++ b/apps/docs/content/docs/commands/app-window.mdx@@ -68,7 +68,7 @@ agent-desktop launch gtk3-demo}```-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.+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; [Chromium and Electron apps](/desktop/guides/chromium-and-electron) walks through the handoff.Errors specific to `launch`:diff --git a/apps/docs/content/docs/ffi/api.mdx b/apps/docs/content/docs/ffi/api.mdxnew file mode 100644index 000000000..4debe2269--- /dev/null+++ b/apps/docs/content/docs/ffi/api.mdx@@ -0,0 +1,837 @@+---+title: C library API+navTitle: API+description: Every function, struct, and enum in agent_desktop.h, grouped by area, with exact C signatures.+---++Signatures on this page are extracted from `crates/ffi/include/agent_desktop.h` (ABI major 6). Every `AdResult` function returns `AD_RESULT_OK` (0) or a negative code; read the details with the [last-error accessors](/desktop/ffi/ownership-and-threading#errors). Which call frees which pointer is in [Ownership](/desktop/ffi/ownership-and-threading#ownership).++## Enums++Enum fields inside structs are stored as `int32_t`. The library validates each one and returns `AD_RESULT_ERR_INVALID_ARGS` for an out-of-range value. New `AdResult` codes may be appended.++<table>+ <thead>+ <tr><th>Enum</th><th>Values</th></tr>+ </thead>+ <tbody>+ <tr><td><code>AdResult</code></td><td><code>AD_RESULT_OK</code> 0, <code>AD_RESULT_ERR_PERM_DENIED</code> -1, <code>AD_RESULT_ERR_ELEMENT_NOT_FOUND</code> -2, <code>AD_RESULT_ERR_APP_NOT_FOUND</code> -3, <code>AD_RESULT_ERR_ACTION_FAILED</code> -4, <code>AD_RESULT_ERR_ACTION_NOT_SUPPORTED</code> -5, <code>AD_RESULT_ERR_STALE_REF</code> -6, <code>AD_RESULT_ERR_WINDOW_NOT_FOUND</code> -7, <code>AD_RESULT_ERR_PLATFORM_NOT_SUPPORTED</code> -8, <code>AD_RESULT_ERR_TIMEOUT</code> -9, <code>AD_RESULT_ERR_INVALID_ARGS</code> -10, <code>AD_RESULT_ERR_NOTIFICATION_NOT_FOUND</code> -11, <code>AD_RESULT_ERR_INTERNAL</code> -12, <code>AD_RESULT_ERR_SNAPSHOT_NOT_FOUND</code> -13, <code>AD_RESULT_ERR_POLICY_DENIED</code> -14, <code>AD_RESULT_ERR_AMBIGUOUS_TARGET</code> -15, <code>AD_RESULT_ERR_APP_UNRESPONSIVE</code> -16</td></tr>+ <tr><td><code>AdImageFormat</code></td><td><code>AD_IMAGE_FORMAT_PNG</code> 0, <code>AD_IMAGE_FORMAT_JPG</code> 1</td></tr>+ <tr><td><code>AdActionKind</code></td><td><code>AD_ACTION_KIND_CLICK</code> 0, <code>AD_ACTION_KIND_DOUBLE_CLICK</code> 1, <code>AD_ACTION_KIND_RIGHT_CLICK</code> 2, <code>AD_ACTION_KIND_TRIPLE_CLICK</code> 3, <code>AD_ACTION_KIND_SET_VALUE</code> 4, <code>AD_ACTION_KIND_SET_FOCUS</code> 5, <code>AD_ACTION_KIND_EXPAND</code> 6, <code>AD_ACTION_KIND_COLLAPSE</code> 7, <code>AD_ACTION_KIND_SELECT</code> 8, <code>AD_ACTION_KIND_TOGGLE</code> 9, <code>AD_ACTION_KIND_CHECK</code> 10, <code>AD_ACTION_KIND_UNCHECK</code> 11, <code>AD_ACTION_KIND_SCROLL</code> 12, <code>AD_ACTION_KIND_SCROLL_TO</code> 13, <code>AD_ACTION_KIND_PRESS_KEY</code> 14, <code>AD_ACTION_KIND_KEY_DOWN</code> 15, <code>AD_ACTION_KIND_KEY_UP</code> 16, <code>AD_ACTION_KIND_TYPE_TEXT</code> 17, <code>AD_ACTION_KIND_CLEAR</code> 18, <code>AD_ACTION_KIND_HOVER</code> 19, <code>AD_ACTION_KIND_DRAG</code> 20</td></tr>+ <tr><td><code>AdDirection</code></td><td><code>AD_DIRECTION_UP</code> 0, <code>AD_DIRECTION_DOWN</code> 1, <code>AD_DIRECTION_LEFT</code> 2, <code>AD_DIRECTION_RIGHT</code> 3</td></tr>+ <tr><td><code>AdDeliveryDisposition</code></td><td><code>AD_DELIVERY_DISPOSITION_UNKNOWN</code> 0, <code>AD_DELIVERY_DISPOSITION_NOT_DELIVERED</code> 1, <code>AD_DELIVERY_DISPOSITION_DELIVERY_UNCERTAIN</code> 2, <code>AD_DELIVERY_DISPOSITION_DELIVERED_UNVERIFIED</code> 3, <code>AD_DELIVERY_DISPOSITION_DELIVERED_VERIFIED</code> 4</td></tr>+ <tr><td><code>AdFindSelectionKind</code></td><td><code>AD_FIND_SELECTION_KIND_STRICT</code> 0, <code>AD_FIND_SELECTION_KIND_FIRST</code> 1, <code>AD_FIND_SELECTION_KIND_LAST</code> 2, <code>AD_FIND_SELECTION_KIND_NTH</code> 3</td></tr>+ <tr><td><code>AdIdentifierKind</code></td><td><code>AD_IDENTIFIER_KIND_AX_IDENTIFIER</code> 0, <code>AD_IDENTIFIER_KIND_AX_DOM_IDENTIFIER</code> 1, <code>AD_IDENTIFIER_KIND_AUTOMATION_ID</code> 2, <code>AD_IDENTIFIER_KIND_RUNTIME_ID</code> 3, <code>AD_IDENTIFIER_KIND_ATSPI_OBJECT_PATH</code> 4</td></tr>+ <tr><td><code>AdModifier</code></td><td><code>AD_MODIFIER_META</code> 0, <code>AD_MODIFIER_CTRL</code> 1, <code>AD_MODIFIER_ALT</code> 2, <code>AD_MODIFIER_SHIFT</code> 3</td></tr>+ <tr><td><code>AdMouseButton</code></td><td><code>AD_MOUSE_BUTTON_LEFT</code> 0, <code>AD_MOUSE_BUTTON_RIGHT</code> 1, <code>AD_MOUSE_BUTTON_MIDDLE</code> 2</td></tr>+ <tr><td><code>AdMouseEventKind</code></td><td><code>AD_MOUSE_EVENT_KIND_MOVE</code> 0, <code>AD_MOUSE_EVENT_KIND_DOWN</code> 1, <code>AD_MOUSE_EVENT_KIND_UP</code> 2, <code>AD_MOUSE_EVENT_KIND_CLICK</code> 3</td></tr>+ <tr><td><code>AdPolicyKind</code></td><td><code>AD_POLICY_KIND_HEADLESS</code> 0, <code>AD_POLICY_KIND_FOCUS_FALLBACK</code> 1, <code>AD_POLICY_KIND_HEADED</code> 2</td></tr>+ <tr><td><code>AdRetryDisposition</code></td><td><code>AD_RETRY_DISPOSITION_UNKNOWN</code> 0, <code>AD_RETRY_DISPOSITION_SAFE</code> 1, <code>AD_RETRY_DISPOSITION_UNSAFE</code> 2</td></tr>+ <tr><td><code>AdScreenshotKind</code></td><td><code>AD_SCREENSHOT_KIND_SCREEN</code> 0, <code>AD_SCREENSHOT_KIND_FULL_SCREEN</code> 2</td></tr>+ <tr><td><code>AdSnapshotSurface</code></td><td><code>AD_SNAPSHOT_SURFACE_WINDOW</code> 0, <code>AD_SNAPSHOT_SURFACE_FOCUSED</code> 1, <code>AD_SNAPSHOT_SURFACE_MENU</code> 2, <code>AD_SNAPSHOT_SURFACE_MENUBAR</code> 3, <code>AD_SNAPSHOT_SURFACE_SHEET</code> 4, <code>AD_SNAPSHOT_SURFACE_POPOVER</code> 5, <code>AD_SNAPSHOT_SURFACE_ALERT</code> 6, <code>AD_SNAPSHOT_SURFACE_DESKTOP</code> 7, <code>AD_SNAPSHOT_SURFACE_TASKBAR</code> 8, <code>AD_SNAPSHOT_SURFACE_SYSTEM_TRAY</code> 9, <code>AD_SNAPSHOT_SURFACE_QUICK_SETTINGS</code> 10, <code>AD_SNAPSHOT_SURFACE_NOTIFICATION_CENTER</code> 11, <code>AD_SNAPSHOT_SURFACE_TOOLBAR</code> 12, <code>AD_SNAPSHOT_SURFACE_DOCK</code> 13, <code>AD_SNAPSHOT_SURFACE_SPOTLIGHT</code> 14, <code>AD_SNAPSHOT_SURFACE_MENU_BAR_EXTRAS</code> 15, <code>AD_SNAPSHOT_SURFACE_SYSTEM_TRAY_OVERFLOW</code> 16, <code>AD_SNAPSHOT_SURFACE_START_MENU</code> 17, <code>AD_SNAPSHOT_SURFACE_ACTION_CENTER</code> 18</td></tr>+ <tr><td><code>AdStepMechanism</code></td><td><code>AD_STEP_MECHANISM_SEMANTIC_API</code> 1, <code>AD_STEP_MECHANISM_PHYSICAL_SYNTHETIC</code> 2</td></tr>+ <tr><td><code>AdWindowOpKind</code></td><td><code>AD_WINDOW_OP_KIND_RESIZE</code> 0, <code>AD_WINDOW_OP_KIND_MOVE</code> 1, <code>AD_WINDOW_OP_KIND_MINIMIZE</code> 2, <code>AD_WINDOW_OP_KIND_MAXIMIZE</code> 3, <code>AD_WINDOW_OP_KIND_RESTORE</code> 4</td></tr>+ </tbody>+</table>++Sizes and versions of versioned structs are the `AD_*_SIZE` and `AD_*_VERSION` macros in the header. `AD_MAX_STRING_BYTES` (1 MiB) bounds every C string the library reads.++## ABI handshake++```c+// Returns the major ABI version of the loaded library.+uint32_t ad_abi_version(void);++// Checks the header major against the library; call once after loading.+AdResult ad_init(uint32_t expected_major);+```++## Adapter lifecycle++An `AdAdapter` is an opaque token. Create one per process, or one per session.++```c+// Creates a platform adapter with no session; null on failure.+struct AdAdapter *ad_adapter_create(void);++// Creates an adapter scoped to a session id; a null session means none.+struct AdAdapter *ad_adapter_create_with_session(const char *session);++// Destroys an adapter; calls in flight finish, later calls fail with invalid args.+void ad_adapter_destroy(struct AdAdapter *adapter);++// Returns OK when accessibility permission is granted or not required.+AdResult ad_check_permissions(const struct AdAdapter *adapter);+```++## Command-backed JSON entrypoints++Each writes an owned JSON envelope into `*out`; free it with `ad_free_string`, including an `"ok": false` envelope. `*out` is null only on an argument or infrastructure failure.++```c+// Snapshots an app's focused window; surface is an AdSnapshotSurface.+AdResult ad_snapshot(const struct AdAdapter *adapter,+ const char *app,+ int32_t surface,+ uint8_t max_depth,+ bool interactive_only,+ bool compact,+ char **out);++// Runs a ref action with the default 5000 ms auto-wait; policy is an AdPolicyKind.+AdResult ad_execute_by_ref(const struct AdAdapter *adapter,+ const char *ref_id,+ const struct AdAction *action,+ int32_t policy,+ char **out);++// Same, with an explicit auto-wait budget (-1 default, 0 single attempt).+AdResult ad_execute_by_ref_timeout(const struct AdAdapter *adapter,+ const char *ref_id,+ const struct AdAction *action,+ int32_t policy,+ int64_t timeout_ms,+ char **out);++// Runs the wait command until the condition holds or scope.timeout_ms elapses.+AdResult ad_wait(const struct AdAdapter *adapter, const struct AdWaitArgs *args, char **out);++// Returns the status envelope.+AdResult ad_status(const struct AdAdapter *adapter, char **out);++// Returns the version envelope.+AdResult ad_version(char **out);++// Returns the merged trace timeline of the adapter's session.+AdResult ad_trace_show(const struct AdAdapter *adapter,+ int32_t limit,+ const char *event_prefix,+ char **out);++// Exports the session trace as a self-contained HTML file.+AdResult ad_trace_export(const struct AdAdapter *adapter,+ int32_t limit,+ const char *out_path,+ char **out);+```++## Actions, refs, and native handles++`ad_execute_by_ref` is the primary action entrypoint. `ad_execute_action` and `ad_execute_action_with_policy` act on a native handle and skip strict re-identification and the actionability checks.++```c+typedef struct AdNativeHandle {+ const void *ptr;+} AdNativeHandle;++typedef struct AdScrollParams {+ int32_t direction;+ uint32_t amount;+} AdScrollParams;++typedef struct AdKeyCombo {+ const char *key;+ const int32_t *modifiers;+ uint32_t modifier_count;+} AdKeyCombo;++typedef struct AdPoint {+ double x;+ double y;+} AdPoint;++typedef struct AdDragParams {+ struct AdPoint from;+ struct AdPoint to;+ uint64_t duration_ms;+ uint64_t drop_delay_ms;+} AdDragParams;++typedef struct AdAction {+ int32_t kind;+ const char *text;+ struct AdScrollParams scroll;+ struct AdKeyCombo key;+ struct AdDragParams drag;+} AdAction;++typedef struct AdElementState {+ const char *role;+ char **states;+ uint32_t state_count;+ const char *value;+} AdElementState;++typedef struct AdActionStep {+ const char *label;+ const char *outcome;+ int32_t mechanism;+ bool has_mechanism;+ bool verified;+ bool has_verified;+ uint64_t _reserved;+} AdActionStep;++typedef struct AdDeliverySemantics {+ int32_t delivery;+ int32_t retry;+} AdDeliverySemantics;++typedef struct AdActionResult {+ const char *action;+ const char *ref_id;+ struct AdElementState *post_state;+ struct AdActionStep *steps;+ uint32_t step_count;+ const char *details_json;+ struct AdDeliverySemantics disposition;+} AdActionResult;+```++```c+typedef struct AdRefProcess {+ uint32_t pid;+} AdRefProcess;++typedef struct AdRefIdentity {+ const char *role;+ const char *name;+ const char *value;+ const char *description;+ const char *native_id;+} AdRefIdentity;++typedef struct AdRect {+ double x;+ double y;+ double width;+ double height;+} AdRect;++typedef struct AdRefGeometry {+ struct AdRect bounds;+ uint64_t bounds_hash;+ bool has_bounds;+ bool has_bounds_hash;+ int32_t bounds_space;+} AdRefGeometry;++typedef struct AdStringSlice {+ const char *const *items;+ size_t count;+} AdStringSlice;++typedef struct AdRefCapabilities {+ struct AdStringSlice states;+ struct AdStringSlice available_actions;+} AdRefCapabilities;++typedef struct AdRefSource {+ const char *app;+ const char *window_id;+ const char *window_title;+ uint64_t window_bounds_hash;+ int32_t surface;+ bool has_window_bounds_hash;+} AdRefSource;++typedef struct AdRefScope {+ const char *root_ref;+ const uint32_t *path;+ size_t path_count;+ bool path_is_absolute;+} AdRefScope;++typedef struct AdRefEntry {+ struct AdRefProcess process;+ struct AdRefIdentity identity;+ struct AdRefGeometry geometry;+ struct AdRefCapabilities capabilities;+ struct AdRefSource source;+ struct AdRefScope scope;+} AdRefEntry;++typedef struct AdExactRefEntry {+ uint32_t version;+ uint32_t size;+ struct AdRefEntry entry;+ const char *process_instance;+ int32_t identifier_kind;+} AdExactRefEntry;+```++```c+// Acts on a native handle under the default policy, with no preflight.+AdResult ad_execute_action(const struct AdAdapter *adapter,+ const struct AdNativeHandle *handle,+ const struct AdAction *action,+ struct AdActionResult *out);++// Acts on a native handle with an explicit AdPolicyKind.+AdResult ad_execute_action_with_policy(const struct AdAdapter *adapter,+ const struct AdNativeHandle *handle,+ const struct AdAction *action,+ int32_t policy,+ struct AdActionResult *out);++// Runs the full ref-action pipeline from an exact ref entry.+AdResult ad_execute_ref_action_exact_with_policy(const struct AdAdapter *adapter,+ const struct AdExactRefEntry *entry,+ const struct AdAction *action,+ int32_t policy,+ struct AdActionResult *out);++// Strictly resolves an exact ref entry to a native handle.+AdResult ad_resolve_element_exact(const struct AdAdapter *adapter,+ const struct AdExactRefEntry *entry,+ struct AdNativeHandle *out);++// Releases a native handle on the resolving thread and zeroes it.+AdResult ad_free_handle(const struct AdAdapter *adapter, struct AdNativeHandle *handle);++// Frees every string and array owned by an AdActionResult.+void ad_free_action_result(struct AdActionResult *result);+```++## Find, get, and is++```c+typedef struct AdFindSelection {+ int32_t kind;+ uint32_t nth;+} AdFindSelection;++typedef struct AdFindControl {+ uint32_t version;+ struct AdFindSelection selection;+ uint64_t timeout_ms;+} AdFindControl;++typedef struct AdFindIdentity {+ const char *role;+ const char *name;+ const char *description;+ const char *native_id;+ const char *value;+} AdFindIdentity;++typedef struct AdFindStatePredicate {+ const char *token;+ int32_t expected;+} AdFindStatePredicate;++typedef struct AdFindStateSlice {+ const struct AdFindStatePredicate *items;+ size_t count;+} AdFindStateSlice;++typedef struct AdFindFilter {+ struct AdFindIdentity identity;+ const char *has_text;+ struct AdFindStateSlice states;+ const struct AdFindQuery *has;+ const struct AdFindQuery *has_not;+ bool exact;+} AdFindFilter;++typedef struct AdFindQuery {+ struct AdFindControl control;+ struct AdFindFilter filter;+} AdFindQuery;+```++```c+// Finds and strictly resolves one element in an exact window; duplicates need a first, last, or nth selection.+AdResult ad_find_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *win,+ const struct AdFindQuery *query,+ struct AdNativeHandle *out_handle);++// Reads "value" or "bounds" from a resolved handle into an owned string, or null.+AdResult ad_get(const struct AdAdapter *adapter,+ const struct AdNativeHandle *handle,+ const char *property,+ char **out);++// Checks a boolean state of the element a query matches in an exact window.+AdResult ad_is_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *win,+ const struct AdFindQuery *query,+ const char *property,+ bool *out);+```++## Raw tree++`ad_get_tree_exact` returns a flat, breadth-first tree with no refs, refmap, or envelope. Use `ad_snapshot` for the observe and act loop.++```c+typedef struct AdNodeContent {+ const char *ref_id;+ const char *role;+ const char *name;+ const char *value;+ const char *description;+ const char *hint;+} AdNodeContent;++typedef struct AdNodePresentation {+ char **states;+ struct AdRect bounds;+ uint32_t state_count;+ bool has_bounds;+} AdNodePresentation;++typedef struct AdNodeRelation {+ int32_t parent_index;+ uint32_t child_start;+ uint32_t child_count;+} AdNodeRelation;++typedef struct AdNode {+ struct AdNodeContent content;+ struct AdNodePresentation presentation;+ struct AdNodeRelation relation;+} AdNode;++typedef struct AdNodeTree {+ struct AdNode *nodes;+ uint32_t count;+} AdNodeTree;++typedef struct AdTreeOptions {+ uint8_t max_depth;+ bool include_bounds;+ bool interactive_only;+ bool compact;+ int32_t surface;+} AdTreeOptions;+```++```c+// Reads an exact window into a flat tree; children are contiguous at nodes[child_start..].+AdResult ad_get_tree_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *win,+ const struct AdTreeOptions *opts,+ struct AdNodeTree *out);++// Frees a tree and zeroes it.+void ad_free_tree(struct AdNodeTree *tree);+```++## Apps and windows++Window functions take an `AdExactWindowInfo`, which carries the process-generation token that targeting needs.++```c+typedef struct AdWindowInfo {+ const char *id;+ const char *title;+ const char *app_name;+ uint32_t pid;+ struct AdRect bounds;+ bool has_bounds;+ bool is_focused;+} AdWindowInfo;++typedef struct AdExactWindowInfo {+ uint32_t version;+ uint32_t size;+ struct AdWindowInfo window;+ const char *process_instance;+ bool accessible;+} AdExactWindowInfo;++typedef struct AdAppInfo {+ const char *name;+ uint32_t pid;+ const char *bundle_id;+} AdAppInfo;++typedef struct AdWindowOp {+ int32_t kind;+ double width;+ double height;+ double x;+ double y;+} AdWindowOp;+```++```c+// Launches an app and writes its first window.+AdResult ad_launch_app_exact(const struct AdAdapter *adapter,+ const char *id,+ uint64_t timeout_ms,+ struct AdExactWindowInfo *out);++// Closes an app; force skips graceful shutdown.+AdResult ad_close_app(const struct AdAdapter *adapter, const char *id, bool force);++// Lists running apps into an opaque list.+AdResult ad_list_apps(const struct AdAdapter *adapter, struct AdAppList **out);++// Returns the number of apps in the list.+uint32_t ad_app_list_count(const struct AdAppList *list);++// Returns a borrowed entry, or null when out of range.+const struct AdAppInfo *ad_app_list_get(const struct AdAppList *list, uint32_t index);++// Frees the list.+void ad_app_list_free(struct AdAppList *list);++// Lists windows with process-generation evidence, optionally filtered.+AdResult ad_list_windows_exact(const struct AdAdapter *adapter,+ const char *app_filter,+ bool focused_only,+ struct AdExactWindowList **out);++// Returns the number of windows in the list.+uint32_t ad_exact_window_list_count(const struct AdExactWindowList *list);++// Returns a borrowed window entry, or null when out of range.+const struct AdExactWindowInfo *ad_exact_window_list_get(const struct AdExactWindowList *list,+ uint32_t index);++// Frees the window list.+void ad_exact_window_list_free(struct AdExactWindowList *list);++// Focuses an exact window.+AdResult ad_focus_window_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *win);++// Resizes, moves, minimizes, maximizes, or restores an exact window.+AdResult ad_window_op_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *win,+ struct AdWindowOp op);++// Releases the strings inside an AdExactWindowInfo written by ad_launch_app_exact.+void ad_release_exact_window_fields(struct AdExactWindowInfo *win);+```++## Surfaces++```c+typedef struct AdSurfaceInfo {+ const char *kind;+ const char *title;+ int64_t item_count;+} AdSurfaceInfo;++typedef struct AdExactSurfaceInfo {+ uint32_t version;+ uint32_t size;+ const char *id;+ struct AdSurfaceInfo surface;+ const char *unclassified;+} AdExactSurfaceInfo;+```++```c+// Lists the overlay surfaces a process presents.+AdResult ad_list_surfaces_exact(const struct AdAdapter *adapter,+ uint32_t pid,+ struct AdExactSurfaceList **out);++// Returns the number of surfaces in the list.+uint32_t ad_exact_surface_list_count(const struct AdExactSurfaceList *list);++// Returns a borrowed surface entry, or null when out of range.+const struct AdExactSurfaceInfo *ad_exact_surface_list_get(const struct AdExactSurfaceList *list,+ uint32_t index);++// Frees the surface list.+void ad_exact_surface_list_free(struct AdExactSurfaceList *list);+```++## Wait++Zero-initialize `AdWaitArgs` and check its size before calling [`ad_wait`](#command-backed-json-entrypoints).++```c+typedef struct AdOptionalU64 {+ uint64_t value;+ bool present;+} AdOptionalU64;++typedef struct AdWaitSurfaceModes {+ bool menu;+ bool menu_closed;+ bool notification;+} AdWaitSurfaceModes;++typedef struct AdWaitMode {+ struct AdOptionalU64 pause;+ const char *element;+ const char *window;+ const char *text;+ struct AdWaitSurfaceModes surfaces;+} AdWaitMode;++typedef struct AdOptionalUsize {+ size_t value;+ bool present;+} AdOptionalUsize;++typedef struct AdWaitPredicate {+ const char *predicate;+ const char *value;+ const char *action;+ struct AdOptionalUsize count;+} AdWaitPredicate;++typedef struct AdWaitScope {+ uint64_t timeout_ms;+ const char *app;+} AdWaitScope;++typedef struct AdWaitArgs {+ struct AdWaitMode mode;+ struct AdWaitPredicate predicate;+ struct AdWaitScope scope;+} AdWaitArgs;+```++## Displays and screenshots++```c+typedef struct AdDisplayInfo {+ uint32_t version;+ uint32_t size;+ const char *id;+ struct AdRect bounds;+ bool is_primary;+ double scale;+} AdDisplayInfo;++typedef struct AdScreenshotTarget {+ int32_t kind;+ uint64_t screen_index;+} AdScreenshotTarget;+```++```c+// Lists displays in screenshot screen-index order.+AdResult ad_list_displays(const struct AdAdapter *adapter, struct AdDisplayList **out);++// Returns the number of displays.+uint32_t ad_display_list_count(const struct AdDisplayList *list);++// Returns a borrowed display entry, or null when out of range.+const struct AdDisplayInfo *ad_display_list_get(const struct AdDisplayList *list, uint32_t index);++// Frees the display list.+void ad_display_list_free(struct AdDisplayList *list);++// Captures a display into an opaque image buffer.+AdResult ad_screenshot(const struct AdAdapter *adapter,+ const struct AdScreenshotTarget *target,+ struct AdImageBuffer **out);++// Captures one exact window into an opaque image buffer.+AdResult ad_screenshot_window_exact(const struct AdAdapter *adapter,+ const struct AdExactWindowInfo *window,+ struct AdImageBuffer **out);++// Returns a borrowed pointer to the image bytes.+const uint8_t *ad_image_buffer_data(const struct AdImageBuffer *buf);++// Returns the byte length of the image.+uint64_t ad_image_buffer_size(const struct AdImageBuffer *buf);++// Returns the pixel width.+uint32_t ad_image_buffer_width(const struct AdImageBuffer *buf);++// Returns the pixel height.+uint32_t ad_image_buffer_height(const struct AdImageBuffer *buf);++// Returns the encoding.+AdImageFormat ad_image_buffer_format(const struct AdImageBuffer *buf);++// Returns the point-to-pixel scale factor.+double ad_image_buffer_scale_factor(const struct AdImageBuffer *buf);++// Frees the image buffer; freeing twice is undefined behavior.+void ad_image_buffer_free(struct AdImageBuffer *buf);+```++## Clipboard++```c+// Reads clipboard text into an owned string.+AdResult ad_get_clipboard(const struct AdAdapter *adapter, char **out);++// Writes UTF-8 text to the clipboard.+AdResult ad_set_clipboard(const struct AdAdapter *adapter, const char *text);++// Clears the clipboard.+AdResult ad_clear_clipboard(const struct AdAdapter *adapter);+```++## Mouse++These send physical input and carry no headless policy. For policy-checked clicks, use ref actions.++```c+typedef struct AdMouseEvent {+ int32_t kind;+ struct AdPoint point;+ int32_t button;+ uint32_t click_count;+} AdMouseEvent;+```++```c+// Drags the pointer from params.from to params.to.+AdResult ad_drag(const struct AdAdapter *adapter, const struct AdDragParams *params);++// Sends a move, down, up, or click event at a screen point.+AdResult ad_mouse_event(const struct AdAdapter *adapter, const struct AdMouseEvent *event);++// Same, while holding a modifier chord.+AdResult ad_mouse_event_with_modifiers(const struct AdAdapter *adapter,+ const struct AdMouseEvent *event,+ const int32_t *modifiers,+ uint32_t modifier_count);++// Sends a wheel event in line deltas; modifier_mask bits 0 to 3 are meta, ctrl, alt, shift.+AdResult ad_mouse_wheel(const struct AdAdapter *adapter,+ struct AdPoint point,+ double delta_x,+ double delta_y,+ uint32_t modifier_mask);+```++## Notifications++```c+typedef struct AdNotificationIdentity {+ const char *app;+ const char *title;+} AdNotificationIdentity;++typedef struct AdNotificationActionRequest {+ uint32_t index;+ int32_t policy;+ const char *action_name;+ struct AdNotificationIdentity identity;+} AdNotificationActionRequest;++typedef struct AdNotificationFilter {+ const char *app;+ const char *text;+ uint32_t limit;+ bool has_limit;+} AdNotificationFilter;++typedef struct AdNotificationInfo {+ uint32_t index;+ const char *app_name;+ const char *title;+ const char *body;+ char **actions;+ uint32_t action_count;+} AdNotificationInfo;+```++```c+// Lists notifications; indexes are stable only within one list.+AdResult ad_list_notifications(const struct AdAdapter *adapter,+ const struct AdNotificationFilter *filter,+ struct AdNotificationList **out);++// Returns the number of notifications.+uint32_t ad_notification_list_count(const struct AdNotificationList *list);++// Returns a borrowed notification, or null when out of range.+const struct AdNotificationInfo *ad_notification_list_get(const struct AdNotificationList *list,+ uint32_t index);++// Frees the list.+void ad_notification_list_free(struct AdNotificationList *list);++// Presses a named action, failing closed when the identity no longer matches.+AdResult ad_notification_action(const struct AdAdapter *adapter,+ const struct AdNotificationActionRequest *request,+ struct AdActionResult *out);++// Dismisses one notification when it matches the expected app or title.+AdResult ad_dismiss_notification(const struct AdAdapter *adapter,+ uint32_t index,+ const char *app_filter,+ const char *expected_app,+ const char *expected_title);++// Dismisses every matching notification and returns the dismissed and failed lists.+AdResult ad_dismiss_all_notifications(const struct AdAdapter *adapter,+ const char *app_filter,+ struct AdNotificationList **dismissed_out,+ struct AdNotificationList **failed_out);++// Frees both lists returned by ad_dismiss_all_notifications.+void ad_dismiss_all_notifications_free(struct AdNotificationList *dismissed,+ struct AdNotificationList *failed);+```++## Errors++These read the calling thread's last-error slot. See [Errors](/desktop/ffi/ownership-and-threading#errors).++```c+// Returns the code of the last failure on this thread.+AdResult ad_last_error_code(void);++// Returns a borrowed description, or null.+const char *ad_last_error_message(void);++// Returns a borrowed recovery hint, or null.+const char *ad_last_error_suggestion(void);++// Returns a borrowed OS diagnostic, or null.+const char *ad_last_error_platform_detail(void);++// Returns borrowed structured JSON, or null; it may contain on-screen text.+const char *ad_last_error_details(void);++// Writes the delivery and retry semantics of the last failure.+AdResult ad_last_error_delivery_semantics(struct AdDeliverySemantics *out);+```++## Logging and memory++```c+// Registers or clears one process-wide callback for log events.+AdResult ad_set_log_callback(void (*callback)(int32_t level, const char *msg));++// Frees a string the library returned; null-tolerant.+void ad_free_string(char *s);+```++## Size getters++Each returns a struct size as compiled in the library. Compare it with your binding's size before you pass the struct.++```c+size_t ad_action_size(void);++size_t ad_action_result_size(void);++size_t ad_action_step_size(void);++size_t ad_display_info_size(void);++size_t ad_drag_params_size(void);++size_t ad_element_state_size(void);++size_t ad_exact_ref_entry_size(void);++size_t ad_exact_surface_info_size(void);++size_t ad_exact_window_info_size(void);++size_t ad_ref_entry_size(void);++size_t ad_wait_args_size(void);+```++`AdAdapter`, `AdAppList`, `AdDisplayList`, `AdExactSurfaceList`, `AdExactWindowList`, `AdImageBuffer`, and `AdNotificationList` are opaque: use them only through the functions above.diff --git a/apps/docs/content/docs/ffi/build-and-link.mdx b/apps/docs/content/docs/ffi/build-and-link.mdxnew file mode 100644index 000000000..d838d05c3--- /dev/null+++ b/apps/docs/content/docs/ffi/build-and-link.mdx@@ -0,0 +1,108 @@+---+title: Build and link+navTitle: Build and link+description: Get libagent_desktop_ffi from a release or build it from source, find the header, link a C program against it, and run the ABI handshake.+---++Use a prebuilt archive from a release, or build the library from source with the `release-ffi` profile.++## Prebuilt archives++Every GitHub release ships `agent-desktop-ffi-v<version>-<target>.tar.gz` (`.zip` on Windows) for macOS arm64 and x86_64, Linux x64 and arm64 (glibc), and Windows x64 and ARM64. Each archive holds:++<table>+ <thead>+ <tr><th>Path</th><th>Contents</th></tr>+ </thead>+ <tbody>+ <tr><td><code>lib/</code></td><td>The library and the helper that must stay beside it: <code>agent-desktop-macos-helper</code> on macOS, <code>agent-desktop-linux-clipboard-owner</code> on Linux. On Windows, also <code>agent_desktop_ffi.dll.lib</code>, the import library for MSVC.</td></tr>+ <tr><td><code>include/agent_desktop.h</code></td><td>The generated C header</td></tr>+ </tbody>+</table>++`checksums.txt` in the release catches corruption; verify origin with `gh attestation verify <file> --repo vercel-labs/agent-desktop`.++## Build from source++```bash+cargo build --profile release-ffi -p agent-desktop-ffi # writes target/release-ffi/libagent_desktop_ffi.so on Linux+```++The output is `libagent_desktop_ffi.dylib` on macOS, `libagent_desktop_ffi.so` on Linux, and `agent_desktop_ffi.dll` on Windows, in `target/release-ffi/`. The `release-ffi` profile keeps `panic = "unwind"`, so every entrypoint can catch a panic and report it as `AD_RESULT_ERR_INTERNAL`. The workspace `release` profile uses `panic = "abort"`, so `cargo build --release` produces a library whose panics abort the host process. Do not ship it.++A source build also needs the platform helper beside the library; see [Installation](/desktop/installation#build-from-source).++## The header++`crates/ffi/include/agent_desktop.h` is generated by cbindgen; do not edit it. When the Rust ABI or `crates/ffi/cbindgen.toml` changes, regenerate it with `scripts/update-ffi-header.sh`, and CI fails on drift. The header ends with C11 `_Static_assert` guards that pin the size and field offsets of every size-pinned struct; define `AGENT_DESKTOP_ABI_ASSERTS` to skip them.++## Link and run a program++This program checks the ABI, snapshots one app, and prints the envelope:++```c+#include <stdio.h>+#include "agent_desktop.h"++int main(int argc, char **argv) {+ const char *app = argc > 1 ? argv[1] : NULL; /* NULL reads the focused window */++ if (ad_init(AD_ABI_VERSION_MAJOR) != AD_RESULT_OK) {+ fprintf(stderr, "ABI mismatch: %s\n", ad_last_error_message());+ return 1;+ }++ AdAdapter *adapter = ad_adapter_create();+ if (!adapter) {+ fprintf(stderr, "adapter_create failed: %s\n", ad_last_error_message());+ return 1;+ }++ char *json = NULL;+ AdResult rc = ad_snapshot(adapter, app, AD_SNAPSHOT_SURFACE_WINDOW,+ 3, true, true, &json); /* max_depth, interactive_only, compact */+ if (json) { /* an ok:true or ok:false envelope: free either */+ printf("%s\n", json);+ ad_free_string(json);+ } else {+ fprintf(stderr, "snapshot failed (%d): %s\n", (int)rc, ad_last_error_message());+ }++ ad_adapter_destroy(adapter);+ return rc == AD_RESULT_OK ? 0 : 1;+}+```++Compile and run it from the repository root on Linux or macOS:++```bash+cc -std=c11 -I crates/ffi/include main.c \+ -L target/release-ffi -lagent_desktop_ffi \+ -Wl,-rpath,"$PWD/target/release-ffi" \+ -o snapshot_demo+./snapshot_demo gnome-calculator+```++On Linux against GNOME Calculator it printed this envelope, shown here with `tree` elided:++```json+{"version":"2.5","ok":true,"command":"snapshot","data":{"app":"gnome-calculator","complete":true,"ref_count":2,"snapshot_id":"s18ekeexjf5trb","tree":{"...":"..."}}}+```++The macOS install name is `@rpath/libagent_desktop_ffi.dylib`, so a program that links the library needs an rpath to its directory; `dlopen` and `ctypes` callers load by path and need nothing. On Windows, an MSVC program links `agent_desktop_ffi.dll.lib` and loads the DLL at run time. On Linux the program must run inside the user's graphical session to see apps; see [Linux](/desktop/platforms/linux).++## Validate struct sizes++A language whose struct layout can differ from C's, such as Python `ctypes` or Go `cgo`, must check each size-pinned struct before passing one to the library. Each has an `AD_*_SIZE` macro and a runtime getter that returns the size compiled on the Rust side: `AdAction` (`ad_action_size`), `AdActionResult`, `AdActionStep`, `AdDisplayInfo`, `AdDragParams`, `AdElementState`, `AdExactRefEntry`, `AdExactSurfaceInfo`, `AdExactWindowInfo`, `AdRefEntry`, and `AdWaitArgs`, each with a matching `ad_<name>_size()` getter.++Zero-initialize every caller-allocated struct before you set fields, and set the `version` and `size` fields of versioned structs to the header's constants.++## Smoke test++`tests/ffi-python/smoke.py` is the reference for non-C hosts and uses only the Python standard library. It checks the ABI version, the size getters, `ad_version`, and the create, snapshot, free, and destroy cycle:++```bash+python3 tests/ffi-python/smoke.py target/release-ffi/libagent_desktop_ffi.so crates/ffi/include/agent_desktop.h+```++On the Linux test desktop it ended with `All legs passed.`diff --git a/apps/docs/content/docs/ffi/index.mdx b/apps/docs/content/docs/ffi/index.mdxnew file mode 100644index 000000000..9e92ec5c8--- /dev/null+++ b/apps/docs/content/docs/ffi/index.mdx@@ -0,0 +1,44 @@+---+title: C library+navTitle: Overview+description: Call agent-desktop in process through libagent_desktop_ffi, the C ABI over the same core and platform adapters as the CLI.+---++The C library exposes agent-desktop as a shared library: `libagent_desktop_ffi.dylib` on macOS, `libagent_desktop_ffi.so` on Linux, and `agent_desktop_ffi.dll` on Windows. Your program calls `ad_*` functions instead of starting the CLI for each command. Any language with a C FFI can load it; `tests/ffi-python/smoke.py` is the tested reference. The header is `crates/ffi/include/agent_desktop.h`.++## Relationship to the CLI++The library and the CLI run the same core and the same platform adapter; the `agent-desktop` binary and the `agent-desktop-ffi` crate are the only two places that connect a platform adapter to core.++- **Same envelope.** The command-backed functions return the CLI's JSON envelope as an owned string. See [JSON output](/desktop/json-output).+- **Same refs.** `ad_snapshot` writes a refmap under the same [state root](/desktop/configuration#state-root) and returns qualified refs, which `ad_execute_by_ref` resolves strictly. A bare `@e5` returns `AD_RESULT_ERR_INVALID_ARGS`.+- **Same safety rules.** Ref actions run the same resolution, actionability checks, and interaction policy as the CLI, and mutations take the same cross-process input lock, so CLI and library calls from one user serialize.+- **Same sessions.** `ad_adapter_create_with_session` scopes refmaps to a [session](/desktop/sessions) like `--session`.++## Two layers++<table>+ <thead>+ <tr><th>Layer</th><th>Functions</th><th>Use when</th></tr>+ </thead>+ <tbody>+ <tr><td>JSON entrypoints</td><td><code>ad_snapshot</code>, <code>ad_execute_by_ref</code>, <code>ad_execute_by_ref_timeout</code>, <code>ad_wait</code>, <code>ad_status</code>, <code>ad_version</code>, <code>ad_trace_show</code>, <code>ad_trace_export</code></td><td>You run the observe, act, and verify loop: parse the envelope and pass refs back.</td></tr>+ <tr><td>Struct-based exact APIs</td><td><code>ad_list_windows_exact</code>, <code>ad_launch_app_exact</code>, <code>ad_find_exact</code>, <code>ad_get_tree_exact</code>, and the rest of the <code>*_exact</code> family, plus clipboard, mouse, display, notification, and screenshot calls</td><td>You need typed results without JSON. These carry process-generation evidence in versioned, size-pinned structs.</td></tr>+ </tbody>+</table>++## What the library does not expose++- `ad_snapshot` always reads the focused window of the app you name. It has no window id, skeleton mode, or `--root` drill-down; use the CLI for those.+- `ad_wait` does not expose `wait --event` or `--window-id`.+- The library carries no skills. Read the FFI guide with `agent-desktop skills get ffi` from the CLI.++## ABI version++`AD_ABI_VERSION_MAJOR` is 6 in this header. The major increments when a symbol is removed or a struct layout changes; new functions and new result codes are additive. Call `ad_init(AD_ABI_VERSION_MAJOR)` once after loading the library: a mismatch returns `AD_RESULT_ERR_INVALID_ARGS`, and you should call nothing else.++## Next steps++- [Build and link](/desktop/ffi/build-and-link): build the library, link it, and run a minimal program.+- [API](/desktop/ffi/api): every function, struct, and enum, grouped by area.+- [Ownership, threading, errors](/desktop/ffi/ownership-and-threading): who frees what, which threads may call, and how to read failures.diff --git a/apps/docs/content/docs/ffi/meta.json b/apps/docs/content/docs/ffi/meta.jsonnew file mode 100644index 000000000..815bbd45d--- /dev/null+++ b/apps/docs/content/docs/ffi/meta.json@@ -0,0 +1,4 @@+{+ "title": "C library",+ "pages": ["index", "build-and-link", "api", "ownership-and-threading"]+}diff --git a/apps/docs/content/docs/ffi/ownership-and-threading.mdx b/apps/docs/content/docs/ffi/ownership-and-threading.mdxnew file mode 100644index 000000000..4e91c9b9e--- /dev/null+++ b/apps/docs/content/docs/ffi/ownership-and-threading.mdx@@ -0,0 +1,106 @@+---+title: Ownership, threading, and errors+navTitle: Ownership, threading, errors+description: Who frees every pointer the C library returns, which threads may call it, and how to read failures.+---++## Ownership++Every pointer the library hands you was allocated by Rust, so C's `free()` cannot release it. Each one has a matching free function. Borrowed pointers, such as the `ad_last_error_*` strings and entries returned by `*_list_get`, are never freed.++<table>+ <thead>+ <tr><th>Allocated by</th><th>Free with</th></tr>+ </thead>+ <tbody>+ <tr><td>The JSON entrypoints (<code>ad_snapshot</code>, <code>ad_execute_by_ref</code>, <code>ad_execute_by_ref_timeout</code>, <code>ad_wait</code>, <code>ad_status</code>, <code>ad_version</code>, <code>ad_trace_show</code>, <code>ad_trace_export</code>)</td><td><code>ad_free_string(out)</code></td></tr>+ <tr><td><code>ad_get_clipboard</code>, <code>ad_get</code> (which may write null)</td><td><code>ad_free_string(text)</code></td></tr>+ <tr><td><code>ad_adapter_create</code>, <code>ad_adapter_create_with_session</code></td><td><code>ad_adapter_destroy(adapter)</code></td></tr>+ <tr><td><code>ad_list_apps</code></td><td><code>ad_app_list_free(list)</code></td></tr>+ <tr><td><code>ad_list_displays</code></td><td><code>ad_display_list_free(list)</code></td></tr>+ <tr><td><code>ad_list_windows_exact</code></td><td><code>ad_exact_window_list_free(list)</code></td></tr>+ <tr><td><code>ad_list_surfaces_exact</code></td><td><code>ad_exact_surface_list_free(list)</code></td></tr>+ <tr><td><code>ad_list_notifications</code></td><td><code>ad_notification_list_free(list)</code></td></tr>+ <tr><td><code>ad_dismiss_all_notifications</code></td><td><code>ad_dismiss_all_notifications_free(dismissed, failed)</code></td></tr>+ <tr><td><code>ad_launch_app_exact</code> (the window struct's strings)</td><td><code>ad_release_exact_window_fields(&out)</code></td></tr>+ <tr><td><code>ad_get_tree_exact</code></td><td><code>ad_free_tree(&out)</code></td></tr>+ <tr><td><code>ad_resolve_element_exact</code>, <code>ad_find_exact</code> (the native handle)</td><td><code>ad_free_handle(adapter, &handle)</code></td></tr>+ <tr><td><code>ad_execute_action</code>, <code>ad_execute_action_with_policy</code>, <code>ad_execute_ref_action_exact_with_policy</code>, <code>ad_notification_action</code></td><td><code>ad_free_action_result(&out)</code></td></tr>+ <tr><td><code>ad_screenshot</code>, <code>ad_screenshot_window_exact</code></td><td><code>ad_image_buffer_free(buf)</code></td></tr>+ </tbody>+</table>++- Every free function accepts null and does nothing.+- Freeing a list handle or an image buffer twice is undefined behavior. Set the pointer to `NULL` after you free it.+- `ad_free_handle` zeroes the handle, so a second call on the same struct is a no-op. Free handles before you destroy the adapter that produced them.+- Strings inside a struct belong to the struct's owner. Do not free them one by one.+- Every fallible function zeroes its out-parameter before validating anything, so calling the paired free function after a failure is safe.++## Threading++Entrypoints may be called from any host thread. Native handles are the exception: resolve, use, and release a handle on the same thread, with the adapter that produced it; anything else returns `AD_RESULT_ERR_INVALID_ARGS`. To pass a target across threads, pass the qualified ref and use `ad_execute_by_ref`.++<table>+ <thead>+ <tr><th>Concurrent calls</th><th>Contract</th></tr>+ </thead>+ <tbody>+ <tr><td>read and read</td><td>Both run concurrently.</td></tr>+ <tr><td>read and mutation</td><td>The read does not wait and may overlap the mutation; its result is a point-in-time observation.</td></tr>+ <tr><td>mutation and mutation</td><td>One holder of the interaction lock runs at a time for the same OS user. A waiter that cannot get it returns a structured timeout.</td></tr>+ </tbody>+</table>++Snapshots, finds, listings, screenshots, clipboard reads, status, and trace reads are observations. Ref actions, native-handle actions, input synthesis, clipboard writes, app and window changes, and notification actions are mutations. The lock is shared with the CLI, so mutations serialize across threads and processes of one user. It is scoped to one command, not a transaction: the UI can change between an observation and a later action.++- `ad_adapter_destroy` revokes the adapter. Calls already in flight finish; calls that start afterward return `AD_RESULT_ERR_INVALID_ARGS`.+- `ad_wait` blocks its calling thread for at most `scope.timeout_ms`.+- The `ad_set_log_callback` callback may run on any thread that calls an `ad_*` function, concurrently, and may still fire briefly after you unregister it. Keep it alive for the process lifetime and never let it unwind across the C ABI.+- A language runtime's global lock does not give thread affinity; keep native handles in thread-confined objects, or use refs.+- On macOS, `ad_check_permissions` reports Accessibility trust for the host executable (`python3`, `node`, your app), not for the library.++## Errors++A failing `AdResult` function returns a negative code and fills the calling thread's last-error slot. Read it before the next call that can fail.++```c+AdExactWindowInfo win = {0};+AdResult rc = ad_launch_app_exact(adapter, "gnome-calculator", 5000, &win);+if (rc != AD_RESULT_OK) {+ const char *msg = ad_last_error_message();+ const char *sug = ad_last_error_suggestion(); /* may be NULL */+ fprintf(stderr, "launch failed (%d): %s\n", (int)rc, msg ? msg : "(no message)");+ if (sug) fprintf(stderr, " suggestion: %s\n", sug);+ return -1;+}+ad_release_exact_window_fields(&win);+```++<table>+ <thead>+ <tr><th>Accessor</th><th>Returns</th></tr>+ </thead>+ <tbody>+ <tr><td><code>ad_last_error_code()</code></td><td>The code of the last failure, or <code>AD_RESULT_OK</code></td></tr>+ <tr><td><code>ad_last_error_message()</code></td><td>Description, or null</td></tr>+ <tr><td><code>ad_last_error_suggestion()</code></td><td>Recovery hint, or null</td></tr>+ <tr><td><code>ad_last_error_platform_detail()</code></td><td>OS diagnostic, or null</td></tr>+ <tr><td><code>ad_last_error_details()</code></td><td>Structured JSON, or null. It can contain text from the user's screen, so keep it out of shared logs.</td></tr>+ <tr><td><code>ad_last_error_delivery_semantics(&sem)</code></td><td>Writes the delivery and retry values of the last failure; both are <code>UNKNOWN</code> when none is recorded.</td></tr>+ </tbody>+</table>++The strings stay valid across later successful calls on the same thread; only the next failing call replaces them, like POSIX `errno`. The slot is thread-local. Retry only when the retry disposition is `AD_RETRY_DISPOSITION_SAFE`, as described in [Errors and recovery](/desktop/errors-and-recovery#disposition).++`AdResult` codes mirror the CLI's [error codes](/desktop/errors-and-recovery#error-codes): `AD_RESULT_ERR_PERM_DENIED` is -1 through `AD_RESULT_ERR_APP_UNRESPONSIVE` at -16. The full list is on the [API page](/desktop/ffi/api#enums). Treat any negative value outside that list as an unknown error, because new codes can be appended.++### Two failure modes for JSON entrypoints++The JSON entrypoints fail in two ways, so check `*out` before you decide whether to free:++- **Argument or infrastructure failure** (a null adapter, bad UTF-8, a bad enum): `*out` is null, nothing is allocated, and only the last-error slot reports it.+- **Command failure** (app not found, `STALE_REF`, `TIMEOUT`): `*out` holds an `"ok": false` envelope that you free with `ad_free_string`. The last-error slot is also set.++### Refs, enums, and panics++Ref-taking functions accept only `@<snapshot_id>:e<N>`. A bare or malformed ref returns `AD_RESULT_ERR_INVALID_ARGS` before dispatch; a missing snapshot returns `AD_RESULT_ERR_SNAPSHOT_NOT_FOUND`; a missing ref returns `AD_RESULT_ERR_STALE_REF`. Every `int32_t` enum field is validated, so an out-of-range value returns `AD_RESULT_ERR_INVALID_ARGS` instead of undefined behavior. Every entrypoint traps panics and reports them as `AD_RESULT_ERR_INTERNAL`, but only in a library built with the `release-ffi` profile; see [Build and link](/desktop/ffi/build-and-link#build-from-source).diff --git a/apps/docs/content/docs/guides/batch.mdx b/apps/docs/content/docs/guides/batch.mdxnew file mode 100644index 000000000..f3df04433--- /dev/null+++ b/apps/docs/content/docs/guides/batch.mdx@@ -0,0 +1,70 @@+---+title: Batching commands+navTitle: Batch+description: Run several agent-desktop commands in one process with batch. When to batch, the non-atomic semantics, validation before the first entry, and how to read the result.+---++`batch` runs a JSON array of commands in order, in one process. It is not a transaction. Use it to save process starts on a known sequence, and to pair an action with `wait --event` so the wait's baseline is read before the action runs. The input format, limits, and output fields are in the [`batch` reference](/desktop/commands/batch).++## When to batch++Batch these:++- An action followed by `wait --event`, such as a click or launch that opens a window. See [Waiting without sleeps](/desktop/guides/waiting#wait-for-an-event-your-action-causes).+- A fixed sequence on refs you already hold, where you do not need to read anything between steps.++Do not batch these:++- Steps where the next command depends on the previous output. Observe, act, and verify each need a read; see [the observe, act, verify loop](/desktop/guides/observe-act-verify).+- Steps that need a ref an earlier entry would create. A batch is validated before its first entry runs, so it cannot name refs from a `snapshot` entry inside it.++## Know what runs first++Before any entry runs, agent-desktop checks every entry: the JSON, the command names, the arguments, ref syntax, and the permissions each command needs. One failure rejects the whole batch and nothing runs:++```json+{+ "code": "INVALID_ARGS",+ "message": "Batch entry 0 ('click') failed validation: Invalid ref_id '@e1': expected @<snapshot_id>:e<N>",+ "details": { "batch_command": "click", "batch_index": 0 },+ "disposition": { "delivery": "not_delivered", "retry": "safe" }+}+```++The check does not reach the live desktop. Whether a ref still resolves, and whether a headless physical action is refused, are decided when the entry runs.++## Read every entry++A batch returns `ok: true` and exit code `0` even when entries fail, so read each entry's `ok`. This batch clicked the calculator's C button, then a ref that does not exist, then C again, with `--stop-on-error` (fields abridged):++```json+{+ "results": [+ { "index": 0, "ok": true, "execution": "completed", "data": { "disposition": { "delivery": "delivered_unverified", "retry": "unsafe" } } },+ {+ "index": 1, "ok": false, "execution": "completed",+ "error": {+ "code": "STALE_REF",+ "message": "@s3sl23kzkoxzvb:e999 not found in current RefMap",+ "disposition": { "delivery": "not_delivered", "retry": "safe" }+ }+ }+ ],+ "total_entries": 3,+ "completed_entries": 2,+ "not_started_entries": 1,+ "stopped": { "index": 1, "reason": "stop_on_error" }+}+```++Each entry keeps its own disposition, and a batch never retries an entry. Apply the normal rule per entry: retry only when `retry` is `safe`.++## Control failures++- **Default.** A failed entry does not stop the batch. Later entries still run, so an action after a failed one can act on a UI you did not expect.+- **`--stop-on-error`.** The batch halts after the first failed entry and reports `stopped`. Use it for any sequence where a later step is wrong after an earlier one fails.+- **`--timeout-ms`.** The default 60000 ms covers the whole batch, waits included. When it expires, the next entry is reported `not_started` with reason `deadline`.++## Use refs in a batch++Refs in `args` must be qualified and come from a snapshot or `find` taken before the batch, under the same `--session`. If an earlier entry changes the UI, a later ref can go stale and that entry fails with `STALE_REF`. Keep batched ref actions to controls that one action does not rebuild. See [Snapshots and refs](/desktop/snapshots-and-refs#refresh-after-the-ui-changes).diff --git a/apps/docs/content/docs/guides/chromium-and-electron.mdx b/apps/docs/content/docs/guides/chromium-and-electron.mdxnew file mode 100644index 000000000..c6addb466--- /dev/null+++ b/apps/docs/content/docs/guides/chromium-and-electron.mdx@@ -0,0 +1,102 @@+---+title: Chromium and Electron apps+navTitle: Chromium and Electron+description: Drive the web contents of a Chromium or Electron app with agent-browser over a DevTools port that agent-desktop opens, and keep the native UI on agent-desktop.+---++agent-desktop reads every app through the OS accessibility tree, and that path works for Chromium and Electron apps too. Their web contents can be dense and slow to walk, though. For an app you can launch fresh, `launch --cdp` starts it with a loopback-only Chrome DevTools Protocol (CDP) port, and [agent-browser](https://agent-browser.dev) connects to that port to drive the web contents. agent-desktop never speaks CDP itself; it opens and verifies the port, and keeps the native UI.++<table>+ <thead>+ <tr><th>Part of the app</th><th>Drive it with</th></tr>+ </thead>+ <tbody>+ <tr><td>Web contents: pages, panels, editors, forms inside the app</td><td>agent-browser, over the CDP port</td></tr>+ <tr><td>Native menu bar, file dialogs and sheets, window management, notifications, screenshots</td><td>agent-desktop</td></tr>+ <tr><td>An app that is already running, or one you did not launch</td><td>agent-desktop only. The port exists only on a process launched with it</td></tr>+ </tbody>+</table>++## 1. Launch the app with a DevTools port++```bash+agent-desktop launch chrome --cdp --env ACCESSIBILITY_ENABLED=1 \+ --arg=--force-renderer-accessibility --arg=--user-data-dir=/tmp/chrome-profile+```++`--cdp` adds the remote-debugging switches, waits until the endpoint answers, and returns it in `data.cdp`. Omit the port, as here, to let the OS pick a free one, or pass one (`--cdp 9229`). The `--env` and `--force-renderer-accessibility` arguments are for Linux, where Chromium joins the accessibility bus only when asked, so that agent-desktop can still see the native UI; see [Linux](/desktop/platforms/linux#chromium-qt-and-electron). An Electron app needs no extra arguments.++This is Google Chrome on Linux, with the suggestion and the window object trimmed:++```json+{+ "version": "2.5",+ "ok": true,+ "command": "launch",+ "data": {+ "app": "chrome",+ "cdp": {+ "http_endpoint": "http://127.0.0.1:44297",+ "port": 44297,+ "product": "Chrome/156.0.8078.79",+ "websocket_url": "ws://127.0.0.1:44297/devtools/browser/4a28a252-c7ea-4288-9985-50e34fc49b8f"+ },+ "pid": 11342,+ "process_instance": "1e1c1e2e:168278",+ "renderer": "chromium",+ "suggestion": "Next: run `agent-browser connect 44297` (preferred; `agent-browser skills get electron` has the guide) or connect any CDP client such as Playwright or Puppeteer. ...",+ "window": { "id": "w-1.10-org-a11y-atspi-accessible-1", "title": "Untitled - Google Chrome" }+ }+}+```++Pass the app name that `list-apps` prints (`chrome`, `Slack`, `Obsidian`). agent-desktop refuses `--cdp` for an app that is already running, because a running process has no port and quitting it would lose the user's state. It finds the running app by that name, so a launcher alias such as `google-chrome` on Linux skips the check and the launch times out instead.++## 2. Connect agent-browser to the port++```bash+agent-browser connect 44297 # the port from data.cdp.port+agent-browser snapshot -i+# - heading "Settings" [level=1, ref=e1]+# - textbox "Name" [ref=e3]+# - button "Save" [ref=e2]+agent-browser fill @e3 "Ada"+agent-browser click @e2+```++From here the web contents follow agent-browser's own snapshot, ref, and act loop; see [agent-browser](https://agent-browser.dev) and `agent-browser skills get electron`. Playwright, Puppeteer, and other CDP clients can use `data.cdp.websocket_url` instead. Do not write raw CDP or call app-internal APIs.++## 3. Keep the native UI on agent-desktop++The window chrome, menus, and dialogs are not in the web contents, so they stay on agent-desktop, in the same run:++```bash+agent-desktop find --app chrome --role button --name Reload --first+agent-desktop find --app chrome --role textfield --first # the address bar+```++Against the session above, the second `find` returned the address bar, `"name": "Address and search bar"`, with the page agent-browser had opened as its value. Use `snapshot --surface` for a native file dialog or sheet the web contents open; see [Surfaces](/desktop/surfaces).++## 4. Close the app++```bash+agent-desktop close-app chrome+```++`close-app` ends the process and with it the port; the run above returned `delivered_verified` with `details.evidence: "process_instance_exited"`, and the endpoint stopped answering. While the port is open, any local process of the same user can control the app's web contents, so request `--cdp` only for the steps that need it.++## When `--cdp` fails++<table>+ <thead>+ <tr><th>Error</th><th>Cause</th><th>What to do</th></tr>+ </thead>+ <tbody>+ <tr><td><code>ACTION_FAILED</code>, <code>details.kind: cdp_requires_fresh_launch</code></td><td>The app is already running. <code>details.pids</code> lists it, and nothing was launched (<code>not_delivered</code>).</td><td>Run <code>close-app</code>, confirm the exit, and launch again with <code>--cdp</code>, or drive the running app through accessibility.</td></tr>+ <tr><td><code>ACTION_FAILED</code>, <code>details.kind: cdp_endpoint_unavailable</code></td><td>The app started, but no DevTools endpoint answered before the deadline. The app keeps running (<code>delivered_unverified</code>).</td><td>Use the accessibility path, or <code>close-app</code> and check the app name and arguments.</td></tr>+ <tr><td><code>INVALID_ARGS</code>, <code>details.kind: cdp_port_in_use</code></td><td>The port you named is bound.</td><td>Name another port, or omit it.</td></tr>+ <tr><td><code>INVALID_ARGS</code>, <code>details.kind: cdp_switch_conflict</code></td><td>An <code>--arg</code> sets <code>--remote-debugging-*</code> or <code>--remote-allow-origins</code>, which <code>--cdp</code> owns.</td><td>Drop that <code>--arg</code>.</td></tr>+ </tbody>+</table>++The flags are in the [`launch` reference](/desktop/commands/app-window#launch). For a dense app you cannot relaunch, map it with a skeleton and drill into one region instead; see [Skeleton and drill-down](/desktop/skeleton-and-drill-down).diff --git a/apps/docs/content/docs/guides/headed-mode.mdx b/apps/docs/content/docs/guides/headed-mode.mdxnew file mode 100644index 000000000..017a22c05--- /dev/null+++ b/apps/docs/content/docs/guides/headed-mode.mdx@@ -0,0 +1,90 @@+---+title: Headed mode+navTitle: Headed mode+description: What headless ref actions do by default, what the --headed flag permits, which commands need it, and how to handle POLICY_DENIED without switching modes by reflex.+---++agent-desktop runs ref actions headless by default. The global `--headed` flag is a permission to use physical input: take focus, move the real cursor, and synthesize keys and pointer events.++## What headless actions do++A headless ref action calls the app's accessibility actions. It does not take focus, move the cursor, synthesize keystrokes, or use the clipboard, which keeps it safe to run while a person uses the desktop. When the accessibility API cannot do what you asked, the action fails closed with a structured error such as `ACTION_NOT_SUPPORTED` or `POLICY_DENIED`. It never silently switches to physical input.++A result shows which mechanism ran: in `data.steps`, `semantic_api` is an accessibility call and `physical_synthetic` is synthesized input.++## What `--headed` permits++`--headed` authorizes the focus and cursor side effects an action declares:++- For a ref, core focuses the exact source window first, and pointer actions need a verified target point.+- Raw coordinates (`--xy`) carry no window identity, so they never focus anything.+- It applies to every entry of a [batch](/desktop/guides/batch).+- It permits physical input; it does not force it. Each platform decides per action whether to use a physical or a semantic path, and `check`, `set-value`, and `expand` stay semantic under `--headed` everywhere.+- It does not lift other guards. A blocked key combo still needs `--force`, and a platform that cannot deliver physical input, such as pointer input on Wayland, still refuses.++```bash+agent-desktop --headed double-click @s8f3k2p9:e3 # a physical gesture+```++Physical input gets no confirmation from the OS, so a physical result is usually `delivered_unverified`. Confirm the effect with a read, as in [the observe, act, verify loop](/desktop/guides/observe-act-verify).++## Which commands need `--headed`++On every platform: `triple-click`, `hover`, `drag`, `mouse-move`, `mouse-click`, and `mouse-wheel`. `double-click` needs it too, except on macOS when the element offers `AXOpen`. `key-down`, `key-up`, `mouse-down`, and `mouse-up` never deliver input in either mode; see the [keyboard](/desktop/commands/keyboard#key-down) and [mouse](/desktop/commands/mouse#mouse-down) references.++Depending on the OS:++<table>+ <thead>+ <tr><th>Command</th><th>macOS</th><th>Windows</th><th>Linux</th></tr>+ </thead>+ <tbody>+ <tr><td><code>right-click</code></td><td>Headless</td><td><code>--headed</code></td><td>Headless, if the element has a context-menu action</td></tr>+ <tr><td><code>type</code></td><td>Headless</td><td><code>--headed</code></td><td>Headless, except into a terminal text node</td></tr>+ <tr><td><code>focus</code></td><td>Headless</td><td><code>--headed</code></td><td><code>--headed</code></td></tr>+ <tr><td><code>scroll</code></td><td>Headless</td><td>Headless</td><td><code>--headed</code>, X11 only</td></tr>+ <tr><td>Listing notifications</td><td>Headless while the surface is open</td><td>Headless while the surface is open</td><td>Headless</td></tr>+ <tr><td>Notification mutations</td><td><code>--headed</code></td><td><code>--headed</code></td><td><code>--headed</code>, X11 only</td></tr>+ <tr><td><code>open-system-surface</code></td><td>Not supported</td><td><code>--headed</code></td><td><code>--headed</code></td></tr>+ </tbody>+</table>++`press` is keyboard input and does not need `--headed` for an unscoped press; scoped presses have platform rules. Each platform page has the full capability table: [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), [Linux](/desktop/platforms/linux).++## Handle `POLICY_DENIED`++`POLICY_DENIED` means the interaction policy blocked a physical or focus path. Nothing was delivered, so the disposition is `not_delivered`. This is `hover` without `--headed`:++```json+{+ "version": "2.5",+ "ok": false,+ "command": "hover",+ "error": {+ "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" }+ }+}+```++Get an explicit decision from the user before you retry. Some `POLICY_DENIED` errors need something other than `--headed`: a blocked key combo needs `--force`, and a failed `supported_action` check in `error.details.checks` means the element offers no route for that action.++<Callout title="Do not switch to headed to recover from a failure">+ Use `--headed` only when the task needs physical input and the user permits it. Do not add it after a headless action fails.+</Callout>++A headless failure usually means the semantic path is missing or the UI changed. A headed retry would move the user's cursor or steal focus to work around that, and if the first attempt may have been delivered, a retry can act twice. Instead:++1. Read `error.code`, `error.disposition`, and `error.details`.+2. Fix the cause: take a fresh snapshot, run `wait --element REF --predicate actionable`, or pick the semantic command (`set-value` for `type`, `check` for `click`).+3. If the step is physical by nature, such as a drag or a hover, and the user permits it, run that step with `--headed` from the start.++## See where actions land++The agent cursor overlay draws a cursor, a ripple, and an element highlight where each action lands. It is presentation only and never changes what an action does. Enable it once per session with `session start --cursor` or `cursor-overlay enable`; a headed command hides it while it dispatches real input. See [`cursor-overlay`](/desktop/commands/system#cursor-overlay).diff --git a/apps/docs/content/docs/guides/meta.json b/apps/docs/content/docs/guides/meta.jsonnew file mode 100644index 000000000..6761466e6--- /dev/null+++ b/apps/docs/content/docs/guides/meta.json@@ -0,0 +1,11 @@+{+ "title": "Guides",+ "pages": [+ "observe-act-verify",+ "waiting",+ "batch",+ "chromium-and-electron",+ "headed-mode",+ "traces"+ ]+}diff --git a/apps/docs/content/docs/guides/observe-act-verify.mdx b/apps/docs/content/docs/guides/observe-act-verify.mdxnew file mode 100644index 000000000..b84c7b95a--- /dev/null+++ b/apps/docs/content/docs/guides/observe-act-verify.mdx@@ -0,0 +1,84 @@+---+title: The observe, act, verify loop+navTitle: Observe, act, verify+description: Run the observe, act, verify loop against a desktop app. Pick the smallest observation, act on a qualified ref, and confirm the effect by reading the app again.+---++agent-desktop does not run the loop; your agent does, one command at a time. `ok: true` does not show that an action worked, so each step ends with a read.++Before the first step, run `agent-desktop status`. If a permission is missing or `supported_surfaces` is empty, fix that first with the page for your OS: [macOS](/desktop/platforms/macos), [Windows](/desktop/platforms/windows), or [Linux](/desktop/platforms/linux).++## Observe++Read the smallest part of the UI that holds your target. A larger read costs more time and tokens, and its refs go stale sooner.++<table>+ <thead>+ <tr><th>What you know</th><th>Run</th></tr>+ </thead>+ <tbody>+ <tr><td>The role and exact name of the element</td><td><code>find --app APP --role button --name Save --exact --first</code></td></tr>+ <tr><td>Nothing yet, and the app is small</td><td><code>snapshot --app APP -i --compact</code></td></tr>+ <tr><td>Nothing yet, and the app is dense (Electron, or more than about 50 interactive elements)</td><td><code>snapshot --skeleton</code>, then <code>snapshot --root REF</code> on one region</td></tr>+ <tr><td>A menu, sheet, alert, or popover is open</td><td><code>snapshot --surface KIND</code>, never with <code>--skeleton</code></td></tr>+ </tbody>+</table>++[Skeleton and drill-down](/desktop/skeleton-and-drill-down) explains the dense-app row and [Surfaces](/desktop/surfaces) the last one. Pass every ref exactly as printed, and re-read the region after any UI change; see [Snapshots and refs](/desktop/snapshots-and-refs).++## Act++Run the command that matches your intent:++```bash+agent-desktop click @s8f3k2p9:e12 # activate a control+agent-desktop set-value @s8f3k2p9:e3 "hello" # replace a field's value+agent-desktop check @s8f3k2p9:e6 # idempotent, unlike toggle+```++Prefer the semantic, idempotent commands: `set-value` over `type`, `check` and `uncheck` over `toggle`, `select` for combo boxes. They run headless, re-read the element, and report `not_delivered` when the element was already in the requested state. Each ref action also waits up to 5000 ms for its target to become actionable, so you rarely need a `wait` before it. Physical gestures such as hover, drag, and double-click need `--headed`; read [Headed mode](/desktop/guides/headed-mode) first. Flags are in the [interaction commands](/desktop/commands/interaction).++## Verify++`ok: true` means the command returned a delivered or already-satisfied result, not that the app did what you wanted. Read `data.disposition.delivery`:++<table>+ <thead>+ <tr><th>Delivery</th><th>What it proves</th><th>What to do</th></tr>+ </thead>+ <tbody>+ <tr><td><code>delivered_verified</code></td><td>The adapter read back the postcondition it names, such as the checked state or the field value. For values, it does not prove the app committed them.</td><td>Confirm document-level effects with an independent read.</td></tr>+ <tr><td><code>delivered_unverified</code></td><td>The dispatch completed. The effect was not confirmed.</td><td>Read the app before you act again.</td></tr>+ <tr><td><code>not_delivered</code></td><td>Nothing was sent, because the operation was already satisfied.</td><td>Read the state if you expected a change.</td></tr>+ </tbody>+</table>++Then read the app again with the smallest read that answers the question:++```bash+agent-desktop is @s8f3k2p9:e6 --property checked # one state+agent-desktop wait --element @s8f3k2p9:e3 --predicate value --value 7 # a value that updates asynchronously+agent-desktop snapshot --root @s8f3k2p9:e2 -i --compact # the region that changed+```++Apps update asynchronously: a read taken right after a click can still show the old state, so prefer `wait` to a single read. If the result has a `menu`, `sheet`, or `alert` in `data.surfaces`, the app is waiting on that overlay; observe it with `snapshot --surface` before the window behind it. See [Waiting without sleeps](/desktop/guides/waiting).++## Recover from failures++Branch on `error.code` and `error.disposition`, never on message text. `STALE_REF` and `SNAPSHOT_NOT_FOUND` mean observe again and use the new ref; `AMBIGUOUS_TARGET` means narrow the target with `find --exact` or `--root`; `POLICY_DENIED` means read [Headed mode](/desktop/guides/headed-mode) before anything else. Retry or substitute an action only when `disposition.retry` is `safe`; otherwise read the live state first. Every code and its recovery is in [Errors and recovery](/desktop/errors-and-recovery).++## Worked example++This run presses a Calculator button on Linux, verifies the display, and clears it. The [quick start](/desktop/quick-start) shows the output of each step.++```bash+agent-desktop find --app gnome-calculator --role button --name 7 --exact --first # ref of the 7 button+agent-desktop find --app gnome-calculator --role textfield --first # ref of the display+agent-desktop click @s3jjre8xzrvo2l:e1 # act+agent-desktop wait --element @s3sxeejcz18ky3:e1 --predicate value --value 7 # verify+agent-desktop find --app gnome-calculator --role button --name C --exact --first # then clear with C+```++1. Each `find` returns one match in `data.match`; its `ref_id` names the snapshot that `find` saved. Use the refs from your own output.+2. `click` returns `delivered_unverified`: the accessibility call returned, which does not prove the button did its job.+3. The `wait` is the verification. If it times out, read `details.last_observed` and `data.surfaces` before you click again, because a second click could type `77`.diff --git a/apps/docs/content/docs/guides/traces.mdx b/apps/docs/content/docs/guides/traces.mdxnew file mode 100644index 000000000..1bdb87f03--- /dev/null+++ b/apps/docs/content/docs/guides/traces.mdx@@ -0,0 +1,109 @@+---+title: Traces+navTitle: Traces+description: Record what agent-desktop did with session traces or --trace, read the timeline with trace show and trace export, and capture visual debug files without leaking private data.+---++A trace is an append-only JSONL record of what agent-desktop did: each command, its outcome and duration, and each snapshot it saved. Use one to debug a run or to audit what an agent did. There are two ways to record: a [session](/desktop/sessions), which also lets you read the trace back, and `--trace PATH`, which writes one file.++## Record a run in a session++A session records a trace by default. `session start` does not activate the session for later commands, so export its id:++```bash+export AGENT_DESKTOP_SESSION="$(agent-desktop session start --name trace-demo | jq -er '.data.session_id')"+agent-desktop snapshot --app gnome-calculator -i --compact+agent-desktop status # session_id is set and tracing is true+```++Each process that runs a command writes its own segment under `<state root>/sessions/<id>/trace/`, named `<pid>-<process start>.jsonl`, starting with a `trace.meta` line. `session start --no-trace` creates a session without one. On PowerShell, see [Windows](/desktop/platforms/windows#use-powershell) for the equivalent of `export`.++## Read the timeline++`trace show` merges every segment into one ordered timeline and needs no OS permission:++```bash+agent-desktop trace show --limit 20 # the last 20 events+agent-desktop trace show --event command. # only command.start and command.end+agent-desktop trace show --limit 0 | jq -r '.data.events[] | select(.event == "command.end") | [.command, .ok, .duration_ms] | @tsv'+```++These are three real events from the session above:++```json+[+ { "command": "snapshot", "duration_ms": 109, "event": "command.end", "ok": true, "segment": "23161-1793353372418", "seq": 3, "session_id": "run-1793353372413-23159-0", "ts_ms": 1793353372528, "writer_pid": 23161, "writer_proc_start_ms": 1793353372418 },+ { "event": "trace.meta", "os": "linux", "pid": 23176, "proc_start_ms": 1793353372533, "schema": 1, "segment": "23176-1793353372531", "seq": 0, "session_id": "run-1793353372413-23159-0", "ts_ms": 1793353372533, "version": "1.0.1", "writer_pid": 23176, "writer_proc_start_ms": 1793353372533 },+ { "command": "trace", "event": "command.start", "segment": "23176-1793353372531", "seq": 1, "session_id": "run-1793353372413-23159-0", "ts_ms": 1793353372534, "writer_pid": 23176, "writer_proc_start_ms": 1793353372533 }+]+```++`trace export` writes a self-contained HTML viewer, by default `trace-<session>.html` in the session directory:++```bash+agent-desktop trace export --out /tmp/run.html+```++Both need an active session and read session segments only, not a `--trace PATH` file. Flags and result fields are in the [`trace` reference](/desktop/commands/system#trace).++### Event names++<table>+ <thead>+ <tr><th>Event</th><th>Written when</th></tr>+ </thead>+ <tbody>+ <tr><td><code>trace.meta</code></td><td>A segment opens. Carries <code>schema</code>, the version, <code>os</code>, and the writer pid.</td></tr>+ <tr><td><code>command.start</code>, <code>command.end</code></td><td>A command begins and ends. <code>command.end</code> has <code>ok</code>, <code>duration_ms</code>, and <code>code</code> on failure.</td></tr>+ <tr><td><code>snapshot.saved</code>, <code>snapshot.root.saved</code></td><td>A snapshot or a drill-down is saved.</td></tr>+ <tr><td><code>locator.resolve</code></td><td>A <code>find</code> finished its search.</td></tr>+ <tr><td><code>ref.resolve.ok</code>, <code>ref.resolve.error</code></td><td>A ref action re-identified its target, or failed to.</td></tr>+ <tr><td><code>actionability.check.ok</code>, <code>actionability.check.error</code></td><td>The pre-dispatch checks passed or failed.</td></tr>+ <tr><td><code>action.artifacts</code></td><td>A screenshot-enabled session captured, or skipped, the before and after images.</td></tr>+ </tbody>+</table>++Other events and fields can appear; ignore the ones you do not know.++## Trace to a single file++`--trace PATH` appends events to one file and needs no session:++```bash+agent-desktop --trace /tmp/run.jsonl find --app gnome-calculator --role button --name 7 --exact --count+jq -c 'select(.event == "command.end")' /tmp/run.jsonl+```++The file is created private. While `--trace` is set, the session's trace directory receives nothing. A trace write failure does not fail the command unless you add `--trace-strict`.++## Capture screenshots with a session++`session start --screenshots` stores a before and after PNG of the target window for each ref action, and a copy of each refmap, under the session's `trace/screens/` and `trace/refmaps/`. `trace export` embeds the images. When an image cannot be taken, the `action.artifacts` event records why. Screenshots need tracing on, and on macOS the Screen Recording permission.++A session's recording budget is 32 MiB, 100,000 events, and 4,096 directory entries. When it is spent, existing events stay readable and new ones are dropped; start a new session to keep recording.++## Make a visual debug file++Visual debug writes one HTML file that pairs a window screenshot with labeled element bounds:++```bash+agent-desktop --debug --screenshot /tmp/calc-debug.html snapshot --app gnome-calculator -i+agent-desktop --debug --screenshot /tmp/click-debug.html click @s8f3k2p9:e12+```++- `--debug` requires `--screenshot PATH.html`, a new file ending in `.html`. It is created with owner-only permissions.+- It supports `snapshot` (window surface only) and `click`.+- The result gains `data.debug` with `path` and `format`. If the window cannot be captured, the command still succeeds and `data.debug.warning` says why; on the openbox test desktop it read `No X11 window of the window manager matches this window`.+- The before and after images of a click are two separate observations, not proof that the click was delivered.++## Keep private data private++<Callout title="Traces and debug files contain desktop content">+ Snapshot trees, window titles, clipboard reads, notifications, screenshots, and command results contain what you asked agent-desktop to inspect. Treat these files as private.+</Callout>++- Trace lines replace sensitive fields, such as `text`, `value`, `name`, `title`, `url`, `label`, `description`, and `password`, with `{ "redacted": true }`. Command names, app names, ref and snapshot ids, error codes, and durations stay readable.+- Session screenshots, the exported HTML that embeds them, and visual debug files are not redacted.+- Keep these files, and the transcripts of the calling agent, out of public repositories and issue reports.++`session end` seals a session, and `session gc --ended` removes ended sessions with their traces.diff --git a/apps/docs/content/docs/guides/waiting.mdx b/apps/docs/content/docs/guides/waiting.mdxnew file mode 100644index 000000000..e8beb5c13--- /dev/null+++ b/apps/docs/content/docs/guides/waiting.mdx@@ -0,0 +1,105 @@+---+title: Waiting without sleeps+navTitle: Waiting+description: Wait for a desktop app to reach a state without fixed sleeps. Choose between the post-action wait flags and the wait command, and read a timeout.+---++A fixed sleep either wastes time or races the app. agent-desktop gives you two waits that poll for a condition instead: the post-action `--wait-for` flags, which wait inside the command you already run, and the `wait` command, which waits on its own. Every flag is in the [`wait` reference](/desktop/commands/wait) and in [Post-action wait flags](/desktop/configuration#post-action-wait-flags).++## Choose the wait++<table>+ <thead>+ <tr><th>You are waiting for</th><th>Use</th></tr>+ </thead>+ <tbody>+ <tr><td>A control or text to appear after an action</td><td><code>--wait-for "role:text"</code> on the action</td></tr>+ <tr><td>A control to disappear after an action, such as a spinner</td><td><code>--wait-for-gone "role"</code> on the action</td></tr>+ <tr><td>One element to reach a value or become ready</td><td><code>wait --element REF --predicate value</code> or <code>actionable</code></td></tr>+ <tr><td>A new window or dialog</td><td><code>wait --window TITLE --app APP</code></td></tr>+ <tr><td>Text anywhere in an app</td><td><code>wait --text TEXT --app APP</code></td></tr>+ <tr><td>A menu to open or close</td><td><code>wait --menu</code>, <code>wait --menu-closed</code></td></tr>+ <tr><td>A window or app lifecycle change your action causes</td><td><code>wait --event KIND</code>, in a batch with the action</td></tr>+ <tr><td>A new notification</td><td><code>wait --notification</code></td></tr>+ <tr><td>Nothing observable</td><td><code>wait MS</code>, as a last resort</td></tr>+ </tbody>+</table>++## Wait inside the action++`--wait-for` polls the acted-on window until the selector matches, then returns a fresh snapshot with the action's own report under `after_action`, so you can act on the new refs at once:++```bash+agent-desktop click @s8f3k2p9:e5 --wait-for "button:Done" --wait-timeout 10000+agent-desktop click @s8f3k2p9:e5 --wait-for-gone "progressindicator"+```++If the wait times out, the action already ran: the error keeps the action's delivery in `error.disposition` and its report in `details.after_action`. Read the app before you retry the action.++## Wait for an element++Use `wait --element` when you hold a ref and need a condition on it. The verify step of the [quick start](/desktop/quick-start#verify) waits for the calculator display to read `7`, which took 286 ms after the click:++```bash+agent-desktop wait --element @s2txcl95uvubmn:e6 --predicate value --value 7 --timeout 5000+```++Use `--predicate actionable --action type` before typing into a field that is still loading. You rarely need a wait before a plain click: ref actions already wait for their target to become actionable.++## Wait for a window, then its content++A window can exist before its content does. Wait for the window, then for the content:++```bash+agent-desktop wait --window "Save As" --app gedit --timeout 10000+agent-desktop wait --text "Save" --app gedit --timeout 10000+```++`--window` matches a title that contains your text. If an app has a document and a dialog open, `wait --text` returns `AMBIGUOUS_TARGET` before it checks any text; wait for the dialog by title with `--window`, then read it with `snapshot --surface sheet` or `--window-id`.++## Wait for an event your action causes++`wait --event` diffs a baseline taken when the wait starts against fresh reads, so a separate `wait` started after your action can miss the change. Put the action and the wait in one [batch](/desktop/guides/batch), which takes the baseline before the action runs:++```bash+agent-desktop batch '[+ {"command":"launch","args":{"app":"gtk3-demo"}},+ {"command":"wait","args":{"event":"window-opened","app":"gtk3-demo","timeout":10000}}+]' --stop-on-error+```++On Linux this returned the new window 144 ms after the launch; the [`wait` reference](/desktop/commands/wait#event) shows the result. A misspelled `--app` makes closing events such as `app-terminated` return at once with `target_unresolved: true`, so check the name with `list-apps` first.++## Wait for a menu++Open the menu, wait for it, and read it as a surface:++```bash+agent-desktop click @s2qfke45s1966h:e1 # the Menu button+agent-desktop wait --menu --app gtk3-widget-factory --timeout 5000+agent-desktop snapshot --app gtk3-widget-factory --surface menu -i --compact+```++After you choose an item or dismiss the menu, `wait --menu-closed --app gtk3-widget-factory` confirms it is gone. Wait for `--menu` before `--menu-closed`: on Linux, `--menu-closed` on a menu that never opened is true at once. See [Surfaces](/desktop/surfaces).++## Set timeouts++<table>+ <thead>+ <tr><th>Wait</th><th>Flag</th><th>Default</th></tr>+ </thead>+ <tbody>+ <tr><td><code>wait</code> in every mode except <code>wait MS</code></td><td><code>--timeout</code></td><td>30000 ms</td></tr>+ <tr><td><code>--wait-for</code>, <code>--wait-for-gone</code></td><td><code>--wait-timeout</code></td><td>30000 ms</td></tr>+ <tr><td>Auto-wait before a ref action</td><td><code>--timeout-ms</code></td><td>5000 ms</td></tr>+ <tr><td>A whole <code>batch</code>, including waits inside it</td><td><code>--timeout-ms</code></td><td>60000 ms</td></tr>+ </tbody>+</table>++`wait` uses `--timeout`; the other commands use `--timeout-ms`.++## Read a timeout++A `TIMEOUT` from a wait says what the wait last saw in `details.last_observed`. A `wait --window "Save As"` that timed out reported the only window it found, `Untitled Document 1 - gedit`, which tells you the dialog never opened rather than that the title was wrong. Use it to decide between a wrong title, a wrong `--app`, and a slow app. The fields per mode are in the [`wait` reference](/desktop/commands/wait#errors).++On macOS and Windows, a headless `wait --notification` sees only an already-open notification surface; see [macOS](/desktop/platforms/macos) and [Windows](/desktop/platforms/windows).diff --git a/apps/docs/content/docs/index.mdx b/apps/docs/content/docs/index.mdxindex 3f4939414..8f635882c 100644--- a/apps/docs/content/docs/index.mdx+++ b/apps/docs/content/docs/index.mdx@@ -16,7 +16,7 @@ agent-desktop skills get desktop # the guide your agent should load first- **A tool that agents call.** It is not an agent. The observe, act, and verify loop lives in the calling agent or script.- **No model inside.** It never embeds an LLM, has no GUI, and has no interactive prompt. Every command prints one JSON envelope and exits.-- **Desktop apps only.** It does not automate web pages. Use [agent-browser](https://agent-browser.dev) for those.+- **Desktop apps only.** It does not automate web pages; use [agent-browser](https://agent-browser.dev) for those. For the web contents of a Chromium or Electron app you launch, agent-desktop opens a DevTools port that agent-browser connects to. See [Chromium and Electron apps](/desktop/guides/chromium-and-electron).- **Limited to what apps expose.** It reads accessibility trees and does not match pixels, so it cannot see a UI that publishes no accessibility tree.## The loop in four commandsdiff --git a/apps/docs/content/docs/meta.json b/apps/docs/content/docs/meta.jsonindex d7c702b4c..115bac452 100644--- a/apps/docs/content/docs/meta.json+++ b/apps/docs/content/docs/meta.json@@ -13,6 +13,14 @@"errors-and-recovery","---Reference---","...commands",- "configuration"+ "configuration",+ "---Guides---",+ "...guides",+ "---Platforms---",+ "...platforms",+ "---C library---",+ "...ffi",+ "---",+ "changelog"]}diff --git a/apps/docs/content/docs/platforms/linux.mdx b/apps/docs/content/docs/platforms/linux.mdxnew file mode 100644index 000000000..d62ba551f--- /dev/null+++ b/apps/docs/content/docs/platforms/linux.mdx@@ -0,0 +1,139 @@+---+title: Linux+navTitle: Linux+description: Requirements, the accessibility bus, per-command capabilities on X11 and Wayland, app naming, surfaces, and troubleshooting for agent-desktop on Linux.+---++agent-desktop reads Linux apps through AT-SPI over D-Bus. The loop, refs, JSON envelope, sessions, and traces match every platform, so this page covers only what differs on Linux. GNOME is the measured desktop; X11 and Wayland sessions both work and differ in input, capture, and window control. The examples on this page ran on an X11 session (Xvfb with the openbox window manager, no GNOME Shell), so shell surfaces and notifications were not exercised.++## Requirements++- Ubuntu 24.04 or later on x86_64 or aarch64, with a glibc 2.35 floor. Other distributions need an `at-spi2-core` bridge with fix (commit `dc0dc33`); Ubuntu 22.04's bridge aborts on `Action.GetActions`.+- A graphical session of the signed-in user, a running AT-SPI bus (`at-spi2-core`), and a window manager. Run agent-desktop from a shell inside that session: the session bus, display, and runtime directory come from its environment. A TTY login, an SSH shell without those variables, a container without a bus, or another user's session sees no apps.+- X11 keys need XTEST, and Wayland keys need GNOME Mutter RemoteDesktop. The Wayland clipboard needs `wl-clipboard`.+- On X11, `clipboard-set` needs `agent-desktop-linux-clipboard-owner` beside the binary. npm installs and release archives include it; from source, build it with `cargo build --release -p agent-desktop-linux --bins`.+- A private state root. A group-writable or world-readable `~/.agent-desktop` makes commands that write there fail with `INTERNAL`. Run `chmod 700` on it, or let agent-desktop create it.++## Check the accessibility bus++Linux has no permission dialog for accessibility; whether the bus answers gates everything. Run `status` first:++```bash+agent-desktop status+```++```json+{+ "permissions": {+ "accessibility": { "state": "granted" },+ "automation": { "state": "not_required" },+ "screen_recording": { "state": "not_required" }+ },+ "platform": "linux",+ "supported_surfaces": ["window", "sheet", "alert", "menu"]+}+```++<table>+ <thead>+ <tr><th>State</th><th>What <code>status</code> and <code>list-apps</code> show</th><th>Meaning</th></tr>+ </thead>+ <tbody>+ <tr><td>Answered, healthy</td><td><code>accessibility</code> is <code>granted</code>, <code>supported_surfaces</code> lists surfaces, <code>list-apps</code> returns rows</td><td>Normal</td></tr>+ <tr><td>Answered, empty</td><td><code>granted</code>, but <code>list-apps</code> returns no rows</td><td>The bus is up and no app registered. Start an app, or restart one that started before the bus</td></tr>+ <tr><td>Unavailable</td><td><code>denied</code> with a suggestion, empty <code>supported_surfaces</code>, and commands fail with <code>PLATFORM_NOT_SUPPORTED</code></td><td>The session bus or the accessibility bus cannot be reached</td></tr>+ </tbody>+</table>++An unavailable bus has four usual causes, each reported with the raw D-Bus error in `platform_detail`:++- **No session bus.** Run inside a desktop session, or start one with `dbus-run-session -- COMMAND`.+- **AT-SPI not installed.** Install `at-spi2-core`. For Flatpak add `--talk-name=org.a11y.Bus`; for snap connect `desktop-legacy` or `unity7`.+- **Launcher cannot start.** Read `systemctl --user status at-spi-dbus-bus.service`.+- **Socket gone.** Restart `at-spi-dbus-bus.service`, or log out and back in.++Judge health with `status`, not with `busctl`: on a cold session `org.a11y.Bus` has no owner until its first use. Do not restart a bus you did not start, because other clients on a shared host depend on it.++## What works headless++Ref actions are semantic AT-SPI calls that never move the pointer or change the active window. Under `--headed` on X11, `click`, `right-click`, and `type` try physical input first and fall back to the semantic action only after a `not_delivered` refusal. See [Headed mode](/desktop/guides/headed-mode).++<table>+ <thead>+ <tr><th>Group</th><th>Works headless</th><th>Needs <code>--headed</code></th><th>Fails closed or not supported</th></tr>+ </thead>+ <tbody>+ <tr><td>Observation and surfaces</td><td><code>snapshot</code>, <code>find</code>, <code>get</code>, <code>is</code>, <code>list-surfaces</code>, on X11 and Wayland</td><td></td><td></td></tr>+ <tr><td>Ref actions</td><td><code>click</code>, <code>right-click</code>, <code>type</code>, <code>set-value</code>, <code>clear</code>, <code>select</code>, <code>toggle</code>, <code>check</code>, <code>uncheck</code>, <code>expand</code>, <code>collapse</code>, <code>scroll-to</code>, when the element exposes the AT-SPI capability</td><td><code>focus</code>; <code>type</code> into a terminal text node; some Qt and libadwaita combos for <code>select</code></td><td>An element with no semantic route refuses and never falls back to physical input</td></tr>+ <tr><td>Wheel scrolling</td><td></td><td><code>scroll</code>, <code>mouse-wheel</code>, X11 only</td><td>Headless <code>scroll</code>: <code>POLICY_DENIED</code></td></tr>+ <tr><td>Pointer gestures</td><td></td><td><code>double-click</code>, <code>triple-click</code>, <code>hover</code>, <code>drag</code>, <code>mouse-click</code>, <code>mouse-move</code>, X11 only</td><td>Wayland: <code>ACTION_NOT_SUPPORTED</code>, cause <code>wayland_session</code></td></tr>+ <tr><td>Keyboard</td><td><code>press</code> on X11 and Mutter Wayland. A scoped headless <code>press</code> needs the target window already active</td><td>A scoped <code>press</code> to a background app (X11)</td><td>Blocked combos such as <code>alt+f4</code> without <code>--force</code></td></tr>+ <tr><td>Held input</td><td></td><td></td><td><code>key-down</code>, <code>key-up</code>, <code>mouse-down</code>, <code>mouse-up</code></td></tr>+ <tr><td>App and window</td><td><code>launch</code>, <code>list-apps</code>, <code>list-windows</code> on X11 and Wayland; window control and graceful <code>close-app</code> on X11</td><td></td><td><code>focus-window</code> and window control on Wayland: <code>ACTION_NOT_SUPPORTED</code></td></tr>+ <tr><td>Capture</td><td><code>screenshot</code>, <code>list-displays</code></td><td></td><td>X11 under a compositing window manager (GNOME): display and <code>--screen</code> captures return <code>PLATFORM_NOT_SUPPORTED</code> (<code>details.reason: "compositing"</code>); capture one window instead. Wayland: portal consent on first use, and window targets are <code>PLATFORM_NOT_SUPPORTED</code></td></tr>+ <tr><td>Clipboard</td><td><code>clipboard-get</code>, <code>clipboard-set</code>, <code>clipboard-clear</code> (text, images, file lists)</td><td></td><td>Missing helper or <code>wl-clipboard</code>: <code>PLATFORM_NOT_SUPPORTED</code></td></tr>+ <tr><td>Wait</td><td>All modes; <code>--notification</code> on GNOME</td><td></td><td></td></tr>+ <tr><td>Notifications</td><td><code>list-notifications</code>, even with the list closed</td><td>Every dismiss and action, on X11</td><td>GNOME Shell only; otherwise <code>PLATFORM_NOT_SUPPORTED</code></td></tr>+ <tr><td>Shell surfaces</td><td><code>snapshot --surface system-tray</code> with a StatusNotifierWatcher</td><td><code>open-system-surface</code> for <code>action-center</code>, and for <code>system-tray</code> when a StatusNotifierWatcher is present</td><td><code>quick-settings</code>, <code>taskbar</code>, <code>start-menu</code>, and <code>system-tray-overflow</code> refuse</td></tr>+ <tr><td>System</td><td><code>status</code>, <code>permissions</code>, <code>version</code>, <code>batch</code>, <code>skills</code>, <code>session</code>, <code>trace</code>, <code>cursor-overlay</code></td><td></td><td>Wayland: the overlay setting saves with <code>rendered: false</code></td></tr>+ </tbody>+</table>++## App naming++`--app` takes the name `list-apps` prints, such as `gnome-calculator`, or a desktop-entry name or id backed by a verified executable, such as `Files`. It never matches a window title.++```json+{ "bundle_id": "org.gnome.Calculator", "name": "gnome-calculator", "pid": 8255, "presentation": "foreground", "process_instance": "6d91df60:28340" }+```++`list-windows --app` is an exact, case-insensitive match; `list-apps --app` also matches a substring. Window ids are opaque strings such as `w-1.11-org-gnome-Calculator-a11y-...`, valid for the life of the window's process. Several instances of one app share a name; pick one with `--window-id`. `launch` accepts an absolute path, a desktop id, a bare command, or a desktop entry name.++## Surfaces++`supported_surfaces` lists `window`, `sheet`, `alert`, and `menu`, plus GNOME Shell kinds the session can resolve. After an opener, read `data.surfaces`. A GTK popover appears asynchronously, so if it is absent, run `wait --menu` before you assume the opener failed. A list-backed GTK4 dropdown is part of the window tree, not a menu surface. See [Surfaces](/desktop/surfaces).++## Chromium, Qt, and Electron++An app appears in `list-apps` only when its toolkit registered on the accessibility bus.++<table>+ <thead>+ <tr><th>App</th><th>Needs</th></tr>+ </thead>+ <tbody>+ <tr><td>GTK3, GTK4</td><td>Nothing. An app that started before the bus never registers: restart it</td></tr>+ <tr><td>Qt</td><td><code>QT_ACCESSIBILITY=1</code> in its environment</td></tr>+ <tr><td>Chromium browsers</td><td><code>--force-renderer-accessibility</code>; in a bare session without a settings daemon, also <code>--env ACCESSIBILITY_ENABLED=1</code> on <code>launch</code></td></tr>+ <tr><td>Electron</td><td>No flag. <code>--no-sandbox</code> where <code>chrome-sandbox</code> is not setuid</td></tr>+ </tbody>+</table>++```bash+agent-desktop launch google-chrome --arg=--force-renderer-accessibility+```++To drive the web contents with agent-browser instead, launch the app with `--cdp`; see [Chromium and Electron apps](/desktop/guides/chromium-and-electron). GTK apps nest deeply with unnamed `group` wrappers that `-i --compact` keeps; read past them, or let a skeleton find the drill targets. Electron native dialogs are not on the AT-SPI tree.++## Troubleshooting++<table>+ <thead>+ <tr><th>Symptom</th><th>Cause</th><th>Fix</th></tr>+ </thead>+ <tbody>+ <tr><td>Empty <code>supported_surfaces</code>, or <code>PLATFORM_NOT_SUPPORTED</code> about the AT-SPI bus</td><td>The session bus or accessibility bus is unreachable</td><td>Run inside the desktop session; see the four causes above</td></tr>+ <tr><td><code>list-apps</code> or <code>snapshot</code> returns <code>ACTION_NOT_SUPPORTED</code>, "The native window type of accessibility frame owned by pid N could not be proven"</td><td>No window manager is running, so windows cannot be matched to their X11 clients</td><td>Run inside a real desktop session, or start a window manager</td></tr>+ <tr><td>The app runs but <code>--app</code> finds nothing</td><td>The app is not on the bus, or the name is wrong</td><td>Use the <code>list-apps</code> name, and see the toolkit table</td></tr>+ <tr><td>The window appears but <code>snapshot</code> is thin</td><td>The content is not ready</td><td><code>wait --window</code>, then <code>wait --text</code>, and raise <code>--timeout-ms</code></td></tr>+ <tr><td><code>ACTION_FAILED</code>, cause <code>frame_not_active</code>, on a scoped <code>press</code></td><td>The target window is not active and focus changes are not allowed</td><td>Bring the window forward, or pass <code>--headed</code> if focus changes are permitted</td></tr>+ <tr><td><code>ACTION_FAILED</code>, cause <code>blocked_by_modal_dialog</code></td><td>A modal dialog or popover blocks the window</td><td>Read it with <code>snapshot --surface</code> and answer or dismiss it</td></tr>+ <tr><td><code>ACTION_FAILED</code>, cause <code>grab_focus_rejected</code>, on <code>focus</code></td><td>A GTK4 app rejects <code>Component.GrabFocus</code></td><td>Focus its window with <code>focus-window</code></td></tr>+ <tr><td>Two quick <code>click</code> calls on one GTK4 button act once</td><td>GTK4 reads clicks less than about 250 ms apart as one</td><td>Wait for the effect between clicks</td></tr>+ <tr><td><code>--menu-closed</code> returns at once</td><td>The menu never opened</td><td>Wait for <code>--menu</code> first</td></tr>+ <tr><td><code>screenshot</code> returns <code>ACTION_FAILED</code> with <code>details.reason: "covered"</code></td><td>A non-compositing window manager cannot capture a covered window</td><td>Raise it with <code>focus-window</code>; on a non-compositing window manager, capture the display with <code>--screen 0</code></td></tr>+ <tr><td><code>INTERNAL</code>, "private file parent is accessible by group or other users"</td><td>The state root is not private</td><td><code>chmod 700</code> the state root</td></tr>+ </tbody>+</table>++More cases are in `agent-desktop skills get linux troubleshooting`.diff --git a/apps/docs/content/docs/platforms/macos.mdx b/apps/docs/content/docs/platforms/macos.mdxnew file mode 100644index 000000000..05c9a3a0f--- /dev/null+++ b/apps/docs/content/docs/platforms/macos.mdx@@ -0,0 +1,102 @@+---+title: macOS+navTitle: macOS+description: Requirements, permissions, per-command capabilities, app naming, surfaces, and troubleshooting for agent-desktop on macOS.+---++agent-desktop reads macOS apps through the Accessibility (AX) API. The loop, refs, JSON envelope, sessions, and traces match every platform, so this page covers only what differs on macOS. The macOS behavior here is checked against the macOS adapter, its tests, and the macOS skill (`agent-desktop skills get macos`); it was not run for these docs.++## Requirements++- macOS 13 or later, Intel or Apple Silicon.+- Accessibility permission for the app that launches agent-desktop, such as Terminal, iTerm2, VS Code, or your agent's host app. If System Settings lists the `agent-desktop` binary separately, grant it too.+- Screen Recording permission, only for `screenshot` and for `session start --screenshots`.+- Automation permission for System Events, only where a command reports it missing, such as opening Notification Center.++## Grant and check permissions++The grant belongs to the app that launched agent-desktop, not to the shell. A different terminal or an IDE needs its own grant.++1. Run `agent-desktop permissions`. It does not prompt.+2. If a permission is `denied`, run `agent-desktop permissions --guide`. It opens System Settings at the missing permission with a panel that shows which app to add, and returns at once with `data.guide` set to `started`, `already_running`, or `not_needed`.+3. If the guide cannot run, open **System Settings > Privacy & Security > Accessibility**, add the launching app, and turn it on.+4. Run `agent-desktop permissions` again and confirm `granted`. The app does not need a restart.++```json+{+ "version": "2.5",+ "ok": true,+ "command": "permissions",+ "data": {+ "accessibility": { "state": "granted" },+ "automation": { "state": "unknown" },+ "screen_recording": { "state": "granted" }+ }+}+```++`automation` stays `unknown` until macOS would need to prompt. `permissions --request` is the only path that prompts, and it covers Automation; `--guide` covers Accessibility and Screen Recording. Under tmux or SSH there is no launching app, so add the terminal app that started tmux by hand.++## What works headless++Ref actions are headless by default. Under `--headed`, `click`, `right-click`, `type`, `clear`, and `scroll` become physical first: core focuses the exact window, then a real click, key, or wheel event goes to the verified point. `expand`, `collapse`, `set-value`, `select`, `toggle`, `check`, `uncheck`, `focus`, and `scroll-to` stay semantic. See [Headed mode](/desktop/guides/headed-mode).++<table>+ <thead>+ <tr><th>Group</th><th>Works headless</th><th>Needs <code>--headed</code></th><th>Fails closed or not supported</th></tr>+ </thead>+ <tbody>+ <tr><td>Observation</td><td><code>snapshot</code>, <code>find</code>, <code>get</code>, <code>is</code>, <code>list-surfaces</code>, <code>list-displays</code></td><td></td><td></td></tr>+ <tr><td>Capture</td><td><code>screenshot</code>, with Screen Recording permission</td><td></td><td></td></tr>+ <tr><td>Ref actions</td><td><code>click</code>, <code>right-click</code>, <code>type</code>, <code>clear</code>, <code>scroll</code>, <code>expand</code>, <code>collapse</code>, <code>set-value</code>, <code>select</code>, <code>toggle</code>, <code>check</code>, <code>uncheck</code>, <code>focus</code>, <code>scroll-to</code></td><td>None required</td><td></td></tr>+ <tr><td>Multi-click and pointer</td><td><code>double-click</code> when the element offers <code>AXOpen</code></td><td><code>double-click</code>, <code>triple-click</code>, <code>hover</code>, <code>drag</code>, <code>mouse-move</code>, <code>mouse-click</code>, <code>mouse-wheel</code></td><td>Headless: <code>POLICY_DENIED</code></td></tr>+ <tr><td>Keyboard</td><td><code>press</code>, always physical keyboard input; it never runs a menu item, so <code>click</code> the item instead</td><td></td><td>Quit shortcuts such as <code>cmd+q</code>: <code>POLICY_DENIED</code> without <code>--force</code></td></tr>+ <tr><td>Held input</td><td></td><td></td><td><code>key-down</code>, <code>key-up</code>, <code>mouse-down</code>, <code>mouse-up</code></td></tr>+ <tr><td>App and window</td><td><code>launch</code>, <code>close-app</code>, <code>list-apps</code>, <code>list-windows</code>, <code>focus-window</code>, <code>resize-window</code>, <code>move-window</code>, <code>minimize</code>, <code>maximize</code>, <code>restore</code></td><td></td><td></td></tr>+ <tr><td>Clipboard</td><td><code>clipboard-get</code>, <code>clipboard-set</code> (read back: <code>delivered_verified</code>), <code>clipboard-clear</code></td><td></td><td></td></tr>+ <tr><td>Wait</td><td>All modes. <code>wait --notification</code> sees only an already-open Notification Center</td><td></td><td></td></tr>+ <tr><td>Notifications</td><td><code>list-notifications</code> while Notification Center is open</td><td>Listing while it is closed, and every dismiss and action</td><td>Headless listing with the center closed: <code>POLICY_DENIED</code></td></tr>+ <tr><td>Shell surfaces</td><td></td><td></td><td><code>open-system-surface</code>: <code>PLATFORM_NOT_SUPPORTED</code></td></tr>+ <tr><td>System</td><td><code>status</code>, <code>permissions</code>, <code>version</code>, <code>batch</code>, <code>skills</code>, <code>session</code>, <code>cursor-overlay</code>, <code>trace</code></td><td></td><td></td></tr>+ </tbody>+</table>++Judge delivery by observation. AX return codes do not prove an effect: an app can return success from an action that does nothing, so re-read with `get`, `is`, or a snapshot.++## App naming++`--app` takes the display name `list-apps` prints, such as `"System Settings"` or `"TextEdit"`. `launch` also accepts a bundle ID such as `com.apple.TextEdit`. Window ids such as `w-4521` stay valid for the life of the window; find them with `list-windows`.++## Surfaces++`supported_surfaces` lists `window`, `focused`, `menu`, `menubar`, `sheet`, `popover`, and `alert`. Use `--surface menubar` for the File, Edit, and View menus and for menu bar status items. macOS has no shell surfaces; Notification Center is reached through the notification commands. See [Surfaces](/desktop/surfaces).++## Keys and notifications++- The primary modifier is `cmd`: `press cmd+c`. Punctuation keys work as the symbol or by name (`comma`, `period`, `slash`).+- `cmd+q`, `cmd+shift+q`, `cmd+alt+esc`, `ctrl+cmd+q`, and `cmd+shift+delete` return `POLICY_DENIED` unless you pass `--force`. To quit an app, use `close-app`.+- `press cmd+s --app "TextEdit"` sends keys to one app without focusing it.+- When agent-desktop opens Notification Center, it closes it afterward and restores the previous focus. Pass `--expected-app` and `--expected-title` on a single dismiss or action, because the stack shifts. Use `wait --notification --app "App"` for banners that vanish before you can list them.++## Chromium and Electron++agent-desktop turns on web accessibility in a Chromium renderer when it needs it. For a dense running app, take a skeleton and drill with `--root`. For the web contents of an Electron app you can launch fresh, `launch "App" --cdp` opens a DevTools endpoint for agent-browser. See [Chromium and Electron apps](/desktop/guides/chromium-and-electron).++## Troubleshooting++<table>+ <thead>+ <tr><th>Symptom</th><th>Cause</th><th>Fix</th></tr>+ </thead>+ <tbody>+ <tr><td><code>PERM_DENIED</code>, or <code>permissions</code> shows <code>denied</code></td><td>The launching app has no Accessibility permission, or no Screen Recording permission for <code>screenshot</code></td><td>Follow the grant steps above</td></tr>+ <tr><td>Few nodes or no refs</td><td>Custom-rendered UI, or a Chromium renderer still settling</td><td>Check permissions, drop <code>-i</code>, raise <code>--timeout-ms</code>, and run <code>list-surfaces</code> in case the content is in a sheet</td></tr>+ <tr><td><code>complete: false</code> or a slow snapshot</td><td>A deep tree ran out of budget</td><td>Use <code>find</code>, or a skeleton and <code>--root</code>. See <a href="/desktop/skeleton-and-drill-down">Skeleton and drill-down</a></td></tr>+ <tr><td><code>APP_UNRESPONSIVE</code> after <code>right-click</code> with <code>retry: unsafe</code></td><td><code>AXShowMenu</code> entered modal menu tracking after the menu opened</td><td>Do not retry. Run <code>snapshot --surface menu</code>; for a combo box or menu button, use <code>select</code></td></tr>+ <tr><td><code>select</code> cannot confirm the choice</td><td>It needs a closed-to-open menu change, and a menu was already open</td><td>Dismiss the open menu, then run <code>select</code> again</td></tr>+ <tr><td><code>WINDOW_NOT_FOUND</code></td><td>The app has no open window</td><td><code>launch "App"</code> with <code>--activate</code>, then <code>list-windows --app "App"</code></td></tr>+ <tr><td>A shortcut does nothing</td><td><code>ctrl</code> used where macOS uses <code>cmd</code>, or the keys went to another app</td><td>Use <code>cmd+...</code>, or scope with <code>--app</code></td></tr>+ </tbody>+</table>++More cases are in `agent-desktop skills get macos troubleshooting`.diff --git a/apps/docs/content/docs/platforms/meta.json b/apps/docs/content/docs/platforms/meta.jsonnew file mode 100644index 000000000..d30c90dbb--- /dev/null+++ b/apps/docs/content/docs/platforms/meta.json@@ -0,0 +1,4 @@+{+ "title": "Platforms",+ "pages": ["macos", "windows", "linux"]+}diff --git a/apps/docs/content/docs/platforms/windows.mdx b/apps/docs/content/docs/platforms/windows.mdxnew file mode 100644index 000000000..f7a22af51--- /dev/null+++ b/apps/docs/content/docs/platforms/windows.mdx@@ -0,0 +1,104 @@+---+title: Windows+navTitle: Windows+description: Requirements, permissions and elevation, per-command capabilities, app naming, surfaces, PowerShell notes, and troubleshooting for agent-desktop on Windows.+---++agent-desktop reads Windows apps through UI Automation (UIA). The loop, refs, JSON envelope, sessions, and traces match every platform, so this page covers only what differs on Windows. The Windows behavior here is checked against the Windows adapter, its tests, and the Windows skill (`agent-desktop skills get windows`); it was not run for these docs. Examples elsewhere are POSIX shell; the PowerShell forms are in [Use PowerShell](#use-powershell).++## Requirements++- Windows 10 1809 or later, or Windows Server 2019 or later, on x64 or ARM64.+- The interactive desktop session of the signed-in user. Session 0 (services and SYSTEM tasks), Server Core, the secure desktop (UAC prompts and the sign-in screen), a locked desktop, and another user's session are not supported.+- The binary is unsigned. SmartScreen can warn on a browser download, antivirus can quarantine it, and Smart App Control on a clean Windows 11 install blocks it.++## Permissions and elevation++Windows has no grant dialog for UI Automation; access is controlled by integrity level.++- Apps at your terminal's integrity level need no grant. `permissions` reports `accessibility: granted` when UIA answers, and `automation: not_required`. `permissions --guide` returns `PLATFORM_NOT_SUPPORTED`.+- An app running as administrator can be read but not driven from a lower-integrity terminal, because User Interface Privilege Isolation (UIPI) blocks the input. agent-desktop compares the process tokens before sending anything and returns `PERM_DENIED` with `E_ACCESSDENIED` in `platform_detail`. Run agent-desktop from a terminal elevated to the same level.+- Elevated and non-elevated runs cannot share a state root; the second fails with `INTERNAL`, "private file parent is owned by a foreign principal". Give the elevated run its own `AGENT_DESKTOP_HOME`.++## What works headless++Ref actions are semantic UIA calls headless and under `--headed`, except the ones that are physical or take focus. See [Headed mode](/desktop/guides/headed-mode).++<table>+ <thead>+ <tr><th>Group</th><th>Works headless</th><th>Needs <code>--headed</code></th><th>Fails closed or not supported</th></tr>+ </thead>+ <tbody>+ <tr><td>Observation and capture</td><td><code>snapshot</code>, <code>find</code>, <code>get</code>, <code>is</code>, <code>screenshot</code>, <code>list-surfaces</code>, <code>list-displays</code></td><td></td><td></td></tr>+ <tr><td>Ref actions</td><td><code>click</code>, <code>set-value</code>, <code>clear</code>, <code>select</code>, <code>toggle</code>, <code>check</code>, <code>uncheck</code>, <code>expand</code>, <code>collapse</code>, <code>scroll</code>, <code>scroll-to</code></td><td><code>right-click</code>, <code>type</code>, <code>focus</code></td><td>Headless <code>right-click</code> and <code>type</code>: <code>POLICY_DENIED</code>. Use <code>set-value</code> to write text headless</td></tr>+ <tr><td>Multi-click and pointer</td><td></td><td><code>double-click</code>, <code>triple-click</code>, <code>hover</code>, <code>drag</code>, <code>mouse-click</code>, <code>mouse-move</code>, <code>mouse-wheel</code></td><td>Headless: <code>POLICY_DENIED</code></td></tr>+ <tr><td>Keyboard</td><td><code>press</code></td><td>A scoped <code>press --app</code> to an app that is not frontmost</td><td>Blocked shortcuts without <code>--force</code></td></tr>+ <tr><td>Held input</td><td></td><td></td><td><code>key-down</code>, <code>key-up</code>, <code>mouse-down</code>, <code>mouse-up</code></td></tr>+ <tr><td>App and window</td><td><code>launch</code>, <code>close-app</code>, <code>list-windows</code>, <code>list-apps</code>, <code>focus-window</code>, <code>resize-window</code>, <code>move-window</code>, <code>minimize</code>, <code>maximize</code>, <code>restore</code></td><td></td><td><code>close-app</code> on <code>explorer.exe</code> and other protected images: <code>INVALID_ARGS</code></td></tr>+ <tr><td>Clipboard</td><td><code>clipboard-get</code>, <code>clipboard-set</code>, <code>clipboard-clear</code> (text and images)</td><td></td><td></td></tr>+ <tr><td>Wait</td><td>All modes except notifications with the Action Center closed</td><td><code>--notification</code> when the Action Center is closed</td><td></td></tr>+ <tr><td>Notifications</td><td><code>list-notifications</code> while the Action Center is open</td><td>Listing while it is closed, and every dismiss and action</td><td>Headless on a closed center: <code>POLICY_DENIED</code></td></tr>+ <tr><td>Shell surfaces</td><td><code>snapshot --surface KIND</code> on a surface that is already present</td><td><code>open-system-surface</code> for <code>start-menu</code>, <code>taskbar</code>, <code>system-tray</code>, <code>system-tray-overflow</code>, <code>action-center</code></td><td><code>quick-settings</code>: <code>PLATFORM_NOT_SUPPORTED</code>, naming <code>action-center</code></td></tr>+ <tr><td>System</td><td><code>status</code>, <code>permissions</code>, <code>version</code>, <code>batch</code>, <code>skills</code>, <code>session</code>, <code>cursor-overlay</code>, <code>trace</code></td><td></td><td></td></tr>+ </tbody>+</table>++## App naming++- `launch` takes an absolute path, or a bare name under System32 or the Windows directory, with or without `.exe` (`notepad` or `notepad.exe`). It does not resolve a display name such as "Google Chrome".+- For a running app, pass the name `list-apps` prints to `--app`, such as `notepad.exe`.+- Window ids are `w-` followed by the window handle. A hosted (UWP) app is reported through its `ApplicationFrameHost` frame.+- A window behind another window is drivable. A minimized one is not: every element reports `offscreen`. Run `restore --app IMAGE` and snapshot again, instead of `focus-window`, which steals the user's foreground.++## Surfaces++`supported_surfaces` lists `window`, `focused`, `sheet` (a Chromium modal), `menu`, and the shell kinds `start-menu`, `taskbar`, `system-tray`, `system-tray-overflow`, and `action-center`. There is no `menubar` surface. `snapshot --surface KIND` reads a shell surface without `--app` and without `--headed`; a closed one returns `WINDOW_NOT_FOUND` with a suggestion that names `open-system-surface`. The `menu` detector covers classic Win32, WPF, and Chromium or Electron menus, but not WinUI 3 or MSIX hosts, so read "no menu" as "not detected" there. See [Surfaces](/desktop/surfaces).++## Use PowerShell++PowerShell reads a bare `@token` as its splatting operator and drops the argument before agent-desktop sees it. Quote every ref:++```powershell+agent-desktop set-value '@s8f3k2p9:e1' "hello"+$env:AGENT_DESKTOP_HOME = "$env:TEMP\ad-scratch"+$start = agent-desktop session start | ConvertFrom-Json+$env:AGENT_DESKTOP_SESSION = $start.data.session_id+```++Use `$env:NAME = 'value'` instead of `export`, and `| ConvertFrom-Json` instead of `jq`. An unquoted ref fails with `INVALID_ARGS`. `cmd.exe` and bash need no quoting.++## Keys++- `cmd` and `meta` are the Windows key, so `meta+c` is a shell shortcut. Write `ctrl+c` to copy.+- `alt+f4`, `win+l`, `win+d`, `alt+tab`, `win+r`, `win+x`, `win+e`, `ctrl+shift+esc`, and their supersets are refused without `--force`. `ctrl+alt+delete` cannot be synthesized at all.+- `type` is keystroke synthesis and needs `--headed`; use `set-value` headless.+- `press --app` writes to the foreground input queue and cannot target one background process.++## Chromium and Electron++Chromium 138 and later exposes a full UIA tree with no flag, but the first read starts the renderer's accessibility build and returns a small fraction of the tree. A cold launch takes 10 to 25 seconds to settle.++- Pass a longer `--timeout-ms` to `snapshot` instead of concluding the tree is empty.+- A settled tree with boundary nodes carrying `children_count` and no controls is a depth effect: drill into a boundary with `snapshot --root`.+- For the web contents of an app you can launch fresh, `launch --cdp` opens a DevTools port for agent-browser; see [Chromium and Electron apps](/desktop/guides/chromium-and-electron).+- A WPF window read before its automation peer exists can bind an empty generic provider. Take a new snapshot after a few seconds.++## Troubleshooting++<table>+ <thead>+ <tr><th>Symptom</th><th>Cause</th><th>Fix</th></tr>+ </thead>+ <tbody>+ <tr><td>A Chromium or Electron app returns far fewer nodes than it shows</td><td>The first read came before the renderer settled</td><td><code>snapshot --timeout-ms 30000</code></td></tr>+ <tr><td><code>PERM_DENIED</code> with <code>E_ACCESSDENIED</code></td><td>The target runs at a higher integrity level</td><td>Run the terminal elevated to the target's level</td></tr>+ <tr><td><code>INVALID_ARGS</code> on a ref in PowerShell</td><td>An unquoted <code>@</code> ref was eaten as splatting</td><td>Quote the ref in single quotes</td></tr>+ <tr><td><code>POLICY_DENIED</code> from <code>open-system-surface</code> or a notification command</td><td>The command raises shell chrome, which takes the foreground</td><td>Pass <code>--headed</code>, or open the surface yourself first</td></tr>+ <tr><td><code>wait --notification</code> times out while toasts are posted</td><td>The Action Center collects a toast only while open</td><td>Hold the center open, or confirm with <code>list-notifications</code> while it is open</td></tr>+ <tr><td>A hosted app reads as <code>ApplicationFrameHost</code></td><td>The app is suspended</td><td>Activate the app so it resumes, then list again</td></tr>+ <tr><td>The binary will not start</td><td>SmartScreen, antivirus quarantine, or Smart App Control</td><td>Choose <strong>More info</strong>, then <strong>Run anyway</strong>; restore a quarantined file after checking its SHA-256 checksum</td></tr>+ <tr><td>Headed coordinates land offset on a scaled display</td><td>A host process locked an incompatible DPI awareness</td><td>Run from a plain terminal and prefer refs to <code>--xy</code></td></tr>+ </tbody>+</table>++More cases are in `agent-desktop skills get windows troubleshooting`.