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 auto-update for cua-computer-server and cua-agent on startup (#942)

Harsh Vermab3c0e6dc1ac2
diff --git a/libs/kasm/Dockerfile b/libs/kasm/Dockerfile
index 3aae33fb1a..b4789c206c 100644
--- a/libs/kasm/Dockerfile
+++ b/libs/kasm/Dockerfile
@@ -31,24 +31,10 @@ RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
# Install pip for Python 3.12
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
-# Install UV package manager
-RUN python3.12 -m pip install uv
-
-# Install cua-computer-server
-RUN uv pip install --system cua-computer-server
-
-# Install playwright and Firefox dependencies
-RUN uv pip install --system playwright && \
- python3.12 -m playwright install --with-deps firefox
-
# Disable SSL requirement
RUN sed -i 's/require_ssl: true/require_ssl: false/g' /usr/share/kasmvnc/kasmvnc_defaults.yaml
RUN sed -i 's/-sslOnly//g' /dockerstartup/vnc_startup.sh
-# Running the python script on startup
-RUN echo "/usr/bin/python3 -m computer_server" > $STARTUPDIR/custom_startup.sh \
- && chmod +x $STARTUPDIR/custom_startup.sh
-
# Enable sudo support for kasm-user
RUN echo "kasm-user:password" | chpasswd
RUN usermod -aG sudo kasm-user
@@ -62,4 +48,24 @@ ENV HOME=/home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
+# Install UV package manager
+RUN python3.12 -m pip install uv
+
+# Install cua-computer-server and cua-agent
+RUN uv pip install --system cua-computer-server "cua-agent[all]"
+
+# Install playwright and Firefox dependencies
+RUN uv pip install --system playwright && \
+ python3.12 -m playwright install --with-deps firefox
+
+# Clean up uv cache to avoid issues and reduce size
+RUN rm -rf /home/kasm-user/.cache/uv /root/.cache/uv
+
+# Fix ownership of remaining cache files
+RUN chown -R 1000:0 /home/kasm-user/.cache 2>/dev/null || true
+
+# Running the python script on startup
+RUN echo -e "#!/bin/bash\nsudo uv pip install --upgrade --system cua-computer-server \"cua-agent[all]\"\n/usr/bin/python3 -m computer_server" > $STARTUPDIR/custom_startup.sh \
+ && chmod +x $STARTUPDIR/custom_startup.sh
+
USER 1000
\ No newline at end of file
diff --git a/libs/qemu-docker/android/Dockerfile b/libs/qemu-docker/android/Dockerfile
index 6b15834d87..9621198f24 100644
--- a/libs/qemu-docker/android/Dockerfile
+++ b/libs/qemu-docker/android/Dockerfile
@@ -65,10 +65,10 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
update-alternatives --set python3 /usr/bin/python3.12
-# Create UV project for cua-computer-server
+# Create UV project for cua-computer-server and cua-agent
RUN mkdir -p /opt/cua-server && \
uv init --vcs none --no-readme --no-workspace --no-pin-python /opt/cua-server && \
- uv add --directory /opt/cua-server cua-computer-server
+ uv add --directory /opt/cua-server cua-computer-server "cua-agent[all]"
COPY src/entry.sh /usr/local/bin/entry.sh
RUN chmod +x /usr/local/bin/entry.sh
diff --git a/libs/qemu-docker/android/src/entry.sh b/libs/qemu-docker/android/src/entry.sh
index 7282707a1a..f214c30832 100644
--- a/libs/qemu-docker/android/src/entry.sh
+++ b/libs/qemu-docker/android/src/entry.sh
@@ -81,5 +81,8 @@ else
fi
fi
+info "Updating cua-computer-server and cua-agent..."
+uv add --directory /opt/cua-server cua-computer-server "cua-agent[all]"
+
info "Starting Computer Server..."
DISPLAY= uv run --directory /opt/cua-server python -m computer_server --host 0.0.0.0 --port 8000 --log-level info
diff --git a/libs/qemu-docker/linux/src/vm/setup/setup-cua-server.sh b/libs/qemu-docker/linux/src/vm/setup/setup-cua-server.sh
index 31fb80a8bd..84bcd0a528 100644
--- a/libs/qemu-docker/linux/src/vm/setup/setup-cua-server.sh
+++ b/libs/qemu-docker/linux/src/vm/setup/setup-cua-server.sh
@@ -104,9 +104,9 @@ else
fi
# Install packages using UV as the service user
-log "Installing cua-computer-server..."
-sudo -u "$USER_NAME" uv add --directory "$PROJECT_DIR" cua-computer-server "Pillow>=9.2.0"
-log "cua-computer-server installed successfully"
+log "Installing cua-computer-server and cua-agent..."
+sudo -u "$USER_NAME" uv add --directory "$PROJECT_DIR" cua-computer-server "cua-agent[all]" "Pillow>=9.2.0"
+log "cua-computer-server and cua-agent installed successfully"
log "Installing playwright & firefox browser..."
sudo -u "$USER_NAME" uv add --directory "$PROJECT_DIR" playwright
@@ -132,8 +132,8 @@ PROJECT_DIR="/opt/cua-server"
LOG_FILE="$PROJECT_DIR/server.log"
start_server() {
- echo "$(date '+%Y-%m-%d %H:%M:%S') Updating cua-computer-server..." >> "$LOG_FILE"
- uv add --directory "$PROJECT_DIR" cua-computer-server >> "$LOG_FILE" 2>&1
+ echo "$(date '+%Y-%m-%d %H:%M:%S') Updating cua-computer-server and cua-agent..." >> "$LOG_FILE"
+ uv add --directory "$PROJECT_DIR" cua-computer-server "cua-agent[all]" >> "$LOG_FILE" 2>&1
echo "$(date '+%Y-%m-%d %H:%M:%S') Starting Cua Computer Server on port 5000..." >> "$LOG_FILE"
uv run --directory "$PROJECT_DIR" python -m computer_server --port 5000 >> "$LOG_FILE" 2>&1
diff --git a/libs/qemu-docker/windows/src/vm/setup/setup-cua-server.ps1 b/libs/qemu-docker/windows/src/vm/setup/setup-cua-server.ps1
index f5a9c8dcda..5fb145cab9 100644
--- a/libs/qemu-docker/windows/src/vm/setup/setup-cua-server.ps1
+++ b/libs/qemu-docker/windows/src/vm/setup/setup-cua-server.ps1
@@ -92,10 +92,10 @@ if (Test-Path -LiteralPath $ProjectFile) {
}
}
-Write-Log -LogFile $script:LogFile -Message "Installing cua-computer-server"
+Write-Log -LogFile $script:LogFile -Message "Installing cua-computer-server and cua-agent"
try {
- & uv add --directory $ProjectDir cua-computer-server 2>&1 | Tee-Object -FilePath $script:LogFile -Append | Out-Null
- Write-Log -LogFile $script:LogFile -Message "cua-computer-server installed successfully"
+ & uv add --directory $ProjectDir cua-computer-server "cua-agent[all]" 2>&1 | Tee-Object -FilePath $script:LogFile -Append | Out-Null
+ Write-Log -LogFile $script:LogFile -Message "cua-computer-server and cua-agent installed successfully"
} catch {
Write-Log -LogFile $script:LogFile -Message "Server install error: $($_.Exception.Message)"
throw
@@ -137,8 +137,8 @@ if (Test-Path `$uvPath) {
`$LogFile = Join-Path `$ProjectDir 'server.log'
function Start-Server {
- Write-Output "Updating cua-computer-server..." | Out-File -FilePath `$LogFile -Append
- & uv add --directory `$ProjectDir cua-computer-server 2>&1 | Out-File -FilePath `$LogFile -Append
+ Write-Output "Updating cua-computer-server and cua-agent..." | Out-File -FilePath `$LogFile -Append
+ & uv add --directory `$ProjectDir cua-computer-server "cua-agent[all]" 2>&1 | Out-File -FilePath `$LogFile -Append
Write-Output "Starting Cua Computer Server on port 5000..." | Out-File -FilePath `$LogFile -Append
& uv run --directory `$ProjectDir python -m computer_server --port 5000 2>&1 | Out-File -FilePath `$LogFile -Append
diff --git a/libs/xfce/Dockerfile b/libs/xfce/Dockerfile
index d7cb62ee96..9809ebd693 100644
--- a/libs/xfce/Dockerfile
+++ b/libs/xfce/Dockerfile
@@ -123,8 +123,8 @@ RUN git clone https://github.com/trycua/noVNC.git /opt/noVNC && \
RUN mkdir -p /home/cua/.cache && \
chown -R cua:cua /home/cua/.cache
-# Install computer-server
-RUN uv pip install --system cua-computer-server
+# Install computer-server and cua-agent
+RUN uv pip install --system cua-computer-server "cua-agent[all]"
# Install GTK and WebKit dependencies for pywebview
RUN apt-get update && apt-get install -y \
diff --git a/libs/xfce/src/scripts/start-computer-server.sh b/libs/xfce/src/scripts/start-computer-server.sh
index e00a795d3f..ece0748ae6 100644
--- a/libs/xfce/src/scripts/start-computer-server.sh
+++ b/libs/xfce/src/scripts/start-computer-server.sh
@@ -8,6 +8,10 @@ while ! xdpyinfo -display :1 >/dev/null 2>&1; do
done
echo "X server is ready"
+# Update cua-computer-server and cua-agent
+echo "Updating cua-computer-server and cua-agent..."
+sudo uv pip install --upgrade --system cua-computer-server "cua-agent[all]"
+
# Start computer-server
export DISPLAY=:1
python3.12 -m computer_server --port ${API_PORT:-8000}