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 Docker image pull to cuabot onboarding (#1016)

Francesco Bonacci64ffd52c7949
diff --git a/libs/cuabot/src/cuabot.tsx b/libs/cuabot/src/cuabot.tsx
index 34192ee9f8..0de203781b 100644
--- a/libs/cuabot/src/cuabot.tsx
+++ b/libs/cuabot/src/cuabot.tsx
@@ -8,6 +8,7 @@ import { ensureServerRunning, setSessionName as setClientSessionName } from "./c
import { getDefaultAgent, AGENTS, AgentId, getAliasIgnored, getTelemetryEnabled } from "./settings.js";
import { runOnboarding } from "./onboarding.js";
import { sendTelemetryToServer } from "./telemetry.js";
+import { checkDependencies } from "./utils.js";
import { execSync } from "child_process";
import { existsSync, readFileSync } from "fs";
import { homedir } from "os";
@@ -488,8 +489,11 @@ Commands:
const defaultAgent = getDefaultAgent();
const needsAliasSetup = !isCuabotInPath() && !getAliasIgnored();
- // Show onboarding if no default agent or alias needs setup
- if (!defaultAgent || needsAliasSetup) {
+ // Check if critical dependencies are missing
+ const deps = await checkDependencies();
+
+ // Show onboarding if no default agent, alias needs setup, or dependencies missing
+ if (!defaultAgent || needsAliasSetup || !deps.ok) {
runOnboarding();
return;
}
diff --git a/libs/cuabot/src/onboarding.tsx b/libs/cuabot/src/onboarding.tsx
index aff96f76c8..bba1f440d7 100644
--- a/libs/cuabot/src/onboarding.tsx
+++ b/libs/cuabot/src/onboarding.tsx
@@ -5,7 +5,7 @@
import React, { useState, useEffect } from "react";
import { render, Box, Text, useInput, useApp } from "ink";
-import { checkDocker, checkXpra, checkPlaywright } from "./utils.js";
+import { checkDocker, checkXpra, checkPlaywright, checkDockerImage, pullDockerImage } from "./utils.js";
import { AGENTS, AgentId, getDefaultAgent, setDefaultAgent, setTelemetryEnabled, loadSettings, getAliasIgnored, setAliasIgnored } from "./settings.js";
import { exec, execSync } from "child_process";
import { homedir } from "os";
@@ -236,10 +236,13 @@ function Onboarding() {
{ label: "Default Agent", status: "loading", message: "checking..." },
{ label: "cuabot Command", status: "loading", message: "checking..." },
{ label: "Docker", status: "loading", message: "checking..." },
+ { label: "Docker Image", status: "loading", message: "checking..." },
{ label: "Xpra Client", status: "loading", message: "checking..." },
{ label: "Playwright", status: "loading", message: "checking..." },
{ label: "Usage Telemetry", status: "loading", message: "checking..." },
]);
+ const [pullingImage, setPullingImage] = useState(false);
+ const [pullProgress, setPullProgress] = useState("");
const [loading, setLoading] = useState(true);
const [showAgentSelector, setShowAgentSelector] = useState(false);
const [showTelemetrySelector, setShowTelemetrySelector] = useState(false);
@@ -275,6 +278,22 @@ function Onboarding() {
message: docker.ok ? "running" : "not found",
});
+ // Check Docker Image (only if Docker is running)
+ if (docker.ok) {
+ const dockerImage = await checkDockerImage();
+ newChecks.push({
+ label: "Docker Image",
+ status: dockerImage.ok ? "ok" : "error",
+ message: dockerImage.message,
+ });
+ } else {
+ newChecks.push({
+ label: "Docker Image",
+ status: "error",
+ message: "requires Docker",
+ });
+ }
+
// Check Xpra
const xpra = await checkXpra();
setXpraQuarantined(xpra.quarantined || false);
@@ -428,6 +447,29 @@ function Onboarding() {
/>
)}
+ {firstError === "Docker Image" && !pullingImage && (
+ <OptionSelector
+ options={[
+ { label: "Pull Docker image (~2GB)", action: async () => {
+ setPullingImage(true);
+ setPullProgress("Starting pull...");
+ await pullDockerImage((line) => setPullProgress(line));
+ setPullingImage(false);
+ runChecks();
+ }},
+ { label: "Check Again", action: () => runChecks() },
+ ]}
+ onSelect={() => {}}
+ />
+ )}
+
+ {firstError === "Docker Image" && pullingImage && (
+ <Box flexDirection="column" marginTop={1}>
+ <Text color="cyan">Pulling Docker image...</Text>
+ <Text dimColor>{pullProgress}</Text>
+ </Box>
+ )}
+
{firstError === "Xpra Client" && !xpraQuarantined && (
<OptionSelector
options={[
@@ -441,7 +483,7 @@ function Onboarding() {
{firstError === "Xpra Client" && xpraQuarantined && (
<OptionSelector
options={[
- { label: "Exit and copy command: \x1b[2msudo xattr -rd com.apple.quarantine /Applications/Xpra.app\x1b[0m", action: () => { copyToClipboard("sudo xattr -rd com.apple.quarantine /Applications/Xpra.app"); exit(); } },
+ { label: "Exit and copy command: \x1b[2msudo xattr -c /Applications/Xpra.app\x1b[0m", action: () => { copyToClipboard("sudo xattr -c /Applications/Xpra.app"); exit(); } },
{ label: "Read why", action: () => openUrl("https://github.com/Xpra-org/xpra/wiki/Download#-macos") },
{ label: "Exit", action: () => exit() },
]}
diff --git a/libs/cuabot/src/utils.ts b/libs/cuabot/src/utils.ts
index 4388124856..a8e0be5f67 100644
--- a/libs/cuabot/src/utils.ts
+++ b/libs/cuabot/src/utils.ts
@@ -158,7 +158,7 @@ export async function checkXpra(): Promise<{ ok: boolean; message: string; quara
try {
const { stdout } = await execAsync("xattr /Applications/Xpra.app");
if (stdout.includes("com.apple.quarantine")) {
- return { ok: false, message: `Xpra is installed but quarantined. Run: xattr -d com.apple.quarantine /Applications/Xpra.app`, quarantined: true };
+ return { ok: false, message: `Xpra is installed but quarantined. Run: sudo xattr -c /Applications/Xpra.app`, quarantined: true };
}
} catch {
// xattr command failed, ignore
@@ -198,15 +198,65 @@ export async function checkPlaywright(): Promise<{ ok: boolean; message: string
}
}
+const DOCKER_IMAGE = "trycua/cuabot:latest";
+
+/**
+ * Check if Docker image exists locally
+ */
+export async function checkDockerImage(): Promise<{ ok: boolean; message: string }> {
+ try {
+ await execAsync(`docker image inspect ${DOCKER_IMAGE}`);
+ return { ok: true, message: "cached" };
+ } catch {
+ return { ok: false, message: "not pulled" };
+ }
+}
+
+/**
+ * Pull the Docker image with progress callback
+ */
+export async function pullDockerImage(onProgress?: (line: string) => void): Promise<{ ok: boolean; message: string }> {
+ return new Promise((resolve) => {
+ const pullProcess = exec(`docker pull ${DOCKER_IMAGE}`);
+
+ pullProcess.stdout?.on("data", (data: Buffer) => {
+ const lines = data.toString().split("\n").filter(l => l.trim());
+ for (const line of lines) {
+ onProgress?.(line);
+ }
+ });
+
+ pullProcess.stderr?.on("data", (data: Buffer) => {
+ const lines = data.toString().split("\n").filter(l => l.trim());
+ for (const line of lines) {
+ onProgress?.(line);
+ }
+ });
+
+ pullProcess.on("exit", (code) => {
+ if (code === 0) {
+ resolve({ ok: true, message: "pulled" });
+ } else {
+ resolve({ ok: false, message: "pull failed" });
+ }
+ });
+
+ pullProcess.on("error", () => {
+ resolve({ ok: false, message: "pull failed" });
+ });
+ });
+}
+
/**
* Check all dependencies required for cuabot to run
*/
export async function checkDependencies(): Promise<{ ok: boolean; errors: string[] }> {
const errors: string[] = [];
- const [dockerCheck, xpraCheck] = await Promise.all([
+ const [dockerCheck, xpraCheck, playwrightCheck] = await Promise.all([
checkDocker(),
checkXpra(),
+ checkPlaywright(),
]);
if (!dockerCheck.ok) {
@@ -217,5 +267,17 @@ export async function checkDependencies(): Promise<{ ok: boolean; errors: string
errors.push(xpraCheck.message);
}
+ if (!playwrightCheck.ok) {
+ errors.push("Playwright Chromium not installed. Run: npx playwright install chromium");
+ }
+
+ // Only check Docker image if Docker is running
+ if (dockerCheck.ok) {
+ const dockerImageCheck = await checkDockerImage();
+ if (!dockerImageCheck.ok) {
+ errors.push("Docker image not pulled. Run: docker pull trycua/cuabot:latest");
+ }
+ }
+
return { ok: errors.length === 0, errors };
}