Configuration
agent-desktop has no configuration file. Behavior comes from global flags on each command, a few environment variables, and the state root directory where snapshots, sessions, and traces live.
Global flags
Global flags work before or after the command name, so agent-desktop --headed click REF and agent-desktop click REF --headed are the same. agent-desktop --help lists them.
| Flag | Default | Meaning |
|---|---|---|
--headed | off | Prefer physical delivery for natural input commands and allow focus and cursor side effects. The default is strict headless semantic delivery. See Headed mode. |
--session ID | none | Select the snapshot namespace and trace. Overrides AGENT_DESKTOP_SESSION. See Sessions. |
--agent-id ID | none | Subagent id within the session. Overrides AGENT_DESKTOP_AGENT_ID. Required for desktop actions in a multi-agent session. |
--trace PATH | off | Append trace events as JSONL to this file instead of the session's trace. See Traces. |
--trace-strict | off | Fail when trace setup or a pre-action write fails. Requires --trace or a tracing session. |
--wait-for SELECTOR, -w | none | After the command, poll until an element matches. See Post-action wait flags. |
--wait-for-gone SELECTOR | none | After the command, poll until no element matches. |
--wait-timeout MS | 30000 | Longest wait for the two flags above. |
--verbose, -v | off | Write debug logs to stderr. Stdout stays one JSON envelope. |
--debug, --screenshot PATH.html | off | Write a visual debug HTML file for snapshot or click. Each requires the other. See Traces. |
--help, -h; --version, -V | Print help or the version as text. The version command prints it as JSON. |
Post-action wait flags
--wait-for, --wait-for-gone, and --wait-timeout make a command wait for the UI to show its effect. The command runs first; then the flag polls the accessibility tree until the selector is satisfied or the timeout ends. Waiting without sleeps compares them with the wait command.
Selector. role:text, split at the first :. button matches by role, :Saved by text, and button:Save by both. Text is a case-insensitive substring of an element's name, value, or description. An empty selector returns INVALID_ARGS before the command runs.
Commands that accept them. snapshot, press, hover, drag, and every ref action (click, double-click, triple-click, right-click, type, set-value, clear, focus, select, toggle, check, uncheck, expand, collapse, scroll, scroll-to). Every other command returns INVALID_ARGS. snapshot --root cannot combine with them, and a batch entry never inherits them.
Which owner is polled. For snapshot, the selected surface owner. For a ref action, the original process. Application-owned refs keep their source surface; a macOS menu or menubar ref is observed through its application without requiring a document window. Window-owned refs observe their original pinned window, even when captured from sheet, alert, popover, focused, or a window-owned menu such as a Linux menu. The wait reads the whole window, so a selector elsewhere in the parent can satisfy --wait-for early or keep --wait-for-gone from succeeding. On Linux, GTK3 context menus and Chromium popups can be exposed outside that window tree, so a gone wait cannot establish that a popup outside the observed scope was dismissed. To observe the overlay itself, run a separate snapshot with the desired --surface and wait selector. For press, the --app or --window-id window, else the focused one. For drag, the destination window, or the source with --wait-for-scope from.
Results.
--wait-forsucceeds with snapshot data (snapshot_id,ref_count,tree, and so on) pluselapsed_msandmatched_selector. For an action, the action's own report moves underdata.after_action.--wait-for-gonesucceeds withmatched_selector,gone: true,target_absent: true, andelapsed_ms, with the action's report underafter_action.- On expiry the command fails with
TIMEOUT,details.kind: "wait_timeout",details.selector, anddetails.timeout_ms. After an action,details.after_actionholds its report, and the error keeps the action's own delivery disposition, so a timeout does not make the action safe to repeat. - If a ref action returns
delivery_uncertain,error.details.post_action_observationrecords read-only evidence from the original process and its application-owned source surface or pinned window. Its fields and outcomes do not change the original error or unsafe retry disposition. The wait uses--wait-timeoutseparately from the action timeout. - A temporary
ACTION_NOT_SUPPORTEDerror withdetails.kind: "window_without_accessibility_element"is retried during wait polling. For--wait-for-gone, that error does not count as absence; the wait succeeds only after a complete selector read finds no match or the app/window lookup confirms the target is gone.
Environment variables
| Variable | Meaning |
|---|---|
AGENT_DESKTOP_HOME | Relocates the state root. Must be an absolute path. |
AGENT_DESKTOP_SESSION | Session id used when --session is not passed. session start prints the line that sets it. An empty value is INVALID_ARGS. |
AGENT_DESKTOP_AGENT_ID | Subagent id used when --agent-id is not passed. |
AGENT_DESKTOP_MACOS_HELPER_PATH | macOS only. Absolute path to the packaged agent-desktop-macos-helper. The npm launcher sets it. |
RUST_LOG | Log filter for stderr logs. A valid value replaces the default level. |
An invalid value returns INVALID_ARGS with not_delivered, and nothing runs. In PowerShell, set a variable with $env:AGENT_DESKTOP_HOME = "$env:TEMP\ad-scratch". On Linux the adapter also reads the desktop session's DISPLAY, WAYLAND_DISPLAY, XDG_RUNTIME_DIR, and DBUS_SESSION_BUS_ADDRESS; see Linux.
State root
agent-desktop keeps its state under one directory: .agent-desktop in your home directory by default. agent-desktop status reports the resolved path as state_root. AGENT_DESKTOP_HOME replaces the default:
- It must be an absolute path. If it exists, it must be a directory you own and not a symlink.
- It does not need to exist yet; it is created on first use with mode
0700on macOS and Linux.
On macOS and Linux the state root must stay private. A root that is group-writable or readable by other users makes commands that write there fail with PERM_DENIED, "private file parent is accessible by group or other users". Run chmod 700 on it, or let agent-desktop create it. A fresh root per run isolates refs:
Layout
- Snapshots. Each snapshot writes
snapshots/<id>/refmap.json. Size and retention limits are in Where refs are stored. - Sessions.
session startcreatessessions/<id>/with its ownsnapshots/, so one session's refs are invisible to another.session gcdeletes ended sessions with their traces. See Sessions. - Traces. A tracing session writes one JSONL segment per process under
trace/, plusscreens/andrefmaps/with--screenshots. See Traces.
The cross-process interaction lock lives outside the state root (under /tmp on macOS and Linux), so every agent of one user shares it whatever their AGENT_DESKTOP_HOME. Files you name yourself, such as a --trace path or a screenshot path, are also outside it.