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.

fix cuabot publish 3 (#1003)

ddupont03d7c1c10514
diff --git a/.github/workflows/cd-ts-cuabot.yml b/.github/workflows/cd-ts-cuabot.yml
index 5f5b5d97be..5d227e1266 100644
--- a/.github/workflows/cd-ts-cuabot.yml
+++ b/.github/workflows/cd-ts-cuabot.yml
@@ -69,7 +69,7 @@ jobs:
release_name: "cuabot v${{ needs.prepare.outputs.version }}"
module_path: "libs/cuabot"
body: |
- ## Installation
+ ## Quick Start
```bash
npx cuabot
@@ -79,8 +79,24 @@ jobs:
```bash
npm install -g cuabot
+ cuabot
+ ```
+
+ ## Usage
+
+ ```bash
+ cuabot # Run default agent (or setup)
+ cuabot claude # Run Claude Code in sandbox
+ cuabot gemini # Run Gemini CLI in sandbox
+ cuabot codex # Run Codex CLI in sandbox
+ cuabot chromium # Open sandboxed Chromium
+
+ cuabot --screenshot # Take screenshot
+ cuabot --type "hello" # Type text
+ cuabot --click 100 200 # Click at coordinates
```
## Documentation
- See [cua.ai/docs/cuabot](https://cua.ai/docs/cuabot)
+ - [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+ - [Installation Guide](https://cua.ai/docs/cuabot/install)
diff --git a/libs/cuabot/Dockerfile b/libs/cuabot/Dockerfile
index 5bd027c496..2513aaf2b4 100644
--- a/libs/cuabot/Dockerfile
+++ b/libs/cuabot/Dockerfile
@@ -114,6 +114,9 @@ ENV AGENT_BROWSER_HEADED=1
COPY --chown=user:user src/prompts/.mcp.json /home/user/.mcp.json
COPY --chown=user:user src/prompts/SYSTEM.md /home/user/CLAUDE.md
+# Copy MCP server files
+COPY --chown=user:user src/mcp /home/user/.cuabot/mcp
+
EXPOSE 10000
USER user
diff --git a/libs/cuabot/README.md b/libs/cuabot/README.md
index e1a9533ff6..ac9e765a16 100644
--- a/libs/cuabot/README.md
+++ b/libs/cuabot/README.md
@@ -2,7 +2,7 @@
Co-op computer-use for any agent.
-Multi-user computing sandbox that gives any coding agent (Claude, Gemini, Codex, OpenClaw, Vibe) seamless computer-use capabilities.
+Multi-user computing sandbox that gives any coding agent (Claude Code, Gemini CLI, Codex, OpenClaw, Vibe) seamless computer-use capabilities.
## Quick Start
@@ -10,9 +10,27 @@ Multi-user computing sandbox that gives any coding agent (Claude, Gemini, Codex,
npx cuabot
```
-## Documentation
+## Usage
+
+```bash
+cuabot # Run default agent (or setup if not configured)
+cuabot claude # Run Claude Code in the sandbox
+cuabot gemini # Run Gemini CLI in the sandbox
+cuabot codex # Run Codex CLI in the sandbox
+cuabot chromium # Open sandboxed Chromium window
+
+cuabot --screenshot # Take screenshot
+cuabot --type "hello" # Type text
+cuabot --click 100 200 # Click at coordinates
+```
+
+## Requirements
-See the [CuaBot documentation](https://cua.ai/docs/cuabot) for:
+- [Node.js](https://nodejs.org/) v18+
+- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
+- [Xpra client](https://github.com/Xpra-org/xpra/wiki/Download)
+
+## Documentation
-- [Installation Guide](https://cua.ai/docs/cuabot/guide/getting-started/installation)
-- [Commands Reference](https://cua.ai/docs/cuabot/reference/commands)
+- [Getting Started](https://cua.ai/docs/cuabot/cuabot)
+- [Installation Guide](https://cua.ai/docs/cuabot/install)
diff --git a/libs/cuabot/src/cuabot.tsx b/libs/cuabot/src/cuabot.tsx
index db3af52420..7ea54d4ec2 100644
--- a/libs/cuabot/src/cuabot.tsx
+++ b/libs/cuabot/src/cuabot.tsx
@@ -5,9 +5,19 @@
import { startServer, stopServer, getServerInfo, setSessionName as setServerSessionName } from "./cuabotd.js";
import { ensureServerRunning, setSessionName as setClientSessionName } from "./client.js";
-import { getDefaultAgent, AGENTS, AgentId } from "./settings.js";
+import { getDefaultAgent, AGENTS, AgentId, getAliasIgnored } from "./settings.js";
import { runOnboarding } from "./onboarding.js";
import { log_cli_invocation } from "./telemetry.js";
+import { execSync } from "child_process";
+
+function isCuabotInPath(): boolean {
+ try {
+ execSync("which cuabot", { stdio: "ignore" });
+ return true;
+ } catch {
+ return false;
+ }
+}
const args = process.argv.slice(2);
@@ -357,19 +367,23 @@ Commands:
// No args: run default agent or onboarding
if (remainingArgs.length === 0) {
const defaultAgent = getDefaultAgent();
- if (defaultAgent) {
- try {
- await runAgent(defaultAgent);
- } catch (err) {
- // If dependencies fail, show onboarding
- if (err instanceof Error && err.message.includes("Missing dependencies")) {
- runOnboarding();
- return;
- }
- throw err;
- }
- } else {
+ const needsAliasSetup = !isCuabotInPath() && !getAliasIgnored();
+
+ // Show onboarding if no default agent or alias needs setup
+ if (!defaultAgent || needsAliasSetup) {
runOnboarding();
+ return;
+ }
+
+ try {
+ await runAgent(defaultAgent);
+ } catch (err) {
+ // If dependencies fail, show onboarding
+ if (err instanceof Error && err.message.includes("Missing dependencies")) {
+ runOnboarding();
+ return;
+ }
+ throw err;
}
return;
}
diff --git a/libs/cuabot/src/cuabotd.ts b/libs/cuabot/src/cuabotd.ts
index 999ddb7539..9cd70fc648 100644
--- a/libs/cuabot/src/cuabotd.ts
+++ b/libs/cuabot/src/cuabotd.ts
@@ -12,18 +12,15 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeF
import { openWindows } from "get-windows";
import { createServer, IncomingMessage, ServerResponse } from "http";
import { homedir } from "os";
-import { dirname, join } from "path";
+import { join } from "path";
import { Browser, BrowserContext, chromium, Page } from "playwright";
import sharp from "sharp";
-import { fileURLToPath } from "url";
import { promisify } from "util";
import { WebSocket, WebSocketServer } from "ws";
import { getTelemetryEnabled } from "./settings.js";
import { log_event, startHistoryPolling, stopHistoryPolling, TelemetryEvent } from "./telemetry.js";
import { getXpraAttachArgs, getXpraBinPath, nameToColor } from "./utils.js";
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = dirname(__filename);
const execAsync = promisify(exec);
@@ -154,39 +151,30 @@ async function ensureImage(): Promise<void> {
await execAsync(`docker image inspect ${IMAGE_NAME}`);
console.log(`[server] Image ${IMAGE_NAME} already exists`);
} catch {
- console.log(`[server] Building ${IMAGE_NAME}...`);
- console.log(`[server] This may take 10-20 minutes on first build. Progress will be shown below:`);
- const buildProcess = exec(`docker build -t ${IMAGE_NAME} .`, {
- cwd: join(__dirname, ".."),
- });
+ console.log(`[server] Pulling ${IMAGE_NAME}...`);
+ const pullProcess = exec(`docker pull ${IMAGE_NAME}`);
- buildProcess.stdout?.on("data", (data: Buffer) => {
+ pullProcess.stdout?.on("data", (data: Buffer) => {
const lines = data.toString().split("\n").filter(l => l.trim());
for (const line of lines) {
- // Show progress lines (step numbers, downloading, etc.)
- if (line.includes("Step ") || line.includes("Downloading") || line.includes("Installing") || line.includes("RUN")) {
- console.log(`[build] ${line}`);
- }
+ console.log(`[pull] ${line}`);
}
});
- buildProcess.stderr?.on("data", (data: Buffer) => {
+ pullProcess.stderr?.on("data", (data: Buffer) => {
const lines = data.toString().split("\n").filter(l => l.trim());
for (const line of lines) {
- // Show important error/warning lines
- if (!line.includes("WARNING") || line.includes("ERROR")) {
- console.error(`[build] ${line}`);
- }
+ console.error(`[pull] ${line}`);
}
});
await new Promise<void>((resolve, reject) => {
- buildProcess.on("exit", (code) => {
+ pullProcess.on("exit", (code) => {
if (code === 0) {
- console.log(`[server] Build completed successfully!`);
+ console.log(`[server] Pull completed successfully!`);
resolve();
} else {
- reject(new Error(`Docker build failed with exit code ${code}`));
+ reject(new Error(`Docker pull failed with exit code ${code}`));
}
});
});
@@ -217,7 +205,6 @@ async function ensureContainer(): Promise<number> {
// Convert Windows path to Docker-compatible path for volume mount
const toDockerPath = (p: string) => p.replace(/\\/g, "/").replace(/^([A-Z]):/, (_, letter) => `/${letter.toLowerCase()}`);
const claudeConfigPath = toDockerPath(CLAUDE_CONFIG_DIR);
- const mcpPath = toDockerPath(join(__dirname, "mcp"));
const telemetryEnabled = getTelemetryEnabled();
const cuabotName = sessionName || "cuabot";
@@ -234,7 +221,6 @@ async function ensureContainer(): Promise<number> {
"-e", `CUABOT_COLOR=${cuabotColor}`,
"--add-host=host.docker.internal:host-gateway",
"-v", `${claudeConfigPath}:/home/user/.claude`,
- "-v", `${mcpPath}:/home/user/.cuabot/mcp`,
IMAGE_NAME,
"xpra", "start", ":100", "--bind-tcp=0.0.0.0:10000", "--no-daemon", "--html=on",
];
diff --git a/libs/cuabot/src/onboarding.tsx b/libs/cuabot/src/onboarding.tsx
index cdf878c115..9a1f1a6cd0 100644
--- a/libs/cuabot/src/onboarding.tsx
+++ b/libs/cuabot/src/onboarding.tsx
@@ -6,8 +6,12 @@
import React, { useState, useEffect } from "react";
import { render, Box, Text, useInput, useApp } from "ink";
import { checkDocker, checkXpra, checkPlaywright } from "./utils.js";
-import { AGENTS, AgentId, getDefaultAgent, setDefaultAgent, setTelemetryEnabled, loadSettings } from "./settings.js";
-import { exec } from "child_process";
+import { AGENTS, AgentId, getDefaultAgent, setDefaultAgent, setTelemetryEnabled, loadSettings, getAliasIgnored, setAliasIgnored } from "./settings.js";
+import { log_telemetry_onboard } from "./telemetry.js";
+import { exec, execSync } from "child_process";
+import { homedir } from "os";
+import { appendFileSync, existsSync, readFileSync } from "fs";
+import { join } from "path";
type CheckStatus = "ok" | "error" | "loading";
@@ -17,6 +21,47 @@ interface Check {
message: string;
}
+function checkCuabotInPath(): boolean {
+ try {
+ execSync("which cuabot", { stdio: "ignore" });
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+function getShellRcFile(): string | null {
+ const shell = process.env.SHELL || "";
+ if (shell.includes("zsh")) return join(homedir(), ".zshrc");
+ if (shell.includes("bash")) {
+ // macOS uses .bash_profile, Linux uses .bashrc
+ const bashProfile = join(homedir(), ".bash_profile");
+ if (process.platform === "darwin" && existsSync(bashProfile)) return bashProfile;
+ return join(homedir(), ".bashrc");
+ }
+ return null;
+}
+
+function addAliasToShell(): boolean {
+ const rcFile = getShellRcFile();
+ if (!rcFile) return false;
+ try {
+ // Check if alias already exists
+ if (existsSync(rcFile)) {
+ const content = readFileSync(rcFile, "utf-8");
+ if (content.includes('alias cuabot=')) {
+ setAliasIgnored(true);
+ return true;
+ }
+ }
+ appendFileSync(rcFile, '\n# cuabot alias\nalias cuabot="npx cuabot"\n');
+ setAliasIgnored(true);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
function StatusLine({ check }: { check: Check }) {
const icon = check.status === "ok" ? "✓" : check.status === "error" ? "✗" : "○";
const color = check.status === "ok" ? "green" : check.status === "error" ? "red" : "gray";
@@ -129,6 +174,7 @@ function Onboarding() {
const { exit } = useApp();
const [checks, setChecks] = useState<Check[]>([
{ label: "Default Agent", status: "loading", message: "checking..." },
+ { label: "cuabot Command", status: "loading", message: "checking..." },
{ label: "Docker", status: "loading", message: "checking..." },
{ label: "Xpra Client", status: "loading", message: "checking..." },
{ label: "Playwright", status: "loading", message: "checking..." },
@@ -152,6 +198,15 @@ function Onboarding() {
message: defaultAgent ? `${AGENTS[defaultAgent as AgentId]?.name || defaultAgent}` : "not configured",
});
+ // Check cuabot command availability
+ const cuabotInPath = checkCuabotInPath();
+ const aliasIgnored = getAliasIgnored();
+ newChecks.push({
+ label: "cuabot Command",
+ status: cuabotInPath || aliasIgnored ? "ok" : "error",
+ message: cuabotInPath ? "ready" : aliasIgnored ? "using npx" : "not set up",
+ });
+
// Check Docker
const docker = await checkDocker();
newChecks.push({
@@ -268,6 +323,10 @@ function Onboarding() {
<TelemetrySelector
onSelect={(enabled) => {
setTelemetryEnabled(enabled);
+ if (enabled) {
+ // Log telemetry onboard event with default agent
+ log_telemetry_onboard(getDefaultAgent());
+ }
setShowTelemetrySelector(false);
runChecks();
}}
@@ -343,6 +402,21 @@ function Onboarding() {
onSelect={() => {}}
/>
)}
+
+ {firstError === "cuabot Command" && (
+ <OptionSelector
+ options={[
+ { label: `Set up 'cuabot' command`, action: () => {
+ if (addAliasToShell()) {
+ console.log("\n✓ Added! Restart your terminal or run: source " + getShellRcFile() + "\n");
+ }
+ runChecks();
+ }},
+ { label: "Skip (use 'npx cuabot' instead)", action: () => { setAliasIgnored(true); runChecks(); } },
+ ]}
+ onSelect={() => {}}
+ />
+ )}
</Box>
);
}
diff --git a/libs/cuabot/src/settings.ts b/libs/cuabot/src/settings.ts
index 20bee19d08..03ae2b7965 100644
--- a/libs/cuabot/src/settings.ts
+++ b/libs/cuabot/src/settings.ts
@@ -12,6 +12,7 @@ const SETTINGS_FILE = join(CONFIG_DIR, "settings.json");
export interface Settings {
defaultAgent?: string;
telemetryEnabled?: boolean;
+ aliasIgnored?: boolean;
}
export const AGENTS = {
@@ -104,3 +105,13 @@ export function setTelemetryEnabled(enabled: boolean): void {
settings.telemetryEnabled = enabled;
saveSettings(settings);
}
+
+export function getAliasIgnored(): boolean {
+ return loadSettings().aliasIgnored === true;
+}
+
+export function setAliasIgnored(ignored: boolean): void {
+ const settings = loadSettings();
+ settings.aliasIgnored = ignored;
+ saveSettings(settings);
+}
diff --git a/libs/cuabot/src/telemetry.ts b/libs/cuabot/src/telemetry.ts
index 6f2036f917..e0c87b0d68 100644
--- a/libs/cuabot/src/telemetry.ts
+++ b/libs/cuabot/src/telemetry.ts
@@ -15,7 +15,7 @@ const __dirname = dirname(__filename);
const TELEMETRY_LOG_PATH = join(__dirname, "..", "telemetry.log");
export interface TelemetryEvent {
- type: "mcp_tool_call" | "prompt_change" | "cli_invocation";
+ type: "mcp_tool_call" | "prompt_change" | "cli_invocation" | "telemetry_onboard";
timestamp: number;
// MCP tool call fields
tool_name?: string;
@@ -27,6 +27,8 @@ export interface TelemetryEvent {
// CLI invocation fields
cli_args?: string[];
cwd?: string;
+ // Telemetry onboard fields
+ default_agent?: string;
}
/**
@@ -68,6 +70,19 @@ export function log_cli_invocation(args: string[]): void {
});
}
+/**
+ * Log telemetry onboarding (when user opts in)
+ */
+export function log_telemetry_onboard(default_agent: string | undefined): void {
+ // Note: We log this even though telemetry was just enabled
+ // This is the first event after opting in
+ log_event({
+ type: "telemetry_onboard",
+ timestamp: Date.now(),
+ default_agent,
+ });
+}
+
// History scraper state
let lastPrompt: string | null = null;
let historyPollingInterval: ReturnType<typeof setInterval> | null = null;