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.

FlagDefaultMeaning
--headedoffPrefer physical delivery for natural input commands and allow focus and cursor side effects. The default is strict headless semantic delivery. See Headed mode.
--session IDnoneSelect the snapshot namespace and trace. Overrides AGENT_DESKTOP_SESSION. See Sessions.
--agent-id IDnoneSubagent id within the session. Overrides AGENT_DESKTOP_AGENT_ID. Required for desktop actions in a multi-agent session.
--trace PATHoffAppend trace events as JSONL to this file instead of the session's trace. See Traces.
--trace-strictoffFail when trace setup or a pre-action write fails. Requires --trace or a tracing session.
--wait-for SELECTOR, -wnoneAfter the command, poll until an element matches. See Post-action wait flags.
--wait-for-gone SELECTORnoneAfter the command, poll until no element matches.
--wait-timeout MS30000Longest wait for the two flags above.
--verbose, -voffWrite debug logs to stderr. Stdout stays one JSON envelope.
--debug, --screenshot PATH.htmloffWrite a visual debug HTML file for snapshot or click. Each requires the other. See Traces.
--help, -h; --version, -VPrint 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-for succeeds with snapshot data (snapshot_id, ref_count, tree, and so on) plus elapsed_ms and matched_selector. For an action, the action's own report moves under data.after_action.
  • --wait-for-gone succeeds with matched_selector, gone: true, target_absent: true, and elapsed_ms, with the action's report under after_action.
  • On expiry the command fails with TIMEOUT, details.kind: "wait_timeout", details.selector, and details.timeout_ms. After an action, details.after_action holds its report, and the error keeps the action's own delivery disposition, so a timeout does not make the action safe to repeat.
  • If a ref action returns delivery_uncertain, error.details.post_action_observation records 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-timeout separately from the action timeout.
  • A temporary ACTION_NOT_SUPPORTED error with details.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.
agent-desktop click @s8f3k2p9:e5 --wait-for ":Saved" --wait-timeout 5000
agent-desktop click @s8f3k2p9:e5 --wait-for-gone "progressindicator"
agent-desktop snapshot --app gnome-calculator -w "button:7"

Environment variables

VariableMeaning
AGENT_DESKTOP_HOMERelocates the state root. Must be an absolute path.
AGENT_DESKTOP_SESSIONSession id used when --session is not passed. session start prints the line that sets it. An empty value is INVALID_ARGS.
AGENT_DESKTOP_AGENT_IDSubagent id used when --agent-id is not passed.
AGENT_DESKTOP_MACOS_HELPER_PATHmacOS only. Absolute path to the packaged agent-desktop-macos-helper. The npm launcher sets it.
RUST_LOGLog 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 0700 on macOS and Linux.

On macOS and Linux the state root must stay private. A root that is group-writable or readable by other users makes commands that write there fail with 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:

export AGENT_DESKTOP_HOME="$(mktemp -d)"   # absolute and private
agent-desktop status                       # data.state_root shows this path

Layout

~/.agent-desktop/                     state root
  latest_snapshot_id                  newest snapshot in the global namespace
  snapshots/
    s8f3k2p9/refmap.json              one refmap per snapshot
  tmp/                                clipboard-get images outside a session
  sessions/
    run-1793352720537-17009-0/        one directory per session
      session.json                    manifest
      latest_snapshot_id
      snapshots/s8f3k2p9/refmap.json  the session's own namespace
      trace/                          JSONL segments, one per process
      clipboard/                      clipboard-get images inside the session
  • Snapshots. Each snapshot writes snapshots/<id>/refmap.json. Size and retention limits are in Where refs are stored.
  • Sessions. session start creates sessions/<id>/ with its own snapshots/, so one session's refs are invisible to another. session gc deletes ended sessions with their traces. See Sessions.
  • Traces. A tracing session writes one JSONL segment per process under trace/, plus screens/ and refmaps/ 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.