Skip to main content
Glama
README.md
# Antigravity Hands

**Give Google Antigravity Codex-level hands and eyes across macOS, Windows, and Linux.**

English | [简体中文](./README_ZH.md) | [Changelog](./CHANGELOG.md)

`antigravity-hands` is an open-source, native **Computer Use plugin & MCP server** built specifically for **Google Antigravity** — working seamlessly across **Antigravity CLI (`agy`)**, **Antigravity Desktop App**, and **Antigravity IDE**.

It combines **accessibility-tree-first semantic control**, **a Codex `cua_repl`-inspired persistent JS sandbox (`hands_script`)**, **in-memory `ScreenCaptureKit` + native offline Chinese/English OCR**, **Set-of-Marks numbered screenshot grounding**, **lossless CJK/Unicode input**, **screenshot-invisible HUD glow**, and **instant `Esc` / mouse-takeover emergency stop**.

<p align="center">
  <img src="https://raw.githubusercontent.com/ye4wzp/antigravity-hands/main/docs/media/som-demo.png" alt="Set-of-Marks numbered UI grounding on macOS Calculator (computed 7x8=56 in the background via AXPress)" width="260" />
  <br />
  <sub>Real macOS capture: <code>7 × 8 = 56</code> executed 100% in the background via <code>AXPress</code> (zero focus steal), followed by Set-of-Marks (<code>annotate: true</code>) numbered grounding with screenshot-invisible HUD.</sub>
</p>

---

## Why Antigravity Hands?

| Capability | Typical Screenshot MCP | Antigravity Hands (v0.5) |
| :--- | :--- | :--- |
| **Multi-Step Loops** | 1 LLM turn per click/scroll | **Codex-style `hands_script` JS sandbox** (`if`/`for`/`while`, persistent `state`) + native `repeat` bursting |
| **Element Targeting** | Fragile pixel coordinates | **Hybrid `hands_observe`** (AX/UIA tree `@e1` + auto native CJK/EN OCR `@m1`) + **Set-of-Marks** badges |
| **Capture Speed** | Slow CLI temp PNGs (1.5MB+) | **In-memory macOS `ScreenCaptureKit`** + compact JPEG + blank/black-frame guard |
| **Focus & Cursor** | Constantly hijacks your screen | **Background AX/UIA first**; 4-step smart un-minimize/reopen; automatic focus, cursor & clipboard restore |
| **Chinese / CJK / IME** | Garbled keys or broken IME | **Lossless clipboard paste** with automatic binary clipboard backup & restore |
| **Human-in-the-Loop UX** | Blind cursor movement | **Screenshot-invisible window glow HUD + click pulse**, **`Esc` stop**, mouse-takeover yield, `<1ms` `SIGUSR1` Stop hook |
| **Antigravity Native** | Manual JSON wiring | Full **Antigravity Plugin** (`plugin.json` + `mcp_config.json` + `hooks.json` + `skills/` + `rules/`), clean `antigravity-hands_cua/*` namespace |

---

## Codex-Style `hands_script` Example

Instead of spending 10 LLM round-trips scrolling and guessing coordinates, Antigravity can drive an entire multi-step desktop workflow in **one `hands_script` call** (all guarded by password-field refusal, destructive-action blocking, HUD glow, and `Esc` abort):

```js
await hands.focus("WPS Office");
await hands.doubleClick({ app: "WPS Office", ocr_text: "Quarterly_Deck.pptx" });
await hands.waitFor({ app: "WPS Office", ocr_text: "/38", timeout_ms: 8000 });
await hands.key("pagedown", { repeat: 29, delay_ms: 35 }); // native ~1s burst
await hands.wait(250);
const p30 = await hands.observe("WPS Office");
return { title: p30.window_title, lines: p30.lines.slice(0, 10) };
```

---

## Quick Start

### One-Command Install (macOS / Windows / Linux)

Requires **Node.js 22+** — no Swift, .NET, or Rust toolchain needed. The installer automatically downloads the SHA-256-verified prebuilt native driver for your platform from GitHub Releases and installs a self-contained plugin into Antigravity (`agy` CLI, Desktop App, and IDE):

