Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
docs: add Cua-Bench documentation with restructured navigation
f-trycuaf6316388cccc
diff --git a/docs/content/docs/cuabench/guide/advanced/configuration.mdx b/docs/content/docs/cuabench/guide/advanced/configuration.mdxnew file mode 100644index 0000000000..6e382a4334--- /dev/null+++ b/docs/content/docs/cuabench/guide/advanced/configuration.mdx@@ -0,0 +1,145 @@+---+title: Configuration+description: Configure cua-bench with config files and environment variables+---++# Configuration++Configure cua-bench behavior with `.cua/` config files and environment variables.++## Config Files++| File | Description |+|------|-------------|+| `.cua/config.yaml` | Default execution settings |+| `.cua/secrets.yaml` | Secret references for API keys |+| `.cua/agents.yaml` | Agent definitions |++## config.yaml++Default execution settings for `cb run`:++```yaml+# Where to run: "local" or "cloud"+on: local++# Parallel execution+max_parallel: 16+timeout: 600++# Default images by platform+defaults:+ images:+ linux-docker: linux-docker+ linux-qemu: linux-qemu+ windows-qemu: windows-waa+ android-qemu: android-qemu+ macos-lume: macos-lume++ resources:+ linux-docker:+ memory: 4G+ cpus: 2+ windows-qemu:+ memory: 8G+ cpus: 4++# Default agent image+default_image: trycua/cua-bench:latest+```++## secrets.yaml++Reference API keys securely (values stored in environment variables):++```yaml+secrets:+ anthropic-api-key:+ env: ANTHROPIC_API_KEY+ openai-api-key:+ env: OPENAI_API_KEY+ custom-key:+ env: MY_CUSTOM_KEY+```++Use in code with `Secret.from_name()`:++```python+from cua_bench import Secret++ secrets=[Secret.from_name("anthropic-api-key")],+)+async def run_task(task_index: int, env) -> dict:+ import os+ api_key = os.environ["ANTHROPIC_API_KEY"]+```++## agents.yaml++Define custom agents:++```yaml+agents:+ my-agent:+ image: my-registry/my-agent:latest+ model: anthropic/claude-sonnet-4-20250514+ max_steps: 50++ cua-agent:+ image: trycua/cua-agent:latest+ model: anthropic/claude-sonnet-4-20250514+```++Use with `--agent`:++```bash+cb run --dataset cua-bench-basic --agent my-agent+```++## Environment Variables++| Variable | Description |+|----------|-------------|+| `ANTHROPIC_API_KEY` | Anthropic API key for Claude models |+| `OPENAI_API_KEY` | OpenAI API key for GPT models |+| `CUA_CLOUD_TOKEN` | CUA Cloud authentication token |+| `CUA_CONFIG_PATH` | Custom config directory (default: `.cua/`) |++## Image Registry++Images are stored in `~/.local/state/cua-bench/images.json`:++```json+{+ "version": 1,+ "images": {+ "linux-docker": {+ "platform": "linux-docker",+ "docker_image": "trycua/cua-xfce:latest",+ "status": "ready"+ },+ "windows-qemu": {+ "platform": "windows-qemu",+ "path": "~/.local/state/cua-bench/images/windows-qemu",+ "config": {+ "memory": "8G",+ "cpus": 4+ },+ "status": "ready"+ }+ }+}+```++## Authentication++For CUA Cloud access:++```bash+# Browser-based login+cb login++# Verify authentication+cb status+```diff --git a/docs/content/docs/cuabench/guide/advanced/creating-private-tasks.mdx b/docs/content/docs/cuabench/guide/advanced/creating-private-tasks.mdxnew file mode 100644index 0000000000..926797ba8b--- /dev/null+++ b/docs/content/docs/cuabench/guide/advanced/creating-private-tasks.mdx@@ -0,0 +1,162 @@+---+title: Creating Private Tasks+description: How to create a private set of tasks.+---++Cua-Bench is a broad set of tasks meant to test the general ability of an agent to perform complex tasks in a desktop environment.++However, many agents are designed for more narrow use cases. The harness can still be leveraged by making it easy for agent developers to create a custom set of tasks for their agent.++## Creating a Custom Task++### Using the Wizard++```bash+cb create-task tasks/my_custom_task+```++This starts an interactive wizard that guides you through the task creation process.++### Using AI Generation++Use Claude Code to scaffold your starter environment:++```bash+cb generate-task "discord clone with channels and messages" --output tasks/discord_clone+```++### Manual Creation++Create the task structure manually:++```+tasks/my_custom_task/+├── main.py # Task implementation+├── gui/+│ └── index.html # UI assets+└── pyproject.toml # Optional metadata+```++## Task Implementation++Here's a complete example task:++```python+"""Custom task example - Click a button."""+import cua_bench as cb+from pathlib import Path+[email protected]_config(split="train")+def load():+ """Define task variants."""+ return [+ cb.Task(+ description='Click the "Submit" button to complete the task.',+ metadata={"button_id": "submit"},+ computer={+ "provider": "computer",+ "setup_config": {+ "os_type": "linux",+ "width": 1024,+ "height": 768,+ }+ }+ )+ ]++pid = None+[email protected]_task(split="train")+async def start(task_cfg, session: cb.DesktopSession):+ """Initialize the task environment."""+ global pid+ pid = await session.launch_window(+ html=(Path(__file__).parent / "gui/index.html").read_text('utf-8'),+ title="My Custom Task",+ width=400,+ height=300,+ )+[email protected]_task(split="train")+async def evaluate(task_cfg, session: cb.DesktopSession) -> list[float]:+ """Check if the task was completed successfully."""+ global pid+ if pid is None:+ return [0.0]++ submitted = await session.execute_javascript(pid, "window.__submitted")+ return [1.0] if submitted is True else [0.0]+[email protected]_task(split="train")+async def solve(task_cfg, session: cb.DesktopSession):+ """Oracle solution - click the button."""+ global pid+ if pid is None:+ return++ await session.click_element(pid, "#submit")++if __name__ == "__main__":+ cb.interact(__file__)+```++<Callout title="Async Required" type="warn">+ All task functions (setup, evaluate, solve) must be `async` functions, and session methods must be called with `await`.+</Callout>++## Running Custom Tasks++### Test Locally++```bash+# Interactive mode - opens browser to view task+cb interact tasks/my_custom_task++# Run specific task variant+cb interact tasks/my_custom_task --task-id 0++# Run oracle solution+cb interact tasks/my_custom_task --oracle++# Save screenshot+cb interact tasks/my_custom_task --oracle --screenshot output.png+```++### Evaluate with Agent++```bash+# Run with agent+cb run tasks/my_custom_task --agent cua-agent --model anthropic/claude-sonnet-4-20250514++# Validate oracle solutions+cb run tasks/my_custom_task --oracle+```++## Running a Custom Dataset++To run multiple tasks as a dataset:++```bash+# Run all tasks in a directory+cb run --dataset-path tasks --agent cua-agent --model anthropic/claude-sonnet-4-20250514++# Run specific tasks+cb run --dataset-path tasks/my_custom_task,tasks/another_task --agent cua-agent+```++## Task Development Workflow++1. **Create task structure** with `cb create-task` or `cb generate-task`+2. **Implement task logic** in `main.py` with async functions+3. **Test interactively** with `cb interact tasks/my_task`+4. **Validate oracle** with `cb interact tasks/my_task --oracle`+5. **Run evaluation** with `cb run tasks/my_task --oracle` to verify evaluation returns `[1.0]`+6. **Test with agent** with `cb run tasks/my_task --agent cua-agent`++## Tips++- Use `global pid` to share window references between setup, evaluate, and solve functions+- Always check `if pid is None` in evaluate and solve functions+- Use `await session.execute_javascript(pid, "expression")` to read app state+- Use `await session.click_element(pid, "selector")` for reliable element clicks+- Test with `--oracle` first to ensure your evaluation logic is correct\ No newline at end of filediff --git a/docs/content/docs/cuabench/guide/advanced/custom-agents.mdx b/docs/content/docs/cuabench/guide/advanced/custom-agents.mdxnew file mode 100644index 0000000000..be565c4a9f--- /dev/null+++ b/docs/content/docs/cuabench/guide/advanced/custom-agents.mdx@@ -0,0 +1,244 @@+---+title: Custom Agents+description: Define and run custom agents with Docker images or Python import paths+---++# Custom Agents++Cua-Bench supports custom agents through the `.cua/agents.yaml` configuration file. Agents can be defined as Docker images (cloud-ready) or Python import paths (local development).++## Architecture++Cua-Bench uses a **2-container architecture** where the agent and environment run in separate Docker containers communicating via Docker network:++```+┌─────────────────────────────────────────────────────────────┐+│ Docker Network: cua-task-{id} │+│ │+│ ┌─────────────────────┐ ┌─────────────────────────────┐│+│ │ cua-agent-{id} │ │ cua-env-{id} ││+│ │ │ │ ││+│ │ Your agent image │───►│ trycua/cua-qemu-windows ││+│ │ (or default) │HTTP│ (or linux-docker, etc.) ││+│ │ │ │ ││+│ │ Runs your agent │ │ cua-computer-server:5000 ││+│ └─────────────────────┘ └─────────────────────────────┘│+└─────────────────────────────────────────────────────────────┘+```++This architecture mirrors cloud deployments (Cloud Run Jobs + Azure Batch) for consistent behavior between local and production.++## Agent Configuration++Create a `.cua/agents.yaml` file in your project:++```yaml+# .cua/agents.yaml+agents:+ # Built-in agents (use default cua-agent image)+ - name: cua-agent+ builtin: true+ defaults:+ model: anthropic/claude-sonnet-4-20250514+ max_steps: 50++ - name: gemini+ builtin: true+ defaults:+ model: gemini-2.0-flash+ max_steps: 50++ # Custom Docker image agent (cloud-ready)+ - name: my-agent+ image: myregistry/my-agent:latest+ command: ["python", "-m", "my_agent.main"]+ defaults:+ model: gpt-4o+ max_steps: 100++ # Import path agent (local development)+ - name: dev-agent+ import_path: my_agents.custom:CustomAgent+ defaults:+ model: claude-sonnet-4-20250514+```++## Agent Types++### 1. Docker Image Agents (Cloud-Ready)++Best for production and CI/CD. Your agent is fully self-contained in a Docker image.++```yaml+- name: my-agent+ image: myregistry/my-agent:latest+ command: ["python", "-m", "my_agent.main"] # Optional+ defaults:+ model: gpt-4o+```++Your Docker image can include **any dependencies** - the only requirement is that it can:+1. Read environment variables (to know where to connect)+2. Make HTTP requests (to communicate with the environment)++### 2. Import Path Agents (Local Development)++Best for rapid iteration during development. No Docker build needed.++```yaml+- name: dev-agent+ import_path: my_agents.custom:CustomAgent+```++The import path format is `module.path:ClassName`. Your agent class runs inside the default `trycua/cua-agent` container with your code mounted.++### 3. Built-in Agents++Use the pre-configured agents without any setup:++```yaml+- name: cua-agent+ builtin: true+ defaults:+ model: anthropic/claude-sonnet-4-20250514+```++## Environment Variables++Custom Docker image agents receive these environment variables:++| Variable | Description | Example |+|----------|-------------|---------|+| `CUA_ENV_API_URL` | API endpoint for environment | `http://cua-env:5000` |+| `CUA_ENV_VNC_URL` | VNC endpoint for debugging | `http://cua-env:8006` |+| `CUA_ENV_TYPE` | OS type | `linux`, `windows`, `android` |+| `CUA_TASK_PATH` | Mounted task config path | `/app/env` |+| `CUA_TASK_INDEX` | Task index to run | `0` |+| `CUA_MODEL` | Model to use (if specified) | `gpt-4o` |+| `ANTHROPIC_API_KEY` | Passed through from host | `sk-...` |+| `OPENAI_API_KEY` | Passed through from host | `sk-...` |+| `GOOGLE_API_KEY` | Passed through from host | `...` |++## Building a Docker Image Agent++### Dockerfile++```dockerfile+FROM python:3.12-slim+WORKDIR /app++# Install any dependencies you need+RUN pip install httpx pillow anthropic openai++# Copy your agent code+COPY my_agent/ /app/my_agent/++# Entry point+CMD ["python", "-m", "my_agent.main"]+```++### Agent Implementation++```python+# my_agent/main.py+import os+import base64+import httpx+from PIL import Image+from io import BytesIO++# Read environment variables+API_URL = os.environ["CUA_ENV_API_URL"]+TASK_INDEX = int(os.environ["CUA_TASK_INDEX"])++def screenshot():+ """Get screenshot from environment."""+ r = httpx.post(f"{API_URL}/screenshot")+ b64 = r.json()["screenshot"]+ return Image.open(BytesIO(base64.b64decode(b64)))++def click(x, y):+ """Click at coordinates."""+ httpx.post(f"{API_URL}/execute", json={+ "action": "click",+ "coordinate": [x, y]+ })++def type_text(text):+ """Type text."""+ httpx.post(f"{API_URL}/execute", json={+ "action": "type",+ "text": text+ })++def main():+ import anthropic++ client = anthropic.Anthropic()++ for step in range(50):+ img = screenshot()++ # Your agent logic here...+ # Call LLM, parse response, execute action++ response = client.messages.create(+ model="claude-sonnet-4-20250514",+ messages=[...],+ )++ action = parse_response(response)+ if action["type"] == "click":+ click(action["x"], action["y"])+ elif action["type"] == "type":+ type_text(action["text"])+ elif action["type"] == "done":+ break++if __name__ == "__main__":+ main()+```++### Build and Register++```bash+# Build image+docker build -t myregistry/my-agent:latest .++# Push to registry (for cloud deployment)+docker push myregistry/my-agent:latest+```++## Running Custom Agents++```bash+# Run with your custom agent+cb run tasks/my_task --task-index 0 --eval --agent my-agent++# Run with VNC debugging+cb run tasks/my_task --task-index 0 --eval --agent my-agent --vnc-port 8006++# Override model+cb run tasks/my_task --eval --agent my-agent --model gpt-4-turbo+```++## What You Can Include++Since you control the Docker image, you can include any dependencies:++| Use Case | Dependencies |+|----------|-------------|+| Vision model agent | `torch`, `transformers`, CUDA runtime |+| Browser automation | `playwright`, `selenium`, Chrome |+| OCR-based agent | `tesseract`, `pytesseract`, `opencv` |+| Multi-modal LLM | `openai`, `anthropic`, `google-generativeai` |+| Local LLM | `llama-cpp-python`, GGUF models |+| Reinforcement learning | `stable-baselines3`, `gymnasium` |++## Best Practices++1. **Start with import paths** for rapid development, then containerize for production+2. **Handle connection retries** - the environment may take a few seconds to start+3. **Log to stdout** - container logs are captured automatically+4. **Exit with code 0** on success, non-zero on failure+5. **Read task config** from `/app/env/main.py` if neededdiff --git a/docs/content/docs/cuabench/guide/advanced/meta.json b/docs/content/docs/cuabench/guide/advanced/meta.jsonnew file mode 100644index 0000000000..c6a0a374dc--- /dev/null+++ b/docs/content/docs/cuabench/guide/advanced/meta.json@@ -0,0 +1,10 @@+{+ "title": "Advanced",+ "description": "Build your own tasks and agents",+ "icon": "Layers",+ "pages": [+ "creating-private-tasks",+ "custom-agents",+ "configuration"+ ]+}diff --git a/docs/content/docs/cuabench/guide/fundamentals/meta.json b/docs/content/docs/cuabench/guide/fundamentals/meta.jsonnew file mode 100644index 0000000000..68836caffa--- /dev/null+++ b/docs/content/docs/cuabench/guide/fundamentals/meta.json@@ -0,0 +1,11 @@+{+ "title": "Fundamentals",+ "description": "Core concepts of tasks and environments",+ "icon": "Lightbulb",+ "pages": [+ "tasks",+ "simulated-tasks",+ "native-tasks",+ "registry"+ ]+}diff --git a/docs/content/docs/cuabench/guide/fundamentals/native-tasks.mdx b/docs/content/docs/cuabench/guide/fundamentals/native-tasks.mdxnew file mode 100644index 0000000000..5c7375ea47--- /dev/null+++ b/docs/content/docs/cuabench/guide/fundamentals/native-tasks.mdx@@ -0,0 +1,100 @@+---+title: Native Tasks+description: Real-world benchmarks with production applications+---++# Native Tasks++Native tasks run against real desktop and mobile applications in full VM environments. They use Docker containers with QEMU/KVM virtualization to provide isolated, reproducible environments.++## What are Native Tasks?++- **Real Applications**: Actual Windows, Linux, macOS, Android software+- **Production Benchmarks**: Industry-standard evaluation datasets+- **Full VM Environments**: QEMU/KVM virtualization+- **Reproducible**: Base images ensure consistent starting state++## How They Work++Native tasks run inside Docker containers with VNC for remote access:++```+┌───────────────────────────────────────────────────────────┐+│ Docker Container │+│ ┌─────────────────────────────────────────────────────┐ │+│ │ Real XFCE/Windows Desktop (via VNC) │ │+│ │ ┌─────────────────────────────────────────────────┐│ │+│ │ │ Actual applications: Firefox, LibreOffice, ││ │+│ │ │ Terminal, File Manager, etc. ││ │+│ │ └─────────────────────────────────────────────────┘│ │+│ └─────────────────────────────────────────────────────┘ │+│ Startup: 60-180 seconds | Requires Docker + KVM │+└───────────────────────────────────────────────────────────┘+```++## Available Benchmarks++| Benchmark | Platform | Tasks | Description |+|-----------|----------|-------|-------------|+| Windows Arena | `windows-qemu` | 173 | Windows 11 across 12 app domains |+| OSWorld | `linux-qemu` | 369 | Linux desktop automation |+| WebArena | `linux-docker` | 812 | Web browsing tasks |+| AndroidWorld | `android-qemu` | 200+ | Android mobile automation |+| macOSWorld | `macos-lume` | 100+ | macOS desktop automation |++## Platform Requirements++| Platform | Requirements |+|----------|--------------|+| `linux-docker` | Docker |+| `linux-qemu` | Docker + KVM |+| `windows-qemu` | Docker + KVM, x86_64 Linux |+| `android-qemu` | Docker + KVM |+| `macos-lume` | Apple Silicon Mac |++## Running Native Tasks++```bash+# Create required base image first+cb image create windows-qemu --download-iso++# Check task provider type+cb task info ./tasks/winarena++# Interactive mode (opens VNC in browser)+cb interact ./tasks/winarena --variant-id 0 --oracle++# Run with agent+cb run --dataset winarena --agent cua-agent --image windows-qemu+```++## When to Use++- Final agent evaluation+- Benchmarking against published results+- Testing real-world robustness+- Production-grade testing++## Creating Native Tasks++Native tasks use the `native` provider and require a base image:++```python+ environment="windows-qemu",+ timeout=600,+)+async def my_task(session):+ # Setup+ import subprocess+ subprocess.run(["powershell", "-Command", "Start-Process notepad"])++ yield {+ "description": "Type 'Hello' in Notepad",+ }++ # Evaluation+ return {"success": True, "reward": 1.0}+```++See [Creating Private Tasks](/docs/cuabench/guide/advanced/creating-private-tasks) for details.diff --git a/docs/content/docs/cuabench/guide/fundamentals/registry.mdx b/docs/content/docs/cuabench/guide/fundamentals/registry.mdxnew file mode 100644index 0000000000..768ee7ba99--- /dev/null+++ b/docs/content/docs/cuabench/guide/fundamentals/registry.mdx@@ -0,0 +1,94 @@+---+title: Registry+description: The Cua-Bench registry of tasks and datasets.+---++The [Cua-Bench registry](https://cuabench.ai/cuabench/registry) contains a collection of pre-built tasks and datasets for evaluating computer-use agents.++The goal of the registry is to be a community-based effort to increase the variety and quantity of useful, verifiable computer-use tasks.++## Using the Registry++### List Available Datasets++```bash+cb datasets+```++### Run a Dataset from the Registry++```bash+# Run with agent+cb run --dataset cua-bench-basic --agent cua-agent --model anthropic/claude-sonnet-4-20250514++# Run interactively+cb interact click-button --dataset cua-bench-basic++# Run oracle solutions+cb run --dataset cua-bench-basic --oracle+```++### Clone Registry Locally++The registry is automatically cloned when you first use the `--dataset` flag:++```bash+# Registry location+~/.cua/cbregistry/++# Update registry+cd ~/.cua/cbregistry && git pull+```++## Available Datasets++| Dataset | Tasks | Description | Golden Environment |+|---------|-------|-------------|-------------------|+| `cua-bench-basic` | 13 | Basic UI interaction tasks (clicking, typing, dragging) | `linux-docker` |+| `winarena` | 173 | Windows 11 desktop automation | `windows-qemu` |+| `osworld` | 369 | Linux desktop automation | `linux-qemu` |+| `webarena` | 812 | Web browsing tasks | `linux-docker` |++## Dataset Structure++Each dataset in the registry follows this structure:++```+registry/+└── datasets/+ └── cua-bench-basic/+ ├── meta.json # Dataset metadata+ └── tasks/+ ├── click-button/+ │ ├── main.py # Task implementation+ │ └── gui/+ │ └── index.html+ └── ...+```++### meta.json Format++```json+{+ "name": "cua-bench-basic",+ "version": "1.0.0",+ "description": "Basic UI interaction tasks",+ "platform": "linux-docker",+ "tasks": [+ "click-button",+ "typing-input",+ "drag-slider"+ ]+}+```++## Contributing Tasks++To contribute tasks to the registry:++1. Fork the [cua-bench-registry](https://github.com/trycua/cua-bench-registry) repository+2. Create your task following the [task structure](/docs/cuabench/guide/fundamentals/tasks)+3. Test locally with `cb interact tasks/your_task`+4. Submit a pull request++See [Creating Private Tasks](/docs/cuabench/guide/advanced/creating-private-tasks) for task development guidance.\ No newline at end of filediff --git a/docs/content/docs/cuabench/guide/fundamentals/simulated-tasks.mdx b/docs/content/docs/cuabench/guide/fundamentals/simulated-tasks.mdxnew file mode 100644index 0000000000..abcd36337f--- /dev/null+++ b/docs/content/docs/cuabench/guide/fundamentals/simulated-tasks.mdx@@ -0,0 +1,71 @@+---+title: Simulated Tasks+description: Lightweight synthetic tasks for testing and development+---++# Simulated Tasks++Simulated tasks use synthetic HTML webapps to test agent capabilities in controlled environments. They run via Playwright in a headless browser, making them fast and lightweight.++## What are Simulated Tasks?++- **Lightweight**: Run in `linux-docker` containers, no KVM required+- **Fast**: Quick to set up and iterate (~2 seconds startup)+- **Deterministic**: Consistent behavior for reproducible testing+- **No Docker Required**: Uses Playwright directly++## How They Work++Simulated tasks render HTML/CSS desktops in a Chromium browser:++```+┌───────────────────────────────────────────────────────────┐+│ Simulated macOS/Windows Desktop (HTML/CSS) │+│ ┌─────────────────────────────────────────────────────┐ │+│ │ App Window (iframe) │ │+│ │ HTML content, JS enabled │ │+│ └─────────────────────────────────────────────────────┘ │+│ 🍎 Finder Chrome Slack ... │+└───────────────────────────────────────────────────────────┘+```++## Available Datasets++| Dataset | Tasks | Description |+|---------|-------|-------------|+| `cua-bench-basic` | 13 | Core UI interactions (click, type, drag, etc.) |+| `cua-bench-forms` | - | Form filling and validation |+| `cua-bench-navigation` | - | Multi-page navigation |++## Running Simulated Tasks++```bash+# Check task provider type+cb task info ./tasks/my_task++# Interactive mode (opens Chromium window)+cb interact ./tasks/slack_env --oracle++# Run with agent+cb run --dataset cua-bench-basic --agent cua-agent+```++## When to Use++- Agent development and debugging+- CI/CD pipeline testing+- Quick iteration on agent logic+- Testing UI interaction patterns++## Creating Simulated Tasks++Simulated tasks use the `simulated` provider and include HTML/CSS for the desktop simulation:++```+my_task/+├── main.py # Task definition+└── gui/+ └── index.html # HTML webapp+```++See [Creating Private Tasks](/docs/cuabench/guide/advanced/creating-private-tasks) for details.diff --git a/docs/content/docs/cuabench/guide/fundamentals/tasks.mdx b/docs/content/docs/cuabench/guide/fundamentals/tasks.mdxnew file mode 100644index 0000000000..a80d154a50--- /dev/null+++ b/docs/content/docs/cuabench/guide/fundamentals/tasks.mdx@@ -0,0 +1,224 @@+---+title: Tasks+description: An in-depth guide describing the structure of a Cua-Bench task.+---++<div className="not-prose relative rounded-xl overflow-hidden my-8 w-full">+ <img src="/docs/img/cua_bench_overview.png" alt="Cua" className="w-full h-auto rounded-xl border" />+</div>++A Cua-Bench task is a Python module that defines a verifiable computer-use environment. Tasks use decorators to define configuration, setup, evaluation, and oracle solutions.++## Task Structure++Every task consists of a `main.py` file with four key components:++### 1. Task Configuration (`@cb.tasks_config`)++Defines the list of task variants to generate:++```python+import cua_bench as cb+[email protected]_config(split="train")+def load():+ return [+ cb.Task(+ description='Click the "Submit" button on the page.',+ metadata={+ "button_text": "Submit",+ },+ # Configure the computer platform+ computer={+ "provider": provider,+ "setup_config": {+ "os_type": os_type,+ "width": 1024,+ "height": 768+ }+ }+ )+ for provider, os_type in [("computer", "linux"), ("computer", "macos"), ("computer", "windows"), ("webtop", "linux"), ("webtop", "macos"), ("webtop", "win11"), ("webtop", "win10")]+ # More task variants...+ ]+```++Each task variant can have different metadata, enabling thousands of unique scenarios from a single template.++The `computer` provider **emulates** `windows`, `macos`, `linux`, and `android` operating systems, while the `webtop` provider **simulates** `macos`, `win10`, `win11`, `win7`, `win98`, `winxp`, `ios`, and `android`.++### 2. Setup (`@cb.setup_task`)++Initializes the environment for a specific task, installing any necessary apps or web UI onto the desktop:++```python+# Each (setup_task, evaluate_task, and solve_task) function runs in 1 thread/context per task_cfg+# All task functions must be async+pid = None+[email protected]_task(split="train")+async def start(task_cfg: cb.Task, session: cb.DesktopSession | cb.MobileSession):+ global pid+ # Launch a window with HTML content+ pid = await session.launch_window(+ html=Path("gui/index.html").read_text(),+ title="My App",+ width=800,+ height=600+ )+```++<Callout title="Async Required" type="warn">+ All task functions (setup, evaluate, solve) must be `async` functions, and session methods must be called with `await`.+</Callout>++### 3. Evaluation (`@cb.evaluate_task`)++Checks if the task was completed successfully by observing the internal state of the apps:++```python[email protected]_task(split="train")+async def evaluate(task_cfg: cb.Task, session: cb.DesktopSession | cb.MobileSession) -> list[float]:+ global pid+ if pid is None:+ return [0.0]++ # Check task completion+ submitted = await session.execute_javascript(pid, "window.__submitted")++ # Return reward: 1.0 for success, 0.0 for failure+ return [1.0] if submitted is True else [0.0]+```++### 4. Oracle Solution (`@cb.solve_task`)++Provides a reference solution for trajectory generation:++```python[email protected]_task(split="train")+async def solve(task_cfg: cb.Task, session: cb.DesktopSession | cb.MobileSession):+ global pid+ if pid is None:+ return++ # Execute the solution+ await session.click_element(pid, ".submit-button")+```++## Environment API++### Window Management++Cua-Bench provides a Python API for launching webviews and installing web apps, which makes it simple to add custom GUI applications to your tasks.++```python+# Launch a webview window (async)+pid = await session.launch_window(+ html="<html>...</html>",+ title="Window Title",+ width=800,+ height=600+)++# Execute JavaScript (async)+result = await session.execute_javascript(pid, "document.title")++# Install a webapp shortcut+await session.install_app("Slack Clone", html="<html>...</html>")+```++### Playwright-style Actions++Cua-Bench also provides a Playwright-like API, making it easy to script oracle solutions:++```python+# Click an element by CSS selector (async)+await session.click_element(pid, ".button")+await session.click_element(pid, "#submit-btn")++# Type text+await session.type_text("Hello world")++# Press keys+await session.key("Enter")+await session.key("Control+c")+```++### Low-level Actions++All actions from the agent or the oracle solution are performed via low-level keyboard and mouse actions. You can use `execute_action` to execute these actions directly:++```python+# Perform low-level actions (async)+await session.execute_action(cb.ClickAction(x=64, y=128))+await session.execute_action(cb.MoveToAction(x=16, y=100, duration=0.5))+await session.execute_action(cb.KeyAction(key="Enter"))++# Take screenshot+screenshot = await session.screenshot()+```++### Shell Actions++If your task setup requires installing binaries or packages, then you can use `session.run_command` to execute shell commands in the computer environment.++```python+# Install firefox (async)+await session.run_command("sudo apt update && sudo apt install firefox")+```++<Callout title="Compatibility Warning" type="warn">+ This feature is only supported by `VMDesktopSession` and not `WebDesktopSession`. Avoid using this API for writing tasks unless you cannot create your task with the other provided environment APIs.+</Callout>++## Structuring your task folders++All tasks must have a top-level `main.py` file. We recommend also including a `gui/` directory for any HTML/CSS/JS files:++```+tasks/my_task/+├── main.py+└── gui/+ ├── index.html+ ├── style.css+ └── script.js+```++To reference these files in your setup function:++```python+folder_path = Path(__file__).parent / "gui"+pid = env.launch_window(folder=str(folder_path), title="My GUI", ...)+```++If you use a web framework such as React or Svelte, you can serve the `dist/` folder, or you can start a development server and launch a window pointing to it:++```python[email protected]_task(split="train")+def start(task_cfg: cb.Task, env: cb.DesktopSession | cb.MobileSession):+ folder_path = Path(__file__).parent / "gui"++ # Start framework app in the background+ _server_process = subprocess.Popen(["npm", "run", "dev"], cwd=folder_path)++ # Launch window pointing to the local server+ pid = env.launch_window(+ url="http://localhost:3000",+ title="My React GUI",+ width=800,+ height=600+ )+```++## Running Tasks++```bash+# Run interactively+cb interact tasks/my_task --task-id 0++# Run evaluations+cb run tasks/my_task --model anthropic/claude-opus-4-5 --agent cua-agent++# Generate oracle trajectories+cb run tasks/my_task --oracle+```diff --git a/docs/content/docs/cuabench/guide/getting-started/first-steps.mdx b/docs/content/docs/cuabench/guide/getting-started/first-steps.mdxnew file mode 100644index 0000000000..10481a73b8--- /dev/null+++ b/docs/content/docs/cuabench/guide/getting-started/first-steps.mdx@@ -0,0 +1,178 @@+---+title: First Steps+description: Running the benchmark and testing your own agent.+---++## Prerequisites++Before running benchmarks, ensure you have:++1. [Installed the CLI](/docs/cuabench/guide/getting-started/installation)+2. Created at least one [base image](/docs/cuabench/guide/getting-started/images):++```bash+# Quick setup (Linux container, no KVM required)+cb image create linux-docker++# Check available images+cb image list+```++## Run a Basic Benchmark++The Cua-Bench CLI can run many different computer-use benchmarks and versions of benchmarks.++To see the available datasets, run `cb datasets` or visit the [registry](http://cuabench.ai/cuabench/registry/).++### Step 1: Explore Interactively++Start by exploring a single task interactively to see how it works in a browser window:++```bash+cb interact click-icon --dataset cua-bench-basic+```++### Step 2: Validate Oracle Solutions++Next, verify your environment setup by running the oracle solutions:++```bash+cb run --dataset cua-bench-basic --oracle+```++### Step 3: Run with an Agent++Finally, perform a benchmark using the Cua Agent SDK:++```bash+export ANTHROPIC_API_KEY=sk-....+cb run \+ --dataset cua-bench-basic \+ --agent cua-agent \+ --model anthropic/claude-haiku-4-5 \+ --max-parallel 8 \+ --max-steps 10 \+ --max-variants 1+```++You should see output similar to:++```++ ⠀⣀⣀⡀⠀⠀⠀⠀⢀⣀⣀⣀⡀⠘⠋⢉⠙⣷⠀⠀ ⠀+ ⠀⠀⢀⣴⣿⡿⠋⣉⠁⣠⣾⣿⣿⣿⣿⡿⠿⣦⡈⠀⣿⡇⠃⠀+ ⠀⠀⠀⣽⣿⣧⠀⠃⢰⣿⣿⡏⠙⣿⠿⢧⣀⣼⣷⠀⡿⠃⠀⠀+ ⠀⠀⠀⠉⣿⣿⣦⠀⢿⣿⣿⣷⣾⡏⠀⠀⢹⣿⣿⠀⠀⠀⠀⠀⠀+ ⠀⠀⠀⠀⠀⠉⠛⠁⠈⠿⣿⣿⣿⣷⣄⣠⡼⠟⠁⠀cua-bench==v0.1.0+ toolkit for computer-use RL environments and benchmarks++████████████████████ 13/13+Model: anthropic/claude-haiku-4-5+Agent: cua-agent+Run ID: run-2768db7f++++SESSION ID ENVIRONMENT VARIANT STATUS REWARD+---------------------------------------- --------------- ------- --------------- ----------+task-baecb22e typing-input 0 ✗ failed 0.0+task-05a6e068 video-player 0 ✓ completed 1.0+task-a8faeb43 spreadsheet-cell 0 ✗ failed 0.0+task-5a5f30c5 toggle-switch 0 ✓ completed 1.0+task-3555ee20 select-dropdown 0 ✗ failed 0.0+task-e9560151 click-button 0 ✓ completed 1.0+task-7ec326f2 fill-form 0 ✗ failed 0.0+task-57dae23d date-picker 0 ✗ failed 0.0+task-01276975 drag-slider 0 ✗ failed 0.0+task-4b875cd2 color-picker 0 ✓ completed 1.0+task-c933d5b0 drag-drop 0 ✗ failed 0.0+task-ec44d643 right-click-menu 0 ✗ failed 0.0+task-7c4acb4c click-icon 0 ✓ completed 1.0++++✓ All sessions completed!+Average Reward: 0.385++REWARD COUNT+-------------+1.0 5+0.0 8+```++You can see an overview table of your past runs with `cb runs`++## Run Windows Arena++Windows Arena is a benchmark with 173 tasks across 12 Windows application domains.++<Callout title="Requirements" type="info">+ Windows Arena requires x86_64 Linux with KVM support (nested virtualization). Setup takes ~1-2 hours.+</Callout>++### Step 1: Create Windows Base Image++```bash+# Download Windows ISO and create base image (~1-2 hours)+cb image create windows-qemu --download-iso++# Monitor progress (VNC at http://localhost:8006)+docker logs -f cua-setup-windows+```++### Step 2: Start Sandbox++```bash+# Start Windows sandbox+cb sandbox start windows-qemu++# Verify it's running+cb sandbox list++# Connect via VNC+cb sandbox vnc windows-qemu+```++### Step 3: Run Tasks++```bash+# List available tasks+cb run tasks/winarena_adapter --list++# Run specific task with oracle+cb interact tasks/winarena_adapter --variant-id 0 --oracle++# Run with agent+cb run tasks/winarena_adapter \+ --agent cua-agent \+ --model anthropic/claude-sonnet-4-20250514 \+ --image windows-qemu++# Stop when done+cb sandbox stop windows-qemu+```++## View Past Runs++```bash+# List all runs with statistics+cb runs++# View traces from a specific run+cb view-traces outputs/<run-id>+```++## Export Training Data++Export agent trajectories to training datasets:++```bash+# Export with aguvis-stage-1 format+cb process outputs/<run-id> --save-dir datasets/++# Export with gui-r1 format+cb process outputs/<run-id> --mode gui-r1 --save-dir datasets/++# Push to Hugging Face+cb process outputs/<run-id> --push-to-hub --repo-id username/my-dataset+```\ No newline at end of filediff --git a/docs/content/docs/cuabench/guide/getting-started/images.mdx b/docs/content/docs/cuabench/guide/getting-started/images.mdxnew file mode 100644index 0000000000..eb91613907--- /dev/null+++ b/docs/content/docs/cuabench/guide/getting-started/images.mdx@@ -0,0 +1,206 @@+---+title: Base Images+description: Setting up reproducible VM environments for benchmarks+---++Base images are reproducible environments for running benchmarks. Each image type provides a consistent, isolated desktop or mobile environment that can be started, stopped, and reset to a known state.++## Image Types++| Type | Command | Description | Requirements |+|------|---------|-------------|--------------|+| `linux-docker` | `cb image create linux-docker` | Linux GUI container (XFCE) | Docker |+| `linux-qemu` | `cb image create linux-qemu` | Linux VM with QEMU/KVM | Docker + KVM |+| `windows-qemu` | `cb image create windows-qemu --download-iso` | Windows 11 VM | Docker + KVM |+| `android-qemu` | `cb image create android-qemu` | Android VM | Docker + KVM |+| `macos-lume` | `cb image create macos-lume` | macOS VM via Lume | Apple Silicon |++## Quick Setup++### linux-docker (Fastest)++Container-based Linux GUI. No KVM required, works anywhere Docker runs.++```bash+# Create image (~1 minute)+cb image create linux-docker++# Start sandbox+cb sandbox start linux-docker++# Connect via browser+cb sandbox vnc linux-docker++# Stop when done+cb sandbox stop linux-docker+```++### windows-qemu (Windows Arena)++Full Windows 11 VM with QEMU/KVM. Required for Windows Arena benchmarks.++```bash+# Create image (~1-2 hours, downloads Windows 11 ISO)+cb image create windows-qemu --download-iso++# With specific apps pre-installed+cb image create windows-qemu --download-iso --apps chrome,libreoffice,vlc++# With custom resources+cb image create windows-qemu --download-iso --memory 16G --cpus 8 --disk 128G++# Run in background (detached)+cb image create windows-qemu --download-iso --detach+```++<Callout title="Requirements" type="info">+ Windows QEMU requires an x86_64 Linux host with KVM support. For cloud VMs, ensure nested virtualization is enabled.+</Callout>++### macos-lume (Apple Silicon only)++macOS VM using Apple's Virtualization framework via Lume.++```bash+# Install Lume first+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"++# Create macOS image+cb image create macos-lume --version sonoma+```++## Managing Sandboxes++### Start and Stop++```bash+# Start sandbox from image+cb sandbox start linux-docker+cb sandbox start windows-qemu --vnc-port 8080 --api-port 9000++# List running sandboxes+cb sandbox list++# Stop sandbox+cb sandbox stop linux-docker+```++### Connect to Sandbox++```bash+# Open VNC in browser+cb sandbox vnc linux-docker++# Or access directly via ports+# linux-docker: http://localhost:6901 (VNC), http://localhost:8000 (API)+# windows-qemu: http://localhost:8006 (VNC), http://localhost:5000 (API)+```++## Image Management++Images are stored in `~/.local/share/cua-bench/images/`. Use the `cb image` commands to manage them:++```bash+# List all images+cb image list+cb image list --format json++# Show detailed info+cb image info windows-qemu++# Clone for customization+cb image clone windows-qemu windows-custom++# Delete an image+cb image delete windows-custom+```++## Port Mappings++Different image types use different internal ports:++| Image Type | VNC Port (internal) | API Port (internal) |+|------------|---------------------|---------------------|+| `linux-docker` | 6901 | 8000 |+| `windows-qemu` | 8006 | 5000 |+| `linux-qemu` | 8006 | 5000 |+| `android-qemu` | 8006 | 5000 |++When starting sandboxes, you can map these to custom external ports:++```bash+cb sandbox start linux-docker --vnc-port 8080 --api-port 9000+```++## Storage Structure++Cua-Bench follows the XDG Base Directory specification:++```+~/.local/share/cua-bench/ # Data directory+├── images/ # Base images+│ ├── linux-docker/+│ ├── windows-qemu/+│ │ ├── windows.boot # Marker file (setup complete)+│ │ └── data/ # VM disk files+│ └── ...+└── windows.iso # Downloaded Windows ISO++~/.local/state/cua-bench/ # State directory+├── images.json # Image registry+└── sandboxes.json # Running sandbox registry+```++## Architecture++```+┌─────────────────────────────────────────────────────────────────────────┐+│ cua-bench │+├─────────────────────────────────┬───────────────────────────────────────┤+│ LOCAL │ CLOUD │+│ (Development & Authoring) │ (Execution & Scale) │+├─────────────────────────────────┼───────────────────────────────────────┤+│ │ │+│ cb image create windows-qemu │ cb run --on cloud │+│ cb sandbox start │ Parallel execution │+│ cb interact │ Agent orchestration │+│ cb image clone │ Result aggregation │+│ │ │+│ ↓ │ ↑ │+│ Create base images │ Run evals at scale │+│ Develop benchmark tasks │ 100s of parallel VMs │+│ Debug & iterate │ Automatic infrastructure │+│ │ │+└─────────────────────────────────┴───────────────────────────────────────┘+```++**Local** is the authoring environment for images and tasks. **Cloud** handles scale.++## Troubleshooting++### KVM not available++```bash+# Check if KVM is available+ls -la /dev/kvm++# If not available on cloud VM, enable nested virtualization+# or use linux-docker which doesn't require KVM+```++### Docker not running++```bash+# Start Docker+sudo systemctl start docker++# Or on macOS+open -a Docker+```++### Port already in use++```bash+# Use custom ports+cb sandbox start linux-docker --vnc-port 9000 --api-port 9001+```diff --git a/docs/content/docs/cuabench/guide/getting-started/installation.mdx b/docs/content/docs/cuabench/guide/getting-started/installation.mdxnew file mode 100644index 0000000000..3607c65b96--- /dev/null+++ b/docs/content/docs/cuabench/guide/getting-started/installation.mdx@@ -0,0 +1,87 @@+---+title: Installation+description: Getting started with Cua-Bench+---++Cua-Bench provides a CLI for running the benchmark, creating tasks, and generating training data.++## Install Dependencies++Cua-Bench requires `git` and `Docker` to be installed on your system.++## Install the CLI++Install Cua-Bench using `uv`:++```bash+# Post-OSS this step will just be:+# uv tool install cua-bench++# Clone the repo+git clone https://github.com/trycua/cua-bench.git+cd cua-bench++# Install cua-bench CLI+uv tool install -e .++# Install playwright+uv run python -m playwright install chromium++# Build cua-bench Docker image+docker build -t cua-bench:latest .+```++After installation, you can run the CLI using `cua-bench` or `cb` for convenience.++## Create Base Image++Base images are reproducible environments for running benchmarks. Create at least one:++```bash+# Quick setup (Linux container, no KVM required)+cb image create linux-docker++# Or for Windows Arena benchmarks (~1-2 hours)+cb image create windows-qemu --download-iso+```++See [Base Images](/docs/cuabench/guide/getting-started/images) for more options.++## Verify Installation++Run the help command to verify the installation:++```bash+cb --help+```++You should see output similar to:++```+ ⠀⣀⣀⡀⠀⠀⠀⠀⢀⣀⣀⣀⡀⠘⠋⢉⠙⣷⠀⠀ ⠀+ ⠀⠀⢀⣴⣿⡿⠋⣉⠁⣠⣾⣿⣿⣿⣿⡿⠿⣦⡈⠀⣿⡇⠃⠀+ ⠀⠀⠀⣽⣿⣧⠀⠃⢰⣿⣿⡏⠙⣿⠿⢧⣀⣼⣷⠀⡿⠃⠀⠀+ ⠀⠀⠀⠉⣿⣿⣦⠀⢿⣿⣿⣷⣾⡏⠀⠀⢹⣿⣿⠀⠀⠀⠀⠀⠀+ ⠀⠀⠀⠀⠀⠉⠛⠁⠈⠿⣿⣿⣿⣷⣄⣠⡼⠟⠁⠀cua-bench==v0.4.0+ toolkit for computer-use RL environments and benchmarks++Commands:+ run Run a benchmark file or task+ interact Run a task interactively with visible GUI+ task Inspect and manage tasks (info, list)+ image Manage base images (create, list, info, clone, delete)+ sandbox Manage running sandboxes (start, stop, list, vnc, logs, exec)+ platform View available platforms (list)+ status Show system status+ datasets List available datasets from the registry+ process Process outputs into training datasets+ view-trace View a single trace+ view-traces View multiple traces in a grid+ create-task Scaffold a new task+ generate-task AI-generate a task from description+ login Authenticate with CUA Cloud++Options:+ -h, --help Show this help message and exit+ --version Show version+```diff --git a/docs/content/docs/cuabench/guide/getting-started/introduction.mdx b/docs/content/docs/cuabench/guide/getting-started/introduction.mdxnew file mode 100644index 0000000000..02b4f33e39--- /dev/null+++ b/docs/content/docs/cuabench/guide/getting-started/introduction.mdx@@ -0,0 +1,70 @@+---+title: Introduction+description: A benchmark to measure the capabilities of computer-use agents in desktop environments.+---++**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.++<div className="not-prose relative rounded-xl overflow-hidden my-8 w-full">+ <img src="/docs/img/cua_bench_screenshots.png" alt="Cua" className="w-full h-auto rounded-xl border" />+</div>++Examples of Cua-Bench tasks are:++- Navigating a web browser to book travel reservations+- Installing design software and editing images to remove backgrounds+- Using office applications to format and merge multiple documents++Cua-Bench consists of two parts:++1. **A dataset of tasks** - Verifiable, dynamic computer-use environments across multiple operating systems+2. **An evaluation/training harness** - Tools for running benchmarks, generating data, and testing agents++# Dataset of tasks++Each task in Cua-Bench includes:++- a description in English+- a config for the desktop/mobile environment+- a setup script to install any HTML webapps+- a test script to verify if the agent completed the task successfully+- a reference ("oracle") solution that solves the task++Check out our existing tasks [here](https://cuabench.ai/cuabench/registry)++# An environment harness++The harness provides familiar APIs for creating verifiable tasks. Use an Electron-like Python API to install web apps onto desktop/mobile environments, then use a Playwright-like API to write automated solutions or reward test scripts.++After [installing the package](/docs/cuabench/guide/getting-started/installation), you can run the harness using `cb run` or `cb interact`.++# Base Images++Cua-Bench uses **base images** - reproducible environments that provide consistent, isolated desktop or mobile VMs. Each image can be used to start sandboxes that can be stopped and reset to a known state.++| Type | Description | Requirements |+|------|-------------|--------------|+| `linux-docker` | Linux GUI container (XFCE) | Docker |+| `linux-qemu` | Linux VM with QEMU/KVM | Docker + KVM |+| `windows-qemu` | Windows 11 VM | Docker + KVM |+| `android-qemu` | Android VM | Docker + KVM |+| `macos-lume` | macOS VM via Lume | Apple Silicon |++See [Base Images](/docs/cuabench/guide/getting-started/images) for setup instructions.++# Supported Benchmarks++| Benchmark | Image | Tasks | Status | Description |+|-----------|--------------|-------|--------|-------------|+| Windows Arena | `windows-qemu` | 173 | Available | Windows 11 desktop automation across 12 apps |+| OSWorld | `linux-qemu` | 369 | Coming soon | Linux desktop automation |+| WebArena | `linux-docker` | 812 | Coming soon | Web browsing tasks |+| AndroidWorld | `android-qemu` | 200+ | Coming soon | Android mobile automation |+| macOSWorld | `macos-lume` | 100+ | Coming soon | macOS desktop automation |++# Next Steps++1. [Install the CLI](/docs/cuabench/guide/getting-started/installation)+2. [Create a base image](/docs/cuabench/guide/getting-started/images)+3. [Run your first benchmark](/docs/cuabench/guide/getting-started/first-steps)+4. [Create custom tasks](/docs/cuabench/guide/fundamentals/tasks)\ No newline at end of filediff --git a/docs/content/docs/cuabench/guide/getting-started/meta.json b/docs/content/docs/cuabench/guide/getting-started/meta.jsonnew file mode 100644index 0000000000..58cb322929--- /dev/null+++ b/docs/content/docs/cuabench/guide/getting-started/meta.json@@ -0,0 +1,12 @@+{+ "title": "Getting Started",+ "description": "Get started with Cua-Bench",+ "icon": "Rocket",+ "defaultOpen": true,+ "pages": [+ "introduction",+ "installation",+ "images",+ "first-steps"+ ]+}diff --git a/docs/content/docs/cuabench/guide/meta.json b/docs/content/docs/cuabench/guide/meta.jsonnew file mode 100644index 0000000000..93bc120de0--- /dev/null+++ b/docs/content/docs/cuabench/guide/meta.json@@ -0,0 +1,10 @@+{+ "title": "Guide",+ "description": "Learn how to use Cua-Bench",+ "icon": "Book",+ "pages": [+ "getting-started",+ "fundamentals",+ "advanced"+ ]+}diff --git a/docs/content/docs/cuabench/index.mdx b/docs/content/docs/cuabench/index.mdxnew file mode 100644index 0000000000..a220adf247--- /dev/null+++ b/docs/content/docs/cuabench/index.mdx@@ -0,0 +1,64 @@+---+title: Cua Bench+description: Framework for benchmarking and training computer-use agents+---++# Cua Bench++A toolkit for verifiable cross-platform computer-use RL environments and benchmarks. Supports real Windows, Linux, macOS, and Android VM environments with reproducible base images.++## Quick Start++```bash+# Install+git clone https://github.com/trycua/cua-bench.git && cd cua-bench+uv tool install -e .++# Create base image+cb image create linux-docker++# Run interactive task+cb interact tasks/click_button --dataset cua-bench-basic++# Run with agent+cb run --dataset cua-bench-basic --agent cua-agent --model anthropic/claude-sonnet-4-20250514+```++## Key Features++- **Base Images** - Reproducible VM images for Windows, Linux, macOS, and Android+- **Task Authoring** - Python API with async decorators for setup, evaluation, and oracle solutions+- **Custom Agents** - Docker image agents for production, import path agents for development+- **2-Container Architecture** - Agent and environment containers communicate via Docker network+- **Benchmark Execution** - Run evaluations locally or at scale on cloud+- **Training Data** - Export trajectories to datasets for UI grounding models++## Architecture++Cua-Bench uses a **2-container architecture** where agent and environment run in isolated containers:++```+┌─────────────────────────────────────────────────────────────┐+│ Docker Network: cua-task-{id} │+│ │+│ ┌─────────────────────┐ ┌─────────────────────────────┐│+│ │ cua-agent-{id} │ │ cua-env-{id} ││+│ │ │ │ ││+│ │ Your agent image │───►│ Base image sandbox ││+│ │ (or built-in) │HTTP│ (linux/windows/android) ││+│ │ │ │ ││+│ └─────────────────────┘ └─────────────────────────────┘│+└─────────────────────────────────────────────────────────────┘+```++This architecture is consistent between local development and cloud deployments.++## Next Steps++<Cards>+ <Card title="Introduction" href="/docs/cuabench/guide/getting-started/introduction" description="Learn about Cua-Bench concepts" />+ <Card title="Installation" href="/docs/cuabench/guide/getting-started/installation" description="Install the CLI and dependencies" />+ <Card title="Base Images" href="/docs/cuabench/guide/getting-started/images" description="Set up VM environments" />+ <Card title="First Steps" href="/docs/cuabench/guide/getting-started/first-steps" description="Run your first benchmark" />+ <Card title="Custom Agents" href="/docs/cuabench/guide/advanced/custom-agents" description="Build and run custom agents" />+</Cards>diff --git a/docs/content/docs/cuabench/meta.json b/docs/content/docs/cuabench/meta.jsonnew file mode 100644index 0000000000..a50a5636d2--- /dev/null+++ b/docs/content/docs/cuabench/meta.json@@ -0,0 +1,8 @@+{+ "title": "Cua-Bench",+ "description": "Framework for benchmarking and training computer-use agents",+ "pages": [+ "guide",+ "reference"+ ]+}diff --git a/docs/content/docs/cuabench/reference/cli-reference.mdx b/docs/content/docs/cuabench/reference/cli-reference.mdxnew file mode 100644index 0000000000..1a42994b90--- /dev/null+++ b/docs/content/docs/cuabench/reference/cli-reference.mdx@@ -0,0 +1,239 @@+---+title: CLI Reference+description: Complete reference for all cua-bench CLI commands+---++## Image Commands++Create and manage base images for environments.++```bash+cb image <action> [options]+```++| Command | Description |+|---------|-------------|+| `cb image create <platform>` | Create a base image |+| `cb image list` | List all images |+| `cb image info <name>` | Show image details |+| `cb image clone <src> <dst>` | Clone/fork an image |+| `cb image delete <name>` | Delete an image |++### Create Options++```bash+cb image create <platform> [options]+```++| Option | Description |+|--------|-------------|+| `--download-iso` | Download Windows 11 ISO (~6GB) |+| `--iso <path>` | Use existing Windows ISO |+| `--name <name>` | Image name (default: same as platform) |+| `--apps <list>` | Comma-separated apps to install (e.g., chrome,libreoffice) |+| `--memory <size>` | Memory (default: 8G) |+| `--cpus <count>` | CPU cores (default: 8) |+| `--disk <size>` | Disk size (default: 64G) |+| `--detach`, `-d` | Run in background |+| `--force` | Force recreation |++### List Options++```bash+cb image list [options]+```++| Option | Description |+|--------|-------------|+| `--format <fmt>` | Output format: table, json |+| `--platform <type>` | Filter by platform type |++## Sandbox Commands++Manage running sandbox instances.++```bash+cb sandbox <action> [options]+```++| Command | Description |+|---------|-------------|+| `cb sandbox start <image>` | Start sandbox from image |+| `cb sandbox stop <id>` | Stop running sandbox |+| `cb sandbox list` | List running sandboxes |+| `cb sandbox vnc <id>` | Open VNC in browser |+| `cb sandbox logs <id>` | View sandbox logs |+| `cb sandbox exec <id> <cmd>` | Execute command in sandbox |++### Start Options++```bash+cb sandbox start <image> [options]+```++| Option | Description |+|--------|-------------|+| `--vnc-port <port>` | VNC port (default varies by type) |+| `--api-port <port>` | API port (default varies by type) |+| `--name <name>` | Custom sandbox name |++## Platform Commands++View available platforms.++```bash+cb platform list [options]+```++| Option | Description |+|--------|-------------|+| `--format <fmt>` | Output format: table, json |++## Status Commands++Show system status.++```bash+cb status+```++Shows Docker status, KVM availability, and running sandboxes.++## Run Commands++Run tasks with the 2-container architecture (agent container + environment container).++```bash+cb run <task> [options]+```++### Basic Options++| Option | Description |+|--------|-------------|+| `--agent <name>` | Agent to use (from `.cua/agents.yaml`) |+| `--model <model>` | Model to use (e.g., `anthropic/claude-sonnet-4-20250514`) |+| `--oracle` | Run with oracle solution (no agent) |+| `--variant-id <n>` | Run specific task variant (default: 0) |+| `--max-steps <n>` | Maximum steps per task (default: 100) |++### Environment Options++| Option | Description |+|--------|-------------|+| `--image <name>` | Use specific base image |+| `--platform <type>` | Platform type: `linux-docker`, `windows-qemu`, `android-qemu` |++### Debugging Options++| Option | Description |+|--------|-------------|+| `--vnc-port <port>` | Expose VNC on host port (for live viewing) |+| `--api-port <port>` | Expose API on host port (for debugging) |++### Batch Options++| Option | Description |+|--------|-------------|+| `--max-parallel <n>` | Maximum parallel sessions |+| `--max-variants <n>` | Maximum variants per task |+| `--output-dir <dir>` | Output directory for results |+| `--dataset <name>` | Use dataset from registry |+| `--dataset-path <path>` | Use local dataset path |+| `--list` | List available tasks |++### Provider Options++| Option | Description |+|--------|-------------|+| `--on <provider>` | Where to run: `local` (default) or `cloud` |++### Examples++```bash+# Run task with oracle solution+cb run tasks/click_button --variant-id 0++# Run with agent evaluation+cb run tasks/click_button --variant-id 0 --agent cua-agent++# Run with VNC for live debugging (open http://localhost:8006)+cb run tasks/click_button --agent cua-agent --vnc-port 8006++# Run with custom model and step limit+cb run tasks/click_button --agent cua-agent --model gpt-4o --max-steps 50++# Run Windows task+cb run tasks/winarena --variant-id 0 --platform windows-qemu --agent cua-agent++# Run with specific image+cb run tasks/winarena --image windows-custom --agent cua-agent+```++## Interact Commands++Interactive task mode with visible browser.++```bash+cb interact <task> [options]+```++| Option | Description |+|--------|-------------|+| `--variant-id <id>` | Run specific task variant |+| `--oracle` | Run oracle solution |+| `--screenshot <path>` | Save screenshot to file |+| `--dataset <name>` | Use dataset from registry |++## Task Creation Commands++Create and generate tasks.++```bash+# Create empty task scaffold+cb create-task <path>++# AI-generate a task+cb generate-task "<description>" [options]+```++| Option | Description |+|--------|-------------|+| `--output <path>` | Output directory for generated task |++## Data Processing Commands++Export snapshots to training datasets.++```bash+cb process <dir> [options]+```++| Option | Description |+|--------|-------------|+| `--save-dir <dir>` | Output directory for datasets |+| `--mode <mode>` | Processor mode: aguvis-stage-1, gui-r1 |+| `--push-to-hub` | Push to Hugging Face Hub |+| `--repo-id <id>` | Hugging Face repo ID |++## View Commands++View traces and results.++```bash+# View single trace+cb view-trace <path>++# View multiple traces+cb view-traces <dir>+```++## Datasets Commands++View available datasets.++```bash+cb datasets [options]+```++Lists available datasets from the registry.diff --git a/docs/content/docs/cuabench/reference/meta.json b/docs/content/docs/cuabench/reference/meta.jsonnew file mode 100644index 0000000000..2c3e81403e--- /dev/null+++ b/docs/content/docs/cuabench/reference/meta.json@@ -0,0 +1,9 @@+{+ "title": "Reference",+ "description": "CLI and API reference",+ "icon": "FileText",+ "pages": [+ "cli-reference",+ "sdk-reference"+ ]+}diff --git a/docs/content/docs/cuabench/reference/sdk-reference.mdx b/docs/content/docs/cuabench/reference/sdk-reference.mdxnew file mode 100644index 0000000000..e1adce1b2d--- /dev/null+++ b/docs/content/docs/cuabench/reference/sdk-reference.mdx@@ -0,0 +1,316 @@+---+title: SDK Reference+description: Programming API for writing agents and tasks+---++# SDK Reference++cua-bench provides a Modal-style Python SDK for writing agents and tasks.++## Quick Example++```python+from cua_bench import Benchmark, Image, Secret, TaskDataset++benchmark = Benchmark("my-eval")+tasks = TaskDataset.from_registry("winarena")++image = (+ Image.from_registry("trycua/cua-bench:latest")+ .pip_install("anthropic")+)++ image=image,+ timeout=600,+ secrets=[Secret.from_name("anthropic-api-key")],+)+async def run_task(task_index: int, env) -> dict:+ session, task_config = await env.reset()++ for _ in range(50):+ screenshot = await session.screenshot()+ # ... agent logic ...+ await session.click(100, 200)++ result = await session.close()+ return {"reward": result["reward"]}+[email protected]_entrypoint()+def main():+ results = run_task.map(+ [i for i, _ in enumerate(tasks)],+ env=[task for task in tasks]+ )+ print(f"Avg reward: {sum(r['reward'] for r in results) / len(results):.2%}")+```++---++## Core Classes++### Benchmark++Create a benchmark context for organizing agent functions and tasks.++```python+from cua_bench import Benchmark++benchmark = Benchmark("my-benchmark-name")+```++**Decorators:**++| Decorator | Description |+|-----------|-------------|+| `@benchmark.function(...)` | Define an agent function |+| `@benchmark.task(...)` | Define a task with setup/eval |+| `@benchmark.local_entrypoint()` | Entry point for local runs |++---++### Image++Build agent runtime environments using a builder pattern:++```python+from cua_bench import Image++image = (+ Image.from_registry("trycua/cua-bench:latest")+ .pip_install("anthropic", "openai")+ .apt_install("ffmpeg", "imagemagick")+ .run_commands("python -c 'import anthropic'")+ .copy_local_dir("./src", "/app/src")+ .env("MY_VAR", "value")+)+```++**Builder Methods:**++| Method | Description |+|--------|-------------|+| `Image.from_registry(name)` | Start from a base Docker image |+| `.pip_install(*packages)` | Install Python packages |+| `.apt_install(*packages)` | Install system packages (Debian/Ubuntu) |+| `.run_commands(*commands)` | Run shell commands during build |+| `.copy_local_dir(src, dst)` | Copy local directory into image |+| `.env(key, value)` | Set environment variable |++---++### Secret++Reference API keys securely:++```python+from cua_bench import Secret++# Reference by name (configured in .cua/secrets.yaml)+anthropic_key = Secret.from_name("anthropic-api-key")++# Reference from environment variable+openai_key = Secret.from_env("OPENAI_API_KEY")++ image=image,+ secrets=[anthropic_key, openai_key],+)+async def run_task(task_index: int, env) -> dict:+ import os+ api_key = os.environ["ANTHROPIC_API_KEY"]+```++**Methods:**++| Method | Description |+|--------|-------------|+| `Secret.from_name(name)` | Reference a named secret |+| `Secret.from_env(var)` | Reference an environment variable |++---++### TaskDataset++Load task definitions from the registry or local paths:++```python+from cua_bench import TaskDataset++# Load from registry+tasks = TaskDataset.from_registry("winarena")+tasks = TaskDataset.from_registry("osworld")++# Load from local path+tasks = TaskDataset.from_path("./my_tasks/")++# Filter tasks+tasks = tasks.filter(domain="chrome")+tasks = tasks.filter(difficulty="easy")+tasks = tasks[:10] # First 10 tasks++# Iterate+for task in tasks:+ print(task.id, task.description)+```++**Methods:**++| Method | Description |+|--------|-------------|+| `TaskDataset.from_registry(name)` | Load from CUA registry |+| `TaskDataset.from_path(path)` | Load from local directory |+| `.filter(**kwargs)` | Filter by attributes |+| `[start:end]` | Slice tasks |+| `len(tasks)` | Get task count |++---++### Session Interface++Interact with the desktop environment:++```python[email protected](image=image)+async def run_task(task_index: int, env) -> dict:+ session, task_config = await env.reset()++ # Screenshot+ screenshot_bytes = await session.screenshot() # PNG bytes+ screenshot_b64 = await session.screenshot(format="base64")++ # Mouse actions+ await session.click(x, y)+ await session.right_click(x, y)+ await session.double_click(x, y)+ await session.drag(from_x, from_y, to_x, to_y)+ await session.scroll(x, y, direction="down", amount=3)+ await session.move_to(x, y)++ # Keyboard actions+ await session.type("Hello, world!")+ await session.key("Enter")+ await session.hotkey(["ctrl", "c"])++ # Advanced+ snapshot = await session.get_snapshot() # Window info+ pid = await session.launch_window("https://example.com")+ result = await session.execute_javascript(pid, "document.title")++ # Finalize+ result = await session.close() # Runs evaluation+ return {"reward": result["reward"]}+```++**Session Methods:**++| Method | Description |+|--------|-------------|+| `screenshot(format?)` | Capture screen (PNG bytes or base64) |+| `click(x, y)` | Left click at coordinates |+| `right_click(x, y)` | Right click |+| `double_click(x, y)` | Double click |+| `drag(x1, y1, x2, y2)` | Drag gesture |+| `scroll(x, y, direction, amount)` | Scroll at position |+| `move_to(x, y)` | Move cursor |+| `type(text)` | Type text |+| `key(key)` | Press single key |+| `hotkey(keys)` | Key combination (e.g., `["ctrl", "c"]`) |+| `get_snapshot()` | Get desktop state |+| `launch_window(url)` | Launch browser window |+| `execute_javascript(pid, js)` | Run JS in window |+| `close()` | Finalize and get result |++---++## Execution Patterns++Agent functions support multiple execution patterns:++```python[email protected](image=image, timeout=600)+async def run_task(task_index: int, env) -> dict:+ ...+[email protected]_entrypoint()+def main():+ # Single local execution+ result = run_task.local(task_index=0, env=tasks[0])++ # Single remote execution+ result = run_task.remote(task_index=0, env=tasks[0])++ # Parallel execution (recommended)+ results = run_task.map(+ [i for i, _ in enumerate(tasks)],+ env=[task for task in tasks]+ )++ # With concurrency limit+ results = run_task.map(+ task_indices,+ env=task_configs,+ concurrency=10,+ )+```++**Execution Methods:**++| Method | Description |+|--------|-------------|+| `.local(...)` | Run locally in current process |+| `.remote(...)` | Run single task remotely |+| `.map(...)` | Run multiple tasks in parallel |++---++## Task Definition++Define tasks using a generator pattern with `yield`:++```python+from cua_bench import benchmark, Demonstrations++ environment="windows-qemu",+ oracle=Demonstrations.from_name("my-demo"),+ timeout=600,+)+async def my_task(session):+ # ─── SETUP (runs on env.reset()) ───+ import subprocess+ subprocess.run(["powershell", "-Command", "Start-Process notepad"])++ # ─── YIELD TASK DESCRIPTION ───+ yield {+ "description": "Type 'Hello World' in Notepad",+ "hints": ["Use Ctrl+S to save"],+ }++ # ─── EVALUATION (runs on session.close()) ───+ import os+ if os.path.exists("C:/Users/User/Desktop/hello.txt"):+ return {"success": True, "reward": 1.0}++ return {"success": False, "reward": 0.0}+```++**Task Decorator Options:**++| Option | Type | Description |+|--------|------|-------------|+| `environment` | string | Platform type |+| `oracle` | Demonstrations | Optional oracle demonstration |+| `timeout` | int | Task timeout in seconds |+| `tags` | list | Task tags for filtering |++**Task Return Value:**++```python+{+ "success": bool, # Whether task succeeded+ "reward": float, # 0.0 to 1.0+ "reason": str, # Optional explanation+ "details": dict, # Optional extra data+}+```diff --git a/docs/public/img/cua_bench_overview.png b/docs/public/img/cua_bench_overview.pngnew file mode 100644index 0000000000..015959cd8eBinary files /dev/null and b/docs/public/img/cua_bench_overview.png differdiff --git a/docs/public/img/cua_bench_screenshots.png b/docs/public/img/cua_bench_screenshots.pngnew file mode 100644index 0000000000..d477cfbbcaBinary files /dev/null and b/docs/public/img/cua_bench_screenshots.png differ