agy-windows-computer
by HLenu
README.md
<div align="center">
# hybrid-computer-use
**Give your AI agent its own Windows computer — without stealing your mouse, keyboard or focus.**
English | [简体中文](README_CN.md)





</div>
Originally built for **[Antigravity](https://antigravity.google) (`agy`)**, and usable from any MCP client (Claude Desktop, Cursor, Codex, …) as a standard **MCP Server** (JSON-RPC over stdio, zero Python dependencies, 25 tools) and as an **Agent Skill** ([`SKILL.md`](SKILL.md)).
## Why this project
| | Typical approach | hybrid-computer-use |
| :--- | :--- | :--- |
| Host input | Drives your real desktop; you can't work meanwhile | Separate Windows session / desktop / AppContainer; host cursor and focus untouched (verified: foreground handle unchanged) |
| Footprint | Always-on VM or container (GBs of RAM) | Child Session reclaimed when idle or on low host memory; sandbox idles at **0 MB** |
| Fit for a 16 GB host | VM + browser + IDE competes for RAM | Auto-reclaim frees ~1.2–1.4 GB when memory is low |
| Untrusted code | Runs with your user rights | AppContainer + JobObject: no network by default, hard memory/process caps, sealed workspace |
| Setup | Hypervisor, images, licences | Build ~5 small helpers from source with the in-box `csc.exe` |
Two isolation layers, chosen per task (`backend` argument of `computer_create`):
- **`child_session`** — a full second Windows session for a dedicated least-privilege user: real `SendInput`, UI Automation, menus, drag, GPU/Chromium, live preview, human "Take Control".
- **`sandbox`** — headless AppContainer + JobObject for untrusted CLI/scripts/archives. No restart, no Child Session, many instances in parallel.
- `hidden_desktop` — instant `CreateDesktopW` desktop for cheap GUI probes (PostMessage/UIA only).
## Architecture
```mermaid
flowchart TD
C["MCP Client / Agent<br/>(Antigravity, Claude Desktop, Cursor, Codex)"] -->|"JSON-RPC over stdio"| S["mcp_server.py<br/>25 tools"]
S --> M["ComputerManager<br/>computer_id registry, idle / low-memory reclaim, orphan GC"]
M -->|"max 1 active"| CS["Child Session backend<br/>separate Windows session<br/>standard user, zero SYSTEM"]
M -->|"N instances, no session slot"| SB["Sandbox backend<br/>AppContainer + JobObject<br/>headless"]
M -.->|"optional"| HD["Hidden Desktop backend"]
CS --> H["AgyChildSessionHost / AgySessionAgent<br/>GUI, UIA, SendInput, screenshot"]
SB --> R["AgySandboxRunner<br/>provision / exec / cleanup / gc"]
subgraph B1["Isolation boundary 1: Windows session + ACL workspace"]
H
end
subgraph B2["Isolation boundary 2: AppContainer SID + job limits + sealed DACL"]
R
end
```
## Measured performance
All numbers are real-machine results from [`docs/`](docs) (Windows 11 IoT Enterprise LTSC, Ryzen 7 7800X3D, 16 GB RAM with only ~2 GB free during tests, 360 Security + Defender online).
| Area | Result | Source |
| :--- | :--- | :--- |
| Child Session hot reconnect | **9–27 ms** (23 ms in the latest run), state and open apps preserved (Phase 0 baseline: 49 ms) | M1 / M2 reports |
| Child Session cold start | 15.7–17.8 s with reused profile (43.5 s for a brand-new profile) | Phase 0 / M1 / M2 |
| `ping` RTT | P50 **2.46 ms** (baseline 31.4 ms, -92%) | M1 §2.4 |
| `screenshot(base64=False)` | P50 26.9–42.7 ms (baseline 62.4 ms) | M1 §2.4 |
| Child Session RAM | ~1.53–1.64 GB private commit + ~287 MB VRAM while alive | Phase 0 §2.1 |
| Low-memory auto-reclaim | Triggered at 1536 MB threshold; logoff in 7.0 s; free RAM **1353.5 → 2598.1 MB** (+1.22 GB) | M1 §2.3 |
| Sandbox create / exec / destroy | **203 ms** / 55 ms / 213 ms (AppContainer profile 20 ms) | M2 §2.2 |
| Sandbox memory | Idle **0 MB**, peak **7.61 MB** | M2 §2.2 |
| Escape tests | **9/9 blocked**: host profile and secrets, sibling sandboxes, writes to `ProgramData`/`Windows\Temp`, internet, loopback; junction/symlink attacks 10/10 blocked | M2 §2.2 |
| Resource bombs | Memory bomb killed in 105 ms, fork bomb in 359 ms, timeout kill in 1.84 s; 0 leftover processes/profiles/dirs | M2 §2.2 |
| Host disturbance | Foreground window handle unchanged during GUI automation | M1 / M2 |
Raw result JSON is not published (it contains host snapshots); the test suites in `tests/` regenerate it.
## Quick start
Requirements: Windows 10/11 x64 (**Pro / Enterprise / LTSC** for `child_session`), Python 3.10+. Developed and verified on Windows 11 IoT Enterprise LTSC.
```powershell
git clone https://github.com/HLenu/hybrid-computer-use.git
cd hybrid-computer-use
.\native\build.ps1 # 1. compile bin\*.exe from source (uses the .NET Framework csc.exe shipped with Windows)
pip install -e . # 2. editable install is REQUIRED
```
- **Why build locally?** The helpers are small unsigned .NET executables. Distributing unsigned binaries triggers SmartScreen / antivirus false positives and asks you to trust an opaque blob. Source only: compile in seconds and audit `native\*.cs`.
- **Why `pip install -e .`?** The Python package resolves native binaries relative to the repository (`<repo>\bin`). A regular (non-editable) install copies the package away from `bin\` and the helpers will not be found.
- 3. Register the server in your MCP client (below). `sandbox` works immediately; for `child_session` run **once** from an elevated PowerShell: `.\scripts\setup_agent_env.ps1` (creates a standard, non-admin `AgyDesktopAgent` user; revert with `.\scripts\cleanup_agent_env.ps1`).
## Connect your client
**Antigravity** — add the server in *Manage MCP Servers* (raw config) using the JSON below.
**Generic MCP client JSON** (Claude Desktop `claude_desktop_config.json`, Cursor `mcp.json`, …):
```json
{
"mcpServers": {
"agy-windows-computer": {
"command": "agy-computer-mcp",
"env": { "AGY_COMPUTER_BACKEND": "child_session" }
}
}
}
```
If `agy-computer-mcp` is not on `PATH`, use `"command": "C:\\path\\to\\python.exe", "args": ["-m", "agy_computer.mcp_server"]`.
**Codex** (`~/.codex/config.toml`):
```toml
[mcp_servers.agy-windows-computer]
command = "agy-computer-mcp"
```
**Agent Skill** — copy [`SKILL.md`](SKILL.md) into your agent's skills folder (e.g. `<skills-dir>/hybrid-computer-use/SKILL.md`). It tells the agent which backend to pick and how to call every tool.
Tuning env vars: `AGY_IDLE_TIMEOUT_SEC` (300), `AGY_LOW_MEMORY_MB` (1536), `AGY_LOW_MEMORY_IDLE_SEC` (15), `AGY_MIN_SESSION_AGE_SEC` (15), `AGY_LOGOFF_TIMEOUT_SEC` (20), `AGY_REAPER_INTERVAL_SEC` (5).
## The 25 tools
All accept an optional `computer_id` (default `"default"`) except the two pool tools.
| Group | Tools |
| :--- | :--- |
| Lifecycle | `computer_create`, `computer_destroy`, `computer_status` |
| Pool | `computer_list`, `computer_reclaim` |
| Perception | `computer_observe`, `computer_screenshot`, `computer_list_windows`, `computer_inspect_ui` |
| Semantic actions | `computer_invoke`, `computer_set_value` |
| Coordinate input | `computer_click`, `computer_double_click`, `computer_move`, `computer_drag`, `computer_scroll`, `computer_type`, `computer_key` |
| Processes & files | `computer_launch`, `computer_exec`, `computer_upload_file`, `computer_download_file` |
| Control | `computer_pause`, `computer_resume`, `computer_preview` |
`sandbox` supports `exec`, upload/download, status, pause/resume and pool tools; every GUI tool fails fast with an error. See [`SKILL.md`](SKILL.md).
## Security model
- Runtime needs no SYSTEM, no scheduled-task creation and no admin rights; the agent user is a standard user, never in `Administrators`. Credentials are DPAPI-protected.
- Sandbox: per-instance AppContainer SID, protected DACL (no inherited ACEs), process token verified before resume, JobObject memory/process limits, sanitized environment, TOCTOU-safe file transfer, crash-orphan GC.
- Antivirus (360 / Huorong / Defender) notes and threat table: [`SECURITY_AND_AV_MITIGATION.md`](SECURITY_AND_AV_MITIGATION.md). Design details: [`ARCHITECTURE.md`](ARCHITECTURE.md).
## Known limits & roadmap
- Only **one** active Child Session at a time; it needs ~1.5 GB RAM while alive.
- `sandbox` is headless, shares the host kernel (not a VM), and cannot run **.NET Framework 4.x** programs (reported as `runtimeIncompatible`, status `0x8007045A`).
- Backend selection is manual (guided by `SKILL.md`).
- **M3 (planned):** lightweight concurrent Playwright web backend, automatic task routing, JPEG/scaled screenshot encoding (PNG encode currently ~95 ms for base64 screenshots) and DPI handling.
- `tests/` are real-machine regression suites that create sessions and sandboxes; they are not CI tests.
## License
[MIT](LICENSE) © HLenu
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues