Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat: auto-generated SDK docs, Python CLI, and docs improvements (#1040)

Francesco Bonacci174ae253badb
diff --git a/.github/workflows/cd-py-agent.yml b/.github/workflows/cd-py-agent.yml
index 9eee5dc902..4041070585 100644
--- a/.github/workflows/cd-py-agent.yml
+++ b/.github/workflows/cd-py-agent.yml
@@ -181,23 +181,4 @@ jobs:
release_name: "cua-agent v${{ needs.prepare.outputs.version }}"
module_path: "libs/python/agent"
body: |
- ## Dependencies
- * cua-computer: ${{ needs.prepare.outputs.computer_version }}
- * cua-som: ${{ needs.prepare.outputs.som_version }}
-
- ## Installation Options
-
- ### Basic installation with Anthropic
- ```bash
- pip install cua-agent[anthropic]==${{ needs.prepare.outputs.version }}
- ```
-
- ### With SOM (recommended)
- ```bash
- pip install cua-agent[som]==${{ needs.prepare.outputs.version }}
- ```
-
- ### All features
- ```bash
- pip install cua-agent[all]==${{ needs.prepare.outputs.version }}
- ```
+ **Dependencies:** cua-computer ${{ needs.prepare.outputs.computer_version }}, cua-som ${{ needs.prepare.outputs.som_version }}
diff --git a/.github/workflows/cd-py-bench-ui.yml b/.github/workflows/cd-py-bench-ui.yml
index 0752799f7c..c01122928c 100644
--- a/.github/workflows/cd-py-bench-ui.yml
+++ b/.github/workflows/cd-py-bench-ui.yml
@@ -70,11 +70,4 @@ jobs:
with:
tag_name: "bench-ui-v${{ needs.prepare.outputs.version }}"
release_name: "cua-bench-ui v${{ needs.prepare.outputs.version }}"
- body: |
- ## Lightweight webUI window controller for Cua bench
-
- ## Installation
-
- ```bash
- pip install cua-bench-ui==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-bench.yml b/.github/workflows/cd-py-bench.yml
index aafde57892..defa065e8a 100644
--- a/.github/workflows/cd-py-bench.yml
+++ b/.github/workflows/cd-py-bench.yml
@@ -70,11 +70,4 @@ jobs:
with:
tag_name: "bench-v${{ needs.prepare.outputs.version }}"
release_name: "cua-bench v${{ needs.prepare.outputs.version }}"
- body: |
- ## Toolkit for computer-use RL environments and benchmarks
-
- ## Installation
-
- ```bash
- pip install cua-bench==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-cli.yml b/.github/workflows/cd-py-cli.yml
new file mode 100644
index 0000000000..5a69d90474
--- /dev/null
+++ b/.github/workflows/cd-py-cli.yml
@@ -0,0 +1,74 @@
+name: "CD: cua-cli (PyPI)"
+
+on:
+ push:
+ tags:
+ - "cli-v*"
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "Version to publish (without v prefix)"
+ required: true
+ default: "0.1.0"
+ workflow_call:
+ inputs:
+ version:
+ description: "Version to publish"
+ required: true
+ type: string
+
+# Adding permissions at workflow level
+permissions:
+ contents: write
+
+jobs:
+ prepare:
+ runs-on: macos-latest
+ outputs:
+ version: ${{ steps.get-version.outputs.version }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Determine version
+ id: get-version
+ run: |
+ # Check inputs.version first (set by workflow_call)
+ if [ -n "${{ inputs.version }}" ]; then
+ VERSION=${{ inputs.version }}
+ elif [ "${{ github.event_name }}" == "push" ]; then
+ # Extract version from tag (for package-specific tags)
+ if [[ "${{ github.ref }}" =~ ^refs/tags/cli-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
+ VERSION=${BASH_REMATCH[1]}
+ else
+ echo "Invalid tag format for cli"
+ exit 1
+ fi
+ elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
+ # Use version from workflow dispatch
+ VERSION=${{ github.event.inputs.version }}
+ else
+ echo "No version provided"
+ exit 1
+ fi
+ echo "VERSION=$VERSION"
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
+
+ publish:
+ needs: prepare
+ uses: ./.github/workflows/py-reusable-publish.yml
+ with:
+ package_name: "cli"
+ package_dir: "libs/python/cua-cli"
+ version: ${{ needs.prepare.outputs.version }}
+ base_package_name: "cua-cli"
+ secrets:
+ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
+
+ create-release:
+ needs: [prepare, publish]
+ uses: ./.github/workflows/release-github-reusable.yml
+ with:
+ tag_name: "cli-v${{ needs.prepare.outputs.version }}"
+ release_name: "cua-cli v${{ needs.prepare.outputs.version }}"
+ module_path: "libs/python/cua-cli"
+ body: ""
diff --git a/.github/workflows/cd-py-computer-server.yml b/.github/workflows/cd-py-computer-server.yml
index a9d7b09c99..f6a5bbfb43 100644
--- a/.github/workflows/cd-py-computer-server.yml
+++ b/.github/workflows/cd-py-computer-server.yml
@@ -88,20 +88,4 @@ jobs:
tag_name: "computer-server-v${{ needs.prepare.outputs.version }}"
release_name: "cua-computer-server v${{ needs.prepare.outputs.version }}"
module_path: "libs/python/computer-server"
- body: |
- ## Computer Server for the Computer Universal Automation (Cua) project
-
- A FastAPI-based server implementation for computer control.
-
- ## Usage
-
- ```bash
- # Run the server
- cua-computer-server
- ```
-
- ## Installation
-
- ```bash
- pip install cua-computer-server==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-computer.yml b/.github/workflows/cd-py-computer.yml
index 38ecd368bf..7fadc87795 100644
--- a/.github/workflows/cd-py-computer.yml
+++ b/.github/workflows/cd-py-computer.yml
@@ -163,11 +163,4 @@ jobs:
tag_name: "computer-v${{ needs.prepare.outputs.version }}"
release_name: "cua-computer v${{ needs.prepare.outputs.version }}"
module_path: "libs/python/computer"
- body: |
- ## Computer control library for the Computer Universal Automation (Cua) project
-
- ## Installation
-
- ```bash
- pip install cua-computer==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-core.yml b/.github/workflows/cd-py-core.yml
index f979914d7d..1795f0e021 100644
--- a/.github/workflows/cd-py-core.yml
+++ b/.github/workflows/cd-py-core.yml
@@ -71,11 +71,4 @@ jobs:
tag_name: "core-v${{ needs.prepare.outputs.version }}"
release_name: "cua-core v${{ needs.prepare.outputs.version }}"
module_path: "libs/python/core"
- body: |
- ## Base package for Cua project with telemetry and core utilities
-
- ## Installation
-
- ```bash
- pip install cua-core==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-mcp-server.yml b/.github/workflows/cd-py-mcp-server.yml
index 15f3945ebb..b7c8c42b00 100644
--- a/.github/workflows/cd-py-mcp-server.yml
+++ b/.github/workflows/cd-py-mcp-server.yml
@@ -165,40 +165,4 @@ jobs:
tag_name: "mcp-server-v${{ needs.prepare.outputs.version }}"
release_name: "cua-mcp-server v${{ needs.prepare.outputs.version }}"
module_path: "libs/python/mcp-server"
- body: |
- ## MCP Server for the Computer-Use Agent (Cua)
-
- This package provides MCP (Model Context Protocol) integration for Cua agents, allowing them to be used with Claude Desktop, Cursor, and other MCP clients.
-
- ## Usage
-
- ```bash
- # Run the MCP server directly
- cua-mcp-server
- ```
-
- ## Claude Desktop Integration
-
- Add to your Claude Desktop configuration (~/.config/claude-desktop/claude_desktop_config.json or OS-specific location):
-
- ```json
- "mcpServers": {
- "cua-agent": {
- "command": "cua-mcp-server",
- "args": [],
- "env": {
- "CUA_AGENT_LOOP": "OMNI",
- "CUA_MODEL_PROVIDER": "ANTHROPIC",
- "CUA_MODEL_NAME": "claude-3-opus-20240229",
- "ANTHROPIC_API_KEY": "your-api-key",
- "PYTHONIOENCODING": "utf-8"
- }
- }
- }
- ```
-
- ## Installation
-
- ```bash
- pip install cua-mcp-server==${{ needs.prepare.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-py-som.yml b/.github/workflows/cd-py-som.yml
index dd72b20e76..c85f024759 100644
--- a/.github/workflows/cd-py-som.yml
+++ b/.github/workflows/cd-py-som.yml
@@ -75,13 +75,4 @@ jobs:
tag_name: "som-v${{ needs.determine-version.outputs.version }}"
release_name: "cua-som v${{ needs.determine-version.outputs.version }}"
module_path: "libs/python/som"
- body: |
- ## Computer Vision and OCR library for detecting and analyzing UI elements
-
- This package provides enhanced UI understanding capabilities through computer vision and OCR.
-
- ## Installation
-
- ```bash
- pip install cua-som==${{ needs.determine-version.outputs.version }}
- ```
+ body: ""
diff --git a/.github/workflows/cd-swift-lume.yml b/.github/workflows/cd-swift-lume.yml
index eae3a973ff..de57a86017 100644
--- a/.github/workflows/cd-swift-lume.yml
+++ b/.github/workflows/cd-swift-lume.yml
@@ -53,9 +53,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- - name: Select Xcode 16.2
+ - name: Select Xcode 16
run: |
- sudo xcode-select -s /Applications/Xcode_16.2.app
+ sudo xcode-select -s /Applications/Xcode_16.app
xcodebuild -version
- name: Install dependencies
diff --git a/.github/workflows/ci-check-docs.yml b/.github/workflows/ci-check-docs.yml
index 7f37b25097..9bb726ac06 100644
--- a/.github/workflows/ci-check-docs.yml
+++ b/.github/workflows/ci-check-docs.yml
@@ -10,13 +10,16 @@ on:
# MCP Server (Python)
- "libs/python/mcp-server/src/**"
# Computer SDK
- - "libs/python/computer/src/**"
+ - "libs/python/computer/computer/**"
- "libs/typescript/computer/src/**"
# Agent SDK
- - "libs/python/agent/src/**"
+ - "libs/python/agent/agent/**"
- "libs/typescript/agent/src/**"
+ # Cua-Bot
+ - "libs/cuabot/src/**"
# Documentation files themselves
- "docs/content/docs/cua/reference/**"
+ - "docs/content/docs/cuabot/reference/**"
# Generator scripts
- "scripts/docs-generators/**"
@@ -28,7 +31,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
- fetch-depth: 2 # Need history for changed file detection
+ fetch-depth: 0 # Need full history for git tags (version discovery) and changed file detection
- name: Setup Node.js
uses: actions/setup-node@v4
@@ -42,6 +45,14 @@ jobs:
run: pnpm install
working-directory: docs
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Install Python doc dependencies
+ run: pip install -r scripts/docs-generators/requirements.txt
+
- name: Determine changed generators
id: changed
run: |
@@ -68,14 +79,14 @@ jobs:
GENERATORS="$GENERATORS mcp-server"
fi
- # Computer SDK changes
- if echo "$CHANGED_FILES" | grep -q "^libs/python/computer/src/\|^libs/typescript/computer/src/"; then
- GENERATORS="$GENERATORS computer-sdk"
+ # Python SDK changes (Computer and Agent)
+ if echo "$CHANGED_FILES" | grep -q "^libs/python/computer/computer/\|^libs/python/agent/agent/"; then
+ GENERATORS="$GENERATORS python-sdk"
fi
- # Agent SDK changes
- if echo "$CHANGED_FILES" | grep -q "^libs/python/agent/src/\|^libs/typescript/agent/src/"; then
- GENERATORS="$GENERATORS agent-sdk"
+ # Cua-Bot changes
+ if echo "$CHANGED_FILES" | grep -q "^libs/cuabot/src/"; then
+ GENERATORS="$GENERATORS cuabot"
fi
# Generator changes should run all
@@ -113,20 +124,27 @@ jobs:
if: failure()
run: |
echo ""
- echo "╔══════════════════════════════════════════════════════════════════╗"
- echo "║ Documentation Out of Sync! ║"
- echo "╠══════════════════════════════════════════════════════════════════╣"
- echo "║ ║"
- echo "║ The documentation has drifted from the source code. ║"
- echo "║ ║"
- echo "║ To fix this, run from the repository root: ║"
- echo "║ ║"
- echo "║ npx tsx scripts/docs-generators/runner.ts ║"
- echo "║ ║"
- echo "║ Or for a specific library: ║"
- echo "║ ║"
- echo "║ npx tsx scripts/docs-generators/runner.ts --library lume ║"
- echo "║ ║"
- echo "║ Then commit the updated documentation files. ║"
- echo "║ ║"
- echo "╚══════════════════════════════════════════════════════════════════╝"
+ echo "╔═══════════════════════════════════════════════════════════════════════╗"
+ echo "║ Documentation Out of Sync! ║"
+ echo "╠═══════════════════════════════════════════════════════════════════════╣"
+ echo "║ ║"
+ echo "║ The documentation has drifted from the source code. ║"
+ echo "║ ║"
+ echo "║ To regenerate all docs, run from the repository root: ║"
+ echo "║ ║"
+ echo "║ npx tsx scripts/docs-generators/runner.ts ║"
+ echo "║ ║"
+ echo "║ Or for a specific library: ║"
+ echo "║ ║"
+ echo "║ npx tsx scripts/docs-generators/runner.ts --library lume ║"
+ echo "║ npx tsx scripts/docs-generators/runner.ts --library python-sdk ║"
+ echo "║ npx tsx scripts/docs-generators/runner.ts --library cuabot ║"
+ echo "║ ║"
+ echo "║ For versioned docs and changelogs (after tagging a new release): ║"
+ echo "║ ║"
+ echo "║ npx tsx scripts/docs-generators/generate-versioned-docs.ts ║"
+ echo "║ npx tsx scripts/docs-generators/generate-changelog.ts ║"
+ echo "║ ║"
+ echo "║ Then commit the updated documentation files. ║"
+ echo "║ ║"
+ echo "╚═══════════════════════════════════════════════════════════════════════╝"
diff --git a/.github/workflows/ci-swift-lume.yml b/.github/workflows/ci-swift-lume.yml
index 4cfa569bb0..0c121215bb 100644
--- a/.github/workflows/ci-swift-lume.yml
+++ b/.github/workflows/ci-swift-lume.yml
@@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: uname -a
- - run: sudo xcode-select -s /Applications/Xcode_16.2.app # Swift 6.2
+ - run: sudo xcode-select -s /Applications/Xcode_16.app # Swift 6.0
- run: swift test
working-directory: ./libs/lume
build:
@@ -27,6 +27,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: uname -a
- - run: sudo xcode-select -s /Applications/Xcode_16.2.app # Swift 6.2
+ - run: sudo xcode-select -s /Applications/Xcode_16.app # Swift 6.0
- run: swift build --configuration release
working-directory: ./libs/lume
diff --git a/.github/workflows/release-github-reusable.yml b/.github/workflows/release-github-reusable.yml
index 408b77fdf1..6a8e1e01f6 100644
--- a/.github/workflows/release-github-reusable.yml
+++ b/.github/workflows/release-github-reusable.yml
@@ -83,6 +83,11 @@ jobs:
# Get commits and process each one to fetch GitHub username
while IFS='|' read -r sha subject; do
+ # Skip automated bump commits (e.g., "Bump cua-agent to v0.7.22")
+ if [[ "$subject" =~ ^Bump\ cua- ]]; then
+ continue
+ fi
+
# Try to get GitHub username via API
USERNAME=$(gh api repos/${{ github.repository }}/commits/${sha} --jq '.author.login' 2>/dev/null || echo "")
@@ -98,12 +103,15 @@ jobs:
fi
fi
+ # Link PR numbers: (#123) -> ([#123](https://github.com/REPO/pull/123))
+ LINKED_SUBJECT=$(echo "$subject" | sed 's/(#\([0-9]*\))/([#\1](https:\/\/github.com\/${{ github.repository }}\/pull\/\1))/g')
+
SHORT_SHA=$(echo ${sha} | cut -c1-7)
- NOTES="${NOTES}* ${subject} (${SHORT_SHA}) by @${USERNAME}"$'\n'
+ NOTES="${NOTES}* ${LINKED_SUBJECT} (${SHORT_SHA}) by @${USERNAME}"$'\n'
done < <(git log ${COMMIT_RANGE} --pretty=format:"%H|%s" -- "${{ inputs.module_path }}" | head -50)
if [ -z "$NOTES" ]; then
- NOTES="* Initial release or no path-specific changes found"
+ NOTES="Maintenance release — dependency updates only."
fi
# Store notes in output (handle multiline)
diff --git a/.github/workflows/ts-reusable-build.yml b/.github/workflows/ts-reusable-build.yml
index 58d6d72cab..8d519ad085 100644
--- a/.github/workflows/ts-reusable-build.yml
+++ b/.github/workflows/ts-reusable-build.yml
@@ -56,7 +56,7 @@ jobs:
bun run build
fi
else
- pnpm run --if-present build
+ pnpm run build --if-present
fi
- name: Verify build
diff --git a/.github/workflows/ts-reusable-publish.yml b/.github/workflows/ts-reusable-publish.yml
index 74b65c2dc6..3b631d6f8e 100644
--- a/.github/workflows/ts-reusable-publish.yml
+++ b/.github/workflows/ts-reusable-publish.yml
@@ -98,7 +98,7 @@ jobs:
bun run build
fi
else
- pnpm run --if-present build
+ pnpm run build --if-present
fi
- name: Publish to npm
diff --git a/.prettierignore b/.prettierignore
index c9aaff70f2..cd64d01155 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -31,8 +31,12 @@ venv/
pnpm-lock.yaml
uv.lock
-# Docs with complex JSX formatting
-docs/content/docs/get-started/quickstart.mdx
+# Auto-generated docs source
+docs/.source/
+docs/next-env.d.ts
+
+# MDX files (prettier mangles {/* */} comment syntax into {/_ _/})
+*.mdx
# Git worktrees (separate branches)
.worktrees/
\ No newline at end of file
diff --git a/README.md b/README.md
index 43e5fbd96e..cc98ffe76f 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ Built-in support for `agent-browser` and `agent-device` (iOS, Android) out of th
<div align="center">
-**[Get Started](https://cua.ai/docs/cuabot/cuabot)** | **[Installation](https://cua.ai/docs/cuabot/install)** | *First spotted at [ClawCon](https://www.claw-con.com/)*
+**[Get Started](https://cua.ai/docs/cuabot/cuabot)** | **[Installation](https://cua.ai/docs/cuabot/install)** | _First spotted at [ClawCon](https://www.claw-con.com/)_
<div align="center">
<img src="img/cuabot-screenshot.png" alt="cuabot screenshot" style="max-height: 32em;">
diff --git a/blog/clawcon-multiplayer.md b/blog/clawcon-multiplayer.md
index 68ea0d9ba5..fe98674e1f 100644
--- a/blog/clawcon-multiplayer.md
+++ b/blog/clawcon-multiplayer.md
@@ -1,4 +1,5 @@
# Announcing the First Multi-Player Computer-Use — Live from ClawCon
+
_Published on February 6, 2026 by Francesco Bonacci and Dillon DuPont_
ClawCon brought over 700 attendees to Frontier Tower, with a waitlist that had people lining up down Market Street, and another 20k tuned into the livestream. It was the first community event for OpenClaw, and we had the 2nd demo session.
@@ -54,8 +55,6 @@ ClawCon livestream demo
</div>
Multi-Player Computer Use Agent building an RL gym and coding and playing a desktop game simultaneously. Before today, you could only have 1 Computer-Use Agent deployed per system to control
-
-
## OpenClaw + CuaBot
We demoed this at ClawCon for a reason — CuaBot is designed to work with OpenClaw out of the box.
diff --git a/blog/clawdbot-computer-use-history.md b/blog/clawdbot-computer-use-history.md
index fd9b2128da..0ede49e27f 100644
--- a/blog/clawdbot-computer-use-history.md
+++ b/blog/clawdbot-computer-use-history.md
@@ -2,7 +2,7 @@
_Published on Jan 28, 2026 by Francesco Bonacci. Originally posted on [X](https://x.com/francedot/status/2016627257310384554)._
-***TLDR**: Since Clawdbot went viral, I've gotten a lot of questions: Where did this all come from? What's next? Here's my take.*
+**\*TLDR**: Since Clawdbot went viral, I've gotten a lot of questions: Where did this all come from? What's next? Here's my take.\*
Clawdbot just hit the mainstream. The open-source AI assistant — now rebranded to Moltbot after trademark issues — has captured the imagination of developers and mainstream users alike. An AI that runs on your own machine, controlled through WhatsApp, extensible through plugins. It feels like the future arriving all at once.
@@ -104,7 +104,7 @@ Nine days later, the open-source community responded. Browser-use ([@gregpr07](h
![story_11](https://github.com/user-attachments/assets/e079984a-ee73-4dc1-b43d-fdea78f08158)
-Then, on January 23, 2025, OpenAI entered with [Operator](https://openai.com/index/introducing-operator/), powered by their Computer-Using Agent (CUA) model.
+Then, on January 23, 2025, OpenAI entered with [Operator](https://openai.com/index/introducing-operator/), powered by their Computer-Using Agent (CUA) model.
![story_12](https://github.com/user-attachments/assets/9a146ad2-174a-46a3-bbaf-9d066708fba1)
@@ -188,6 +188,7 @@ Created by Austrian developer Peter Steinberger, [Clawdbot](https://github.com/c
![story_18](https://github.com/user-attachments/assets/a7eaffff-d62b-452d-98c5-402fd7dadf69)
What makes it different:
+
- **Self-hosted**: Runs entirely on your machine. Your data stays local.
- **Multi-model**: Works with Claude, GPT, or local models via Ollama.
- **Extensible**: Skills and plugins from ClawdHub — a public registry where anyone can contribute capabilities.
@@ -202,6 +203,7 @@ But the paradigm is clear: the future of computer-use agents is modular, and use
## The Evolution in One Frame
Looking back, the progression follows a clear arc:
+
- 2023: "Can AI see a screen?" (GPT-4V)
- 2024: "Can AI click buttons?" (Claude Computer Use, Operator)
- 2025: "Can AI write code instead?" (CoAct-1)
diff --git a/docs/content/docs/cua/examples/claude-code/meta.json b/docs/content/docs/cua/examples/claude-code/meta.json
index c0e2d2d959..f3100520a7 100644
--- a/docs/content/docs/cua/examples/claude-code/meta.json
+++ b/docs/content/docs/cua/examples/claude-code/meta.json
@@ -1,5 +1,6 @@
{
"title": "Claude Code",
"description": "Claude Code integration examples",
+ "icon": "Terminal",
"pages": ["human-demonstrations"]
}
diff --git a/docs/content/docs/cua/guide/advanced/vnc-recorder.mdx b/docs/content/docs/cua/guide/advanced/vnc-recorder.mdx
index f1d39b31da..109cbd8835 100644
--- a/docs/content/docs/cua/guide/advanced/vnc-recorder.mdx
+++ b/docs/content/docs/cua/guide/advanced/vnc-recorder.mdx
@@ -61,7 +61,7 @@ cua skills read my-skill
### 1. Start a sandbox and open the VNC UI
-Start a sandbox using [Docker](/docs/cua/guide/get-started/set-up-sandbox) or [Cua Cloud](/docs/cua/guide/get-started/set-up-sandbox). The VNC UI will be available at:
+Start a sandbox using [Docker](/docs/cua/guide/get-started/self-hosted-sandboxes) or [Cua Cloud](/docs/cua/guide/get-started/quickstart). The VNC UI will be available at:
- **Docker**: `http://localhost:8006`
- **Cloud**: `https://{sandbox-name}.sandbox.cua.ai/vnc.html`
diff --git a/docs/content/docs/cua/guide/get-started/meta.json b/docs/content/docs/cua/guide/get-started/meta.json
index a9b3c92ed9..3eef4f68e7 100644
--- a/docs/content/docs/cua/guide/get-started/meta.json
+++ b/docs/content/docs/cua/guide/get-started/meta.json
@@ -5,11 +5,9 @@
"icon": "Rocket",
"pages": [
"what-is-cua",
- "what-is-computer-use-agent",
- "what-is-desktop-sandbox",
- "set-up-sandbox",
+ "quickstart",
"using-computer-sdk",
"using-agent-sdk",
- "using-cloud-cli"
+ "self-hosted-sandboxes"
]
}
diff --git a/docs/content/docs/cua/guide/get-started/quickstart.mdx b/docs/content/docs/cua/guide/get-started/quickstart.mdx
new file mode 100644
index 0000000000..3aaa9a939e
--- /dev/null
+++ b/docs/content/docs/cua/guide/get-started/quickstart.mdx
@@ -0,0 +1,184 @@
+---
+title: Quickstart
+description: Get a computer-use agent running in 5 minutes
+---
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+This guide gets you from zero to a working computer-use agent using Cua Cloud sandboxes.
+
+<Callout type="info">
+ **Prerequisites:** Python 3.12 or 3.13 and a free Cua account at [cua.ai](https://cua.ai/signin).
+</Callout>
+
+## 1. Install the Cua CLI and SDKs
+
+```bash
+pip install cua-cli cua-computer "cua-agent[all]"
+```
+
+## 2. Authenticate
+
+Login with your Cua account:
+
+```bash
+cua auth login
+```
+
+This opens your browser for authentication. Once complete, your API key is stored locally.
+
+To export your API key to a `.env` file for use in scripts:
+
+```bash
+cua auth env
+```
+
+## 3. Create a Cloud Sandbox
+
+Create a Linux sandbox:
+
+```bash
+cua sandbox create --os linux --size small --region north-america
+```
+
+Note the sandbox name from the output (e.g., `curious-fox-123`).
+
+You can view all your sandboxes:
+
+```bash
+cua sandbox list
+```
+
+## 4. Take a Screenshot (Hello World)
+
+Create a file `hello.py`:
+
+```python
+import os
+import asyncio
+from computer import Computer
+
+# Load API key from environment (or set directly)
+os.environ["CUA_API_KEY"] = "sk_cua-api01_..." # or use: cua auth env
+
+computer = Computer(
+ os_type="linux",
+ provider_type="cloud",
+ name="curious-fox-123" # your sandbox name
+)
+
+async def main():
+ await computer.run() # Connect to the sandbox
+
+ try:
+ # Take a screenshot
+ screenshot = await computer.interface.screenshot()
+ screenshot.save("screenshot.png")
+ print("Screenshot saved to screenshot.png")
+
+ # Click at coordinates (100, 100)
+ await computer.interface.left_click(100, 100)
+
+ # Type some text
+ await computer.interface.type_text("Hello from Cua!")
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+Run it:
+
+```bash
+python hello.py
+```
+
+## 5. Run an Agent
+
+Now let's add AI. Create `agent.py`:
+
+```python
+import os
+import asyncio
+from computer import Computer
+from agent import ComputerAgent
+
+os.environ["CUA_API_KEY"] = "sk_cua-api01_..." # or use: cua auth env
+
+computer = Computer(
+ os_type="linux",
+ provider_type="cloud",
+ name="curious-fox-123" # your sandbox name
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ agent = ComputerAgent(
+ model="cua/anthropic/claude-sonnet-4.5",
+ tools=[computer],
+ )
+
+ messages = [{"role": "user", "content": "Open Firefox and go to google.com"}]
+
+ async for result in agent.run(messages):
+ for item in result["output"]:
+ if item["type"] == "message":
+ print(item["content"][0]["text"])
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+Run it:
+
+```bash
+python agent.py
+```
+
+The agent will observe the screen, decide what actions to take, and execute them to complete your task.
+
+## 6. Open the Desktop in Your Browser
+
+Watch your agent work in real-time:
+
+```bash
+cua sandbox vnc curious-fox-123
+```
+
+This opens a browser window showing the sandbox desktop.
+
+## 7. Clean Up
+
+When you're done, stop your sandbox to avoid charges:
+
+```bash
+cua sandbox stop curious-fox-123
+```
+
+Or delete it entirely:
+
+```bash
+cua sandbox delete curious-fox-123
+```
+
+## CLI Reference
+
+| Command | Description |
+| -------------------------------------------------------------- | ---------------------------------- |
+| `cua auth login` | Authenticate with your Cua account |
+| `cua auth env` | Export API key to `.env` file |
+| `cua sandbox list` | List all sandboxes |
+| `cua sandbox create --os <os> --size <size> --region <region>` | Create a sandbox |
+| `cua sandbox vnc <name>` | Open sandbox in browser |
+| `cua sandbox start <name>` | Start a stopped sandbox |
+| `cua sandbox stop <name>` | Stop a sandbox |
+| `cua sandbox delete <name>` | Delete a sandbox |
+
+## Next Steps
+
+- [Using the Computer SDK](/cua/guide/get-started/using-computer-sdk) - Learn low-level computer control
+- [Using the Agent SDK](/cua/guide/get-started/using-agent-sdk) - Advanced AI agent configuration
+- [Self-Hosted Sandboxes](/cua/guide/get-started/self-hosted-sandboxes) - Run sandboxes locally with Docker
diff --git a/docs/content/docs/cua/guide/get-started/self-hosted-sandboxes.mdx b/docs/content/docs/cua/guide/get-started/self-hosted-sandboxes.mdx
new file mode 100644
index 0000000000..5c4a8794c7
--- /dev/null
+++ b/docs/content/docs/cua/guide/get-started/self-hosted-sandboxes.mdx
@@ -0,0 +1,308 @@
+---
+title: Self-Hosted Sandboxes
+description: Run sandboxes locally with Docker, QEMU, or native virtualization
+---
+
+import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
+import { Callout } from 'fumadocs-ui/components/callout';
+
+For development, testing, or air-gapped environments, you can run sandboxes locally instead of using Cua Cloud.
+
+## Options Overview
+
+| Option | OS Support | Requirements | Best For |
+| ------------------- | ----------------------- | ----------------------------- | -------------------------------- |
+| **Docker** | Linux | Docker Desktop/Engine | Local development, fastest setup |
+| **QEMU Docker** | Linux, Windows, Android | Docker + golden image | Testing specific OS versions |
+| **Lume** | macOS | macOS host + Lume CLI | macOS automation |
+| **Windows Sandbox** | Windows | Windows 10 Pro/Enterprise, 11 | Windows automation |
+
+## Linux on Docker (Recommended)
+
+The fastest way to get a local sandbox running.
+
+**1. Install Docker Desktop or Docker Engine**
+
+**2. Pull a Cua Docker image:**
+
+```bash
+# XFCE (Lightweight) - recommended for most use cases
+docker pull --platform=linux/amd64 trycua/cua-xfce:latest
+
+# OR KASM (Full-Featured) - full Ubuntu desktop
+docker pull --platform=linux/amd64 trycua/cua-ubuntu:latest
+```
+
+**3. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-xfce:latest"
+)
+
+async def main():
+ await computer.run() # Launch & connect
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ await computer.interface.type_text("Hello!")
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+## QEMU Docker
+
+Run full virtual machines (Linux, Windows, Android) inside Docker containers using QEMU virtualization.
+
+<Callout type="warn">
+ Linux and Windows images require a **golden image preparation step** on first use. Android images
+ start directly.
+</Callout>
+
+<Tabs items={['Linux', 'Windows', 'Android']}>
+ <Tab value="Linux">
+
+**1. Pull the QEMU Linux image:**
+
+```bash
+docker pull trycua/cua-qemu-linux:latest
+```
+
+**2. Download Ubuntu 22.04 LTS Server ISO:**
+
+Download the [Ubuntu 22.04 Server ISO](https://releases.ubuntu.com/22.04/ubuntu-22.04.5-live-server-amd64.iso) (~2GB)
+
+**3. Create golden image:**
+
+```bash
+docker run -it --rm \
+ --device=/dev/kvm \
+ --cap-add NET_ADMIN \
+ --mount type=bind,source=/path/to/ubuntu-22.04.5-live-server-amd64.iso,target=/custom.iso \
+ -v ~/cua-storage/linux:/storage \
+ -p 8006:8006 \
+ -p 5000:5000 \
+ -e RAM_SIZE=8G \
+ -e CPU_CORES=4 \
+ -e DISK_SIZE=64G \
+ trycua/cua-qemu-linux:latest
+```
+
+Monitor progress at [http://localhost:8006](http://localhost:8006). The container will install Ubuntu Desktop and shut down when complete.
+
+**4. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-qemu-linux:latest",
+ storage="~/cua-storage/linux",
+ run_opts={"devices": ["/dev/kvm"]},
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+ </Tab>
+ <Tab value="Windows">
+
+**1. Pull the QEMU Windows image:**
+
+```bash
+docker pull trycua/cua-qemu-windows:latest
+```
+
+**2. Download Windows 11 Enterprise Evaluation ISO:**
+
+- Visit [Microsoft Evaluation Center](https://info.microsoft.com/ww-landing-windows-11-enterprise.html)
+- Download **Windows 11 Enterprise Evaluation (90-day trial)** ISO (~6GB)
+
+**3. Create golden image:**
+
+```bash
+docker run -it --rm \
+ --device=/dev/kvm \
+ --cap-add NET_ADMIN \
+ --mount type=bind,source=/path/to/windows-11-enterprise-eval.iso,target=/custom.iso \
+ -v ~/cua-storage/windows:/storage \
+ -p 8006:8006 \
+ -p 5000:5000 \
+ -e RAM_SIZE=8G \
+ -e CPU_CORES=4 \
+ -e DISK_SIZE=64G \
+ trycua/cua-qemu-windows:latest
+```
+
+Monitor progress at [http://localhost:8006](http://localhost:8006). The container will install Windows 11 and shut down when complete.
+
+**4. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="windows",
+ provider_type="docker",
+ image="trycua/cua-qemu-windows:latest",
+ storage="~/cua-storage/windows",
+ run_opts={"devices": ["/dev/kvm"]},
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+ </Tab>
+ <Tab value="Android">
+
+No golden image preparation needed.
+
+**1. Pull the QEMU Android image:**
+
+```bash
+docker pull trycua/cua-qemu-android:latest
+```
+
+**2. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="android",
+ provider_type="docker",
+ image="trycua/cua-qemu-android:latest",
+ timeout=150, # Emulator needs more time to boot
+ run_opts={
+ "devices": ["/dev/kvm"],
+ "env": {"EMULATOR_DEVICE": "Samsung Galaxy S10"},
+ },
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+ </Tab>
+</Tabs>
+
+## macOS Sandbox (Lume)
+
+Run native macOS VMs using Apple's Virtualization framework. **macOS host required.**
+
+**1. Install the Lume CLI:**
+
+```bash
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"
+```
+
+**2. Start a macOS sandbox:**
+
+```bash
+lume run macos-sequoia-cua:latest
+```
+
+**3. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="macos",
+ provider_type="lume",
+ name="macos-sequoia-cua:latest"
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+## Windows Sandbox
+
+Use the native Windows Sandbox feature. **Windows 10 Pro/Enterprise or Windows 11 required.**
+
+**1. Enable Windows Sandbox:**
+
+Follow the [Microsoft guide](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-install) to enable Windows Sandbox.
+
+**2. Install the dependency:**
+
+```bash
+pip install -U git+git://github.com/karkason/pywinsandbox.git
+```
+
+**3. Connect with Python:**
+
+```python
+from computer import Computer
+import asyncio
+
+computer = Computer(
+ os_type="windows",
+ provider_type="windows_sandbox"
+)
+
+async def main():
+ await computer.run()
+
+ try:
+ screenshot = await computer.interface.screenshot()
+ await computer.interface.left_click(100, 100)
+ finally:
+ await computer.disconnect()
+
+asyncio.run(main())
+```
+
+## Next Steps
+
+- [Using the Computer SDK](/cua/guide/get-started/using-computer-sdk) - Full SDK reference with all sandbox types
+- [Using the Agent SDK](/cua/guide/get-started/using-agent-sdk) - Add AI automation to your sandboxes
diff --git a/docs/content/docs/cua/guide/get-started/what-is-cua.mdx b/docs/content/docs/cua/guide/get-started/what-is-cua.mdx
index b25568f097..74b0c016f0 100644
--- a/docs/content/docs/cua/guide/get-started/what-is-cua.mdx
+++ b/docs/content/docs/cua/guide/get-started/what-is-cua.mdx
@@ -14,12 +14,16 @@ Cua is an open-source platform for building, benchmarking, and deploying agents
Cua consists of three main components:
<div className="not-prose relative rounded-xl overflow-hidden my-8 w-full">
- <img src="/docs/img/cua-architecture.png" alt="Cua Architecture" className="w-full h-auto rounded-xl" />
+ <img
+ src="/docs/img/cua-architecture.png"
+ alt="Cua Architecture"
+ className="w-full h-auto rounded-xl"
+ />
</div>
### 1. Desktop Sandboxes
-Isolated virtual environments where your agents can safely execute tasks. Cua supports:
+Isolated virtual environments where your agents can safely execute tasks:
- **Cloud Sandboxes** - Managed Linux, Windows, and macOS environments hosted by Cua
- **Local Sandboxes** - Docker containers, QEMU VMs, macOS VMs via Lume, or Windows Sandbox on your own machine
@@ -36,16 +40,60 @@ A unified SDK for controlling desktop environments programmatically:
### 3. Agent Framework
-Build agents that see screens, click buttons, and complete tasks autonomously. Run isolated code execution environments for AI coding assistants like Claude Code, Codex CLI, or OpenCode.
+Build agents that see screens, click buttons, and complete tasks autonomously:
- **100+ vision-language model options** through Cua VLM Router or direct provider access
- **Pre-built agent loops** optimized for computer-use tasks
- **Composable architecture** for combining grounding and planning models
- **Built-in telemetry** for monitoring agent performance
-## Why Cua?
+## How Computer-Use Agents Work
+
+Computer-use agents operate through a continuous loop:
+
+```
+┌─────────────────────────────────────────┐
+│ 1. OBSERVE │
+│ Take a screenshot of the screen │
+└──────────────────┬──────────────────────┘
+ │
+ ▼
+┌─────────────────────────────────────────┐
+│ 2. UNDERSTAND │
+│ Vision-language model analyzes │
+│ the screenshot and current goal │
+└──────────────────┬──────────────────────┘
+ │
+ ▼
+┌─────────────────────────────────────────┐
+│ 3. DECIDE │
+│ Determine the next action: │
+│ click, type, scroll, etc. │
+└──────────────────┬──────────────────────┘
+ │
+ ▼
+┌─────────────────────────────────────────┐
+│ 4. ACT │
+│ Execute the action on the computer │
+└──────────────────┬──────────────────────┘
+ │
+ ▼
+ Loop back to 1
+```
+
+This cycle repeats until the agent completes its goal or determines it cannot proceed.
+
+## Sandbox Options
+
+| Sandbox Type | OS Support | Best For | API Key Required |
+| ------------------- | ----------------------- | ---------------------------- | ---------------- |
+| **Cloud** | Linux, Windows, macOS | Production, teams, CI/CD | Yes |
+| **Docker** | Linux | Local development | No |
+| **QEMU Docker** | Linux, Windows, Android | Testing specific OS versions | No |
+| **Lume (macOS)** | macOS | macOS automation | No |
+| **Windows Sandbox** | Windows | Windows automation | No |
-Cua provides isolated, reproducible environments for AI agents to operate safely:
+## Why Cua?
- **Secure execution** - Run AI coding assistants and computer-use agents in sandboxed environments
- **Self-hostable** - Deploy locally with Docker, QEMU, or Apple Virtualization
@@ -54,8 +102,6 @@ Cua provides isolated, reproducible environments for AI agents to operate safely
## Use Cases
-Cua is ideal for:
-
- **AI coding assistants** - Isolated code execution environments for Claude Code, Codex CLI, OpenCode, and other AI coding tools
- **Computer-use agents** - Build agents that interact with any desktop application autonomously
- **Workflow automation** - Automate repetitive tasks across any application
@@ -65,4 +111,4 @@ Cua is ideal for:
## Getting Started
-Ready to build your first agent? Continue to [Set Up a Sandbox](/cua/guide/get-started/set-up-sandbox) to set up your environment and run your first automation.
+Ready to build your first agent? Continue to the [Quickstart](/cua/guide/get-started/quickstart) to get a computer-use agent running.
diff --git a/docs/content/docs/cua/reference/agent-sdk/changelog.mdx b/docs/content/docs/cua/reference/agent-sdk/changelog.mdx
new file mode 100644
index 0000000000..7eea1428f9
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/changelog.mdx
@@ -0,0 +1,623 @@
+---
+title: Changelog
+description: Release history for Agent SDK
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-changelog.ts
+Last updated: 2026-02-04
+*/}
+
+# Agent SDK Changelog
+
+All notable changes to the Agent SDK are documented here.
+
+## 0.7.x
+
+### v0.7.24 (2026-02-04)
+
+**Dependencies:** cua-computer: 0.5.12, cua-som: 0.1.3
+
+- Initial release or no path-specific changes found
+
+### v0.7.22 (2026-01-28)
+
+**Dependencies:** cua-computer: 0.5.12, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.22 by @github-actions[bot]
+
+### v0.7.21 (2026-01-26)
+
+**Dependencies:** cua-computer: 0.5.11, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.21 by @github-actions[bot]
+
+### v0.7.18 (2026-01-22)
+
+**Dependencies:** cua-computer: 0.5.10, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.18 by @github-actions[bot]
+- fix(agent): accept 'computer_use' as valid function name for Fara model ([#865](https://github.com/trycua/cua/pull/865)) by @sarinali
+
+### v0.7.17 (2026-01-17)
+
+**Dependencies:** cua-computer: 0.5.7, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.17 by @github-actions[bot]
+
+### v0.7.16 (2026-01-17)
+
+**Dependencies:** cua-computer: 0.5.7, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.16 by @github-actions[bot]
+
+### v0.7.15 (2026-01-17)
+
+**Dependencies:** cua-computer: 0.5.7, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.15 by @github-actions[bot]
+
+### v0.7.14 (2026-01-17)
+
+**Dependencies:** cua-computer: 0.5.6, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.14 by @github-actions[bot]
+
+### v0.7.13 (2026-01-17)
+
+**Dependencies:** cua-computer: 0.5.6, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.13 by @github-actions[bot]
+- Fix/gradio 6.3 compatibility ([#810](https://github.com/trycua/cua/pull/810)) by @Weichen Zhang
+- fix(agent): create screenshot_dir when trajectory_dir option is specified ([#813](https://github.com/trycua/cua/pull/813)) by @Harsh Verma
+- fix(agent): only yield partial response if not empty ([#802](https://github.com/trycua/cua/pull/802)) by @Harsh Verma
+- fix tool mismatch in uitars agent loop ([#640](https://github.com/trycua/cua/pull/640)) by @zju-lx
+
+### v0.7.12 (2026-01-13)
+
+**Dependencies:** cua-computer: 0.5.6, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.12 by @github-actions[bot]
+- pass browser tool ([#774](https://github.com/trycua/cua/pull/774)) by @Sarina Li
+- feat(agent): add OpenTelemetry instrumentation callback ([#662](https://github.com/trycua/cua/pull/662)) by @r33drichards
+- Fix Omniparser historical message conversion using per-screenshot mappings ([#706](https://github.com/trycua/cua/pull/706)) by @Fizza Mukhtar
+
+### v0.7.11 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.6, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.11 by @github-actions[bot]
+
+### v0.7.10 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.6, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.10 by @github-actions[bot]
+
+### v0.7.9 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.5, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.9 by @github-actions[bot]
+
+### v0.7.8 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.4, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.8 by @github-actions[bot]
+- Bump cua-agent to v0.7.7 ([#781](https://github.com/trycua/cua/pull/781)) by @Francesco Bonacci
+- Bump cua-agent to v0.7.7 ([#780](https://github.com/trycua/cua/pull/780)) by @Francesco Bonacci
+
+### v0.7.6 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.1, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.6 by @github-actions[bot]
+
+### v0.7.5 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.1, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.5 by @github-actions[bot]
+
+### v0.7.4 (2026-01-12)
+
+**Dependencies:** cua-computer: 0.5.1, cua-som: 0.1.3
+
+- Bump cua-agent to v0.7.4 by @github-actions[bot]
+- refactor(docs): reorganize lume/cua docs and standardize READMEs ([#752](https://github.com/trycua/cua/pull/752)) by @Francesco Bonacci
+- feat(lume,ci): add unattended VM setup and reorganize CI/CD workflows ([#729](https://github.com/trycua/cua/pull/729)) by @Francesco Bonacci
+- Fix linting in cua-bench module ([#727](https://github.com/trycua/cua/pull/727)) by @ddupont
+- Raise clear error when using Ollama models with ComputerAgent image inputs ([#711](https://github.com/trycua/cua/pull/711)) by @Fizza Mukhtar
+- update dead links due to docs update by @Sarina Li
+- add vm name to start/end by @Sarina Li
+
+## 0.4.x
+
+### v0.4.53 (2025-11-19)
+
+cua-agent is a general Computer-Use framework with liteLLM integration for running agentic workflows on macOS, Windows, and Linux sandboxes. It provides a unified interface for computer-use agents across multiple LLM providers with advanced callback system for extensibility.
+
+- Jagjeevan's Fix + Merged Main for 4o Model Fix by @sarinali in https://github.com/trycua/cua/pull/522
+- fix: Added GPT-4o compatibility for screenshot actions with text parameter by @JagjeevanAK in https://github.com/trycua/cua/pull/422
+- Add test infrastructure with CI/CD #478 by @AceAtDev in https://github.com/trycua/cua/pull/491
+- Fix/omniparser predict refactor by @sarinali in https://github.com/trycua/cua/pull/529
+- Make VS Code Python interpreter path cross-platform by @skools-here in https://github.com/trycua/cua/pull/520
+- Fix: sanitize shell in subprocess calls by @AdityaBavadekar in https://github.com/trycua/cua/pull/519
+- [Agent] Add support for overriding api_base and api_url kwargs by @ddupont808 in https://github.com/trycua/cua/pull/504
+- Update model list and schedule daily test for agent testing by @YeIIcw in https://github.com/trycua/cua/pull/540
+- Add Claude Desktop Extension by @YeIIcw in https://github.com/trycua/cua/pull/521
+- [AGENT] - New Model Gelato-30B-A3B added by @tamoghnokandar in https://github.com/trycua/cua/pull/558
+- [AGENT] - New model UI-Ins added by @tamoghnokandar in https://github.com/trycua/cua/pull/549
+- Add "cua/" LLM provider by @ddupont808 in https://github.com/trycua/cua/pull/506
+- Add Local Desktop Mode for MCP Server with updated docs by @YeIIcw in https://github.com/trycua/cua/pull/493
+- Fix: Enable custom function tools with Anthropic models by @LucaStngn in https://github.com/trycua/cua/pull/548
+- Fix cua adapter, add UI-TARS-2 model by @ddupont808 in https://github.com/trycua/cua/pull/592
+- Fix cua adapter for anthropic models by @ddupont808 in https://github.com/trycua/cua/pull/601
+- Remove hud-python from cua-agent[all] extra by @f-trycua in https://github.com/trycua/cua/pull/603
+- Add automatic CUA_API_KEY environment variable support by @f-trycua in https://github.com/trycua/cua/pull/604
+
+New Contributors
+
+- @AceAtDev made their first contribution in https://github.com/trycua/cua/pull/491
+- @skools-here made their first contribution in https://github.com/trycua/cua/pull/520
+- @tamoghnokandar made their first contribution in https://github.com/trycua/cua/pull/545
+- @dinmukhamedm made their first contribution in https://github.com/trycua/cua/pull/404
+- @LucaStngn made their first contribution in https://github.com/trycua/cua/pull/548
+
+### v0.4.35 (2025-10-22)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Standardize Python version 3.12 across all packages by @AdityaBavadekar in https://github.com/trycua/cua/pull/500
+- Add support for all QwenVL models by @ddupont808 in https://github.com/trycua/cua/pull/501
+
+### v0.4.34 (2025-10-17)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Fix torch dependency in moondream3 loop by @ddupont808 in https://github.com/trycua/cua/pull/482
+
+New Contributors
+
+- @sarinali made their first contribution in https://github.com/trycua/cua/pull/477
+
+### v0.4.33 (2025-10-15)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Stream MCP responses instead of buffering by @YeIIcw in https://github.com/trycua/cua/pull/427
+- Add support for Gemini CUA model by @ddupont808 in https://github.com/trycua/cua/pull/472
+- Add support for Claude Haiku 4.5 by @ddupont808 in https://github.com/trycua/cua/pull/474
+- Add bump2version configuration for all Python packages by @r33drichards in https://github.com/trycua/cua/pull/463
+
+### v0.4.32 (2025-09-25)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.31 (2025-09-13)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.30 (2025-09-12)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.29 (2025-09-12)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.28 (2025-09-12)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.27 (2025-09-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.26 (2025-09-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.25 (2025-09-05)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Change HUD dataset name from `OSWorld-Verified-XLang` to `OSWorld-Verified` by @jamesmurdza in https://github.com/trycua/cua/pull/392
+- Fixed error when running agent with multimodal user inputs in the anthropic loop by @ddupont808 in https://github.com/trycua/cua/pull/394
+- Reference documentation batch by @onel in https://github.com/trycua/cua/pull/390
+
+### v0.4.24 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.23 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.22 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.21 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.20 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.19 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Added screenshot_dir parameter
+- Bugfix: Lazy loading of MLX by @ddupont808 in https://github.com/trycua/cua/pull/373
+
+### v0.4.18 (2025-08-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Fix example code and notebooks by @jamesmurdza in https://github.com/trycua/cua/pull/364
+- Added a readme file to the notebooks folder by @onel in https://github.com/trycua/cua/pull/361
+- Restrict root project to Python versions below 3.14 by @jamesmurdza in https://github.com/trycua/cua/pull/363
+- Restored `mlx/` adapter by @ddupont808 in https://github.com/trycua/cua/pull/366
+- Upgrade HUD SDK to 0.4.12 by @ddupont808 in https://github.com/trycua/cua/pull/371
+- Added callback to normalize common tool call hallucinations seen during evals
+
+New Contributors
+
+- @onel made their first contribution in https://github.com/trycua/cua/pull/361
+
+### v0.4.17 (2025-08-19)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.16 (2025-08-19)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.15 (2025-08-19)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Pin OpenAI version to work around BerriAI/litellm#13711 by @jamesmurdza in https://github.com/trycua/cua/pull/356
+- Upgrade Claude 3.5 snapshot in web app, examples and docs by @jamesmurdza in https://github.com/trycua/cua/pull/359
+- Update agent/computer SDKs to match changes in telemetry SDK by @jamesmurdza in https://github.com/trycua/cua/pull/355
+
+### v0.4.14 (2025-08-18)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Upgrade Agent SDK to require Python 3.12 by @jamesmurdza in https://github.com/trycua/cua/pull/342
+- Fix UI-TARS predict_click always returning None by @ddupont808 in https://github.com/trycua/cua/pull/350
+
+### v0.4.13 (2025-08-14)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- [Agent] Add HUD evals, OSWorld-verified docs, and support for custom computers by @ddupont808 in https://github.com/trycua/cua/pull/334
+
+### v0.4.12 (2025-08-12)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- [Agent] Implement left_mouse_down, left_mouse_up, and tool errors by @ddupont808 in https://github.com/trycua/cua/pull/333
+- [Agent] Add GLM-4.5V support by @ddupont808 in https://github.com/trycua/cua/pull/337
+
+### v0.4.11 (2025-08-07)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.10 (2025-08-06)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.9 (2025-08-06)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.8 (2025-08-05)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.7 (2025-08-05)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.6 (2025-08-04)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.5 (2025-07-29)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.4.4 (2025-07-29)
+
+Bugfixes caused by `mouse_move` having the wrong name
+
+### v0.4.3 (2025-07-29)
+
+Bugfixes caused by `mouse_move` having the wrong name
+
+### v0.4.2 (2025-07-29)
+
+- [Agent] Fix Anthropic unexpected tool_use_id by @ddupont808 in https://github.com/trycua/cua/pull/325
+
+### v0.4.1 (2025-07-28)
+
+Updated to use latest `cua-core`
+
+### v0.4.0 (2025-07-28)
+
+This update refactored the Agent SDK to make it easier to implement new features and support the release of new agent models/loops.
+
+Changelog:
+
+- Reworked agent loop, now all agent providers share a loop (Generate, Execute, Repeat), with the only difference between loops being the implementation of the Generate function
+- Replaced LLM clients with LiteLLM, now all agent providers support any provider supported by LiteLLM
+- Added 2 custom LiteLLM providers for local model inference on CUDA and MLX devices: `huggingface-local/`, `mlx/`
+- Reworked callback system to have hooks at every step of the lifecycle
+- Converted logging, trajectory saving, image retention into callbacks
+- Added new callbacks - PII Anonymization (still a W.I.P) & budget management
+- Anthropic providers - Added support for explicit prompt caching
+- OpenAI providers - Added support for zero data retention
+- Added Agent CLI for quick testing: `python -m agent.cli <model name>`
+
+[Breaking Changes](https://docs-woad-phi.vercel.app/home/agent-sdk/migration-guide#breaking-changes)
+
+- **Initialization:**
+ - `ComputerAgent` (v0.4.x) uses `model` as a string (e.g. "anthropic/claude-3-5-sonnet-20241022") instead of `LLM` and `AgentLoop` objects.
+ - `tools` is a list (can include multiple computers and decorated functions).
+ - `callbacks` are now first-class for extensibility (image retention, budget, trajectory, logging, etc).
+- **No explicit `loop` parameter:**
+ - Loop is inferred from the `model` string (e.g. `anthropic/`, `openai/`, `omniparser+`, `ui-tars`).
+- **No explicit `computer` parameter:**
+ - Computers are added to `tools` list.
+
+Install
+
+```bash
+Before merge:
+pip install --pre "cua-agent[all]==0.4.0b4"
+
+After merge:
+pip install "cua-agent[all]"
+
+or install specific providers
+pip install "cua-agent[openai]" # OpenAI computer-use-preview support
+pip install "cua-agent[anthropic]" # Anthropic Claude support
+pip install "cua-agent[omni]" # Omniparser + any LLM support
+pip install "cua-agent[uitars]" # UI-TARS
+pip install "cua-agent[uitars-mlx]" # UI-TARS + MLX support
+pip install "cua-agent[uitars-hf]" # UI-TARS + Huggingface support
+pip install "cua-agent[ui]" # Gradio UI support
+```
+
+Supported Models
+
+Anthropic Claude (Computer Use API)
+
+```python
+model="anthropic/claude-3-5-sonnet-20241022"
+model="anthropic/claude-3-5-sonnet-20240620"
+model="anthropic/claude-opus-4-20250514"
+model="anthropic/claude-sonnet-4-20250514"
+```
+
+OpenAI Computer Use Preview
+
+```python
+model="openai/computer-use-preview"
+```
+
+UI-TARS (Local or Huggingface Inference)
+
+```python
+model="huggingface-local/ByteDance-Seed/UI-TARS-1.5-7B"
+model="ollama_chat/0000/ui-tars-1.5-7b"
+```
+
+Omniparser + Any LLM
+
+```python
+model="omniparser+ollama_chat/mistral-small3.2"
+model="omniparser+vertex_ai/gemini-pro"
+model="omniparser+anthropic/claude-3-5-sonnet-20241022"
+model="omniparser+openai/gpt-4o"
+```
+
+## 0.3.x
+
+### v0.3.2 (2025-07-15)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.3.1 (2025-07-01)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+## 0.2.x
+
+### v0.2.15 (2025-06-25)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.14 (2025-06-24)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.13 (2025-06-24)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.12 (2025-06-20)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.11 (2025-06-18)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.10 (2025-06-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+- Fixed image retention bug by @ddupont808 in https://github.com/trycua/cua/pull/282
+- Removed `torch` requirement from `cua-agent/core` and `cua-agent/anthropic` by @ddupont808 in https://github.com/trycua/cua/pull/285
+
+### v0.2.9 (2025-06-05)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.7 (2025-06-05)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.6 (2025-05-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.5 (2025-05-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.4 (2025-05-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.3 (2025-05-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.2 (2025-05-28)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.1 (2025-05-16)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.2.0 (2025-05-14)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+## 0.1.x
+
+### v0.1.44 (2025-05-13)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.43 (2025-05-12)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.42 (2025-05-11)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.41 (2025-05-11)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.40 (2025-05-11)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.39 (2025-05-11)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.38 (2025-05-11)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.37 (2025-05-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.35 (2025-05-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.34 (2025-05-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.33 (2025-05-10)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.32 (2025-05-02)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.31 (2025-04-29)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.30 (2025-04-24)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.29 (2025-04-22)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.28 (2025-04-15)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.27 (2025-04-15)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.26 (2025-04-14)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.25 (2025-04-06)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.24 (2025-04-06)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.23 (2025-04-06)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.22 (2025-04-04)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.21 (2025-04-02)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.20 (2025-03-30)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.19 (2025-03-30)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.18 (2025-03-30)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.17 (2025-03-24)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.6 (2025-03-19)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
+
+### v0.1.5 (2025-03-17)
+
+**Dependencies:** cua-computer: latest, cua-som: latest
diff --git a/docs/content/docs/cua/reference/agent-sdk/index.mdx b/docs/content/docs/cua/reference/agent-sdk/index.mdx
index 60fa6a92b5..ae458d5934 100644
--- a/docs/content/docs/cua/reference/agent-sdk/index.mdx
+++ b/docs/content/docs/cua/reference/agent-sdk/index.mdx
@@ -1,584 +1,1348 @@
---
-title: Agent SDK
-description: Python API reference for the Agent SDK
+title: Agent SDK API Reference
+description: Python API reference for building computer-use agents
---
-import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+{/*
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+ Generated by: npx tsx scripts/docs-generators/python-sdk.ts
+ Source: libs/python/agent/agent
+ Version: 0.7.24
+*/}
+
import { Callout } from 'fumadocs-ui/components/callout';
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
-The **Agent SDK** (`cua-agent`) provides the Python interface for building computer-use agents. This reference covers the ComputerAgent class, callbacks, tools, and response types.
+<VersionHeader
+ versions={[{"version":"0.7","href":"/cua/reference/agent-sdk","isCurrent":true},{"version":"0.6","href":"/cua/reference/agent-sdk/v0.6/api","isCurrent":false},{"version":"0.5","href":"/cua/reference/agent-sdk/v0.5/api","isCurrent":false},{"version":"0.4","href":"/cua/reference/agent-sdk/v0.4/api","isCurrent":false},{"version":"0.3","href":"/cua/reference/agent-sdk/v0.3/api","isCurrent":false}]}
+ currentVersion="0.7"
+ fullVersion="0.7.24"
+ packageName="cua-agent"
+/>
-## Installation
+agent - Decorator-based Computer Use Agent with liteLLM integration
-```bash
-pip install cua-agent
-```
+## Classes
+
+| Class | Description |
+|-------|-------------|
+| [`ComputerAgent`](#computeragent) | Main agent class that automatically selects the appropriate agent loop |
+
+## Functions
+
+| Function | Description |
+|----------|-------------|
+| [`register_agent`](#register_agent) | Decorator to register an AsyncAgentConfig class. |
+
+---
## ComputerAgent
-The main class for creating agents that can autonomously operate computers.
+Main agent class that automatically selects the appropriate agent loop
+based on the model and executes tool calls.
+
+### Constructor
```python
-from agent import ComputerAgent
+ComputerAgent(self, model: str, tools: Optional[List[Any]] = None, custom_loop: Optional[Callable] = None, only_n_most_recent_images: Optional[int] = None, callbacks: Optional[List[Any]] = None, instructions: Optional[str] = None, verbosity: Optional[int] = None, trajectory_dir: Optional[str | Path | dict] = None, max_retries: Optional[int] = 3, screenshot_delay: Optional[float | int] = 0.5, use_prompt_caching: Optional[bool] = False, max_trajectory_budget: Optional[float | dict] = None, telemetry_enabled: Optional[bool] = True, trust_remote_code: Optional[bool] = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {})
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `model` | `Any` | |
+| `tools` | `Any` | |
+| `custom_loop` | `Any` | |
+| `only_n_most_recent_images` | `Any` | |
+| `callbacks` | `Any` | |
+| `instructions` | `Any` | |
+| `verbosity` | `Any` | |
+| `trajectory_dir` | `Any` | |
+| `max_retries` | `Any` | |
+| `screenshot_delay` | `Any` | |
+| `use_prompt_caching` | `Any` | |
+| `telemetry_enabled` | `Any` | |
+| `kwargs` | `Any` | |
+| `trust_remote_code` | `Any` | |
+| `api_key` | `Any` | |
+| `api_base` | `Any` | |
+| `agent_loop` | `Any` | |
+| `agent_config_info` | `Any` | |
+| `tool_schemas` | `Any` | |
+| `computer_handler` | `Any` | |
-agent = ComputerAgent(
- model="anthropic/claude-sonnet-4-5-20250929",
- tools=[computer]
-)
+### Methods
+
+#### ComputerAgent.run
-async for result in agent.run("Open Firefox and search for Cua"):
- print(result.text)
+```python
+async def run(self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {}) -> AsyncGenerator[Dict[str, Any], None]
```
-### Constructor Parameters
+Run the agent with the given messages using Computer protocol handler pattern.
-| Parameter | Type | Default | Description |
-| --------------------------- | --------------- | ---------------- | ----------------------------------------------------------- |
-| `model` | `str` | Required | Model identifier (see [VLMs](/cua/guide/fundamentals/vlms)) |
-| `tools` | `list` | Required | Tools the agent can use |
-| `api_key` | `str` | Provider env var | API key for the model provider |
-| `callbacks` | `list` | `[]` | List of callback handlers |
-| `instructions` | `str` | `None` | Custom instructions prepended to prompts |
-| `verbosity` | `int` | `None` | Logging level (e.g., `logging.INFO`) |
-| `max_trajectory_budget` | `float` | `None` | Maximum cost in dollars |
-| `only_n_most_recent_images` | `int` | `None` | Limit retained screenshots |
-| `trajectory_dir` | `str` \| `dict` | `None` | Directory for saving trajectories |
+**Parameters:**
-### Methods
+| Name | Type | Description |
+|------|------|-------------|
+| `messages` | `Any` | List of message dictionaries |
+| `stream` | `Any` | Whether to stream the response |
+| `api_key` | `Any` | Optional API key override for the model provider |
+| `api_base` | `Any` | Optional API base URL override for the model provider **additional_generation_kwargs: Additional arguments passed to the model provider |
-#### `run(task, chat_history)`
+**Returns:** AsyncGenerator that yields response chunks
-Execute a task autonomously. Returns an async generator of results.
+#### ComputerAgent.predict_click
```python
-async for result in agent.run("Click the submit button"):
- if result.text:
- print(result.text)
- if result.action:
- print(f"Action: {result.action}")
+async def predict_click(self, instruction: str, image_b64: Optional[str] = None) -> Optional[Tuple[int, int]]
```
-| Parameter | Type | Default | Description |
-| -------------- | ------ | -------- | --------------------------------- |
-| `task` | `str` | Required | Natural language task description |
-| `chat_history` | `list` | `[]` | Previous conversation messages |
+Predict click coordinates based on image and instruction.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `instruction` | `Any` | Instruction for where to click |
+| `image_b64` | `Any` | Base64 encoded image (optional, will take screenshot if not provided) |
+
+**Returns:** None or tuple with (x, y) coordinates
+
+#### ComputerAgent.get_capabilities
+
+```python
+def get_capabilities(self) -> List[AgentCapability]
+```
+
+Get list of capabilities supported by the current agent config.
+
+**Returns:** List of capability strings (e.g., ["step", "click"])
+
+#### ComputerAgent.open
+
+```python
+def open(self, port: Optional[int] = None)
+```
+
+Start the playground server and open it in the browser.
+
+This method starts a local HTTP server that exposes the /responses endpoint
+and automatically opens the Cua playground interface in the default browser.
+
+**Parameters:**
-**Yields:** `AgentResult` objects containing model responses and actions.
+| Name | Type | Description |
+|------|------|-------------|
+| `port` | `Any` | Port to run the server on. If None, finds an available port automatically. |
-#### `run_to_completion(task, chat_history)`
+**Example:**
-Execute a task and return only the final result.
+```python
+>>> agent = ComputerAgent(model="claude-sonnet-4")
+>>> agent.open() # Starts server and opens browser
+```
+
+## register_agent
```python
-result = await agent.run_to_completion("Open the calculator app")
-print(result.text)
+def register_agent(models: str, priority: int = 0, tool_type: Optional[str] = None)
```
-**Returns:** `AgentResult` - The final result after task completion.
+Decorator to register an AsyncAgentConfig class.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `models` | `Any` | Regex pattern to match supported models |
+| `priority` | `Any` | Priority for agent selection (higher = more priority) |
+| `tool_type` | `Any` | Required tool type for this model ("browser" | "mobile" | None). Specialized models (like FARA) declare their required tool type, and ComputerAgent will auto-wrap tools accordingly. General models (like Claude) leave this as None for full flexibility. |
+
+---
+
+## types
+
+Type definitions for agent
+
+---
+
+## ToolError
+
+*Inherits from: RuntimeError*
+
+Base exception for tool-related errors
+
+---
+
+## IllegalArgumentError
+
+*Inherits from: ToolError*
+
+Exception raised when function arguments are invalid
---
-## AgentResult
+## AgentConfigInfo
+
+*Inherits from: BaseModel*
+
+Information about a registered agent config
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent_class` | `type` | |
+| `models_regex` | `str` | |
+| `priority` | `int` | |
+| `tool_type` | `Optional[str]` | |
+
+### Methods
-Returned by `agent.run()` for each iteration of the agent loop.
+#### AgentConfigInfo.matches_model
```python
-async for result in agent.run("Search for documentation"):
- # Check what happened this iteration
- if result.text:
- print(f"Agent said: {result.text}")
+def matches_model(self, model: str) -> bool
+```
+
+Check if this agent config matches the given model
+
+---
+
+## tools
- if result.action:
- print(f"Action type: {result.action.type}")
+Agent tools module.
+Provides base classes and registered tools for agent interactions.
+
+---
- if result.usage:
- print(f"Tokens used: {result.usage.total_tokens}")
+## BaseComputerTool
+
+*Inherits from: BaseTool*
+
+Base class for computer tools that can provide screenshots.
+
+Computer tools must implement:
+- All BaseTool requirements (name, description, parameters, call)
+- screenshot() method that returns screenshot as base64 string
+
+### Methods
+
+#### BaseComputerTool.screenshot
+
+```python
+async def screenshot(self) -> str
+```
+
+Take a screenshot of the computer/browser.
+
+**Returns:** Screenshot image data as base64-encoded string
+
+---
+
+## BaseTool
+
+*Inherits from: ABC*
+
+Base class for all agent tools.
+
+Tools must implement:
+- name: str - The tool name (set by @register_tool decorator)
+- description: property that returns str - Tool description
+- parameters: property that returns dict - JSON schema for tool parameters
+- call: method - Execute the tool with given parameters
+
+### Constructor
+
+```python
+BaseTool(self, cfg: Optional[dict] = None)
```
-### Properties
+### Attributes
-| Property | Type | Description |
-| ------------ | ------------------- | ------------------------------------- |
-| `text` | `str \| None` | Text response from the model |
-| `action` | `Action \| None` | Computer action taken |
-| `screenshot` | `PIL.Image \| None` | Screenshot after action |
-| `usage` | `Usage \| None` | Token and cost information |
-| `error` | `str \| None` | Error message if action failed |
-| `done` | `bool` | True if agent considers task complete |
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `str` | |
+| `cfg` | `Any` | |
+| `description` | `str` | Return the tool description. |
+| `parameters` | `dict` | Return the JSON schema for tool parameters. |
+| `function` | `dict` | Return the function information for this tool. |
-### Action Types
+### Methods
-The `action` property contains details about computer actions:
+#### BaseTool.call
```python
-result.action.type # "click", "type", "key", "scroll", etc.
-result.action.coordinate # [x, y] for click actions
-result.action.text # Text for type actions
-result.action.key # Key for key press actions
+def call(self, params: Union[str, dict], kwargs = {}) -> Union[str, list, dict]
```
+Execute the tool with the given parameters.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `params` | `Any` | The parameters for the tool call (JSON string or dict) **kwargs: Additional keyword arguments |
+
+**Returns:** The result of the tool execution
+
---
-## Usage Tracking
+## BrowserTool
+
+*Inherits from: BaseComputerTool*
+
+Browser tool that uses the computer SDK's interface to control a browser.
+Implements a comprehensive computer_use action interface for browser control.
+
+### Constructor
+
+```python
+BrowserTool(self, interface: GenericComputerInterface, cfg: Optional[dict] = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `interface` | `Any` | |
+| `viewport_width` | `Any` | |
+| `viewport_height` | `Any` | |
+| `resized_width` | `Any` | |
+| `resized_height` | `Any` | |
+| `automation` | `Any` | Get the automation interface for keyboard/mouse actions. |
+| `description` | `str` | |
+| `parameters` | `dict` | |
+
+### Methods
+
+#### BrowserTool.call
+
+```python
+def call(self, params: Union[str, dict], kwargs = {}) -> Union[str, dict]
+```
+
+Execute a browser action.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `params` | `Any` | Action parameters (JSON string or dict) **kwargs: Additional keyword arguments |
+
+**Returns:** Result of the action execution
+
+#### BrowserTool.visit_url
+
+```python
+async def visit_url(self, url: str) -> dict
+```
+
+Navigate to a URL.
+
+#### BrowserTool.click
+
+```python
+async def click(self, x: int = None, y: int = None, button: str = 'left', kwargs = {}) -> dict
+```
+
+Click at coordinates. Supports both positional (x, y) and kwargs (button, x, y).
+
+This is compatible with the normalized format from OperatorNormalizerCallback
+which transforms actions like \{"type": "left_click", "coordinate": [x, y]\}
+into \{"type": "click", "button": "left", "x": x, "y": y\}.
+
+#### BrowserTool.type
+
+```python
+async def type(self, text: str) -> dict
+```
+
+Type text into the focused element.
+
+#### BrowserTool.scroll
+
+```python
+async def scroll(self, delta_x: int = None, delta_y: int = None, scroll_x: int = None, scroll_y: int = None, x: int = None, y: int = None, pixels: int = None, coordinate = None, kwargs = {}) -> dict
+```
+
+Scroll the page. Supports multiple formats:
+- Legacy: scroll(delta_x, delta_y)
+- Normalized: scroll(scroll_x=0, scroll_y=100, x=500, y=300)
+- FARA: scroll(pixels=100, coordinate=[500, 300])
+
+#### BrowserTool.web_search
+
+```python
+async def web_search(self, query: str) -> dict
+```
+
+Navigate to a Google search for the query.
+
+#### BrowserTool.screenshot
+
+```python
+async def screenshot(self) -> str
+```
+
+Take a screenshot of the current browser page.
+
+#### BrowserTool.get_current_url
+
+```python
+async def get_current_url(self) -> str
+```
+
+Get the current URL of the browser page.
+
+#### BrowserTool.left_click
+
+```python
+async def left_click(self, coordinate = None, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Left click at coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.right_click
+
+```python
+async def right_click(self, coordinate = None, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Right click at coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.middle_click
+
+```python
+async def middle_click(self, coordinate = None, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Middle click at coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.double_click
-The `Usage` object tracks token consumption and costs.
+```python
+async def double_click(self, coordinate = None, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Double click at coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.triple_click
+
+```python
+async def triple_click(self, coordinate = None, x: int = None, y: int = None, button: str = None, kwargs = {}) -> dict
+```
+
+Triple click at coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.mouse_move
+
+```python
+async def mouse_move(self, coordinate = None, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Move mouse to coordinates. Supports coordinate array or x/y kwargs.
+
+#### BrowserTool.move
+
+```python
+async def move(self, x: int = None, y: int = None, kwargs = {}) -> dict
+```
+
+Move mouse to coordinates. Alias for mouse_move with x/y kwargs.
+
+#### BrowserTool.left_click_drag
+
+```python
+async def left_click_drag(self, coordinate = None, start_coordinate = None, end_coordinate = None, kwargs = {}) -> dict
+```
+
+Drag from start to end coordinates. FARA-compatible.
+
+#### BrowserTool.key
```python
-async for result in agent.run("Complete this form"):
- if result.usage:
- print(f"Input tokens: {result.usage.input_tokens}")
- print(f"Output tokens: {result.usage.output_tokens}")
- print(f"Total tokens: {result.usage.total_tokens}")
- print(f"Cost: ${result.usage.response_cost:.4f}")
+async def key(self, keys = None, kwargs = {}) -> dict
```
-### Properties
+Press keys. FARA-compatible.
-| Property | Type | Description |
-| ----------------------------- | ------- | ----------------------- |
-| `input_tokens` | `int` | Tokens in the prompt |
-| `output_tokens` | `int` | Tokens in the response |
-| `total_tokens` | `int` | Total tokens used |
-| `response_cost` | `float` | Cost in dollars |
-| `cache_creation_input_tokens` | `int` | Tokens written to cache |
-| `cache_read_input_tokens` | `int` | Tokens read from cache |
+#### BrowserTool.keypress
+
+```python
+async def keypress(self, keys = None, kwargs = {}) -> dict
+```
+
+Press keys. Alias for key() - used by OperatorNormalizerCallback.
+
+#### BrowserTool.hscroll
+
+```python
+async def hscroll(self, pixels = None, coordinate = None, kwargs = {}) -> dict
+```
+
+Horizontal scroll. FARA-compatible.
+
+#### BrowserTool.wait
+
+```python
+async def wait(self, time = None, kwargs = {}) -> dict
+```
+
+Wait for specified seconds. FARA-compatible.
+
+#### BrowserTool.history_back
+
+```python
+async def history_back(self, kwargs = {}) -> dict
+```
+
+Go back in browser history. FARA-compatible.
+
+#### BrowserTool.terminate
+
+```python
+async def terminate(self, status = None, kwargs = {}) -> dict
+```
+
+Terminate and report status. FARA-compatible.
+
+### get_registered_tools
+
+```python
+def get_registered_tools() -> Dict[str, type]
+```
+
+Get all registered tools.
+
+**Returns:** Dictionary mapping tool names to tool classes
+
+### get_tool
+
+```python
+def get_tool(name: str) -> Optional[type]
+```
+
+Get a registered tool by name.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | The tool name |
+
+**Returns:** The tool class, or None if not found
+
+### register_tool
+
+```python
+def register_tool(name: str, allow_overwrite: bool = False)
+```
+
+Decorator to register a tool class with a given name.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | The name to register the tool under |
+| `allow_overwrite` | `Any` | Whether to allow overwriting an existing tool with the same name |
+
+**Returns:** Decorator function that registers the class
+
+**Example:**
+
+```python
+@register_tool("my_tool")
+class MyTool(BaseTool):
+ ...
+```
+
+---
+
+## callbacks
+
+Callback system for ComputerAgent preprocessing and postprocessing hooks.
---
-## Callbacks
+## AsyncCallbackHandler
+
+*Inherits from: ABC*
+
+Base class for async callback handlers that can preprocess messages before
+the agent loop and postprocess output after the agent loop.
+
+### Methods
+
+#### AsyncCallbackHandler.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the start of an agent run loop.
+
+#### AsyncCallbackHandler.on_run_end
+
+```python
+async def on_run_end(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the end of an agent run loop.
+
+#### AsyncCallbackHandler.on_run_continue
+
+```python
+async def on_run_continue(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> bool
+```
+
+Called during agent run loop to determine if execution should continue.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `kwargs` | `Any` | Run arguments |
+| `old_items` | `Any` | Original messages |
+| `new_items` | `Any` | New messages generated during run |
+
+**Returns:** True to continue execution, False to stop
+
+#### AsyncCallbackHandler.on_llm_start
+
+```python
+async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]
+```
+
+Called before messages are sent to the agent loop.
-Callbacks hook into the agent lifecycle for logging, cost tracking, and custom behavior.
+**Parameters:**
-### Built-in Callbacks
+| Name | Type | Description |
+|------|------|-------------|
+| `messages` | `Any` | List of message dictionaries to preprocess |
-#### LoggingCallback
+**Returns:** List of preprocessed message dictionaries
-Log agent events with configurable verbosity.
+#### AsyncCallbackHandler.on_llm_end
```python
-from agent.callbacks import LoggingCallback
-import logging
+async def on_llm_end(self, output: List[Dict[str, Any]]) -> List[Dict[str, Any]]
+```
+
+Called after the agent loop returns output.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `output` | `Any` | List of output message dictionaries to postprocess |
+
+**Returns:** List of postprocessed output dictionaries
+
+#### AsyncCallbackHandler.on_computer_call_start
-agent = ComputerAgent(
- model="...",
- tools=[computer],
- callbacks=[LoggingCallback(level=logging.DEBUG)]
-)
+```python
+async def on_computer_call_start(self, item: Dict[str, Any]) -> None
```
-| Parameter | Type | Default | Description |
-| --------- | ----- | -------------- | ------------- |
-| `level` | `int` | `logging.INFO` | Logging level |
+Called when a computer call is about to start.
+
+**Parameters:**
-#### BudgetManagerCallback
+| Name | Type | Description |
+|------|------|-------------|
+| `item` | `Any` | The computer call item dictionary |
-Track costs and stop when budget is exceeded.
+#### AsyncCallbackHandler.on_computer_call_end
```python
-from agent.callbacks import BudgetManagerCallback
+async def on_computer_call_end(self, item: Dict[str, Any], result: List[Dict[str, Any]]) -> None
+```
+
+Called when a computer call has completed.
-agent = ComputerAgent(
- model="...",
- tools=[computer],
- callbacks=[BudgetManagerCallback(
- max_budget=10.0,
- reset_after_each_run=True,
- raise_error=False
- )]
-)
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `item` | `Any` | The computer call item dictionary |
+| `result` | `Any` | The result of the computer call |
+
+#### AsyncCallbackHandler.on_function_call_start
+
+```python
+async def on_function_call_start(self, item: Dict[str, Any]) -> None
```
-| Parameter | Type | Default | Description |
-| ---------------------- | ------- | -------- | -------------------------------- |
-| `max_budget` | `float` | Required | Maximum cost in dollars |
-| `reset_after_each_run` | `bool` | `True` | Reset budget per run |
-| `raise_error` | `bool` | `False` | Raise exception vs graceful stop |
+Called when a function call is about to start.
-#### ImageRetentionCallback
+**Parameters:**
-Limit screenshot history to prevent context overflow.
+| Name | Type | Description |
+|------|------|-------------|
+| `item` | `Any` | The function call item dictionary |
+
+#### AsyncCallbackHandler.on_function_call_end
```python
-from agent.callbacks import ImageRetentionCallback
+async def on_function_call_end(self, item: Dict[str, Any], result: List[Dict[str, Any]]) -> None
+```
+
+Called when a function call has completed.
+
+**Parameters:**
-agent = ComputerAgent(
- model="...",
- tools=[computer],
- callbacks=[ImageRetentionCallback(only_n_most_recent_images=3)]
-)
+| Name | Type | Description |
+|------|------|-------------|
+| `item` | `Any` | The function call item dictionary |
+| `result` | `Any` | The result of the function call |
+
+#### AsyncCallbackHandler.on_text
+
+```python
+async def on_text(self, item: Dict[str, Any]) -> None
```
-| Parameter | Type | Default | Description |
-| --------------------------- | ----- | -------- | ------------------------- |
-| `only_n_most_recent_images` | `int` | Required | Max screenshots to retain |
+Called when a text message is encountered.
+
+**Parameters:**
-#### TrajectorySaverCallback
+| Name | Type | Description |
+|------|------|-------------|
+| `item` | `Any` | The message item dictionary |
-Save complete agent conversations for debugging.
+#### AsyncCallbackHandler.on_api_start
```python
-from agent.callbacks import TrajectorySaverCallback
+async def on_api_start(self, kwargs: Dict[str, Any]) -> None
+```
+
+Called when an API call is about to start.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `kwargs` | `Any` | The kwargs being passed to the API call |
-agent = ComputerAgent(
- model="...",
- tools=[computer],
- callbacks=[TrajectorySaverCallback(
- trajectory_dir="trajectories",
- reset_on_run=True,
- screenshot_dir="screenshots"
- )]
-)
+#### AsyncCallbackHandler.on_api_end
+
+```python
+async def on_api_end(self, kwargs: Dict[str, Any], result: Any) -> None
```
-| Parameter | Type | Default | Description |
-| ---------------- | ------ | -------- | ---------------------------------- |
-| `trajectory_dir` | `str` | Required | Base directory for trajectories |
-| `reset_on_run` | `bool` | `True` | Create new trajectory per run |
-| `screenshot_dir` | `str` | `None` | Separate directory for screenshots |
+Called when an API call has completed.
-#### PromptInstructionsCallback
+**Parameters:**
-Prepend custom instructions to every LLM call.
+| Name | Type | Description |
+|------|------|-------------|
+| `kwargs` | `Any` | The kwargs that were passed to the API call |
+| `result` | `Any` | The result of the API call |
+
+#### AsyncCallbackHandler.on_usage
```python
-from agent.callbacks import PromptInstructionsCallback
+async def on_usage(self, usage: Dict[str, Any]) -> None
+```
-agent = ComputerAgent(
- model="...",
- tools=[computer],
- callbacks=[PromptInstructionsCallback("Always confirm before clicking")]
-)
+Called when usage information is received.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `usage` | `Any` | The usage information |
+
+#### AsyncCallbackHandler.on_screenshot
+
+```python
+async def on_screenshot(self, screenshot: Union[str, bytes], name: str = 'screenshot') -> None
```
-### Creating Custom Callbacks
+Called when a screenshot is taken.
+
+**Parameters:**
-Extend `AsyncCallbackHandler` to create custom callbacks:
+| Name | Type | Description |
+|------|------|-------------|
+| `screenshot` | `Any` | The screenshot image |
+| `name` | `Any` | The name of the screenshot |
+
+#### AsyncCallbackHandler.on_responses
```python
-from agent.callbacks.base import AsyncCallbackHandler
+async def on_responses(self, kwargs: Dict[str, Any], responses: Dict[str, Any]) -> None
+```
-class MyCallback(AsyncCallbackHandler):
- async def on_run_start(self, kwargs, old_items):
- """Called when agent.run() begins"""
- print("Starting run...")
+Called when responses are received.
- async def on_run_continue(self, kwargs, old_items, new_items) -> bool:
- """Called before each iteration. Return False to stop."""
- return True
+**Parameters:**
- async def on_llm_start(self, messages):
- """Preprocess messages before LLM call."""
- return messages
+| Name | Type | Description |
+|------|------|-------------|
+| `kwargs` | `Any` | The kwargs being passed to the agent loop |
+| `responses` | `Any` | The responses received |
- async def on_llm_end(self, messages):
- """Postprocess messages after LLM call."""
- return messages
+---
+
+## BudgetManagerCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Budget manager callback that tracks usage costs and can stop execution when budget is exceeded.
+
+### Constructor
+
+```python
+BudgetManagerCallback(self, max_budget: float, reset_after_each_run: bool = True, raise_error: bool = False)
+```
- async def on_usage(self, usage):
- """Called with usage stats after each LLM call."""
- print(f"Cost: ${usage.response_cost:.4f}")
+### Attributes
- async def on_computer_call_start(self, item):
- """Called before a computer action."""
- pass
+| Name | Type | Description |
+|------|------|-------------|
+| `max_budget` | `Any` | |
+| `reset_after_each_run` | `Any` | |
+| `raise_error` | `Any` | |
+| `total_cost` | `Any` | |
- async def on_computer_call_end(self, item, result):
- """Called after a computer action."""
- pass
+### Methods
+
+#### BudgetManagerCallback.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
+```
+
+Reset budget if configured to do so.
- async def on_screenshot(self, screenshot, name):
- """Called when a screenshot is taken."""
- pass
+#### BudgetManagerCallback.on_usage
- async def on_run_end(self, kwargs, old_items, new_items):
- """Called when agent.run() completes."""
- print("Run complete!")
+```python
+async def on_usage(self, usage: Dict[str, Any]) -> None
```
-### Callback Lifecycle Order
+Track usage costs.
-1. `on_run_start` - Once at the beginning
-2. For each iteration:
- - `on_run_continue` - Check if should continue
- - `on_llm_start` - Before LLM call
- - `on_api_start` - Before API request
- - `on_api_end` - After API response
- - `on_usage` - With usage stats
- - `on_llm_end` - After LLM processing
- - `on_responses` - With model responses
- - `on_text` / `on_computer_call_start` / `on_computer_call_end` - Per response item
- - `on_screenshot` - When screenshots are taken
-3. `on_run_end` - Once at the end
+#### BudgetManagerCallback.on_run_continue
+
+```python
+async def on_run_continue(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> bool
+```
+
+Check if budget allows continuation.
---
-## Tools
+## ImageRetentionCallback
-### Built-in Tools
+*Inherits from: AsyncCallbackHandler*
-#### Computer
+Callback handler that applies image retention policy to limit the number
+of recent images in message history to prevent context window overflow.
-The primary tool for full computer control.
+### Constructor
```python
-from computer import Computer
+ImageRetentionCallback(self, only_n_most_recent_images: Optional[int] = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `only_n_most_recent_images` | `Any` | |
+
+### Methods
-computer = Computer(
- os_type="linux",
- provider_type="docker",
- image="trycua/cua-xfce:latest"
-)
-await computer.run()
+#### ImageRetentionCallback.on_llm_start
-agent = ComputerAgent(
- model="anthropic/claude-sonnet-4-5-20250929",
- tools=[computer]
-)
+```python
+async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]
```
-#### BrowserTool
+Apply image retention policy to messages before sending to agent loop.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `messages` | `Any` | List of message dictionaries |
+
+**Returns:** List of messages with image retention policy applied
+
+---
+
+## LoggingCallback
+
+*Inherits from: AsyncCallbackHandler*
-Specialized tool for web automation with browser-only models.
+Callback handler that logs agent lifecycle events with configurable verbosity.
+
+Logging levels:
+- DEBUG: All events including API calls, message preprocessing, and detailed outputs
+- INFO: Major lifecycle events (start/end, messages, outputs)
+- WARNING: Only warnings and errors
+- ERROR: Only errors
+
+### Constructor
```python
-from agent.tools import BrowserTool
+LoggingCallback(self, logger: Optional[logging.Logger] = None, level: int = logging.INFO)
+```
+
+### Attributes
-browser = BrowserTool(interface=computer)
+| Name | Type | Description |
+|------|------|-------------|
+| `logger` | `Any` | |
+| `level` | `Any` | |
-agent = ComputerAgent(
- model="google/gemini-2.5-flash",
- tools=[browser]
-)
+### Methods
+
+#### LoggingCallback.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
```
-See [Browser Tool](/cua/guide/fundamentals/browser-tool) for available actions.
+Called before the run starts.
-### Custom Function Tools
+#### LoggingCallback.on_usage
-Add Python functions as tools:
+```python
+async def on_usage(self, usage: Dict[str, Any]) -> None
+```
+
+Called when usage information is received.
+
+#### LoggingCallback.on_run_end
```python
-def calculate(a: int, b: int) -> int:
- """Calculate the sum of two integers"""
- return a + b
+async def on_run_end(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> None
+```
+
+Called after the run ends.
-async def fetch_data(url: str) -> str:
- """Fetch data from a URL"""
- async with httpx.AsyncClient() as client:
- response = await client.get(url)
- return response.text
+#### LoggingCallback.on_llm_start
-agent = ComputerAgent(
- model="anthropic/claude-sonnet-4-5-20250929",
- tools=[computer, calculate, fetch_data]
-)
+```python
+async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]
```
-### Sandboxed Tools
+Called before LLM processing starts.
-Run tools inside the sandbox with the `@sandboxed` decorator:
+#### LoggingCallback.on_llm_end
```python
-from computer.helpers import sandboxed
+async def on_llm_end(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]
+```
-@sandboxed()
-def read_sandbox_file(path: str) -> str:
- """Read a file from inside the sandbox"""
- with open(path, 'r') as f:
- return f.read()
+Called after LLM processing ends.
-agent = ComputerAgent(
- model="anthropic/claude-sonnet-4-5-20250929",
- tools=[computer, read_sandbox_file]
-)
+#### LoggingCallback.on_computer_call_start
+
+```python
+async def on_computer_call_start(self, item: Dict[str, Any]) -> None
```
-### BaseTool Class
+Called when a computer call starts.
-For full control over tool schema:
+#### LoggingCallback.on_computer_call_end
```python
-from agent.tools import BaseTool, register_tool
+async def on_computer_call_end(self, item: Dict[str, Any], result: Any) -> None
+```
+
+Called when a computer call ends.
-@register_tool("database_query")
-class DatabaseQueryTool(BaseTool):
- def __init__(self, connection_string: str):
- self.connection = connection_string
+#### LoggingCallback.on_function_call_start
- @property
- def description(self) -> str:
- return "Execute a read-only SQL query"
+```python
+async def on_function_call_start(self, item: Dict[str, Any]) -> None
+```
- @property
- def parameters(self) -> dict:
- return {
- "type": "object",
- "properties": {
- "query": {
- "type": "string",
- "description": "SQL SELECT query to execute"
- }
- },
- "required": ["query"]
- }
+Called when a function call starts.
- def call(self, params, **kwargs):
- query = params["query"] if isinstance(params, dict) else params
- # Execute and return results
- return {"rows": [...]}
+#### LoggingCallback.on_function_call_end
+
+```python
+async def on_function_call_end(self, item: Dict[str, Any], result: Any) -> None
```
-### ToolError
+Called when a function call ends.
-Raise `ToolError` for recoverable errors:
+#### LoggingCallback.on_text
```python
-from agent.tools import ToolError
+async def on_text(self, item: Dict[str, Any]) -> None
+```
+
+Called when a text message is encountered.
-def divide(a: float, b: float) -> float:
- """Divide a by b"""
- if b == 0:
- raise ToolError("Cannot divide by zero")
- return a / b
+#### LoggingCallback.on_api_start
+
+```python
+async def on_api_start(self, kwargs: Dict[str, Any]) -> None
```
-The model sees the error message and can adjust its approach.
+Called when an API call is about to start.
+
+#### LoggingCallback.on_api_end
+
+```python
+async def on_api_end(self, kwargs: Dict[str, Any], result: Any) -> None
+```
+
+Called when an API call has completed.
+
+#### LoggingCallback.on_screenshot
+
+```python
+async def on_screenshot(self, item: Union[str, bytes], name: str = 'screenshot') -> None
+```
+
+Called when a screenshot is taken.
+
+---
+
+## OperatorNormalizerCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Normalizes common computer call hallucinations / errors in computer call syntax.
+
+### Methods
+
+#### OperatorNormalizerCallback.on_llm_end
+
+```python
+async def on_llm_end(self, output: List[Dict[str, Any]]) -> List[Dict[str, Any]]
+```
---
-## Model Providers
+## OtelCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+OpenTelemetry callback handler for instrumentation.
+
+Tracks:
+- Agent session lifecycle (start/end)
+- Agent run lifecycle (start/end with duration)
+- Individual steps (with duration)
+- Computer actions (with duration)
+- Token usage
+- Errors
+
+### Constructor
+
+```python
+OtelCallback(self, agent: Any)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent` | `Any` | |
+| `model` | `Any` | |
+| `run_start_time` | `Optional[float]` | |
+| `step_start_time` | `Optional[float]` | |
+| `step_count` | `Any` | |
+
+### Methods
+
+#### OtelCallback.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the start of an agent run loop.
+
+#### OtelCallback.on_run_end
+
+```python
+async def on_run_end(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the end of an agent run loop.
+
+#### OtelCallback.on_responses
-### Model Format
+```python
+async def on_responses(self, kwargs: Dict[str, Any], responses: Dict[str, Any]) -> None
+```
-Models are specified as `provider/model-name`:
+Called when responses are received (each step).
+
+#### OtelCallback.on_usage
```python
-# Anthropic
-agent = ComputerAgent(model="anthropic/claude-sonnet-4-5-20250929", ...)
+async def on_usage(self, usage: Dict[str, Any]) -> None
+```
-# OpenAI
-agent = ComputerAgent(model="openai/computer-use-preview", ...)
+Called when usage information is received.
-# Google
-agent = ComputerAgent(model="google/gemini-2.5-flash", ...)
+#### OtelCallback.on_computer_call_start
-# Local models via Ollama
-agent = ComputerAgent(model="ollama/ui-tars:latest", ...)
+```python
+async def on_computer_call_start(self, item: Dict[str, Any]) -> None
```
-### Composed Models
+Called when a computer call is about to start.
-Use `+` to combine models for different capabilities:
+#### OtelCallback.on_computer_call_end
```python
-# UI-TARS for grounding, Claude for planning
-agent = ComputerAgent(
- model="ollama/ui-tars:latest+anthropic/claude-sonnet-4-5-20250929",
- tools=[computer]
-)
+async def on_computer_call_end(self, item: Dict[str, Any], result: List[Dict[str, Any]]) -> None
+```
+
+Called when a computer call has completed.
+
+#### OtelCallback.on_api_start
-# Qwen for grounding, GPT-4 for planning
-agent = ComputerAgent(
- model="ollama/qwen2.5-vl:latest+openai/gpt-4o",
- tools=[computer]
-)
+```python
+async def on_api_start(self, kwargs: Dict[str, Any]) -> None
```
-### Environment Variables
+Called when an LLM API call is about to start.
+
+#### OtelCallback.on_api_end
+
+```python
+async def on_api_end(self, kwargs: Dict[str, Any], result: Any) -> None
+```
-| Variable | Description |
-| ------------------- | -------------------------------------------- |
-| `ANTHROPIC_API_KEY` | API key for Anthropic models |
-| `OPENAI_API_KEY` | API key for OpenAI models |
-| `GOOGLE_API_KEY` | API key for Google models |
-| `OLLAMA_HOST` | Host for Ollama (default: `localhost:11434`) |
+Called when an LLM API call has completed.
---
-## Chat History
+## OtelErrorCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Callback that captures errors and sends them to Sentry/OTEL.
+
+Should be added early in the callback chain to catch all errors.
-Pass previous messages to maintain context:
+### Constructor
```python
-from agent.types import Message
+OtelErrorCallback(self, agent: Any)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent` | `Any` | |
+| `model` | `Any` | |
+
+### Methods
-history = [
- Message(role="user", content="Open the browser"),
- Message(role="assistant", content="I've opened Firefox."),
-]
+#### OtelErrorCallback.on_error
-async for result in agent.run(
- "Now search for Python tutorials",
- chat_history=history
-):
- print(result.text)
+```python
+async def on_error(self, error: Exception, context: Dict[str, Any]) -> None
```
-### Message Format
+Called when an error occurs during agent execution.
+
+---
+
+## PromptInstructionsCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Prepend a user instructions message to the message list.
+
+This is a minimal, non-invasive way to guide the agent's behavior without
+modifying agent loops or tools. It works with any provider/loop since it
+only alters the messages array before sending to the model.
+
+### Constructor
```python
-from agent.types import Message
+PromptInstructionsCallback(self, instructions: Optional[str]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `instructions` | `Any` | |
-# User message
-user_msg = Message(role="user", content="Click the button")
+### Methods
-# Assistant message
-assistant_msg = Message(role="assistant", content="I clicked the submit button.")
+#### PromptInstructionsCallback.on_llm_start
-# System message (for instructions)
-system_msg = Message(role="system", content="Be concise in responses.")
+```python
+async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]
```
---
-## Error Handling
+## TelemetryCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Telemetry callback handler for Computer-Use Agent (cua-agent)
-Handle errors during agent execution:
+Tracks agent usage, performance metrics, and optionally trajectory data.
+
+### Constructor
```python
-from agent import ComputerAgent
-from agent.errors import AgentError, BudgetExceededError
+TelemetryCallback(self, agent, log_trajectory: bool = False)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent` | `Any` | |
+| `log_trajectory` | `Any` | |
+| `session_id` | `Any` | |
+| `run_id` | `Any` | |
+| `run_start_time` | `Any` | |
+| `step_count` | `Any` | |
+| `step_start_time` | `Any` | |
+| `total_usage` | `Any` | |
-try:
- async for result in agent.run("Complete the form"):
- if result.error:
- print(f"Action failed: {result.error}")
- print(result.text)
-except BudgetExceededError:
- print("Budget limit reached")
-except AgentError as e:
- print(f"Agent error: {e}")
+### Methods
+
+#### TelemetryCallback.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the start of an agent run loop.
+
+#### TelemetryCallback.on_run_end
+
+```python
+async def on_run_end(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> None
+```
+
+Called at the end of an agent run loop.
+
+#### TelemetryCallback.on_usage
+
+```python
+async def on_usage(self, usage: Dict[str, Any]) -> None
```
-### Error Types
+Called when usage information is received.
+
+#### TelemetryCallback.on_responses
+
+```python
+async def on_responses(self, kwargs: Dict[str, Any], responses: Dict[str, Any]) -> None
+```
-| Error | Description |
-| --------------------- | --------------------------- |
-| `AgentError` | Base class for agent errors |
-| `BudgetExceededError` | Cost limit exceeded |
-| `ModelError` | Model API error |
-| `ToolError` | Tool execution error |
+Called when responses are received.
---
-## Trajectory Configuration
+## TrajectorySaverCallback
+
+*Inherits from: AsyncCallbackHandler*
+
+Callback handler that saves agent trajectories to disk.
+
+Saves each run as a separate trajectory with unique ID, and each turn
+within the trajectory gets its own folder with screenshots and responses.
+
+### Constructor
+
+```python
+TrajectorySaverCallback(self, trajectory_dir: str, reset_on_run: bool = True, screenshot_dir: Optional[str] = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `trajectory_dir` | `Any` | |
+| `trajectory_id` | `Optional[str]` | |
+| `current_turn` | `int` | |
+| `current_artifact` | `int` | |
+| `model` | `Optional[str]` | |
+| `total_usage` | `Dict[str, Any]` | |
+| `reset_on_run` | `Any` | |
+| `screenshot_dir` | `Optional[Path]` | |
+
+### Methods
+
+#### TrajectorySaverCallback.on_run_start
+
+```python
+async def on_run_start(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]]) -> None
+```
+
+Initialize trajectory tracking for a new run.
+
+#### TrajectorySaverCallback.on_run_end
+
+```python
+async def on_run_end(self, kwargs: Dict[str, Any], old_items: List[Dict[str, Any]], new_items: List[Dict[str, Any]]) -> None
+```
+
+Finalize run tracking by updating metadata with completion status, usage, and new items.
+
+#### TrajectorySaverCallback.on_api_start
+
+```python
+async def on_api_start(self, kwargs: Dict[str, Any]) -> None
+```
+
+#### TrajectorySaverCallback.on_api_end
+
+```python
+async def on_api_end(self, kwargs: Dict[str, Any], result: Any) -> None
+```
+
+Save API call result.
+
+#### TrajectorySaverCallback.on_screenshot
+
+```python
+async def on_screenshot(self, screenshot: Union[str, bytes], name: str = 'screenshot') -> None
+```
+
+Save a screenshot.
+
+#### TrajectorySaverCallback.on_usage
+
+```python
+async def on_usage(self, usage: Dict[str, Any]) -> None
+```
+
+Called when usage information is received.
+
+#### TrajectorySaverCallback.on_responses
+
+```python
+async def on_responses(self, kwargs: Dict[str, Any], responses: Dict[str, Any]) -> None
+```
+
+Save responses to the current turn directory and update usage statistics.
-Configure trajectory saving with a dict:
+#### TrajectorySaverCallback.on_computer_call_end
```python
-agent = ComputerAgent(
- model="anthropic/claude-sonnet-4-5-20250929",
- tools=[computer],
- trajectory_dir={
- "trajectory_dir": "trajectories",
- "reset_on_run": False, # Continue same trajectory across runs
- "screenshot_dir": "screenshots" # Save screenshots separately
- }
-)
+async def on_computer_call_end(self, item: Dict[str, Any], result: List[Dict[str, Any]]) -> None
```
-| Option | Default | Description |
-| ---------------- | -------- | ----------------------------- |
-| `trajectory_dir` | Required | Base directory |
-| `reset_on_run` | `True` | Create new ID per run |
-| `screenshot_dir` | `None` | Separate screenshot directory |
+Called when a computer call has completed.
+Saves screenshots and computer call output.
diff --git a/docs/content/docs/cua/reference/agent-sdk/meta.json b/docs/content/docs/cua/reference/agent-sdk/meta.json
index 096a077dbc..0d3799c957 100644
--- a/docs/content/docs/cua/reference/agent-sdk/meta.json
+++ b/docs/content/docs/cua/reference/agent-sdk/meta.json
@@ -2,5 +2,5 @@
"title": "Agent SDK",
"description": "Python API for building computer-use agents",
"icon": "Bot",
- "pages": ["index"]
+ "pages": ["changelog"]
}
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.3/api.mdx b/docs/content/docs/cua/reference/agent-sdk/v0.3/api.mdx
new file mode 100644
index 0000000000..9dcc6f85bf
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.3/api.mdx
@@ -0,0 +1,70 @@
+---
+title: Agent SDK v0.3 API Reference
+description: API reference for Agent SDK version 0.3
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: agent-v0.3.2
+Version: 0.3.2
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.3**. [View latest version](/cua/reference/agent-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.3.2
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-agent==0.3.2</span>
+</div>
+
+CUA (Computer Use) Agent for AI-driven computer interaction.
+
+## Classes
+
+| Class | Description |
+| --------------- | -------------------------------------------------------------------------------------- |
+| `LLMProvider` | Supported LLM providers. |
+| `LLM` | Configuration for LLM model and provider. |
+| `ComputerAgent` | A computer agent that can perform automated tasks using natural language instructions. |
+
+## LLMProvider
+
+Supported LLM providers.
+
+## LLM
+
+Configuration for LLM model and provider.
+
+## ComputerAgent
+
+A computer agent that can perform automated tasks using natural language instructions.
+
+### Methods
+
+#### ComputerAgent.initialize
+
+```python
+async def initialize(self) -> None
+```
+
+Initialize the agent and its components.
+
+#### ComputerAgent.run
+
+```python
+async def run(self, task: str) -> AsyncGenerator[AgentResponse, None]
+```
+
+Run a task using the computer agent.
+
+Args:
+task: Task description
+
+Yields:
+Agent response format
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.3/meta.json b/docs/content/docs/cua/reference/agent-sdk/v0.3/meta.json
new file mode 100644
index 0000000000..4f4b3dc2bf
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.3/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.3",
+ "description": "Agent SDK v0.3 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.4/api.mdx b/docs/content/docs/cua/reference/agent-sdk/v0.4/api.mdx
new file mode 100644
index 0000000000..b1fbe0fefd
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.4/api.mdx
@@ -0,0 +1,83 @@
+---
+title: Agent SDK v0.4 API Reference
+description: API reference for Agent SDK version 0.4
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: agent-v0.4.53
+Version: 0.4.53
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.4**. [View latest version](/cua/reference/agent-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.4.53
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-agent==0.4.53</span>
+</div>
+
+agent - Decorator-based Computer Use Agent with liteLLM integration
+
+## Classes
+
+| Class | Description |
+| --------------- | ---------------------------------------------------------------------- |
+| `ComputerAgent` | Main agent class that automatically selects the appropriate agent loop |
+
+## ComputerAgent
+
+Main agent class that automatically selects the appropriate agent loop
+based on the model and executes tool calls.
+
+### Methods
+
+#### ComputerAgent.run
+
+```python
+async def run(self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {}) -> AsyncGenerator[Dict[str, Any], None]
+```
+
+Run the agent with the given messages using Computer protocol handler pattern.
+
+Args:
+messages: List of message dictionaries
+stream: Whether to stream the response
+api_key: Optional API key override for the model provider
+api_base: Optional API base URL override for the model provider
+\*\*additional_generation_kwargs: Additional arguments passed to the model provider
+
+Returns:
+AsyncGenerator that yields response chunks
+
+#### ComputerAgent.predict_click
+
+```python
+async def predict_click(self, instruction: str, image_b64: Optional[str] = None) -> Optional[Tuple[int, int]]
+```
+
+Predict click coordinates based on image and instruction.
+
+Args:
+instruction: Instruction for where to click
+image_b64: Base64 encoded image (optional, will take screenshot if not provided)
+
+Returns:
+None or tuple with (x, y) coordinates
+
+#### ComputerAgent.get_capabilities
+
+```python
+def get_capabilities(self) -> List[AgentCapability]
+```
+
+Get list of capabilities supported by the current agent config.
+
+Returns:
+List of capability strings (e.g., ["step", "click"])
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.4/meta.json b/docs/content/docs/cua/reference/agent-sdk/v0.4/meta.json
new file mode 100644
index 0000000000..c1fcce1a7b
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.4/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.4",
+ "description": "Agent SDK v0.4 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.5/api.mdx b/docs/content/docs/cua/reference/agent-sdk/v0.5/api.mdx
new file mode 100644
index 0000000000..80eed1cfa3
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.5/api.mdx
@@ -0,0 +1,83 @@
+---
+title: Agent SDK v0.5 API Reference
+description: API reference for Agent SDK version 0.5
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: agent-v0.5.2
+Version: 0.5.2
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.5**. [View latest version](/cua/reference/agent-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.5.2
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-agent==0.5.2</span>
+</div>
+
+agent - Decorator-based Computer Use Agent with liteLLM integration
+
+## Classes
+
+| Class | Description |
+| --------------- | ---------------------------------------------------------------------- |
+| `ComputerAgent` | Main agent class that automatically selects the appropriate agent loop |
+
+## ComputerAgent
+
+Main agent class that automatically selects the appropriate agent loop
+based on the model and executes tool calls.
+
+### Methods
+
+#### ComputerAgent.run
+
+```python
+async def run(self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {}) -> AsyncGenerator[Dict[str, Any], None]
+```
+
+Run the agent with the given messages using Computer protocol handler pattern.
+
+Args:
+messages: List of message dictionaries
+stream: Whether to stream the response
+api_key: Optional API key override for the model provider
+api_base: Optional API base URL override for the model provider
+\*\*additional_generation_kwargs: Additional arguments passed to the model provider
+
+Returns:
+AsyncGenerator that yields response chunks
+
+#### ComputerAgent.predict_click
+
+```python
+async def predict_click(self, instruction: str, image_b64: Optional[str] = None) -> Optional[Tuple[int, int]]
+```
+
+Predict click coordinates based on image and instruction.
+
+Args:
+instruction: Instruction for where to click
+image_b64: Base64 encoded image (optional, will take screenshot if not provided)
+
+Returns:
+None or tuple with (x, y) coordinates
+
+#### ComputerAgent.get_capabilities
+
+```python
+def get_capabilities(self) -> List[AgentCapability]
+```
+
+Get list of capabilities supported by the current agent config.
+
+Returns:
+List of capability strings (e.g., ["step", "click"])
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.5/meta.json b/docs/content/docs/cua/reference/agent-sdk/v0.5/meta.json
new file mode 100644
index 0000000000..0332e1eb36
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.5/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.5",
+ "description": "Agent SDK v0.5 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.6/api.mdx b/docs/content/docs/cua/reference/agent-sdk/v0.6/api.mdx
new file mode 100644
index 0000000000..d28c71bf7e
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.6/api.mdx
@@ -0,0 +1,99 @@
+---
+title: Agent SDK v0.6 API Reference
+description: API reference for Agent SDK version 0.6
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: agent-v0.6.2
+Version: 0.6.2
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.6**. [View latest version](/cua/reference/agent-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.6.2
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-agent==0.6.2</span>
+</div>
+
+agent - Decorator-based Computer Use Agent with liteLLM integration
+
+## Classes
+
+| Class | Description |
+| --------------- | ---------------------------------------------------------------------- |
+| `ComputerAgent` | Main agent class that automatically selects the appropriate agent loop |
+
+## ComputerAgent
+
+Main agent class that automatically selects the appropriate agent loop
+based on the model and executes tool calls.
+
+### Methods
+
+#### ComputerAgent.run
+
+```python
+async def run(self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {}) -> AsyncGenerator[Dict[str, Any], None]
+```
+
+Run the agent with the given messages using Computer protocol handler pattern.
+
+Args:
+messages: List of message dictionaries
+stream: Whether to stream the response
+api_key: Optional API key override for the model provider
+api_base: Optional API base URL override for the model provider
+\*\*additional_generation_kwargs: Additional arguments passed to the model provider
+
+Returns:
+AsyncGenerator that yields response chunks
+
+#### ComputerAgent.predict_click
+
+```python
+async def predict_click(self, instruction: str, image_b64: Optional[str] = None) -> Optional[Tuple[int, int]]
+```
+
+Predict click coordinates based on image and instruction.
+
+Args:
+instruction: Instruction for where to click
+image_b64: Base64 encoded image (optional, will take screenshot if not provided)
+
+Returns:
+None or tuple with (x, y) coordinates
+
+#### ComputerAgent.get_capabilities
+
+```python
+def get_capabilities(self) -> List[AgentCapability]
+```
+
+Get list of capabilities supported by the current agent config.
+
+Returns:
+List of capability strings (e.g., ["step", "click"])
+
+#### ComputerAgent.open
+
+```python
+def open(self, port: Optional[int] = None)
+```
+
+Start the playground server and open it in the browser.
+
+This method starts a local HTTP server that exposes the /responses endpoint
+and automatically opens the CUA playground interface in the default browser.
+
+Args:
+port: Port to run the server on. If None, finds an available port automatically.
+
+Example: >>> agent = ComputerAgent(model="claude-sonnet-4") >>> agent.open() # Starts server and opens browser
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.6/meta.json b/docs/content/docs/cua/reference/agent-sdk/v0.6/meta.json
new file mode 100644
index 0000000000..d141fa6c32
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.6/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.6",
+ "description": "Agent SDK v0.6 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.7/api.mdx b/docs/content/docs/cua/reference/agent-sdk/v0.7/api.mdx
new file mode 100644
index 0000000000..d5ac95e669
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.7/api.mdx
@@ -0,0 +1,99 @@
+---
+title: Agent SDK v0.7 API Reference
+description: API reference for Agent SDK version 0.7
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: agent-v0.7.23
+Version: 0.7.23
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.7**. [View latest version](/cua/reference/agent-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.7.23
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-agent==0.7.23</span>
+</div>
+
+agent - Decorator-based Computer Use Agent with liteLLM integration
+
+## Classes
+
+| Class | Description |
+| --------------- | ---------------------------------------------------------------------- |
+| `ComputerAgent` | Main agent class that automatically selects the appropriate agent loop |
+
+## ComputerAgent
+
+Main agent class that automatically selects the appropriate agent loop
+based on the model and executes tool calls.
+
+### Methods
+
+#### ComputerAgent.run
+
+```python
+async def run(self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, additional_generation_kwargs = {}) -> AsyncGenerator[Dict[str, Any], None]
+```
+
+Run the agent with the given messages using Computer protocol handler pattern.
+
+Args:
+messages: List of message dictionaries
+stream: Whether to stream the response
+api_key: Optional API key override for the model provider
+api_base: Optional API base URL override for the model provider
+\*\*additional_generation_kwargs: Additional arguments passed to the model provider
+
+Returns:
+AsyncGenerator that yields response chunks
+
+#### ComputerAgent.predict_click
+
+```python
+async def predict_click(self, instruction: str, image_b64: Optional[str] = None) -> Optional[Tuple[int, int]]
+```
+
+Predict click coordinates based on image and instruction.
+
+Args:
+instruction: Instruction for where to click
+image_b64: Base64 encoded image (optional, will take screenshot if not provided)
+
+Returns:
+None or tuple with (x, y) coordinates
+
+#### ComputerAgent.get_capabilities
+
+```python
+def get_capabilities(self) -> List[AgentCapability]
+```
+
+Get list of capabilities supported by the current agent config.
+
+Returns:
+List of capability strings (e.g., ["step", "click"])
+
+#### ComputerAgent.open
+
+```python
+def open(self, port: Optional[int] = None)
+```
+
+Start the playground server and open it in the browser.
+
+This method starts a local HTTP server that exposes the /responses endpoint
+and automatically opens the Cua playground interface in the default browser.
+
+Args:
+port: Port to run the server on. If None, finds an available port automatically.
+
+Example: >>> agent = ComputerAgent(model="claude-sonnet-4") >>> agent.open() # Starts server and opens browser
diff --git a/docs/content/docs/cua/reference/agent-sdk/v0.7/meta.json b/docs/content/docs/cua/reference/agent-sdk/v0.7/meta.json
new file mode 100644
index 0000000000..832d2e52d9
--- /dev/null
+++ b/docs/content/docs/cua/reference/agent-sdk/v0.7/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.7",
+ "description": "Agent SDK v0.7 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/cli/changelog.mdx b/docs/content/docs/cua/reference/cli/changelog.mdx
new file mode 100644
index 0000000000..9a54d7db74
--- /dev/null
+++ b/docs/content/docs/cua/reference/cli/changelog.mdx
@@ -0,0 +1,28 @@
+---
+title: Changelog
+description: Release history for Cua CLI
+---
+
+# CLI Changelog
+
+All notable changes to the Cua CLI are documented here.
+
+## 0.1.x
+
+### v0.1.0 (Unreleased)
+
+Initial release of the unified Cua CLI.
+
+**Features:**
+
+- Authentication management (`cua auth login/logout/env`)
+- Sandbox lifecycle management (`cua sandbox create/list/start/stop/delete`)
+- Cloud image management (`cua image list/push/pull/delete`)
+- Skills recording and playback (`cua skills record/list/read/replay`)
+- MCP server for AI assistants (`cua serve-mcp`)
+
+**Installation:**
+
+```bash
+pip install cua-cli
+```
diff --git a/docs/content/docs/cua/reference/cli/commands.mdx b/docs/content/docs/cua/reference/cli/commands.mdx
new file mode 100644
index 0000000000..40eb9cd2aa
--- /dev/null
+++ b/docs/content/docs/cua/reference/cli/commands.mdx
@@ -0,0 +1,338 @@
+---
+title: Command Reference
+description: Complete reference for all Cua CLI commands
+---
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { VersionBadge } from '@/components/version-selector';
+
+<VersionBadge version="0.1.0" />
+
+## Overview
+
+The Cua CLI provides commands for authentication, sandbox management, image management, skills recording, and MCP server.
+
+### Command Groups
+
+| Group | Alias | Description |
+| --------------- | --------- | ---------------------------------- |
+| `cua auth` | | Authentication management |
+| `cua sandbox` | `cua sb` | Sandbox lifecycle management |
+| `cua image` | `cua img` | Cloud image management |
+| `cua skills` | | Skills recording and playback |
+| `cua serve-mcp` | | Start MCP server for AI assistants |
+
+## Authentication Commands
+
+### `cua auth login`
+
+Authenticate with your Cua account.
+
+```bash
+# Browser-based login
+cua auth login
+
+# Direct API key login
+cua auth login --api-key sk_cua-api01_...
+```
+
+### `cua auth env`
+
+Export your API key to a `.env` file in the current directory.
+
+```bash
+cua auth env
+```
+
+### `cua auth logout`
+
+Remove the stored API key.
+
+```bash
+cua auth logout
+```
+
+## Sandbox Commands
+
+All sandbox commands support the `cua sb` alias (e.g., `cua sb list`).
+
+### `cua sandbox list`
+
+List all sandboxes.
+
+```bash
+cua sandbox list
+
+# With JSON output
+cua sandbox list --json
+
+# Show passwords
+cua sandbox list --show-passwords
+```
+
+**Aliases:** `cua sb ls`, `cua sb ps`
+
+### `cua sandbox create`
+
+Create a new sandbox.
+
+```bash
+cua sandbox create --os <OS> --size <SIZE> --region <REGION>
+```
+
+**Required options:**
+
+| Option | Values |
+| ---------- | ---------------------------------------------------------- |
+| `--os` | `linux`, `windows`, `macos` |
+| `--size` | `small`, `medium`, `large` |
+| `--region` | `north-america`, `europe`, `asia-pacific`, `south-america` |
+
+**Example:**
+
+```bash
+cua sandbox create --os linux --size small --region north-america
+```
+
+### `cua sandbox get`
+
+Get details for a specific sandbox.
+
+```bash
+cua sandbox get <name>
+
+# With options
+cua sandbox get <name> --json
+cua sandbox get <name> --show-passwords
+cua sandbox get <name> --show-vnc-url
+```
+
+### `cua sandbox start`
+
+Start a stopped sandbox.
+
+```bash
+cua sandbox start <name>
+```
+
+### `cua sandbox stop`
+
+Stop a running sandbox.
+
+```bash
+cua sandbox stop <name>
+```
+
+### `cua sandbox restart`
+
+Restart a sandbox.
+
+```bash
+cua sandbox restart <name>
+```
+
+### `cua sandbox suspend`
+
+Suspend a sandbox (preserves memory state).
+
+```bash
+cua sandbox suspend <name>
+```
+
+### `cua sandbox delete`
+
+Delete a sandbox permanently.
+
+```bash
+cua sandbox delete <name>
+```
+
+<Callout type="warn">
+ This action is irreversible. All data on the sandbox will be permanently lost.
+</Callout>
+
+### `cua sandbox vnc`
+
+Open the sandbox desktop in your browser.
+
+```bash
+cua sandbox vnc <name>
+```
+
+**Alias:** `cua sb open <name>`
+
+## Image Commands
+
+All image commands support the `cua img` alias.
+
+### `cua image list`
+
+List cloud images.
+
+```bash
+cua image list
+
+# JSON output
+cua image list --json
+
+# List local images instead
+cua image list --local
+```
+
+**Alias:** `cua img ls`
+
+### `cua image push`
+
+Upload a local image to the cloud.
+
+```bash
+cua image push <name> --file <path> --tag <tag>
+```
+
+### `cua image pull`
+
+Download an image from the cloud.
+
+```bash
+cua image pull <name> --tag <tag> --output <path>
+```
+
+### `cua image delete`
+
+Delete a cloud image.
+
+```bash
+cua image delete <name> --tag <tag>
+
+# Skip confirmation
+cua image delete <name> --tag <tag> --force
+```
+
+## Skills Commands
+
+Skills are recorded demonstrations that guide agent behavior.
+
+### `cua skills list`
+
+List all saved skills.
+
+```bash
+cua skills list
+
+# JSON output
+cua skills list --json
+```
+
+### `cua skills record`
+
+Record a new skill from a sandbox.
+
+```bash
+cua skills record --sandbox <name>
+
+# With options
+cua skills record --sandbox <name> --name "my-skill" --description "Does something"
+cua skills record --sandbox <name> --provider anthropic --model claude-sonnet-4-5-20250514
+```
+
+**Options:**
+
+| Option | Description |
+| --------------- | --------------------------------------------------- |
+| `--sandbox` | Sandbox to record from |
+| `--name` | Skill name (skips prompt) |
+| `--description` | Skill description (skips prompt) |
+| `--provider` | LLM provider for captioning (`anthropic`, `openai`) |
+| `--model` | Model to use for captioning |
+
+### `cua skills read`
+
+Display a skill's instructions.
+
+```bash
+cua skills read <name>
+
+# JSON format with trajectory data
+cua skills read <name> --format json
+```
+
+### `cua skills replay`
+
+Open the recorded video for a skill.
+
+```bash
+cua skills replay <name>
+```
+
+### `cua skills delete`
+
+Delete a skill.
+
+```bash
+cua skills delete <name>
+```
+
+### `cua skills clean`
+
+Delete all skills (with confirmation).
+
+```bash
+cua skills clean
+```
+
+## MCP Server
+
+Run the CLI as an MCP (Model Context Protocol) server for AI assistants like Claude.
+
+### `cua serve-mcp`
+
+Start the MCP server.
+
+```bash
+cua serve-mcp
+
+# With specific sandbox
+cua serve-mcp --sandbox <name>
+
+# With permission restrictions
+cua serve-mcp --permissions sandbox:readonly
+```
+
+**Options:**
+
+| Option | Description |
+| --------------- | ------------------------------------- |
+| `--sandbox` | Default sandbox for computer commands |
+| `--permissions` | Permission groups (see below) |
+
+**Permission groups:**
+
+| Group | Description |
+| ------------------- | ---------------------------- |
+| `all` | All permissions (default) |
+| `sandbox:all` | Full sandbox management |
+| `sandbox:readonly` | List and view sandboxes only |
+| `computer:all` | Full computer control |
+| `computer:readonly` | Screenshots only |
+| `skills:all` | Full skills management |
+| `skills:readonly` | List and read skills only |
+
+**Example with multiple permissions:**
+
+```bash
+cua serve-mcp --permissions "sandbox:all,computer:readonly,skills:list"
+```
+
+## Environment Variables
+
+| Variable | Description |
+| --------------------- | -------------------------- |
+| `CUA_API_KEY` | API key for authentication |
+| `CUA_SANDBOX` | Default sandbox name |
+| `CUA_MCP_PERMISSIONS` | Default MCP permissions |
+
+## Next Steps
+
+- [Quickstart Guide](/cua/guide/get-started/quickstart)
+- [Computer SDK Reference](/cua/reference/computer-sdk)
+- [Agent SDK Reference](/cua/reference/agent-sdk)
diff --git a/docs/content/docs/cua/reference/cli/index.mdx b/docs/content/docs/cua/reference/cli/index.mdx
new file mode 100644
index 0000000000..134505206f
--- /dev/null
+++ b/docs/content/docs/cua/reference/cli/index.mdx
@@ -0,0 +1,249 @@
+---
+title: Cua CLI API Reference
+description: Python API reference for the Cua command-line interface
+---
+
+{/*
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+ Generated by: npx tsx scripts/docs-generators/python-sdk.ts
+ Source: libs/python/cua-cli/cua_cli
+ Version: 0.1.0
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"0.1","href":"/cua/reference/cli","isCurrent":true}]}
+ currentVersion="0.1"
+ fullVersion="0.1.0"
+ packageName="cua-cli"
+/>
+
+CUA CLI - Unified command-line interface for Computer-Use Agents.
+
+---
+
+## main
+
+Main entry point for CUA CLI.
+
+### print_error
+
+```python
+def print_error(message: str) -> None
+```
+
+Print an error message to stderr.
+
+### create_parser
+
+```python
+def create_parser() -> argparse.ArgumentParser
+```
+
+Create the main argument parser with all subcommands.
+
+### main
+
+```python
+def main() -> int
+```
+
+Main entry point for the CLI.
+
+---
+
+## auth
+
+Authentication module for CUA CLI.
+
+---
+
+## CredentialStore
+
+SQLite-based credential store with WAL mode for concurrent access.
+
+### Constructor
+
+```python
+CredentialStore(self, db_path: Path | None = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `db_path` | `Any` | |
+
+### Methods
+
+#### CredentialStore.get
+
+```python
+def get(self, key: str) -> Optional[str]
+```
+
+Get a value from the store.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to look up |
+
+**Returns:** The value, or None if not found
+
+#### CredentialStore.set
+
+```python
+def set(self, key: str, value: str) -> None
+```
+
+Set a value in the store.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to set |
+| `value` | `Any` | The value to store |
+
+#### CredentialStore.delete
+
+```python
+def delete(self, key: str) -> bool
+```
+
+Delete a value from the store.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to delete |
+
+**Returns:** True if the key was deleted, False if it didn't exist
+
+#### CredentialStore.clear
+
+```python
+def clear(self) -> None
+```
+
+Clear all stored credentials.
+
+### clear_credentials
+
+```python
+def clear_credentials() -> None
+```
+
+Clear all stored credentials.
+
+### get_api_key
+
+```python
+def get_api_key() -> Optional[str]
+```
+
+Get the stored API key.
+
+First checks CUA_API_KEY environment variable, then falls back to stored credentials.
+
+**Returns:** The API key, or None if not found
+
+### save_api_key
+
+```python
+def save_api_key(api_key: str) -> None
+```
+
+Save an API key to the credential store.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `api_key` | `Any` | The API key to save |
+
+---
+
+## utils
+
+Utility modules for CUA CLI.
+
+### run_async
+
+```python
+def run_async(coro: Coroutine[Any, Any, T]) -> T
+```
+
+Run an async coroutine synchronously.
+
+This is the standard pattern for CLI commands that need to call async code.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `coro` | `Any` | The coroutine to run |
+
+**Returns:** The result of the coroutine
+
+### print_error
+
+```python
+def print_error(message: str) -> None
+```
+
+Print an error message to stderr.
+
+### print_info
+
+```python
+def print_info(message: str) -> None
+```
+
+Print an info message.
+
+### print_json
+
+```python
+def print_json(data: Any) -> None
+```
+
+Print data as formatted JSON.
+
+### print_success
+
+```python
+def print_success(message: str) -> None
+```
+
+Print a success message.
+
+### print_table
+
+```python
+def print_table(data: list[dict[str, Any]], columns: list[tuple[str, str]] | None = None, title: str | None = None) -> None
+```
+
+Print data as a formatted table.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `data` | `Any` | List of dictionaries to display |
+| `columns` | `Any` | List of (key, header) tuples. If None, uses all keys from first item. |
+| `title` | `Any` | Optional table title |
+
+### print_warning
+
+```python
+def print_warning(message: str) -> None
+```
+
+Print a warning message.
diff --git a/docs/content/docs/cua/reference/cli/meta.json b/docs/content/docs/cua/reference/cli/meta.json
new file mode 100644
index 0000000000..739205a5cd
--- /dev/null
+++ b/docs/content/docs/cua/reference/cli/meta.json
@@ -0,0 +1,6 @@
+{
+ "title": "CLI",
+ "description": "Command-line interface for Cua",
+ "icon": "Terminal",
+ "pages": ["commands", "changelog"]
+}
diff --git a/docs/content/docs/cua/reference/computer-sdk/changelog.mdx b/docs/content/docs/cua/reference/computer-sdk/changelog.mdx
new file mode 100644
index 0000000000..7b1ce79d1f
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/changelog.mdx
@@ -0,0 +1,328 @@
+---
+title: Changelog
+description: Release history for Computer SDK
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-changelog.ts
+Last updated: 2026-02-04
+*/}
+
+# Computer SDK Changelog
+
+All notable changes to the Computer SDK are documented here.
+
+## 0.5.x
+
+### v0.5.12 (2026-01-26)
+
+- Initial release or no path-specific changes found
+
+### v0.5.11 (2026-01-24)
+
+- Bump cua-computer to v0.5.11 by @github-actions[bot]
+- Setup UV as venv manager for computer ([#789](https://github.com/trycua/cua/pull/789)) by @synacktraa
+
+### v0.5.10 (2026-01-17)
+
+Maintenance release.
+
+### v0.5.7 (2026-01-17)
+
+- Bump cua-computer to v0.5.7 by @github-actions[bot]
+- fix(computer): prevent data loss when tracing.stop path conflicts with trace directory ([#814](https://github.com/trycua/cua/pull/814)) by @Harsh Verma
+- Improve Computer API Server connection warnings and timeout errors ([#803](https://github.com/trycua/cua/pull/803)) by @Fizza Mukhtar
+- feat(computer): add OpenTelemetry instrumentation ([#663](https://github.com/trycua/cua/pull/663)) by @r33drichards
+
+### v0.5.6 (2026-01-12)
+
+- Initial release or no path-specific changes found
+
+### v0.5.5 (2026-01-12)
+
+- Initial release or no path-specific changes found
+
+### v0.5.4 (2026-01-12)
+
+- Bump cua-computer to v0.5.3 by @github-actions[bot]
+- Bump cua-computer to v0.5.2 by @github-actions[bot]
+- refactor(docs): reorganize lume/cua docs and standardize READMEs ([#752](https://github.com/trycua/cua/pull/752)) by @Francesco Bonacci
+- feat(lume,ci): add unattended VM setup and reorganize CI/CD workflows ([#729](https://github.com/trycua/cua/pull/729)) by @Francesco Bonacci
+- update dead links due to docs update by @Sarina Li
+- pyautogui cleanup by @Adam
+- Revert "refractor docs into 6 sections" by @Adam
+- refractor docs into 6 sections by @Adam
+
+## 0.4.x
+
+### v0.4.11 (2025-10-29)
+
+**Dependencies:** pylume: latest
+
+- Docs/improve readme by @jamesmurdza in https://github.com/trycua/cua/pull/512
+- Feature/version bump workflows by @r33drichards in https://github.com/trycua/cua/pull/511
+- Support `display` and `ephemeral` in Docker provider by @ddupont808 in https://github.com/trycua/cua/pull/514
+- Fix markdown formatting in docs by @jamesmurdza in https://github.com/trycua/cua/pull/523
+- Jagjeevan's Fix + Merged Main for 4o Model Fix by @sarinali in https://github.com/trycua/cua/pull/522
+- fix: Added GPT-4o compatibility for screenshot actions with text parameter by @JagjeevanAK in https://github.com/trycua/cua/pull/422
+- Remove PyLume code and examples by @jamesmurdza in https://github.com/trycua/cua/pull/435
+- Remove PyLume library by @jamesmurdza in https://github.com/trycua/cua/pull/527
+- Add test infrastructure with CI/CD #478 by @AceAtDev in https://github.com/trycua/cua/pull/491
+- Feature/agent loop test by @YeIIcw in https://github.com/trycua/cua/pull/528
+- Update Agent Loop Test by @YeIIcw in https://github.com/trycua/cua/pull/530
+- Fix/omniparser predict refactor by @sarinali in https://github.com/trycua/cua/pull/529
+- Fix agent test condition trigger by @YeIIcw in https://github.com/trycua/cua/pull/531
+- Fix/agent loop test by @YeIIcw in https://github.com/trycua/cua/pull/532
+- Add desktop and window management commands to computer interface by @ddupont808 in https://github.com/trycua/cua/pull/516
+
+### v0.4.10 (2025-10-14)
+
+- Fix XFCE Password Prompts and Lock Screen Issues by @f-trycua in https://github.com/trycua/cua/pull/466
+- Add Cloud VM Management API by @ddupont808 in https://github.com/trycua/cua/pull/452
+
+### v0.4.8 (2025-10-12)
+
+**Dependencies:** pylume: latest
+
+### v0.4.7 (2025-10-03)
+
+**Dependencies:** pylume: latest
+
+### v0.4.6 (2025-09-24)
+
+**Dependencies:** pylume: latest
+
+- 🔧 Improve HUD eval script: auto-discover .env and simplify usage by @YeIIcw in https://github.com/trycua/cua/pull/419
+- Fix Windows Sandbox errors by @ddupont808 in https://github.com/trycua/cua/pull/424
+
+New Contributors
+
+- @YeIIcw made their first contribution in https://github.com/trycua/cua/pull/419
+- @JagjeevanAK made their first contribution in https://github.com/trycua/cua/pull/420
+
+### v0.4.5 (2025-09-05)
+
+**Dependencies:** pylume: latest
+
+- Fix x/y scrolling by @ddupont808 in https://github.com/trycua/cua/pull/393
+- Fix invalid image error with some providers (i.e. WinSandbox)
+- Reference documentation batch by @onel in https://github.com/trycua/cua/pull/390
+
+### v0.4.4 (2025-08-19)
+
+**Dependencies:** pylume: latest
+
+- Update agent/computer SDKs to match changes in telemetry SDK by @jamesmurdza in https://github.com/trycua/cua/pull/355
+- Bugfixes - Removed slashes from container name by @ddupont808 in https://github.com/trycua/cua/pull/358
+
+### v0.4.3 (2025-08-15)
+
+**Dependencies:** pylume: latest
+
+- Fixed bug where the `image` kwarg would be ignored
+
+### v0.4.2 (2025-08-14)
+
+**Dependencies:** pylume: latest
+
+- [Computer] Add Docker as a local VM provider by @ddupont808 in https://github.com/trycua/cua/pull/339
+
+### v0.4.1 (2025-08-05)
+
+**Dependencies:** pylume: latest
+
+### v0.4.0 (2025-07-28)
+
+Bumped `cua-computer` to use latest `cua-core`
+
+## 0.3.x
+
+### v0.3.7 (2025-07-16)
+
+**Dependencies:** pylume: latest
+
+### v0.3.6 (2025-07-16)
+
+**Dependencies:** pylume: latest
+
+### v0.3.5 (2025-07-10)
+
+**Dependencies:** pylume: latest
+
+### v0.3.4 (2025-07-03)
+
+**Dependencies:** pylume: latest
+
+### v0.3.3 (2025-07-03)
+
+**Dependencies:** pylume: latest
+
+### v0.3.2 (2025-07-03)
+
+**Dependencies:** pylume: latest
+
+### v0.3.1 (2025-07-01)
+
+**Dependencies:** pylume: latest
+
+### v0.3.0 (2025-06-25)
+
+**Dependencies:** pylume: latest
+
+## 0.2.x
+
+### v0.2.13 (2025-06-24)
+
+**Dependencies:** pylume: latest
+
+### v0.2.12 (2025-06-20)
+
+**Dependencies:** pylume: latest
+
+### v0.2.11 (2025-06-18)
+
+**Dependencies:** pylume: latest
+
+### v0.2.10 (2025-06-10)
+
+**Dependencies:** pylume: latest
+
+- Removed warning when calling `start_vm` on the CloudProvider
+- Add disconnect() method for Computer
+- Fixed `file_exists` and `directory_exists` not being implemented in the computer-server
+- Added keyboard/mouse primitives ( `mouse_up`, `mouse_down`, `key_up`, `key_down` )
+- Added file system commands to computer interface
+- Added file system interface pytests
+- Improved computer interface accessibility tree output on macOS, now includes menubar and dock items, along with preserving z-ordering
+- Increased timeout for web socket commands due to a TimeoutError if the accessibility tree takes longer than 30 seconds to crawl
+
+**Changes reference:**
+
+```py
+... old actions haven't changed
+
+Disconnect from computer interface / cleanup websocket resources
+await computer.disconnect()
+
+New mouse actions
+await computer.interface.mouse_down(x, y, button="left") # Press and hold a mouse button
+await computer.interface.mouse_up(x, y, button="left") # Release a mouse button
+
+New keyboard actions
+await computer.interface.key_down("command") # Press and hold a key
+await computer.interface.key_up("command") # Release a key
+
+New scrolling actions
+await computer.interface.scroll(x, y) # Scroll the mouse wheel
+
+New file-system commands
+Fixed: await computer.interface.file_exists(path) # Check if file exists
+Fixed: await computer.interface.directory_exists(path) # Check if directory exists
+await computer.interface.read_text(path) # Read file content
+await computer.interface.write_text(path, content) # Write file content
+await computer.interface.read_bytes(path) # Read file content as bytes
+await computer.interface.write_bytes(path, content) # Write file content as bytes
+await computer.interface.delete_file(path) # Delete file
+await computer.interface.create_dir(path) # Create directory
+await computer.interface.delete_dir(path) # Delete directory
+await computer.interface.list_dir(path) # List directory contents
+```
+
+### v0.2.9 (2025-06-05)
+
+**Dependencies:** pylume: latest
+
+### v0.2.8 (2025-05-31)
+
+**Dependencies:** pylume: latest
+
+### v0.2.7 (2025-05-28)
+
+**Dependencies:** pylume: latest
+
+### v0.2.6 (2025-05-28)
+
+**Dependencies:** pylume: latest
+
+### v0.2.5 (2025-05-28)
+
+**Dependencies:** pylume: latest
+
+### v0.2.4 (2025-05-28)
+
+**Dependencies:** pylume: latest
+
+### v0.2.3 (2025-05-28)
+
+**Dependencies:** pylume: latest
+
+### v0.2.2 (2025-05-16)
+
+**Dependencies:** pylume: latest
+
+### v0.2.1 (2025-05-14)
+
+**Dependencies:** pylume: latest
+
+### v0.2.0 (2025-05-14)
+
+**Dependencies:** pylume: latest
+
+## 0.1.x
+
+### v0.1.29 (2025-05-12)
+
+**Dependencies:** pylume: latest
+
+### v0.1.28 (2025-05-10)
+
+**Dependencies:** pylume: latest
+
+### v0.1.27 (2025-05-10)
+
+**Dependencies:** pylume: latest
+
+### v0.1.26 (2025-05-10)
+
+**Dependencies:** pylume: latest
+
+### v0.1.25 (2025-05-07)
+
+**Dependencies:** pylume: latest
+
+### v0.1.24 (2025-04-29)
+
+**Dependencies:** pylume: latest
+
+### v0.1.23 (2025-04-22)
+
+**Dependencies:** pylume: latest
+
+### v0.1.22 (2025-04-15)
+
+**Dependencies:** pylume: latest
+
+### v0.1.21 (2025-03-30)
+
+**Dependencies:** pylume: latest
+
+### v0.1.20 (2025-03-30)
+
+**Dependencies:** pylume: latest
+
+### v0.1.19 (2025-03-30)
+
+**Dependencies:** pylume: latest
+
+### v0.1.18 (2025-03-24)
+
+**Dependencies:** pylume: latest
+
+### v0.1.7 (2025-03-19)
+
+**Dependencies:** pylume: latest
+
+### v0.1.6 (2025-03-17)
+
+**Dependencies:** pylume: latest
diff --git a/docs/content/docs/cua/reference/computer-sdk/index.mdx b/docs/content/docs/cua/reference/computer-sdk/index.mdx
index 36018199b5..cb1025a3c8 100644
--- a/docs/content/docs/cua/reference/computer-sdk/index.mdx
+++ b/docs/content/docs/cua/reference/computer-sdk/index.mdx
@@ -1,1208 +1,2037 @@
---
-title: Computer SDK
-description: Python API reference for the Computer SDK
+title: Computer SDK API Reference
+description: Python API reference for controlling virtual machines and computer interfaces
---
+{/*
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+ Generated by: npx tsx scripts/docs-generators/python-sdk.ts
+ Source: libs/python/computer/computer
+ Version: 0.5.12
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"0.5","href":"/cua/reference/computer-sdk","isCurrent":true},{"version":"0.4","href":"/cua/reference/computer-sdk/v0.4/api","isCurrent":false},{"version":"0.3","href":"/cua/reference/computer-sdk/v0.3/api","isCurrent":false}]}
+ currentVersion="0.5"
+ fullVersion="0.5.12"
+ packageName="cua-computer"
+/>
+
+Cua Computer Interface for cross-platform computer control.
+
+## Classes
+
+| Class | Description |
+|-------|-------------|
+| [`Computer`](#computer) | Computer is the main class for interacting with the computer. |
+| [`VMProviderType`](#vmprovidertype) | Enum of supported VM provider types. |
+
+---
-The **Computer SDK** (`cua-computer`) provides the Python interface for creating and controlling sandboxed desktop environments. This reference covers the core classes, methods, and types you'll use when working with computers programmatically.
+## Computer
+
+Computer is the main class for interacting with the computer.
+
+### Constructor
+
+```python
+Computer(self, display: Union[Display, Dict[str, int], str] = '1024x768', memory: str = '8GB', cpu: str = '4', os_type: OSType = 'macos', name: str = '', image: Optional[str] = None, shared_directories: Optional[List[str]] = None, use_host_computer_server: bool = False, verbosity: Union[int, LogLevel] = logging.INFO, telemetry_enabled: bool = True, provider_type: Union[str, VMProviderType] = VMProviderType.LUME, provider_port: Optional[int] = 7777, noVNC_port: Optional[int] = 8006, api_port: Optional[int] = None, host: str = 'localhost', api_host: Optional[str] = None, storage: Optional[str] = None, ephemeral: bool = False, api_key: Optional[str] = None, experiments: Optional[List[str]] = None, timeout: int = 100, run_opts: Optional[Dict[str, Any]] = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `logger` | `Any` | |
+| `image` | `Any` | |
+| `host` | `Any` | |
+| `provider_port` | `Any` | |
+| `noVNC_port` | `Any` | |
+| `api_port` | `Any` | |
+| `api_host` | `Any` | |
+| `os_type` | `Any` | |
+| `provider_type` | `Any` | |
+| `ephemeral` | `Any` | |
+| `api_key` | `Any` | |
+| `timeout` | `Any` | |
+| `experiments` | `Any` | |
+| `custom_run_opts` | `Any` | |
+| `storage` | `Any` | |
+| `shared_path` | `Any` | |
+| `verbosity` | `Any` | |
+| `vm_logger` | `Any` | |
+| `interface_logger` | `Any` | |
+| `config` | `Any` | |
+| `shared_directories` | `Any` | |
+| `use_host_computer_server` | `Any` | |
+| `interface` | `Any` | Get the computer interface for interacting with the VM. |
+| `tracing` | `ComputerTracing` | Get the computer tracing instance for recording sessions. |
+| `telemetry_enabled` | `bool` | Check if telemetry is enabled for this computer instance. |
-## Installation
+### Methods
+
+#### Computer.create_desktop_from_apps
-```bash
-pip install cua-computer
+```python
+def create_desktop_from_apps(self, apps)
```
-## Core Classes
+Create a virtual desktop from a list of app names, returning a DioramaComputer
+that proxies Diorama.Interface but uses diorama_cmds via the computer interface.
+
+**Parameters:**
-### Computer
+| Name | Type | Description |
+|------|------|-------------|
+| `apps` | `list[str]` | List of application names to include in the desktop. |
-The main class for creating and managing sandboxed desktop environments.
+**Returns:** DioramaComputer: A proxy object with the Diorama interface, but using diorama_cmds.
+
+#### Computer.run
```python
-from computer import Computer
+async def run(self) -> Optional[str]
+```
+
+Initialize the VM and computer interface.
-computer = Computer(
- os_type="linux",
- provider_type="docker",
- image="trycua/cua-xfce:latest"
-)
-await computer.run()
+#### Computer.disconnect
+
+```python
+async def disconnect(self) -> None
```
-#### Constructor Parameters
+Disconnect from the computer's WebSocket interface.
-| Parameter | Type | Default | Description |
-| -------------------- | ------------- | ------------- | ---------------------------------------------------------------------------------------------------- |
-| `os_type` | `str` | Required | Operating system type: `"linux"`, `"macos"`, or `"windows"` |
-| `provider_type` | `str` | Required | Provider type: `"docker"`, `"lume"`, `"cloud"`, `"qemu"`, `"windows-sandbox"`, or `"host"` |
-| `image` | `str` | `None` | Container/VM image to use (provider-specific) |
-| `name` | `str` | `""` | Optional name for the computer instance |
-| `display` | `str \| dict` | `"1024x768"` | Display resolution (can be string like `"1920x1080"` or dict like `{"width": 1920, "height": 1080}`) |
-| `memory` | `str` | `"8GB"` | Memory allocation |
-| `cpu` | `str` | `"4"` | Number of CPU cores |
-| `shared_directories` | `list[str]` | `None` | List of host directories to share with the computer |
-| `storage` | `str` | `None` | Path to persistent storage |
-| `ephemeral` | `bool` | `False` | Use ephemeral storage (data lost on stop) |
-| `api_key` | `str` | `None` | API key for cloud provider (defaults to `CUA_API_KEY` env var) |
-| `host` | `str` | `"localhost"` | Host address for provider connection |
-| `timeout` | `int` | `100` | Connection timeout in seconds |
-| `telemetry_enabled` | `bool` | `True` | Enable telemetry |
+#### Computer.stop
-#### Methods
+```python
+async def stop(self) -> None
+```
-##### `run()`
+Disconnect from the computer's WebSocket interface and stop the computer.
-Start the computer and establish connection.
+#### Computer.start
```python
-await computer.run()
+async def start(self) -> None
```
-Returns once the computer is ready to accept commands.
+Start the computer.
-##### `stop()`
+#### Computer.restart
-Stop the computer and release resources.
+```python
+async def restart(self) -> None
+```
+
+Restart the computer.
+
+If using a VM provider that supports restart, this will issue a restart
+without tearing down the provider context, then reconnect the interface.
+Falls back to stop()+run() when a provider restart is not available.
+
+#### Computer.get_ip
```python
-await computer.stop()
+async def get_ip(self, max_retries: int = 15, retry_delay: int = 3) -> str
```
-##### `restart()`
+Get the IP address of the VM or localhost if using host computer server.
-Restart the computer.
+This method delegates to the provider's get_ip method, which waits indefinitely
+until the VM has a valid IP address.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `max_retries` | `Any` | Unused parameter, kept for backward compatibility |
+| `retry_delay` | `Any` | Delay between retries in seconds (default: 2) |
+
+**Returns:** IP address of the VM or localhost if using host computer server
+
+#### Computer.wait_vm_ready
```python
-await computer.restart()
+async def wait_vm_ready(self) -> Optional[Dict[str, Any]]
```
-##### `disconnect()`
+Wait for VM to be ready with an IP address.
-Disconnect from the computer without stopping it.
+**Returns:** VM status information or None if using host computer server.
+
+#### Computer.update
```python
-await computer.disconnect()
+async def update(self, cpu: Optional[int] = None, memory: Optional[str] = None)
```
-##### `get_ip()`
+Update VM settings.
-Get the IP address of the computer.
+#### Computer.get_screenshot_size
```python
-ip = await computer.get_ip()
+def get_screenshot_size(self, screenshot: bytes) -> Dict[str, int]
```
-**Returns:** `str` - IP address
+Get the dimensions of a screenshot.
+
+**Parameters:**
-##### `update(cpu, memory)`
+| Name | Type | Description |
+|------|------|-------------|
+| `screenshot` | `Any` | The screenshot bytes |
-Update computer resources (cloud provider only).
+**Returns:** Dict[str, int]: Dictionary containing 'width' and 'height' of the image
+
+#### Computer.to_screen_coordinates
```python
-await computer.update(cpu="8", memory="16GB")
+async def to_screen_coordinates(self, x: float, y: float) -> tuple[float, float]
```
-##### Python Execution Methods
+Convert normalized coordinates to screen coordinates.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate between 0 and 1 |
+| `y` | `Any` | Y coordinate between 0 and 1 |
-##### `python_exec(func, *args, **kwargs)`
+**Returns:** tuple[float, float]: Screen coordinates (x, y)
-Execute a Python function in the computer's Python environment.
+#### Computer.to_screenshot_coordinates
```python
-def calculate(x, y):
- return x + y
+async def to_screenshot_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert screen coordinates to screenshot coordinates.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate in screen space |
+| `y` | `Any` | Y coordinate in screen space |
+
+**Returns:** tuple[float, float]: (x, y) coordinates in screenshot space
+
+#### Computer.playwright_exec
-result = await computer.python_exec(calculate, 5, 10)
-# result = 15
+```python
+async def playwright_exec(self, command: str, params: Optional[Dict] = None) -> Dict[str, Any]
```
-##### `python_exec_background(func, *args, requirements=None, **kwargs)`
+Execute a Playwright browser command.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `Any` | The browser command to execute (visit_url, click, type, scroll, web_search) |
+| `params` | `Any` | Command parameters |
+
+**Returns:** Dict containing the command result
-Execute a Python function in the background.
+**Example:**
```python
-def long_running_task():
- import time
- time.sleep(60)
- return "done"
+# Navigate to a URL
+await computer.playwright_exec("visit_url", {"url": "https://example.com"})
-task_id = await computer.python_exec_background(long_running_task)
-```
+# Click at coordinates
+await computer.playwright_exec("click", {"x": 100, "y": 200})
+
+# Type text
+await computer.playwright_exec("type", {"text": "Hello, world!"})
-**Returns:** `int` - Task ID for tracking
+# Scroll
+await computer.playwright_exec("scroll", {"delta_x": 0, "delta_y": -100})
-##### `pip_install(requirements)`
+# Web search
+await computer.playwright_exec("web_search", {"query": "computer use agent"})
+```
-Install Python packages in the computer.
+#### Computer.venv_install
```python
-await computer.pip_install(["requests", "pandas==2.0.0"])
+async def venv_install(self, venv_name: str, requirements: list[str])
```
-##### Virtual Environment Methods
+Install packages in a UV project.
-##### `venv_install(venv_name, requirements)`
+**Parameters:**
-Install packages in a virtual environment.
+| Name | Type | Description |
+|------|------|-------------|
+| `venv_name` | `Any` | Name of the UV project |
+| `requirements` | `Any` | List of package requirements to install |
+
+**Returns:** Tuple of (stdout, stderr) from the installation command
+
+#### Computer.pip_install
```python
-await computer.venv_install("my_env", ["requests", "pandas"])
+async def pip_install(self, requirements: list[str])
```
-##### `venv_cmd(venv_name, command)`
+Install packages using the system Python with UV (no venv).
+
+**Parameters:**
-Run a shell command in a virtual environment.
+| Name | Type | Description |
+|------|------|-------------|
+| `requirements` | `Any` | List of package requirements to install globally/user site. |
+
+**Returns:** Tuple of (stdout, stderr) from the installation command
+
+#### Computer.venv_cmd
```python
-result = await computer.venv_cmd("my_env", "pip list")
-print(result.stdout)
+async def venv_cmd(self, venv_name: str, command: str)
```
-**Returns:** `CommandResult` with `stdout`, `stderr`, `returncode`
+Execute a shell command in a UV project.
+
+**Parameters:**
-##### `venv_exec(venv_name, func, *args, **kwargs)`
+| Name | Type | Description |
+|------|------|-------------|
+| `venv_name` | `Any` | Name of the UV project |
+| `command` | `Any` | Shell command to execute in the UV project |
-Execute a Python function in a virtual environment.
+**Returns:** Tuple of (stdout, stderr) from the command execution
+
+#### Computer.venv_exec
```python
-def process_data(x):
- import pandas as pd
- return pd.DataFrame(x).to_dict()
+async def venv_exec(self, venv_name: str, python_func, args = (), kwargs = {})
+```
+
+Execute Python function in a virtual environment using source code extraction.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `venv_name` | `Any` | Name of the virtual environment |
+| `python_func` | `Any` | A callable function to execute *args: Positional arguments to pass to the function **kwargs: Keyword arguments to pass to the function |
+
+**Returns:** The result of the function execution, or raises any exception that occurred
+
+#### Computer.venv_exec_background
-result = await computer.venv_exec("my_env", process_data, [1, 2, 3])
+```python
+async def venv_exec_background(self, venv_name: str, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
```
-##### `venv_exec_background(venv_name, func, *args, requirements=None, **kwargs)`
+Run the Python function in the venv in the background and return the PID.
+
+Uses a short launcher Python that spawns a detached child and exits immediately.
-Execute a Python function in a virtual environment in the background.
+#### Computer.python_exec
```python
-task_id = await computer.venv_exec_background("my_env", long_task)
+async def python_exec(self, python_func, args = (), kwargs = {})
```
-**Returns:** `int` - Task ID
+Execute a Python function using the system Python (no venv).
+
+Uses source extraction and base64 transport, mirroring venv_exec but
+without virtual environment activation.
+
+Returns the function result or raises a reconstructed exception with
+remote traceback context appended.
-See [Sandboxed Python](/cua/guide/advanced/sandboxed-python) for detailed usage.
+#### Computer.python_exec_background
+
+```python
+async def python_exec_background(self, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
+```
-##### Browser Automation
+Run a Python function with the system interpreter in the background and return PID.
-##### `playwright_exec(command, params=None)`
+Uses a short launcher Python that spawns a detached child and exits immediately.
-Execute Playwright browser automation commands.
+#### Computer.python_command
```python
-result = await computer.playwright_exec("goto", {"url": "https://example.com"})
+def python_command(self, requirements: Optional[List[str]] = None, venv_name: str = 'default', use_system_python: bool = False, background: bool = False) -> Callable[[Callable[P, R]], Callable[P, Awaitable[R]]]
```
+Decorator to execute a Python function remotely in this Computer's venv.
+
+This mirrors `computer.helpers.sandboxed()` but binds to this instance and
+optionally ensures required packages are installed before execution.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `requirements` | `Any` | Packages to install in the virtual environment. |
+| `venv_name` | `Any` | Name of the virtual environment to use. |
+| `use_system_python` | `Any` | If True, use the system Python/pip instead of a venv. |
+| `background` | `Any` | If True, run the function detached and return the child PID immediately. |
+
+**Returns:** A decorator that turns a local function into an async callable which runs remotely and returns the function's result.
+
---
-### ComputerInterface
+## VMProviderType
+
+*Inherits from: StrEnum*
+
+Enum of supported VM provider types.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `LUME` | `Any` | |
+| `LUMIER` | `Any` | |
+| `CLOUD` | `Any` | |
+| `CLOUDV2` | `Any` | |
+| `WINSANDBOX` | `Any` | |
+| `DOCKER` | `Any` | |
+| `UNKNOWN` | `Any` | |
+
+---
+
+## tracing
+
+Computer tracing functionality for recording sessions.
-The interface for interacting with the computer's display, keyboard, and mouse. Accessed via `computer.interface`.
+This module provides a Computer.tracing API inspired by Playwright's tracing functionality,
+allowing users to record computer interactions for debugging, training, and analysis.
+
+---
+
+## ComputerTracing
+
+Computer tracing class that records computer interactions and saves them to disk.
+
+This class provides a flexible API for recording computer sessions with configurable
+options for what to record (screenshots, API calls, video, etc.).
+
+### Constructor
```python
-interface = computer.interface
+ComputerTracing(self, computer_instance)
```
-All interface methods accept an optional `delay` parameter to add a pause after the action:
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `is_tracing` | `bool` | Check if tracing is currently active. |
+
+### Methods
+
+#### ComputerTracing.start
```python
-await computer.interface.left_click(500, 300, delay=0.5)
+async def start(self, config: Optional[Dict[str, Any]] = None) -> None
```
-#### Mouse Actions
+Start tracing with the specified configuration.
-##### `left_click(x=None, y=None, delay=None)`
+**Parameters:**
-Perform a left mouse click. If coordinates are omitted, clicks at current cursor position.
+| Name | Type | Description |
+|------|------|-------------|
+| `config` | `Any` | Tracing configuration dict with options: - video: bool - Record video frames (default: False) - screenshots: bool - Record screenshots (default: True) - api_calls: bool - Record API calls and results (default: True) - accessibility_tree: bool - Record accessibility tree snapshots (default: False) - metadata: bool - Record custom metadata (default: True) - name: str - Custom trace name (default: auto-generated) - path: str - Custom trace directory path (default: auto-generated) |
+
+#### ComputerTracing.stop
```python
-await computer.interface.left_click(500, 300)
-await computer.interface.left_click() # Click at current position
+async def stop(self, options: Optional[Dict[str, Any]] = None) -> str
```
-| Parameter | Type | Description |
-| --------- | --------------- | ----------------------------- |
-| `x` | `int \| None` | X coordinate (optional) |
-| `y` | `int \| None` | Y coordinate (optional) |
-| `delay` | `float \| None` | Delay in seconds after action |
+Stop tracing and save the trace data.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `options` | `Any` | Stop options dict with: - path: str - Custom output path for the trace archive - format: str - Output format ('zip' or 'dir', default: 'zip') |
-##### `right_click(x=None, y=None, delay=None)`
+**Returns:** str: Path to the saved trace file or directory
-Perform a right mouse click.
+#### ComputerTracing.record_api_call
```python
-await computer.interface.right_click(500, 300)
+async def record_api_call(self, method: str, args: Dict[str, Any], result: Any = None, error: Optional[Exception] = None) -> None
```
-##### `double_click(x=None, y=None, delay=None)`
+Record an API call event.
-Perform a double-click.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `method` | `Any` | The method name that was called |
+| `args` | `Any` | Arguments passed to the method |
+| `result` | `Any` | Result returned by the method |
+| `error` | `Any` | Exception raised by the method, if any |
+
+#### ComputerTracing.record_accessibility_tree
```python
-await computer.interface.double_click(500, 300)
+async def record_accessibility_tree(self) -> None
```
-##### `mouse_down(x=None, y=None, button="left", delay=None)`
+Record the current accessibility tree if enabled.
-Press and hold a mouse button.
+#### ComputerTracing.add_metadata
```python
-await computer.interface.mouse_down(100, 100, button="left")
+async def add_metadata(self, key: str, value: Any) -> None
```
-| Parameter | Type | Description |
-| --------- | ----- | ------------------------------------------------ |
-| `button` | `str` | Mouse button: `"left"`, `"right"`, or `"middle"` |
+Add custom metadata to the trace.
-##### `mouse_up(x=None, y=None, button="left", delay=None)`
+**Parameters:**
-Release a mouse button.
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | Metadata key |
+| `value` | `Any` | Metadata value |
+
+---
+
+## models
+
+Models for computer configuration.
+
+---
+
+## BaseVMProvider
+
+*Inherits from: AsyncContextManager*
+
+Base interface for VM providers.
+
+All VM provider implementations must implement this interface.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider_type` | `VMProviderType` | Get the provider type. |
+
+### Methods
+
+#### BaseVMProvider.get_vm
```python
-await computer.interface.mouse_up(500, 500, button="left")
+async def get_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]
```
-##### `move_cursor(x, y, delay=None)`
+Get VM information by name.
-Move the mouse cursor to the specified coordinates.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Name of the VM to get information for |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
+
+**Returns:** Dictionary with VM information including status, IP address, etc.
+
+#### BaseVMProvider.list_vms
```python
-await computer.interface.move_cursor(500, 300)
+async def list_vms(self) -> ListVMsResponse
```
-##### `drag_to(x, y, button="left", duration=0.5, delay=None)`
+List all available VMs.
-Drag from the current cursor position to the specified coordinates.
+**Returns:** ListVMsResponse: A list of minimal VM objects as defined in `computer.providers.types.MinimalVM`.
+
+#### BaseVMProvider.run_vm
```python
-# Move cursor to start position first
-await computer.interface.move_cursor(100, 100)
-# Then drag to end position
-await computer.interface.drag_to(500, 500, duration=1.0)
+async def run_vm(self, image: str, name: str, run_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]
```
-| Parameter | Type | Description |
-| ---------- | ------- | ------------------------------------------------------- |
-| `x` | `int` | Ending X coordinate |
-| `y` | `int` | Ending Y coordinate |
-| `button` | `str` | Mouse button to use: `"left"`, `"right"`, or `"middle"` |
-| `duration` | `float` | Duration of drag in seconds |
+Run a VM by name with the given options.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `image` | `Any` | Name/tag of the image to use |
+| `name` | `Any` | Name of the VM to run |
+| `run_opts` | `Any` | Dictionary of run options (memory, cpu, etc.) |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
-##### `drag(path, button="left", duration=0.5, delay=None)`
+**Returns:** Dictionary with VM run status and information
-Drag along a path of coordinates.
+#### BaseVMProvider.stop_vm
```python
-path = [(100, 100), (200, 150), (300, 200), (400, 250)]
-await computer.interface.drag(path, duration=2.0)
+async def stop_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]
```
-| Parameter | Type | Description |
-| --------- | ----------------------- | -------------------------------- |
-| `path` | `list[tuple[int, int]]` | List of (x, y) coordinate tuples |
+Stop a VM by name.
-##### `scroll(x, y, delay=None)`
+**Parameters:**
-Scroll by the specified amounts. Positive y scrolls up, negative scrolls down.
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Name of the VM to stop |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
+
+**Returns:** Dictionary with VM stop status and information
+
+#### BaseVMProvider.restart_vm
```python
-# Scroll down (negative y)
-await computer.interface.scroll(0, -3)
+async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]
+```
+
+Restart a VM by name.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Name of the VM to restart |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
+
+**Returns:** Dictionary with VM restart status and information
-# Scroll up (positive y)
-await computer.interface.scroll(0, 3)
+#### BaseVMProvider.update_vm
-# Scroll right (positive x)
-await computer.interface.scroll(3, 0)
+```python
+async def update_vm(self, name: str, update_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]
```
-| Parameter | Type | Description |
-| --------- | ----- | ------------------------------------------------------------ |
-| `x` | `int` | Horizontal scroll amount (positive = right, negative = left) |
-| `y` | `int` | Vertical scroll amount (positive = up, negative = down) |
+Update VM configuration.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Name of the VM to update |
+| `update_opts` | `Any` | Dictionary of update options (memory, cpu, etc.) |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
-##### `scroll_down(clicks=1, delay=None)` / `scroll_up(clicks=1, delay=None)`
+**Returns:** Dictionary with VM update status and information
-Convenience methods for vertical scrolling.
+#### BaseVMProvider.get_ip
```python
-await computer.interface.scroll_down(3) # Scroll down 3 clicks
-await computer.interface.scroll_up(2) # Scroll up 2 clicks
+async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str
```
-#### Keyboard Actions
+Get the IP address of a VM, waiting indefinitely until it's available.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Name of the VM to get the IP for |
+| `storage` | `Any` | Optional storage path override. If provided, this will be used instead of the provider's default storage path. |
+| `retry_delay` | `Any` | Delay between retries in seconds (default: 2) |
+
+**Returns:** IP address of the VM when it becomes available
-##### `type_text(text, delay=None)`
+---
+
+## Display
-Type text using the keyboard.
+Display configuration.
+
+### Constructor
```python
-await computer.interface.type_text("Hello, World!")
+Display(self, width: int, height: int) -> None
```
-| Parameter | Type | Description |
-| --------- | ----- | ------------ |
-| `text` | `str` | Text to type |
+### Attributes
-##### `press(key, delay=None)`
+| Name | Type | Description |
+|------|------|-------------|
+| `width` | `int` | |
+| `height` | `int` | |
-Press a single key.
+---
+
+## Image
+
+VM image configuration.
+
+### Constructor
```python
-from computer.interface.models import Key
+Image(self, image: str, tag: str, name: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `image` | `str` | |
+| `tag` | `str` | |
+| `name` | `str` | |
+
+---
+
+## Computer
-# Using Key enum (recommended)
-await computer.interface.press(Key.ENTER)
-await computer.interface.press(Key.PAGE_DOWN)
+Computer configuration.
-# Using string (also supported)
-await computer.interface.press("enter")
+### Constructor
+
+```python
+Computer(self, image: str, tag: str, name: str, display: Display, memory: str, cpu: str, vm_provider: Optional[BaseVMProvider] = None) -> None
```
-| Parameter | Type | Description |
-| --------- | ------------ | --------------------------------------- |
-| `key` | `Key \| str` | Key to press (use `Key` enum or string) |
+### Attributes
-##### `hotkey(*keys, delay=None)`
+| Name | Type | Description |
+|------|------|-------------|
+| `image` | `str` | |
+| `tag` | `str` | |
+| `name` | `str` | |
+| `display` | `Display` | |
+| `memory` | `str` | |
+| `cpu` | `str` | |
+| `vm_provider` | `Optional[BaseVMProvider]` | |
+
+### Methods
-Press a key combination.
+#### Computer.get_ip
```python
-from computer.interface.models import Key
+async def get_ip(self) -> Optional[str]
+```
-# Copy (Ctrl+C)
-await computer.interface.hotkey(Key.CTRL, Key.C)
+Get the IP address of the VM.
-# Paste (Ctrl+V)
-await computer.interface.hotkey(Key.CTRL, Key.V)
+---
-# Save (Ctrl+S)
-await computer.interface.hotkey(Key.CTRL, Key.S)
+## diorama_computer
-# Quit (Cmd+Q on macOS)
-await computer.interface.hotkey(Key.COMMAND, Key.Q)
+---
+
+## Key
+
+*Inherits from: Enum*
+
+Keyboard keys that can be used with press_key.
+
+These key names follow a consistent cross-platform keyboard key naming convention.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `PAGE_DOWN` | `Any` | |
+| `PAGE_UP` | `Any` | |
+| `HOME` | `Any` | |
+| `END` | `Any` | |
+| `LEFT` | `Any` | |
+| `RIGHT` | `Any` | |
+| `UP` | `Any` | |
+| `DOWN` | `Any` | |
+| `RETURN` | `Any` | |
+| `ENTER` | `Any` | |
+| `ESCAPE` | `Any` | |
+| `ESC` | `Any` | |
+| `TAB` | `Any` | |
+| `SPACE` | `Any` | |
+| `BACKSPACE` | `Any` | |
+| `DELETE` | `Any` | |
+| `ALT` | `Any` | |
+| `CTRL` | `Any` | |
+| `SHIFT` | `Any` | |
+| `WIN` | `Any` | |
+| `COMMAND` | `Any` | |
+| `OPTION` | `Any` | |
+| `F1` | `Any` | |
+| `F2` | `Any` | |
+| `F3` | `Any` | |
+| `F4` | `Any` | |
+| `F5` | `Any` | |
+| `F6` | `Any` | |
+| `F7` | `Any` | |
+| `F8` | `Any` | |
+| `F9` | `Any` | |
+| `F10` | `Any` | |
+| `F11` | `Any` | |
+| `F12` | `Any` | |
+
+### Methods
+
+#### Key.from_string
+
+```python
+def from_string(cls, key: str) -> Key | str
```
-##### `key_down(key, delay=None)` / `key_up(key, delay=None)`
+Convert a string key name to a Key enum value.
-Press and hold or release a key.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | String key name to convert |
+
+**Returns:** Key enum value if the string matches a known key, otherwise returns the original string for single character keys
+
+---
+
+## DioramaComputer
+
+A Computer-compatible proxy for Diorama that sends commands over the ComputerInterface.
+
+### Constructor
```python
-# Hold shift while clicking
-await computer.interface.key_down(Key.SHIFT)
-await computer.interface.left_click(500, 300)
-await computer.interface.key_up(Key.SHIFT)
+DioramaComputer(self, computer, apps)
```
-**Supported Keys (Key enum):**
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `computer` | `Any` | |
+| `apps` | `Any` | |
+| `interface` | `Any` | |
+
+### Methods
+
+#### DioramaComputer.run
```python
-from computer.interface.models import Key
+async def run(self)
+```
+
+Initialize and run the DioramaComputer if not already initialized.
-# Navigation
-Key.PAGE_DOWN, Key.PAGE_UP, Key.HOME, Key.END
-Key.LEFT, Key.RIGHT, Key.UP, Key.DOWN
+**Returns:** self: The DioramaComputer instance
-# Special
-Key.RETURN, Key.ENTER # Same key
-Key.ESCAPE, Key.ESC # Same key
-Key.TAB, Key.SPACE, Key.BACKSPACE, Key.DELETE
+---
-# Modifiers
-Key.ALT, Key.CTRL, Key.SHIFT
-Key.WIN # Windows key
-Key.COMMAND # macOS Cmd key
-Key.OPTION # macOS Option key
+## DioramaComputerInterface
-# Function keys
-Key.F1, Key.F2, Key.F3, Key.F4, Key.F5, Key.F6
-Key.F7, Key.F8, Key.F9, Key.F10, Key.F11, Key.F12
+Diorama Interface proxy that sends diorama_cmds via the Computer's interface.
-# Letters and numbers can be strings or Key.A, Key.B, etc.
+### Constructor
+
+```python
+DioramaComputerInterface(self, computer, apps)
```
-#### Screen Methods
+### Attributes
-##### `screenshot(boxes=None, box_color="#FF0000", box_thickness=2, scale_factor=1.0)`
+| Name | Type | Description |
+|------|------|-------------|
+| `computer` | `Any` | |
+| `apps` | `Any` | |
+
+### Methods
-Capture the current screen with optional box overlays.
+#### DioramaComputerInterface.screenshot
```python
-# Basic screenshot
-screenshot_bytes = await computer.interface.screenshot()
+async def screenshot(self, as_bytes = True)
+```
+
+Take a screenshot of the diorama scene.
+
+**Parameters:**
-# Screenshot with bounding boxes
-boxes = [
- {"x": 100, "y": 100, "width": 200, "height": 150},
- {"x": 400, "y": 300, "width": 100, "height": 100}
-]
-screenshot_bytes = await computer.interface.screenshot(
- boxes=boxes,
- box_color="#00FF00",
- box_thickness=3
-)
+| Name | Type | Description |
+|------|------|-------------|
+| `as_bytes` | `bool` | If True, return image as bytes; if False, return PIL Image object |
-# Screenshot scaled down to 50%
-screenshot_bytes = await computer.interface.screenshot(scale_factor=0.5)
+**Returns:** bytes or PIL.Image: Screenshot data in the requested format
+
+#### DioramaComputerInterface.get_screen_size
+
+```python
+async def get_screen_size(self)
```
-**Returns:** `bytes` - Raw image data (PNG format)
+Get the dimensions of the diorama scene.
-##### `get_screen_size()`
+**Returns:** dict: Dictionary containing 'width' and 'height' keys with pixel dimensions
-Get the screen dimensions.
+#### DioramaComputerInterface.move_cursor
```python
-size = await computer.interface.get_screen_size()
-width = size["width"]
-height = size["height"]
+async def move_cursor(self, x, y)
```
-**Returns:** `dict[str, int]` - Dictionary with `"width"` and `"height"` keys
+Move the cursor to the specified coordinates.
-##### `get_cursor_position()`
+**Parameters:**
-Get the current cursor position.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | X coordinate to move cursor to |
+| `y` | `int` | Y coordinate to move cursor to |
+
+#### DioramaComputerInterface.left_click
```python
-pos = await computer.interface.get_cursor_position()
-x = pos["x"]
-y = pos["y"]
+async def left_click(self, x = None, y = None)
```
-**Returns:** `dict[str, int]` - Dictionary with `"x"` and `"y"` keys
+Perform a left mouse click at the specified coordinates or current cursor position.
-##### Coordinate Conversion
+**Parameters:**
-##### `to_screen_coordinates(x, y)`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int, optional` | X coordinate to click at. If None, clicks at current cursor position |
+| `y` | `int, optional` | Y coordinate to click at. If None, clicks at current cursor position |
-Convert screenshot coordinates to screen coordinates.
+#### DioramaComputerInterface.right_click
```python
-screen_x, screen_y = await computer.interface.to_screen_coordinates(100, 100)
+async def right_click(self, x = None, y = None)
```
-**Returns:** `tuple[float, float]` - Screen coordinates
+Perform a right mouse click at the specified coordinates or current cursor position.
-##### `to_screenshot_coordinates(x, y)`
+**Parameters:**
-Convert screen coordinates to screenshot coordinates.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int, optional` | X coordinate to click at. If None, clicks at current cursor position |
+| `y` | `int, optional` | Y coordinate to click at. If None, clicks at current cursor position |
+
+#### DioramaComputerInterface.double_click
```python
-ss_x, ss_y = await computer.interface.to_screenshot_coordinates(1920, 1080)
+async def double_click(self, x = None, y = None)
```
-**Returns:** `tuple[float, float]` - Screenshot coordinates
+Perform a double mouse click at the specified coordinates or current cursor position.
-#### Clipboard Methods
+**Parameters:**
-##### `copy_to_clipboard()`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int, optional` | X coordinate to double-click at. If None, clicks at current cursor position |
+| `y` | `int, optional` | Y coordinate to double-click at. If None, clicks at current cursor position |
-Get the current clipboard contents.
+#### DioramaComputerInterface.scroll_up
```python
-text = await computer.interface.copy_to_clipboard()
+async def scroll_up(self, clicks = 1)
```
-**Returns:** `str` - Clipboard text content
+Scroll up by the specified number of clicks.
+
+**Parameters:**
-##### `set_clipboard(text)`
+| Name | Type | Description |
+|------|------|-------------|
+| `clicks` | `int` | Number of scroll clicks to perform upward. Defaults to 1 |
-Set the clipboard contents.
+#### DioramaComputerInterface.scroll_down
```python
-await computer.interface.set_clipboard("Text to copy")
+async def scroll_down(self, clicks = 1)
```
-| Parameter | Type | Description |
-| --------- | ----- | ------------------------ |
-| `text` | `str` | Text to set in clipboard |
+Scroll down by the specified number of clicks.
-#### Shell Methods
+**Parameters:**
-##### `run_command(command)`
+| Name | Type | Description |
+|------|------|-------------|
+| `clicks` | `int` | Number of scroll clicks to perform downward. Defaults to 1 |
-Execute a shell command in the computer.
+#### DioramaComputerInterface.drag_to
```python
-result = await computer.interface.run_command("ls -la")
-print(result.stdout)
-print(result.stderr)
-print(result.returncode)
+async def drag_to(self, x, y, duration = 0.5)
```
-| Parameter | Type | Description |
-| --------- | ----- | ------------------------ |
-| `command` | `str` | Shell command to execute |
+Drag from the current cursor position to the specified coordinates.
-**Returns:** `CommandResult` with properties:
+**Parameters:**
-- `stdout: str` - Standard output
-- `stderr: str` - Standard error
-- `returncode: int` - Exit code (0 = success)
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | X coordinate to drag to |
+| `y` | `int` | Y coordinate to drag to |
+| `duration` | `float` | Duration of the drag operation in seconds. Defaults to 0.5 |
-#### File Methods
+#### DioramaComputerInterface.get_cursor_position
-##### `read_text(path, encoding="utf-8")`
+```python
+async def get_cursor_position(self)
+```
-Read a text file from the computer.
+Get the current cursor position.
+
+**Returns:** dict: Dictionary containing the current cursor coordinates
+
+#### DioramaComputerInterface.type_text
```python
-content = await computer.interface.read_text("/home/user/file.txt")
+async def type_text(self, text)
```
-**Returns:** `str` - File contents
+Type the specified text at the current cursor position.
-##### `write_text(path, content, encoding="utf-8")`
+**Parameters:**
-Write text content to a file.
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `str` | The text to type |
+
+#### DioramaComputerInterface.press_key
```python
-await computer.interface.write_text("/home/user/file.txt", "Hello!")
+async def press_key(self, key)
```
-##### `read_bytes(path, offset=0, length=None)`
+Press a single key.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to press |
-Read a file as bytes with optional seeking.
+#### DioramaComputerInterface.hotkey
```python
-# Read entire file
-data = await computer.interface.read_bytes("/home/user/image.png")
+async def hotkey(self, keys = ())
+```
+
+Press multiple keys simultaneously as a hotkey combination.
+
+**Raises:**
+
+- `ValueError` - If any key is not a Key enum or string type
+
+#### DioramaComputerInterface.to_screen_coordinates
-# Read 1024 bytes starting at offset 512
-data = await computer.interface.read_bytes("/home/user/file.bin", offset=512, length=1024)
+```python
+async def to_screen_coordinates(self, x, y)
```
-**Returns:** `bytes` - File contents
+Convert coordinates to screen coordinates.
-##### `write_bytes(path, content, append=False)`
+**Parameters:**
-Write binary content to a file.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | X coordinate to convert |
+| `y` | `int` | Y coordinate to convert |
+
+**Returns:** dict: Dictionary containing the converted screen coordinates
+
+---
+
+## helpers
+
+Helper functions and decorators for the Computer module.
+
+---
+
+## DependencyInfo
+
+*Inherits from: TypedDict*
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `import_statements` | `List[str]` | |
+| `definitions` | `List[tuple[str, Any]]` | |
+
+### set_default_computer
```python
-await computer.interface.write_bytes("/home/user/image.png", image_bytes)
+def set_default_computer(computer: Any) -> None
+```
+
+Set the default computer instance to be used by the remote decorator.
+
+**Parameters:**
-# Append to file
-await computer.interface.write_bytes("/home/user/log.bin", data, append=True)
+| Name | Type | Description |
+|------|------|-------------|
+| `computer` | `Any` | The computer instance to use as default |
+
+### sandboxed
+
+```python
+def sandboxed(venv_name: str = 'default', computer: str = 'default', max_retries: int = 3) -> Callable[[Callable[P, R]], Callable[P, Awaitable[R]]]
```
-##### `file_exists(path)` / `directory_exists(path)`
+Decorator that wraps a function to be executed remotely via computer.venv_exec
-Check if a file or directory exists.
+The function is automatically analyzed for dependencies (imports, helper functions,
+constants, etc.) and reconstructed with all necessary code in the remote sandbox.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `venv_name` | `Any` | Name of the virtual environment to execute in |
+| `computer` | `Any` | The computer instance to use, or "default" to use the globally set default |
+| `max_retries` | `Any` | Maximum number of retries for the remote execution |
+
+### generate_source_code
```python
-if await computer.interface.file_exists("/home/user/file.txt"):
- print("File exists")
+def generate_source_code(func: FunctionType) -> str
+```
+
+Generate complete source code for a function with all dependencies.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `func` | `Any` | The function to generate source code for |
+
+**Returns:** Complete Python source code as a string
+
+---
+
+## interface
+
+Interface package for Computer SDK.
+
+---
+
+## BaseComputerInterface
+
+*Inherits from: ABC*
+
+Base class for computer control interfaces.
-if await computer.interface.directory_exists("/home/user/documents"):
- print("Directory exists")
+### Constructor
+
+```python
+BaseComputerInterface(self, ip_address: str, username: str = 'lume', password: str = 'lume', api_key: Optional[str] = None, vm_name: Optional[str] = None)
```
-**Returns:** `bool` - True if exists
+### Attributes
-##### `get_file_size(path)`
+| Name | Type | Description |
+|------|------|-------------|
+| `ip_address` | `Any` | |
+| `username` | `Any` | |
+| `password` | `Any` | |
+| `api_key` | `Any` | |
+| `vm_name` | `Any` | |
+| `logger` | `Any` | |
+| `delay` | `float` | |
-Get the size of a file in bytes.
+### Methods
+
+#### BaseComputerInterface.wait_for_ready
```python
-size = await computer.interface.get_file_size("/home/user/file.txt")
+async def wait_for_ready(self, timeout: int = 60) -> None
```
-**Returns:** `int` - File size in bytes
+Wait for interface to be ready.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `timeout` | `Any` | Maximum time to wait in seconds |
-##### `list_dir(path)`
+**Raises:**
-List contents of a directory.
+- `TimeoutError` - If interface is not ready within timeout
+
+#### BaseComputerInterface.close
```python
-files = await computer.interface.list_dir("/home/user")
-for file in files:
- print(file)
+def close(self) -> None
```
-**Returns:** `list[str]` - List of file/directory names
+Close the interface connection.
-##### `create_dir(path)` / `delete_dir(path)` / `delete_file(path)`
+#### BaseComputerInterface.force_close
-Create or delete files and directories.
+```python
+def force_close(self) -> None
+```
+
+Force close the interface connection.
+
+By default, this just calls close(), but subclasses can override
+to provide more forceful cleanup.
+
+#### BaseComputerInterface.mouse_down
```python
-await computer.interface.create_dir("/home/user/new_folder")
-await computer.interface.delete_file("/home/user/old_file.txt")
-await computer.interface.delete_dir("/home/user/old_folder")
+async def mouse_down(self, x: Optional[int] = None, y: Optional[int] = None, button: MouseButton = 'left', delay: Optional[float] = None) -> None
```
-#### Window Management
+Press and hold a mouse button.
-##### `launch(application, args=None)`
+**Parameters:**
-Launch an application.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to press at. If None, uses current cursor position. |
+| `y` | `Any` | Y coordinate to press at. If None, uses current cursor position. |
+| `button` | `Any` | Mouse button to press ('left', 'middle', 'right'). |
+| `delay` | `Any` | Optional delay in seconds after the action |
+
+#### BaseComputerInterface.mouse_up
```python
-await computer.interface.launch("xfce4-terminal")
-await computer.interface.launch("firefox", ["--private-window"])
+async def mouse_up(self, x: Optional[int] = None, y: Optional[int] = None, button: MouseButton = 'left', delay: Optional[float] = None) -> None
```
-**Returns:** `int | None` - Window ID if available
+Release a mouse button.
+
+**Parameters:**
-##### `open(uri)`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to release at. If None, uses current cursor position. |
+| `y` | `Any` | Y coordinate to release at. If None, uses current cursor position. |
+| `button` | `Any` | Mouse button to release ('left', 'middle', 'right'). |
+| `delay` | `Any` | Optional delay in seconds after the action |
-Open a URL or file with the default application.
+#### BaseComputerInterface.left_click
```python
-await computer.interface.open("https://www.google.com")
-await computer.interface.open("/home/user/document.pdf")
+async def left_click(self, x: Optional[int] = None, y: Optional[int] = None, delay: Optional[float] = None) -> None
```
-##### `get_current_window_id()`
+Perform a left mouse button click.
-Get the active window ID.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to click at. If None, uses current cursor position. |
+| `y` | `Any` | Y coordinate to click at. If None, uses current cursor position. |
+| `delay` | `Any` | Optional delay in seconds after the action |
+
+#### BaseComputerInterface.right_click
```python
-window_id = await computer.interface.get_current_window_id()
+async def right_click(self, x: Optional[int] = None, y: Optional[int] = None, delay: Optional[float] = None) -> None
```
-**Returns:** `int | str` - Window ID
+Perform a right mouse button click.
+
+**Parameters:**
-##### `get_application_windows(app_name)`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to click at. If None, uses current cursor position. |
+| `y` | `Any` | Y coordinate to click at. If None, uses current cursor position. |
+| `delay` | `Any` | Optional delay in seconds after the action |
-Get window IDs for an application.
+#### BaseComputerInterface.double_click
```python
-windows = await computer.interface.get_application_windows("firefox")
-for window_id in windows:
- print(window_id)
+async def double_click(self, x: Optional[int] = None, y: Optional[int] = None, delay: Optional[float] = None) -> None
```
-**Returns:** `list[int | str]` - List of window IDs
+Perform a double left mouse button click.
-##### `get_window_name(window_id)` / `get_window_title(window_id)`
+**Parameters:**
-Get the title of a window.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to double-click at. If None, uses current cursor position. |
+| `y` | `Any` | Y coordinate to double-click at. If None, uses current cursor position. |
+| `delay` | `Any` | Optional delay in seconds after the action |
+
+#### BaseComputerInterface.move_cursor
```python
-title = await computer.interface.get_window_name(window_id)
+async def move_cursor(self, x: int, y: int, delay: Optional[float] = None) -> None
```
-**Returns:** `str` - Window title
+Move the cursor to the specified screen coordinates.
+
+**Parameters:**
-##### `get_window_size(window_id)` / `window_size(window_id)`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate to move cursor to. |
+| `y` | `Any` | Y coordinate to move cursor to. |
+| `delay` | `Any` | Optional delay in seconds after the action |
-Get window dimensions.
+#### BaseComputerInterface.drag_to
```python
-width, height = await computer.interface.get_window_size(window_id)
+async def drag_to(self, x: int, y: int, button: str = 'left', duration: float = 0.5, delay: Optional[float] = None) -> None
```
-**Returns:** `tuple[int, int]` - Width and height in pixels
+Drag from current position to specified coordinates.
+
+**Parameters:**
-##### `set_window_size(window_id, width, height)`
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | The x coordinate to drag to |
+| `y` | `Any` | The y coordinate to drag to |
+| `button` | `Any` | The mouse button to use ('left', 'middle', 'right') |
+| `duration` | `Any` | How long the drag should take in seconds |
+| `delay` | `Any` | Optional delay in seconds after the action |
-Set window dimensions.
+#### BaseComputerInterface.drag
```python
-await computer.interface.set_window_size(window_id, 1200, 800)
+async def drag(self, path: List[Tuple[int, int]], button: str = 'left', duration: float = 0.5, delay: Optional[float] = None) -> None
```
-##### `get_window_position(window_id)`
+Drag the cursor along a path of coordinates.
-Get window position on screen.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | List of (x, y) coordinate tuples defining the drag path |
+| `button` | `Any` | The mouse button to use ('left', 'middle', 'right') |
+| `duration` | `Any` | Total time in seconds that the drag operation should take |
+| `delay` | `Any` | Optional delay in seconds after the action |
+
+#### BaseComputerInterface.key_down
```python
-x, y = await computer.interface.get_window_position(window_id)
+async def key_down(self, key: str, delay: Optional[float] = None) -> None
```
-**Returns:** `tuple[int, int]` - X and Y coordinates
+Press and hold a key.
-##### `set_window_position(window_id, x, y)`
+**Parameters:**
-Set window position on screen.
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to press and hold (e.g., 'a', 'shift', 'ctrl'). |
+| `delay` | `Any` | Optional delay in seconds after the action. |
+
+#### BaseComputerInterface.key_up
```python
-await computer.interface.set_window_position(window_id, 100, 100)
+async def key_up(self, key: str, delay: Optional[float] = None) -> None
```
-##### `maximize_window(window_id)` / `minimize_window(window_id)`
+Release a previously pressed key.
+
+**Parameters:**
-Change window state.
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to release (e.g., 'a', 'shift', 'ctrl'). |
+| `delay` | `Any` | Optional delay in seconds after the action. |
+
+#### BaseComputerInterface.type_text
```python
-await computer.interface.maximize_window(window_id)
-await computer.interface.minimize_window(window_id)
+async def type_text(self, text: str, delay: Optional[float] = None) -> None
```
-##### `activate_window(window_id)`
+Type the specified text string.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `Any` | The text string to type. |
+| `delay` | `Any` | Optional delay in seconds after the action. |
-Bring a window to focus.
+#### BaseComputerInterface.press_key
```python
-await computer.interface.activate_window(window_id)
+async def press_key(self, key: str, delay: Optional[float] = None) -> None
```
-##### `close_window(window_id)`
+Press and release a single key.
-Close a window.
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `Any` | The key to press (e.g., 'a', 'enter', 'escape'). |
+| `delay` | `Any` | Optional delay in seconds after the action. |
+
+#### BaseComputerInterface.hotkey
```python
-await computer.interface.close_window(window_id)
+async def hotkey(self, keys: str = (), delay: Optional[float] = None) -> None
```
-#### Accessibility
+Press multiple keys simultaneously (keyboard shortcut).
+
+**Parameters:**
-##### `get_accessibility_tree()`
+| Name | Type | Description |
+|------|------|-------------|
+| `delay` | `Any` | Optional delay in seconds after the action. |
-Get the accessibility tree for the current screen.
+#### BaseComputerInterface.scroll
```python
-tree = await computer.interface.get_accessibility_tree()
+async def scroll(self, x: int, y: int, delay: Optional[float] = None) -> None
```
-**Returns:** `dict` - Accessibility tree structure with UI element information
+Scroll the mouse wheel by specified amounts.
-##### `get_active_window_bounds()`
+**Parameters:**
-Get the bounds of the active window.
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | Horizontal scroll amount (positive = right, negative = left). |
+| `y` | `Any` | Vertical scroll amount (positive = up, negative = down). |
+| `delay` | `Any` | Optional delay in seconds after the action. |
+
+#### BaseComputerInterface.scroll_down
```python
-bounds = await computer.interface.get_active_window_bounds()
-x = bounds["x"]
-y = bounds["y"]
-width = bounds["width"]
-height = bounds["height"]
+async def scroll_down(self, clicks: int = 1, delay: Optional[float] = None) -> None
```
-**Returns:** `dict[str, int]` - Dictionary with `"x"`, `"y"`, `"width"`, `"height"`
+Scroll down by the specified number of clicks.
-#### Advanced Methods
+**Parameters:**
-##### `get_desktop_environment()`
+| Name | Type | Description |
+|------|------|-------------|
+| `clicks` | `Any` | Number of scroll clicks to perform downward. |
+| `delay` | `Any` | Optional delay in seconds after the action. |
-Get the desktop environment name.
+#### BaseComputerInterface.scroll_up
```python
-de = await computer.interface.get_desktop_environment()
-# Returns "XFCE", "GNOME", "KDE", etc.
+async def scroll_up(self, clicks: int = 1, delay: Optional[float] = None) -> None
```
-**Returns:** `str` - Desktop environment name
+Scroll up by the specified number of clicks.
+
+**Parameters:**
-##### `set_wallpaper(path)`
+| Name | Type | Description |
+|------|------|-------------|
+| `clicks` | `Any` | Number of scroll clicks to perform upward. |
+| `delay` | `Any` | Optional delay in seconds after the action. |
-Set the desktop wallpaper.
+#### BaseComputerInterface.screenshot
```python
-await computer.interface.set_wallpaper("/home/user/wallpaper.jpg")
+async def screenshot(self) -> bytes
```
-##### `playwright_exec(command, params=None)`
+Take a screenshot.
+
+**Returns:** Raw bytes of the screenshot image
-Execute Playwright browser automation commands.
+#### BaseComputerInterface.get_screen_size
```python
-result = await computer.interface.playwright_exec("goto", {"url": "https://example.com"})
+async def get_screen_size(self) -> Dict[str, int]
```
-**Returns:** `dict` - Command result
+Get the screen dimensions.
----
+**Returns:** Dict with 'width' and 'height' keys
+
+#### BaseComputerInterface.get_cursor_position
+
+```python
+async def get_cursor_position(self) -> Dict[str, int]
+```
+
+Get the current cursor position on screen.
-### Tracing
+**Returns:** Dict with 'x' and 'y' keys containing cursor coordinates.
-The tracing subsystem records computer interactions. Accessed via `computer.tracing`.
+#### BaseComputerInterface.copy_to_clipboard
```python
-tracing = computer.tracing
+async def copy_to_clipboard(self) -> str
```
-#### Methods
+Get the current clipboard content.
-##### `start(options)`
+**Returns:** The text content currently stored in the clipboard.
-Start recording interactions.
+#### BaseComputerInterface.set_clipboard
```python
-await computer.tracing.start({
- "name": "my-workflow",
- "screenshots": True,
- "api_calls": True,
- "accessibility_tree": False,
- "metadata": True
-})
+async def set_clipboard(self, text: str) -> None
```
-| Option | Type | Default | Description |
-| -------------------- | ------ | -------------- | -------------------------- |
-| `name` | `str` | Auto-generated | Custom trace name |
-| `screenshots` | `bool` | `True` | Capture screenshots |
-| `api_calls` | `bool` | `True` | Log interface calls |
-| `accessibility_tree` | `bool` | `False` | Record accessibility trees |
-| `metadata` | `bool` | `True` | Enable custom metadata |
+Set the clipboard content to the specified text.
-##### `stop(options)`
+**Parameters:**
-Stop recording and save the trace.
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `Any` | The text to store in the clipboard. |
+
+#### BaseComputerInterface.file_exists
```python
-trace_path = await computer.tracing.stop({
- "format": "zip", # or "dir"
- "path": "/custom/path.zip" # optional
-})
+async def file_exists(self, path: str) -> bool
```
-**Returns:** `str` - Path to saved trace
+Check if a file exists at the specified path.
-##### `add_metadata(key, value)`
+**Parameters:**
-Add custom metadata to the trace.
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to check. |
+
+**Returns:** True if the file exists, False otherwise.
+
+#### BaseComputerInterface.directory_exists
```python
-await computer.tracing.add_metadata("workflow", "login-flow")
-await computer.tracing.add_metadata("step", "entering-credentials")
+async def directory_exists(self, path: str) -> bool
```
----
+Check if a directory exists at the specified path.
+
+**Parameters:**
-## Provider Types
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The directory path to check. |
-Different providers offer different capabilities and trade-offs.
+**Returns:** True if the directory exists, False otherwise.
-### Docker Provider
+#### BaseComputerInterface.list_dir
```python
-computer = Computer(
- os_type="linux",
- provider_type="docker",
- image="trycua/cua-xfce:latest"
-)
+async def list_dir(self, path: str) -> List[str]
```
-Best for Linux sandboxes with fast startup. Requires Docker to be installed.
+List the contents of a directory.
-### Lume Provider
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The directory path to list. |
+
+**Returns:** List of file and directory names in the specified directory.
+
+#### BaseComputerInterface.read_text
```python
-computer = Computer(
- os_type="macos",
- provider_type="lume",
- name="my-macos-vm"
-)
+async def read_text(self, path: str) -> str
```
-For macOS virtual machines on Apple Silicon. Requires [Lume](/lume) to be installed.
+Read the text contents of a file.
+
+**Parameters:**
-### Cloud Provider
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to read from. |
+
+**Returns:** The text content of the file.
+
+#### BaseComputerInterface.write_text
```python
-from computer import Computer
+async def write_text(self, path: str, content: str) -> None
+```
-computer = Computer(
- os_type="linux",
- provider_type="cloud",
- api_key="your-api-key" # or set CUA_API_KEY env var
-)
+Write text content to a file.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to write to. |
+| `content` | `Any` | The text content to write. |
+
+#### BaseComputerInterface.read_bytes
+
+```python
+async def read_bytes(self, path: str, offset: int = 0, length: Optional[int] = None) -> bytes
```
-For managed cloud sandboxes. See [CloudProvider](#cloudprovider) for management API.
+Read file binary contents with optional seeking support.
-### Windows Sandbox Provider
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | Path to the file |
+| `offset` | `Any` | Byte offset to start reading from (default: 0) |
+| `length` | `Any` | Number of bytes to read (default: None for entire file) |
+
+#### BaseComputerInterface.write_bytes
```python
-computer = Computer(
- os_type="windows",
- provider_type="windows-sandbox"
-)
+async def write_bytes(self, path: str, content: bytes) -> None
```
-For Windows sandboxes on Windows hosts. Requires Windows Sandbox feature enabled.
+Write binary content to a file.
+
+**Parameters:**
-### QEMU Provider
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to write to. |
+| `content` | `Any` | The binary content to write. |
+
+#### BaseComputerInterface.delete_file
```python
-computer = Computer(
- os_type="linux",
- provider_type="qemu",
- image="/path/to/disk.qcow2"
-)
+async def delete_file(self, path: str) -> None
```
-For full VM emulation with QEMU. Supports any guest OS.
+Delete a file at the specified path.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to delete. |
-### Host Provider
+#### BaseComputerInterface.create_dir
```python
-computer = Computer(
- os_type="macos", # or current host OS
- provider_type="host"
-)
+async def create_dir(self, path: str) -> None
```
-Directly controls the host machine. Use with caution.
+Create a directory at the specified path.
----
+**Parameters:**
-## CloudProvider
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The directory path to create. |
-The `CloudProvider` class enables programmatic management of cloud sandboxes.
+#### BaseComputerInterface.delete_dir
```python
-from computer.providers.cloud.provider import CloudProvider
+async def delete_dir(self, path: str) -> None
+```
+
+Delete a directory at the specified path.
-# Automatically reads CUA_API_KEY from environment
-provider = CloudProvider(verbose=False)
+**Parameters:**
-async with provider:
- vms = await provider.list_vms()
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The directory path to delete. |
+
+#### BaseComputerInterface.get_file_size
+
+```python
+async def get_file_size(self, path: str) -> int
```
-### Constructor Parameters
+Get the size of a file in bytes.
-| Parameter | Type | Default | Description |
-| --------- | ------ | --------------------- | -------------------------- |
-| `api_key` | `str` | `CUA_API_KEY` env var | API key for authentication |
-| `verbose` | `bool` | `False` | Enable verbose logging |
+**Parameters:**
-### Methods
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to get the size of. |
-##### `list_vms()`
+**Returns:** The size of the file in bytes.
-List all sandboxes.
+#### BaseComputerInterface.get_desktop_environment
```python
-async with provider:
- vms = await provider.list_vms()
- for vm in vms:
- print(f"{vm['name']}: {vm['status']}")
+async def get_desktop_environment(self) -> str
```
-##### `get_vm(name)`
+Get the current desktop environment.
-Get details for a specific sandbox.
+**Returns:** The name of the current desktop environment.
+
+#### BaseComputerInterface.set_wallpaper
```python
-info = await provider.get_vm("my-vm-name")
+async def set_wallpaper(self, path: str) -> None
```
-##### `run_vm(name)`
+Set the desktop wallpaper to the specified path.
+
+**Parameters:**
-Start a sandbox.
+| Name | Type | Description |
+|------|------|-------------|
+| `path` | `Any` | The file path to set as wallpaper |
+
+#### BaseComputerInterface.open
```python
-resp = await provider.run_vm("my-vm-name")
-# {"name": "my-vm-name", "status": "starting"}
+async def open(self, target: str) -> None
```
-##### `stop_vm(name)`
+Open a target using the system's default handler.
+
+Typically opens files, folders, or URLs with the associated application.
+
+**Parameters:**
-Stop a sandbox.
+| Name | Type | Description |
+|------|------|-------------|
+| `target` | `Any` | The file path, folder path, or URL to open. |
+
+#### BaseComputerInterface.launch
```python
-resp = await provider.stop_vm("my-vm-name")
-# {"name": "my-vm-name", "status": "stopping"}
+async def launch(self, app: str, args: List[str] | None = None) -> Optional[int]
```
-##### `restart_vm(name)`
+Launch an application with optional arguments.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `app` | `Any` | The application executable or bundle identifier. |
+| `args` | `Any` | Optional list of arguments to pass to the application. |
+
+**Returns:** Optional process ID (PID) of the launched application if available, otherwise None.
-Restart a sandbox.
+#### BaseComputerInterface.get_current_window_id
```python
-resp = await provider.restart_vm("my-vm-name")
-# {"name": "my-vm-name", "status": "restarting"}
+async def get_current_window_id(self) -> int | str
```
-### Sandbox Status Values
+Get the identifier of the currently active/focused window.
-| Status | Description |
-| ------------ | ------------------------------ |
-| `pending` | Deployment in progress |
-| `running` | Active and accessible |
-| `stopped` | Stopped but not terminated |
-| `terminated` | Permanently destroyed |
-| `failed` | Deployment or operation failed |
+**Returns:** A window identifier that can be used with other window management methods.
-### HTTP API
+#### BaseComputerInterface.get_application_windows
+
+```python
+async def get_application_windows(self, app: str) -> List[int | str]
+```
-You can also manage sandboxes via HTTP:
+Get all window identifiers for a specific application.
-```bash
-# List sandboxes
-curl -H "Authorization: Bearer $CUA_API_KEY" \
- "https://api.cua.ai/v1/vms"
+**Parameters:**
-# Start sandbox
-curl -X POST -H "Authorization: Bearer $CUA_API_KEY" \
- "https://api.cua.ai/v1/vms/my-vm-name/start"
+| Name | Type | Description |
+|------|------|-------------|
+| `app` | `Any` | The application name, executable, or identifier to query. |
-# Stop sandbox
-curl -X POST -H "Authorization: Bearer $CUA_API_KEY" \
- "https://api.cua.ai/v1/vms/my-vm-name/stop"
+**Returns:** A list of window identifiers belonging to the specified application.
-# Restart sandbox
-curl -X POST -H "Authorization: Bearer $CUA_API_KEY" \
- "https://api.cua.ai/v1/vms/my-vm-name/restart"
+#### BaseComputerInterface.get_window_name
+
+```python
+async def get_window_name(self, window_id: int | str) -> str
```
----
+Get the title/name of a window.
+
+**Parameters:**
-## Types
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
-### OSType
+**Returns:** The window's title or name string.
+
+#### BaseComputerInterface.get_window_size
```python
-from computer import OSType
+async def get_window_size(self, window_id: int | str) -> tuple[int, int]
+```
+
+Get the size of a window in pixels.
-OSType.LINUX # "linux"
-OSType.MACOS # "macos"
-OSType.WINDOWS # "windows"
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+
+**Returns:** A tuple of (width, height) representing the window size in pixels.
+
+#### BaseComputerInterface.get_window_position
+
+```python
+async def get_window_position(self, window_id: int | str) -> tuple[int, int]
```
-### ProviderType
+Get the screen position of a window.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+
+**Returns:** A tuple of (x, y) representing the window's top-left corner in screen coordinates.
+
+#### BaseComputerInterface.set_window_size
```python
-from computer import ProviderType
+async def set_window_size(self, window_id: int | str, width: int, height: int) -> None
+```
+
+Set the size of a window in pixels.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+| `width` | `Any` | Desired width in pixels. |
+| `height` | `Any` | Desired height in pixels. |
-ProviderType.DOCKER # "docker"
-ProviderType.LUME # "lume"
-ProviderType.CLOUD # "cloud"
-ProviderType.QEMU # "qemu"
-ProviderType.WINDOWS_SANDBOX # "windows-sandbox"
-ProviderType.HOST # "host"
+#### BaseComputerInterface.set_window_position
+
+```python
+async def set_window_position(self, window_id: int | str, x: int, y: int) -> None
```
-### Key
+Move a window to a specific position on the screen.
+
+**Parameters:**
-Enum for keyboard keys with cross-platform support.
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+| `x` | `Any` | X coordinate for the window's top-left corner. |
+| `y` | `Any` | Y coordinate for the window's top-left corner. |
+
+#### BaseComputerInterface.maximize_window
```python
-from computer.interface.models import Key
+async def maximize_window(self, window_id: int | str) -> None
+```
+
+Maximize a window.
-# Use in keyboard methods
-await computer.interface.press(Key.ENTER)
-await computer.interface.hotkey(Key.CTRL, Key.C)
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+
+#### BaseComputerInterface.minimize_window
+
+```python
+async def minimize_window(self, window_id: int | str) -> None
```
-**Available Keys:**
+Minimize a window.
-| Category | Keys |
-| ---------- | ----------------------------------------------------------------------- |
-| Navigation | `PAGE_DOWN`, `PAGE_UP`, `HOME`, `END`, `LEFT`, `RIGHT`, `UP`, `DOWN` |
-| Special | `RETURN`/`ENTER`, `ESCAPE`/`ESC`, `TAB`, `SPACE`, `BACKSPACE`, `DELETE` |
-| Modifiers | `ALT`, `CTRL`, `SHIFT`, `WIN`, `COMMAND`, `OPTION` |
-| Function | `F1` through `F12` |
-| Letters | `A` through `Z` |
-| Numbers | `N0` through `N9` |
+**Parameters:**
-### CommandResult
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
-Result from `run_command()` calls.
+#### BaseComputerInterface.activate_window
```python
-result = await computer.interface.run_command("echo hello")
-result.stdout # "hello\n"
-result.stderr # ""
-result.returncode # 0
+async def activate_window(self, window_id: int | str) -> None
```
-| Property | Type | Description |
-| ------------ | ----- | ----------------------- |
-| `stdout` | `str` | Standard output |
-| `stderr` | `str` | Standard error |
-| `returncode` | `int` | Exit code (0 = success) |
+Bring a window to the foreground and focus it.
----
+**Parameters:**
-## Environment Variables
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
-| Variable | Description |
-| ------------- | ------------------------------------------------ |
-| `CUA_API_KEY` | API key for cloud provider |
-| `CUA_REGION` | Default region for cloud provider |
-| `DOCKER_HOST` | Custom Docker host for Docker provider |
-| `LUME_HOST` | Custom Lume API host (default: `localhost:7777`) |
+#### BaseComputerInterface.close_window
----
+```python
+async def close_window(self, window_id: int | str) -> None
+```
+
+Close a window.
-## Context Manager Usage
+**Parameters:**
-The Computer class supports async context managers for automatic cleanup:
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+
+#### BaseComputerInterface.get_window_title
```python
-from computer import Computer
+async def get_window_title(self, window_id: int | str) -> str
+```
+
+Convenience alias for get_window_name().
-async with Computer(
- os_type="linux",
- provider_type="docker",
- image="trycua/cua-xfce:latest"
-) as computer:
- await computer.interface.type_text("Hello!")
- # Computer automatically stopped on exit
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
+
+**Returns:** The window's title or name string.
+
+#### BaseComputerInterface.window_size
+
+```python
+async def window_size(self, window_id: int | str) -> tuple[int, int]
```
----
+Convenience alias for get_window_size().
+
+**Parameters:**
-## Common Patterns
+| Name | Type | Description |
+|------|------|-------------|
+| `window_id` | `Any` | The window identifier. |
-### Click and Type
+**Returns:** A tuple of (width, height) representing the window size in pixels.
+
+#### BaseComputerInterface.run_command
```python
-# Click a text field and type
-await computer.interface.left_click(500, 300)
-await computer.interface.type_text("Hello, World!")
-await computer.interface.press(Key.ENTER)
+async def run_command(self, command: str) -> CommandResult
```
-### Drag and Drop
+Run shell command and return structured result.
+
+Executes a shell command using subprocess.run with shell=True and check=False.
+The command is run in the target environment and captures both stdout and stderr.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `str` | The shell command to execute |
+
+**Returns:** CommandResult: A structured result containing: - stdout (str): Standard output from the command - stderr (str): Standard error from the command - returncode (int): Exit code from the command (0 indicates success)
+
+**Raises:**
+
+- `RuntimeError` - If the command execution fails at the system level
+
+**Example:**
```python
-# Method 1: Using drag_to
-await computer.interface.move_cursor(100, 100)
-await computer.interface.drag_to(500, 500)
+result = await interface.run_command("ls -la")
+if result.returncode == 0:
+ print(f"Output: {result.stdout}")
+else:
+ print(f"Error: {result.stderr}, Exit code: {result.returncode}")
+```
-# Method 2: Using mouse_down/up
-await computer.interface.mouse_down(100, 100)
-await computer.interface.move_cursor(500, 500)
-await computer.interface.mouse_up()
+#### BaseComputerInterface.get_accessibility_tree
+
+```python
+async def get_accessibility_tree(self) -> Dict
```
-### Keyboard Shortcuts
+Get the accessibility tree of the current screen.
+
+**Returns:** Dict containing the hierarchical accessibility information of screen elements.
+
+#### BaseComputerInterface.to_screen_coordinates
```python
-from computer.interface.models import Key
+async def to_screen_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
-# Copy
-await computer.interface.hotkey(Key.CTRL, Key.C)
+Convert screenshot coordinates to screen coordinates.
+
+**Parameters:**
-# Paste
-await computer.interface.hotkey(Key.CTRL, Key.V)
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate in screenshot space |
+| `y` | `Any` | Y coordinate in screenshot space |
-# Select All
-await computer.interface.hotkey(Key.CTRL, Key.A)
+**Returns:** tuple[float, float]: (x, y) coordinates in screen space
-# Undo
-await computer.interface.hotkey(Key.CTRL, Key.Z)
+#### BaseComputerInterface.to_screenshot_coordinates
-# macOS uses Command key
-await computer.interface.hotkey(Key.COMMAND, Key.Q) # Quit
+```python
+async def to_screenshot_coordinates(self, x: float, y: float) -> tuple[float, float]
```
-### File Operations
+Convert screen coordinates to screenshot coordinates.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `Any` | X coordinate in screen space |
+| `y` | `Any` | Y coordinate in screen space |
+
+**Returns:** tuple[float, float]: (x, y) coordinates in screenshot space
+
+---
+
+## InterfaceFactory
+
+Factory for creating OS-specific computer interfaces.
+
+### Methods
+
+#### InterfaceFactory.create_interface_for_os
```python
-# Read a text file
-content = await computer.interface.read_text("/home/user/config.json")
-data = json.loads(content)
+def create_interface_for_os(os: OSType, ip_address: str, api_port: Optional[int] = None, api_key: Optional[str] = None, vm_name: Optional[str] = None) -> BaseComputerInterface
+```
+
+Create an interface for the specified OS.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os` | `Any` | Operating system type ('macos', 'linux', or 'windows') |
+| `ip_address` | `Any` | IP address of the computer to control |
+| `api_port` | `Any` | Optional API port of the computer to control |
+| `api_key` | `Any` | Optional API key for cloud authentication |
+| `vm_name` | `Any` | Optional VM name for cloud authentication |
+
+**Returns:** BaseComputerInterface: The appropriate interface for the OS
-# Write a text file
-await computer.interface.write_text("/home/user/output.txt", "Results")
+**Raises:**
-# Read binary file
-image_data = await computer.interface.read_bytes("/home/user/photo.jpg")
+- `ValueError` - If the OS type is not supported
-# Write binary file
-await computer.interface.write_bytes("/home/user/output.png", image_bytes)
+---
+
+## MacOSComputerInterface
+
+*Inherits from: GenericComputerInterface*
+
+Interface for macOS.
-# Check if file exists
-if await computer.interface.file_exists("/home/user/data.csv"):
- content = await computer.interface.read_text("/home/user/data.csv")
+### Constructor
+
+```python
+MacOSComputerInterface(self, ip_address: str, username: str = 'lume', password: str = 'lume', api_key: Optional[str] = None, vm_name: Optional[str] = None, api_port: Optional[int] = None)
```
+
+### Methods
+
+#### MacOSComputerInterface.diorama_cmd
+
+```python
+async def diorama_cmd(self, action: str, arguments: Optional[dict] = None) -> dict
+```
+
+Send a diorama command to the server (macOS only).
diff --git a/docs/content/docs/cua/reference/computer-sdk/meta.json b/docs/content/docs/cua/reference/computer-sdk/meta.json
index bf192152fe..5ae7deabe4 100644
--- a/docs/content/docs/cua/reference/computer-sdk/meta.json
+++ b/docs/content/docs/cua/reference/computer-sdk/meta.json
@@ -2,5 +2,5 @@
"title": "Computer SDK",
"description": "Python API for sandboxed desktop environments",
"icon": "Monitor",
- "pages": ["index"]
+ "pages": ["changelog"]
}
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.3/api.mdx b/docs/content/docs/cua/reference/computer-sdk/v0.3/api.mdx
new file mode 100644
index 0000000000..b4f1973cfe
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.3/api.mdx
@@ -0,0 +1,209 @@
+---
+title: Computer SDK v0.3 API Reference
+description: API reference for Computer SDK version 0.3
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: computer-v0.3.7
+Version: 0.3.7
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.3**. [View latest version](/cua/reference/computer-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.3.7
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-computer==0.3.7</span>
+</div>
+
+CUA Computer Interface for cross-platform computer control.
+
+## Classes
+
+| Class | Description |
+| ---------------- | ------------------------------------------------------------- |
+| `Computer` | Computer is the main class for interacting with the computer. |
+| `VMProviderType` | Enum of supported VM provider types. |
+
+## Computer
+
+Computer is the main class for interacting with the computer.
+
+### Methods
+
+#### Computer.create_desktop_from_apps
+
+```python
+def create_desktop_from_apps(self, apps)
+```
+
+Create a virtual desktop from a list of app names, returning a DioramaComputer
+that proxies Diorama.Interface but uses diorama_cmds via the computer interface.
+
+Args:
+apps (list[str]): List of application names to include in the desktop.
+Returns:
+DioramaComputer: A proxy object with the Diorama interface, but using diorama_cmds.
+
+#### Computer.run
+
+```python
+async def run(self) -> Optional[str]
+```
+
+Initialize the VM and computer interface.
+
+#### Computer.disconnect
+
+```python
+async def disconnect(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface.
+
+#### Computer.stop
+
+```python
+async def stop(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface and stop the computer.
+
+#### Computer.get_ip
+
+```python
+async def get_ip(self, max_retries: int = 15, retry_delay: int = 3) -> str
+```
+
+Get the IP address of the VM or localhost if using host computer server.
+
+This method delegates to the provider's get_ip method, which waits indefinitely
+until the VM has a valid IP address.
+
+Args:
+max_retries: Unused parameter, kept for backward compatibility
+retry_delay: Delay between retries in seconds (default: 2)
+
+Returns:
+IP address of the VM or localhost if using host computer server
+
+#### Computer.wait_vm_ready
+
+```python
+async def wait_vm_ready(self) -> Optional[Dict[str, Any]]
+```
+
+Wait for VM to be ready with an IP address.
+
+Returns:
+VM status information or None if using host computer server.
+
+#### Computer.update
+
+```python
+async def update(self, cpu: Optional[int] = None, memory: Optional[str] = None)
+```
+
+Update VM settings.
+
+#### Computer.get_screenshot_size
+
+```python
+def get_screenshot_size(self, screenshot: bytes) -> Dict[str, int]
+```
+
+Get the dimensions of a screenshot.
+
+Args:
+screenshot: The screenshot bytes
+
+Returns:
+Dict[str, int]: Dictionary containing 'width' and 'height' of the image
+
+#### Computer.to_screen_coordinates
+
+```python
+async def to_screen_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert normalized coordinates to screen coordinates.
+
+Args:
+x: X coordinate between 0 and 1
+y: Y coordinate between 0 and 1
+
+Returns:
+tuple[float, float]: Screen coordinates (x, y)
+
+#### Computer.to_screenshot_coordinates
+
+```python
+async def to_screenshot_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert screen coordinates to screenshot coordinates.
+
+Args:
+x: X coordinate in screen space
+y: Y coordinate in screen space
+
+Returns:
+tuple[float, float]: (x, y) coordinates in screenshot space
+
+#### Computer.venv_install
+
+```python
+async def venv_install(self, venv_name: str, requirements: list[str])
+```
+
+Install packages in a virtual environment.
+
+Args:
+venv_name: Name of the virtual environment
+requirements: List of package requirements to install
+
+Returns:
+Tuple of (stdout, stderr) from the installation command
+
+#### Computer.venv_cmd
+
+```python
+async def venv_cmd(self, venv_name: str, command: str)
+```
+
+Execute a shell command in a virtual environment.
+
+Args:
+venv_name: Name of the virtual environment
+command: Shell command to execute in the virtual environment
+
+Returns:
+Tuple of (stdout, stderr) from the command execution
+
+#### Computer.venv_exec
+
+```python
+async def venv_exec(self, venv_name: str, python_func, args = (), kwargs = {})
+```
+
+Execute Python function in a virtual environment using source code extraction.
+
+Args:
+venv_name: Name of the virtual environment
+python_func: A callable function to execute
+\*args: Positional arguments to pass to the function
+\*\*kwargs: Keyword arguments to pass to the function
+
+Returns:
+The result of the function execution, or raises any exception that occurred
+
+## VMProviderType
+
+Enum of supported VM provider types.
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.3/meta.json b/docs/content/docs/cua/reference/computer-sdk/v0.3/meta.json
new file mode 100644
index 0000000000..1d882707c5
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.3/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.3",
+ "description": "Computer SDK v0.3 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.4/api.mdx b/docs/content/docs/cua/reference/computer-sdk/v0.4/api.mdx
new file mode 100644
index 0000000000..9a865a16d4
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.4/api.mdx
@@ -0,0 +1,328 @@
+---
+title: Computer SDK v0.4 API Reference
+description: API reference for Computer SDK version 0.4
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: computer-v0.4.19
+Version: 0.4.19
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.4**. [View latest version](/cua/reference/computer-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.4.19
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-computer==0.4.19</span>
+</div>
+
+CUA Computer Interface for cross-platform computer control.
+
+## Classes
+
+| Class | Description |
+| ---------------- | ------------------------------------------------------------- |
+| `Computer` | Computer is the main class for interacting with the computer. |
+| `VMProviderType` | Enum of supported VM provider types. |
+
+## Computer
+
+Computer is the main class for interacting with the computer.
+
+### Methods
+
+#### Computer.create_desktop_from_apps
+
+```python
+def create_desktop_from_apps(self, apps)
+```
+
+Create a virtual desktop from a list of app names, returning a DioramaComputer
+that proxies Diorama.Interface but uses diorama_cmds via the computer interface.
+
+Args:
+apps (list[str]): List of application names to include in the desktop.
+Returns:
+DioramaComputer: A proxy object with the Diorama interface, but using diorama_cmds.
+
+#### Computer.run
+
+```python
+async def run(self) -> Optional[str]
+```
+
+Initialize the VM and computer interface.
+
+#### Computer.disconnect
+
+```python
+async def disconnect(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface.
+
+#### Computer.stop
+
+```python
+async def stop(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface and stop the computer.
+
+#### Computer.start
+
+```python
+async def start(self) -> None
+```
+
+Start the computer.
+
+#### Computer.restart
+
+```python
+async def restart(self) -> None
+```
+
+Restart the computer.
+
+If using a VM provider that supports restart, this will issue a restart
+without tearing down the provider context, then reconnect the interface.
+Falls back to stop()+run() when a provider restart is not available.
+
+#### Computer.get_ip
+
+```python
+async def get_ip(self, max_retries: int = 15, retry_delay: int = 3) -> str
+```
+
+Get the IP address of the VM or localhost if using host computer server.
+
+This method delegates to the provider's get_ip method, which waits indefinitely
+until the VM has a valid IP address.
+
+Args:
+max_retries: Unused parameter, kept for backward compatibility
+retry_delay: Delay between retries in seconds (default: 2)
+
+Returns:
+IP address of the VM or localhost if using host computer server
+
+#### Computer.wait_vm_ready
+
+```python
+async def wait_vm_ready(self) -> Optional[Dict[str, Any]]
+```
+
+Wait for VM to be ready with an IP address.
+
+Returns:
+VM status information or None if using host computer server.
+
+#### Computer.update
+
+```python
+async def update(self, cpu: Optional[int] = None, memory: Optional[str] = None)
+```
+
+Update VM settings.
+
+#### Computer.get_screenshot_size
+
+```python
+def get_screenshot_size(self, screenshot: bytes) -> Dict[str, int]
+```
+
+Get the dimensions of a screenshot.
+
+Args:
+screenshot: The screenshot bytes
+
+Returns:
+Dict[str, int]: Dictionary containing 'width' and 'height' of the image
+
+#### Computer.to_screen_coordinates
+
+```python
+async def to_screen_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert normalized coordinates to screen coordinates.
+
+Args:
+x: X coordinate between 0 and 1
+y: Y coordinate between 0 and 1
+
+Returns:
+tuple[float, float]: Screen coordinates (x, y)
+
+#### Computer.to_screenshot_coordinates
+
+```python
+async def to_screenshot_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert screen coordinates to screenshot coordinates.
+
+Args:
+x: X coordinate in screen space
+y: Y coordinate in screen space
+
+Returns:
+tuple[float, float]: (x, y) coordinates in screenshot space
+
+#### Computer.playwright_exec
+
+```python
+async def playwright_exec(self, command: str, params: Optional[Dict] = None) -> Dict[str, Any]
+```
+
+Execute a Playwright browser command.
+
+Args:
+command: The browser command to execute (visit_url, click, type, scroll, web_search)
+params: Command parameters
+
+Returns:
+Dict containing the command result
+
+Examples: # Navigate to a URL
+await computer.playwright_exec("visit_url", \{"url": "https://example.com"\})
+
+ # Click at coordinates
+ await computer.playwright_exec("click", \{"x": 100, "y": 200\})
+
+ # Type text
+ await computer.playwright_exec("type", \{"text": "Hello, world!"\})
+
+ # Scroll
+ await computer.playwright_exec("scroll", \{"delta_x": 0, "delta_y": -100\})
+
+ # Web search
+ await computer.playwright_exec("web_search", \{"query": "computer use agent"\})
+
+#### Computer.venv_install
+
+```python
+async def venv_install(self, venv_name: str, requirements: list[str])
+```
+
+Install packages in a virtual environment.
+
+Args:
+venv_name: Name of the virtual environment
+requirements: List of package requirements to install
+
+Returns:
+Tuple of (stdout, stderr) from the installation command
+
+#### Computer.pip_install
+
+```python
+async def pip_install(self, requirements: list[str])
+```
+
+Install packages using the system Python/pip (no venv).
+
+Args:
+requirements: List of package requirements to install globally/user site.
+
+Returns:
+Tuple of (stdout, stderr) from the installation command
+
+#### Computer.venv_cmd
+
+```python
+async def venv_cmd(self, venv_name: str, command: str)
+```
+
+Execute a shell command in a virtual environment.
+
+Args:
+venv_name: Name of the virtual environment
+command: Shell command to execute in the virtual environment
+
+Returns:
+Tuple of (stdout, stderr) from the command execution
+
+#### Computer.venv_exec
+
+```python
+async def venv_exec(self, venv_name: str, python_func, args = (), kwargs = {})
+```
+
+Execute Python function in a virtual environment using source code extraction.
+
+Args:
+venv_name: Name of the virtual environment
+python_func: A callable function to execute
+\*args: Positional arguments to pass to the function
+\*\*kwargs: Keyword arguments to pass to the function
+
+Returns:
+The result of the function execution, or raises any exception that occurred
+
+#### Computer.venv_exec_background
+
+```python
+async def venv_exec_background(self, venv_name: str, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
+```
+
+Run the Python function in the venv in the background and return the PID.
+
+Uses a short launcher Python that spawns a detached child and exits immediately.
+
+#### Computer.python_exec
+
+```python
+async def python_exec(self, python_func, args = (), kwargs = {})
+```
+
+Execute a Python function using the system Python (no venv).
+
+Uses source extraction and base64 transport, mirroring venv_exec but
+without virtual environment activation.
+
+Returns the function result or raises a reconstructed exception with
+remote traceback context appended.
+
+#### Computer.python_exec_background
+
+```python
+async def python_exec_background(self, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
+```
+
+Run a Python function with the system interpreter in the background and return PID.
+
+Uses a short launcher Python that spawns a detached child and exits immediately.
+
+#### Computer.python_command
+
+```python
+def python_command(self, requirements: Optional[List[str]] = None, venv_name: str = 'default', use_system_python: bool = False, background: bool = False) -> Callable[[Callable[P, R]], Callable[P, Awaitable[R]]]
+```
+
+Decorator to execute a Python function remotely in this Computer's venv.
+
+This mirrors `computer.helpers.sandboxed()` but binds to this instance and
+optionally ensures required packages are installed before execution.
+
+Args:
+requirements: Packages to install in the virtual environment.
+venv_name: Name of the virtual environment to use.
+use_system_python: If True, use the system Python/pip instead of a venv.
+background: If True, run the function detached and return the child PID immediately.
+
+Returns:
+A decorator that turns a local function into an async callable which
+runs remotely and returns the function's result.
+
+## VMProviderType
+
+Enum of supported VM provider types.
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.4/meta.json b/docs/content/docs/cua/reference/computer-sdk/v0.4/meta.json
new file mode 100644
index 0000000000..c526fd3ce1
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.4/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.4",
+ "description": "Computer SDK v0.4 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.5/api.mdx b/docs/content/docs/cua/reference/computer-sdk/v0.5/api.mdx
new file mode 100644
index 0000000000..8bb1dc3488
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.5/api.mdx
@@ -0,0 +1,328 @@
+---
+title: Computer SDK v0.5 API Reference
+description: API reference for Computer SDK version 0.5
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts
+Source tag: computer-v0.5.12
+Version: 0.5.12
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+
+<Callout type="warn">
+ This is documentation for **v0.5**. [View latest version](/cua/reference/computer-sdk).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.5.12
+ </span>
+ <span className="text-sm text-fd-muted-foreground">pip install cua-computer==0.5.12</span>
+</div>
+
+Cua Computer Interface for cross-platform computer control.
+
+## Classes
+
+| Class | Description |
+| ---------------- | ------------------------------------------------------------- |
+| `Computer` | Computer is the main class for interacting with the computer. |
+| `VMProviderType` | Enum of supported VM provider types. |
+
+## Computer
+
+Computer is the main class for interacting with the computer.
+
+### Methods
+
+#### Computer.create_desktop_from_apps
+
+```python
+def create_desktop_from_apps(self, apps)
+```
+
+Create a virtual desktop from a list of app names, returning a DioramaComputer
+that proxies Diorama.Interface but uses diorama_cmds via the computer interface.
+
+Args:
+apps (list[str]): List of application names to include in the desktop.
+Returns:
+DioramaComputer: A proxy object with the Diorama interface, but using diorama_cmds.
+
+#### Computer.run
+
+```python
+async def run(self) -> Optional[str]
+```
+
+Initialize the VM and computer interface.
+
+#### Computer.disconnect
+
+```python
+async def disconnect(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface.
+
+#### Computer.stop
+
+```python
+async def stop(self) -> None
+```
+
+Disconnect from the computer's WebSocket interface and stop the computer.
+
+#### Computer.start
+
+```python
+async def start(self) -> None
+```
+
+Start the computer.
+
+#### Computer.restart
+
+```python
+async def restart(self) -> None
+```
+
+Restart the computer.
+
+If using a VM provider that supports restart, this will issue a restart
+without tearing down the provider context, then reconnect the interface.
+Falls back to stop()+run() when a provider restart is not available.
+
+#### Computer.get_ip
+
+```python
+async def get_ip(self, max_retries: int = 15, retry_delay: int = 3) -> str
+```
+
+Get the IP address of the VM or localhost if using host computer server.
+
+This method delegates to the provider's get_ip method, which waits indefinitely
+until the VM has a valid IP address.
+
+Args:
+max_retries: Unused parameter, kept for backward compatibility
+retry_delay: Delay between retries in seconds (default: 2)
+
+Returns:
+IP address of the VM or localhost if using host computer server
+
+#### Computer.wait_vm_ready
+
+```python
+async def wait_vm_ready(self) -> Optional[Dict[str, Any]]
+```
+
+Wait for VM to be ready with an IP address.
+
+Returns:
+VM status information or None if using host computer server.
+
+#### Computer.update
+
+```python
+async def update(self, cpu: Optional[int] = None, memory: Optional[str] = None)
+```
+
+Update VM settings.
+
+#### Computer.get_screenshot_size
+
+```python
+def get_screenshot_size(self, screenshot: bytes) -> Dict[str, int]
+```
+
+Get the dimensions of a screenshot.
+
+Args:
+screenshot: The screenshot bytes
+
+Returns:
+Dict[str, int]: Dictionary containing 'width' and 'height' of the image
+
+#### Computer.to_screen_coordinates
+
+```python
+async def to_screen_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert normalized coordinates to screen coordinates.
+
+Args:
+x: X coordinate between 0 and 1
+y: Y coordinate between 0 and 1
+
+Returns:
+tuple[float, float]: Screen coordinates (x, y)
+
+#### Computer.to_screenshot_coordinates
+
+```python
+async def to_screenshot_coordinates(self, x: float, y: float) -> tuple[float, float]
+```
+
+Convert screen coordinates to screenshot coordinates.
+
+Args:
+x: X coordinate in screen space
+y: Y coordinate in screen space
+
+Returns:
+tuple[float, float]: (x, y) coordinates in screenshot space
+
+#### Computer.playwright_exec
+
+```python
+async def playwright_exec(self, command: str, params: Optional[Dict] = None) -> Dict[str, Any]
+```
+
+Execute a Playwright browser command.
+
+Args:
+command: The browser command to execute (visit_url, click, type, scroll, web_search)
+params: Command parameters
+
+Returns:
+Dict containing the command result
+
+Examples: # Navigate to a URL
+await computer.playwright_exec("visit_url", \{"url": "https://example.com"\})
+
+ # Click at coordinates
+ await computer.playwright_exec("click", \{"x": 100, "y": 200\})
+
+ # Type text
+ await computer.playwright_exec("type", \{"text": "Hello, world!"\})
+
+ # Scroll
+ await computer.playwright_exec("scroll", \{"delta_x": 0, "delta_y": -100\})
+
+ # Web search
+ await computer.playwright_exec("web_search", \{"query": "computer use agent"\})
+
+#### Computer.venv_install
+
+```python
+async def venv_install(self, venv_name: str, requirements: list[str])
+```
+
+Install packages in a UV project.
+
+Args:
+venv_name: Name of the UV project
+requirements: List of package requirements to install
+
+Returns:
+Tuple of (stdout, stderr) from the installation command
+
+#### Computer.pip_install
+
+```python
+async def pip_install(self, requirements: list[str])
+```
+
+Install packages using the system Python with UV (no venv).
+
+Args:
+requirements: List of package requirements to install globally/user site.
+
+Returns:
+Tuple of (stdout, stderr) from the installation command
+
+#### Computer.venv_cmd
+
+```python
+async def venv_cmd(self, venv_name: str, command: str)
+```
+
+Execute a shell command in a UV project.
+
+Args:
+venv_name: Name of the UV project
+command: Shell command to execute in the UV project
+
+Returns:
+Tuple of (stdout, stderr) from the command execution
+
+#### Computer.venv_exec
+
+```python
+async def venv_exec(self, venv_name: str, python_func, args = (), kwargs = {})
+```
+
+Execute Python function in a virtual environment using source code extraction.
+
+Args:
+venv_name: Name of the virtual environment
+python_func: A callable function to execute
+\*args: Positional arguments to pass to the function
+\*\*kwargs: Keyword arguments to pass to the function
+
+Returns:
+The result of the function execution, or raises any exception that occurred
+
+#### Computer.venv_exec_background
+
+```python
+async def venv_exec_background(self, venv_name: str, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
+```
+
+Run the Python function in the venv in the background and return the PID.
+
+Uses a short launcher Python that spawns a detached child and exits immediately.
+
+#### Computer.python_exec
+
+```python
+async def python_exec(self, python_func, args = (), kwargs = {})
+```
+
+Execute a Python function using the system Python (no venv).
+
+Uses source extraction and base64 transport, mirroring venv_exec but
+without virtual environment activation.
+
+Returns the function result or raises a reconstructed exception with
+remote traceback context appended.
+
+#### Computer.python_exec_background
+
+```python
+async def python_exec_background(self, python_func, args = (), requirements: Optional[List[str]] = None, kwargs = {}) -> int
+```
+
+Run a Python function with the system interpreter in the background and return PID.
+
+Uses a short launcher Python that spawns a detached child and exits immediately.
+
+#### Computer.python_command
+
+```python
+def python_command(self, requirements: Optional[List[str]] = None, venv_name: str = 'default', use_system_python: bool = False, background: bool = False) -> Callable[[Callable[P, R]], Callable[P, Awaitable[R]]]
+```
+
+Decorator to execute a Python function remotely in this Computer's venv.
+
+This mirrors `computer.helpers.sandboxed()` but binds to this instance and
+optionally ensures required packages are installed before execution.
+
+Args:
+requirements: Packages to install in the virtual environment.
+venv_name: Name of the virtual environment to use.
+use_system_python: If True, use the system Python/pip instead of a venv.
+background: If True, run the function detached and return the child PID immediately.
+
+Returns:
+A decorator that turns a local function into an async callable which
+runs remotely and returns the function's result.
+
+## VMProviderType
+
+Enum of supported VM provider types.
diff --git a/docs/content/docs/cua/reference/computer-sdk/v0.5/meta.json b/docs/content/docs/cua/reference/computer-sdk/v0.5/meta.json
new file mode 100644
index 0000000000..3dedd0e8d4
--- /dev/null
+++ b/docs/content/docs/cua/reference/computer-sdk/v0.5/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.5",
+ "description": "Computer SDK v0.5 API Reference",
+ "pages": ["api"]
+}
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/changelog.mdx b/docs/content/docs/cua/reference/desktop-sandbox/changelog.mdx
new file mode 100644
index 0000000000..f0defa0579
--- /dev/null
+++ b/docs/content/docs/cua/reference/desktop-sandbox/changelog.mdx
@@ -0,0 +1,341 @@
+---
+title: Changelog
+description: Release history for Desktop Sandbox
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-changelog.ts
+Last updated: 2026-02-04
+*/}
+
+# Desktop Sandbox Changelog
+
+All notable changes to the Desktop Sandbox are documented here.
+
+## 0.3.x
+
+### v0.3.16 (2026-01-30)
+
+- Initial release or no path-specific changes found
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.3.15 (2026-01-29)
+
+* Bump cua-computer-server to v0.3.15 by @github-actions[bot]
+* fix(computer-server): initialize coordinate scaling after auto-resize in ([#936](https://github.com/trycua/cua/pull/936)) by @synacktraa
+* fix(mcp-server): disable redirect for /mcp endpoint ([#935](https://github.com/trycua/cua/pull/935)) by @Fizza-Mukhtar
+* feat(agent): Centralized tool resolution in ComputerAgent ([#920](https://github.com/trycua/cua/pull/920)) by @sarinali
+
+Run the server
+cua-computer-server
+```
+
+### v0.3.14 (2026-01-24)
+
+Maintenance release.
+
+### v0.3.13 (2026-01-23)
+
+- Bump cua-computer-server to v0.3.13 by @github-actions[bot]
+- fix(computer-server): standardize Android handler response format ([#893](https://github.com/trycua/cua/pull/893)) by @synacktraa
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.3.12 (2026-01-21)
+
+Maintenance release.
+
+### v0.3.11 (2026-01-21)
+
+* Initial release or no path-specific changes found
+
+Run the server
+cua-computer-server
+```
+
+### v0.3.9 (2026-01-21)
+
+- Bump cua-computer-server to v0.3.9 by @github-actions[bot]
+- fix(computer-server): make fastmcp a required dependency ([#875](https://github.com/trycua/cua/pull/875)) by @Francesco Bonacci
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.3.8 (2026-01-20)
+
+* Bump cua-computer-server to v0.3.8 by @github-actions[bot]
+* fix(computer-server): correct MCP endpoint path and lifespan ([#869](https://github.com/trycua/cua/pull/869)) by @Francesco Bonacci
+
+Run the server
+cua-computer-server
+```
+
+### v0.3.7 (2026-01-20)
+
+- Bump cua-computer-server to v0.3.7 by @github-actions[bot]
+- feat(computer-server): expose HTTP and MCP interfaces simultaneously ([#861](https://github.com/trycua/cua/pull/861)) by @Francesco Bonacci
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.3.6 (2026-01-20)
+
+* Bump cua-computer-server to v0.3.6 by @github-actions[bot]
+* feat(computer-server): auto-detect MCP mode and expose HTTP+MCP simultaneously ([#860](https://github.com/trycua/cua/pull/860)) by @Francesco Bonacci
+
+Run the server
+cua-computer-server
+```
+
+### v0.3.5 (2026-01-20)
+
+- Bump cua-computer-server to v0.3.5 by @github-actions[bot]
+- feat(computer-server): add MCP interface for Claude Code integration ([#859](https://github.com/trycua/cua/pull/859)) by @Francesco Bonacci
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.3.2 (2026-01-11)
+
+* Initial release or no path-specific changes found
+
+### v0.3.1 (2026-01-11)
+
+Maintenance release.
+
+## 0.1.x
+
+### v0.1.28 (2025-10-29)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+- Add test infrastructure with CI/CD #478 by @AceAtDev in https://github.com/trycua/cua/pull/491
+- Add desktop and window management commands to computer interface by @ddupont808 in https://github.com/trycua/cua/pull/516
+
+New Contributors
+
+- @AceAtDev made their first contribution in https://github.com/trycua/cua/pull/491
+
+### v0.1.27 (2025-10-24)
+
+**Dependencies:** cua-computer: latest
+
+- Patch Python SSL on Windows VMs to use system cert store (Python bug: https://bugs.python.org/issue36011) ( by @ddupont808 in https://github.com/trycua/cua/pull/510
+
+### v0.1.26 (2025-10-24)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+
+* Moved platform-specific deps from computer-server out of optional dependencies (fixes accessibility API not working on macOS, Windows) by @ddupont808 in https://github.com/trycua/cua/pull/508
+
+### v0.1.25 (2025-10-22)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+- Fix authentication / connection errors caused by computer-server using old API url by @ddupont808 in https://github.com/trycua/cua/pull/499
+
+New Contributors
+
+- @masterbatcoderman10 made their first contribution in https://github.com/trycua/cua/pull/480
+
+### v0.1.23 (2025-10-03)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.22 (2025-09-03)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.21 (2025-08-06)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.20 (2025-07-29)
+
+Replaced `pyautogui.type_text` with `pynput.KeyboardController`, fixing the bug where multi-line text would just type the letter `"v"` on Linux
+
+### v0.1.19 (2025-07-11)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.18 (2025-07-10)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.17 (2025-07-09)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.16 (2025-07-09)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.15 (2025-07-01)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.14 (2025-07-01)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.13 (2025-06-18)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.12 (2025-06-10)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.11 (2025-06-05)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.10 (2025-05-31)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.9 (2025-05-28)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.8 (2025-05-28)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.7 (2025-05-28)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.6 (2025-05-25)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.5 (2025-05-16)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
+
+### v0.1.4 (2025-04-25)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+
+```
+
+### v0.1.3 (2025-04-15)
+
+**Dependencies:** cua-computer: latest
+
+Run the server
+cua-computer-server
+```
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/index.mdx b/docs/content/docs/cua/reference/desktop-sandbox/index.mdx
index 0c6ab59092..dbfb13002e 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/index.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/index.mdx
@@ -7,43 +7,43 @@ Desktop sandbox environments provide isolated desktops for running Computer-Usin
## Sandbox Options
-### [macOS Sandbox](/cua/reference/desktop-sandbox/macos)
+### macOS Sandbox
-Native macOS virtual machines on Apple Silicon using Apple's Virtualization Framework. Near-native performance for macOS automation.
+Native macOS virtual machines on Apple Silicon using Apple's Virtualization Framework. Near-native performance for macOS automation. [Learn more →](/cua/reference/desktop-sandbox/macos)
- **Lume** - Native CLI for VM management
- **Lumier** - Docker wrapper for containerized deployments
-### [Linux Container](/cua/reference/desktop-sandbox/linux-container)
+### Linux Container
-Docker containers running Linux desktops. Fast startup, low resource usage.
+Docker containers running Linux desktops. Fast startup, low resource usage. [Learn more →](/cua/reference/desktop-sandbox/linux-container)
-| Container | Description |
-|-----------|-------------|
-| [Kasm](/cua/reference/desktop-sandbox/linux-container/kasm) | KasmWeb-based Ubuntu with XFCE |
+| Container | Description |
+| ----------------------------------------------------------- | ---------------------------------- |
+| [Kasm](/cua/reference/desktop-sandbox/linux-container/kasm) | KasmWeb-based Ubuntu with XFCE |
| [XFCE](/cua/reference/desktop-sandbox/linux-container/xfce) | Vanilla XFCE, minimal dependencies |
-### [QEMU Container](/cua/reference/desktop-sandbox/qemu-container)
+### QEMU Container
-Full virtual machines running in Docker via QEMU/KVM. Complete OS isolation, supports Windows.
+Full virtual machines running in Docker via QEMU/KVM. Complete OS isolation, supports Windows. [Learn more →](/cua/reference/desktop-sandbox/qemu-container)
-| Container | OS | Description |
-|-----------|-----|-------------|
-| [Windows](/cua/reference/desktop-sandbox/qemu-container/windows) | Windows 11 | Windows desktop with KVM |
-| [Linux](/cua/reference/desktop-sandbox/qemu-container/linux) | Ubuntu 22.04 | Full Ubuntu VM |
-| [Android](/cua/reference/desktop-sandbox/qemu-container/android) | Android 11 | Android emulator |
+| Container | OS | Description |
+| ---------------------------------------------------------------- | ------------ | ------------------------ |
+| [Windows](/cua/reference/desktop-sandbox/qemu-container/windows) | Windows 11 | Windows desktop with KVM |
+| [Linux](/cua/reference/desktop-sandbox/qemu-container/linux) | Ubuntu 22.04 | Full Ubuntu VM |
+| [Android](/cua/reference/desktop-sandbox/qemu-container/android) | Android 11 | Android emulator |
## Quick Comparison
-| Feature | macOS (Lume) | Linux Container | QEMU VM |
-|---------|--------------|-----------------|---------|
-| Performance | Near-native | Native | Virtualized |
-| Startup Time | Minutes | Seconds | 30s-2min |
-| Host Requirements | Apple Silicon | Docker | KVM support |
-| Windows Support | No | No | Yes |
-| Resource Usage | Medium | Low | High |
-| Memory Snapshots | Yes | No | Yes |
-| Filesystem Snapshots | Yes | Yes | Yes |
+| Feature | macOS (Lume) | Linux Container | QEMU VM |
+| -------------------- | ------------- | --------------- | ----------- |
+| Performance | Near-native | Native | Virtualized |
+| Startup Time | Minutes | Seconds | 30s-2min |
+| Host Requirements | Apple Silicon | Docker | KVM support |
+| Windows Support | No | No | Yes |
+| Resource Usage | Medium | Low | High |
+| Memory Snapshots | Yes | No | Yes |
+| Filesystem Snapshots | Yes | Yes | Yes |
### Snapshot Capabilities
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/linux-container/kasm.mdx b/docs/content/docs/cua/reference/desktop-sandbox/linux-container/kasm.mdx
index 47c8f88876..b4c07bf912 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/linux-container/kasm.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/linux-container/kasm.mdx
@@ -28,6 +28,7 @@ docker run --rm -it \
```
**Access Points:**
+
- **VNC Web Interface**: `http://localhost:6901`
- **Computer Server API**: `http://localhost:8000`
@@ -60,10 +61,10 @@ async with computer:
### Environment Variables
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `VNC_PW` | `password` | VNC password |
-| `DISPLAY` | `:0` | X11 display |
+| Variable | Default | Description |
+| --------- | ---------- | ------------ |
+| `VNC_PW` | `password` | VNC password |
+| `DISPLAY` | `:0` | X11 display |
### Volumes
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/linux-container/xfce.mdx b/docs/content/docs/cua/reference/desktop-sandbox/linux-container/xfce.mdx
index e34892ff61..189ca99b57 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/linux-container/xfce.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/linux-container/xfce.mdx
@@ -28,6 +28,7 @@ docker run --rm -it \
```
**Access Points:**
+
- **noVNC Web Interface**: `http://localhost:6901` (no password required)
- **VNC Client**: `localhost:5901` (no password required)
- **Computer Server API**: `http://localhost:8000`
@@ -78,13 +79,13 @@ async with computer:
### Environment Variables
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `VNC_RESOLUTION` | `1024x768` | Screen resolution |
-| `VNC_COL_DEPTH` | `24` | Color depth |
-| `VNC_PORT` | `5901` | VNC server port |
-| `NOVNC_PORT` | `6901` | noVNC web interface port |
-| `API_PORT` | `8000` | Computer-server API port |
+| Variable | Default | Description |
+| ---------------- | ---------- | ------------------------ |
+| `VNC_RESOLUTION` | `1024x768` | Screen resolution |
+| `VNC_COL_DEPTH` | `24` | Color depth |
+| `VNC_PORT` | `5901` | VNC server port |
+| `NOVNC_PORT` | `6901` | noVNC web interface port |
+| `API_PORT` | `8000` | Computer-server API port |
### Ports
@@ -111,12 +112,12 @@ docker commit <container_id> cua-xfce-snapshot:latest
## Comparison with Kasm Container
-| Feature | Kasm Container | XFCE Container |
-|---------|----------------|----------------|
-| Base Image | KasmWeb Ubuntu | Vanilla Ubuntu |
-| VNC Server | KasmVNC | TigerVNC |
-| Dependencies | Higher | Lower |
-| Size | Larger | Smaller |
+| Feature | Kasm Container | XFCE Container |
+| ------------ | -------------- | -------------- |
+| Base Image | KasmWeb Ubuntu | Vanilla Ubuntu |
+| VNC Server | KasmVNC | TigerVNC |
+| Dependencies | Higher | Lower |
+| Size | Larger | Smaller |
## Building from Source
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/macos.mdx b/docs/content/docs/cua/reference/desktop-sandbox/macos.mdx
index 40cc8806cc..6b5df57166 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/macos.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/macos.mdx
@@ -7,10 +7,10 @@ macOS sandbox environments run native macOS virtual machines on Apple Silicon us
## Options
-| Option | Description | Best For |
-|--------|-------------|----------|
-| [Lume](/lume) | Native CLI for creating and managing macOS VMs | Direct VM management, development |
-| [Lumier](/lume/guide/advanced/lumier) | Docker wrapper around Lume | Containerized deployments |
+| Option | Description | Best For |
+| ------------------------------------- | ---------------------------------------------- | --------------------------------- |
+| [Lume](/lume) | Native CLI for creating and managing macOS VMs | Direct VM management, development |
+| [Lumier](/lume/guide/advanced/lumier) | Docker wrapper around Lume | Containerized deployments |
## Requirements
@@ -67,12 +67,12 @@ async with computer:
## Comparison with Other Platforms
-| Feature | macOS (Lume) | Linux Container | QEMU VM |
-|---------|--------------|-----------------|---------|
-| Performance | Near-native | Native | Virtualized |
-| Host OS | macOS only | Any with Docker | Any with KVM |
-| Setup Time | Minutes | Seconds | 15-30 min (first run) |
-| Windows Support | No | No | Yes |
+| Feature | macOS (Lume) | Linux Container | QEMU VM |
+| --------------- | ------------ | --------------- | --------------------- |
+| Performance | Near-native | Native | Virtualized |
+| Host OS | macOS only | Any with Docker | Any with KVM |
+| Setup Time | Minutes | Seconds | 15-30 min (first run) |
+| Windows Support | No | No | Yes |
## Related Documentation
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/meta.json b/docs/content/docs/cua/reference/desktop-sandbox/meta.json
index c51d5986c2..12cf0816e1 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/meta.json
+++ b/docs/content/docs/cua/reference/desktop-sandbox/meta.json
@@ -1,5 +1,5 @@
{
"title": "Desktop Sandbox",
"icon": "Container",
- "pages": ["macos", "linux-container", "qemu-container"]
+ "pages": ["macos", "linux-container", "qemu-container", "changelog"]
}
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/android.mdx b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/android.mdx
index c5700c25e0..882240c09a 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/android.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/android.mdx
@@ -33,6 +33,7 @@ docker run -d \
```
**Access Points:**
+
- **VNC Web UI**: `http://localhost:6080`
- **Computer Server API**: `http://localhost:8000`
- **API Documentation**: `http://localhost:8000/docs`
@@ -60,10 +61,10 @@ curl -X POST http://localhost:8000/cmd \
### Environment Variables
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `EMULATOR_DEVICE` | - | Device profile (e.g., "Samsung Galaxy S10") |
-| `WEB_VNC` | `true` | Enable VNC web interface |
+| Variable | Default | Description |
+| ----------------- | ------- | ------------------------------------------- |
+| `EMULATOR_DEVICE` | - | Device profile (e.g., "Samsung Galaxy S10") |
+| `WEB_VNC` | `true` | Enable VNC web interface |
### Ports
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/linux.mdx b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/linux.mdx
index 26ec7ff5ea..066c00e12d 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/linux.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/linux.mdx
@@ -37,6 +37,7 @@ docker run -it --rm \
```
**Access Points:**
+
- **Computer Server API**: `http://localhost:5000`
- **noVNC Browser**: `http://localhost:8006`
@@ -44,11 +45,11 @@ docker run -it --rm \
### Environment Variables
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `RAM_SIZE` | `8G` | RAM allocated to Ubuntu VM |
-| `CPU_CORES` | `8` | CPU cores allocated to VM |
-| `DISK_SIZE` | `64G` | VM disk size (minimum: 32G) |
+| Variable | Default | Description |
+| ----------- | ------- | --------------------------- |
+| `RAM_SIZE` | `8G` | RAM allocated to Ubuntu VM |
+| `CPU_CORES` | `8` | CPU cores allocated to VM |
+| `DISK_SIZE` | `64G` | VM disk size (minimum: 32G) |
### Ports
diff --git a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/windows.mdx b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/windows.mdx
index 10f4fc905a..74962d1350 100644
--- a/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/windows.mdx
+++ b/docs/content/docs/cua/reference/desktop-sandbox/qemu-container/windows.mdx
@@ -37,6 +37,7 @@ docker run -it --rm \
```
**Access Points:**
+
- **Computer Server API**: `http://localhost:5000`
- **noVNC Browser**: `http://localhost:8006`
@@ -44,11 +45,11 @@ docker run -it --rm \
### Environment Variables
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `RAM_SIZE` | `8G` | RAM allocated to Windows VM |
-| `CPU_CORES` | `8` | CPU cores allocated to VM |
-| `DISK_SIZE` | `30G` | VM disk size (minimum: 20G) |
+| Variable | Default | Description |
+| ----------- | ------- | --------------------------- |
+| `RAM_SIZE` | `8G` | RAM allocated to Windows VM |
+| `CPU_CORES` | `8` | CPU cores allocated to VM |
+| `DISK_SIZE` | `30G` | VM disk size (minimum: 20G) |
### Ports
diff --git a/docs/content/docs/cua/reference/meta.json b/docs/content/docs/cua/reference/meta.json
index 8658412b4e..f2222bec5d 100644
--- a/docs/content/docs/cua/reference/meta.json
+++ b/docs/content/docs/cua/reference/meta.json
@@ -2,5 +2,5 @@
"title": "Reference",
"description": "SDK and CLI API reference",
"icon": "FileText",
- "pages": ["desktop-sandbox", "computer-sdk", "agent-sdk", "mcp-server", "cloud-cli"]
+ "pages": ["desktop-sandbox", "computer-sdk", "agent-sdk", "cli"]
}
diff --git a/docs/content/docs/cuabench/examples/rl-training.mdx b/docs/content/docs/cuabench/examples/rl-training.mdx
index 392ab20e39..a2469c07f2 100644
--- a/docs/content/docs/cuabench/examples/rl-training.mdx
+++ b/docs/content/docs/cuabench/examples/rl-training.mdx
@@ -713,16 +713,16 @@ modal run modal_grpo_training.py \
## CLI Options
-| Option | Default | Description |
-|--------|---------|-------------|
-| `--model-id` | `Qwen/Qwen3-VL-2B-Instruct` | Model to train |
-| `--num-workers` | `2` | Number of parallel environment workers |
-| `--max-steps` | `10` | Max steps per episode |
-| `--num-generations` | `4` | Rollouts per prompt |
-| `--dataset-size` | `1000` | Number of training samples |
-| `--learning-rate` | `5e-6` | Learning rate |
-| `--save-steps` | `100` | Checkpoint save interval |
-| `--debug` | `False` | Enable verbose output |
+| Option | Default | Description |
+| ------------------- | --------------------------- | -------------------------------------- |
+| `--model-id` | `Qwen/Qwen3-VL-2B-Instruct` | Model to train |
+| `--num-workers` | `2` | Number of parallel environment workers |
+| `--max-steps` | `10` | Max steps per episode |
+| `--num-generations` | `4` | Rollouts per prompt |
+| `--dataset-size` | `1000` | Number of training samples |
+| `--learning-rate` | `5e-6` | Learning rate |
+| `--save-steps` | `100` | Checkpoint save interval |
+| `--debug` | `False` | Enable verbose output |
## Creating Custom Tasks
diff --git a/docs/content/docs/cuabench/guide/fundamentals/meta.json b/docs/content/docs/cuabench/guide/fundamentals/meta.json
index ab2dbc6363..c675290a14 100644
--- a/docs/content/docs/cuabench/guide/fundamentals/meta.json
+++ b/docs/content/docs/cuabench/guide/fundamentals/meta.json
@@ -2,5 +2,13 @@
"title": "Fundamentals",
"description": "Core concepts of tasks and environments",
"icon": "Lightbulb",
- "pages": ["tasks", "app-helpers", "universal-gui", "simulated-desktop", "agent-traces", "adapters", "registry"]
+ "pages": [
+ "tasks",
+ "app-helpers",
+ "universal-gui",
+ "simulated-desktop",
+ "agent-traces",
+ "adapters",
+ "registry"
+ ]
}
diff --git a/docs/content/docs/cuabench/guide/getting-started/introduction.mdx b/docs/content/docs/cuabench/guide/getting-started/introduction.mdx
index 82b3f0469c..3059692846 100644
--- a/docs/content/docs/cuabench/guide/getting-started/introduction.mdx
+++ b/docs/content/docs/cuabench/guide/getting-started/introduction.mdx
@@ -4,7 +4,8 @@ description: A benchmark to measure the capabilities of computer-use agents in d
---
<Callout type="info">
- Building or researching computer-use agents? Fill out the [Interest Form](https://cuabench.ai/) to chat with us.
+ Building or researching computer-use agents? Fill out the [Interest Form](https://cuabench.ai/) to
+ chat with us.
</Callout>
**Cua-Bench** is a framework and set of tasks for evaluating how well AI agents can accomplish complex tasks on a desktop computer using primarily the keyboard and mouse, or on a mobile device using primarily the touchscreen.
diff --git a/docs/content/docs/cuabench/reference/api.mdx b/docs/content/docs/cuabench/reference/api.mdx
new file mode 100644
index 0000000000..849c840192
--- /dev/null
+++ b/docs/content/docs/cuabench/reference/api.mdx
@@ -0,0 +1,5157 @@
+---
+title: API Reference
+description: Python API reference for the desktop automation benchmarking framework
+---
+
+{/*
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+ Generated by: npx tsx scripts/docs-generators/python-sdk.ts
+ Source: libs/cua-bench/cua_bench
+ Version: 0.2.3
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"0.2","href":"/cuabench/reference","isCurrent":true}]}
+ currentVersion="0.2"
+ fullVersion="0.2.3"
+ packageName="cua-bench"
+/>
+
+cua-bench SDK - A framework for desktop automation tasks with batch processing.
+
+## Classes
+
+| Class | Description |
+|-------|-------------|
+| [`Task`](#task) | Represents a single task to be executed. |
+| [`Desktop`](#desktop) | Desktop environment manager. |
+| [`Environment`](#environment) | A minimal environment wrapper that delegates everything to a provider. |
+| [`BenchmarkResult`](#benchmarkresult) | Result of a benchmark run. |
+| [`TaskResult`](#taskresult) | Result of a single task execution. |
+| [`ClickAction`](#clickaction) | No description |
+| [`DoneAction`](#doneaction) | No description |
+| [`DoubleClickAction`](#doubleclickaction) | No description |
+| [`DragAction`](#dragaction) | No description |
+| [`HotkeyAction`](#hotkeyaction) | No description |
+| [`KeyAction`](#keyaction) | No description |
+| [`MiddleClickAction`](#middleclickaction) | No description |
+| [`MoveToAction`](#movetoaction) | No description |
+| [`RightClickAction`](#rightclickaction) | No description |
+| [`ScrollAction`](#scrollaction) | No description |
+| [`TypeAction`](#typeaction) | No description |
+| [`WaitAction`](#waitaction) | No description |
+
+## Functions
+
+| Function | Description |
+|----------|-------------|
+| [`repr_to_action`](#repr_to_action) | Parse an action from repr format string. |
+| [`interact`](#interact) | Run an environment interactively with simplified output. |
+| [`make`](#make) | Create an Environment by loading the env's main.py as a module. |
+| [`evaluate_task`](#evaluate_task) | Decorator for the function that evaluates a task. |
+| [`setup_task`](#setup_task) | Decorator for the function that sets up a task. |
+| [`solve_task`](#solve_task) | Decorator for the function that solves a task. |
+| [`tasks_config`](#tasks_config) | Decorator for the function that loads tasks. |
+| [`run_benchmark`](#run_benchmark) | Run a benchmark on a dataset using the gym interface. |
+| [`run_interactive`](#run_interactive) | Run an environment interactively using the gym interface. |
+| [`run_single_task`](#run_single_task) | Run a single task using the gym interface. |
+
+---
+
+## Task
+
+Represents a single task to be executed.
+
+### Constructor
+
+```python
+Task(self, description: str, task_id: Optional[str] = None, metadata: Optional[dict] = None, computer: Optional[dict] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `description` | `str` | |
+| `task_id` | `Optional[str]` | |
+| `metadata` | `Optional[dict]` | |
+| `computer` | `Optional[dict]` | |
+
+---
+
+## Desktop
+
+Desktop environment manager.
+
+### Constructor
+
+```python
+Desktop(self, env)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+| `state` | `Any` | |
+| `template` | `Any` | |
+
+### Methods
+
+#### Desktop.configure
+
+```python
+def configure(self, os_type: Optional[str] = None, width: Optional[int] = None, height: Optional[int] = None, background: Optional[str] = None, dock_state: Optional[Dict[str, List[Union[str, Dict[str, str]]]]] = None, randomize_dock: bool = True, taskbar_state: Optional[Dict[str, List[Union[str, Dict[str, str]]]]] = None, randomize_taskbar: bool = True)
+```
+
+Configure desktop appearance.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os_type` | `Any` | OS appearance (win11, win10, win7, macos, winxp, win98, android, ios) |
+| `width` | `Any` | Screen width in pixels |
+| `height` | `Any` | Screen height in pixels |
+| `background` | `Any` | Background color |
+| `dock_state` | `Any` | Explicit dock state to set with keys 'pinned_apps', 'recent_apps', 'pinned_folders' |
+| `randomize_dock` | `Any` | If True, populate dock_state using macOS icon sets |
+| `taskbar_state` | `Any` | Explicit taskbar state to set with keys 'pinned_apps', 'open_apps' |
+| `randomize_taskbar` | `Any` | If True, populate taskbar_state using Windows 11 icon sets |
+
+#### Desktop.launch
+
+```python
+def launch(self, content: str, title: str = 'Window', x: Optional[int] = None, y: Optional[int] = None, width: int = 600, height: int = 400, icon: Optional[str] = None, use_inner_size: bool = False, title_bar_style: str = 'default') -> Window
+```
+
+Launch a new window on the desktop.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `content` | `Any` | HTML content for the window body |
+| `title` | `Any` | Window title |
+| `x` | `Any` | X position (auto-calculated if None) |
+| `y` | `Any` | Y position (auto-calculated if None) |
+| `width` | `Any` | Window width |
+| `height` | `Any` | Window height |
+| `use_inner_size` | `Any` | Whether to use the inner size of the window (i.e. content size) |
+
+**Returns:** Window instance
+
+---
+
+## Environment
+
+A minimal environment wrapper that delegates everything to a provider.
+
+Functions can be injected directly, or discovered from a module via
+`make_from_module` based on cua-bench decorators (`_td_type`, `_td_split`).
+
+### Constructor
+
+```python
+Environment(self, env_name: Optional[str] = None, split: str = 'train', tasks_config_fn: Optional[Callable[..., Any]] = None, setup_task_fn: Optional[Callable[..., Any]] = None, solve_task_fn: Optional[Callable[..., Any]] = None, evaluate_task_fn: Optional[Callable[..., Any]] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Optional[Any]` | |
+| `env_name` | `Optional[str]` | |
+| `split` | `Optional[str]` | |
+| `headless` | `bool` | |
+| `print_actions` | `bool` | |
+| `bot` | `Optional[Bot]` | |
+| `tracing` | `Optional[Tracing]` | |
+| `step_count` | `int` | |
+| `max_steps` | `Optional[int]` | |
+| `tasks_config_fn` | `Any` | |
+| `setup_task_fn` | `Any` | |
+| `solve_task_fn` | `Any` | |
+| `evaluate_task_fn` | `Any` | |
+| `tasks` | `Optional[list]` | |
+| `current_task` | `Optional[Any]` | |
+| `session_name` | `Optional[str]` | |
+| `session_config` | `Dict[str, Any]` | |
+| `setup_config` | `DesktopSetupConfig` | |
+| `page` | `Optional[Any]` | |
+
+### Methods
+
+#### Environment.make_from_module
+
+```python
+def make_from_module(cls, module: Any, env_path: str | Path, split: str = 'train') -> 'Environment'
+```
+
+#### Environment.create_sandbox
+
+```python
+async def create_sandbox(self, provider: str, provider_config: Dict[str, Any] | None = None, setup_config: DesktopSetupConfig | None = None) -> None
+```
+
+#### Environment.reset
+
+```python
+async def reset(self, task_id: Optional[int] = None, run_id: Optional[str] = None) -> Tuple[bytes, Dict]
+```
+
+#### Environment.step
+
+```python
+async def step(self, action: Action, dry_run: bool | Literal['before', 'after'] = False) -> bytes
+```
+
+#### Environment.solve
+
+```python
+async def solve(self) -> bytes
+```
+
+#### Environment.evaluate
+
+```python
+async def evaluate(self) -> Any
+```
+
+#### Environment.close
+
+```python
+async def close(self) -> None
+```
+
+---
+
+## BenchmarkResult
+
+Result of a benchmark run.
+
+Attributes:
+ run_id: Unique identifier for this run
+ task_results: List of individual task results
+ total_tasks: Total number of tasks in the benchmark
+ success_count: Number of successful tasks
+ failed_count: Number of failed tasks
+ avg_reward: Average reward across all tasks
+ duration_seconds: Total duration of the benchmark
+ output_dir: Output directory for results (if any)
+
+### Constructor
+
+```python
+BenchmarkResult(self, run_id: str, task_results: List[Dict[str, Any]], total_tasks: int, success_count: int, failed_count: int, avg_reward: float, duration_seconds: float, output_dir: Optional[str] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `run_id` | `str` | |
+| `task_results` | `List[Dict[str, Any]]` | |
+| `total_tasks` | `int` | |
+| `success_count` | `int` | |
+| `failed_count` | `int` | |
+| `avg_reward` | `float` | |
+| `duration_seconds` | `float` | |
+| `output_dir` | `Optional[str]` | |
+
+---
+
+## TaskResult
+
+Result of a single task execution.
+
+Attributes:
+ task_path: Path to the task
+ variant_id: Task variant index
+ success: Whether the task succeeded
+ reward: Reward from evaluation
+ steps: Number of steps taken
+ error: Error message if failed
+
+### Constructor
+
+```python
+TaskResult(self, task_path: str, variant_id: int, success: bool, reward: float, steps: int, error: Optional[str] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `task_path` | `str` | |
+| `variant_id` | `int` | |
+| `success` | `bool` | |
+| `reward` | `float` | |
+| `steps` | `int` | |
+| `error` | `Optional[str]` | |
+
+---
+
+## ClickAction
+
+### Constructor
+
+```python
+ClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DoneAction
+
+### Constructor
+
+```python
+DoneAction(self) -> None
+```
+
+---
+
+## DoubleClickAction
+
+### Constructor
+
+```python
+DoubleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DragAction
+
+### Constructor
+
+```python
+DragAction(self, from_x: int, from_y: int, to_x: int, to_y: int, duration: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `from_x` | `int` | |
+| `from_y` | `int` | |
+| `to_x` | `int` | |
+| `to_y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## HotkeyAction
+
+### Constructor
+
+```python
+HotkeyAction(self, keys: List[str]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `keys` | `List[str]` | |
+
+---
+
+## KeyAction
+
+### Constructor
+
+```python
+KeyAction(self, key: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `str` | |
+
+---
+
+## MiddleClickAction
+
+### Constructor
+
+```python
+MiddleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## MoveToAction
+
+### Constructor
+
+```python
+MoveToAction(self, x: int, y: int, duration: float = 0.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## RightClickAction
+
+### Constructor
+
+```python
+RightClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## ScrollAction
+
+### Constructor
+
+```python
+ScrollAction(self, direction: Literal['up', 'down'] = 'up', amount: int = 100) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `direction` | `Literal['up', 'down']` | |
+| `amount` | `int` | |
+
+---
+
+## TypeAction
+
+### Constructor
+
+```python
+TypeAction(self, text: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `str` | |
+
+---
+
+## WaitAction
+
+### Constructor
+
+```python
+WaitAction(self, seconds: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `seconds` | `float` | |
+
+## repr_to_action
+
+```python
+def repr_to_action(action_repr: str) -> Action
+```
+
+Parse an action from repr format string.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_repr` | `Any` | Action string in repr format, e.g., "ClickAction(x=100, y=200)" |
+
+**Returns:** Parsed Action object
+
+**Raises:**
+
+- `ValueError` - If the action string cannot be parsed
+
+## interact
+
+```python
+def interact(env_path: str, task_id: int = 0) -> None
+```
+
+Run an environment interactively with simplified output.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the environment directory |
+| `task_id` | `Any` | Task ID to run (default: 0) |
+
+## make
+
+```python
+def make(env_name: str, split: str = 'train') -> Any
+```
+
+Create an Environment by loading the env's main.py as a module.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Path to the environment directory (must contain main.py) |
+| `split` | `Any` | Dataset split to use for decorated functions (e.g., 'train', 'test') |
+
+**Returns:** Environment instance
+
+## evaluate_task
+
+```python
+def evaluate_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that evaluates a task.
+
+Can be used as ``@cb.evaluate_task`` or ``@cb.evaluate_task("train")``.
+The decorated function receives task_cfg and should return evaluation results.
+
+## setup_task
+
+```python
+def setup_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that sets up a task.
+
+Can be used as ``@cb.setup_task`` or ``@cb.setup_task("train")``.
+The decorated function receives task_cfg and should initialize the environment.
+
+## solve_task
+
+```python
+def solve_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that solves a task.
+
+Can be used as ``@cb.solve_task`` or ``@cb.solve_task("train")``.
+The decorated function receives task_cfg and should execute the solution.
+
+## tasks_config
+
+```python
+def tasks_config(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that loads tasks.
+
+Can be used as ``@cb.tasks_config`` or ``@cb.tasks_config("train")``.
+The decorated function should return a list of Task objects.
+
+## run_benchmark
+
+```python
+async def run_benchmark(dataset_path: Path, agent_fn: Optional[Callable[[bytes, Task], Action]] = None, max_steps: int = 100, max_parallel: int = 4, oracle: bool = False, max_variants: Optional[int] = None, task_filter: Optional[str] = None, split: str = 'train') -> BenchmarkResult
+```
+
+Run a benchmark on a dataset using the gym interface.
+
+This function runs multiple tasks in parallel using the core gym interface
+(make, reset, step, evaluate).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `dataset_path` | `Any` | Path to the dataset directory |
+| `agent_fn` | `Any` | Optional agent function that takes (screenshot, task_config) and returns an Action. Required if oracle=False. |
+| `max_steps` | `Any` | Maximum steps per task (default: 100) |
+| `max_parallel` | `Any` | Maximum parallel workers (default: 4) |
+| `oracle` | `Any` | Run oracle/solver mode (default: False) |
+| `max_variants` | `Any` | Maximum variants per task (optional) |
+| `task_filter` | `Any` | Glob pattern to filter tasks (optional) |
+| `split` | `Any` | Dataset split (default: "train") |
+
+**Returns:** BenchmarkResult with run statistics and task results
+
+**Example:**
+
+```python
+# Run oracle benchmark
+result = await run_benchmark(
+ Path("./datasets/cua-bench-basic"),
+ oracle=True,
+ max_parallel=8,
+)
+print(f"Success rate: {result.success_count / result.total_tasks:.2%}")
+
+# Run with custom agent
+def random_agent(screenshot: bytes, task: Task) -> Action:
+ import random
+ return random.choice([
+ ClickAction(x=random.randint(0, 1920), y=random.randint(0, 1080)),
+ DoneAction(),
+ ])
+
+result = await run_benchmark(
+ Path("./datasets/my-dataset"),
+ agent_fn=random_agent,
+ max_parallel=4,
+)
+```
+
+## run_interactive
+
+```python
+async def run_interactive(env_path: Path, task_index: int = 0, split: str = 'train', headless: bool = False) -> Tuple[Environment, bytes, Task]
+```
+
+Run an environment interactively using the gym interface.
+
+This function sets up an environment for interactive use, returning
+the environment instance, initial screenshot, and task configuration.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the environment directory |
+| `task_index` | `Any` | Task variant index (default: 0) |
+| `split` | `Any` | Dataset split (default: "train") |
+| `headless` | `Any` | Run in headless mode (default: False) |
+
+**Returns:** Tuple of (env, screenshot, task_config) - env: Environment instance (caller should call env.close() when done) - screenshot: Initial screenshot bytes - task_config: Task configuration
+
+**Example:**
+
+```python
+env, screenshot, task_cfg = await run_interactive(Path("./task"))
+print(f"Task: {task_cfg.description}")
+
+# Execute actions...
+screenshot = await env.step(ClickAction(x=100, y=200))
+
+# Evaluate
+reward = await env.evaluate()
+print(f"Reward: {reward}")
+
+# Cleanup
+await env.close()
+```
+
+## run_single_task
+
+```python
+async def run_single_task(env_path: Path, task_index: int = 0, split: str = 'train', agent_fn: Optional[Callable[[bytes, Task], Action]] = None, max_steps: int = 100, oracle: bool = False) -> TaskResult
+```
+
+Run a single task using the gym interface.
+
+This function uses the core gym interface (make, reset, step, evaluate)
+to run a task with either an agent function or the oracle solver.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the task environment directory |
+| `task_index` | `Any` | Task variant index (default: 0) |
+| `split` | `Any` | Dataset split (default: "train") |
+| `agent_fn` | `Any` | Optional agent function that takes (screenshot, task_config) and returns an Action. If None and oracle=False, returns after setup. |
+| `max_steps` | `Any` | Maximum steps per task (default: 100) |
+| `oracle` | `Any` | Run oracle/solver mode (default: False) |
+
+**Returns:** TaskResult with execution results
+
+**Example:**
+
+```python
+# Run with oracle
+result = await run_single_task(Path("./task"), oracle=True)
+
+# Run with custom agent
+def my_agent(screenshot: bytes, task: Task) -> Action:
+ return DoneAction() # Simple agent that immediately finishes
+
+result = await run_single_task(Path("./task"), agent_fn=my_agent)
+```
+
+---
+
+## tracing
+
+---
+
+## Tracing
+
+Lightweight trajectory tracing using Hugging Face Datasets.
+
+Records events with arbitrary JSON metadata and a list of PIL images.
+Exposes a datasets.Dataset-compatible interface for saving/pushing.
+
+### Constructor
+
+```python
+Tracing(self, env: Any) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+| `trajectory_id` | `Optional[str]` | |
+| `dataset` | `Dataset` | Return a HF Dataset built from current rows, constructing lazily. |
+
+### Methods
+
+#### Tracing.start
+
+```python
+def start(self, trajectory_id: Optional[str] = None) -> str
+```
+
+Start a new trajectory. Resets any previously recorded rows.
+
+Returns the trajectory_id used.
+
+#### Tracing.record
+
+```python
+def record(self, event_name: str, data_dict: Dict[str, Any], data_images: List[Image.Image | bytes] | None = None) -> None
+```
+
+#### Tracing.save_to_disk
+
+```python
+def save_to_disk(self, output_dir: str, save_pngs: bool = False, image_dir: Optional[str] = None, filter_events: Optional[List[str]] = None) -> None
+```
+
+#### Tracing.push_to_hub
+
+```python
+def push_to_hub(self, repo_id: str, private: bool | None = None) -> str
+```
+
+#### Tracing.bytes_to_image
+
+```python
+def bytes_to_image(png_bytes: bytes) -> Image.Image
+```
+
+---
+
+## actions
+
+---
+
+## ClickAction
+
+### Constructor
+
+```python
+ClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DoneAction
+
+### Constructor
+
+```python
+DoneAction(self) -> None
+```
+
+---
+
+## DoubleClickAction
+
+### Constructor
+
+```python
+DoubleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DragAction
+
+### Constructor
+
+```python
+DragAction(self, from_x: int, from_y: int, to_x: int, to_y: int, duration: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `from_x` | `int` | |
+| `from_y` | `int` | |
+| `to_x` | `int` | |
+| `to_y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## HotkeyAction
+
+### Constructor
+
+```python
+HotkeyAction(self, keys: List[str]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `keys` | `List[str]` | |
+
+---
+
+## KeyAction
+
+### Constructor
+
+```python
+KeyAction(self, key: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `str` | |
+
+---
+
+## MiddleClickAction
+
+### Constructor
+
+```python
+MiddleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## MoveToAction
+
+### Constructor
+
+```python
+MoveToAction(self, x: int, y: int, duration: float = 0.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## RightClickAction
+
+### Constructor
+
+```python
+RightClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## ScrollAction
+
+### Constructor
+
+```python
+ScrollAction(self, direction: Literal['up', 'down'] = 'up', amount: int = 100) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `direction` | `Literal['up', 'down']` | |
+| `amount` | `int` | |
+
+---
+
+## TypeAction
+
+### Constructor
+
+```python
+TypeAction(self, text: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `str` | |
+
+---
+
+## WaitAction
+
+### Constructor
+
+```python
+WaitAction(self, seconds: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `seconds` | `float` | |
+
+### repr_to_action
+
+```python
+def repr_to_action(action_repr: str) -> Action
+```
+
+Parse an action from repr format string.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_repr` | `Any` | Action string in repr format, e.g., "ClickAction(x=100, y=200)" |
+
+**Returns:** Parsed Action object
+
+**Raises:**
+
+- `ValueError` - If the action string cannot be parsed
+
+### snake_case_to_action
+
+```python
+def snake_case_to_action(action_str: str) -> Action
+```
+
+Parse an action from snake_case format string.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_str` | `Any` | Action string in snake_case format, e.g., "click(0.5, 0.5)" |
+
+**Returns:** Parsed Action object
+
+**Raises:**
+
+- `ValueError` - If the action string cannot be parsed
+
+### parse_action_string
+
+```python
+def parse_action_string(action_str: str) -> Action
+```
+
+Parse an action from either repr or snake_case format.
+
+This is the unified entry point for parsing action strings.
+It automatically detects the format and delegates to the appropriate parser.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_str` | `Any` | Action string in either format: - Repr format: "ClickAction(x=100, y=200)" - Snake_case format: "click(0.5, 0.5)" |
+
+**Returns:** Parsed Action object
+
+**Raises:**
+
+- `ValueError` - If the action string cannot be parsed in either format
+
+### action_to_dict
+
+```python
+def action_to_dict(action: Action) -> Dict[str, Any]
+```
+
+Convert an Action object to a dictionary.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action` | `Any` | Action object to convert |
+
+**Returns:** Dictionary representation of the action with 'type' key
+
+### dict_to_action
+
+```python
+def dict_to_action(action_dict: Dict[str, Any]) -> Action
+```
+
+Convert a dictionary to an Action object.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_dict` | `Any` | Dictionary with 'type' key and action parameters |
+
+**Returns:** Action object
+
+**Raises:**
+
+- `ValueError` - If the action type is unknown
+
+---
+
+## core
+
+Core classes and functions for cua-bench.
+
+---
+
+## Task
+
+Represents a single task to be executed.
+
+### Constructor
+
+```python
+Task(self, description: str, task_id: Optional[str] = None, metadata: Optional[dict] = None, computer: Optional[dict] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `description` | `str` | |
+| `task_id` | `Optional[str]` | |
+| `metadata` | `Optional[dict]` | |
+| `computer` | `Optional[dict]` | |
+
+### make
+
+```python
+def make(env_name: str, split: str = 'train') -> Any
+```
+
+Create an Environment by loading the env's main.py as a module.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Path to the environment directory (must contain main.py) |
+| `split` | `Any` | Dataset split to use for decorated functions (e.g., 'train', 'test') |
+
+**Returns:** Environment instance
+
+### interact
+
+```python
+def interact(env_path: str, task_id: int = 0) -> None
+```
+
+Run an environment interactively with simplified output.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the environment directory |
+| `task_id` | `Any` | Task ID to run (default: 0) |
+
+---
+
+## types
+
+---
+
+## WindowSnapshot
+
+### Constructor
+
+```python
+WindowSnapshot(self, window_type: Literal['webview', 'process', 'desktop'], pid: Optional[str] = None, url: Optional[str] = None, html: Optional[str] = None, title: str = '', x: int = 0, y: int = 0, width: int = 0, height: int = 0, active: bool = False, minimized: bool = False) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `window_type` | `Literal['webview', 'process', 'desktop']` | |
+| `pid` | `Optional[str]` | |
+| `url` | `Optional[str]` | |
+| `html` | `Optional[str]` | |
+| `title` | `str` | |
+| `x` | `int` | |
+| `y` | `int` | |
+| `width` | `int` | |
+| `height` | `int` | |
+| `active` | `bool` | |
+| `minimized` | `bool` | |
+
+---
+
+## Snapshot
+
+### Constructor
+
+```python
+Snapshot(self, windows: List[WindowSnapshot]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `windows` | `List[WindowSnapshot]` | |
+
+---
+
+## ClickAction
+
+### Constructor
+
+```python
+ClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## RightClickAction
+
+### Constructor
+
+```python
+RightClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DoubleClickAction
+
+### Constructor
+
+```python
+DoubleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## MiddleClickAction
+
+### Constructor
+
+```python
+MiddleClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## DragAction
+
+### Constructor
+
+```python
+DragAction(self, from_x: int, from_y: int, to_x: int, to_y: int, duration: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `from_x` | `int` | |
+| `from_y` | `int` | |
+| `to_x` | `int` | |
+| `to_y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## MoveToAction
+
+### Constructor
+
+```python
+MoveToAction(self, x: int, y: int, duration: float = 0.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+| `duration` | `float` | |
+
+---
+
+## ScrollAction
+
+### Constructor
+
+```python
+ScrollAction(self, direction: Literal['up', 'down'] = 'up', amount: int = 100) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `direction` | `Literal['up', 'down']` | |
+| `amount` | `int` | |
+
+---
+
+## TypeAction
+
+### Constructor
+
+```python
+TypeAction(self, text: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `text` | `str` | |
+
+---
+
+## KeyAction
+
+### Constructor
+
+```python
+KeyAction(self, key: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `key` | `str` | |
+
+---
+
+## HotkeyAction
+
+### Constructor
+
+```python
+HotkeyAction(self, keys: List[str]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `keys` | `List[str]` | |
+
+---
+
+## DoneAction
+
+### Constructor
+
+```python
+DoneAction(self) -> None
+```
+
+---
+
+## WaitAction
+
+### Constructor
+
+```python
+WaitAction(self, seconds: float = 1.0) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `seconds` | `float` | |
+
+---
+
+## bot
+
+---
+
+## ClickAction
+
+### Constructor
+
+```python
+ClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## RightClickAction
+
+### Constructor
+
+```python
+RightClickAction(self, x: int, y: int) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+
+---
+
+## Bot
+
+Helper class for writing trajectories for task solutions.
+
+### Constructor
+
+```python
+Bot(self, env: Any)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+
+### Methods
+
+#### Bot.click_element
+
+```python
+def click_element(self, pid: int, selector: str) -> None
+```
+
+Find element by CSS selector and click its center.
+
+Uses provider's bench-ui bridge to fetch element rect in screen space
+and then dispatches a ClickAction via env.step().
+
+#### Bot.right_click_element
+
+```python
+def right_click_element(self, pid: int, selector: str) -> None
+```
+
+---
+
+## utils
+
+Utility functions for synthetic data generation.
+
+---
+
+## DesktopSetupConfig
+
+*Inherits from: TypedDict*
+
+Configuration for desktop setup provided to providers.
+
+Fields mirror high-level desktop appearance and workspace options.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os_type` | `Literal['win11', 'win10', 'win7', 'winxp', 'win98', 'macos', 'linux', 'android', 'ios', 'windows']` | |
+| `width` | `int` | |
+| `height` | `int` | |
+| `background` | `str` | |
+| `wallpaper` | `str` | |
+| `installed_apps` | `List[str]` | |
+| `image` | `str` | |
+| `storage` | `str` | |
+| `memory` | `str` | |
+| `cpu` | `str` | |
+| `provider_type` | `str` | |
+
+---
+
+## Environment
+
+A minimal environment wrapper that delegates everything to a provider.
+
+Functions can be injected directly, or discovered from a module via
+`make_from_module` based on cua-bench decorators (`_td_type`, `_td_split`).
+
+### Constructor
+
+```python
+Environment(self, env_name: Optional[str] = None, split: str = 'train', tasks_config_fn: Optional[Callable[..., Any]] = None, setup_task_fn: Optional[Callable[..., Any]] = None, solve_task_fn: Optional[Callable[..., Any]] = None, evaluate_task_fn: Optional[Callable[..., Any]] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Optional[Any]` | |
+| `env_name` | `Optional[str]` | |
+| `split` | `Optional[str]` | |
+| `headless` | `bool` | |
+| `print_actions` | `bool` | |
+| `bot` | `Optional[Bot]` | |
+| `tracing` | `Optional[Tracing]` | |
+| `step_count` | `int` | |
+| `max_steps` | `Optional[int]` | |
+| `tasks_config_fn` | `Any` | |
+| `setup_task_fn` | `Any` | |
+| `solve_task_fn` | `Any` | |
+| `evaluate_task_fn` | `Any` | |
+| `tasks` | `Optional[list]` | |
+| `current_task` | `Optional[Any]` | |
+| `session_name` | `Optional[str]` | |
+| `session_config` | `Dict[str, Any]` | |
+| `setup_config` | `DesktopSetupConfig` | |
+| `page` | `Optional[Any]` | |
+
+### Methods
+
+#### Environment.make_from_module
+
+```python
+def make_from_module(cls, module: Any, env_path: str | Path, split: str = 'train') -> 'Environment'
+```
+
+#### Environment.create_sandbox
+
+```python
+async def create_sandbox(self, provider: str, provider_config: Dict[str, Any] | None = None, setup_config: DesktopSetupConfig | None = None) -> None
+```
+
+#### Environment.reset
+
+```python
+async def reset(self, task_id: Optional[int] = None, run_id: Optional[str] = None) -> Tuple[bytes, Dict]
+```
+
+#### Environment.step
+
+```python
+async def step(self, action: Action, dry_run: bool | Literal['before', 'after'] = False) -> bytes
+```
+
+#### Environment.solve
+
+```python
+async def solve(self) -> bytes
+```
+
+#### Environment.evaluate
+
+```python
+async def evaluate(self) -> Any
+```
+
+#### Environment.close
+
+```python
+async def close(self) -> None
+```
+
+---
+
+## Snapshot
+
+### Constructor
+
+```python
+Snapshot(self, windows: List[WindowSnapshot]) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `windows` | `List[WindowSnapshot]` | |
+
+### render_snapshot_async
+
+```python
+async def render_snapshot_async(setup_config: Dict[str, Any], snapshot: Dict[str, Any], screenshot_delay: float = 0, provider: Literal['webtop', 'computer'] = 'webtop') -> bytes
+```
+
+Render a snapshot and return screenshot bytes (async).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider` | `Any` | Provider name ("webtop" or "computer") |
+| `setup_config` | `Any` | Configuration dict for create_sandbox setup_config parameter |
+| `snapshot` | `Any` | Snapshot dict containing windows and other state |
+| `screenshot_delay` | `Any` | Delay in seconds before taking screenshot |
+
+**Returns:** Screenshot as bytes
+
+### render_windows_async
+
+```python
+async def render_windows_async(setup_config: Dict[str, Any], windows: List[Dict[str, Any]], screenshot_delay: float = 0, provider: Literal['webtop', 'computer'] = 'webtop', return_snapshot: bool = False, scroll_into_view: Optional[str] = None) -> bytes | Tuple[bytes, Snapshot]
+```
+
+Render windows and return screenshot bytes (async).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider` | `Any` | Provider name ("webtop" or "computer") |
+| `setup_config` | `Any` | Configuration dict for create_sandbox setup_config parameter |
+| `windows` | `Any` | List of window dicts to pass directly to launch_window |
+| `screenshot_delay` | `Any` | Delay in seconds before taking screenshot |
+| `return_snapshot` | `Any` | If True, return tuple of (bytes, Snapshot) instead of just bytes |
+| `scroll_into_view` | `Any` | Optional CSS selector for an element to scroll into view |
+
+**Returns:** Screenshot as bytes, or tuple of (bytes, Snapshot) if return_snapshot=True
+
+### render_snapshot
+
+```python
+def render_snapshot(setup_config: Dict[str, Any], snapshot: Dict[str, Any], screenshot_delay: float = 0, provider: Literal['webtop', 'computer'] = 'webtop') -> bytes
+```
+
+Render a snapshot and return screenshot bytes (sync wrapper).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider` | `Any` | Provider name ("webtop" or "computer") |
+| `setup_config` | `Any` | Configuration dict for create_sandbox setup_config parameter |
+| `snapshot` | `Any` | Snapshot dict containing windows and other state |
+| `screenshot_delay` | `Any` | Delay in seconds before taking screenshot |
+
+**Returns:** Screenshot as bytes
+
+### render_windows
+
+```python
+def render_windows(setup_config: Dict[str, Any], windows: List[Dict[str, Any]], screenshot_delay: float = 0, provider: Literal['webtop', 'computer'] = 'webtop', return_snapshot: bool = False, scroll_into_view: Optional[str] = None) -> bytes | Tuple[bytes, Snapshot]
+```
+
+Render windows and return screenshot bytes (sync wrapper).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider` | `Any` | Provider name ("webtop" or "computer") |
+| `setup_config` | `Any` | Configuration dict for create_sandbox setup_config parameter |
+| `windows` | `Any` | List of window dicts to pass directly to launch_window |
+| `screenshot_delay` | `Any` | Delay in seconds before taking screenshot |
+| `return_snapshot` | `Any` | If True, return tuple of (bytes, Snapshot) instead of just bytes |
+| `scroll_into_view` | `Any` | Optional CSS selector for an element to scroll into view |
+
+**Returns:** Screenshot as bytes, or tuple of (bytes, Snapshot) if return_snapshot=True
+
+---
+
+## runners
+
+Benchmark runner functions for cua-bench.
+
+This module provides programmatic interfaces for running benchmarks and
+interactive environments, using the core gym interface (make, reset, step, evaluate).
+
+---
+
+## Task
+
+Represents a single task to be executed.
+
+### Constructor
+
+```python
+Task(self, description: str, task_id: Optional[str] = None, metadata: Optional[dict] = None, computer: Optional[dict] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `description` | `str` | |
+| `task_id` | `Optional[str]` | |
+| `metadata` | `Optional[dict]` | |
+| `computer` | `Optional[dict]` | |
+
+---
+
+## Environment
+
+A minimal environment wrapper that delegates everything to a provider.
+
+Functions can be injected directly, or discovered from a module via
+`make_from_module` based on cua-bench decorators (`_td_type`, `_td_split`).
+
+### Constructor
+
+```python
+Environment(self, env_name: Optional[str] = None, split: str = 'train', tasks_config_fn: Optional[Callable[..., Any]] = None, setup_task_fn: Optional[Callable[..., Any]] = None, solve_task_fn: Optional[Callable[..., Any]] = None, evaluate_task_fn: Optional[Callable[..., Any]] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Optional[Any]` | |
+| `env_name` | `Optional[str]` | |
+| `split` | `Optional[str]` | |
+| `headless` | `bool` | |
+| `print_actions` | `bool` | |
+| `bot` | `Optional[Bot]` | |
+| `tracing` | `Optional[Tracing]` | |
+| `step_count` | `int` | |
+| `max_steps` | `Optional[int]` | |
+| `tasks_config_fn` | `Any` | |
+| `setup_task_fn` | `Any` | |
+| `solve_task_fn` | `Any` | |
+| `evaluate_task_fn` | `Any` | |
+| `tasks` | `Optional[list]` | |
+| `current_task` | `Optional[Any]` | |
+| `session_name` | `Optional[str]` | |
+| `session_config` | `Dict[str, Any]` | |
+| `setup_config` | `DesktopSetupConfig` | |
+| `page` | `Optional[Any]` | |
+
+### Methods
+
+#### Environment.make_from_module
+
+```python
+def make_from_module(cls, module: Any, env_path: str | Path, split: str = 'train') -> 'Environment'
+```
+
+#### Environment.create_sandbox
+
+```python
+async def create_sandbox(self, provider: str, provider_config: Dict[str, Any] | None = None, setup_config: DesktopSetupConfig | None = None) -> None
+```
+
+#### Environment.reset
+
+```python
+async def reset(self, task_id: Optional[int] = None, run_id: Optional[str] = None) -> Tuple[bytes, Dict]
+```
+
+#### Environment.step
+
+```python
+async def step(self, action: Action, dry_run: bool | Literal['before', 'after'] = False) -> bytes
+```
+
+#### Environment.solve
+
+```python
+async def solve(self) -> bytes
+```
+
+#### Environment.evaluate
+
+```python
+async def evaluate(self) -> Any
+```
+
+#### Environment.close
+
+```python
+async def close(self) -> None
+```
+
+---
+
+## DoneAction
+
+### Constructor
+
+```python
+DoneAction(self) -> None
+```
+
+---
+
+## BenchmarkResult
+
+Result of a benchmark run.
+
+Attributes:
+ run_id: Unique identifier for this run
+ task_results: List of individual task results
+ total_tasks: Total number of tasks in the benchmark
+ success_count: Number of successful tasks
+ failed_count: Number of failed tasks
+ avg_reward: Average reward across all tasks
+ duration_seconds: Total duration of the benchmark
+ output_dir: Output directory for results (if any)
+
+### Constructor
+
+```python
+BenchmarkResult(self, run_id: str, task_results: List[Dict[str, Any]], total_tasks: int, success_count: int, failed_count: int, avg_reward: float, duration_seconds: float, output_dir: Optional[str] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `run_id` | `str` | |
+| `task_results` | `List[Dict[str, Any]]` | |
+| `total_tasks` | `int` | |
+| `success_count` | `int` | |
+| `failed_count` | `int` | |
+| `avg_reward` | `float` | |
+| `duration_seconds` | `float` | |
+| `output_dir` | `Optional[str]` | |
+
+---
+
+## TaskResult
+
+Result of a single task execution.
+
+Attributes:
+ task_path: Path to the task
+ variant_id: Task variant index
+ success: Whether the task succeeded
+ reward: Reward from evaluation
+ steps: Number of steps taken
+ error: Error message if failed
+
+### Constructor
+
+```python
+TaskResult(self, task_path: str, variant_id: int, success: bool, reward: float, steps: int, error: Optional[str] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `task_path` | `str` | |
+| `variant_id` | `int` | |
+| `success` | `bool` | |
+| `reward` | `float` | |
+| `steps` | `int` | |
+| `error` | `Optional[str]` | |
+
+### make
+
+```python
+def make(env_name: str, split: str = 'train') -> Any
+```
+
+Create an Environment by loading the env's main.py as a module.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Path to the environment directory (must contain main.py) |
+| `split` | `Any` | Dataset split to use for decorated functions (e.g., 'train', 'test') |
+
+**Returns:** Environment instance
+
+### run_single_task
+
+```python
+async def run_single_task(env_path: Path, task_index: int = 0, split: str = 'train', agent_fn: Optional[Callable[[bytes, Task], Action]] = None, max_steps: int = 100, oracle: bool = False) -> TaskResult
+```
+
+Run a single task using the gym interface.
+
+This function uses the core gym interface (make, reset, step, evaluate)
+to run a task with either an agent function or the oracle solver.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the task environment directory |
+| `task_index` | `Any` | Task variant index (default: 0) |
+| `split` | `Any` | Dataset split (default: "train") |
+| `agent_fn` | `Any` | Optional agent function that takes (screenshot, task_config) and returns an Action. If None and oracle=False, returns after setup. |
+| `max_steps` | `Any` | Maximum steps per task (default: 100) |
+| `oracle` | `Any` | Run oracle/solver mode (default: False) |
+
+**Returns:** TaskResult with execution results
+
+**Example:**
+
+```python
+# Run with oracle
+result = await run_single_task(Path("./task"), oracle=True)
+
+# Run with custom agent
+def my_agent(screenshot: bytes, task: Task) -> Action:
+ return DoneAction() # Simple agent that immediately finishes
+
+result = await run_single_task(Path("./task"), agent_fn=my_agent)
+```
+
+### run_benchmark
+
+```python
+async def run_benchmark(dataset_path: Path, agent_fn: Optional[Callable[[bytes, Task], Action]] = None, max_steps: int = 100, max_parallel: int = 4, oracle: bool = False, max_variants: Optional[int] = None, task_filter: Optional[str] = None, split: str = 'train') -> BenchmarkResult
+```
+
+Run a benchmark on a dataset using the gym interface.
+
+This function runs multiple tasks in parallel using the core gym interface
+(make, reset, step, evaluate).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `dataset_path` | `Any` | Path to the dataset directory |
+| `agent_fn` | `Any` | Optional agent function that takes (screenshot, task_config) and returns an Action. Required if oracle=False. |
+| `max_steps` | `Any` | Maximum steps per task (default: 100) |
+| `max_parallel` | `Any` | Maximum parallel workers (default: 4) |
+| `oracle` | `Any` | Run oracle/solver mode (default: False) |
+| `max_variants` | `Any` | Maximum variants per task (optional) |
+| `task_filter` | `Any` | Glob pattern to filter tasks (optional) |
+| `split` | `Any` | Dataset split (default: "train") |
+
+**Returns:** BenchmarkResult with run statistics and task results
+
+**Example:**
+
+```python
+# Run oracle benchmark
+result = await run_benchmark(
+ Path("./datasets/cua-bench-basic"),
+ oracle=True,
+ max_parallel=8,
+)
+print(f"Success rate: {result.success_count / result.total_tasks:.2%}")
+
+# Run with custom agent
+def random_agent(screenshot: bytes, task: Task) -> Action:
+ import random
+ return random.choice([
+ ClickAction(x=random.randint(0, 1920), y=random.randint(0, 1080)),
+ DoneAction(),
+ ])
+
+result = await run_benchmark(
+ Path("./datasets/my-dataset"),
+ agent_fn=random_agent,
+ max_parallel=4,
+)
+```
+
+### run_interactive
+
+```python
+async def run_interactive(env_path: Path, task_index: int = 0, split: str = 'train', headless: bool = False) -> Tuple[Environment, bytes, Task]
+```
+
+Run an environment interactively using the gym interface.
+
+This function sets up an environment for interactive use, returning
+the environment instance, initial screenshot, and task configuration.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the environment directory |
+| `task_index` | `Any` | Task variant index (default: 0) |
+| `split` | `Any` | Dataset split (default: "train") |
+| `headless` | `Any` | Run in headless mode (default: False) |
+
+**Returns:** Tuple of (env, screenshot, task_config) - env: Environment instance (caller should call env.close() when done) - screenshot: Initial screenshot bytes - task_config: Task configuration
+
+**Example:**
+
+```python
+env, screenshot, task_cfg = await run_interactive(Path("./task"))
+print(f"Task: {task_cfg.description}")
+
+# Execute actions...
+screenshot = await env.step(ClickAction(x=100, y=200))
+
+# Evaluate
+reward = await env.evaluate()
+print(f"Reward: {reward}")
+
+# Cleanup
+await env.close()
+```
+
+---
+
+## environment
+
+Simplified, provider-driven environment.
+
+---
+
+## Bot
+
+Helper class for writing trajectories for task solutions.
+
+### Constructor
+
+```python
+Bot(self, env: Any)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+
+### Methods
+
+#### Bot.click_element
+
+```python
+def click_element(self, pid: int, selector: str) -> None
+```
+
+Find element by CSS selector and click its center.
+
+Uses provider's bench-ui bridge to fetch element rect in screen space
+and then dispatches a ClickAction via env.step().
+
+#### Bot.right_click_element
+
+```python
+def right_click_element(self, pid: int, selector: str) -> None
+```
+
+---
+
+## Tracing
+
+Lightweight trajectory tracing using Hugging Face Datasets.
+
+Records events with arbitrary JSON metadata and a list of PIL images.
+Exposes a datasets.Dataset-compatible interface for saving/pushing.
+
+### Constructor
+
+```python
+Tracing(self, env: Any) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+| `trajectory_id` | `Optional[str]` | |
+| `dataset` | `Dataset` | Return a HF Dataset built from current rows, constructing lazily. |
+
+### Methods
+
+#### Tracing.start
+
+```python
+def start(self, trajectory_id: Optional[str] = None) -> str
+```
+
+Start a new trajectory. Resets any previously recorded rows.
+
+Returns the trajectory_id used.
+
+#### Tracing.record
+
+```python
+def record(self, event_name: str, data_dict: Dict[str, Any], data_images: List[Image.Image | bytes] | None = None) -> None
+```
+
+#### Tracing.save_to_disk
+
+```python
+def save_to_disk(self, output_dir: str, save_pngs: bool = False, image_dir: Optional[str] = None, filter_events: Optional[List[str]] = None) -> None
+```
+
+#### Tracing.push_to_hub
+
+```python
+def push_to_hub(self, repo_id: str, private: bool | None = None) -> str
+```
+
+#### Tracing.bytes_to_image
+
+```python
+def bytes_to_image(png_bytes: bytes) -> Image.Image
+```
+
+---
+
+## MaxStepsExceeded
+
+*Inherits from: Exception*
+
+Raised when the environment's max step budget is exhausted.
+
+---
+
+## Environment
+
+A minimal environment wrapper that delegates everything to a provider.
+
+Functions can be injected directly, or discovered from a module via
+`make_from_module` based on cua-bench decorators (`_td_type`, `_td_split`).
+
+### Constructor
+
+```python
+Environment(self, env_name: Optional[str] = None, split: str = 'train', tasks_config_fn: Optional[Callable[..., Any]] = None, setup_task_fn: Optional[Callable[..., Any]] = None, solve_task_fn: Optional[Callable[..., Any]] = None, evaluate_task_fn: Optional[Callable[..., Any]] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Optional[Any]` | |
+| `env_name` | `Optional[str]` | |
+| `split` | `Optional[str]` | |
+| `headless` | `bool` | |
+| `print_actions` | `bool` | |
+| `bot` | `Optional[Bot]` | |
+| `tracing` | `Optional[Tracing]` | |
+| `step_count` | `int` | |
+| `max_steps` | `Optional[int]` | |
+| `tasks_config_fn` | `Any` | |
+| `setup_task_fn` | `Any` | |
+| `solve_task_fn` | `Any` | |
+| `evaluate_task_fn` | `Any` | |
+| `tasks` | `Optional[list]` | |
+| `current_task` | `Optional[Any]` | |
+| `session_name` | `Optional[str]` | |
+| `session_config` | `Dict[str, Any]` | |
+| `setup_config` | `DesktopSetupConfig` | |
+| `page` | `Optional[Any]` | |
+
+### Methods
+
+#### Environment.make_from_module
+
+```python
+def make_from_module(cls, module: Any, env_path: str | Path, split: str = 'train') -> 'Environment'
+```
+
+#### Environment.create_sandbox
+
+```python
+async def create_sandbox(self, provider: str, provider_config: Dict[str, Any] | None = None, setup_config: DesktopSetupConfig | None = None) -> None
+```
+
+#### Environment.reset
+
+```python
+async def reset(self, task_id: Optional[int] = None, run_id: Optional[str] = None) -> Tuple[bytes, Dict]
+```
+
+#### Environment.step
+
+```python
+async def step(self, action: Action, dry_run: bool | Literal['before', 'after'] = False) -> bytes
+```
+
+#### Environment.solve
+
+```python
+async def solve(self) -> bytes
+```
+
+#### Environment.evaluate
+
+```python
+async def evaluate(self) -> Any
+```
+
+#### Environment.close
+
+```python
+async def close(self) -> None
+```
+
+---
+
+## iconify
+
+Iconify icon processing module for cua_bench.
+
+This module provides functionality to process HTML containing iconify-icon elements
+and replace them with inline SVG content fetched from the Iconify API.
+
+Key features:
+- Processes &lt;iconify-icon icon="prefix:name"> elements
+- Supports custom icons.json for icon resolution
+- Option to ignore icon set prefixes for randomization
+- Caches SVG content for performance
+- Preserves element attributes (width, height, class, etc.)
+
+### process_icons
+
+```python
+def process_icons(html: str, icons_json: Optional[str] = None, ignore_iconset: bool = False) -> str
+```
+
+Process HTML containing iconify-icon elements and replace them with inline SVGs.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `html` | `Any` | HTML content containing iconify-icon elements |
+| `icons_json` | `Any` | Path to custom icons.json file. If None, uses default iconsets/icons.json |
+| `ignore_iconset` | `Any` | If True, ignores the iconset prefix and searches for icon name only. Useful for shuffling/randomizing icon sets. For example: - eva:people-outline becomes */people-outline - mingcute:ad-circle-line becomes */ad-circle-line |
+
+**Returns:** HTML with iconify-icon elements replaced by inline SVG content
+
+**Example:**
+
+```python
+>>> html = '<iconify-icon icon="eva:people-outline"></iconify-icon>'
+>>> process_icons(html)
+'<svg>...</svg>'
+
+>>> # With ignore_iconset=True for randomization
+>>> process_icons(html, ignore_iconset=True) # May use different iconset
+```
+
+### clear_cache
+
+```python
+def clear_cache()
+```
+
+Clear the SVG cache. Useful for testing or memory management.
+
+### get_cache_size
+
+```python
+def get_cache_size() -> int
+```
+
+Get the number of cached SVG entries.
+
+---
+
+## main
+
+Main entry point for cua-bench CLI.
+
+### main
+
+```python
+def main()
+```
+
+Main CLI entry point.
+
+---
+
+## desktop
+
+Desktop environment management for cua-bench.
+
+---
+
+## Window
+
+Represents a window in the desktop environment.
+
+### Constructor
+
+```python
+Window(self, x: int, y: int, width: int, height: int, title: str, content: str, focused: bool = False, icon: Optional[str] = None, title_bar_style: str = 'hidden') -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `x` | `int` | |
+| `y` | `int` | |
+| `width` | `int` | |
+| `height` | `int` | |
+| `title` | `str` | |
+| `content` | `str` | |
+| `focused` | `bool` | |
+| `icon` | `Optional[str]` | |
+| `title_bar_style` | `str` | |
+
+---
+
+## DesktopState
+
+State of the unified desktop environment.
+
+### Constructor
+
+```python
+DesktopState(self, os_type: str = 'win11', width: int = 1024, height: int = 768, background: str = '#000', windows: List[Window] = list(), dock_state: Dict[str, List[Dict[str, str]]] = (lambda: {'pinned_apps': [], 'recent_apps': [], 'pinned_folders': []})(), taskbar_state: Dict[str, List[Dict[str, str]]] = (lambda: {'pinned_apps': [], 'open_apps': []})()) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os_type` | `str` | |
+| `width` | `int` | |
+| `height` | `int` | |
+| `background` | `str` | |
+| `windows` | `List[Window]` | |
+| `dock_state` | `Dict[str, List[Dict[str, str]]]` | |
+| `taskbar_state` | `Dict[str, List[Dict[str, str]]]` | |
+
+---
+
+## Desktop
+
+Desktop environment manager.
+
+### Constructor
+
+```python
+Desktop(self, env)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env` | `Any` | |
+| `state` | `Any` | |
+| `template` | `Any` | |
+
+### Methods
+
+#### Desktop.configure
+
+```python
+def configure(self, os_type: Optional[str] = None, width: Optional[int] = None, height: Optional[int] = None, background: Optional[str] = None, dock_state: Optional[Dict[str, List[Union[str, Dict[str, str]]]]] = None, randomize_dock: bool = True, taskbar_state: Optional[Dict[str, List[Union[str, Dict[str, str]]]]] = None, randomize_taskbar: bool = True)
+```
+
+Configure desktop appearance.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os_type` | `Any` | OS appearance (win11, win10, win7, macos, winxp, win98, android, ios) |
+| `width` | `Any` | Screen width in pixels |
+| `height` | `Any` | Screen height in pixels |
+| `background` | `Any` | Background color |
+| `dock_state` | `Any` | Explicit dock state to set with keys 'pinned_apps', 'recent_apps', 'pinned_folders' |
+| `randomize_dock` | `Any` | If True, populate dock_state using macOS icon sets |
+| `taskbar_state` | `Any` | Explicit taskbar state to set with keys 'pinned_apps', 'open_apps' |
+| `randomize_taskbar` | `Any` | If True, populate taskbar_state using Windows 11 icon sets |
+
+#### Desktop.launch
+
+```python
+def launch(self, content: str, title: str = 'Window', x: Optional[int] = None, y: Optional[int] = None, width: int = 600, height: int = 400, icon: Optional[str] = None, use_inner_size: bool = False, title_bar_style: str = 'default') -> Window
+```
+
+Launch a new window on the desktop.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `content` | `Any` | HTML content for the window body |
+| `title` | `Any` | Window title |
+| `x` | `Any` | X position (auto-calculated if None) |
+| `y` | `Any` | Y position (auto-calculated if None) |
+| `width` | `Any` | Window width |
+| `height` | `Any` | Window height |
+| `use_inner_size` | `Any` | Whether to use the inner size of the window (i.e. content size) |
+
+**Returns:** Window instance
+
+---
+
+## decorators
+
+Decorators for defining cua-bench environments.
+
+### tasks_config
+
+```python
+def tasks_config(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that loads tasks.
+
+Can be used as ``@cb.tasks_config`` or ``@cb.tasks_config("train")``.
+The decorated function should return a list of Task objects.
+
+### setup_task
+
+```python
+def setup_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that sets up a task.
+
+Can be used as ``@cb.setup_task`` or ``@cb.setup_task("train")``.
+The decorated function receives task_cfg and should initialize the environment.
+
+### solve_task
+
+```python
+def solve_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that solves a task.
+
+Can be used as ``@cb.solve_task`` or ``@cb.solve_task("train")``.
+The decorated function receives task_cfg and should execute the solution.
+
+### evaluate_task
+
+```python
+def evaluate_task(_arg: Optional[Callable] = None, args = (), kwargs = {}) -> Callable
+```
+
+Decorator for the function that evaluates a task.
+
+Can be used as ``@cb.evaluate_task`` or ``@cb.evaluate_task("train")``.
+The decorated function receives task_cfg and should return evaluation results.
+
+---
+
+## computers
+
+---
+
+## DesktopSession
+
+*Inherits from: Protocol*
+
+Desktop session interface for environment backends.
+
+Usage:
+ # Preferred: async context manager
+ async with get_session("native")(os_type="linux") as session:
+ await session.screenshot()
+
+ # Alternative: manual lifecycle
+ session = get_session("native")(os_type="linux")
+ await session.start()
+ try:
+ await session.screenshot()
+ finally:
+ await session.close()
+
+### Constructor
+
+```python
+DesktopSession(self, env: Any)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `page` | `Any` | |
+| `vnc_url` | `str` | Return the VNC URL for accessing the desktop environment. |
+| `apps` | `'AppsProxy'` | Access registered apps via session.apps.\{app_name\}. |
+
+### Methods
+
+#### DesktopSession.start
+
+```python
+async def start(self, config: Optional[DesktopSetupConfig] = None, headless: Optional[bool] = None) -> None
+```
+
+Start the session and connect to the environment.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `config` | `Any` | Optional configuration to apply before starting. |
+| `headless` | `Any` | If False, shows browser/VNC preview. Defaults to True. |
+
+#### DesktopSession.serve_static
+
+```python
+async def serve_static(self, url_path: str, local_path: str) -> None
+```
+
+#### DesktopSession.launch_window
+
+```python
+async def launch_window(self, url: Optional[str] = None, html: Optional[str] = None, folder: Optional[str] = None, title: str = 'Window', x: Optional[int] = None, y: Optional[int] = None, width: int = 600, height: int = 400, icon: Optional[str] = None, use_inner_size: bool = False, title_bar_style: str = 'default') -> int | str
+```
+
+Launch a window and return its process ID.
+
+#### DesktopSession.get_element_rect
+
+```python
+async def get_element_rect(self, pid: int | str, selector: str, space: Literal['window', 'screen'] = 'window', timeout: float = 0.5) -> dict[str, Any] | None
+```
+
+#### DesktopSession.execute_javascript
+
+```python
+async def execute_javascript(self, pid: int | str, javascript: str) -> Any
+```
+
+#### DesktopSession.execute_action
+
+```python
+async def execute_action(self, action: Any) -> None
+```
+
+#### DesktopSession.screenshot
+
+```python
+async def screenshot(self) -> bytes
+```
+
+#### DesktopSession.get_snapshot
+
+```python
+async def get_snapshot(self) -> Snapshot
+```
+
+Return a lightweight snapshot of the desktop state (windows, etc.).
+
+Implementations should populate the list of open windows with geometry
+and metadata. If not supported, raise NotImplementedError.
+
+#### DesktopSession.close
+
+```python
+async def close(self) -> None
+```
+
+#### DesktopSession.close_all_windows
+
+```python
+async def close_all_windows(self) -> None
+```
+
+Close or clear all open windows in the desktop environment.
+
+#### DesktopSession.click_element
+
+```python
+async def click_element(self, pid: int | str, selector: str) -> None
+```
+
+Find element by CSS selector and click its center.
+
+Uses the session's get_element_rect to fetch element rect in screen space
+and then dispatches a ClickAction.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `pid` | `Any` | Process ID of the window |
+| `selector` | `Any` | CSS selector for the element |
+
+#### DesktopSession.right_click_element
+
+```python
+async def right_click_element(self, pid: int | str, selector: str) -> None
+```
+
+Find element by CSS selector and right-click its center.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `pid` | `Any` | Process ID of the window |
+| `selector` | `Any` | CSS selector for the element |
+
+#### DesktopSession.run_command
+
+```python
+async def run_command(self, command: str, timeout: Optional[float] = None, check: bool = True) -> 'CommandResult'
+```
+
+Execute a shell command on the native desktop environment.
+
+This method is only available with the native provider (Docker/QEMU).
+It will raise NotImplementedError on simulated sessions.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `Any` | Shell command to execute |
+| `timeout` | `Any` | Optional timeout in seconds |
+| `check` | `Any` | If True (default), raise an exception if the command fails (non-zero return code). If False, return the result regardless. |
+
+**Returns:** CommandResult with stdout, stderr, and return_code
+
+**Raises:**
+
+- `NotImplementedError` - If called on simulated provider
+- `RuntimeError` - If check=True and command returns non-zero exit code
+
+**Example:**
+
+```python
+result = await session.run_command("ls -la /home/user")
+print(result.stdout)
+```
+
+#### DesktopSession.install_app
+
+```python
+async def install_app(self, app_name: str, with_shortcut: bool = True, kwargs = {}) -> None
+```
+
+Install a registered app on the native desktop environment.
+
+Uses the app registry to find platform-specific install functions.
+This method is only available with the native provider (Docker/QEMU).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `app_name` | `Any` | Name of the app to install (e.g., "godot", "firefox") |
+| `with_shortcut` | `Any` | Create desktop shortcut (default True) **kwargs: App-specific arguments (e.g., version="4.2.1") |
+
+**Raises:**
+
+- `ValueError` - If app is not registered
+- `NotImplementedError` - If app doesn't support the current platform
+
+**Example:**
+
+```python
+await session.install_app("godot", version="4.2.1")
+await session.install_app("firefox", with_shortcut=True)
+```
+
+#### DesktopSession.launch_app
+
+```python
+async def launch_app(self, app_name: str, kwargs = {}) -> None
+```
+
+Launch a registered app on the native desktop environment.
+
+Uses the app registry to find platform-specific launch functions.
+This method is only available with the native provider (Docker/QEMU).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `app_name` | `Any` | Name of the app to launch **kwargs: App-specific arguments (e.g., project_path="/path") |
+
+**Raises:**
+
+- `ValueError` - If app is not registered
+- `NotImplementedError` - If app doesn't support the current platform
+
+**Example:**
+
+```python
+await session.launch_app("godot", project_path="~/project", editor=True)
+```
+
+---
+
+## DesktopSetupConfig
+
+*Inherits from: TypedDict*
+
+Configuration for desktop setup provided to providers.
+
+Fields mirror high-level desktop appearance and workspace options.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `os_type` | `Literal['win11', 'win10', 'win7', 'winxp', 'win98', 'macos', 'linux', 'android', 'ios', 'windows']` | |
+| `width` | `int` | |
+| `height` | `int` | |
+| `background` | `str` | |
+| `wallpaper` | `str` | |
+| `installed_apps` | `List[str]` | |
+| `image` | `str` | |
+| `storage` | `str` | |
+| `memory` | `str` | |
+| `cpu` | `str` | |
+| `provider_type` | `str` | |
+
+---
+
+## RemoteDesktopSession
+
+Unified desktop session using cua-computer SDK.
+
+Supports two modes:
+1. **Full lifecycle mode** (default): Computer SDK manages container/VM
+ - Pass config via constructor kwargs or start(config=\{...\})
+ - SDK starts container, waits for boot, connects
+
+2. **Client-only mode**: Connect to pre-existing cua-computer-server
+ - Pass api_url to connect to existing server
+ - Used by 2-container architecture, batch execution
+
+Works with any golden environment type:
+- linux-docker: trycua/cua-xfce container
+- windows-qemu: Windows 11 VM
+- linux-qemu: Linux VM
+- android-qemu: Android VM
+
+Supports full bench_ui integration when bench_ui is installed in the
+remote environment, enabling:
+- launch_window() with HTML content via pywebview
+- execute_javascript() for DOM manipulation
+- get_element_rect() for element location queries
+- click_element() / right_click_element() for element-based interaction
+
+### Constructor
+
+```python
+RemoteDesktopSession(self, api_url: str = '', vnc_url: str = '', width: int = 1920, height: int = 1080, os_type: str = 'linux', image: str = '', provider_type: str = 'docker', memory: str = '8GB', cpu: str = '4', name: str = '', storage: str = '', ephemeral: bool = True, headless: bool = True, kwargs = {})
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `DEFAULT_TIMEOUT` | `Any` | |
+| `SCREENSHOT_TIMEOUT` | `Any` | |
+| `computer` | `Any` | Get the Computer SDK instance for advanced operations. |
+| `interface` | `Any` | Get the computer interface for direct SDK access. |
+| `page` | `Any` | Return underlying page object - not applicable for remote. |
+| `vnc_url` | `str` | Return the VNC URL for accessing the environment. |
+| `apps` | `'AppsProxy'` | Access registered apps via session.apps.\{app_name\}. |
+| `os_type` | `str` | Return the OS type for this session. |
+
+### Methods
+
+#### RemoteDesktopSession.step
+
+```python
+async def step(self, action: Action) -> None
+```
+
+Execute an action (alias for execute_action, for env.step() compatibility).
+
+#### RemoteDesktopSession.start
+
+```python
+async def start(self, config: Optional[DesktopSetupConfig] = None, headless: Optional[bool] = None) -> None
+```
+
+Start the session and connect to the environment.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `config` | `Any` | Optional configuration to apply before starting. |
+| `headless` | `Any` | If False, opens VNC preview in browser. Defaults to constructor value if not specified. |
+
+**Example:**
+
+```python
+# Using constructor params (preferred)
+async with RemoteDesktopSession(os_type="linux") as session:
+ await session.screenshot()
+
+# Or with config dict
+session = RemoteDesktopSession()
+await session.start(config={"os_type": "linux", "width": 1920})
+```
+
+#### RemoteDesktopSession.serve_static
+
+```python
+async def serve_static(self, url_path: str, local_path: str) -> None
+```
+
+Serve static files - not applicable for remote environments.
+
+#### RemoteDesktopSession.launch_window
+
+```python
+async def launch_window(self, url: Optional[str] = None, html: Optional[str] = None, folder: Optional[str] = None, title: str = 'Window', x: Optional[int] = None, y: Optional[int] = None, width: int = 600, height: int = 400, icon: Optional[str] = None, use_inner_size: bool = False, title_bar_style: str = 'default') -> int | str
+```
+
+Launch a window in the remote environment using bench_ui (pywebview).
+
+Supports:
+- url: Open a URL in a pywebview window
+- html: Display HTML content in a pywebview window
+- folder: Copy folder to remote and serve it in a pywebview window
+
+**Returns:** Process ID of the pywebview window (int)
+
+#### RemoteDesktopSession.get_element_rect
+
+```python
+async def get_element_rect(self, pid: int | str, selector: str, space: Literal['window', 'screen'] = 'window', timeout: float = 0.5) -> dict[str, Any] | None
+```
+
+Get element rect by CSS selector using bench_ui.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `pid` | `Any` | Process ID of the pywebview window |
+| `selector` | `Any` | CSS selector for the element |
+| `space` | `Any` | Coordinate space - "window" or "screen" |
+| `timeout` | `Any` | Maximum time to wait for element |
+
+**Returns:** Dict with x, y, width, height or None if not found
+
+#### RemoteDesktopSession.execute_javascript
+
+```python
+async def execute_javascript(self, pid: int | str, javascript: str) -> Any
+```
+
+Execute JavaScript in a pywebview window using bench_ui.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `pid` | `Any` | Process ID of the pywebview window |
+| `javascript` | `Any` | JavaScript code to execute |
+
+**Returns:** Result of the JavaScript execution
+
+#### RemoteDesktopSession.execute_action
+
+```python
+async def execute_action(self, action: Action) -> None
+```
+
+Execute an action on the remote desktop using the SDK.
+
+#### RemoteDesktopSession.screenshot
+
+```python
+async def screenshot(self) -> bytes
+```
+
+Capture screenshot from remote environment.
+
+**Returns:** PNG image bytes
+
+#### RemoteDesktopSession.get_snapshot
+
+```python
+async def get_snapshot(self) -> Snapshot
+```
+
+Get snapshot of desktop state with active window info.
+
+Uses pywinctl on remote to get active window, and if it's a webview
+we launched, extracts HTML via snapshot.js.
+
+#### RemoteDesktopSession.close
+
+```python
+async def close(self) -> None
+```
+
+Close the session and cleanup resources.
+
+#### RemoteDesktopSession.close_all_windows
+
+```python
+async def close_all_windows(self) -> None
+```
+
+Close all windows - best effort.
+
+#### RemoteDesktopSession.click_element
+
+```python
+async def click_element(self, pid: int | str, selector: str) -> None
+```
+
+Find element by CSS selector and click its center.
+
+Uses get_element_rect to fetch element rect in screen space
+and then dispatches a ClickAction.
+
+#### RemoteDesktopSession.right_click_element
+
+```python
+async def right_click_element(self, pid: int | str, selector: str) -> None
+```
+
+Find element by CSS selector and right-click its center.
+
+#### RemoteDesktopSession.get_accessibility_tree
+
+```python
+async def get_accessibility_tree(self) -> Dict[str, Any]
+```
+
+Get the accessibility tree if supported.
+
+#### RemoteDesktopSession.shell_command
+
+```python
+async def shell_command(self, command: str, check: bool = True) -> Dict[str, Any]
+```
+
+Execute a shell command.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `Any` | Shell command to execute |
+| `check` | `Any` | If True (default), raise an exception if the command fails (non-zero return code). If False, return the result regardless. |
+
+**Returns:** Command result with stdout/stderr
+
+**Raises:**
+
+- `RuntimeError` - If check=True and command returns non-zero exit code
+
+#### RemoteDesktopSession.read_file
+
+```python
+async def read_file(self, path: str) -> str
+```
+
+Read a text file from the environment.
+
+#### RemoteDesktopSession.write_file
+
+```python
+async def write_file(self, path: str, content: str) -> None
+```
+
+Write a text file to the environment.
+
+#### RemoteDesktopSession.read_bytes
+
+```python
+async def read_bytes(self, path: str) -> bytes
+```
+
+Read a file as bytes from the environment.
+
+#### RemoteDesktopSession.write_bytes
+
+```python
+async def write_bytes(self, path: str, data: bytes) -> None
+```
+
+Write bytes to a file in the environment.
+
+#### RemoteDesktopSession.file_exists
+
+```python
+async def file_exists(self, path: str) -> bool
+```
+
+Check if a file exists in the environment.
+
+#### RemoteDesktopSession.directory_exists
+
+```python
+async def directory_exists(self, path: str) -> bool
+```
+
+Check if a directory exists in the environment.
+
+#### RemoteDesktopSession.list_dir
+
+```python
+async def list_dir(self, path: str) -> list[str]
+```
+
+List contents of a directory in the environment.
+
+#### RemoteDesktopSession.run_command
+
+```python
+async def run_command(self, command: str, check: bool = True) -> Dict[str, Any]
+```
+
+Execute a shell command (alias for shell_command).
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `Any` | Shell command to execute |
+| `check` | `Any` | If True (default), raise an exception if the command fails (non-zero return code). If False, return the result regardless. |
+
+**Returns:** Command result with stdout/stderr
+
+**Raises:**
+
+- `RuntimeError` - If check=True and command returns non-zero exit code
+
+#### RemoteDesktopSession.launch_application
+
+```python
+async def launch_application(self, app_name: str) -> None
+```
+
+Launch an application by name.
+
+#### RemoteDesktopSession.check_status
+
+```python
+async def check_status(self) -> bool
+```
+
+Check if the environment is responsive.
+
+**Returns:** True if environment is ready, False otherwise
+
+#### RemoteDesktopSession.wait_until_ready
+
+```python
+async def wait_until_ready(self, timeout: int = 60, poll_interval: float = 2.0) -> bool
+```
+
+Wait until the environment is ready.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `timeout` | `Any` | Maximum time to wait in seconds |
+| `poll_interval` | `Any` | Time between status checks |
+
+**Returns:** True if environment became ready, False if timeout
+
+#### RemoteDesktopSession.click
+
+```python
+async def click(self, x: int, y: int) -> None
+```
+
+Click at coordinates.
+
+#### RemoteDesktopSession.right_click
+
+```python
+async def right_click(self, x: int, y: int) -> None
+```
+
+Right-click at coordinates.
+
+#### RemoteDesktopSession.double_click
+
+```python
+async def double_click(self, x: int, y: int) -> None
+```
+
+Double-click at coordinates.
+
+#### RemoteDesktopSession.type
+
+```python
+async def type(self, text: str) -> None
+```
+
+Type text.
+
+#### RemoteDesktopSession.key
+
+```python
+async def key(self, key: str) -> None
+```
+
+Press a key.
+
+#### RemoteDesktopSession.hotkey
+
+```python
+async def hotkey(self, keys: list[str]) -> None
+```
+
+Press a key combination.
+
+#### RemoteDesktopSession.scroll
+
+```python
+async def scroll(self, direction: str = 'down', amount: int = 300) -> None
+```
+
+Scroll the screen.
+
+#### RemoteDesktopSession.move_to
+
+```python
+async def move_to(self, x: int, y: int) -> None
+```
+
+Move cursor to coordinates.
+
+#### RemoteDesktopSession.drag
+
+```python
+async def drag(self, from_x: int, from_y: int, to_x: int, to_y: int) -> None
+```
+
+Drag from one position to another.
+
+#### RemoteDesktopSession.install_app
+
+```python
+async def install_app(self, app_name: str, with_shortcut: bool = True, kwargs = {}) -> None
+```
+
+Install a registered app on the native desktop environment.
+
+Uses the app registry to find platform-specific install functions.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `app_name` | `Any` | Name of the app to install (e.g., "godot", "firefox") |
+| `with_shortcut` | `Any` | Create desktop shortcut (default True) **kwargs: App-specific arguments (e.g., version="4.2.1") |
+
+**Raises:**
+
+- `ValueError` - If app is not registered
+- `NotImplementedError` - If app doesn't support the current platform
+
+**Example:**
+
+```python
+await session.install_app("godot", version="4.2.1")
+await session.install_app("firefox", with_shortcut=True)
+```
+
+#### RemoteDesktopSession.launch_app
+
+```python
+async def launch_app(self, app_name: str, kwargs = {}) -> None
+```
+
+Launch a registered app on the native desktop environment.
+
+Uses the app registry to find platform-specific launch functions.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `app_name` | `Any` | Name of the app to launch **kwargs: App-specific arguments (e.g., project_path="/path") |
+
+**Raises:**
+
+- `ValueError` - If app is not registered
+- `NotImplementedError` - If app doesn't support the current platform
+
+**Example:**
+
+```python
+await session.launch_app("godot", project_path="~/project", editor=True)
+```
+
+### get_session
+
+```python
+def get_session(name: Optional[str] = None) -> type[DesktopSession]
+```
+
+Return session class by name.
+
+Provider names:
+ - "simulated" (alias: "webtop"): Playwright-based browser simulation
+ Fast, no Docker required. UI is HTML/CSS rendering of desktop.
+ Good for web-app testing, UI benchmarks.
+
+ - "native" (alias: "computer"): Real OS in Docker/QEMU container
+ Actual desktop environment with real applications.
+ Requires Docker. Good for real app testing, OS-level tasks.
+
+### create_remote_session
+
+```python
+def create_remote_session(api_url: str, vnc_url: str = '', os_type: str = 'linux', width: int = 1920, height: int = 1080) -> RemoteDesktopSession
+```
+
+Create a RemoteDesktopSession.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `api_url` | `Any` | URL of the environment's API endpoint |
+| `vnc_url` | `Any` | URL for VNC access |
+| `os_type` | `Any` | Operating system type |
+| `width` | `Any` | Screen width |
+| `height` | `Any` | Screen height |
+
+**Returns:** Configured RemoteDesktopSession instance
+
+---
+
+## config
+
+Configuration module for cua-bench.
+
+---
+
+## ConfigLoader
+
+Load and merge configuration from .cua/ directory.
+
+### Constructor
+
+```python
+ConfigLoader(self, search_path: Path | None = None)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `CONFIG_DIR_NAME` | `Any` | |
+| `CONFIG_FILE_NAME` | `Any` | |
+| `AGENTS_FILE_NAME` | `Any` | |
+| `search_path` | `Any` | |
+
+### Methods
+
+#### ConfigLoader.find_config_dir
+
+```python
+def find_config_dir(self) -> Path | None
+```
+
+Walk up directory tree to find .cua/ directory.
+
+**Returns:** Path to .cua/ directory if found, None otherwise.
+
+#### ConfigLoader.load_config
+
+```python
+def load_config(self) -> CuaConfig | None
+```
+
+Load .cua/config.yaml if it exists.
+
+**Returns:** CuaConfig object if config file exists, None otherwise.
+
+#### ConfigLoader.load_agents
+
+```python
+def load_agents(self) -> list[CustomAgentEntry]
+```
+
+Load .cua/agents.yaml if it exists.
+
+**Returns:** List of CustomAgentEntry objects.
+
+#### ConfigLoader.get_agent_by_name
+
+```python
+def get_agent_by_name(self, name: str) -> CustomAgentEntry | None
+```
+
+Get a custom agent entry by name.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Agent name to look up. |
+
+**Returns:** CustomAgentEntry if found, None otherwise.
+
+#### ConfigLoader.get_effective_config
+
+```python
+def get_effective_config(self, cli_args: dict[str, Any], env_type: str | None = None) -> dict[str, Any]
+```
+
+Merge configuration sources into effective config.
+
+Priority (highest to lowest):
+1. CLI arguments
+2. Environment-specific overrides
+3. Agent defaults from agents.yaml
+4. Agent config from config.yaml
+5. Defaults from config.yaml
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `cli_args` | `Any` | Command line arguments as dictionary. |
+| `env_type` | `Any` | Environment type for env-specific overrides (e.g., "webtop", "winarena"). |
+
+**Returns:** Merged configuration dictionary.
+
+---
+
+## AgentConfig
+
+Agent configuration from .cua/config.yaml.
+
+### Constructor
+
+```python
+AgentConfig(self, name: str | None = None, import_path: str | None = None, model: str | None = None, max_steps: int = 100, environments: dict[str, dict[str, Any]] | None = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `str | None` | |
+| `import_path` | `str | None` | |
+| `model` | `str | None` | |
+| `max_steps` | `int` | |
+| `environments` | `dict[str, dict[str, Any]] | None` | |
+
+### Methods
+
+#### AgentConfig.from_dict
+
+```python
+def from_dict(cls, data: dict[str, Any]) -> AgentConfig
+```
+
+Create AgentConfig from dictionary.
+
+---
+
+## AgentsConfig
+
+Configuration from .cua/agents.yaml.
+
+Supports two formats:
+- Legacy: `custom_agents` list
+- New: `agents` list (preferred)
+
+Example .cua/agents.yaml:
+ agents:
+ - name: my-agent
+ image: myregistry/my-agent:latest
+ defaults:
+ model: gpt-4o
+
+ - name: dev-agent
+ import_path: my_agents.dev:DevAgent
+
+### Constructor
+
+```python
+AgentsConfig(self, custom_agents: list[CustomAgentEntry] = list()) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `custom_agents` | `list[CustomAgentEntry]` | |
+
+### Methods
+
+#### AgentsConfig.from_dict
+
+```python
+def from_dict(cls, data: dict[str, Any]) -> AgentsConfig
+```
+
+Create AgentsConfig from dictionary.
+
+---
+
+## CuaConfig
+
+Root configuration from .cua/config.yaml.
+
+### Constructor
+
+```python
+CuaConfig(self, defaults: DefaultsConfig | None = None, agent: AgentConfig | None = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `defaults` | `DefaultsConfig | None` | |
+| `agent` | `AgentConfig | None` | |
+
+### Methods
+
+#### CuaConfig.from_dict
+
+```python
+def from_dict(cls, data: dict[str, Any]) -> CuaConfig
+```
+
+Create CuaConfig from dictionary.
+
+---
+
+## CustomAgentEntry
+
+Entry for a custom agent in .cua/agents.yaml.
+
+Agents can be defined in two ways:
+1. Docker image (cloud-ready): Specify `image` field with a Docker image
+2. Import path (local dev): Specify `import_path` for Python import
+
+Examples:
+ # Docker image agent
+ - name: my-agent
+ image: myregistry/my-agent:latest
+
+ # Import path agent (uses default cua-agent image)
+ - name: dev-agent
+ import_path: my_agents.dev:DevAgent
+
+ # Built-in agent
+ - name: cua-agent
+ builtin: true
+
+### Constructor
+
+```python
+CustomAgentEntry(self, name: str, image: Optional[str] = None, import_path: Optional[str] = None, builtin: bool = False, command: Optional[list[str]] = None, defaults: dict[str, Any] = dict()) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `str` | |
+| `image` | `Optional[str]` | |
+| `import_path` | `Optional[str]` | |
+| `builtin` | `bool` | |
+| `command` | `Optional[list[str]]` | |
+| `defaults` | `dict[str, Any]` | |
+
+### Methods
+
+#### CustomAgentEntry.get_image
+
+```python
+def get_image(self) -> str
+```
+
+Get the Docker image to use for this agent.
+
+**Returns:** Docker image name. Uses custom image if specified, otherwise returns the default cua-agent image.
+
+#### CustomAgentEntry.is_docker_agent
+
+```python
+def is_docker_agent(self) -> bool
+```
+
+Check if this agent is defined as a Docker image.
+
+**Returns:** True if agent has a custom Docker image specified.
+
+---
+
+## DefaultsConfig
+
+Default configuration values from .cua/config.yaml.
+
+### Constructor
+
+```python
+DefaultsConfig(self, model: str | None = None, max_steps: int = 100, output_dir: str = './results') -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `model` | `str | None` | |
+| `max_steps` | `int` | |
+| `output_dir` | `str` | |
+
+### Methods
+
+#### DefaultsConfig.from_dict
+
+```python
+def from_dict(cls, data: dict[str, Any]) -> DefaultsConfig
+```
+
+Create DefaultsConfig from dictionary.
+
+### detect_env_type
+
+```python
+def detect_env_type(env_path: str) -> str | None
+```
+
+Detect environment type from path.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to the environment. |
+
+**Returns:** Environment type string ("webtop" or "winarena"), or None if unknown.
+
+---
+
+## runner
+
+Runner module for 2-container task execution.
+
+---
+
+## TaskResult
+
+Result of a task execution.
+
+### Constructor
+
+```python
+TaskResult(self, success: bool, exit_code: int, agent_logs: str, env_logs: str, output_dir: Optional[str] = None, error: Optional[str] = None) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `success` | `bool` | |
+| `exit_code` | `int` | |
+| `agent_logs` | `str` | |
+| `env_logs` | `str` | |
+| `output_dir` | `Optional[str]` | |
+| `error` | `Optional[str]` | |
+
+---
+
+## TaskRunner
+
+Orchestrates 2-container task execution.
+
+Architecture:
+- Creates isolated Docker network per task
+- Creates task overlay to protect golden image (QEMU types)
+- Starts environment container (base image with QCOW2 disk)
+- Starts agent container (runs solver)
+- Agent connects to env via network hostname
+- Waits for agent completion
+- Collects results and cleans up (including overlay)
+
+### Constructor
+
+```python
+TaskRunner(self, agent_image: str = DEFAULT_AGENT_IMAGE, env_hostname: str = 'cua-env', agent_hostname: str = 'cua-agent')
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent_image` | `Any` | |
+| `env_hostname` | `Any` | |
+| `agent_hostname` | `Any` | |
+
+### Methods
+
+#### TaskRunner.run_task
+
+```python
+async def run_task(self, env_path: Path, task_index: int, env_type: str, golden_name: Optional[str] = None, agent: Optional[str] = None, agent_image: Optional[str] = None, agent_command: Optional[List[str]] = None, agent_import_path: Optional[str] = None, model: Optional[str] = None, max_steps: int = 100, oracle: bool = False, memory: str = '8G', cpus: str = '8', vnc_port: Optional[int] = None, api_port: Optional[int] = None, output_dir: Optional[str] = None, stream_agent_logs: bool = False, timeout: Optional[int] = None, cleanup_before: bool = True, remove_images_after: bool = False, provider_type: Optional[str] = None) -> TaskResult
+```
+
+Run a task with 2-container architecture.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to task environment directory |
+| `task_index` | `Any` | Task index to run |
+| `env_type` | `Any` | Environment type (linux-docker, windows-qemu, etc.) |
+| `image_name` | `Any` | Image name to use (defaults to env_type). See: cb image list |
+| `agent` | `Any` | Agent name (for built-in agents) |
+| `agent_image` | `Any` | Docker image for agent container (overrides default) |
+| `agent_command` | `Any` | Custom command for agent container |
+| `agent_import_path` | `Any` | Custom agent import path |
+| `model` | `Any` | Model to use |
+| `max_steps` | `Any` | Maximum agent steps |
+| `oracle` | `Any` | Run oracle solution instead of agent |
+| `memory` | `Any` | Memory for environment (QEMU only) |
+| `cpus` | `Any` | CPUs for environment (QEMU only) |
+| `vnc_port` | `Any` | Host port to map VNC (for debugging) |
+| `api_port` | `Any` | Host port to map API (for debugging) |
+| `output_dir` | `Any` | Output directory for results |
+| `stream_agent_logs` | `Any` | Stream agent logs to &lt;output_dir>/run.log in real-time (default: False) |
+| `timeout` | `Any` | Timeout in seconds (None = no timeout) |
+| `cleanup_before` | `Any` | Clean up stale containers before starting (default: True) |
+| `remove_images_after` | `Any` | Remove Docker images after task (default: False) Note: This removes Docker images but NOT base VM disk images. |
+| `provider_type` | `Any` | Provider type ("simulated", "webtop", "native", "computer", None). If "simulated" or "webtop", the agent container will use a local Playwright session instead of connecting to a remote environment. |
+
+**Returns:** TaskResult with execution details
+
+#### TaskRunner.run_task_interactively
+
+```python
+async def run_task_interactively(self, env_type: str, golden_name: Optional[str] = None, env_path: Optional[Path] = None, task_index: int = 0, memory: str = '8G', cpus: str = '8', vnc_port: Optional[int] = None, api_port: Optional[int] = None, auto_allocate_ports: bool = True, cleanup_before: bool = True) -> tuple[str, str, callable, Optional[dict]]
+```
+
+Start an environment container interactively (without agent).
+
+This method starts only the environment container with VNC and API ports
+exposed to the host, allowing manual interaction or agent connection.
+If env_path is provided, it will also load the task and run the setup.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_type` | `Any` | Environment type (linux-docker, windows-qemu, etc.) |
+| `golden_name` | `Any` | Image name to use (defaults to env_type) |
+| `env_path` | `Any` | Path to task directory (optional, for running task setup) |
+| `task_index` | `Any` | Task index to run (default: 0) |
+| `memory` | `Any` | Memory for environment (QEMU only) |
+| `cpus` | `Any` | CPUs for environment (QEMU only) |
+| `vnc_port` | `Any` | Host port to map VNC (None = auto-allocate) |
+| `api_port` | `Any` | Host port to map API (None = auto-allocate) |
+| `auto_allocate_ports` | `Any` | Auto-allocate ports if not specified (default: True) |
+| `cleanup_before` | `Any` | Clean up stale containers before starting (default: True) |
+
+**Returns:** Tuple of (vnc_url, api_url, cleanup_func, task_config, env, session) - vnc_url: URL to access VNC (e.g., http://localhost:8006) - api_url: URL to access API (e.g., http://localhost:5000) - cleanup_func: Async function to call when done to cleanup resources - task_config: Task configuration dict (None if env_path not provided) - env: Environment object (None if env_path not provided) - session: RemoteDesktopSession object (None if env_path not provided)
+
+**Example:**
+
+```python
+```python
+runner = TaskRunner()
+vnc_url, api_url, cleanup, task_cfg, env, session = await runner.run_task_interactively(
+ "linux-docker",
+ env_path=Path("./my_task"),
+ task_index=0
+)
+print(f"VNC: {vnc_url}")
+print(f"Task: {task_cfg.get('description')}")
+# ... do interactive work ...
+# Evaluate before cleanup
+if env and env.evaluate_task_fn:
+ result = await env.evaluate_task_fn(task_cfg['_task_cfg'], session)
+ print(f"Result: {result}")
+await cleanup()
+```
+```
+
+#### TaskRunner.cleanup_all
+
+```python
+async def cleanup_all(self) -> None
+```
+
+Clean up all running tasks.
+
+#### TaskRunner.force_cleanup
+
+```python
+async def force_cleanup() -> dict
+```
+
+Force cleanup of all stale cua-bench containers and networks.
+
+Use this when containers are left behind from previous runs.
+
+**Returns:** Dict with counts: \{"containers": N, "networks": N\}
+
+---
+
+## agents
+
+---
+
+## AgentResult
+
+Result of agent execution.
+
+### Constructor
+
+```python
+AgentResult(self, total_input_tokens: int = 0, total_output_tokens: int = 0, failure_mode: FailureMode = FailureMode.UNSET) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `total_input_tokens` | `int` | |
+| `total_output_tokens` | `int` | |
+| `failure_mode` | `FailureMode` | |
+
+---
+
+## BaseAgent
+
+*Inherits from: ABC*
+
+Base class for agents that can perform tasks.
+
+### Constructor
+
+```python
+BaseAgent(self, kwargs = {})
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `version` | `str | None` | The version of the agent. Can be any string (e.g. could be |
+| `prompt_template` | `str | None` | The path to a custom prompt template file. If specified, this template |
+
+### Methods
+
+#### BaseAgent.name
+
+```python
+def name() -> str
+```
+
+Return the name of the agent.
+
+#### BaseAgent.perform_task
+
+```python
+async def perform_task(self, task_description: str, session: DesktopSession, logging_dir: Path | None = None, tracer = None) -> AgentResult
+```
+
+Perform a task using the agent.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `task_description` | `Any` | The task description/instruction |
+| `session` | `Any` | The desktop or mobile session to interact with |
+| `logging_dir` | `Any` | Optional directory for logging agent execution |
+| `tracer` | `Any` | Optional tracer object for recording agent actions |
+
+**Returns:** AgentResult with token counts and failure mode
+
+---
+
+## FailureMode
+
+*Inherits from: Enum*
+
+Failure mode for agent execution.
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `UNSET` | `Any` | |
+| `NONE` | `Any` | |
+| `UNKNOWN` | `Any` | |
+| `MAX_STEPS_EXCEEDED` | `Any` | |
+
+---
+
+## CuaAgent
+
+*Inherits from: BaseAgent*
+
+Agent implementation using the CUA Computer Agent SDK.
+
+### Constructor
+
+```python
+CuaAgent(self, kwargs = {})
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `model` | `Any` | |
+| `max_steps` | `Any` | |
+
+### Methods
+
+#### CuaAgent.name
+
+```python
+def name() -> str
+```
+
+#### CuaAgent.perform_task
+
+```python
+async def perform_task(self, task_description: str, session: DesktopSession, logging_dir: Path | None = None, tracer = None) -> AgentResult
+```
+
+Perform a task using the CUA Computer Agent.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `task_description` | `Any` | The task description/instruction |
+| `session` | `Any` | The desktop session to interact with |
+| `logging_dir` | `Any` | Optional directory for logging agent execution |
+| `tracer` | `Any` | Optional tracer object for recording agent actions |
+
+**Returns:** AgentResult with token counts and failure mode
+
+---
+
+## GeminiAgent
+
+*Inherits from: BaseAgent*
+
+Agent implementation using Google's Gemini API with Computer Use.
+
+### Constructor
+
+```python
+GeminiAgent(self, kwargs = {})
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `model` | `Any` | |
+| `api_key` | `Any` | |
+| `thinking_level` | `Any` | |
+| `media_resolution` | `Any` | |
+| `max_steps` | `Any` | |
+
+### Methods
+
+#### GeminiAgent.name
+
+```python
+def name() -> str
+```
+
+#### GeminiAgent.perform_task
+
+```python
+async def perform_task(self, task_description: str, session: DesktopSession, logging_dir: Path | None = None, tracer = None) -> AgentResult
+```
+
+Perform a task using the Gemini Computer Use agent.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `task_description` | `Any` | The task description/instruction |
+| `session` | `Any` | The desktop session to interact with |
+| `logging_dir` | `Any` | Optional directory for logging agent execution |
+| `tracer` | `Any` | Optional tracer object for recording agent actions |
+
+**Returns:** AgentResult with token counts and failure mode
+
+### register_agent
+
+```python
+def register_agent(name: str)
+```
+
+Decorator to register an agent class with a given name.
+
+### load_agent_from_path
+
+```python
+def load_agent_from_path(import_path: str) -> type[BaseAgent]
+```
+
+Load an agent class from an import path.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `import_path` | `Any` | Import path in format 'module.path:ClassName' |
+
+**Returns:** Agent class
+
+**Raises:**
+
+- `ValueError` - If import path format is invalid
+- `ImportError` - If module cannot be imported
+- `AttributeError` - If class is not found in module
+
+### get_agent
+
+```python
+def get_agent(name: str, config_loader: 'ConfigLoader | None' = None) -> type[BaseAgent] | None
+```
+
+Get an agent class by name.
+
+Lookup order:
+1. Local registry (.cua/agents.yaml) - if config_loader provided
+2. Built-in registry (_AGENT_REGISTRY)
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `Any` | Agent name to look up |
+| `config_loader` | `Any` | Optional ConfigLoader for local registry lookup |
+
+**Returns:** Agent class if found, None otherwise
+
+### list_agents
+
+```python
+def list_agents(config_loader: 'ConfigLoader | None' = None) -> list[str]
+```
+
+List all registered agent names.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `config_loader` | `Any` | Optional ConfigLoader to include local agents |
+
+**Returns:** List of agent names (local + built-in, deduplicated)
+
+---
+
+## processors
+
+Snapshot processors for converting batch outputs into various dataset formats.
+
+---
+
+## AgUVisStage1Processor
+
+*Inherits from: BaseProcessor*
+
+Processor for aguvis-stage-1 format (action augmentation dataset).
+
+### Methods
+
+#### AgUVisStage1Processor.get_dataset_name
+
+```python
+def get_dataset_name(self) -> str
+```
+
+#### AgUVisStage1Processor.process
+
+```python
+def process(self) -> List[Dict[str, Any]]
+```
+
+Process snapshots into aguvis-stage-1 format.
+
+---
+
+## BaseProcessor
+
+*Inherits from: ABC*
+
+Base class for snapshot processors.
+
+A processor converts batch dump outputs (screenshots + snapshots)
+into a specific dataset format.
+
+### Constructor
+
+```python
+BaseProcessor(self, args: ProcessorArgs)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `args` | `Any` | |
+
+### Methods
+
+#### BaseProcessor.process
+
+```python
+def process(self) -> List[Dict[str, Any]]
+```
+
+Process the snapshots and return a list of dataset rows.
+
+**Returns:** List of dictionaries, where each dict is a row in the dataset. The schema depends on the specific processor implementation.
+
+#### BaseProcessor.get_dataset_name
+
+```python
+def get_dataset_name(self) -> str
+```
+
+Get the default dataset name for this processor.
+
+#### BaseProcessor.save_jsonl
+
+```python
+def save_jsonl(self, rows: List[Dict[str, Any]], save_dir: Path, dataset_name: str) -> Path
+```
+
+Save dataset rows as JSONL file.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `rows` | `Any` | List of dataset row dictionaries |
+| `save_dir` | `Any` | Directory to save to |
+| `dataset_name` | `Any` | Name of the dataset file (without extension) |
+
+**Returns:** Path to the saved file
+
+#### BaseProcessor.save_to_disk
+
+```python
+def save_to_disk(self, rows: List[Dict[str, Any]], save_dir: Path, dataset_name: str) -> Path
+```
+
+Save dataset rows using HuggingFace's save_to_disk method.
+
+This method properly handles PIL images and other complex data types
+that cannot be serialized to JSON.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `rows` | `Any` | List of dataset row dictionaries |
+| `save_dir` | `Any` | Directory to save to |
+| `dataset_name` | `Any` | Name of the dataset directory |
+
+**Returns:** Path to the saved dataset directory
+
+#### BaseProcessor.push_to_hub
+
+```python
+def push_to_hub(self, rows: List[Dict[str, Any]], repo_id: str, private: bool) -> None
+```
+
+Push dataset to Hugging Face Hub.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `rows` | `Any` | List of dataset row dictionaries |
+| `repo_id` | `Any` | HuggingFace repository ID (e.g., "username/dataset-name") |
+| `private` | `Any` | Whether to make the dataset private |
+
+---
+
+## GuiR1Processor
+
+*Inherits from: BaseProcessor*
+
+Processor for gui-r1 format (low-level click instructions).
+
+### Methods
+
+#### GuiR1Processor.get_dataset_name
+
+```python
+def get_dataset_name(self) -> str
+```
+
+#### GuiR1Processor.process
+
+```python
+def process(self) -> List[Dict[str, Any]]
+```
+
+Process snapshots into gui-r1 format.
+
+### get_processor
+
+```python
+def get_processor(name: str) -> type[BaseProcessor]
+```
+
+Get a processor class by name.
+
+---
+
+## sessions
+
+Sessions module for async container management.
+
+---
+
+## SessionProvider
+
+*Inherits from: ABC*
+
+Base class for session providers (Docker, CUA Cloud, etc.).
+
+### Methods
+
+#### SessionProvider.start_session
+
+```python
+async def start_session(self, session_id: str, env_path: Path, container_script: str, image_uri: Optional[str] = None, output_dir: Optional[str] = None, kwargs = {}) -> Dict[str, Any]
+```
+
+Start a new session.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session_id` | `Any` | Unique identifier for the session |
+| `env_path` | `Any` | Path to the environment directory |
+| `container_script` | `Any` | Script to run in the container |
+| `image_uri` | `Any` | Container image to use |
+| `output_dir` | `Any` | Directory to save outputs **kwargs: Additional provider-specific arguments |
+
+**Returns:** Dict containing session metadata (container_id, status, etc.)
+
+#### SessionProvider.get_session_status
+
+```python
+async def get_session_status(self, session_id: str) -> Dict[str, Any]
+```
+
+Get the status of a running session.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session_id` | `Any` | Session identifier |
+
+**Returns:** Dict containing session status information
+
+#### SessionProvider.stop_session
+
+```python
+async def stop_session(self, session_id: str) -> None
+```
+
+Stop a running session.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session_id` | `Any` | Session identifier |
+
+#### SessionProvider.get_session_logs
+
+```python
+async def get_session_logs(self, session_id: str, tail: Optional[int] = None) -> str
+```
+
+Get logs from a session.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session_id` | `Any` | Session identifier |
+| `tail` | `Any` | Number of lines to return from the end (None for all) |
+
+**Returns:** Log output as string
+
+### list_sessions
+
+```python
+def list_sessions(provider: Optional[str] = None) -> List[Dict[str, Any]]
+```
+
+List all stored sessions.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider` | `Any` | Optional provider filter ("docker", "cua-cloud", etc.) |
+
+**Returns:** List of session metadata dicts
+
+### make
+
+```python
+def make(provider_name: str, env_type: Optional[str] = None) -> SessionProvider
+```
+
+Create a session provider for the specified provider.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `provider_name` | `Any` | Name of the provider: - "local": Run locally using Docker (webtop) or QEMU/KVM (winarena) - "cloud": Run on CUA Cloud (GCP Batch for webtop, Azure Batch for winarena) - "docker": (legacy) Alias for "local" |
+| `env_type` | `Any` | Optional environment type hint ("webtop" or "winarena"). Used by local provider to select appropriate backend. |
+
+**Returns:** SessionProvider instance
+
+**Raises:**
+
+- `ValueError` - If provider is not supported
+
+---
+
+## batch
+
+Batch integration for cua-bench.
+
+### execute_batch
+
+```python
+async def execute_batch(job_name: str, env_path: Path, container_script: str, task_count: int = 4, task_parallelism: int = 4, run_local: bool = False, image_uri: Optional[str] = None, auto_cleanup: bool = True, output_dir: Optional[str] = None) -> List[str]
+```
+
+Execute a batch job for cua-bench environment.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `job_name` | `Any` | Name of the batch job |
+| `env_path` | `Any` | Path to the environment directory |
+| `container_script` | `Any` | Script to run in the container |
+| `task_count` | `Any` | Number of tasks to run |
+| `task_parallelism` | `Any` | Max concurrent tasks |
+| `run_local` | `Any` | Run locally using Docker instead of GCP |
+| `image_uri` | `Any` | Custom container image |
+| `auto_cleanup` | `Any` | Clean up resources after completion |
+
+**Returns:** List of log lines from the job
+
+### run_local_docker
+
+```python
+async def run_local_docker(env_path: Path, container_script: str, image_uri: Optional[str] = None, output_dir: Optional[str] = None, task_count: int = 1, parallelism: int = 1) -> List[str]
+```
+
+Run the batch job locally using Docker.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_path` | `Any` | Path to environment directory |
+| `container_script` | `Any` | Script to run |
+| `image_uri` | `Any` | Docker image to use |
+| `output_dir` | `Any` | Local directory to mount as /tmp/td_output for results |
+| `task_count` | `Any` | Total number of tasks to run |
+| `parallelism` | `Any` | Maximum number of concurrent containers |
+
+**Returns:** List of output lines
+
+---
+
+## workers
+
+Worker-based gym system for parallel environment management.
+
+This module provides a FastAPI-based worker system for running CUA-Bench
+environments in parallel, enabling efficient RL training and evaluation.
+
+Components:
+- worker_server: FastAPI server wrapping Environment instances
+- worker_client: HTTP client for interacting with worker servers
+- worker_manager: Utilities for spawning and managing multiple workers
+- dataloader: MultiTurnDataloader and ReplayBuffer for RL training
+
+---
+
+## MultiTurnDataloader
+
+Dataloader for RL training with parallel environment workers.
+
+Each env_config must contain a 'task_configs' key with a list of task
+configurations that the client will use internally.
+
+### Constructor
+
+```python
+MultiTurnDataloader(self, env_class, env_configs, tokenizer, processor = None, is_multi_modal = True, batch_size = 8, replay_capacity = 10000, replay_reward_discount = 0.9, max_prompt_length = 1024, max_response_length = 1024, only_keep_outcome_in_replay = False)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `num_envs` | `Any` | |
+| `batch_size` | `Any` | |
+| `replay` | `Any` | |
+
+### Methods
+
+#### MultiTurnDataloader.async_step
+
+```python
+def async_step(self, batch_return)
+```
+
+#### MultiTurnDataloader.sample_from_buffer
+
+```python
+def sample_from_buffer(self, batch_size = None)
+```
+
+#### MultiTurnDataloader.clear_replay_buffer
+
+```python
+def clear_replay_buffer(self)
+```
+
+#### MultiTurnDataloader.get_balance_stats
+
+```python
+def get_balance_stats(self)
+```
+
+#### MultiTurnDataloader.calculate_outcome_reward
+
+```python
+def calculate_outcome_reward(self)
+```
+
+#### MultiTurnDataloader.print_examples
+
+```python
+def print_examples(self, n = 2)
+```
+
+#### MultiTurnDataloader.print_stats_in_replay_buffer
+
+```python
+def print_stats_in_replay_buffer(self)
+```
+
+#### MultiTurnDataloader.running_outcome_reward
+
+```python
+def running_outcome_reward(self)
+```
+
+#### MultiTurnDataloader.close
+
+```python
+def close(self)
+```
+
+Close all workers and clean up resources.
+
+---
+
+## ReplayBuffer
+
+### Constructor
+
+```python
+ReplayBuffer(self, capacity = 10000, gamma = 1.0, only_keep_outcome = False, balance_thres = 0.1)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `capacity` | `Any` | |
+| `gamma` | `Any` | |
+| `only_keep_outcome` | `Any` | |
+| `balance_thres` | `Any` | |
+| `ready_buffer` | `Any` | |
+| `ready_position` | `Any` | |
+| `ready_count` | `Any` | |
+| `episode_buffer` | `Any` | |
+
+### Methods
+
+#### ReplayBuffer.add
+
+```python
+def add(self, data)
+```
+
+Add data to the replay buffer
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `data` | `tuple` | A tuple of (worker_id, env_ret, meta_info) |
+
+#### ReplayBuffer.get_balance_stats
+
+```python
+def get_balance_stats(self)
+```
+
+#### ReplayBuffer.should_keep
+
+```python
+def should_keep(self, curr_below, curr_above, curr_ret)
+```
+
+#### ReplayBuffer.sample
+
+```python
+def sample(self, batch_size)
+```
+
+Sample experiences from the ready buffer
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `batch_size` | `int` | Number of experiences to sample |
+
+**Returns:** list: List of sampled experiences
+
+#### ReplayBuffer.clear
+
+```python
+def clear(self)
+```
+
+Clear both ready buffer and episode buffer
+
+---
+
+## CBEnvWorkerClient
+
+HTTP client for CUA-Bench worker servers.
+
+This client manages communication with the worker server, image processing,
+observation history tracking, and action normalization.
+
+Args:
+ env_config: Configuration dict with keys:
+ - server_url: URL of the worker server
+ - task_configs: List of task configs, each with env_path, task_index, split
+ - img_w: Image width (default: 1920)
+ - img_h: Image height (default: 1080)
+ - max_step: Maximum steps per episode (default: 50)
+ - max_hist: Maximum observation history length (default: 10)
+ - timeout: Environment timeout in seconds (default: 300)
+
+### Constructor
+
+```python
+CBEnvWorkerClient(self, env_config)
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `vision_start_token` | `Any` | |
+| `vision_end_token` | `Any` | |
+| `think_start_token` | `Any` | |
+| `think_end_token` | `Any` | |
+| `action_start_token` | `Any` | |
+| `action_end_token` | `Any` | |
+| `valid_fn_names` | `Any` | |
+| `vlm_img_w` | `Any` | |
+| `vlm_img_h` | `Any` | |
+| `dynamic_img_size` | `Any` | |
+| `env_config` | `Any` | |
+| `server_url` | `Any` | |
+| `max_step` | `Any` | |
+| `max_hist` | `Any` | |
+| `task_configs` | `List[Dict[str, Any]]` | |
+| `img_h` | `Any` | |
+| `img_w` | `Any` | |
+| `timeout` | `Any` | |
+| `env_id` | `Any` | |
+| `uid` | `Any` | |
+| `step_count` | `Any` | |
+| `done` | `Any` | |
+| `prompt` | `Any` | |
+
+### Methods
+
+#### CBEnvWorkerClient.reset
+
+```python
+def reset(self)
+```
+
+#### CBEnvWorkerClient.reset_attempt
+
+```python
+def reset_attempt(self)
+```
+
+#### CBEnvWorkerClient.prompt_to_input_obs
+
+```python
+def prompt_to_input_obs(self, prompt)
+```
+
+#### CBEnvWorkerClient.check_and_fix_action
+
+```python
+def check_and_fix_action(self, action_str)
+```
+
+Parse action string and return (normalized_str, Action object for server).
+
+#### CBEnvWorkerClient.reward_shaping
+
+```python
+def reward_shaping(self, reward)
+```
+
+#### CBEnvWorkerClient.check_and_resize_image
+
+```python
+def check_and_resize_image(self, jpg_string)
+```
+
+#### CBEnvWorkerClient.step
+
+```python
+def step(self, action)
+```
+
+#### CBEnvWorkerClient.step_attempt
+
+```python
+def step_attempt(self, action)
+```
+
+#### CBEnvWorkerClient.render
+
+```python
+def render(self)
+```
+
+Renders the current state in self.prompt as a sequence of text-image pairs into a single image
+
+**Returns:** PIL.Image: Combined image showing the instruction and interaction history
+
+---
+
+## WorkerHandle
+
+Handle for a running worker server.
+
+Attributes:
+ worker_id: Unique identifier for this worker
+ port: Port the worker is listening on
+ process: Subprocess running the worker
+ api_url: Full URL for API requests
+
+### Constructor
+
+```python
+WorkerHandle(self, worker_id: str, port: int, process: subprocess.Popen, api_url: str) -> None
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `worker_id` | `str` | |
+| `port` | `int` | |
+| `process` | `subprocess.Popen` | |
+| `api_url` | `str` | |
+| `is_running` | `bool` | Check if the worker process is still running. |
+
+### Methods
+
+#### WorkerHandle.health_check
+
+```python
+async def health_check(self, timeout: float = 5.0) -> bool
+```
+
+Check if the worker is healthy.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `timeout` | `Any` | Request timeout in seconds |
+
+**Returns:** True if healthy, False otherwise
+
+#### WorkerHandle.stop
+
+```python
+def stop(self) -> None
+```
+
+Stop the worker process.
+
+---
+
+## WorkerPool
+
+Context manager for a pool of worker servers.
+
+Example:
+ async with WorkerPool(n_workers=4, allowed_ips=["127.0.0.1"]) as pool:
+ for url in pool.urls:
+ client = CBEnvWorkerClient(\{ "server_url": url \})
+ # Use client...
+
+### Constructor
+
+```python
+WorkerPool(self, n_workers: int, allowed_ips: List[str], startup_timeout: float = 30.0, host: str = '0.0.0.0')
+```
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `n_workers` | `Any` | |
+| `allowed_ips` | `Any` | |
+| `startup_timeout` | `Any` | |
+| `host` | `Any` | |
+| `workers` | `List[WorkerHandle]` | Get the list of worker handles. |
+| `urls` | `List[str]` | Get the list of worker URLs. |
+
+### Methods
+
+#### WorkerPool.health_check_all
+
+```python
+async def health_check_all(self) -> dict
+```
+
+Check health of all workers.
+
+**Returns:** Dict mapping worker_id to health status
+
+### cleanup_workers
+
+```python
+async def cleanup_workers(workers: List[WorkerHandle]) -> None
+```
+
+Stop all workers.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `workers` | `Any` | List of WorkerHandle objects to stop |
+
+### create_workers
+
+```python
+async def create_workers(n_workers: int, allowed_ips: List[str], startup_timeout: float = 30.0, host: str = '0.0.0.0') -> List[WorkerHandle]
+```
+
+Spawn N worker servers on automatically allocated free ports.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `n_workers` | `Any` | Number of worker servers to spawn |
+| `allowed_ips` | `Any` | List of IPs allowed to access workers |
+| `startup_timeout` | `Any` | Max time to wait for each worker to become healthy |
+| `host` | `Any` | Host for workers to bind to |
+
+**Returns:** List of WorkerHandle objects
+
+**Raises:**
+
+- `RuntimeError` - If any worker fails to start
+
+**Example:**
+
+```python
+workers = await create_workers(
+ n_workers=4,
+ allowed_ips=["127.0.0.1", "10.0.0.5"],
+)
+# Each worker manages up to 2 envs, so 4 workers = 8 parallel envs
+```
+
+---
+
+## telemetry
+
+Telemetry module for cua-bench.
+
+This module provides analytics for tracking feature usage, user workflows,
+and system performance. All telemetry is routed through cua-core's PostHog
+infrastructure for consistency across the CUA ecosystem.
+
+Events tracked:
+- Tier 1 (Core): command_invoked, task_execution_started, task_evaluation_completed, batch_job_started
+- Tier 2 (High Value): task_step_executed, batch_task_completed, dataset_processing_completed, task_execution_failed
+
+Usage:
+ from cua_bench.telemetry import record_event, track_command
+
+ # Track CLI command usage
+ @track_command
+ def my_command(args):
+ ...
+
+ # Track custom events
+ record_event("custom_event", \{"property": "value"\})
+
+Environment Variables:
+ CUA_TELEMETRY_ENABLED: Set to "false" to disable telemetry (default: "true")
+ CUA_TELEMETRY_DEBUG: Set to "on" for debug logging
+
+### flush_telemetry
+
+```python
+def flush_telemetry() -> None
+```
+
+Flush pending telemetry events.
+
+Delegates to cua-core's PostHog client.
+
+### is_telemetry_enabled
+
+```python
+def is_telemetry_enabled() -> bool
+```
+
+Check if telemetry is enabled.
+
+Delegates to cua-core's telemetry check.
+
+### record_event
+
+```python
+def record_event(event_name: str, properties: Optional[Dict[str, Any]] = None) -> None
+```
+
+Record a telemetry event.
+
+Routes through cua-core's telemetry infrastructure.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `event_name` | `Any` | Name of the event (e.g., "cb_command_invoked") |
+| `properties` | `Any` | Optional dict of event properties |
+
+### track_batch_job_started
+
+```python
+def track_batch_job_started(dataset_name: str, task_count: int, variant_count: int, parallelism: int = 1, agent: Optional[str] = None, model: Optional[str] = None, run_id: Optional[str] = None, provider_type: Optional[str] = None) -> None
+```
+
+Track batch job start.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `dataset_name` | `Any` | Name of the dataset |
+| `task_count` | `Any` | Number of unique tasks |
+| `variant_count` | `Any` | Total variants to run |
+| `parallelism` | `Any` | Max parallel workers |
+| `agent` | `Any` | Agent name if specified |
+| `model` | `Any` | Model name if specified |
+| `run_id` | `Any` | Run ID for correlation |
+| `provider_type` | `Any` | Provider type |
+
+### track_batch_task_completed
+
+```python
+def track_batch_task_completed(env_name: str, task_index: int, success: bool, reward: Optional[float] = None, total_steps: int = 0, duration_seconds: float = 0, run_id: Optional[str] = None, error: Optional[str] = None) -> None
+```
+
+Track individual task completion in batch.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Name of the environment/task |
+| `task_index` | `Any` | Task variant index |
+| `success` | `Any` | Whether task succeeded |
+| `reward` | `Any` | Reward/score if available |
+| `total_steps` | `Any` | Steps taken |
+| `duration_seconds` | `Any` | Task duration |
+| `run_id` | `Any` | Run ID for correlation |
+| `error` | `Any` | Error message if failed |
+
+### track_command
+
+```python
+def track_command(func: Callable) -> Callable
+```
+
+Decorator to track command invocation.
+
+Usage:
+ @track_command
+ def cmd_run_task(args):
+ ...
+
+### track_command_async
+
+```python
+def track_command_async(func: Callable) -> Callable
+```
+
+Async decorator to track command invocation.
+
+### track_command_invoked
+
+```python
+def track_command_invoked(command: str, subcommand: Optional[str] = None, args: Optional[Dict[str, Any]] = None) -> None
+```
+
+Track CLI command invocation.
+
+This is the primary event for understanding feature usage.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `command` | `Any` | Main command (e.g., "run", "interact", "trace") |
+| `subcommand` | `Any` | Optional subcommand (e.g., "task", "dataset", "list") |
+| `args` | `Any` | Optional sanitized arguments (no sensitive data) |
+
+### track_dataset_processing_completed
+
+```python
+def track_dataset_processing_completed(processor_mode: str, rows_processed: int, duration_seconds: float, success: bool = True, output_format: Optional[str] = None) -> None
+```
+
+Track dataset processing completion.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `processor_mode` | `Any` | Processing mode (aguvis-stage-1, gui-r1, etc.) |
+| `rows_processed` | `Any` | Number of rows processed |
+| `duration_seconds` | `Any` | Processing duration |
+| `success` | `Any` | Whether processing succeeded |
+| `output_format` | `Any` | Output format (disk, hub, jsonl) |
+
+### track_task_evaluation_completed
+
+```python
+def track_task_evaluation_completed(env_name: str, task_index: int, result: Any, success: bool, total_steps: int, duration_seconds: float, run_id: Optional[str] = None, agent: Optional[str] = None, model: Optional[str] = None) -> None
+```
+
+Track task evaluation completion.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Name of the environment/task |
+| `task_index` | `Any` | Task variant index |
+| `result` | `Any` | Evaluation result (reward/score) |
+| `success` | `Any` | Whether task was successful |
+| `total_steps` | `Any` | Total steps taken |
+| `duration_seconds` | `Any` | Total duration in seconds |
+| `run_id` | `Any` | Run ID for correlation |
+| `agent` | `Any` | Agent name if used |
+| `model` | `Any` | Model name if used |
+
+### track_task_execution_failed
+
+```python
+def track_task_execution_failed(env_name: str, task_index: int, error_type: str, error_message: str, stage: str, run_id: Optional[str] = None) -> None
+```
+
+Track task execution failure.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Name of the environment/task |
+| `task_index` | `Any` | Task variant index |
+| `error_type` | `Any` | Exception class name |
+| `error_message` | `Any` | Error message (truncated) |
+| `stage` | `Any` | Stage where error occurred |
+| `run_id` | `Any` | Run ID for correlation |
+
+### track_task_execution_started
+
+```python
+def track_task_execution_started(env_name: str, task_index: int, provider_type: Optional[str] = None, os_type: Optional[str] = None, agent: Optional[str] = None, model: Optional[str] = None, max_steps: Optional[int] = None, execution_mode: str = 'single', run_id: Optional[str] = None) -> None
+```
+
+Track task execution start.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `env_name` | `Any` | Name of the environment/task |
+| `task_index` | `Any` | Task variant index |
+| `provider_type` | `Any` | Provider type (simulated, webtop, native, computer) |
+| `os_type` | `Any` | OS type (linux, windows, android) |
+| `agent` | `Any` | Agent name if specified |
+| `model` | `Any` | Model name if specified |
+| `max_steps` | `Any` | Max steps budget |
+| `execution_mode` | `Any` | Execution mode (single, batch, interactive) |
+| `run_id` | `Any` | Run ID for correlation |
+
+### track_task_step_executed
+
+```python
+def track_task_step_executed(action_type: str, step_count: int, duration_ms: Optional[float] = None, run_id: Optional[str] = None) -> None
+```
+
+Track individual step execution.
+
+Note: This should be sampled to avoid high event volume.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `action_type` | `Any` | Type of action (ClickAction, TypeAction, etc.) |
+| `step_count` | `Any` | Current step number |
+| `duration_ms` | `Any` | Step duration in milliseconds |
+| `run_id` | `Any` | Run ID for correlation |
+
+---
+
+## apps
+
+App Registry for cua-bench.
+
+A decorator-based API for registering platform-specific app installers and launchers.
+Makes it easy for contributors to add support for new applications.
+
+Example - Defining an app:
+
+ # cua_bench/apps/godot.py
+ from cua_bench.apps import App, install, launch
+
+ class Godot(App):
+ name = "godot"
+ description = "Godot game engine"
+
+ @install("linux")
+ async def install_linux(session, *, with_shortcut=True, version="4.2.1"):
+ await session.run_command(
+ f"cd ~/Desktop && "
+ f"wget -q https://github.com/godotengine/godot/releases/download/\{version\}-stable/Godot_v\{version\}-stable_linux.x86_64.zip && "
+ f"unzip -q Godot_v\{version\}-stable_linux.x86_64.zip"
+ )
+ if with_shortcut:
+ await session.run_command(
+ "ln -sf ~/Desktop/Godot_v*_linux.x86_64 ~/Desktop/Godot"
+ )
+
+ @install("windows")
+ async def install_windows(session, *, with_shortcut=True, version="4.2.1"):
+ await session.run_command(f"choco install godot --version=\{version\} -y")
+
+ @launch("linux", "windows")
+ async def launch_editor(session, *, project_path=None):
+ cmd = "~/Desktop/Godot" if session.os_type == "linux" else "godot"
+ if project_path:
+ cmd += f" --editor --path \{project_path\}"
+ await session.run_command(f"\{cmd\} &")
+
+Example - Using in a task:
+
+ @cb.setup_task(split="train")
+ async def start(task_cfg: cb.Task, session: cb.DesktopSession):
+ # Install app (auto-selects platform)
+ await session.install_app("godot", with_shortcut=True, version="4.2.1")
+
+ # Launch app
+ await session.launch_app("godot", project_path="~/project")
+
+---
+
+## App
+
+Base class for app definitions.
+
+Subclass this and define platform-specific methods using decorators:
+
+ class MyApp(App):
+ name = "myapp"
+ description = "My application"
+
+ @install("linux")
+ async def install_linux(session, **kwargs):
+ ...
+
+ @install("windows")
+ async def install_windows(session, **kwargs):
+ ...
+
+ @launch("linux", "windows")
+ async def launch(session, **kwargs):
+ ...
+
+### Attributes
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `str` | |
+| `description` | `str` | |
+
+### Methods
+
+#### App.get_method
+
+```python
+def get_method(self, method_type: str, platform: Platform) -> Optional[AppMethod]
+```
+
+Get a method for the given type and platform.
+
+#### App.get_install
+
+```python
+def get_install(self, platform: Platform) -> Optional[AppMethod]
+```
+
+Get the install method for a platform.
+
+#### App.get_launch
+
+```python
+def get_launch(self, platform: Platform) -> Optional[AppMethod]
+```
+
+Get the launch method for a platform.
+
+#### App.get_uninstall
+
+```python
+def get_uninstall(self, platform: Platform) -> Optional[AppMethod]
+```
+
+Get the uninstall method for a platform.
+
+#### App.supported_platforms
+
+```python
+def supported_platforms(self, method_type: str = 'install') -> Set[Platform]
+```
+
+Get platforms supported for a method type.
+
+---
+
+## AppRegistry
+
+Registry access for DesktopSession integration.
+
+This class provides the interface used by DesktopSession to install/launch apps.
+
+### Methods
+
+#### AppRegistry.install_app
+
+```python
+async def install_app(session: Any, app_name: str, with_shortcut: bool = True, kwargs = {}) -> None
+```
+
+Install an app on the session's platform.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Any` | DesktopSession instance |
+| `app_name` | `Any` | Name of the app to install |
+| `with_shortcut` | `Any` | Whether to create desktop shortcut (default True) **kwargs: Additional app-specific arguments |
+
+#### AppRegistry.launch_app
+
+```python
+async def launch_app(session: Any, app_name: str, kwargs = {}) -> None
+```
+
+Launch an app on the session's platform.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Any` | DesktopSession instance |
+| `app_name` | `Any` | Name of the app to launch **kwargs: App-specific launch arguments |
+
+#### AppRegistry.uninstall_app
+
+```python
+async def uninstall_app(session: Any, app_name: str, kwargs = {}) -> None
+```
+
+Uninstall an app from the session's platform.
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `session` | `Any` | DesktopSession instance |
+| `app_name` | `Any` | Name of the app to uninstall **kwargs: App-specific arguments |
+
+### get_app
+
+```python
+def get_app(name: str) -> Optional[App]
+```
+
+Get a registered app by name.
+
+### list_apps
+
+```python
+def list_apps() -> List[str]
+```
+
+List all registered app names.
diff --git a/docs/content/docs/cuabench/reference/cli-reference.mdx b/docs/content/docs/cuabench/reference/cli-reference.mdx
index 5ba667ba4b..42e838cdbd 100644
--- a/docs/content/docs/cuabench/reference/cli-reference.mdx
+++ b/docs/content/docs/cuabench/reference/cli-reference.mdx
@@ -3,6 +3,10 @@ title: CLI Reference
description: Complete reference for all cua-bench CLI commands
---
+import { VersionBadge } from '@/components/version-selector';
+
+<VersionBadge version="0.2.3" />
+
## Image Commands
Create and manage base images for environments.
diff --git a/docs/content/docs/cuabench/reference/meta.json b/docs/content/docs/cuabench/reference/meta.json
index 362465d2e5..b1238bf890 100644
--- a/docs/content/docs/cuabench/reference/meta.json
+++ b/docs/content/docs/cuabench/reference/meta.json
@@ -2,5 +2,5 @@
"title": "Reference",
"description": "CLI and API reference",
"icon": "FileText",
- "pages": ["cli-reference", "sdk-reference"]
+ "pages": ["cli-reference", "api"]
}
diff --git a/docs/content/docs/cuabot/install.mdx b/docs/content/docs/cuabot/guide/getting-started/installation.mdx
similarity index 95%
rename from docs/content/docs/cuabot/install.mdx
rename to docs/content/docs/cuabot/guide/getting-started/installation.mdx
index 49ed5f58a2..4fcddf5f54 100644
--- a/docs/content/docs/cuabot/install.mdx
+++ b/docs/content/docs/cuabot/guide/getting-started/installation.mdx
@@ -1,6 +1,6 @@
---
title: Installation
-description: Install CuaBot and its dependencies
+description: Install Cua-Bot and its dependencies
---
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
@@ -41,7 +41,7 @@ import { Callout } from 'fumadocs-ui/components/callout';
# Install Xpra
sudo apt install xpra
- # Install CuaBot
+ # Install Cua-Bot
npm install -g cuabot
```
diff --git a/docs/content/docs/cuabot/cuabot.mdx b/docs/content/docs/cuabot/guide/getting-started/introduction.mdx
similarity index 91%
rename from docs/content/docs/cuabot/cuabot.mdx
rename to docs/content/docs/cuabot/guide/getting-started/introduction.mdx
index e26e514d83..e41b0630b4 100644
--- a/docs/content/docs/cuabot/cuabot.mdx
+++ b/docs/content/docs/cuabot/guide/getting-started/introduction.mdx
@@ -1,10 +1,15 @@
---
-title: CuaBot
+title: Introduction
description: Multi-user computing with AI
---
<div className="not-prose flex justify-center my-8">
- <img src="/docs/img/cuabot-screenshot.png" alt="cuabot screenshot" style={{maxHeight: '32em'}} className="rounded-xl" />
+ <img
+ src="/docs/img/cuabot-screenshot.png"
+ alt="cuabot screenshot"
+ style={{ maxHeight: '32em' }}
+ className="rounded-xl"
+ />
</div>
**Multi-user computing with AI**
@@ -107,7 +112,7 @@ cuabot --help # Show help
## How It Works
-CuaBot runs a Docker container with Xpra, streaming individual application windows to your desktop. Your chosen agent runs inside the container with:
+Cua-Bot runs a Docker container with Xpra, streaming individual application windows to your desktop. Your chosen agent runs inside the container with:
- Full Ubuntu 22.04 environment
- Pre-installed: Node.js, Python, browsers, dev tools
@@ -117,6 +122,7 @@ CuaBot runs a Docker container with Xpra, streaming individual application windo
## Configuration
Config files are stored in `~/.cuabot/`:
+
- `settings.json` - Default agent and preferences
- `server.pid` / `server.<name>.pid` - Server process ID
- `server.port` / `server.<name>.port` - Server port number
diff --git a/docs/content/docs/cuabot/guide/getting-started/meta.json b/docs/content/docs/cuabot/guide/getting-started/meta.json
new file mode 100644
index 0000000000..4e1aaf13ac
--- /dev/null
+++ b/docs/content/docs/cuabot/guide/getting-started/meta.json
@@ -0,0 +1,7 @@
+{
+ "title": "Getting Started",
+ "description": "Get started with Cua-Bot",
+ "icon": "Rocket",
+ "defaultOpen": true,
+ "pages": ["introduction", "installation"]
+}
diff --git a/docs/content/docs/cuabot/guide/meta.json b/docs/content/docs/cuabot/guide/meta.json
new file mode 100644
index 0000000000..5f712fc7b9
--- /dev/null
+++ b/docs/content/docs/cuabot/guide/meta.json
@@ -0,0 +1,6 @@
+{
+ "title": "Guide",
+ "description": "Learn how to use Cua-Bot",
+ "icon": "Book",
+ "pages": ["getting-started"]
+}
diff --git a/docs/content/docs/cuabot/meta.json b/docs/content/docs/cuabot/meta.json
index ddbac8ba13..2e99986ace 100644
--- a/docs/content/docs/cuabot/meta.json
+++ b/docs/content/docs/cuabot/meta.json
@@ -1,5 +1,5 @@
{
- "title": "CuaBot",
+ "title": "Cua-Bot",
"description": "Co-op computer-use for any agent",
- "pages": ["cuabot", "install"]
+ "pages": ["guide", "reference"]
}
diff --git a/docs/content/docs/cuabot/reference/changelog.mdx b/docs/content/docs/cuabot/reference/changelog.mdx
new file mode 100644
index 0000000000..51a2247cb8
--- /dev/null
+++ b/docs/content/docs/cuabot/reference/changelog.mdx
@@ -0,0 +1,132 @@
+---
+title: Changelog
+description: Release history for Cua-Bot
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-changelog.ts
+Last updated: 2026-02-09
+*/}
+
+# Cua-Bot Changelog
+
+All notable changes to the Cua-Bot are documented here.
+
+## 1.0.x
+
+### v1.0.13 (2026-02-05)
+
+- Bump cuabot to v1.0.13 by @github-actions[bot]
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.12 (2026-02-05)
+
+- Bump cuabot to v1.0.12 by @github-actions[bot]
+- fix cursor blocking input, remove start command override for cuabot ([#1020](https://github.com/trycua/cua/pull/1020)) by @ddupont808
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.11 (2026-02-04)
+
+- Bump cuabot to v1.0.11 by @github-actions[bot]
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.10 (2026-02-04)
+
+- Bump cuabot to v1.0.10 by @github-actions[bot]
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.9 (2026-02-04)
+
+- Bump cuabot to v1.0.9 by @github-actions[bot]
+- Fix onboarding step missing on Windows over npx/pnpx
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.8 (2026-02-04)
+
+- Bump cuabot to v1.0.8 by @github-actions[bot]
+- Add onboarding debug info and fix Xpra window detection on Windows ([#1014](https://github.com/trycua/cua/pull/1014)) by @ddupont808
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.7 (2026-02-04)
+
+- Bump cuabot to v1.0.7 by @github-actions[bot]
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.6 (2026-02-04)
+
+- Bump cuabot to v1.0.6 by @github-actions[bot]
+- Bugfixes for Windows
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.5 (2026-02-04)
+
+- Bump cuabot to v1.0.5 by @github-actions[bot]
+- [Cuabot] add y to npx ([#1009](https://github.com/trycua/cua/pull/1009)) by @ddupont808
+- chore: bump cuabot container to 1.0.4 by @github-actions[bot]
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.4 (2026-02-04)
+
+- Initial release or no path-specific changes found
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.3 (2026-02-04)
+
+- Bump cuabot to v1.0.3 by @github-actions[bot]
+- fix cuabot publish 3 ([#1003](https://github.com/trycua/cua/pull/1003)) by @ddupont808
+- fix cuabot publish 2 ([#1002](https://github.com/trycua/cua/pull/1002)) by @ddupont808
+
+Documentation
+
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
+
+### v1.0.2 (2026-02-04)
+
+- fix cuabot publish ([#1001](https://github.com/trycua/cua/pull/1001)) by @ddupont808
+- Bump cuabot to v1.0.2 by @github-actions[bot]
+
+Documentation
+
+See [cua.ai/docs/cuabot](https://cua.ai/docs/cuabot)
diff --git a/docs/content/docs/cuabot/reference/index.mdx b/docs/content/docs/cuabot/reference/index.mdx
new file mode 100644
index 0000000000..90eacfd324
--- /dev/null
+++ b/docs/content/docs/cuabot/reference/index.mdx
@@ -0,0 +1,295 @@
+---
+title: API Reference
+description: TypeScript API reference for the Cua-Bot sandboxed agent framework
+---
+
+{/*
+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+ Generated by: npx tsx scripts/docs-generators/typescript-sdk.ts
+ Source: libs/cuabot/src
+ Version: 1.0.13
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"1.0","href":"/cuabot/reference","isCurrent":true}]}
+ currentVersion="1.0"
+ fullVersion="1.0.13"
+ packageName="cuabot"
+ installCommand="npm install -g cuabot"
+/>
+
+---
+
+## client
+
+CuaBot Server Client
+Connects to the CuaBot server via HTTP
+
+### CuaBotClient
+
+#### Constructor
+
+```typescript
+new CuaBotClient(port: number)
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `port` | `number` | |
+
+#### Methods
+
+##### CuaBotClient.for
+
+```typescript
+for(): Promise<
+```
+
+**Returns:** `Promise&lt;`
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<number | null>
+```
+
+**Returns:** `Promise&lt;number | null>`
+
+##### CuaBotClient.status
+
+```typescript
+status(): Promise<
+```
+
+**Returns:** `Promise&lt;`
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<string>
+```
+
+**Returns:** `Promise&lt;string>`
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+##### CuaBotClient.request
+
+```typescript
+request(): Promise<void>
+```
+
+### setSessionName
+
+```typescript
+function setSessionName(name: string | null): void
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `name` | `string | null` | |
+
+### getSessionName
+
+```typescript
+function getSessionName(): string | null
+```
+
+**Returns:** `string | null`
+
+### isServerRunning
+
+```typescript
+async function isServerRunning(): Promise<
+```
+
+**Returns:** `Promise&lt;`
+
+### ensureServerRunning
+
+```typescript
+async function ensureServerRunning(): Promise<number>
+```
+
+**Returns:** `Promise&lt;number>`
+
+---
+
+## settings
+
+CuaBot Settings Management
+
+### Settings
+
+```typescript
+interface Settings {
+ defaultAgent?: string;
+ telemetryEnabled?: boolean;
+ aliasIgnored?: boolean;
+}
+```
+
+| Property | Type | Description |
+|----------|------|-------------|
+| `defaultAgent` | `string` | *(optional)* |
+| `telemetryEnabled` | `boolean` | *(optional)* |
+| `aliasIgnored` | `boolean` | *(optional)* |
+
+### AGENTS
+
+```typescript
+const AGENTS: const
+```
+
+### loadSettings
+
+```typescript
+function loadSettings(): Settings
+```
+
+**Returns:** `Settings`
+
+### saveSettings
+
+```typescript
+function saveSettings(settings: Settings): void
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `settings` | `Settings` | |
+
+### getDefaultAgent
+
+```typescript
+function getDefaultAgent(): string | undefined
+```
+
+**Returns:** `string | undefined`
+
+### setDefaultAgent
+
+```typescript
+function setDefaultAgent(agent: string): void
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `agent` | `string` | |
+
+### getTelemetryEnabled
+
+```typescript
+function getTelemetryEnabled(): boolean
+```
+
+**Returns:** `boolean`
+
+### isTelemetryConfigured
+
+```typescript
+function isTelemetryConfigured(): boolean
+```
+
+**Returns:** `boolean`
+
+### setTelemetryEnabled
+
+```typescript
+function setTelemetryEnabled(enabled: boolean): void
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `enabled` | `boolean` | |
+
+### getAliasIgnored
+
+```typescript
+function getAliasIgnored(): boolean
+```
+
+**Returns:** `boolean`
+
+### setAliasIgnored
+
+```typescript
+function setAliasIgnored(ignored: boolean): void
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|------|------|-------------|
+| `ignored` | `boolean` | |
diff --git a/docs/content/docs/cuabot/reference/meta.json b/docs/content/docs/cuabot/reference/meta.json
new file mode 100644
index 0000000000..6680696f7e
--- /dev/null
+++ b/docs/content/docs/cuabot/reference/meta.json
@@ -0,0 +1,6 @@
+{
+ "title": "Reference",
+ "description": "API and CLI reference for Cua-Bot",
+ "icon": "FileText",
+ "pages": ["changelog"]
+}
diff --git a/docs/content/docs/lume/examples/claude-code/homebrew-testing.mdx b/docs/content/docs/lume/examples/claude-code/homebrew-testing.mdx
index 13bf521724..bbb2582861 100644
--- a/docs/content/docs/lume/examples/claude-code/homebrew-testing.mdx
+++ b/docs/content/docs/lume/examples/claude-code/homebrew-testing.mdx
@@ -190,11 +190,11 @@ You: Install jq, uninstall it, and verify it's completely removed with no leftov
## Why this matters
-| Testing Approach | Clean Environment | Isolated | Resettable |
-|-----------------|-------------------|----------|------------|
-| Host machine | No | No | No |
-| Docker | Yes | Yes | Yes (but no macOS) |
-| **macOS VM** | **Yes** | **Yes** | **Yes** |
+| Testing Approach | Clean Environment | Isolated | Resettable |
+| ---------------- | ----------------- | -------- | ------------------ |
+| Host machine | No | No | No |
+| Docker | Yes | Yes | Yes (but no macOS) |
+| **macOS VM** | **Yes** | **Yes** | **Yes** |
Homebrew is macOS-specific. Testing Homebrew formulas requires macOS, and testing them properly requires isolation.
diff --git a/docs/content/docs/lume/examples/claude-code/sandbox.mdx b/docs/content/docs/lume/examples/claude-code/sandbox.mdx
index b332c6bc88..2038a826d1 100644
--- a/docs/content/docs/lume/examples/claude-code/sandbox.mdx
+++ b/docs/content/docs/lume/examples/claude-code/sandbox.mdx
@@ -89,13 +89,15 @@ Then tell Claude:
> Install any dependencies you need, run builds, execute tests—all inside that VM."
Claude Code will:
+
1. SSH into the sandbox VM
2. Navigate to your shared project
3. Run commands in the isolated environment
4. Report results back to you
<Callout type="info">
-Claude Code runs on your host but executes commands via SSH inside the VM. Your host system stays untouched—only the sandbox and shared files are affected.
+ Claude Code runs on your host but executes commands via SSH inside the VM. Your host system stays
+ untouched—only the sandbox and shared files are affected.
</Callout>
## Example session
@@ -157,18 +159,19 @@ echo "Then tell Claude to SSH into lume@$VM_IP"
## Security considerations
<Callout type="warn">
-The shared folder is read/write. Claude can modify or delete files in that folder. For sensitive work:
-- Share a copy of your project, not the original
-- Use git to track changes and revert if needed
-- Clone the VM before risky operations
+ The shared folder is read/write. Claude can modify or delete files in that folder. For sensitive
+ work: - Share a copy of your project, not the original - Use git to track changes and revert if
+ needed - Clone the VM before risky operations
</Callout>
The VM itself is fully isolated—code running inside cannot:
+
- Access files outside the shared folder
- Modify your host system
- Read your host's environment variables or credentials
But it can:
+
- Access the network
- Install software inside the VM
- Consume CPU/memory
diff --git a/docs/content/docs/lume/examples/claude-cowork/numbers-stock-analysis.mdx b/docs/content/docs/lume/examples/claude-cowork/numbers-stock-analysis.mdx
index 4e12530da5..8680aa5acf 100644
--- a/docs/content/docs/lume/examples/claude-cowork/numbers-stock-analysis.mdx
+++ b/docs/content/docs/lume/examples/claude-cowork/numbers-stock-analysis.mdx
@@ -159,11 +159,11 @@ Try these related tasks:
This example shows why macOS sandboxes are valuable:
-| Approach | Can use Numbers.app? | Native macOS automation? |
-|----------|---------------------|-------------------------|
-| Docker | No | No |
-| Linux VM | No | No |
-| **macOS VM** | **Yes** | **Yes** |
+| Approach | Can use Numbers.app? | Native macOS automation? |
+| ------------ | -------------------- | ------------------------ |
+| Docker | No | No |
+| Linux VM | No | No |
+| **macOS VM** | **Yes** | **Yes** |
Tasks requiring Numbers, Keynote, Pages, or other macOS-only apps need a macOS environment. Lume provides that in an isolated sandbox.
diff --git a/docs/content/docs/lume/examples/claude-cowork/sandbox.mdx b/docs/content/docs/lume/examples/claude-cowork/sandbox.mdx
index 865c3b251f..6096aea9a6 100644
--- a/docs/content/docs/lume/examples/claude-cowork/sandbox.mdx
+++ b/docs/content/docs/lume/examples/claude-cowork/sandbox.mdx
@@ -53,7 +53,7 @@ Add the Lume MCP server to your Claude Desktop config:
```
<Callout type="info">
-If `lume` isn't in your PATH, use the full path: `/Users/yourname/.local/bin/lume`
+ If `lume` isn't in your PATH, use the full path: `/Users/yourname/.local/bin/lume`
</Callout>
### 2. Restart Claude Desktop
@@ -70,15 +70,15 @@ lume create sandbox --os macos --ipsw latest --unattended tahoe
## Available MCP tools
-| Tool | Description |
-|------|-------------|
-| `lume_list_vms` | List all VMs with status and IP addresses |
-| `lume_get_vm` | Get detailed VM info |
-| `lume_run_vm` | Start a VM with optional shared directory |
-| `lume_stop_vm` | Stop a running VM |
-| `lume_clone_vm` | Clone a VM (for golden images) |
-| `lume_delete_vm` | Delete a VM |
-| `lume_exec` | Execute commands inside the VM |
+| Tool | Description |
+| ---------------- | ----------------------------------------- |
+| `lume_list_vms` | List all VMs with status and IP addresses |
+| `lume_get_vm` | Get detailed VM info |
+| `lume_run_vm` | Start a VM with optional shared directory |
+| `lume_stop_vm` | Stop a running VM |
+| `lume_clone_vm` | Clone a VM (for golden images) |
+| `lume_delete_vm` | Delete a VM |
+| `lume_exec` | Execute commands inside the VM |
## Example workflow
@@ -150,12 +150,12 @@ VM 'sandbox' started from clean state.
## Advantages over SSH
-| Feature | SSH (Claude Code) | MCP (Claude Cowork) |
-|---------|------------------|---------------------|
-| VM lifecycle | Manual (`lume run/stop`) | Automated via tools |
-| IP lookup | Manual (`lume get`) | Automatic |
-| Credentials | User provides | Configured once |
-| Reset workflow | Script required | Natural language |
+| Feature | SSH (Claude Code) | MCP (Claude Cowork) |
+| -------------- | ------------------------ | ------------------- |
+| VM lifecycle | Manual (`lume run/stop`) | Automated via tools |
+| IP lookup | Manual (`lume get`) | Automatic |
+| Credentials | User provides | Configured once |
+| Reset workflow | Script required | Natural language |
With MCP, Cowork can manage the entire VM lifecycle through conversation.
diff --git a/docs/content/docs/lume/examples/index.mdx b/docs/content/docs/lume/examples/index.mdx
index 5fd3590601..d16ebdfefd 100644
--- a/docs/content/docs/lume/examples/index.mdx
+++ b/docs/content/docs/lume/examples/index.mdx
@@ -4,7 +4,7 @@ description: Step-by-step tutorials and use cases for Lume
---
import { Card, Cards } from 'fumadocs-ui/components/card';
-import { Bot, Terminal, MessageCircle } from 'lucide-react';
+import { Bot, Terminal } from 'lucide-react';
# Examples
@@ -23,12 +23,6 @@ Explore real-world examples and tutorials for using Lume to create and manage ma
title="Claude Cowork"
description="Use Claude Cowork with Lume MCP connector"
/>
- <Card
- icon={<MessageCircle className="w-6 h-6" />}
- href="/lume/examples/openclaw"
- title="OpenClaw"
- description="Run OpenClaw messaging gateway with iMessage support"
- />
</Cards>
## Available Examples
@@ -47,12 +41,6 @@ Use Claude Cowork with the Lume MCP connector for native VM management:
- **[Sandbox with MCP](/lume/examples/claude-cowork/sandbox)** — Configure the MCP connector for VM lifecycle control
- **[Stock Analysis with Numbers](/lume/examples/claude-cowork/numbers-stock-analysis)** — Use macOS-only apps like Numbers.app
-### OpenClaw
-
-Run a unified messaging gateway that bridges WhatsApp, Telegram, iMessage, and more with AI agents:
-
-- **[OpenClaw Setup](/lume/examples/openclaw)** — Install and configure OpenClaw in a headless macOS VM with iMessage support
-
## Coming Soon
- **CI/CD with GitHub Actions** - Run macOS builds and tests in ephemeral VMs
diff --git a/docs/content/docs/lume/examples/meta.json b/docs/content/docs/lume/examples/meta.json
index 72804e2d01..82acebbe70 100644
--- a/docs/content/docs/lume/examples/meta.json
+++ b/docs/content/docs/lume/examples/meta.json
@@ -2,5 +2,5 @@
"title": "Examples",
"description": "Step-by-step tutorials and use cases",
"icon": "Blocks",
- "pages": ["claude-code", "claude-cowork", "openclaw"]
+ "pages": ["claude-code", "claude-cowork"]
}
diff --git a/docs/content/docs/lume/guide/advanced/http-server.mdx b/docs/content/docs/lume/guide/advanced/http-server.mdx
index 550546ab54..009456d64f 100644
--- a/docs/content/docs/lume/guide/advanced/http-server.mdx
+++ b/docs/content/docs/lume/guide/advanced/http-server.mdx
@@ -16,7 +16,8 @@ lume serve --port 8080
```
<Callout type="info">
-If you installed Lume with default settings, the server runs as a background service on port 7777. No need to start it manually.
+ If you installed Lume with default settings, the server runs as a background service on port 7777.
+ No need to start it manually.
</Callout>
## Base URL
@@ -66,6 +67,7 @@ curl -X POST http://localhost:7777/lume/vms \
```
Response:
+
```json
{
"message": "VM creation started",
diff --git a/docs/content/docs/lume/guide/advanced/lumier/building-lumier.mdx b/docs/content/docs/lume/guide/advanced/lumier/building-lumier.mdx
index 178b8a8b51..81a803845c 100644
--- a/docs/content/docs/lume/guide/advanced/lumier/building-lumier.mdx
+++ b/docs/content/docs/lume/guide/advanced/lumier/building-lumier.mdx
@@ -27,11 +27,11 @@ docker run -it --rm \
## Customization points
-| Location | What to customize |
-|----------|-------------------|
-| `Dockerfile` | Base image, installed packages |
-| `/run/hooks/` | Scripts that run during VM lifecycle |
-| `/run/config/constants.sh` | Default settings |
+| Location | What to customize |
+| -------------------------- | ------------------------------------ |
+| `Dockerfile` | Base image, installed packages |
+| `/run/hooks/` | Scripts that run during VM lifecycle |
+| `/run/config/constants.sh` | Default settings |
### Change the base image
diff --git a/docs/content/docs/lume/guide/advanced/lumier/docker-compose.mdx b/docs/content/docs/lume/guide/advanced/lumier/docker-compose.mdx
index 17f415ac6e..bf7ffee895 100644
--- a/docs/content/docs/lume/guide/advanced/lumier/docker-compose.mdx
+++ b/docs/content/docs/lume/guide/advanced/lumier/docker-compose.mdx
@@ -53,11 +53,11 @@ Access at `http://localhost:8006`.
## Configuration options
-| Field | Description |
-|-------|-------------|
+| Field | Description |
+| ------------------------- | ------------------------------------ |
| `restart: unless-stopped` | Auto-restart unless manually stopped |
-| `stop_grace_period: 2m` | Wait 2 minutes for graceful shutdown |
-| `stop_signal: SIGINT` | Send interrupt signal to stop |
+| `stop_grace_period: 2m` | Wait 2 minutes for graceful shutdown |
+| `stop_signal: SIGINT` | Send interrupt signal to stop |
## Multiple VMs
diff --git a/docs/content/docs/lume/guide/advanced/lumier/docker.mdx b/docs/content/docs/lume/guide/advanced/lumier/docker.mdx
index e22cf74960..3ea783482d 100644
--- a/docs/content/docs/lume/guide/advanced/lumier/docker.mdx
+++ b/docs/content/docs/lume/guide/advanced/lumier/docker.mdx
@@ -22,7 +22,7 @@ docker run -it --rm \
Open `http://localhost:8006` in your browser.
<Callout type="info">
-In ephemeral mode, changes are lost when you stop the container. See below for persistent storage.
+ In ephemeral mode, changes are lost when you stop the container. See below for persistent storage.
</Callout>
## Persistent storage
@@ -90,19 +90,20 @@ chmod +x shared/lifecycle/on-logon.sh
```
The script runs as the `lume` user and can access:
+
- `/Users/lume` — home directory
- `/Volumes/My Shared Files` — shared folder
## Environment variables
-| Variable | Description | Example |
-|----------|-------------|---------|
-| `VM_NAME` | Name for the VM | `my-vm` |
-| `VERSION` | macOS image to use | `ghcr.io/trycua/macos-sequoia-cua:latest` |
-| `CPU_CORES` | CPU cores | `4` |
-| `RAM_SIZE` | Memory in MB | `8192` |
-| `HOST_STORAGE_PATH` | Persistent storage path | `$(pwd)/storage` |
-| `HOST_SHARED_PATH` | Shared folder path | `$(pwd)/shared` |
+| Variable | Description | Example |
+| ------------------- | ----------------------- | ----------------------------------------- |
+| `VM_NAME` | Name for the VM | `my-vm` |
+| `VERSION` | macOS image to use | `ghcr.io/trycua/macos-sequoia-cua:latest` |
+| `CPU_CORES` | CPU cores | `4` |
+| `RAM_SIZE` | Memory in MB | `8192` |
+| `HOST_STORAGE_PATH` | Persistent storage path | `$(pwd)/storage` |
+| `HOST_SHARED_PATH` | Shared folder path | `$(pwd)/shared` |
## Change the port
diff --git a/docs/content/docs/lume/guide/advanced/lumier/index.mdx b/docs/content/docs/lume/guide/advanced/lumier/index.mdx
index eb9f230d81..ae754c9d01 100644
--- a/docs/content/docs/lume/guide/advanced/lumier/index.mdx
+++ b/docs/content/docs/lume/guide/advanced/lumier/index.mdx
@@ -21,17 +21,18 @@ Open `http://localhost:8006` in your browser—you'll see a macOS desktop.
## When to use Lumier vs Lume directly
-| Use Lumier when... | Use Lume directly when... |
-|--------------------|---------------------------|
-| You want browser-based VNC access | You prefer native VNC clients |
-| You're distributing VM environments | You're running locally for development |
-| You want Docker Compose orchestration | You need maximum performance |
-| You're building Docker-based workflows | You want full CLI control |
+| Use Lumier when... | Use Lume directly when... |
+| -------------------------------------- | -------------------------------------- |
+| You want browser-based VNC access | You prefer native VNC clients |
+| You're distributing VM environments | You're running locally for development |
+| You want Docker Compose orchestration | You need maximum performance |
+| You're building Docker-based workflows | You want full CLI control |
## How it works
<Callout type="info">
-Docker is the delivery mechanism, not an isolation layer. Lumier connects to the Lume service on your host Mac to create real VMs using Apple's Virtualization Framework.
+ Docker is the delivery mechanism, not an isolation layer. Lumier connects to the Lume service on
+ your host Mac to create real VMs using Apple's Virtualization Framework.
</Callout>
```
@@ -53,6 +54,7 @@ Docker is the delivery mechanism, not an isolation layer. Lumier connects to the
```
The Docker container provides:
+
- noVNC server for browser access
- Environment variable configuration
- Lifecycle hooks for automation
diff --git a/docs/content/docs/lume/guide/advanced/lumier/installation.mdx b/docs/content/docs/lume/guide/advanced/lumier/installation.mdx
index 2def7c8393..b8b8cf2d20 100644
--- a/docs/content/docs/lume/guide/advanced/lumier/installation.mdx
+++ b/docs/content/docs/lume/guide/advanced/lumier/installation.mdx
@@ -32,7 +32,8 @@ curl http://localhost:7777/lume/vms
```
<Callout type="info">
-Lume runs as a background service on port 7777. Lumier connects to this service to create and manage VMs.
+ Lume runs as a background service on port 7777. Lumier connects to this service to create and
+ manage VMs.
</Callout>
## Verify everything works
diff --git a/docs/content/docs/lume/guide/advanced/mcp-server.mdx b/docs/content/docs/lume/guide/advanced/mcp-server.mdx
index e521f64626..a8de20ef0f 100644
--- a/docs/content/docs/lume/guide/advanced/mcp-server.mdx
+++ b/docs/content/docs/lume/guide/advanced/mcp-server.mdx
@@ -58,7 +58,8 @@ Or manually edit `~/Library/Application Support/Claude/claude_desktop_config.jso
```
<Callout type="info">
-If editing manually, replace `/Users/yourname/.local/bin/lume` with the actual path to your lume binary. You can find it by running `which lume` in your terminal.
+ If editing manually, replace `/Users/yourname/.local/bin/lume` with the actual path to your lume
+ binary. You can find it by running `which lume` in your terminal.
</Callout>
### 2. Restart Claude Desktop
@@ -68,6 +69,7 @@ Claude will now have access to Lume's VM management tools.
### 3. Try it out
Ask Claude:
+
- "List my VMs"
- "Start the sandbox VM"
- "Run `ls -la` in the sandbox VM"
@@ -75,35 +77,35 @@ Ask Claude:
## Available tools
-| Tool | Description |
-|------|-------------|
-| `lume_create_vm` | Create a new macOS VM (async, returns immediately) |
-| `lume_list_vms` | List all VMs with status, IP addresses, and resource allocation |
-| `lume_get_vm` | Get detailed VM info (IP, VNC URL, SSH availability) |
-| `lume_run_vm` | Start a VM with optional shared directory |
-| `lume_stop_vm` | Stop a running VM gracefully |
-| `lume_clone_vm` | Clone a VM (useful for golden images) |
-| `lume_delete_vm` | Delete a VM and its files |
-| `lume_exec` | Execute commands inside a VM via SSH |
+| Tool | Description |
+| ---------------- | --------------------------------------------------------------- |
+| `lume_create_vm` | Create a new macOS VM (async, returns immediately) |
+| `lume_list_vms` | List all VMs with status, IP addresses, and resource allocation |
+| `lume_get_vm` | Get detailed VM info (IP, VNC URL, SSH availability) |
+| `lume_run_vm` | Start a VM with optional shared directory |
+| `lume_stop_vm` | Stop a running VM gracefully |
+| `lume_clone_vm` | Clone a VM (useful for golden images) |
+| `lume_delete_vm` | Delete a VM and its files |
+| `lume_exec` | Execute commands inside a VM via SSH |
## Resources
The MCP server provides documentation resources that AI agents can read:
-| Resource | Description |
-|----------|-------------|
+| Resource | Description |
+| -------------------- | ------------------------------------------------------------------------ |
| `lume://usage-guide` | Comprehensive guide with workflows, best practices, and status reference |
-| `lume://credentials` | Default SSH credentials for VMs created with unattended setup |
+| `lume://credentials` | Default SSH credentials for VMs created with unattended setup |
## Prompts
Pre-defined workflow prompts guide AI agents through common tasks:
-| Prompt | Description |
-|--------|-------------|
-| `create-sandbox` | Create a new macOS VM with unattended setup |
-| `run-in-sandbox` | Execute a command in an existing VM |
-| `reset-sandbox` | Reset a sandbox by cloning from a golden image |
+| Prompt | Description |
+| ---------------- | ---------------------------------------------- |
+| `create-sandbox` | Create a new macOS VM with unattended setup |
+| `run-in-sandbox` | Execute a command in an existing VM |
+| `reset-sandbox` | Reset a sandbox by cloning from a golden image |
## Creating VMs
@@ -111,15 +113,15 @@ The `lume_create_vm` tool creates new macOS VMs asynchronously. Since VM creatio
### Parameters
-| Parameter | Required | Default | Description |
-|-----------|----------|---------|-------------|
-| `name` | Yes | - | Name for the new VM |
-| `ipsw` | No | `latest` | IPSW path or "latest" to download |
-| `unattended` | No | - | Preset name (e.g., "tahoe", "sequoia") for automatic setup |
-| `cpu` | No | 4 | Number of CPU cores |
-| `memory` | No | `8GB` | Memory size (e.g., "8GB", "16GB") |
-| `disk_size` | No | `64GB` | Disk size (e.g., "64GB", "128GB") |
-| `storage` | No | - | Storage location name or path |
+| Parameter | Required | Default | Description |
+| ------------ | -------- | -------- | ---------------------------------------------------------- |
+| `name` | Yes | - | Name for the new VM |
+| `ipsw` | No | `latest` | IPSW path or "latest" to download |
+| `unattended` | No | - | Preset name (e.g., "tahoe", "sequoia") for automatic setup |
+| `cpu` | No | 4 | Number of CPU cores |
+| `memory` | No | `8GB` | Memory size (e.g., "8GB", "16GB") |
+| `disk_size` | No | `64GB` | Disk size (e.g., "64GB", "128GB") |
+| `storage` | No | - | Storage location name or path |
### Provisioning status
@@ -133,6 +135,7 @@ test stopped -
```
The operation progresses through:
+
1. `ipsw_install` — Downloading and installing macOS
2. `unattended_setup` — Running Setup Assistant automation (if `unattended` specified)
@@ -171,6 +174,7 @@ brew install hudochenkov/sshpass/sshpass
```
For VMs created with `--unattended tahoe`:
+
- Username: `lume`
- Password: `lume`
@@ -208,12 +212,12 @@ Tests completed! Here are the results:
## MCP vs HTTP API
-| Feature | MCP Server | HTTP Server |
-|---------|-----------|-------------|
-| Command | `lume serve --mcp` | `lume serve` |
-| Transport | stdio (spawned by client) | HTTP (port 7777) |
-| Use case | AI agent integration | Scripts, CI/CD, SDKs |
-| Lifecycle | On-demand, client-managed | Background daemon |
+| Feature | MCP Server | HTTP Server |
+| --------- | ------------------------- | -------------------- |
+| Command | `lume serve --mcp` | `lume serve` |
+| Transport | stdio (spawned by client) | HTTP (port 7777) |
+| Use case | AI agent integration | Scripts, CI/CD, SDKs |
+| Lifecycle | On-demand, client-managed | Background daemon |
Use MCP for AI agent integration. Use HTTP for programmatic access from scripts and applications.
@@ -226,6 +230,7 @@ npx @modelcontextprotocol/inspector lume serve --mcp
```
This opens a web UI where you can:
+
- See all available tools
- Test tool calls interactively
- Inspect request/response payloads
@@ -276,15 +281,18 @@ New VMs created with `--unattended tahoe` have SSH enabled automatically.
## Security considerations
<Callout type="warn">
-The MCP server gives AI agents direct control over your VMs. Only use it with trusted AI applications.
+ The MCP server gives AI agents direct control over your VMs. Only use it with trusted AI
+ applications.
</Callout>
The MCP server:
+
- Runs locally (stdio transport, no network exposure)
- Has full access to VM lifecycle operations
- Can execute commands inside VMs with SSH access
Consider:
+
- Using dedicated sandbox VMs for AI agent tasks
- Cloning VMs before letting agents modify them
- Reviewing agent actions in Claude's interface
diff --git a/docs/content/docs/lume/guide/fundamentals/unattended-setup.mdx b/docs/content/docs/lume/guide/fundamentals/unattended-setup.mdx
index 632093cab2..4a5d5aadfd 100644
--- a/docs/content/docs/lume/guide/fundamentals/unattended-setup.mdx
+++ b/docs/content/docs/lume/guide/fundamentals/unattended-setup.mdx
@@ -14,7 +14,8 @@ lume create my-vm --os macos --ipsw latest --unattended tahoe
This creates a VM, installs macOS, and runs through the entire Setup Assistant. When it's done, you have a configured VM with user `lume` (password `lume`) and SSH enabled.
<Callout type="warn">
-Unattended configs are macOS version-specific. The `tahoe` preset works with macOS Tahoe (15.x). Setup Assistant changes between versions, so configs may need updating for new releases.
+ Unattended configs are macOS version-specific. The `tahoe` preset works with macOS Tahoe (15.x).
+ Setup Assistant changes between versions, so configs may need updating for new releases.
</Callout>
## Prerequisites
@@ -72,15 +73,15 @@ Screenshots go to `/tmp/unattended-<uuid>` by default, or specify `--debug-dir /
A config has three parts:
```yaml
-boot_wait: 30 # Seconds to wait after boot
+boot_wait: 30 # Seconds to wait after boot
-boot_commands: # Sequence of automation commands
+boot_commands: # Sequence of automation commands
- "<wait 'Continue'>"
- "<click 'Continue'>"
- "<type 'lume'>"
- - "<enter>"
+ - '<enter>'
-health_check: # Optional verification
+health_check: # Optional verification
type: ssh
user: lume
password: lume
@@ -91,20 +92,21 @@ health_check: # Optional verification
### Wait for text (OCR)
```yaml
-- "<wait 'Continue'>" # Wait up to 120s (default)
-- "<wait 'Loading...', timeout=300>" # Custom timeout
+- "<wait 'Continue'>" # Wait up to 120s (default)
+- "<wait 'Loading...', timeout=300>" # Custom timeout
```
### Click text
```yaml
-- "<click 'Continue'>" # Click first occurrence
-- "<click 'Agree', index=-1>" # Click last occurrence
-- "<click 'Label', xoffset=50>" # Click 50px right of text
-- "<click_at 960,540>" # Click exact coordinates
+- "<click 'Continue'>" # Click first occurrence
+- "<click 'Agree', index=-1>" # Click last occurrence
+- "<click 'Label', xoffset=50>" # Click 50px right of text
+- '<click_at 960,540>' # Click exact coordinates
```
When text appears multiple times (like "Agree" in license text and button), use `index`:
+
- `index=0` — first (top)
- `index=-1` — last (bottom)
@@ -131,12 +133,12 @@ When text appears multiple times (like "Agree" in license text and button), use
### Hotkey combinations
```yaml
-- "<cmd+space>" # Spotlight
-- "<cmd+c>" # Copy
-- "<cmd+v>" # Paste
-- "<cmd+q>" # Quit
-- "<shift+cmd+3>" # Screenshot
-- "<ctrl+alt+delete>"
+- '<cmd+space>' # Spotlight
+- '<cmd+c>' # Copy
+- '<cmd+v>' # Paste
+- '<cmd+q>' # Quit
+- '<shift+cmd+3>' # Screenshot
+- '<ctrl+alt+delete>'
```
Modifiers: `cmd`/`command`/`super`, `shift`, `alt`/`option`, `ctrl`/`control`
@@ -144,8 +146,8 @@ Modifiers: `cmd`/`command`/`super`, `shift`, `alt`/`option`, `ctrl`/`control`
### Delays
```yaml
-- "<delay 2>" # Wait 2 seconds
-- "<delay 0.5>" # Decimals work
+- '<delay 2>' # Wait 2 seconds
+- '<delay 0.5>' # Decimals work
```
## Example: Complete Setup Assistant
@@ -157,30 +159,30 @@ boot_wait: 30
boot_commands:
# Dismiss greeting
- - "<delay 5>"
- - "<space>"
- - "<delay 2>"
+ - '<delay 5>'
+ - '<space>'
+ - '<delay 2>'
# Language
- "<wait 'English', timeout=120>"
- "<type 'English'>"
- - "<delay 1>"
- - "<enter>"
- - "<delay 2>"
+ - '<delay 1>'
+ - '<enter>'
+ - '<delay 2>'
# Country
- "<wait 'Country or Region'>"
- - "<click_at 960,900>"
+ - '<click_at 960,900>'
- "<type 'United States'>"
- - "<enter>"
+ - '<enter>'
- "<click 'Continue'>"
- - "<delay 2>"
+ - '<delay 2>'
# Transfer - select "Set up as new"
- "<wait 'Transfer Your Data'>"
- - "<delay 20>"
- - "<tab><tab><tab>"
- - "<space>"
+ - '<delay 20>'
+ - '<tab><tab><tab>'
+ - '<space>'
- "<click 'Continue'>"
# Accessibility
@@ -189,13 +191,13 @@ boot_commands:
# Account creation
- "<wait 'Create a Mac Account'>"
- - "<tab><tab><tab><tab><tab><tab>"
+ - '<tab><tab><tab><tab><tab><tab>'
- "<type 'lume'>"
- - "<tab><tab>"
+ - '<tab><tab>'
- "<type 'lume'>"
- - "<tab>"
+ - '<tab>'
- "<type 'lume'>"
- - "<tab><tab><space>"
+ - '<tab><tab><space>'
- "<click 'Continue'>"
# Terms
@@ -222,9 +224,9 @@ health_check:
type: ssh
user: lume
password: lume
- timeout: 30 # Seconds per attempt
- retries: 5 # Number of attempts
- retry_delay: 10 # Seconds between retries
+ timeout: 30 # Seconds per attempt
+ retries: 5 # Number of attempts
+ retry_delay: 10 # Seconds between retries
```
The automation waits for the VM to become reachable via SSH before declaring success.
@@ -240,10 +242,10 @@ The automation waits for the VM to become reachable via SSH before declaring suc
**Keyboard navigation** — macOS doesn't Tab through all elements by default. Enable full keyboard access:
```yaml
-- "<cmd+space>"
+- '<cmd+space>'
- "<type 'Keyboard'>"
-- "<delay 2>"
-- "<enter>"
+- '<delay 2>'
+- '<enter>'
# Then enable "Keyboard navigation" in settings
```
@@ -251,13 +253,13 @@ The automation waits for the VM to become reachable via SSH before declaring suc
## Troubleshooting
-| Problem | Solution |
-|---------|----------|
-| Commands run too early | Increase `boot_wait`, add `<delay>` |
-| Text not found | Check spelling/case, increase timeout, use coordinates |
-| Wrong element clicked | Use `index` to select correct occurrence |
-| Hotkeys ignored | Click desktop first to focus |
-| Tab skips elements | Enable keyboard navigation in System Settings |
+| Problem | Solution |
+| ---------------------- | ------------------------------------------------------ |
+| Commands run too early | Increase `boot_wait`, add `<delay>` |
+| Text not found | Check spelling/case, increase timeout, use coordinates |
+| Wrong element clicked | Use `index` to select correct occurrence |
+| Hotkeys ignored | Click desktop first to focus |
+| Tab skips elements | Enable keyboard navigation in System Settings |
## Limitations
@@ -270,19 +272,19 @@ The automation waits for the VM to become reachable via SSH before declaring suc
### Config fields
-| Field | Type | Default | Description |
-|-------|------|---------|-------------|
-| `boot_wait` | integer | 60 | Seconds to wait before starting |
-| `boot_commands` | array | required | List of commands |
-| `health_check` | object | optional | Verification config |
+| Field | Type | Default | Description |
+| --------------- | ------- | -------- | ------------------------------- |
+| `boot_wait` | integer | 60 | Seconds to wait before starting |
+| `boot_commands` | array | required | List of commands |
+| `health_check` | object | optional | Verification config |
### Health check fields
-| Field | Type | Default | Description |
-|-------|------|---------|-------------|
-| `type` | string | required | `ssh` |
-| `user` | string | — | SSH username |
-| `password` | string | — | SSH password |
-| `timeout` | integer | 30 | Seconds per attempt |
-| `retries` | integer | 3 | Number of attempts |
-| `retry_delay` | integer | 5 | Seconds between retries |
+| Field | Type | Default | Description |
+| ------------- | ------- | -------- | ----------------------- |
+| `type` | string | required | `ssh` |
+| `user` | string | — | SSH username |
+| `password` | string | — | SSH password |
+| `timeout` | integer | 30 | Seconds per attempt |
+| `retries` | integer | 3 | Number of attempts |
+| `retry_delay` | integer | 5 | Seconds between retries |
diff --git a/docs/content/docs/lume/guide/fundamentals/vm-management.mdx b/docs/content/docs/lume/guide/fundamentals/vm-management.mdx
index 1110a81465..38eda3df56 100644
--- a/docs/content/docs/lume/guide/fundamentals/vm-management.mdx
+++ b/docs/content/docs/lume/guide/fundamentals/vm-management.mdx
@@ -9,15 +9,15 @@ Once you've [created a VM](/lume/guide/getting-started/quickstart), here's how t
## Quick reference
-| Task | Command |
-|------|---------|
-| List VMs | `lume ls` |
-| Get details | `lume get my-vm` |
-| Run | `lume run my-vm` |
+| Task | Command |
+| ------------ | ----------------------------- |
+| List VMs | `lume ls` |
+| Get details | `lume get my-vm` |
+| Run | `lume run my-vm` |
| Run headless | `lume run my-vm --no-display` |
-| Stop | `lume stop my-vm` |
-| Clone | `lume clone my-vm backup` |
-| Delete | `lume delete my-vm` |
+| Stop | `lume stop my-vm` |
+| Clone | `lume clone my-vm backup` |
+| Delete | `lume delete my-vm` |
## Run a VM
@@ -73,7 +73,8 @@ Any ARM64 Linux distribution works. Download the ARM64 (aarch64) ISO, not x86_64
- **Fedora** - [fedoraproject.org](https://fedoraproject.org/)
<Callout type="info">
-Linux VMs have no licensing restrictions—run as many concurrent instances as your hardware supports. Only macOS VMs are limited to 2 per Mac.
+ Linux VMs have no licensing restrictions—run as many concurrent instances as your hardware
+ supports. Only macOS VMs are limited to 2 per Mac.
</Callout>
## Stop a VM
@@ -101,7 +102,7 @@ lume get my-vm
## Change VM settings
<Callout type="warn">
-Stop the VM before changing settings. Disk size can only increase, not decrease.
+ Stop the VM before changing settings. Disk size can only increase, not decrease.
</Callout>
```bash
@@ -207,7 +208,8 @@ lume prune
```
<Callout type="info">
-Enable caching if you frequently pull the same images or images sharing base layers. With caching disabled, each `lume pull` downloads everything fresh.
+ Enable caching if you frequently pull the same images or images sharing base layers. With caching
+ disabled, each `lume pull` downloads everything fresh.
</Callout>
## What's next
diff --git a/docs/content/docs/lume/guide/getting-started/comparison.mdx b/docs/content/docs/lume/guide/getting-started/comparison.mdx
index 5cba87d28e..c88ed2ac00 100644
--- a/docs/content/docs/lume/guide/getting-started/comparison.mdx
+++ b/docs/content/docs/lume/guide/getting-started/comparison.mdx
@@ -9,16 +9,16 @@ This page compares Lume with other macOS virtualization tools. All of these are
## Quick Comparison
-| Feature | Lume | Tart | Lima | UTM |
-|---------|------|------|------|-----|
-| **License** | MIT | Fair Source | Apache 2.0 | Apache 2.0 |
-| **macOS VMs** | Yes | Yes | No | Yes |
-| **Linux VMs** | Yes | Yes | Yes | Yes |
-| **HTTP API** | Yes | No | No | No |
-| **MCP Server** | Yes | No | No | No |
-| **Unattended Setup** | Yes (VNC + OCR) | Via Packer | N/A | No |
-| **Registry Support** | OCI (GHCR, GCS) | OCI registries | N/A | No |
-| **Primary Use Case** | Agent automation, CI/CD | CI/CD | Linux containers | General desktop |
+| Feature | Lume | Tart | Lima | UTM |
+| -------------------- | ----------------------- | -------------- | ---------------- | --------------- |
+| **License** | MIT | Fair Source | Apache 2.0 | Apache 2.0 |
+| **macOS VMs** | Yes | Yes | No | Yes |
+| **Linux VMs** | Yes | Yes | Yes | Yes |
+| **HTTP API** | Yes | No | No | No |
+| **MCP Server** | Yes | No | No | No |
+| **Unattended Setup** | Yes (VNC + OCR) | Via Packer | N/A | No |
+| **Registry Support** | OCI (GHCR, GCS) | OCI registries | N/A | No |
+| **Primary Use Case** | Agent automation, CI/CD | CI/CD | Linux containers | General desktop |
## Tart
@@ -91,6 +91,7 @@ This page compares Lume with other macOS virtualization tools. All of these are
## Summary
Choose Lume if you need:
+
- An HTTP API for programmatic VM control
- MCP server integration for AI agents
- Fully automated macOS VM provisioning
diff --git a/docs/content/docs/lume/guide/getting-started/faq.mdx b/docs/content/docs/lume/guide/getting-started/faq.mdx
index 64580d8213..1f5a1d2bba 100644
--- a/docs/content/docs/lume/guide/getting-started/faq.mdx
+++ b/docs/content/docs/lume/guide/getting-started/faq.mdx
@@ -141,11 +141,11 @@ lume run linux-vm
Check VM status with `lume ls`:
-| Status | Description |
-|--------|-------------|
-| `stopped` | VM is not running and ready to start |
-| `running` | VM is running |
-| `provisioning (ipsw_install)` | VM is being created—downloading and installing macOS |
+| Status | Description |
+| --------------------------------- | ----------------------------------------------------- |
+| `stopped` | VM is not running and ready to start |
+| `running` | VM is running |
+| `provisioning (ipsw_install)` | VM is being created—downloading and installing macOS |
| `provisioning (unattended_setup)` | VM is being created—running automated Setup Assistant |
VMs in `provisioning` status are being created asynchronously. Wait for status to change to `stopped` before starting them.
diff --git a/docs/content/docs/lume/guide/getting-started/installation.mdx b/docs/content/docs/lume/guide/getting-started/installation.mdx
index f6cb63021b..4b683bbaeb 100644
--- a/docs/content/docs/lume/guide/getting-started/installation.mdx
+++ b/docs/content/docs/lume/guide/getting-started/installation.mdx
@@ -22,6 +22,7 @@ source ~/.zshrc
```
Or restart your terminal after the first command.
+
</Callout>
### Verify it worked
@@ -47,11 +48,11 @@ If you see version output, you're ready to [create your first VM](/lume/guide/ge
The default install includes a background service and auto-updater. You can disable either:
-| Option | Command |
-|--------|---------|
-| No background service | `install.sh -- --no-background-service` |
-| No auto-updates | `install.sh -- --no-auto-updater` |
-| Neither | `install.sh -- --no-background-service --no-auto-updater` |
+| Option | Command |
+| --------------------- | --------------------------------------------------------- |
+| No background service | `install.sh -- --no-background-service` |
+| No auto-updates | `install.sh -- --no-auto-updater` |
+| Neither | `install.sh -- --no-background-service --no-auto-updater` |
Full command with options:
@@ -60,7 +61,8 @@ Full command with options:
```
<Callout type="info">
-Without the background service, you'll need to run `lume serve` manually when using tools that rely on the Lume API (like the Computer Use Agent).
+ Without the background service, you'll need to run `lume serve` manually when using tools that
+ rely on the Lume API (like the Computer Use Agent).
</Callout>
## Manual installation
@@ -104,23 +106,28 @@ rm ~/Library/LaunchAgents/com.trycua.lume_updater.plist
## Uninstall
-Remove Lume with a single command:
+Remove Lume completely:
```bash
-/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/uninstall.sh)"
-```
+# Stop and remove background service
+launchctl unload ~/Library/LaunchAgents/com.trycua.lume_daemon.plist 2>/dev/null
+rm -f ~/Library/LaunchAgents/com.trycua.lume_daemon.plist
-This stops all services, removes the binary, and cleans up LaunchAgents while preserving your VMs and configuration.
+# Stop and remove auto-updater
+launchctl unload ~/Library/LaunchAgents/com.trycua.lume_updater.plist 2>/dev/null
+rm -f ~/Library/LaunchAgents/com.trycua.lume_updater.plist
+rm -f ~/.local/bin/lume-update
-To also remove all VMs and data, use the `--purge` flag:
+# Optional: Remove cached images (run before removing binary)
+lume prune
-```bash
-/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/uninstall.sh)" -- --purge
-```
+# Remove Lume binary
+rm -f $(which lume)
-<Callout type="warn">
-The `--purge` flag permanently deletes all VMs in `~/.lume/` and configuration in `~/.config/lume/`. This cannot be undone.
-</Callout>
+# Optional: Remove VMs and config
+rm -rf ~/.lume
+rm -rf ~/.config/lume
+```
## Troubleshooting
diff --git a/docs/content/docs/lume/guide/getting-started/introduction.mdx b/docs/content/docs/lume/guide/getting-started/introduction.mdx
index f2dbe35a63..bcbaddebfe 100644
--- a/docs/content/docs/lume/guide/getting-started/introduction.mdx
+++ b/docs/content/docs/lume/guide/getting-started/introduction.mdx
@@ -8,11 +8,14 @@ import { Callout } from 'fumadocs-ui/components/callout';
Lume is a VM runtime for building AI agents, running CI/CD pipelines, and automating macOS. It uses Apple's native Virtualization Framework to run macOS and Linux VMs at near-native speed on Apple Silicon.
<Callout type="info" title="MIT License">
-Lume is open-source and MIT licensed. If you find it useful, we'd appreciate a [star on GitHub](https://github.com/trycua/cua)!
+ Lume is open-source and MIT licensed. If you find it useful, we'd appreciate a [star on
+ GitHub](https://github.com/trycua/cua)!
</Callout>
<Callout type="info" title="Cloud macOS Sandboxes">
-We're piloting a managed service for customers who want to run cloud macOS sandboxes for CI/CD and agent workloads. [Book a demo](https://cal.com/cua/cua-demo?overlayCalendar=true) if you're interested.
+ We're piloting a managed service for customers who want to run cloud macOS sandboxes for CI/CD and
+ agent workloads. [Book a demo](https://cal.com/cua/cua-demo?overlayCalendar=true) if you're
+ interested.
</Callout>
```bash
@@ -52,7 +55,10 @@ Lume is a thin layer over Apple's [Virtualization Framework](https://developer.a
**Building AI agents** — Lume powers the [Cua Computer SDK](/cua/reference/computer-sdk), providing VMs that AI models can interact with through screenshots and input simulation.
<Callout type="info" title="Used by Anthropic">
-Apple's Virtualization Framework—the same technology Lume is built on—powers [Claude Cowork](https://support.claude.com/en/articles/13345190-getting-started-with-cowork), Anthropic's sandboxed environment for Claude Code. It downloads a Linux root filesystem and boots it in an isolated VM where Claude can safely execute commands without access to your broader system.
+ Apple's Virtualization Framework—the same technology Lume is built on—powers [Claude
+ Cowork](https://support.claude.com/en/articles/13345190-getting-started-with-cowork), Anthropic's
+ sandboxed environment for Claude Code. It downloads a Linux root filesystem and boots it in an
+ isolated VM where Claude can safely execute commands without access to your broader system.
</Callout>
## What Lume doesn't do
diff --git a/docs/content/docs/lume/guide/getting-started/quickstart.mdx b/docs/content/docs/lume/guide/getting-started/quickstart.mdx
index 19f5b5cdaa..976c5a46cf 100644
--- a/docs/content/docs/lume/guide/getting-started/quickstart.mdx
+++ b/docs/content/docs/lume/guide/getting-started/quickstart.mdx
@@ -38,7 +38,8 @@ lume create my-vm --os macos --ipsw latest
```
<Callout type="info">
-The IPSW file is ~15GB. If you plan to create multiple VMs, downloading manually and reusing the file saves time and bandwidth.
+ The IPSW file is ~15GB. If you plan to create multiple VMs, downloading manually and reusing the
+ file saves time and bandwidth.
</Callout>
## Configure VM storage location (optional)
@@ -67,7 +68,8 @@ lume create my-vm --os macos --ipsw latest --storage /path/to/vm/directory
```
<Callout type="info">
-VM disk images can grow large (~50GB+). Using an external SSD keeps your internal storage free and can improve performance for I/O-heavy workloads.
+ VM disk images can grow large (~50GB+). Using an external SSD keeps your internal storage free and
+ can improve performance for I/O-heavy workloads.
</Callout>
## Create a Linux VM
@@ -86,7 +88,8 @@ lume run ubuntu-vm
```
<Callout type="info">
-Linux VMs require ARM64 ISO images (not x86). Ubuntu, Debian, and Fedora all provide ARM64 server and desktop images.
+ Linux VMs require ARM64 ISO images (not x86). Ubuntu, Debian, and Fedora all provide ARM64 server
+ and desktop images.
</Callout>
## Run your VM
@@ -97,10 +100,6 @@ lume run my-vm
A VNC window opens. For macOS VMs, you'll see the Setup Assistant—complete it manually or use [Unattended Setup](/lume/guide/fundamentals/unattended-setup) to automate it.
-<Callout type="info">
-**Automatic clipboard sync:** When Remote Login (SSH) is enabled on your VM, Lume automatically syncs clipboard between your Mac and the VM in both directions. Copy on your Mac, paste in the VM—or copy in the VM, paste on your Mac. VMs created with `--unattended` have SSH enabled by default.
-</Callout>
-
## Create a VM with custom resources
By default, Lume creates VMs with 4 CPU cores, 8GB memory, and a 50GB disk. Override any of these:
@@ -112,11 +111,11 @@ lume create dev-vm --os macos --ipsw latest \
--disk-size 100GB
```
-| Resource | Default | Notes |
-|----------|---------|-------|
-| CPU | 4 cores | Max is your Mac's core count |
-| Memory | 8GB | Leave headroom for your host |
-| Disk | 50GB | Uses sparse files—only consumes actual usage |
+| Resource | Default | Notes |
+| -------- | ------- | -------------------------------------------- |
+| CPU | 4 cores | Max is your Mac's core count |
+| Memory | 8GB | Leave headroom for your host |
+| Disk | 50GB | Uses sparse files—only consumes actual usage |
## Change display resolution
@@ -128,12 +127,12 @@ lume set my-vm --display 1920x1080
The change takes effect on the next VM start. After starting the VM, go to **System Settings → Displays**, enable **Show all resolutions**, and select your new resolution. Common resolutions:
-| Resolution | Aspect Ratio | Use Case |
-|------------|--------------|----------|
-| 1024x768 | 4:3 | Default, low resource usage |
-| 1280x800 | 16:10 | MacBook-style |
-| 1920x1080 | 16:9 | Full HD |
-| 2560x1440 | 16:9 | QHD |
+| Resolution | Aspect Ratio | Use Case |
+| ---------- | ------------ | --------------------------- |
+| 1024x768 | 4:3 | Default, low resource usage |
+| 1280x800 | 16:10 | MacBook-style |
+| 1920x1080 | 16:9 | Full HD |
+| 2560x1440 | 16:9 | QHD |
## Automate the Setup Assistant
@@ -143,7 +142,7 @@ Skip manual setup entirely with the `--unattended` flag:
lume create my-vm --os macos --ipsw latest --unattended tahoe
```
-The `tahoe` preset runs through the Setup Assistant automatically, creating a user `lume` with password `lume` and enabling Remote Login (SSH). Once complete, you can connect with `lume ssh my-vm`. This takes 10-15 minutes but requires no interaction.
+The `tahoe` preset runs through the Setup Assistant automatically, creating a user `lume` with password `lume` and enabling SSH. This takes 10-15 minutes but requires no interaction.
For custom configurations, see [Unattended Setup](/lume/guide/fundamentals/unattended-setup).
@@ -160,7 +159,7 @@ lume run my-vm --no-display
lume run my-vm > /dev/null 2>&1 &
```
-When running headless or in background, connect via `lume ssh my-vm` (if Remote Login is enabled) or a VNC client. Use `lume ls` to see running VMs and their connection details.
+When running headless or in background, connect via SSH (if enabled) or VNC client. Use `lume ls` to see running VMs and their connection details.
## Common operations
@@ -181,33 +180,6 @@ lume clone my-vm my-vm-backup
lume delete my-vm
```
-## Connect via SSH
-
-Access your VM from the terminal without needing the VNC window:
-
-```bash
-# Interactive shell
-lume ssh my-vm
-
-# Run a single command
-lume ssh my-vm "ls -la"
-
-# Run multiple commands
-lume ssh my-vm "cd /tmp && pwd"
-```
-
-<Callout type="warn">
-**SSH requires Remote Login to be enabled on the VM.** Either:
-- Create the VM with `--unattended` (enables SSH automatically with user `lume`, password `lume`)
-- Or manually enable it: **System Settings → General → Sharing → Remote Login**
-</Callout>
-
-Custom credentials:
-
-```bash
-lume ssh my-vm -u myuser -p mypassword
-```
-
## Share files with your VM
Mount a host directory inside the VM:
diff --git a/docs/content/docs/lume/reference/changelog.mdx b/docs/content/docs/lume/reference/changelog.mdx
new file mode 100644
index 0000000000..abfec79aa1
--- /dev/null
+++ b/docs/content/docs/lume/reference/changelog.mdx
@@ -0,0 +1,441 @@
+---
+title: Changelog
+description: Release history for Lume
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/generate-changelog.ts
+Last updated: 2026-02-04
+*/}
+
+# Lume Changelog
+
+All notable changes to the Lume are documented here.
+
+## 0.2.x
+
+### v0.2.76 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.75 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.74 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.73 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.72 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.71 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.70 (2026-02-03)
+
+Maintenance release.
+
+### v0.2.69 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.68 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.67 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.66 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.65 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.64 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.63 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.62 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.61 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.60 (2026-02-02)
+
+Maintenance release.
+
+### v0.2.59 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.58 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.57 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.56 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.55 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.54 (2026-02-01)
+
+Maintenance release.
+
+### v0.2.52 (2026-01-25)
+
+Maintenance release.
+
+### v0.2.51 (2026-01-21)
+
+Maintenance release.
+
+### v0.2.50 (2026-01-21)
+
+Maintenance release.
+
+### v0.2.49 (2026-01-21)
+
+Maintenance release.
+
+### v0.2.46 (2026-01-20)
+
+Maintenance release.
+
+### v0.2.45 (2026-01-19)
+
+Maintenance release.
+
+### v0.2.44 (2026-01-19)
+
+Maintenance release.
+
+### v0.2.43 (2026-01-19)
+
+Maintenance release.
+
+### v0.2.42 (2026-01-19)
+
+Maintenance release.
+
+### v0.2.41 (2026-01-19)
+
+Maintenance release.
+
+### v0.2.40 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.39 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.38 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.37 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.36 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.34 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.33 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.32 (2026-01-18)
+
+Maintenance release.
+
+### v0.2.31 (2026-01-17)
+
+Maintenance release.
+
+### v0.2.30 (2026-01-17)
+
+Maintenance release.
+
+### v0.2.29 (2026-01-17)
+
+Maintenance release.
+
+### v0.2.28 (2026-01-17)
+
+Maintenance release.
+
+### v0.2.27 (2026-01-11)
+
+Maintenance release.
+
+### v0.2.26 (2026-01-11)
+
+Maintenance release.
+
+### v0.2.25 (2026-01-11)
+
+Maintenance release.
+
+### v0.2.23 (2025-12-23)
+
+- Update README badges with sky/emerald colors and larger logo by @f-trycua in https://github.com/trycua/cua/pull/641
+- Add QEMU Ubuntu 22.04 template with CUA computer-server support by @synacktraa in https://github.com/trycua/cua/pull/622
+- Add QEMU Windows 11 template with CUA computer-server support by @synacktraa in https://github.com/trycua/cua/pull/551
+- docs: update intro page with hero image and Geist font by @f-trycua in https://github.com/trycua/cua/pull/642
+- docs: expand CUA description with screenshot-VLM-action loop by @f-trycua in https://github.com/trycua/cua/pull/643
+- F trycua/docs hero image by @f-trycua in https://github.com/trycua/cua/pull/644
+- Introduce cua-bench-ui submodules (webview API, configurable ports, improved python RPC) by @ddupont808 in https://github.com/trycua/cua/pull/645
+- Replace PyQt6 with PySide6 by @ddupont808 in https://github.com/trycua/cua/pull/646
+- Bump cua-bench-ui version in xfce Dockerfile by @ddupont808 in https://github.com/trycua/cua/pull/647
+- Replace qt backend with gtk in xfce Docker image by @ddupont808 in https://github.com/trycua/cua/pull/648
+- fix(docs): broken link references for docs by @sarinali in https://github.com/trycua/cua/pull/652
+- fix(docs): document cloud models by @sarinali in https://github.com/trycua/cua/pull/651
+- Refactor Docker publish workflow to correctly build and publish multi-arch images by @synacktraa in https://github.com/trycua/cua/pull/653
+- Refactor Python quickstart examples to use asyncio by @LucaStngn in https://github.com/trycua/cua/pull/650
+- fix(lume): Resolve install script downloading wrong release by @synacktraa in https://github.com/trycua/cua/pull/655
+
+### v0.2.22 (2025-06-17)
+
+Maintenance release.
+
+### v0.2.16 (2025-06-16)
+
+- Add .devcontainer and Dockerfile fixes by @ddupont808 in https://github.com/trycua/cua/pull/287
+- [Agent] Removed extra screenshots in OpenAI/Anthropic tools, fixed image retention bug by @ddupont808 in https://github.com/trycua/cua/pull/291
+
+### v0.2.15 (2025-05-23)
+
+- Lumier computer provider takes non-trycua image by @jklapacz in https://github.com/trycua/cua/pull/181
+- Added Cmake dep to playground.sh by @ddupont808 in https://github.com/trycua/cua/pull/184
+
+### v0.2.14 (2025-05-14)
+
+- [Computer] Add initial VM Provider by @f-trycua in https://github.com/trycua/cua/pull/162
+
+### v0.2.13 (2025-05-11)
+
+- Add clipboard and audio device by @f-trycua in https://github.com/trycua/cua/pull/170
+
+### v0.2.12 (2025-05-07)
+
+- Replaced remaining `os=` occurances with `os_type=` by @ddupont808 in https://github.com/trycua/cua/pull/159
+- Prevent install if sudo by @f-trycua in https://github.com/trycua/cua/pull/161
+
+### v0.2.11 (2025-05-06)
+
+Maintenance release.
+
+### v0.2.10 (2025-05-06)
+
+Maintenance release.
+
+### v0.2.9 (2025-05-05)
+
+- [Agent] Add standardized agent trajectory logging by @ddupont808 in https://github.com/trycua/cua/pull/155
+
+### v0.2.8 (2025-05-02)
+
+Maintenance release.
+
+### v0.2.7 (2025-04-30)
+
+Maintenance release.
+
+### v0.2.6 (2025-04-29)
+
+- docs: fix wait action in blog notebook by @FinnBorge in https://github.com/trycua/cua/pull/142
+- [Lumier] Introduce Lumier - Docker-based macOS VM Management Interface by @f-trycua in https://github.com/trycua/cua/pull/144
+
+New Contributors
+
+- @FinnBorge made their first contribution in https://github.com/trycua/cua/pull/142
+
+### v0.2.5 (2025-04-25)
+
+Maintenance release.
+
+### v0.2.4 (2025-04-24)
+
+- [Root] Fix root py project toml by @f-trycua in https://github.com/trycua/cua/pull/133
+- Update Mac identifier during clone process by @dp221125 in https://github.com/trycua/cua/pull/130
+
+New Contributors
+
+- @dp221125 made their first contribution in https://github.com/trycua/cua/pull/130
+
+### v0.2.3 (2025-04-23)
+
+Maintenance release.
+
+### v0.2.2 (2025-04-22)
+
+Maintenance release.
+
+### v0.2.1 (2025-04-22)
+
+Maintenance release.
+
+### v0.2.0 (2025-04-22)
+
+- [Computer] Add Gradio UI and fix interaction bugs by @ddupont808 in https://github.com/trycua/cua/pull/116
+- Docs: Add EasyOCR SSL & Lume VM Startup Troubleshooting to FAQ by @trospix in https://github.com/trycua/cua/pull/114
+- [Lume] Fix broken storage tests by @f-trycua in https://github.com/trycua/cua/pull/107
+- docs: add trospix as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/115
+- docs: add eltociear as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/121
+- docs: update computer/README.md by @eltociear in https://github.com/trycua/cua/pull/119
+- [Lume] Sparse Push & Pull Optimizations by @f-trycua in https://github.com/trycua/cua/pull/122
+
+New Contributors
+
+- @trospix made their first contribution in https://github.com/trycua/cua/pull/114
+- @eltociear made their first contribution in https://github.com/trycua/cua/pull/119
+
+## 0.1.x
+
+### v0.1.38 (2025-04-15)
+
+Maintenance release.
+
+### v0.1.37 (2025-04-15)
+
+Maintenance release.
+
+### v0.1.36 (2025-04-15)
+
+Maintenance release.
+
+### v0.1.35 (2025-04-15)
+
+- Update install_mcp_server.sh - remove piping to /dev/null by @rahulkarajgikar in https://github.com/trycua/cua/pull/110
+- docs: add rahulkarajgikar as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/111
+- Support py >= 3.13 by @f-trycua in https://github.com/trycua/cua/pull/112
+
+New Contributors
+
+- @rahulkarajgikar made their first contribution in https://github.com/trycua/cua/pull/110
+
+### v0.1.34 (2025-04-14)
+
+- [Lume] Add multiple VM locations and configurable cache by @f-trycua in https://github.com/trycua/cua/pull/91
+
+### v0.1.33 (2025-04-14)
+
+- [Agent] Improved Gradio UI by @ddupont808 in https://github.com/trycua/cua/pull/104
+
+### v0.1.32 (2025-04-12)
+
+- [Lume] Optimize VM image assembly by @f-trycua in https://github.com/trycua/cua/pull/102
+
+### v0.1.31 (2025-04-11)
+
+- [Agent] Fix leftover Gradio docs by @f-trycua in https://github.com/trycua/cua/pull/97
+- docs: add RicterZ as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/98
+- [Lume] Fix reassemble kill by @f-trycua in https://github.com/trycua/cua/pull/99
+
+### v0.1.30 (2025-04-07)
+
+Maintenance release.
+
+### v0.1.29 (2025-04-07)
+
+Maintenance release.
+
+### v0.1.28 (2025-04-07)
+
+Maintenance release.
+
+### v0.1.27 (2025-04-07)
+
+Maintenance release.
+
+### v0.1.26 (2025-04-06)
+
+- Fix anthropic format in omni loop by @f-trycua in https://github.com/trycua/cua/pull/94
+
+### v0.1.25 (2025-04-06)
+
+Maintenance release.
+
+### v0.1.24 (2025-04-06)
+
+- [Agent] Add Gradio UI & OAI-Compatible Provider by @f-trycua in https://github.com/trycua/cua/pull/93
+
+### v0.1.23 (2025-04-04)
+
+- Add ai-gradio notebook by @f-trycua in https://github.com/trycua/cua/pull/85
+- Update README with gradio by @f-trycua in https://github.com/trycua/cua/pull/86
+- [SOM] Fix overlapping bounding boxes and added GPU/MPS support by @ddupont808 in https://github.com/trycua/cua/pull/87
+- Add Ollama support in Omni parser by @Lizzard1123 in https://github.com/trycua/cua/pull/76
+- docs: add ddupont808 as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/88
+- docs: add Lizzard1123 as a contributor for code by @allcontributors in https://github.com/trycua/cua/pull/89
+- [Agent] Add ollama support by @f-trycua in https://github.com/trycua/cua/pull/90
+
+New Contributors
+
+- @ddupont808 made their first contribution in https://github.com/trycua/cua/pull/87
+- @Lizzard1123 made their first contribution in https://github.com/trycua/cua/pull/76
+
+### v0.1.22 (2025-04-02)
+
+- Refactor Developer Guide by @f-trycua in https://github.com/trycua/cua/pull/77
+- Add operator blogpost - part 1 by @f-trycua in https://github.com/trycua/cua/pull/80
+- [Agent] Add OpenAI generate summary by @f-trycua in https://github.com/trycua/cua/pull/84
+
+### v0.1.21 (2025-03-30)
+
+Maintenance release.
+
+### v0.1.20 (2025-03-30)
+
+- [Lume] Optimize disk image reassembly for performance and storage by @f-trycua in https://github.com/trycua/cua/pull/72
+
+### v0.1.19 (2025-03-24)
+
+- Add `--no-cache` option in lume pull by @aktech in https://github.com/trycua/cua/pull/67
+
+### v0.1.18 (2025-03-19)
+
+Maintenance release.
+
+### v0.1.17 (2025-03-17)
+
+Maintenance release.
+
+### v0.1.16 (2025-03-17)
+
+Maintenance release.
+
+### v0.1.14 (2025-03-17)
+
+- Fix url for clone endpoint by @aktech in https://github.com/trycua/computer/pull/54
diff --git a/docs/content/docs/lume/reference/cli-reference.mdx b/docs/content/docs/lume/reference/cli-reference.mdx
index 800ea54aec..a8c3427314 100644
--- a/docs/content/docs/lume/reference/cli-reference.mdx
+++ b/docs/content/docs/lume/reference/cli-reference.mdx
@@ -1,5 +1,5 @@
---
-title: Lume CLI Reference
+title: CLI Reference
description: Command Line Interface reference for Lume
---
@@ -7,9 +7,19 @@ description: Command Line Interface reference for Lume
AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
Generated by: npx tsx scripts/docs-generators/lume.ts
Source: libs/lume/src/Commands/*.swift
+ Version: 0.2.76
*/}
import { Callout } from 'fumadocs-ui/components/callout';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"0.2","href":"/lume/reference/cli-reference","isCurrent":true}]}
+ currentVersion="0.2"
+ fullVersion="0.2.76"
+ packageName="lume"
+ installCommand="curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh | bash"
+/>
A lightweight CLI and local API server to build, run and manage macOS VMs.
@@ -17,7 +27,7 @@ A lightweight CLI and local API server to build, run and manage macOS VMs.
```bash
# Run a prebuilt macOS VM
-lume run macos-sequoia-vanilla:latest
+lume run macos-tahoe-vanilla:latest
# Create a custom VM
lume create my-vm --cpu 4 --memory 8GB --disk-size 50GB
@@ -156,24 +166,6 @@ List virtual machines
- `-f, --format` - Output format (json or text) (default: text)
- `--storage` - Filter by storage location name
-## Remote Access
-
-### lume ssh
-
-Connect to a VM via SSH or execute commands remotely
-
-**Arguments:**
-
-- `<name>` - Name of the virtual machine
-- `<command>` - Command to execute (omit for interactive shell) (optional)
-
-**Options:**
-
-- `-u, --user` - SSH username (default: lume)
-- `-p, --password` - SSH password (default: lume)
-- `--storage` - Storage location name or path
-- `-t, --timeout` - Command timeout in seconds (0 for no timeout) (default: 60)
-
## Image Management
### lume pull
diff --git a/docs/content/docs/lume/reference/http-api.mdx b/docs/content/docs/lume/reference/http-api.mdx
index c7be47c4db..524738783a 100644
--- a/docs/content/docs/lume/reference/http-api.mdx
+++ b/docs/content/docs/lume/reference/http-api.mdx
@@ -1,5 +1,5 @@
---
-title: Lume HTTP API Reference
+title: API Reference
description: HTTP API reference for Lume server
---
@@ -7,10 +7,20 @@ description: HTTP API reference for Lume server
AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
Generated by: npx tsx scripts/docs-generators/lume.ts
Source: libs/lume/src/Server/*.swift
+ Version: 0.2.76
*/}
import { Callout } from 'fumadocs-ui/components/callout';
import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
+
+<VersionHeader
+ versions={[{"version":"0.2","href":"/lume/reference/cli-reference","isCurrent":true}]}
+ currentVersion="0.2"
+ fullVersion="0.2.76"
+ packageName="lume"
+ installCommand="curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh | bash"
+/>
HTTP API for managing macOS and Linux virtual machines
@@ -589,7 +599,7 @@ Pull a VM image from a container registry
curl -X POST "http://localhost:7777/lume/pull" \
-H "Content-Type: application/json" \
-d '{
- "image": "macos-sequoia-vanilla:latest"
+ "image": "macos-tahoe-vanilla:latest"
}'
```
</Tab>
@@ -598,7 +608,7 @@ curl -X POST "http://localhost:7777/lume/pull" \
import requests
data = {
- "image": "macos-sequoia-vanilla:latest",
+ "image": "macos-tahoe-vanilla:latest",
}
response = requests.post("http://localhost:7777/lume/pull", json=data)
@@ -611,7 +621,7 @@ const response = await fetch(`http://localhost:7777/lume/pull`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
- image: "macos-sequoia-vanilla:latest",
+ image: "macos-tahoe-vanilla:latest",
}),
});
const data = await response.json();
diff --git a/docs/content/docs/lume/reference/meta.json b/docs/content/docs/lume/reference/meta.json
index bb4d7c192b..8af3a48a14 100644
--- a/docs/content/docs/lume/reference/meta.json
+++ b/docs/content/docs/lume/reference/meta.json
@@ -2,5 +2,5 @@
"title": "Reference",
"description": "CLI and API reference documentation",
"icon": "FileText",
- "pages": ["cli-reference", "http-api"]
+ "pages": ["cli-reference", "http-api", "changelog"]
}
diff --git a/docs/content/docs/lume/reference/v0.2/cli-reference.mdx b/docs/content/docs/lume/reference/v0.2/cli-reference.mdx
new file mode 100644
index 0000000000..2842b77473
--- /dev/null
+++ b/docs/content/docs/lume/reference/v0.2/cli-reference.mdx
@@ -0,0 +1,295 @@
+---
+title: Lume CLI Reference
+description: Command Line Interface reference for Lume
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/lume.ts
+Source: libs/lume/src/Commands/*.swift
+Version: 0.2.75
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { VersionHeader } from '@/components/version-selector';
+
+<Callout type="warn">
+ This is documentation for **v0.2**. [View latest version](/lume/reference/cli-reference).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.2.75
+ </span>
+ <span className="text-sm text-fd-muted-foreground">curl -fsSL .../install.sh | bash</span>
+</div>
+
+A lightweight CLI and local API server to build, run and manage macOS VMs.
+
+## Quick Start
+
+```bash
+# Run a prebuilt macOS VM
+lume run macos-sequoia-vanilla:latest
+
+# Create a custom VM
+lume create my-vm --cpu 4 --memory 8GB --disk-size 50GB
+```
+
+## VM Management
+
+### lume create
+
+Create a new virtual machine
+
+**Arguments:**
+
+- `<name>` - Name for the virtual machine
+
+**Options:**
+
+- `--os` - Operating system to install (macOS or linux) (default: macOS)
+- `--cpu` - Number of CPU cores (default: 4)
+- `--memory` - Memory size (e.g., 8GB) (default: 8GB)
+- `--disk-size` - Disk size (e.g., 50GB) (default: 50GB)
+- `--display` - Display resolution (e.g., 1024x768) (default: 1024x768)
+- `--ipsw` - Path to IPSW file or 'latest' for macOS VMs
+- `--storage` - VM storage location to use
+- `--unattended` - [Preview] Preset name or path to YAML config file for unattended macOS Setup Assistant automation. Built-in presets: sequoia, tahoe. Only supported for macOS VMs.
+- `--debug-dir` - Custom directory for debug screenshots during unattended setup (defaults to unique folder in system temp)
+- `--vnc-port` - Port to use for the VNC server during unattended setup. Defaults to 0 (auto-assign) (default: 0)
+
+**Flags:**
+
+- `--debug` - Enable debug mode for unattended setup - saves screenshots with click coordinates
+- `--no-display` - Do not open the VNC client during unattended setup (default: true for unattended)
+
+### lume clone
+
+Clone an existing virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the source VM
+- `<new-name>` - Name for the cloned VM
+
+**Options:**
+
+- `--source-storage` - Source VM storage location
+- `--dest-storage` - Destination VM storage location
+
+### lume run
+
+Run a virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the VM or image to run (format: name or name:tag)
+
+**Options:**
+
+- `--shared-dir` - Directory to share with the VM (format: path or path:ro or path:rw)
+- `--mount` - For Linux VMs only, attach a read-only disk image
+- `--usb-storage` - Disk image to attach as USB mass storage device
+- `--registry` - Container registry URL (default: ghcr.io)
+- `--organization` - Organization to pull from (default: trycua)
+- `--vnc-port` - Port for VNC server (0 for auto-assign) (default: 0)
+- `--recovery-mode` - For macOS VMs only, boot in recovery mode (default: false)
+- `--storage` - VM storage location to use
+
+**Flags:**
+
+- `-d, --no-display` - Do not start the VNC client
+
+### lume stop
+
+Stop a virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the VM to stop
+
+**Options:**
+
+- `--storage` - VM storage location to use
+
+### lume delete
+
+Delete a virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the VM to delete
+
+**Options:**
+
+- `--storage` - VM storage location to use
+
+**Flags:**
+
+- `--force` - Force deletion without confirmation
+
+## VM Information and Configuration
+
+### lume get
+
+Get detailed information about a virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the VM
+
+**Options:**
+
+- `-f, --format` - Output format (default: text)
+- `--storage` - VM storage location to use
+
+### lume set
+
+Set new values for CPU, memory, and disk size of a virtual machine
+
+**Arguments:**
+
+- `<name>` - Name of the VM
+
+**Options:**
+
+- `--cpu` - New number of CPU cores
+- `--memory` - New memory size (e.g., 8GB)
+- `--disk-size` - New disk size (e.g., 100GB)
+- `--display` - New display resolution
+- `--storage` - VM storage location to use
+
+### lume ls
+
+List virtual machines
+
+**Options:**
+
+- `-f, --format` - Output format (json or text) (default: text)
+- `--storage` - Filter by storage location name
+
+## Image Management
+
+### lume pull
+
+Pull a macOS image from GitHub Container Registry
+
+**Arguments:**
+
+- `<image>` - Image to pull (format: name:tag)
+- `<name>` - Name for the resulting VM (optional)
+
+**Options:**
+
+- `--registry` - Container registry URL (default: ghcr.io)
+- `--organization` - Organization to pull from (default: trycua)
+- `--storage` - VM storage location to use
+
+### lume push
+
+Push a macOS VM to GitHub Container Registry
+
+**Arguments:**
+
+- `<name>` - Name of VM to push
+- `<image>` - Image tag (format: name:tag)
+
+**Options:**
+
+- `--additional-tags` - Additional tags to push
+- `--registry` - Container registry URL (default: ghcr.io)
+- `--organization` - Organization to push to (default: trycua)
+- `--storage` - VM storage location to use
+- `--chunk-size-mb` - Chunk size for upload in MB (default: 512)
+
+**Flags:**
+
+- `--verbose` - Enable verbose logging
+- `--dry-run` - Prepare files without uploading
+- `--reassemble` - Verify integrity by reassembling chunks
+
+### lume images
+
+List available macOS images from local cache
+
+**Options:**
+
+- `--organization` - Organization to list images for (default: trycua)
+
+### lume ipsw
+
+Get macOS restore image IPSW URL
+
+### lume prune
+
+Remove cached images
+
+## Configuration and Server
+
+### lume serve
+
+Start the VM management server
+
+**Options:**
+
+- `--port` - Port to listen on (default: 7777)
+
+### lume config
+
+Get or set lume configuration
+
+**Subcommands:**
+
+- `lume config get` - Get current configuration
+- `lume config storage` - Manage VM storage locations
+ - `lume config storage add` - Add a new VM storage location
+ - `lume config storage remove` - Remove a VM storage location
+ - `lume config storage list` - List all VM storage locations
+ - `lume config storage default` - Set the default VM storage location
+- `lume config cache` - Manage cache settings
+ - `lume config cache get` - Get current cache directory
+ - `lume config cache set` - Set cache directory
+- `lume config caching` - Manage image caching settings
+ - `lume config caching get` - Show current caching status
+ - `lume config caching set` - Enable or disable image caching
+
+### lume logs
+
+View lume serve logs
+
+**Subcommands:**
+
+- `lume logs info` - View info logs from the daemon
+ - `-n, --lines` - Number of lines to display
+- `lume logs error` - View error logs from the daemon
+ - `-n, --lines` - Number of lines to display
+- `lume logs all` - View both info and error logs
+ - `-n, --lines` - Number of lines to display
+
+### lume setup
+
+[Preview] Run unattended Setup Assistant automation on a macOS VM
+
+**Arguments:**
+
+- `<name>` - Name of the virtual machine
+
+**Options:**
+
+- `--unattended` - Preset name or path to YAML config file for unattended macOS Setup Assistant automation. Built-in presets: sequoia, tahoe.
+- `--storage` - VM storage location to use or direct path to VM location
+- `--vnc-port` - Port to use for the VNC server. Defaults to 0 (auto-assign) (default: 0)
+- `--debug-dir` - Custom directory for debug screenshots (defaults to unique folder in system temp)
+
+**Flags:**
+
+- `--no-display` - Do not open the VNC client automatically
+- `--debug` - Enable debug mode - saves screenshots with click coordinates
+
+## Global Options
+
+These options are available for all commands:
+
+- `--help` - Show help information
+- `--version` - Show version number
diff --git a/docs/content/docs/lume/reference/v0.2/http-api.mdx b/docs/content/docs/lume/reference/v0.2/http-api.mdx
new file mode 100644
index 0000000000..fa9715f6a3
--- /dev/null
+++ b/docs/content/docs/lume/reference/v0.2/http-api.mdx
@@ -0,0 +1,1114 @@
+---
+title: Lume HTTP API Reference
+description: HTTP API reference for Lume server
+---
+
+{/*
+AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
+Generated by: npx tsx scripts/docs-generators/lume.ts
+Source: libs/lume/src/Server/*.swift
+Version: 0.2.75
+*/}
+
+import { Callout } from 'fumadocs-ui/components/callout';
+import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
+import { VersionHeader } from '@/components/version-selector';
+
+<Callout type="warn">
+ This is documentation for **v0.2**. [View latest version](/lume/reference/cli-reference).
+</Callout>
+
+<div className="flex items-center gap-2 mb-6">
+ <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">
+ v0.2.75
+ </span>
+ <span className="text-sm text-fd-muted-foreground">curl -fsSL .../install.sh | bash</span>
+</div>
+
+HTTP API for managing macOS and Linux virtual machines
+
+## Default URL
+
+```
+http://localhost:7777
+```
+
+Start the server with `lume serve` or specify a custom port with `lume serve --port <port>`.
+
+## VM Management
+
+### All virtual machines
+
+List all virtual machines
+
+`GET: /lume/vms`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ------- | ------ | -------- | ------------------------------- |
+| storage | string | No | Filter by storage location name |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/vms"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/vms")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Bad request
+
+---
+
+### Detailed information about a specific virtual machine
+
+Get detailed information about a specific virtual machine
+
+`GET: /lume/vms/:name`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ------- | ------ | -------- | -------------------------- |
+| name | string | Yes | Name of the VM |
+| storage | string | No | VM storage location to use |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/vms/{name}"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/vms/{name}")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/${name}`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: VM not found or invalid request
+
+---
+
+### A new virtual machine
+
+Create a new virtual machine
+
+`POST: /lume/vms`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| -------- | ------- | -------- | -------------------------------------------- |
+| name | string | Yes | Name for the virtual machine |
+| os | string | Yes | Operating system to install (macOS or linux) |
+| cpu | integer | Yes | Number of CPU cores |
+| memory | string | Yes | Memory size (e.g., 8GB) |
+| diskSize | string | Yes | Disk size (e.g., 50GB) |
+| display | string | Yes | Display resolution (e.g., 1024x768) |
+| ipsw | string | No | Path to IPSW file or 'latest' for macOS VMs |
+| storage | string | No | VM storage location to use |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/vms" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "name": "my-vm",
+ "os": "macOS",
+ "cpu": 4,
+ "memory": "8GB",
+ "diskSize": "50GB",
+ "display": "1024x768"
+}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+"name": "my-vm",
+"os": "macOS",
+"cpu": 4,
+"memory": "8GB",
+"diskSize": "50GB",
+"display": "1024x768",
+}
+
+response = requests.post("http://localhost:7777/lume/vms", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ name: "my-vm",
+ os: "macOS",
+ cpu: 4,
+ memory: "8GB",
+ diskSize: "50GB",
+ display: "1024x768",
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: VM created successfully
+- **400**: Invalid request body or VM creation failed
+
+---
+
+### A virtual machine and its associated files
+
+Delete a virtual machine and its associated files
+
+`DELETE: /lume/vms/:name`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ------- | ------ | -------- | ------------------------ |
+| name | string | Yes | Name of the VM to delete |
+| storage | string | No | VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X DELETE "http://localhost:7777/lume/vms/{name}"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.delete("http://localhost:7777/lume/vms/{name}")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/${name}`, {
+ method: "DELETE",
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: VM deleted successfully
+- **400**: VM not found or deletion failed
+
+---
+
+### A copy of an existing virtual machine
+
+Create a copy of an existing virtual machine
+
+`POST: /lume/vms/clone`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| -------------- | ------ | -------- | ------------------------------- |
+| name | string | Yes | Name of the source VM |
+| newName | string | Yes | Name for the cloned VM |
+| sourceLocation | string | No | Source VM storage location |
+| destLocation | string | No | Destination VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/vms/clone" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "name": "my-vm",
+ "newName": "example"
+}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+"name": "my-vm",
+"newName": "example",
+}
+
+response = requests.post("http://localhost:7777/lume/vms/clone", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/clone`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ name: "my-vm",
+ newName: "example",
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: VM cloned successfully
+- **400**: Clone operation failed
+
+---
+
+### Virtual machine configuration settings
+
+Update virtual machine configuration settings
+
+`PATCH: /lume/vms/:name`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ------------------------ |
+| name | string | Yes | Name of the VM to update |
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| -------- | ------- | -------- | ---------------------------- |
+| cpu | integer | No | New number of CPU cores |
+| memory | string | No | New memory size (e.g., 16GB) |
+| diskSize | string | No | New disk size (e.g., 100GB) |
+| display | string | No | New display resolution |
+| storage | string | No | VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X PATCH "http://localhost:7777/lume/vms/{name}" \
+ -H "Content-Type: application/json" \
+ -d '{}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+}
+
+response = requests.patch("http://localhost:7777/lume/vms/{name}", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/${name}`, {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Settings updated successfully
+- **400**: Invalid settings or update failed
+
+---
+
+### Start a virtual machine
+
+Start a virtual machine
+
+`POST: /lume/vms/:name/run`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ----------------------- |
+| name | string | Yes | Name of the VM to start |
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| ----------------- | ------- | -------- | ----------------------------------------------- |
+| noDisplay | boolean | No | Run without VNC display (default: false) |
+| sharedDirectories | array | No | Directories to share with the VM |
+| recoveryMode | boolean | No | Boot macOS VM in recovery mode (default: false) |
+| storage | string | No | VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/vms/{name}/run" \
+ -H "Content-Type: application/json" \
+ -d '{}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+}
+
+response = requests.post("http://localhost:7777/lume/vms/{name}/run", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/${name}/run`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **202**: VM start initiated (async operation)
+- **400**: Invalid request or VM not found
+
+---
+
+### A running virtual machine
+
+Stop a running virtual machine
+
+`POST: /lume/vms/:name/stop`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ---------------------- |
+| name | string | Yes | Name of the VM to stop |
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| ------- | ------ | -------- | ------------------- |
+| storage | string | No | VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/vms/{name}/stop" \
+ -H "Content-Type: application/json" \
+ -d '{}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+}
+
+response = requests.post("http://localhost:7777/lume/vms/{name}/stop", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/${name}/stop`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: VM stopped successfully
+- **400**: Stop operation failed
+
+---
+
+## Image Management
+
+### Available images from local cache
+
+List available images from local cache
+
+`GET: /lume/images`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ------------ | ------ | -------- | ------------------------------------------------- |
+| organization | string | No | Organization to list images for (default: trycua) |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/images"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/images")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/images`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Failed to list images
+
+---
+
+### The latest macOS restore image (IPSW) URL
+
+Get the latest macOS restore image (IPSW) URL
+
+`GET: /lume/ipsw`
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/ipsw"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/ipsw")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/ipsw`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Failed to get IPSW URL
+
+---
+
+### A VM image from a container registry
+
+Pull a VM image from a container registry
+
+`POST: /lume/pull`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| ------------ | ------ | -------- | ------------------------------------------- |
+| image | string | Yes | Image to pull (format: name:tag) |
+| name | string | No | Name for the resulting VM |
+| registry | string | No | Container registry URL (default: ghcr.io) |
+| organization | string | No | Organization to pull from (default: trycua) |
+| storage | string | No | VM storage location |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/pull" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "image": "macos-sequoia-vanilla:latest"
+}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+"image": "macos-sequoia-vanilla:latest",
+}
+
+response = requests.post("http://localhost:7777/lume/pull", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/pull`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ image: "macos-sequoia-vanilla:latest",
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Image pulled successfully
+- **400**: Pull operation failed
+
+---
+
+### A VM image to a container registry
+
+Push a VM image to a container registry
+
+`POST: /lume/vms/push`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| ------------ | ------- | -------- | ------------------------------------------ |
+| name | string | Yes | Name of the local VM to push |
+| imageName | string | Yes | Base name for the image in the registry |
+| tags | array | Yes | List of tags to push |
+| registry | string | No | Container registry URL (default: ghcr.io) |
+| organization | string | No | Organization to push to (default: trycua) |
+| storage | string | No | VM storage location |
+| chunkSizeMb | integer | No | Chunk size for upload in MB (default: 512) |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/vms/push" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "name": "my-vm",
+ "imageName": "example",
+ "tags": [
+ "latest"
+ ]
+}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+"name": "my-vm",
+"imageName": "example",
+"tags": ["latest"],
+}
+
+response = requests.post("http://localhost:7777/lume/vms/push", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/vms/push`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ name: "my-vm",
+ imageName: "example",
+ tags: ["latest"],
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **202**: Push initiated (async operation)
+- **400**: Invalid request
+
+---
+
+### Cached images to free up disk space
+
+Remove cached images to free up disk space
+
+`POST: /lume/prune`
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/prune"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.post("http://localhost:7777/lume/prune")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/prune`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Images pruned successfully
+- **400**: Prune operation failed
+
+---
+
+## Configuration
+
+### Current Lume configuration settings
+
+Get current Lume configuration settings
+
+`GET: /lume/config`
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/config"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/config")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Failed to get config
+
+---
+
+### Lume configuration settings
+
+Update Lume configuration settings
+
+`POST: /lume/config`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| -------------- | ------- | -------- | ------------------------------- |
+| homeDirectory | string | No | VM home directory path |
+| cacheDirectory | string | No | Cache directory path |
+| cachingEnabled | boolean | No | Enable or disable image caching |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/config" \
+ -H "Content-Type: application/json" \
+ -d '{}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+}
+
+response = requests.post("http://localhost:7777/lume/config", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Configuration updated successfully
+- **400**: Invalid request
+
+---
+
+### All VM storage locations
+
+List all VM storage locations
+
+`GET: /lume/config/locations`
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/config/locations"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/config/locations")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config/locations`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Failed to get locations
+
+---
+
+### A new VM storage location
+
+Add a new VM storage location
+
+`POST: /lume/config/locations`
+
+#### Request Body
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ------------------------- |
+| name | string | Yes | Storage location name |
+| path | string | Yes | Path to storage directory |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/config/locations" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "name": "my-vm",
+ "path": "/path/to/storage"
+}'
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+data = {
+"name": "my-vm",
+"path": "/path/to/storage",
+}
+
+response = requests.post("http://localhost:7777/lume/config/locations", json=data)
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config/locations`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ name: "my-vm",
+ path: "/path/to/storage",
+ }),
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Location added successfully
+- **400**: Invalid request or location already exists
+
+---
+
+### A VM storage location
+
+Remove a VM storage location
+
+`DELETE: /lume/config/locations/:name`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | ------------------------------ |
+| name | string | Yes | Name of the location to remove |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X DELETE "http://localhost:7777/lume/config/locations/{name}"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.delete("http://localhost:7777/lume/config/locations/{name}")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config/locations/${name}`, {
+ method: "DELETE",
+});
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Location removed successfully
+- **400**: Location not found or cannot be removed
+
+---
+
+### The default VM storage location
+
+Set the default VM storage location
+
+`POST: /lume/config/locations/default/:name`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ---- | ------ | -------- | -------------------------------------- |
+| name | string | Yes | Name of the location to set as default |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl -X POST "http://localhost:7777/lume/config/locations/default/{name}"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.post("http://localhost:7777/lume/config/locations/default/{name}")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/config/locations/default/${name}`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Default location set successfully
+- **400**: Location not found
+
+---
+
+## Logs
+
+### Lume server logs
+
+Retrieve Lume server logs
+
+`GET: /lume/logs`
+
+#### Parameters
+
+| Name | Type | Required | Description |
+| ----- | ------- | -------- | -------------------------------------------------- |
+| type | string | No | Log type: 'info', 'error', or 'all' (default: all) |
+| lines | integer | No | Number of lines to return from end of log |
+
+#### Example Request
+
+<Tabs groupId="language" persist items={['Curl', 'Python', 'TypeScript']}>
+ <Tab value="Curl">
+```bash
+curl "http://localhost:7777/lume/logs"
+```
+ </Tab>
+ <Tab value="Python">
+```python
+import requests
+
+response = requests.get("http://localhost:7777/lume/logs")
+print(response.json())
+
+````
+ </Tab>
+ <Tab value="TypeScript">
+```typescript
+const response = await fetch(`http://localhost:7777/lume/logs`);
+const data = await response.json();
+````
+
+ </Tab>
+</Tabs>
+
+#### Response
+
+- **200**: Success
+- **400**: Failed to read logs
+
+---
diff --git a/docs/content/docs/lume/reference/v0.2/meta.json b/docs/content/docs/lume/reference/v0.2/meta.json
new file mode 100644
index 0000000000..a31a729a53
--- /dev/null
+++ b/docs/content/docs/lume/reference/v0.2/meta.json
@@ -0,0 +1,5 @@
+{
+ "title": "v0.2",
+ "description": "Lume v0.2 Reference",
+ "pages": ["cli-reference", "http-api"]
+}
diff --git a/docs/next.config.mjs b/docs/next.config.mjs
index a495960d78..531236fa47 100644
--- a/docs/next.config.mjs
+++ b/docs/next.config.mjs
@@ -50,6 +50,17 @@ const config = {
destination: '/get-started/quickstart',
permanent: true,
},
+ // Redirect old /api URLs to SDK landing pages
+ {
+ source: '/cua/reference/computer-sdk/api',
+ destination: '/cua/reference/computer-sdk',
+ permanent: true,
+ },
+ {
+ source: '/cua/reference/agent-sdk/api',
+ destination: '/cua/reference/agent-sdk',
+ permanent: true,
+ },
];
},
images: {
diff --git a/docs/package.json b/docs/package.json
index fa34dd2259..bbb9eb3f50 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -10,7 +10,10 @@
"docs:generate": "tsx ../scripts/docs-generators/runner.ts",
"docs:check": "tsx ../scripts/docs-generators/runner.ts --check",
"docs:list": "tsx ../scripts/docs-generators/runner.ts --list",
- "docs:generate:lume": "tsx ../scripts/docs-generators/lume.ts"
+ "docs:generate:lume": "tsx ../scripts/docs-generators/lume.ts",
+ "docs:generate:python": "tsx ../scripts/docs-generators/python-sdk.ts",
+ "docs:generate:changelog": "tsx ../scripts/docs-generators/generate-changelog.ts",
+ "docs:generate:versions": "tsx ../scripts/docs-generators/generate-versioned-docs.ts"
},
"dependencies": {
"@ai-sdk/anthropic": "^3.0.9",
diff --git a/docs/scripts/README.md b/docs/scripts/README.md
index fac104e73d..e08e3080e8 100644
--- a/docs/scripts/README.md
+++ b/docs/scripts/README.md
@@ -4,7 +4,15 @@ This directory contains scripts for crawling, indexing, and serving CUA document
## Scripts
-- **modal_app.py**: Complete Modal app with scheduled crawling, database generation, and MCP server deployment
+### Local Scripts
+
+- **crawl_docs.py**: Crawls cua.ai/docs using crawl4ai
+- **generate_db.py**: Creates LanceDB vector database for semantic search
+- **generate_sqlite.py**: Creates SQLite FTS5 database for full-text search
+
+### Modal Deployment
+
+- **modal_app.py**: Complete Modal app with scheduled crawling and MCP server deployment
## Installation
@@ -17,7 +25,25 @@ uv sync --group docs-scripts
## Usage
-### Modal Deployment
+### Option 1: Local Development
+
+#### 1. Crawl Documentation
+
+```bash
+uv run docs/scripts/crawl_docs.py
+```
+
+#### 2. Generate Databases
+
+```bash
+# Generate vector database for semantic search
+uv run docs/scripts/generate_db.py
+
+# Generate SQLite FTS5 database for full-text search
+uv run docs/scripts/generate_sqlite.py
+```
+
+### Option 2: Modal Deployment (Production)
The Modal app provides a production-ready deployment with:
diff --git a/docs/scripts/crawl_docs.py b/docs/scripts/crawl_docs.py
new file mode 100644
index 0000000000..59d3a85881
--- /dev/null
+++ b/docs/scripts/crawl_docs.py
@@ -0,0 +1,261 @@
+"""
+Comprehensive crawler for cua.ai/docs using crawl4ai
+Recursively crawls all documentation pages and saves content to JSON files
+"""
+
+import asyncio
+import json
+import re
+from pathlib import Path
+from urllib.parse import urljoin, urlparse
+
+from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig
+
+# Configuration
+BASE_URL = "https://cua.ai"
+DOCS_URL = f"{BASE_URL}/docs"
+OUTPUT_DIR = Path(__file__).parent.parent / "crawled_data"
+MAX_CONCURRENT = 5 # Limit concurrent requests to be polite
+DELAY_BETWEEN_REQUESTS = 0.5 # seconds
+
+
+class CuaDocsCrawler:
+ def __init__(self):
+ self.visited_urls: set[str] = set()
+ self.to_visit: set[str] = set()
+ self.failed_urls: set[str] = set()
+ self.all_data: list[dict] = []
+ self.semaphore = asyncio.Semaphore(MAX_CONCURRENT)
+
+ def normalize_url(self, url: str) -> str:
+ """Normalize URL to avoid duplicates"""
+ parsed = urlparse(url)
+ # Remove trailing slashes and fragments
+ path = parsed.path.rstrip("/")
+ if not path:
+ path = ""
+ return f"{parsed.scheme}://{parsed.netloc}{path}"
+
+ def is_valid_url(self, url: str) -> bool:
+ """Check if URL should be crawled (only /docs pages)"""
+ parsed = urlparse(url)
+
+ # Only crawl cua.ai pages
+ if parsed.netloc and parsed.netloc not in ["cua.ai", "www.cua.ai"]:
+ return False
+
+ # Only crawl /docs paths
+ if not parsed.path.startswith("/docs"):
+ return False
+
+ # Skip non-page resources
+ skip_extensions = [
+ ".pdf",
+ ".png",
+ ".jpg",
+ ".jpeg",
+ ".gif",
+ ".svg",
+ ".css",
+ ".js",
+ ".ico",
+ ".woff",
+ ".woff2",
+ ".ttf",
+ ".zip",
+ ".tar",
+ ".gz",
+ ]
+ if any(parsed.path.lower().endswith(ext) for ext in skip_extensions):
+ return False
+
+ # Skip external links and anchors
+ if url.startswith("#") or url.startswith("mailto:") or url.startswith("javascript:"):
+ return False
+
+ return True
+
+ def extract_links(self, html: str, current_url: str) -> set[str]:
+ """Extract all internal links from HTML content"""
+ links = set()
+
+ # Find all href attributes
+ href_pattern = r'href=["\']([^"\']+)["\']'
+ matches = re.findall(href_pattern, html, re.IGNORECASE)
+
+ for href in matches:
+ # Convert relative URLs to absolute
+ if href.startswith("/"):
+ full_url = urljoin(BASE_URL, href)
+ elif href.startswith("http"):
+ full_url = href
+ elif not href.startswith("#") and not href.startswith("mailto:"):
+ full_url = urljoin(current_url, href)
+ else:
+ continue
+
+ normalized = self.normalize_url(full_url)
+ if self.is_valid_url(normalized):
+ links.add(normalized)
+
+ return links
+
+ def extract_path_info(self, url: str) -> dict:
+ """Extract meaningful path information from URL"""
+ parsed = urlparse(url)
+ path = parsed.path.replace("/docs/", "").strip("/")
+ parts = path.split("/") if path else []
+
+ return {
+ "path": path,
+ "category": parts[0] if parts else "root",
+ "subcategory": parts[1] if len(parts) > 1 else None,
+ "page": parts[-1] if parts else "index",
+ "depth": len(parts),
+ }
+
+ async def crawl_page(self, crawler: AsyncWebCrawler, url: str) -> dict | None:
+ """Crawl a single page"""
+ async with self.semaphore:
+ try:
+ print(f"Crawling: {url}")
+
+ config = CrawlerRunConfig(
+ word_count_threshold=10,
+ exclude_external_links=True,
+ )
+
+ result = await crawler.arun(url=url, config=config)
+
+ if result.success:
+ # Extract new links from the page
+ new_links = self.extract_links(result.html, url)
+ for link in new_links:
+ if link not in self.visited_urls and link not in self.to_visit:
+ self.to_visit.add(link)
+
+ path_info = self.extract_path_info(url)
+
+ page_data = {
+ "url": url,
+ "title": result.metadata.get("title", "") if result.metadata else "",
+ "description": (
+ result.metadata.get("description", "") if result.metadata else ""
+ ),
+ "markdown": result.markdown,
+ "path_info": path_info,
+ "links_found": list(new_links),
+ }
+
+ # Save individual page
+ self.save_page(url, page_data)
+
+ await asyncio.sleep(DELAY_BETWEEN_REQUESTS)
+ return page_data
+ else:
+ print(f"Failed to crawl {url}: {result.error_message}")
+ self.failed_urls.add(url)
+ return None
+
+ except Exception as e:
+ print(f"Error crawling {url}: {e}")
+ self.failed_urls.add(url)
+ return None
+
+ def save_page(self, url: str, data: dict):
+ """Save page data to a JSON file"""
+ # Create filename from URL path
+ parsed = urlparse(url)
+ path = parsed.path.strip("/") or "index"
+ filename = path.replace("/", "_") + ".json"
+
+ filepath = OUTPUT_DIR / filename
+ with open(filepath, "w", encoding="utf-8") as f:
+ json.dump(data, f, indent=2, ensure_ascii=False)
+
+ async def crawl_all(self):
+ """Main crawl loop"""
+ OUTPUT_DIR.mkdir(exist_ok=True)
+
+ # Start with the docs URL and key sections based on typical CUA docs structure
+ seed_urls = [
+ DOCS_URL,
+ f"{DOCS_URL}/cua",
+ f"{DOCS_URL}/cua/guide",
+ f"{DOCS_URL}/cua/guide/get-started",
+ f"{DOCS_URL}/cua/reference",
+ f"{DOCS_URL}/cua/reference/computer-sdk",
+ f"{DOCS_URL}/cua-bench",
+ f"{BASE_URL}/llms.txt", # LLM-optimized content if available
+ ]
+
+ for url in seed_urls:
+ normalized = self.normalize_url(url)
+ if self.is_valid_url(normalized) or url.endswith("llms.txt"):
+ self.to_visit.add(normalized)
+
+ browser_config = BrowserConfig(
+ headless=True,
+ verbose=False,
+ )
+
+ async with AsyncWebCrawler(config=browser_config) as crawler:
+ while self.to_visit:
+ # Get batch of URLs to crawl
+ batch = []
+ while self.to_visit and len(batch) < MAX_CONCURRENT:
+ url = self.to_visit.pop()
+ if url not in self.visited_urls:
+ batch.append(url)
+ self.visited_urls.add(url)
+
+ if not batch:
+ break
+
+ # Crawl batch concurrently
+ tasks = [self.crawl_page(crawler, url) for url in batch]
+ results = await asyncio.gather(*tasks)
+
+ # Collect successful results
+ for result in results:
+ if result:
+ self.all_data.append(result)
+
+ print(f"Progress: {len(self.visited_urls)} crawled, {len(self.to_visit)} remaining")
+
+ # Save summary
+ summary = {
+ "total_pages": len(self.all_data),
+ "failed_urls": list(self.failed_urls),
+ "all_urls": list(self.visited_urls),
+ "categories": self._get_categories(),
+ }
+
+ with open(OUTPUT_DIR / "_summary.json", "w", encoding="utf-8") as f:
+ json.dump(summary, f, indent=2)
+
+ # Save all data in one file too
+ with open(OUTPUT_DIR / "_all_pages.json", "w", encoding="utf-8") as f:
+ json.dump(self.all_data, f, indent=2, ensure_ascii=False)
+
+ print("\nCrawl complete!")
+ print(f"Total pages crawled: {len(self.all_data)}")
+ print(f"Failed URLs: {len(self.failed_urls)}")
+ print(f"Output saved to: {OUTPUT_DIR.absolute()}")
+
+ def _get_categories(self) -> dict:
+ """Get summary of categories crawled"""
+ categories = {}
+ for page in self.all_data:
+ cat = page.get("path_info", {}).get("category", "unknown")
+ categories[cat] = categories.get(cat, 0) + 1
+ return categories
+
+
+async def main():
+ crawler = CuaDocsCrawler()
+ await crawler.crawl_all()
+
+
+if __name__ == "__main__":
+ asyncio.run(main())
diff --git a/docs/scripts/generate_db.py b/docs/scripts/generate_db.py
new file mode 100644
index 0000000000..c0418e21cb
--- /dev/null
+++ b/docs/scripts/generate_db.py
@@ -0,0 +1,261 @@
+"""
+Database generator for CUA documentation
+Parses crawled JSON data and creates a LanceDB vector database for RAG
+"""
+
+import json
+import re
+from pathlib import Path
+from typing import Optional
+
+import lancedb
+from lancedb.embeddings import get_registry
+from lancedb.pydantic import LanceModel, Vector
+
+# Configuration
+CRAWLED_DATA_DIR = Path(__file__).parent.parent / "crawled_data"
+DB_PATH = Path(__file__).parent.parent / "docs_db"
+CHUNK_SIZE = 1000 # Characters per chunk
+CHUNK_OVERLAP = 200 # Overlap between chunks
+
+# Use sentence-transformers for embeddings
+model = get_registry().get("sentence-transformers").create(name="all-MiniLM-L6-v2")
+
+
+class DocChunk(LanceModel):
+ """Schema for document chunks in the database"""
+
+ text: str = model.SourceField()
+ vector: Vector(model.ndims()) = model.VectorField()
+ url: str
+ title: str
+ category: str
+ subcategory: Optional[str]
+ page: str
+ chunk_index: int
+
+
+def clean_markdown(markdown: str) -> str:
+ """Clean markdown content for better chunking"""
+ # Remove excessive whitespace
+ text = re.sub(r"\n{3,}", "\n\n", markdown)
+ # Remove image markdown
+ text = re.sub(r"!\[.*?\]\(.*?\)", "", text)
+ # Remove link URLs but keep text
+ text = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", text)
+ # Remove HTML tags
+ text = re.sub(r"<[^>]+>", "", text)
+ # Clean up whitespace
+ text = re.sub(r" {2,}", " ", text)
+ return text.strip()
+
+
+def chunk_text(text: str, chunk_size: int = CHUNK_SIZE, overlap: int = CHUNK_OVERLAP) -> list[str]:
+ """Split text into overlapping chunks, respecting sentence boundaries"""
+ if not text:
+ return []
+
+ # Split by paragraphs first
+ paragraphs = text.split("\n\n")
+ chunks = []
+ current_chunk = ""
+
+ for para in paragraphs:
+ para = para.strip()
+ if not para:
+ continue
+
+ # If adding this paragraph exceeds chunk size, save current and start new
+ if len(current_chunk) + len(para) + 2 > chunk_size:
+ if current_chunk:
+ chunks.append(current_chunk.strip())
+ # Start new chunk with overlap from previous
+ if overlap > 0 and len(current_chunk) > overlap:
+ # Try to find a sentence boundary for overlap
+ overlap_text = current_chunk[-overlap:]
+ sentence_end = overlap_text.rfind(". ")
+ if sentence_end > 0:
+ overlap_text = overlap_text[sentence_end + 2 :]
+ current_chunk = overlap_text + "\n\n" + para
+ else:
+ current_chunk = para
+ else:
+ # Single paragraph exceeds chunk size, split by sentences
+ sentences = re.split(r"(?<=[.!?])\s+", para)
+ for sentence in sentences:
+ if len(current_chunk) + len(sentence) + 1 > chunk_size:
+ if current_chunk:
+ chunks.append(current_chunk.strip())
+ # Start new chunk with overlap from previous, similar to paragraph logic
+ if overlap > 0 and len(current_chunk) > overlap:
+ overlap_text = current_chunk[-overlap:]
+ sentence_end = overlap_text.rfind(". ")
+ if sentence_end > 0:
+ overlap_text = overlap_text[sentence_end + 2 :]
+ current_chunk = (overlap_text + " " + sentence).strip()
+ else:
+ current_chunk = sentence.strip()
+ else:
+ # No existing chunk; start with this sentence
+ current_chunk = sentence.strip()
+ else:
+ current_chunk = (current_chunk + " " + sentence).strip()
+ else:
+ current_chunk = (current_chunk + "\n\n" + para).strip()
+
+ # Don't forget the last chunk
+ if current_chunk:
+ chunks.append(current_chunk.strip())
+
+ return chunks
+
+
+def load_crawled_data() -> list[dict]:
+ """Load all crawled page data"""
+ all_pages_file = CRAWLED_DATA_DIR / "_all_pages.json"
+
+ if all_pages_file.exists():
+ with open(all_pages_file, "r", encoding="utf-8") as f:
+ return json.load(f)
+
+ # Fallback: load individual files
+ pages = []
+ for json_file in CRAWLED_DATA_DIR.glob("*.json"):
+ if json_file.name.startswith("_"):
+ continue
+ with open(json_file, "r", encoding="utf-8") as f:
+ pages.append(json.load(f))
+
+ return pages
+
+
+def process_pages(pages: list[dict]) -> list[dict]:
+ """Process pages into document chunks"""
+ all_chunks = []
+
+ for page in pages:
+ markdown = page.get("markdown", "")
+ if not markdown:
+ continue
+
+ # Clean the markdown
+ cleaned_text = clean_markdown(markdown)
+ if not cleaned_text or len(cleaned_text) < 50:
+ continue
+
+ # Get path info
+ path_info = page.get("path_info", {})
+
+ # Chunk the text
+ text_chunks = chunk_text(cleaned_text)
+
+ # Ensure non-null values for required fields
+ url = page.get("url", "")
+ title = page.get("title") or path_info.get("page", "") or "Untitled"
+ category = path_info.get("category") or "unknown"
+ page_name = path_info.get("page") or ""
+
+ for i, chunk_text_content in enumerate(text_chunks):
+ chunk = {
+ "text": chunk_text_content,
+ "url": url,
+ "title": title,
+ "category": category,
+ "subcategory": path_info.get("subcategory"),
+ "page": page_name,
+ "chunk_index": i,
+ }
+ all_chunks.append(chunk)
+
+ return all_chunks
+
+
+def create_database(chunks: list[dict]):
+ """Create LanceDB database from chunks"""
+ # Remove existing database
+ if DB_PATH.exists():
+ import shutil
+
+ shutil.rmtree(DB_PATH)
+
+ # Create database
+ db = lancedb.connect(DB_PATH)
+
+ # Create table with schema
+ table = db.create_table(
+ "docs",
+ schema=DocChunk,
+ mode="overwrite",
+ )
+
+ # Add data in batches
+ batch_size = 100
+ for i in range(0, len(chunks), batch_size):
+ batch = chunks[i : i + batch_size]
+ print(f"Adding batch {i // batch_size + 1}/{(len(chunks) + batch_size - 1) // batch_size}")
+ table.add(batch)
+
+ print(f"Database created at: {DB_PATH}")
+ print(f"Total chunks: {len(chunks)}")
+
+ return db
+
+
+def test_search(db: lancedb.DBConnection, query: str, limit: int = 5):
+ """Test search functionality"""
+ table = db.open_table("docs")
+
+ print(f"\nSearching for: '{query}'")
+ print("-" * 50)
+
+ results = table.search(query).limit(limit).to_list()
+
+ for i, result in enumerate(results):
+ print(f"\n{i + 1}. [{result['category']}] {result['title']}")
+ print(f" URL: {result['url']}")
+ print(f" Score: {result.get('_distance', 'N/A'):.4f}")
+ print(f" Preview: {result['text'][:150]}...")
+
+
+def main():
+ print("Loading crawled data...")
+ pages = load_crawled_data()
+ print(f"Loaded {len(pages)} pages")
+
+ if not pages:
+ print("No crawled data found. Run crawl_docs.py first.")
+ return
+
+ print("\nProcessing pages into chunks...")
+ chunks = process_pages(pages)
+ print(f"Created {len(chunks)} chunks")
+
+ if not chunks:
+ print("No chunks created. Check your crawled data.")
+ return
+
+ print("\nCreating database...")
+ db = create_database(chunks)
+
+ # Test with sample queries
+ print("\n" + "=" * 50)
+ print("Testing search functionality")
+ print("=" * 50)
+
+ test_queries = [
+ "how to install CUA",
+ "computer use agent",
+ "benchmark evaluation",
+ "API reference",
+ ]
+
+ for query in test_queries:
+ test_search(db, query)
+
+ print("\n" + "=" * 50)
+ print("Database generation complete!")
+ print(f"Database location: {DB_PATH}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/scripts/generate_sqlite.py b/docs/scripts/generate_sqlite.py
new file mode 100644
index 0000000000..8aac1932b6
--- /dev/null
+++ b/docs/scripts/generate_sqlite.py
@@ -0,0 +1,278 @@
+"""
+SQLite database generator for CUA documentation
+Creates a full-text search enabled SQLite database from crawled data
+"""
+
+import json
+import re
+import sqlite3
+from pathlib import Path
+
+from markdown_it import MarkdownIt
+
+# Configuration
+CRAWLED_DATA_DIR = Path(__file__).parent.parent / "crawled_data"
+SQLITE_PATH = Path(__file__).parent.parent / "docs_db" / "docs.sqlite"
+
+
+def clean_markdown(markdown: str) -> str:
+ """
+ Extract plain text content from markdown using a proper markdown parser.
+
+ This function uses markdown-it-py to parse the markdown into a token tree
+ and then extracts only the text content, removing:
+ - Markdown formatting (bold, italic, headers, etc.)
+ - Links (keeping only the link text)
+ - Images (alt text is discarded)
+ - HTML tags
+ - Code block language identifiers
+
+ Args:
+ markdown: Raw markdown content
+
+ Returns:
+ Plain text content suitable for full-text search
+ """
+ md_parser = MarkdownIt()
+ tokens = md_parser.parse(markdown)
+
+ text_parts = []
+
+ def extract_text(token_list):
+ """Recursively extract text from token tree"""
+ for token in token_list:
+ if token.type == "inline" and token.children:
+ # Process inline content (text, links, formatting, etc.)
+ for child in token.children:
+ if child.type == "text":
+ text_parts.append(child.content)
+ elif child.type == "code_inline":
+ text_parts.append(child.content)
+ elif child.type == "softbreak":
+ text_parts.append(" ")
+ elif child.type == "hardbreak":
+ text_parts.append("\n")
+ # Skip link markup, images, and formatting tokens
+ # (link_open, link_close, image, strong_open, strong_close, em_open, em_close, etc.)
+ elif token.type == "fence" or token.type == "code_block":
+ # Include code content and add newline after
+ text_parts.append(token.content)
+ text_parts.append("\n")
+ elif token.type == "html_block" or token.type == "html_inline":
+ # Skip HTML blocks and inline HTML
+ pass
+
+ # Recursively process nested children
+ if token.children:
+ extract_text(token.children)
+
+ # Add spacing after block elements
+ if token.type in [
+ "heading_close",
+ "paragraph_close",
+ "list_item_close",
+ "blockquote_close",
+ ]:
+ text_parts.append("\n")
+
+ extract_text(tokens)
+
+ # Join and clean up whitespace
+ text = "".join(text_parts)
+ # Normalize multiple newlines to at most double newlines
+ text = re.sub(r"\n{3,}", "\n\n", text)
+ # Normalize multiple spaces to single space within lines
+ text = re.sub(r" {2,}", " ", text)
+
+ return text.strip()
+
+
+def load_crawled_data() -> list[dict]:
+ """Load all crawled page data"""
+ all_pages_file = CRAWLED_DATA_DIR / "_all_pages.json"
+
+ if all_pages_file.exists():
+ with open(all_pages_file, "r", encoding="utf-8") as f:
+ return json.load(f)
+
+ pages = []
+ for json_file in CRAWLED_DATA_DIR.glob("*.json"):
+ if json_file.name.startswith("_"):
+ continue
+ with open(json_file, "r", encoding="utf-8") as f:
+ pages.append(json.load(f))
+
+ return pages
+
+
+def create_database(pages: list[dict]):
+ """Create SQLite database with FTS5 full-text search"""
+ # Ensure parent directory exists
+ SQLITE_PATH.parent.mkdir(parents=True, exist_ok=True)
+
+ # Remove existing database
+ if SQLITE_PATH.exists():
+ SQLITE_PATH.unlink()
+
+ conn = sqlite3.connect(SQLITE_PATH)
+ cursor = conn.cursor()
+
+ # Create main pages table
+ cursor.execute(
+ """
+ CREATE TABLE pages (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ url TEXT UNIQUE NOT NULL,
+ title TEXT,
+ description TEXT,
+ category TEXT,
+ subcategory TEXT,
+ page_name TEXT,
+ content TEXT,
+ raw_markdown TEXT
+ )
+ """
+ )
+
+ # Create FTS5 virtual table for full-text search
+ cursor.execute(
+ """
+ CREATE VIRTUAL TABLE pages_fts USING fts5(
+ content,
+ url UNINDEXED,
+ title UNINDEXED,
+ category UNINDEXED,
+ content='pages',
+ content_rowid='id'
+ )
+ """
+ )
+
+ # Create triggers to keep FTS in sync
+ cursor.execute(
+ """
+ CREATE TRIGGER pages_ai AFTER INSERT ON pages BEGIN
+ INSERT INTO pages_fts(rowid, content, url, title, category)
+ VALUES (new.id, new.content, new.url, new.title, new.category);
+ END;
+ """
+ )
+
+ cursor.execute(
+ """
+ CREATE TRIGGER pages_ad AFTER DELETE ON pages BEGIN
+ DELETE FROM pages_fts WHERE rowid = old.id;
+ END;
+ """
+ )
+
+ cursor.execute(
+ """
+ CREATE TRIGGER pages_au AFTER UPDATE ON pages BEGIN
+ DELETE FROM pages_fts WHERE rowid = old.id;
+ INSERT INTO pages_fts(rowid, content, url, title, category)
+ VALUES (new.id, new.content, new.url, new.title, new.category);
+ END;
+ """
+ )
+
+ # Insert pages
+ for page in pages:
+ markdown = page.get("markdown", "")
+ if not markdown:
+ continue
+
+ content = clean_markdown(markdown)
+ if not content or len(content) < 50:
+ continue
+
+ path_info = page.get("path_info", {})
+
+ cursor.execute(
+ """
+ INSERT OR REPLACE INTO pages
+ (url, title, description, category, subcategory, page_name, content, raw_markdown)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+ """,
+ (
+ page.get("url", ""),
+ page.get("title") or path_info.get("page", "") or "Untitled",
+ page.get("description", ""),
+ path_info.get("category", "unknown"),
+ path_info.get("subcategory"),
+ path_info.get("page", ""),
+ content,
+ markdown,
+ ),
+ )
+
+ conn.commit()
+
+ # Get stats
+ cursor.execute("SELECT COUNT(*) FROM pages")
+ page_count = cursor.fetchone()[0]
+
+ cursor.execute("SELECT category, COUNT(*) FROM pages GROUP BY category")
+ categories = cursor.fetchall()
+
+ conn.close()
+
+ print(f"SQLite database created at: {SQLITE_PATH}")
+ print(f"Total pages: {page_count}")
+ print("Pages by category:")
+ for cat, count in categories:
+ print(f" - {cat}: {count}")
+
+
+def test_search(query: str):
+ """Test full-text search"""
+ conn = sqlite3.connect(SQLITE_PATH)
+ cursor = conn.cursor()
+
+ print(f"\nFTS5 search for: '{query}'")
+ print("-" * 50)
+
+ cursor.execute(
+ """
+ SELECT url, title, snippet(pages_fts, 0, '>>>', '<<<', '...', 50) as snippet
+ FROM pages_fts
+ WHERE pages_fts MATCH ?
+ ORDER BY rank
+ LIMIT 5
+ """,
+ (query,),
+ )
+
+ results = cursor.fetchall()
+ for url, title, snippet in results:
+ print(f"\n{title}")
+ print(f" URL: {url}")
+ print(f" Snippet: {snippet}")
+
+ conn.close()
+
+
+def main():
+ print("Loading crawled data...")
+ pages = load_crawled_data()
+ print(f"Loaded {len(pages)} pages")
+
+ if not pages:
+ print("No crawled data found. Run crawl_docs.py first.")
+ return
+
+ print("\nCreating SQLite database...")
+ create_database(pages)
+
+ # Test searches
+ print("\n" + "=" * 50)
+ print("Testing FTS5 search")
+ print("=" * 50)
+
+ test_search("install")
+ test_search("computer use agent")
+ test_search("benchmark")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/scripts/modal_app.py b/docs/scripts/modal_app.py
index 52457e1b6c..cb3499d18d 100644
--- a/docs/scripts/modal_app.py
+++ b/docs/scripts/modal_app.py
@@ -1,12 +1,9 @@
"""
-Modal app for CUA documentation crawling and database generation
+Modal app for CUA documentation crawling and MCP server
This app provides:
1. Scheduled daily crawling of cua.ai/docs stored in a Modal volume
-2. Database generation (LanceDB vectors + SQLite FTS) for the MCP server
-
-The MCP server that queries these databases runs as a separate containerized
-service (see docs/scripts/docs-mcp-server/).
+2. MCP server that serves documentation search over the crawled data
Usage:
modal deploy docs/scripts/modal_app.py
@@ -17,6 +14,7 @@ import json
import re
import sqlite3
from pathlib import Path
+from typing import Optional
import modal
from markdown_it import MarkdownIt
@@ -41,6 +39,8 @@ image = (
"lancedb>=0.4.0",
"sentence-transformers>=2.2.0",
"pyarrow>=14.0.1",
+ "fastapi>=0.100.0",
+ "fastmcp>=2.14.0",
"pydantic>=2.0.0",
"pandas>=2.0.0",
"markdown-it-py>=3.0.0",
@@ -1492,6 +1492,384 @@ async def scheduled_code_index():
}
+# =============================================================================
+# MCP Server
+# =============================================================================
+
+
+ image=image,
+ volumes={VOLUME_PATH: docs_volume, CODE_VOLUME_PATH: code_volume},
+ cpu=1.0,
+ memory=2048,
+ keep_warm=1, # Keep one container warm to avoid cold start latency
+)
[email protected](max_inputs=10)
[email protected]_app(custom_domains=["docs-mcp.cua.ai"])
+def web():
+ """ASGI web endpoint for the MCP server"""
+ import lancedb
+ from fastmcp import FastMCP
+ from lancedb.embeddings import get_registry
+ from starlette.middleware.cors import CORSMiddleware
+
+ # Initialize the MCP server
+ mcp = FastMCP(
+ name="CUA Docs & Code",
+ instructions="""CUA Documentation and Code Server - provides direct read-only query access to Computer Use Agent (CUA) documentation and versioned source code.
+
+=== AVAILABLE TOOLS ===
+
+Documentation:
+- query_docs_db: Execute SQL queries against the documentation SQLite database
+- query_docs_vectors: Execute vector similarity searches against the documentation LanceDB
+
+Code:
+- query_code_db: Execute SQL queries against the code search SQLite database
+- query_code_vectors: Execute vector similarity searches against the code LanceDB
+
+All tools are READ-ONLY. Only SELECT queries are allowed for SQL databases.
+
+=== DOCUMENTATION DATABASE ===
+
+The documentation database contains crawled pages from cua.ai/docs covering:
+- CUA SDK: Python library for building computer-use agents
+- CUA Bench: Benchmarking framework for evaluating computer-use agents
+- Agent Loop: Core execution loop for autonomous agent operation
+- Sandboxes: Docker and cloud VM environments for safe agent execution
+- Computer interfaces: Screen, mouse, keyboard, and bash interaction APIs
+
+=== CODE DATABASE ===
+
+The code database contains versioned source code indexed across all git tags.
+Components include: agent, computer, mcp-server, som, etc.
+
+=== WORKFLOW EXAMPLES ===
+
+1. Find documentation about a topic:
+ - Use query_docs_vectors with a natural language query for semantic search
+ - Use query_docs_db with FTS5 MATCH for keyword search
+
+2. Explore code across versions:
+ - List components: SELECT component, COUNT(DISTINCT version) FROM code_files GROUP BY component
+ - Search code: Use query_code_db with FTS5 on code_files_fts
+ - Get file content: SELECT content FROM code_files WHERE component='agent' AND version='0.7.3' AND file_path='...'
+
+3. Semantic code search:
+ - Use query_code_vectors with natural language queries like "screenshot capture implementation"
+
+IMPORTANT: Always cite sources - URLs for docs, component@version:path for code.""",
+ )
+
+ # Initialize embedding model - load eagerly to avoid cold start on first search
+ print("Initializing embedding model...")
+ model = get_registry().get("sentence-transformers").create(name="all-MiniLM-L6-v2")
+
+ # Eagerly initialize database connections at startup to reduce first-request latency
+ print("Initializing database connections...")
+
+ # Docs LanceDB
+ _docs_lance_db = None
+ _docs_lance_table = None
+ db_path = Path(DB_PATH)
+ if db_path.exists():
+ try:
+ _docs_lance_db = lancedb.connect(db_path)
+ _docs_lance_table = _docs_lance_db.open_table("docs")
+ print(f" Docs LanceDB loaded from {db_path}")
+ except Exception as e:
+ print(f" Warning: Could not load docs LanceDB: {e}")
+
+ # Docs SQLite
+ _docs_sqlite_conn = None
+ sqlite_path = Path(DB_PATH) / "docs.sqlite"
+ if sqlite_path.exists():
+ try:
+ _docs_sqlite_conn = sqlite3.connect(f"file:{sqlite_path}?mode=ro", uri=True)
+ _docs_sqlite_conn.row_factory = sqlite3.Row
+ print(f" Docs SQLite loaded from {sqlite_path}")
+ except Exception as e:
+ print(f" Warning: Could not load docs SQLite: {e}")
+
+ # Code LanceDB
+ _code_lance_db = None
+ _code_lance_table = None
+ code_lance_path = Path(CODE_DB_PATH) / "code_index.lancedb"
+ if code_lance_path.exists():
+ try:
+ _code_lance_db = lancedb.connect(code_lance_path)
+ _code_lance_table = _code_lance_db.open_table("code")
+ print(f" Code LanceDB loaded from {code_lance_path}")
+ except Exception as e:
+ print(f" Warning: Could not load code LanceDB: {e}")
+
+ # Code SQLite
+ _code_sqlite_conn = None
+ code_sqlite_path = Path(CODE_DB_PATH) / "code_index.sqlite"
+ if code_sqlite_path.exists():
+ try:
+ _code_sqlite_conn = sqlite3.connect(f"file:{code_sqlite_path}?mode=ro", uri=True)
+ _code_sqlite_conn.row_factory = sqlite3.Row
+ print(f" Code SQLite loaded from {code_sqlite_path}")
+ except Exception as e:
+ print(f" Warning: Could not load code SQLite: {e}")
+
+ print("Database initialization complete.")
+
+ def get_lance_table():
+ """Get LanceDB connection for docs (eagerly loaded)"""
+ if _docs_lance_table is None:
+ raise RuntimeError("Database not found. Run crawl and generation functions first.")
+ return _docs_lance_table
+
+ def get_sqlite_conn():
+ """Get read-only SQLite connection for docs (eagerly loaded)"""
+ if _docs_sqlite_conn is None:
+ raise RuntimeError("SQLite database not found.")
+ return _docs_sqlite_conn
+
+ def get_code_lance_table():
+ """Get LanceDB connection for the aggregated code database (eagerly loaded)."""
+ if _code_lance_table is None:
+ raise RuntimeError(
+ "Code LanceDB not found. Run generate_code_index_parallel and aggregate_code_databases first."
+ )
+ return _code_lance_table
+
+ def get_code_sqlite_conn():
+ """Get read-only SQLite connection for the aggregated code database (eagerly loaded)."""
+ if _code_sqlite_conn is None:
+ raise RuntimeError(
+ "Code SQLite database not found. Run generate_code_index_parallel and aggregate_code_databases first."
+ )
+ return _code_sqlite_conn
+
+ # =================== DOCUMENTATION QUERY TOOLS (READ-ONLY) ===================
+
+ @mcp.tool()
+ def query_docs_db(sql: str) -> list[dict]:
+ """
+ Execute a SQL query against the documentation database.
+ The database is READ-ONLY.
+
+ Database Schema:
+
+ Table: pages
+ - id INTEGER PRIMARY KEY AUTOINCREMENT
+ - url TEXT NOT NULL UNIQUE -- Full URL of the documentation page
+ - title TEXT NOT NULL -- Page title
+ - category TEXT NOT NULL -- Category (e.g., 'cua', 'cuabench', 'llms.txt')
+ - content TEXT NOT NULL -- Plain text content (markdown stripped)
+
+ Virtual Table: pages_fts (FTS5 full-text search)
+ - content TEXT -- Full-text indexed content
+ - url TEXT UNINDEXED
+ - title TEXT UNINDEXED
+ - category TEXT UNINDEXED
+
+ Example queries:
+
+ 1. List all pages: SELECT url, title, category FROM pages ORDER BY category, title
+
+ 2. Full-text search with snippets:
+ SELECT p.url, p.title, snippet(pages_fts, 0, '>>>', '<<<', '...', 64) as snippet
+ FROM pages_fts JOIN pages p ON pages_fts.rowid = p.id
+ WHERE pages_fts MATCH 'agent loop' ORDER BY rank LIMIT 10
+
+ 3. Get page content: SELECT url, title, content FROM pages WHERE url LIKE '%quickstart%'
+
+ Args:
+ sql: SQL query to execute
+
+ Returns:
+ List of dictionaries, one per row, with column names as keys
+ """
+ conn = get_sqlite_conn()
+ cursor = conn.cursor()
+ cursor.execute(sql)
+ return [dict(row) for row in cursor.fetchall()]
+
+ @mcp.tool()
+ def query_docs_vectors(
+ query: str,
+ limit: int = 10,
+ where: Optional[str] = None,
+ select: Optional[list[str]] = None,
+ ) -> list[dict]:
+ """
+ Execute a vector similarity search against the documentation LanceDB (read-only).
+
+ Schema:
+ - text TEXT -- The document chunk text
+ - vector VECTOR -- Embedding vector (all-MiniLM-L6-v2, 384 dimensions)
+ - url TEXT -- Source URL
+ - title TEXT -- Document title
+ - category TEXT -- Category (e.g., 'cua', 'cuabench')
+ - chunk_index INT -- Index of chunk within document
+
+ Args:
+ query: Natural language query to embed and search for
+ limit: Maximum number of results (default: 10, max: 100)
+ where: Optional SQL-like filter (e.g., "category = 'cua'")
+ select: Optional list of columns to return (default: all except vector)
+
+ Returns:
+ List of matching documents with similarity scores (_distance field)
+ """
+ limit = min(max(1, limit), 100)
+ table = get_lance_table()
+
+ search = table.search(query).limit(limit)
+
+ if where:
+ search = search.where(where)
+ if select:
+ search = search.select(select)
+
+ results = search.to_list()
+
+ formatted = []
+ for r in results:
+ result = {}
+ for key, value in r.items():
+ if key == "vector":
+ continue
+ result[key] = value
+ formatted.append(result)
+
+ return formatted
+
+ # =================== CODE QUERY TOOLS (READ-ONLY) ===================
+
+ @mcp.tool()
+ def query_code_db(sql: str) -> list[dict]:
+ """
+ Execute a SQL query against the code search database.
+ The database is READ-ONLY.
+
+ Database Schema:
+
+ Table: code_files
+ - id INTEGER PRIMARY KEY AUTOINCREMENT
+ - component TEXT NOT NULL -- Component name (e.g., "agent", "computer")
+ - version TEXT NOT NULL -- Version string (e.g., "0.7.3")
+ - file_path TEXT NOT NULL -- Path to file
+ - content TEXT NOT NULL -- Full source code content
+ - language TEXT NOT NULL -- Programming language
+ - UNIQUE(component, version, file_path)
+
+ Virtual Table: code_files_fts (FTS5 full-text search)
+ - content TEXT -- Full-text indexed content
+ - component TEXT UNINDEXED
+ - version TEXT UNINDEXED
+ - file_path TEXT UNINDEXED
+
+ Example queries:
+
+ 1. List components: SELECT component, COUNT(DISTINCT version) as version_count
+ FROM code_files GROUP BY component ORDER BY component
+
+ 2. List versions: SELECT DISTINCT version FROM code_files
+ WHERE component = 'agent' ORDER BY version DESC
+
+ 3. Full-text search:
+ SELECT f.component, f.version, f.file_path,
+ snippet(code_files_fts, 0, '>>>', '<<<', '...', 64) as snippet
+ FROM code_files_fts JOIN code_files f ON code_files_fts.rowid = f.id
+ WHERE code_files_fts MATCH 'ComputerAgent' ORDER BY rank LIMIT 10
+
+ 4. Get file content: SELECT content, language FROM code_files
+ WHERE component = 'agent' AND version = '0.7.3' AND file_path = 'agent/core.py'
+
+ Args:
+ sql: SQL query to execute
+
+ Returns:
+ List of dictionaries, one per row, with column names as keys
+ """
+ conn = get_code_sqlite_conn()
+ cursor = conn.cursor()
+ cursor.execute(sql)
+ return [dict(row) for row in cursor.fetchall()]
+
+ @mcp.tool()
+ def query_code_vectors(
+ query: str,
+ limit: int = 10,
+ where: Optional[str] = None,
+ select: Optional[list[str]] = None,
+ component: Optional[str] = None,
+ ) -> list[dict]:
+ """
+ Execute a vector similarity search against the code LanceDB (read-only).
+
+ Schema:
+ - text TEXT -- The source code content
+ - vector VECTOR -- Embedding vector (all-MiniLM-L6-v2, 384 dimensions)
+ - component TEXT -- Component name (e.g., "agent", "computer")
+ - version TEXT -- Version string (e.g., "0.7.3")
+ - file_path TEXT -- Path to file within the component
+ - language TEXT -- Programming language
+
+ Args:
+ query: Natural language query to embed and search for
+ limit: Maximum number of results (default: 10, max: 100)
+ where: Optional SQL-like filter (e.g., "version = '0.7.3'")
+ select: Optional list of columns to return (default: all except vector)
+ component: Optional component to filter by (if not specified, searches all)
+
+ Returns:
+ List of matching code files with similarity scores (_distance field)
+ """
+ limit = min(max(1, limit), 100)
+ table = get_code_lance_table()
+
+ search = table.search(query).limit(limit)
+
+ # Build where clause, adding component filter if specified
+ where_clauses = []
+ if component:
+ where_clauses.append(f"component = '{component}'")
+ if where:
+ where_clauses.append(where)
+
+ if where_clauses:
+ search = search.where(" AND ".join(where_clauses))
+ if select:
+ search = search.select(select)
+
+ results = search.to_list()
+
+ formatted = []
+ for r in results:
+ result = {}
+ for key, value in r.items():
+ if key == "vector":
+ continue
+ result[key] = value
+ formatted.append(result)
+
+ return formatted
+
+ # Create SSE app directly - endpoints at /sse (GET) and /messages (POST)
+ from starlette.middleware import Middleware
+
+ mcp_app = mcp.http_app(
+ transport="sse",
+ middleware=[
+ Middleware(
+ CORSMiddleware,
+ allow_origins=["*"],
+ allow_credentials=True,
+ allow_methods=["*"],
+ allow_headers=["*"],
+ )
+ ],
+ )
+
+ return mcp_app
+
+
# =============================================================================
# Local testing functions
# =============================================================================
diff --git a/docs/src/components/custom-header.tsx b/docs/src/components/custom-header.tsx
index 188f8069ec..27e8e6f909 100644
--- a/docs/src/components/custom-header.tsx
+++ b/docs/src/components/custom-header.tsx
@@ -7,7 +7,8 @@ import { usePathname } from 'next/navigation';
import { cn } from 'fumadocs-ui/utils/cn';
import { SearchToggle } from 'fumadocs-ui/components/layout/search-toggle';
import { ThemeToggle } from 'fumadocs-ui/components/layout/theme-toggle';
-import { ChevronsUpDown, Check } from 'lucide-react';
+import { ChevronsUpDown, Check, Menu } from 'lucide-react';
+import { useSidebar } from 'fumadocs-ui/provider';
import LogoBlack from '@/assets/cuala-icon-black.svg';
import LogoWhite from '@/assets/cuala-icon-white.svg';
import CuaBenchLogoBlack from '@/assets/cuabench-logo-black.svg';
@@ -68,32 +69,6 @@ const docsSites = [
},
],
},
- {
- name: 'CuaBot',
- label: 'Docs',
- href: '/cuabot/cuabot',
- prefix: '/cuabot',
- isDefault: false,
- description: 'Co-op computer-use for any agent',
- logoBlack: LogoBlack,
- logoWhite: LogoWhite,
- iconWidth: 24,
- iconHeight: 24,
- dropdownIconWidth: 20,
- dropdownIconHeight: 20,
- navTabs: [
- {
- name: 'Overview',
- href: '/cuabot/cuabot',
- prefix: '/cuabot/cuabot',
- },
- {
- name: 'Install',
- href: '/cuabot/install',
- prefix: '/cuabot/install',
- },
- ],
- },
{
name: 'Lume',
label: 'Docs',
@@ -125,12 +100,39 @@ const docsSites = [
},
],
},
+ {
+ name: 'Cua-Bot',
+ label: 'Docs',
+ href: '/cuabot/guide/getting-started/introduction',
+ prefix: '/cuabot',
+ isDefault: false,
+ description: 'Co-op computer-use for any agent',
+ logoBlack: LogoBlack,
+ logoWhite: LogoWhite,
+ iconWidth: 24,
+ iconHeight: 24,
+ dropdownIconWidth: 20,
+ dropdownIconHeight: 20,
+ navTabs: [
+ {
+ name: 'Guide',
+ href: '/cuabot/guide/getting-started/introduction',
+ prefix: '/cuabot/guide',
+ },
+ {
+ name: 'Reference',
+ href: '/cuabot/reference',
+ prefix: '/cuabot/reference',
+ },
+ ],
+ },
];
export function CustomHeader() {
const pathname = usePathname();
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
+ const { open: sidebarOpen, setOpen: setSidebarOpen } = useSidebar();
// Determine current docs site based on pathname
const currentSite =
@@ -153,26 +155,32 @@ export function CustomHeader() {
<header className="fixed top-0 left-0 right-0 z-40 border-b border-fd-border bg-fd-background/80 backdrop-blur-sm">
<div className="container mx-auto flex h-14 items-center justify-between px-4">
{/* Left: Logo and Nav */}
- <div className="flex items-center gap-6">
+ <div className="flex items-center gap-4 md:gap-6">
+ {/* Hamburger Menu Button - visible on mobile only, opens native fumadocs sidebar */}
+ <button
+ onClick={() => setSidebarOpen(!sidebarOpen)}
+ className="inline-flex md:hidden h-9 w-9 items-center justify-center rounded-md text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-foreground"
+ aria-label="Toggle sidebar"
+ >
+ <Menu className="h-5 w-5" />
+ </button>
+
{/* Docs Switcher - wraps logo, name, and label */}
<div className="relative" ref={dropdownRef}>
<button
onClick={() => setIsOpen(!isOpen)}
className="flex items-center gap-2 rounded-lg px-2 py-1.5 transition-colors hover:bg-fd-accent"
>
- {/* Logo */}
+ {/* Logo - fixed width container to prevent layout shift */}
{currentSite.logoBlack && currentSite.logoWhite && (
- <div
- className="relative flex h-6 items-center justify-center"
- style={{ width: currentSite.iconWidth }}
- >
+ <div className="relative flex h-6 w-6 shrink-0 items-center justify-center">
<Image
width={currentSite.iconWidth}
height={currentSite.iconHeight}
src={currentSite.logoBlack}
aria-label="Logo"
- className="block dark:hidden"
- style={{ width: currentSite.iconWidth, height: currentSite.iconHeight }}
+ className="block dark:hidden object-contain"
+ style={{ maxWidth: 24, maxHeight: 24 }}
alt="Logo"
/>
<Image
@@ -180,14 +188,17 @@ export function CustomHeader() {
height={currentSite.iconHeight}
src={currentSite.logoWhite}
aria-label="Logo"
- className="hidden dark:block"
- style={{ width: currentSite.iconWidth, height: currentSite.iconHeight }}
+ className="hidden dark:block object-contain"
+ style={{ maxWidth: 24, maxHeight: 24 }}
alt="Logo"
/>
</div>
)}
- {/* Site name and label */}
- <span className="font-semibold" style={{ fontFamily: 'var(--font-urbanist)' }}>
+ {/* Site name and label - min-width prevents layout shift between products */}
+ <span
+ className="inline-block min-w-[5.5rem] font-semibold"
+ style={{ fontFamily: 'var(--font-urbanist)' }}
+ >
{currentSite.name}
</span>
<span className="text-sky-500 font-medium">{currentSite.label}</span>
@@ -293,20 +304,8 @@ export function CustomHeader() {
className="hidden sm:inline-flex h-9 w-9 items-center justify-center rounded-md text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-foreground"
title="Vibe Coding MCP"
>
- <Image
- src={McpBlack}
- alt="MCP"
- width={20}
- height={20}
- className="block dark:hidden"
- />
- <Image
- src={McpWhite}
- alt="MCP"
- width={20}
- height={20}
- className="hidden dark:block"
- />
+ <Image src={McpBlack} alt="MCP" width={20} height={20} className="block dark:hidden" />
+ <Image src={McpWhite} alt="MCP" width={20} height={20} className="hidden dark:block" />
</Link>
<ThemeToggle />
diff --git a/docs/src/components/version-selector.tsx b/docs/src/components/version-selector.tsx
new file mode 100644
index 0000000000..6f39ad2e03
--- /dev/null
+++ b/docs/src/components/version-selector.tsx
@@ -0,0 +1,82 @@
+'use client';
+
+import { useRouter } from 'next/navigation';
+import { ChevronDown } from 'lucide-react';
+
+export interface Version {
+ version: string;
+ href: string;
+ isCurrent: boolean;
+}
+
+interface VersionSelectorProps {
+ versions: Version[];
+ current: string;
+ className?: string;
+}
+
+export function VersionSelector({ versions, current, className = '' }: VersionSelectorProps) {
+ const router = useRouter();
+
+ const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
+ router.push(e.target.value);
+ };
+
+ if (versions.length <= 1) {
+ // Don't show selector if only one version
+ return null;
+ }
+
+ return (
+ <div className={`relative inline-flex items-center ${className}`}>
+ <select
+ value={versions.find((v) => v.version === current)?.href || ''}
+ onChange={handleChange}
+ className="appearance-none bg-fd-secondary text-fd-foreground border border-fd-border rounded-md px-3 py-1.5 pr-8 text-sm font-mono cursor-pointer hover:bg-fd-accent focus:outline-none focus:ring-2 focus:ring-fd-ring"
+ >
+ {versions.map((v) => (
+ <option key={v.version} value={v.href}>
+ v{v.version} {v.isCurrent ? '(latest)' : ''}
+ </option>
+ ))}
+ </select>
+ <ChevronDown className="absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 text-fd-muted-foreground pointer-events-none" />
+ </div>
+ );
+}
+
+// Static version badge for display
+export function VersionBadge({ version, className = '' }: { version: string; className?: string }) {
+ return (
+ <span
+ className={`inline-flex items-center px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 rounded text-sm font-mono ${className}`}
+ >
+ v{version}
+ </span>
+ );
+}
+
+// Combined component with version selector and current version display
+export function VersionHeader({
+ versions,
+ currentVersion,
+ fullVersion,
+ packageName,
+ installCommand,
+}: {
+ versions: Version[];
+ currentVersion: string;
+ fullVersion: string;
+ packageName: string;
+ installCommand?: string;
+}) {
+ return (
+ <div className="flex flex-wrap items-center gap-3 mb-6">
+ <VersionSelector versions={versions} current={currentVersion} />
+ <VersionBadge version={fullVersion} />
+ <span className="text-sm text-fd-muted-foreground">
+ {installCommand ?? `pip install ${packageName}`}
+ </span>
+ </div>
+ );
+}
diff --git a/libs/cua-bench/cua_bench/cli/commands/image.py b/libs/cua-bench/cua_bench/cli/commands/image.py
index fd5665ec10..62bec170e2 100644
--- a/libs/cua-bench/cua_bench/cli/commands/image.py
+++ b/libs/cua-bench/cua_bench/cli/commands/image.py
@@ -1320,21 +1320,65 @@ def register_parser(subparsers):
image_parser.set_defaults(image_command="list")
+def _deprecation_notice(cmd_name: str) -> None:
+ """Print deprecation notice for cb image commands."""
+ import sys
+
+ equivalent = f"cua image {cmd_name}"
+ print(
+ f"\033[33m⚠ Deprecation: 'cb image {cmd_name}' is deprecated. "
+ f"Use '{equivalent}' instead.\033[0m",
+ file=sys.stderr,
+ )
+
+
def execute(args) -> int:
- """Execute the image command."""
+ """Execute the image command.
+
+ Delegates to cua_cli for local image management commands (create, clone,
+ shell, info, list, delete) with a deprecation warning. Users should migrate
+ to 'cua image' commands.
+ """
cmd = getattr(args, "image_command", "list")
+ try:
+ from cua_cli.commands import local_image as cua_local_image
+ except ImportError:
+ # Fall back to local implementations if cua-cli is not installed
+ if cmd == "list":
+ return cmd_list(args)
+ elif cmd == "info":
+ return cmd_info(args)
+ elif cmd == "create":
+ return cmd_create(args)
+ elif cmd == "delete":
+ return cmd_delete(args)
+ elif cmd == "clone":
+ return cmd_clone(args)
+ elif cmd == "shell":
+ return cmd_shell(args)
+ else:
+ return cmd_list(args)
+
+ # Delegate to cua_cli with deprecation warning
if cmd == "list":
- return cmd_list(args)
+ _deprecation_notice("list")
+ return cua_local_image.cmd_local_list(args)
elif cmd == "info":
- return cmd_info(args)
+ _deprecation_notice("info")
+ return cua_local_image.cmd_info(args)
elif cmd == "create":
- return cmd_create(args)
+ _deprecation_notice("create")
+ return cua_local_image.cmd_create(args)
elif cmd == "delete":
- return cmd_delete(args)
+ _deprecation_notice("delete")
+ return cua_local_image.cmd_local_delete(args)
elif cmd == "clone":
- return cmd_clone(args)
+ _deprecation_notice("clone")
+ return cua_local_image.cmd_clone(args)
elif cmd == "shell":
- return cmd_shell(args)
+ _deprecation_notice("shell")
+ return cua_local_image.cmd_shell(args)
else:
- return cmd_list(args)
+ _deprecation_notice("list")
+ return cua_local_image.cmd_local_list(args)
diff --git a/libs/cua-bench/cua_bench/cli/commands/platform.py b/libs/cua-bench/cua_bench/cli/commands/platform.py
index 9d900193ab..8bcd429d5d 100644
--- a/libs/cua-bench/cua_bench/cli/commands/platform.py
+++ b/libs/cua-bench/cua_bench/cli/commands/platform.py
@@ -300,13 +300,44 @@ def register_parser(subparsers):
platform_parser.set_defaults(platform_command="list")
+def _deprecation_notice(cmd_name: str) -> None:
+ """Print deprecation notice for cb platform commands."""
+ import sys
+
+ equivalent = f"cua platform {cmd_name}"
+ print(
+ f"\033[33m⚠ Deprecation: 'cb platform {cmd_name}' is deprecated. "
+ f"Use '{equivalent}' instead.\033[0m",
+ file=sys.stderr,
+ )
+
+
def execute(args) -> int:
- """Execute the platform command."""
+ """Execute the platform command.
+
+ Delegates to cua_cli with a deprecation warning. Users should migrate
+ to 'cua platform' commands.
+ """
cmd = getattr(args, "platform_command", "list")
+ try:
+ from cua_cli.commands import platform as cua_platform
+ except ImportError:
+ # Fall back to local implementations if cua-cli is not installed
+ if cmd == "list":
+ return cmd_list(args)
+ elif cmd == "info":
+ return cmd_info(args)
+ else:
+ return cmd_list(args)
+
+ # Delegate to cua_cli with deprecation warning
if cmd == "list":
- return cmd_list(args)
+ _deprecation_notice("list")
+ return cua_platform.cmd_list(args)
elif cmd == "info":
- return cmd_info(args)
+ _deprecation_notice("info")
+ return cua_platform.cmd_info(args)
else:
- return cmd_list(args)
+ _deprecation_notice("list")
+ return cua_platform.cmd_list(args)
diff --git a/libs/cua-bench/datasets/cua-bench-workflows/README.md b/libs/cua-bench/datasets/cua-bench-workflows/README.md
index 8f5dbbba51..4d6d39dccd 100644
--- a/libs/cua-bench/datasets/cua-bench-workflows/README.md
+++ b/libs/cua-bench/datasets/cua-bench-workflows/README.md
@@ -46,10 +46,10 @@ cb interact datasets/cua-bench-workflows/photoshop-tasks --variant-id 2
### photoshop-tasks
-| Variant | Description |
-|---------|-------------|
-| 0 | Create document with "Hello World" text layer |
-| 1 | Create document with "Welcome to CUA" text layer |
-| 2 | Open PSD and count layers |
-| 3 | Open PSD and describe layers |
-| 4 | Create and save document as specific filename |
+| Variant | Description |
+| ------- | ------------------------------------------------ |
+| 0 | Create document with "Hello World" text layer |
+| 1 | Create document with "Welcome to CUA" text layer |
+| 2 | Open PSD and count layers |
+| 3 | Open PSD and describe layers |
+| 4 | Create and save document as specific filename |
diff --git a/libs/cuabot/Dockerfile b/libs/cuabot/Dockerfile
index 2bc919c84e..250bfc1ff1 100644
--- a/libs/cuabot/Dockerfile
+++ b/libs/cuabot/Dockerfile
@@ -1,4 +1,4 @@
-# Minimal xpra container with agent-browser
+# Minimal xpra + agent-browser container
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
@@ -70,7 +70,9 @@ RUN npm install -g agent-device
# Set Android SDK environment variables
ENV ANDROID_SDK_ROOT=/home/user/android-sdk
-ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
+# Create arch-agnostic symlink for JAVA_HOME (amd64 vs aarch64)
+RUN ln -sfn "/usr/lib/jvm/java-17-openjdk-$(dpkg --print-architecture)" /usr/lib/jvm/java-17-openjdk
+ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk
ENV PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator:${PATH}"
# Install Android SDK command-line tools
@@ -83,13 +85,22 @@ RUN mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" \
&& chown -R user:user "${ANDROID_SDK_ROOT}"
# Install platform-tools, emulator, and platforms (NOT the system image - too large)
-RUN yes | sdkmanager --licenses 2>/dev/null || true \
- && sdkmanager "platform-tools" "emulator" "platforms;android-35" \
+# Re-export JAVA_HOME to override any value written to /etc/environment by openjdk install
+# Note: the "emulator" package is only available for amd64, so skip it on arm64
+RUN export JAVA_HOME=/usr/lib/jvm/java-17-openjdk \
+ && (yes | sdkmanager --licenses 2>/dev/null || true) \
+ && if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
+ sdkmanager "platform-tools" "emulator" "platforms;android-35"; \
+ else \
+ sdkmanager "platform-tools" "platforms;android-35"; \
+ fi \
&& chown -R user:user "${ANDROID_SDK_ROOT}"
-# Symlink adb/emulator into PATH
+# Symlink adb/emulator into PATH (emulator may not exist on arm64)
RUN ln -sf /home/user/android-sdk/platform-tools/adb /usr/local/bin/adb \
- && ln -sf /home/user/android-sdk/emulator/emulator /usr/local/bin/emulator
+ && if [ -f /home/user/android-sdk/emulator/emulator ]; then \
+ ln -sf /home/user/android-sdk/emulator/emulator /usr/local/bin/emulator; \
+ fi
# Install Chromium from xtradeb PPA (avoids snap requirement on Ubuntu 22.04)
RUN add-apt-repository ppa:xtradeb/apps -y \
diff --git a/libs/cuabot/bin/cuabot.js b/libs/cuabot/bin/cuabot.js
index da01a4cd13..60e8ef7088 100755
--- a/libs/cuabot/bin/cuabot.js
+++ b/libs/cuabot/bin/cuabot.js
@@ -1,11 +1,11 @@
#!/usr/bin/env node
-import { fileURLToPath, pathToFileURL } from "url";
-import { dirname, join } from "path";
+import { fileURLToPath, pathToFileURL } from 'url';
+import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Import and run the compiled cuabot module
-const cuabotPath = join(__dirname, "..", "dist", "cuabot.js");
-const importPath = process.platform === "win32" ? pathToFileURL(cuabotPath).href : cuabotPath;
+const cuabotPath = join(__dirname, '..', 'dist', 'cuabot.js');
+const importPath = process.platform === 'win32' ? pathToFileURL(cuabotPath).href : cuabotPath;
import(importPath);
diff --git a/libs/cuabot/package.json b/libs/cuabot/package.json
index 053910a2c9..984e93610e 100644
--- a/libs/cuabot/package.json
+++ b/libs/cuabot/package.json
@@ -46,4 +46,4 @@
"@types/ws": "^8.18.1",
"typescript": "^5.7.0"
}
-}
\ No newline at end of file
+}
diff --git a/libs/cuabot/src/client.ts b/libs/cuabot/src/client.ts
index 2d1ab58843..cc243b1e73 100644
--- a/libs/cuabot/src/client.ts
+++ b/libs/cuabot/src/client.ts
@@ -3,19 +3,19 @@
* Connects to the CuaBot server via HTTP
*/
-import { spawn } from "child_process";
-import { existsSync, readFileSync, openSync } from "fs";
-import { join, dirname } from "path";
-import { homedir } from "os";
-import { fileURLToPath } from "url";
-import { checkDependencies } from "./utils.js";
+import { spawn } from 'child_process';
+import { existsSync, readFileSync, openSync } from 'fs';
+import { join, dirname } from 'path';
+import { homedir } from 'os';
+import { fileURLToPath } from 'url';
+import { checkDependencies } from './utils.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
-const CONFIG_DIR = join(homedir(), ".cuabot");
+const CONFIG_DIR = join(homedir(), '.cuabot');
-const STARTING_ERROR = "cuabotd is still starting";
+const STARTING_ERROR = 'cuabotd is still starting';
// Session name support
let currentSessionName: string | null = null;
@@ -31,13 +31,13 @@ export function getSessionName(): string | null {
function getPidFile(): string {
return currentSessionName
? join(CONFIG_DIR, `server.${currentSessionName}.pid`)
- : join(CONFIG_DIR, "server.pid");
+ : join(CONFIG_DIR, 'server.pid');
}
function getPortFile(): string {
return currentSessionName
? join(CONFIG_DIR, `server.${currentSessionName}.port`)
- : join(CONFIG_DIR, "server.port");
+ : join(CONFIG_DIR, 'server.port');
}
// Read port from port file, with optional wait
@@ -45,7 +45,7 @@ function readPortFromFile(): number | null {
const portFile = getPortFile();
if (existsSync(portFile)) {
try {
- return parseInt(readFileSync(portFile, "utf-8").trim(), 10);
+ return parseInt(readFileSync(portFile, 'utf-8').trim(), 10);
} catch {
return null;
}
@@ -66,8 +66,8 @@ export class CuaBotClient {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const res = await fetch(`${this.baseUrl}/${endpoint}`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
});
@@ -76,9 +76,9 @@ export class CuaBotClient {
// If server is still starting, wait and retry
if (data.error === STARTING_ERROR) {
if (attempt === 0) {
- console.error("Waiting for cuabotd to finish starting...");
+ console.error('Waiting for cuabotd to finish starting...');
}
- await new Promise(r => setTimeout(r, retryDelay));
+ await new Promise((r) => setTimeout(r, retryDelay));
continue;
}
throw new Error(data.error);
@@ -86,11 +86,16 @@ export class CuaBotClient {
return data;
}
- throw new Error("Timed out waiting for cuabotd to start");
+ throw new Error('Timed out waiting for cuabotd to start');
}
- async status(): Promise<{ ok: boolean; container: string; containerPort: number | null; playwright: string }> {
- return this.request("status");
+ async status(): Promise<{
+ ok: boolean;
+ container: string;
+ containerPort: number | null;
+ playwright: string;
+ }> {
+ return this.request('status');
}
async getContainerPort(): Promise<number | null> {
@@ -103,61 +108,69 @@ export class CuaBotClient {
run_in_background?: boolean,
timeout?: number
): Promise<{ stdout: string; stderr: string; pid?: number }> {
- return this.request("bash", { command, run_in_background, timeout });
+ return this.request('bash', { command, run_in_background, timeout });
}
async screenshot(): Promise<string> {
- const result = await this.request("screenshot");
+ const result = await this.request('screenshot');
return result.image;
}
- async click(x: number, y: number, button: "left" | "right" | "middle" = "left"): Promise<void> {
- await this.request("click", { x, y, button });
+ async click(x: number, y: number, button: 'left' | 'right' | 'middle' = 'left'): Promise<void> {
+ await this.request('click', { x, y, button });
}
async doubleClick(x: number, y: number): Promise<void> {
- await this.request("doubleClick", { x, y });
+ await this.request('doubleClick', { x, y });
}
async type(text: string, delay?: number): Promise<void> {
- await this.request("type", { text, delay });
+ await this.request('type', { text, delay });
}
async mouseMove(x: number, y: number): Promise<void> {
- await this.request("mouseMove", { x, y });
+ await this.request('mouseMove', { x, y });
}
- async mouseDown(x: number, y: number, button: "left" | "right" | "middle" = "left"): Promise<void> {
- await this.request("mouseDown", { x, y, button });
+ async mouseDown(
+ x: number,
+ y: number,
+ button: 'left' | 'right' | 'middle' = 'left'
+ ): Promise<void> {
+ await this.request('mouseDown', { x, y, button });
}
- async mouseUp(x: number, y: number, button: "left" | "right" | "middle" = "left"): Promise<void> {
- await this.request("mouseUp", { x, y, button });
+ async mouseUp(x: number, y: number, button: 'left' | 'right' | 'middle' = 'left'): Promise<void> {
+ await this.request('mouseUp', { x, y, button });
}
async scroll(x: number, y: number, deltaX: number, deltaY: number): Promise<void> {
- await this.request("scroll", { x, y, deltaX, deltaY });
+ await this.request('scroll', { x, y, deltaX, deltaY });
}
async keyDown(key: string): Promise<void> {
- await this.request("keyDown", { key });
+ await this.request('keyDown', { key });
}
async keyUp(key: string): Promise<void> {
- await this.request("keyUp", { key });
+ await this.request('keyUp', { key });
}
async keyPress(key: string): Promise<void> {
- await this.request("keyPress", { key });
+ await this.request('keyPress', { key });
}
async drag(fromX: number, fromY: number, toX: number, toY: number): Promise<void> {
- await this.request("drag", { fromX, fromY, toX, toY });
+ await this.request('drag', { fromX, fromY, toX, toY });
}
}
// Check if server is running and actually responding
-export async function isServerRunning(): Promise<{ running: boolean; port: number | null; pid?: number }> {
+export async function isServerRunning(): Promise<{
+ running: boolean;
+ port: number | null;
+ pid?: number;
+}> {
const pidFile = getPidFile();
const portFile = getPortFile();
@@ -165,16 +178,16 @@ export async function isServerRunning(): Promise<{ running: boolean; port: numbe
return { running: false, port: null };
}
- const pid = parseInt(readFileSync(pidFile, "utf-8").trim(), 10);
- const port = existsSync(portFile)
- ? parseInt(readFileSync(portFile, "utf-8").trim(), 10)
- : null;
+ const pid = parseInt(readFileSync(pidFile, 'utf-8').trim(), 10);
+ const port = existsSync(portFile) ? parseInt(readFileSync(portFile, 'utf-8').trim(), 10) : null;
try {
process.kill(pid, 0);
// Check if HTTP server is actually responding
try {
- const res = await fetch(`http://localhost:${port}/status`, { signal: AbortSignal.timeout(2000) });
+ const res = await fetch(`http://localhost:${port}/status`, {
+ signal: AbortSignal.timeout(2000),
+ });
if (res.ok) {
return { running: true, port, pid };
}
@@ -198,48 +211,52 @@ export async function ensureServerRunning(): Promise<number> {
// Check dependencies before trying to start the server
const deps = await checkDependencies();
if (!deps.ok) {
- console.log("deps", deps);
- throw new Error(`Missing dependencies:\n${deps.errors.map(e => ` - ${e}`).join("\n")}\n\nSee https://github.com/trycua/cuabot#quick-start for installation instructions.`);
+ console.log('deps', deps);
+ throw new Error(
+ `Missing dependencies:\n${deps.errors.map((e) => ` - ${e}`).join('\n')}\n\nSee https://github.com/trycua/cuabot#quick-start for installation instructions.`
+ );
}
- const sessionSuffix = currentSessionName ? ` (session: ${currentSessionName})` : "";
+ const sessionSuffix = currentSessionName ? ` (session: ${currentSessionName})` : '';
console.error(`starting cuabotd in background${sessionSuffix}...`);
// Start server as detached background process using npx cuabot serve
- const spawnArgs = ["cuabot", "--serve"];
+ const spawnArgs = ['cuabot', '--serve'];
if (currentSessionName) {
- spawnArgs.push("--name", currentSessionName);
+ spawnArgs.push('--name', currentSessionName);
}
// Write stderr to a log file so we can debug issues
- const logFile = join(CONFIG_DIR, "server.log");
- const logFd = openSync(logFile, "w");
+ const logFile = join(CONFIG_DIR, 'server.log');
+ const logFd = openSync(logFile, 'w');
// console.error(`Server logs will be written to: ${logFile}`);
- const child = spawn("npx", spawnArgs, {
+ const child = spawn('npx', spawnArgs, {
detached: true,
- stdio: ["ignore", "ignore", logFd],
+ stdio: ['ignore', 'ignore', logFd],
cwd: process.cwd(),
windowsHide: true,
- shell: process.platform === "win32",
+ shell: process.platform === 'win32',
});
child.unref();
// Wait for port file to be written, then poll for server ready
let lastError: Error | null = null;
for (let i = 0; i < 240; i++) {
- await new Promise(r => setTimeout(r, 500));
+ await new Promise((r) => setTimeout(r, 500));
// Try to read port from file
const port = readPortFromFile();
if (!port) continue;
try {
- const res = await fetch(`http://localhost:${port}/status`, { signal: AbortSignal.timeout(1000) });
+ const res = await fetch(`http://localhost:${port}/status`, {
+ signal: AbortSignal.timeout(1000),
+ });
if (res.ok) {
- const data = await res.json() as { ready?: boolean };
+ const data = (await res.json()) as { ready?: boolean };
if (data.ready) {
- console.error("Server ready!");
+ console.error('Server ready!');
return port;
}
// Server responded but not ready yet, keep waiting
@@ -253,6 +270,8 @@ export async function ensureServerRunning(): Promise<number> {
}
}
- const errorMsg = lastError ? `: ${lastError.message}` : "";
- throw new Error(`Failed to start server after 2 minutes${errorMsg}. The server may still be initializing (building Docker image, starting container, etc.). Check server logs at: ${logFile} or try again in a moment.`);
+ const errorMsg = lastError ? `: ${lastError.message}` : '';
+ throw new Error(
+ `Failed to start server after 2 minutes${errorMsg}. The server may still be initializing (building Docker image, starting container, etc.). Check server logs at: ${logFile} or try again in a moment.`
+ );
}
diff --git a/libs/cuabot/src/cuabot.tsx b/libs/cuabot/src/cuabot.tsx
index 0de203781b..99d5172946 100644
--- a/libs/cuabot/src/cuabot.tsx
+++ b/libs/cuabot/src/cuabot.tsx
@@ -3,25 +3,36 @@
* CuaBot CLI
*/
-import { startServer, stopServer, getServerInfo, setSessionName as setServerSessionName } from "./cuabotd.js";
-import { ensureServerRunning, setSessionName as setClientSessionName } from "./client.js";
-import { getDefaultAgent, AGENTS, AgentId, getAliasIgnored, getTelemetryEnabled } from "./settings.js";
-import { runOnboarding } from "./onboarding.js";
-import { sendTelemetryToServer } from "./telemetry.js";
-import { checkDependencies } from "./utils.js";
-import { execSync } from "child_process";
-import { existsSync, readFileSync } from "fs";
-import { homedir } from "os";
-import { join } from "path";
+import {
+ startServer,
+ stopServer,
+ getServerInfo,
+ setSessionName as setServerSessionName,
+} from './cuabotd.js';
+import { ensureServerRunning, setSessionName as setClientSessionName } from './client.js';
+import {
+ getDefaultAgent,
+ AGENTS,
+ AgentId,
+ getAliasIgnored,
+ getTelemetryEnabled,
+} from './settings.js';
+import { runOnboarding } from './onboarding.js';
+import { sendTelemetryToServer } from './telemetry.js';
+import { checkDependencies } from './utils.js';
+import { execSync } from 'child_process';
+import { existsSync, readFileSync } from 'fs';
+import { homedir } from 'os';
+import { join } from 'path';
function isCuabotInPath(): boolean {
try {
- const cmd = process.platform === "win32" ? "where cuabot" : "which cuabot";
- const result = execSync(cmd, { encoding: "utf-8" }).trim();
+ const cmd = process.platform === 'win32' ? 'where cuabot' : 'which cuabot';
+ const result = execSync(cmd, { encoding: 'utf-8' }).trim();
// Ignore paths from npx/pnpm dlx temporary cache
- const paths = result.split(/\r?\n/).filter(p =>
- !p.includes("_npx") && !p.includes("\\dlx\\") && !p.includes("/dlx/")
- );
+ const paths = result
+ .split(/\r?\n/)
+ .filter((p) => !p.includes('_npx') && !p.includes('\\dlx\\') && !p.includes('/dlx/'));
return paths.length > 0;
} catch {
return false;
@@ -37,7 +48,7 @@ function parseSessionName(inputArgs: string[]): [string | null, string[]] {
for (let i = 0; i < inputArgs.length; i++) {
const arg = inputArgs[i];
- if (arg === "--name" || arg === "-n") {
+ if (arg === '--name' || arg === '-n') {
sessionName = inputArgs[i + 1] || null;
i++; // Skip the next arg (the name value)
} else {
@@ -62,7 +73,7 @@ async function sendCliTelemetry(port: number): Promise<void> {
cliTelemetrySent = true;
await sendTelemetryToServer(port, {
- type: "cli_invocation",
+ type: 'cli_invocation',
timestamp: Date.now(),
cli_args: args,
cwd: process.cwd(),
@@ -70,14 +81,14 @@ async function sendCliTelemetry(port: number): Promise<void> {
}
async function getClient() {
- const { CuaBotClient } = await import("./client.js");
+ const { CuaBotClient } = await import('./client.js');
const port = await ensureServerRunning();
sendCliTelemetry(port); // Fire and forget
return new CuaBotClient(port);
}
async function runCommand(shellCommand: string) {
- const WebSocket = (await import("ws")).default;
+ const WebSocket = (await import('ws')).default;
const port = await ensureServerRunning();
sendCliTelemetry(port); // Fire and forget
@@ -87,20 +98,20 @@ async function runCommand(shellCommand: string) {
const ws = new WebSocket(wsUrl);
- ws.on("open", () => {
+ ws.on('open', () => {
if (process.stdin.isTTY) process.stdin.setRawMode(true);
process.stdin.resume();
});
- ws.on("message", (data: Buffer) => {
+ ws.on('message', (data: Buffer) => {
try {
const msg = JSON.parse(data.toString());
- if (msg.type === "stdout" || msg.type === "stderr") {
- process.stdout.write(Buffer.from(msg.data, "base64"));
- } else if (msg.type === "exit") {
+ if (msg.type === 'stdout' || msg.type === 'stderr') {
+ process.stdout.write(Buffer.from(msg.data, 'base64'));
+ } else if (msg.type === 'exit') {
cleanup();
process.exit(msg.code || 0);
- } else if (msg.type === "error") {
+ } else if (msg.type === 'error') {
console.error(`\nError: ${msg.message}`);
cleanup();
process.exit(1);
@@ -112,32 +123,44 @@ async function runCommand(shellCommand: string) {
const onStdinData = (data: Buffer) => {
if (ws.readyState === WebSocket.OPEN) {
- ws.send(JSON.stringify({ type: "stdin", data: data.toString("base64") }));
+ ws.send(JSON.stringify({ type: 'stdin', data: data.toString('base64') }));
}
};
- process.stdin.on("data", onStdinData);
+ process.stdin.on('data', onStdinData);
const onResize = () => {
if (ws.readyState === WebSocket.OPEN) {
- ws.send(JSON.stringify({ type: "resize", cols: process.stdout.columns || 80, rows: process.stdout.rows || 24 }));
+ ws.send(
+ JSON.stringify({
+ type: 'resize',
+ cols: process.stdout.columns || 80,
+ rows: process.stdout.rows || 24,
+ })
+ );
}
};
- process.stdout.on("resize", onResize);
+ process.stdout.on('resize', onResize);
const cleanup = () => {
- process.stdin.removeListener("data", onStdinData);
- process.stdout.removeListener("resize", onResize);
+ process.stdin.removeListener('data', onStdinData);
+ process.stdout.removeListener('resize', onResize);
if (process.stdin.isTTY) process.stdin.setRawMode(false);
ws.close();
};
- ws.on("close", () => { cleanup(); process.exit(0); });
- ws.on("error", (err: Error & { code?: string }) => {
+ ws.on('close', () => {
+ cleanup();
+ process.exit(0);
+ });
+ ws.on('error', (err: Error & { code?: string }) => {
console.error(`WebSocket error: ${err.message || err.code || err}`);
cleanup();
process.exit(1);
});
- process.on("SIGINT", () => { cleanup(); process.exit(0); });
+ process.on('SIGINT', () => {
+ cleanup();
+ process.exit(0);
+ });
}
async function runAgent(agentId: string, extraArgs: string[] = []) {
@@ -145,11 +168,12 @@ async function runAgent(agentId: string, extraArgs: string[] = []) {
sendCliTelemetry(port); // Fire and forget
let shellCommand: string;
- if (agentId === "claude") {
- shellCommand = `claude --mcp-config /home/user/.mcp.json --append-system-prompt-file /home/user/CLAUDE.md ${extraArgs.join(" ")}`.trim();
+ if (agentId === 'claude') {
+ shellCommand =
+ `claude --mcp-config /home/user/.mcp.json --append-system-prompt-file /home/user/CLAUDE.md ${extraArgs.join(' ')}`.trim();
} else {
const agent = AGENTS[agentId as AgentId];
- shellCommand = `${agent?.command || agentId} ${extraArgs.join(" ")}`.trim();
+ shellCommand = `${agent?.command || agentId} ${extraArgs.join(' ')}`.trim();
}
await runCommand(shellCommand);
@@ -163,12 +187,12 @@ async function main() {
const flag = remainingArgs[0];
// Flag commands
- if (flag?.startsWith("--")) {
+ if (flag?.startsWith('--')) {
const flagArgs = remainingArgs.slice(1);
switch (flag) {
- case "--help":
- case "-h": {
+ case '--help':
+ case '-h': {
console.log(`cuabot - Computer Use Agent Bot
Usage:
@@ -201,76 +225,84 @@ Commands:
process.exit(0);
}
- case "--serve": {
+ case '--serve': {
const port = flagArgs[0] ? parseInt(flagArgs[0], 10) : undefined;
await startServer(port);
break;
}
- case "--stop": {
+ case '--stop': {
const stopped = await stopServer();
process.exit(stopped ? 0 : 1);
}
- case "--status": {
+ case '--status': {
const info = getServerInfo();
if (info) {
- const nameSuffix = sessionName ? ` [${sessionName}]` : "";
+ const nameSuffix = sessionName ? ` [${sessionName}]` : '';
console.log(`Server${nameSuffix} running on port ${info.port} (PID: ${info.pid})`);
} else {
- console.log("Server not running");
+ console.log('Server not running');
}
process.exit(0);
}
- case "--reset": {
- const { execSync } = await import("child_process");
- const { rmSync } = await import("fs");
- const { homedir } = await import("os");
- const { join } = await import("path");
-
- const target = flagArgs[0] || "all";
- const CONTAINER_NAME = "cuabot-xpra";
- const IMAGE_NAME = "trycua/cuabot:latest";
- const CONFIG_DIR = join(homedir(), ".cuabot");
-
- if (target === "sandbox" || target === "all") {
- console.log("Resetting sandbox...");
- try { await stopServer(); } catch {}
- try { execSync(`docker rm -f ${CONTAINER_NAME}`, { stdio: "ignore" }); } catch {}
- try { execSync(`docker rmi ${IMAGE_NAME}`, { stdio: "ignore" }); } catch {}
- console.log(" ✓ Container and image removed");
+ case '--reset': {
+ const { execSync } = await import('child_process');
+ const { rmSync } = await import('fs');
+ const { homedir } = await import('os');
+ const { join } = await import('path');
+
+ const target = flagArgs[0] || 'all';
+ const CONTAINER_NAME = 'cuabot-xpra';
+ const IMAGE_NAME = 'trycua/cuabot:latest';
+ const CONFIG_DIR = join(homedir(), '.cuabot');
+
+ if (target === 'sandbox' || target === 'all') {
+ console.log('Resetting sandbox...');
+ try {
+ await stopServer();
+ } catch {}
+ try {
+ execSync(`docker rm -f ${CONTAINER_NAME}`, { stdio: 'ignore' });
+ } catch {}
+ try {
+ execSync(`docker rmi ${IMAGE_NAME}`, { stdio: 'ignore' });
+ } catch {}
+ console.log(' ✓ Container and image removed');
}
- if (target === "settings" || target === "all") {
- console.log("Resetting settings...");
- try { rmSync(CONFIG_DIR, { recursive: true, force: true }); } catch {}
- console.log(" ✓ ~/.cuabot removed");
+ if (target === 'settings' || target === 'all') {
+ console.log('Resetting settings...');
+ try {
+ rmSync(CONFIG_DIR, { recursive: true, force: true });
+ } catch {}
+ console.log(' ✓ ~/.cuabot removed');
}
- if (target !== "all" && target !== "sandbox" && target !== "settings") {
- console.error("Usage: cuabot --reset [all|sandbox|settings]");
+ if (target !== 'all' && target !== 'sandbox' && target !== 'settings') {
+ console.error('Usage: cuabot --reset [all|sandbox|settings]');
process.exit(1);
}
- console.log("Done.");
+ console.log('Done.');
process.exit(0);
}
- case "--screenshot": {
+ case '--screenshot': {
const client = await getClient();
const base64 = await client.screenshot();
- const { writeFileSync } = await import("fs");
- const outputPath = flagArgs[0] || "screenshot.jpg";
- writeFileSync(outputPath, Buffer.from(base64, "base64"));
+ const { writeFileSync } = await import('fs');
+ const outputPath = flagArgs[0] || 'screenshot.jpg';
+ writeFileSync(outputPath, Buffer.from(base64, 'base64'));
console.log(`Screenshot saved to ${outputPath}`);
process.exit(0);
}
- case "--bash": {
- const cmd = flagArgs.join(" ");
+ case '--bash': {
+ const cmd = flagArgs.join(' ');
if (!cmd) {
- console.error("Usage: cuabot --bash <command>");
+ console.error('Usage: cuabot --bash <command>');
process.exit(1);
}
const client = await getClient();
@@ -280,198 +312,249 @@ Commands:
process.exit(0);
}
- case "--click": {
+ case '--click': {
const [x, y, button] = flagArgs;
- if (!x || !y) { console.error("Usage: cuabot --click <x> <y> [button]"); process.exit(1); }
+ if (!x || !y) {
+ console.error('Usage: cuabot --click <x> <y> [button]');
+ process.exit(1);
+ }
const client = await getClient();
- await client.click(parseInt(x), parseInt(y), (button as any) || "left");
+ await client.click(parseInt(x), parseInt(y), (button as any) || 'left');
console.log(`Clicked at ${x},${y}`);
process.exit(0);
}
- case "--doubleclick": {
+ case '--doubleclick': {
const [x, y] = flagArgs;
- if (!x || !y) { console.error("Usage: cuabot --doubleclick <x> <y>"); process.exit(1); }
+ if (!x || !y) {
+ console.error('Usage: cuabot --doubleclick <x> <y>');
+ process.exit(1);
+ }
const client = await getClient();
await client.doubleClick(parseInt(x), parseInt(y));
console.log(`Double-clicked at ${x},${y}`);
process.exit(0);
}
- case "--move": {
+ case '--move': {
const [x, y] = flagArgs;
- if (!x || !y) { console.error("Usage: cuabot --move <x> <y>"); process.exit(1); }
+ if (!x || !y) {
+ console.error('Usage: cuabot --move <x> <y>');
+ process.exit(1);
+ }
const client = await getClient();
await client.mouseMove(parseInt(x), parseInt(y));
console.log(`Moved to ${x},${y}`);
process.exit(0);
}
- case "--mousedown": {
+ case '--mousedown': {
const [x, y, button] = flagArgs;
- if (!x || !y) { console.error("Usage: cuabot --mousedown <x> <y> [button]"); process.exit(1); }
+ if (!x || !y) {
+ console.error('Usage: cuabot --mousedown <x> <y> [button]');
+ process.exit(1);
+ }
const client = await getClient();
- await client.mouseDown(parseInt(x), parseInt(y), (button as any) || "left");
+ await client.mouseDown(parseInt(x), parseInt(y), (button as any) || 'left');
console.log(`Mouse down at ${x},${y}`);
process.exit(0);
}
- case "--mouseup": {
+ case '--mouseup': {
const [x, y, button] = flagArgs;
- if (!x || !y) { console.error("Usage: cuabot --mouseup <x> <y> [button]"); process.exit(1); }
+ if (!x || !y) {
+ console.error('Usage: cuabot --mouseup <x> <y> [button]');
+ process.exit(1);
+ }
const client = await getClient();
- await client.mouseUp(parseInt(x), parseInt(y), (button as any) || "left");
+ await client.mouseUp(parseInt(x), parseInt(y), (button as any) || 'left');
console.log(`Mouse up at ${x},${y}`);
process.exit(0);
}
- case "--drag": {
+ case '--drag': {
const [x1, y1, x2, y2] = flagArgs;
- if (!x1 || !y1 || !x2 || !y2) { console.error("Usage: cuabot --drag <x1> <y1> <x2> <y2>"); process.exit(1); }
+ if (!x1 || !y1 || !x2 || !y2) {
+ console.error('Usage: cuabot --drag <x1> <y1> <x2> <y2>');
+ process.exit(1);
+ }
const client = await getClient();
await client.drag(parseInt(x1), parseInt(y1), parseInt(x2), parseInt(y2));
console.log(`Dragged from ${x1},${y1} to ${x2},${y2}`);
process.exit(0);
}
- case "--scroll": {
+ case '--scroll': {
const [x, y, dx, dy] = flagArgs;
- if (!x || !y || !dy) { console.error("Usage: cuabot --scroll <x> <y> <dx> <dy>"); process.exit(1); }
+ if (!x || !y || !dy) {
+ console.error('Usage: cuabot --scroll <x> <y> <dx> <dy>');
+ process.exit(1);
+ }
const client = await getClient();
- await client.scroll(parseInt(x), parseInt(y), parseInt(dx || "0"), parseInt(dy));
+ await client.scroll(parseInt(x), parseInt(y), parseInt(dx || '0'), parseInt(dy));
console.log(`Scrolled at ${x},${y}`);
process.exit(0);
}
- case "--type": {
- const text = flagArgs.join(" ");
- if (!text) { console.error("Usage: cuabot --type <text>"); process.exit(1); }
+ case '--type': {
+ const text = flagArgs.join(' ');
+ if (!text) {
+ console.error('Usage: cuabot --type <text>');
+ process.exit(1);
+ }
const client = await getClient();
await client.type(text);
console.log(`Typed: ${text}`);
process.exit(0);
}
- case "--key": {
+ case '--key': {
const key = flagArgs[0];
- if (!key) { console.error("Usage: cuabot --key <key>"); process.exit(1); }
+ if (!key) {
+ console.error('Usage: cuabot --key <key>');
+ process.exit(1);
+ }
const client = await getClient();
await client.keyPress(key);
console.log(`Pressed: ${key}`);
process.exit(0);
}
- case "--keydown": {
+ case '--keydown': {
const key = flagArgs[0];
- if (!key) { console.error("Usage: cuabot --keydown <key>"); process.exit(1); }
+ if (!key) {
+ console.error('Usage: cuabot --keydown <key>');
+ process.exit(1);
+ }
const client = await getClient();
await client.keyDown(key);
console.log(`Key down: ${key}`);
process.exit(0);
}
- case "--keyup": {
+ case '--keyup': {
const key = flagArgs[0];
- if (!key) { console.error("Usage: cuabot --keyup <key>"); process.exit(1); }
+ if (!key) {
+ console.error('Usage: cuabot --keyup <key>');
+ process.exit(1);
+ }
const client = await getClient();
await client.keyUp(key);
console.log(`Key up: ${key}`);
process.exit(0);
}
- case "--debug-onboarding": {
- const CONFIG_DIR = join(homedir(), ".cuabot");
- const SETTINGS_FILE = join(CONFIG_DIR, "settings.json");
+ case '--debug-onboarding': {
+ const CONFIG_DIR = join(homedir(), '.cuabot');
+ const SETTINGS_FILE = join(CONFIG_DIR, 'settings.json');
- console.log("=== Onboarding Debug ===\n");
- console.log("Platform:", process.platform);
- console.log("Home:", homedir());
- console.log("");
+ console.log('=== Onboarding Debug ===\n');
+ console.log('Platform:', process.platform);
+ console.log('Home:', homedir());
+ console.log('');
// Check settings
- console.log("=== Settings ===");
- console.log("Settings file:", SETTINGS_FILE);
- console.log("Settings exists:", existsSync(SETTINGS_FILE));
+ console.log('=== Settings ===');
+ console.log('Settings file:', SETTINGS_FILE);
+ console.log('Settings exists:', existsSync(SETTINGS_FILE));
if (existsSync(SETTINGS_FILE)) {
try {
- const settings = JSON.parse(readFileSync(SETTINGS_FILE, "utf-8"));
- console.log("Settings content:", JSON.stringify(settings, null, 2));
- console.log("aliasIgnored:", settings.aliasIgnored === true);
+ const settings = JSON.parse(readFileSync(SETTINGS_FILE, 'utf-8'));
+ console.log('Settings content:', JSON.stringify(settings, null, 2));
+ console.log('aliasIgnored:', settings.aliasIgnored === true);
} catch (e) {
- console.log("Failed to read settings:", e);
+ console.log('Failed to read settings:', e);
}
} else {
- console.log("aliasIgnored: false (no settings file)");
+ console.log('aliasIgnored: false (no settings file)');
}
- console.log("");
+ console.log('');
// Check cuabot in PATH
- console.log("=== Cuabot in PATH ===");
- const pathCmd = process.platform === "win32" ? "where cuabot" : "which cuabot";
- console.log("Command:", pathCmd);
+ console.log('=== Cuabot in PATH ===');
+ const pathCmd = process.platform === 'win32' ? 'where cuabot' : 'which cuabot';
+ console.log('Command:', pathCmd);
try {
- const result = execSync(pathCmd, { encoding: "utf-8" });
- console.log("Result:", result.trim());
- console.log("checkCuabotInPath: true");
+ const result = execSync(pathCmd, { encoding: 'utf-8' });
+ console.log('Result:', result.trim());
+ console.log('checkCuabotInPath: true');
} catch (e: any) {
- console.log("Error:", e.message?.split("\n")[0] || "Command failed");
- console.log("Exit code:", e.status);
- console.log("checkCuabotInPath: false");
+ console.log('Error:', e.message?.split('\n')[0] || 'Command failed');
+ console.log('Exit code:', e.status);
+ console.log('checkCuabotInPath: false');
}
- console.log("");
+ console.log('');
// Check shell RC file
- console.log("=== Shell RC File ===");
+ console.log('=== Shell RC File ===');
let rcFile: string | null = null;
- if (process.platform === "win32") {
- const ps7Profile = join(homedir(), "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1");
- const ps5Profile = join(homedir(), "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1");
- const ps7Dir = join(homedir(), "Documents", "PowerShell");
- console.log("PS7 dir exists:", existsSync(ps7Dir));
+ if (process.platform === 'win32') {
+ const ps7Profile = join(
+ homedir(),
+ 'Documents',
+ 'PowerShell',
+ 'Microsoft.PowerShell_profile.ps1'
+ );
+ const ps5Profile = join(
+ homedir(),
+ 'Documents',
+ 'WindowsPowerShell',
+ 'Microsoft.PowerShell_profile.ps1'
+ );
+ const ps7Dir = join(homedir(), 'Documents', 'PowerShell');
+ console.log('PS7 dir exists:', existsSync(ps7Dir));
rcFile = existsSync(ps7Dir) ? ps7Profile : ps5Profile;
} else {
- const shell = process.env.SHELL || "";
- console.log("SHELL env:", shell);
- if (shell.includes("zsh")) rcFile = join(homedir(), ".zshrc");
- else if (shell.includes("bash")) {
- const bashProfile = join(homedir(), ".bash_profile");
- rcFile = (process.platform === "darwin" && existsSync(bashProfile)) ? bashProfile : join(homedir(), ".bashrc");
+ const shell = process.env.SHELL || '';
+ console.log('SHELL env:', shell);
+ if (shell.includes('zsh')) rcFile = join(homedir(), '.zshrc');
+ else if (shell.includes('bash')) {
+ const bashProfile = join(homedir(), '.bash_profile');
+ rcFile =
+ process.platform === 'darwin' && existsSync(bashProfile)
+ ? bashProfile
+ : join(homedir(), '.bashrc');
}
}
- console.log("RC file:", rcFile);
+ console.log('RC file:', rcFile);
if (rcFile) {
- console.log("RC file exists:", existsSync(rcFile));
+ console.log('RC file exists:', existsSync(rcFile));
if (existsSync(rcFile)) {
- const content = readFileSync(rcFile, "utf-8");
- const hasAlias = content.includes("alias cuabot=") || content.includes("function cuabot");
- console.log("Has cuabot alias/function:", hasAlias);
+ const content = readFileSync(rcFile, 'utf-8');
+ const hasAlias =
+ content.includes('alias cuabot=') || content.includes('function cuabot');
+ console.log('Has cuabot alias/function:', hasAlias);
}
}
- console.log("");
+ console.log('');
// Windows batch file check
- if (process.platform === "win32") {
- console.log("=== Windows Batch File ===");
- const windowsApps = join(process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local"), "Microsoft", "WindowsApps");
- const batchFile = join(windowsApps, "cuabot.cmd");
- console.log("Batch file path:", batchFile);
- console.log("Batch file exists:", existsSync(batchFile));
+ if (process.platform === 'win32') {
+ console.log('=== Windows Batch File ===');
+ const windowsApps = join(
+ process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'),
+ 'Microsoft',
+ 'WindowsApps'
+ );
+ const batchFile = join(windowsApps, 'cuabot.cmd');
+ console.log('Batch file path:', batchFile);
+ console.log('Batch file exists:', existsSync(batchFile));
if (existsSync(batchFile)) {
- console.log("Batch file content:", readFileSync(batchFile, "utf-8"));
+ console.log('Batch file content:', readFileSync(batchFile, 'utf-8'));
}
- console.log("");
+ console.log('');
}
// Final result
- console.log("=== Final Check Result ===");
+ console.log('=== Final Check Result ===');
const cuabotInPath = isCuabotInPath();
const aliasIgnored = getAliasIgnored();
- const status = cuabotInPath || aliasIgnored ? "ok" : "error";
- const message = cuabotInPath ? "ready" : aliasIgnored ? "using npx" : "not set up";
- console.log("cuabotInPath:", cuabotInPath);
- console.log("aliasIgnored:", aliasIgnored);
- console.log("Status:", status);
- console.log("Message:", message);
+ const status = cuabotInPath || aliasIgnored ? 'ok' : 'error';
+ const message = cuabotInPath ? 'ready' : aliasIgnored ? 'using npx' : 'not set up';
+ console.log('cuabotInPath:', cuabotInPath);
+ console.log('aliasIgnored:', aliasIgnored);
+ console.log('Status:', status);
+ console.log('Message:', message);
process.exit(0);
}
@@ -502,7 +585,7 @@ Commands:
await runAgent(defaultAgent);
} catch (err) {
// If dependencies fail, show onboarding
- if (err instanceof Error && err.message.includes("Missing dependencies")) {
+ if (err instanceof Error && err.message.includes('Missing dependencies')) {
runOnboarding();
return;
}
@@ -519,7 +602,7 @@ Commands:
}
// cuabot <command> - run command in sandbox
- await runCommand(remainingArgs.join(" "));
+ await runCommand(remainingArgs.join(' '));
}
main().catch((err) => {
diff --git a/libs/cuabot/src/cuabotd.ts b/libs/cuabot/src/cuabotd.ts
index f09b3f4bb4..8b1fef58fb 100644
--- a/libs/cuabot/src/cuabotd.ts
+++ b/libs/cuabot/src/cuabotd.ts
@@ -6,38 +6,37 @@
* WebSocket support for interactive shell sessions
*/
-import * as pty from "@lydell/node-pty";
-import { exec, spawn } from "child_process";
-import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
-import { openWindows } from "get-windows";
-import { createServer, IncomingMessage, ServerResponse } from "http";
-import { homedir } from "os";
-import { join } from "path";
-import { Browser, BrowserContext, chromium, Page } from "playwright";
-import sharp from "sharp";
-import { promisify } from "util";
-import { WebSocket, WebSocketServer } from "ws";
-import { getDefaultAgent, getTelemetryEnabled } from "./settings.js";
+import * as pty from '@lydell/node-pty';
+import { exec, spawn } from 'child_process';
+import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'fs';
+import { openWindows } from 'get-windows';
+import { createServer, IncomingMessage, ServerResponse } from 'http';
+import { homedir } from 'os';
+import { join } from 'path';
+import { Browser, BrowserContext, chromium, Page } from 'playwright';
+import sharp from 'sharp';
+import { promisify } from 'util';
+import { WebSocket, WebSocketServer } from 'ws';
+import { getDefaultAgent, getTelemetryEnabled } from './settings.js';
import {
CuabotTelemetry,
initTelemetry,
startHistoryPolling,
stopHistoryPolling,
TelemetryEvent,
-} from "./telemetry.js";
-import { getXpraAttachArgs, getXpraBinPath, nameToColor } from "./utils.js";
-
+} from './telemetry.js';
+import { getXpraAttachArgs, getXpraBinPath, nameToColor } from './utils.js';
const execAsync = promisify(exec);
// Config
const DEFAULT_PORT = 7842;
-const CONFIG_DIR = join(homedir(), ".cuabot");
-const CLAUDE_CONFIG_DIR = join(CONFIG_DIR, "user", ".claude");
-const ANDROID_SDK_IMAGES_DIR = join(CONFIG_DIR, "user", "android-sdk", "system-images");
+const CONFIG_DIR = join(homedir(), '.cuabot');
+const CLAUDE_CONFIG_DIR = join(CONFIG_DIR, 'user', '.claude');
+const ANDROID_SDK_IMAGES_DIR = join(CONFIG_DIR, 'user', 'android-sdk', 'system-images');
-const IMAGE_NAME = "trycua/cuabot:latest";
-const BASE_CONTAINER_NAME = "cuabot-xpra";
+const IMAGE_NAME = 'trycua/cuabot:latest';
+const BASE_CONTAINER_NAME = 'cuabot-xpra';
// Session name support
let sessionName: string | null = null;
@@ -50,16 +49,15 @@ export function getSessionName(): string | null {
return sessionName;
}
-
// Find an available HTTP server port
async function findAvailableServerPort(preferredPort: number): Promise<number> {
- const net = await import("net");
+ const net = await import('net');
const isPortAvailable = (port: number): Promise<boolean> => {
return new Promise((resolve) => {
const server = net.createServer();
- server.once("error", () => resolve(false));
- server.once("listening", () => {
+ server.once('error', () => resolve(false));
+ server.once('listening', () => {
server.close();
resolve(true);
});
@@ -81,7 +79,7 @@ async function findAvailableServerPort(preferredPort: number): Promise<number> {
port++;
}
- throw new Error("No available ports found");
+ throw new Error('No available ports found');
}
function getContainerName(): string {
@@ -89,14 +87,18 @@ function getContainerName(): string {
}
function getPidFile(): string {
- return sessionName ? join(CONFIG_DIR, `server.${sessionName}.pid`) : join(CONFIG_DIR, "server.pid");
+ return sessionName
+ ? join(CONFIG_DIR, `server.${sessionName}.pid`)
+ : join(CONFIG_DIR, 'server.pid');
}
function getPortFile(): string {
- return sessionName ? join(CONFIG_DIR, `server.${sessionName}.port`) : join(CONFIG_DIR, "server.port");
+ return sessionName
+ ? join(CONFIG_DIR, `server.${sessionName}.port`)
+ : join(CONFIG_DIR, 'server.port');
}
-const SCREENSHOT_PATH = "F:\\Projects\\cuabot\\screenshot.jpg";
-const SCREENSHOT_CLICKED_PATH = "F:\\Projects\\cuabot\\screenshot-clicked.jpg";
+const SCREENSHOT_PATH = 'F:\\Projects\\cuabot\\screenshot.jpg';
+const SCREENSHOT_CLICKED_PATH = 'F:\\Projects\\cuabot\\screenshot-clicked.jpg';
const DEBUG = false;
// Telemetry client (initialized at startup)
@@ -112,7 +114,7 @@ let screenshotScale: number = 1; // Scale factor applied to screenshots (for sca
let xpraClientPid: number | null = null; // Track xpra client process for cleanup
let serverReady: boolean = false; // Track if server initialization is complete
-const STARTING_ERROR = "cuabotd is still starting";
+const STARTING_ERROR = 'cuabotd is still starting';
// Ensure config directory exists
function ensureConfigDir() {
@@ -132,14 +134,14 @@ function ensureConfigDir() {
// Docker helpers
async function testDockerConnection(): Promise<{ ok: boolean; message: string }> {
try {
- await execAsync("docker info");
- return { ok: true, message: "Docker connected" };
+ await execAsync('docker info');
+ return { ok: true, message: 'Docker connected' };
} catch {
try {
- await execAsync("docker --version");
- return { ok: false, message: "Docker installed but not running - start Docker Desktop" };
+ await execAsync('docker --version');
+ return { ok: false, message: 'Docker installed but not running - start Docker Desktop' };
} catch {
- return { ok: false, message: "Docker not installed" };
+ return { ok: false, message: 'Docker not installed' };
}
}
}
@@ -148,14 +150,14 @@ async function findAvailablePort(): Promise<number> {
const usedPorts = new Set<number>();
try {
const { stdout } = await execAsync('docker ps -a --format "{{json .Ports}}"');
- for (const line of stdout.trim().split("\n")) {
+ for (const line of stdout.trim().split('\n')) {
if (!line) continue;
const matches = line.matchAll(/(\d+)->(\d+)/g);
for (const match of matches) {
usedPorts.add(parseInt(match[1], 10));
}
}
- } catch { }
+ } catch {}
let port = 10000;
while (usedPorts.has(port)) port++;
return port;
@@ -169,22 +171,28 @@ async function ensureImage(): Promise<void> {
console.log(`[server] Pulling ${IMAGE_NAME}...`);
const pullProcess = exec(`docker pull ${IMAGE_NAME}`);
- pullProcess.stdout?.on("data", (data: Buffer) => {
- const lines = data.toString().split("\n").filter(l => l.trim());
+ pullProcess.stdout?.on('data', (data: Buffer) => {
+ const lines = data
+ .toString()
+ .split('\n')
+ .filter((l) => l.trim());
for (const line of lines) {
console.log(`[pull] ${line}`);
}
});
- pullProcess.stderr?.on("data", (data: Buffer) => {
- const lines = data.toString().split("\n").filter(l => l.trim());
+ pullProcess.stderr?.on('data', (data: Buffer) => {
+ const lines = data
+ .toString()
+ .split('\n')
+ .filter((l) => l.trim());
for (const line of lines) {
console.error(`[pull] ${line}`);
}
});
await new Promise<void>((resolve, reject) => {
- pullProcess.on("exit", (code) => {
+ pullProcess.on('exit', (code) => {
if (code === 0) {
console.log(`[server] Pull completed successfully!`);
resolve();
@@ -199,12 +207,14 @@ async function ensureImage(): Promise<void> {
async function ensureContainer(): Promise<number> {
// Check if container is running
try {
- const { stdout: runningOut } = await execAsync(`docker inspect -f "{{.State.Running}}" ${getContainerName()}`);
- if (runningOut.trim() === "true") {
+ const { stdout: runningOut } = await execAsync(
+ `docker inspect -f "{{.State.Running}}" ${getContainerName()}`
+ );
+ if (runningOut.trim() === 'true') {
const { stdout: portOut } = await execAsync(`docker port ${getContainerName()} 10000`);
- return parseInt(portOut.split(":")[1]?.trim() || "10000", 10);
+ return parseInt(portOut.split(':')[1]?.trim() || '10000', 10);
}
- } catch { }
+ } catch {}
const dockerCheck = await testDockerConnection();
if (!dockerCheck.ok) {
@@ -213,42 +223,54 @@ async function ensureContainer(): Promise<number> {
await ensureImage();
// Remove existing stopped container
- await execAsync(`docker rm -f ${getContainerName()}`).catch(() => { });
+ await execAsync(`docker rm -f ${getContainerName()}`).catch(() => {});
const port = await findAvailablePort();
// Convert Windows path to Docker-compatible path for volume mount
- const toDockerPath = (p: string) => p.replace(/\\/g, "/").replace(/^([A-Z]):/, (_, letter) => `/${letter.toLowerCase()}`);
+ const toDockerPath = (p: string) =>
+ p.replace(/\\/g, '/').replace(/^([A-Z]):/, (_, letter) => `/${letter.toLowerCase()}`);
const claudeConfigPath = toDockerPath(CLAUDE_CONFIG_DIR);
const androidSdkImagesPath = toDockerPath(ANDROID_SDK_IMAGES_DIR);
const telemetryEnabled = getTelemetryEnabled();
- const cuabotName = sessionName || "cuabot";
+ const cuabotName = sessionName || 'cuabot';
const cuabotColor = nameToColor(cuabotName).slice(1); // Remove # prefix
const createCmd = [
- "docker", "create",
- "--name", getContainerName(),
- "-p", `${port}:10000`,
- "-e", "DISPLAY=:100",
- "-e", "CLAUDE_CONFIG_DIR=/home/user/.claude",
- "-e", `CUABOT_HOST=http://host.docker.internal:${serverPort}`,
- "-e", `CUABOT_TELEMETRY=${telemetryEnabled ? "true" : "false"}`,
- "-e", `CUABOT_NAME=${cuabotName}`,
- "-e", `CUABOT_COLOR=${cuabotColor}`,
- "--add-host=host.docker.internal:host-gateway",
- "-v", `${claudeConfigPath}:/home/user/.claude`,
- "-v", `${androidSdkImagesPath}:/home/user/android-sdk/system-images`,
+ 'docker',
+ 'create',
+ '--name',
+ getContainerName(),
+ '-p',
+ `${port}:10000`,
+ '-e',
+ 'DISPLAY=:100',
+ '-e',
+ 'CLAUDE_CONFIG_DIR=/home/user/.claude',
+ '-e',
+ `CUABOT_HOST=http://host.docker.internal:${serverPort}`,
+ '-e',
+ `CUABOT_TELEMETRY=${telemetryEnabled ? 'true' : 'false'}`,
+ '-e',
+ `CUABOT_NAME=${cuabotName}`,
+ '-e',
+ `CUABOT_COLOR=${cuabotColor}`,
+ '--add-host=host.docker.internal:host-gateway',
+ '-v',
+ `${claudeConfigPath}:/home/user/.claude`,
+ '-v',
+ `${androidSdkImagesPath}:/home/user/android-sdk/system-images`,
];
// Add KVM device passthrough for nested virtualization
- if (process.env.CUABOT_NESTED_VIRT === "1") {
- createCmd.push("--device=/dev/kvm");
- console.log("[server] Nested virtualization enabled (--device=/dev/kvm)");
+ if (process.env.CUABOT_NESTED_VIRT === '1') {
+ createCmd.push('--device=/dev/kvm');
+ console.log('[server] Nested virtualization enabled (--device=/dev/kvm)');
}
createCmd.push(IMAGE_NAME);
- await execAsync(createCmd.join(" "));
+ await execAsync(createCmd.join(' '));
await execAsync(`docker start ${getContainerName()}`);
// Wait for xpra to be ready
@@ -257,18 +279,18 @@ async function ensureContainer(): Promise<number> {
const { stdout } = await execAsync(
`docker exec ${getContainerName()} sh -c "netstat -tln 2>/dev/null | grep -q 10000 && echo ready || ss -tln 2>/dev/null | grep -q 10000 && echo ready"`
);
- if (stdout.includes("ready")) break;
- } catch { }
- await new Promise(r => setTimeout(r, 500));
+ if (stdout.includes('ready')) break;
+ } catch {}
+ await new Promise((r) => setTimeout(r, 500));
}
// Start overlay cursor in background
- const cursorName = sessionName || "cuabot";
+ const cursorName = sessionName || 'cuabot';
try {
await execAsync(
`docker exec -d ${getContainerName()} python3 /home/user/.cuabot/mcp/overlay-cursor.py --name=${cursorName}`
);
- } catch { }
+ } catch {}
// Start mask polling for cursor visibility
startMaskPolling();
@@ -293,7 +315,7 @@ ${command}
`;
// Write script to container using docker exec with base64 to avoid any escaping issues
- const base64Script = Buffer.from(scriptContent).toString("base64");
+ const base64Script = Buffer.from(scriptContent).toString('base64');
await execAsync(
`docker exec ${getContainerName()} bash -c "echo '${base64Script}' | base64 -d > ${scriptPath} && chmod +x ${scriptPath}"`
);
@@ -305,7 +327,7 @@ ${command}
const bgCmd = `docker exec ${getContainerName()} bash -c "nohup ${scriptPath} > /tmp/cuabot-bg-${scriptId}.log 2>&1 & echo \\$!; sleep 1; if ! kill -0 \\$! 2>/dev/null; then cat /tmp/cuabot-bg-${scriptId}.log; exit 1; fi"`;
const { stdout, stderr } = await execAsync(bgCmd, { timeout: 10000 });
- const pid = parseInt(stdout.trim().split("\n")[0], 10);
+ const pid = parseInt(stdout.trim().split('\n')[0], 10);
// Clean up script after a delay (let it start first)
setTimeout(async () => {
@@ -328,12 +350,12 @@ ${command}
} catch (err: any) {
// Clean up script on error
await execAsync(`docker exec ${getContainerName()} rm -f ${scriptPath}`).catch(() => {});
- return { stdout: err.stdout || "", stderr: err.stderr || err.message };
+ return { stdout: err.stdout || '', stderr: err.stderr || err.message };
}
}
// Overlay cursor management
-const CURSOR_SOCKET = "/tmp/cuabot-overlay-cursor.sock";
+const CURSOR_SOCKET = '/tmp/cuabot-overlay-cursor.sock';
let maskPollingInterval: ReturnType<typeof setInterval> | null = null;
let lastCursorPos = { x: 0, y: 0 };
@@ -346,7 +368,7 @@ async function sendCursorCommand(cmd: Record<string, unknown>): Promise<void> {
async function notifyCursorMove(x: number, y: number, click = false): Promise<void> {
lastCursorPos = { x, y };
- await sendCursorCommand({ type: "move", x: x, y: y, click });
+ await sendCursorCommand({ type: 'move', x: x, y: y, click });
}
// AABB types and operations for mask computation
@@ -358,7 +380,7 @@ interface AABB {
}
interface AABBOp extends AABB {
- op: "add" | "subtract";
+ op: 'add' | 'subtract';
}
function subtractAABB(a: AABB, b: AABB): AABB[] {
@@ -400,8 +422,10 @@ function subtractAABB(a: AABB, b: AABB): AABB[] {
}
function tryMerge(a: AABB, b: AABB): AABB | null {
- const aRight = a.x + a.width, aBottom = a.y + a.height;
- const bRight = b.x + b.width, bBottom = b.y + b.height;
+ const aRight = a.x + a.width,
+ aBottom = a.y + a.height;
+ const bRight = b.x + b.width,
+ bBottom = b.y + b.height;
// Horizontal merge
if (a.y === b.y && a.height === b.height) {
@@ -446,10 +470,10 @@ function computeAABBs(ops: AABBOp[]): AABB[] {
for (const op of ops) {
const box: AABB = { x: op.x, y: op.y, width: op.width, height: op.height };
- if (op.op === "add") {
+ if (op.op === 'add') {
regions.push(box);
} else {
- regions = regions.flatMap(r => subtractAABB(r, box));
+ regions = regions.flatMap((r) => subtractAABB(r, box));
}
}
@@ -459,7 +483,7 @@ function computeAABBs(ops: AABBOp[]): AABB[] {
async function updateCursorMasks(): Promise<void> {
try {
const windows = await openWindows();
- const cursorName = sessionName || "cuabot";
+ const cursorName = sessionName || 'cuabot';
const cursorWindowPattern = `cuabot-cursor-${cursorName}`;
// Build AABB operations from windows (all in absolute screen coordinates)
@@ -472,10 +496,10 @@ async function updateCursorMasks(): Promise<void> {
// Reverse to go back-to-front (openWindows returns front-to-back)
for (const win of [...windows].reverse()) {
const b = win.bounds;
- const isXpra = win.owner.name === "Xpra" || win.owner.name.toLowerCase().includes("xpra");
+ const isXpra = win.owner.name === 'Xpra' || win.owner.name.toLowerCase().includes('xpra');
const isCursorWindow = win.title.includes(cursorWindowPattern);
- const ignoredWindows = ["cuabot-debug-masks", "Screen Studio", "recording-manager-widget"];
- const isIgnoredWindow = ignoredWindows.some(name => win.title.includes(name));
+ const ignoredWindows = ['cuabot-debug-masks', 'Screen Studio', 'recording-manager-widget'];
+ const isIgnoredWindow = ignoredWindows.some((name) => win.title.includes(name));
if (isCursorWindow || isIgnoredWindow) {
continue;
@@ -490,10 +514,10 @@ async function updateCursorMasks(): Promise<void> {
if (isXpra) {
// Xpra windows: subtract (cut holes in masks behind it)
- ops.push({ x: b.x, y: b.y, width: b.width, height: b.height, op: "subtract" });
+ ops.push({ x: b.x, y: b.y, width: b.width, height: b.height, op: 'subtract' });
} else {
// Non-Xpra windows: add (mask areas where cursor should hide)
- ops.push({ x: b.x, y: b.y, width: b.width, height: b.height, op: "add" });
+ ops.push({ x: b.x, y: b.y, width: b.width, height: b.height, op: 'add' });
}
}
@@ -505,8 +529,8 @@ async function updateCursorMasks(): Promise<void> {
// Check if cursor is inside any mask
const cx = lastCursorPos.x;
const cy = lastCursorPos.y;
- const isInMask = maskRects.some(r =>
- cx >= r.x && cx <= r.x + r.width && cy >= r.y && cy <= r.y + r.height
+ const isInMask = maskRects.some(
+ (r) => cx >= r.x && cx <= r.x + r.width && cy >= r.y && cy <= r.y + r.height
);
// Debug visualization
@@ -515,7 +539,7 @@ async function updateCursorMasks(): Promise<void> {
}
// Send masked state to overlay cursor (not the rects - calculation done here)
- await sendCursorCommand({ type: "masked", value: isInMask });
+ await sendCursorCommand({ type: 'masked', value: isInMask });
} catch (e) {
// Silently ignore errors
}
@@ -532,10 +556,11 @@ async function drawDebugMasks(
const width = 2400;
const height = 1600;
const crosshairSize = 20;
- const cursorColor = isInMask ? "red" : "lime";
+ const cursorColor = isInMask ? 'red' : 'lime';
// Escape XML special characters
- const escapeXml = (s: string) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
+ const escapeXml = (s: string) =>
+ s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
// Build SVG
let svg = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">`;
@@ -551,7 +576,7 @@ async function drawDebugMasks(
// Draw window rects (blue outlined) with labels
for (const win of windows) {
const b = win.bounds;
- const strokeColor = win.isXpra ? "cyan" : "blue";
+ const strokeColor = win.isXpra ? 'cyan' : 'blue';
svg += `<rect x="${b.x}" y="${b.y}" width="${b.width}" height="${b.height}" fill="none" stroke="${strokeColor}" stroke-width="2"/>`;
// Label background
@@ -573,9 +598,11 @@ async function drawDebugMasks(
svg += `</svg>`;
- await sharp(Buffer.from(svg)).png().toFile(SCREENSHOT_PATH.replace("screenshot.jpg", "masks.png"));
+ await sharp(Buffer.from(svg))
+ .png()
+ .toFile(SCREENSHOT_PATH.replace('screenshot.jpg', 'masks.png'));
} catch (e) {
- console.error("[debug] Failed to draw masks:", e);
+ console.error('[debug] Failed to draw masks:', e);
}
}
@@ -623,11 +650,11 @@ async function ensurePlaywrightConnected(): Promise<Page> {
// Wait for xpra to be ready
for (let i = 0; i < 60; i++) {
const isReady = await page!.evaluate(() => {
- const canvas = document.querySelector("canvas");
+ const canvas = document.querySelector('canvas');
return canvas !== null;
});
if (isReady) break;
- await new Promise(r => setTimeout(r, 500));
+ await new Promise((r) => setTimeout(r, 500));
}
playwrightConnected = true;
@@ -636,9 +663,18 @@ async function ensurePlaywrightConnected(): Promise<Page> {
}
async function closePlaywrightSession(): Promise<void> {
- if (page) { await page.close().catch(() => { }); page = null; }
- if (context) { await context.close().catch(() => { }); context = null; }
- if (browser) { await browser.close().catch(() => { }); browser = null; }
+ if (page) {
+ await page.close().catch(() => {});
+ page = null;
+ }
+ if (context) {
+ await context.close().catch(() => {});
+ context = null;
+ }
+ if (browser) {
+ await browser.close().catch(() => {});
+ browser = null;
+ }
playwrightConnected = false;
}
@@ -660,10 +696,7 @@ async function scaleScreenshot(buffer: Buffer): Promise<{ scaled: Buffer; scale:
const newWidth = Math.round(width * scale);
const newHeight = Math.round(height * scale);
- const scaled = await sharp(buffer)
- .resize(newWidth, newHeight)
- .jpeg()
- .toBuffer();
+ const scaled = await sharp(buffer).resize(newWidth, newHeight).jpeg().toBuffer();
return { scaled, scale };
}
@@ -679,7 +712,7 @@ function scaleCoordinates(x: number, y: number): { x: number; y: number } {
// Save screenshot with click coordinates marked
async function saveClickedScreenshot(p: Page, x: number, y: number): Promise<void> {
- const buffer = await p.screenshot({ type: "jpeg", fullPage: false });
+ const buffer = await p.screenshot({ type: 'jpeg', fullPage: false });
// Save the regular screenshot
writeFileSync(SCREENSHOT_PATH, buffer);
@@ -720,9 +753,9 @@ const handlers: Record<string, Handler> = {
return {
ok: true,
ready: serverReady,
- container: containerPort ? `running on port ${containerPort}` : "not started",
+ container: containerPort ? `running on port ${containerPort}` : 'not started',
containerPort: containerPort,
- playwright: browser?.isConnected() ? "connected" : "not connected",
+ playwright: browser?.isConnected() ? 'connected' : 'not connected',
};
},
@@ -739,18 +772,18 @@ const handlers: Record<string, Handler> = {
async screenshot() {
requireReady();
const p = await ensurePlaywrightConnected();
- const buffer = await p.screenshot({ type: "jpeg", fullPage: false });
+ const buffer = await p.screenshot({ type: 'jpeg', fullPage: false });
const { scaled, scale } = await scaleScreenshot(buffer);
screenshotScale = scale; // Store for coordinate scaling
- return { image: Buffer.from(scaled).toString("base64"), scale };
+ return { image: Buffer.from(scaled).toString('base64'), scale };
},
- async click(body: { x: number; y: number; button?: "left" | "right" | "middle" }) {
+ async click(body: { x: number; y: number; button?: 'left' | 'right' | 'middle' }) {
requireReady();
const p = await ensurePlaywrightConnected();
const { x, y } = scaleCoordinates(body.x, body.y);
notifyCursorMove(x, y, true);
- await p.mouse.click(x, y, { button: body.button || "left" });
+ await p.mouse.click(x, y, { button: body.button || 'left' });
// Save screenshot with click coordinates marked (DEBUG only)
if (DEBUG) await saveClickedScreenshot(p, x, y);
return { ok: true, scaledCoords: { x, y } };
@@ -783,23 +816,23 @@ const handlers: Record<string, Handler> = {
return { ok: true, scaledCoords: { x, y } };
},
- async mouseDown(body: { x: number; y: number; button?: "left" | "right" | "middle" }) {
+ async mouseDown(body: { x: number; y: number; button?: 'left' | 'right' | 'middle' }) {
requireReady();
const p = await ensurePlaywrightConnected();
const { x, y } = scaleCoordinates(body.x, body.y);
notifyCursorMove(x, y, true);
await p.mouse.move(x, y);
- await p.mouse.down({ button: body.button || "left" });
+ await p.mouse.down({ button: body.button || 'left' });
return { ok: true, scaledCoords: { x, y } };
},
- async mouseUp(body: { x: number; y: number; button?: "left" | "right" | "middle" }) {
+ async mouseUp(body: { x: number; y: number; button?: 'left' | 'right' | 'middle' }) {
requireReady();
const p = await ensurePlaywrightConnected();
const { x, y } = scaleCoordinates(body.x, body.y);
notifyCursorMove(x, y);
await p.mouse.move(x, y);
- await p.mouse.up({ button: body.button || "left" });
+ await p.mouse.up({ button: body.button || 'left' });
return { ok: true, scaledCoords: { x, y } };
},
@@ -857,7 +890,7 @@ const handlers: Record<string, Handler> = {
// Cleanup
async function cleanup() {
- console.log("[server] Cleaning up...");
+ console.log('[server] Cleaning up...');
// Shutdown telemetry (records shutdown event and flushes)
if (telemetryClient) {
@@ -874,18 +907,22 @@ async function cleanup() {
// Kill xpra client first (before container stops, so it exits cleanly)
if (xpraClientPid) {
try {
- process.kill(xpraClientPid, "SIGKILL");
+ process.kill(xpraClientPid, 'SIGKILL');
console.log(`[server] Killed xpra client (PID ${xpraClientPid})`);
- } catch { }
+ } catch {}
xpraClientPid = null;
}
await closePlaywrightSession();
- await execAsync(`docker stop ${getContainerName()}`).catch(() => { });
- await execAsync(`docker rm ${getContainerName()}`).catch(() => { });
- try { unlinkSync(getPidFile()); } catch { }
- try { unlinkSync(getPortFile()); } catch { }
- console.log("[server] Cleanup complete");
+ await execAsync(`docker stop ${getContainerName()}`).catch(() => {});
+ await execAsync(`docker rm ${getContainerName()}`).catch(() => {});
+ try {
+ unlinkSync(getPidFile());
+ } catch {}
+ try {
+ unlinkSync(getPortFile());
+ } catch {}
+ console.log('[server] Cleanup complete');
}
// Server start
@@ -897,7 +934,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
// Check if already running
if (existsSync(getPidFile())) {
- const pids = readFileSync(getPidFile(), "utf-8").trim().split("\n");
+ const pids = readFileSync(getPidFile(), 'utf-8').trim().split('\n');
const serverPid = parseInt(pids[0], 10);
try {
process.kill(serverPid, 0); // Check if process exists
@@ -921,25 +958,25 @@ export async function startServer(preferredPort?: number): Promise<void> {
// Create HTTP server immediately (before initialization)
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
- const url = new URL(req.url || "/", `http://localhost:${port}`);
+ const url = new URL(req.url || '/', `http://localhost:${port}`);
const path = url.pathname.slice(1); // Remove leading /
// CORS headers
- res.setHeader("Content-Type", "application/json");
- res.setHeader("Access-Control-Allow-Origin", "*");
- res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
- res.setHeader("Access-Control-Allow-Headers", "Content-Type");
+ res.setHeader('Content-Type', 'application/json');
+ res.setHeader('Access-Control-Allow-Origin', '*');
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
- if (req.method === "OPTIONS") {
+ if (req.method === 'OPTIONS') {
res.writeHead(200);
res.end();
return;
}
// Handle stop request
- if (path === "stop") {
+ if (path === 'stop') {
res.writeHead(200);
- res.end(JSON.stringify({ ok: true, message: "Server stopping" }));
+ res.end(JSON.stringify({ ok: true, message: 'Server stopping' }));
setTimeout(async () => {
await cleanup();
process.exit(0);
@@ -956,7 +993,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
try {
let body = {};
- if (req.method === "POST") {
+ if (req.method === 'POST') {
const chunks: Buffer[] = [];
for await (const chunk of req) {
chunks.push(chunk as Buffer);
@@ -978,18 +1015,18 @@ export async function startServer(preferredPort?: number): Promise<void> {
const wss = new WebSocketServer({ server });
const activeSessions = new Map<string, pty.IPty>();
- wss.on("connection", (ws: WebSocket, req: IncomingMessage) => {
+ wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
// Check if server is ready
if (!serverReady) {
- ws.send(JSON.stringify({ type: "error", message: STARTING_ERROR }));
+ ws.send(JSON.stringify({ type: 'error', message: STARTING_ERROR }));
ws.close();
return;
}
- const url = new URL(req.url || "/", `http://localhost:${port}`);
- const command = url.searchParams.get("command") || "bash";
- const cols = parseInt(url.searchParams.get("cols") || "80", 10);
- const rows = parseInt(url.searchParams.get("rows") || "24", 10);
+ const url = new URL(req.url || '/', `http://localhost:${port}`);
+ const command = url.searchParams.get('command') || 'bash';
+ const cols = parseInt(url.searchParams.get('cols') || '80', 10);
+ const rows = parseInt(url.searchParams.get('rows') || '24', 10);
const sessionId = Date.now().toString(36) + Math.random().toString(36).slice(2);
console.log(`[ws] New interactive session: ${sessionId}, command: ${command}`);
@@ -998,24 +1035,32 @@ export async function startServer(preferredPort?: number): Promise<void> {
try {
// Use node-pty to spawn docker exec with proper PTY support
// Wrap command in bash -c to ensure proper shell environment
- const shell = process.platform === "win32" ? "docker.exe" : "docker";
- ptyProcess = pty.spawn(shell, [
- "exec",
- "-it",
- "-e", `TERM=${process.env.TERM || "xterm-256color"}`,
- "-e", "DISPLAY=:100",
- getContainerName(),
- "bash", "-c", command,
- ], {
- name: "xterm-256color",
- cols,
- rows,
- cwd: process.cwd(),
- env: process.env as Record<string, string>,
- });
+ const shell = process.platform === 'win32' ? 'docker.exe' : 'docker';
+ ptyProcess = pty.spawn(
+ shell,
+ [
+ 'exec',
+ '-it',
+ '-e',
+ `TERM=${process.env.TERM || 'xterm-256color'}`,
+ '-e',
+ 'DISPLAY=:100',
+ getContainerName(),
+ 'bash',
+ '-c',
+ command,
+ ],
+ {
+ name: 'xterm-256color',
+ cols,
+ rows,
+ cwd: process.cwd(),
+ env: process.env as Record<string, string>,
+ }
+ );
} catch (err) {
console.error(`[ws] Failed to spawn PTY:`, err);
- ws.send(JSON.stringify({ type: "error", message: `Failed to spawn: ${err}` }));
+ ws.send(JSON.stringify({ type: 'error', message: `Failed to spawn: ${err}` }));
ws.close();
return;
}
@@ -1025,7 +1070,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
// Pipe PTY output to WebSocket
ptyProcess.onData((data: string) => {
if (ws.readyState === WebSocket.OPEN) {
- ws.send(JSON.stringify({ type: "stdout", data: Buffer.from(data).toString("base64") }));
+ ws.send(JSON.stringify({ type: 'stdout', data: Buffer.from(data).toString('base64') }));
}
});
@@ -1033,19 +1078,19 @@ export async function startServer(preferredPort?: number): Promise<void> {
console.log(`[ws] Session ${sessionId} exited with code ${exitCode}`);
activeSessions.delete(sessionId);
if (ws.readyState === WebSocket.OPEN) {
- ws.send(JSON.stringify({ type: "exit", code: exitCode }));
+ ws.send(JSON.stringify({ type: 'exit', code: exitCode }));
ws.close();
}
});
// Handle WebSocket messages (stdin from client)
- ws.on("message", (message: Buffer) => {
+ ws.on('message', (message: Buffer) => {
try {
const msg = JSON.parse(message.toString());
- if (msg.type === "stdin" && msg.data) {
- const data = Buffer.from(msg.data, "base64").toString();
+ if (msg.type === 'stdin' && msg.data) {
+ const data = Buffer.from(msg.data, 'base64').toString();
ptyProcess.write(data);
- } else if (msg.type === "resize" && msg.cols && msg.rows) {
+ } else if (msg.type === 'resize' && msg.cols && msg.rows) {
ptyProcess.resize(msg.cols, msg.rows);
}
} catch (err) {
@@ -1053,7 +1098,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
}
});
- ws.on("close", () => {
+ ws.on('close', () => {
console.log(`[ws] Session ${sessionId} WebSocket closed`);
if (activeSessions.has(sessionId)) {
ptyProcess.kill();
@@ -1061,12 +1106,12 @@ export async function startServer(preferredPort?: number): Promise<void> {
}
});
- ws.on("error", (err) => {
+ ws.on('error', (err) => {
console.error(`[ws] Session ${sessionId} WebSocket error:`, err);
});
// Send session info to client
- ws.send(JSON.stringify({ type: "session", id: sessionId, command }));
+ ws.send(JSON.stringify({ type: 'session', id: sessionId, command }));
});
server.listen(port, () => {
@@ -1075,17 +1120,23 @@ export async function startServer(preferredPort?: number): Promise<void> {
console.log(`[server] Server is ready to accept connections`);
});
- server.on("error", (err: NodeJS.ErrnoException) => {
+ server.on('error', (err: NodeJS.ErrnoException) => {
console.error(`[server] HTTP server error:`, err);
- if (err.code === "EADDRINUSE") {
+ if (err.code === 'EADDRINUSE') {
console.error(`[server] Port ${port} is already in use`);
}
process.exit(1);
});
// Cleanup on exit
- process.on("SIGINT", async () => { await cleanup(); process.exit(0); });
- process.on("SIGTERM", async () => { await cleanup(); process.exit(0); });
+ process.on('SIGINT', async () => {
+ await cleanup();
+ process.exit(0);
+ });
+ process.on('SIGTERM', async () => {
+ await cleanup();
+ process.exit(0);
+ });
// Initialize container, playwright, and xpra client in background
(async () => {
@@ -1105,7 +1156,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
const xpraArgs = getXpraAttachArgs(containerPort, sessionName);
const xpraClient = spawn(xpraCmd, xpraArgs, {
detached: true,
- stdio: "ignore",
+ stdio: 'ignore',
windowsHide: true,
});
xpraClientPid = xpraClient.pid ?? null;
@@ -1125,7 +1176,7 @@ export async function startServer(preferredPort?: number): Promise<void> {
}
// Start history polling for telemetry (scrapes /home/user/.claude/history.jsonl)
- const historyPath = join(CLAUDE_CONFIG_DIR, "history.jsonl");
+ const historyPath = join(CLAUDE_CONFIG_DIR, 'history.jsonl');
startHistoryPolling(historyPath, 2000);
} catch (err) {
console.error(`[server] Initialization failed:`, err);
@@ -1137,22 +1188,26 @@ export async function startServer(preferredPort?: number): Promise<void> {
// Stop server
export async function stopServer(): Promise<boolean> {
if (!existsSync(getPidFile())) {
- console.log("Server not running");
+ console.log('Server not running');
return false;
}
- const pids = readFileSync(getPidFile(), "utf-8").trim().split("\n").map(p => parseInt(p, 10)).filter(p => !isNaN(p));
+ const pids = readFileSync(getPidFile(), 'utf-8')
+ .trim()
+ .split('\n')
+ .map((p) => parseInt(p, 10))
+ .filter((p) => !isNaN(p));
const serverPid = pids[0];
const xpraPid = pids[1];
const port = existsSync(getPortFile())
- ? parseInt(readFileSync(getPortFile(), "utf-8").trim(), 10)
+ ? parseInt(readFileSync(getPortFile(), 'utf-8').trim(), 10)
: DEFAULT_PORT;
try {
// Try graceful shutdown via HTTP
- const res = await fetch(`http://localhost:${port}/stop`, { method: "POST" });
+ const res = await fetch(`http://localhost:${port}/stop`, { method: 'POST' });
if (res.ok) {
- console.log("Server stopped");
+ console.log('Server stopped');
return true;
}
} catch {
@@ -1161,38 +1216,42 @@ export async function stopServer(): Promise<boolean> {
// Kill server process
try {
- process.kill(serverPid, "SIGTERM");
+ process.kill(serverPid, 'SIGTERM');
console.log(`Sent SIGTERM to server (PID ${serverPid})`);
killed = true;
- } catch { }
+ } catch {}
// Kill xpra client process
if (xpraPid) {
try {
- process.kill(xpraPid, "SIGKILL");
+ process.kill(xpraPid, 'SIGKILL');
console.log(`Sent SIGKILL to xpra client (PID ${xpraPid})`);
killed = true;
- } catch { }
+ } catch {}
}
// Stop and remove Docker container
try {
await execAsync(`docker stop ${getContainerName()}`);
console.log(`Stopped container ${getContainerName()}`);
- } catch { }
+ } catch {}
try {
await execAsync(`docker rm ${getContainerName()}`);
console.log(`Removed container ${getContainerName()}`);
- } catch { }
+ } catch {}
// Clean up files
- try { unlinkSync(getPidFile()); } catch { }
- try { unlinkSync(getPortFile()); } catch { }
+ try {
+ unlinkSync(getPidFile());
+ } catch {}
+ try {
+ unlinkSync(getPortFile());
+ } catch {}
if (killed) {
return true;
} else {
- console.log("Server not running (stale PID file)");
+ console.log('Server not running (stale PID file)');
return false;
}
}
@@ -1203,10 +1262,10 @@ export async function stopServer(): Promise<boolean> {
export function getServerInfo(): { running: boolean; port: number; pid: number } | null {
if (!existsSync(getPidFile())) return null;
- const pids = readFileSync(getPidFile(), "utf-8").trim().split("\n");
+ const pids = readFileSync(getPidFile(), 'utf-8').trim().split('\n');
const pid = parseInt(pids[0], 10);
const port = existsSync(getPortFile())
- ? parseInt(readFileSync(getPortFile(), "utf-8").trim(), 10)
+ ? parseInt(readFileSync(getPortFile(), 'utf-8').trim(), 10)
: DEFAULT_PORT;
try {
diff --git a/libs/cuabot/src/mcp/computer-use-mcp.py b/libs/cuabot/src/mcp/computer-use-mcp.py
index d64454e143..515fcbb180 100644
--- a/libs/cuabot/src/mcp/computer-use-mcp.py
+++ b/libs/cuabot/src/mcp/computer-use-mcp.py
@@ -80,6 +80,7 @@ def screenshot(save_path: str | None = None) -> Image:
save_path: Optional path to save the screenshot (e.g., "/tmp/screenshot.jpg")
"""
import base64
+
log_mcp_tool_call("screenshot", {"save_path": save_path})
result = request("screenshot")
image_bytes = base64.b64decode(result["image"])
diff --git a/libs/cuabot/src/onboarding.tsx b/libs/cuabot/src/onboarding.tsx
index bba1f440d7..bb0d1d1771 100644
--- a/libs/cuabot/src/onboarding.tsx
+++ b/libs/cuabot/src/onboarding.tsx
@@ -3,16 +3,31 @@
* CuaBot Onboarding UI
*/
-import React, { useState, useEffect } from "react";
-import { render, Box, Text, useInput, useApp } from "ink";
-import { checkDocker, checkXpra, checkPlaywright, checkDockerImage, pullDockerImage } from "./utils.js";
-import { AGENTS, AgentId, getDefaultAgent, setDefaultAgent, setTelemetryEnabled, loadSettings, getAliasIgnored, setAliasIgnored } from "./settings.js";
-import { exec, execSync } from "child_process";
-import { homedir } from "os";
-import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
-import { join } from "path";
-
-type CheckStatus = "ok" | "error" | "loading";
+import React, { useState, useEffect } from 'react';
+import { render, Box, Text, useInput, useApp } from 'ink';
+import {
+ checkDocker,
+ checkXpra,
+ checkPlaywright,
+ checkDockerImage,
+ pullDockerImage,
+} from './utils.js';
+import {
+ AGENTS,
+ AgentId,
+ getDefaultAgent,
+ setDefaultAgent,
+ setTelemetryEnabled,
+ loadSettings,
+ getAliasIgnored,
+ setAliasIgnored,
+} from './settings.js';
+import { exec, execSync } from 'child_process';
+import { homedir } from 'os';
+import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
+import { join } from 'path';
+
+type CheckStatus = 'ok' | 'error' | 'loading';
interface Check {
label: string;
@@ -22,12 +37,12 @@ interface Check {
function checkCuabotInPath(): boolean {
try {
- const cmd = process.platform === "win32" ? "where cuabot" : "which cuabot";
- const result = execSync(cmd, { encoding: "utf-8" }).trim();
+ const cmd = process.platform === 'win32' ? 'where cuabot' : 'which cuabot';
+ const result = execSync(cmd, { encoding: 'utf-8' }).trim();
// Ignore paths from npx/pnpm dlx temporary cache
- const paths = result.split(/\r?\n/).filter(p =>
- !p.includes("_npx") && !p.includes("\\dlx\\") && !p.includes("/dlx/")
- );
+ const paths = result
+ .split(/\r?\n/)
+ .filter((p) => !p.includes('_npx') && !p.includes('\\dlx\\') && !p.includes('/dlx/'));
return paths.length > 0;
} catch {
return false;
@@ -35,28 +50,38 @@ function checkCuabotInPath(): boolean {
}
function getShellRcFile(): string | null {
- if (process.platform === "win32") {
+ if (process.platform === 'win32') {
// PowerShell profile paths
- const ps7Profile = join(homedir(), "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1");
- const ps5Profile = join(homedir(), "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1");
+ const ps7Profile = join(
+ homedir(),
+ 'Documents',
+ 'PowerShell',
+ 'Microsoft.PowerShell_profile.ps1'
+ );
+ const ps5Profile = join(
+ homedir(),
+ 'Documents',
+ 'WindowsPowerShell',
+ 'Microsoft.PowerShell_profile.ps1'
+ );
// Prefer PS7 if its directory exists, otherwise PS5
- if (existsSync(join(homedir(), "Documents", "PowerShell"))) return ps7Profile;
+ if (existsSync(join(homedir(), 'Documents', 'PowerShell'))) return ps7Profile;
return ps5Profile;
}
- const shell = process.env.SHELL || "";
- if (shell.includes("zsh")) return join(homedir(), ".zshrc");
- if (shell.includes("bash")) {
+ const shell = process.env.SHELL || '';
+ if (shell.includes('zsh')) return join(homedir(), '.zshrc');
+ if (shell.includes('bash')) {
// macOS uses .bash_profile, Linux uses .bashrc
- const bashProfile = join(homedir(), ".bash_profile");
- if (process.platform === "darwin" && existsSync(bashProfile)) return bashProfile;
- return join(homedir(), ".bashrc");
+ const bashProfile = join(homedir(), '.bash_profile');
+ if (process.platform === 'darwin' && existsSync(bashProfile)) return bashProfile;
+ return join(homedir(), '.bashrc');
}
return null;
}
function addAliasToShell(): boolean {
- const isWindows = process.platform === "win32";
+ const isWindows = process.platform === 'win32';
if (isWindows) {
return addWindowsAlias();
@@ -68,7 +93,7 @@ function addAliasToShell(): boolean {
try {
// Check if alias already exists
if (existsSync(rcFile)) {
- const content = readFileSync(rcFile, "utf-8");
+ const content = readFileSync(rcFile, 'utf-8');
if (content.includes('alias cuabot=')) {
setAliasIgnored(true);
return true;
@@ -89,12 +114,13 @@ function addWindowsAlias(): boolean {
const psProfile = getShellRcFile();
if (psProfile) {
try {
- const dir = join(psProfile, "..");
+ const dir = join(psProfile, '..');
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
- const needsAdd = !existsSync(psProfile) || !readFileSync(psProfile, "utf-8").includes('function cuabot');
+ const needsAdd =
+ !existsSync(psProfile) || !readFileSync(psProfile, 'utf-8').includes('function cuabot');
if (needsAdd) {
appendFileSync(psProfile, '\n# cuabot function\nfunction cuabot { npx -y cuabot @args }\n');
}
@@ -105,8 +131,12 @@ function addWindowsAlias(): boolean {
}
// 2. Create batch file for cmd.exe in WindowsApps (already in PATH)
- const windowsApps = join(process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local"), "Microsoft", "WindowsApps");
- const batchFile = join(windowsApps, "cuabot.cmd");
+ const windowsApps = join(
+ process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'),
+ 'Microsoft',
+ 'WindowsApps'
+ );
+ const batchFile = join(windowsApps, 'cuabot.cmd');
try {
if (!existsSync(batchFile)) {
writeFileSync(batchFile, '@echo off\r\nnpx -y cuabot %*\r\n');
@@ -123,8 +153,8 @@ function addWindowsAlias(): boolean {
}
function StatusLine({ check }: { check: Check }) {
- const icon = check.status === "ok" ? "✓" : check.status === "error" ? "✗" : "○";
- const color = check.status === "ok" ? "green" : check.status === "error" ? "red" : "gray";
+ const icon = check.status === 'ok' ? '✓' : check.status === 'error' ? '✗' : '○';
+ const color = check.status === 'ok' ? 'green' : check.status === 'error' ? 'red' : 'gray';
return (
<Box>
<Text color={color}>{icon} </Text>
@@ -134,8 +164,14 @@ function StatusLine({ check }: { check: Check }) {
);
}
-function AgentSelector({ onSelect, onBack }: { onSelect: (agent: string) => void; onBack: () => void }) {
- const agentList = Object.entries(AGENTS) as [AgentId, typeof AGENTS[AgentId]][];
+function AgentSelector({
+ onSelect,
+ onBack,
+}: {
+ onSelect: (agent: string) => void;
+ onBack: () => void;
+}) {
+ const agentList = Object.entries(AGENTS) as [AgentId, (typeof AGENTS)[AgentId]][];
const [selectedIndex, setSelectedIndex] = useState(0);
useInput((input, key) => {
@@ -156,8 +192,8 @@ function AgentSelector({ onSelect, onBack }: { onSelect: (agent: string) => void
<Box flexDirection="column" marginTop={1}>
{agentList.map(([id, agent], index) => (
<Box key={id}>
- <Text color={index === selectedIndex ? "cyan" : undefined}>
- {index === selectedIndex ? "❯ " : " "}
+ <Text color={index === selectedIndex ? 'cyan' : undefined}>
+ {index === selectedIndex ? '❯ ' : ' '}
{agent.name}
</Text>
<Text dimColor> - {agent.description}</Text>
@@ -168,7 +204,13 @@ function AgentSelector({ onSelect, onBack }: { onSelect: (agent: string) => void
);
}
-function OptionSelector({ options, onSelect }: { options: { label: string; action: () => void }[]; onSelect: () => void }) {
+function OptionSelector({
+ options,
+ onSelect,
+}: {
+ options: { label: string; action: () => void }[];
+ onSelect: () => void;
+}) {
const [selectedIndex, setSelectedIndex] = useState(0);
useInput((input, key) => {
@@ -186,8 +228,8 @@ function OptionSelector({ options, onSelect }: { options: { label: string; actio
<Box flexDirection="column" marginTop={1}>
{options.map((opt, index) => (
<Box key={index}>
- <Text color={index === selectedIndex ? "cyan" : undefined}>
- {index === selectedIndex ? "❯ " : " "}
+ <Text color={index === selectedIndex ? 'cyan' : undefined}>
+ {index === selectedIndex ? '❯ ' : ' '}
{opt.label}
</Text>
</Box>
@@ -199,8 +241,11 @@ function OptionSelector({ options, onSelect }: { options: { label: string; actio
function TelemetrySelector({ onSelect }: { onSelect: (enabled: boolean) => void }) {
const [selectedIndex, setSelectedIndex] = useState(0);
const options = [
- { label: "Yes, share prompts and usage data", description: "Help improve computer-use technology" },
- { label: "No thanks", description: "Keep prompts private" },
+ {
+ label: 'Yes, share prompts and usage data',
+ description: 'Help improve computer-use technology',
+ },
+ { label: 'No thanks', description: 'Keep prompts private' },
];
useInput((input, key) => {
@@ -219,8 +264,8 @@ function TelemetrySelector({ onSelect }: { onSelect: (enabled: boolean) => void
<Box flexDirection="column" marginTop={1}>
{options.map((opt, index) => (
<Box key={index}>
- <Text color={index === selectedIndex ? "cyan" : undefined}>
- {index === selectedIndex ? "❯ " : " "}
+ <Text color={index === selectedIndex ? 'cyan' : undefined}>
+ {index === selectedIndex ? '❯ ' : ' '}
{opt.label}
</Text>
</Box>
@@ -233,16 +278,16 @@ function TelemetrySelector({ onSelect }: { onSelect: (enabled: boolean) => void
function Onboarding() {
const { exit } = useApp();
const [checks, setChecks] = useState<Check[]>([
- { label: "Default Agent", status: "loading", message: "checking..." },
- { label: "cuabot Command", status: "loading", message: "checking..." },
- { label: "Docker", status: "loading", message: "checking..." },
- { label: "Docker Image", status: "loading", message: "checking..." },
- { label: "Xpra Client", status: "loading", message: "checking..." },
- { label: "Playwright", status: "loading", message: "checking..." },
- { label: "Usage Telemetry", status: "loading", message: "checking..." },
+ { label: 'Default Agent', status: 'loading', message: 'checking...' },
+ { label: 'cuabot Command', status: 'loading', message: 'checking...' },
+ { label: 'Docker', status: 'loading', message: 'checking...' },
+ { label: 'Docker Image', status: 'loading', message: 'checking...' },
+ { label: 'Xpra Client', status: 'loading', message: 'checking...' },
+ { label: 'Playwright', status: 'loading', message: 'checking...' },
+ { label: 'Usage Telemetry', status: 'loading', message: 'checking...' },
]);
const [pullingImage, setPullingImage] = useState(false);
- const [pullProgress, setPullProgress] = useState("");
+ const [pullProgress, setPullProgress] = useState('');
const [loading, setLoading] = useState(true);
const [showAgentSelector, setShowAgentSelector] = useState(false);
const [showTelemetrySelector, setShowTelemetrySelector] = useState(false);
@@ -256,41 +301,43 @@ function Onboarding() {
// Check default agent
const defaultAgent = getDefaultAgent();
newChecks.push({
- label: "Default Agent",
- status: defaultAgent ? "ok" : "error",
- message: defaultAgent ? `${AGENTS[defaultAgent as AgentId]?.name || defaultAgent}` : "not configured",
+ label: 'Default Agent',
+ status: defaultAgent ? 'ok' : 'error',
+ message: defaultAgent
+ ? `${AGENTS[defaultAgent as AgentId]?.name || defaultAgent}`
+ : 'not configured',
});
// Check cuabot command availability
const cuabotInPath = checkCuabotInPath();
const aliasIgnored = getAliasIgnored();
newChecks.push({
- label: "cuabot Command",
- status: cuabotInPath || aliasIgnored ? "ok" : "error",
- message: cuabotInPath ? "ready" : aliasIgnored ? "using npx" : "not set up",
+ label: 'cuabot Command',
+ status: cuabotInPath || aliasIgnored ? 'ok' : 'error',
+ message: cuabotInPath ? 'ready' : aliasIgnored ? 'using npx' : 'not set up',
});
// Check Docker
const docker = await checkDocker();
newChecks.push({
- label: "Docker",
- status: docker.ok ? "ok" : "error",
- message: docker.ok ? "running" : "not found",
+ label: 'Docker',
+ status: docker.ok ? 'ok' : 'error',
+ message: docker.ok ? 'running' : 'not found',
});
// Check Docker Image (only if Docker is running)
if (docker.ok) {
const dockerImage = await checkDockerImage();
newChecks.push({
- label: "Docker Image",
- status: dockerImage.ok ? "ok" : "error",
+ label: 'Docker Image',
+ status: dockerImage.ok ? 'ok' : 'error',
message: dockerImage.message,
});
} else {
newChecks.push({
- label: "Docker Image",
- status: "error",
- message: "requires Docker",
+ label: 'Docker Image',
+ status: 'error',
+ message: 'requires Docker',
});
}
@@ -298,16 +345,16 @@ function Onboarding() {
const xpra = await checkXpra();
setXpraQuarantined(xpra.quarantined || false);
newChecks.push({
- label: "Xpra Client",
- status: xpra.ok ? "ok" : "error",
+ label: 'Xpra Client',
+ status: xpra.ok ? 'ok' : 'error',
message: xpra.message,
});
// Check Playwright
const playwright = await checkPlaywright();
newChecks.push({
- label: "Playwright",
- status: playwright.ok ? "ok" : "error",
+ label: 'Playwright',
+ status: playwright.ok ? 'ok' : 'error',
message: playwright.message,
});
@@ -315,20 +362,24 @@ function Onboarding() {
const settings = loadSettings();
const telemetryAsked = settings.telemetryEnabled !== undefined;
newChecks.push({
- label: "Usage Telemetry",
- status: telemetryAsked ? "ok" : "error",
- message: telemetryAsked ? (settings.telemetryEnabled ? "enabled" : "disabled") : "not configured",
+ label: 'Usage Telemetry',
+ status: telemetryAsked ? 'ok' : 'error',
+ message: telemetryAsked
+ ? settings.telemetryEnabled
+ ? 'enabled'
+ : 'disabled'
+ : 'not configured',
});
setChecks(newChecks);
setLoading(false);
// Find first error
- const first = newChecks.find((c) => c.status === "error");
+ const first = newChecks.find((c) => c.status === 'error');
setFirstError(first?.label || null);
// If all good, exit
- if (newChecks.every((c) => c.status === "ok")) {
+ if (newChecks.every((c) => c.status === 'ok')) {
console.log("\n✓ Ready! Run 'cuabot' to start.\n");
exit();
}
@@ -339,25 +390,33 @@ function Onboarding() {
}, []);
useInput((input, key) => {
- if (key.escape || (key.ctrl && input === "c")) {
+ if (key.escape || (key.ctrl && input === 'c')) {
exit();
}
});
const openUrl = (url: string) => {
- const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
+ const cmd =
+ process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
exec(`${cmd} "${url}"`);
};
const copyToClipboard = (text: string) => {
- const cmd = process.platform === "darwin" ? "pbcopy" : process.platform === "win32" ? "clip" : "xclip -selection clipboard";
+ const cmd =
+ process.platform === 'darwin'
+ ? 'pbcopy'
+ : process.platform === 'win32'
+ ? 'clip'
+ : 'xclip -selection clipboard';
exec(`printf '%s' "${text}" | ${cmd}`);
};
const getXpraUrl = () => {
- if (process.platform === "darwin") return "https://github.com/Xpra-org/xpra/wiki/Download#-macos";
- if (process.platform === "linux") return "https://github.com/Xpra-org/xpra/wiki/Download#-linux";
- return "https://github.com/Xpra-org/xpra/wiki/Download#full-builds";
+ if (process.platform === 'darwin')
+ return 'https://github.com/Xpra-org/xpra/wiki/Download#-macos';
+ if (process.platform === 'linux')
+ return 'https://github.com/Xpra-org/xpra/wiki/Download#-linux';
+ return 'https://github.com/Xpra-org/xpra/wiki/Download#full-builds';
};
if (loading) {
@@ -419,102 +478,132 @@ function Onboarding() {
))}
</Box>
- {firstError === "Default Agent" && (
+ {firstError === 'Default Agent' && (
<OptionSelector
- options={[
- { label: "Configure default agent", action: () => setShowAgentSelector(true) },
- ]}
+ options={[{ label: 'Configure default agent', action: () => setShowAgentSelector(true) }]}
onSelect={() => {}}
/>
)}
- {firstError === "Usage Telemetry" && (
+ {firstError === 'Usage Telemetry' && (
<OptionSelector
options={[
- { label: "Configure usage telemetry", action: () => setShowTelemetrySelector(true) },
+ { label: 'Configure usage telemetry', action: () => setShowTelemetrySelector(true) },
]}
onSelect={() => {}}
/>
)}
- {firstError === "Docker" && (
+ {firstError === 'Docker' && (
<OptionSelector
options={[
- { label: "Open Docker Download", action: () => openUrl("https://www.docker.com/products/docker-desktop/") },
- { label: "Check Again", action: () => runChecks() },
+ {
+ label: 'Open Docker Download',
+ action: () => openUrl('https://www.docker.com/products/docker-desktop/'),
+ },
+ { label: 'Check Again', action: () => runChecks() },
]}
onSelect={() => {}}
/>
)}
- {firstError === "Docker Image" && !pullingImage && (
+ {firstError === 'Docker Image' && !pullingImage && (
<OptionSelector
options={[
- { label: "Pull Docker image (~2GB)", action: async () => {
- setPullingImage(true);
- setPullProgress("Starting pull...");
- await pullDockerImage((line) => setPullProgress(line));
- setPullingImage(false);
- runChecks();
- }},
- { label: "Check Again", action: () => runChecks() },
+ {
+ label: 'Pull Docker image (~2GB)',
+ action: async () => {
+ setPullingImage(true);
+ setPullProgress('Starting pull...');
+ await pullDockerImage((line) => setPullProgress(line));
+ setPullingImage(false);
+ runChecks();
+ },
+ },
+ { label: 'Check Again', action: () => runChecks() },
]}
onSelect={() => {}}
/>
)}
- {firstError === "Docker Image" && pullingImage && (
+ {firstError === 'Docker Image' && pullingImage && (
<Box flexDirection="column" marginTop={1}>
<Text color="cyan">Pulling Docker image...</Text>
<Text dimColor>{pullProgress}</Text>
</Box>
)}
- {firstError === "Xpra Client" && !xpraQuarantined && (
+ {firstError === 'Xpra Client' && !xpraQuarantined && (
<OptionSelector
options={[
- { label: "Open Xpra Download", action: () => openUrl(getXpraUrl()) },
- { label: "Check Again", action: () => runChecks() },
+ { label: 'Open Xpra Download', action: () => openUrl(getXpraUrl()) },
+ { label: 'Check Again', action: () => runChecks() },
]}
onSelect={() => {}}
/>
)}
- {firstError === "Xpra Client" && xpraQuarantined && (
+ {firstError === 'Xpra Client' && xpraQuarantined && (
<OptionSelector
options={[
- { label: "Exit and copy command: \x1b[2msudo xattr -c /Applications/Xpra.app\x1b[0m", action: () => { copyToClipboard("sudo xattr -c /Applications/Xpra.app"); exit(); } },
- { label: "Read why", action: () => openUrl("https://github.com/Xpra-org/xpra/wiki/Download#-macos") },
- { label: "Exit", action: () => exit() },
+ {
+ label: 'Exit and copy command: \x1b[2msudo xattr -c /Applications/Xpra.app\x1b[0m',
+ action: () => {
+ copyToClipboard('sudo xattr -c /Applications/Xpra.app');
+ exit();
+ },
+ },
+ {
+ label: 'Read why',
+ action: () => openUrl('https://github.com/Xpra-org/xpra/wiki/Download#-macos'),
+ },
+ { label: 'Exit', action: () => exit() },
]}
onSelect={() => {}}
/>
)}
- {firstError === "Playwright" && (
+ {firstError === 'Playwright' && (
<OptionSelector
options={[
- { label: "Exit and copy command: \x1b[2mnpx playwright install\x1b[0m", action: () => { copyToClipboard("npx playwright install"); exit(); } },
- { label: "Exit", action: () => exit() },
+ {
+ label: 'Exit and copy command: \x1b[2mnpx playwright install\x1b[0m',
+ action: () => {
+ copyToClipboard('npx playwright install');
+ exit();
+ },
+ },
+ { label: 'Exit', action: () => exit() },
]}
onSelect={() => {}}
/>
)}
- {firstError === "cuabot Command" && (
+ {firstError === 'cuabot Command' && (
<OptionSelector
options={[
- { label: `Set up 'cuabot' command`, action: () => {
- if (addAliasToShell()) {
- if (process.platform === "win32") {
- console.log("\n✓ Added! Restart your terminal to use 'cuabot' command.\n");
- } else {
- console.log("\n✓ Added! Restart your terminal or run: source " + getShellRcFile() + "\n");
+ {
+ label: `Set up 'cuabot' command`,
+ action: () => {
+ if (addAliasToShell()) {
+ if (process.platform === 'win32') {
+ console.log("\n✓ Added! Restart your terminal to use 'cuabot' command.\n");
+ } else {
+ console.log(
+ '\n✓ Added! Restart your terminal or run: source ' + getShellRcFile() + '\n'
+ );
+ }
}
- }
- runChecks();
- }},
- { label: "Skip (use 'npx cuabot' instead)", action: () => { setAliasIgnored(true); runChecks(); } },
+ runChecks();
+ },
+ },
+ {
+ label: "Skip (use 'npx cuabot' instead)",
+ action: () => {
+ setAliasIgnored(true);
+ runChecks();
+ },
+ },
]}
onSelect={() => {}}
/>
diff --git a/libs/cuabot/src/prompts/SYSTEM.md b/libs/cuabot/src/prompts/SYSTEM.md
index 676c25c5ef..02f2f7aea2 100644
--- a/libs/cuabot/src/prompts/SYSTEM.md
+++ b/libs/cuabot/src/prompts/SYSTEM.md
@@ -1,17 +1,20 @@
You are a computer-use agent with your own Ubuntu 22.04 sandbox (xpra). User sees your desktop in real-time. You have sudo privileges.
## Environment
+
- Node.js 22.x, Python 3.10, pip3, uv (Python package manager)
- Currently installed: chromium, agent-browser, agent-device (adb), feh, claude-code, x11-apps
- Python libs: matplotlib, numpy, pandas, seaborn, plotly
- uv is available for running self-contained Python scripts with inline dependencies
## Agent Tools
+
- **computer-use**: Desktop automation MCP. Use for all screenshot tasks or desktop app automation.
- **agent-browser**: Browser automation CLI. Use for all web browsing tasks.
- **agent-device**: Android device/emulator automation CLI. Use for Android app testing and automation.
## Guidelines
+
- Keep responses brief
- Use agent-browser for browser automation (not chromium-browser)
- Use agent-device for Android emulator/device automation
diff --git a/libs/cuabot/src/settings.ts b/libs/cuabot/src/settings.ts
index 230fd11fc9..eddb5ded44 100644
--- a/libs/cuabot/src/settings.ts
+++ b/libs/cuabot/src/settings.ts
@@ -2,12 +2,12 @@
* CuaBot Settings Management
*/
-import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
-import { join } from "path";
-import { homedir } from "os";
+import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
+import { join } from 'path';
+import { homedir } from 'os';
-const CONFIG_DIR = join(homedir(), ".cuabot");
-const SETTINGS_FILE = join(CONFIG_DIR, "settings.json");
+const CONFIG_DIR = join(homedir(), '.cuabot');
+const SETTINGS_FILE = join(CONFIG_DIR, 'settings.json');
export interface Settings {
defaultAgent?: string;
@@ -17,34 +17,34 @@ export interface Settings {
export const AGENTS = {
claude: {
- name: "Claude Code",
+ name: 'Claude Code',
description: "Anthropic's Claude AI coding assistant",
- command: "claude",
+ command: 'claude',
},
gemini: {
- name: "Gemini CLI",
+ name: 'Gemini CLI',
description: "Google's Gemini AI assistant",
- command: "npx @google/gemini-cli",
+ command: 'npx @google/gemini-cli',
},
codex: {
- name: "OpenAI Codex",
+ name: 'OpenAI Codex',
description: "OpenAI's Codex coding assistant",
- command: "codex",
+ command: 'codex',
},
aider: {
- name: "Aider",
- description: "AI pair programming in your terminal",
- command: "aider",
+ name: 'Aider',
+ description: 'AI pair programming in your terminal',
+ command: 'aider',
},
openclaw: {
- name: "OpenClaw",
- description: "OpenClaw AI assistant",
- command: "openclaw",
+ name: 'OpenClaw',
+ description: 'OpenClaw AI assistant',
+ command: 'openclaw',
},
vibe: {
- name: "Vibe",
+ name: 'Vibe',
description: "Mistral's Vibe coding assistant",
- command: "vibe",
+ command: 'vibe',
},
} as const;
@@ -62,7 +62,7 @@ export function loadSettings(): Settings {
return {};
}
try {
- return JSON.parse(readFileSync(SETTINGS_FILE, "utf-8"));
+ return JSON.parse(readFileSync(SETTINGS_FILE, 'utf-8'));
} catch {
return {};
}
@@ -85,8 +85,8 @@ export function setDefaultAgent(agent: string): void {
export function getTelemetryEnabled(): boolean {
const settings = loadSettings();
- const envValue = process.env.CUABOT_TELEMETRY?.toLowerCase() === "true";
- const envFalse = process.env.CUABOT_TELEMETRY?.toLowerCase() === "false";
+ const envValue = process.env.CUABOT_TELEMETRY?.toLowerCase() === 'true';
+ const envFalse = process.env.CUABOT_TELEMETRY?.toLowerCase() === 'false';
// If any source is explicitly false, return false
if (settings.telemetryEnabled === false || envFalse) {
diff --git a/libs/cuabot/src/telemetry.ts b/libs/cuabot/src/telemetry.ts
index 1a340c1e7a..de551a33d7 100644
--- a/libs/cuabot/src/telemetry.ts
+++ b/libs/cuabot/src/telemetry.ts
@@ -5,19 +5,19 @@
* Other components (cuabot.tsx, computer-use-mcp.py) send events via HTTP.
*/
-import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
-import { homedir } from "os";
-import { join } from "path";
-import { PostHog } from "posthog-node";
-import { v4 as uuidv4 } from "uuid";
-import { getTelemetryEnabled } from "./settings.js";
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
+import { homedir } from 'os';
+import { join } from 'path';
+import { PostHog } from 'posthog-node';
+import { v4 as uuidv4 } from 'uuid';
+import { getTelemetryEnabled } from './settings.js';
// PostHog config (same as @trycua/core - intentionally public)
-const POSTHOG_API_KEY = "phc_eSkLnbLxsnYFaXksif1ksbrNzYlJShr35miFLDppF14";
-const POSTHOG_HOST = "https://eu.i.posthog.com";
+const POSTHOG_API_KEY = 'phc_eSkLnbLxsnYFaXksif1ksbrNzYlJShr35miFLDppF14';
+const POSTHOG_HOST = 'https://eu.i.posthog.com';
// Installation ID path (shared with @trycua/core)
-const INSTALLATION_ID_PATH = join(homedir(), ".cua", "installation_id");
+const INSTALLATION_ID_PATH = join(homedir(), '.cua', 'installation_id');
export interface TelemetryEvent {
type: string;
@@ -33,7 +33,7 @@ export interface TelemetryEvent {
function getOrCreateInstallationId(): string {
try {
if (existsSync(INSTALLATION_ID_PATH)) {
- return readFileSync(INSTALLATION_ID_PATH, "utf-8").trim();
+ return readFileSync(INSTALLATION_ID_PATH, 'utf-8').trim();
}
} catch {
// Fall through to create new ID
@@ -41,7 +41,7 @@ function getOrCreateInstallationId(): string {
const newId = uuidv4();
try {
- const dir = join(homedir(), ".cua");
+ const dir = join(homedir(), '.cua');
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
@@ -80,7 +80,7 @@ export class CuabotTelemetry {
flushInterval: 30000,
});
} catch (err) {
- console.error("[telemetry] Failed to initialize PostHog:", err);
+ console.error('[telemetry] Failed to initialize PostHog:', err);
}
}
}
@@ -109,7 +109,7 @@ export class CuabotTelemetry {
...properties,
session_id: this.sessionId,
timestamp,
- version: process.env.npm_package_version || "unknown",
+ version: process.env.npm_package_version || 'unknown',
platform: process.platform,
node_version: process.version,
},
@@ -126,7 +126,7 @@ export class CuabotTelemetry {
*/
recordStartup(port: number, sessionName: string | null, defaultAgent: string | null): void {
this.recordEvent({
- type: "startup",
+ type: 'startup',
timestamp: Date.now(),
port,
session_name: sessionName,
@@ -140,7 +140,7 @@ export class CuabotTelemetry {
recordShutdown(): void {
const uptimeSeconds = Math.round((Date.now() - this.startTime) / 1000);
this.recordEvent({
- type: "shutdown",
+ type: 'shutdown',
timestamp: Date.now(),
uptime_seconds: uptimeSeconds,
events_recorded: this.eventCount,
@@ -227,8 +227,8 @@ export function scrapeHistory(historyPath: string): void {
try {
if (!existsSync(historyPath)) return;
- const content = readFileSync(historyPath, "utf-8");
- const lines = content.trim().split("\n").filter(Boolean);
+ const content = readFileSync(historyPath, 'utf-8');
+ const lines = content.trim().split('\n').filter(Boolean);
if (lines.length === 0) return;
const lastLine = lines[lines.length - 1];
@@ -238,7 +238,7 @@ export function scrapeHistory(historyPath: string): void {
if (currentPrompt !== lastPrompt) {
lastPrompt = currentPrompt;
telemetryInstance.recordEvent({
- type: "prompt_change",
+ type: 'prompt_change',
timestamp: Date.now(),
prompt: currentPrompt,
claude_session_id: entry.sessionId,
@@ -283,19 +283,17 @@ export function stopHistoryPolling(): void {
*/
export async function sendTelemetryToServer(
port: number,
- event: Omit<TelemetryEvent, "session_id">
+ event: Omit<TelemetryEvent, 'session_id'>
): Promise<void> {
if (!getTelemetryEnabled()) return;
try {
await fetch(`http://localhost:${port}/telemetry`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event),
});
} catch {
// Silently ignore - server may not be running yet
}
}
-
-
diff --git a/libs/cuabot/src/types/node-pty.d.ts b/libs/cuabot/src/types/node-pty.d.ts
index d849e2431c..5b946a0fab 100644
--- a/libs/cuabot/src/types/node-pty.d.ts
+++ b/libs/cuabot/src/types/node-pty.d.ts
@@ -1,4 +1,4 @@
-declare module "@lydell/node-pty" {
+declare module '@lydell/node-pty' {
export interface IPtyForkOptions {
name?: string;
cols?: number;
@@ -19,17 +19,13 @@ declare module "@lydell/node-pty" {
readonly handleFlowControl: boolean;
onData: (callback: (data: string) => void) => void;
onExit: (callback: (exitCode: { exitCode: number; signal?: number }) => void) => void;
- on(event: "data", callback: (data: string) => void): void;
- on(event: "exit", callback: (exitCode: number, signal?: number) => void): void;
+ on(event: 'data', callback: (data: string) => void): void;
+ on(event: 'exit', callback: (exitCode: number, signal?: number) => void): void;
resize(cols: number, rows: number): void;
clear(): void;
write(data: string): void;
kill(signal?: string): void;
}
- export function spawn(
- file: string,
- args: string[] | string,
- options: IPtyForkOptions
- ): IPty;
+ export function spawn(file: string, args: string[] | string, options: IPtyForkOptions): IPty;
}
diff --git a/libs/cuabot/src/utils.ts b/libs/cuabot/src/utils.ts
index cafb835284..6290446ebb 100644
--- a/libs/cuabot/src/utils.ts
+++ b/libs/cuabot/src/utils.ts
@@ -3,13 +3,13 @@
* Shared utilities for Docker and Xpra detection
*/
-import { exec } from "child_process";
-import { copyFileSync, existsSync, mkdirSync } from "fs";
-import { tmpdir } from "os";
-import { dirname, join } from "path";
-import { fileURLToPath } from "url";
-import { promisify } from "util";
-import { isTelemetryConfigured } from "./settings.js";
+import { exec } from 'child_process';
+import { copyFileSync, existsSync, mkdirSync } from 'fs';
+import { tmpdir } from 'os';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
+import { promisify } from 'util';
+import { isTelemetryConfigured } from './settings.js';
const execAsync = promisify(exec);
@@ -19,7 +19,7 @@ const execAsync = promisify(exec);
export function nameToColor(name: string): string {
let hash = 0;
for (let i = 0; i < name.length; i++) {
- hash = ((hash << 5) - hash) + name.charCodeAt(i);
+ hash = (hash << 5) - hash + name.charCodeAt(i);
hash = hash & hash;
}
@@ -31,28 +31,51 @@ export function nameToColor(name: string): string {
const l = 0.5;
const c = (1 - Math.abs(2 * l - 1)) * s;
- const x = c * (1 - Math.abs((hue * 6) % 2 - 1));
+ const x = c * (1 - Math.abs(((hue * 6) % 2) - 1));
const m = l - c / 2;
let r: number, g: number, b: number;
const h = hue * 6;
- if (h < 1) { r = c; g = x; b = 0; }
- else if (h < 2) { r = x; g = c; b = 0; }
- else if (h < 3) { r = 0; g = c; b = x; }
- else if (h < 4) { r = 0; g = x; b = c; }
- else if (h < 5) { r = x; g = 0; b = c; }
- else { r = c; g = 0; b = x; }
+ if (h < 1) {
+ r = c;
+ g = x;
+ b = 0;
+ } else if (h < 2) {
+ r = x;
+ g = c;
+ b = 0;
+ } else if (h < 3) {
+ r = 0;
+ g = c;
+ b = x;
+ } else if (h < 4) {
+ r = 0;
+ g = x;
+ b = c;
+ } else if (h < 5) {
+ r = x;
+ g = 0;
+ b = c;
+ } else {
+ r = c;
+ g = 0;
+ b = x;
+ }
- const toHex = (n: number) => Math.round((n + m) * 255).toString(16).padStart(2, "0").toUpperCase();
+ const toHex = (n: number) =>
+ Math.round((n + m) * 255)
+ .toString(16)
+ .padStart(2, '0')
+ .toUpperCase();
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
}
// Xpra paths by platform
const XPRA_PATHS = {
- win32: "C:\\Program Files\\Xpra\\xpra_cmd.exe",
- darwin: "/Applications/Xpra.app/Contents/MacOS/Xpra",
- linux: "xpra",
+ win32: 'C:\\Program Files\\Xpra\\xpra_cmd.exe',
+ darwin: '/Applications/Xpra.app/Contents/MacOS/Xpra',
+ linux: 'xpra',
} as const;
/**
@@ -60,7 +83,7 @@ const XPRA_PATHS = {
*/
export function getXpraBinPath(): string {
const platform = process.platform as keyof typeof XPRA_PATHS;
- return XPRA_PATHS[platform] || "xpra";
+ return XPRA_PATHS[platform] || 'xpra';
}
/**
@@ -68,10 +91,10 @@ export function getXpraBinPath(): string {
*/
function getAssetPath(filename: string): string {
const currentDir = dirname(fileURLToPath(import.meta.url));
- const srcPath = join(currentDir, "..", "assets", filename);
+ const srcPath = join(currentDir, '..', 'assets', filename);
// Copy to temp directory to avoid file locking issues with npx cache
- const tempDir = join(tmpdir(), "cuabot-assets");
+ const tempDir = join(tmpdir(), 'cuabot-assets');
const tempPath = join(tempDir, filename);
try {
@@ -92,28 +115,28 @@ function getAssetPath(filename: string): string {
*/
export function getXpraAttachArgs(containerPort: number, sessionName?: string | null): string[] {
const platform = process.platform;
- const iconFile = platform === "win32" ? "icon.ico" : "icon.png";
+ const iconFile = platform === 'win32' ? 'icon.ico' : 'icon.png';
const iconPath = getAssetPath(iconFile);
- const name = sessionName || "default";
+ const name = sessionName || 'default';
const displayName = `cuabot (${name})`;
// Generate border color from session name to match overlay cursor
- const borderColor = "auto" // TODO: fix this nameToColor(name).substring(1); // remove #
+ const borderColor = 'auto'; // TODO: fix this nameToColor(name).substring(1); // remove #
const args = [
- "attach",
+ 'attach',
`tcp://localhost:${containerPort}`,
- "--splash=no",
- "--notifications=no",
+ '--splash=no',
+ '--notifications=no',
`--border=${borderColor},4`,
- "--sharing=yes",
+ '--sharing=yes',
`--tray-icon=${iconPath}`,
`--window-icon=${iconPath}`,
`--session-name=${displayName}`,
];
// Mac-only dock icon
- if (platform === "darwin") {
+ if (platform === 'darwin') {
args.push(`--dock-icon=${iconPath}`);
}
@@ -125,14 +148,21 @@ export function getXpraAttachArgs(containerPort: number, sessionName?: string |
*/
export async function checkDocker(): Promise<{ ok: boolean; message: string }> {
try {
- await execAsync("docker info");
- return { ok: true, message: "Docker is running" };
+ await execAsync('docker info');
+ return { ok: true, message: 'Docker is running' };
} catch {
try {
- await execAsync("docker --version");
- return { ok: false, message: "Docker is installed but not running. Please start Docker Desktop." };
+ await execAsync('docker --version');
+ return {
+ ok: false,
+ message: 'Docker is installed but not running. Please start Docker Desktop.',
+ };
} catch {
- return { ok: false, message: "Docker is not installed. Please install Docker Desktop from https://www.docker.com/products/docker-desktop/" };
+ return {
+ ok: false,
+ message:
+ 'Docker is not installed. Please install Docker Desktop from https://www.docker.com/products/docker-desktop/',
+ };
}
}
}
@@ -140,47 +170,56 @@ export async function checkDocker(): Promise<{ ok: boolean; message: string }> {
/**
* Check if Xpra client is available
*/
-export async function checkXpra(): Promise<{ ok: boolean; message: string; quarantined?: boolean }> {
+export async function checkXpra(): Promise<{
+ ok: boolean;
+ message: string;
+ quarantined?: boolean;
+}> {
const xpraPath = getXpraBinPath();
const platform = process.platform;
// Platform-specific install instructions
- const installInstructions = platform === "darwin"
- ? "Please install from https://github.com/Xpra-org/xpra/wiki/Download and ensure it's installed at /Applications/Xpra.app"
- : platform === "linux"
- ? "Please install via your package manager (e.g., 'apt install xpra' or 'brew install xpra')"
- : "Please install from https://github.com/Xpra-org/xpra/wiki/Download";
+ const installInstructions =
+ platform === 'darwin'
+ ? "Please install from https://github.com/Xpra-org/xpra/wiki/Download and ensure it's installed at /Applications/Xpra.app"
+ : platform === 'linux'
+ ? "Please install via your package manager (e.g., 'apt install xpra' or 'brew install xpra')"
+ : 'Please install from https://github.com/Xpra-org/xpra/wiki/Download';
// For absolute paths, check if file exists
- if (xpraPath.includes("/") || xpraPath.includes("\\")) {
+ if (xpraPath.includes('/') || xpraPath.includes('\\')) {
if (existsSync(xpraPath)) {
// On macOS, check for quarantine attribute
- if (platform === "darwin") {
+ if (platform === 'darwin') {
try {
- const { stdout } = await execAsync("xattr /Applications/Xpra.app");
- if (stdout.includes("com.apple.quarantine")) {
- return { ok: false, message: `Xpra is installed but quarantined. Run: sudo xattr -c /Applications/Xpra.app`, quarantined: true };
+ const { stdout } = await execAsync('xattr /Applications/Xpra.app');
+ if (stdout.includes('com.apple.quarantine')) {
+ return {
+ ok: false,
+ message: `Xpra is installed but quarantined. Run: sudo xattr -c /Applications/Xpra.app`,
+ quarantined: true,
+ };
}
} catch {
// xattr command failed, ignore
}
}
- return { ok: true, message: "Xpra client found" };
+ return { ok: true, message: 'Xpra client found' };
}
return {
ok: false,
- message: `Xpra client not found. ${installInstructions}`
+ message: `Xpra client not found. ${installInstructions}`,
};
}
// For command names, try to run with --version
try {
await execAsync(`${xpraPath} --version`);
- return { ok: true, message: "Xpra client found" };
+ return { ok: true, message: 'Xpra client found' };
} catch {
return {
ok: false,
- message: `Xpra client not found. ${installInstructions}`
+ message: `Xpra client not found. ${installInstructions}`,
};
}
}
@@ -190,16 +229,16 @@ export async function checkXpra(): Promise<{ ok: boolean; message: string; quara
*/
export async function checkPlaywright(): Promise<{ ok: boolean; message: string }> {
try {
- const { chromium } = await import("playwright");
+ const { chromium } = await import('playwright');
const browser = await chromium.launch({ headless: true });
await browser.close();
- return { ok: true, message: "installed" };
+ return { ok: true, message: 'installed' };
} catch {
- return { ok: false, message: "not installed" };
+ return { ok: false, message: 'not installed' };
}
}
-const DOCKER_IMAGE = "trycua/cuabot:latest";
+const DOCKER_IMAGE = 'trycua/cuabot:latest';
/**
* Check if Docker image exists locally
@@ -207,43 +246,51 @@ const DOCKER_IMAGE = "trycua/cuabot:latest";
export async function checkDockerImage(): Promise<{ ok: boolean; message: string }> {
try {
await execAsync(`docker image inspect ${DOCKER_IMAGE}`);
- return { ok: true, message: "cached" };
+ return { ok: true, message: 'cached' };
} catch {
- return { ok: false, message: "not pulled" };
+ return { ok: false, message: 'not pulled' };
}
}
/**
* Pull the Docker image with progress callback
*/
-export async function pullDockerImage(onProgress?: (line: string) => void): Promise<{ ok: boolean; message: string }> {
+export async function pullDockerImage(
+ onProgress?: (line: string) => void
+): Promise<{ ok: boolean; message: string }> {
return new Promise((resolve) => {
const pullProcess = exec(`docker pull ${DOCKER_IMAGE}`);
- pullProcess.stdout?.on("data", (data: Buffer) => {
- const lines = data.toString().split("\n").filter(l => l.trim());
+ pullProcess.stdout?.on('data', (data: Buffer) => {
+ const lines = data
+ .toString()
+ .split('\n')
+ .filter((l) => l.trim());
for (const line of lines) {
onProgress?.(line);
}
});
- pullProcess.stderr?.on("data", (data: Buffer) => {
- const lines = data.toString().split("\n").filter(l => l.trim());
+ pullProcess.stderr?.on('data', (data: Buffer) => {
+ const lines = data
+ .toString()
+ .split('\n')
+ .filter((l) => l.trim());
for (const line of lines) {
onProgress?.(line);
}
});
- pullProcess.on("exit", (code) => {
+ pullProcess.on('exit', (code) => {
if (code === 0) {
- resolve({ ok: true, message: "pulled" });
+ resolve({ ok: true, message: 'pulled' });
} else {
- resolve({ ok: false, message: "pull failed" });
+ resolve({ ok: false, message: 'pull failed' });
}
});
- pullProcess.on("error", () => {
- resolve({ ok: false, message: "pull failed" });
+ pullProcess.on('error', () => {
+ resolve({ ok: false, message: 'pull failed' });
});
});
}
@@ -269,20 +316,20 @@ export async function checkDependencies(): Promise<{ ok: boolean; errors: string
}
if (!playwrightCheck.ok) {
- errors.push("Playwright Chromium not installed. Run: npx playwright install chromium");
+ errors.push('Playwright Chromium not installed. Run: npx playwright install chromium');
}
// Only check Docker image if Docker is running
if (dockerCheck.ok) {
const dockerImageCheck = await checkDockerImage();
if (!dockerImageCheck.ok) {
- errors.push("Docker image not pulled. Run: docker pull trycua/cuabot:latest");
+ errors.push('Docker image not pulled. Run: docker pull trycua/cuabot:latest');
}
}
// Check telemetry configuration
if (!isTelemetryConfigured()) {
- errors.push("Usage telemetry not configured");
+ errors.push('Usage telemetry not configured');
}
return { ok: errors.length === 0, errors };
diff --git a/libs/lume/src/SSH/SSHClient.swift b/libs/lume/src/SSH/SSHClient.swift
index 911bc8efb5..46137e72b1 100644
--- a/libs/lume/src/SSH/SSHClient.swift
+++ b/libs/lume/src/SSH/SSHClient.swift
@@ -47,23 +47,25 @@ public actor SSHClient {
// Create a promise for the result
let resultPromise = channel.eventLoop.makePromise(of: SSHResult.self)
- // Create the SSH child channel for command execution
- // nonisolated(unsafe) is safe because NIOSSHHandler is confined to its event loop
- nonisolated(unsafe) let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
-
+ // Create the SSH child channel for command execution.
+ // We keep handler access + createChannel on the event loop to avoid
+ // crossing a Sendable boundary with NIOSSHHandler.
let childChannelPromise = channel.eventLoop.makePromise(of: Channel.self)
- sshHandler.createChannel(childChannelPromise) { childChannel, channelType in
- guard channelType == .session else {
- return channel.eventLoop.makeFailedFuture(SSHError.connectionFailed("Invalid channel type"))
- }
+ let childChannelFuture = channel.pipeline.handler(type: NIOSSHHandler.self).flatMap { sshHandler -> EventLoopFuture<Channel> in
+ sshHandler.createChannel(childChannelPromise) { childChannel, channelType in
+ guard channelType == .session else {
+ return channel.eventLoop.makeFailedFuture(SSHError.connectionFailed("Invalid channel type"))
+ }
- return childChannel.eventLoop.makeCompletedFuture {
- let execHandler = CommandExecHandler(command: command, resultPromise: resultPromise)
- try childChannel.pipeline.syncOperations.addHandler(execHandler)
+ return childChannel.eventLoop.makeCompletedFuture {
+ let execHandler = CommandExecHandler(command: command, resultPromise: resultPromise)
+ try childChannel.pipeline.syncOperations.addHandler(execHandler)
+ }
}
+ return childChannelPromise.futureResult
}
- let childChannel = try await childChannelPromise.futureResult.get()
+ let childChannel = try await childChannelFuture.get()
// Set up timeout if specified
if timeout > 0 {
@@ -92,25 +94,27 @@ public actor SSHClient {
public func interactive() async throws {
let channel = try await connect()
- // Create the SSH child channel for interactive session
- // nonisolated(unsafe) is safe because NIOSSHHandler is confined to its event loop
- nonisolated(unsafe) let sshHandler = try await channel.pipeline.handler(type: NIOSSHHandler.self).get()
-
+ // Create the SSH child channel for interactive session.
+ // We keep handler access + createChannel on the event loop to avoid
+ // crossing a Sendable boundary with NIOSSHHandler.
let childChannelPromise = channel.eventLoop.makePromise(of: Channel.self)
let sessionCompletePromise = channel.eventLoop.makePromise(of: Void.self)
- sshHandler.createChannel(childChannelPromise) { childChannel, channelType in
- guard channelType == .session else {
- return channel.eventLoop.makeFailedFuture(SSHError.connectionFailed("Invalid channel type"))
- }
+ let childChannelFuture = channel.pipeline.handler(type: NIOSSHHandler.self).flatMap { sshHandler -> EventLoopFuture<Channel> in
+ sshHandler.createChannel(childChannelPromise) { childChannel, channelType in
+ guard channelType == .session else {
+ return channel.eventLoop.makeFailedFuture(SSHError.connectionFailed("Invalid channel type"))
+ }
- return childChannel.eventLoop.makeCompletedFuture {
- let interactiveHandler = InteractiveSessionHandler(completePromise: sessionCompletePromise)
- try childChannel.pipeline.syncOperations.addHandler(interactiveHandler)
+ return childChannel.eventLoop.makeCompletedFuture {
+ let interactiveHandler = InteractiveSessionHandler(completePromise: sessionCompletePromise)
+ try childChannel.pipeline.syncOperations.addHandler(interactiveHandler)
+ }
}
+ return childChannelPromise.futureResult
}
- let childChannel = try await childChannelPromise.futureResult.get()
+ let childChannel = try await childChannelFuture.get()
// Wait for the session to complete
try await sessionCompletePromise.futureResult.get()
diff --git a/libs/lume/tests/Mocks/MockVNCService.swift b/libs/lume/tests/Mocks/MockVNCService.swift
index 3f94378f94..215053d0f6 100644
--- a/libs/lume/tests/Mocks/MockVNCService.swift
+++ b/libs/lume/tests/Mocks/MockVNCService.swift
@@ -75,7 +75,7 @@ final class MockVNCService: VNCService {
// No-op for testing
}
- func sendText(_ text: String) async throws {
+ func sendText(_ text: String, delayMs: Int?) async throws {
// No-op for testing
}
diff --git a/libs/python/computer-server/README.md b/libs/python/computer-server/README.md
index 1ff09c8426..531b17296d 100644
--- a/libs/python/computer-server/README.md
+++ b/libs/python/computer-server/README.md
@@ -35,6 +35,7 @@ python -m computer_server --width 1512 --height 982
```
This provides:
+
- HTTP API at `/ws`, `/cmd`, `/status` endpoints
- MCP server at `/mcp` endpoint (requires `fastmcp` package)
@@ -53,11 +54,13 @@ This ensures the AI model sees consistent coordinates between screenshots and mo
#### Claude Code Integration
1. Start the server (or run as a service/LaunchAgent):
+
```bash
python -m computer_server --port 8000
```
2. Add the MCP server URL to Claude Code:
+
```bash
claude mcp add cua-computer-server --transport http http://localhost:8000/mcp
```
@@ -67,6 +70,7 @@ claude mcp add cua-computer-server --transport http http://localhost:8000/mcp
The MCP interface exposes 40+ tools for computer control:
### Screen & Mouse
+
- `computer_screenshot` - Capture current screen
- `computer_click` - Click at coordinates
- `computer_double_click` - Double-click
@@ -77,19 +81,23 @@ The MCP interface exposes 40+ tools for computer control:
- `computer_get_cursor_position` - Get cursor position
### Keyboard
+
- `computer_type` - Type text
- `computer_press_key` - Press a single key
- `computer_hotkey` - Press key combination (e.g., Ctrl+C)
- `computer_key_down` / `computer_key_up` - Hold/release keys
### Clipboard
+
- `computer_clipboard_get` - Get clipboard content
- `computer_clipboard_set` - Set clipboard content
### Shell
+
- `computer_run_command` - Execute shell command
### File System
+
- `computer_file_read` / `computer_file_write` - Read/write files
- `computer_file_exists` / `computer_directory_exists` - Check existence
- `computer_list_directory` - List directory contents
@@ -97,6 +105,7 @@ The MCP interface exposes 40+ tools for computer control:
- `computer_delete_file` / `computer_delete_directory` - Delete files/directories
### Window Management
+
- `computer_open` - Open file or URL
- `computer_launch_app` - Launch application
- `computer_get_active_window` - Get active window
@@ -105,5 +114,6 @@ The MCP interface exposes 40+ tools for computer control:
- `computer_close_window` - Close window
### Accessibility
+
- `computer_get_accessibility_tree` - Get UI element tree
- `computer_find_element` - Find UI element by role/title
diff --git a/libs/python/cua-cli/.bumpversion.cfg b/libs/python/cua-cli/.bumpversion.cfg
new file mode 100644
index 0000000000..af1c9f9448
--- /dev/null
+++ b/libs/python/cua-cli/.bumpversion.cfg
@@ -0,0 +1,14 @@
+[bumpversion]
+current_version = 0.1.0
+commit = True
+tag = True
+tag_name = cli-v{new_version}
+message = Bump cua-cli to v{new_version}
+
+[bumpversion:file:pyproject.toml]
+search = version = "{current_version}"
+replace = version = "{new_version}"
+
+[bumpversion:file:cua_cli/__init__.py]
+search = __version__ = "{current_version}"
+replace = __version__ = "{new_version}"
diff --git a/libs/python/cua-cli/README.md b/libs/python/cua-cli/README.md
new file mode 100644
index 0000000000..f7f02df1a0
--- /dev/null
+++ b/libs/python/cua-cli/README.md
@@ -0,0 +1,100 @@
+# CUA CLI
+
+Unified command-line interface for CUA (Computer-Use Agents).
+
+## Installation
+
+```bash
+pip install cua-cli
+```
+
+## Usage
+
+```bash
+# Authentication
+cua auth login # Authenticate via browser
+cua auth login --api-key # Authenticate with API key
+cua auth logout # Clear credentials
+cua auth env # Export API key to .env file
+
+# Sandbox Management
+cua sb list # List all sandboxes
+cua sb create --os linux --size medium --region north-america
+cua sb get <name> # Get sandbox details
+cua sb start <name> # Start a stopped sandbox
+cua sb stop <name> # Stop a running sandbox
+cua sb restart <name> # Restart a sandbox
+cua sb suspend <name> # Suspend a sandbox
+cua sb delete <name> # Delete a sandbox
+cua sb vnc <name> # Open sandbox in browser
+
+# Image Management
+cua image list # List cloud images
+cua image list --local # List local images
+cua image push <name> # Upload image to cloud
+cua image pull <name> # Download image from cloud
+cua image delete <name> # Delete cloud image
+
+# Skills Management
+cua skills list # List recorded skills
+cua skills read <name> # Read a skill's content
+cua skills record <name> # Record a new skill
+cua skills replay <name> # Replay a skill
+cua skills delete <name> # Delete a skill
+cua skills clean # Delete all skills
+
+# MCP Server (for AI assistants)
+cua serve-mcp # Start MCP server with all permissions
+cua serve-mcp --permissions sandbox:all,computer:readonly
+```
+
+## Installation Options
+
+```bash
+# Basic installation
+pip install cua-cli
+
+# With MCP server support
+pip install cua-cli[mcp]
+
+# With skills recording (VLM captioning)
+pip install cua-cli[skills]
+
+# Full installation
+pip install cua-cli[all]
+```
+
+## MCP Integration
+
+To use CUA with Claude Code or other MCP-compatible AI assistants:
+
+```bash
+# Add CUA as an MCP server
+claude mcp add cua -- cua serve-mcp
+
+# With specific permissions
+claude mcp add cua -- cua serve-mcp --permissions sandbox:all,computer:readonly
+
+# With a default sandbox
+claude mcp add cua -- cua serve-mcp --sandbox my-sandbox
+```
+
+### Available Permissions
+
+- `all` - All permissions
+- `sandbox:all` - Full sandbox management
+- `sandbox:readonly` - List and get sandboxes only
+- `computer:all` - Full computer control
+- `computer:readonly` - Screenshots only
+- `skills:all` - Full skills management
+- `skills:readonly` - List and read skills only
+
+Individual permissions: `sandbox:list`, `sandbox:create`, `sandbox:delete`, `sandbox:start`, `sandbox:stop`, `sandbox:restart`, `sandbox:suspend`, `sandbox:get`, `sandbox:vnc`, `computer:screenshot`, `computer:click`, `computer:type`, `computer:key`, `computer:scroll`, `computer:drag`, `computer:hotkey`, `computer:clipboard`, `computer:file`, `computer:shell`, `computer:window`, `skills:list`, `skills:read`, `skills:record`, `skills:delete`
+
+## Environment Variables
+
+- `CUA_API_KEY`: API key for authentication
+- `CUA_API_BASE`: API base URL (default: https://api.cua.ai)
+- `CUA_WEBSITE_URL`: Website URL for OAuth (default: https://cua.ai)
+- `CUA_MCP_PERMISSIONS`: Default MCP permissions (comma-separated)
+- `CUA_SANDBOX`: Default sandbox name for computer commands
diff --git a/libs/python/cua-cli/cua_cli/__init__.py b/libs/python/cua-cli/cua_cli/__init__.py
new file mode 100644
index 0000000000..ba87f228a5
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/__init__.py
@@ -0,0 +1,3 @@
+"""CUA CLI - Unified command-line interface for Computer-Use Agents."""
+
+__version__ = "0.1.0"
diff --git a/libs/python/cua-cli/cua_cli/api/__init__.py b/libs/python/cua-cli/cua_cli/api/__init__.py
new file mode 100644
index 0000000000..23d6f4984c
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/api/__init__.py
@@ -0,0 +1 @@
+"""API client module for CUA CLI."""
diff --git a/libs/python/cua-cli/cua_cli/api/client.py b/libs/python/cua-cli/cua_cli/api/client.py
new file mode 100644
index 0000000000..7dee69092c
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/api/client.py
@@ -0,0 +1,142 @@
+"""HTTP API client for CUA cloud services."""
+
+import hashlib
+import os
+from pathlib import Path
+from typing import Any, Optional
+from urllib.parse import quote
+
+import aiohttp
+from cua_cli.auth.store import require_api_key
+
+DEFAULT_API_BASE = "https://api.cua.ai"
+
+
+def get_api_base() -> str:
+ """Get the API base URL."""
+ return os.environ.get("CUA_API_BASE", DEFAULT_API_BASE).rstrip("/")
+
+
+class CloudAPIClient:
+ """HTTP client for CUA cloud API."""
+
+ def __init__(self, api_key: Optional[str] = None, api_base: Optional[str] = None):
+ self.api_key = api_key or require_api_key()
+ self.api_base = api_base or get_api_base()
+
+ def _headers(self) -> dict[str, str]:
+ return {
+ "Authorization": f"Bearer {self.api_key}",
+ "Accept": "application/json",
+ }
+
+ async def _request(
+ self,
+ method: str,
+ path: str,
+ json: Optional[dict] = None,
+ timeout: int = 30,
+ ) -> tuple[int, Any]:
+ """Make an HTTP request to the API.
+
+ Returns:
+ Tuple of (status_code, response_data)
+ """
+ url = f"{self.api_base}{path}"
+ headers = self._headers()
+
+ if json is not None:
+ headers["Content-Type"] = "application/json"
+
+ async with aiohttp.ClientSession() as session:
+ timeout_obj = aiohttp.ClientTimeout(total=timeout)
+ async with session.request(
+ method, url, headers=headers, json=json, timeout=timeout_obj
+ ) as resp:
+ try:
+ data = await resp.json(content_type=None)
+ except Exception:
+ data = await resp.text()
+ return resp.status, data
+
+ # Image API methods
+
+ async def list_images(self) -> list[dict[str, Any]]:
+ """List all images in the workspace."""
+ status, data = await self._request("GET", "/v1/images")
+ if status == 200 and isinstance(data, list):
+ return data
+ return []
+
+ async def initiate_upload(
+ self,
+ name: str,
+ tag: str,
+ image_type: str,
+ size_bytes: int,
+ checksum_sha256: str,
+ ) -> tuple[int, dict[str, Any]]:
+ """Initiate a multi-part upload session.
+
+ Returns:
+ Tuple of (status_code, session_data)
+ """
+ path = f"/v1/images/{quote(name, safe='')}/upload"
+ body = {
+ "tag": tag,
+ "image_type": image_type,
+ "size_bytes": size_bytes,
+ "checksum_sha256": checksum_sha256,
+ }
+ return await self._request("POST", path, json=body)
+
+ async def get_upload_part_url(
+ self, name: str, upload_id: str, part_number: int
+ ) -> tuple[int, dict[str, Any]]:
+ """Get a signed URL for uploading a part."""
+ path = f"/v1/images/{quote(name, safe='')}/upload/{upload_id}/part/{part_number}"
+ return await self._request("GET", path)
+
+ async def complete_upload(
+ self, name: str, upload_id: str, parts: list[dict[str, Any]]
+ ) -> tuple[int, dict[str, Any]]:
+ """Complete a multi-part upload."""
+ path = f"/v1/images/{quote(name, safe='')}/upload/{upload_id}/complete"
+ return await self._request("POST", path, json={"parts": parts})
+
+ async def abort_upload(self, name: str, upload_id: str) -> tuple[int, Any]:
+ """Abort an upload session."""
+ path = f"/v1/images/{quote(name, safe='')}/upload/{upload_id}"
+ return await self._request("DELETE", path)
+
+ async def get_download_url(self, name: str, tag: str) -> tuple[int, dict[str, Any]]:
+ """Get a signed URL for downloading an image."""
+ path = f"/v1/images/{quote(name, safe='')}/download?tag={quote(tag, safe='')}"
+ return await self._request("GET", path)
+
+ async def delete_image(self, name: str, tag: str) -> tuple[int, Any]:
+ """Delete an image version."""
+ path = f"/v1/images/{quote(name, safe='')}?tag={quote(tag, safe='')}"
+ return await self._request("DELETE", path)
+
+
+def calculate_file_hash(file_path: Path) -> str:
+ """Calculate SHA256 hash of a file."""
+ sha256 = hashlib.sha256()
+ with open(file_path, "rb") as f:
+ for chunk in iter(lambda: f.read(8192), b""):
+ sha256.update(chunk)
+ return sha256.hexdigest()
+
+
+def format_bytes(size_bytes: int) -> str:
+ """Format bytes in human-readable format."""
+ if size_bytes == 0:
+ return "0 B"
+ units = ["B", "KB", "MB", "GB", "TB"]
+ k = 1024
+ i = 0
+ while size_bytes >= k and i < len(units) - 1:
+ size_bytes /= k
+ i += 1
+ return f"{size_bytes:.2f} {units[i]}"
diff --git a/libs/python/cua-cli/cua_cli/auth/__init__.py b/libs/python/cua-cli/cua_cli/auth/__init__.py
new file mode 100644
index 0000000000..37aecc4370
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/auth/__init__.py
@@ -0,0 +1,5 @@
+"""Authentication module for CUA CLI."""
+
+from .store import CredentialStore, clear_credentials, get_api_key, save_api_key
+
+__all__ = ["CredentialStore", "get_api_key", "save_api_key", "clear_credentials"]
diff --git a/libs/python/cua-cli/cua_cli/auth/browser.py b/libs/python/cua-cli/cua_cli/auth/browser.py
new file mode 100644
index 0000000000..80292d1ccd
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/auth/browser.py
@@ -0,0 +1,148 @@
+"""Browser-based OAuth authentication for CUA CLI."""
+
+import asyncio
+import os
+import platform
+import subprocess
+import urllib.parse
+from http.server import BaseHTTPRequestHandler, HTTPServer
+from threading import Thread
+from typing import Optional
+
+# Default URLs
+DEFAULT_WEBSITE_URL = "https://cua.ai"
+
+# Timeout for browser authentication (2 minutes)
+AUTH_TIMEOUT_SECONDS = 120
+
+
+class CallbackHandler(BaseHTTPRequestHandler):
+ """HTTP request handler for OAuth callback."""
+
+ token: Optional[str] = None
+ error: Optional[str] = None
+
+ def do_GET(self) -> None:
+ """Handle GET request from OAuth callback."""
+ parsed = urllib.parse.urlparse(self.path)
+ params = urllib.parse.parse_qs(parsed.query)
+
+ if "token" in params:
+ CallbackHandler.token = params["token"][0]
+ self._send_response(
+ 200,
+ "<html><body><h1>Authentication successful!</h1>"
+ "<p>You can close this window and return to the terminal.</p></body></html>",
+ )
+ elif "error" in params:
+ CallbackHandler.error = params.get("error_description", params["error"])[0]
+ self._send_response(
+ 400,
+ f"<html><body><h1>Authentication failed</h1>"
+ f"<p>{CallbackHandler.error}</p></body></html>",
+ )
+ else:
+ self._send_response(
+ 400,
+ "<html><body><h1>Invalid callback</h1>"
+ "<p>Missing token parameter.</p></body></html>",
+ )
+
+ def _send_response(self, status: int, body: str) -> None:
+ """Send an HTTP response."""
+ self.send_response(status)
+ self.send_header("Content-Type", "text/html")
+ self.end_headers()
+ self.wfile.write(body.encode())
+
+ def log_message(self, format: str, *args) -> None:
+ """Suppress default logging."""
+ pass
+
+
+def open_browser(url: str) -> bool:
+ """Open a URL in the default browser.
+
+ Args:
+ url: The URL to open
+
+ Returns:
+ True if the browser was opened successfully
+ """
+ system = platform.system()
+
+ try:
+ if system == "Darwin":
+ subprocess.run(["open", url], check=True)
+ elif system == "Windows":
+ subprocess.run(["cmd", "/c", "start", url], check=True, shell=True)
+ else: # Linux and others
+ subprocess.run(["xdg-open", url], check=True)
+ return True
+ except (subprocess.SubprocessError, FileNotFoundError):
+ return False
+
+
+async def authenticate_via_browser(
+ website_url: Optional[str] = None,
+) -> str:
+ """Authenticate via browser OAuth flow.
+
+ Starts a local HTTP server to receive the callback, opens the browser
+ to the authentication page, and waits for the token.
+
+ Args:
+ website_url: Base URL for the authentication page. Defaults to CUA_WEBSITE_URL
+ env var or https://cua.ai
+
+ Returns:
+ The API token
+
+ Raises:
+ TimeoutError: If authentication times out
+ RuntimeError: If authentication fails
+ """
+ website_url = website_url or os.environ.get("CUA_WEBSITE_URL", DEFAULT_WEBSITE_URL)
+
+ # Reset handler state
+ CallbackHandler.token = None
+ CallbackHandler.error = None
+
+ # Start local server on dynamic port
+ server = HTTPServer(("localhost", 0), CallbackHandler)
+ port = server.server_address[1]
+ callback_url = f"http://localhost:{port}"
+
+ # Build auth URL
+ encoded_callback = urllib.parse.quote(callback_url, safe="")
+ auth_url = f"{website_url}/cli-auth?callback_url={encoded_callback}"
+
+ # Start server in background thread
+ server_thread = Thread(target=server.handle_request, daemon=True)
+ server_thread.start()
+
+ # Open browser
+ print("Opening browser for authentication...")
+ if not open_browser(auth_url):
+ print("Could not open browser automatically.")
+ print(f"Please visit: {auth_url}")
+
+ # Wait for callback with timeout
+ try:
+ for _ in range(AUTH_TIMEOUT_SECONDS):
+ if CallbackHandler.token or CallbackHandler.error:
+ break
+ await asyncio.sleep(1)
+ else:
+ raise TimeoutError("Authentication timed out. Please try again.")
+
+ if CallbackHandler.error:
+ raise RuntimeError(f"Authentication failed: {CallbackHandler.error}")
+
+ if not CallbackHandler.token:
+ raise RuntimeError("Authentication failed: No token received")
+
+ return CallbackHandler.token
+
+ finally:
+ server.server_close()
diff --git a/libs/python/cua-cli/cua_cli/auth/store.py b/libs/python/cua-cli/cua_cli/auth/store.py
new file mode 100644
index 0000000000..de26145fbf
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/auth/store.py
@@ -0,0 +1,168 @@
+"""SQLite-based credential storage for CUA CLI."""
+
+import os
+import sqlite3
+from pathlib import Path
+from typing import Optional
+
+# Default storage location
+CUA_DIR = Path.home() / ".cua"
+CREDENTIALS_DB = CUA_DIR / "credentials.db"
+
+# Key names
+API_KEY_NAME = "api_key"
+
+
+class CredentialStore:
+ """SQLite-based credential store with WAL mode for concurrent access."""
+
+ def __init__(self, db_path: Path | None = None):
+ """Initialize the credential store.
+
+ Args:
+ db_path: Path to the SQLite database. Defaults to ~/.cua/credentials.db
+ """
+ self.db_path = db_path or CREDENTIALS_DB
+ self._ensure_db()
+
+ def _ensure_db(self) -> None:
+ """Ensure the database and table exist."""
+ self.db_path.parent.mkdir(parents=True, exist_ok=True)
+
+ conn = sqlite3.connect(self.db_path)
+ try:
+ # Enable WAL mode for better concurrent access
+ conn.execute("PRAGMA journal_mode=WAL")
+
+ # Create key-value table
+ conn.execute(
+ """
+ CREATE TABLE IF NOT EXISTS kv (
+ key TEXT PRIMARY KEY,
+ value TEXT NOT NULL
+ )
+ """
+ )
+ conn.commit()
+ finally:
+ conn.close()
+
+ def get(self, key: str) -> Optional[str]:
+ """Get a value from the store.
+
+ Args:
+ key: The key to look up
+
+ Returns:
+ The value, or None if not found
+ """
+ conn = sqlite3.connect(self.db_path)
+ try:
+ cursor = conn.execute("SELECT value FROM kv WHERE key = ?", (key,))
+ row = cursor.fetchone()
+ return row[0] if row else None
+ finally:
+ conn.close()
+
+ def set(self, key: str, value: str) -> None:
+ """Set a value in the store.
+
+ Args:
+ key: The key to set
+ value: The value to store
+ """
+ conn = sqlite3.connect(self.db_path)
+ try:
+ conn.execute(
+ "INSERT OR REPLACE INTO kv (key, value) VALUES (?, ?)",
+ (key, value),
+ )
+ conn.commit()
+ finally:
+ conn.close()
+
+ def delete(self, key: str) -> bool:
+ """Delete a value from the store.
+
+ Args:
+ key: The key to delete
+
+ Returns:
+ True if the key was deleted, False if it didn't exist
+ """
+ conn = sqlite3.connect(self.db_path)
+ try:
+ cursor = conn.execute("DELETE FROM kv WHERE key = ?", (key,))
+ conn.commit()
+ return cursor.rowcount > 0
+ finally:
+ conn.close()
+
+ def clear(self) -> None:
+ """Clear all stored credentials."""
+ conn = sqlite3.connect(self.db_path)
+ try:
+ conn.execute("DELETE FROM kv")
+ conn.commit()
+ finally:
+ conn.close()
+
+
+# Module-level convenience functions
+_store: Optional[CredentialStore] = None
+
+
+def _get_store() -> CredentialStore:
+ """Get the global credential store instance."""
+ global _store
+ if _store is None:
+ _store = CredentialStore()
+ return _store
+
+
+def get_api_key() -> Optional[str]:
+ """Get the stored API key.
+
+ First checks CUA_API_KEY environment variable, then falls back to stored credentials.
+
+ Returns:
+ The API key, or None if not found
+ """
+ # Environment variable takes precedence
+ env_key = os.environ.get("CUA_API_KEY")
+ if env_key:
+ return env_key
+
+ return _get_store().get(API_KEY_NAME)
+
+
+def save_api_key(api_key: str) -> None:
+ """Save an API key to the credential store.
+
+ Args:
+ api_key: The API key to save
+ """
+ _get_store().set(API_KEY_NAME, api_key)
+
+
+def clear_credentials() -> None:
+ """Clear all stored credentials."""
+ _get_store().clear()
+
+
+def require_api_key() -> str:
+ """Get the API key, raising an error if not found.
+
+ Returns:
+ The API key
+
+ Raises:
+ RuntimeError: If no API key is configured
+ """
+ api_key = get_api_key()
+ if not api_key:
+ raise RuntimeError(
+ "No API key configured. Run 'cua auth login' to authenticate, "
+ "or set the CUA_API_KEY environment variable."
+ )
+ return api_key
diff --git a/libs/python/cua-cli/cua_cli/commands/__init__.py b/libs/python/cua-cli/cua_cli/commands/__init__.py
new file mode 100644
index 0000000000..8ff5abf228
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/__init__.py
@@ -0,0 +1,5 @@
+"""CLI commands for CUA."""
+
+from . import auth, image, mcp, sandbox, skills
+
+__all__ = ["auth", "sandbox", "image", "skills", "mcp"]
diff --git a/libs/python/cua-cli/cua_cli/commands/auth.py b/libs/python/cua-cli/cua_cli/commands/auth.py
new file mode 100644
index 0000000000..9e72b2a8e5
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/auth.py
@@ -0,0 +1,181 @@
+"""Authentication commands for CUA CLI."""
+
+import argparse
+from pathlib import Path
+
+from cua_cli.auth.browser import authenticate_via_browser
+from cua_cli.auth.store import clear_credentials, get_api_key, save_api_key
+from cua_cli.utils.async_utils import run_async
+from cua_cli.utils.output import print_error, print_info, print_success
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the auth command and subcommands.
+
+ Args:
+ subparsers: The subparsers object from the main parser
+ """
+ auth_parser = subparsers.add_parser(
+ "auth",
+ help="Authentication commands",
+ description="Manage authentication for CUA cloud services",
+ )
+
+ auth_subparsers = auth_parser.add_subparsers(
+ dest="auth_command",
+ help="Authentication command",
+ )
+
+ # login command
+ login_parser = auth_subparsers.add_parser(
+ "login",
+ help="Authenticate with CUA cloud",
+ description="Authenticate via browser or API key",
+ )
+ login_parser.add_argument(
+ "--api-key",
+ type=str,
+ help="API key for direct authentication (skips browser flow)",
+ )
+
+ # logout command
+ auth_subparsers.add_parser(
+ "logout",
+ help="Clear stored credentials",
+ description="Remove all stored authentication credentials",
+ )
+
+ # env command
+ env_parser = auth_subparsers.add_parser(
+ "env",
+ help="Export API key to .env file",
+ description="Write CUA_API_KEY to .env file in current directory",
+ )
+ env_parser.add_argument(
+ "--file",
+ type=str,
+ default=".env",
+ help="Path to .env file (default: .env)",
+ )
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute auth command based on subcommand.
+
+ Args:
+ args: Parsed command-line arguments
+
+ Returns:
+ Exit code (0 for success, non-zero for failure)
+ """
+ cmd = getattr(args, "auth_command", None)
+
+ if cmd == "login":
+ return cmd_login(args)
+ elif cmd == "logout":
+ return cmd_logout(args)
+ elif cmd == "env":
+ return cmd_env(args)
+ else:
+ print_error("Usage: cua auth <command>")
+ print_info("Commands: login, logout, env")
+ return 1
+
+
+def cmd_login(args: argparse.Namespace) -> int:
+ """Handle the login command.
+
+ Args:
+ args: Parsed command-line arguments
+
+ Returns:
+ Exit code
+ """
+ # Check if already logged in
+ existing_key = get_api_key()
+ if existing_key and not args.api_key:
+ print_info("Already authenticated. Use 'cua auth logout' to clear credentials.")
+ return 0
+
+ if args.api_key:
+ # Direct API key authentication
+ api_key = args.api_key
+ print_info("Authenticating with provided API key...")
+ else:
+ # Browser-based authentication
+ try:
+ api_key = run_async(authenticate_via_browser())
+ except TimeoutError as e:
+ print_error(str(e))
+ return 1
+ except RuntimeError as e:
+ print_error(str(e))
+ return 1
+
+ # Save the API key
+ save_api_key(api_key)
+ print_success("Successfully authenticated!")
+
+ return 0
+
+
+def cmd_logout(args: argparse.Namespace) -> int:
+ """Handle the logout command.
+
+ Args:
+ args: Parsed command-line arguments
+
+ Returns:
+ Exit code
+ """
+ clear_credentials()
+ print_success("Credentials cleared.")
+ return 0
+
+
+def cmd_env(args: argparse.Namespace) -> int:
+ """Handle the env command - export API key to .env file.
+
+ Args:
+ args: Parsed command-line arguments
+
+ Returns:
+ Exit code
+ """
+ api_key = get_api_key()
+ if not api_key:
+ print_error("Not authenticated. Run 'cua auth login' first.")
+ return 1
+
+ env_file = Path(args.file)
+ env_line = f"CUA_API_KEY={api_key}"
+
+ if env_file.exists():
+ # Read existing content
+ content = env_file.read_text()
+ lines = content.splitlines()
+
+ # Check if CUA_API_KEY already exists
+ updated = False
+ for i, line in enumerate(lines):
+ if line.startswith("CUA_API_KEY="):
+ lines[i] = env_line
+ updated = True
+ break
+
+ if updated:
+ env_file.write_text("\n".join(lines) + "\n")
+ print_success(f"Updated CUA_API_KEY in {env_file}")
+ else:
+ # Append to file
+ with env_file.open("a") as f:
+ if content and not content.endswith("\n"):
+ f.write("\n")
+ f.write(env_line + "\n")
+ print_success(f"Added CUA_API_KEY to {env_file}")
+ else:
+ # Create new file
+ env_file.write_text(env_line + "\n")
+ print_success(f"Created {env_file} with CUA_API_KEY")
+
+ return 0
diff --git a/libs/python/cua-cli/cua_cli/commands/image.py b/libs/python/cua-cli/cua_cli/commands/image.py
new file mode 100644
index 0000000000..aca036c8b8
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/image.py
@@ -0,0 +1,673 @@
+"""Image management commands for CUA CLI.
+
+Handles both cloud images (push/pull to CUA cloud) and local images
+(create, clone, shell, info).
+"""
+
+import argparse
+from datetime import datetime
+from pathlib import Path
+from typing import Any
+
+import aiohttp
+from cua_cli.api.client import CloudAPIClient, calculate_file_hash, format_bytes
+from cua_cli.utils.async_utils import run_async
+from cua_cli.utils.output import (
+ print_error,
+ print_info,
+ print_json,
+ print_success,
+ print_table,
+)
+
+# Default local image storage
+LOCAL_IMAGES_DIR = Path.home() / ".local" / "share" / "cua" / "images"
+
+# Default part size for multi-part upload: 100MB
+DEFAULT_PART_SIZE = 100 * 1024 * 1024
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the image command and subcommands."""
+ for cmd_name in ("image", "img"):
+ img_parser = subparsers.add_parser(
+ cmd_name,
+ help="Image management commands",
+ description="Manage VM images (cloud and local)",
+ )
+
+ img_subparsers = img_parser.add_subparsers(
+ dest="image_command",
+ help="Image command",
+ )
+
+ # list command
+ list_parser = img_subparsers.add_parser(
+ "list",
+ aliases=["ls"],
+ help="List images",
+ )
+ list_parser.add_argument(
+ "--json",
+ action="store_true",
+ help="Output as JSON",
+ )
+ list_parser.add_argument(
+ "--local",
+ action="store_true",
+ help="List local images only",
+ )
+ list_parser.add_argument(
+ "--cloud",
+ action="store_true",
+ help="List cloud images only (default)",
+ )
+ list_parser.add_argument(
+ "--platform",
+ type=str,
+ help="Filter local images by platform",
+ )
+ list_parser.add_argument(
+ "--format",
+ choices=["table", "json"],
+ default="table",
+ help="Output format for local images",
+ )
+
+ # push command
+ push_parser = img_subparsers.add_parser(
+ "push",
+ help="Push image to cloud storage",
+ )
+ push_parser.add_argument(
+ "name",
+ help="Image name",
+ )
+ push_parser.add_argument(
+ "--file",
+ "-f",
+ type=str,
+ help="Path to image file (default: ~/.local/share/cua/images/<name>/data.img)",
+ )
+ push_parser.add_argument(
+ "--tag",
+ type=str,
+ default="latest",
+ help="Image tag (default: latest)",
+ )
+ push_parser.add_argument(
+ "--type",
+ type=str,
+ default="qcow2",
+ choices=["qcow2", "raw", "vmdk"],
+ help="Image type (default: qcow2)",
+ )
+
+ # pull command
+ pull_parser = img_subparsers.add_parser(
+ "pull",
+ help="Pull image from cloud storage",
+ )
+ pull_parser.add_argument(
+ "name",
+ help="Image name",
+ )
+ pull_parser.add_argument(
+ "--tag",
+ type=str,
+ default="latest",
+ help="Image tag (default: latest)",
+ )
+ pull_parser.add_argument(
+ "--output",
+ "-o",
+ type=str,
+ help="Output file path",
+ )
+
+ # delete command
+ delete_parser = img_subparsers.add_parser(
+ "delete",
+ help="Delete an image",
+ )
+ delete_parser.add_argument(
+ "name",
+ help="Image name",
+ )
+ delete_parser.add_argument(
+ "--tag",
+ type=str,
+ default="latest",
+ help="Image tag (default: latest, for cloud images)",
+ )
+ delete_parser.add_argument(
+ "--force",
+ action="store_true",
+ help="Skip confirmation",
+ )
+ delete_parser.add_argument(
+ "--local",
+ action="store_true",
+ help="Delete a local image instead of cloud",
+ )
+
+ # create command (local)
+ create_parser = img_subparsers.add_parser(
+ "create",
+ help="Create a local image from platform",
+ )
+ create_parser.add_argument(
+ "platform",
+ help="Platform name (e.g., linux-docker, windows-qemu)",
+ )
+ create_parser.add_argument("--name", help="Image name (default: same as platform)")
+ create_parser.add_argument("--iso", help="Path to ISO file (for QEMU platforms)")
+ create_parser.add_argument(
+ "--download-iso",
+ action="store_true",
+ dest="download_iso",
+ help="Download Windows 11 ISO (~6GB)",
+ )
+ create_parser.add_argument(
+ "--docker-image", dest="docker_image", help="Override Docker image"
+ )
+ create_parser.add_argument(
+ "--distro",
+ default="ubuntu",
+ choices=["ubuntu", "fedora"],
+ help="Linux distribution",
+ )
+ create_parser.add_argument(
+ "--version",
+ default="14",
+ help="OS version (e.g., 14 for Android, sonoma for macOS)",
+ )
+ create_parser.add_argument("--disk", default="64G", help="Disk size (default: 64G)")
+ create_parser.add_argument("--memory", default="8G", help="Memory (default: 8G)")
+ create_parser.add_argument("--cpus", default="8", help="CPU cores (default: 8)")
+ create_parser.add_argument(
+ "--winarena-apps",
+ action="store_true",
+ dest="winarena_apps",
+ help="Install WinArena benchmark apps (Chrome, LibreOffice, VLC, etc.)",
+ )
+ create_parser.add_argument("--detach", "-d", action="store_true", help="Run in background")
+ create_parser.add_argument("--force", action="store_true", help="Force recreation")
+ create_parser.add_argument(
+ "--skip-pull",
+ action="store_true",
+ dest="skip_pull",
+ help="Don't pull Docker image",
+ )
+ create_parser.add_argument(
+ "--no-kvm",
+ action="store_true",
+ dest="no_kvm",
+ help="Disable KVM acceleration",
+ )
+ create_parser.add_argument(
+ "--vnc-port",
+ dest="vnc_port",
+ help="VNC port (default: auto-allocate from 8006)",
+ )
+ create_parser.add_argument(
+ "--api-port",
+ dest="api_port",
+ help="API port (default: auto-allocate from 5000)",
+ )
+
+ # info command (local)
+ info_parser = img_subparsers.add_parser(
+ "info",
+ help="Show local image details",
+ )
+ info_parser.add_argument("name", help="Image name")
+
+ # clone command (local)
+ clone_parser = img_subparsers.add_parser(
+ "clone",
+ help="Clone a local image",
+ )
+ clone_parser.add_argument("source", help="Source image name")
+ clone_parser.add_argument("target", help="Target image name")
+ clone_parser.add_argument("--force", action="store_true", help="Overwrite if target exists")
+
+ # shell command (local)
+ shell_parser = img_subparsers.add_parser(
+ "shell",
+ help="Interactive shell into image (uses overlay by default)",
+ )
+ shell_parser.add_argument("name", help="Image name")
+ shell_parser.add_argument(
+ "--writable",
+ action="store_true",
+ help="Modify golden image directly (dangerous!)",
+ )
+ shell_parser.add_argument("--detach", "-d", action="store_true", help="Run in background")
+ shell_parser.add_argument(
+ "--vnc-port",
+ dest="vnc_port",
+ help="VNC port (default: auto-allocate from 8006)",
+ )
+ shell_parser.add_argument(
+ "--api-port",
+ dest="api_port",
+ help="API port (default: auto-allocate from 5000)",
+ )
+ shell_parser.add_argument("--memory", default="8G", help="Memory (default: 8G)")
+ shell_parser.add_argument("--cpus", default="8", help="CPU cores (default: 8)")
+ shell_parser.add_argument(
+ "--no-kvm",
+ action="store_true",
+ dest="no_kvm",
+ help="Disable KVM acceleration",
+ )
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute image command based on subcommand."""
+ from cua_cli.commands import local_image
+
+ cmd = getattr(args, "image_command", None)
+
+ if cmd in ("list", "ls"):
+ return cmd_list(args)
+ elif cmd == "push":
+ return cmd_push(args)
+ elif cmd == "pull":
+ return cmd_pull(args)
+ elif cmd == "delete":
+ return cmd_delete(args)
+ elif cmd == "create":
+ return local_image.cmd_create(args)
+ elif cmd == "info":
+ return local_image.cmd_info(args)
+ elif cmd == "clone":
+ return local_image.cmd_clone(args)
+ elif cmd == "shell":
+ return local_image.cmd_shell(args)
+ else:
+ print_error("Usage: cua image <command>")
+ print_info("Commands: list, push, pull, delete, create, info, clone, shell")
+ return 1
+
+
+def cmd_list(args: argparse.Namespace) -> int:
+ """List images."""
+ show_local = getattr(args, "local", False)
+ show_cloud = getattr(args, "cloud", False)
+
+ # If --local is set, delegate to local_image list
+ if show_local and not show_cloud:
+ from cua_cli.commands import local_image
+
+ return local_image.cmd_local_list(args)
+
+ # Default to cloud if neither specified, or if --cloud is set
+ if not show_local:
+ show_cloud = True
+
+ all_images = []
+
+ if show_cloud:
+ cloud_images = run_async(_list_cloud_images())
+ all_images.extend(cloud_images)
+
+ if show_local:
+ local_images = _list_local_images()
+ all_images.extend(local_images)
+
+ if getattr(args, "json", False):
+ print_json(all_images)
+ return 0
+
+ if not all_images:
+ print_info("No images found.")
+ return 0
+
+ columns = [
+ ("name", "NAME"),
+ ("type", "TYPE"),
+ ("tag", "TAG"),
+ ("size", "SIZE"),
+ ("status", "STATUS"),
+ ("created", "CREATED"),
+ ]
+
+ print_table(all_images, columns)
+ return 0
+
+
+async def _list_cloud_images() -> list[dict[str, Any]]:
+ """List cloud images."""
+ try:
+ client = CloudAPIClient()
+ images = await client.list_images()
+
+ result = []
+ for img in images:
+ versions = img.get("versions", [])
+ if versions:
+ for ver in versions:
+ result.append(
+ {
+ "name": img.get("name", ""),
+ "type": img.get("image_type", ""),
+ "tag": ver.get("tag", ""),
+ "size": format_bytes(ver.get("size_bytes", 0)),
+ "status": ver.get("status", ""),
+ "created": _format_date(ver.get("created_at", "")),
+ "source": "cloud",
+ }
+ )
+ else:
+ result.append(
+ {
+ "name": img.get("name", ""),
+ "type": img.get("image_type", ""),
+ "tag": "-",
+ "size": "-",
+ "status": "-",
+ "created": _format_date(img.get("created_at", "")),
+ "source": "cloud",
+ }
+ )
+ return result
+ except Exception as e:
+ print_error(f"Failed to list cloud images: {e}")
+ return []
+
+
+def _list_local_images() -> list[dict[str, Any]]:
+ """List local images."""
+ result = []
+
+ if not LOCAL_IMAGES_DIR.exists():
+ return result
+
+ for image_dir in LOCAL_IMAGES_DIR.iterdir():
+ if not image_dir.is_dir():
+ continue
+
+ name = image_dir.name
+ data_file = image_dir / "data.img"
+
+ if data_file.exists():
+ size = format_bytes(data_file.stat().st_size)
+ created = datetime.fromtimestamp(data_file.stat().st_mtime).strftime("%Y-%m-%d")
+ else:
+ size = "-"
+ created = "-"
+
+ result.append(
+ {
+ "name": name,
+ "type": "local",
+ "tag": "latest",
+ "size": size,
+ "status": "ready" if data_file.exists() else "incomplete",
+ "created": created,
+ "source": "local",
+ }
+ )
+
+ return result
+
+
+def _format_date(date_str: str) -> str:
+ """Format a date string."""
+ if not date_str:
+ return "-"
+ try:
+ dt = datetime.fromisoformat(date_str.replace("Z", "+00:00"))
+ return dt.strftime("%Y-%m-%d")
+ except Exception:
+ return date_str[:10] if len(date_str) >= 10 else date_str
+
+
+def cmd_push(args: argparse.Namespace) -> int:
+ """Push an image to cloud storage."""
+ name = args.name
+ tag = args.tag
+ image_type = args.type
+
+ # Determine file path
+ if args.file:
+ file_path = Path(args.file)
+ else:
+ # Look in local images directory
+ file_path = LOCAL_IMAGES_DIR / name / "data.img"
+
+ if not file_path.exists():
+ if args.file:
+ print_error(f"File not found: {file_path}")
+ else:
+ print_error(f"Image not found: {name}")
+ print_info(f"Looked in: {file_path}")
+ print_info("Use --file to specify a custom path")
+ return 1
+
+ size_bytes = file_path.stat().st_size
+ print_info(f"Pushing {file_path} ({format_bytes(size_bytes)})")
+
+ return run_async(_push_image(name, tag, image_type, file_path, size_bytes))
+
+
+async def _push_image(
+ name: str, tag: str, image_type: str, file_path: Path, size_bytes: int
+) -> int:
+ """Push an image using multi-part upload."""
+ from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn
+
+ # Calculate checksum
+ print_info("Calculating checksum...")
+ checksum = calculate_file_hash(file_path)
+ print_info(f"Checksum: {checksum}")
+
+ client = CloudAPIClient()
+
+ # Initiate upload
+ print_info("Initiating upload...")
+ status, data = await client.initiate_upload(
+ name=name,
+ tag=tag,
+ image_type=image_type,
+ size_bytes=size_bytes,
+ checksum_sha256=checksum,
+ )
+
+ if status == 401:
+ print_error("Unauthorized. Run 'cua auth login' again.")
+ return 1
+ if status == 409:
+ print_error(f"Image version already exists: {name}:{tag}")
+ return 1
+ if status not in (200, 201):
+ print_error(f"Failed to initiate upload: {data}")
+ return 1
+
+ upload_id = data.get("upload_id")
+ part_size = data.get("part_size", DEFAULT_PART_SIZE)
+ total_parts = data.get("total_parts", 1)
+
+ print_info(f"Upload session: {upload_id}")
+ print_info(f"Parts: {total_parts} x {format_bytes(part_size)}")
+
+ # Read file into memory (for simplicity - could stream for very large files)
+ file_data = file_path.read_bytes()
+
+ completed_parts = []
+
+ with Progress(
+ SpinnerColumn(),
+ TextColumn("[progress.description]{task.description}"),
+ BarColumn(),
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
+ ) as progress:
+ task = progress.add_task("Uploading...", total=total_parts)
+
+ for part_num in range(1, total_parts + 1):
+ # Get signed URL
+ status, url_data = await client.get_upload_part_url(name, upload_id, part_num)
+ if status != 200:
+ print_error(f"Failed to get upload URL for part {part_num}")
+ await client.abort_upload(name, upload_id)
+ return 1
+
+ upload_url = url_data.get("upload_url")
+
+ # Calculate part range
+ start = (part_num - 1) * part_size
+ end = min(start + part_size, size_bytes)
+ part_data = file_data[start:end]
+
+ # Upload part
+ async with aiohttp.ClientSession() as session:
+ async with session.put(
+ upload_url,
+ data=part_data,
+ headers={"Content-Type": "application/octet-stream"},
+ ) as resp:
+ if resp.status not in (200, 201):
+ print_error(f"Failed to upload part {part_num}: {resp.status}")
+ await client.abort_upload(name, upload_id)
+ return 1
+
+ etag = resp.headers.get("ETag", "")
+ completed_parts.append({"part_number": part_num, "etag": etag})
+
+ progress.update(task, advance=1)
+
+ # Complete upload
+ print_info("Completing upload...")
+ status, result = await client.complete_upload(name, upload_id, completed_parts)
+
+ if status not in (200, 201):
+ print_error(f"Failed to complete upload: {result}")
+ return 1
+
+ print_success(f"Push complete: {name}:{tag}")
+ if isinstance(result, dict):
+ print_info(f"Version ID: {result.get('version_id', 'N/A')}")
+ print_info(f"Status: {result.get('status', 'N/A')}")
+
+ return 0
+
+
+def cmd_pull(args: argparse.Namespace) -> int:
+ """Pull an image from cloud storage."""
+ name = args.name
+ tag = args.tag
+ output_path = args.output or f"{name}-{tag}.qcow2"
+
+ print_info(f"Pulling {name}:{tag}...")
+ return run_async(_pull_image(name, tag, Path(output_path)))
+
+
+async def _pull_image(name: str, tag: str, output_path: Path) -> int:
+ """Pull an image from cloud storage."""
+ from rich.progress import (
+ BarColumn,
+ DownloadColumn,
+ Progress,
+ SpinnerColumn,
+ TextColumn,
+ )
+
+ client = CloudAPIClient()
+
+ # Get download URL
+ status, data = await client.get_download_url(name, tag)
+
+ if status == 401:
+ print_error("Unauthorized. Run 'cua auth login' again.")
+ return 1
+ if status == 404:
+ print_error(f"Image not found: {name}:{tag}")
+ return 1
+ if status != 200:
+ print_error(f"Failed to get download URL: {data}")
+ return 1
+
+ download_url = data.get("download_url")
+ size_bytes = data.get("size_bytes", 0)
+ expected_checksum = data.get("checksum_sha256", "")
+
+ print_info(f"Size: {format_bytes(size_bytes)}")
+ print_info(f"Downloading to {output_path}...")
+
+ # Download file
+ async with aiohttp.ClientSession() as session:
+ async with session.get(download_url) as resp:
+ if resp.status != 200:
+ print_error(f"Download failed: {resp.status}")
+ return 1
+
+ with Progress(
+ SpinnerColumn(),
+ TextColumn("[progress.description]{task.description}"),
+ BarColumn(),
+ DownloadColumn(),
+ ) as progress:
+ task = progress.add_task("Downloading...", total=size_bytes)
+
+ with open(output_path, "wb") as f:
+ async for chunk in resp.content.iter_chunked(8192):
+ f.write(chunk)
+ progress.update(task, advance=len(chunk))
+
+ # Verify checksum
+ if expected_checksum:
+ print_info("Verifying checksum...")
+ downloaded_checksum = calculate_file_hash(output_path)
+
+ if downloaded_checksum != expected_checksum:
+ print_error("Checksum mismatch! Download may be corrupted.")
+ print_error(f"Expected: {expected_checksum}")
+ print_error(f"Got: {downloaded_checksum}")
+ return 1
+
+ print_success(f"Checksum verified: {downloaded_checksum}")
+
+ print_success(f"Pull complete: {output_path}")
+ return 0
+
+
+def cmd_delete(args: argparse.Namespace) -> int:
+ """Delete an image."""
+ # If --local flag, delegate to local_image delete
+ if getattr(args, "local", False):
+ from cua_cli.commands import local_image
+
+ return local_image.cmd_local_delete(args)
+
+ # Cloud delete
+ name = args.name
+ tag = args.tag
+
+ if not args.force:
+ print_info(f"This will delete {name}:{tag}. Use --force to confirm.")
+ return 1
+
+ print_info(f"Deleting {name}:{tag}...")
+ return run_async(_delete_image(name, tag))
+
+
+async def _delete_image(name: str, tag: str) -> int:
+ """Delete an image from cloud storage."""
+ client = CloudAPIClient()
+
+ status, data = await client.delete_image(name, tag)
+
+ if status == 401:
+ print_error("Unauthorized. Run 'cua auth login' again.")
+ return 1
+ if status == 404:
+ print_error(f"Image not found: {name}:{tag}")
+ return 1
+ if status not in (200, 202, 204):
+ print_error(f"Delete failed: {data}")
+ return 1
+
+ print_success(f"Deleted: {name}:{tag}")
+ return 0
diff --git a/libs/python/cua-cli/cua_cli/commands/local_image.py b/libs/python/cua-cli/cua_cli/commands/local_image.py
new file mode 100644
index 0000000000..7ce1ffcf6c
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/local_image.py
@@ -0,0 +1,993 @@
+"""Local image management commands for CUA CLI.
+
+Handles creating, cloning, and managing local VM/container images.
+These are stored base images used for running sandboxes. For QEMU-based
+platforms, images contain QCOW2 disk files. For Docker-based platforms,
+images reference Docker container images.
+
+Usage:
+ cua image create <platform> # Create image from platform
+ cua image info <name> # Show image details
+ cua image clone <src> <dest> # Clone an image
+ cua image shell <name> # Interactive shell (uses overlay by default)
+ cua image shell <name> --writable # Modify golden image directly (dangerous!)
+"""
+
+import argparse
+import json
+import shutil
+import subprocess
+import urllib.request
+from datetime import datetime
+from pathlib import Path
+from typing import Optional
+
+from cua_cli.commands.platform import (
+ PLATFORMS,
+ check_docker,
+ check_image_exists,
+ check_kvm,
+ check_lume,
+)
+from cua_cli.utils.docker import allocate_ports, create_overlay_copy
+from cua_cli.utils.output import print_error, print_info, print_success, print_warning
+from cua_cli.utils.paths import get_data_dir
+from cua_cli.utils.registry import (
+ auto_discover_images,
+ get_image_info,
+ load_image_registry,
+ register_image,
+ unregister_image,
+)
+
+# =============================================================================
+# Storage Paths
+# =============================================================================
+
+
+def get_images_base_path() -> Path:
+ """Get the base path for all images."""
+ return get_data_dir() / "images"
+
+
+def get_image_path(name: str) -> Path:
+ """Get the image path for a named image."""
+ image_path = get_images_base_path() / name
+ image_path.mkdir(parents=True, exist_ok=True)
+ return image_path
+
+
+def get_iso_path() -> Path:
+ """Get the default Windows ISO path."""
+ return get_data_dir() / "windows.iso"
+
+
+# =============================================================================
+# Helper Functions
+# =============================================================================
+
+WINDOWS_ISO_URL = "https://go.microsoft.com/fwlink/?linkid=2334167&clcid=0x409"
+
+
+def pull_docker_image(image_name: str) -> None:
+ """Pull Docker image from registry."""
+ print_info(f"Pulling image: {image_name}")
+ subprocess.run(["docker", "pull", image_name], check=True)
+
+
+def download_windows_iso(dest_path: Path) -> bool:
+ """Download Windows 11 ISO from Microsoft."""
+ print_info("Downloading Windows 11 Enterprise Evaluation ISO...")
+ print_info(f" URL: {WINDOWS_ISO_URL}")
+ print_info(f" Destination: {dest_path}")
+ print_warning("This is a large file (~6GB) and may take a while.")
+
+ try:
+ dest_path.parent.mkdir(parents=True, exist_ok=True)
+
+ def report_progress(block_num, block_size, total_size):
+ downloaded = block_num * block_size
+ if total_size > 0:
+ percent = min(100, downloaded * 100 / total_size)
+ downloaded_mb = downloaded / (1024 * 1024)
+ total_mb = total_size / (1024 * 1024)
+ print(
+ f"\r Progress: {percent:.1f}% ({downloaded_mb:.1f}/{total_mb:.1f} MB)",
+ end="",
+ flush=True,
+ )
+ else:
+ downloaded_mb = downloaded / (1024 * 1024)
+ print(f"\r Downloaded: {downloaded_mb:.1f} MB", end="", flush=True)
+
+ urllib.request.urlretrieve(WINDOWS_ISO_URL, dest_path, reporthook=report_progress)
+ print()
+ print_success("Download complete!")
+ return True
+ except Exception as e:
+ print()
+ print_error(f"Download failed: {e}")
+ return False
+
+
+def format_size(size_bytes: int) -> str:
+ """Format size in human-readable format."""
+ for unit in ["B", "KB", "MB", "GB", "TB"]:
+ if size_bytes < 1024.0:
+ return f"{size_bytes:.1f} {unit}"
+ size_bytes /= 1024.0
+ return f"{size_bytes:.1f} PB"
+
+
+# =============================================================================
+# Commands
+# =============================================================================
+
+
+def cmd_local_list(args: argparse.Namespace) -> int:
+ """List all local images."""
+ auto_discover_images()
+
+ registry = load_image_registry()
+ output_format = getattr(args, "format", "table")
+ filter_platform = getattr(args, "platform", None)
+
+ if output_format == "json":
+ if filter_platform:
+ filtered = {k: v for k, v in registry.items() if v.get("platform") == filter_platform}
+ print(json.dumps(filtered, indent=2))
+ else:
+ print(json.dumps(registry, indent=2))
+ return 0
+
+ print("\nLocal Images")
+ print("=" * 85)
+
+ if not registry:
+ print_info("No local images found.")
+ print_info("Create one with:")
+ print_info(" cua image create linux-docker")
+ print_info(" cua image create windows-qemu --download-iso")
+ return 0
+
+ print(f"\n{'NAME':<20} {'PLATFORM':<15} {'SIZE':<10} {'CREATED':<12} {'STATUS':<10}")
+ print("-" * 85)
+
+ for name, info in sorted(registry.items()):
+ platform = info.get("platform", "unknown")
+
+ if filter_platform and platform != filter_platform:
+ continue
+
+ path = Path(info.get("path", ""))
+ created_at = info.get("created_at", "")
+ if created_at:
+ try:
+ dt = datetime.fromisoformat(created_at)
+ created = dt.strftime("%Y-%m-%d")
+ except Exception:
+ created = created_at[:10] if len(created_at) >= 10 else created_at
+ else:
+ created = "-"
+
+ if path.exists() and str(path) != "/dev/null":
+ try:
+ total_size = sum(f.stat().st_size for f in path.rglob("*") if f.is_file())
+ size = format_size(total_size)
+ except Exception:
+ size = "-"
+ else:
+ size = "-"
+
+ config = PLATFORMS.get(platform, {})
+ marker = config.get("image_marker")
+ if marker and path.exists():
+ marker_path = path / marker
+ status = "ready" if marker_path.exists() else "missing"
+ elif platform == "linux-docker":
+ docker_img = info.get("docker_image", "")
+ status = "ready" if docker_img and check_image_exists(docker_img) else "missing"
+ else:
+ status = "ready" if path.exists() or str(path) == "/dev/null" else "missing"
+
+ if info.get("parent"):
+ status = f"ready (from {info['parent']})" if status == "ready" else status
+
+ status_color = "\033[92m" if "ready" in status else "\033[91m"
+ reset = "\033[0m"
+
+ print(f"{name:<20} {platform:<15} {size:<10} {created:<12} {status_color}{status}{reset}")
+
+ print("\n" + "=" * 85)
+ print("\nCommands:")
+ print(" cua image info <name> # Show detailed info")
+ print(" cua image clone <source> <target> # Clone an image")
+ print(" cua image create <platform> # Create new image")
+ print()
+ return 0
+
+
+def cmd_info(args: argparse.Namespace) -> int:
+ """Show detailed information about an image."""
+ name = args.name
+ info = get_image_info(name)
+
+ if not info:
+ print_error(f"Image '{name}' not found.")
+ print_info("Available images:")
+ for n in load_image_registry().keys():
+ print_info(f" - {n}")
+ return 1
+
+ platform = info.get("platform", "unknown")
+ path = Path(info.get("path", ""))
+
+ print(f"\nImage: {name}")
+ print("=" * 60)
+
+ print(f"\nPlatform: {platform}")
+ print(f"Path: {path}")
+
+ if path.exists() and str(path) != "/dev/null":
+ try:
+ total_size = sum(f.stat().st_size for f in path.rglob("*") if f.is_file())
+ print(f"Size: {format_size(total_size)}")
+ except Exception:
+ pass
+
+ created_at = info.get("created_at", "")
+ if created_at:
+ try:
+ dt = datetime.fromisoformat(created_at)
+ print(f"Created: {dt.strftime('%Y-%m-%d %H:%M:%S')}")
+ except Exception:
+ print(f"Created: {created_at}")
+
+ if info.get("parent"):
+ print(f"Parent: {info['parent']}")
+
+ if info.get("docker_image"):
+ print(f"Docker: {info['docker_image']}")
+
+ config = PLATFORMS.get(platform, {})
+ marker = config.get("image_marker")
+ if marker:
+ marker_path = path / marker if path.exists() else None
+ marker_ok = marker_path and marker_path.exists()
+ print(f"Marker: {marker} {'✓' if marker_ok else '✗'}")
+
+ if info.get("description"):
+ print(f"Description: {info['description']}")
+
+ if info.get("apps_installed"):
+ apps = ", ".join(info["apps_installed"])
+ print(f"Apps: {apps}")
+
+ if info.get("tags"):
+ tags = ", ".join(info["tags"])
+ print(f"Tags: {tags}")
+
+ if info.get("config"):
+ print("\nConfig:")
+ for key, value in info["config"].items():
+ print(f" {key.capitalize():<10} {value}")
+
+ print()
+ return 0
+
+
+def cmd_create(args: argparse.Namespace) -> int:
+ """Create an image from a platform."""
+ platform_name = args.platform
+ config = PLATFORMS.get(platform_name)
+
+ if not config:
+ print_error(f"Unknown platform '{platform_name}'")
+ print_info(f"Available platforms: {', '.join(PLATFORMS.keys())}")
+ return 1
+
+ if platform_name == "linux-docker":
+ return _create_linux_docker(args, config)
+ elif platform_name == "linux-qemu":
+ return _create_linux_qemu(args, config)
+ elif platform_name == "windows-qemu":
+ return _create_windows_qemu(args, config)
+ elif platform_name == "android-qemu":
+ return _create_android_qemu(args, config)
+ elif platform_name == "macos-lume":
+ return _create_macos_lume(args, config)
+ else:
+ print_error(f"Image creation not implemented for platform: {platform_name}")
+ return 1
+
+
+def _create_linux_docker(args: argparse.Namespace, config: dict) -> int:
+ """Create linux-docker image (pull container)."""
+ if not check_docker():
+ print_error("Docker is not running. Please start Docker and try again.")
+ return 1
+
+ image_name = getattr(args, "docker_image", None) or config["image"]
+ name = getattr(args, "name", None) or "linux-docker"
+
+ if getattr(args, "skip_pull", False):
+ if not check_image_exists(image_name):
+ print_error("--skip-pull is set but image not found locally.")
+ return 1
+ print_info(f"Skipping pull (using local image: {image_name})")
+ else:
+ print_info(f"Pulling latest Linux Docker image: {image_name}")
+ try:
+ pull_docker_image(image_name)
+ except Exception as e:
+ print_error(f"Failed to pull image: {e}")
+ return 1
+
+ register_image(
+ name=name,
+ platform="linux-docker",
+ path=Path("/dev/null"),
+ description="Linux GUI container",
+ docker_image=image_name,
+ config={"memory": "4G", "cpus": "2"},
+ tags=["default", "webtop"],
+ )
+
+ print_success(f"Linux Docker image '{name}' ready!")
+ print_info(f"Next: cua image shell {name}")
+ return 0
+
+
+def _create_linux_qemu(args: argparse.Namespace, config: dict) -> int:
+ """Create linux-qemu image."""
+ if not check_docker():
+ print_error("Docker is not running. Please start Docker and try again.")
+ return 1
+
+ name = getattr(args, "name", None) or "linux-qemu"
+ image_path = get_image_path(name)
+
+ marker_path = image_path / config["image_marker"]
+ if marker_path.exists() and not getattr(args, "force", False):
+ print_info(f"Linux QEMU image '{name}' already exists at: {image_path}")
+ print_info("Use --force to recreate it.")
+ print_info(f"Next: cua image shell {name}")
+ return 0
+
+ if getattr(args, "iso", None):
+ iso_path = Path(args.iso).resolve()
+ if not iso_path.exists():
+ print_error(f"ISO file not found: {iso_path}")
+ return 1
+ else:
+ print_info("Linux QEMU Setup")
+ print_info("[Coming soon] For now, please:")
+ print_info(" 1. Download an Ubuntu/Fedora ISO manually")
+ print_info(" 2. Run: cua image create linux-qemu --iso /path/to/linux.iso")
+ return 1
+
+ return 1
+
+
+def _create_windows_qemu(args: argparse.Namespace, config: dict) -> int:
+ """Create windows-qemu image."""
+ import sys
+
+ if not check_docker():
+ print_error("Docker is not running. Please start Docker and try again.")
+ return 1
+
+ docker_image = getattr(args, "docker_image", None) or config["image"]
+ name = getattr(args, "name", None) or "windows-qemu"
+ image_path = get_image_path(name)
+
+ marker_path = image_path / config["image_marker"]
+ if marker_path.exists() and not getattr(args, "force", False):
+ print_info(f"Windows QEMU image '{name}' already exists at: {image_path}")
+ print_info("Use --force to recreate it.")
+ print_info(f"Next: cua image shell {name}")
+ return 0
+
+ iso_path: Optional[Path] = None
+ if getattr(args, "iso", None):
+ iso_path = Path(args.iso).resolve()
+ if not iso_path.exists():
+ print_error(f"ISO file not found: {iso_path}")
+ return 1
+ else:
+ default_iso = get_iso_path()
+ if default_iso.exists():
+ iso_path = default_iso
+ print_info(f"Using existing ISO: {iso_path}")
+ elif getattr(args, "download_iso", False):
+ if not download_windows_iso(default_iso):
+ return 1
+ iso_path = default_iso
+ else:
+ print_info("Windows ISO Required")
+ print_info("Options:")
+ print_info(" 1. Download automatically (~6GB):")
+ print_info(" cua image create windows-qemu --download-iso")
+ print_info(" 2. Provide your own ISO:")
+ print_info(" cua image create windows-qemu --iso /path/to/windows.iso")
+ return 1
+
+ if getattr(args, "skip_pull", False):
+ if not check_image_exists(docker_image):
+ print_error("--skip-pull is set but image not found locally.")
+ return 1
+ print_info(f"Skipping pull (using local image: {docker_image})")
+ else:
+ pull_docker_image(docker_image)
+
+ print_info(f"Creating Windows QEMU Image: {name}")
+ print_info(f"Image path: {image_path}")
+
+ user_vnc = getattr(args, "vnc_port", None)
+ user_api = getattr(args, "api_port", None)
+
+ if user_vnc and user_api:
+ vnc_port = int(user_vnc)
+ api_port = int(user_api)
+ else:
+ vnc_port, api_port = allocate_ports(
+ vnc_default=int(user_vnc) if user_vnc else 8006,
+ api_default=int(user_api) if user_api else 5000,
+ )
+ if not user_vnc or not user_api:
+ print_info(f"Auto-allocated ports: VNC={vnc_port}, API={api_port}")
+
+ print_info(f"Monitor progress at: http://localhost:{vnc_port}")
+
+ setup_container = "cua-setup-windows"
+ check_result = subprocess.run(
+ ["docker", "ps", "-q", "-f", f"name={setup_container}"], capture_output=True, text=True
+ )
+ if check_result.stdout.strip():
+ print_error(f"Setup container '{setup_container}' is already running.")
+ print_info(f"Use 'docker stop {setup_container}' to stop it first.")
+ return 1
+
+ detach_mode = getattr(args, "detach", False)
+
+ docker_cmd = [
+ "docker",
+ "run",
+ "-t",
+ "--rm",
+ "-p",
+ f"{vnc_port}:8006",
+ "-p",
+ f"{api_port}:5000",
+ "--name",
+ setup_container,
+ "--platform",
+ "linux/amd64",
+ "-v",
+ f"{image_path}:/storage",
+ "-v",
+ f"{iso_path}:/custom.iso:ro",
+ "--cap-add",
+ "NET_ADMIN",
+ "--stop-timeout",
+ "120",
+ ]
+
+ if detach_mode:
+ docker_cmd.insert(2, "-d")
+ elif sys.stdin.isatty():
+ docker_cmd.insert(2, "-i")
+
+ if check_kvm() and not getattr(args, "no_kvm", False):
+ docker_cmd.extend(["--device=/dev/kvm"])
+ else:
+ docker_cmd.extend(["-e", "KVM=N"])
+ print_warning("Running without KVM (slower)")
+
+ memory = getattr(args, "memory", "8G")
+ disk = getattr(args, "disk", "64G")
+ cpus = getattr(args, "cpus", "8")
+ docker_cmd.extend(["-e", f"RAM_SIZE={memory}"])
+ docker_cmd.extend(["-e", f"CPU_CORES={cpus}"])
+
+ winarena_apps = getattr(args, "winarena_apps", False)
+ if winarena_apps:
+ print_info("Will install WinArena benchmark apps (Chrome, LibreOffice, VLC, etc.)")
+ docker_cmd.extend(["-e", "INSTALL_WINARENA_APPS=true"])
+
+ config_file = image_path / "install_config.json"
+ config_data = {"INSTALL_WINARENA_APPS": True}
+ config_file.write_text(json.dumps(config_data))
+ docker_cmd.extend(["-v", f"{config_file}:/oem/install_config.json:ro"])
+ print_info(f" Config mounted: {config_file} -> /oem/install_config.json")
+ else:
+ docker_cmd.extend(["-e", "INSTALL_WINARENA_APPS=false"])
+
+ docker_cmd.append(docker_image)
+
+ try:
+ if detach_mode:
+ result = subprocess.run(docker_cmd, capture_output=True, text=True, check=False)
+ if result.returncode != 0:
+ print_error(f"Failed to start container: {result.stderr}")
+ return 1
+
+ container_id = result.stdout.strip()[:12]
+ print_success(f"Setup started in background (ID: {container_id})")
+ print_info(f" Browser: http://localhost:{vnc_port}")
+ print_info(f" Logs: docker logs -f {setup_container}")
+ return 0
+ else:
+ result = subprocess.run(docker_cmd, check=False)
+
+ if marker_path.exists():
+ description = "Windows 11 VM"
+ apps_installed = None
+ if winarena_apps:
+ description += " with WinArena apps"
+ apps_installed = ["chrome", "libreoffice", "vlc", "vscode", "7zip"]
+
+ register_image(
+ name=name,
+ platform="windows-qemu",
+ path=image_path,
+ description=description,
+ docker_image=docker_image,
+ config={"memory": memory, "cpus": cpus, "disk": disk},
+ tags=["winarena"] if winarena_apps else ["default"],
+ apps_installed=apps_installed,
+ )
+
+ print_success(f"Windows QEMU image '{name}' created!")
+ print_info(f" Path: {image_path}")
+ print_info(f"Next: cua image shell {name}")
+ return 0
+ else:
+ print_error("Image was not created.")
+ return 1
+ except KeyboardInterrupt:
+ print_warning("Interrupted.")
+ return 1
+
+
+def _create_android_qemu(args: argparse.Namespace, config: dict) -> int:
+ """Create android-qemu image."""
+ name = getattr(args, "name", None) or "android-qemu"
+ android_version = getattr(args, "version", "14")
+
+ print_info("Android QEMU Setup")
+ print_info(f" Android version: {android_version}")
+ print_info(f" Image name: {name}")
+ print_info("[Coming soon] This will be available in a future release.")
+ return 1
+
+
+def _create_macos_lume(args: argparse.Namespace, config: dict) -> int:
+ """Create macos-lume image."""
+ import platform as sys_platform
+
+ if sys_platform.system() != "Darwin":
+ print_error("macOS image creation can only run on macOS hosts (Apple Silicon required).")
+ return 1
+
+ if not check_lume():
+ print_error("Lume is not installed.")
+ print_info("Install Lume:")
+ print_info(
+ ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"'
+ )
+ return 1
+
+ name = getattr(args, "name", None) or "macos-lume"
+ macos_version = getattr(args, "version", "sonoma")
+
+ print_success("Lume is installed")
+ print_info(f"To create a macOS VM ({macos_version}):")
+ print_info(f" lume create --name {name} --os {macos_version}")
+ print_info("To start:")
+ print_info(f" cua image shell {name}")
+ return 0
+
+
+def cmd_local_delete(args: argparse.Namespace) -> int:
+ """Delete a local image."""
+ name = args.name
+ force = getattr(args, "force", False)
+
+ info = get_image_info(name)
+ if not info:
+ print_error(f"Image '{name}' not found.")
+ return 1
+
+ platform = info.get("platform", "unknown")
+ path = Path(info.get("path", ""))
+
+ print_info(f"Removing image: {name}")
+ print_info(f" Platform: {platform}")
+ print_info(f" Path: {path}")
+
+ if not force:
+ if platform != "linux-docker" and path.exists() and str(path) != "/dev/null":
+ try:
+ total_size = sum(f.stat().st_size for f in path.rglob("*") if f.is_file())
+ print_info(f" Size: {format_size(total_size)}")
+ except Exception:
+ pass
+
+ print_warning("This will:")
+ print_warning(" - Remove the registry entry")
+ if platform != "linux-docker" and path.exists() and str(path) != "/dev/null":
+ print_warning(" - Delete all files in the image directory")
+
+ response = input("\nContinue? [y/N] ").strip().lower()
+ if response != "y":
+ print_info("Cancelled.")
+ return 0
+
+ unregister_image(name)
+ print_success("Removed from registry")
+
+ if platform != "linux-docker" and path.exists() and str(path) != "/dev/null":
+ try:
+ shutil.rmtree(path)
+ print_success(f"Deleted files: {path}")
+ except Exception as e:
+ print_error(f"Failed to delete files: {e}")
+ return 1
+
+ print_success(f"Image '{name}' removed")
+ return 0
+
+
+def cmd_clone(args: argparse.Namespace) -> int:
+ """Clone an image."""
+ source = args.source
+ target = args.target
+
+ source_info = get_image_info(source)
+ if not source_info:
+ print_error(f"Source image '{source}' not found.")
+ return 1
+
+ if get_image_info(target):
+ if not getattr(args, "force", False):
+ print_error(f"Target image '{target}' already exists.")
+ print_info("Use --force to overwrite.")
+ return 1
+
+ source_platform = source_info.get("platform", "unknown")
+ source_path = Path(source_info.get("path", ""))
+
+ if source_platform == "linux-docker":
+ print_info(f"Cloning '{source}' to '{target}'...")
+ register_image(
+ name=target,
+ platform=source_platform,
+ path=source_path,
+ description=f"Clone of {source}",
+ docker_image=source_info.get("docker_image"),
+ config=source_info.get("config"),
+ parent=source,
+ tags=(source_info.get("tags", []) or []) + ["cloned"],
+ )
+ print_success(f"Created '{target}' (reference to same container image)")
+ return 0
+
+ if not source_path.exists():
+ print_error(f"Source path does not exist: {source_path}")
+ return 1
+
+ target_path = get_image_path(target)
+
+ print_info(f"Cloning '{source}' to '{target}'...")
+ print_info(f" Source: {source_path}")
+ print_info(f" Target: {target_path}")
+
+ try:
+ total_size = sum(f.stat().st_size for f in source_path.rglob("*") if f.is_file())
+ print_info(f" Size: {format_size(total_size)}")
+ except Exception:
+ pass
+
+ print_info("Copying files (this may take a while for large images)...")
+
+ try:
+ if target_path.exists():
+ shutil.rmtree(target_path)
+
+ shutil.copytree(source_path, target_path)
+
+ register_image(
+ name=target,
+ platform=source_platform,
+ path=target_path,
+ description=f"Clone of {source}",
+ docker_image=source_info.get("docker_image"),
+ config=source_info.get("config"),
+ parent=source,
+ tags=(source_info.get("tags", []) or []) + ["cloned"],
+ apps_installed=source_info.get("apps_installed"),
+ )
+
+ print_success(f"Successfully cloned '{source}' to '{target}'")
+ print_info("Next:")
+ print_info(f" cua image shell {target} # Start shell (protected)")
+ print_info(f" cua image shell {target} --writable # Start shell (modify image)")
+ print_info(f" cua image info {target} # View details")
+ return 0
+
+ except Exception as e:
+ print_error(f"Failed to clone: {e}")
+ return 1
+
+
+def cmd_shell(args: argparse.Namespace) -> int:
+ """Start an interactive shell into an image.
+
+ By default, uses an overlay to protect the golden image.
+ With --writable, modifies the golden image directly (dangerous!).
+ """
+ name = args.name
+ writable = getattr(args, "writable", False)
+
+ info = get_image_info(name)
+ if not info:
+ print_error(f"Image '{name}' not found.")
+ print_info("Available images:")
+ for n in load_image_registry().keys():
+ print_info(f" - {n}")
+ return 1
+
+ platform = info.get("platform", "unknown")
+
+ config = PLATFORMS.get(platform, {})
+ if not config:
+ print_error(f"Unknown platform '{platform}'")
+ return 1
+
+ if not check_docker():
+ print_error("Docker is not running. Please start Docker and try again.")
+ return 1
+
+ if platform == "linux-docker":
+ return _shell_linux_docker(args, info, name)
+
+ return _shell_qemu(args, info, name, writable)
+
+
+def _shell_linux_docker(args: argparse.Namespace, info: dict, name: str) -> int:
+ """Start interactive shell for linux-docker image."""
+ import sys
+
+ docker_image = info.get("docker_image")
+ if not docker_image:
+ print_error(f"No Docker image configured for '{name}'")
+ return 1
+
+ user_vnc = getattr(args, "vnc_port", None)
+ user_api = getattr(args, "api_port", None)
+
+ if user_vnc and user_api:
+ vnc_port = int(user_vnc)
+ api_port = int(user_api)
+ else:
+ vnc_port, api_port = allocate_ports(
+ vnc_default=int(user_vnc) if user_vnc else 6901,
+ api_default=int(user_api) if user_api else 8000,
+ )
+ if not user_vnc or not user_api:
+ print_info(f"Auto-allocated ports: VNC={vnc_port}, API={api_port}")
+
+ detach_mode = getattr(args, "detach", False)
+
+ container_name = f"cua-shell-{name}"
+
+ check_result = subprocess.run(
+ ["docker", "ps", "-q", "-f", f"name={container_name}"], capture_output=True, text=True
+ )
+ if check_result.stdout.strip():
+ print_info(f"Shell for '{name}' is already running.")
+ print_info(f" VNC: http://localhost:{vnc_port}")
+ print_info(f" Stop: docker stop {container_name}")
+ return 0
+
+ print_info(f"Starting interactive shell for '{name}'...")
+
+ docker_cmd = [
+ "docker",
+ "run",
+ "-t",
+ "--rm",
+ "-p",
+ f"{vnc_port}:6901",
+ "-p",
+ f"{api_port}:8000",
+ "--name",
+ container_name,
+ docker_image,
+ ]
+
+ if detach_mode:
+ docker_cmd.insert(2, "-d")
+ elif sys.stdin.isatty():
+ docker_cmd.insert(2, "-i")
+
+ print_info(f" VNC: http://localhost:{vnc_port}")
+
+ if detach_mode:
+ print_info(f" Stop: docker stop {container_name}")
+ else:
+ print_info("Press Ctrl+C to stop.")
+
+ try:
+ if detach_mode:
+ result = subprocess.run(docker_cmd, capture_output=True, text=True, check=False)
+ if result.returncode != 0:
+ print_error(f"Failed to start container: {result.stderr}")
+ return 1
+ container_id = result.stdout.strip()[:12]
+ print_success(f"Shell started in background (ID: {container_id})")
+ return 0
+ else:
+ subprocess.run(docker_cmd, check=False)
+ return 0
+ except KeyboardInterrupt:
+ print_info("Stopped.")
+ return 0
+
+
+def _shell_qemu(args: argparse.Namespace, info: dict, name: str, writable: bool) -> int:
+ """Start interactive shell for QEMU-based image."""
+ import sys
+
+ platform = info.get("platform")
+ image_path = Path(info.get("path", ""))
+ docker_image = info.get("docker_image") or PLATFORMS.get(platform, {}).get("image")
+
+ if not image_path.exists():
+ print_error(f"Image path does not exist: {image_path}")
+ return 1
+
+ config = PLATFORMS.get(platform, {})
+ marker = config.get("image_marker")
+ if marker:
+ marker_path = image_path / marker
+ if not marker_path.exists():
+ print_error(f"Image '{name}' is not ready (marker missing: {marker})")
+ print_info(f"Recreate with: cua image create {platform}")
+ return 1
+
+ user_vnc = getattr(args, "vnc_port", None)
+ user_api = getattr(args, "api_port", None)
+
+ if user_vnc and user_api:
+ vnc_port = int(user_vnc)
+ api_port = int(user_api)
+ else:
+ vnc_port, api_port = allocate_ports(
+ vnc_default=int(user_vnc) if user_vnc else 8006,
+ api_default=int(user_api) if user_api else 5000,
+ )
+ if not user_vnc or not user_api:
+ print_info(f"Auto-allocated ports: VNC={vnc_port}, API={api_port}")
+
+ memory = getattr(args, "memory", "8G")
+ cpus = getattr(args, "cpus", "8")
+ detach_mode = getattr(args, "detach", False)
+
+ container_name = f"cua-shell-{name}"
+
+ check_result = subprocess.run(
+ ["docker", "ps", "-q", "-f", f"name={container_name}"], capture_output=True, text=True
+ )
+ if check_result.stdout.strip():
+ print_info(f"Shell for '{name}' is already running.")
+ print_info(f" VNC: http://localhost:{vnc_port}")
+ print_info(f" API: http://localhost:{api_port}")
+ print_info(f" Stop: docker stop {container_name}")
+ return 0
+
+ volumes = []
+ overlay_path = None
+
+ if writable:
+ print_warning("WARNING: WRITABLE MODE")
+ print_warning("You are about to modify the golden image directly.")
+ print_warning("Any changes will be PERMANENT and affect all future runs.")
+ print_info(f" Image: {name}")
+ print_info(f" Path: {image_path}")
+
+ if sys.stdin.isatty():
+ response = input("\nAre you sure? Type 'yes' to continue: ").strip().lower()
+ if response != "yes":
+ print_info("Cancelled.")
+ return 0
+ else:
+ print_error("Writable mode requires interactive terminal for confirmation.")
+ print_info("Use --detach if you want to run without a TTY.")
+ return 1
+
+ volumes.append(f"{image_path}:/storage")
+ print_info("Writable mode: Changes will persist to golden image")
+ else:
+ overlay_path = get_data_dir() / "overlays" / f"shell-{name}"
+
+ print_info("Protected mode: Copying golden image to overlay...")
+ try:
+ create_overlay_copy(image_path, overlay_path, verbose=True)
+ except Exception as e:
+ print_error(f"Failed to create overlay: {e}")
+ return 1
+
+ volumes.append(f"{overlay_path}:/storage")
+ print_success("Overlay ready (changes will be discarded on exit)")
+
+ print_info(f"Starting {platform} shell for '{name}'...")
+
+ docker_cmd = [
+ "docker",
+ "run",
+ "-t",
+ "--rm",
+ "-p",
+ f"{vnc_port}:8006",
+ "-p",
+ f"{api_port}:5000",
+ "--name",
+ container_name,
+ "--platform",
+ "linux/amd64",
+ "--cap-add",
+ "NET_ADMIN",
+ "--stop-timeout",
+ "120",
+ ]
+
+ if detach_mode:
+ docker_cmd.insert(2, "-d")
+ elif sys.stdin.isatty():
+ docker_cmd.insert(2, "-i")
+
+ for vol in volumes:
+ docker_cmd.extend(["-v", vol])
+
+ if check_kvm() and not getattr(args, "no_kvm", False):
+ docker_cmd.extend(["--device=/dev/kvm"])
+ else:
+ docker_cmd.extend(["-e", "KVM=N"])
+ print_warning("Running without KVM (slower)")
+
+ docker_cmd.extend(["-e", f"RAM_SIZE={memory}"])
+ docker_cmd.extend(["-e", f"CPU_CORES={cpus}"])
+ docker_cmd.append(docker_image)
+
+ print_info(f" VNC: http://localhost:{vnc_port}")
+ print_info(f" API: http://localhost:{api_port}")
+
+ if detach_mode:
+ print_info(f" Stop: docker stop {container_name}")
+ else:
+ print_info("Press Ctrl+C to stop.")
+
+ try:
+ if detach_mode:
+ result = subprocess.run(docker_cmd, capture_output=True, text=True, check=False)
+ if result.returncode != 0:
+ print_error(f"Failed to start container: {result.stderr}")
+ return 1
+ container_id = result.stdout.strip()[:12]
+ print_success(f"Shell started in background (ID: {container_id})")
+ return 0
+ else:
+ subprocess.run(docker_cmd, check=False)
+ return 0
+ except KeyboardInterrupt:
+ print_info("Stopped.")
+ return 0
+ finally:
+ if not detach_mode and overlay_path and overlay_path.exists() and not writable:
+ print_info(f"Cleaning up overlay: {overlay_path}")
+ try:
+ shutil.rmtree(overlay_path)
+ except Exception as e:
+ print_warning(f"Failed to clean up overlay: {e}")
diff --git a/libs/python/cua-cli/cua_cli/commands/mcp.py b/libs/python/cua-cli/cua_cli/commands/mcp.py
new file mode 100644
index 0000000000..3cf300a69d
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/mcp.py
@@ -0,0 +1,844 @@
+"""MCP server command for CUA CLI.
+
+Provides a Model Context Protocol server that exposes CUA functionality
+to AI assistants like Claude.
+"""
+
+import argparse
+import json
+import logging
+import os
+import sys
+from enum import Enum
+from typing import TYPE_CHECKING, Any, Optional
+
+if TYPE_CHECKING:
+ from mcp.server.fastmcp import FastMCP
+
+# Set up logging to stderr
+logging.basicConfig(
+ level=logging.INFO,
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
+ stream=sys.stderr,
+)
+logger = logging.getLogger("cua-mcp")
+
+
+class Permission(Enum):
+ """MCP permission types."""
+
+ # Sandbox management
+ SANDBOX_LIST = "sandbox:list"
+ SANDBOX_CREATE = "sandbox:create"
+ SANDBOX_DELETE = "sandbox:delete"
+ SANDBOX_START = "sandbox:start"
+ SANDBOX_STOP = "sandbox:stop"
+ SANDBOX_RESTART = "sandbox:restart"
+ SANDBOX_SUSPEND = "sandbox:suspend"
+ SANDBOX_GET = "sandbox:get"
+ SANDBOX_VNC = "sandbox:vnc"
+
+ # Computer control
+ COMPUTER_SCREENSHOT = "computer:screenshot"
+ COMPUTER_CLICK = "computer:click"
+ COMPUTER_TYPE = "computer:type"
+ COMPUTER_KEY = "computer:key"
+ COMPUTER_SCROLL = "computer:scroll"
+ COMPUTER_DRAG = "computer:drag"
+ COMPUTER_HOTKEY = "computer:hotkey"
+ COMPUTER_CLIPBOARD = "computer:clipboard"
+ COMPUTER_FILE = "computer:file"
+ COMPUTER_SHELL = "computer:shell"
+ COMPUTER_WINDOW = "computer:window"
+
+ # Skills
+ SKILLS_LIST = "skills:list"
+ SKILLS_READ = "skills:read"
+ SKILLS_RECORD = "skills:record"
+ SKILLS_DELETE = "skills:delete"
+
+
+# Permission groups for convenience
+PERMISSION_GROUPS = {
+ "sandbox:all": [
+ Permission.SANDBOX_LIST,
+ Permission.SANDBOX_CREATE,
+ Permission.SANDBOX_DELETE,
+ Permission.SANDBOX_START,
+ Permission.SANDBOX_STOP,
+ Permission.SANDBOX_RESTART,
+ Permission.SANDBOX_SUSPEND,
+ Permission.SANDBOX_GET,
+ Permission.SANDBOX_VNC,
+ ],
+ "sandbox:readonly": [
+ Permission.SANDBOX_LIST,
+ Permission.SANDBOX_GET,
+ ],
+ "computer:all": [
+ Permission.COMPUTER_SCREENSHOT,
+ Permission.COMPUTER_CLICK,
+ Permission.COMPUTER_TYPE,
+ Permission.COMPUTER_KEY,
+ Permission.COMPUTER_SCROLL,
+ Permission.COMPUTER_DRAG,
+ Permission.COMPUTER_HOTKEY,
+ Permission.COMPUTER_CLIPBOARD,
+ Permission.COMPUTER_FILE,
+ Permission.COMPUTER_SHELL,
+ Permission.COMPUTER_WINDOW,
+ ],
+ "computer:readonly": [
+ Permission.COMPUTER_SCREENSHOT,
+ ],
+ "skills:all": [
+ Permission.SKILLS_LIST,
+ Permission.SKILLS_READ,
+ Permission.SKILLS_RECORD,
+ Permission.SKILLS_DELETE,
+ ],
+ "skills:readonly": [
+ Permission.SKILLS_LIST,
+ Permission.SKILLS_READ,
+ ],
+ "all": list(Permission),
+}
+
+
+def parse_permissions(permissions_str: str) -> set[Permission]:
+ """Parse permissions from a comma-separated string."""
+ if not permissions_str:
+ return set()
+
+ permissions = set()
+ for perm in permissions_str.split(","):
+ perm = perm.strip()
+ if not perm:
+ continue
+
+ # Check if it's a group
+ if perm in PERMISSION_GROUPS:
+ permissions.update(PERMISSION_GROUPS[perm])
+ else:
+ # Try to match individual permission
+ try:
+ permissions.add(Permission(perm))
+ except ValueError:
+ logger.warning(f"Unknown permission: {perm}")
+
+ return permissions
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the serve-mcp command."""
+ mcp_parser = subparsers.add_parser(
+ "serve-mcp",
+ help="Start MCP server for AI assistants",
+ description="Start a Model Context Protocol server that exposes CUA functionality",
+ )
+
+ mcp_parser.add_argument(
+ "--permissions",
+ type=str,
+ default="",
+ help="Comma-separated list of permissions (default: from CUA_MCP_PERMISSIONS env var)",
+ )
+
+ mcp_parser.add_argument(
+ "--sandbox",
+ type=str,
+ default="",
+ help="Default sandbox name for computer commands (default: from CUA_SANDBOX env var)",
+ )
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute the serve-mcp command."""
+ try:
+ from mcp.server.fastmcp import FastMCP # noqa: F401
+ except ImportError:
+ print("MCP support not installed. Run: pip install cua-cli[mcp]", file=sys.stderr)
+ return 1
+
+ # Parse permissions from args or env var
+ permissions_str = args.permissions or os.environ.get("CUA_MCP_PERMISSIONS", "")
+ permissions = parse_permissions(permissions_str)
+
+ if not permissions:
+ # Default to all permissions if none specified
+ logger.info("No permissions specified, granting all permissions")
+ permissions = set(Permission)
+ else:
+ logger.info(f"Enabled permissions: {[p.value for p in permissions]}")
+
+ # Get default sandbox
+ default_sandbox = args.sandbox or os.environ.get("CUA_SANDBOX", "")
+
+ # Create and run the MCP server
+ import anyio
+
+ anyio.run(lambda: _run_mcp_server(permissions, default_sandbox))
+ return 0
+
+
+async def _run_mcp_server(permissions: set[Permission], default_sandbox: str) -> None:
+ """Create and run the MCP server."""
+ from mcp.server.fastmcp import FastMCP
+
+ server = FastMCP(name="cua")
+
+ # Register tools based on permissions
+ await _register_sandbox_tools(server, permissions)
+ await _register_computer_tools(server, permissions, default_sandbox)
+ await _register_skills_tools(server, permissions)
+
+ logger.info("Starting CUA MCP server...")
+ await server.run_stdio_async()
+
+
+async def _register_sandbox_tools(server: "FastMCP", permissions: set[Permission]) -> None:
+ """Register sandbox management tools."""
+ from mcp.server.fastmcp import Context
+
+ if Permission.SANDBOX_LIST in permissions:
+
+ @server.tool()
+ async def sandbox_list(ctx: Context) -> str:
+ """List all cloud sandboxes."""
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ vms = await provider.list_vms()
+ return json.dumps(
+ [
+ {
+ "name": vm.name,
+ "status": vm.status,
+ "os_type": vm.os_type,
+ "created_at": vm.created_at,
+ }
+ for vm in vms
+ ],
+ indent=2,
+ )
+
+ if Permission.SANDBOX_CREATE in permissions:
+
+ @server.tool()
+ async def sandbox_create(
+ ctx: Context,
+ os_type: str = "linux",
+ size: str = "medium",
+ region: str = "north-america",
+ ) -> str:
+ """Create a new cloud sandbox.
+
+ Args:
+ os_type: Operating system (linux, macos, windows)
+ size: VM size (small, medium, large, xlarge)
+ region: Region (north-america, europe, asia)
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ vm = await provider.create_vm(os_type=os_type, size=size, region=region)
+ return json.dumps(
+ {
+ "name": vm.name,
+ "status": vm.status,
+ "os_type": vm.os_type,
+ "message": f"Created sandbox: {vm.name}",
+ },
+ indent=2,
+ )
+
+ if Permission.SANDBOX_GET in permissions:
+
+ @server.tool()
+ async def sandbox_get(ctx: Context, name: str) -> str:
+ """Get details for a specific sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ vm = await provider.get_vm(name)
+ if not vm:
+ return json.dumps({"error": f"Sandbox not found: {name}"})
+ return json.dumps(
+ {
+ "name": vm.name,
+ "status": vm.status,
+ "os_type": vm.os_type,
+ "size": getattr(vm, "size", None),
+ "region": getattr(vm, "region", None),
+ "created_at": vm.created_at,
+ "vnc_url": getattr(vm, "vnc_url", None),
+ "server_url": getattr(vm, "server_url", None),
+ },
+ indent=2,
+ )
+
+ if Permission.SANDBOX_START in permissions:
+
+ @server.tool()
+ async def sandbox_start(ctx: Context, name: str) -> str:
+ """Start a stopped sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ await provider.run_vm(name)
+ return json.dumps({"success": True, "message": f"Started sandbox: {name}"})
+
+ if Permission.SANDBOX_STOP in permissions:
+
+ @server.tool()
+ async def sandbox_stop(ctx: Context, name: str) -> str:
+ """Stop a running sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ await provider.stop_vm(name)
+ return json.dumps({"success": True, "message": f"Stopped sandbox: {name}"})
+
+ if Permission.SANDBOX_RESTART in permissions:
+
+ @server.tool()
+ async def sandbox_restart(ctx: Context, name: str) -> str:
+ """Restart a sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ await provider.restart_vm(name)
+ return json.dumps({"success": True, "message": f"Restarted sandbox: {name}"})
+
+ if Permission.SANDBOX_SUSPEND in permissions:
+
+ @server.tool()
+ async def sandbox_suspend(ctx: Context, name: str) -> str:
+ """Suspend a running sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ await provider.suspend_vm(name)
+ return json.dumps({"success": True, "message": f"Suspended sandbox: {name}"})
+
+ if Permission.SANDBOX_DELETE in permissions:
+
+ @server.tool()
+ async def sandbox_delete(ctx: Context, name: str) -> str:
+ """Delete a sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ await provider.delete_vm(name)
+ return json.dumps({"success": True, "message": f"Deleted sandbox: {name}"})
+
+ if Permission.SANDBOX_VNC in permissions:
+
+ @server.tool()
+ async def sandbox_vnc(ctx: Context, name: str) -> str:
+ """Get VNC URL for a sandbox.
+
+ Args:
+ name: Sandbox name
+ """
+ from computer.providers import VMProviderFactory, VMProviderType
+ from cua_cli.auth.store import require_api_key
+
+ api_key = require_api_key()
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ vm = await provider.get_vm(name)
+ if not vm:
+ return json.dumps({"error": f"Sandbox not found: {name}"})
+ vnc_url = getattr(vm, "vnc_url", None)
+ if not vnc_url:
+ return json.dumps({"error": "VNC URL not available"})
+ return json.dumps({"vnc_url": vnc_url})
+
+
+async def _register_computer_tools(
+ server: "FastMCP",
+ permissions: set[Permission],
+ default_sandbox: str,
+) -> None:
+ """Register computer control tools that proxy to computer-server."""
+ import aiohttp
+ from cua_cli.auth.store import get_api_key
+ from mcp.server.fastmcp import Context
+ from mcp.server.fastmcp.utilities.types import Image
+
+ async def _get_server_url(sandbox_name: str) -> Optional[str]:
+ """Get the computer-server URL for a sandbox."""
+ from computer.providers import VMProviderFactory, VMProviderType
+
+ name = sandbox_name or default_sandbox
+ if not name:
+ raise ValueError("No sandbox specified. Use --sandbox or set CUA_SANDBOX env var")
+
+ api_key = get_api_key()
+ if not api_key:
+ raise ValueError("Not authenticated. Run 'cua auth login' first")
+
+ provider = VMProviderFactory.create_provider(VMProviderType.CLOUD, api_key=api_key)
+ async with provider:
+ vm = await provider.get_vm(name)
+ if not vm:
+ raise ValueError(f"Sandbox not found: {name}")
+ server_url = getattr(vm, "server_url", None)
+ if not server_url:
+ raise ValueError(f"Sandbox {name} is not running or has no server URL")
+ return server_url
+
+ async def _send_command(sandbox_name: str, command: str, params: dict) -> dict:
+ """Send a command to the computer-server."""
+ server_url = await _get_server_url(sandbox_name)
+ api_key = get_api_key()
+
+ headers = {
+ "Content-Type": "application/json",
+ "X-API-Key": api_key,
+ "X-Container-Name": sandbox_name or default_sandbox,
+ }
+
+ async with aiohttp.ClientSession() as session:
+ async with session.post(
+ f"{server_url}/cmd",
+ json={"command": command, "params": params},
+ headers=headers,
+ ) as resp:
+ # Read SSE response
+ text = await resp.text()
+ # Parse SSE data lines
+ for line in text.split("\n"):
+ if line.startswith("data: "):
+ return json.loads(line[6:])
+ return {"success": False, "error": "No response from server"}
+
+ if Permission.COMPUTER_SCREENSHOT in permissions:
+
+ @server.tool()
+ async def computer_screenshot(ctx: Context, sandbox: str = "") -> Any:
+ """Take a screenshot of the sandbox screen.
+
+ Args:
+ sandbox: Sandbox name (optional, uses default if not specified)
+ """
+ result = await _send_command(sandbox, "screenshot", {})
+ if result.get("success") and result.get("image_data"):
+ import base64
+
+ return Image(format="png", data=base64.b64decode(result["image_data"]))
+ return json.dumps(result)
+
+ if Permission.COMPUTER_CLICK in permissions:
+
+ @server.tool()
+ async def computer_click(
+ ctx: Context,
+ x: int,
+ y: int,
+ button: str = "left",
+ sandbox: str = "",
+ ) -> str:
+ """Click at coordinates on the screen.
+
+ Args:
+ x: X coordinate
+ y: Y coordinate
+ button: Mouse button (left, right, middle)
+ sandbox: Sandbox name (optional)
+ """
+ if button == "left":
+ result = await _send_command(sandbox, "left_click", {"x": x, "y": y})
+ elif button == "right":
+ result = await _send_command(sandbox, "right_click", {"x": x, "y": y})
+ else:
+ result = await _send_command(sandbox, "left_click", {"x": x, "y": y})
+ return json.dumps(result)
+
+ @server.tool()
+ async def computer_double_click(
+ ctx: Context,
+ x: int,
+ y: int,
+ sandbox: str = "",
+ ) -> str:
+ """Double-click at coordinates on the screen.
+
+ Args:
+ x: X coordinate
+ y: Y coordinate
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "double_click", {"x": x, "y": y})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_TYPE in permissions:
+
+ @server.tool()
+ async def computer_type(ctx: Context, text: str, sandbox: str = "") -> str:
+ """Type text on the keyboard.
+
+ Args:
+ text: Text to type
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "type_text", {"text": text})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_KEY in permissions:
+
+ @server.tool()
+ async def computer_key(ctx: Context, key: str, sandbox: str = "") -> str:
+ """Press a key on the keyboard.
+
+ Args:
+ key: Key to press (e.g., "enter", "tab", "escape")
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "press_key", {"key": key})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_HOTKEY in permissions:
+
+ @server.tool()
+ async def computer_hotkey(ctx: Context, keys: str, sandbox: str = "") -> str:
+ """Press a keyboard shortcut.
+
+ Args:
+ keys: Keys to press (e.g., "cmd+c", "ctrl+shift+s")
+ sandbox: Sandbox name (optional)
+ """
+ key_list = keys.replace("-", "+").split("+")
+ result = await _send_command(sandbox, "hotkey", {"keys": key_list})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_SCROLL in permissions:
+
+ @server.tool()
+ async def computer_scroll(
+ ctx: Context,
+ direction: str = "down",
+ amount: int = 3,
+ sandbox: str = "",
+ ) -> str:
+ """Scroll the screen.
+
+ Args:
+ direction: Scroll direction (up, down, left, right)
+ amount: Number of scroll clicks
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(
+ sandbox, "scroll_direction", {"direction": direction, "clicks": amount}
+ )
+ return json.dumps(result)
+
+ if Permission.COMPUTER_DRAG in permissions:
+
+ @server.tool()
+ async def computer_drag(
+ ctx: Context,
+ start_x: int,
+ start_y: int,
+ end_x: int,
+ end_y: int,
+ sandbox: str = "",
+ ) -> str:
+ """Drag from one point to another.
+
+ Args:
+ start_x: Starting X coordinate
+ start_y: Starting Y coordinate
+ end_x: Ending X coordinate
+ end_y: Ending Y coordinate
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(
+ sandbox,
+ "drag_to",
+ {"start_x": start_x, "start_y": start_y, "end_x": end_x, "end_y": end_y},
+ )
+ return json.dumps(result)
+
+ if Permission.COMPUTER_CLIPBOARD in permissions:
+
+ @server.tool()
+ async def computer_clipboard_get(ctx: Context, sandbox: str = "") -> str:
+ """Get clipboard contents.
+
+ Args:
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "copy_to_clipboard", {})
+ return json.dumps(result)
+
+ @server.tool()
+ async def computer_clipboard_set(ctx: Context, text: str, sandbox: str = "") -> str:
+ """Set clipboard contents.
+
+ Args:
+ text: Text to copy to clipboard
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "set_clipboard", {"text": text})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_FILE in permissions:
+
+ @server.tool()
+ async def computer_file_read(ctx: Context, path: str, sandbox: str = "") -> str:
+ """Read a file from the sandbox.
+
+ Args:
+ path: Path to the file
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "read_text", {"path": path})
+ return json.dumps(result)
+
+ @server.tool()
+ async def computer_file_write(
+ ctx: Context, path: str, content: str, sandbox: str = ""
+ ) -> str:
+ """Write a file to the sandbox.
+
+ Args:
+ path: Path to the file
+ content: File content
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "write_text", {"path": path, "content": content})
+ return json.dumps(result)
+
+ @server.tool()
+ async def computer_file_list(ctx: Context, path: str = ".", sandbox: str = "") -> str:
+ """List files in a directory.
+
+ Args:
+ path: Directory path
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "list_dir", {"path": path})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_SHELL in permissions:
+
+ @server.tool()
+ async def computer_shell(ctx: Context, command: str, sandbox: str = "") -> str:
+ """Run a shell command in the sandbox.
+
+ Args:
+ command: Shell command to run
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "run_command", {"command": command})
+ return json.dumps(result)
+
+ if Permission.COMPUTER_WINDOW in permissions:
+
+ @server.tool()
+ async def computer_window_list(ctx: Context, sandbox: str = "") -> str:
+ """List open windows.
+
+ Args:
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "get_application_windows", {})
+ return json.dumps(result)
+
+ @server.tool()
+ async def computer_window_open(ctx: Context, path: str, sandbox: str = "") -> str:
+ """Open a file or URL.
+
+ Args:
+ path: Path to file or URL to open
+ sandbox: Sandbox name (optional)
+ """
+ result = await _send_command(sandbox, "open", {"path": path})
+ return json.dumps(result)
+
+
+async def _register_skills_tools(server: "FastMCP", permissions: set[Permission]) -> None:
+ """Register skills management tools."""
+ from pathlib import Path
+
+ from mcp.server.fastmcp import Context
+
+ SKILLS_DIR = Path.home() / ".cua" / "skills"
+
+ if Permission.SKILLS_LIST in permissions:
+
+ @server.tool()
+ async def skills_list(ctx: Context) -> str:
+ """List all recorded skills."""
+ if not SKILLS_DIR.exists():
+ return json.dumps([])
+
+ skills = []
+ for skill_dir in SKILLS_DIR.iterdir():
+ if skill_dir.is_dir() and (skill_dir / "SKILL.md").exists():
+ skill_file = skill_dir / "SKILL.md"
+ content = skill_file.read_text()
+
+ # Extract title from markdown
+ title = skill_dir.name
+ for line in content.split("\n"):
+ if line.startswith("# "):
+ title = line[2:].strip()
+ break
+
+ # Count trajectory steps
+ trajectory_dir = skill_dir / "trajectory"
+ step_count = (
+ len(list(trajectory_dir.glob("step_*.md")))
+ if trajectory_dir.exists()
+ else 0
+ )
+
+ skills.append(
+ {
+ "name": skill_dir.name,
+ "title": title,
+ "steps": step_count,
+ }
+ )
+
+ return json.dumps(skills, indent=2)
+
+ if Permission.SKILLS_READ in permissions:
+
+ @server.tool()
+ async def skills_read(ctx: Context, name: str) -> str:
+ """Read a skill's content.
+
+ Args:
+ name: Skill name
+ """
+ skill_dir = SKILLS_DIR / name
+ skill_file = skill_dir / "SKILL.md"
+
+ if not skill_file.exists():
+ return json.dumps({"error": f"Skill not found: {name}"})
+
+ content = skill_file.read_text()
+
+ # Also include trajectory steps
+ trajectory_dir = skill_dir / "trajectory"
+ steps = []
+ if trajectory_dir.exists():
+ for step_file in sorted(trajectory_dir.glob("step_*.md")):
+ steps.append(
+ {
+ "file": step_file.name,
+ "content": step_file.read_text(),
+ }
+ )
+
+ return json.dumps(
+ {
+ "name": name,
+ "content": content,
+ "steps": steps,
+ },
+ indent=2,
+ )
+
+ if Permission.SKILLS_DELETE in permissions:
+
+ @server.tool()
+ async def skills_delete(ctx: Context, name: str) -> str:
+ """Delete a skill.
+
+ Args:
+ name: Skill name
+ """
+ import shutil
+
+ skill_dir = SKILLS_DIR / name
+
+ if not skill_dir.exists():
+ return json.dumps({"error": f"Skill not found: {name}"})
+
+ shutil.rmtree(skill_dir)
+ return json.dumps({"success": True, "message": f"Deleted skill: {name}"})
+
+ if Permission.SKILLS_RECORD in permissions:
+
+ @server.tool()
+ async def skills_record(
+ ctx: Context,
+ name: str,
+ sandbox: str = "",
+ port: int = 8765,
+ ) -> str:
+ """Start recording a skill.
+
+ This starts a WebSocket server that receives screen recordings.
+ Use the CUA browser extension or screen recorder to send frames.
+
+ Args:
+ name: Name for the skill
+ sandbox: Sandbox name (optional)
+ port: WebSocket port (default: 8765)
+ """
+ return json.dumps(
+ {
+ "message": f"To record skill '{name}', use 'cua skills record {name}' from the terminal",
+ "instructions": [
+ f"1. Run: cua skills record {name}",
+ "2. Use the CUA browser extension or screen recorder",
+ "3. Perform the actions you want to record",
+ "4. Stop the recording when done",
+ ],
+ },
+ indent=2,
+ )
diff --git a/libs/python/cua-cli/cua_cli/commands/platform.py b/libs/python/cua-cli/cua_cli/commands/platform.py
new file mode 100644
index 0000000000..c6c158aaf9
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/platform.py
@@ -0,0 +1,309 @@
+"""Platform information commands.
+
+Platforms are read-only built-in configurations for different environment types.
+Each platform defines the Docker image, ports, and requirements for running
+a specific type of sandbox (linux-docker, windows-qemu, etc.).
+
+Usage:
+ cua platform list # Show available platforms
+ cua platform info <type> # Show platform details
+"""
+
+import argparse
+import json
+import os
+import platform as sys_platform
+import subprocess
+from typing import Any, Dict, Optional
+
+from cua_cli.utils.output import print_error, print_info
+
+# =============================================================================
+# Platform Configurations
+# =============================================================================
+
+PLATFORMS: Dict[str, Dict[str, Any]] = {
+ "linux-docker": {
+ "image": "trycua/cua-xfce:latest",
+ "description": "Linux GUI container (no KVM required)",
+ "internal_vnc_port": 6901,
+ "internal_api_port": 8000,
+ "requires_kvm": False,
+ "image_marker": None,
+ "os_type": "linux",
+ "boot_timeout": 60,
+ "use_overlays": False,
+ },
+ "linux-qemu": {
+ "image": "trycua/cua-qemu-linux:latest",
+ "description": "Linux VM with QEMU/KVM (OSWorld)",
+ "internal_vnc_port": 8006,
+ "internal_api_port": 5000,
+ "requires_kvm": True,
+ "image_marker": "linux.boot",
+ "os_type": "linux",
+ "boot_timeout": 120,
+ "use_overlays": True,
+ },
+ "windows-qemu": {
+ "image": "trycua/cua-qemu-windows:latest",
+ "description": "Windows VM with QEMU/KVM (Windows Arena)",
+ "internal_vnc_port": 8006,
+ "internal_api_port": 5000,
+ "requires_kvm": True,
+ "image_marker": "windows.boot",
+ "os_type": "windows",
+ "boot_timeout": 180,
+ "use_overlays": True,
+ },
+ "android-qemu": {
+ "image": "trycua/cua-qemu-android:latest",
+ "description": "Android VM with QEMU/KVM",
+ "internal_vnc_port": 8006,
+ "internal_api_port": 5000,
+ "requires_kvm": True,
+ "image_marker": "android.boot",
+ "os_type": "android",
+ "boot_timeout": 120,
+ "use_overlays": True,
+ },
+ "macos-lume": {
+ "image": None,
+ "description": "macOS VM with Apple Virtualization (Lume, Apple Silicon only)",
+ "internal_vnc_port": None,
+ "internal_api_port": 5000,
+ "requires_kvm": False,
+ "image_marker": None,
+ "os_type": "macos",
+ "boot_timeout": 120,
+ "use_overlays": False,
+ "requires_apple_silicon": True,
+ },
+}
+
+
+# =============================================================================
+# Helper Functions
+# =============================================================================
+
+
+def check_docker() -> bool:
+ """Check if Docker is running."""
+ try:
+ result = subprocess.run(["docker", "info"], capture_output=True, timeout=10)
+ return result.returncode == 0
+ except Exception:
+ return False
+
+
+def check_kvm() -> bool:
+ """Check if KVM is available.
+
+ On Linux: checks /dev/kvm directly
+ On Windows/macOS with Docker: checks if KVM is available inside Docker's VM
+ """
+ if sys_platform.system() == "Linux":
+ return os.path.exists("/dev/kvm")
+
+ try:
+ result = subprocess.run(
+ ["docker", "run", "--rm", "--device=/dev/kvm", "alpine", "test", "-e", "/dev/kvm"],
+ capture_output=True,
+ timeout=30,
+ )
+ return result.returncode == 0
+ except Exception:
+ return False
+
+
+def check_lume() -> bool:
+ """Check if Lume is installed."""
+ try:
+ result = subprocess.run(["lume", "--version"], capture_output=True, timeout=10)
+ return result.returncode == 0
+ except Exception:
+ return False
+
+
+def check_image_exists(image_name: str) -> bool:
+ """Check if a Docker image exists locally."""
+ try:
+ result = subprocess.run(
+ ["docker", "images", "-q", image_name], capture_output=True, text=True, timeout=10
+ )
+ return bool(result.stdout.strip())
+ except Exception:
+ return False
+
+
+def get_platform_config(platform_name: str) -> Optional[Dict[str, Any]]:
+ """Get platform configuration by name."""
+ return PLATFORMS.get(platform_name)
+
+
+# =============================================================================
+# Commands
+# =============================================================================
+
+
+def cmd_list(args: argparse.Namespace) -> int:
+ """List all available platforms."""
+ output_format = getattr(args, "format", "table")
+
+ if output_format == "json":
+ print(json.dumps(PLATFORMS, indent=2))
+ return 0
+
+ print("\nPlatforms")
+ print("=" * 80)
+
+ docker_ok = check_docker()
+ kvm_ok = check_kvm()
+ lume_ok = check_lume() if sys_platform.system() == "Darwin" else False
+ is_macos = sys_platform.system() == "Darwin"
+ is_linux = sys_platform.system() == "Linux"
+
+ print("\nSystem:")
+ print(f" Docker: {'✓ Running' if docker_ok else '✗ Not running'}")
+ if is_linux:
+ print(f" KVM: {'✓ Available' if kvm_ok else '○ Not available (QEMU will be slower)'}")
+ if is_macos:
+ print(f" Lume: {'✓ Installed' if lume_ok else '○ Not installed'}")
+
+ print("\n" + "-" * 80)
+ print(f"\n{'PLATFORM':<18} {'DESCRIPTION':<45} {'STATUS':<12}")
+ print("-" * 80)
+
+ for name, config in PLATFORMS.items():
+ description = config.get("description", "")[:44]
+
+ if name == "macos-lume":
+ if not is_macos:
+ status = "macOS only"
+ status_color = "\033[90m"
+ elif not lume_ok:
+ status = "needs Lume"
+ status_color = "\033[33m"
+ else:
+ status = "ready"
+ status_color = "\033[92m"
+ elif config.get("requires_kvm") and not kvm_ok:
+ if is_linux:
+ status = "no KVM"
+ status_color = "\033[33m"
+ else:
+ status = "Linux only"
+ status_color = "\033[90m"
+ elif not docker_ok:
+ status = "no Docker"
+ status_color = "\033[91m"
+ else:
+ status = "ready"
+ status_color = "\033[92m"
+
+ reset = "\033[0m"
+ print(f"{name:<18} {description:<45} {status_color}{status:<12}{reset}")
+
+ print("\n" + "=" * 80)
+ print("\nCommands:")
+ print(" cua platform info <type> # Show platform details")
+ print(" cua image create <platform> # Create image from platform")
+ print()
+
+ return 0
+
+
+def cmd_info(args: argparse.Namespace) -> int:
+ """Show detailed information about a platform."""
+ name = args.platform
+ config = get_platform_config(name)
+
+ if not config:
+ print_error(f"Unknown platform '{name}'")
+ print_info(f"Available platforms: {', '.join(PLATFORMS.keys())}")
+ return 1
+
+ print(f"\nPlatform: {name}")
+ print("=" * 60)
+
+ print(f"\nDescription: {config.get('description', '-')}")
+ print(f"OS Type: {config.get('os_type', '-')}")
+
+ if config.get("image"):
+ print(f"Docker Image: {config['image']}")
+ if check_docker():
+ exists = check_image_exists(config["image"])
+ print(f"Image Pulled: {'✓ Yes' if exists else '✗ No'}")
+
+ print("\nPorts:")
+ if config.get("internal_api_port"):
+ print(f" API Port (internal): {config['internal_api_port']}")
+ if config.get("internal_vnc_port"):
+ print(f" VNC Port (internal): {config['internal_vnc_port']}")
+
+ print("\nRequirements:")
+ if config.get("requires_kvm"):
+ kvm_ok = check_kvm()
+ print(f" KVM: Required {'(✓ available)' if kvm_ok else '(✗ not available)'}")
+ else:
+ print(" KVM: Not required")
+
+ if config.get("requires_apple_silicon"):
+ is_macos = sys_platform.system() == "Darwin"
+ print(
+ f" Apple Silicon: Required {'(✓ running on macOS)' if is_macos else '(✗ not on macOS)'}"
+ )
+
+ if config.get("image_marker"):
+ print(f"\nImage Marker: {config['image_marker']}")
+ print(" (Marker file created in image directory when image is ready)")
+
+ print("\nConfiguration:")
+ print(f" Boot Timeout: {config.get('boot_timeout', 60)}s")
+ print(f" Use Overlays: {'Yes' if config.get('use_overlays') else 'No'}")
+
+ print("\n" + "=" * 60)
+ print("\nTo create an image from this platform:")
+ print(f" cua image create {name}")
+ print()
+
+ return 0
+
+
+# =============================================================================
+# CLI Registration
+# =============================================================================
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the platform command with the main CLI parser."""
+ platform_parser = subparsers.add_parser(
+ "platform", help="Show available platform configurations"
+ )
+ platform_subparsers = platform_parser.add_subparsers(
+ dest="platform_command", help="Platform command"
+ )
+
+ # platform list
+ list_parser = platform_subparsers.add_parser("list", help="List all available platforms")
+ list_parser.add_argument(
+ "--format", choices=["table", "json"], default="table", help="Output format"
+ )
+
+ # platform info
+ info_parser = platform_subparsers.add_parser("info", help="Show platform details")
+ info_parser.add_argument("platform", help="Platform name (e.g., linux-docker, windows-qemu)")
+
+ platform_parser.set_defaults(platform_command="list")
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute the platform command."""
+ cmd = getattr(args, "platform_command", "list")
+
+ if cmd == "list":
+ return cmd_list(args)
+ elif cmd == "info":
+ return cmd_info(args)
+ else:
+ return cmd_list(args)
diff --git a/libs/python/cua-cli/cua_cli/commands/sandbox.py b/libs/python/cua-cli/cua_cli/commands/sandbox.py
new file mode 100644
index 0000000000..a9e7b7b723
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/sandbox.py
@@ -0,0 +1,541 @@
+"""Sandbox management commands for CUA CLI."""
+
+import argparse
+import os
+import webbrowser
+from typing import Any, Optional
+from urllib.parse import quote
+
+import aiohttp
+from cua_cli.auth.store import require_api_key
+from cua_cli.utils.async_utils import run_async
+from cua_cli.utils.output import (
+ print_error,
+ print_info,
+ print_json,
+ print_success,
+ print_table,
+)
+
+DEFAULT_API_BASE = "https://api.cua.ai"
+
+
+def _get_api_base() -> str:
+ """Get the API base URL."""
+ return os.environ.get("CUA_API_BASE", DEFAULT_API_BASE).rstrip("/")
+
+
+async def _api_request(
+ method: str,
+ path: str,
+ api_key: str,
+ json: Optional[dict] = None,
+ timeout: int = 30,
+) -> tuple[int, Any]:
+ """Make an HTTP request to the CUA API."""
+ url = f"{_get_api_base()}{path}"
+ headers = {
+ "Authorization": f"Bearer {api_key}",
+ "Accept": "application/json",
+ }
+
+ if json is not None:
+ headers["Content-Type"] = "application/json"
+
+ async with aiohttp.ClientSession() as session:
+ timeout_obj = aiohttp.ClientTimeout(total=timeout)
+ async with session.request(
+ method, url, headers=headers, json=json, timeout=timeout_obj
+ ) as resp:
+ try:
+ data = await resp.json(content_type=None)
+ except Exception:
+ data = await resp.text()
+ return resp.status, data
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the sandbox command and subcommands."""
+ # Register both 'sandbox' and 'sb' as aliases
+ for cmd_name in ("sandbox", "sb"):
+ sb_parser = subparsers.add_parser(
+ cmd_name,
+ help="Sandbox management commands",
+ description="Manage cloud sandboxes (virtual machines)",
+ )
+
+ sb_subparsers = sb_parser.add_subparsers(
+ dest="sandbox_command",
+ help="Sandbox command",
+ )
+
+ # list command
+ list_parser = sb_subparsers.add_parser(
+ "list",
+ aliases=["ls", "ps"],
+ help="List all sandboxes",
+ )
+ list_parser.add_argument(
+ "--json",
+ action="store_true",
+ help="Output as JSON",
+ )
+ list_parser.add_argument(
+ "--show-passwords",
+ action="store_true",
+ help="Show sandbox passwords in output",
+ )
+
+ # create command
+ create_parser = sb_subparsers.add_parser(
+ "create",
+ help="Create a new sandbox",
+ )
+ create_parser.add_argument(
+ "--os",
+ required=True,
+ choices=["linux", "windows", "macos"],
+ help="Operating system",
+ )
+ create_parser.add_argument(
+ "--size",
+ required=True,
+ choices=["small", "medium", "large"],
+ help="Sandbox size",
+ )
+ create_parser.add_argument(
+ "--region",
+ required=True,
+ choices=["north-america", "europe", "asia-pacific", "south-america"],
+ help="Region for the sandbox",
+ )
+ create_parser.add_argument(
+ "--json",
+ action="store_true",
+ help="Output as JSON",
+ )
+
+ # get command
+ get_parser = sb_subparsers.add_parser(
+ "get",
+ help="Get sandbox details",
+ )
+ get_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+ get_parser.add_argument(
+ "--json",
+ action="store_true",
+ help="Output as JSON",
+ )
+ get_parser.add_argument(
+ "--show-passwords",
+ action="store_true",
+ help="Show sandbox password",
+ )
+ get_parser.add_argument(
+ "--show-vnc-url",
+ action="store_true",
+ help="Show VNC URL",
+ )
+
+ # delete command
+ delete_parser = sb_subparsers.add_parser(
+ "delete",
+ help="Delete a sandbox",
+ )
+ delete_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+ # start command
+ start_parser = sb_subparsers.add_parser(
+ "start",
+ help="Start a stopped sandbox",
+ )
+ start_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+ # stop command
+ stop_parser = sb_subparsers.add_parser(
+ "stop",
+ help="Stop a running sandbox",
+ )
+ stop_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+ # restart command
+ restart_parser = sb_subparsers.add_parser(
+ "restart",
+ help="Restart a sandbox",
+ )
+ restart_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+ # suspend command
+ suspend_parser = sb_subparsers.add_parser(
+ "suspend",
+ help="Suspend a sandbox (preserves memory state)",
+ )
+ suspend_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+ # vnc command
+ vnc_parser = sb_subparsers.add_parser(
+ "vnc",
+ aliases=["open"],
+ help="Open sandbox in browser (VNC)",
+ )
+ vnc_parser.add_argument(
+ "name",
+ help="Sandbox name",
+ )
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute sandbox command based on subcommand."""
+ cmd = getattr(args, "sandbox_command", None)
+
+ if cmd in ("list", "ls", "ps"):
+ return cmd_list(args)
+ elif cmd == "create":
+ return cmd_create(args)
+ elif cmd == "get":
+ return cmd_get(args)
+ elif cmd == "delete":
+ return cmd_delete(args)
+ elif cmd == "start":
+ return cmd_start(args)
+ elif cmd == "stop":
+ return cmd_stop(args)
+ elif cmd == "restart":
+ return cmd_restart(args)
+ elif cmd == "suspend":
+ return cmd_suspend(args)
+ elif cmd in ("vnc", "open"):
+ return cmd_vnc(args)
+ else:
+ print_error("Usage: cua sandbox <command>")
+ print_info("Commands: list, create, get, delete, start, stop, restart, suspend, vnc")
+ return 1
+
+
+def _get_provider():
+ """Get a configured CloudProvider instance."""
+ from computer.providers.cloud.provider import CloudProvider
+
+ api_key = require_api_key()
+ return CloudProvider(api_key=api_key)
+
+
+def cmd_list(args: argparse.Namespace) -> int:
+ """List all sandboxes."""
+
+ async def _list():
+ async with _get_provider() as provider:
+ return await provider.list_vms()
+
+ vms = run_async(_list())
+
+ if args.json:
+ print_json(vms)
+ return 0
+
+ if not vms:
+ print_info("No sandboxes found.")
+ return 0
+
+ # Format for table display
+ columns = [
+ ("name", "NAME"),
+ ("status", "STATUS"),
+ ("host", "HOST"),
+ ]
+
+ if args.show_passwords:
+ columns.append(("password", "PASSWORD"))
+
+ print_table(vms, columns)
+ return 0
+
+
+def cmd_create(args: argparse.Namespace) -> int:
+ """Create a new sandbox."""
+ api_key = require_api_key()
+
+ async def _create():
+ body = {
+ "os": args.os,
+ "configuration": args.size,
+ "region": args.region,
+ }
+ status_code, data = await _api_request("POST", "/v1/vms", api_key, json=body)
+
+ if status_code == 200:
+ # Sandbox ready immediately
+ return {
+ "status": data.get("status", "ready") if isinstance(data, dict) else "ready",
+ "name": data.get("name") if isinstance(data, dict) else None,
+ "password": data.get("password") if isinstance(data, dict) else None,
+ "host": data.get("host") if isinstance(data, dict) else None,
+ }
+ elif status_code == 202:
+ # Provisioning in progress
+ return {
+ "status": (
+ data.get("status", "provisioning") if isinstance(data, dict) else "provisioning"
+ ),
+ "name": data.get("name") if isinstance(data, dict) else None,
+ "job_id": data.get("job_id") if isinstance(data, dict) else None,
+ }
+ elif status_code == 401:
+ return {"status": "unauthorized"}
+ elif status_code == 400:
+ return {"status": "invalid_request", "message": str(data)}
+ else:
+ return {"status": "error", "message": str(data)}
+
+ result = run_async(_create())
+
+ if args.json:
+ print_json(result)
+ return 0 if result.get("status") not in ("error", "unauthorized", "invalid_request") else 1
+
+ status = result.get("status")
+
+ if status in ("error", "unauthorized", "invalid_request"):
+ print_error(f"Failed to create sandbox: {result.get('message', status)}")
+ return 1
+
+ if status == "provisioning":
+ print_info(f"Sandbox '{result.get('name')}' is being provisioned...")
+ print_info("Use 'cua sb list' to check status.")
+ else:
+ print_success(f"Sandbox '{result.get('name')}' created!")
+ if result.get("password"):
+ print_info(f"Password: {result.get('password')}")
+ if result.get("host"):
+ print_info(f"Host: {result.get('host')}")
+
+ return 0
+
+
+def cmd_get(args: argparse.Namespace) -> int:
+ """Get sandbox details."""
+
+ async def _get():
+ async with _get_provider() as provider:
+ # First get from list to get full details including password
+ vms = await provider.list_vms()
+ vm_info = next((vm for vm in vms if vm.get("name") == args.name), None)
+
+ # Also probe the VM directly for status
+ status_info = await provider.get_vm(args.name)
+
+ if vm_info:
+ # Merge status info
+ vm_info["status"] = status_info.get("status", vm_info.get("status"))
+ vm_info["os_type"] = status_info.get("os_type") or vm_info.get("os_type")
+ return vm_info
+ else:
+ return status_info
+
+ result = run_async(_get())
+
+ if args.json:
+ print_json(result)
+ return 0
+
+ if result.get("status") == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+
+ # Display sandbox info
+ print_info(f"Name: {result.get('name')}")
+ print_info(f"Status: {result.get('status')}")
+
+ if result.get("os_type"):
+ print_info(f"OS: {result.get('os_type')}")
+ if result.get("host"):
+ print_info(f"Host: {result.get('host')}")
+ if args.show_passwords and result.get("password"):
+ print_info(f"Password: {result.get('password')}")
+ if args.show_vnc_url and result.get("vnc_url"):
+ print_info(f"VNC URL: {result.get('vnc_url')}")
+
+ return 0
+
+
+def cmd_delete(args: argparse.Namespace) -> int:
+ """Delete a sandbox."""
+ api_key = require_api_key()
+
+ async def _delete():
+ status_code, data = await _api_request("DELETE", f"/v1/vms/{args.name}", api_key)
+
+ if status_code in (200, 202, 204):
+ body_status = data.get("status") if isinstance(data, dict) else None
+ return {"name": args.name, "status": body_status or "deleting"}
+ elif status_code == 404:
+ return {"name": args.name, "status": "not_found"}
+ elif status_code == 401:
+ return {"name": args.name, "status": "unauthorized"}
+ else:
+ return {"name": args.name, "status": "error", "message": str(data)}
+
+ result = run_async(_delete())
+ status = result.get("status")
+
+ if status == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+ elif status in ("error", "unauthorized"):
+ print_error(f"Failed to delete sandbox: {result.get('message', status)}")
+ return 1
+ else:
+ print_success(f"Sandbox '{args.name}' is being deleted.")
+ return 0
+
+
+def cmd_start(args: argparse.Namespace) -> int:
+ """Start a stopped sandbox."""
+
+ async def _start():
+ async with _get_provider() as provider:
+ return await provider.run_vm(name=args.name)
+
+ result = run_async(_start())
+ status = result.get("status")
+
+ if status == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+ elif status in ("error", "unauthorized"):
+ print_error(f"Failed to start sandbox: {result.get('message', status)}")
+ return 1
+ else:
+ print_success(f"Sandbox '{args.name}' is starting.")
+ return 0
+
+
+def cmd_stop(args: argparse.Namespace) -> int:
+ """Stop a running sandbox."""
+
+ async def _stop():
+ async with _get_provider() as provider:
+ return await provider.stop_vm(args.name)
+
+ result = run_async(_stop())
+ status = result.get("status")
+
+ if status == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+ elif status in ("error", "unauthorized"):
+ print_error(f"Failed to stop sandbox: {result.get('message', status)}")
+ return 1
+ else:
+ print_success(f"Sandbox '{args.name}' is stopping.")
+ return 0
+
+
+def cmd_restart(args: argparse.Namespace) -> int:
+ """Restart a sandbox."""
+
+ async def _restart():
+ async with _get_provider() as provider:
+ return await provider.restart_vm(args.name)
+
+ result = run_async(_restart())
+ status = result.get("status")
+
+ if status == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+ elif status in ("error", "unauthorized"):
+ print_error(f"Failed to restart sandbox: {result.get('message', status)}")
+ return 1
+ else:
+ print_success(f"Sandbox '{args.name}' is restarting.")
+ return 0
+
+
+def cmd_suspend(args: argparse.Namespace) -> int:
+ """Suspend a sandbox."""
+ api_key = require_api_key()
+
+ async def _suspend():
+ status_code, data = await _api_request("POST", f"/v1/vms/{args.name}/suspend", api_key)
+
+ if status_code in (200, 202):
+ body_status = data.get("status") if isinstance(data, dict) else None
+ return {"name": args.name, "status": body_status or "suspending"}
+ elif status_code == 404:
+ return {"name": args.name, "status": "not_found"}
+ elif status_code == 401:
+ return {"name": args.name, "status": "unauthorized"}
+ elif status_code == 400:
+ # Suspend may not be supported for all VM types
+ return {"name": args.name, "status": "unsupported", "message": str(data)}
+ else:
+ return {"name": args.name, "status": "error", "message": str(data)}
+
+ result = run_async(_suspend())
+ status = result.get("status")
+
+ if status == "not_found":
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+ elif status == "unsupported":
+ print_error(f"Suspend not supported for this sandbox: {result.get('message', '')}")
+ return 1
+ elif status in ("error", "unauthorized"):
+ print_error(f"Failed to suspend sandbox: {result.get('message', status)}")
+ return 1
+ else:
+ print_success(f"Sandbox '{args.name}' is suspending.")
+ return 0
+
+
+def cmd_vnc(args: argparse.Namespace) -> int:
+ """Open sandbox in browser via VNC."""
+
+ async def _get_vnc_url():
+ async with _get_provider() as provider:
+ vms = await provider.list_vms()
+ vm_info = next((vm for vm in vms if vm.get("name") == args.name), None)
+ return vm_info
+
+ vm_info = run_async(_get_vnc_url())
+
+ if not vm_info:
+ print_error(f"Sandbox '{args.name}' not found.")
+ return 1
+
+ vnc_url = vm_info.get("vnc_url")
+
+ if not vnc_url:
+ # Try to construct it manually
+ host = vm_info.get("host")
+ password = vm_info.get("password")
+
+ if host and password:
+ encoded_password = quote(password, safe="")
+ vnc_url = f"https://{host}/vnc.html?autoconnect=true&password={encoded_password}&show_dot=true"
+ else:
+ print_error("Could not determine VNC URL. Sandbox may not be ready.")
+ return 1
+
+ print_info(f"Opening VNC: {vnc_url}")
+ webbrowser.open(vnc_url)
+ return 0
diff --git a/libs/python/cua-cli/cua_cli/commands/skills.py b/libs/python/cua-cli/cua_cli/commands/skills.py
new file mode 100644
index 0000000000..e0f6a1472c
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/commands/skills.py
@@ -0,0 +1,929 @@
+"""Skills management commands for CUA CLI.
+
+Skills are recorded demonstrations that can guide agent behavior.
+Each skill contains:
+- SKILL.md: Markdown file with frontmatter and steps
+- trajectory/: Directory with video, events.json, trajectory.json, screenshots
+"""
+
+import argparse
+import json
+import shutil
+import webbrowser
+from datetime import datetime
+from pathlib import Path
+from typing import Any, Optional
+
+from cua_cli.utils.async_utils import run_async
+from cua_cli.utils.output import (
+ print_error,
+ print_info,
+ print_json,
+ print_success,
+ print_table,
+)
+
+# Skills directory
+SKILLS_DIR = Path.home() / ".cua" / "skills"
+
+
+def register_parser(subparsers: argparse._SubParsersAction) -> None:
+ """Register the skills command and subcommands."""
+ skills_parser = subparsers.add_parser(
+ "skills",
+ help="Manage demonstration skills",
+ description="Record and manage demonstration skills for agent guidance",
+ )
+
+ skills_subparsers = skills_parser.add_subparsers(
+ dest="skills_command",
+ help="Skills command",
+ )
+
+ # list command
+ list_parser = skills_subparsers.add_parser(
+ "list",
+ aliases=["ls"],
+ help="List all saved skills",
+ )
+ list_parser.add_argument(
+ "--json",
+ action="store_true",
+ help="Output as JSON",
+ )
+
+ # read command
+ read_parser = skills_subparsers.add_parser(
+ "read",
+ help="Read a skill",
+ )
+ read_parser.add_argument(
+ "name",
+ help="Skill name",
+ )
+ read_parser.add_argument(
+ "--format",
+ "-f",
+ choices=["json", "md"],
+ default="md",
+ help="Output format (default: md)",
+ )
+
+ # replay command
+ replay_parser = skills_subparsers.add_parser(
+ "replay",
+ help="Open the video recording for a skill",
+ )
+ replay_parser.add_argument(
+ "name",
+ help="Skill name",
+ )
+
+ # delete command
+ delete_parser = skills_subparsers.add_parser(
+ "delete",
+ help="Delete a skill",
+ )
+ delete_parser.add_argument(
+ "name",
+ help="Skill name",
+ )
+
+ # clean command
+ skills_subparsers.add_parser(
+ "clean",
+ help="Delete all skills (with confirmation)",
+ )
+
+ # record command
+ record_parser = skills_subparsers.add_parser(
+ "record",
+ help="Record a demonstration and create a skill",
+ )
+ record_parser.add_argument(
+ "--sandbox",
+ "-s",
+ type=str,
+ help="Sandbox name to connect to",
+ )
+ record_parser.add_argument(
+ "--vnc-url",
+ "-u",
+ type=str,
+ help="Direct VNC URL to connect to",
+ )
+ record_parser.add_argument(
+ "--provider",
+ "-p",
+ choices=["anthropic", "openai"],
+ default="anthropic",
+ help="LLM provider for captioning (default: anthropic)",
+ )
+ record_parser.add_argument(
+ "--model",
+ "-m",
+ type=str,
+ help="Model to use for captioning",
+ )
+ record_parser.add_argument(
+ "--api-key",
+ "-k",
+ type=str,
+ help="API key for the LLM provider",
+ )
+ record_parser.add_argument(
+ "--name",
+ "-n",
+ type=str,
+ help="Skill name (skips interactive prompt)",
+ )
+ record_parser.add_argument(
+ "--description",
+ "-d",
+ type=str,
+ help="Skill description (skips interactive prompt)",
+ )
+
+
+def execute(args: argparse.Namespace) -> int:
+ """Execute skills command based on subcommand."""
+ cmd = getattr(args, "skills_command", None)
+
+ if cmd in ("list", "ls"):
+ return cmd_list(args)
+ elif cmd == "read":
+ return cmd_read(args)
+ elif cmd == "replay":
+ return cmd_replay(args)
+ elif cmd == "delete":
+ return cmd_delete(args)
+ elif cmd == "clean":
+ return cmd_clean(args)
+ elif cmd == "record":
+ return cmd_record(args)
+ else:
+ print_error("Usage: cua skills <command>")
+ print_info("Commands: list, read, replay, delete, clean, record")
+ return 1
+
+
+def _ensure_skills_dir() -> None:
+ """Ensure skills directory exists."""
+ SKILLS_DIR.mkdir(parents=True, exist_ok=True)
+
+
+def _parse_frontmatter(content: str) -> Optional[dict[str, str]]:
+ """Parse YAML frontmatter from markdown content."""
+ import re
+
+ match = re.match(r"^---\n(.*?)\n---\n(.*)$", content, re.DOTALL)
+ if not match:
+ return None
+
+ frontmatter = match.group(1)
+ body = match.group(2).strip()
+
+ name_match = re.search(r"^name:\s*(.+)$", frontmatter, re.MULTILINE)
+ desc_match = re.search(r"^description:\s*(.+)$", frontmatter, re.MULTILINE)
+
+ if not name_match or not desc_match:
+ return None
+
+ return {
+ "name": name_match.group(1).strip(),
+ "description": desc_match.group(1).strip(),
+ "body": body,
+ }
+
+
+def _get_skill_info(skill_dir: Path) -> Optional[dict[str, Any]]:
+ """Get skill info from a skill directory."""
+ skill_path = skill_dir / "SKILL.md"
+ if not skill_path.exists():
+ return None
+
+ content = skill_path.read_text()
+ parsed = _parse_frontmatter(content)
+ if not parsed:
+ return None
+
+ # Try to read trajectory.json for additional info
+ steps = 0
+ created = None
+ trajectory_path = skill_dir / "trajectory" / "trajectory.json"
+ if trajectory_path.exists():
+ try:
+ traj_data = json.loads(trajectory_path.read_text())
+ steps = len(traj_data.get("trajectory", []))
+ if traj_data.get("metadata", {}).get("created_at"):
+ created = traj_data["metadata"]["created_at"]
+ except Exception:
+ pass
+
+ return {
+ "name": parsed["name"],
+ "description": parsed["description"],
+ "steps": steps,
+ "created": created,
+ "path": str(skill_dir),
+ }
+
+
+def cmd_list(args: argparse.Namespace) -> int:
+ """List all skills."""
+ _ensure_skills_dir()
+
+ skills = []
+ for skill_dir in sorted(SKILLS_DIR.iterdir()):
+ if not skill_dir.is_dir():
+ continue
+ info = _get_skill_info(skill_dir)
+ if info:
+ skills.append(info)
+
+ if args.json:
+ print_json(skills)
+ return 0
+
+ if not skills:
+ print_info("No skills found.")
+ print_info("Record a skill with: cua skills record --sandbox <name>")
+ return 0
+
+ # Format for table
+ rows = []
+ for skill in skills:
+ created = "-"
+ if skill["created"]:
+ try:
+ dt = datetime.fromisoformat(skill["created"].replace("Z", "+00:00"))
+ created = dt.strftime("%Y-%m-%d")
+ except Exception:
+ created = skill["created"][:10]
+
+ rows.append(
+ {
+ "name": skill["name"],
+ "description": skill["description"][:40]
+ + ("..." if len(skill["description"]) > 40 else ""),
+ "steps": str(skill["steps"]),
+ "created": created,
+ }
+ )
+
+ columns = [
+ ("name", "NAME"),
+ ("description", "DESCRIPTION"),
+ ("steps", "STEPS"),
+ ("created", "CREATED"),
+ ]
+ print_table(rows, columns)
+ return 0
+
+
+def cmd_read(args: argparse.Namespace) -> int:
+ """Read a skill."""
+ _ensure_skills_dir()
+
+ skill_dir = SKILLS_DIR / args.name
+ skill_path = skill_dir / "SKILL.md"
+
+ if not skill_path.exists():
+ print_error(f"Skill not found: {args.name}")
+ return 1
+
+ content = skill_path.read_text()
+
+ if args.format == "md":
+ print(content)
+ return 0
+
+ # JSON format - include trajectory data
+ parsed = _parse_frontmatter(content)
+ if not parsed:
+ print_error(f"Invalid skill file format: {args.name}")
+ return 1
+
+ trajectory_path = skill_dir / "trajectory" / "trajectory.json"
+ trajectory = []
+ metadata = {}
+
+ if trajectory_path.exists():
+ try:
+ traj_data = json.loads(trajectory_path.read_text())
+ trajectory = traj_data.get("trajectory", [])
+ metadata = traj_data.get("metadata", {})
+ except Exception as e:
+ print_error(f"Failed to read trajectory: {e}")
+
+ result = {
+ "name": parsed["name"],
+ "description": parsed["description"],
+ "trajectory": trajectory,
+ "skill_prompt": parsed["body"],
+ "trajectory_dir": str(skill_dir / "trajectory"),
+ "metadata": metadata,
+ }
+
+ print_json(result)
+ return 0
+
+
+def cmd_replay(args: argparse.Namespace) -> int:
+ """Open the video recording for a skill."""
+ _ensure_skills_dir()
+
+ skill_dir = SKILLS_DIR / args.name
+ if not skill_dir.exists():
+ print_error(f"Skill not found: {args.name}")
+ return 1
+
+ # Find MP4 file
+ trajectory_dir = skill_dir / "trajectory"
+ mp4_files = list(trajectory_dir.glob("*.mp4"))
+
+ if not mp4_files:
+ print_error(f"No video found in: {trajectory_dir}")
+ return 1
+
+ video_path = mp4_files[0]
+ print_info(f"Opening: {video_path}")
+ webbrowser.open(f"file://{video_path}")
+ return 0
+
+
+def cmd_delete(args: argparse.Namespace) -> int:
+ """Delete a skill."""
+ _ensure_skills_dir()
+
+ skill_dir = SKILLS_DIR / args.name
+ if not skill_dir.exists():
+ print_error(f"Skill not found: {args.name}")
+ return 1
+
+ shutil.rmtree(skill_dir)
+ print_success(f"Deleted skill: {args.name}")
+ return 0
+
+
+def cmd_clean(args: argparse.Namespace) -> int:
+ """Delete all skills with confirmation."""
+ _ensure_skills_dir()
+
+ skills = [d for d in SKILLS_DIR.iterdir() if d.is_dir() and (d / "SKILL.md").exists()]
+
+ if not skills:
+ print_info("No skills to clean.")
+ return 0
+
+ print_info("Skills to delete:")
+ for skill_dir in sorted(skills):
+ print(f" - {skill_dir.name}")
+
+ response = input(f"\nDelete {len(skills)} skill(s)? [y/N]: ").strip().lower()
+ if response != "y":
+ print_info("Cancelled.")
+ return 0
+
+ for skill_dir in skills:
+ shutil.rmtree(skill_dir)
+
+ print_success(f"Deleted {len(skills)} skill(s).")
+ return 0
+
+
+def cmd_record(args: argparse.Namespace) -> int:
+ """Record a demonstration and create a skill.
+
+ This is a complex operation that:
+ 1. Starts a WebSocket server to receive the recording
+ 2. Opens the VNC viewer with recording parameters
+ 3. Waits for the recording to complete
+ 4. Extracts frames and captions them with LLM
+ 5. Saves the skill to disk
+ """
+ # Check for required dependencies
+ if not _check_ffmpeg():
+ print_error("ffmpeg is required for skill recording.")
+ print_info("Install with: brew install ffmpeg (macOS) or apt install ffmpeg (Linux)")
+ return 1
+
+ if not args.sandbox and not args.vnc_url:
+ print_error("Either --sandbox or --vnc-url is required")
+ return 1
+
+ # Defer to async implementation
+ return run_async(_record_skill_async(args))
+
+
+def _check_ffmpeg() -> bool:
+ """Check if ffmpeg is available."""
+ import subprocess
+
+ try:
+ result = subprocess.run(["which", "ffmpeg"], capture_output=True)
+ return result.returncode == 0
+ except Exception:
+ return False
+
+
+async def _record_skill_async(args: argparse.Namespace) -> int:
+ """Async implementation of skill recording."""
+ import asyncio
+ import os
+
+ import websockets
+
+ # Get LLM API key
+ provider = args.provider
+ api_key = args.api_key
+
+ if not api_key:
+ if provider == "openai":
+ api_key = os.environ.get("OPENAI_API_KEY")
+ else:
+ api_key = os.environ.get("ANTHROPIC_API_KEY")
+
+ if not api_key:
+ env_var = "OPENAI_API_KEY" if provider == "openai" else "ANTHROPIC_API_KEY"
+ print_error(f"No {provider.upper()} API key found.")
+ print_info(f"Set {env_var} environment variable or use --api-key flag.")
+ return 1
+
+ model = args.model
+ if not model:
+ model = "gpt-4o-mini" if provider == "openai" else "claude-haiku-4-5"
+
+ # Start WebSocket server to receive recording
+ recording_data = bytearray()
+ recording_complete = asyncio.Event()
+
+ async def handle_ws(websocket):
+ nonlocal recording_data
+ try:
+ async for message in websocket:
+ if isinstance(message, bytes):
+ recording_data.extend(message)
+ except websockets.exceptions.ConnectionClosed:
+ pass
+ finally:
+ recording_complete.set()
+
+ # Find available port
+ import socket
+
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.bind(("localhost", 0))
+ port = sock.getsockname()[1]
+ sock.close()
+
+ server = await websockets.serve(handle_ws, "localhost", port)
+ record_url = f"ws://localhost:{port}"
+
+ print_info(f"Recording server started on port {port}")
+
+ # Build VNC URL with recording parameters
+ if args.sandbox:
+ # Get sandbox VNC URL
+ from computer.providers.cloud.provider import CloudProvider
+ from cua_cli.auth.store import require_api_key
+
+ cloud_api_key = require_api_key()
+ provider_inst = CloudProvider(api_key=cloud_api_key)
+
+ async with provider_inst:
+ vms = await provider_inst.list_vms()
+ sandbox = next((vm for vm in vms if vm.get("name") == args.sandbox), None)
+
+ if not sandbox:
+ print_error(f"Sandbox not found: {args.sandbox}")
+ server.close()
+ return 1
+
+ if sandbox.get("status") != "running":
+ print_error(f"Sandbox is not running (status: {sandbox.get('status')})")
+ server.close()
+ return 1
+
+ host = sandbox.get("host", f"{args.sandbox}.sandbox.cua.ai")
+ password = sandbox.get("password", "")
+ from urllib.parse import quote
+
+ base_url = (
+ f"https://{host}/vnc.html?autoconnect=true&password={quote(password)}&show_dot=true"
+ )
+ else:
+ base_url = args.vnc_url
+
+ # Add recording parameters
+ from urllib.parse import parse_qs, urlencode, urlparse
+
+ parsed = urlparse(base_url)
+ params = parse_qs(parsed.query)
+ params["autorecord"] = ["true"]
+ params["record_format"] = ["mp4"]
+ params["record_url"] = [record_url]
+ recording_url = (
+ f"{parsed.scheme}://{parsed.netloc}{parsed.path}?{urlencode(params, doseq=True)}"
+ )
+
+ print_info("\nRecording will start automatically when you connect.")
+ print_info("When finished, click 'Stop Recording' in the VNC panel.\n")
+
+ import webbrowser
+
+ webbrowser.open(recording_url)
+
+ # Wait for recording (30 min timeout)
+ try:
+ await asyncio.wait_for(recording_complete.wait(), timeout=30 * 60)
+ except asyncio.TimeoutError:
+ print_error("Recording timeout (30 minutes)")
+ server.close()
+ return 1
+
+ server.close()
+
+ if len(recording_data) == 0:
+ print_error("No recording data received")
+ return 1
+
+ print_info(f"Received {len(recording_data)} bytes of recording data")
+
+ # Get skill name
+ skill_name = args.name
+ if not skill_name:
+ skill_name = input("Enter skill name: ").strip()
+ while not skill_name or not skill_name.replace("-", "").replace("_", "").isalnum():
+ print("Use only letters, numbers, hyphens, and underscores.")
+ skill_name = input("Enter skill name: ").strip()
+
+ # Ensure unique name
+ _ensure_skills_dir()
+ final_name = skill_name
+ counter = 1
+ while (SKILLS_DIR / final_name).exists():
+ final_name = f"{skill_name}-{counter}"
+ counter += 1
+
+ if final_name != skill_name:
+ print_info(f'Skill "{skill_name}" exists, using "{final_name}"')
+ skill_name = final_name
+
+ # Get description
+ description = args.description
+ if not description:
+ description = input("Describe what this skill demonstrates: ").strip()
+ while not description:
+ print("Description is required.")
+ description = input("Describe what this skill demonstrates: ").strip()
+
+ print_info("\nProcessing recording...")
+
+ # Process recording
+ result = await _process_recording(
+ recording_data=bytes(recording_data),
+ skill_name=skill_name,
+ description=description,
+ provider=provider,
+ model=model,
+ api_key=api_key,
+ )
+
+ if not result:
+ print_error("Failed to process recording")
+ return 1
+
+ print_success(f"\nSkill saved: {SKILLS_DIR / skill_name / 'SKILL.md'}")
+ print_info(f"Steps: {result['steps']}")
+ return 0
+
+
+async def _process_recording(
+ recording_data: bytes,
+ skill_name: str,
+ description: str,
+ provider: str,
+ model: str,
+ api_key: str,
+) -> Optional[dict[str, Any]]:
+ """Process recording data and create skill files."""
+ import struct
+ import subprocess
+ import tempfile
+
+ # Parse recording format: [4 bytes JSON length][JSON][MP4 data]
+ if len(recording_data) < 4:
+ print_error("Recording data too short")
+ return None
+
+ json_length = struct.unpack(">I", recording_data[:4])[0]
+ if len(recording_data) < 4 + json_length:
+ print_error("Invalid recording format")
+ return None
+
+ json_bytes = recording_data[4 : 4 + json_length]
+ mp4_data = recording_data[4 + json_length :]
+
+ if not mp4_data:
+ print_error("No video data in recording")
+ return None
+
+ try:
+ recording_json = json.loads(json_bytes.decode())
+ except Exception as e:
+ print_error(f"Failed to parse recording JSON: {e}")
+ return None
+
+ events = recording_json.get("events", [])
+ metadata = recording_json.get("metadata", {})
+
+ # Create skill directory structure
+ skill_dir = SKILLS_DIR / skill_name
+ trajectory_dir = skill_dir / "trajectory"
+ trajectory_dir.mkdir(parents=True, exist_ok=True)
+
+ # Save video
+ video_path = trajectory_dir / f"{skill_name}.mp4"
+ video_path.write_bytes(mp4_data)
+
+ # Save events
+ events_path = trajectory_dir / "events.json"
+ events_path.write_text(json.dumps({"events": events, "metadata": metadata}, indent=2))
+
+ # Process each event with LLM captioning
+ trajectory = []
+ from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn
+
+ with Progress(
+ SpinnerColumn(),
+ TextColumn("[progress.description]{task.description}"),
+ BarColumn(),
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
+ ) as progress:
+ task = progress.add_task("Captioning steps...", total=len(events))
+
+ with tempfile.TemporaryDirectory() as temp_dir:
+ temp_path = Path(temp_dir)
+
+ for idx, event in enumerate(events):
+ step_idx = idx + 1
+
+ # Extract frame at event timestamp
+ frame_path = temp_path / f"step_{step_idx}.jpg"
+ timestamp_sec = max(0, event.get("timestamp", 0) / 1000 - 0.1)
+
+ result = subprocess.run(
+ [
+ "ffmpeg",
+ "-y",
+ "-ss",
+ f"{timestamp_sec:.3f}",
+ "-i",
+ str(video_path),
+ "-frames:v",
+ "1",
+ "-q:v",
+ "2",
+ str(frame_path),
+ ],
+ capture_output=True,
+ )
+
+ if result.returncode != 0 or not frame_path.exists():
+ # Skip if frame extraction fails
+ trajectory.append(
+ {
+ "step_idx": step_idx,
+ "caption": {
+ "observation": "",
+ "think": "",
+ "action": event.get("type", ""),
+ "expectation": "",
+ },
+ "raw_event": event,
+ }
+ )
+ progress.update(task, advance=1)
+ continue
+
+ # Caption with LLM
+ caption = await _caption_step(
+ frame_path=frame_path,
+ event=event,
+ step_idx=step_idx,
+ description=description,
+ provider=provider,
+ model=model,
+ api_key=api_key,
+ )
+
+ # Save screenshot to trajectory dir
+ dest_full = trajectory_dir / f"step_{step_idx}_full.jpg"
+ shutil.copy(frame_path, dest_full)
+
+ trajectory.append(
+ {
+ "step_idx": step_idx,
+ "caption": caption,
+ "raw_event": event,
+ "screenshot_full": str(dest_full),
+ }
+ )
+
+ progress.update(task, advance=1)
+
+ # Save trajectory
+ trajectory_json_path = trajectory_dir / "trajectory.json"
+ trajectory_json_path.write_text(
+ json.dumps(
+ {
+ "events": events,
+ "trajectory": trajectory,
+ "metadata": {
+ "task_description": description,
+ "total_steps": len(trajectory),
+ "width": metadata.get("width"),
+ "height": metadata.get("height"),
+ "duration": metadata.get("duration"),
+ "created_at": datetime.now().isoformat(),
+ },
+ },
+ indent=2,
+ )
+ )
+
+ # Generate skill markdown
+ steps_text = "\n".join(
+ [
+ f"Step {s['step_idx']}: {s['caption'].get('action', s['raw_event'].get('type', ''))}"
+ for s in trajectory
+ ]
+ )
+
+ skill_prompt = f"""You have been shown a demonstration of how to perform this task:
+{description}
+
+The demonstration consisted of the following steps:
+{steps_text}
+
+Follow this workflow pattern, adapting as needed for the current screen state.
+Total steps: {len(trajectory)}"""
+
+ steps_markdown = "\n".join(
+ [
+ f"### Step {s['step_idx']}: {s['caption'].get('action', s['raw_event'].get('type', ''))}\n\n"
+ f"**Context:** {s['caption'].get('observation', '')}\n\n"
+ f"**Intent:** {s['caption'].get('think', '')}\n\n"
+ f"**Expected Result:** {s['caption'].get('expectation', '')}\n"
+ for s in trajectory
+ ]
+ )
+
+ skill_content = f"""---
+name: {skill_name}
+description: {description}
+---
+
+# {skill_name}
+
+{description}
+
+## Steps
+
+{steps_markdown}
+
+## Agent Prompt
+
+{skill_prompt}
+"""
+
+ skill_path = skill_dir / "SKILL.md"
+ skill_path.write_text(skill_content)
+
+ return {"steps": len(trajectory)}
+
+
+async def _caption_step(
+ frame_path: Path,
+ event: dict,
+ step_idx: int,
+ description: str,
+ provider: str,
+ model: str,
+ api_key: str,
+) -> dict[str, str]:
+ """Caption a single step using LLM."""
+ import base64
+
+ import aiohttp
+
+ # Build prompt
+ prompt = f"""Describe this GUI action step. The overall task is: {description}
+
+Step {step_idx}: {event.get('type', 'action')}
+Event data: {json.dumps(event.get('data', {}))}
+
+Respond with JSON only:
+{{
+ "Observation": "Describe what you see in the screenshot",
+ "Think": "Explain the user's likely intention",
+ "Action": "Describe the action being taken",
+ "Expectation": "What should happen after this action"
+}}"""
+
+ # Read image
+ image_data = frame_path.read_bytes()
+ image_b64 = base64.b64encode(image_data).decode()
+
+ try:
+ if provider == "openai":
+ async with aiohttp.ClientSession() as session:
+ async with session.post(
+ "https://api.openai.com/v1/chat/completions",
+ headers={
+ "Authorization": f"Bearer {api_key}",
+ "Content-Type": "application/json",
+ },
+ json={
+ "model": model,
+ "messages": [
+ {
+ "role": "user",
+ "content": [
+ {"type": "text", "text": prompt},
+ {
+ "type": "image_url",
+ "image_url": {"url": f"data:image/jpeg;base64,{image_b64}"},
+ },
+ ],
+ }
+ ],
+ "temperature": 0.2,
+ },
+ ) as resp:
+ if resp.status != 200:
+ return {
+ "observation": "",
+ "think": "",
+ "action": event.get("type", ""),
+ "expectation": "",
+ }
+ data = await resp.json()
+ text = data.get("choices", [{}])[0].get("message", {}).get("content", "")
+ else:
+ async with aiohttp.ClientSession() as session:
+ async with session.post(
+ "https://api.anthropic.com/v1/messages",
+ headers={
+ "x-api-key": api_key,
+ "anthropic-version": "2023-06-01",
+ "content-type": "application/json",
+ },
+ json={
+ "model": model,
+ "max_tokens": 1200,
+ "messages": [
+ {
+ "role": "user",
+ "content": [
+ {"type": "text", "text": prompt},
+ {
+ "type": "image",
+ "source": {
+ "type": "base64",
+ "media_type": "image/jpeg",
+ "data": image_b64,
+ },
+ },
+ ],
+ }
+ ],
+ },
+ ) as resp:
+ if resp.status != 200:
+ return {
+ "observation": "",
+ "think": "",
+ "action": event.get("type", ""),
+ "expectation": "",
+ }
+ data = await resp.json()
+ text = data.get("content", [{}])[0].get("text", "")
+
+ # Parse JSON response
+ import re
+
+ json_match = re.search(r"\{[\s\S]*\}", text)
+ if json_match:
+ parsed = json.loads(json_match.group())
+ return {
+ "observation": parsed.get("Observation", parsed.get("observation", "")),
+ "think": parsed.get("Think", parsed.get("think", "")),
+ "action": parsed.get("Action", parsed.get("action", "")),
+ "expectation": parsed.get("Expectation", parsed.get("expectation", "")),
+ }
+ except Exception:
+ pass
+
+ return {"observation": "", "think": "", "action": event.get("type", ""), "expectation": ""}
diff --git a/libs/python/cua-cli/cua_cli/main.py b/libs/python/cua-cli/cua_cli/main.py
new file mode 100644
index 0000000000..5c8d1bcc9f
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/main.py
@@ -0,0 +1,88 @@
+"""Main entry point for CUA CLI."""
+
+import argparse
+import sys
+
+from cua_cli import __version__
+from cua_cli.commands import auth, image, mcp, platform, sandbox, skills
+from cua_cli.utils.output import print_error
+
+
+def create_parser() -> argparse.ArgumentParser:
+ """Create the main argument parser with all subcommands."""
+ parser = argparse.ArgumentParser(
+ prog="cua",
+ description="CUA CLI - Unified command-line interface for Computer-Use Agents",
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ epilog="""
+Examples:
+ cua auth login Authenticate via browser
+ cua auth login --api-key Authenticate with API key
+ cua sb list List all sandboxes
+ cua sb create --os linux Create a new Linux sandbox
+ cua image list List cloud images
+ cua image list --local List local images
+ cua image create linux-docker Create a local image
+ cua image shell <name> Interactive shell into image
+ cua platform list Show available platforms
+
+For more information, visit https://docs.trycua.com
+""",
+ )
+
+ parser.add_argument(
+ "-v",
+ "--version",
+ action="version",
+ version=f"cua {__version__}",
+ )
+
+ subparsers = parser.add_subparsers(dest="command", help="Available commands")
+
+ # Register command modules
+ auth.register_parser(subparsers)
+ sandbox.register_parser(subparsers)
+ image.register_parser(subparsers)
+ platform.register_parser(subparsers)
+ skills.register_parser(subparsers)
+ mcp.register_parser(subparsers)
+
+ return parser
+
+
+def main() -> int:
+ """Main entry point for the CLI."""
+ parser = create_parser()
+ args = parser.parse_args()
+
+ if args.command is None:
+ parser.print_help()
+ return 0
+
+ try:
+ # Dispatch to command modules
+ if args.command == "auth":
+ return auth.execute(args)
+ elif args.command in ("sandbox", "sb"):
+ return sandbox.execute(args)
+ elif args.command in ("image", "img"):
+ return image.execute(args)
+ elif args.command == "platform":
+ return platform.execute(args)
+ elif args.command == "skills":
+ return skills.execute(args)
+ elif args.command == "serve-mcp":
+ return mcp.execute(args)
+ else:
+ print_error(f"Unknown command: {args.command}")
+ return 1
+ except KeyboardInterrupt:
+ print_error("Operation cancelled")
+ return 130
+ except Exception as e:
+ print_error(str(e))
+ return 1
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/libs/python/cua-cli/cua_cli/utils/__init__.py b/libs/python/cua-cli/cua_cli/utils/__init__.py
new file mode 100644
index 0000000000..d3ef79afdd
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/__init__.py
@@ -0,0 +1,21 @@
+"""Utility modules for CUA CLI."""
+
+from .async_utils import run_async
+from .output import (
+ print_error,
+ print_info,
+ print_json,
+ print_success,
+ print_table,
+ print_warning,
+)
+
+__all__ = [
+ "print_table",
+ "print_json",
+ "print_error",
+ "print_success",
+ "print_warning",
+ "print_info",
+ "run_async",
+]
diff --git a/libs/python/cua-cli/cua_cli/utils/async_utils.py b/libs/python/cua-cli/cua_cli/utils/async_utils.py
new file mode 100644
index 0000000000..23c0c8aac8
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/async_utils.py
@@ -0,0 +1,20 @@
+"""Async utilities for CUA CLI."""
+
+import asyncio
+from typing import Any, Coroutine, TypeVar
+
+T = TypeVar("T")
+
+
+def run_async(coro: Coroutine[Any, Any, T]) -> T:
+ """Run an async coroutine synchronously.
+
+ This is the standard pattern for CLI commands that need to call async code.
+
+ Args:
+ coro: The coroutine to run
+
+ Returns:
+ The result of the coroutine
+ """
+ return asyncio.run(coro)
diff --git a/libs/python/cua-cli/cua_cli/utils/docker.py b/libs/python/cua-cli/cua_cli/utils/docker.py
new file mode 100644
index 0000000000..69d6f39311
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/docker.py
@@ -0,0 +1,103 @@
+"""Docker utilities for CUA CLI."""
+
+import platform
+import shutil
+import subprocess
+from pathlib import Path
+
+
+def find_free_port(start: int = 5000, end: int = 9000) -> int:
+ """Find a free port in the given range.
+
+ Args:
+ start: Start of port range (inclusive)
+ end: End of port range (exclusive)
+
+ Returns:
+ First available port in the range
+
+ Raises:
+ RuntimeError: If no free port found
+ """
+ import socket
+
+ for port in range(start, end):
+ try:
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+ s.bind(("", port))
+ return port
+ except OSError:
+ continue
+ raise RuntimeError(f"No free port found in range {start}-{end}")
+
+
+def allocate_ports(vnc_default: int = 8006, api_default: int = 5000) -> tuple[int, int]:
+ """Allocate VNC and API ports, auto-selecting if defaults are in use.
+
+ Args:
+ vnc_default: Preferred VNC port
+ api_default: Preferred API port
+
+ Returns:
+ Tuple of (vnc_port, api_port)
+ """
+ import socket
+
+ def is_port_free(port: int) -> bool:
+ try:
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+ s.bind(("", port))
+ return True
+ except OSError:
+ return False
+
+ vnc_port = vnc_default if is_port_free(vnc_default) else find_free_port(8000, 9000)
+ api_port = api_default if is_port_free(api_default) else find_free_port(5000, 6000)
+
+ return vnc_port, api_port
+
+
+def create_overlay_copy(golden_path: Path, overlay_path: Path, verbose: bool = False) -> None:
+ """Copy golden image to overlay directory for COW-like behavior.
+
+ This is a temporary workaround until proper QEMU overlay support is added.
+ Uses native `cp -a` on Unix for speed (5x faster than Python shutil).
+ Falls back to shutil.copytree on Windows.
+
+ WIP: https://github.com/trycua/cua/issues/699
+
+ Args:
+ golden_path: Path to golden image directory
+ overlay_path: Path to overlay directory (will be created/cleaned)
+ verbose: Print progress messages
+
+ Raises:
+ RuntimeError: If copy fails
+ """
+ if overlay_path.exists():
+ shutil.rmtree(overlay_path)
+ overlay_path.mkdir(parents=True, exist_ok=True)
+
+ if verbose:
+ print(f" Source: {golden_path}")
+ print(f" Overlay: {overlay_path}")
+ print(" (This may take a while for large images)")
+ print(" WIP: https://github.com/trycua/cua/issues/699")
+
+ if platform.system() == "Windows":
+ try:
+ for item in golden_path.iterdir():
+ src = golden_path / item.name
+ dst = overlay_path / item.name
+ if src.is_dir():
+ shutil.copytree(src, dst)
+ else:
+ shutil.copy2(src, dst)
+ except Exception as e:
+ raise RuntimeError(f"Failed to create overlay: {e}")
+ else:
+ result = subprocess.run(
+ ["cp", "-a", f"{golden_path}/.", str(overlay_path)], capture_output=True, text=True
+ )
+ if result.returncode != 0:
+ raise RuntimeError(f"Failed to create overlay: {result.stderr or 'cp failed'}")
diff --git a/libs/python/cua-cli/cua_cli/utils/output.py b/libs/python/cua-cli/cua_cli/utils/output.py
new file mode 100644
index 0000000000..c6b6682da0
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/output.py
@@ -0,0 +1,66 @@
+"""Output formatting utilities for CUA CLI."""
+
+import json
+from typing import Any
+
+from rich.console import Console
+from rich.table import Table
+
+console = Console()
+error_console = Console(stderr=True)
+
+
+def print_table(
+ data: list[dict[str, Any]],
+ columns: list[tuple[str, str]] | None = None,
+ title: str | None = None,
+) -> None:
+ """Print data as a formatted table.
+
+ Args:
+ data: List of dictionaries to display
+ columns: List of (key, header) tuples. If None, uses all keys from first item.
+ title: Optional table title
+ """
+ if not data:
+ console.print("[dim]No data to display[/dim]")
+ return
+
+ table = Table(title=title, show_header=True, header_style="bold")
+
+ if columns is None:
+ columns = [(k, k.upper()) for k in data[0].keys()]
+
+ for _, header in columns:
+ table.add_column(header)
+
+ for item in data:
+ row = [str(item.get(key, "")) for key, _ in columns]
+ table.add_row(*row)
+
+ console.print(table)
+
+
+def print_json(data: Any) -> None:
+ """Print data as formatted JSON."""
+ console.print_json(json.dumps(data, indent=2, default=str))
+
+
+def print_error(message: str) -> None:
+ """Print an error message to stderr."""
+ error_console.print(f"[red]Error:[/red] {message}")
+
+
+def print_success(message: str) -> None:
+ """Print a success message."""
+ console.print(f"[green]{message}[/green]")
+
+
+def print_warning(message: str) -> None:
+ """Print a warning message."""
+ console.print(f"[yellow]Warning:[/yellow] {message}")
+
+
+def print_info(message: str) -> None:
+ """Print an info message."""
+ console.print(f"[blue]{message}[/blue]")
diff --git a/libs/python/cua-cli/cua_cli/utils/paths.py b/libs/python/cua-cli/cua_cli/utils/paths.py
new file mode 100644
index 0000000000..a1f4ed7d2b
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/paths.py
@@ -0,0 +1,30 @@
+"""XDG Base Directory helpers for CUA CLI."""
+
+import os
+from pathlib import Path
+
+
+def get_xdg_data_home() -> Path:
+ """Get XDG_DATA_HOME, defaulting to ~/.local/share per spec."""
+ xdg_data = os.environ.get("XDG_DATA_HOME")
+ if xdg_data:
+ return Path(xdg_data)
+ return Path.home() / ".local" / "share"
+
+
+def get_xdg_state_home() -> Path:
+ """Get XDG_STATE_HOME, defaulting to ~/.local/state per spec."""
+ xdg_state = os.environ.get("XDG_STATE_HOME")
+ if xdg_state:
+ return Path(xdg_state)
+ return Path.home() / ".local" / "state"
+
+
+def get_data_dir() -> Path:
+ """Get the CUA data directory (for images)."""
+ return get_xdg_data_home() / "cua"
+
+
+def get_state_dir() -> Path:
+ """Get the CUA state directory (for registries)."""
+ return get_xdg_state_home() / "cua"
diff --git a/libs/python/cua-cli/cua_cli/utils/registry.py b/libs/python/cua-cli/cua_cli/utils/registry.py
new file mode 100644
index 0000000000..eced79e920
--- /dev/null
+++ b/libs/python/cua-cli/cua_cli/utils/registry.py
@@ -0,0 +1,148 @@
+"""Image registry for CUA CLI.
+
+Manages a JSON registry of locally stored images at ~/.local/state/cua/images.json.
+"""
+
+import json
+from datetime import datetime
+from pathlib import Path
+from typing import Any, Dict, List, Optional
+
+from cua_cli.utils.paths import get_data_dir, get_state_dir
+
+
+def get_image_registry_path() -> Path:
+ """Get the image registry file path."""
+ return get_state_dir() / "images.json"
+
+
+def load_image_registry() -> Dict[str, Any]:
+ """Load the image registry."""
+ registry_path = get_image_registry_path()
+ if registry_path.exists():
+ try:
+ data = json.loads(registry_path.read_text())
+ return data.get("images", data)
+ except Exception:
+ return {}
+ return {}
+
+
+def save_image_registry(registry: Dict[str, Any]) -> None:
+ """Save the image registry."""
+ registry_path = get_image_registry_path()
+ registry_path.parent.mkdir(parents=True, exist_ok=True)
+ data = {"version": 1, "images": registry}
+ registry_path.write_text(json.dumps(data, indent=2))
+
+
+def register_image(
+ name: str,
+ platform: str,
+ path: Path,
+ description: str = "",
+ docker_image: Optional[str] = None,
+ config: Optional[Dict] = None,
+ parent: Optional[str] = None,
+ tags: Optional[List[str]] = None,
+ apps_installed: Optional[List[str]] = None,
+) -> None:
+ """Register an image in the registry."""
+ from cua_cli.commands.platform import PLATFORMS
+
+ registry = load_image_registry()
+
+ entry: Dict[str, Any] = {
+ "platform": platform,
+ "path": str(path),
+ "description": description,
+ "created_at": datetime.now().isoformat(),
+ }
+
+ if docker_image:
+ entry["docker_image"] = docker_image
+ if config:
+ entry["config"] = config
+ if parent:
+ entry["parent"] = parent
+ if tags:
+ entry["tags"] = tags
+ if apps_installed:
+ entry["apps_installed"] = apps_installed
+
+ platform_config = PLATFORMS.get(platform, {})
+ if platform_config.get("image_marker"):
+ entry["marker_file"] = platform_config["image_marker"]
+
+ registry[name] = entry
+ save_image_registry(registry)
+
+
+def unregister_image(name: str) -> None:
+ """Remove an image from the registry."""
+ registry = load_image_registry()
+ if name in registry:
+ del registry[name]
+ save_image_registry(registry)
+
+
+def get_image_info(name: str) -> Optional[Dict]:
+ """Get image info by name."""
+ registry = load_image_registry()
+ return registry.get(name)
+
+
+def list_images() -> Dict[str, Any]:
+ """List all registered images."""
+ return load_image_registry()
+
+
+def auto_discover_images() -> None:
+ """Scan images directory and register any unregistered images.
+
+ Handles images created with --detach mode that never got registered.
+ """
+ from cua_cli.commands.platform import PLATFORMS
+
+ images_dir = get_data_dir() / "images"
+ if not images_dir.exists():
+ return
+
+ registry = load_image_registry()
+ modified = False
+
+ for image_dir in images_dir.iterdir():
+ if not image_dir.is_dir():
+ continue
+
+ name = image_dir.name
+
+ if name in registry:
+ continue
+
+ for platform_name, config in PLATFORMS.items():
+ marker = config.get("image_marker")
+ if not marker:
+ continue
+
+ marker_path = image_dir / marker
+ if marker_path.exists():
+ print(f"Auto-registering discovered image: {name} ({platform_name})")
+
+ entry = {
+ "platform": platform_name,
+ "path": str(image_dir),
+ "description": f"Auto-discovered {platform_name} image",
+ "created_at": datetime.now().isoformat(),
+ "docker_image": config.get("image"),
+ "config": {"memory": "8G", "cpus": "8"},
+ "tags": ["auto-discovered"],
+ "marker_file": marker,
+ }
+
+ registry[name] = entry
+ modified = True
+ break
+
+ if modified:
+ save_image_registry(registry)
diff --git a/libs/python/cua-cli/pyproject.toml b/libs/python/cua-cli/pyproject.toml
new file mode 100644
index 0000000000..b7cf7de772
--- /dev/null
+++ b/libs/python/cua-cli/pyproject.toml
@@ -0,0 +1,111 @@
+[project]
+name = "cua-cli"
+version = "0.1.0"
+description = "Unified CLI for CUA - Computer-Use Agents"
+readme = "README.md"
+license = "MIT"
+authors = [
+ { name = "TryCua", email = "[email protected]" }
+]
+keywords = [
+ "computer-use",
+ "cli",
+ "cloud",
+ "sandbox",
+ "agents",
+]
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.12",
+ "Programming Language :: Python :: 3.13",
+ "Environment :: Console",
+]
+requires-python = ">=3.11,<3.14"
+
+dependencies = [
+ # Core CUA packages
+ "cua-computer>=0.4.0",
+ "cua-core>=0.1.0",
+ # HTTP client
+ "aiohttp>=3.9.0",
+ # CLI output
+ "rich>=13.0.0",
+ # Image processing for skills
+ "pillow>=10.0.0",
+ # WebSocket for skills recording
+ "websockets>=12.0",
+]
+
+[project.optional-dependencies]
+# MCP server support
+mcp = [
+ "fastmcp>=2.0",
+]
+# Skills recording with LLM captioning
+skills = [
+ "litellm>=1.74.0",
+]
+# Full installation
+all = [
+ "cua-cli[mcp,skills]",
+]
+# Development
+dev = [
+ "pytest>=8.0.0",
+ "pytest-asyncio>=0.23.0",
+ "pytest-cov>=4.0.0",
+ "ruff>=0.1.0",
+ "respx>=0.20.0",
+]
+
+[project.urls]
+Homepage = "https://github.com/trycua/cua"
+Documentation = "https://docs.trycua.com"
+Repository = "https://github.com/trycua/cua"
+Issues = "https://github.com/trycua/cua/issues"
+
+[project.scripts]
+cua = "cua_cli.main:main"
+
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[tool.hatch.build]
+include = [
+ "cua_cli/**",
+ "README.md",
+ "LICENSE",
+]
+exclude = [
+ "cua_cli/**/__pycache__",
+ "cua_cli/**/tests",
+ "**/.DS_Store",
+]
+
+[tool.hatch.build.targets.wheel]
+packages = ["cua_cli"]
+
+[tool.hatch.build.targets.sdist]
+include = [
+ "cua_cli/**",
+ "README.md",
+ "LICENSE",
+ "pyproject.toml",
+]
+
+[tool.ruff]
+line-length = 100
+target-version = "py312"
+
+[tool.ruff.lint]
+select = ["E", "F", "W"]
+ignore = ["E501"]
+
+[tool.pytest.ini_options]
+asyncio_mode = "auto"
+testpaths = ["tests"]
diff --git a/libs/python/cua-cli/tests/__init__.py b/libs/python/cua-cli/tests/__init__.py
new file mode 100644
index 0000000000..77c030dc64
--- /dev/null
+++ b/libs/python/cua-cli/tests/__init__.py
@@ -0,0 +1 @@
+"""Tests for cua-cli."""
diff --git a/libs/python/cua-cli/tests/api/__init__.py b/libs/python/cua-cli/tests/api/__init__.py
new file mode 100644
index 0000000000..09f13ed0d9
--- /dev/null
+++ b/libs/python/cua-cli/tests/api/__init__.py
@@ -0,0 +1 @@
+"""API module tests."""
diff --git a/libs/python/cua-cli/tests/auth/__init__.py b/libs/python/cua-cli/tests/auth/__init__.py
new file mode 100644
index 0000000000..5c7f8a6223
--- /dev/null
+++ b/libs/python/cua-cli/tests/auth/__init__.py
@@ -0,0 +1 @@
+"""Auth module tests."""
diff --git a/libs/python/cua-cli/tests/auth/test_store.py b/libs/python/cua-cli/tests/auth/test_store.py
new file mode 100644
index 0000000000..f0d8484bfa
--- /dev/null
+++ b/libs/python/cua-cli/tests/auth/test_store.py
@@ -0,0 +1,230 @@
+"""Tests for auth.store module."""
+
+import sqlite3
+import threading
+from unittest.mock import patch
+
+import pytest
+from cua_cli.auth.store import (
+ CredentialStore,
+ clear_credentials,
+ get_api_key,
+ require_api_key,
+ save_api_key,
+)
+
+
+class TestCredentialStore:
+ """Tests for CredentialStore class."""
+
+ def test_init_creates_database(self, tmp_path):
+ """Test that initializing creates the database file."""
+ db_path = tmp_path / "test.db"
+ CredentialStore(db_path)
+
+ assert db_path.exists()
+
+ def test_init_creates_parent_directory(self, tmp_path):
+ """Test that initializing creates parent directories."""
+ db_path = tmp_path / "nested" / "dir" / "test.db"
+ CredentialStore(db_path)
+
+ assert db_path.parent.exists()
+ assert db_path.exists()
+
+ def test_set_and_get(self, tmp_path):
+ """Test setting and getting a value."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ store.set("test_key", "test_value")
+ result = store.get("test_key")
+
+ assert result == "test_value"
+
+ def test_get_nonexistent_key(self, tmp_path):
+ """Test getting a nonexistent key returns None."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ result = store.get("nonexistent")
+
+ assert result is None
+
+ def test_set_overwrites_existing(self, tmp_path):
+ """Test that setting an existing key overwrites the value."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ store.set("key", "value1")
+ store.set("key", "value2")
+ result = store.get("key")
+
+ assert result == "value2"
+
+ def test_delete_existing_key(self, tmp_path):
+ """Test deleting an existing key returns True."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ store.set("key", "value")
+ result = store.delete("key")
+
+ assert result is True
+ assert store.get("key") is None
+
+ def test_delete_nonexistent_key(self, tmp_path):
+ """Test deleting a nonexistent key returns False."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ result = store.delete("nonexistent")
+
+ assert result is False
+
+ def test_clear_removes_all(self, tmp_path):
+ """Test that clear removes all values."""
+ store = CredentialStore(tmp_path / "test.db")
+
+ store.set("key1", "value1")
+ store.set("key2", "value2")
+ store.clear()
+
+ assert store.get("key1") is None
+ assert store.get("key2") is None
+
+ def test_wal_mode_enabled(self, tmp_path):
+ """Test that WAL mode is enabled for concurrent access."""
+ db_path = tmp_path / "test.db"
+ CredentialStore(db_path)
+
+ conn = sqlite3.connect(db_path)
+ try:
+ cursor = conn.execute("PRAGMA journal_mode")
+ mode = cursor.fetchone()[0]
+ assert mode.lower() == "wal"
+ finally:
+ conn.close()
+
+ def test_concurrent_access(self, tmp_path):
+ """Test that concurrent access works with WAL mode."""
+ db_path = tmp_path / "test.db"
+ store = CredentialStore(db_path)
+ results = []
+ errors = []
+
+ def writer():
+ try:
+ for i in range(10):
+ store.set(f"key_{i}", f"value_{i}")
+ except Exception as e:
+ errors.append(e)
+
+ def reader():
+ try:
+ for i in range(10):
+ result = store.get(f"key_{i}")
+ if result is not None:
+ results.append(result)
+ except Exception as e:
+ errors.append(e)
+
+ threads = [
+ threading.Thread(target=writer),
+ threading.Thread(target=reader),
+ threading.Thread(target=reader),
+ ]
+
+ for t in threads:
+ t.start()
+ for t in threads:
+ t.join()
+
+ assert len(errors) == 0
+
+
+class TestGetApiKey:
+ """Tests for get_api_key function."""
+
+ def test_returns_env_var_first(self, monkeypatch, tmp_path):
+ """Test that environment variable takes precedence."""
+ # Set up a store with a different value
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.setenv("CUA_API_KEY", "env-key")
+ save_api_key("stored-key")
+
+ result = get_api_key()
+
+ assert result == "env-key"
+
+ def test_falls_back_to_stored(self, monkeypatch, tmp_path):
+ """Test that stored key is used when env var not set."""
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+ save_api_key("stored-key")
+
+ result = get_api_key()
+
+ assert result == "stored-key"
+
+ def test_returns_none_when_not_found(self, monkeypatch, tmp_path):
+ """Test that None is returned when no key is found."""
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+
+ result = get_api_key()
+
+ assert result is None
+
+
+class TestSaveApiKey:
+ """Tests for save_api_key function."""
+
+ def test_saves_api_key(self, tmp_path, monkeypatch):
+ """Test that API key is saved correctly."""
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+
+ save_api_key("my-api-key")
+ result = get_api_key()
+
+ assert result == "my-api-key"
+
+
+class TestClearCredentials:
+ """Tests for clear_credentials function."""
+
+ def test_clears_all_credentials(self, tmp_path, monkeypatch):
+ """Test that all credentials are cleared."""
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+
+ save_api_key("my-api-key")
+ clear_credentials()
+ result = get_api_key()
+
+ assert result is None
+
+
+class TestRequireApiKey:
+ """Tests for require_api_key function."""
+
+ def test_returns_key_when_available(self, monkeypatch):
+ """Test that key is returned when available."""
+ monkeypatch.setenv("CUA_API_KEY", "my-api-key")
+
+ result = require_api_key()
+
+ assert result == "my-api-key"
+
+ def test_raises_when_not_available(self, monkeypatch, tmp_path):
+ """Test that RuntimeError is raised when no key available."""
+ with patch("cua_cli.auth.store.CREDENTIALS_DB", tmp_path / "test.db"):
+ with patch("cua_cli.auth.store._store", None):
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+
+ with pytest.raises(RuntimeError) as exc_info:
+ require_api_key()
+
+ assert "No API key configured" in str(exc_info.value)
+ assert "cua auth login" in str(exc_info.value)
diff --git a/libs/python/cua-cli/tests/commands/__init__.py b/libs/python/cua-cli/tests/commands/__init__.py
new file mode 100644
index 0000000000..1ee51794d9
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/__init__.py
@@ -0,0 +1 @@
+"""Command module tests."""
diff --git a/libs/python/cua-cli/tests/commands/test_auth.py b/libs/python/cua-cli/tests/commands/test_auth.py
new file mode 100644
index 0000000000..457997a6ee
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/test_auth.py
@@ -0,0 +1,200 @@
+"""Tests for auth command module."""
+
+import argparse
+from unittest.mock import patch
+
+from cua_cli.commands import auth
+
+
+class TestRegisterParser:
+ """Tests for register_parser function."""
+
+ def test_registers_auth_command(self):
+ """Test that auth command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ auth.register_parser(subparsers)
+
+ args = parser.parse_args(["auth", "login"])
+ assert args.auth_command == "login"
+
+ def test_login_has_api_key_flag(self):
+ """Test that login has --api-key flag."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ auth.register_parser(subparsers)
+
+ args = parser.parse_args(["auth", "login", "--api-key", "my-key"])
+ assert args.api_key == "my-key"
+
+ def test_logout_command(self):
+ """Test that logout command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ auth.register_parser(subparsers)
+
+ args = parser.parse_args(["auth", "logout"])
+ assert args.auth_command == "logout"
+
+ def test_env_command(self):
+ """Test that env command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ auth.register_parser(subparsers)
+
+ args = parser.parse_args(["auth", "env"])
+ assert args.auth_command == "env"
+
+
+class TestExecute:
+ """Tests for execute function."""
+
+ def test_dispatch_to_login(self, args_namespace):
+ """Test dispatch to login command."""
+ args = args_namespace(command="auth", auth_command="login", api_key=False)
+
+ with patch.object(auth, "cmd_login", return_value=0) as mock_cmd:
+ result = auth.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+ assert result == 0
+
+ def test_dispatch_to_logout(self, args_namespace):
+ """Test dispatch to logout command."""
+ args = args_namespace(command="auth", auth_command="logout")
+
+ with patch.object(auth, "cmd_logout", return_value=0) as mock_cmd:
+ auth.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_dispatch_to_env(self, args_namespace):
+ """Test dispatch to env command."""
+ args = args_namespace(command="auth", auth_command="env")
+
+ with patch.object(auth, "cmd_env", return_value=0) as mock_cmd:
+ auth.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_unknown_command_returns_error(self, args_namespace):
+ """Test that unknown command returns error."""
+ args = args_namespace(command="auth", auth_command=None)
+
+ with patch.object(auth, "print_error"):
+ result = auth.execute(args)
+
+ assert result == 1
+
+
+class TestCmdLogin:
+ """Tests for cmd_login function."""
+
+ def test_login_with_api_key_direct(self, args_namespace):
+ """Test login with --api-key flag and value."""
+ args = args_namespace(api_key="test-api-key")
+
+ with patch.object(auth, "get_api_key", return_value=None):
+ with patch.object(auth, "save_api_key") as mock_save:
+ with patch.object(auth, "print_info"):
+ with patch.object(auth, "print_success"):
+ result = auth.cmd_login(args)
+
+ mock_save.assert_called_once_with("test-api-key")
+ assert result == 0
+
+ def test_login_already_authenticated(self, args_namespace):
+ """Test login when already authenticated."""
+ args = args_namespace(api_key=None)
+
+ with patch.object(auth, "get_api_key", return_value="existing-key"):
+ with patch.object(auth, "print_info") as mock_info:
+ result = auth.cmd_login(args)
+
+ assert result == 0
+ mock_info.assert_called()
+
+ def test_login_browser_flow(self, args_namespace):
+ """Test login with browser OAuth flow."""
+ args = args_namespace(api_key=None)
+
+ with patch.object(auth, "get_api_key", return_value=None):
+ with patch.object(auth, "run_async") as mock_run:
+ mock_run.return_value = "browser-api-key"
+ with patch.object(auth, "save_api_key") as mock_save:
+ with patch.object(auth, "print_success"):
+ result = auth.cmd_login(args)
+
+ mock_save.assert_called_once_with("browser-api-key")
+ assert result == 0
+
+ def test_login_browser_flow_timeout(self, args_namespace):
+ """Test login when browser flow times out."""
+ args = args_namespace(api_key=None)
+
+ with patch.object(auth, "get_api_key", return_value=None):
+ with patch.object(auth, "run_async") as mock_run:
+ mock_run.side_effect = TimeoutError("Authentication timed out")
+ with patch.object(auth, "print_error"):
+ result = auth.cmd_login(args)
+
+ assert result == 1
+
+
+class TestCmdLogout:
+ """Tests for cmd_logout function."""
+
+ def test_logout_clears_credentials(self, args_namespace):
+ """Test that logout clears credentials."""
+ args = args_namespace()
+
+ with patch.object(auth, "clear_credentials") as mock_clear:
+ with patch.object(auth, "print_success"):
+ result = auth.cmd_logout(args)
+
+ mock_clear.assert_called_once()
+ assert result == 0
+
+
+class TestCmdEnv:
+ """Tests for cmd_env function."""
+
+ def test_env_writes_to_dotenv(self, args_namespace, tmp_path, monkeypatch):
+ """Test that env command writes to .env file."""
+ args = args_namespace(file=str(tmp_path / ".env"))
+
+ with patch.object(auth, "get_api_key", return_value="test-api-key"):
+ with patch.object(auth, "print_success"):
+ result = auth.cmd_env(args)
+
+ assert result == 0
+ env_file = tmp_path / ".env"
+ assert env_file.exists()
+ content = env_file.read_text()
+ assert "CUA_API_KEY=test-api-key" in content
+
+ def test_env_no_credentials_fails(self, args_namespace, tmp_path):
+ """Test that env command fails when not logged in."""
+ args = args_namespace(file=str(tmp_path / ".env"))
+
+ with patch.object(auth, "get_api_key", return_value=None):
+ with patch.object(auth, "print_error"):
+ result = auth.cmd_env(args)
+
+ assert result == 1
+
+ def test_env_appends_to_existing_dotenv(self, args_namespace, tmp_path):
+ """Test that env command appends to existing .env file."""
+ env_file = tmp_path / ".env"
+ env_file.write_text("EXISTING_VAR=value\n")
+ args = args_namespace(file=str(env_file))
+
+ with patch.object(auth, "get_api_key", return_value="test-api-key"):
+ with patch.object(auth, "print_success"):
+ result = auth.cmd_env(args)
+
+ assert result == 0
+ content = env_file.read_text()
+ assert "EXISTING_VAR=value" in content
+ assert "CUA_API_KEY=test-api-key" in content
diff --git a/libs/python/cua-cli/tests/commands/test_image.py b/libs/python/cua-cli/tests/commands/test_image.py
new file mode 100644
index 0000000000..b27fdf9196
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/test_image.py
@@ -0,0 +1,297 @@
+"""Tests for image command module."""
+
+import argparse
+from unittest.mock import patch
+
+from cua_cli.commands import image
+
+
+class TestRegisterParser:
+ """Tests for register_parser function."""
+
+ def test_registers_image_command(self):
+ """Test that image command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "list"])
+ assert args.image_command == "list"
+
+ def test_registers_img_alias(self):
+ """Test that img alias is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["img", "list"])
+ assert args.image_command == "list"
+
+ def test_list_has_json_flag(self):
+ """Test that list command has --json flag."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "list", "--json"])
+ assert args.json is True
+
+ def test_list_has_local_flag(self):
+ """Test that list command has --local flag."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "list", "--local"])
+ assert args.local is True
+
+ def test_push_command(self):
+ """Test that push command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "push", "my-image"])
+ assert args.image_command == "push"
+ assert args.name == "my-image"
+
+ def test_pull_command(self):
+ """Test that pull command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "pull", "my-image"])
+ assert args.image_command == "pull"
+ assert args.name == "my-image"
+
+ def test_delete_command(self):
+ """Test that delete command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ image.register_parser(subparsers)
+
+ args = parser.parse_args(["image", "delete", "my-image", "--force"])
+ assert args.image_command == "delete"
+ assert args.name == "my-image"
+ assert args.force is True
+
+
+class TestExecute:
+ """Tests for execute function."""
+
+ def test_dispatch_to_list(self, args_namespace):
+ """Test dispatch to list command."""
+ args = args_namespace(
+ command="image",
+ image_command="list",
+ json=False,
+ local=False,
+ cloud=False,
+ )
+
+ with patch.object(image, "cmd_list", return_value=0) as mock_cmd:
+ result = image.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+ assert result == 0
+
+ def test_dispatch_to_push(self, args_namespace):
+ """Test dispatch to push command."""
+ args = args_namespace(command="image", image_command="push", name="my-image")
+
+ with patch.object(image, "cmd_push", return_value=0) as mock_cmd:
+ image.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_dispatch_to_pull(self, args_namespace):
+ """Test dispatch to pull command."""
+ args = args_namespace(command="image", image_command="pull", name="my-image")
+
+ with patch.object(image, "cmd_pull", return_value=0) as mock_cmd:
+ image.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_dispatch_to_delete(self, args_namespace):
+ """Test dispatch to delete command."""
+ args = args_namespace(command="image", image_command="delete", name="my-image")
+
+ with patch.object(image, "cmd_delete", return_value=0) as mock_cmd:
+ image.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_unknown_command_returns_error(self, args_namespace):
+ """Test that unknown command returns error."""
+ args = args_namespace(command="image", image_command=None)
+
+ with patch.object(image, "print_error"):
+ result = image.execute(args)
+
+ assert result == 1
+
+
+class TestCmdList:
+ """Tests for cmd_list function."""
+
+ def test_list_cloud_images(self, args_namespace, sample_cloud_images, mock_api_key):
+ """Test listing cloud images."""
+ args = args_namespace(json=False, local=False, cloud=True)
+
+ with patch.object(image, "run_async") as mock_run:
+ mock_run.return_value = [
+ {
+ "name": "ubuntu-22.04",
+ "type": "qcow2",
+ "tag": "latest",
+ "size": "5.0 GB",
+ "status": "ready",
+ "created": "2024-01-10",
+ "source": "cloud",
+ }
+ ]
+ with patch.object(image, "print_table") as mock_print:
+ result = image.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once()
+
+ def test_list_local_images(self, args_namespace, tmp_path, monkeypatch):
+ """Test listing local images delegates to local_image."""
+ args = args_namespace(json=False, local=True, cloud=False)
+
+ with patch("cua_cli.commands.local_image.cmd_local_list", return_value=0) as mock_local:
+ result = image.cmd_list(args)
+
+ assert result == 0
+ mock_local.assert_called_once_with(args)
+
+ def test_list_empty(self, args_namespace, tmp_path, monkeypatch):
+ """Test listing when no local images exist."""
+ args = args_namespace(json=False, local=True, cloud=False)
+
+ with patch("cua_cli.commands.local_image.cmd_local_list", return_value=0) as mock_local:
+ result = image.cmd_list(args)
+
+ assert result == 0
+ mock_local.assert_called_once()
+
+ def test_list_json_output(self, args_namespace, mock_api_key):
+ """Test JSON output format."""
+ args = args_namespace(json=True, local=False, cloud=True)
+
+ with patch.object(image, "run_async") as mock_run:
+ mock_run.return_value = [{"name": "test", "source": "cloud"}]
+ with patch.object(image, "print_json") as mock_print:
+ result = image.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once()
+
+
+class TestCmdPush:
+ """Tests for cmd_push function."""
+
+ def test_push_success(self, args_namespace, temp_image_file, mock_api_key):
+ """Test successful image push."""
+ args = args_namespace(
+ name="test-image",
+ tag="latest",
+ type="qcow2",
+ file=str(temp_image_file),
+ )
+
+ with patch.object(image, "run_async") as mock_run:
+ mock_run.return_value = 0
+ result = image.cmd_push(args)
+
+ assert result == 0
+
+ def test_push_file_not_found(self, args_namespace, mock_api_key):
+ """Test push with nonexistent file."""
+ args = args_namespace(
+ name="test-image",
+ tag="latest",
+ type="qcow2",
+ file="/nonexistent/path",
+ )
+
+ with patch.object(image, "print_error") as mock_error:
+ result = image.cmd_push(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdPull:
+ """Tests for cmd_pull function."""
+
+ def test_pull_success(self, args_namespace, tmp_path, mock_api_key):
+ """Test successful image pull."""
+ args = args_namespace(
+ name="test-image",
+ tag="latest",
+ output=str(tmp_path / "output.qcow2"),
+ )
+
+ with patch.object(image, "run_async") as mock_run:
+ mock_run.return_value = 0
+ result = image.cmd_pull(args)
+
+ assert result == 0
+
+
+class TestCmdDelete:
+ """Tests for cmd_delete function."""
+
+ def test_delete_with_force(self, args_namespace, mock_api_key):
+ """Test delete with --force flag."""
+ args = args_namespace(name="test-image", tag="latest", force=True, local=False)
+
+ with patch.object(image, "run_async") as mock_run:
+ mock_run.return_value = 0
+ result = image.cmd_delete(args)
+
+ assert result == 0
+
+ def test_delete_without_force_prompts(self, args_namespace, mock_api_key):
+ """Test delete without --force shows prompt."""
+ args = args_namespace(name="test-image", tag="latest", force=False, local=False)
+
+ with patch.object(image, "print_info") as mock_print:
+ result = image.cmd_delete(args)
+
+ assert result == 1
+ mock_print.assert_called()
+
+ def test_delete_local_delegates(self, args_namespace):
+ """Test delete with --local delegates to local_image."""
+ args = args_namespace(name="test-image", tag="latest", force=True, local=True)
+
+ with patch("cua_cli.commands.local_image.cmd_local_delete", return_value=0) as mock_local:
+ result = image.cmd_delete(args)
+
+ assert result == 0
+ mock_local.assert_called_once_with(args)
+
+
+class TestHelperFunctions:
+ """Tests for helper functions."""
+
+ def test_format_date_valid(self):
+ """Test formatting a valid ISO date."""
+ result = image._format_date("2024-01-15T10:30:00Z")
+ assert result == "2024-01-15"
+
+ def test_format_date_empty(self):
+ """Test formatting empty string."""
+ result = image._format_date("")
+ assert result == "-"
+
+ def test_format_date_invalid(self):
+ """Test formatting invalid date."""
+ result = image._format_date("not-a-date")
+ assert result == "not-a-date" # Falls back to first 10 chars
diff --git a/libs/python/cua-cli/tests/commands/test_mcp.py b/libs/python/cua-cli/tests/commands/test_mcp.py
new file mode 100644
index 0000000000..33db5e3d1e
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/test_mcp.py
@@ -0,0 +1,232 @@
+"""Tests for MCP server command module."""
+
+import argparse
+import sys
+from unittest.mock import patch
+
+from cua_cli.commands.mcp import (
+ PERMISSION_GROUPS,
+ Permission,
+ execute,
+ parse_permissions,
+ register_parser,
+)
+
+
+class TestPermission:
+ """Tests for Permission enum."""
+
+ def test_all_permissions_have_values(self):
+ """Test that all permissions have string values."""
+ for perm in Permission:
+ assert isinstance(perm.value, str)
+ assert ":" in perm.value
+
+ def test_sandbox_permissions(self):
+ """Test sandbox permission values."""
+ assert Permission.SANDBOX_LIST.value == "sandbox:list"
+ assert Permission.SANDBOX_CREATE.value == "sandbox:create"
+ assert Permission.SANDBOX_DELETE.value == "sandbox:delete"
+
+ def test_computer_permissions(self):
+ """Test computer permission values."""
+ assert Permission.COMPUTER_SCREENSHOT.value == "computer:screenshot"
+ assert Permission.COMPUTER_CLICK.value == "computer:click"
+ assert Permission.COMPUTER_TYPE.value == "computer:type"
+
+ def test_skills_permissions(self):
+ """Test skills permission values."""
+ assert Permission.SKILLS_LIST.value == "skills:list"
+ assert Permission.SKILLS_READ.value == "skills:read"
+ assert Permission.SKILLS_RECORD.value == "skills:record"
+
+
+class TestPermissionGroups:
+ """Tests for permission groups."""
+
+ def test_sandbox_all_group(self):
+ """Test sandbox:all group contains all sandbox permissions."""
+ group = PERMISSION_GROUPS["sandbox:all"]
+ assert Permission.SANDBOX_LIST in group
+ assert Permission.SANDBOX_CREATE in group
+ assert Permission.SANDBOX_DELETE in group
+ assert Permission.SANDBOX_START in group
+ assert Permission.SANDBOX_STOP in group
+
+ def test_sandbox_readonly_group(self):
+ """Test sandbox:readonly group contains only read permissions."""
+ group = PERMISSION_GROUPS["sandbox:readonly"]
+ assert Permission.SANDBOX_LIST in group
+ assert Permission.SANDBOX_GET in group
+ assert Permission.SANDBOX_CREATE not in group
+ assert Permission.SANDBOX_DELETE not in group
+
+ def test_computer_all_group(self):
+ """Test computer:all group contains all computer permissions."""
+ group = PERMISSION_GROUPS["computer:all"]
+ assert Permission.COMPUTER_SCREENSHOT in group
+ assert Permission.COMPUTER_CLICK in group
+ assert Permission.COMPUTER_TYPE in group
+ assert Permission.COMPUTER_SHELL in group
+
+ def test_computer_readonly_group(self):
+ """Test computer:readonly group contains only screenshot."""
+ group = PERMISSION_GROUPS["computer:readonly"]
+ assert Permission.COMPUTER_SCREENSHOT in group
+ assert Permission.COMPUTER_CLICK not in group
+
+ def test_all_group_contains_everything(self):
+ """Test that 'all' group contains all permissions."""
+ group = PERMISSION_GROUPS["all"]
+ assert len(group) == len(Permission)
+
+
+class TestParsePermissions:
+ """Tests for parse_permissions function."""
+
+ def test_empty_string_returns_empty_set(self):
+ """Test that empty string returns empty set."""
+ result = parse_permissions("")
+ assert result == set()
+
+ def test_single_permission(self):
+ """Test parsing a single permission."""
+ result = parse_permissions("sandbox:list")
+ assert result == {Permission.SANDBOX_LIST}
+
+ def test_multiple_permissions(self):
+ """Test parsing multiple permissions."""
+ result = parse_permissions("sandbox:list,sandbox:create")
+ assert result == {Permission.SANDBOX_LIST, Permission.SANDBOX_CREATE}
+
+ def test_permission_with_spaces(self):
+ """Test parsing permissions with spaces."""
+ result = parse_permissions("sandbox:list, sandbox:create")
+ assert result == {Permission.SANDBOX_LIST, Permission.SANDBOX_CREATE}
+
+ def test_group_expansion(self):
+ """Test that groups are expanded."""
+ result = parse_permissions("sandbox:readonly")
+ assert Permission.SANDBOX_LIST in result
+ assert Permission.SANDBOX_GET in result
+
+ def test_all_group(self):
+ """Test that 'all' group includes everything."""
+ result = parse_permissions("all")
+ assert len(result) == len(Permission)
+
+ def test_mixed_groups_and_permissions(self):
+ """Test mixing groups and individual permissions."""
+ result = parse_permissions("sandbox:readonly,computer:screenshot")
+ assert Permission.SANDBOX_LIST in result
+ assert Permission.SANDBOX_GET in result
+ assert Permission.COMPUTER_SCREENSHOT in result
+
+ def test_unknown_permission_ignored(self):
+ """Test that unknown permissions are ignored with warning."""
+ with patch("cua_cli.commands.mcp.logger") as mock_logger:
+ result = parse_permissions("sandbox:list,unknown:perm")
+
+ assert result == {Permission.SANDBOX_LIST}
+ mock_logger.warning.assert_called()
+
+
+class TestRegisterParser:
+ """Tests for register_parser function."""
+
+ def test_registers_serve_mcp_command(self):
+ """Test that serve-mcp command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ register_parser(subparsers)
+
+ args = parser.parse_args(["serve-mcp"])
+ assert hasattr(args, "permissions")
+
+ def test_has_permissions_flag(self):
+ """Test that --permissions flag is available."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ register_parser(subparsers)
+
+ args = parser.parse_args(["serve-mcp", "--permissions", "sandbox:all"])
+ assert args.permissions == "sandbox:all"
+
+ def test_has_sandbox_flag(self):
+ """Test that --sandbox flag is available."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ register_parser(subparsers)
+
+ args = parser.parse_args(["serve-mcp", "--sandbox", "my-sandbox"])
+ assert args.sandbox == "my-sandbox"
+
+
+class TestExecute:
+ """Tests for execute function."""
+
+ def test_missing_fastmcp_returns_error(self, args_namespace, capsys):
+ """Test that missing fastmcp dependency returns error."""
+
+ args = args_namespace(permissions="", sandbox="")
+
+ # Temporarily remove mcp modules to simulate ImportError
+ original_modules = {}
+ for mod in list(sys.modules.keys()):
+ if mod.startswith("mcp"):
+ original_modules[mod] = sys.modules.pop(mod)
+
+ try:
+ with patch.dict(
+ "sys.modules", {"mcp": None, "mcp.server": None, "mcp.server.fastmcp": None}
+ ):
+ result = execute(args)
+ finally:
+ # Restore modules
+ sys.modules.update(original_modules)
+
+ assert result == 1
+
+ def test_permissions_from_env_var(self, args_namespace, monkeypatch):
+ """Test that permissions are read from environment variable."""
+ monkeypatch.setenv("CUA_MCP_PERMISSIONS", "sandbox:readonly")
+
+ permissions = parse_permissions("sandbox:readonly")
+ assert Permission.SANDBOX_LIST in permissions
+ assert Permission.SANDBOX_CREATE not in permissions
+
+ def test_permissions_from_args_override_env(self, args_namespace, monkeypatch):
+ """Test that command line args override environment variable."""
+ args = args_namespace(permissions="computer:all", sandbox="")
+ monkeypatch.setenv("CUA_MCP_PERMISSIONS", "sandbox:readonly")
+
+ # The args.permissions should take precedence
+ assert args.permissions == "computer:all"
+
+
+class TestMCPToolRegistration:
+ """Tests for MCP tool registration based on permissions."""
+
+ def test_permission_affects_tool_registration(self):
+ """Test that permissions control which tools would be registered."""
+ # This is a unit test of the permission logic, not the actual registration
+ # The actual registration requires fastmcp which may not be installed
+
+ all_perms = parse_permissions("all")
+ assert len(all_perms) == len(Permission)
+
+ readonly_perms = parse_permissions("sandbox:readonly")
+ assert Permission.SANDBOX_LIST in readonly_perms
+ assert Permission.SANDBOX_CREATE not in readonly_perms
+
+ # Test that the registration functions exist and are callable
+ from cua_cli.commands.mcp import (
+ _register_computer_tools,
+ _register_sandbox_tools,
+ _register_skills_tools,
+ )
+
+ assert callable(_register_sandbox_tools)
+ assert callable(_register_computer_tools)
+ assert callable(_register_skills_tools)
diff --git a/libs/python/cua-cli/tests/commands/test_sandbox.py b/libs/python/cua-cli/tests/commands/test_sandbox.py
new file mode 100644
index 0000000000..b0db8b2280
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/test_sandbox.py
@@ -0,0 +1,442 @@
+"""Tests for sandbox command module."""
+
+import argparse
+from unittest.mock import AsyncMock, MagicMock, patch
+
+from cua_cli.commands import sandbox
+
+
+class TestRegisterParser:
+ """Tests for register_parser function."""
+
+ def test_registers_sandbox_command(self):
+ """Test that sandbox command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ sandbox.register_parser(subparsers)
+
+ # Parse a sandbox command to verify it's registered
+ args = parser.parse_args(["sandbox", "list"])
+ assert args.sandbox_command == "list"
+
+ def test_registers_sb_alias(self):
+ """Test that sb alias is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ sandbox.register_parser(subparsers)
+
+ # Parse using alias
+ args = parser.parse_args(["sb", "list"])
+ assert args.sandbox_command == "list"
+
+ def test_list_command_has_json_flag(self):
+ """Test that list command has --json flag."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ sandbox.register_parser(subparsers)
+
+ args = parser.parse_args(["sandbox", "list", "--json"])
+ assert args.json is True
+
+ def test_create_command_has_required_args(self):
+ """Test that create command has required arguments."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ sandbox.register_parser(subparsers)
+
+ args = parser.parse_args(
+ [
+ "sandbox",
+ "create",
+ "--os",
+ "linux",
+ "--size",
+ "medium",
+ "--region",
+ "north-america",
+ ]
+ )
+ assert args.os == "linux"
+ assert args.size == "medium"
+ assert args.region == "north-america"
+
+
+class TestExecute:
+ """Tests for execute function."""
+
+ def test_dispatch_to_list(self, args_namespace):
+ """Test dispatch to list command."""
+ args = args_namespace(
+ command="sandbox", sandbox_command="list", json=False, show_passwords=False
+ )
+
+ with patch.object(sandbox, "cmd_list", return_value=0) as mock_cmd:
+ result = sandbox.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+ assert result == 0
+
+ def test_dispatch_to_list_alias(self, args_namespace):
+ """Test dispatch to list command via ls alias."""
+ args = args_namespace(command="sb", sandbox_command="ls", json=False, show_passwords=False)
+
+ with patch.object(sandbox, "cmd_list", return_value=0) as mock_cmd:
+ sandbox.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_unknown_command_returns_error(self, args_namespace):
+ """Test that unknown command returns error."""
+ args = args_namespace(command="sandbox", sandbox_command=None)
+
+ with patch.object(sandbox, "print_error") as mock_error:
+ result = sandbox.execute(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdList:
+ """Tests for cmd_list function."""
+
+ def test_list_sandboxes_success(self, args_namespace, sample_vm_list, mock_api_key):
+ """Test listing sandboxes successfully."""
+ args = args_namespace(json=False, show_passwords=False)
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=sample_vm_list)
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_table") as mock_print:
+ result = sandbox.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once()
+
+ def test_list_sandboxes_empty(self, args_namespace, mock_api_key):
+ """Test listing when no sandboxes exist."""
+ args = args_namespace(json=False, show_passwords=False)
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[])
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_info") as mock_print:
+ result = sandbox.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_with("No sandboxes found.")
+
+ def test_list_sandboxes_json_output(self, args_namespace, sample_vm_list, mock_api_key):
+ """Test JSON output format."""
+ args = args_namespace(json=True, show_passwords=False)
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=sample_vm_list)
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_json") as mock_print:
+ result = sandbox.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once_with(sample_vm_list)
+
+
+class TestCmdCreate:
+ """Tests for cmd_create function."""
+
+ def test_create_sandbox_success(self, args_namespace, mock_api_key):
+ """Test creating a sandbox successfully."""
+ args = args_namespace(
+ os="linux",
+ size="medium",
+ region="north-america",
+ json=False,
+ )
+
+ # Mock the API response (status 202 = provisioning)
+ async def mock_api_request(*args, **kwargs):
+ return (
+ 202,
+ {
+ "status": "provisioning",
+ "name": "new-sandbox",
+ "host": "sandbox.example.com",
+ },
+ )
+
+ with patch.object(sandbox, "_api_request", side_effect=mock_api_request):
+ with patch.object(sandbox, "print_info"):
+ result = sandbox.cmd_create(args)
+
+ assert result == 0
+
+ def test_create_sandbox_error(self, args_namespace, mock_api_key):
+ """Test handling create error."""
+ args = args_namespace(
+ os="linux",
+ size="medium",
+ region="north-america",
+ json=False,
+ )
+
+ # Mock the API response (status 500 = error)
+ async def mock_api_request(*args, **kwargs):
+ return (500, "Quota exceeded")
+
+ with patch.object(sandbox, "_api_request", side_effect=mock_api_request):
+ with patch.object(sandbox, "print_error") as mock_error:
+ result = sandbox.cmd_create(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdGet:
+ """Tests for cmd_get function."""
+
+ def test_get_sandbox_success(self, args_namespace, sample_vm, mock_api_key):
+ """Test getting sandbox details."""
+ args = args_namespace(
+ name="test-sandbox-1",
+ json=False,
+ show_passwords=False,
+ show_vnc_url=False,
+ )
+
+ vm_dict = {
+ "name": sample_vm.name,
+ "status": sample_vm.status,
+ "os_type": sample_vm.os_type,
+ "host": "sandbox.example.com",
+ }
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[vm_dict])
+ mock_provider.get_vm = AsyncMock(return_value={"status": "running"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_info"):
+ result = sandbox.cmd_get(args)
+
+ assert result == 0
+
+ def test_get_sandbox_not_found(self, args_namespace, mock_api_key):
+ """Test getting nonexistent sandbox."""
+ args = args_namespace(
+ name="nonexistent",
+ json=False,
+ show_passwords=False,
+ show_vnc_url=False,
+ )
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[])
+ mock_provider.get_vm = AsyncMock(return_value={"status": "not_found"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_error") as mock_error:
+ result = sandbox.cmd_get(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdStart:
+ """Tests for cmd_start function."""
+
+ def test_start_sandbox_success(self, args_namespace, mock_api_key):
+ """Test starting a sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.run_vm = AsyncMock(return_value={"status": "starting"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_success"):
+ result = sandbox.cmd_start(args)
+
+ assert result == 0
+
+ def test_start_sandbox_not_found(self, args_namespace, mock_api_key):
+ """Test starting nonexistent sandbox."""
+ args = args_namespace(name="nonexistent")
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.run_vm = AsyncMock(return_value={"status": "not_found"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_error"):
+ result = sandbox.cmd_start(args)
+
+ assert result == 1
+
+
+class TestCmdStop:
+ """Tests for cmd_stop function."""
+
+ def test_stop_sandbox_success(self, args_namespace, mock_api_key):
+ """Test stopping a sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.stop_vm = AsyncMock(return_value={"status": "stopping"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_success"):
+ result = sandbox.cmd_stop(args)
+
+ assert result == 0
+
+
+class TestCmdRestart:
+ """Tests for cmd_restart function."""
+
+ def test_restart_sandbox_success(self, args_namespace, mock_api_key):
+ """Test restarting a sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.restart_vm = AsyncMock(return_value={"status": "restarting"})
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_success"):
+ result = sandbox.cmd_restart(args)
+
+ assert result == 0
+
+
+class TestCmdSuspend:
+ """Tests for cmd_suspend function."""
+
+ def test_suspend_sandbox_success(self, args_namespace, mock_api_key):
+ """Test suspending a sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ # Mock the API response (status 202 = suspending)
+ async def mock_api_request(*args, **kwargs):
+ return (202, {"status": "suspending"})
+
+ with patch.object(sandbox, "_api_request", side_effect=mock_api_request):
+ with patch.object(sandbox, "print_success"):
+ result = sandbox.cmd_suspend(args)
+
+ assert result == 0
+
+ def test_suspend_unsupported(self, args_namespace, mock_api_key):
+ """Test suspend on unsupported sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ # Mock the API response (status 400 = unsupported)
+ async def mock_api_request(*args, **kwargs):
+ return (400, "Suspend not supported for Windows")
+
+ with patch.object(sandbox, "_api_request", side_effect=mock_api_request):
+ with patch.object(sandbox, "print_error"):
+ result = sandbox.cmd_suspend(args)
+
+ assert result == 1
+
+
+class TestCmdDelete:
+ """Tests for cmd_delete function."""
+
+ def test_delete_sandbox_success(self, args_namespace, mock_api_key):
+ """Test deleting a sandbox."""
+ args = args_namespace(name="test-sandbox")
+
+ # Mock the API response (status 202 = deleting)
+ async def mock_api_request(*args, **kwargs):
+ return (202, {"status": "deleting"})
+
+ with patch.object(sandbox, "_api_request", side_effect=mock_api_request):
+ with patch.object(sandbox, "print_success"):
+ result = sandbox.cmd_delete(args)
+
+ assert result == 0
+
+
+class TestCmdVnc:
+ """Tests for cmd_vnc function."""
+
+ def test_vnc_opens_browser(self, args_namespace, mock_api_key, mock_webbrowser):
+ """Test VNC opens browser with correct URL."""
+ args = args_namespace(name="test-sandbox")
+
+ vm_info = {
+ "name": "test-sandbox",
+ "vnc_url": "https://vnc.example.com/test",
+ }
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[vm_info])
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_info"):
+ result = sandbox.cmd_vnc(args)
+
+ assert result == 0
+ mock_webbrowser.assert_called_once_with("https://vnc.example.com/test")
+
+ def test_vnc_constructs_url_from_host(self, args_namespace, mock_api_key, mock_webbrowser):
+ """Test VNC constructs URL when vnc_url not provided."""
+ args = args_namespace(name="test-sandbox")
+
+ vm_info = {
+ "name": "test-sandbox",
+ "host": "sandbox.example.com",
+ "password": "secret123",
+ }
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[vm_info])
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_info"):
+ result = sandbox.cmd_vnc(args)
+
+ assert result == 0
+ mock_webbrowser.assert_called_once()
+ # Check URL contains host and encoded password
+ call_url = mock_webbrowser.call_args[0][0]
+ assert "sandbox.example.com" in call_url
+ assert "secret123" in call_url
+
+ def test_vnc_sandbox_not_found(self, args_namespace, mock_api_key):
+ """Test VNC with nonexistent sandbox."""
+ args = args_namespace(name="nonexistent")
+
+ mock_provider = MagicMock()
+ mock_provider.__aenter__ = AsyncMock(return_value=mock_provider)
+ mock_provider.__aexit__ = AsyncMock(return_value=None)
+ mock_provider.list_vms = AsyncMock(return_value=[])
+
+ with patch.object(sandbox, "_get_provider", return_value=mock_provider):
+ with patch.object(sandbox, "print_error"):
+ result = sandbox.cmd_vnc(args)
+
+ assert result == 1
diff --git a/libs/python/cua-cli/tests/commands/test_skills.py b/libs/python/cua-cli/tests/commands/test_skills.py
new file mode 100644
index 0000000000..59b50c55d1
--- /dev/null
+++ b/libs/python/cua-cli/tests/commands/test_skills.py
@@ -0,0 +1,235 @@
+"""Tests for skills command module."""
+
+import argparse
+from unittest.mock import patch
+
+from cua_cli.commands import skills
+
+
+class TestRegisterParser:
+ """Tests for register_parser function."""
+
+ def test_registers_skills_command(self):
+ """Test that skills command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+
+ skills.register_parser(subparsers)
+
+ args = parser.parse_args(["skills", "list"])
+ assert args.skills_command == "list"
+
+ def test_record_command_exists(self):
+ """Test that record command is registered."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ skills.register_parser(subparsers)
+
+ args = parser.parse_args(["skills", "record"])
+ assert args.skills_command == "record"
+
+ def test_record_command_has_sandbox_flag(self):
+ """Test that record command has --sandbox flag."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ skills.register_parser(subparsers)
+
+ args = parser.parse_args(["skills", "record", "--sandbox", "my-sandbox"])
+ assert args.sandbox == "my-sandbox"
+
+ def test_read_command_has_name_arg(self):
+ """Test that read command has name argument."""
+ parser = argparse.ArgumentParser()
+ subparsers = parser.add_subparsers()
+ skills.register_parser(subparsers)
+
+ args = parser.parse_args(["skills", "read", "my-skill"])
+ assert args.name == "my-skill"
+
+
+class TestExecute:
+ """Tests for execute function."""
+
+ def test_dispatch_to_list(self, args_namespace):
+ """Test dispatch to list command."""
+ args = args_namespace(command="skills", skills_command="list", json=False)
+
+ with patch.object(skills, "cmd_list", return_value=0) as mock_cmd:
+ result = skills.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+ assert result == 0
+
+ def test_dispatch_to_read(self, args_namespace):
+ """Test dispatch to read command."""
+ args = args_namespace(command="skills", skills_command="read", name="my-skill")
+
+ with patch.object(skills, "cmd_read", return_value=0) as mock_cmd:
+ skills.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_dispatch_to_delete(self, args_namespace):
+ """Test dispatch to delete command."""
+ args = args_namespace(command="skills", skills_command="delete", name="my-skill")
+
+ with patch.object(skills, "cmd_delete", return_value=0) as mock_cmd:
+ skills.execute(args)
+
+ mock_cmd.assert_called_once_with(args)
+
+ def test_unknown_command_returns_error(self, args_namespace):
+ """Test that unknown command returns error."""
+ args = args_namespace(command="skills", skills_command=None)
+
+ with patch.object(skills, "print_error"):
+ result = skills.execute(args)
+
+ assert result == 1
+
+
+class TestCmdList:
+ """Tests for cmd_list function."""
+
+ def test_list_empty_directory(self, args_namespace, temp_skills_dir):
+ """Test listing when no skills exist."""
+ args = args_namespace(json=False)
+
+ with patch.object(skills, "print_info") as mock_print:
+ result = skills.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called()
+
+ def test_list_with_skills(self, args_namespace, sample_skill, temp_skills_dir):
+ """Test listing existing skills."""
+ args = args_namespace(json=False)
+
+ with patch.object(skills, "print_table") as mock_print:
+ result = skills.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once()
+ # Verify the skill is in the output
+ call_args = mock_print.call_args[0]
+ skill_data = call_args[0]
+ assert len(skill_data) == 1
+ assert skill_data[0]["name"] == "test-skill"
+
+ def test_list_json_output(self, args_namespace, sample_skill, temp_skills_dir):
+ """Test JSON output format."""
+ args = args_namespace(json=True)
+
+ with patch.object(skills, "print_json") as mock_print:
+ result = skills.cmd_list(args)
+
+ assert result == 0
+ mock_print.assert_called_once()
+
+
+class TestCmdRead:
+ """Tests for cmd_read function."""
+
+ def test_read_existing_skill(self, args_namespace, sample_skill, temp_skills_dir, capsys):
+ """Test reading an existing skill."""
+ args = args_namespace(name="test-skill", format="md")
+
+ result = skills.cmd_read(args)
+
+ assert result == 0
+ # Verify content was printed to stdout
+ captured = capsys.readouterr()
+ assert "test-skill" in captured.out
+
+ def test_read_nonexistent_skill(self, args_namespace, temp_skills_dir):
+ """Test reading a nonexistent skill."""
+ args = args_namespace(name="nonexistent", format="md")
+
+ with patch.object(skills, "print_error") as mock_error:
+ result = skills.cmd_read(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdDelete:
+ """Tests for cmd_delete function."""
+
+ def test_delete_existing_skill(self, args_namespace, sample_skill, temp_skills_dir):
+ """Test deleting an existing skill."""
+ args = args_namespace(name="test-skill")
+
+ assert sample_skill.exists()
+
+ with patch.object(skills, "print_success"):
+ result = skills.cmd_delete(args)
+
+ assert result == 0
+ assert not sample_skill.exists()
+
+ def test_delete_nonexistent_skill(self, args_namespace, temp_skills_dir):
+ """Test deleting a nonexistent skill."""
+ args = args_namespace(name="nonexistent")
+
+ with patch.object(skills, "print_error") as mock_error:
+ result = skills.cmd_delete(args)
+
+ assert result == 1
+ mock_error.assert_called()
+
+
+class TestCmdClean:
+ """Tests for cmd_clean function."""
+
+ def test_clean_removes_all_skills(self, args_namespace, sample_skill, temp_skills_dir):
+ """Test that clean removes all skills."""
+ args = args_namespace()
+
+ assert sample_skill.exists()
+
+ with patch("builtins.input", return_value="y"):
+ with patch.object(skills, "print_success"):
+ result = skills.cmd_clean(args)
+
+ assert result == 0
+ # Verify no skills remain
+ remaining = list(temp_skills_dir.iterdir())
+ assert len(remaining) == 0
+
+ def test_clean_empty_directory(self, args_namespace, temp_skills_dir):
+ """Test clean on empty directory."""
+ args = args_namespace()
+
+ with patch.object(skills, "print_info"):
+ result = skills.cmd_clean(args)
+
+ assert result == 0
+
+
+class TestCmdReplay:
+ """Tests for cmd_replay function."""
+
+ def test_replay_existing_skill(
+ self, args_namespace, sample_skill, temp_skills_dir, mock_webbrowser
+ ):
+ """Test replaying an existing skill opens the video."""
+ args = args_namespace(name="test-skill")
+
+ with patch.object(skills, "print_info"):
+ result = skills.cmd_replay(args)
+
+ assert result == 0
+ # Verify webbrowser was called with the video path
+ mock_webbrowser.assert_called_once()
+ call_url = mock_webbrowser.call_args[0][0]
+ assert "test-skill.mp4" in call_url
+
+ def test_replay_nonexistent_skill(self, args_namespace, temp_skills_dir):
+ """Test replaying a nonexistent skill."""
+ args = args_namespace(name="nonexistent")
+
+ with patch.object(skills, "print_error") as mock_error:
+ result = skills.cmd_replay(args)
+
+ assert result == 1
+ mock_error.assert_called()
diff --git a/libs/python/cua-cli/tests/conftest.py b/libs/python/cua-cli/tests/conftest.py
new file mode 100644
index 0000000000..d38dc0ea95
--- /dev/null
+++ b/libs/python/cua-cli/tests/conftest.py
@@ -0,0 +1,258 @@
+"""Shared test fixtures for cua-cli tests."""
+
+import sys
+from unittest.mock import AsyncMock, MagicMock, patch
+
+import pytest
+
+# Mock external modules before importing cua_cli
+# This allows tests to run without cua-computer installed
+mock_providers = MagicMock()
+mock_providers.VMProviderFactory = MagicMock()
+mock_providers.VMProviderType = MagicMock()
+mock_providers.VMProviderType.CLOUD = "cloud"
+
+mock_computer = MagicMock()
+mock_computer.providers = mock_providers
+mock_computer.providers.cloud = MagicMock()
+mock_computer.providers.cloud.provider = MagicMock()
+mock_computer.providers.cloud.provider.CloudProvider = MagicMock()
+
+sys.modules["computer"] = mock_computer
+sys.modules["computer.providers"] = mock_providers
+sys.modules["computer.providers.cloud"] = mock_computer.providers.cloud
+sys.modules["computer.providers.cloud.provider"] = mock_computer.providers.cloud.provider
+
+
+def disable_telemetry(monkeypatch):
+ """Disable telemetry for tests."""
+ monkeypatch.setenv("CUA_TELEMETRY_DISABLED", "1")
+
+
+def temp_credentials_db(tmp_path, monkeypatch):
+ """Provide a temporary credentials database."""
+ cua_dir = tmp_path / ".cua"
+ cua_dir.mkdir(parents=True)
+ db_path = cua_dir / "credentials.db"
+
+ # Patch the CREDENTIALS_DB path in the store module
+ monkeypatch.setattr("cua_cli.auth.store.CREDENTIALS_DB", db_path)
+
+ yield db_path
+
+ if db_path.exists():
+ db_path.unlink()
+
+
+def mock_api_key(monkeypatch):
+ """Set a mock API key in environment."""
+ monkeypatch.setenv("CUA_API_KEY", "test-api-key-12345")
+ return "test-api-key-12345"
+
+
+def clear_api_key_env(monkeypatch):
+ """Ensure no API key is in environment."""
+ monkeypatch.delenv("CUA_API_KEY", raising=False)
+
+
+def mock_aiohttp_session():
+ """Mock aiohttp.ClientSession for API tests."""
+ with patch("aiohttp.ClientSession") as mock_session:
+ mock_instance = AsyncMock()
+ mock_session.return_value.__aenter__.return_value = mock_instance
+ mock_session.return_value.__aexit__.return_value = None
+ yield mock_instance
+
+
+def mock_cloud_provider():
+ """Mock CloudProvider for sandbox tests."""
+ with patch("cua_cli.commands.sandbox.VMProviderFactory") as mock_factory:
+ mock_provider = AsyncMock()
+ mock_provider.__aenter__.return_value = mock_provider
+ mock_provider.__aexit__.return_value = None
+ mock_factory.create_provider.return_value = mock_provider
+ yield mock_provider
+
+
+def sample_vm():
+ """Sample VM object for testing."""
+ vm = MagicMock()
+ vm.name = "test-sandbox-1"
+ vm.status = "running"
+ vm.os_type = "linux"
+ vm.created_at = "2024-01-15T10:00:00Z"
+ vm.size = "medium"
+ vm.region = "north-america"
+ vm.vnc_url = "https://vnc.example.com/test-sandbox-1"
+ vm.server_url = "https://server.example.com:8000"
+ return vm
+
+
+def sample_vm_list(sample_vm):
+ """Sample VM list for testing."""
+ vm2 = MagicMock()
+ vm2.name = "test-sandbox-2"
+ vm2.status = "stopped"
+ vm2.os_type = "macos"
+ vm2.created_at = "2024-01-14T08:30:00Z"
+ vm2.size = "large"
+ vm2.region = "europe"
+ vm2.vnc_url = None
+ vm2.server_url = None
+ return [sample_vm, vm2]
+
+
+def temp_skills_dir(tmp_path, monkeypatch):
+ """Provide a temporary skills directory."""
+ skills_dir = tmp_path / ".cua" / "skills"
+ skills_dir.mkdir(parents=True)
+
+ # Patch the SKILLS_DIR in the skills module
+ monkeypatch.setattr("cua_cli.commands.skills.SKILLS_DIR", skills_dir)
+
+ return skills_dir
+
+
+def sample_skill(temp_skills_dir):
+ """Create a sample skill for testing."""
+ skill_dir = temp_skills_dir / "test-skill"
+ skill_dir.mkdir()
+
+ # Create SKILL.md with proper frontmatter format expected by _parse_frontmatter
+ skill_file = skill_dir / "SKILL.md"
+ skill_file.write_text(
+ """---
+name: test-skill
+description: A sample skill for testing
+---
+
+# Test Skill
+
+A sample skill for testing.
+
+## Steps
+
+1. Click on the button
+2. Type some text
+3. Press Enter
+"""
+ )
+
+ # Create trajectory directory with trajectory.json and a video file
+ trajectory_dir = skill_dir / "trajectory"
+ trajectory_dir.mkdir()
+
+ # Create trajectory.json for proper skill info extraction
+ trajectory_json = trajectory_dir / "trajectory.json"
+ trajectory_json.write_text(
+ """{
+ "trajectory": [
+ {"step_idx": 1, "caption": {"action": "click"}},
+ {"step_idx": 2, "caption": {"action": "type"}}
+ ],
+ "metadata": {
+ "created_at": "2024-01-15T10:00:00Z"
+ }
+ }"""
+ )
+
+ # Create a fake MP4 file for replay tests
+ video_file = trajectory_dir / "test-skill.mp4"
+ video_file.write_bytes(b"fake mp4 content")
+
+ return skill_dir
+
+
+def mock_image_api_client():
+ """Mock CloudAPIClient for image tests."""
+ with patch("cua_cli.commands.image.CloudAPIClient") as mock_client_class:
+ mock_client = AsyncMock()
+ mock_client_class.return_value = mock_client
+ yield mock_client
+
+
+def sample_cloud_images():
+ """Sample cloud images for testing."""
+ return [
+ {
+ "name": "ubuntu-22.04",
+ "image_type": "qcow2",
+ "created_at": "2024-01-10T12:00:00Z",
+ "versions": [
+ {
+ "tag": "latest",
+ "size_bytes": 5368709120,
+ "status": "ready",
+ "created_at": "2024-01-10T12:00:00Z",
+ },
+ {
+ "tag": "v1.0",
+ "size_bytes": 5000000000,
+ "status": "ready",
+ "created_at": "2024-01-05T10:00:00Z",
+ },
+ ],
+ },
+ {
+ "name": "macos-sonoma",
+ "image_type": "qcow2",
+ "created_at": "2024-01-08T09:00:00Z",
+ "versions": [
+ {
+ "tag": "latest",
+ "size_bytes": 21474836480,
+ "status": "ready",
+ "created_at": "2024-01-08T09:00:00Z",
+ },
+ ],
+ },
+ ]
+
+
+def temp_image_file(tmp_path):
+ """Create a temporary image file for upload tests."""
+ image_file = tmp_path / "test-image" / "data.img"
+ image_file.parent.mkdir(parents=True)
+ # Create a small test file
+ image_file.write_bytes(b"fake image content" * 1000)
+ return image_file
+
+
+def mock_webbrowser():
+ """Mock webbrowser.open for browser tests."""
+ with patch("webbrowser.open") as mock_open:
+ yield mock_open
+
+
+def mock_rich_console():
+ """Mock rich console for output tests."""
+ with patch("cua_cli.utils.output.Console") as mock_console_class:
+ mock_console = MagicMock()
+ mock_console_class.return_value = mock_console
+ yield mock_console
+
+
+def args_namespace():
+ """Create an argparse.Namespace factory for command tests."""
+ import argparse
+
+ def create_args(**kwargs):
+ return argparse.Namespace(**kwargs)
+
+ return create_args
diff --git a/libs/python/cua-cli/tests/test_main.py b/libs/python/cua-cli/tests/test_main.py
new file mode 100644
index 0000000000..ee6592f401
--- /dev/null
+++ b/libs/python/cua-cli/tests/test_main.py
@@ -0,0 +1,166 @@
+"""Tests for the main CLI entry point."""
+
+import argparse
+import sys
+from unittest.mock import patch
+
+import pytest
+from cua_cli.main import create_parser, main
+
+
+class TestCreateParser:
+ """Tests for create_parser function."""
+
+ def test_creates_parser(self):
+ """Test that parser is created."""
+ parser = create_parser()
+
+ assert isinstance(parser, argparse.ArgumentParser)
+ assert parser.prog == "cua"
+
+ def test_has_version_flag(self):
+ """Test that --version flag is present."""
+ parser = create_parser()
+
+ with pytest.raises(SystemExit) as exc_info:
+ parser.parse_args(["--version"])
+
+ assert exc_info.value.code == 0
+
+ def test_has_auth_command(self):
+ """Test that auth command is registered."""
+ parser = create_parser()
+
+ args = parser.parse_args(["auth", "login"])
+ assert args.command == "auth"
+ assert args.auth_command == "login"
+
+ def test_has_sandbox_command(self):
+ """Test that sandbox command is registered."""
+ parser = create_parser()
+
+ args = parser.parse_args(["sandbox", "list"])
+ assert args.command == "sandbox"
+ assert args.sandbox_command == "list"
+
+ def test_has_sb_alias(self):
+ """Test that sb alias works."""
+ parser = create_parser()
+
+ args = parser.parse_args(["sb", "list"])
+ assert args.command == "sb"
+ assert args.sandbox_command == "list"
+
+ def test_has_image_command(self):
+ """Test that image command is registered."""
+ parser = create_parser()
+
+ args = parser.parse_args(["image", "list"])
+ assert args.command == "image"
+ assert args.image_command == "list"
+
+ def test_has_skills_command(self):
+ """Test that skills command is registered."""
+ parser = create_parser()
+
+ args = parser.parse_args(["skills", "list"])
+ assert args.command == "skills"
+ assert args.skills_command == "list"
+
+ def test_has_serve_mcp_command(self):
+ """Test that serve-mcp command is registered."""
+ parser = create_parser()
+
+ args = parser.parse_args(["serve-mcp"])
+ assert args.command == "serve-mcp"
+
+
+class TestMain:
+ """Tests for main function."""
+
+ def test_no_args_shows_help(self, capsys):
+ """Test that no arguments shows help."""
+ with patch.object(sys, "argv", ["cua"]):
+ result = main()
+
+ assert result == 0
+ captured = capsys.readouterr()
+ assert "usage:" in captured.out.lower() or "cua" in captured.out
+
+ def test_dispatch_to_auth(self):
+ """Test dispatch to auth command."""
+ with patch.object(sys, "argv", ["cua", "auth", "logout"]):
+ with patch("cua_cli.commands.auth.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_dispatch_to_sandbox(self):
+ """Test dispatch to sandbox command."""
+ with patch.object(sys, "argv", ["cua", "sandbox", "list"]):
+ with patch("cua_cli.commands.sandbox.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_dispatch_to_sb_alias(self):
+ """Test dispatch to sb alias."""
+ with patch.object(sys, "argv", ["cua", "sb", "list"]):
+ with patch("cua_cli.commands.sandbox.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_dispatch_to_image(self):
+ """Test dispatch to image command."""
+ with patch.object(sys, "argv", ["cua", "image", "list"]):
+ with patch("cua_cli.commands.image.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_dispatch_to_skills(self):
+ """Test dispatch to skills command."""
+ with patch.object(sys, "argv", ["cua", "skills", "list"]):
+ with patch("cua_cli.commands.skills.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_dispatch_to_mcp(self):
+ """Test dispatch to serve-mcp command."""
+ with patch.object(sys, "argv", ["cua", "serve-mcp"]):
+ with patch("cua_cli.commands.mcp.execute", return_value=0) as mock_execute:
+ result = main()
+
+ mock_execute.assert_called_once()
+ assert result == 0
+
+ def test_keyboard_interrupt_returns_130(self):
+ """Test that KeyboardInterrupt returns exit code 130."""
+ with patch.object(sys, "argv", ["cua", "sandbox", "list"]):
+ with patch("cua_cli.commands.sandbox.execute", side_effect=KeyboardInterrupt):
+ result = main()
+
+ assert result == 130
+
+ def test_exception_returns_1(self):
+ """Test that exceptions return exit code 1."""
+ with patch.object(sys, "argv", ["cua", "sandbox", "list"]):
+ with patch("cua_cli.commands.sandbox.execute", side_effect=Exception("Test error")):
+ result = main()
+
+ assert result == 1
+
+ def test_unknown_command_returns_1(self):
+ """Test that unknown commands are handled."""
+ # Mock parse_args to return an unknown command
+ with patch.object(sys, "argv", ["cua", "unknown"]):
+ # This should trigger SystemExit from argparse
+ with pytest.raises(SystemExit):
+ main()
diff --git a/libs/python/cua-cli/tests/utils/__init__.py b/libs/python/cua-cli/tests/utils/__init__.py
new file mode 100644
index 0000000000..88bdacd9b3
--- /dev/null
+++ b/libs/python/cua-cli/tests/utils/__init__.py
@@ -0,0 +1 @@
+"""Utils module tests."""
diff --git a/libs/python/cua-cli/tests/utils/test_async_utils.py b/libs/python/cua-cli/tests/utils/test_async_utils.py
new file mode 100644
index 0000000000..6f3f1e47ae
--- /dev/null
+++ b/libs/python/cua-cli/tests/utils/test_async_utils.py
@@ -0,0 +1,95 @@
+"""Tests for async utilities."""
+
+import asyncio
+
+import pytest
+from cua_cli.utils.async_utils import run_async
+
+
+class TestRunAsync:
+ """Tests for run_async function."""
+
+ def test_runs_coroutine(self):
+ """Test that coroutine is executed."""
+
+ async def sample_coro():
+ return "result"
+
+ result = run_async(sample_coro())
+
+ assert result == "result"
+
+ def test_returns_correct_value(self):
+ """Test that return value is correct."""
+
+ async def add(a, b):
+ return a + b
+
+ result = run_async(add(2, 3))
+
+ assert result == 5
+
+ def test_propagates_exception(self):
+ """Test that exceptions are propagated."""
+
+ async def failing_coro():
+ raise ValueError("Test error")
+
+ with pytest.raises(ValueError) as exc_info:
+ run_async(failing_coro())
+
+ assert "Test error" in str(exc_info.value)
+
+ def test_handles_async_sleep(self):
+ """Test that async sleep works correctly."""
+
+ async def with_sleep():
+ await asyncio.sleep(0.01)
+ return "done"
+
+ result = run_async(with_sleep())
+
+ assert result == "done"
+
+ def test_handles_nested_coroutines(self):
+ """Test that nested coroutines work."""
+
+ async def inner():
+ return 42
+
+ async def outer():
+ return await inner()
+
+ result = run_async(outer())
+
+ assert result == 42
+
+ def test_handles_none_result(self):
+ """Test that None result is handled."""
+
+ async def returns_none():
+ pass
+
+ result = run_async(returns_none())
+
+ assert result is None
+
+ def test_handles_list_result(self):
+ """Test that list result is handled."""
+
+ async def returns_list():
+ return [1, 2, 3]
+
+ result = run_async(returns_list())
+
+ assert result == [1, 2, 3]
+
+ def test_handles_dict_result(self):
+ """Test that dict result is handled."""
+
+ async def returns_dict():
+ return {"key": "value"}
+
+ result = run_async(returns_dict())
+
+ assert result == {"key": "value"}
diff --git a/libs/python/cua-cli/tests/utils/test_output.py b/libs/python/cua-cli/tests/utils/test_output.py
new file mode 100644
index 0000000000..92ea20b16f
--- /dev/null
+++ b/libs/python/cua-cli/tests/utils/test_output.py
@@ -0,0 +1,163 @@
+"""Tests for output utilities."""
+
+from unittest.mock import patch
+
+from cua_cli.utils.output import (
+ print_error,
+ print_info,
+ print_json,
+ print_success,
+ print_table,
+ print_warning,
+)
+
+
+class TestPrintTable:
+ """Tests for print_table function."""
+
+ def test_prints_table_with_data(self):
+ """Test printing a table with data."""
+ data = [
+ {"name": "test1", "status": "running"},
+ {"name": "test2", "status": "stopped"},
+ ]
+ columns = [("name", "NAME"), ("status", "STATUS")]
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_table(data, columns)
+
+ mock_console.print.assert_called_once()
+
+ def test_handles_empty_data(self):
+ """Test handling empty data list."""
+ data = []
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_table(data)
+
+ mock_console.print.assert_called_once()
+ # Should print "No data" message
+ call_args = mock_console.print.call_args[0][0]
+ assert "No data" in call_args
+
+ def test_auto_generates_columns(self):
+ """Test that columns are auto-generated from data keys."""
+ data = [{"foo": "bar", "baz": "qux"}]
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_table(data)
+
+ mock_console.print.assert_called_once()
+
+ def test_handles_missing_keys(self):
+ """Test handling data items with missing keys."""
+ data = [
+ {"name": "test1", "status": "running"},
+ {"name": "test2"}, # Missing status
+ ]
+ columns = [("name", "NAME"), ("status", "STATUS")]
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_table(data, columns)
+
+ mock_console.print.assert_called_once()
+
+ def test_with_title(self):
+ """Test table with title."""
+ data = [{"name": "test"}]
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_table(data, title="Test Table")
+
+ mock_console.print.assert_called_once()
+
+
+class TestPrintJson:
+ """Tests for print_json function."""
+
+ def test_prints_dict(self):
+ """Test printing a dictionary as JSON."""
+ data = {"key": "value", "number": 42}
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_json(data)
+
+ mock_console.print_json.assert_called_once()
+
+ def test_prints_list(self):
+ """Test printing a list as JSON."""
+ data = [{"name": "test1"}, {"name": "test2"}]
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_json(data)
+
+ mock_console.print_json.assert_called_once()
+
+ def test_handles_nested_data(self):
+ """Test printing nested data structures."""
+ data = {
+ "level1": {
+ "level2": {
+ "value": 123,
+ }
+ }
+ }
+
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_json(data)
+
+ mock_console.print_json.assert_called_once()
+
+
+class TestPrintError:
+ """Tests for print_error function."""
+
+ def test_prints_to_stderr(self):
+ """Test that error is printed to stderr."""
+ with patch("cua_cli.utils.output.error_console") as mock_console:
+ print_error("Test error message")
+
+ mock_console.print.assert_called_once()
+ call_args = mock_console.print.call_args[0][0]
+ assert "Error:" in call_args
+ assert "Test error message" in call_args
+
+
+class TestPrintSuccess:
+ """Tests for print_success function."""
+
+ def test_prints_success_message(self):
+ """Test printing success message."""
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_success("Operation successful")
+
+ mock_console.print.assert_called_once()
+ call_args = mock_console.print.call_args[0][0]
+ assert "Operation successful" in call_args
+
+
+class TestPrintWarning:
+ """Tests for print_warning function."""
+
+ def test_prints_warning_message(self):
+ """Test printing warning message."""
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_warning("This is a warning")
+
+ mock_console.print.assert_called_once()
+ call_args = mock_console.print.call_args[0][0]
+ assert "Warning:" in call_args
+ assert "This is a warning" in call_args
+
+
+class TestPrintInfo:
+ """Tests for print_info function."""
+
+ def test_prints_info_message(self):
+ """Test printing info message."""
+ with patch("cua_cli.utils.output.console") as mock_console:
+ print_info("Information message")
+
+ mock_console.print.assert_called_once()
+ call_args = mock_console.print.call_args[0][0]
+ assert "Information message" in call_args
diff --git a/libs/typescript/cua-cli/README.md b/libs/typescript/cua-cli/README.md
index c127c0fb83..c914749c85 100644
--- a/libs/typescript/cua-cli/README.md
+++ b/libs/typescript/cua-cli/README.md
@@ -1,5 +1,28 @@
-# Cua CLI
+# Cua CLI (TypeScript) - DEPRECATED
-Command-line tool for managing cloud sandboxes and authentication.
+> **This package is deprecated.** Please use the Python CLI instead:
+>
+> ```bash
+> pip install cua-cli
+> ```
+>
+> The Python CLI provides the same functionality with better integration into the Cua ecosystem.
+> See the [Quickstart Guide](https://cua.ai/docs/cua/guide/get-started/quickstart) for installation and usage.
-**[Documentation](https://cua.ai/docs/cua/reference/cloud-cli)** - Installation, guides, and configuration.
+---
+
+The TypeScript SDKs (`@trycua/computer`, `@trycua/agent`) are still actively maintained for building applications. Only the CLI is deprecated.
+
+## Migration
+
+| TypeScript CLI | Python CLI |
+| ------------------------ | ------------------------ |
+| `cua auth login` | `cua auth login` |
+| `cua sandbox list` | `cua sandbox list` |
+| `cua sandbox create` | `cua sandbox create` |
+| `cua sandbox vnc <name>` | `cua sandbox vnc <name>` |
+| `cua image list` | `cua image list` |
+| `cua skills list` | `cua skills list` |
+| `cua serve-mcp` | `cua serve-mcp` |
+
+Commands are identical - just install the Python CLI and continue using the same commands.
diff --git a/libs/typescript/cua-cli/package.json b/libs/typescript/cua-cli/package.json
index b352b2196c..00a55c9a17 100644
--- a/libs/typescript/cua-cli/package.json
+++ b/libs/typescript/cua-cli/package.json
@@ -1,8 +1,9 @@
{
"name": "@trycua/cli",
"version": "0.2.0",
+ "deprecated": "This package is deprecated. Use the Python CLI instead: pip install cua-cli",
"packageManager": "[email protected]",
- "description": "Command-line interface for Cua cloud sandboxes and authentication",
+ "description": "[DEPRECATED] Command-line interface for Cua cloud sandboxes and authentication. Use pip install cua-cli instead.",
"type": "module",
"license": "MIT",
"homepage": "https://github.com/trycua/cua/tree/main/libs/typescript/cua-cli",
diff --git a/libs/typescript/cua-cli/src/commands/image.ts b/libs/typescript/cua-cli/src/commands/image.ts
index 9ea350b045..cc533666d4 100644
--- a/libs/typescript/cua-cli/src/commands/image.ts
+++ b/libs/typescript/cua-cli/src/commands/image.ts
@@ -114,7 +114,14 @@ const listHandler = async (argv: Record<string, unknown>) => {
]);
}
} else {
- rows.push([img.name, img.image_type, '-', '-', '-', new Date(img.created_at).toLocaleDateString()]);
+ rows.push([
+ img.name,
+ img.image_type,
+ '-',
+ '-',
+ '-',
+ new Date(img.created_at).toLocaleDateString(),
+ ]);
}
}
@@ -184,13 +191,18 @@ const pushHandler = async (argv: Record<string, unknown>) => {
}
if (!initRes.ok) {
const body = await initRes.json().catch(() => ({}));
- console.error(`Failed to initiate upload: ${initRes.status}`, (body as any).error || '');
+ console.error(
+ `Failed to initiate upload: ${initRes.status}`,
+ (body as any).error || ''
+ );
process.exit(1);
}
const session = (await initRes.json()) as UploadSession;
console.log(`Upload session: ${session.upload_id}`);
- console.log(`Parts: ${session.total_parts} x ${formatBytes(session.part_size)}`);
+ console.log(
+ `Parts: ${session.total_parts} x ${formatBytes(session.part_size)}`
+ );
// Upload parts
const completedParts: PartInfo[] = [];
@@ -210,17 +222,25 @@ const pushHandler = async (argv: Record<string, unknown>) => {
if (!urlRes.ok) {
console.error(`Failed to get upload URL for part ${partNum}`);
// Abort upload
- await http(`/v1/images/${encodeURIComponent(name)}/upload/${session.upload_id}`, {
- token,
- method: 'DELETE',
- });
+ await http(
+ `/v1/images/${encodeURIComponent(name)}/upload/${session.upload_id}`,
+ {
+ token,
+ method: 'DELETE',
+ }
+ );
process.exit(1);
}
- const urlData = (await urlRes.json()) as { upload_url: string; expires_in: number };
+ const urlData = (await urlRes.json()) as {
+ upload_url: string;
+ expires_in: number;
+ };
// Upload the part
- process.stdout.write(`\rUploading part ${partNum}/${session.total_parts}...`);
+ process.stdout.write(
+ `\rUploading part ${partNum}/${session.total_parts}...`
+ );
const uploadRes = await fetch(urlData.upload_url, {
method: 'PUT',
@@ -233,10 +253,13 @@ const pushHandler = async (argv: Record<string, unknown>) => {
if (!uploadRes.ok) {
console.error(`\nFailed to upload part ${partNum}: ${uploadRes.status}`);
// Abort upload
- await http(`/v1/images/${encodeURIComponent(name)}/upload/${session.upload_id}`, {
- token,
- method: 'DELETE',
- });
+ await http(
+ `/v1/images/${encodeURIComponent(name)}/upload/${session.upload_id}`,
+ {
+ token,
+ method: 'DELETE',
+ }
+ );
process.exit(1);
}
@@ -259,7 +282,10 @@ const pushHandler = async (argv: Record<string, unknown>) => {
if (!completeRes.ok) {
const body = await completeRes.json().catch(() => ({}));
- console.error(`Failed to complete upload: ${completeRes.status}`, (body as any).error || '');
+ console.error(
+ `Failed to complete upload: ${completeRes.status}`,
+ (body as any).error || ''
+ );
process.exit(1);
}
@@ -278,9 +304,12 @@ const pullHandler = async (argv: Record<string, unknown>) => {
console.log(`Pulling ${name}:${tag}...`);
// Get download URL
- const urlRes = await http(`/v1/images/${encodeURIComponent(name)}/download?tag=${encodeURIComponent(tag)}`, {
- token,
- });
+ const urlRes = await http(
+ `/v1/images/${encodeURIComponent(name)}/download?tag=${encodeURIComponent(tag)}`,
+ {
+ token,
+ }
+ );
if (urlRes.status === 401) {
clearApiKey();
@@ -293,11 +322,18 @@ const pullHandler = async (argv: Record<string, unknown>) => {
}
if (!urlRes.ok) {
const body = await urlRes.json().catch(() => ({}));
- console.error(`Failed to get download URL: ${urlRes.status}`, (body as any).error || '');
+ console.error(
+ `Failed to get download URL: ${urlRes.status}`,
+ (body as any).error || ''
+ );
process.exit(1);
}
- const urlData = (await urlRes.json()) as { download_url: string; size_bytes: number; checksum_sha256: string };
+ const urlData = (await urlRes.json()) as {
+ download_url: string;
+ size_bytes: number;
+ checksum_sha256: string;
+ };
console.log(`Size: ${formatBytes(urlData.size_bytes)}`);
// Download the file
@@ -339,10 +375,13 @@ const deleteHandler = async (argv: Record<string, unknown>) => {
console.log(`Deleting ${name}:${tag}...`);
- const res = await http(`/v1/images/${encodeURIComponent(name)}?tag=${encodeURIComponent(tag)}`, {
- token,
- method: 'DELETE',
- });
+ const res = await http(
+ `/v1/images/${encodeURIComponent(name)}?tag=${encodeURIComponent(tag)}`,
+ {
+ token,
+ method: 'DELETE',
+ }
+ );
if (res.status === 401) {
clearApiKey();
@@ -385,11 +424,16 @@ export function registerImageCommands(y: Argv) {
'Push a VM image to cloud storage',
(y) =>
y
- .positional('name', { type: 'string', describe: 'Image name', demandOption: true })
+ .positional('name', {
+ type: 'string',
+ describe: 'Image name',
+ demandOption: true,
+ })
.option('file', {
alias: 'f',
type: 'string',
- describe: 'Path to image file (defaults to ~/.local/share/cua-bench/images/<name>/data.img)',
+ describe:
+ 'Path to image file (defaults to ~/.local/share/cua-bench/images/<name>/data.img)',
})
.option('tag', {
type: 'string',
@@ -409,7 +453,11 @@ export function registerImageCommands(y: Argv) {
'Pull a VM image from cloud storage',
(y) =>
y
- .positional('name', { type: 'string', describe: 'Image name', demandOption: true })
+ .positional('name', {
+ type: 'string',
+ describe: 'Image name',
+ demandOption: true,
+ })
.option('tag', {
type: 'string',
default: 'latest',
@@ -427,7 +475,11 @@ export function registerImageCommands(y: Argv) {
'Delete an image version from cloud storage',
(y) =>
y
- .positional('name', { type: 'string', describe: 'Image name', demandOption: true })
+ .positional('name', {
+ type: 'string',
+ describe: 'Image name',
+ demandOption: true,
+ })
.option('tag', {
type: 'string',
default: 'latest',
diff --git a/libs/typescript/playground/src/adapters/cloud.ts b/libs/typescript/playground/src/adapters/cloud.ts
index 3d4cdfacfd..ce5d9387b1 100644
--- a/libs/typescript/playground/src/adapters/cloud.ts
+++ b/libs/typescript/playground/src/adapters/cloud.ts
@@ -50,8 +50,7 @@ class CloudPersistenceAdapter implements PersistenceAdapter {
let errorMessage: string;
try {
const errorBody = await response.json();
- errorMessage =
- errorBody.detail || errorBody.error || `HTTP ${response.status}`;
+ errorMessage = errorBody.detail || errorBody.error || `HTTP ${response.status}`;
} catch {
errorMessage = `HTTP ${response.status}`;
}
@@ -146,8 +145,7 @@ class CloudComputerAdapter implements ComputerAdapter {
let errorMessage: string;
try {
const errorBody = await response.json();
- errorMessage =
- errorBody.detail || errorBody.error || `HTTP ${response.status}`;
+ errorMessage = errorBody.detail || errorBody.error || `HTTP ${response.status}`;
} catch {
errorMessage = `HTTP ${response.status}`;
}
@@ -168,9 +166,7 @@ class CloudComputerAdapter implements ComputerAdapter {
}));
}
- private mapVMStatus(
- status: string
- ): 'running' | 'stopped' | 'starting' | 'error' {
+ private mapVMStatus(status: string): 'running' | 'stopped' | 'starting' | 'error' {
switch (status.toLowerCase()) {
case 'running':
return 'running';
@@ -188,9 +184,7 @@ class CloudComputerAdapter implements ComputerAdapter {
async getDefaultComputer(): Promise<ComputerInfo | null> {
const computers = await this.listComputers();
// Prefer a running computer, otherwise return the first one
- return (
- computers.find((c) => c.status === 'running') ?? computers[0] ?? null
- );
+ return computers.find((c) => c.status === 'running') ?? computers[0] ?? null;
}
async checkHealth(computerId: string): Promise<boolean> {
@@ -271,9 +265,7 @@ class CloudInferenceAdapter implements InferenceAdapter {
* <Playground adapters={adapters} />
* ```
*/
-export function createCloudAdapter(
- config: CloudAdapterConfig
-): PlaygroundAdapters {
+export function createCloudAdapter(config: CloudAdapterConfig): PlaygroundAdapters {
const baseUrl = config.baseUrl || 'https://api.cua.ai';
return {
diff --git a/libs/typescript/playground/src/adapters/local.ts b/libs/typescript/playground/src/adapters/local.ts
index f4f40f98b1..f2d0853571 100644
--- a/libs/typescript/playground/src/adapters/local.ts
+++ b/libs/typescript/playground/src/adapters/local.ts
@@ -116,9 +116,7 @@ class LocalComputerAdapter implements ComputerAdapter {
return computers[0] ?? null;
}
- async addCustomComputer(
- computer: Omit<ComputerInfo, 'id'>
- ): Promise<ComputerInfo> {
+ async addCustomComputer(computer: Omit<ComputerInfo, 'id'>): Promise<ComputerInfo> {
const newComputer: ComputerInfo = {
...computer,
id: crypto.randomUUID(),
@@ -233,9 +231,7 @@ class LocalInferenceAdapter implements InferenceAdapter {
* <Playground adapters={adapters} />
* ```
*/
-export function createLocalAdapter(
- config: LocalAdapterConfig = {}
-): PlaygroundAdapters {
+export function createLocalAdapter(config: LocalAdapterConfig = {}): PlaygroundAdapters {
return {
persistence: new LocalPersistenceAdapter(),
computer: new LocalComputerAdapter(config),
diff --git a/libs/typescript/playground/src/types/chat.ts b/libs/typescript/playground/src/types/chat.ts
index 7f7e3df983..d781ece625 100644
--- a/libs/typescript/playground/src/types/chat.ts
+++ b/libs/typescript/playground/src/types/chat.ts
@@ -1,10 +1,7 @@
// Types copied from cloud/src/website/app/types.ts and cloud/src/website/app/contexts/ChatContext.tsx
// IMPORTANT: Keep these in sync with the source files
-import type {
- AgentMessage,
- ComputerCallOutputMessage,
-} from './messages';
+import type { AgentMessage, ComputerCallOutputMessage } from './messages';
// Model type
export interface Model {
diff --git a/libs/typescript/playground/src/types/index.ts b/libs/typescript/playground/src/types/index.ts
index b161211274..e49202a95a 100644
--- a/libs/typescript/playground/src/types/index.ts
+++ b/libs/typescript/playground/src/types/index.ts
@@ -45,10 +45,4 @@ export type {
ChatAction,
} from './chat';
-export {
- VMStatus,
- isVM,
- isCustomComputer,
- getComputerId,
- getComputerName,
-} from './chat';
+export { VMStatus, isVM, isCustomComputer, getComputerId, getComputerName } from './chat';
diff --git a/libs/typescript/playground/src/utils/localStorage.ts b/libs/typescript/playground/src/utils/localStorage.ts
index 8d4fb1b8a6..7ac678f2cb 100644
--- a/libs/typescript/playground/src/utils/localStorage.ts
+++ b/libs/typescript/playground/src/utils/localStorage.ts
@@ -70,20 +70,14 @@ const defaultDeserializer = (obj: unknown): unknown => {
};
// Save array of items to localStorage
-export const saveItemsToLocalStorage = <T>(
- items: T[],
- config: StorageConfig<T>
-): void => {
+export const saveItemsToLocalStorage = <T>(items: T[], config: StorageConfig<T>): void => {
try {
if (typeof window === 'undefined') return;
const serializer = config.serialize || defaultSerializer;
const serializedItems = items.map(serializer);
localStorage.setItem(config.storageKey, JSON.stringify(serializedItems));
} catch (error) {
- console.error(
- `Failed to save items to localStorage (${config.storageKey}):`,
- error
- );
+ console.error(`Failed to save items to localStorage (${config.storageKey}):`, error);
}
};
@@ -97,45 +91,32 @@ export const loadItemsFromLocalStorage = <T>(config: StorageConfig<T>): T[] => {
const parsedItems: unknown = JSON.parse(stored);
if (!Array.isArray(parsedItems)) {
- console.warn(
- `Expected array but got ${typeof parsedItems} from localStorage`
- );
+ console.warn(`Expected array but got ${typeof parsedItems} from localStorage`);
return [];
}
const deserializer = config.deserialize || defaultDeserializer;
return parsedItems.map((item) => deserializer(item) as T);
} catch (error) {
- console.error(
- `Failed to load items from localStorage (${config.storageKey}):`,
- error
- );
+ console.error(`Failed to load items from localStorage (${config.storageKey}):`, error);
return [];
}
};
// Save single item to localStorage
-export const saveItemToLocalStorage = <T>(
- item: T,
- config: StorageConfig<T>
-): void => {
+export const saveItemToLocalStorage = <T>(item: T, config: StorageConfig<T>): void => {
try {
if (typeof window === 'undefined') return;
const serializer = config.serialize || defaultSerializer;
const serializedItem = serializer(item);
localStorage.setItem(config.storageKey, JSON.stringify(serializedItem));
} catch (error) {
- console.error(
- `Failed to save item to localStorage (${config.storageKey}):`,
- error
- );
+ console.error(`Failed to save item to localStorage (${config.storageKey}):`, error);
}
};
// Load single item from localStorage
-export const loadItemFromLocalStorage = <T>(
- config: StorageConfig<T>
-): T | null => {
+export const loadItemFromLocalStorage = <T>(config: StorageConfig<T>): T | null => {
try {
if (typeof window === 'undefined') return null;
const stored = localStorage.getItem(config.storageKey);
@@ -145,10 +126,7 @@ export const loadItemFromLocalStorage = <T>(
const deserializer = config.deserialize || defaultDeserializer;
return deserializer(parsedItem) as T;
} catch (error) {
- console.error(
- `Failed to load item from localStorage (${config.storageKey}):`,
- error
- );
+ console.error(`Failed to load item from localStorage (${config.storageKey}):`, error);
return null;
}
};
diff --git a/scripts/docs-generators/config.json b/scripts/docs-generators/config.json
index 74febd68ef..de1cb70b87 100644
--- a/scripts/docs-generators/config.json
+++ b/scripts/docs-generators/config.json
@@ -71,23 +71,29 @@
"enabled": false,
"notes": "Requires MCP tool introspection - to be implemented"
},
- "computer-sdk-python": {
- "name": "Computer SDK (Python)",
+ "python-sdk": {
+ "name": "Python SDKs (Computer + Agent)",
"language": "python",
- "sourcePath": "libs/python/computer/src",
- "docsOutputPath": "docs/content/docs/cua/reference/computer-sdk",
+ "sourcePath": "libs/python",
+ "docsOutputPath": "docs/content/docs/cua/reference",
"generatorScript": "scripts/docs-generators/python-sdk.ts",
- "watchPaths": ["libs/python/computer/src/**/*.py"],
- "extractionMethod": "sphinx-autodoc",
+ "watchPaths": ["libs/python/computer/computer/**/*.py", "libs/python/agent/agent/**/*.py"],
+ "buildCommand": null,
+ "buildDirectory": "libs/python",
+ "extractionMethod": "griffe",
"outputs": [
{
"type": "api",
- "outputFile": "python-api.mdx",
- "extractCommand": null
+ "outputFile": "computer-sdk/api.mdx",
+ "extractCommand": "python3 scripts/docs-generators/extract_python_docs.py"
+ },
+ {
+ "type": "api",
+ "outputFile": "agent-sdk/api.mdx",
+ "extractCommand": "python3 scripts/docs-generators/extract_python_docs.py"
}
],
- "enabled": false,
- "notes": "Requires Sphinx or pydoc introspection - to be implemented"
+ "enabled": true
},
"computer-sdk-typescript": {
"name": "Computer SDK (TypeScript)",
@@ -107,24 +113,6 @@
"enabled": false,
"notes": "Requires TypeDoc or ts-morph introspection - to be implemented"
},
- "agent-sdk-python": {
- "name": "Agent SDK (Python)",
- "language": "python",
- "sourcePath": "libs/python/agent/src",
- "docsOutputPath": "docs/content/docs/cua/reference/agent-sdk",
- "generatorScript": "scripts/docs-generators/python-sdk.ts",
- "watchPaths": ["libs/python/agent/src/**/*.py"],
- "extractionMethod": "sphinx-autodoc",
- "outputs": [
- {
- "type": "api",
- "outputFile": "python-api.mdx",
- "extractCommand": null
- }
- ],
- "enabled": false,
- "notes": "Requires Sphinx or pydoc introspection - to be implemented"
- },
"agent-sdk-typescript": {
"name": "Agent SDK (TypeScript)",
"language": "typescript",
@@ -142,6 +130,25 @@
],
"enabled": false,
"notes": "Requires TypeDoc or ts-morph introspection - to be implemented"
+ },
+ "cuabot": {
+ "name": "Cua-Bot",
+ "language": "typescript",
+ "sourcePath": "libs/cuabot/src",
+ "docsOutputPath": "docs/content/docs/cuabot/reference",
+ "generatorScript": "scripts/docs-generators/typescript-sdk.ts",
+ "watchPaths": ["libs/cuabot/src/**/*.ts"],
+ "buildCommand": null,
+ "buildDirectory": "libs/cuabot",
+ "extractionMethod": "regex-parse",
+ "outputs": [
+ {
+ "type": "api",
+ "outputFile": "index.mdx",
+ "extractCommand": null
+ }
+ ],
+ "enabled": true
}
}
}
diff --git a/scripts/docs-generators/extract_python_docs.py b/scripts/docs-generators/extract_python_docs.py
new file mode 100644
index 0000000000..4819ca1bf1
--- /dev/null
+++ b/scripts/docs-generators/extract_python_docs.py
@@ -0,0 +1,309 @@
+#!/usr/bin/env python3
+"""
+Extract Python API documentation using griffe.
+
+This script extracts structured documentation from Python packages
+without requiring them to be installed or imported.
+
+Usage:
+ python extract_python_docs.py <package_path> <package_name>
+
+Example:
+ python extract_python_docs.py libs/python/computer/computer computer
+"""
+
+import json
+import sys
+from pathlib import Path
+from typing import Any, Dict, List, Optional
+
+from griffe import (
+ Alias,
+ Attribute,
+ Class,
+ DocstringSectionKind,
+ Function,
+ Module,
+ Object,
+ load,
+)
+
+
+def extract_docstring_sections(obj: Object) -> Dict[str, Any]:
+ """Extract parsed docstring sections from an object."""
+ result = {
+ "description": "",
+ "params": [],
+ "returns": None,
+ "raises": [],
+ "examples": [],
+ }
+
+ if not obj.docstring:
+ return result
+
+ # Get parsed sections (griffe parses automatically based on detected style)
+ try:
+ sections = obj.docstring.parsed
+ except Exception:
+ # Fallback to raw docstring
+ result["description"] = str(obj.docstring.value) if obj.docstring else ""
+ return result
+
+ for section in sections:
+ if section.kind == DocstringSectionKind.text:
+ result["description"] = str(section.value).strip()
+
+ elif section.kind == DocstringSectionKind.parameters:
+ for param in section.value:
+ result["params"].append(
+ {
+ "name": param.name,
+ "type": str(param.annotation) if param.annotation else "",
+ "description": param.description or "",
+ "default": str(param.default) if param.default else None,
+ }
+ )
+
+ elif section.kind == DocstringSectionKind.returns:
+ ret = section.value
+ if ret:
+ result["returns"] = {
+ "type": (
+ str(ret.annotation) if hasattr(ret, "annotation") and ret.annotation else ""
+ ),
+ "description": ret.description if hasattr(ret, "description") else str(ret),
+ }
+
+ elif section.kind == DocstringSectionKind.raises:
+ for exc in section.value:
+ result["raises"].append(
+ {
+ "type": str(exc.annotation) if exc.annotation else "",
+ "description": exc.description or "",
+ }
+ )
+
+ elif section.kind == DocstringSectionKind.examples:
+ result["examples"].append(str(section.value))
+
+ return result
+
+
+def extract_function(fn: Function, is_method: bool = False) -> Dict[str, Any]:
+ """Extract function/method documentation."""
+ # Check if async (stored in labels)
+ is_async = "async" in getattr(fn, "labels", set())
+
+ # Build signature
+ params = []
+ for param in fn.parameters:
+ param_str = param.name
+ if param.annotation:
+ param_str += f": {param.annotation}"
+ if param.default is not None:
+ param_str += f" = {param.default}"
+ params.append(param_str)
+
+ signature = f"{'async ' if is_async else ''}def {fn.name}({', '.join(params)})"
+ if fn.returns:
+ signature += f" -> {fn.returns}"
+
+ docstring_data = extract_docstring_sections(fn)
+
+ return {
+ "name": fn.name,
+ "signature": signature,
+ "is_async": is_async,
+ "is_method": is_method,
+ "description": docstring_data["description"],
+ "parameters": docstring_data["params"],
+ "returns": docstring_data["returns"],
+ "raises": docstring_data["raises"],
+ "examples": docstring_data["examples"],
+ "is_private": fn.name.startswith("_") and not fn.name.startswith("__"),
+ "is_dunder": fn.name.startswith("__") and fn.name.endswith("__"),
+ }
+
+
+def extract_attribute(attr: Attribute) -> Dict[str, Any]:
+ """Extract attribute/property documentation."""
+ return {
+ "name": attr.name,
+ "type": str(attr.annotation) if attr.annotation else "",
+ "description": str(attr.docstring.value) if attr.docstring else "",
+ "default": str(attr.value) if attr.value else None,
+ "is_private": attr.name.startswith("_"),
+ }
+
+
+def resolve_member(member: Any) -> Any:
+ """Resolve an alias to its target if needed."""
+ if isinstance(member, Alias):
+ try:
+ return member.target
+ except Exception:
+ return member
+ return member
+
+
+def extract_class(cls: Class) -> Dict[str, Any]:
+ """Extract class documentation."""
+ docstring_data = extract_docstring_sections(cls)
+
+ # Extract methods
+ methods = []
+ for name, member in cls.members.items():
+ member = resolve_member(member)
+ if isinstance(member, Function):
+ method_doc = extract_function(member, is_method=True)
+ # Skip private methods except __init__
+ if not method_doc["is_private"] or name == "__init__":
+ methods.append(method_doc)
+
+ # Extract attributes/properties
+ attributes = []
+ for name, member in cls.members.items():
+ member = resolve_member(member)
+ if isinstance(member, Attribute) and not name.startswith("_"):
+ attributes.append(extract_attribute(member))
+
+ # Get base classes
+ bases = []
+ for base in cls.bases:
+ bases.append(str(base))
+
+ return {
+ "name": cls.name,
+ "description": docstring_data["description"],
+ "bases": bases,
+ "methods": methods,
+ "attributes": attributes,
+ "is_private": cls.name.startswith("_"),
+ }
+
+
+def extract_module(module: Module, include_private: bool = False) -> Dict[str, Any]:
+ """Extract module documentation."""
+ # Get version from module if available
+ version = "unknown"
+ if "__version__" in module.members:
+ version_attr = module.members["__version__"]
+ if hasattr(version_attr, "value") and version_attr.value:
+ version = str(version_attr.value).strip("'\"")
+
+ # Get __all__ exports if defined
+ exports = None
+ if "__all__" in module.members:
+ all_attr = module.members["__all__"]
+ if hasattr(all_attr, "value") and all_attr.value:
+ try:
+ # Try to parse __all__ as a list
+ exports = eval(str(all_attr.value))
+ except Exception:
+ exports = None
+
+ # Extract classes
+ classes = []
+ for name, member in module.members.items():
+ member = resolve_member(member)
+ if isinstance(member, Class):
+ # Include if in __all__ or if public
+ if exports is None:
+ if not name.startswith("_") or include_private:
+ classes.append(extract_class(member))
+ elif name in exports:
+ classes.append(extract_class(member))
+
+ # Extract module-level functions
+ functions = []
+ for name, member in module.members.items():
+ member = resolve_member(member)
+ if isinstance(member, Function):
+ if exports is None:
+ if not name.startswith("_") or include_private:
+ functions.append(extract_function(member))
+ elif name in exports:
+ functions.append(extract_function(member))
+
+ return {
+ "name": module.name,
+ "version": version,
+ "docstring": str(module.docstring.value) if module.docstring else "",
+ "exports": exports,
+ "classes": classes,
+ "functions": functions,
+ }
+
+
+def extract_package_docs(package_path: str, package_name: str) -> Dict[str, Any]:
+ """
+ Extract documentation from a Python package.
+
+ Args:
+ package_path: Path to the package directory (e.g., 'libs/python/computer/computer')
+ package_name: Name of the package to load (e.g., 'computer')
+
+ Returns:
+ Dictionary containing structured documentation
+ """
+ # Resolve paths
+ package_dir = Path(package_path).resolve()
+ search_path = package_dir.parent
+
+ # Load the package using griffe
+ try:
+ package = load(
+ package_name,
+ search_paths=[str(search_path)],
+ )
+ except Exception as e:
+ return {
+ "error": f"Failed to load package: {e}",
+ "name": package_name,
+ "version": "unknown",
+ "modules": [],
+ }
+
+ # Extract main module
+ main_module = extract_module(package)
+
+ # Extract submodules
+ submodules = []
+ for name, member in package.members.items():
+ member = resolve_member(member)
+ if isinstance(member, Module) and not name.startswith("_"):
+ submodule_doc = extract_module(member)
+ if submodule_doc["classes"] or submodule_doc["functions"]:
+ submodules.append(submodule_doc)
+
+ return {
+ "name": package_name,
+ "version": main_module["version"],
+ "docstring": main_module["docstring"],
+ "exports": main_module["exports"],
+ "classes": main_module["classes"],
+ "functions": main_module["functions"],
+ "submodules": submodules,
+ }
+
+
+def main():
+ """Main entry point."""
+ if len(sys.argv) < 3:
+ print("Usage: python extract_python_docs.py <package_path> <package_name>", file=sys.stderr)
+ print(
+ "Example: python extract_python_docs.py libs/python/computer/computer computer",
+ file=sys.stderr,
+ )
+ sys.exit(1)
+
+ package_path = sys.argv[1]
+ package_name = sys.argv[2]
+
+ docs = extract_package_docs(package_path, package_name)
+ print(json.dumps(docs, indent=2))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/scripts/docs-generators/generate-changelog.ts b/scripts/docs-generators/generate-changelog.ts
new file mode 100644
index 0000000000..14b32c6cc6
--- /dev/null
+++ b/scripts/docs-generators/generate-changelog.ts
@@ -0,0 +1,546 @@
+#!/usr/bin/env npx tsx
+
+/**
+ * Changelog Generator
+ *
+ * Generates changelog MDX files for each SDK by parsing GitHub releases.
+ * Fetches all releases, cleans up noisy auto-generated body content, and
+ * produces clean per-SDK changelogs grouped by major.minor version.
+ *
+ * Usage:
+ * npx tsx scripts/docs-generators/generate-changelog.ts # Generate all
+ * npx tsx scripts/docs-generators/generate-changelog.ts --check # Check for drift
+ * npx tsx scripts/docs-generators/generate-changelog.ts --sdk=computer # Specific SDK
+ */
+
+import { execSync } from 'child_process';
+import * as fs from 'fs';
+import * as path from 'path';
+
+// ============================================================================
+// Types
+// ============================================================================
+
+interface GitHubRelease {
+ tagName: string;
+ name: string;
+ body: string;
+ publishedAt: string;
+ isDraft: boolean;
+ isPrerelease: boolean;
+}
+
+interface SDKConfig {
+ name: string;
+ displayName: string;
+ tagPrefix: string;
+ outputPath: string;
+}
+
+// ============================================================================
+// Configuration
+// ============================================================================
+
+const ROOT_DIR = path.resolve(__dirname, '../..');
+const DOCS_BASE = path.join(ROOT_DIR, 'docs/content/docs');
+const GITHUB_REPO = 'trycua/cua';
+
+const SDK_CONFIGS: SDKConfig[] = [
+ {
+ name: 'computer',
+ displayName: 'Computer SDK',
+ tagPrefix: 'computer-v',
+ outputPath: 'cua/reference/computer-sdk/changelog.mdx',
+ },
+ {
+ name: 'agent',
+ displayName: 'Agent SDK',
+ tagPrefix: 'agent-v',
+ outputPath: 'cua/reference/agent-sdk/changelog.mdx',
+ },
+ {
+ name: 'computer-server',
+ displayName: 'Desktop Sandbox',
+ tagPrefix: 'computer-server-v',
+ outputPath: 'cua/reference/desktop-sandbox/changelog.mdx',
+ },
+ {
+ name: 'lume',
+ displayName: 'Lume',
+ tagPrefix: 'lume-v',
+ outputPath: 'lume/reference/changelog.mdx',
+ },
+ {
+ name: 'cuabot',
+ displayName: 'Cua-Bot',
+ tagPrefix: 'cuabot-v',
+ outputPath: 'cuabot/reference/changelog.mdx',
+ },
+];
+
+// ============================================================================
+// Main
+// ============================================================================
+
+async function main() {
+ const args = process.argv.slice(2);
+ const checkOnly = args.includes('--check');
+ const sdkArg = args.find((a) => a.startsWith('--sdk='));
+ const targetSdk = sdkArg?.split('=')[1];
+
+ console.log('Changelog Generator');
+ console.log('======================\n');
+
+ // Fetch ALL releases once (across all SDKs)
+ console.log('Fetching all GitHub releases...');
+ const allReleases = fetchAllReleases();
+ console.log(`Found ${allReleases.length} total releases\n`);
+
+ let hasErrors = false;
+
+ for (const config of SDK_CONFIGS) {
+ if (targetSdk && targetSdk !== config.name) {
+ continue;
+ }
+
+ console.log(`Processing ${config.displayName}...`);
+
+ // Filter releases for this SDK
+ const sdkReleases = allReleases.filter(
+ (r) => r.tagName.startsWith(config.tagPrefix) && !r.isDraft
+ );
+
+ // Sort by version descending
+ sdkReleases.sort((a, b) => {
+ const versionA = a.tagName.replace(config.tagPrefix, '');
+ const versionB = b.tagName.replace(config.tagPrefix, '');
+ return compareVersions(versionB, versionA);
+ });
+
+ console.log(` Found ${sdkReleases.length} releases`);
+
+ if (sdkReleases.length === 0) {
+ console.log(` No releases found for ${config.displayName}`);
+ continue;
+ }
+
+ // Fetch body for each release
+ const releasesWithBody = fetchBodies(sdkReleases);
+
+ // Generate MDX
+ const mdx = generateChangelogMDX(config, releasesWithBody);
+
+ // Output path
+ const outputPath = path.join(DOCS_BASE, config.outputPath);
+ const outputDir = path.dirname(outputPath);
+
+ if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+ }
+
+ if (checkOnly) {
+ if (fs.existsSync(outputPath)) {
+ const existing = fs.readFileSync(outputPath, 'utf-8');
+ if (existing !== mdx) {
+ console.error(` ${config.name} changelog is out of sync`);
+ hasErrors = true;
+ } else {
+ console.log(` ${config.name} changelog is up to date`);
+ }
+ } else {
+ console.error(` ${config.name} changelog does not exist`);
+ hasErrors = true;
+ }
+ } else {
+ fs.writeFileSync(outputPath, mdx);
+ console.log(` Generated ${path.relative(ROOT_DIR, outputPath)}`);
+ }
+ }
+
+ if (hasErrors) {
+ if (checkOnly) {
+ console.error("\nRun 'npx tsx scripts/docs-generators/generate-changelog.ts' to update");
+ }
+ process.exit(1);
+ }
+
+ console.log('\nChangelog generation complete!');
+}
+
+// ============================================================================
+// GitHub Release Fetching
+// ============================================================================
+
+/**
+ * Fetch all releases at once (without body) to avoid per-SDK limit issues.
+ * Uses --limit 500 to get all releases across the entire repo.
+ */
+function fetchAllReleases(): GitHubRelease[] {
+ try {
+ const output = execSync(
+ 'gh release list --limit 500 --json tagName,name,publishedAt,isDraft,isPrerelease',
+ { encoding: 'utf-8', cwd: ROOT_DIR, maxBuffer: 10 * 1024 * 1024 }
+ );
+ return JSON.parse(output);
+ } catch (error) {
+ console.error(`Failed to fetch releases: ${error}`);
+ return [];
+ }
+}
+
+/**
+ * Fetch release bodies individually for a filtered set of releases.
+ */
+function fetchBodies(releases: GitHubRelease[]): GitHubRelease[] {
+ const results: GitHubRelease[] = [];
+
+ for (const release of releases) {
+ try {
+ const output = execSync(`gh release view "${release.tagName}" --json body`, {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ maxBuffer: 1024 * 1024,
+ });
+ const data = JSON.parse(output);
+ results.push({
+ ...release,
+ body: data.body || '',
+ });
+ } catch {
+ results.push({ ...release, body: '' });
+ }
+ }
+
+ return results;
+}
+
+function compareVersions(a: string, b: string): number {
+ const partsA = a.split('.').map((x) => parseInt(x, 10) || 0);
+ const partsB = b.split('.').map((x) => parseInt(x, 10) || 0);
+
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
+ const partA = partsA[i] || 0;
+ const partB = partsB[i] || 0;
+ if (partA !== partB) {
+ return partA - partB;
+ }
+ }
+ return 0;
+}
+
+// ============================================================================
+// MDX Generation
+// ============================================================================
+
+function generateChangelogMDX(config: SDKConfig, releases: GitHubRelease[]): string {
+ const lines: string[] = [];
+
+ // Frontmatter
+ lines.push('---');
+ lines.push(`title: Changelog`);
+ lines.push(`description: Release history for ${config.displayName}`);
+ lines.push('---');
+ lines.push('');
+
+ // Auto-generated notice
+ lines.push(`{/*`);
+ lines.push(` AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY`);
+ lines.push(` Generated by: npx tsx scripts/docs-generators/generate-changelog.ts`);
+ lines.push(` Last updated: ${new Date().toISOString().split('T')[0]}`);
+ lines.push(`*/}`);
+ lines.push('');
+
+ // Introduction
+ lines.push(`# ${config.displayName} Changelog`);
+ lines.push('');
+ lines.push(`All notable changes to the ${config.displayName} are documented here.`);
+ lines.push('');
+
+ // Group releases by major.minor version
+ const grouped = groupByMajorMinor(releases, config.tagPrefix);
+
+ for (const [majorMinor, versionReleases] of Object.entries(grouped)) {
+ lines.push(`## ${majorMinor}.x`);
+ lines.push('');
+
+ for (const release of versionReleases) {
+ const version = release.tagName.replace(config.tagPrefix, '');
+ const date = formatDate(release.publishedAt);
+
+ lines.push(`### v${version} (${date})`);
+ lines.push('');
+
+ // Process release body
+ const body = processReleaseBody(release.body);
+ if (body) {
+ lines.push(body);
+ lines.push('');
+ } else {
+ lines.push('Maintenance release.');
+ lines.push('');
+ }
+ }
+ }
+
+ return lines.join('\n');
+}
+
+function groupByMajorMinor(
+ releases: GitHubRelease[],
+ tagPrefix: string
+): Record<string, GitHubRelease[]> {
+ const grouped: Record<string, GitHubRelease[]> = {};
+
+ for (const release of releases) {
+ const version = release.tagName.replace(tagPrefix, '');
+ const parts = version.split('.');
+ const majorMinor = `${parts[0]}.${parts[1] || '0'}`;
+
+ if (!grouped[majorMinor]) {
+ grouped[majorMinor] = [];
+ }
+ grouped[majorMinor].push(release);
+ }
+
+ // Sort keys by version descending
+ const sortedKeys = Object.keys(grouped).sort((a, b) => compareVersions(b, a));
+ const sortedGrouped: Record<string, GitHubRelease[]> = {};
+ for (const key of sortedKeys) {
+ sortedGrouped[key] = grouped[key];
+ }
+
+ return sortedGrouped;
+}
+
+function formatDate(isoDate: string): string {
+ const date = new Date(isoDate);
+ return date.toISOString().split('T')[0];
+}
+
+// ============================================================================
+// Release Body Processing
+// ============================================================================
+
+/**
+ * Clean up a GitHub release body to produce focused changelog content.
+ *
+ * Strips:
+ * - "## What's Changed" header
+ * - "## Installation" / "## Installation Options" sections
+ * - "## Usage" / "## Quick Start" / "## Claude Desktop Integration" sections
+ * - "## Dependencies" section (condensed to one line if present)
+ * - Package description boilerplate
+ * - "**Full Changelog**" links
+ * - Heading markers ## / ### (to avoid hierarchy conflicts)
+ * - Commit SHAs like (abc1234)
+ *
+ * Adds:
+ * - Linked PR numbers: (#789) -> ([#789](https://github.com/trycua/cua/pull/789))
+ *
+ * Detects:
+ * - Bot-only releases (all entries are "Bump cua-X") -> "Maintenance release."
+ */
+function processReleaseBody(body: string): string {
+ if (!body || body.trim() === '') {
+ return '';
+ }
+
+ let processed = body;
+
+ // Remove "**Full Changelog**" links
+ processed = processed.replace(/\*\*Full Changelog\*\*:.*$/gm, '');
+
+ // Remove package description boilerplate headers
+ processed = processed.replace(
+ /^##\s*(Computer control library|Computer Server|Base package|MCP Server|Computer Vision|Toolkit for computer-use|Lightweight webUI|Unified CLI).*$/gm,
+ ''
+ );
+
+ // Remove standalone description lines that match boilerplate patterns
+ processed = processed.replace(
+ /^(A FastAPI-based server implementation|This package provides (MCP|enhanced UI)|Manage cloud sandboxes).*$/gm,
+ ''
+ );
+
+ // Remove raw checksum lines (sha256 hex + filename)
+ processed = processed.replace(/^[a-f0-9]{64}\s+\S+.*$/gm, '');
+ // Remove markdown table rows that look like checksum tables
+ processed = processed.replace(/^\|?\s*`?[a-f0-9]{64}`?\s*\|.*$/gm, '');
+ // Remove checksum table headers
+ processed = processed.replace(/^\|?\s*SHA256\s*\|.*$/gim, '');
+ processed = processed.replace(/^\|?\s*-+\s*\|.*$/gm, '');
+
+ // Extract dependencies from "## Dependencies" section before removing sections
+ let depsLine = '';
+ const depsContent = extractSection(processed, 'Dependencies');
+ if (depsContent !== null) {
+ const items = depsContent
+ .split('\n')
+ .filter((l) => l.trim().startsWith('*'))
+ .map((l) => l.replace(/^\*\s*/, '').trim());
+ if (items.length > 0) {
+ depsLine = `**Dependencies:** ${items.join(', ')}`;
+ }
+ processed = removeSection(processed, 'Dependencies');
+ }
+
+ // Remove boilerplate sections (BEFORE removing "What's Changed" heading,
+ // so section boundaries are intact for removeSection to work correctly)
+ const sectionsToRemove = [
+ 'Installation Options',
+ 'Installation with script',
+ 'Installation',
+ 'Usage',
+ 'Claude Desktop Integration',
+ 'Quick Start',
+ ];
+ for (const section of sectionsToRemove) {
+ processed = removeSection(processed, section);
+ }
+
+ // NOW remove "What's Changed" / "Whats Changed" header line (after sections are removed)
+ processed = processed.replace(/^#{1,3}\s*What'?s Changed\s*$/gm, '');
+
+ // Handle single-line "**Dependencies:**" already in the body (from new workflow format)
+ const inlineDeps = processed.match(/^\*\*Dependencies:\*\*.*$/m);
+ if (inlineDeps) {
+ depsLine = inlineDeps[0].trim();
+ processed = processed.replace(/^\*\*Dependencies:\*\*.*$/m, '');
+ }
+
+ // Remove release title headings like "# cua-computer v0.4.11"
+ processed = processed.replace(/^#{1,3}\s*cua-\S+\s+v[\d.]+\s*$/gm, '');
+
+ // Strip heading markers (## / ###) from remaining content to avoid hierarchy issues
+ processed = processed.replace(/^#{1,3}\s+/gm, '');
+
+ // Link PR numbers: (#123) -> ([#123](https://github.com/trycua/cua/pull/123))
+ processed = processed.replace(
+ /\(#(\d+)\)/g,
+ `([#$1](https://github.com/${GITHUB_REPO}/pull/$1))`
+ );
+
+ // Strip commit SHAs: (7-8 char hex in parens) from entries
+ processed = processed.replace(/\s*\([a-f0-9]{7,8}\)/g, '');
+
+ // Clean up excessive blank lines
+ processed = processed.replace(/\n{3,}/g, '\n\n').trim();
+
+ // Check if all remaining bullet lines are bot bumps
+ const contentLines = processed
+ .split('\n')
+ .filter((l) => l.trim().startsWith('*') || l.trim().startsWith('-'));
+ const allBotBumps =
+ contentLines.length > 0 && contentLines.every((l) => /Bump (cua-|lume)/i.test(l));
+
+ if (allBotBumps && !depsLine) {
+ return 'Maintenance release.';
+ }
+
+ // Re-add dependencies line at the top if present
+ if (depsLine) {
+ processed = depsLine + (processed ? '\n\n' + processed : '');
+ }
+
+ // Final check: if nothing meaningful remains
+ if (!processed.trim()) {
+ return '';
+ }
+
+ // Escape curly braces outside of code blocks for MDX compatibility
+ processed = escapeMDXOutsideCode(processed);
+
+ return processed;
+}
+
+/**
+ * Extract the content of a markdown section (any heading level) up to the next
+ * same-or-higher-level heading or end of text.
+ * Returns null if the section is not found.
+ */
+function extractSection(text: string, sectionTitle: string): string | null {
+ const lines = text.split('\n');
+ let inSection = false;
+ let sectionLevel = 0;
+ let content: string[] = [];
+
+ for (const line of lines) {
+ const headerMatch = line.match(
+ new RegExp(`^(#{1,6})\\s*${escapeRegex(sectionTitle)}\\s*$`, 'i')
+ );
+ if (!inSection && headerMatch) {
+ inSection = true;
+ sectionLevel = headerMatch[1].length;
+ continue;
+ }
+ if (inSection) {
+ // Stop at next heading of same or higher level
+ const headingMatch = line.match(/^(#{1,6})\s/);
+ if (headingMatch && headingMatch[1].length <= sectionLevel) {
+ break;
+ }
+ content.push(line);
+ }
+ }
+
+ return inSection ? content.join('\n') : null;
+}
+
+/**
+ * Remove a markdown section (any heading level) and everything until the next
+ * same-or-higher-level heading or end of text.
+ */
+function removeSection(text: string, sectionTitle: string): string {
+ const lines = text.split('\n');
+ const result: string[] = [];
+ let inSection = false;
+ let sectionLevel = 0;
+
+ for (const line of lines) {
+ const headerMatch =
+ !inSection && line.match(new RegExp(`^(#{1,6})\\s*${escapeRegex(sectionTitle)}\\s*$`, 'i'));
+ if (headerMatch) {
+ inSection = true;
+ sectionLevel = headerMatch[1].length;
+ continue;
+ }
+ if (inSection) {
+ const headingMatch = line.match(/^(#{1,6})\s/);
+ if (headingMatch && headingMatch[1].length <= sectionLevel) {
+ inSection = false;
+ result.push(line);
+ }
+ continue;
+ }
+ result.push(line);
+ }
+
+ return result.join('\n');
+}
+
+function escapeRegex(str: string): string {
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+}
+
+function escapeMDXOutsideCode(text: string): string {
+ const codeBlockRegex = /(```[\s\S]*?```|`[^`]+`)/g;
+ const parts = text.split(codeBlockRegex);
+
+ return parts
+ .map((part) => {
+ if (part.startsWith('```') || part.startsWith('`')) {
+ return part;
+ }
+ return part.replace(/\{/g, '\\{').replace(/\}/g, '\\}');
+ })
+ .join('');
+}
+
+// ============================================================================
+// Run
+// ============================================================================
+
+main().catch((error) => {
+ console.error('Error:', error);
+ process.exit(1);
+});
diff --git a/scripts/docs-generators/generate-versioned-docs.ts b/scripts/docs-generators/generate-versioned-docs.ts
new file mode 100644
index 0000000000..53cd2cf52e
--- /dev/null
+++ b/scripts/docs-generators/generate-versioned-docs.ts
@@ -0,0 +1,681 @@
+#!/usr/bin/env npx tsx
+
+/**
+ * Versioned Documentation Generator
+ *
+ * Generates API documentation for historical versions by checking out
+ * tagged versions from git and running the extraction.
+ *
+ * Usage:
+ * npx tsx scripts/docs-generators/generate-versioned-docs.ts # Generate all
+ * npx tsx scripts/docs-generators/generate-versioned-docs.ts --sdk=computer # Specific SDK
+ * npx tsx scripts/docs-generators/generate-versioned-docs.ts --list # List available versions
+ */
+
+import { execSync, spawnSync } from 'child_process';
+import * as fs from 'fs';
+import * as path from 'path';
+
+// ============================================================================
+// Types
+// ============================================================================
+
+type ExtractionType = 'python-griffe' | 'swift-dump-docs' | 'typescript';
+
+interface SDKConfig {
+ name: string;
+ displayName: string;
+ tagPrefix: string;
+ packageDir: string;
+ packageName: string;
+ outputDir: string;
+ extractionType: ExtractionType;
+ /** Skip versions below this major.minor (e.g. '0.2' skips 0.1.x) */
+ minVersion?: string;
+ /** Base docs directory (defaults to cua/reference under DOCS_BASE) */
+ docsBasePath?: string;
+}
+
+interface VersionInfo {
+ tag: string;
+ version: string;
+ majorMinor: string;
+}
+
+// ============================================================================
+// Configuration
+// ============================================================================
+
+const ROOT_DIR = path.resolve(__dirname, '../..');
+const DOCS_BASE = path.join(ROOT_DIR, 'docs/content/docs');
+const DOCS_DIR = path.join(DOCS_BASE, 'cua/reference');
+const PYTHON_SCRIPT = path.join(__dirname, 'extract_python_docs.py');
+
+const SDK_CONFIGS: SDKConfig[] = [
+ {
+ name: 'computer',
+ displayName: 'Computer SDK',
+ tagPrefix: 'computer-v',
+ packageDir: 'libs/python/computer/computer',
+ packageName: 'computer',
+ outputDir: 'computer-sdk',
+ extractionType: 'python-griffe',
+ },
+ {
+ name: 'agent',
+ displayName: 'Agent SDK',
+ tagPrefix: 'agent-v',
+ packageDir: 'libs/python/agent/agent',
+ packageName: 'agent',
+ outputDir: 'agent-sdk',
+ extractionType: 'python-griffe',
+ },
+ {
+ name: 'bench',
+ displayName: 'Cua Bench',
+ tagPrefix: 'bench-v',
+ packageDir: 'libs/cua-bench/cua_bench',
+ packageName: 'cua_bench',
+ outputDir: 'reference',
+ extractionType: 'python-griffe',
+ docsBasePath: 'cuabench/reference',
+ },
+ {
+ name: 'lume',
+ displayName: 'Lume',
+ tagPrefix: 'lume-v',
+ packageDir: 'libs/lume',
+ packageName: 'lume',
+ outputDir: 'lume/reference',
+ extractionType: 'swift-dump-docs',
+ minVersion: '0.2',
+ docsBasePath: 'lume/reference',
+ },
+ {
+ name: 'cuabot',
+ displayName: 'Cua-Bot',
+ tagPrefix: 'cuabot-v',
+ packageDir: 'libs/cuabot/src',
+ packageName: 'cuabot',
+ outputDir: 'reference',
+ extractionType: 'typescript',
+ minVersion: '1.0',
+ docsBasePath: 'cuabot/reference',
+ },
+];
+
+// ============================================================================
+// Main
+// ============================================================================
+
+async function main() {
+ const args = process.argv.slice(2);
+ const listOnly = args.includes('--list');
+ const sdkArg = args.find((a) => a.startsWith('--sdk='));
+ const targetSdk = sdkArg?.split('=')[1];
+
+ console.log('📚 Versioned Documentation Generator');
+ console.log('====================================\n');
+
+ // Check for uncommitted changes
+ const status = execSync('git status --porcelain', { encoding: 'utf-8', cwd: ROOT_DIR });
+ if (status.trim()) {
+ console.warn('⚠️ Warning: You have uncommitted changes. They will be preserved.\n');
+ }
+
+ for (const config of SDK_CONFIGS) {
+ if (targetSdk && targetSdk !== config.name) {
+ continue;
+ }
+
+ console.log(`\n📦 ${config.displayName}`);
+ console.log('─'.repeat(40));
+
+ // Get all version tags
+ const versions = getVersions(config.tagPrefix);
+ console.log(` Found ${versions.length} version tags`);
+
+ if (listOnly) {
+ // Just list versions
+ const grouped = groupByMajorMinor(versions);
+ for (const [majorMinor, versionList] of Object.entries(grouped)) {
+ console.log(` v${majorMinor}.x: ${versionList.map((v) => v.version).join(', ')}`);
+ }
+ continue;
+ }
+
+ // Group by major.minor (we only generate one doc per major.minor)
+ const grouped = groupByMajorMinor(versions);
+
+ for (const [majorMinor, versionList] of Object.entries(grouped)) {
+ // Skip versions below minVersion
+ if (config.minVersion && compareVersions(majorMinor, config.minVersion) < 0) {
+ console.log(` Skipping v${majorMinor} (below minVersion ${config.minVersion})`);
+ continue;
+ }
+
+ // Use the latest patch version for this major.minor
+ const latestVersion = versionList[0];
+ console.log(`\n Generating v${majorMinor} (from ${latestVersion.tag})...`);
+
+ try {
+ // Generate docs for this version
+ await generateVersionDocs(config, latestVersion, majorMinor);
+ const files =
+ config.extractionType === 'swift-dump-docs'
+ ? 'cli-reference.mdx + http-api.mdx'
+ : 'api.mdx';
+ console.log(` ✅ Generated v${majorMinor}/${files}`);
+ } catch (error) {
+ console.error(` ❌ Failed: ${error}`);
+ }
+ }
+ }
+
+ console.log('\n✅ Versioned documentation generation complete!');
+}
+
+// ============================================================================
+// Version Discovery
+// ============================================================================
+
+function getVersions(tagPrefix: string): VersionInfo[] {
+ try {
+ const output = execSync(`git tag | grep "^${tagPrefix}"`, {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ });
+
+ return output
+ .trim()
+ .split('\n')
+ .filter(Boolean)
+ .map((tag) => {
+ const version = tag.replace(tagPrefix, '');
+ const parts = version.split('.');
+ const majorMinor = `${parts[0]}.${parts[1] || '0'}`;
+ return { tag, version, majorMinor };
+ })
+ .sort((a, b) => compareVersions(b.version, a.version)); // Descending
+ } catch {
+ return [];
+ }
+}
+
+function groupByMajorMinor(versions: VersionInfo[]): Record<string, VersionInfo[]> {
+ const grouped: Record<string, VersionInfo[]> = {};
+
+ for (const v of versions) {
+ if (!grouped[v.majorMinor]) {
+ grouped[v.majorMinor] = [];
+ }
+ grouped[v.majorMinor].push(v);
+ }
+
+ // Sort keys descending
+ const sortedKeys = Object.keys(grouped).sort((a, b) => compareVersions(b, a));
+ const sorted: Record<string, VersionInfo[]> = {};
+ for (const key of sortedKeys) {
+ sorted[key] = grouped[key];
+ }
+
+ return sorted;
+}
+
+function compareVersions(a: string, b: string): number {
+ const partsA = a.split('.').map((x) => parseInt(x, 10) || 0);
+ const partsB = b.split('.').map((x) => parseInt(x, 10) || 0);
+
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
+ const partA = partsA[i] || 0;
+ const partB = partsB[i] || 0;
+ if (partA !== partB) {
+ return partA - partB;
+ }
+ }
+ return 0;
+}
+
+// ============================================================================
+// Documentation Generation
+// ============================================================================
+
+async function generateVersionDocs(
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string
+): Promise<void> {
+ // Resolve output directory based on config
+ const baseDir = config.docsBasePath
+ ? path.join(DOCS_BASE, config.docsBasePath)
+ : path.join(DOCS_DIR, config.outputDir);
+ const outputDir = path.join(baseDir, `v${majorMinor}`);
+
+ // Create output directory
+ if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+ }
+
+ // Checkout the package directory at the tagged version
+ const packagePath = path.join(ROOT_DIR, config.packageDir);
+
+ try {
+ // Save current state
+ execSync(`git stash push -m "versioned-docs-temp" -- ${config.packageDir}`, {
+ cwd: ROOT_DIR,
+ stdio: 'pipe',
+ });
+ } catch {
+ // No changes to stash, continue
+ }
+
+ try {
+ // Checkout tagged version of the package
+ execSync(`git checkout ${versionInfo.tag} -- ${config.packageDir}`, {
+ cwd: ROOT_DIR,
+ stdio: 'pipe',
+ });
+
+ if (config.extractionType === 'swift-dump-docs') {
+ await generateSwiftVersionDocs(config, versionInfo, majorMinor, outputDir);
+ } else if (config.extractionType === 'typescript') {
+ await generateTypeScriptVersionDocs(config, versionInfo, majorMinor, outputDir);
+ } else {
+ await generatePythonVersionDocs(config, versionInfo, majorMinor, outputDir);
+ }
+ } finally {
+ // Restore HEAD version
+ execSync(`git checkout HEAD -- ${config.packageDir}`, {
+ cwd: ROOT_DIR,
+ stdio: 'pipe',
+ });
+
+ // Restore stashed changes if any
+ try {
+ execSync('git stash pop', { cwd: ROOT_DIR, stdio: 'pipe' });
+ } catch {
+ // No stash to pop
+ }
+ }
+}
+
+async function generatePythonVersionDocs(
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string,
+ outputDir: string
+): Promise<void> {
+ const packagePath = path.join(ROOT_DIR, config.packageDir);
+ const outputPath = path.join(outputDir, 'api.mdx');
+
+ // Run extraction
+ const extractOutput = execSync(
+ `python3 "${PYTHON_SCRIPT}" "${packagePath}" "${config.packageName}"`,
+ { encoding: 'utf-8', cwd: ROOT_DIR, maxBuffer: 10 * 1024 * 1024 }
+ );
+
+ const docs = JSON.parse(extractOutput);
+
+ // Generate MDX
+ const mdx = generateMDX(docs, config, versionInfo, majorMinor);
+
+ // Write output
+ fs.writeFileSync(outputPath, mdx);
+
+ // Create meta.json for the version folder
+ const metaPath = path.join(outputDir, 'meta.json');
+ fs.writeFileSync(
+ metaPath,
+ JSON.stringify(
+ {
+ title: `v${majorMinor}`,
+ description: `${config.displayName} v${majorMinor} API Reference`,
+ pages: ['api'],
+ },
+ null,
+ 2
+ )
+ );
+}
+
+async function generateSwiftVersionDocs(
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string,
+ outputDir: string
+): Promise<void> {
+ const lumeDir = path.join(ROOT_DIR, config.packageDir);
+
+ // Build Lume at this version
+ try {
+ execSync('swift build -c release', {
+ cwd: lumeDir,
+ stdio: 'pipe',
+ timeout: 300000, // 5 min build timeout
+ });
+ } catch (error) {
+ throw new Error(`Swift build failed for ${versionInfo.tag}: ${error}`);
+ }
+
+ // Import Lume MDX generators
+ const { generateCLIReferenceMDX, generateHTTPAPIMDX } = await import('./lume');
+
+ // Extract CLI docs
+ let cliMdx: string;
+ try {
+ const cliDocsJson = execSync('.build/release/lume dump-docs --type cli', {
+ cwd: lumeDir,
+ encoding: 'utf-8',
+ });
+ const cliDocs = JSON.parse(cliDocsJson);
+ cliMdx = generateVersionedLumeMDX(
+ generateCLIReferenceMDX(cliDocs),
+ config,
+ versionInfo,
+ majorMinor,
+ 'CLI Reference'
+ );
+ } catch (error) {
+ throw new Error(`CLI docs extraction failed for ${versionInfo.tag}: ${error}`);
+ }
+
+ // Extract API docs
+ let apiMdx: string;
+ try {
+ const apiDocsJson = execSync('.build/release/lume dump-docs --type api', {
+ cwd: lumeDir,
+ encoding: 'utf-8',
+ });
+ const apiDocs = JSON.parse(apiDocsJson);
+ apiMdx = generateVersionedLumeMDX(
+ generateHTTPAPIMDX(apiDocs),
+ config,
+ versionInfo,
+ majorMinor,
+ 'HTTP API Reference'
+ );
+ } catch (error) {
+ throw new Error(`API docs extraction failed for ${versionInfo.tag}: ${error}`);
+ }
+
+ // Write outputs
+ fs.writeFileSync(path.join(outputDir, 'cli-reference.mdx'), cliMdx);
+ fs.writeFileSync(path.join(outputDir, 'http-api.mdx'), apiMdx);
+
+ // Create meta.json
+ fs.writeFileSync(
+ path.join(outputDir, 'meta.json'),
+ JSON.stringify(
+ {
+ title: `v${majorMinor}`,
+ description: `${config.displayName} v${majorMinor} Reference`,
+ pages: ['cli-reference', 'http-api'],
+ },
+ null,
+ 2
+ )
+ );
+}
+
+async function generateTypeScriptVersionDocs(
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string,
+ outputDir: string
+): Promise<void> {
+ // Run the typescript-sdk generator to produce MDX, then wrap it with a version callout
+ const tsGenScript = path.join(__dirname, 'typescript-sdk.ts');
+ const outputPath = path.join(outputDir, 'api.mdx');
+
+ // Run the TS generator targeting cuabot — it will write to the configured output path
+ // Instead, we run it inline and capture the current version's output, then modify it
+ try {
+ // Generate using the typescript-sdk generator
+ spawnSync('npx', ['tsx', tsGenScript, `--sdk=${config.name}`], {
+ cwd: ROOT_DIR,
+ stdio: 'pipe',
+ });
+
+ // Read the generated file and wrap it with version callout
+ const generatedPath = path.join(ROOT_DIR, 'docs/content/docs/cuabot/reference/index.mdx');
+ if (fs.existsSync(generatedPath)) {
+ let content = fs.readFileSync(generatedPath, 'utf-8');
+
+ // Replace VersionHeader with old-version callout
+ const lines = content.split('\n');
+ const result: string[] = [];
+ let skipVersionHeader = false;
+
+ for (const line of lines) {
+ if (line.startsWith('<VersionHeader')) {
+ skipVersionHeader = true;
+ result.push('<Callout type="warn">');
+ result.push(
+ ` This is documentation for **v${majorMinor}**. [View latest version](/cuabot/reference).`
+ );
+ result.push('</Callout>');
+ result.push('');
+ result.push('<div className="flex items-center gap-2 mb-6">');
+ result.push(
+ ` <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">v${versionInfo.version}</span>`
+ );
+ result.push(
+ ` <span className="text-sm text-fd-muted-foreground">npm install -g cuabot@${versionInfo.version}</span>`
+ );
+ result.push('</div>');
+ result.push('');
+ continue;
+ }
+ if (skipVersionHeader) {
+ if (line.startsWith('/>')) {
+ skipVersionHeader = false;
+ continue;
+ }
+ continue;
+ }
+ result.push(line);
+ }
+
+ // Update title
+ content = result
+ .join('\n')
+ .replace(/^title: .*$/m, `title: ${config.displayName} v${majorMinor} API Reference`);
+
+ fs.writeFileSync(outputPath, content);
+ }
+ } catch (error) {
+ throw new Error(`TypeScript docs generation failed for ${versionInfo.tag}: ${error}`);
+ }
+
+ // Create meta.json
+ fs.writeFileSync(
+ path.join(outputDir, 'meta.json'),
+ JSON.stringify(
+ {
+ title: `v${majorMinor}`,
+ description: `${config.displayName} v${majorMinor} API Reference`,
+ pages: ['api'],
+ },
+ null,
+ 2
+ )
+ );
+}
+
+/**
+ * Wrap generated Lume MDX with a version warning callout for historical versions.
+ * Replaces the VersionHeader (which shows current version) with an old-version notice.
+ */
+function generateVersionedLumeMDX(
+ currentMdx: string,
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string,
+ title: string
+): string {
+ // Replace the VersionHeader block with an old-version callout
+ const lines = currentMdx.split('\n');
+ const result: string[] = [];
+ let skipVersionHeader = false;
+
+ for (const line of lines) {
+ // Skip the VersionHeader block
+ if (line.startsWith('<VersionHeader')) {
+ skipVersionHeader = true;
+ // Insert old-version callout instead
+ result.push('<Callout type="warn">');
+ result.push(
+ ` This is documentation for **v${majorMinor}**. [View latest version](/lume/reference/cli-reference).`
+ );
+ result.push('</Callout>');
+ result.push('');
+ result.push('<div className="flex items-center gap-2 mb-6">');
+ result.push(
+ ` <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">v${versionInfo.version}</span>`
+ );
+ result.push(
+ ` <span className="text-sm text-fd-muted-foreground">curl -fsSL .../install.sh | bash</span>`
+ );
+ result.push('</div>');
+ result.push('');
+ continue;
+ }
+ if (skipVersionHeader) {
+ if (line.startsWith('/>')) {
+ skipVersionHeader = false;
+ continue;
+ }
+ continue;
+ }
+ result.push(line);
+ }
+
+ return result.join('\n');
+}
+
+// ============================================================================
+// MDX Generation (simplified version for historical docs)
+// ============================================================================
+
+function generateMDX(
+ docs: any,
+ config: SDKConfig,
+ versionInfo: VersionInfo,
+ majorMinor: string
+): string {
+ const lines: string[] = [];
+
+ // Frontmatter
+ lines.push('---');
+ lines.push(`title: ${config.displayName} v${majorMinor} API Reference`);
+ lines.push(`description: API reference for ${config.displayName} version ${majorMinor}`);
+ lines.push('---');
+ lines.push('');
+
+ // Auto-generated notice
+ lines.push(`{/*`);
+ lines.push(` AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY`);
+ lines.push(` Generated by: npx tsx scripts/docs-generators/generate-versioned-docs.ts`);
+ lines.push(` Source tag: ${versionInfo.tag}`);
+ lines.push(` Version: ${versionInfo.version}`);
+ lines.push(`*/}`);
+ lines.push('');
+
+ // Imports
+ lines.push("import { Callout } from 'fumadocs-ui/components/callout';");
+ lines.push('');
+
+ // Version notice — link to the folder root (index.mdx is the landing page)
+ const latestHref = config.docsBasePath
+ ? `/${config.docsBasePath.replace(/\/$/, '')}/${config.outputDir}`
+ : `/cua/reference/${config.outputDir}`;
+ lines.push('<Callout type="warn">');
+ lines.push(
+ ` This is documentation for **v${majorMinor}**. [View latest version](${latestHref}).`
+ );
+ lines.push('</Callout>');
+ lines.push('');
+
+ // Version badge
+ const pipName = config.packageName.replace(/_/g, '-');
+ const fullPipName = pipName.startsWith('cua') ? pipName : `cua-${pipName}`;
+ lines.push('<div className="flex items-center gap-2 mb-6">');
+ lines.push(
+ ` <span className="px-2 py-1 bg-amber-100 dark:bg-amber-900 text-amber-800 dark:text-amber-200 rounded text-sm font-mono">v${versionInfo.version}</span>`
+ );
+ lines.push(
+ ` <span className="text-sm text-fd-muted-foreground">pip install ${fullPipName}==${versionInfo.version}</span>`
+ );
+ lines.push('</div>');
+ lines.push('');
+
+ // Package description
+ if (docs.docstring) {
+ lines.push(escapeMDX(docs.docstring));
+ lines.push('');
+ }
+
+ // Classes
+ if (docs.classes && docs.classes.length > 0) {
+ lines.push('## Classes');
+ lines.push('');
+ lines.push('| Class | Description |');
+ lines.push('|-------|-------------|');
+ for (const cls of docs.classes) {
+ if (!cls.is_private) {
+ const desc = escapeMDX(cls.description?.split('\n')[0]) || 'No description';
+ lines.push(`| \`${cls.name}\` | ${desc} |`);
+ }
+ }
+ lines.push('');
+
+ // Class details
+ for (const cls of docs.classes) {
+ if (!cls.is_private) {
+ lines.push(`## ${cls.name}`);
+ lines.push('');
+ if (cls.description) {
+ lines.push(escapeMDX(cls.description));
+ lines.push('');
+ }
+
+ // Methods
+ const publicMethods = (cls.methods || []).filter(
+ (m: any) => !m.is_private && !m.is_dunder && m.name !== '__init__'
+ );
+ if (publicMethods.length > 0) {
+ lines.push('### Methods');
+ lines.push('');
+ for (const method of publicMethods) {
+ lines.push(`#### ${cls.name}.${method.name}`);
+ lines.push('');
+ lines.push('```python');
+ lines.push(method.signature || `def ${method.name}(...)`);
+ lines.push('```');
+ lines.push('');
+ if (method.description) {
+ lines.push(escapeMDX(method.description));
+ lines.push('');
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return lines.join('\n');
+}
+
+function escapeMDX(text: string): string {
+ if (!text) return text;
+ return text.replace(/\{/g, '\\{').replace(/\}/g, '\\}');
+}
+
+// ============================================================================
+// Run
+// ============================================================================
+
+main().catch((error) => {
+ console.error('Error:', error);
+ process.exit(1);
+});
diff --git a/scripts/docs-generators/lume.ts b/scripts/docs-generators/lume.ts
index fb5efdcbef..ddddf5b0f5 100644
--- a/scripts/docs-generators/lume.ts
+++ b/scripts/docs-generators/lume.ts
@@ -19,14 +19,14 @@ import * as path from 'path';
// Types
// ============================================================================
-interface CLIDocumentation {
+export interface CLIDocumentation {
name: string;
version: string;
abstract: string;
commands: CommandDoc[];
}
-interface CommandDoc {
+export interface CommandDoc {
name: string;
abstract: string;
discussion?: string;
@@ -36,14 +36,14 @@ interface CommandDoc {
subcommands: CommandDoc[];
}
-interface ArgumentDoc {
+export interface ArgumentDoc {
name: string;
help: string;
type: string;
is_optional: boolean;
}
-interface OptionDoc {
+export interface OptionDoc {
name: string;
short_name?: string;
help: string;
@@ -52,21 +52,21 @@ interface OptionDoc {
is_optional: boolean;
}
-interface FlagDoc {
+export interface FlagDoc {
name: string;
short_name?: string;
help: string;
default_value: boolean;
}
-interface HTTPAPIDocumentation {
+export interface HTTPAPIDocumentation {
base_path: string;
version: string;
description: string;
endpoints: APIEndpointDoc[];
}
-interface APIEndpointDoc {
+export interface APIEndpointDoc {
method: string;
path: string;
description: string;
@@ -78,26 +78,26 @@ interface APIEndpointDoc {
status_codes: APIStatusCodeDoc[];
}
-interface APIParameterDoc {
+export interface APIParameterDoc {
name: string;
type: string;
required: boolean;
description: string;
}
-interface APIRequestBodyDoc {
+export interface APIRequestBodyDoc {
content_type: string;
description: string;
fields: APIFieldDoc[];
}
-interface APIResponseDoc {
+export interface APIResponseDoc {
content_type: string;
description: string;
fields?: APIFieldDoc[];
}
-interface APIFieldDoc {
+export interface APIFieldDoc {
name: string;
type: string;
required: boolean;
@@ -105,7 +105,7 @@ interface APIFieldDoc {
default_value?: string;
}
-interface APIStatusCodeDoc {
+export interface APIStatusCodeDoc {
code: number;
description: string;
}
@@ -117,6 +117,80 @@ interface APIStatusCodeDoc {
const ROOT_DIR = path.resolve(__dirname, '../..');
const LUME_DIR = path.join(ROOT_DIR, 'libs', 'lume');
const DOCS_OUTPUT_DIR = path.join(ROOT_DIR, 'docs', 'content', 'docs', 'lume', 'reference');
+const TAG_PREFIX = 'lume-v';
+
+// ============================================================================
+// Version Discovery
+// ============================================================================
+
+interface VersionInfo {
+ version: string;
+ href: string;
+ isCurrent: boolean;
+}
+
+/**
+ * Get the latest released version from git tags.
+ */
+export function getLatestReleasedVersion(): string {
+ try {
+ const output = execSync(`git tag | grep "^${TAG_PREFIX}" | sort -V | tail -1`, {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ }).trim();
+ if (output) {
+ return output.replace(TAG_PREFIX, '');
+ }
+ } catch {
+ // Fall through
+ }
+ return '0.0.0';
+}
+
+/**
+ * Discover available versioned doc folders and build version list.
+ */
+export function discoverVersions(currentVersion: string): VersionInfo[] {
+ const versions: VersionInfo[] = [];
+ const currentMajorMinor = currentVersion.split('.').slice(0, 2).join('.');
+
+ // Add current version (latest)
+ versions.push({
+ version: currentMajorMinor,
+ href: '/lume/reference/cli-reference',
+ isCurrent: true,
+ });
+
+ // Discover versioned folders (v0.2, v0.1, etc.)
+ if (fs.existsSync(DOCS_OUTPUT_DIR)) {
+ const entries = fs.readdirSync(DOCS_OUTPUT_DIR, { withFileTypes: true });
+ for (const entry of entries) {
+ if (entry.isDirectory() && entry.name.startsWith('v')) {
+ const version = entry.name.substring(1);
+ if (version === currentMajorMinor) continue;
+ versions.push({
+ version,
+ href: `/lume/reference/${entry.name}/cli-reference`,
+ isCurrent: false,
+ });
+ }
+ }
+ }
+
+ // Sort descending
+ versions.sort((a, b) => {
+ const partsA = a.version.split('.').map((x) => parseInt(x, 10) || 0);
+ const partsB = b.version.split('.').map((x) => parseInt(x, 10) || 0);
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
+ const partA = partsA[i] || 0;
+ const partB = partsB[i] || 0;
+ if (partA !== partB) return partB - partA;
+ }
+ return 0;
+ });
+
+ return versions;
+}
// ============================================================================
// Main
@@ -222,12 +296,17 @@ async function main() {
// CLI Reference Generator
// ============================================================================
-function generateCLIReferenceMDX(docs: CLIDocumentation): string {
+export function generateCLIReferenceMDX(docs: CLIDocumentation): string {
const lines: string[] = [];
+ // Discover version info
+ const releasedVersion = getLatestReleasedVersion();
+ const currentMajorMinor = releasedVersion.split('.').slice(0, 2).join('.');
+ const versions = discoverVersions(releasedVersion);
+
// Header - frontmatter MUST be at the very beginning of the file
lines.push('---');
- lines.push('title: Lume CLI Reference');
+ lines.push('title: CLI Reference');
lines.push('description: Command Line Interface reference for Lume');
lines.push('---');
lines.push('');
@@ -235,9 +314,23 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
Generated by: npx tsx scripts/docs-generators/lume.ts
Source: libs/lume/src/Commands/*.swift
+ Version: ${releasedVersion}
*/}`);
lines.push('');
lines.push("import { Callout } from 'fumadocs-ui/components/callout';");
+ lines.push("import { VersionHeader } from '@/components/version-selector';");
+ lines.push('');
+
+ // Version selector and badge
+ lines.push('<VersionHeader');
+ lines.push(` versions={${JSON.stringify(versions)}}`);
+ lines.push(` currentVersion="${currentMajorMinor}"`);
+ lines.push(` fullVersion="${releasedVersion}"`);
+ lines.push(` packageName="lume"`);
+ lines.push(
+ ` installCommand="curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh | bash"`
+ );
+ lines.push('/>');
lines.push('');
// Introduction
@@ -247,7 +340,7 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
lines.push('');
lines.push('```bash');
lines.push('# Run a prebuilt macOS VM');
- lines.push('lume run macos-sequoia-vanilla:latest');
+ lines.push('lume run macos-tahoe-vanilla:latest');
lines.push('');
lines.push('# Create a custom VM');
lines.push('lume create my-vm --cpu 4 --memory 8GB --disk-size 50GB');
@@ -257,7 +350,6 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
// Group commands by category
const vmManagement = ['create', 'run', 'stop', 'delete', 'clone'];
const vmInfo = ['ls', 'get', 'set'];
- const remoteAccess = ['ssh'];
const imageManagement = ['images', 'pull', 'push', 'ipsw', 'prune'];
const configuration = ['config', 'serve', 'logs', 'setup'];
@@ -273,12 +365,6 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
lines.push(...generateCommandDoc(cmd, '###'));
}
- lines.push('## Remote Access');
- lines.push('');
- for (const cmd of docs.commands.filter((c) => remoteAccess.includes(c.name))) {
- lines.push(...generateCommandDoc(cmd, '###'));
- }
-
lines.push('## Image Management');
lines.push('');
for (const cmd of docs.commands.filter((c) => imageManagement.includes(c.name))) {
@@ -303,7 +389,7 @@ function generateCLIReferenceMDX(docs: CLIDocumentation): string {
return lines.join('\n');
}
-function generateCommandDoc(cmd: CommandDoc, heading: string): string[] {
+export function generateCommandDoc(cmd: CommandDoc, heading: string): string[] {
const lines: string[] = [];
lines.push(`${heading} lume ${cmd.name}`);
@@ -380,12 +466,17 @@ function generateCommandDoc(cmd: CommandDoc, heading: string): string[] {
// HTTP API Reference Generator
// ============================================================================
-function generateHTTPAPIMDX(docs: HTTPAPIDocumentation): string {
+export function generateHTTPAPIMDX(docs: HTTPAPIDocumentation): string {
const lines: string[] = [];
+ // Discover version info
+ const releasedVersion = getLatestReleasedVersion();
+ const currentMajorMinor = releasedVersion.split('.').slice(0, 2).join('.');
+ const versions = discoverVersions(releasedVersion);
+
// Header - frontmatter MUST be at the very beginning of the file
lines.push('---');
- lines.push('title: Lume HTTP API Reference');
+ lines.push('title: API Reference');
lines.push('description: HTTP API reference for Lume server');
lines.push('---');
lines.push('');
@@ -393,10 +484,24 @@ function generateHTTPAPIMDX(docs: HTTPAPIDocumentation): string {
AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
Generated by: npx tsx scripts/docs-generators/lume.ts
Source: libs/lume/src/Server/*.swift
+ Version: ${releasedVersion}
*/}`);
lines.push('');
lines.push("import { Callout } from 'fumadocs-ui/components/callout';");
lines.push("import { Tabs, Tab } from 'fumadocs-ui/components/tabs';");
+ lines.push("import { VersionHeader } from '@/components/version-selector';");
+ lines.push('');
+
+ // Version selector and badge
+ lines.push('<VersionHeader');
+ lines.push(` versions={${JSON.stringify(versions)}}`);
+ lines.push(` currentVersion="${currentMajorMinor}"`);
+ lines.push(` fullVersion="${releasedVersion}"`);
+ lines.push(` packageName="lume"`);
+ lines.push(
+ ` installCommand="curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh | bash"`
+ );
+ lines.push('/>');
lines.push('');
// Introduction
@@ -430,7 +535,7 @@ function generateHTTPAPIMDX(docs: HTTPAPIDocumentation): string {
return lines.join('\n');
}
-function generateEndpointDoc(endpoint: APIEndpointDoc): string[] {
+export function generateEndpointDoc(endpoint: APIEndpointDoc): string[] {
const lines: string[] = [];
// Title from description
@@ -625,7 +730,7 @@ function getExampleValue(field: APIFieldDoc): unknown {
if (field.name === 'memory') return '8GB';
if (field.name === 'diskSize') return '50GB';
if (field.name === 'display') return '1024x768';
- if (field.name === 'image') return 'macos-sequoia-vanilla:latest';
+ if (field.name === 'image') return 'macos-tahoe-vanilla:latest';
if (field.name === 'path') return '/path/to/storage';
return 'example';
case 'integer':
diff --git a/scripts/docs-generators/python-sdk.ts b/scripts/docs-generators/python-sdk.ts
new file mode 100644
index 0000000000..6541ae3681
--- /dev/null
+++ b/scripts/docs-generators/python-sdk.ts
@@ -0,0 +1,920 @@
+#!/usr/bin/env npx tsx
+
+/**
+ * Python SDK Documentation Generator
+ *
+ * Generates MDX API reference documentation from Python source code docstrings.
+ * Uses griffe to extract documentation without importing packages.
+ *
+ * Usage:
+ * npx tsx scripts/docs-generators/python-sdk.ts # Generate all
+ * npx tsx scripts/docs-generators/python-sdk.ts --sdk=computer # Generate specific SDK
+ * npx tsx scripts/docs-generators/python-sdk.ts --check # Check for drift (CI mode)
+ */
+
+import { execSync } from 'child_process';
+import * as fs from 'fs';
+import * as path from 'path';
+
+// ============================================================================
+// Types
+// ============================================================================
+
+interface PythonPackage {
+ name: string;
+ version: string;
+ docstring: string;
+ exports: string[] | null;
+ classes: ClassDoc[];
+ functions: FunctionDoc[];
+ submodules: ModuleDoc[];
+ error?: string;
+}
+
+interface ModuleDoc {
+ name: string;
+ version: string;
+ docstring: string;
+ exports: string[] | null;
+ classes: ClassDoc[];
+ functions: FunctionDoc[];
+}
+
+interface ClassDoc {
+ name: string;
+ description: string;
+ bases: string[];
+ methods: FunctionDoc[];
+ attributes: AttributeDoc[];
+ is_private: boolean;
+}
+
+interface FunctionDoc {
+ name: string;
+ signature: string;
+ is_async: boolean;
+ is_method: boolean;
+ description: string;
+ parameters: ParameterDoc[];
+ returns: ReturnDoc | null;
+ raises: RaiseDoc[];
+ examples: string[];
+ is_private: boolean;
+ is_dunder: boolean;
+}
+
+interface ParameterDoc {
+ name: string;
+ type: string;
+ description: string;
+ default: string | null;
+}
+
+interface ReturnDoc {
+ type: string;
+ description: string;
+}
+
+interface RaiseDoc {
+ type: string;
+ description: string;
+}
+
+interface AttributeDoc {
+ name: string;
+ type: string;
+ description: string;
+ default: string | null;
+ is_private: boolean;
+}
+
+interface SDKConfig {
+ packageDir: string;
+ packageName: string;
+ outputPath: string;
+ displayName: string;
+ description: string;
+ outputDir: string; // For version discovery (relative to docsBaseDir)
+ tagPrefix: string; // Git tag prefix for version discovery
+ /** Absolute docs dir for this SDK (defaults to docs/content/docs/cua/reference) */
+ docsBaseDir?: string;
+ /** URL base path for hrefs (defaults to /cua/reference) */
+ hrefBase?: string;
+ /** Submodules to include in docs (if set, only these are included; if unset, all are included) */
+ includeSubmodules?: string[];
+ /** Override the page title (defaults to "${displayName} API Reference") */
+ pageTitle?: string;
+}
+
+// ============================================================================
+// Configuration
+// ============================================================================
+
+const ROOT_DIR = path.resolve(__dirname, '../..');
+const PYTHON_SCRIPT = path.join(__dirname, 'extract_python_docs.py');
+
+const SDK_CONFIGS: Record<string, SDKConfig> = {
+ computer: {
+ packageDir: 'libs/python/computer/computer',
+ packageName: 'computer',
+ outputPath: 'docs/content/docs/cua/reference/computer-sdk/index.mdx',
+ displayName: 'Computer SDK',
+ description: 'Python API reference for controlling virtual machines and computer interfaces',
+ outputDir: 'computer-sdk',
+ tagPrefix: 'computer-v',
+ includeSubmodules: ['interface', 'models', 'tracing', 'helpers', 'diorama_computer'],
+ },
+ agent: {
+ packageDir: 'libs/python/agent/agent',
+ packageName: 'agent',
+ outputPath: 'docs/content/docs/cua/reference/agent-sdk/index.mdx',
+ displayName: 'Agent SDK',
+ description: 'Python API reference for building computer-use agents',
+ outputDir: 'agent-sdk',
+ tagPrefix: 'agent-v',
+ includeSubmodules: ['callbacks', 'tools', 'types'],
+ },
+ cli: {
+ packageDir: 'libs/python/cua-cli/cua_cli',
+ packageName: 'cua_cli',
+ outputPath: 'docs/content/docs/cua/reference/cli/index.mdx',
+ displayName: 'Cua CLI',
+ description: 'Python API reference for the Cua command-line interface',
+ outputDir: 'cli',
+ tagPrefix: 'cli-v',
+ },
+ bench: {
+ packageDir: 'libs/cua-bench/cua_bench',
+ packageName: 'cua_bench',
+ outputPath: 'docs/content/docs/cuabench/reference/api.mdx',
+ displayName: 'Cua Bench',
+ description: 'Python API reference for the desktop automation benchmarking framework',
+ outputDir: 'reference',
+ tagPrefix: 'bench-v',
+ docsBaseDir: 'docs/content/docs/cuabench',
+ hrefBase: '/cuabench',
+ pageTitle: 'API Reference',
+ },
+};
+
+// ============================================================================
+// Main
+// ============================================================================
+
+async function main() {
+ const args = process.argv.slice(2);
+ const checkOnly = args.includes('--check') || args.includes('--check-only');
+ const sdkArg = args.find((a) => a.startsWith('--sdk='));
+ const targetSdk = sdkArg?.split('=')[1];
+
+ console.log('🐍 Python SDK Documentation Generator');
+ console.log('=====================================\n');
+
+ // Check if Python script exists
+ if (!fs.existsSync(PYTHON_SCRIPT)) {
+ console.error(`❌ Python extraction script not found: ${PYTHON_SCRIPT}`);
+ process.exit(1);
+ }
+
+ let hasErrors = false;
+
+ for (const [sdkName, config] of Object.entries(SDK_CONFIGS)) {
+ // Skip if targeting specific SDK
+ if (targetSdk && targetSdk !== sdkName) {
+ continue;
+ }
+
+ console.log(`📖 Processing ${config.displayName}...`);
+
+ // Check if package exists
+ const packagePath = path.join(ROOT_DIR, config.packageDir);
+ if (!fs.existsSync(packagePath)) {
+ console.error(` ❌ Package not found: ${config.packageDir}`);
+ hasErrors = true;
+ continue;
+ }
+
+ // Extract documentation using Python script
+ console.log(` Extracting documentation from ${config.packageDir}...`);
+ let docs: PythonPackage;
+ try {
+ const output = execSync(
+ `python3 "${PYTHON_SCRIPT}" "${packagePath}" "${config.packageName}"`,
+ {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ timeout: 60000,
+ }
+ );
+ docs = JSON.parse(output);
+ } catch (error) {
+ console.error(` ❌ Failed to extract documentation: ${error}`);
+ hasErrors = true;
+ continue;
+ }
+
+ if (docs.error) {
+ console.error(` ❌ Extraction error: ${docs.error}`);
+ hasErrors = true;
+ continue;
+ }
+
+ console.log(` Found ${docs.classes.length} classes, ${docs.functions.length} functions`);
+
+ // Generate MDX
+ console.log(` Generating MDX...`);
+ const mdx = generateMDX(docs, config);
+
+ // Ensure output directory exists
+ const outputPath = path.join(ROOT_DIR, config.outputPath);
+ const outputDir = path.dirname(outputPath);
+ if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+ }
+
+ if (checkOnly) {
+ // Check mode: compare with existing file
+ if (fs.existsSync(outputPath)) {
+ const existing = fs.readFileSync(outputPath, 'utf-8');
+ if (existing !== mdx) {
+ console.error(` ❌ ${path.basename(outputPath)} is out of sync with source code`);
+ hasErrors = true;
+ } else {
+ console.log(` ✅ ${path.basename(outputPath)} is up to date`);
+ }
+ } else {
+ console.error(` ❌ ${path.basename(outputPath)} does not exist`);
+ hasErrors = true;
+ }
+ } else {
+ // Generate mode: write file
+ fs.writeFileSync(outputPath, mdx);
+ console.log(` ✅ Generated ${path.relative(ROOT_DIR, outputPath)}`);
+ }
+ }
+
+ if (hasErrors) {
+ if (checkOnly) {
+ console.error(
+ "\n💡 Run 'npx tsx scripts/docs-generators/python-sdk.ts' to update documentation"
+ );
+ }
+ process.exit(1);
+ }
+
+ console.log('\n✅ Python SDK documentation generation complete!');
+}
+
+// ============================================================================
+// Version Discovery
+// ============================================================================
+
+interface VersionInfo {
+ version: string;
+ href: string;
+ isCurrent: boolean;
+}
+
+/**
+ * Get the latest released version from git tags.
+ * Falls back to the version from source if no tags found.
+ */
+function getLatestReleasedVersion(config: SDKConfig, fallbackVersion: string): string {
+ try {
+ const output = execSync(`git tag | grep "^${config.tagPrefix}" | sort -V | tail -1`, {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ }).trim();
+ if (output) {
+ return output.replace(config.tagPrefix, '');
+ }
+ } catch {
+ // Fall through to fallback
+ }
+ return fallbackVersion;
+}
+
+function discoverVersions(config: SDKConfig, currentVersion: string): VersionInfo[] {
+ const baseDir = config.docsBaseDir
+ ? path.join(ROOT_DIR, config.docsBaseDir)
+ : path.join(ROOT_DIR, 'docs/content/docs/cua/reference');
+ const docsDir = path.join(baseDir, config.outputDir);
+ const hrefBase = config.hrefBase ?? '/cua/reference';
+ const versions: VersionInfo[] = [];
+
+ // Add current version (latest) — points to the index page (folder root)
+ const currentMajorMinor = currentVersion.split('.').slice(0, 2).join('.');
+ versions.push({
+ version: currentMajorMinor,
+ href: `${hrefBase}/${config.outputDir}`,
+ isCurrent: true,
+ });
+
+ // Discover versioned folders (v0.5, v0.4, etc.)
+ if (fs.existsSync(docsDir)) {
+ const entries = fs.readdirSync(docsDir, { withFileTypes: true });
+ for (const entry of entries) {
+ if (entry.isDirectory() && entry.name.startsWith('v')) {
+ const version = entry.name.substring(1); // Remove 'v' prefix
+ // Skip if this is the current version
+ if (version === currentMajorMinor) continue;
+
+ versions.push({
+ version,
+ href: `${hrefBase}/${config.outputDir}/${entry.name}/api`,
+ isCurrent: false,
+ });
+ }
+ }
+ }
+
+ // Sort versions descending
+ versions.sort((a, b) => {
+ const partsA = a.version.split('.').map((x) => parseInt(x, 10) || 0);
+ const partsB = b.version.split('.').map((x) => parseInt(x, 10) || 0);
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
+ const partA = partsA[i] || 0;
+ const partB = partsB[i] || 0;
+ if (partA !== partB) return partB - partA;
+ }
+ return 0;
+ });
+
+ return versions;
+}
+
+// ============================================================================
+// MDX Generation
+// ============================================================================
+
+function generateMDX(docs: PythonPackage, config: SDKConfig): string {
+ const lines: string[] = [];
+
+ // Get the actual latest released version from git tags
+ const releasedVersion = getLatestReleasedVersion(config, docs.version);
+
+ // Frontmatter
+ const pageTitle = config.pageTitle ?? `${config.displayName} API Reference`;
+ lines.push('---');
+ lines.push(`title: ${pageTitle}`);
+ lines.push(`description: ${config.description}`);
+ lines.push('---');
+ lines.push('');
+
+ // Auto-generated notice
+ lines.push(`{/*`);
+ lines.push(` AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY`);
+ lines.push(` Generated by: npx tsx scripts/docs-generators/python-sdk.ts`);
+ lines.push(` Source: ${config.packageDir}`);
+ lines.push(` Version: ${releasedVersion}`);
+ lines.push(`*/}`);
+ lines.push('');
+
+ // Imports
+ lines.push("import { Callout } from 'fumadocs-ui/components/callout';");
+ lines.push("import { Tabs, Tab } from 'fumadocs-ui/components/tabs';");
+ lines.push("import { VersionHeader } from '@/components/version-selector';");
+ lines.push('');
+
+ // Discover available versions using the released version
+ const versions = discoverVersions(config, releasedVersion);
+ const currentMajorMinor = releasedVersion.split('.').slice(0, 2).join('.');
+
+ // Version selector and badge
+ lines.push('<VersionHeader');
+ lines.push(` versions={${JSON.stringify(versions)}}`);
+ lines.push(` currentVersion="${currentMajorMinor}"`);
+ lines.push(` fullVersion="${releasedVersion}"`);
+ // Use pip-style package name (underscores → hyphens)
+ // If it already starts with 'cua', don't add prefix
+ const pipName = config.packageName.replace(/_/g, '-');
+ const fullPipName = pipName.startsWith('cua') ? pipName : `cua-${pipName}`;
+ lines.push(` packageName="${fullPipName}"`);
+ lines.push('/>');
+ lines.push('');
+
+ // Package description
+ if (docs.docstring) {
+ lines.push(docs.docstring);
+ lines.push('');
+ }
+
+ // Table of contents for classes
+ if (docs.classes.length > 0) {
+ lines.push('## Classes');
+ lines.push('');
+ lines.push('| Class | Description |');
+ lines.push('|-------|-------------|');
+ for (const cls of docs.classes) {
+ if (!cls.is_private) {
+ const desc = escapeMDX(cls.description.split('\n')[0]) || 'No description';
+ lines.push(`| [\`${cls.name}\`](#${cls.name.toLowerCase()}) | ${desc} |`);
+ }
+ }
+ lines.push('');
+ }
+
+ // Table of contents for functions
+ if (docs.functions.length > 0) {
+ lines.push('## Functions');
+ lines.push('');
+ lines.push('| Function | Description |');
+ lines.push('|----------|-------------|');
+ for (const fn of docs.functions) {
+ if (!fn.is_private) {
+ const desc = escapeMDX(fn.description.split('\n')[0]) || 'No description';
+ lines.push(`| [\`${fn.name}\`](#${fn.name.toLowerCase()}) | ${desc} |`);
+ }
+ }
+ lines.push('');
+ }
+
+ // Detailed class documentation
+ for (const cls of docs.classes) {
+ if (!cls.is_private) {
+ lines.push(...generateClassDoc(cls));
+ }
+ }
+
+ // Detailed function documentation
+ for (const fn of docs.functions) {
+ if (!fn.is_private) {
+ lines.push(...generateFunctionDoc(fn, '##'));
+ }
+ }
+
+ // Submodules (for packages that expose API through submodules)
+ if (docs.submodules && docs.submodules.length > 0) {
+ let publicSubmodules = docs.submodules.filter(
+ (m) => !m.name.startsWith('_') && (m.classes.length > 0 || m.functions.length > 0)
+ );
+
+ // Filter to only included submodules if configured
+ if (config.includeSubmodules) {
+ publicSubmodules = publicSubmodules.filter((m) => config.includeSubmodules!.includes(m.name));
+ }
+
+ for (const mod of publicSubmodules) {
+ const publicClasses = mod.classes.filter((c) => !c.is_private);
+ const publicFunctions = mod.functions.filter((f) => !f.is_private && !f.is_dunder);
+
+ if (publicClasses.length === 0 && publicFunctions.length === 0) continue;
+
+ lines.push('---');
+ lines.push('');
+ lines.push(`## ${mod.name}`);
+ lines.push('');
+ if (mod.docstring) {
+ lines.push(escapeMDX(mod.docstring));
+ lines.push('');
+ }
+
+ for (const cls of publicClasses) {
+ lines.push(...generateClassDoc(cls));
+ }
+
+ for (const fn of publicFunctions) {
+ lines.push(...generateFunctionDoc(fn, '###'));
+ }
+ }
+ }
+
+ return lines.join('\n');
+}
+
+function generateClassDoc(cls: ClassDoc): string[] {
+ const lines: string[] = [];
+
+ lines.push('---');
+ lines.push('');
+ lines.push(`## ${cls.name}`);
+ lines.push('');
+
+ // Base classes
+ if (cls.bases.length > 0) {
+ const bases = cls.bases.filter((b) => b !== 'object').join(', ');
+ if (bases) {
+ lines.push(`*Inherits from: ${bases}*`);
+ lines.push('');
+ }
+ }
+
+ // Description
+ if (cls.description) {
+ lines.push(escapeMDX(cls.description));
+ lines.push('');
+ }
+
+ // Constructor (__init__)
+ const initMethod = cls.methods.find((m) => m.name === '__init__');
+ if (initMethod) {
+ lines.push('### Constructor');
+ lines.push('');
+ lines.push('```python');
+ lines.push(formatSignature(initMethod.signature, cls.name));
+ lines.push('```');
+ lines.push('');
+
+ if (initMethod.parameters.length > 0) {
+ lines.push(...generateParametersTable(initMethod.parameters));
+ }
+ }
+
+ // Attributes
+ if (cls.attributes.length > 0) {
+ lines.push('### Attributes');
+ lines.push('');
+ lines.push('| Name | Type | Description |');
+ lines.push('|------|------|-------------|');
+ for (const attr of cls.attributes) {
+ const type = attr.type || 'Any';
+ // Strip docstring sections and collapse to single line for table cells
+ const desc = escapeMDX(stripDocstringSections(attr.description)) || '';
+ lines.push(`| \`${attr.name}\` | \`${type}\` | ${desc} |`);
+ }
+ lines.push('');
+ }
+
+ // Methods (excluding __init__ and private)
+ const publicMethods = cls.methods.filter(
+ (m) => !m.is_private && !m.is_dunder && m.name !== '__init__'
+ );
+
+ if (publicMethods.length > 0) {
+ lines.push('### Methods');
+ lines.push('');
+
+ for (const method of publicMethods) {
+ lines.push(...generateMethodDoc(method, cls.name));
+ }
+ }
+
+ return lines;
+}
+
+function generateMethodDoc(method: FunctionDoc, className: string): string[] {
+ const lines: string[] = [];
+
+ lines.push(`#### ${className}.${method.name}`);
+ lines.push('');
+ lines.push('```python');
+ lines.push(formatSignature(method.signature));
+ lines.push('```');
+ lines.push('');
+
+ // Use structured data flags to avoid duplicating info from docstring
+ const hasStructuredParams = method.parameters.filter((p) => p.name !== 'self').length > 0;
+ const hasStructuredReturns = !!method.returns;
+ const hasStructuredRaises = method.raises.length > 0;
+
+ if (method.description) {
+ lines.push(
+ ...formatDocstringLines(
+ method.description,
+ hasStructuredParams,
+ hasStructuredReturns,
+ hasStructuredRaises
+ )
+ );
+ }
+
+ // Structured parameters (from parsed signature)
+ if (hasStructuredParams) {
+ const params = method.parameters.filter((p) => p.name !== 'self');
+ lines.push(...generateParametersTable(params));
+ }
+
+ // Structured returns
+ if (method.returns) {
+ lines.push('**Returns:**');
+ lines.push('');
+ const returnType = method.returns.type || 'None';
+ const returnDesc = escapeMDX(method.returns.description) || '';
+ lines.push(`- \`${returnType}\` - ${returnDesc}`);
+ lines.push('');
+ }
+
+ // Structured raises
+ if (method.raises.length > 0) {
+ lines.push('**Raises:**');
+ lines.push('');
+ for (const exc of method.raises) {
+ lines.push(`- \`${exc.type}\` - ${escapeMDX(exc.description)}`);
+ }
+ lines.push('');
+ }
+
+ return lines;
+}
+
+function generateFunctionDoc(fn: FunctionDoc, heading: string): string[] {
+ const lines: string[] = [];
+
+ lines.push(`${heading} ${fn.name}`);
+ lines.push('');
+ lines.push('```python');
+ lines.push(formatSignature(fn.signature));
+ lines.push('```');
+ lines.push('');
+
+ const hasStructuredParams = fn.parameters.length > 0;
+ const hasStructuredReturns = !!fn.returns;
+ const hasStructuredRaises = fn.raises.length > 0;
+
+ if (fn.description) {
+ lines.push(
+ ...formatDocstringLines(
+ fn.description,
+ hasStructuredParams,
+ hasStructuredReturns,
+ hasStructuredRaises
+ )
+ );
+ }
+
+ // Structured parameters
+ if (hasStructuredParams) {
+ lines.push(...generateParametersTable(fn.parameters));
+ }
+
+ // Structured returns
+ if (fn.returns) {
+ lines.push('**Returns:**');
+ lines.push('');
+ const returnType = fn.returns.type || 'None';
+ const returnDesc = escapeMDX(fn.returns.description) || '';
+ lines.push(`- \`${returnType}\` - ${returnDesc}`);
+ lines.push('');
+ }
+
+ // Structured raises
+ if (fn.raises.length > 0) {
+ lines.push('**Raises:**');
+ lines.push('');
+ for (const exc of fn.raises) {
+ lines.push(`- \`${exc.type}\` - ${escapeMDX(exc.description)}`);
+ }
+ lines.push('');
+ }
+
+ // Structured examples (from parsed data)
+ if (fn.examples.length > 0) {
+ lines.push('**Example:**');
+ lines.push('');
+ lines.push('```python');
+ for (const example of fn.examples) {
+ lines.push(example);
+ }
+ lines.push('```');
+ lines.push('');
+ }
+
+ return lines;
+}
+
+function generateParametersTable(params: ParameterDoc[]): string[] {
+ const lines: string[] = [];
+
+ lines.push('**Parameters:**');
+ lines.push('');
+ lines.push('| Name | Type | Description |');
+ lines.push('|------|------|-------------|');
+
+ for (const param of params) {
+ const type = param.type || 'Any';
+ const desc = escapeMDX(param.description) || '';
+ const defaultVal = param.default ? ` (default: \`${param.default}\`)` : '';
+ lines.push(`| \`${param.name}\` | \`${type}\` | ${desc}${defaultVal} |`);
+ }
+
+ lines.push('');
+ return lines;
+}
+
+function formatSignature(signature: string, className?: string): string {
+ // Replace __init__ with class name for constructors
+ if (className && signature.includes('__init__')) {
+ return signature.replace('def __init__', className);
+ }
+ return signature;
+}
+
+/**
+ * Escape special MDX characters in text content.
+ * Curly braces and HTML-like tags must be escaped outside of code blocks.
+ */
+function escapeMDX(text: string): string {
+ if (!text) return text;
+ return (
+ text
+ .replace(/\{/g, '\\{')
+ .replace(/\}/g, '\\}')
+ // Escape HTML-like tags that would be interpreted as JSX components
+ // but preserve markdown links []() and code backticks
+ .replace(/<(?!\/?(?:Callout|Tab|Tabs|VersionHeader|div|span|a|code|pre|br|hr)\b)/g, '&lt;')
+ );
+}
+
+/**
+ * Parse Google-style docstring sections (Args, Returns, Raises, Examples)
+ * and return the description text with those sections stripped,
+ * plus the parsed sections as structured data.
+ */
+interface ParsedDocstring {
+ description: string;
+ args: { name: string; type: string; description: string }[];
+ returns: string;
+ raises: { type: string; description: string }[];
+ examples: string[];
+}
+
+function parseDocstring(text: string): ParsedDocstring {
+ if (!text) return { description: '', args: [], returns: '', raises: [], examples: [] };
+
+ const lines = text.split('\n');
+ const result: ParsedDocstring = {
+ description: '',
+ args: [],
+ returns: '',
+ raises: [],
+ examples: [],
+ };
+
+ type Section = 'description' | 'args' | 'returns' | 'raises' | 'examples';
+ let currentSection: Section = 'description';
+ const descLines: string[] = [];
+ const returnsLines: string[] = [];
+ const exampleLines: string[] = [];
+ let currentArg: { name: string; type: string; description: string } | null = null;
+ let currentRaise: { type: string; description: string } | null = null;
+
+ for (const line of lines) {
+ const trimmed = line.trim();
+
+ // Detect section headers
+ if (/^Args?\s*:/.test(trimmed) || /^Parameters?\s*:/.test(trimmed)) {
+ currentSection = 'args';
+ continue;
+ }
+ if (/^Returns?\s*:/.test(trimmed)) {
+ // Check if it's a one-liner like "Returns: something"
+ const inlineReturn = trimmed.replace(/^Returns?\s*:\s*/, '');
+ if (inlineReturn) {
+ returnsLines.push(inlineReturn);
+ }
+ currentSection = 'returns';
+ continue;
+ }
+ if (/^Raises?\s*:/.test(trimmed)) {
+ currentSection = 'raises';
+ continue;
+ }
+ if (/^Examples?\s*:/.test(trimmed)) {
+ currentSection = 'examples';
+ continue;
+ }
+
+ switch (currentSection) {
+ case 'description':
+ descLines.push(line);
+ break;
+
+ case 'args': {
+ // Match "param_name (type): description" or "param_name: description"
+ const argMatch = trimmed.match(/^(\w+)\s*(?:\(([^)]+)\))?\s*:\s*(.*)$/);
+ if (argMatch && !line.startsWith(' ')) {
+ if (currentArg) result.args.push(currentArg);
+ currentArg = {
+ name: argMatch[1],
+ type: argMatch[2] || '',
+ description: argMatch[3],
+ };
+ } else if (currentArg && trimmed) {
+ // Continuation line for current arg
+ currentArg.description += ' ' + trimmed;
+ }
+ break;
+ }
+
+ case 'returns':
+ if (trimmed) returnsLines.push(trimmed);
+ break;
+
+ case 'raises': {
+ const raiseMatch = trimmed.match(/^(\w+)\s*:\s*(.*)$/);
+ if (raiseMatch && !line.startsWith(' ')) {
+ if (currentRaise) result.raises.push(currentRaise);
+ currentRaise = { type: raiseMatch[1], description: raiseMatch[2] };
+ } else if (currentRaise && trimmed) {
+ currentRaise.description += ' ' + trimmed;
+ }
+ break;
+ }
+
+ case 'examples':
+ exampleLines.push(line);
+ break;
+ }
+ }
+
+ // Flush remaining items
+ if (currentArg) result.args.push(currentArg);
+ if (currentRaise) result.raises.push(currentRaise);
+
+ result.description = descLines.join('\n').trim();
+ result.returns = returnsLines.join(' ').trim();
+ result.examples = exampleLines;
+
+ return result;
+}
+
+/**
+ * Format a parsed docstring into markdown lines.
+ * Only outputs sections not already covered by structured data.
+ */
+function formatDocstringLines(
+ text: string,
+ hasStructuredParams: boolean,
+ hasStructuredReturns: boolean,
+ hasStructuredRaises: boolean
+): string[] {
+ const parsed = parseDocstring(text);
+ const lines: string[] = [];
+
+ // Description (always output)
+ if (parsed.description) {
+ lines.push(escapeMDX(parsed.description));
+ lines.push('');
+ }
+
+ // Args (only if no structured params)
+ if (!hasStructuredParams && parsed.args.length > 0) {
+ lines.push('**Parameters:**');
+ lines.push('');
+ lines.push('| Name | Type | Description |');
+ lines.push('|------|------|-------------|');
+ for (const arg of parsed.args) {
+ const type = arg.type || 'Any';
+ lines.push(`| \`${arg.name}\` | \`${escapeMDX(type)}\` | ${escapeMDX(arg.description)} |`);
+ }
+ lines.push('');
+ }
+
+ // Returns (only if no structured returns)
+ if (!hasStructuredReturns && parsed.returns) {
+ lines.push(`**Returns:** ${escapeMDX(parsed.returns)}`);
+ lines.push('');
+ }
+
+ // Raises (only if no structured raises)
+ if (!hasStructuredRaises && parsed.raises.length > 0) {
+ lines.push('**Raises:**');
+ lines.push('');
+ for (const r of parsed.raises) {
+ lines.push(`- \`${r.type}\` - ${escapeMDX(r.description)}`);
+ }
+ lines.push('');
+ }
+
+ // Examples
+ if (parsed.examples.length > 0) {
+ // Dedent example lines by removing common leading whitespace
+ const nonEmptyLines = parsed.examples.filter((l) => l.trim().length > 0);
+ if (nonEmptyLines.length > 0) {
+ const minIndent = Math.min(...nonEmptyLines.map((l) => l.match(/^(\s*)/)?.[1].length ?? 0));
+ const dedented = parsed.examples
+ .map((l) => (l.trim().length > 0 ? l.substring(minIndent) : ''))
+ .join('\n')
+ .trim();
+ if (dedented) {
+ lines.push('**Example:**');
+ lines.push('');
+ lines.push('```python');
+ lines.push(dedented);
+ lines.push('```');
+ lines.push('');
+ }
+ }
+ }
+
+ return lines;
+}
+
+/**
+ * Strip docstring sections from text for use in single-line contexts (e.g. table cells).
+ */
+function stripDocstringSections(text: string): string {
+ if (!text) return text;
+ const parsed = parseDocstring(text);
+ // Return only the first line of the description
+ return parsed.description.split('\n')[0].trim();
+}
+
+// ============================================================================
+// Run
+// ============================================================================
+
+main().catch((error) => {
+ console.error('Error:', error);
+ process.exit(1);
+});
diff --git a/scripts/docs-generators/requirements.txt b/scripts/docs-generators/requirements.txt
new file mode 100644
index 0000000000..b702894ddc
--- /dev/null
+++ b/scripts/docs-generators/requirements.txt
@@ -0,0 +1,2 @@
+# Python dependencies for documentation generation
+griffe>=0.40.0
diff --git a/scripts/docs-generators/typescript-sdk.ts b/scripts/docs-generators/typescript-sdk.ts
new file mode 100644
index 0000000000..ba26a29af1
--- /dev/null
+++ b/scripts/docs-generators/typescript-sdk.ts
@@ -0,0 +1,772 @@
+#!/usr/bin/env npx tsx
+
+/**
+ * TypeScript SDK Documentation Generator
+ *
+ * Generates MDX API reference documentation from TypeScript source code.
+ * Uses regex-based parsing to extract exports and JSDoc comments (no TS compiler dependency).
+ *
+ * Usage:
+ * npx tsx scripts/docs-generators/typescript-sdk.ts # Generate all
+ * npx tsx scripts/docs-generators/typescript-sdk.ts --sdk=cuabot # Generate specific
+ * npx tsx scripts/docs-generators/typescript-sdk.ts --check # Check for drift (CI mode)
+ */
+
+import * as fs from 'fs';
+import * as path from 'path';
+import { execSync } from 'child_process';
+
+// ============================================================================
+// Types
+// ============================================================================
+
+interface ExtractedClass {
+ name: string;
+ description: string;
+ constructorSig: string | null;
+ constructorParams: ParamInfo[];
+ methods: MethodInfo[];
+ properties: PropInfo[];
+}
+
+interface ExtractedInterface {
+ name: string;
+ description: string;
+ properties: PropInfo[];
+}
+
+interface ExtractedFunction {
+ name: string;
+ description: string;
+ signature: string;
+ params: ParamInfo[];
+ returnType: string;
+ isAsync: boolean;
+}
+
+interface ExtractedConst {
+ name: string;
+ type: string;
+ description: string;
+}
+
+interface MethodInfo {
+ name: string;
+ description: string;
+ signature: string;
+ params: ParamInfo[];
+ returnType: string;
+ isAsync: boolean;
+}
+
+interface ParamInfo {
+ name: string;
+ type: string;
+ description: string;
+ defaultValue: string | null;
+ isOptional: boolean;
+}
+
+interface PropInfo {
+ name: string;
+ type: string;
+ description: string;
+ isOptional: boolean;
+}
+
+interface ModuleDoc {
+ name: string;
+ description: string;
+ classes: ExtractedClass[];
+ interfaces: ExtractedInterface[];
+ functions: ExtractedFunction[];
+ constants: ExtractedConst[];
+}
+
+interface SDKConfig {
+ packageDir: string;
+ packageName: string;
+ outputPath: string;
+ displayName: string;
+ description: string;
+ outputDir: string;
+ tagPrefix: string;
+ docsBaseDir?: string;
+ hrefBase?: string;
+ pageTitle?: string;
+ includeFiles?: string[];
+ installCommand?: string;
+}
+
+// ============================================================================
+// Configuration
+// ============================================================================
+
+const ROOT_DIR = path.resolve(__dirname, '../..');
+
+const SDK_CONFIGS: Record<string, SDKConfig> = {
+ cuabot: {
+ packageDir: 'libs/cuabot/src',
+ packageName: 'cuabot',
+ outputPath: 'docs/content/docs/cuabot/reference/index.mdx',
+ displayName: 'Cua-Bot',
+ description: 'TypeScript API reference for the Cua-Bot sandboxed agent framework',
+ outputDir: 'reference',
+ tagPrefix: 'cuabot-v',
+ docsBaseDir: 'docs/content/docs/cuabot',
+ hrefBase: '/cuabot',
+ pageTitle: 'API Reference',
+ includeFiles: ['client.ts', 'settings.ts'],
+ installCommand: 'npm install -g cuabot',
+ },
+};
+
+// ============================================================================
+// Main
+// ============================================================================
+
+async function main() {
+ const args = process.argv.slice(2);
+ const checkOnly = args.includes('--check') || args.includes('--check-only');
+ const sdkArg = args.find((a) => a.startsWith('--sdk='));
+ const targetSdk = sdkArg?.split('=')[1];
+
+ console.log('📦 TypeScript SDK Documentation Generator');
+ console.log('==========================================\n');
+
+ let hasErrors = false;
+
+ for (const [sdkName, config] of Object.entries(SDK_CONFIGS)) {
+ if (targetSdk && targetSdk !== sdkName) continue;
+
+ console.log(`📖 Processing ${config.displayName}...`);
+
+ const packagePath = path.join(ROOT_DIR, config.packageDir);
+ if (!fs.existsSync(packagePath)) {
+ console.error(` ❌ Package not found: ${config.packageDir}`);
+ hasErrors = true;
+ continue;
+ }
+
+ const modules = extractDocs(packagePath, config);
+ console.log(
+ ` Found ${modules.reduce((n, m) => n + m.classes.length, 0)} classes, ` +
+ `${modules.reduce((n, m) => n + m.functions.length, 0)} functions, ` +
+ `${modules.reduce((n, m) => n + m.interfaces.length, 0)} interfaces`
+ );
+
+ const mdx = generateMDX(modules, config);
+
+ const outputPath = path.join(ROOT_DIR, config.outputPath);
+ const outputDir = path.dirname(outputPath);
+ if (!fs.existsSync(outputDir)) {
+ fs.mkdirSync(outputDir, { recursive: true });
+ }
+
+ if (checkOnly) {
+ // Check mode: compare with existing file
+ if (fs.existsSync(outputPath)) {
+ const existing = fs.readFileSync(outputPath, 'utf-8');
+ if (existing !== mdx) {
+ console.error(` ❌ ${path.basename(outputPath)} is out of sync with source code`);
+ hasErrors = true;
+ } else {
+ console.log(` ✅ ${path.basename(outputPath)} is up to date`);
+ }
+ } else {
+ console.error(` ❌ ${path.basename(outputPath)} does not exist (needs generation)`);
+ hasErrors = true;
+ }
+ } else {
+ // Generate mode: write file
+ fs.writeFileSync(outputPath, mdx);
+ console.log(` ✅ Generated ${path.relative(ROOT_DIR, outputPath)}`);
+ }
+ }
+
+ if (hasErrors) {
+ if (checkOnly) {
+ console.error(
+ "\n💡 Run 'npx tsx scripts/docs-generators/typescript-sdk.ts' to update documentation"
+ );
+ }
+ process.exit(1);
+ }
+ console.log('\n✅ TypeScript SDK documentation generation complete!');
+}
+
+// ============================================================================
+// Regex-based Extraction
+// ============================================================================
+
+function extractDocs(packagePath: string, config: SDKConfig): ModuleDoc[] {
+ const fileNames = config.includeFiles
+ ? config.includeFiles
+ : fs.readdirSync(packagePath).filter((f) => f.endsWith('.ts') && !f.endsWith('.d.ts'));
+
+ const modules: ModuleDoc[] = [];
+
+ for (const fileName of fileNames) {
+ const filePath = path.join(packagePath, fileName);
+ if (!fs.existsSync(filePath)) continue;
+ const source = fs.readFileSync(filePath, 'utf-8');
+ const moduleName = path.basename(fileName, '.ts');
+
+ const mod: ModuleDoc = {
+ name: moduleName,
+ description: extractFileDescription(source),
+ classes: extractClasses(source),
+ interfaces: extractInterfaces(source),
+ functions: extractFunctions(source),
+ constants: extractConstants(source),
+ };
+
+ if (
+ mod.classes.length > 0 ||
+ mod.interfaces.length > 0 ||
+ mod.functions.length > 0 ||
+ mod.constants.length > 0
+ ) {
+ modules.push(mod);
+ }
+ }
+
+ return modules;
+}
+
+function extractFileDescription(source: string): string {
+ const match = source.match(/^\/\*\*\s*\n([\s\S]*?)\*\//);
+ if (!match) return '';
+ return match[1]
+ .split('\n')
+ .map((l) => l.replace(/^\s*\*\s?/, '').trim())
+ .filter(Boolean)
+ .join('\n');
+}
+
+/**
+ * Get the JSDoc comment immediately preceding a position in source.
+ */
+function getJSDocBefore(source: string, pos: number): string {
+ const before = source.substring(0, pos);
+ const match = before.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
+ if (!match) return '';
+ return match[1]
+ .split('\n')
+ .map((l) => l.replace(/^\s*\*\s?/, ''))
+ .filter((l) => !l.startsWith('@'))
+ .join('\n')
+ .trim();
+}
+
+function extractClasses(source: string): ExtractedClass[] {
+ const classes: ExtractedClass[] = [];
+ const classRegex = /export\s+class\s+(\w+)(?:\s+extends\s+[\w.]+)?\s*\{/g;
+
+ let match;
+ while ((match = classRegex.exec(source)) !== null) {
+ const name = match[1];
+ const description = getJSDocBefore(source, match.index);
+ const classBodyStart = match.index + match[0].length;
+ const classBody = extractBraceBlock(source, classBodyStart - 1);
+
+ const cls: ExtractedClass = {
+ name,
+ description,
+ constructorSig: null,
+ constructorParams: [],
+ methods: [],
+ properties: [],
+ };
+
+ // Extract constructor
+ const ctorMatch = classBody.match(/constructor\s*\(([\s\S]*?)\)\s*\{/);
+ if (ctorMatch) {
+ cls.constructorParams = parseParams(ctorMatch[1]);
+ cls.constructorSig = `constructor(${ctorMatch[1].trim()})`;
+ }
+
+ // Extract methods (async or not, excluding private)
+ const methodRegex =
+ /(\/\*\*[\s\S]*?\*\/\s*)?(async\s+)?(\w+)\s*\(([\s\S]*?)\)\s*:\s*([\w<>\[\]|, ]+)\s*\{/g;
+ let mMatch;
+ while ((mMatch = methodRegex.exec(classBody)) !== null) {
+ const methodName = mMatch[3];
+ if (methodName === 'constructor' || methodName.startsWith('_') || methodName === 'private')
+ continue;
+
+ const isAsync = !!mMatch[2];
+ const params = parseParams(mMatch[4]);
+ const returnType = mMatch[5].trim();
+ const jsdoc = mMatch[1] ? parseJSDocBlock(mMatch[1]) : '';
+
+ // Get param descriptions from JSDoc
+ if (mMatch[1]) {
+ const paramDescs = parseJSDocParams(mMatch[1]);
+ for (const p of params) {
+ if (paramDescs[p.name]) p.description = paramDescs[p.name];
+ }
+ }
+
+ cls.methods.push({
+ name: methodName,
+ description: jsdoc,
+ signature: `${isAsync ? 'async ' : ''}${methodName}(${params.map((p) => formatParam(p)).join(', ')}): ${returnType}`,
+ params: params.filter((p) => p.name !== 'this'),
+ returnType,
+ isAsync,
+ });
+ }
+
+ classes.push(cls);
+ }
+
+ return classes;
+}
+
+function extractInterfaces(source: string): ExtractedInterface[] {
+ const interfaces: ExtractedInterface[] = [];
+ const ifaceRegex = /export\s+interface\s+(\w+)\s*\{/g;
+
+ let match;
+ while ((match = ifaceRegex.exec(source)) !== null) {
+ const name = match[1];
+ const description = getJSDocBefore(source, match.index);
+ const bodyStart = match.index + match[0].length;
+ const body = extractBraceBlock(source, bodyStart - 1);
+
+ const properties: PropInfo[] = [];
+ const propRegex = /(\w+)(\?)?\s*:\s*([^;\n]+)/g;
+ let pMatch;
+ while ((pMatch = propRegex.exec(body)) !== null) {
+ properties.push({
+ name: pMatch[1],
+ type: pMatch[3].trim().replace(/;$/, ''),
+ description: '',
+ isOptional: !!pMatch[2],
+ });
+ }
+
+ interfaces.push({ name, description, properties });
+ }
+
+ return interfaces;
+}
+
+function extractFunctions(source: string): ExtractedFunction[] {
+ const functions: ExtractedFunction[] = [];
+ const fnRegex =
+ /export\s+(async\s+)?function\s+(\w+)\s*\(([\s\S]*?)\)\s*:\s*([\w<>\[\]|, {}:]+)\s*\{/g;
+
+ let match;
+ while ((match = fnRegex.exec(source)) !== null) {
+ const isAsync = !!match[1];
+ const name = match[2];
+ if (name.startsWith('_')) continue;
+
+ const params = parseParams(match[3]);
+ const returnType = match[4].trim();
+ const description = getJSDocBefore(source, match.index);
+
+ // Get param descriptions from JSDoc
+ const jsdocBlock = source.substring(Math.max(0, match.index - 500), match.index);
+ const jsdocMatch = jsdocBlock.match(/\/\*\*([\s\S]*?)\*\/\s*$/);
+ if (jsdocMatch) {
+ const paramDescs = parseJSDocParams(jsdocMatch[0]);
+ for (const p of params) {
+ if (paramDescs[p.name]) p.description = paramDescs[p.name];
+ }
+ }
+
+ functions.push({
+ name,
+ description,
+ signature: `${isAsync ? 'async ' : ''}function ${name}(${params.map((p) => formatParam(p)).join(', ')}): ${returnType}`,
+ params,
+ returnType,
+ isAsync,
+ });
+ }
+
+ return functions;
+}
+
+function extractConstants(source: string): ExtractedConst[] {
+ const constants: ExtractedConst[] = [];
+ const constRegex = /export\s+const\s+(\w+)(?:\s*:\s*([^=]+))?\s*=/g;
+
+ let match;
+ while ((match = constRegex.exec(source)) !== null) {
+ const name = match[1];
+ if (name.startsWith('_')) continue;
+ const type = match[2]?.trim() || 'const';
+ const description = getJSDocBefore(source, match.index);
+ constants.push({ name, type, description });
+ }
+
+ return constants;
+}
+
+// ============================================================================
+// Helpers
+// ============================================================================
+
+function extractBraceBlock(source: string, openBracePos: number): string {
+ let depth = 0;
+ let start = openBracePos;
+ for (let i = openBracePos; i < source.length; i++) {
+ if (source[i] === '{') depth++;
+ else if (source[i] === '}') {
+ depth--;
+ if (depth === 0) return source.substring(start + 1, i);
+ }
+ }
+ return source.substring(start + 1);
+}
+
+function parseParams(paramStr: string): ParamInfo[] {
+ if (!paramStr.trim()) return [];
+
+ const params: ParamInfo[] = [];
+ let depth = 0;
+ let current = '';
+
+ for (const char of paramStr) {
+ if (char === '(' || char === '<' || char === '{' || char === '[') depth++;
+ else if (char === ')' || char === '>' || char === '}' || char === ']') depth--;
+
+ if (char === ',' && depth === 0) {
+ const p = parseSingleParam(current.trim());
+ if (p) params.push(p);
+ current = '';
+ } else {
+ current += char;
+ }
+ }
+ if (current.trim()) {
+ const p = parseSingleParam(current.trim());
+ if (p) params.push(p);
+ }
+
+ return params;
+}
+
+function parseSingleParam(param: string): ParamInfo | null {
+ if (!param) return null;
+
+ // Match: name?: type = default
+ const match = param.match(/^(\w+)(\?)?\s*(?::\s*([\s\S]+?))?(?:\s*=\s*([\s\S]+))?$/);
+ if (!match) return null;
+
+ return {
+ name: match[1],
+ type: match[3]?.trim().replace(/\s*=\s*[\s\S]*$/, '') || 'any',
+ description: '',
+ defaultValue: match[4]?.trim() || null,
+ isOptional: !!match[2] || !!match[4],
+ };
+}
+
+function formatParam(p: ParamInfo): string {
+ const opt = p.isOptional && !p.defaultValue ? '?' : '';
+ const def = p.defaultValue ? ` = ${p.defaultValue}` : '';
+ return `${p.name}${opt}: ${p.type}${def}`;
+}
+
+function parseJSDocBlock(block: string): string {
+ return block
+ .replace(/^\/\*\*\s*/, '')
+ .replace(/\s*\*\/\s*$/, '')
+ .split('\n')
+ .map((l) => l.replace(/^\s*\*\s?/, ''))
+ .filter((l) => !l.startsWith('@'))
+ .join('\n')
+ .trim();
+}
+
+function parseJSDocParams(block: string): Record<string, string> {
+ const params: Record<string, string> = {};
+ const lines = block.split('\n');
+ for (const line of lines) {
+ const match = line.match(/@param\s+(\w+)\s+(.*)/);
+ if (match) params[match[1]] = match[2].trim();
+ }
+ return params;
+}
+
+// ============================================================================
+// Version Discovery
+// ============================================================================
+
+interface VersionInfo {
+ version: string;
+ href: string;
+ isCurrent: boolean;
+}
+
+function getLatestReleasedVersion(config: SDKConfig, fallback: string): string {
+ try {
+ const output = execSync(`git tag | grep "^${config.tagPrefix}" | sort -V | tail -1`, {
+ encoding: 'utf-8',
+ cwd: ROOT_DIR,
+ }).trim();
+ if (output) return output.replace(config.tagPrefix, '');
+ } catch {
+ // fall through
+ }
+ return fallback;
+}
+
+function discoverVersions(config: SDKConfig, currentVersion: string): VersionInfo[] {
+ const baseDir = config.docsBaseDir
+ ? path.join(ROOT_DIR, config.docsBaseDir)
+ : path.join(ROOT_DIR, 'docs/content/docs/cuabot');
+ const docsDir = path.join(baseDir, config.outputDir);
+ const hrefBase = config.hrefBase ?? '/cuabot';
+ const versions: VersionInfo[] = [];
+
+ const currentMM = currentVersion.split('.').slice(0, 2).join('.');
+ versions.push({ version: currentMM, href: `${hrefBase}/${config.outputDir}`, isCurrent: true });
+
+ if (fs.existsSync(docsDir)) {
+ for (const entry of fs.readdirSync(docsDir, { withFileTypes: true })) {
+ if (entry.isDirectory() && entry.name.startsWith('v')) {
+ const v = entry.name.substring(1);
+ if (v === currentMM) continue;
+ versions.push({
+ version: v,
+ href: `${hrefBase}/${config.outputDir}/${entry.name}/api`,
+ isCurrent: false,
+ });
+ }
+ }
+ }
+
+ versions.sort((a, b) => {
+ const pa = a.version.split('.').map(Number);
+ const pb = b.version.split('.').map(Number);
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
+ if ((pa[i] || 0) !== (pb[i] || 0)) return (pb[i] || 0) - (pa[i] || 0);
+ }
+ return 0;
+ });
+
+ return versions;
+}
+
+function getPackageVersion(config: SDKConfig): string {
+ const pkgJsonPath = path.join(ROOT_DIR, path.dirname(config.packageDir), 'package.json');
+ try {
+ return JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')).version || '0.0.0';
+ } catch {
+ return '0.0.0';
+ }
+}
+
+// ============================================================================
+// MDX Generation
+// ============================================================================
+
+function escapeMDX(text: string): string {
+ if (!text) return text;
+ return text
+ .replace(/\{/g, '\\{')
+ .replace(/\}/g, '\\}')
+ .replace(/<(?!\/?(?:Callout|Tab|Tabs|VersionHeader|div|span|a|code|pre|br|hr)\b)/g, '&lt;');
+}
+
+function generateMDX(modules: ModuleDoc[], config: SDKConfig): string {
+ const lines: string[] = [];
+ const pkgVersion = getPackageVersion(config);
+ const releasedVersion = getLatestReleasedVersion(config, pkgVersion);
+ const pageTitle = config.pageTitle ?? `${config.displayName} API Reference`;
+
+ // Frontmatter
+ lines.push('---');
+ lines.push(`title: ${pageTitle}`);
+ lines.push(`description: ${config.description}`);
+ lines.push('---');
+ lines.push('');
+ lines.push(`{/*`);
+ lines.push(` AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY`);
+ lines.push(` Generated by: npx tsx scripts/docs-generators/typescript-sdk.ts`);
+ lines.push(` Source: ${config.packageDir}`);
+ lines.push(` Version: ${releasedVersion}`);
+ lines.push(`*/}`);
+ lines.push('');
+
+ // Imports
+ lines.push("import { Callout } from 'fumadocs-ui/components/callout';");
+ lines.push("import { VersionHeader } from '@/components/version-selector';");
+ lines.push('');
+
+ // Version header
+ const versions = discoverVersions(config, releasedVersion);
+ const currentMM = releasedVersion.split('.').slice(0, 2).join('.');
+ lines.push('<VersionHeader');
+ lines.push(` versions={${JSON.stringify(versions)}}`);
+ lines.push(` currentVersion="${currentMM}"`);
+ lines.push(` fullVersion="${releasedVersion}"`);
+ lines.push(` packageName="${config.packageName}"`);
+ if (config.installCommand) {
+ lines.push(` installCommand="${config.installCommand}"`);
+ }
+ lines.push('/>');
+ lines.push('');
+
+ for (const mod of modules) {
+ lines.push('---');
+ lines.push('');
+ lines.push(`## ${mod.name}`);
+ lines.push('');
+ if (mod.description) {
+ lines.push(escapeMDX(mod.description));
+ lines.push('');
+ }
+
+ // Interfaces
+ for (const iface of mod.interfaces) {
+ lines.push(`### ${iface.name}`);
+ lines.push('');
+ if (iface.description) {
+ lines.push(escapeMDX(iface.description));
+ lines.push('');
+ }
+ lines.push('```typescript');
+ lines.push(`interface ${iface.name} {`);
+ for (const prop of iface.properties) {
+ const opt = prop.isOptional ? '?' : '';
+ lines.push(` ${prop.name}${opt}: ${prop.type};`);
+ }
+ lines.push('}');
+ lines.push('```');
+ lines.push('');
+ if (iface.properties.length > 0) {
+ lines.push('| Property | Type | Description |');
+ lines.push('|----------|------|-------------|');
+ for (const prop of iface.properties) {
+ const opt = prop.isOptional ? ' *(optional)*' : '';
+ lines.push(
+ `| \`${prop.name}\` | \`${escapeMDX(prop.type)}\` | ${opt}${escapeMDX(prop.description)} |`
+ );
+ }
+ lines.push('');
+ }
+ }
+
+ // Constants
+ for (const c of mod.constants) {
+ lines.push(`### ${c.name}`);
+ lines.push('');
+ lines.push('```typescript');
+ lines.push(`const ${c.name}: ${escapeMDX(c.type)}`);
+ lines.push('```');
+ lines.push('');
+ if (c.description) {
+ lines.push(escapeMDX(c.description));
+ lines.push('');
+ }
+ }
+
+ // Classes
+ for (const cls of mod.classes) {
+ lines.push(`### ${cls.name}`);
+ lines.push('');
+ if (cls.description) {
+ lines.push(escapeMDX(cls.description));
+ lines.push('');
+ }
+
+ if (cls.constructorSig) {
+ lines.push('#### Constructor');
+ lines.push('');
+ lines.push('```typescript');
+ lines.push(
+ `new ${cls.name}(${cls.constructorParams.map((p) => formatParam(p)).join(', ')})`
+ );
+ lines.push('```');
+ lines.push('');
+ if (cls.constructorParams.length > 0) {
+ lines.push(...generateParamsTable(cls.constructorParams));
+ }
+ }
+
+ if (cls.methods.length > 0) {
+ lines.push('#### Methods');
+ lines.push('');
+ for (const method of cls.methods) {
+ lines.push(`##### ${cls.name}.${method.name}`);
+ lines.push('');
+ lines.push('```typescript');
+ lines.push(method.signature);
+ lines.push('```');
+ lines.push('');
+ if (method.description) {
+ lines.push(escapeMDX(method.description));
+ lines.push('');
+ }
+ if (method.params.length > 0) {
+ lines.push(...generateParamsTable(method.params));
+ }
+ if (
+ method.returnType &&
+ method.returnType !== 'void' &&
+ method.returnType !== 'Promise<void>'
+ ) {
+ lines.push(`**Returns:** \`${escapeMDX(method.returnType)}\``);
+ lines.push('');
+ }
+ }
+ }
+ }
+
+ // Functions
+ for (const fn of mod.functions) {
+ lines.push(`### ${fn.name}`);
+ lines.push('');
+ lines.push('```typescript');
+ lines.push(fn.signature);
+ lines.push('```');
+ lines.push('');
+ if (fn.description) {
+ lines.push(escapeMDX(fn.description));
+ lines.push('');
+ }
+ if (fn.params.length > 0) {
+ lines.push(...generateParamsTable(fn.params));
+ }
+ if (fn.returnType && fn.returnType !== 'void') {
+ lines.push(`**Returns:** \`${escapeMDX(fn.returnType)}\``);
+ lines.push('');
+ }
+ }
+ }
+
+ return lines.join('\n');
+}
+
+function generateParamsTable(params: ParamInfo[]): string[] {
+ const lines: string[] = [];
+ lines.push('**Parameters:**');
+ lines.push('');
+ lines.push('| Name | Type | Description |');
+ lines.push('|------|------|-------------|');
+ for (const p of params) {
+ const def = p.defaultValue ? ` (default: \`${p.defaultValue}\`)` : '';
+ const opt = p.isOptional ? ' *(optional)*' : '';
+ lines.push(
+ `| \`${p.name}\` | \`${escapeMDX(p.type)}\` | ${escapeMDX(p.description)}${opt}${def} |`
+ );
+ }
+ lines.push('');
+ return lines;
+}
+
+// ============================================================================
+// Run
+// ============================================================================
+
+main().catch((error) => {
+ console.error('Error:', error);
+ process.exit(1);
+});
diff --git a/scripts/typescript-typecheck.js b/scripts/typescript-typecheck.js
index 77f65a1675..1a29b73b7d 100644
--- a/scripts/typescript-typecheck.js
+++ b/scripts/typescript-typecheck.js
@@ -1,9 +1,15 @@
#!/usr/bin/env node
const { execSync } = require('child_process');
+// Allow pnpm version mismatch (root uses 9.x, workspace packages declare 10.x)
+const env = { ...process.env, COREPACK_ENABLE_STRICT: '0' };
+
try {
- execSync('pnpm -C libs/typescript install', { stdio: 'inherit' });
- execSync('pnpm -C libs/typescript -r run typecheck', { stdio: 'inherit' });
+ execSync('pnpm -C libs/typescript install', { stdio: 'inherit', env });
+ // Build core first so its type declarations (dist/) are available
+ // for dependent packages like @trycua/computer and @trycua/agent
+ execSync('pnpm -C libs/typescript/core run build', { stdio: 'inherit', env });
+ execSync('pnpm -C libs/typescript -r run typecheck', { stdio: 'inherit', env });
} catch (err) {
process.exit(1);
}
diff --git a/uv.lock b/uv.lock
index 852f8559fd..be1ae85fbc 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1039,7 +1039,7 @@ wheels = [
[[package]]
name = "cua-agent"
-version = "0.7.17"
+version = "0.7.24"
source = { editable = "libs/python/agent" }
dependencies = [
{ name = "aiohttp" },
@@ -1208,7 +1208,7 @@ requires-dist = [
[[package]]
name = "cua-computer"
-version = "0.5.10"
+version = "0.5.12"
source = { editable = "libs/python/computer" }
dependencies = [
{ name = "aiohttp" },
@@ -1252,11 +1252,13 @@ provides-extras = ["lume", "lumier", "ui", "all"]
[[package]]
name = "cua-computer-server"
-version = "0.3.5"
+version = "0.3.16"
source = { editable = "libs/python/computer-server" }
dependencies = [
{ name = "aiohttp" },
+ { name = "cua-core" },
{ name = "fastapi" },
+ { name = "fastmcp" },
{ name = "pillow" },
{ name = "playwright" },
{ name = "pydantic" },
@@ -1282,9 +1284,6 @@ macos = [
{ name = "pyobjc-framework-cocoa" },
{ name = "pyobjc-framework-quartz" },
]
-mcp = [
- { name = "fastmcp" },
-]
windows = [
{ name = "pywin32" },
]
@@ -1292,8 +1291,9 @@ windows = [
[package.metadata]
requires-dist = [
{ name = "aiohttp", specifier = ">=3.9.1" },
+ { name = "cua-core", editable = "libs/python/core" },
{ name = "fastapi", specifier = ">=0.111.0" },
- { name = "fastmcp", marker = "extra == 'mcp'", specifier = ">=2.0,<3" },
+ { name = "fastmcp", specifier = ">=2.0,<3" },
{ name = "pillow", specifier = ">=10.2.0" },
{ name = "playwright", specifier = ">=1.40.0" },
{ name = "pydantic", specifier = ">=2.0.0" },
@@ -1314,7 +1314,7 @@ requires-dist = [
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.27.0" },
{ name = "websockets", specifier = ">=12.0" },
]
-provides-extras = ["mcp", "macos", "linux", "windows"]
+provides-extras = ["macos", "linux", "windows"]
[[package]]
name = "cua-core"
@@ -1364,7 +1364,7 @@ dev = [{ name = "pytest", specifier = ">=8.3.5" }]
[[package]]
name = "cua-mcp-server"
-version = "0.1.15"
+version = "0.1.16"
source = { editable = "libs/python/mcp-server" }
dependencies = [
{ name = "cua-agent", extra = ["all"] },