```bash
npx -y antigravity-hands install
npx -y antigravity-hands doctor
```

> Prefer a workspace-only install? Run `npx -y antigravity-hands install --workspace`.

### Grant macOS System Permissions
Open **System Settings → Privacy & Security** and enable your host app (**Terminal / iTerm / Antigravity**):
1. **Accessibility**
2. **Screen & System Audio Recording**

Restart Antigravity / your terminal once after granting permissions, then try:

```text
/antigravity-hands:computer-use Open Notes, create a note titled "Daily Plan", and add 3 items.
```

Press **`Esc`** (or move your mouse sharply away) at any time to immediately halt automation and release all modifier keys.

### Build from Source (Contributors)

```bash
git clone https://github.com/ye4wzp/antigravity-hands.git
cd antigravity-hands

npm install
npm run build:all          # Builds TypeScript core + signed macOS Swift driver
npm test                   # Runs unit, sandbox & MCP protocol tests
node dist/cli.js install
node dist/cli.js doctor
```

---

## MCP Tools (13 High-Cohesion Tools)

| Tool | Purpose |
| :--- | :--- |
| `hands_script` | **Codex-style persistent async JS sandbox** for loops, conditionals, and multi-step workflows |
| `hands_observe` | Hybrid observer (`mode: "auto" \| "ax" \| "ocr" \| "both"`) merging `@e1` AX nodes + `@m1` offline OCR |
| `hands_screenshot` | Silent window capture (fast compact JPEG) with `annotate: true` Set-of-Marks numbered badges |
| `hands_list_windows` | Single-call compact `[VISIBLE]` + `[MINIMIZED / OTHER SPACE]` window listing |
| `hands_focus_app` | Smart 4-step wake (unhide → activate → un-minimize → reopen/launch) returning fresh `window_id` & `bounds` |
| `hands_click` | Click / double-click / right-click by `@ref`, semantic `{label, role}`, `ocr_text`, or `(x, y)` |
| `hands_type_text` | Lossless CJK/Unicode clipboard paste or background `AXSetValue` (blocks password fields) |
| `hands_key` | Single key or shortcut chord with native `repeat` & `delay_ms` bursting |
| `hands_scroll` / `hands_drag` | Scroll (with native `repeat`) and smooth mouse drag |
| `hands_wait_for` | Poll live AX tree or native OCR until target appears |
| `hands_batch` | Linear multi-step batching with auto HUD glow and optional `final_observe: true` |
| `hands_status` | Compact health, permissions, capabilities, and emergency-stop check/reset |

---

## Platform Support Matrix

| Platform | Driver | Status |
| :--- | :--- | :--- |
| **macOS** (Apple Silicon & Intel) | `drivers/macos` (Swift) | **v0.5 Complete** (In-memory `ScreenCaptureKit`, AX dedup + background `AXPress`/`AXSetValue`, Vision CJK OCR, SoM badges, lossless clipboard, smart un-minimize, blank-frame guard, native `repeat`, multi-monitor glow HUD + click pulse, `Esc`/mouse-yield, `SIGUSR1` Stop hook) |
| **Windows** (x64 & ARM64) | `drivers/windows` (C# .NET 8) | **v0.5 Feature-Complete + CI Ready** (UIA tree + background `Invoke`/`Value`, `PrintWindow` + SoM badges, WinRT OCR, `SendInput` + native `repeat` + lossless clipboard, `WDA_EXCLUDEFROMCAPTURE` glow HUD, `WH_KEYBOARD_LL` `Esc` hook) |
| **Linux** (X11 / Wayland) | `drivers/linux` (Rust) | **v0.5 Functional + CI Ready** (`wmctrl`/`xdotool` windows & native `repeat` input, lossless `xclip`/`wl-copy` clipboard, `import`/`scrot`/`grim` screenshots, `tesseract` CJK/EN OCR) |

---

## Documentation & Contributing

- [Architecture Guide](./docs/ARCHITECTURE.md)
- [Native Driver Protocol (v1.0)](./docs/DRIVER_PROTOCOL.md)
- [Contributing Guide](./CONTRIBUTING.md)

## License

[MIT](./LICENSE)