agy-cua-desktop
README.md
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg" />
<img src="assets/logo.svg" alt="agy-cua-desktop logo" width="84" />
</picture>
# agy-cua-desktop
**Fast, Background-First Computer Use MCP Server & Google Antigravity Plugin**
[](CHANGELOG.md)
[](https://github.com/Nodifferentiable/agy-cua-desktop/actions/workflows/ci.yml)
[](https://github.com/Nodifferentiable/agy-cua-desktop/stargazers)
[](#quick-start)
[](#architecture)
[](#quick-start)
[](LICENSE)
English · [简体中文](README.zh-CN.md) · [Why Computer Use?](#why-rethink-computer-use) · [Use Cases](#real-world-computer-use-scenarios) · [Quick Start](#quick-start) · [Tool Catalog](#tool-catalog) · [Security Model](#security-model) · [Star History](#star-history)
</div>
<br />
**`agy-cua-desktop`** brings fast, safe **Computer Use** (desktop GUI + logged-in browser automation on **Windows, macOS, and Linux**) to **Google Antigravity**, **Claude Code**, **Cursor**, **OpenAI Codex CLI**, **Windsurf**, **Cline**, and **Gemini CLI** via official **[Cua Driver](https://cua.ai/docs/cua-driver)**. Instead of hijacking your physical mouse and burning tokens on slow full-screen screenshot loops, it pairs **zero-screenshot COM introspection (`desktop_fast_context`)**, **compact 2-tier MCP curation**, **isolated subagent execution (`cua-operator`)**, and **built-in `PreToolUse` safety guardrails**—operating desktop apps in the background while you keep typing uninterrupted.
| Eager Schema Footprint | Main-Session Screenshots | Explorer / Office Lookup | `Turbo`-Mode Guardrails |
| :---: | :---: | :---: | :---: |
| **7 Eager (`158–326` chars)**<br><sub>Fixes `get_window_state` 4,096-char drop</sub> | **0**<br><sub>Isolated inside `cua-operator` (`flash`)</sub> | **`<150 ms` COM**<br><sub>Zero UIA walk via `desktop_fast_context`</sub> | **Zero Manual UI Rules**<br><sub>`PreToolUse` `force_ask` + Self/Vault deny</sub> |
## Why Rethink Computer Use?
| Dimension | Traditional Screenshot-Loop Computer Use (`3–8 s/step`) | **`agy-cua-desktop` (Script-First, Background-First)** |
| :--- | :--- | :--- |
| **Mouse & Focus** | Hijacks physical cursor & active window — you must stop typing | **Headless background UIA/AX delivery + `120 ms` cursor-collision deferral** so you keep working uninterrupted |
| **Speed & Token Cost** | Repeated full-screen PNGs bloat context & break prompt cache | **`<150 ms` `desktop_fast_context` COM** (`0` screenshots) + `run_script` / `run_steps` batching `1..64` UI actions in 1 turn |
| **Web + Native Apps** | Isolated browser profiles lose SSO/2FA logins & miss native GUIs | **Drives tabs inside your already-logged-in Chrome / Edge (`browser_*`)** alongside Win32 / WPF / WinUI / Electron / macOS / Linux apps |
| **Autonomous Safety** | Unfiltered clicks risk password leaks or accidental checkout/delete | **Dual-layer guardrails**: hard-blocks `1Password` / `Bitwarden` / `KeePass` / UAC & self-targeting, redacts `[REDACTED_PASSWORD]`, prompts confirmation on `kill_app` / payment / delete |
## Real-World Computer Use Scenarios
- **Explorer + Office → Desktop App Pipelines**: Inspect highlighted File Explorer selections & active Excel/Word/PowerPoint documents in `<150 ms` (`0` screenshots) and batch-fill ERP, finance, or legacy desktop forms in the background.
- **Logged-In Browser ↔ Desktop Bridge**: Pull live data from internal dashboards in your already-authenticated Chrome/Edge tabs and drive native desktop apps without re-login or anti-bot hurdles.
- **Uninterrupted Multi-Step GUI Batching**: Execute 20–60 clicks, form entries, menu invocations, and hotkeys inside a single `run_steps` or `run_script` call while you keep coding in your editor.
- **Desktop App E2E Playtesting & Visual QA**: Launch and verify Electron, Tauri, WPF, Qt, or SwiftUI builds using deterministic `verify_state` assertions plus targeted `zoom` grounding for Canvas/WebGL views.
- **Safe Autonomous ("Turbo") Desktop Assistant**: Delegate repetitive GUI chores confidently with built-in password-vault isolation, self-targeting prevention, and native confirmation gates on irreversible actions.
## Quick Start
**Requirements:** **Node.js >= 20** + official **[Cua Driver](https://cua.ai/docs/cua-driver)** (`--with-driver` installs it automatically).
### Option A: Google Antigravity Native Plugin (Desktop 2.0, CLI `agy`, IDE)
Unlocks the full bundle: 2-tier MCP server + `cua-operator` isolated subagent + `PreToolUse` `Turbo` confirmation hooks + 5-tier routing rules.
**Windows (PowerShell):**
```powershell
# Plugin only
irm https://raw.githubusercontent.com/Nodifferentiable/agy-cua-desktop/main/install.ps1 | iex
# Plugin + official Cua Driver (with Windows background autostart)
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/Nodifferentiable/agy-cua-desktop/main/install.ps1))) --with-driver
```
**macOS / Linux:**
```bash
# Plugin only
curl -fsSL https://raw.githubusercontent.com/Nodifferentiable/agy-cua-desktop/main/install.sh | sh
# Plugin + official Cua Driver
curl -fsSL https://raw.githubusercontent.com/Nodifferentiable/agy-cua-desktop/main/install.sh | sh -s -- --with-driver
```
**Any OS (via GitHub `npx`):**
```bash
npx -y github:Nodifferentiable/agy-cua-desktop install --with-driver
```
### Option B: Universal Computer Use MCP Server (Claude Code, Cursor, Codex, Windsurf, Cline)
1. Install **Cua Driver** once (`irm https://cua.ai/driver/install.ps1 | iex` on Windows, or `/bin/bash -c "$(curl -fsSL https://cua.ai/driver/install.sh)"` on macOS/Linux).
2. Add the stdio MCP server to your client:
```bash
# Claude Code one-liner
claude mcp add agy-cua-desktop -- npx -y github:Nodifferentiable/agy-cua-desktop mcp
```
```json
{
"mcpServers": {
"agy-cua-desktop": {
"command": "npx",
"args": ["-y", "github:Nodifferentiable/agy-cua-desktop", "mcp"]
}
}
}
```
*(Run `npx -y github:Nodifferentiable/agy-cua-desktop mcp-config` to print copyable JSON snippets.)*
> [!TIP]
> **Using Antigravity Desktop `Turbo` Mode?** Zero manual setup in **Settings → General → Tool permissions** is needed! Built-in `hooks.json` (`PreToolUse`) + `policy.ts` allow routine desktop work automatically while popping native confirmation prompts on `kill_app` and financial/permanent-delete actions.
<details>
<summary>More installation options (local clone, per-repo team install, <code>agy</code> CLI, or ask Antigravity)</summary>
#### Local Clone (Any OS)
```bash
git clone https://github.com/Nodifferentiable/agy-cua-desktop.git
cd agy-cua-desktop
node scripts/install.mjs install --with-driver
```
#### Per-Repository Installation (Team Sharing)
Install only into `<repo>/.agents/plugins/agy-cua-desktop`:
```bash
node scripts/install.mjs install --project /path/to/your-repo
```
#### Standalone Pure MCP Server (Claude Code, Codex, Cursor)
```json
{
"mcpServers": {
"agy-cua-desktop": {
"command": "npx",
"args": ["-y", "github:Nodifferentiable/agy-cua-desktop", "mcp"]
}
}
}
```
Run `npx -y github:Nodifferentiable/agy-cua-desktop mcp-config` to print ready-to-paste JSON configs.
#### Native Antigravity CLI (`agy`)
```bash
agy plugin install /path/to/agy-cua-desktop
agy plugin enable agy-cua-desktop
```
#### Ask Antigravity Directly
```text
Clone https://github.com/Nodifferentiable/agy-cua-desktop.git to ~/.gemini/config/plugins/agy-cua-desktop, run `node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs install --with-driver`, and confirm status with `doctor`.
```
</details>
## Architecture
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/architecture-dark.svg" />
<source media="(prefers-color-scheme: light)" srcset="assets/architecture-light.svg" />
<img alt="agy-cua-desktop 5-Tier Script-First & Dual-Guard Architecture" src="assets/architecture-light.svg" width="100%" />
</picture>
</p>
### Why Not Raw `cua-driver mcp` or Custom SDK Scripts?
| Capability | Raw `cua-driver mcp` | Custom SDK Loop (Python/TS) | `agy-cua-desktop` `v0.2.0` |
| :--- | :--- | :--- | :--- |
| **Underlying Engine** | Official `cua-driver` | Official `cua-driver` | **Same official `cua-driver`** |
| **Eager `get_window_state`** | **4,656 chars** *(dropped if >4,096 limit)* | Manual code only | **305 chars** *(compacted & always active)* |
| **Full Desktop Actions** | 50+ mixed tools in flat list | Hardcoded ~12 tools *(misses double-click/drag/zoom)* | **7 Eager + 45 Lazy** *(100% desktop + local browser_*)* |
| **Explorer / Office Lookup** | Slow UIA walk + screenshot | Slow UIA walk + screenshot | **`<150 ms` `desktop_fast_context` COM probe** |
| **Windows Session Pipe** | Bare `mcp` can see 0 windows in sandboxes | Requires separate terminal | **Auto-attaches to `\\.\pipe\cua-driver` daemon** |
| **Main-Session Cache** | Screenshots bloat main context | Separate process + extra API bill | **Isolated in `cua-operator` (`flash`), `0` extra API cost** |
| **`Turbo` Mode Safety** | Unfiltered clicks & self-targeting risk | Manual prompt rules only | **Built-in `PreToolUse` `force_ask` + Self/Vault deny** |
## 5-Tier Script-First Workflow
`rules/AGENTS.md` and `skills/cua-desktop/SKILL.md` guide Antigravity to always solve tasks at the fastest tier:
| Tier | Latency | Approach | When to Use |
| :---: | :---: | :--- | :--- |
| **Tier 0** | `<20 ms` | Direct `read_file` / `agy-fast` / SQLite / OpenXML | Reading/editing files, configs, `.xlsx`, `.docx`, or databases |
| **Tier 1** | `<150 ms` | **`desktop_fast_context`** + PowerShell COM / CLI | Resolving visible windows with self/vault flags (all OS), plus open File Explorer paths, highlighted `selectedItems`, active Excel/Word/PowerPoint docs, and clipboard formats *(COM fast path is Windows-native; macOS/Linux use Tier 2/3 AX/AT-SPI)* |
| **Tier 2** | `0` screenshots | **`run_script`** (`app.query`) & **`run_steps`** | Batching multi-field forms, conditional UI loops, and target-by-name UIA actions in 1 round trip |
| **Tier 3** | `0` screenshots | **`get_window_state`** (`include_screenshot: false, since: "latest"`) | Refreshing `element_token` handles or reading filtered UIA subtrees (`query: "kw1|kw2"`) |
| **Tier 4** | Fallback | **`zoom`** + **`foreground_fallback: true`** / lazy **`browser_*`** | Custom Canvas/WebGL views, apps refusing background input, or tabs inside your logged-in Chrome/Edge |
## Security Model
Built for **`Turbo`** + elevated Windows `RunLevel=Highest` daemons without losing safety—see [SECURITY.md](SECURITY.md) for the 2-minute supply-chain audit:
1. **Self-Targeting Block**: Mutating, pointer, keyboard, menu, and `kill_app` calls targeting `Antigravity` or `cua-driver` processes are denied at both `PreToolUse` and bridge layers.
2. **Vault & UAC Isolation**: Both read (`get_window_state`, `zoom`) and input calls targeting `1Password`, `Bitwarden`, `KeePass`, `consent.exe` (UAC), or `CredentialUIBroker` are hard-denied; `is_password: true` UIA fields are redacted to `[REDACTED_PASSWORD]`.
3. **Irreversible Action Confirmation (`force_ask`)**: `PreToolUse` pops a native confirmation prompt on `kill_app` and UI labels matching financial or destructive actions (Pay, Transfer, Checkout, Delete Forever, Format Disk), even in `Turbo` mode.
4. **Visual Prompt-Injection Isolation**: `cua-operator` runs with `commandExecutionPolicy: off`, preventing untrusted text seen on screen from executing arbitrary shell commands.
5. **Collision Guard, Panic Stop & Audit**: Foreground escalations sample `get_cursor_position` over `120 ms` and defer (`user_cursor_active_deferred`) if your physical mouse is moving; `desktop_panic_stop` halts all sessions immediately (`cua-driver revoke --all`); metadata-only logs write to `${PLUGIN_DATA}/audit.jsonl` (512 KB cap).
## CLI & Configuration
```bash
# Inspect status, daemon pipe, hooks, and active policy
node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs doctor
# View or adjust policy overrides (~/.gemini/config/agy-cua-desktop.json)
node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs config --show
node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs config --mode strict-background --browser off
node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs config --reset
# Emergency stop all active Cua Driver sessions
node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs panic
```
| Config Key (`agy-cua-desktop.json`) | Env Override | Default | Values |
| :--- | :--- | :---: | :--- |
| `policyMode` | `AGY_CUA_POLICY_MODE` | `"smart"` | `"smart"` · `"strict-background"` · `"unrestricted"` |
| `enableBrowserTools` | `AGY_CUA_ENABLE_BROWSER_TOOLS` | `true` *(in smart)* | `true` · `false` |
| `textOnly` | `AGY_CUA_TEXT_ONLY` | `false` | `true` · `false` |
| `maxTextBytes` | `AGY_CUA_MAX_TEXT_BYTES` | `28672` | `2048..262144` |
| `collisionCheckMs` | `AGY_CUA_COLLISION_CHECK_MS` | `120` | `0..1000` |
| `socket` | `AGY_CUA_SOCKET` | Auto-detected | e.g. `\\.\pipe\cua-driver` |
## Example Prompts
- *"Check what folder and files I currently have selected in File Explorer and summarize them (use `desktop_fast_context`, no screenshots)."*
- *"Use `cua-operator` to fill out the open desktop app form in the background while I keep typing here."*
- *"In my already-logged-in Chrome window, inspect the active tab and export the report without opening a new browser profile."*
## Tool Catalog
When connected to `cua-driver`, `agy-cua-desktop` exposes **7 compact Eager tools** + **45 on-demand Lazy tools** (filtered by OS and safety policy; `shell_execute` and `install_extension` are always blocked):
| Tool / Group | Tier | Purpose |
| :--- | :---: | :--- |
| `desktop_doctor` | Eager | Diagnose `cua-driver` binary, daemon pipe/autostart, hooks, and active policy |
| `desktop_fast_context` | Eager | Zero-screenshot window list (`self`/`vault` tags) + Windows Explorer/Office/Clipboard COM probe |
| `list_windows` | Eager | Enumerate open windows (`pid`, `window_id`, `app_name`, `title`, `bounds`) |
| `get_window_state` | Eager | Compact UIA tree (`since:"latest"` diff, `query:"a\|b"`, optional screenshot; `305`-char schema) |
| `run_steps` | Eager | Batch `1..64` desktop actions (`wait_for`, `expect`, `observe`, `foreground_fallback`) |
| `run_script` | Eager | Run headless JavaScript (`cua.getApp`, `app.query`) in Cua Driver's sandbox |
| `verify_state` | Eager | Assert `1..8` deterministic window or element predicates |
| Pointer, Keyboard & Window Controls | Lazy | `click`, `double_click`, `right_click`, `drag`, `set_value`, `type_text`, `press_key`, `hotkey`, `scroll`, `invoke_menu`, `launch_app`, `kill_app`, `set_window_frame`, etc. |
| Local Logged-In Browser (`browser_*`) | Lazy | Drive tabs in your already-open Chrome/Edge (`browser_prepare`, `get_browser_state`, `browser_click`, `browser_type`, `browser_navigate`, `browser_download`, etc.) |
| Visual Grounding & Session Lifecycle | Lazy | `zoom`, `parse_visual_regions`, `get_accessibility_tree`, `start_session`/`end_session`, `get_guide` |
| `desktop_panic_stop` | Lazy | Emergency kill-switch: runs `cua-driver revoke --all` and resets bridge state |
## Project Layout & Platform Troubleshooting
```text
agy-cua-desktop/
├── plugin.json # Antigravity plugin manifest
├── mcp_config.json # 2-tier MCP server config (7 Eager tools)
├── hooks.json # Turbo-ready PreToolUse multi-path hook loader
├── src/ & dist/ # TypeScript source -> zero-dep ESM bundles
├── rules/AGENTS.md # Always-on 5-tier script-first routing rules
├── agents/cua-operator.md # Flash multimodal-isolated subagent (commandExecutionPolicy: off)
├── skills/cua-desktop/ # On-demand skill & optional native YAML policy reference
├── scripts/install.mjs # CLI (install, update, uninstall, doctor, config, panic, mcp)
└── install.ps1 / install.sh # Cross-platform one-command installers
```
- **Windows (`cua-driver` sees 0 windows or pipe unavailable)**: Run `cua-driver autostart enable ; cua-driver autostart kick`, then run `node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs doctor` to verify `\\.\pipe\cua-driver`.
- **macOS (missing Accessibility tree or screenshots)**: Run `cua-driver permissions grant` and enable Accessibility & Screen Recording for your terminal / Cua Driver.
- **Linux (headless or Wayland issues)**: Ensure `cua-driver serve` is started inside an active X11/XWayland desktop session.
- **Updating & Uninstalling**: Run `node ~/.gemini/config/plugins/agy-cua-desktop/scripts/install.mjs update` (preserves your custom `rules/AGENTS.local.md`) or `uninstall` to remove cleanly.
## Contributing, Security & License
- Development & Release Workflow: [CONTRIBUTING.md](CONTRIBUTING.md) · [CHANGELOG.md](CHANGELOG.md)
- Security Architecture & Independent Audit: [SECURITY.md](SECURITY.md)
- Powered by Official [Cua Driver](https://cua.ai/docs/cua-driver) · Released under the [MIT License](LICENSE)
## Star History
If **`agy-cua-desktop`** powers up your **Computer Use** workflows, please give it a ⭐ **Star** on GitHub so more developers can discover it!
<a href="https://www.star-history.com/#Nodifferentiable/agy-cua-desktop&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Nodifferentiable/agy-cua-desktop&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Nodifferentiable/agy-cua-desktop&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Nodifferentiable/agy-cua-desktop&type=Date" />
</picture>
</a>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues