Skip to main content
Glama
AGY Computer Use

AGY Computer Use

README.md
<p align="center">
  <img src="assets/logo.png" width="104" height="104" alt="AGY Computer Use Logo" />
</p>

<h1 align="center">AGY Computer Use</h1>

<p align="center">
  <strong>All-in-one Computer Use plugin for Google Antigravity — packaged directly on top of the open-source <a href="https://github.com/trycua/cua"><code>cua-driver</code> (<code>trycua/cua</code>)</a> runtime.</strong><br/>
  Zero npm dependencies · Lean MCP filtering proxy (-38% to -71% schema bloat) · Auto-popup Codex-style floating macOS PiP · Ultra-clean companion pane &amp; full-width Settings
</p>

<p align="center">
  <a href="./README.zh-CN.md">简体中文文档</a>
</p>

---

> **Built Directly on Open-Source [`cua-driver` (`trycua/cua`)](https://github.com/trycua/cua)**  
> **AGY Computer Use** is an independent Antigravity plugin packaged directly on top of the open-source **[`cua-driver`](https://github.com/trycua/cua)** (MIT License) cross-platform runtime. It bundles a zero-dependency lean desktop MCP proxy, a Codex-style live desktop & virtual-display preview Sidecar, and declarative Computer Use agent guidance into a single drop-in Antigravity plugin.

---

## Visual Preview

### Always-on-Top Floating PiP (macOS Native `NSPanel`, Per-Chat Isolated)

<p align="center">
  <img src="assets/screenshots/pip-en.png" alt="AGY Computer Use Floating PiP inside Antigravity (English)" width="100%" />
</p>

### Full-Width Settings & Diagnostics + Native Right Split Console

<table>
  <tr>
    <td width="68%" align="center" valign="top">
      <img src="assets/screenshots/settings-en.png" alt="AGY Computer Use Settings and Diagnostics (English)" width="100%" />
      <br /><sub><b>Full-Width Settings &amp; Diagnostics</b> — Live KPIs, PiP controls, one-click update &amp; auto-refresh, macOS permissions</sub>
    </td>
    <td width="32%" align="center" valign="top">
      <img src="assets/screenshots/auxpane-en.png" alt="AGY Computer Use Right Split Console (English)" width="100%" />
      <br /><sub><b>Right Split Console</b> — Live JPEG stream, Virtual Display toggle &amp; monitorable window list</sub>
    </td>
  </tr>
</table>

### Visual MCP Tool Filtering (`-38%` to `-71%` Schema Size)

<p align="center">
  <img src="assets/screenshots/mcp-tools-en.png" alt="AGY Computer Use MCP Tool Profiles (English)" width="92%" />
</p>

<details>
<summary><b>Preview Simplified Chinese UI (简体中文界面预览)</b></summary>
<br />
<p align="center">
  <img src="assets/screenshots/pip-zh.png" alt="AGY Computer Use Floating PiP (Simplified Chinese)" width="100%" />
</p>
<table>
  <tr>
    <td width="68%" align="center" valign="top">
      <img src="assets/screenshots/settings-zh.png" alt="AGY Computer Use Settings (Simplified Chinese)" width="100%" />
    </td>
    <td width="32%" align="center" valign="top">
      <img src="assets/screenshots/auxpane-zh.png" alt="AGY Computer Use Right Split Console (Simplified Chinese)" width="100%" />
    </td>
  </tr>
</table>
<p align="center">
  <img src="assets/screenshots/mcp-tools-zh.png" alt="AGY Computer Use MCP Tools (Simplified Chinese)" width="92%" />
</p>
</details>

---

## Why AGY Computer Use?

Raw `cua-driver` exposes **63 MCP tools (~212 KB of JSON schemas)** — including 12 browser tools that overlap with Antigravity's built-in `/browser` and Chrome DevTools plugin, deprecated endpoints, and cursor-animation knobs — and ships no built-in live preview UI inside Antigravity when operating background apps or macOS virtual displays (`agent_display`).

**AGY Computer Use** packages both capabilities cleanly on top of `trycua/cua`:

### 1. Lean Desktop MCP Proxy (`mcp_config.json` + `src/mcp/`)
- **Automatic cross-platform runtime discovery**: Dynamically locates `cua-driver` on macOS, Windows, and Linux (zero hardcoded paths; re-checks lazily if installed after launch).
- **Curated tool profiles** (`AGY_CU_TOOL_PROFILE`):
  - `desktop` *(default)*: **33 core desktop tools (~132 KB, -37.8% schema size)** — removes browser-conflicting tools, deprecated endpoints, and vanity cursor controls while keeping full background automation (`run_steps`, `run_script`, `get_window_state`, `invoke_menu`, `agent_display`, `set_window_frame`, clipboard, sessions).
  - `minimal`: **16 essential tools (~62 KB, -70.6% schema size)** for ultra-low context overhead.
  - `full`: Passes all upstream `cua-driver` tools through unchanged.
  - Optional fine-grained overrides via `AGY_CU_EXTRA_TOOLS` and `AGY_CU_DISABLE_TOOLS` (comma-separated tool names).
- **Resilient & Fail-Closed**:
  - Byte-exact NDJSON framing (`src/shared/ndjson.mjs`) with zero quadratic string copies.
  - Stripped or malformed `tools/call` requests are rejected locally before touching upstream.
  - Automatic upstream crash recovery with transparent MCP `initialize` re-handshake.
  - Missing runtimes degrade gracefully with install instructions instead of crash-looping.

### 2. Automatic Always-on-Top Floating PiP (macOS, Codex-Style, ON by Default) (`src/pip/`)
- **Native Non-Activating `NSPanel` + 60 fps `ScreenCaptureKit` GPU Streaming**: Built directly with Swift + Cocoa + `ScreenCaptureKit` + `WKWebView` (async prewarmed & hash-cached) — zero Dock icon (`NSApplication.ActivationPolicy.accessory`), floats across all Spaces (`canJoinAllSpaces`), renders zero-copy `IOSurface` frames up to **60 fps** with zero-flash in-place reconfiguration across expand/resize, and **never steals keyboard/mouse focus**.
- **One-Click Pin Across Apps & Copy PNG Snapshot**: Pin the floating PiP across all applications temporarily right from its hover bar (without changing your saved default), copy a lossless PNG snapshot straight to the macOS clipboard, or cursor-pivot zoom with a live zoom percentage pill when expanded.
- **Smart `Auto` Adaptive FPS (Default)**: Starts at maximum smooth frame rate (60 fps on macOS GPU stream; max sustainable rate on `cua-driver` fallback) and smoothly steps down under thermal pressure, Low Power Mode, high capture latency, or static `304` screens, snapping right back on motion (manual `60 / 30 / 15 / 10 / 6 / 3 fps` gears also selectable).
- **Anchored Inside Antigravity's Main Content Area**: Defaults to `top-left` inside the conversation content area (clear of the left sidebar and titlebar), dynamically tracking window movement/resizing and multi-monitor coordinates, while remembering manually dragged positions.
- **Exact Target Tracking, Multi-Chat Isolation & Live Action Timeline**: The bundled MCP proxy pushes paired in-flight (`start`/`finish`) activity signals to the Sidecar — resolving `pid`, `window_id`, `element_token` snapshot handles, nested `run_steps`, localized app aliases (`Calculator` ↔ `计算器`), and deterministic per-conversation attribution (explicit `conversation_id` + cached local transcript tail fallback) — while recording a privacy-safe recent action timeline (metadata & duration only, zero text/pixels).
- **Cross-Platform Automatic Fallback**: On Windows/Linux (or macOS without Swift CLI tools), native PiP automatically falls back to expanding Antigravity's Right Split Console (once per task run, or standalone HD browser window if CDP is unavailable).

### 3. Native Right Split Console & Dual-Layer HD View (`sidecars/live_pane` + `src/sidecar/`)
- **Calm Native Console Layout**: Matches Antigravity's surface & hairline aesthetic — shows a clean standby card (1-click **Floating PiP** / **Pop Out**, macOS virtual display toggle, 2-step Emergency Stop), a collapsible **Recent Actions** timeline, and a filterable window list with hover quick-actions (**Focus**, **Move to Virtual Display**, **Move back to Main Screen**, and **PiP**). Clicking any window smoothly expands an inline preview card with click-to-zoom HD lightbox (with keyboard shortcuts `Space`, `+`/`-`/`0`, `C`, `S`), lossless PNG download & 1-click clipboard copy, and zero idle capture timers when collapsed.
- **Zero-Interference Fast Streaming**: Streams over a single persistent `cua-driver mcp` bridge using `display_only: true, include_accessibility_tree: false` in JPEG (`q=82`, **3.5×–4.3× smaller** than PNG) with single-flight + micro-cache coalescing, SHA-1 ETag `304` deduplication, `max_image_dimension` `1600px` HD zoom, and on-demand lossless **PNG** snapshots.
- **Read-Only Standalone HD Pop-out (`⤢`)**: Launches a chromeless monitor window scoped with a read-only `viewerToken` (scrubbed from browser history, backed by `HttpOnly; SameSite=Strict` reload cookies while APIs strictly enforce header tokens).

### 4. Native Left-Sidebar Settings, Diagnostics & One-Click Auto-Update (`src/cdp/` + `/settings`)
- **Single-Column Native Settings Canvas**: When Antigravity runs with `--remote-debugging-port` (sharing local `DevToolsActivePort` cleanly alongside other plugins with zero host DOM reflow overhead and lightweight heartbeat sync), a monochrome **Computer Use** entry mounts in Antigravity's left sidebar and opens a clean centered Settings & Diagnostics canvas with clickable quick-jump KPIs and real-time bilingual (`zh-CN` / `en`) auto-sync.
- **Built-In Update Checker, Driver Doctor & One-Click Reload**: Checks GitHub for newer releases right inside Settings (non-blocking async git fast-forward pulls with dirty-worktree protection and tarball/AGY-Market installs), runs `cua-driver doctor` inline on demand, supports Settings JSON export/import + 2-step reset protection, and includes a **Reload Plugin** button to hot-restart the Sidecar & refresh Antigravity via CDP cleanly.
- **Graceful Fallback**: Even without a CDP debug port, clicking the **`⚙`** icon in the Right Split Console opens the exact same Settings page cleanly in a standalone window.
- **Shared Atomic Config (`settings.json`) & Interactive MCP Tool Directory**: Stored at `~/.gemini/antigravity/plugin_data/agy-computer-use/settings.json` and hot-read by **both** the Sidecar and the MCP proxy — visually switch tool profiles (`minimal` / `desktop` / `full`), filter all 63 tools by search or status chip (`All / Enabled / Disabled / Custom`) with independent toggle switches, click any card to inspect full upstream documentation & structured input parameters, configure `Auto` FPS / PiP / virtual displays, toggle telemetry, or copy diagnostics JSON.

---

## Quick Start & Installation

### Prerequisites
1. **Node.js 20.11+** (Node 22 recommended)
2. Open-source **[`cua-driver` (`trycua/cua`)](https://github.com/trycua/cua)** signed system runtime (MIT):
   - **macOS / Linux**:
     ```bash
     /bin/bash -c "$(curl -fsSL https://cua.ai/driver/install.sh)" -- --no-connect
     ```
   - **Windows (PowerShell)**:
     ```powershell
     irm https://cua.ai/driver/install.ps1 | iex
     ```
3. **macOS only** — grant **Accessibility** and **Screen Recording** permissions to `CuaDriver.app`:
   ```bash
   ~/.local/bin/cua-driver permissions grant
   ```

> No manual global `mcp_config.json` edits needed — enabling **AGY Computer Use** activates both the lean desktop MCP proxy and the live preview Sidecar together.

### Option 1: One-Prompt Install Inside Antigravity (Recommended)
Paste this directly into an Antigravity chat:
> Help me install the Antigravity plugin `https://github.com/LuisTheAbysswalker/agy-computer-use`: install the `cua-driver` runtime if missing, clone the repo into `~/.gemini/config/plugins/agy-computer-use` (on Windows: `%USERPROFILE%\.gemini\config\plugins\agy-computer-use`), verify with `npm test`, and guide me through enabling it in Customizations and granting macOS permissions if needed.

### Option 2: Install via AGY Market (GitHub URL)
Open **AGY Market** in Antigravity → click **Add URL (`链接添加`)** → paste:
```text
https://github.com/LuisTheAbysswalker/agy-computer-use
```

### Option 3: Manual CLI Install
- **macOS / Linux**:
  ```bash
  mkdir -p ~/.gemini/config/plugins
  git clone https://github.com/LuisTheAbysswalker/agy-computer-use.git ~/.gemini/config/plugins/agy-computer-use
  ```
- **Windows (PowerShell)**:
  ```powershell
  New-Item -ItemType Directory -Force "$env:USERPROFILE\.gemini\config\plugins" | Out-Null
  git clone https://github.com/LuisTheAbysswalker/agy-computer-use.git "$env:USERPROFILE\.gemini\config\plugins\agy-computer-use"
  ```

### Enable & Verify
1. Open Antigravity **Customizations → Plugins** (`customization://agy-computer-use`) and enable **AGY Computer Use** (reload/refresh MCP once if Antigravity was already running).
2. Try a quick smoke prompt in chat:
   > `Use computer use to open Calculator and calculate 17 * 23.`
   - On **macOS**, the floating PiP pops up automatically in the top-left of the conversation area and tracks Calculator live.
   - On **Windows / Linux**, the Right Split Console opens automatically to stream the target window live.

---

## Architecture

```text
agy-computer-use/
├── plugin.json                  # Antigravity plugin manifest
├── agy-market.json              # AGY Market metadata
├── mcp_config.json              # Bundled lean desktop MCP server registration
├── bin/mcp-proxy.mjs            # Executable stdio MCP filtering proxy
├── sidecars/live_pane/
│   ├── sidecar.json             # AUX_PANE Sidecar registration
│   └── main.mjs                 # Sidecar lifecycle & virtual-display cleanup
├── skills/agy-computer-use/
│   └── SKILL.md                 # Declarative GUI workflow & live preview skill
├── src/
│   ├── shared/                  # Constants, cua-driver discovery, atomic settings, NDJSON framer, child cleanup
│   ├── mcp/                     # Curated tool profiles & crash-recovering fail-closed MCP proxy
│   ├── cua/                     # Persistent MCP bridge, target discovery, coalesced JPEG/PNG ETag capture
│   ├── pip/                     # Native macOS always-on-top NSPanel PiP helper, lifecycle manager & activity bridge
│   ├── cdp/                     # Antigravity left-sidebar CDP settings entry injector (coexists with Powertools)
│   └── sidecar/                 # Loopback auth, HTTP asset cache, popout launcher, server, PiP/Settings/Companion UI
└── tests/                       # Built-in `node --test` unit & integration suite
```

## Development & Testing

```bash
# Run unit & integration tests (zero third-party dependencies)
npm test

# Preview the Sidecar UI standalone in your browser
npm run dev
# Open http://127.0.0.1:47321/?token=dev-token
```

## Credits & Upstream Foundation

- Runtime engine: **[`trycua/cua`](https://github.com/trycua/cua)** (`cua-driver`, MIT License) — this plugin is directly packaged on top of the open-source `cua-driver` runtime for Google Antigravity.

## License

MIT