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.

Add vanilla Docker XFCE container for CUA

f-trycuaef69c4431a17
diff --git a/libs/docker-xfce/.dockerignore b/libs/docker-xfce/.dockerignore
new file mode 100644
index 0000000000..d4352f8876
--- /dev/null
+++ b/libs/docker-xfce/.dockerignore
@@ -0,0 +1,5 @@
+README.md
+.git
+.gitignore
+*.md
+LICENSE
diff --git a/libs/docker-xfce/.gitignore b/libs/docker-xfce/.gitignore
new file mode 100644
index 0000000000..0a2449a104
--- /dev/null
+++ b/libs/docker-xfce/.gitignore
@@ -0,0 +1,4 @@
+storage/
+shared/
+*.log
+.DS_Store
diff --git a/libs/docker-xfce/Dockerfile b/libs/docker-xfce/Dockerfile
new file mode 100644
index 0000000000..94326ae27d
--- /dev/null
+++ b/libs/docker-xfce/Dockerfile
@@ -0,0 +1,122 @@
+# CUA Docker XFCE Container
+# Vanilla XFCE desktop with noVNC and computer-server
+
+FROM ubuntu:22.04
+
+# Avoid prompts from apt
+ENV DEBIAN_FRONTEND=noninteractive
+
+# Set environment variables
+ENV HOME=/home/cua
+ENV DISPLAY=:1
+ENV VNC_PORT=5901
+ENV NOVNC_PORT=6901
+ENV API_PORT=8000
+ENV VNC_RESOLUTION=1920x1080
+ENV VNC_COL_DEPTH=24
+
+# Create user
+RUN useradd -m -s /bin/bash -G sudo cua && \
+ echo "cua:password" | chpasswd && \
+ echo "cua ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
+# Install system dependencies
+RUN apt-get update && apt-get install -y \
+ # Desktop environment
+ xfce4 \
+ xfce4-terminal \
+ xfce4-goodies \
+ dbus-x11 \
+ # VNC server
+ tigervnc-standalone-server \
+ tigervnc-common \
+ # noVNC dependencies
+ python3 \
+ python3-pip \
+ python3-numpy \
+ git \
+ net-tools \
+ supervisor \
+ # Computer-server dependencies
+ python3.11 \
+ python3-tk \
+ python3-dev \
+ gnome-screenshot \
+ wmctrl \
+ ffmpeg \
+ socat \
+ xclip \
+ # Browser
+ wget \
+ software-properties-common \
+ # Build tools
+ build-essential \
+ libncursesw5-dev \
+ libssl-dev \
+ libsqlite3-dev \
+ tk-dev \
+ libgdbm-dev \
+ libc6-dev \
+ libbz2-dev \
+ libffi-dev \
+ zlib1g-dev \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install Python 3.11
+RUN add-apt-repository ppa:deadsnakes/ppa && \
+ apt-get update && \
+ apt-get install -y python3.11 python3.11-distutils && \
+ rm -rf /var/lib/apt/lists/*
+
+# Install noVNC
+RUN git clone https://github.com/novnc/noVNC.git /opt/noVNC && \
+ git clone https://github.com/novnc/websockify /opt/noVNC/utils/websockify && \
+ ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html
+
+# Install computer-server
+RUN pip3 install cua-computer-server
+
+# Install Firefox
+RUN add-apt-repository -y ppa:mozillateam/ppa && \
+ echo 'Package: *\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 1001' > /etc/apt/preferences.d/mozilla-firefox && \
+ apt-get update && \
+ apt-get install -y firefox && \
+ rm -rf /var/lib/apt/lists/*
+
+# Configure Firefox defaults
+RUN mkdir -p /etc/firefox/syspref.js && \
+ echo 'pref("datareporting.policy.firstRunURL", "");' >> /etc/firefox/syspref.js && \
+ echo 'pref("datareporting.policy.dataSubmissionEnabled", false);' >> /etc/firefox/syspref.js && \
+ echo 'pref("datareporting.healthreport.service.enabled", false);' >> /etc/firefox/syspref.js && \
+ echo 'pref("datareporting.healthreport.uploadEnabled", false);' >> /etc/firefox/syspref.js && \
+ echo 'pref("browser.aboutwelcome.enabled", false);' >> /etc/firefox/syspref.js
+
+# Copy startup scripts
+COPY src/supervisor/ /etc/supervisor/conf.d/
+COPY src/scripts/ /usr/local/bin/
+
+# Make scripts executable
+RUN chmod +x /usr/local/bin/*.sh
+
+# Setup VNC
+USER cua
+WORKDIR /home/cua
+
+# Create VNC password file
+RUN mkdir -p $HOME/.vnc && \
+ echo "password" | vncpasswd -f > $HOME/.vnc/passwd && \
+ chmod 600 $HOME/.vnc/passwd
+
+# Configure XFCE for first start
+RUN mkdir -p $HOME/.config/xfce4/xfconf/xfce-perchannel-xml
+
+# Create storage and shared directories
+RUN mkdir -p $HOME/storage $HOME/shared
+
+USER root
+
+# Expose ports
+EXPOSE $VNC_PORT $NOVNC_PORT $API_PORT
+
+# Start services via supervisor
+CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
diff --git a/libs/docker-xfce/LICENSE b/libs/docker-xfce/LICENSE
new file mode 100644
index 0000000000..6899a9dbde
--- /dev/null
+++ b/libs/docker-xfce/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 CUA
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/libs/docker-xfce/Makefile b/libs/docker-xfce/Makefile
new file mode 100644
index 0000000000..e3aa2879ec
--- /dev/null
+++ b/libs/docker-xfce/Makefile
@@ -0,0 +1,127 @@
+.PHONY: build run stop push clean test logs shell
+
+IMAGE_NAME := trycua/cua-docker-xfce
+TAG := latest
+CONTAINER_NAME := cua-docker-xfce-test
+
+# Build the Docker image
+build:
+ docker build -t $(IMAGE_NAME):$(TAG) .
+
+# Run the container
+run:
+ docker run -d \
+ --name $(CONTAINER_NAME) \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ $(IMAGE_NAME):$(TAG)
+ @echo "Container started!"
+ @echo "noVNC: http://localhost:6901"
+ @echo "VNC: localhost:5901 (password: password)"
+ @echo "API: http://localhost:8000"
+
+# Run with custom resolution
+run-hd:
+ docker run -d \
+ --name $(CONTAINER_NAME) \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ -e VNC_RESOLUTION=1280x720 \
+ $(IMAGE_NAME):$(TAG)
+
+# Run with persistent storage
+run-persist:
+ mkdir -p ./storage ./shared
+ docker run -d \
+ --name $(CONTAINER_NAME) \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ -v $(PWD)/storage:/home/cua/storage \
+ -v $(PWD)/shared:/home/cua/shared \
+ $(IMAGE_NAME):$(TAG)
+
+# Stop and remove the container
+stop:
+ docker stop $(CONTAINER_NAME) || true
+ docker rm $(CONTAINER_NAME) || true
+
+# Push to Docker Hub
+push:
+ docker push $(IMAGE_NAME):$(TAG)
+
+# Clean up everything
+clean: stop
+ docker rmi $(IMAGE_NAME):$(TAG) || true
+ rm -rf ./storage ./shared
+
+# Run tests
+test: build run
+ @echo "Waiting for services to start..."
+ @sleep 10
+ @echo "Testing noVNC..."
+ @curl -f http://localhost:6901 > /dev/null && echo "✓ noVNC is running" || echo "✗ noVNC failed"
+ @echo "Testing API..."
+ @curl -f http://localhost:8000 > /dev/null && echo "✓ API is running" || echo "✗ API failed"
+ @$(MAKE) stop
+
+# View logs
+logs:
+ docker logs -f $(CONTAINER_NAME)
+
+# View supervisor logs
+logs-supervisor:
+ docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/supervisord.log
+
+# View individual service logs
+logs-vnc:
+ docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/vncserver.log
+
+logs-novnc:
+ docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/novnc.log
+
+logs-api:
+ docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/computer-server.log
+
+# Open a shell in the container
+shell:
+ docker exec -it $(CONTAINER_NAME) /bin/bash
+
+# Check supervisor status
+status:
+ docker exec $(CONTAINER_NAME) supervisorctl status
+
+# Restart services
+restart-services:
+ docker exec $(CONTAINER_NAME) supervisorctl restart all
+
+# Create a snapshot
+snapshot:
+ docker commit $(CONTAINER_NAME) $(IMAGE_NAME):snapshot
+ @echo "Snapshot created: $(IMAGE_NAME):snapshot"
+
+# Build and run
+dev: build run logs
+
+# Help
+help:
+ @echo "Available targets:"
+ @echo " build - Build the Docker image"
+ @echo " run - Run the container"
+ @echo " run-hd - Run with 720p resolution"
+ @echo " run-persist - Run with persistent storage"
+ @echo " stop - Stop and remove container"
+ @echo " push - Push to Docker Hub"
+ @echo " clean - Remove image and container"
+ @echo " test - Build, run tests, and stop"
+ @echo " logs - View container logs"
+ @echo " logs-* - View specific service logs"
+ @echo " shell - Open shell in container"
+ @echo " status - Check supervisor status"
+ @echo " snapshot - Create container snapshot"
+ @echo " dev - Build, run, and follow logs"
diff --git a/libs/docker-xfce/QUICKSTART.md b/libs/docker-xfce/QUICKSTART.md
new file mode 100644
index 0000000000..9cd8082b2a
--- /dev/null
+++ b/libs/docker-xfce/QUICKSTART.md
@@ -0,0 +1,166 @@
+# Quick Start Guide
+
+Get up and running with CUA Docker XFCE in 5 minutes.
+
+## Prerequisites
+
+- Docker installed and running
+- Python 3.11+ (for using with CUA library)
+- `cua-computer` package installed: `pip install cua-computer`
+
+## Quick Start
+
+### Option 1: Using Makefile (Recommended)
+
+```bash
+# Build and run
+make build
+make run
+
+# Check if it's running
+make status
+
+# View logs
+make logs
+```
+
+Access:
+- 🌐 **Web VNC**: http://localhost:6901
+- 🖥️ **VNC Client**: localhost:5901 (password: `password`)
+- 🔌 **API**: http://localhost:8000
+
+### Option 2: Using Docker Compose
+
+```bash
+# Start the container
+docker-compose up -d
+
+# View logs
+docker-compose logs -f
+
+# Stop the container
+docker-compose down
+```
+
+### Option 3: Docker Command
+
+```bash
+docker run -d \
+ --name cua-desktop \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ trycua/cua-docker-xfce:latest
+```
+
+## Using with Python
+
+```python
+import asyncio
+from computer import Computer
+
+async def main():
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest"
+ )
+
+ async with computer:
+ # Take a screenshot
+ screenshot = await computer.interface.screenshot()
+
+ # Open terminal
+ await computer.interface.hotkey("ctrl", "alt", "t")
+ await asyncio.sleep(1)
+
+ # Type and execute command
+ await computer.interface.type_text("echo 'Hello!'")
+ await computer.interface.press_key("Return")
+
+asyncio.run(main())
+```
+
+## Common Tasks
+
+### Run with custom resolution
+```bash
+make run-hd # 1280x720
+# or
+docker run -e VNC_RESOLUTION=1280x720 ...
+```
+
+### Run with persistent storage
+```bash
+make run-persist
+# or
+docker run -v $(pwd)/storage:/home/cua/storage ...
+```
+
+### View specific logs
+```bash
+make logs-vnc # VNC server logs
+make logs-novnc # noVNC proxy logs
+make logs-api # Computer-server logs
+```
+
+### Open shell in container
+```bash
+make shell
+# or
+docker exec -it cua-desktop /bin/bash
+```
+
+### Create a snapshot
+```bash
+make snapshot
+```
+
+## Troubleshooting
+
+### Container won't start
+```bash
+# Check if ports are already in use
+lsof -i :6901
+lsof -i :8000
+
+# View container logs
+docker logs cua-desktop
+```
+
+### Black screen in noVNC
+```bash
+# Restart VNC server
+docker exec cua-desktop supervisorctl restart vncserver
+```
+
+### API not responding
+```bash
+# Check if computer-server is running
+docker exec cua-desktop supervisorctl status computer-server
+
+# Restart computer-server
+docker exec cua-desktop supervisorctl restart computer-server
+```
+
+## Next Steps
+
+- Read the [full README](README.md) for detailed documentation
+- Check out [example.py](example.py) for more usage examples
+- Customize the [Dockerfile](Dockerfile) for your needs
+
+## Clean Up
+
+```bash
+# Using Makefile
+make clean
+
+# Using docker-compose
+docker-compose down -v
+
+# Manual
+docker stop cua-desktop
+docker rm cua-desktop
+docker rmi trycua/cua-docker-xfce:latest
+```
diff --git a/libs/docker-xfce/README.md b/libs/docker-xfce/README.md
new file mode 100644
index 0000000000..489d00428d
--- /dev/null
+++ b/libs/docker-xfce/README.md
@@ -0,0 +1,238 @@
+# CUA Docker XFCE Container
+
+Vanilla XFCE desktop container for Computer-Using Agents (CUA) with noVNC and computer-server. This is a lightweight alternative to the Kasm-based container with minimal dependencies.
+
+## Features
+
+- Ubuntu 22.04 (Jammy) with vanilla XFCE desktop environment
+- TigerVNC server for remote desktop access
+- noVNC for web-based VNC access (no client required)
+- Pre-installed computer-server for remote computer control
+- Python 3.11 with necessary libraries
+- Screen capture tools (gnome-screenshot, wmctrl, ffmpeg)
+- Clipboard utilities (xclip, socat)
+- Firefox browser with telemetry disabled
+
+## Architecture
+
+```
+┌─────────────────────────────────────────┐
+│ Docker Container (Ubuntu 22.04) │
+├─────────────────────────────────────────┤
+│ XFCE Desktop Environment │
+│ ├── Firefox │
+│ ├── XFCE Terminal │
+│ └── Desktop utilities │
+├─────────────────────────────────────────┤
+│ TigerVNC Server (Port 5901) │
+│ └── X11 Display :1 │
+├─────────────────────────────────────────┤
+│ noVNC Web Interface (Port 6901) │
+│ └── WebSocket proxy to VNC │
+├─────────────────────────────────────────┤
+│ CUA Computer Server (Port 8000) │
+│ └── WebSocket API for automation │
+└─────────────────────────────────────────┘
+```
+
+## Building the Container
+
+```bash
+docker build -t cua-docker-xfce:latest .
+```
+
+## Pushing to Registry
+
+```bash
+# Tag for Docker Hub (replace 'trycua' with your Docker Hub username)
+docker tag cua-docker-xfce:latest trycua/cua-docker-xfce:latest
+
+# Login to Docker Hub
+docker login
+
+# Push to Docker Hub
+docker push trycua/cua-docker-xfce:latest
+```
+
+## Running the Container Manually
+
+### Basic Usage
+
+```bash
+docker run --rm -it \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ cua-docker-xfce:latest
+```
+
+### With Custom Resolution
+
+```bash
+docker run --rm -it \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ -e VNC_RESOLUTION=1280x720 \
+ cua-docker-xfce:latest
+```
+
+### With Persistent Storage
+
+```bash
+docker run --rm -it \
+ --shm-size=512m \
+ -p 5901:5901 \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ -v $(pwd)/storage:/home/cua/storage \
+ cua-docker-xfce:latest
+```
+
+## Accessing the Container
+
+- **noVNC Web Interface**: Open `http://localhost:6901` in your browser
+- **VNC Client**: Connect to `localhost:5901` (password: `password`)
+- **Computer Server API**: Available at `http://localhost:8000`
+
+## Using with CUA Docker Provider
+
+This container is designed to work with the CUA Docker provider:
+
+```python
+from computer import Computer
+
+# Create computer with docker-xfce container
+computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest",
+ display="1920x1080",
+ memory="4GB",
+ cpu="2"
+)
+
+# Use the computer
+async with computer:
+ # Take a screenshot
+ screenshot = await computer.interface.screenshot()
+
+ # Click and type
+ await computer.interface.left_click(100, 100)
+ await computer.interface.type_text("Hello from CUA!")
+
+ # Run commands
+ result = await computer.interface.run_command("ls -la")
+ print(result.stdout)
+```
+
+## Environment Variables
+
+| Variable | Default | Description |
+|----------|---------|-------------|
+| `VNC_RESOLUTION` | `1920x1080` | 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 |
+| `DISPLAY` | `:1` | X11 display number |
+
+## Exposed Ports
+
+- **5901**: TigerVNC server
+- **6901**: noVNC web interface
+- **8000**: Computer-server WebSocket API
+
+## Volume Mount Points
+
+- `/home/cua/storage`: Persistent storage mount point
+- `/home/cua/shared`: Shared folder mount point
+
+## User Credentials
+
+- **Username**: `cua`
+- **Password**: `password`
+- **Sudo access**: Enabled without password
+
+## Creating Snapshots
+
+### Filesystem Snapshot
+```bash
+docker commit <container_id> cua-docker-xfce-snapshot:latest
+```
+
+### Running from Snapshot
+```bash
+docker run --rm -it \
+ --shm-size=512m \
+ -p 6901:6901 \
+ -p 8000:8000 \
+ cua-docker-xfce-snapshot:latest
+```
+
+## Comparison with Kasm Container
+
+| Feature | Kasm Container | Docker XFCE Container |
+|---------|---------------|----------------------|
+| Base Image | KasmWeb Ubuntu | Vanilla Ubuntu |
+| VNC Server | KasmVNC | TigerVNC |
+| Dependencies | Higher | Lower |
+| Configuration | Pre-configured | Minimal |
+| Size | Larger | Smaller |
+| Maintenance | Depends on Kasm | Independent |
+
+## Process Management
+
+The container uses `supervisord` to manage three main processes:
+
+1. **VNC Server** (Priority 10): TigerVNC with XFCE desktop
+2. **noVNC** (Priority 20): WebSocket proxy for browser access
+3. **Computer Server** (Priority 30): CUA automation API
+
+All processes are automatically restarted on failure.
+
+## Troubleshooting
+
+### VNC server won't start
+Check if X11 lock files exist:
+```bash
+docker exec <container_id> rm -rf /tmp/.X1-lock /tmp/.X11-unix/X1
+```
+
+### noVNC shows black screen
+Ensure VNC server is running:
+```bash
+docker exec <container_id> supervisorctl status vncserver
+```
+
+### Computer-server not responding
+Check if X server is accessible:
+```bash
+docker exec <container_id> env DISPLAY=:1 xdpyinfo
+```
+
+### View logs
+```bash
+docker exec <container_id> tail -f /var/log/supervisor/supervisord.log
+docker exec <container_id> supervisorctl status
+```
+
+## Integration with CUA System
+
+This container provides the same functionality as the Kasm container but with:
+- **Reduced dependencies**: No reliance on KasmWeb infrastructure
+- **Smaller image size**: Minimal base configuration
+- **Full control**: Direct access to all components
+- **Easy customization**: Simple to modify and extend
+
+The container integrates seamlessly with:
+- CUA Computer library (via WebSocket API)
+- Docker provider for lifecycle management
+- Standard VNC clients for debugging
+- Web browsers for visual monitoring
+
+## License
+
+MIT License - See LICENSE file for details
diff --git a/libs/docker-xfce/docker-compose.yml b/libs/docker-xfce/docker-compose.yml
new file mode 100644
index 0000000000..bdc1ba2dcd
--- /dev/null
+++ b/libs/docker-xfce/docker-compose.yml
@@ -0,0 +1,44 @@
+version: '3.8'
+
+services:
+ cua-desktop:
+ build: .
+ image: trycua/cua-docker-xfce:latest
+ container_name: cua-docker-xfce
+ shm_size: '512m'
+ ports:
+ - "5901:5901" # VNC
+ - "6901:6901" # noVNC
+ - "8000:8000" # Computer API
+ environment:
+ - VNC_RESOLUTION=1920x1080
+ - VNC_COL_DEPTH=24
+ - VNC_PORT=5901
+ - NOVNC_PORT=6901
+ - API_PORT=8000
+ volumes:
+ - ./storage:/home/cua/storage
+ - ./shared:/home/cua/shared
+ restart: unless-stopped
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:8000"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ start_period: 40s
+
+ # Optional: Multiple instances for parallel testing
+ cua-desktop-2:
+ build: .
+ image: trycua/cua-docker-xfce:latest
+ container_name: cua-docker-xfce-2
+ shm_size: '512m'
+ ports:
+ - "5902:5901"
+ - "6902:6901"
+ - "8001:8000"
+ environment:
+ - VNC_RESOLUTION=1280x720
+ restart: unless-stopped
+ profiles:
+ - multi
diff --git a/libs/docker-xfce/example.py b/libs/docker-xfce/example.py
new file mode 100644
index 0000000000..6c42bbc217
--- /dev/null
+++ b/libs/docker-xfce/example.py
@@ -0,0 +1,213 @@
+#!/usr/bin/env python3
+"""
+Example script demonstrating how to use the CUA Docker XFCE container
+with the Computer library.
+"""
+
+import asyncio
+from computer import Computer
+
+
+async def basic_example():
+ """Basic example: Take a screenshot and click around"""
+ print("=== Basic Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest",
+ display="1920x1080",
+ memory="4GB",
+ cpu="2",
+ port=8000,
+ noVNC_port=6901
+ )
+
+ async with computer:
+ print("Computer is ready!")
+ print(f"noVNC available at: http://localhost:6901")
+
+ # Get screen info
+ screen = await computer.interface.get_screen_size()
+ print(f"Screen size: {screen['width']}x{screen['height']}")
+
+ # Take a screenshot
+ screenshot = await computer.interface.screenshot()
+ with open("screenshot.png", "wb") as f:
+ f.write(screenshot)
+ print("Screenshot saved to screenshot.png")
+
+ # Click and type
+ await computer.interface.left_click(100, 100)
+ await computer.interface.type_text("Hello from CUA!")
+
+ print("Done!")
+
+
+async def file_operations_example():
+ """Example: File system operations"""
+ print("\n=== File Operations Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest"
+ )
+
+ async with computer:
+ # Create a file
+ await computer.interface.write_text(
+ "/home/cua/test.txt",
+ "Hello from CUA!"
+ )
+ print("Created test.txt")
+
+ # Read it back
+ content = await computer.interface.read_text("/home/cua/test.txt")
+ print(f"File content: {content}")
+
+ # List directory
+ files = await computer.interface.list_dir("/home/cua")
+ print(f"Files in home directory: {files}")
+
+
+async def command_execution_example():
+ """Example: Running shell commands"""
+ print("\n=== Command Execution Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest"
+ )
+
+ async with computer:
+ # Run a command
+ result = await computer.interface.run_command("uname -a")
+ print(f"System info:\n{result.stdout}")
+
+ # Check Firefox is installed
+ result = await computer.interface.run_command("which firefox")
+ print(f"Firefox location: {result.stdout.strip()}")
+
+ # Get Python version
+ result = await computer.interface.run_command("python3 --version")
+ print(f"Python version: {result.stdout.strip()}")
+
+
+async def browser_automation_example():
+ """Example: Opening Firefox and navigating"""
+ print("\n=== Browser Automation Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest"
+ )
+
+ async with computer:
+ # Open Firefox
+ await computer.interface.run_command("firefox https://example.com &")
+ print("Firefox opened")
+
+ # Wait for it to load
+ await asyncio.sleep(5)
+
+ # Take a screenshot
+ screenshot = await computer.interface.screenshot()
+ with open("browser_screenshot.png", "wb") as f:
+ f.write(screenshot)
+ print("Browser screenshot saved")
+
+
+async def persistent_storage_example():
+ """Example: Using persistent storage"""
+ print("\n=== Persistent Storage Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest",
+ shared_directories=["./storage"]
+ )
+
+ async with computer:
+ # Write to persistent storage
+ await computer.interface.write_text(
+ "/home/cua/storage/persistent.txt",
+ "This file persists across container restarts!"
+ )
+ print("Written to persistent storage")
+
+ # Read it back
+ content = await computer.interface.read_text(
+ "/home/cua/storage/persistent.txt"
+ )
+ print(f"Content: {content}")
+
+
+async def multi_action_example():
+ """Example: Complex interaction sequence"""
+ print("\n=== Multi-Action Example ===")
+
+ computer = Computer(
+ os_type="linux",
+ provider_type="docker",
+ image="trycua/cua-docker-xfce:latest"
+ )
+
+ async with computer:
+ # Open terminal
+ await computer.interface.hotkey("ctrl", "alt", "t")
+ await asyncio.sleep(2)
+
+ # Type a command
+ await computer.interface.type_text("echo 'Hello from CUA!'")
+ await computer.interface.press_key("Return")
+ await asyncio.sleep(1)
+
+ # Take screenshot
+ screenshot = await computer.interface.screenshot()
+ with open("terminal_screenshot.png", "wb") as f:
+ f.write(screenshot)
+ print("Terminal screenshot saved")
+
+
+async def main():
+ """Run all examples"""
+ examples = [
+ ("Basic", basic_example),
+ ("File Operations", file_operations_example),
+ ("Command Execution", command_execution_example),
+ ("Browser Automation", browser_automation_example),
+ ("Persistent Storage", persistent_storage_example),
+ ("Multi-Action", multi_action_example),
+ ]
+
+ print("Available examples:")
+ for i, (name, _) in enumerate(examples, 1):
+ print(f"{i}. {name}")
+ print(f"{len(examples) + 1}. Run all")
+
+ choice = input("\nSelect an example (1-7): ").strip()
+
+ try:
+ if choice == str(len(examples) + 1):
+ # Run all examples
+ for name, func in examples:
+ try:
+ await func()
+ except Exception as e:
+ print(f"Error in {name}: {e}")
+ else:
+ idx = int(choice) - 1
+ if 0 <= idx < len(examples):
+ await examples[idx][1]()
+ else:
+ print("Invalid choice")
+ except ValueError:
+ print("Invalid input")
+
+
+if __name__ == "__main__":
+ asyncio.run(main())
diff --git a/libs/docker-xfce/src/scripts/start-computer-server.sh b/libs/docker-xfce/src/scripts/start-computer-server.sh
new file mode 100644
index 0000000000..bc27a3dbb4
--- /dev/null
+++ b/libs/docker-xfce/src/scripts/start-computer-server.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+
+# Wait for X server to be ready
+echo "Waiting for X server to start..."
+while ! xdpyinfo -display :1 >/dev/null 2>&1; do
+ sleep 1
+done
+echo "X server is ready"
+
+# Start computer-server
+export DISPLAY=:1
+python3 -m computer_server --port ${API_PORT:-8000}
diff --git a/libs/docker-xfce/src/scripts/start-novnc.sh b/libs/docker-xfce/src/scripts/start-novnc.sh
new file mode 100644
index 0000000000..4f95c644b1
--- /dev/null
+++ b/libs/docker-xfce/src/scripts/start-novnc.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+# Wait for VNC server to be ready
+echo "Waiting for VNC server to start..."
+while ! nc -z localhost ${VNC_PORT:-5901}; do
+ sleep 1
+done
+echo "VNC server is ready"
+
+# Start noVNC
+cd /opt/noVNC
+/opt/noVNC/utils/novnc_proxy \
+ --vnc localhost:${VNC_PORT:-5901} \
+ --listen ${NOVNC_PORT:-6901}
diff --git a/libs/docker-xfce/src/scripts/start-vnc.sh b/libs/docker-xfce/src/scripts/start-vnc.sh
new file mode 100644
index 0000000000..1cbba98f53
--- /dev/null
+++ b/libs/docker-xfce/src/scripts/start-vnc.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -e
+
+# Clean up any existing VNC lock files
+rm -rf /tmp/.X1-lock /tmp/.X11-unix/X1
+
+# Start VNC server
+vncserver :1 \
+ -geometry ${VNC_RESOLUTION:-1920x1080} \
+ -depth ${VNC_COL_DEPTH:-24} \
+ -rfbport ${VNC_PORT:-5901} \
+ -localhost no \
+ -SecurityTypes None \
+ -AlwaysShared \
+ -AcceptPointerEvents \
+ -AcceptKeyEvents \
+ -AcceptCutText \
+ -SendCutText \
+ -xstartup /usr/local/bin/xstartup.sh
+
+# Keep the process running
+tail -f /home/cua/.vnc/*.log
diff --git a/libs/docker-xfce/src/scripts/xstartup.sh b/libs/docker-xfce/src/scripts/xstartup.sh
new file mode 100644
index 0000000000..49bb46a26f
--- /dev/null
+++ b/libs/docker-xfce/src/scripts/xstartup.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+set -e
+
+# Start D-Bus
+if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
+ eval $(dbus-launch --sh-syntax --exit-with-session)
+fi
+
+# Start XFCE
+startxfce4 &
+
+# Wait for XFCE to start
+sleep 2
+
+# Disable screensaver and power management
+xset s off
+xset -dpms
+xset s noblank
+
+# Wait for the session
+wait
diff --git a/libs/docker-xfce/src/supervisor/supervisord.conf b/libs/docker-xfce/src/supervisor/supervisord.conf
new file mode 100644
index 0000000000..fb367c4f75
--- /dev/null
+++ b/libs/docker-xfce/src/supervisor/supervisord.conf
@@ -0,0 +1,30 @@
+[supervisord]
+nodaemon=true
+user=root
+logfile=/var/log/supervisor/supervisord.log
+pidfile=/var/run/supervisord.pid
+childlogdir=/var/log/supervisor
+
+[program:vncserver]
+command=/usr/local/bin/start-vnc.sh
+user=cua
+autorestart=true
+stdout_logfile=/var/log/supervisor/vncserver.log
+stderr_logfile=/var/log/supervisor/vncserver.error.log
+priority=10
+
+[program:novnc]
+command=/usr/local/bin/start-novnc.sh
+user=cua
+autorestart=true
+stdout_logfile=/var/log/supervisor/novnc.log
+stderr_logfile=/var/log/supervisor/novnc.error.log
+priority=20
+
+[program:computer-server]
+command=/usr/local/bin/start-computer-server.sh
+user=cua
+autorestart=true
+stdout_logfile=/var/log/supervisor/computer-server.log
+stderr_logfile=/var/log/supervisor/computer-server.error.log
+priority=30