pi-cua-integration

May 13, 2026 · View on GitHub

ci license: MIT

Cua (trycua/cua) computer-use integration for the pi coding agent.

pi-cua-integration exposes Cua sandboxes (local Docker / QEMU / Lume / Tart and optional cloud) plus unsandboxed Localhost host control as Pi tools and skills. Local mode is the default. No Cua account is required to use it.

Modes

ModeWhere actions runSandboxNeeds API keyRuntimes
localLocal container or VMyesnoDocker (XFCE/Kasm), QEMU, Lume, Tart
localhostYour host machinenonocua-auto (pynput + Pillow/AppKit)
cloudcua.ai-hosted VMyesCUA_API_KEYCua cloud regions

★ default. If mode: "cloud" is selected but CUA_API_KEY is missing, the extension falls back to local with a warning.

Quick start

# 1. Install
pi install npm:pi-cua-integration
pip install cua

# 2. (Optional) project policy
mkdir -p .pi && cat > .pi/cua.jsonc <<'EOF'
{
  "mode": "local",
  "local": {
    "runtime": "docker",
    "image": { "os": "linux", "kind": "container" }
  }
}
EOF

# 3. Run pi
pi

When the session starts you should see [pi-cua] ready (mode=local, ...).

Tools

ToolPurpose
cua_sandbox_startStart (or reconnect) a sandbox
cua_sandbox_stopDestroy a sandbox
cua_sandbox_listList active sandboxes
cua_screenshotCapture a PNG screenshot
cua_clickClick at (x, y)
cua_typeType text
cua_keyPress a key chord (ctrl+s, Return, etc.)
cua_scrollScroll at coordinates

See docs/TOOLS.md for full schemas and examples.

Skills

The extension contributes five markdown skills via the resources_discover event. Pi's skill loader can auto-discover them, and the agent learns when to use the tools without prompt engineering.

SkillWhen the agent loads it
cua-overviewAnytime any cua_* tool comes up
cua-local-sandboxLocal Docker/QEMU/Lume sandbox details
cua-localhostUnsandboxed host control safety notes
cua-cloud-sandboxCloud (cua.ai) sandbox configuration
cua-controlMouse / keyboard / scroll primitives

See docs/SKILLS.md.

Configuration

Policy lives in JSONC files (project beats global, key-by-key merge):

  • .pi/cua.jsonc - project policy
  • ~/.pi/cua.json - global user policy

Schema: schema/cua.schema.json. Regenerate with npm run generate:schema.

See docs/CONFIG.md for the full schema and annotated examples.

Environment variables

VariableDefaultPurpose
CUA_API_KEYunsetRequired for mode: "cloud". Env name configurable.
CUA_TELEMETRY_ENABLEDfalse (forced off)Cua opt-out; this extension forces it off unless overridden.
ANTHROPIC_API_KEY etc.unsetThe pi agent that drives cua reads these for its own LLM calls.

Architecture

+--------------------------------------------------+
|  pi-mono session                                  |
|  +---------------------------------------------+  |
|  |  pi-cua-integration extension (TypeScript)   |  |
|  |   - skills via resources_discover            |  |
|  |   - tools via pi.registerTool                |  |
|  |   - /cua command via pi.registerCommand      |  |
|  |                ^                             |  |
|  |                | JSON-RPC over stdio          |  |
|  |                v                             |  |
|  |   python/daemon.py (Python subprocess)       |  |
|  |   - manages Sandbox/Localhost instances      |  |
|  |   - delegates to cua + cua-auto              |  |
|  +---------------------------------------------+  |
+--------------------------------------------------+

Documentation

Development

npm install
npm run check
npm test

Manual QA scripts live in scripts/qa-*.sh once written. The Python daemon contract is verified by test/integration/python-daemon.test.ts (gated by PI_CUA_INTEGRATION_TEST=1).

License

MIT - see LICENSE and NOTICE.