mirror of
https://github.com/trycua/computer.git
synced 2026-01-09 23:10:11 -06:00
Merge pull request #287 from trycua/fix/x64-docker
Add .devcontainer and Dockerfile fixes
This commit is contained in:
62
.devcontainer/README.md
Normal file
62
.devcontainer/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# Dev Container Setup
|
||||
|
||||
This repository includes a Dev Container configuration that simplifies the development setup to just 3 steps:
|
||||
|
||||
## Quick Start
|
||||
|
||||

|
||||
|
||||
1. **Install Dev Containers extension** in VS Code
|
||||
2. **Clone and open in container**:
|
||||
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
|
||||
- Type "Dev Containers: Clone Repository in Container Volume..."
|
||||
- Paste the repository URL: `https://github.com/trycua/cua.git`
|
||||
3. **Hit play**: Once the container builds, you're ready to develop!
|
||||
|
||||
## What's Included
|
||||
|
||||
The dev container automatically:
|
||||
|
||||
- ✅ Sets up Python 3.11 environment
|
||||
- ✅ Installs all system dependencies (build tools, OpenGL, etc.)
|
||||
- ✅ Configures Python paths for all packages
|
||||
- ✅ Installs Python extensions (Black, Ruff, Pylance)
|
||||
- ✅ Forwards port 7860 for the Gradio web UI
|
||||
- ✅ Mounts your source code for live editing
|
||||
- ✅ Creates the required `.env.local` file
|
||||
|
||||
## Running Examples
|
||||
|
||||
After the container is built, you can run examples directly:
|
||||
|
||||
```bash
|
||||
# Run the agent UI (Gradio web interface)
|
||||
python examples/agent_ui_examples.py
|
||||
|
||||
# Run computer examples
|
||||
python examples/computer_examples.py
|
||||
|
||||
# Run computer UI examples
|
||||
python examples/computer_ui_examples.py
|
||||
```
|
||||
|
||||
The Gradio UI will be available at `http://localhost:7860` and will automatically forward to your host machine.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
You'll need to add your API keys to `.env.local`:
|
||||
|
||||
```bash
|
||||
# Required for Anthropic provider
|
||||
ANTHROPIC_API_KEY=your_anthropic_key_here
|
||||
|
||||
# Required for OpenAI provider
|
||||
OPENAI_API_KEY=your_openai_key_here
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The container connects to `host.docker.internal:7777` for Lume server communication
|
||||
- All Python packages are pre-installed and configured
|
||||
- Source code changes are reflected immediately (no rebuild needed)
|
||||
- The container uses the same Dockerfile as the regular Docker development environment
|
||||
50
.devcontainer/devcontainer.json
Normal file
50
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "C/ua - OSS",
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile"
|
||||
},
|
||||
"containerEnv": {
|
||||
"DISPLAY": "",
|
||||
"PYTHONPATH": "/app/libs/core:/app/libs/computer:/app/libs/agent:/app/libs/som:/app/libs/pylume:/app/libs/computer-server:/app/libs/mcp-server",
|
||||
"PYLUME_HOST": "host.docker.internal"
|
||||
},
|
||||
"forwardPorts": [7860],
|
||||
"portsAttributes": {
|
||||
"7860": {
|
||||
"label": "C/ua web client (Gradio)",
|
||||
"onAutoForward": "silent"
|
||||
}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"ms-python.black-formatter",
|
||||
"charliermarsh.ruff",
|
||||
"ms-python.vscode-pylance"
|
||||
],
|
||||
"settings": {
|
||||
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
||||
"python.terminal.activateEnvironment": false,
|
||||
"[python]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": "explicit"
|
||||
}
|
||||
},
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.ruffEnabled": true,
|
||||
"python.formatting.provider": "black",
|
||||
"files.watcherExclude": {
|
||||
"**/.venv/**": true,
|
||||
"**/node_modules/**": true,
|
||||
"**/__pycache__/**": true,
|
||||
"**/.pytest_cache/**": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// Automatically run post-install.sh after container is created
|
||||
"postCreateCommand": "/bin/bash .devcontainer/post-install.sh"
|
||||
}
|
||||
28
.devcontainer/post-install.sh
Normal file
28
.devcontainer/post-install.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
WORKSPACE="/workspaces/cua"
|
||||
|
||||
# Setup .env.local
|
||||
echo "PYTHON_BIN=python" > /workspaces/cua/.env.local
|
||||
|
||||
# Run /scripts/build.sh
|
||||
./scripts/build.sh
|
||||
|
||||
# ---
|
||||
# Build is complete. Show user a clear message to open the workspace manually.
|
||||
# ---
|
||||
|
||||
cat << 'EOM'
|
||||
|
||||
============================================
|
||||
🚀 Build complete!
|
||||
|
||||
👉 Next steps:
|
||||
|
||||
1. Open '.vscode/py.code-workspace'
|
||||
2. Press 'Open Workspace'
|
||||
|
||||
Happy coding!
|
||||
============================================
|
||||
|
||||
EOM
|
||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
* text=auto
|
||||
*.sh text eol=lf
|
||||
39
.vscode/launch.json
vendored
39
.vscode/launch.json
vendored
@@ -1,5 +1,31 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Agent UI",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/agent_ui_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Computer UI",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/computer_ui_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run Computer Examples",
|
||||
"type": "debugpy",
|
||||
@@ -26,19 +52,6 @@
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run Agent UI Examples",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/agent_ui_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run PyLume Examples",
|
||||
"type": "debugpy",
|
||||
|
||||
113
.vscode/py.code-workspace
vendored
113
.vscode/py.code-workspace
vendored
@@ -148,119 +148,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"launch": {
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Computer Examples",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/computer_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run Agent Examples",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/agent_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run PyLume Examples",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/pylume_examples.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SOM: Run Experiments (No OCR)",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/som_examples.py",
|
||||
"args": [
|
||||
"examples/test_data",
|
||||
"--output-dir", "examples/output",
|
||||
"--ocr", "none",
|
||||
"--mode", "experiment"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "SOM: Run Experiments (EasyOCR)",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "examples/som_examples.py",
|
||||
"args": [
|
||||
"examples/test_data",
|
||||
"--output-dir", "examples/output",
|
||||
"--ocr", "easyocr",
|
||||
"--mode", "experiment"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run Computer Server",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/libs/computer-server/run_server.py",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer:${workspaceFolder:cua-root}/libs/agent:${workspaceFolder:cua-root}/libs/som:${workspaceFolder:cua-root}/libs/pylume"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Run Computer Server with Args",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/libs/computer-server/run_server.py",
|
||||
"args": [
|
||||
"--host", "0.0.0.0",
|
||||
"--port", "8000",
|
||||
"--log-level", "debug"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"python": "${workspaceFolder:cua-root}/.venv/bin/python",
|
||||
"cwd": "${workspaceFolder:cua-root}",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder:cua-root}/libs/core:${workspaceFolder:cua-root}/libs/computer-server"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Run Computer Examples + Server",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM python:3.11-slim
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
@@ -21,6 +21,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
iputils-ping \
|
||||
net-tools \
|
||||
sed \
|
||||
xxd \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
45
README.md
45
README.md
@@ -54,48 +54,31 @@
|
||||
|
||||
|
||||
### Option 1: Fully-managed install (recommended)
|
||||
*I want to be totally guided in the process*
|
||||
*Guided install for quick use*
|
||||
|
||||
**macOS/Linux/Windows (via WSL):**
|
||||
```bash
|
||||
# Requires Python 3.11+
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/scripts/playground.sh)"
|
||||
```
|
||||
This script will guide you through setup and launch the Computer-Use Agent UI.
|
||||
|
||||
This script will:
|
||||
- Ask if you want to use local VMs or C/ua Cloud Containers
|
||||
- Install necessary dependencies (Lume CLI for local VMs)
|
||||
- Download VM images if needed
|
||||
- Install Python packages
|
||||
- Launch the Computer-Use Agent UI
|
||||
---
|
||||
|
||||
### Option 2: Key manual steps
|
||||
<details>
|
||||
<summary>If you are skeptical running one-install scripts</summary>
|
||||
### Option 2: [Dev Container](./.devcontainer/README.md)
|
||||
*Best for contributors and development*
|
||||
|
||||
**For C/ua Agent UI (any system, cloud VMs only):**
|
||||
```bash
|
||||
# Requires Python 3.11+ and C/ua API key
|
||||
pip install -U "cua-computer[all]" "cua-agent[all]"
|
||||
python -m agent.ui.gradio.app
|
||||
```
|
||||
This repository includes a [Dev Container](./.devcontainer/README.md) configuration that simplifies setup to a few steps:
|
||||
|
||||
**For Local macOS/Linux VMs (Apple Silicon only):**
|
||||
```bash
|
||||
# 1. Install Lume CLI
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"
|
||||
1. **Install Dev Containers extension** in VS Code
|
||||
2. **Clone and open in container:**
|
||||
- Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
|
||||
- Type `Dev Containers: Clone Repository in Container Volume...`
|
||||
- Paste the repository URL: `https://github.com/trycua/cua.git`
|
||||
- Open the `.vscode/py.code-workspace` workspace
|
||||
3. **Run the Agent UI example:** Click <img height="24" alt="image" src="https://github.com/user-attachments/assets/7a1b7111-f676-4d86-b7bf-ea337df90d5b" /> to start the Gradio UI
|
||||
|
||||
# 2. Pull macOS image
|
||||
lume pull macos-sequoia-cua:latest
|
||||
|
||||
# 3. Start VM
|
||||
lume run macos-sequoia-cua:latest
|
||||
|
||||
# 4. Install packages and launch UI
|
||||
pip install -U "cua-computer[all]" "cua-agent[all]"
|
||||
python -m agent.ui.gradio.app
|
||||
```
|
||||
</details>
|
||||
The Gradio UI will be available at `http://localhost:7860` and will automatically forward to your host machine.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -18,4 +18,8 @@ from agent.ui.gradio.app import create_gradio_ui
|
||||
if __name__ == "__main__":
|
||||
print("Launching Computer-Use Agent Gradio UI with advanced features...")
|
||||
app = create_gradio_ui()
|
||||
app.launch(share=False)
|
||||
app.launch(
|
||||
share=False,
|
||||
server_name="0.0.0.0",
|
||||
server_port=7860,
|
||||
)
|
||||
|
||||
@@ -18,7 +18,11 @@ from computer.ui.gradio.app import create_gradio_ui
|
||||
if __name__ == "__main__":
|
||||
print("Launching Computer Interface Gradio UI with advanced features...")
|
||||
app = create_gradio_ui()
|
||||
app.launch(share=False)
|
||||
app.launch(
|
||||
share=False,
|
||||
server_name="0.0.0.0",
|
||||
server_port=7860,
|
||||
)
|
||||
|
||||
# Optional: Using the saved dataset
|
||||
# import datasets
|
||||
|
||||
@@ -24,6 +24,24 @@ IMAGE_NAME="cua-dev-image"
|
||||
CONTAINER_NAME="cua-dev-container"
|
||||
PLATFORM="linux/arm64"
|
||||
|
||||
# Detect platform based on architecture
|
||||
arch=$(uname -m)
|
||||
|
||||
if [[ $arch == x86_64* ]]; then
|
||||
PLATFORM="linux/amd64"
|
||||
print_info "X64 Architecture detected, using platform: ${PLATFORM}"
|
||||
elif [[ $arch == i*86 ]]; then
|
||||
PLATFORM="linux/386"
|
||||
print_info "X32 Architecture detected, using platform: ${PLATFORM}"
|
||||
elif [[ $arch == arm* ]] || [[ $arch == aarch64 ]]; then
|
||||
PLATFORM="linux/arm64"
|
||||
print_info "ARM Architecture detected, using platform: ${PLATFORM}"
|
||||
else
|
||||
# Fallback to amd64 for unknown architectures
|
||||
PLATFORM="linux/amd64"
|
||||
print_info "Unknown architecture ($arch), defaulting to platform: ${PLATFORM}"
|
||||
fi
|
||||
|
||||
# Environment variables
|
||||
PYTHONPATH="/app/libs/core:/app/libs/computer:/app/libs/agent:/app/libs/som:/app/libs/pylume:/app/libs/computer-server"
|
||||
|
||||
@@ -56,6 +74,7 @@ case "$1" in
|
||||
-e PYTHONPATH=${PYTHONPATH} \
|
||||
-e DISPLAY=${DISPLAY:-:0} \
|
||||
-e PYLUME_HOST="host.docker.internal" \
|
||||
-p 7860:7860 \
|
||||
${IMAGE_NAME} bash
|
||||
else
|
||||
# Run the specified example
|
||||
@@ -73,6 +92,7 @@ case "$1" in
|
||||
-e PYTHONPATH=${PYTHONPATH} \
|
||||
-e DISPLAY=${DISPLAY:-:0} \
|
||||
-e PYLUME_HOST="host.docker.internal" \
|
||||
-p 7860:7860 \
|
||||
${IMAGE_NAME} python "/app/examples/$2"
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user