Agent Bridge
<div align="center">
<img src="assets/logo.svg" alt="Agent Bridge Logo" width="88" height="88" />
# Agent Bridge v2.2
**Universal Any-App Desktop Automation with Zero-Conflict Virtual Mouse · Cross-Platform (macOS & Windows) Multi-Agent MCP Hub & Hybrid 3D Bridge**
[](#platform-parity-macos--windows)
[](#zero-conflict-virtual-mouse-any-desktop-app)
[-10b981.svg)](#quick-install)
[](#mcp-tools-overview-38-tools)
[](LICENSE)
English | [简体中文](README.zh-CN.md)
</div>
---
**Agent Bridge** is a zero-dependency Python + native OS MCP server & Antigravity plugin across **macOS** and **Windows** that lets AI assistants operate **any desktop software in the background without stealing your physical mouse, keyboard, clipboard, or active window**, while unifying all your local AI coding agents:
1. **Universal Any-App Computer-Use v2.2 with Zero-Conflict Virtual Mouse (macOS Swift + Windows C# / WinRT)**
- **Works with ANY desktop app** — browsers (Chrome, Edge, Safari), Office / WPS, chat & collaboration apps (WeChat, DingTalk, Slack, Feishu), IDEs (VS Code, Cursor, JetBrains, Xcode), creative/CAD suites (Photoshop, Figma, DaVinci Resolve, AutoCAD, Blender), enterprise ERP clients, and native utilities.
- **Zero-Conflict Virtual Mouse & Background Keyboard (Default)**:
- **macOS**: routes mouse clicks/drags/scrolls and Unicode typing directly to the target process via `CGEvent.postToPid(pid)` (`.privateState` source) + `AXUIElement` semantic actions + `screencapture -o -l <wid>` background window capture — **your physical cursor never moves and your foreground app never loses focus**.
- **Windows**: drills into child window handles (`RealChildWindowFromPoint` + `ScreenToClient`) and dispatches `WM_MOUSEMOVE` / `WM_L|R|MBUTTON*` / `WM_MOUSEWHEEL` / `WM_CHAR` via `PostMessage` + `UIAutomation` patterns + `PrintWindow(PW_RENDERFULLCONTENT)` background capture.
- **Zero Clipboard Clobbering**: virtual Unicode typing injects Chinese/CJK & multiline text directly without overwriting the user's clipboard.
- **Smart `saved_restore` Fallback**: if a custom-rendered Chromium/Electron or DirectX/Metal app ignores background events, `input_mode="saved_restore"` waits until the user's physical input is idle (`>= 350ms` via `secondsSinceLastEventType` / `GetLastInputInfo`), executes, and immediately restores the cursor to its exact original position.
- **Offline Chinese + English OCR + Set-of-Marks (SoM) + Grid Overlay**: `Apple Vision` on macOS and built-in WinRT `Windows.Media.Ocr` on Windows locate buttons/text even inside OpenGL/Metal/DirectX/Canvas UIs.
- **Zero pip dependencies, zero external SDKs**: compiles in ~2 seconds using built-in `swiftc` on macOS and built-in `.NET Framework 4.x csc.exe` + PowerShell 5.1 WinRT on Windows 10/11!
2. **Extensible Multi-Agent Hub (8 Built-in + Zero-Code Custom Registry)**
- Built-in native adapters for **OpenAI Codex**, **Claude Code / Desktop**, **Tencent WorkBuddy**, **DeepSeek Harness (`dsh`)**, **OpenCode**, **Trae CN / Trae**, **VS Code**, and **Cursor**.
- Discovers local projects, reads SQLite/JSONL/`.zst` session transcripts & agent memories (`AGENTS.md`, `CLAUDE.md`, `MEMORY.md`), and supports both **headless CLI** (`channel="cli"`) and **live visible Desktop UI chat** (`channel="desktop"`).
- **Zero-code extension**: dynamically register any new CLI tool (`gemini_cli`, `aider`, `cursor_agent`, `qwen_code`, `goose`, `kimi_cli`, `openhands`, or your own) with `bridge_register_agent`.
3. **Dependency-Aware Multi-Agent Orchestrator**
- Create persistent DAG task plans (`collab_create_plan`), dispatch independent agents in parallel (`collab_dispatch_task`) with automatic upstream handoff context injection, monitor status, and synthesize Markdown + Git handoff reports.
4. **Optional Hybrid Blender 3D Bridge (4.x / 5.x)**
- Specialized bonus bridge for Blender 3D modeling: live GUI `bpy`/`bmesh` TCP socket (`127.0.0.1:9876`) + headless `--background` batch execution + multi-angle visual verification renders (`iso`, `front`, `side`, `top`) + `.blend`/`.glb`/`.obj`/`.stl`/`.fbx`/`.usdz` export.
---
## Zero-Conflict Virtual Mouse (Any Desktop App)
Every `cua_mouse`, `cua_keyboard`, and `cua_batch_actions` call supports a 3-tier input isolation strategy, defaulting to **`virtual`**:
| `input_mode` | Physical Mouse Moved? | Steals Active Window Focus? | Clobbers Clipboard? | Best Used For |
| :--- | :---: | :---: | :---: | :--- |
| **`virtual`** *(Default)* | **No (0 px)** | **No** | **No** | Everyday background automation of any app (native macOS/Win32/Qt/WPF/Cocoa/Java apps, browsers, chat, Office, IDEs) while you keep working normally. |
| **`saved_restore`** | Briefly, then **restored** after user idle (`≥ 350ms`) | Only if app requires focus | Restores clipboard | Fallback for custom Chromium/Electron canvases or DirectX/Metal/OpenGL viewports that ignore background OS messages. |
| **`physical`** | Yes | Yes | Restores clipboard | Explicit foreground takeover when requested by the user (e.g., OS-level drag across apps or security prompts). |
> **Recommended Priority Ladder**:
> 1. Semantic UI actions first (`cua_element_action` via `AXUIElement` / `UIAutomation`) — zero cursor movement, 100% background-safe.
> 2. Background capture + Virtual Pointer (`cua_screenshot(target="window", app_name=..., annotate="ocr"|"som")` → `cua_mouse(..., input_mode="virtual", app_name=...)` / `cua_keyboard(..., input_mode="virtual")`).
> 3. Idle-yielding fallback (`input_mode="saved_restore"`) only if a target app ignores background events.
---
## Platform Parity (macOS & Windows)
| Capability | macOS (Apple Silicon / Intel) | Windows 10 / 11 (x64 / ARM64) |
| :--- | :--- | :--- |
| **MCP Server Core** | Pure Python 3.9+ stdlib | Pure Python 3.9+ stdlib (UTF-8 stdio) |
| **Native CUA Helper** | `native/mac_cua.swift` → `bin/mac-cua-helper` (`swiftc`) | `native/win_cua.cs` → `bin/win-cua-helper.exe` (built-in `.NET 4.x csc.exe`) |
| **Virtual Mouse & Keyboard** | `CGEvent.postToPid(pid)` (`.privateState` source, UTF-16 Unicode) | Win32 `PostMessage` (`WM_*` / `WM_CHAR`) to drilled child `HWND` |
| **User-Idle Priority Guard** | `CGEventSource.secondsSinceLastEventType` (`user_idle_ms`) | Win32 `GetLastInputInfo` (`user_idle_ms`) |
| **Background Window Capture** | `screencapture -x -o -l <wid>` *(drop-shadow stripped)* + Stage Manager discovery | `PrintWindow(PW_RENDERFULLCONTENT)` *(occluded window capture)* + DWM bounds |
| **Offline OCR (ZH + EN)** | Apple Vision Neural Engine (`VNRecognizeTextRequest`) | Built-in WinRT `Windows.Media.Ocr` (`native/win_ocr.ps1`) + optional `rapidocr-onnxruntime` |
| **UI Tree & Semantic Actions** | `AXUIElement` (`AXPress`, `AXSetValue`, `AXFocus`) | Windows `UIAutomation` (`InvokePattern`, `ValuePattern`, `TogglePattern`, `SetFocus`) |
| **3D / CAD & Precision Input** | Middle-drag, modifiers, full Numpad, Esc emergency abort | Middle-drag, modifiers, full Numpad, Unicode, Esc emergency abort |
| **OS Scripting Action** | `cua_app_control(action="applescript")` | `cua_app_control(action="powershell")` |
| **8 Built-in Agent Adapters** | `/Applications/*.app`, `~/Library/Application Support/*`, `~/.{codex,claude,workbuddy,dsh}` | `%LOCALAPPDATA%\Programs\*`, `%APPDATA%\*`, `%USERPROFILE%\.{codex,claude,workbuddy,dsh}` |
| **Blender Hybrid Bridge** | Auto-detects `/Applications/Blender.app` | Auto-detects `Blender Foundation\Blender *\blender.exe` (newest first) |
---
## Quick Install
### Prerequisites
- **Python 3.9+** (standard library only — zero `pip install` needed)
- **macOS**: Xcode Command Line Tools (`xcode-select --install`) for compiling `mac-cua-helper`
- **Windows 10 / 11**: Nothing extra! Built-in `.NET Framework 4.x` (`csc.exe`) and `PowerShell 5.1` are pre-installed on Windows.
### macOS (One Command)
```bash
git clone https://github.com/Romeo-romeoo/agent-bridge.git
cd agent-bridge
bash scripts/install.sh
```
> Developer symlink mode (edits in repo apply immediately to Antigravity):
> `bash scripts/install.sh --link`
### Windows (PowerShell One Command)
```powershell
git clone https://github.com/Romeo-romeoo/agent-bridge.git
cd agent-bridge
powershell -ExecutionPolicy Bypass -File scripts\install.ps1
```
> Want to also wire Codex's native MCP server if `codex` is installed? Add `--with-codex-mcp`.
> Want to only compile & test inside the repo without installing to `~/.gemini/config/plugins/`? Add `--skip-plugin-install`.
---
## Using with Any MCP Client (Antigravity / Claude Desktop / Cursor / VS Code)
### Antigravity (Recommended — Full Plugin Bundle)
Running `install.sh` / `install.ps1` installs the full plugin (MCP server + 4 Skills + Always-On Safety Rules + Coordinator Subagent) directly into:
- **macOS**: `~/.gemini/config/plugins/agent-bridge`
- **Windows**: `%USERPROFILE%\.gemini\config\plugins\agent-bridge`
### Standalone MCP Configuration (Claude Desktop / Cursor / VS Code)
**macOS**:
```json
{
"mcpServers": {
"agent-bridge": {
"command": "python3",
"args": ["/path/to/agent-bridge/server/mcp_server.py"],
"env": {
"PYTHONUNBUFFERED": "1",
"PYTHONIOENCODING": "utf-8"
}
}
}
}
```
**Windows**:
```json
{
"mcpServers": {
"agent-bridge": {
"command": "python",
"args": ["C:\\path\\to\\agent-bridge\\server\\mcp_server.py"],
"env": {
"PYTHONUNBUFFERED": "1",
"PYTHONIOENCODING": "utf-8"
}
}
}
}
```
---
## OS Permissions & Setup Notes
### macOS
To use Computer-Use (`cua_*`) or Desktop Live Chat (`channel="desktop"`), grant these toggles in **System Settings → Privacy & Security** to your host IDE/terminal (e.g. Antigravity / Terminal / iTerm2):
1. **Accessibility** (for `AXUIElement`, virtual `postToPid` mouse/keyboard synthesis, window tiling)
2. **Screen & System Audio Recording** (for background window screenshots and Apple Vision OCR)
### Windows 10 / 11
- Standard user privileges work out-of-the-box for all normal apps (browsers, Office, WeChat, VS Code, Cursor, Blender, Electron apps).
- **Automating Admin/UAC windows**: Windows UIPI blocks non-elevated processes from sending input (`PostMessage` / `SendInput`) to Administrator windows; launch your host IDE as Administrator only if you need to control elevated apps.
- **Chinese/English OCR**: Uses built-in Windows 10/11 OCR language packs automatically. If your Windows image lacks an OCR pack (e.g., LTSC/Server), either add a Windows language capability or install the optional fallback:
```powershell
pip install rapidocr-onnxruntime
```
---
## MCP Tools Overview (38 Tools)
| Category | Tools |
| :--- | :--- |
| **Universal Computer-Use v2.2 (12)** | `cua_status`, `cua_screenshot` *(background window / SoM / OCR / Grid)*, `cua_ocr`, `cua_ui_tree`, `cua_find_elements`, `cua_element_action`, `cua_mouse` *(virtual mouse default / saved_restore / 3D middle drag)*, `cua_keyboard` *(virtual Unicode typing / Numpad / hold)*, `cua_app_control` *(window tiling / AppleScript / PowerShell)*, `cua_clipboard`, `cua_wait_for`, `cua_batch_actions` |
| **Agent Discovery & Extensibility (8)** | `bridge_list_agents`, `bridge_list_projects`, `bridge_list_sessions`, `bridge_read_session`, `bridge_read_agent_knowledge`, `bridge_register_agent`, `bridge_unregister_agent`, `bridge_list_agent_presets` |
| **Safe Workspace Inspection (4)** | `bridge_project_tree`, `bridge_read_file` *(blocks secrets/keys)*, `bridge_search_files`, `bridge_project_git` |
| **Live Chat & Channel Control (4)** | `bridge_chat` *(CLI or Desktop UI)*, `bridge_set_channel`, `bridge_get_channel`, `bridge_codex_computer_use` |
| **Multi-Agent Orchestrator (5)** | `collab_create_plan`, `collab_dispatch_task`, `collab_get_status`, `collab_cancel_task`, `collab_handoff_summary` |
| **Hybrid Blender 3D Bridge (5)** | `blender_status`, `blender_launch`, `blender_execute`, `blender_inspect_scene`, `blender_render_preview` |
Plus **4 MCP Resources** (`agent-bridge://status`, `agent-bridge://projects`, `agent-bridge://plans`, `agent-bridge://blender`) and **4 MCP Prompts** (`continue_agent_project`, `multi_agent_sprint`, `desktop_computer_use`, `blender_3d_modeling`).
---
## Security Guardrails
- **Zero-Conflict by Default**: Virtual Mouse & Keyboard avoid hijacking the user's physical cursor, focus, or clipboard, while `saved_restore` automatically yields when the user is actively moving the mouse or typing.
- **Credential Protection**: `bridge_read_file` and `bridge_search_files` automatically block sensitive files (`auth.json`, `.credentials.yaml`, `trae-jwt-token`, `.env*`, `.ssh/*`, `.aws/*`, `.gnupg/*`, `*.pem`, `*.key`, `.npmrc`, `.netrc`).
- **Emergency Escape Abort**: Every mouse drag, typing chunk, wait loop, and batch macro step checks live hardware `Escape` key state so the user can abort automation instantaneously on both macOS and Windows.
- **Audit Trail**: Every GUI mutation is appended to `~/.agent-bridge/audit.jsonl`.
---
## Development & Testing
```bash
# macOS: compile Swift helper
bash scripts/build_native.sh
# Windows PowerShell: compile C# helper
powershell -ExecutionPolicy Bypass -File scripts\build_native.ps1
# Run full cross-platform unit test suite
python3 -m unittest discover -s tests -v # macOS
python -m unittest discover -s tests -v # Windows
# Run end-to-end MCP stdio verification
python3 scripts/self_test.py # macOS
python scripts\self_test.py # Windows
```
---
## License
[MIT](LICENSE)
TDQS
Scored across 38 tools
The four domain prefixes (cua_, bridge_, blender_, collab_) make the tool set broadly easy to navigate, and most tools have a clearly distinct resource/action. Some overlap remains within CUA (cua_screenshot with annotate, cua_ocr, cua_find_elements, and cua_ui_tree all help locate elements), and cua_batch_actions overlaps with individual cua_mouse/cua_keyboard/cua_app_control primitives, but the descriptions generally clarify when to use each.
All names use consistent snake_case with clear domain prefixes, which makes the set predictable. There are minor deviations from a strict verb_noun pattern, such as noun-only tools (cua_mouse, cua_keyboard, cua_status, blender_status) and noun_verb-style names (bridge_project_tree, bridge_project_git), but the convention is still readable and grouped coherently.
At 38 tools, the server is heavy for a single MCP surface and exceeds the typical well-scoped range. The breadth is explained by four large sub-domains (computer use, agent bridge, Blender, multi-agent collaboration), but the total is still likely to overwhelm agents and make discovery harder.
The surface covers a lot: agent registration/listing/session reading/chat, extensive computer-use primitives, Blender launch/execute/inspect/render, and collaborative plan dispatch/status/cancel/handoff. Minor gaps exist, such as no direct project file write/edit tool and no explicit plan update/delete operation, but most workflows have a workable path.