← Catalog

pi-agent-desktop-adapter

Pi extension that lets agents observe and operate macOS, Windows and Linux desktop apps through agent-desktop's accessibility-tree CLI.

Extension

Install

Install with PiG

pig install npm:pi-agent-desktop-adapter

Install with Pi

pi install npm:pi-agent-desktop-adapter
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.0 (README.md). PiG does not review it.

pi-agent-desktop-adapter

A pi extension that lets the agent see and operate desktop apps on macOS, Windows and Linux through agent-desktop, Vercel Labs' accessibility-tree CLI.

The agent works in a loop: it takes a snapshot of an app, acts on an element's ref, then takes another snapshot to check the result. Actions are headless by default, so they go through the accessibility API without moving your pointer or stealing focus. Physical mouse and keyboard input happens only after you allow it.

Install

pi install npm:pi-agent-desktop-adapter

Or from GitHub:

pi install git:github.com/<you>/pi-agent-desktop-adapter

Or try it for one run from a checkout:

pi -e ./extensions/agent-desktop.ts

The agent-desktop npm package is a dependency and ships native binaries for every platform, so nothing else is needed. To use a different build, set AGENT_DESKTOP_BIN=/path/to/agent-desktop.

Permissions

  • macOS: grant Accessibility (and Screen Recording for screenshots) to the terminal app that runs pi. Run agent-desktop permissions --guide. The extension warns at session start if Accessibility is missing.
  • Windows: no grant is needed for apps at your terminal's integrity level.
  • Linux: needs a graphical session with at-spi2-core.

Tools

ToolWhat it does
desktop_snapshotAccessibility tree with qualified refs (@s8f3k2p9:e5). Supports skeleton plus root drill-down, surfaces (menu, sheet, alert…), bounds, and wait_for
desktop_findSearch by role, name, value, text, state or native id
desktop_actAct on a ref: click, right-click, type, set-value, clear, focus, select, toggle, check, uncheck, expand, collapse, scroll, scroll-to (double-click and triple-click are headed)
desktop_pressKey combos (cmd+s, escape, …), optionally scoped to an app or window
desktop_inspectRead one live property (text, value, bounds, …) or one boolean state (enabled, checked, …)
desktop_screenshotWindow or display screenshot returned as an image. On macOS it is downscaled with sips
desktop_listApps, windows, displays, surfaces or notifications
desktop_appLaunch, close, focus, resize, move, minimize, maximize or restore apps and windows
desktop_waitWait for an element predicate, window, text, menu, lifecycle event or notification
desktop_mousePhysical hover, drag, move, click and wheel by ref or screen coordinates (always headed)
desktop_clipboardGet, set or clear the clipboard
desktop_batchUp to 64 commands run in order in one process, e.g. press then wait for window-opened
desktop_cliAny other agent-desktop command, including skills get desktop <reference> for the bundled docs

The extension turns snapshots and find results into a compact text tree, one line per node:

snapshot id=s6feze89hjum4 app=Calculator window=w-26954 title="Calculator" refs=28 complete=true

window "Calculator"
  group
    button "7" @s6feze89hjum4:e10 {Click,SetFocus}
    button "Add" @s6feze89hjum4:e21 {Click,SetFocus}

Errors keep agent-desktop's code, suggestion and retry disposition (delivery=… retry=safe|unsafe), so the model knows when it is safe to repeat an action. Output larger than pi's 50 KB / 2000-line budget is truncated, and the full text is written to a private temp file.

Safety and configuration

Headed input. Physical input moves the real pointer, sends real keystrokes and can raise windows. This covers headed=true, desktop_mouse, double-click and triple-click. Under the default ask policy, pi asks once per session before any of it runs. With no UI to ask (print or JSON mode), headed input is refused.

/agent-desktop                    status: binary, version, permissions, policy, session
/agent-desktop headed allow|ask|deny

Risky actions. Force-sending a shortcut that agent-desktop flags as dangerous (desktop_press force=true) and force-quitting an app (desktop_app action=close force=true) need a confirmation when a UI is available.

Sessions. Each pi session gets its own agent-desktop session, an isolated snapshot namespace. It starts on first use and is sealed on shutdown.

Environment variableDefaultEffect
PI_AGENT_DESKTOP_HEADEDaskallow, ask or deny physical input
PI_AGENT_DESKTOP_SESSION10 uses agent-desktop's global namespace instead of a per-session one
PI_AGENT_DESKTOP_TRACE01 records an agent-desktop trace (agent-desktop trace show/export)
PI_AGENT_DESKTOP_CURSOR01 draws agent-desktop's presentation-only cursor overlay
AGENT_DESKTOP_BINbundledPath to an agent-desktop executable

Snapshots, screenshots and clipboard reads can contain private desktop content, and they reach your model provider like any other tool output.

Development

npm install
npm run typecheck
npm test

Layout: extensions/agent-desktop.ts (entry point: tools, command, lifecycle), src/cli.ts (binary resolution, envelope parsing), src/runtime.ts (session and headed policy), src/format.ts (tree rendering, truncation), src/tools.ts (tool schemas and argv mapping).