Native desktop automation CLI for AI agents. Control any application through OS accessibility trees with structured JSON output and deterministic element refs.
Native desktop automation CLI for AI agents. Control any application through OS accessibility trees with structured JSON output and deterministic element refs.
AGENT DESKTOP
OBSERVE. DECIDE. ACT.
agent-desktop gives any agent reliable computer use on the desktop. Built with Rust, it sees any app's real UI structure through OS accessibility trees and operates it — refs stay stable and actions stay safe to retry, instead of guessing from pixels.
libagent_desktop_ffi): Load once from Python / Swift / Go / Ruby / Node / C instead of forking the CLI per callskills doc loader. The four held-input names are reserved for a stateful daemon and fail closed in the stateless CLI.@s8f3k2p9:e1, @s8f3k2p9:e2)launch --cdp opens a verified DevTools port so any framework that speaks CDP — Playwright, Puppeteer, chrome-remote-interface, agent-browser — can drive the web contents, while native menus, dialogs, and windows stay on the accessibility pathnpm install -g agent-desktop # downloads prebuilt binary automaticallyOr without installing:
npx agent-desktop snapshot --app Finder -igit clone https://github.com/lahfir/agent-desktop
cd agent-desktop
cargo build --release
cp target/release/agent-desktop /usr/local/bin/Requires Rust 1.89+ and macOS 13.0+.
macOS requires Accessibility permission. Screenshots also require Screen Recording permission, and the Notification Center opener requires Automation permission for System Events. Plain permission checks never prompt. Request missing permissions in a bounded isolated helper with:
agent-desktop permissions --request # request missing permissions in an isolated helperPermission fields are explicit objects, for example:
{
"accessibility": { "state": "granted" },
"screen_recording": { "state": "denied", "suggestion": "Grant Screen Recording permission" },
"automation": { "state": "unknown" }
}Automation reports granted, denied, or unknown; unknown means macOS would need to prompt or System Events could not be probed without prompting.
Every GitHub Release ships a prebuilt C-ABI cdylib (libagent_desktop_ffi) for macOS, Linux, and Windows alongside the CLI tarballs. dlopen it and call the functions declared in agent_desktop.h for in-process calls instead of fork-exec per command.
import ctypes
lib = ctypes.CDLL("./lib/libagent_desktop_ffi.dylib")
lib.ad_init(4) # verify ABI major (AD_ABI_VERSION_MAJOR) before any call
adapter = lib.ad_adapter_create()
# observe -> act: ad_snapshot -> parse a qualified ref -> ad_execute_by_ref ...
lib.ad_adapter_destroy(adapter)Full consumer guide — entrypoints, ownership, threading, error-handling, build/link, release archives, and verification: skills/agent-desktop-ffi/.
For dense apps (Slack, VS Code, Notion), use progressive skeleton traversal to minimize token usage:
# 1. Shallow overview — depth-3 map, truncated containers show children_count
agent-desktop snapshot --skeleton --app Slack -i --compact
# Keep snapshot_id, for example s8f3k2p9
# 2. Drill into a region of interest (each truncated branch exposes a safe drill ref)
agent-desktop snapshot --root @e3 --snapshot s8f3k2p9 -i --compact
# 3. Act on an element found in the drill-down
agent-desktop click @e12 --snapshot s8f3k2p9
# 4. Re-drill the same region to verify the state change
agent-desktop snapshot --root @e3 --snapshot s8f3k2p9 -i --compactFor simple apps, a full snapshot is fine:
agent-desktop snapshot --app Finder -i # get interactive elements with refs and snapshot_id
agent-desktop click @e3 --snapshot s8f3k2p9 # click a button by ref
agent-desktop type @e5 --snapshot s8f3k2p9 "quarterly report" # insert text into a field
agent-desktop press cmd+s # keyboard shortcut
agent-desktop snapshot -i # re-observe after UI changesAgent loop: snapshot → decide → act → snapshot → decide → act → ...session_id=$(agent-desktop session start --screenshots | jq -r '.data.session_id')
export AGENT_DESKTOP_SESSION="$session_id"
agent-desktop snapshot --app Finder -i # work inside the explicit session scope
agent-desktop click @s8f3k2p9:e5
agent-desktop trace show --limit 500 # bounded JSON timeline for agents
agent-desktop trace export --out run.html # single-file HTML viewer (works from file://)trace show merges all segment files deterministically and requires no permissions. trace export embeds the timeline plus screenshots as base64 in one static HTML file. Without --out, the HTML is written to the session directory (~/.agent-desktop/sessions//trace-.html), not the current directory; --out overrides the path. Treat exported HTML like a screenshot when artifacts: full was enabled.
Run session start once per agent run to create a trace-enabled session (manifest trace: on by default), then pass the returned ID with global --session or AGENT_DESKTOP_SESSION=. Commands in that explicit scope get automatic JSONL segments under ~/.agent-desktop/sessions//trace/ and share the session's latest-snapshot namespace — no --trace on every call.
For concurrent independent agents, set AGENT_DESKTOP_SESSION= per process. When multiple agents share one session ID, each agent should act on the qualified refs from its own snapshot call rather than assuming the namespace's latest snapshot is unchanged.
Bare --session without a manifest (no session start) still scopes the snapshot namespace only and writes no trace files. Snapshot IDs resolve only inside the selected session namespace; they never trigger a cross-session search.
agent-desktop session start --name release-fix # note data.session_id
export AGENT_DESKTOP_SESSION=
agent-desktop snapshot --app Xcode -i --compact # uses selected session + tracing
agent-desktop wait --element @s8f3k2p9:e9 --predicate actionable --timeout 5000
agent-desktop click @s8f3k2p9:e9
agent-desktop click @e9 --snapshot s2 # legacy bare ref, explicitly pinned
agent-desktop session end "$AGENT_DESKTOP_SESSION"
agent-desktop session gcAgent cursors work in both headless and headed mode, including physical pointer commands. Drags follow the cursor’s curved motion and draw an accent-colored trail while held, then fade after release. Each agent retains its own cursor; the existing interaction lease coordinates the shared OS pointer.
A presentation-only cursor that shows what the agent is about to do. Off by default.
session_id=$(agent-desktop session start --cursor | jq -r '.data.session_id')
export AGENT_DESKTOP_SESSION="$session_id"
agent-desktop snapshot --app Finder -i
agent-desktop click
agent-desktop cursor-overlay disablesession start --cursor turns it on with the default look. cursor-overlay enable does the same for a session that already exists.
Style defaults belong to the session. Set them once; later commands inherit them. Named agents can save their own style using global --agent-id.
agent-desktop --session "$session_id" cursor-overlay enable --label "Opening the menu"
export AGENT_DESKTOP_SESSION="$session_id"For harness subagents on macOS, start one shared session and give each worker a stable ID:
session_id=$(agent-desktop session start --cursor --multi-agent | jq -r '.data.session_id')
export AGENT_DESKTOP_SESSION="$session_id"
# Set a different ID in each subagent's environment:
export AGENT_DESKTOP_AGENT_ID=researcher
agent-desktop cursor-overlay enable --label "Checking details" --accent "#FF3B7B"
agent-desktop snapshot --app Finder -i
agent-desktop click The style command is optional and saves settings for the next presentation without creating a cursor. Each distinct agent ID gets its own cursor on first presentation; three IDs produce three cursors, with no extra coordinator cursor. IDs use 1–64 letters, digits, - or _. Global --agent-id overrides the environment. In multi-agent mode, desktop UI actions require an ID; observations, clipboard operations, and session administration do not. Snapshots remain shared by session, so pin qualified refs and coordinate actions on shared UI. cursor-overlay disable or session end stops every cursor, even when an agent ID is set. To enable this mode on an existing session, run cursor-overlay enable --multi-agent without an agent ID.
| Flag | Meaning | Default |
|---|---|---|
--label TEXT |
Intent text beside the cursor | none |
--max-words N |
Label word limit, 1–12 | 6 |
--fill HEX |
Cursor body | #FFFFFF |
--rim HEX |
Cursor outline | #111318 |
--accent HEX |
Ripple and element outline | #4299FF |
--size N |
Size multiplier, 0.5–4.0 | 1.0 |
--no-ripple |
No ripple on click | ripple on |
--no-highlight |
No element outline on click | outline on |
Behaviour
cursor-overlay disable removes it now. You do not have to end the session.macOS renders it natively. Windows and Linux inherit the adapter's no-op and need only their own renderer against the same core contract.
For a Chromium-based app (Slack, VS Code, Discord, Obsidian, Notion), launch --cdp opens a verified Chrome DevTools Protocol endpoint on the web contents. Any framework that speaks CDP can connect — Playwright, Puppeteer, chrome-remote-interface, agent-browser — with agent-browser preferred for its ref-based agent workflow and bundled electron skill. Native surfaces (menus, dialogs, windows, screenshots) stay on the accessibility path either way.
agent-desktop launch "Obsidian" --cdp{ "app": "Obsidian", "pid": 4821, "cdp": {
"port": 9229,
"http_endpoint": "http://127.0.0.1:9229",
"websocket_url": "ws://127.0.0.1:9229/devtools/browser/",
"product": "Chrome/142.0.7444.265"
},
"suggestion": "Next: run `agent-browser connect 9229` (preferred) or connect any CDP client such as Playwright or Puppeteer. ..." }--cdp needs a fresh launch — an already-running target returns ACTION_FAILED. Run close-app first, confirm the process exited, then launch --cdp again.
The endpoint is pinned to 127.0.0.1. Any local process running as your user can still reach it while it stays open
No open issues yet, or sync has not completed.