Skill1.1k estrellas del repoactualizado 3d ago
agent-desktop
agent-desktop is a command-line tool that enables AI agents to observe and control macOS desktop applications by exposing their accessibility trees as structured JSON with reference-based element identifiers. Use it when building autonomous agents that need to interact with native applications through programmatic UI observation and control, rather than building agents to use the tool directly.
Instalar en Claude Code
Copiargit clone --depth 1 https://github.com/lahfir/agent-desktop /tmp/agent-desktop && cp -r /tmp/agent-desktop/skills/agent-desktop ~/.claude/skills/agent-desktopDespués abre una sesión nueva de Claude Code; el skill carga automáticamente.
Definición
SKILL.md
# agent-desktop CLI tool enabling AI agents to observe and control desktop applications via native OS accessibility trees. **Core principle:** agent-desktop is NOT an AI agent. It is a tool that AI agents invoke. It outputs structured JSON with ref-based element identifiers. The observation-action loop lives in the calling agent. ## Installation ```bash npm install -g agent-desktop # or bun install -g --trust agent-desktop ``` Requires macOS 12+ with Accessibility permission granted to your terminal. Screen Recording permission is also required for screenshots. ## Reference Files Detailed documentation is split into focused reference files. Read them as needed: | Reference | Contents | |-----------|----------| | `references/commands-observation.md` | snapshot, find, get, is, screenshot, list-surfaces — all flags, output examples | | `references/commands-interaction.md` | click, type, set-value, select, toggle, scroll, drag, keyboard, mouse — choosing the right command | | `references/commands-system.md` | launch (including `--cdp` for Chromium web contents), close, windows, clipboard, wait, batch, session, status, permissions, version | | `references/workflows.md` | 16 common patterns: forms, menus, dialogs, scroll-find, drag-drop, async wait, anti-patterns | | `references/macos.md` | macOS permissions/TCC, AX API internals, smart activation chain, surfaces, Notification Center, troubleshooting | ## The Observe-Act Loop (Progressive Skeleton Traversal) When you know the target's role or exact name, use `find --role ... --name ... --exact` directly. Otherwise, use **progressive skeleton traversal** for dense or unfamiliar apps: a shallow overview followed by targeted drill-downs. ``` 1. SKELETON → agent-desktop snapshot --skeleton --app "App" -i --compact Parse the overview. Identify the region containing your target. Regions show children_count (e.g., "Sidebar" with children_count: 42). The nearest safely resolvable container has a ref for drill-down. Keep the returned snapshot_id. 2. DRILL → agent-desktop snapshot --root @e3 --snapshot <snapshot_id> -i --compact Expand the target region. Now you see its interactive elements. 3. ACT → agent-desktop click @e12 --snapshot <snapshot_id> (or type, select, toggle...) 4. VERIFY → agent-desktop snapshot --root @e3 --snapshot <snapshot_id> -i --compact Re-drill the same region to confirm the state change. Scoped invalidation: only @e3's subtree refs are replaced. 5. REPEAT → Continue drilling other regions or acting as needed. ``` **When to skip skeleton and use full snapshot instead:** - Simple apps with few elements (Finder, Calculator, TextEdit) - You already know the exact element name — use `find` instead - Surface snapshots (menus, sheets, alerts) — these are already focused **When skeleton shines:** - Dense Electron apps (Slack, VS Code, Discord, Notion) that are **already running** — for one you are launching fresh, `launch --cdp` plus a CDP client (agent-browser preferred) reads the web contents faster than any skeleton walk (see principle 15) - Any app where full snapshot exceeds ~50 refs - Multi-region workflows (sidebar + main content + toolbar) ## Ref System - Refs are assigned depth-first and emitted with their snapshot, for example `@s8f3k2p9:e1`, `@s8f3k2p9:e2`, `@s8f3k2p9:e3`. Legacy bare refs require an explicit `--snapshot`. - An element gets a ref when it is addressable for an action: an interactive role (button, textfield, checkbox, link, menuitem, tab, slider, combobox, treeitem, cell, radiobutton, switch, ...) **or** any element advertising an action — so `scrollarea` (Scroll) and `disclosure` (Expand/Collapse) are ref-able and `scroll`/`expand`/`collapse` can target them - A `SetFocus`-only affordance does not earn a ref on its own - In skeleton mode, each truncated branch exposes the deepest safely resolvable drill target using stable text, native ID, or bounds evidence; the nearest resolvable ancestor is used when the boundary itself is anonymous - Static text and non-actionable groups/containers remain in tree for context but have no ref - Refs are deterministic within a snapshot but NOT stable across snapshots if UI changed - Snapshot output uses qualified refs that embed `snapshot_id` and need no separate `--snapshot`; a session-owned ref still requires the same `--session` or `AGENT_DESKTOP_SESSION` scope because lookup never crosses namespaces - `last_refmap.json` is only a latest-snapshot inspection artifact. The command path uses snapshot-scoped storage. - After any action that changes UI, re-drill the affected region or re-snapshot - **Scoped invalidation:** re-drilling a qualified root ref only replaces refs from that root's previous drill — refs from other regions and the skeleton itself are preserved - **Strict resolution:** stale refs return `STALE_REF`; duplicate plausible targets return `AMBIGUOUS_TARGET` instead of choosing arbitrarily. - **Actionability:** every ref-addressed action checks its applicable live visibility, stability, enabled, editability, policy, supported-action, and hit-test requirements under one bounded budget before a single dispatch. Pointer actions focus before their final geometry read, re-resolve moving endpoints, and return `TIMEOUT` with `details.kind: "actionability_timeout"` instead of sending input after the deadline. - **Headless vs headed:** ref actions are strictly headless by default: semantic accessibility APIs only, with no focus stealing, cursor movement, or synthesized keyboard input. In headed mode, core focuses the exact ref window before dispatch; pointer actions also require a verified target point, while the adapter owns OS delivery. On macOS, `click`, `right-click`, `type`, `clear`, and `scroll` are physical-first; double/triple-click, hover, and drag are physical-only; expand/collapse and other semantic actions remain semantic. Raw `--xy` input has no window identity and never steals focus. `press` is explic
Del mismo repositorio