macOS 需先授予辅助功能(Accessibility)权限,可用 permissions --guide 引导;ref 绑定所属快照,UI 变化后旧 ref 会返回 STALE_REF 或 AMBIGUOUS_TARGET,需重新快照;多窗口时需用 --window-id 指定目标窗口;PowerShell 中 ref 必须加引号,否则 @token 会被当作 splatting 运算符。
agent-desktop
vercel-labsApache-2.0活跃维护用 Rust 写的命令行工具,让 AI 代理通过 macOS 辅助功能接口直接操作桌面应用,把电脑使用能力接进 Agent 工作流。
Computer use CLI for AI agents
npm install -g agent-desktop
agent-desktop status
agent-desktop permissions --guideREADME 未说明显存或 GPU 要求;运行环境为 macOS 13+(Intel/Apple Silicon)、Windows 10 1809+(x64/ARM64)、Ubuntu 24.04+(x86_64/aarch64,X11 或 Wayland)。
让 AI 代理通过系统无障碍树读写桌面应用,无需截图和像素匹配
用 Rust 写的命令行工具,让 AI 代理通过 macOS 辅助功能接口直接操作桌面应用,把电脑使用能力接进 Agent 工作流。
核心能力
- 把应用无障碍树输出为带 ref 的 JSON 快照
- 用 ref 点击或输入后重新快照验证结果
- 默认无头操作,不移动指针也不抢焦点
- 提供 56 个可执行命令覆盖观察、操作与窗口管理
- 支持以 MCP stdio 服务暴露全部命令为工具
容易踩的坑
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
- v1.2.0最新正式版2026-11-05 · 2026-11-05 02:43 UTC
What's Changed
- feat(macos): select list rows that only their container can select by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/503
- fix(macos): draw the cursor overlay above menus and system panels by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/511
- docs: simplify the README and repo docs by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/481
- docs: document the homebrew-core install by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/524
- feat: agent-desktop mcp by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/519
- fix(macos): ignore exited apps in the workspace inventory by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/371
- fix: preserve partial snapshots after observation expires by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/372
- feat: accept stdin for text commands by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/373
- fix: start the macos cursor overlay outside the caller's directory by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/381
- chore: release 1.2.0 with mcp support by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/568
Full Changelog: https://github.com/vercel-labs/agent-desktop/compare/v1.1.0...v1.2.0
- v1.1.02026-11-03 · 2026-11-03 04:13 UTC
查看更新说明
What's Changed
- fix(windows): stop commands crashing at exit by @ctate in https://github.com/vercel-labs/agent-desktop/pull/342
- fix(windows): stop scaling the overlay's coordinates twice by @ctate in https://github.com/vercel-labs/agent-desktop/pull/343
- fix(windows): stop the overlay flashing a black square when it starts by @ctate in https://github.com/vercel-labs/agent-desktop/pull/344
- fix(windows): type CR LF as one line break by @Railly in https://github.com/vercel-labs/agent-desktop/pull/368
- feat(windows): draw image cursors in the overlay by @ctate in https://github.com/vercel-labs/agent-desktop/pull/345
- fix(macos): draw overlay controls as they arrive and hide a cleared label by @ctate in https://github.com/vercel-labs/agent-desktop/pull/346
- feat(core): move the cursor before taking the interaction lease by @ctate in https://github.com/vercel-labs/agent-desktop/pull/347
- feat: add
type --interval-msto type at a steady pace by @ctate in https://github.com/vercel-labs/agent-desktop/pull/348 - feat(core, macos): show the insertion caret after text entry by @ctate in https://github.com/vercel-labs/agent-desktop/pull/349
- feat(windows): show the insertion caret after text entry by @ctate in https://github.com/vercel-labs/agent-desktop/pull/350
- fix(macos): stop clipping the click highlight's glow and pop by @ctate in https://github.com/vercel-labs/agent-desktop/pull/352
- fix: keep the overlay caret on the insertion point after key presses by @ctate in https://github.com/vercel-labs/agent-desktop/pull/353
- fix(macos): place the caret on an indented new line by @ctate in https://github.com/vercel-labs/agent-desktop/pull/354
- feat: draw the cursor label as a pill that fits its text by @ctate in https://github.com/vercel-labs/agent-desktop/pull/357
- feat: colour the cursor with the accent unless a fill is set by @ctate in https://github.com/vercel-labs/agent-desktop/pull/361
- Video remove by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/421
- fix: remove the macOS command host by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/414
- feat(macos): re-identify refs through the element's own accessibility address by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/441
- feat(identity): resolve Linux and Windows refs through a capture rule by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/442
- Move feature requests and questions to Discussions by @ctate in https://github.com/vercel-labs/agent-desktop/pull/502
- fix(macos): reach the Dock, menu bar status items and system panels by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/480
- chore: prepare version 1.1.0 by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/508
New Contributors
- @ctate made their first contribution in https://github.com/vercel-labs/agent-desktop/pull/342
Full Changelog: https://github.com/vercel-labs/agent-desktop/compare/v1.0.2...v1.1.0
- v1.0.22026-10-30 · 2026-10-30 21:17 UTC
查看更新说明
What's Changed
- docs: make AGENTS.md the single agent instructions file and correct stale docs by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/329
- feat: tell npm users when the node launcher slows each call by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/328
- fix: make the permission guide offer the launching app, see each grant, and leave no stale host by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/330
- chore: remove the personal funding link, badges and name references before the org transfer by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/332
- docs(readme): add Labs badges and plain title header by @Railly in https://github.com/vercel-labs/agent-desktop/pull/334
- chore: point repository links at vercel-labs/agent-desktop after the org transfer by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/333
- feat: add the docs site served at agent-browser.dev/desktop by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/335
- docs: add the technical-writer skill for docs and other prose by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/336
- docs: add the diagram component and the getting started pages (1/4) by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/337
- docs: document snapshots, refs, skeleton drill-down, and the other core concepts (2/4) by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/340
- docs: add the reference for all 60 commands and configuration (3/4) by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/339
- docs: add the guides, platform pages, C library docs, and changelog (4/4) by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/338
- chore: prepare version 1.0.2 by @lahfir in https://github.com/vercel-labs/agent-desktop/pull/341
New Contributors
- @Railly made their first contribution in https://github.com/vercel-labs/agent-desktop/pull/334
Full Changelog: https://github.com/vercel-labs/agent-desktop/compare/v1.0.1...v1.0.2
- v1.0.12026-10-28 · 2026-10-28 03:36 UTC
查看更新说明
What's Changed
- fix: drop the version line from the skills by @lahfir in https://github.com/lahfir/agent-desktop/pull/324
- fix: publish releases automatically and retire the custom package catalogs by @lahfir in https://github.com/lahfir/agent-desktop/pull/320
- test: remove flaky and slow live tests from CI by @lahfir in https://github.com/lahfir/agent-desktop/pull/325
- test: serialize every windows capture test on the single-flight slot by @lahfir in https://github.com/lahfir/agent-desktop/pull/327
- chore: prepare version 1.0.1 by @lahfir in https://github.com/lahfir/agent-desktop/pull/326
Full Changelog: https://github.com/lahfir/agent-desktop/compare/v1.0.0...v1.0.1
- v1.0.02026-10-28 · 2026-10-28 01:15 UTC
查看更新说明
What's Changed
- ci: scope release panic probe trust to its checkout by @lahfir in https://github.com/lahfir/agent-desktop/pull/316
- fix: install the verified 0.11.1 Homebrew release by @lahfir in https://github.com/lahfir/agent-desktop/pull/317
- fix: simplify native installs and generate release package metadata by @lahfir in https://github.com/lahfir/agent-desktop/pull/318
- chore: prepare version 1.0.0 by @lahfir in https://github.com/lahfir/agent-desktop/pull/322
Full Changelog: https://github.com/lahfir/agent-desktop/compare/v0.11.1...v1.0.0
agent-desktop
Computer use for AI agents: see and operate desktop apps on macOS, Windows, and Linux through the OS accessibility tree.
agent-desktop gives an AI agent computer use without screenshots or pixel matching. It reads the accessibility tree of a desktop app and returns it as JSON, with a ref for every element the agent can act on. The agent clicks or types on a ref, reads the UI again to check the result, and repeats. The loop lives in your agent; agent-desktop has no model inside. It ships as a CLI and a C library.
Snapshots, clipboard reads, screenshots, command output, and debug artifacts can contain private desktop content. Keep them out of public logs and uploads.
Install
npm install -g agent-desktop
agent-desktop status # platform, permissions, supported surfaces
agent-desktop permissions --guide # macOS: walks you through the Accessibility grant
Bun, Yarn and pnpm can install the same package. It includes native binaries and platform helpers for x64 and ARM64. For direct execution without a JavaScript launcher, download the matching native archive from GitHub Releases and keep its helper beside the executable.
On macOS and Linux, Homebrew also works: brew install agent-desktop. There is no official Scoop package yet.
The repository no longer maintains a custom Homebrew tap or Scoop bucket.
Release archives and building from source are covered in Installation.
Quick start
agent-desktop snapshot --app Finder -i # interactive elements, each with a ref
agent-desktop click @s8f3k2p9:e8 # act on a ref from that snapshot
agent-desktop snapshot --app Finder -i # observe again to verify
Each command prints one JSON envelope. A trimmed snapshot:
{
"version": "2.6",
"ok": true,
"command": "snapshot",
"data": {
"app": "Finder",
"snapshot_id": "s8f3k2p9",
"ref_count": 59,
"complete": true,
"tree": {
"role": "window",
"name": "Downloads",
"children": [
{ "role": "treeitem", "name": "Documents", "ref_id": "@s8f3k2p9:e8", "available_actions": ["Click"] }
]
}
}
}
- Refs belong to their snapshot. A bare
@e8is rejected withINVALID_ARGS. When the UI changes, an action returnsSTALE_REForAMBIGUOUS_TARGET: take a new snapshot and use its refs. - Several windows give
AMBIGUOUS_TARGET;snapshotlists the candidate window ids inerror.details. Pass one with--window-id. - Dense apps: map first with
snapshot --skeleton --app Slack -i --compact, then drill into one region withsnapshot --root @s8f3k2p9:e3 -i --compact. - Headless by default. Ref actions use the accessibility API without moving the pointer or taking focus. The global
--headedflag allows physical input. - Post-action waits observe the ref's original process. Window-owned refs stay pinned to their original window, including refs captured from a sheet, alert, popover, focused view, or Linux menu. macOS application menus keep their application-owned surface and need no document window. The wait reads the whole pinned window, so overlay selectors share its scope. Wait scope and results describe the selector limits.
type,set-value, andclipboard-setaccept--stdinfor piped text, keeping it out of process arguments. Run secret steps as separate commands; batch JSON text appears in process arguments.- PowerShell. Quote every ref (
'@s8f3k2p9:e8'), because a bare@tokenis the splatting operator.
The full walkthrough is in the quick start.
How it works
Your agent calls the CLI, or the C library in process. Both run the same core, which reaches the OS only through PlatformAdapter. Each binary is built for one OS and talks to that OS's accessibility API.
For AI agents
The binary carries guides that match its version:
agent-desktop skills get desktop # the loop, refs, verification and retry rules
agent-desktop skills get platform # what differs on the OS you run on
agent-desktop <command> --help # flags for one command
Install the skill into an agent harness from skills.sh:
npx skills add https://github.com/vercel-labs/agent-desktop --skill agent-desktop
Or add this to your AGENTS.md:
Use `agent-desktop` to see and operate desktop apps. Before the first use, run
`agent-desktop skills get desktop` and `agent-desktop skills get platform`, and follow them.
Retry a failed command only when error.disposition.retry is safe. See JSON output for the envelope, error codes, and exit codes.
MCP
agent-desktop mcp serves every command as an MCP tool over stdio. A tool is named after its command (desktop_snapshot, desktop_click, desktop_session_start), takes that command's arguments, and returns its JSON envelope:
{ "mcpServers": { "agent-desktop": { "command": "agent-desktop", "args": ["mcp"] } } }
Global flags given to mcp, such as --session, --headed or --trace, apply to every call.
Commands
agent-desktop has 60 command names, 56 operational commands. The other four (key-down, key-up, mouse-down, mouse-up) refuse to run until a daemon can release a held key or button. Commands documents each one.
| Group | Commands |
|---|---|
| Observe | snapshot, find, get, is, screenshot, list-surfaces |
| Act on a ref | click, double-click, triple-click, right-click, type, set-value, clear, focus, select, toggle, check, uncheck, expand, collapse, scroll, scroll-to |
| Keyboard and mouse | press, hover, drag, mouse-move, mouse-click, mouse-wheel, key-down, key-up, mouse-down, mouse-up |
| Apps and windows | launch, close-app, list-apps, list-windows, list-displays, focus-window, resize-window, move-window, minimize, maximize, restore, open-system-surface |
| Notifications | list-notifications, dismiss-notification, dismiss-all-notifications, notification-action |
| Clipboard | clipboard-get, clipboard-set, clipboard-clear |
| Wait | wait |
| Sessions | session, trace, cursor-overlay |
| System | status, permissions, version, batch, skills |
Platform support
| Platform | Requirement | Accessibility API |
|---|---|---|
| macOS | macOS 13 or later, Intel or Apple Silicon | AX API |
| Windows | Windows 10 1809 or later, x64 or ARM64 | UI Automation |
| Linux | Ubuntu 24.04 or later, x86_64 or aarch64, X11 or Wayland | AT-SPI |
Each platform page lists what works headless, what needs --headed, and what refuses.
C library
Each release ships libagent_desktop_ffi, so a program can call agent-desktop in process. See the C library docs.
import ctypes
lib = ctypes.CDLL("./lib/libagent_desktop_ffi.dylib")
lib.ad_adapter_create.restype = ctypes.c_void_p
lib.ad_adapter_destroy.argtypes = [ctypes.c_void_p]
assert lib.ad_init(7) == 0 # AD_RESULT_OK when the header's AD_ABI_VERSION_MAJOR matches the library
adapter = lib.ad_adapter_create()
lib.ad_adapter_destroy(adapter)
Development
Each platform adapter builds only on its own OS, so scope cargo to the host's packages. On macOS:
HOST_PKGS=(-p agent-desktop-core -p agent-desktop-macos -p agent-desktop -p agent-desktop-ffi)
cargo test "${HOST_PKGS[@]}"
cargo clippy "${HOST_PKGS[@]}" --all-targets -- -D warnings
On Windows, use agent-desktop-windows instead of agent-desktop-macos; on Linux, agent-desktop-linux. CONTRIBUTING.md lists every gate.
Documentation
- Introduction: what it is and how it works
- Snapshots and refs
- Errors and recovery
- Skills
- CONCEPTS.md: vocabulary
- CONTRIBUTING.md, SECURITY.md, SUPPORT.md
License
Apache-2.0