Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(images): the slim Linux image carries the cua CLI and a spawn-capable cua-spacesd; drop agent-home (#6515)
dduponta1d98e8ba051
diff --git a/.github/workflows/cd-image-linux.yml b/.github/workflows/cd-image-linux.ymlindex 88d72d23a9..46ec3f77a3 100644--- a/.github/workflows/cd-image-linux.yml+++ b/.github/workflows/cd-image-linux.yml@@ -43,7 +43,8 @@ name: "CD: Image linux"# Tiers: every step above runs once per tier, each tier gated on its own# (`cua images build --target <tier>` of the one Dockerfile; full is FROM slim,# so the registry shares slim's layers):-# slim series 24.04-slim ghcr.io/trycua/linux:24.04-slim[-disk] CI and bench use it+# slim series 24.04-slim ghcr.io/trycua/linux:24.04-slim[-disk] CI and bench use it; the+# home of an agent that makes child Spaces (it carries the cua CLI)# full series 24.04 ghcr.io/trycua/linux:24.04[-disk] the default# docker series 24.04-docker ghcr.io/trycua/linux:24.04-docker-disk slim + the Docker# engine, a VM tier; its own gate (docker/<arch>/qemu: dockerd up at@@ -311,6 +312,10 @@ jobs:chmod +x "$RUNNER_TEMP/bin/cua"echo "$RUNNER_TEMP/bin" >>"$GITHUB_PATH"scripts/images/install-release-tools.sh --free-disk+ # The slim tier bakes this commit's cua CLI (built by the cli job above) into the image,+ # so an agent in a Space can run `cua spaces create`; every tier is FROM slim.+ - name: Stage the cua CLI for the image+ run: CUA_CLI_BIN="$RUNNER_TEMP/bin/cua" libs/images/linux/build-cua-cli-linux.sh "$ARCH"- name: cua images release (build, gates, stage)run: |# prepare only builds cua-spacesd from source: skip it unless thediff --git a/docs/content/docs/spaces/concepts/runtime-conformance.mdx b/docs/content/docs/spaces/concepts/runtime-conformance.mdxindex 213e438ad9..c81d33868f 100644--- a/docs/content/docs/spaces/concepts/runtime-conformance.mdx+++ b/docs/content/docs/spaces/concepts/runtime-conformance.mdx@@ -123,8 +123,8 @@ CUA=/path/to/cua libs/cua/scripts/conformance/run.py --entry vz-microvm --out re```The children case needs the `cua` CLI in the guest. When the Space under-test does not ship it, the run makes a home Space from the `agent-home` image-(the slim Linux image plus the CLI) on the same runtime and runs the case+test does not ship it, the run makes a home Space from the slim Linux image+(`ghcr.io/trycua/linux:24.04-slim`, which carries the CLI) on the same runtime and runs the casethere; `--home-image` and `--entry-home-image ID=IMAGE` name another build.The roster and what each entry must do is `libs/cua/scripts/conformance/entries.json`,diff --git a/examples/openkoalabot-example-swift/Sources/OpenKoalaBotExample/Spaces/SandboxImages.generated.swift b/examples/openkoalabot-example-swift/Sources/OpenKoalaBotExample/Spaces/SandboxImages.generated.swiftindex 36215355b4..0099753cfe 100644--- a/examples/openkoalabot-example-swift/Sources/OpenKoalaBotExample/Spaces/SandboxImages.generated.swift+++ b/examples/openkoalabot-example-swift/Sources/OpenKoalaBotExample/Spaces/SandboxImages.generated.swift@@ -41,7 +41,7 @@ extension SandboxImages {os: "linux",name: "Ubuntu 24.04 slim",variant: "container",- summary: "The minimal Linux desktop: cua-spacesd and Chromium, no dev tooling. What CI and benchmarks run.",+ summary: "The minimal Linux desktop: cua-spacesd, the cua CLI and Chromium, no dev tooling. What CI and benchmarks run, and the home of an agent that makes child Spaces.",spacesd: true,local: "container",cloud: "gvisor",@@ -52,7 +52,7 @@ extension SandboxImages {os: "linux",name: "Ubuntu 24.04 slim VM",variant: "vm",- summary: "The minimal Linux desktop as a full VM.",+ summary: "The minimal Linux desktop, with the cua CLI, as a full VM.",spacesd: true,local: "qemu",cloud: "kubevirt",diff --git a/libs/cua/scripts/conformance/run.py b/libs/cua/scripts/conformance/run.pyindex 5d5e942456..bb3394023d 100755--- a/libs/cua/scripts/conformance/run.py+++ b/libs/cua/scripts/conformance/run.py@@ -398,7 +398,7 @@ def run_entry(entry, args, out_dir, log):def home_image_for(entry, args):- """The image a home Space is made from: the agent-home image (the slim Linux image plus the `cua` CLI),+ """The image a home Space is made from: the slim Linux image (it carries the `cua` CLI),its VM disk for a VM runtime, or what --entry-home-image names for this entry."""override = dict(x.split("=", 1) for x in (args.entry_home_image or []))if entry["id"] in override:@@ -455,7 +455,7 @@ def row_children(run, entry, name, args, row, mode):img = args.child_imageflags = ["--kind", entry["kind"]] + (["--runtime", entry["runtime"]] if entry["runtime"] else [])# The case drives the `cua` CLI inside the Space: the Space under test when its image ships it,- # else a home made from the agent-home image on the same runtime.+ # else a home made from the slim Linux image on the same runtime.rc, o, e, _ = run.exec(name, "command -v cua >/dev/null 2>&1 && echo has-cua || echo no-cua")if "has-cua" not in o:home_img = home_image_for(entry, args)@@ -465,7 +465,7 @@ def row_children(run, entry, name, args, row, mode):said = (e or o).strip()gone = any(k in said for k in ("not published", "not found", "manifest unknown", "MANIFEST_UNKNOWN", "denied", "unauthorized"))row("children", "skip" if gone or any(k in said for k in MISSING) else "fail",- f"the home image {home_img} could not be made: {said[:300]} (build it with libs/images/agent-home and pass --home-image, or --entry-home-image ID=IMAGE)")+ f"the home image {home_img} could not be made: {said[:300]} (build libs/images/linux --target slim and pass --home-image, or --entry-home-image ID=IMAGE)")returnrun.sh("spaces", "add", f"local:{name}")for _ in range(60): # a Space that was just made answers a moment later@@ -695,7 +695,7 @@ def main():ap.add_argument("--image", default="ghcr.io/trycua/linux:24.04-slim")ap.add_argument("--alias", default=None, help="the package the image resolves to (a private mirror of the same tag)")ap.add_argument("--child-image", default="ghcr.io/trycua/linux:24.04-slim")- ap.add_argument("--home-image", default="ghcr.io/trycua/agent-home:24.04",+ ap.add_argument("--home-image", default="ghcr.io/trycua/linux:24.04-slim",help="the image of the home Space the children case makes child Spaces from when the Space under test has no `cua` CLI ""(a VM runtime adds -disk)")ap.add_argument("--entry-home-image", action="append", help="ID=IMAGE: the home image one entry uses (a local build, for example)")diff --git a/libs/images/README.md b/libs/images/README.mdindex 622b629c18..822b2a5c39 100644--- a/libs/images/README.md+++ b/libs/images/README.md@@ -4,8 +4,7 @@ Reference guest images for the cua SDK, built for amd64 and arm64:| Image | Contents | Used for ||---|---|---|-| `linux` | Ubuntu 24.04, XFCE on Xvfb `:1`, AT-SPI, headless PipeWire audio, Firefox, **cua-spacesd** on `:3211` (with the HTML5 viewer at `/viewer`), conformance fixtures | The default recommended "Spaces image": `ghcr.io/trycua/linux` |-| `agent-home` | The slim `linux` image plus the **cua** CLI (`cua spaces create`, `ls`, `delete` reach the Space's spawn channel on their own) | A home for an agent that makes child Spaces; the children case of the runtime conformance suite runs in it. `ghcr.io/trycua/agent-home:24.04[-disk]` (not published yet; the catalog lists it as unpublished) <!-- cua-image-unverified --> |+| `linux` | Ubuntu 24.04, XFCE on Xvfb `:1`, AT-SPI, headless PipeWire audio, Firefox, **cua-spacesd** on `:3211` (with the HTML5 viewer at `/viewer`), the **cua** CLI, conformance fixtures | The default recommended "Spaces image": `ghcr.io/trycua/linux` || `plain/ubuntu-xfce-vnc` | Ubuntu 24.04, XFCE on Xvnc `:1` (RFB `:5901`) and nothing else | Proving that sandboxes don't need cua daemons (VNC only) || `plain/ubuntu-server` | Ubuntu 24.04 and OpenSSH | Proving that sandboxes don't need cua daemons (SSH only) || `macos` | The Lume macOS base plus **cua-spacesd** at login, TCC grants seeded (see [macOS](#macos-lume)) | `ghcr.io/trycua/macos`, local Lume on Apple silicon |@@ -61,26 +60,6 @@ Pass the same `--stamp` (and `--work`, when set) to every run of one release. `t- **Identity:** `/etc/cua-image/manifest.json` (from `image.json` claims and `cua-spacesd build-info`), `/etc/cua-image/spacesd-source`, `/etc/cua-image/variant` (`lume`).- **Gate:** `doctor-gate.sh` runs `cua-spacesd doctor --strict` in the guest over `lume ssh` after a reboot, then `tools/ax_probe.py` (the official MCP SDK against the image's `/mcp`: permissions, an AX tree read, CGEvent clicks in Calculator and a session-keyed `move_cursor` that must return). The build fails unless both pass. The release's `input/arm64/lume` gate (`live-input-gate.sh`) then boots a clone of the built VM and runs `libs/cua/crates/cua-spaces-ext/tests/e2e_macos_input.rs`: a Dock click on a whole-display stream must be delivered and change the screen. The pushed VM itself never boots again after its sanitize.-## agent-home--`agent-home/` is `FROM ghcr.io/trycua/linux:24.04-slim` (override with `--build-arg BASE=`) plus `/usr/local/bin/cua`, so it has every runtime the slim image has: a container rootfs for docker, gVisor and the microVM runtimes, and the VM disk derived from it for QEMU and KubeVirt. Inside a Space with child Spaces on, `cua` finds the Space's spawn channel without configuration and the image holds no token.--`CUA_CLI_SOURCE` selects where the CLI comes from, the way `CUA_SPACESD_SOURCE` does for the driver:--| Value | Behaviour |-|---|---|-| `local` (default) | Copies `agent-home/dist/<arch>/cua`. `agent-home/build-cua-linux.sh [arm64] [amd64]` builds `libs/cua` in `rust:1-bookworm`, natively or under emulation. |-| `release` | Downloads `cua-cli-<version>-linux-<x64\|arm64>.tar.gz` from the `cua-sdk-v<version>` release (`CUA_CLI_VERSION`, or `latest`; `CUA_CLI_RELEASE_URL` has `{version}` and `{arch}`; `CUA_CLI_SHA256` checks it). The release must be cua-sdk 0.10.1 or later, the first with child Spaces. |-| `none` | No CLI: the slim image. |--```bash-libs/images/agent-home/build-cua-linux.sh # host arch CLI into dist/<arch>/-libs/images/build.sh agent-home --outputs rootfs,disk # cua-e2e-local/agent-home:docker-local-<arch>-libs/images/build.sh agent-home --build-arg CUA_CLI_SOURCE=release --build-arg CUA_CLI_VERSION=0.10.1-```--`libs/cua/scripts/conformance/run.py` makes its home Spaces from this image when the Space under test has no `cua` CLI: `--home-image` names it (default `ghcr.io/trycua/agent-home:24.04`; a VM runtime adds `-disk`), and `--entry-home-image ID=IMAGE` points one runtime at a local build. <!-- cua-image-unverified -->-## Built-in Linux runtime (`runtime-gvisor`)`runtime-gvisor/` builds `ghcr.io/trycua/runtime-gvisor`, the disk of the VM a Mac with no Docker runs Linux Spaces in (`cua_vmm::managed`, the Linux row of Settings → Runtimes, `cua config set runtime.linux auto|builtin|system`). It is not a Space image and not in the catalog.@@ -280,8 +259,8 @@ Nobody dispatches the image builds after a cua-spacesd release:| Value | Behaviour ||---|---|-| `local` (default) | Copies `linux/dist/<arch>/cua-spacesd`. `linux/build-spacesd-linux.sh [arm64] [amd64]` produces it by building `libs/cua-spacesd` in `rust:1-bookworm`: natively, via a multiarch cross toolchain (`CROSS_MODE=cross`), or under emulation (`CROSS_MODE=emulate`). |-| `release` | Downloads `CUA_SPACESD_RELEASE_URL`, a placeholder pattern with `{version}` and `{arch}`. |+| `local` | What the publish workflow uses (`release.json` sets it). Copies `linux/dist/<arch>/cua-spacesd`. `linux/build-spacesd-linux.sh [arm64] [amd64]` produces it by building `libs/cua-spacesd` in `rust:1-bookworm`: natively, via a multiarch cross toolchain (`CROSS_MODE=cross`), or under emulation (`CROSS_MODE=emulate`). |+| `release` (default) | Pinned to cua-sdk 0.10.1 with its sha256 in the Dockerfile unless `CUA_CLI_VERSION` says otherwise, so ad-hoc, e2e and nightly builds need no CLI built first. Downloads `CUA_SPACESD_RELEASE_URL`, a placeholder pattern with `{version}` and `{arch}`. || `none` | No driver. The supervisor program idles. |The driver runs inside the desktop session, bound to `0.0.0.0:$CUA_ENV_PORT` (3211, QUIC media on 3212). A non-loopback bind needs a token, so a missing token is fatal rather than anonymous.@@ -313,6 +292,25 @@ Requirements for the pod spec (trycua/cloud#7885):- Keep the container's user root (the image default). supervisord runs the root sync helper and drops the desktop, driver and other programs to `cua`.- If the pod must run as non-root (`runAsUser`), set `fsGroup: 1000` and the Secret's `defaultMode: 0440`. The `cua` user can then read the file and the driver follows it directly. Keep it out of "other" (not 0444): the driver refuses world-readable token files unless it runs as root in a container.+### The cua CLI (slim tier, so every tier)++`ghcr.io/trycua/linux:24.04-slim[-disk]` also carries `/usr/local/bin/cua`, so an agent in a Space (the Home Space of the ask-first flow runs on it) can run `cua spaces create`, `ls` and `delete`. In a Space whose host turned child Spaces on, the CLI finds the Space's own spawn channel (`CUA_SPAWN`, or the files the spawn-capable cua-spacesd keeps) with nothing to configure, and the image holds no token. `full` and `docker` are `FROM slim`, so they have it too. The CLI is not small: the released archive is about 85 MB compressed on x64 (78 MB on arm64), so slim grows from about 0.49 GB to about 0.58 GB compressed and from 1.23 GB to 1.43 GB unpacked on amd64. Child Spaces from a Home Space need it, so the slim gate (`size/{arch}` in `release.json`) allows 1.55 GB unpacked per arch; a thinner in-Space CLI would cut it. The slim tier claims `cua --version` and the `spawn` feature, so `cua-spacesd doctor --strict` fails an image without them.++`CUA_CLI_SOURCE` selects where the CLI comes from, the way `CUA_SPACESD_SOURCE` does for the driver:++| Value | Behaviour |+|---|---|+| `local` | What the publish workflow uses (`release.json` sets it). Copies `linux/dist/<arch>/cua`. `linux/build-cua-cli-linux.sh [arm64] [amd64]` builds `libs/cua` in `rust:1-bookworm`; `CUA_CLI_BIN=<path>` stages a binary you already built (CI hands over the one it built from the same commit). |+| `release` (default) | Pinned to cua-sdk 0.10.1 with its sha256 in the Dockerfile unless `CUA_CLI_VERSION` says otherwise, so ad-hoc, e2e and nightly builds need no CLI built first. Downloads `cua-cli-<version>-linux-<x64\|arm64>.tar.gz` of the `cua-sdk-v<version>` release. `CUA_CLI_VERSION` must be pinned (never `latest`, cua-sdk 0.10.1 or later, the first with child Spaces); the archive is checked against `CUA_CLI_SHA256` or the release's `checksums.txt`. |+| `none` | No CLI. |++```bash+libs/images/linux/build-cua-cli-linux.sh # host arch CLI into dist/<arch>/+libs/images/build.sh linux --build-arg CUA_CLI_SOURCE=release --build-arg CUA_CLI_VERSION=0.10.1+```++`libs/cua/scripts/conformance/run.py` makes its home Spaces from the slim image when the Space under test has no `cua` CLI: `--home-image` names it (default `ghcr.io/trycua/linux:24.04-slim`; a VM runtime adds `-disk`), and `--entry-home-image ID=IMAGE` points one runtime at a local build.+## Test```bashdiff --git a/libs/images/agent-home/Dockerfile b/libs/images/agent-home/Dockerfiledeleted file mode 100644index 24dbf7e3f3..0000000000--- a/libs/images/agent-home/Dockerfile+++ /dev/null@@ -1,97 +0,0 @@-# syntax=docker/dockerfile:1.7-# agent-home: the lightest image a coding agent can live in and make child Spaces from.-#-# It is the slim Linux image (ghcr.io/trycua/linux:24.04-slim: cua-spacesd, the desktop and-# Chromium) plus the `cua` CLI. Inside a Space with child Spaces on, `cua spaces create`, `ls`-# and `delete` reach the Space's spawn channel on their own (nothing to configure, no token in-# the image), so an agent here can create, use and delete child Spaces within its tree's budget.-# The network conformance suite (libs/cua/scripts/conformance) makes its children case run-# in it. One definition, two outputs like the linux image: a container rootfs (docker, gVisor,-# microVMs) and, from the same rootfs, a VM disk (QEMU, KubeVirt).-#-# Where `cua` comes from (CUA_CLI_SOURCE), the way libs/images/linux gets cua-spacesd:-# local copy agent-home/dist/<TARGETARCH>/cua from the build context (produce it with-# agent-home/build-cua-linux.sh). The default.-# release download cua-cli-<version>-linux-<x64|arm64>.tar.gz from the cua-sdk-v<version>-# GitHub release (CUA_CLI_VERSION, or `latest`; CUA_CLI_RELEASE_URL has {version}-# and {arch} placeholders). Pass CUA_CLI_SHA256 to check the archive.-# none no CLI (the image is then the slim image).-# The bind mount needs agent-home/dist to exist, also for `release` (`mkdir -p agent-home/dist`).-# The spawn channel is served by the guest's cua-spacesd: the base image's must be one that has it-# (cua-spacesd 0.10.1 or later). CUA_SPACESD_SOURCE replaces it: `base` keeps the base image's,-# `local` copies agent-home/dist/<arch>/cua-spacesd (linux/build-spacesd-linux.sh builds it into-# linux/dist; copy it over), `release` downloads CUA_SPACESD_VERSION from the cua-spacesd release-# like libs/images/linux does.-# The version must be one with child Spaces (cua-sdk 0.10.1 or later): the CLI of an older-# release does not know the spawn channel.-ARG BASE=ghcr.io/trycua/linux:24.04-slim-FROM ${BASE}-ARG TARGETARCH-ARG CUA_CLI_SOURCE=local-ARG CUA_CLI_VERSION=-ARG CUA_CLI_RELEASE_URL=-ARG CUA_CLI_SHA256=-ARG CUA_SPACESD_SOURCE=base-ARG CUA_SPACESD_VERSION=-ARG CUA_SPACESD_RELEASE_URL=-USER root-RUN --mount=type=bind,source=agent-home/dist,target=/dist \- set -eu; \- bin=/usr/local/bin/cua; \- default_url='https://github.com/trycua/cua/releases/download/cua-sdk-v{version}/cua-cli-{version}-linux-{arch}.tar.gz'; \- CUA_CLI_RELEASE_URL="${CUA_CLI_RELEASE_URL:-$default_url}"; \- case "$CUA_CLI_SOURCE" in \- local) \- src="/dist/$TARGETARCH/cua"; \- [ -f "$src" ] || { echo "CUA_CLI_SOURCE=local but $src is missing; run agent-home/build-cua-linux.sh or pass CUA_CLI_SOURCE=release" >&2; exit 1; }; \- install -m 0755 "$src" "$bin" ;; \- release) \- case "$TARGETARCH" in amd64) arch=x64 ;; arm64) arch=arm64 ;; *) echo "no cua CLI release for $TARGETARCH" >&2; exit 1 ;; esac; \- CUA_CLI_VERSION="${CUA_CLI_VERSION#cua-sdk-v}"; CUA_CLI_VERSION="${CUA_CLI_VERSION#v}"; \- if [ -z "$CUA_CLI_VERSION" ] || [ "$CUA_CLI_VERSION" = latest ]; then \- CUA_CLI_VERSION="$(curl -fsSL 'https://api.github.com/repos/trycua/cua/releases?per_page=100' \- | python3 -c 'import json,sys; print(next(r["tag_name"][len("cua-sdk-v"):] for r in json.load(sys.stdin) if r["tag_name"].startswith("cua-sdk-v") and not r["draft"] and not r["prerelease"]))')"; \- echo "latest cua-sdk release: $CUA_CLI_VERSION"; \- fi; \- url="$(echo "$CUA_CLI_RELEASE_URL" | sed "s/{version}/$CUA_CLI_VERSION/g; s/{arch}/$arch/g")"; \- echo "fetching $url"; \- curl -fsSL -o /tmp/cua-cli.tar.gz "$url"; \- if [ -n "$CUA_CLI_SHA256" ]; then echo "$CUA_CLI_SHA256 /tmp/cua-cli.tar.gz" | sha256sum -c -; fi; \- tar -xzf /tmp/cua-cli.tar.gz -C /usr/local/bin cua; \- rm /tmp/cua-cli.tar.gz; \- chmod 0755 "$bin"; \- echo "$CUA_CLI_VERSION" >/tmp/cua-cli-version ;; \- none) echo "building without the cua CLI" ;; \- *) echo "unknown CUA_CLI_SOURCE=$CUA_CLI_SOURCE" >&2; exit 1 ;; \- esac; \- if [ -x "$bin" ]; then ldd "$bin" | grep 'not found' && exit 1 || true; "$bin" --version; fi; \- mkdir -p /etc/cua-image; \- echo "$CUA_CLI_SOURCE" >/etc/cua-image/cua-cli-source; \- if [ -f /tmp/cua-cli-version ]; then mv /tmp/cua-cli-version /etc/cua-image/cua-cli-release; fi--# cua-spacesd, when the base image's does not serve the spawn channel.-RUN --mount=type=bind,source=agent-home/dist,target=/dist \- set -eu; \- bin=/usr/local/bin/cua-spacesd; \- default_url='https://github.com/trycua/cua/releases/download/cua-spacesd-v{version}/cua-spacesd-linux-{arch}.tar.gz'; \- CUA_SPACESD_RELEASE_URL="${CUA_SPACESD_RELEASE_URL:-$default_url}"; \- case "$CUA_SPACESD_SOURCE" in \- base) exit 0 ;; \- local) \- src="/dist/$TARGETARCH/cua-spacesd"; \- [ -f "$src" ] || { echo "CUA_SPACESD_SOURCE=local but $src is missing" >&2; exit 1; }; \- install -m 0755 "$src" "$bin"; echo local >/etc/cua-image/spacesd-source ;; \- release) \- case "$TARGETARCH" in amd64) arch=x86_64 ;; arm64) arch=aarch64 ;; *) arch="$TARGETARCH" ;; esac; \- CUA_SPACESD_VERSION="${CUA_SPACESD_VERSION#cua-spacesd-v}"; CUA_SPACESD_VERSION="${CUA_SPACESD_VERSION#v}"; \- [ -n "$CUA_SPACESD_VERSION" ] || { echo "CUA_SPACESD_SOURCE=release needs CUA_SPACESD_VERSION" >&2; exit 1; }; \- url="$(echo "$CUA_SPACESD_RELEASE_URL" | sed "s/{version}/$CUA_SPACESD_VERSION/g; s/{arch}/$arch/g")"; \- echo "fetching $url"; \- curl -fsSL -o /tmp/cua-spacesd.tar.gz "$url"; \- sum="$(curl -fsSL "$url.sha256" | cut -d' ' -f1)"; \- echo "$sum /tmp/cua-spacesd.tar.gz" | sha256sum -c -; \- tar -xzf /tmp/cua-spacesd.tar.gz -C /usr/local/bin cua-spacesd; rm /tmp/cua-spacesd.tar.gz; \- chmod 0755 "$bin"; echo release >/etc/cua-image/spacesd-source; echo "$CUA_SPACESD_VERSION" >/etc/cua-image/spacesd-release ;; \- *) echo "unknown CUA_SPACESD_SOURCE=$CUA_SPACESD_SOURCE" >&2; exit 1 ;; \- esac; \- ldd "$bin" | grep 'not found' && exit 1 || true; "$bin" --versiondiff --git a/libs/images/agent-home/image.json b/libs/images/agent-home/image.jsondeleted file mode 100644index 5b986635db..0000000000--- a/libs/images/agent-home/image.json+++ /dev/null@@ -1,246 +0,0 @@-{- "schema_version": 1,- "name": "agent-home",- "description": "The lightest home for a coding agent: the slim Linux image (cua-spacesd, desktop, Chromium) plus the cua CLI, so an agent in a Space can create, use and delete child Spaces. The network conformance suite runs its children case in it. Container rootfs for docker, gVisor and microVMs, and a VM disk for QEMU and KubeVirt.",- "repository": "ghcr.io/trycua/agent-home",- "platforms": [- "linux/amd64",- "linux/arm64"- ],- "outputs": {- "rootfs": {- "tag_prefix": "docker-",- "runtimes": [- "docker",- "gvisor"- ],- "init": "supervisord"- },- "containerdisk": {- "tag_prefix": "",- "runtimes": [- "kubevirt",- "qemu"- ],- "init": "systemd",- "path": "/disk/disk.img",- "firmware": {- "amd64": [- "bios",- "efi"- ],- "arm64": [- "efi"- ]- }- }- },- "desktop": {- "display": ":1",- "resolution": "1280x800",- "user": "cua",- "uid": 1000,- "runtime_dir": "/run/cua-desktop",- "session_bus": "unix:path=/run/cua-desktop/bus"- },- "services": [- {- "name": "env",- "port": 3211,- "protocol": "grpc",- "component": "cua-spacesd",- "auth": "bearer token: CUA_ENV_TOKEN or /run/cua/env-token",- "readiness": "tcp"- },- {- "name": "viewer",- "port": 3211,- "protocol": "http",- "component": "cua-spacesd",- "readiness": "http:/viewer/"- },- {- "name": "env-media",- "port": 3212,- "protocol": "udp",- "component": "cua-spacesd"- },- {- "name": "ssh",- "port": 22,- "protocol": "tcp",- "variants": [- "containerdisk"- ]- }- ],- "audio": {- "server": "pipewire + wireplumber + pipewire-pulse",- "runtime_dir": "/run/cua-desktop",- "default_sink": "cua_desktop",- "desktop_capture": "cua_desktop.monitor",- "default_source": "cua_mic",- "uplink_input_sink": "cua_mic_in",- "format": "48000 Hz stereo"- },- "claims": {- "_doc": "What the image promises; cua-image-manifest turns this into /etc/cua-image/manifest.json and cua-spacesd doctor checks it (claimed = required).",- "features_required": [- "pty",- "fs_watch",- "tunnel.forward",- "driver",- "a11y",- "background_input",- "desktop_stream",- "window_stream",- "h264_sw",- "quic_media",- "windows",- "launch_app",- "clipboard.text",- "presence",- "presence.cursor_shape",- "audio.desktop",- "audio.uplink",- "audio.opus",- "process.exec_ledger"- ],- "features_optional": [- "hotspot",- "spawn",- "exit",- "host_ports",- "process.services",- "relay_attach",- "h264_hw",- "audio.per_app",- "clipboard.files",- "clipboard.image",- "teleport.*",- "volume.mount",- "process.exec_ledger",- "files.multipart",- "fs.run_as",- "fs.xattr",- "process.run_as",- "volume.binds"- ],- "feature_attributes": {- "presence.cursor_shape": {- "hit_test": "atspi",- "system": "xfixes",- "probe": "xtest"- }- },- "codecs_required": [- "openh264"- ],- "auth_modes": [- "local",- "pod-secret",- "kubevirt-bridge"- ],- "units": {- "supervisord": [- "dbus-system",- "desktop",- "audio",- "cua-env-token-sync",- "cua-spacesd"- ],- "systemd": [- "cua-desktop.service",- "cua-audio.service",- "cua-env-token-sync.service",- "cua-spacesd.service"- ]- },- "unit_processes": {- "dbus-system": "dbus-daemon --system",- "desktop": "Xvfb",- "audio": "pipewire",- "cua-env-token-sync": "token-sync",- "cua-spacesd": "cua-spacesd"- },- "compat_links": [- {- "path": "/usr/local/bin/cua-env-driver",- "target": "cua-spacesd"- },- {- "path": "/usr/local/bin/cua-guestd",- "target": "cua-spacesd"- },- {- "path": "/opt/cua/bin/start-env-driver.sh",- "target": "start-spacesd.sh"- },- {- "path": "/opt/cua/bin/start-guestd.sh",- "target": "start-spacesd.sh"- },- {- "path": "/etc/cua-image/env-driver-source",- "target": "spacesd-source"- },- {- "path": "/etc/cua-image/guestd-source",- "target": "spacesd-source"- },- {- "unit_alias": "cua-env-driver.service",- "unit": "cua-spacesd.service"- },- {- "unit_alias": "cua-guestd.service",- "unit": "cua-spacesd.service"- }- ],- "apps": {- "chromium": [- "/usr/lib/chromium/chromium",- "--version"- ],- "python3": [- "python3",- "--version"- ]- },- "launch_app": {- "app": "/opt/cua/bin/cua-chromium",- "args": [- "--no-first-run",- "--no-default-browser-check",- "--new-window",- "about:blank"- ],- "window_match": "Chromium",- "timeout_s": 60- },- "parity_expected_diff": [- "kernel",- "runtime",- "init",- "cpu_model",- "cpu_count",- "memory_mib",- "clock_skew_ms",- "gpu",- "encoder"- ],- "resources": {- "min_disk_gib": 2,- "min_shm_mib": 256,- "min_memory_mib": 1024- },- "tz": "Etc/UTC",- "locale": "C.UTF-8",- "dns_probe": "archive.ubuntu.com",- "av_skew_budget_ms": {- "container": 40,- "gvisor": 80,- "vm": 40- }- }-}diff --git a/libs/images/common/tools/tests/fixtures/manifest.linux.json b/libs/images/common/tools/tests/fixtures/manifest.linux.jsonindex 86d8d14f0e..a865f0b7ee 100644--- a/libs/images/common/tools/tests/fixtures/manifest.linux.json+++ b/libs/images/common/tools/tests/fixtures/manifest.linux.json@@ -93,7 +93,6 @@"features_not_applicable": [],"features_optional": ["hotspot",- "spawn","exit","host_ports","process.services",@@ -130,7 +129,8 @@"audio.desktop","audio.uplink","audio.opus",- "process.exec_ledger"+ "process.exec_ledger",+ "spawn"],"fixtures": {"apps": [@@ -236,6 +236,13 @@],"expect": "^cmake version 3\\."},+ "cua": {+ "argv": [+ "cua",+ "--version"+ ],+ "expect": "^cua [0-9]"+ },"curl": {"argv": ["/bin/sh",diff --git a/libs/images/linux/Dockerfile b/libs/images/linux/Dockerfileindex cc0b352aa3..4ded7477bb 100644--- a/libs/images/linux/Dockerfile+++ b/libs/images/linux/Dockerfile@@ -20,6 +20,7 @@# PipeWire (null sink cua_desktop, virtual source cua_mic)# + Chromium (the browser cua-driver's browser tools drive over CDP)# + cua-spacesd (3211: gRPC, media, and the HTML5 viewer at /viewer)+# + the `cua` CLI (child Spaces from inside a Space)# + conformance fixtures under# /opt/cua/fixtures. This file builds the container rootfs (docker / gVisor,# supervisord as PID 1). The KubeVirt containerDisk is derived from THIS image@@ -42,6 +43,15 @@# The older build args (CUA_GUESTD_* and CUA_ENV_DRIVER_* SOURCE/_VERSION/# _RELEASE_URL) are still honoured when the CUA_SPACESD_* one is not given.#+# CUA_CLI_SOURCE (the `cua` CLI an agent in the Space uses to make child Spaces)+# local copy linux/dist/<TARGETARCH>/cua (linux/build-cua-cli-linux.sh builds it;+# CI hands over the CLI it built from the same commit). Missing = build error.+# What the publish workflow says (release.json cli_source=local).+# release the default, at CUA_CLI_DEFAULT_VERSION (0.10.1, sha256 pinned here): download cua-cli-<version>-linux-<x64|arm64>.tar.gz of the cua-sdk-v<version>+# release; CUA_CLI_VERSION, when given, must be pinned (never `latest`) and the archive is+# checked against CUA_CLI_SHA256 or the release's checksums.txt.+# none no CLI.+## Compat for one release, for both older names (cua-env-driver, cua-guestd):# /usr/local/bin/<old> links to cua-spacesd, <old>.service is an alias of# cua-spacesd.service, and /opt/cua/bin/start-<old>.sh links to@@ -62,6 +72,17 @@ ARG CUA_GUESTD_RELEASE_URL=ARG CUA_ENV_DRIVER_SOURCE=ARG CUA_ENV_DRIVER_VERSION=ARG CUA_ENV_DRIVER_RELEASE_URL=+# The cua CLI (see its RUN below): local (linux/dist/<arch>/cua, default) | release | none.+ARG CUA_CLI_SOURCE=+ARG CUA_CLI_VERSION=+ARG CUA_CLI_RELEASE_URL=+ARG CUA_CLI_SHA256=+# The release a build without a CLI of its own takes (ad-hoc builds, e2e and nightly jobs), pinned with+# the sha256 of its archives (checksums.txt of cua-sdk-v0.10.1). The image publish workflow says+# CUA_CLI_SOURCE=local instead (the CLI built from the same commit).+ARG CUA_CLI_DEFAULT_VERSION=0.10.1+ARG CUA_CLI_DEFAULT_SHA256_AMD64=ea420b0ac21c524b09507c576cf9c55a2177ce3c84169dcb5e2d1792f18c2929+ARG CUA_CLI_DEFAULT_SHA256_ARM64=fd6e24accb572350a433935a67e1b5a21302786ef8bf1cb3b5237d611822c0acENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=Etc/UTC# Desktop, display, a11y and test tooling. No snaps anywhere (the full tier's@@ -233,6 +254,51 @@ RUN --mount=type=bind,source=linux/dist,target=/dist \ln -s spacesd-source /etc/cua-image/env-driver-source; \ln -s spacesd-source /etc/cua-image/guestd-source+# The `cua` CLI (/usr/local/bin/cua), so an agent in a Space can run `cua spaces create`, `ls` and+# `delete`: inside a Space whose host turned child Spaces on, the CLI finds the Space's own spawn+# channel (CUA_SPAWN / the files cua-spacesd keeps, served by the cua-spacesd above) with nothing to+# configure and no token in the image. The CLI must be cua-sdk 0.10.1 or later (the first with+# child Spaces).+RUN --mount=type=bind,source=linux/dist,target=/dist \+ set -eu; \+ bin=/usr/local/bin/cua; \+ CUA_CLI_SOURCE="${CUA_CLI_SOURCE:-release}"; \+ default_url='https://github.com/trycua/cua/releases/download/cua-sdk-v{version}/cua-cli-{version}-linux-{arch}.tar.gz'; \+ CUA_CLI_RELEASE_URL="${CUA_CLI_RELEASE_URL:-$default_url}"; \+ case "$CUA_CLI_SOURCE" in \+ local) \+ src="/dist/$TARGETARCH/cua"; \+ [ -f "$src" ] || { echo "CUA_CLI_SOURCE=local but $src is missing; run linux/build-cua-cli-linux.sh or pass CUA_CLI_SOURCE=release|none" >&2; exit 1; }; \+ install -m 0755 "$src" "$bin" ;; \+ release) \+ case "$TARGETARCH" in amd64) arch=x64 ;; arm64) arch=arm64 ;; *) echo "no cua CLI release for $TARGETARCH" >&2; exit 1 ;; esac; \+ CUA_CLI_VERSION="${CUA_CLI_VERSION:-$CUA_CLI_DEFAULT_VERSION}"; \+ CUA_CLI_VERSION="${CUA_CLI_VERSION#cua-sdk-v}"; CUA_CLI_VERSION="${CUA_CLI_VERSION#v}"; \+ case "$CUA_CLI_VERSION" in ""|latest) echo "CUA_CLI_SOURCE=release needs a pinned CUA_CLI_VERSION (not latest)" >&2; exit 1 ;; esac; \+ url="$(echo "$CUA_CLI_RELEASE_URL" | sed "s/{version}/$CUA_CLI_VERSION/g; s/{arch}/$arch/g")"; \+ echo "fetching $url"; \+ curl -fsSL --retry 5 -o /tmp/cua-cli.tar.gz "$url"; \+ if [ -z "$CUA_CLI_SHA256" ] && [ "$CUA_CLI_VERSION" = "$CUA_CLI_DEFAULT_VERSION" ]; then \+ case "$TARGETARCH" in amd64) CUA_CLI_SHA256="$CUA_CLI_DEFAULT_SHA256_AMD64" ;; arm64) CUA_CLI_SHA256="$CUA_CLI_DEFAULT_SHA256_ARM64" ;; esac; \+ fi; \+ if [ -z "$CUA_CLI_SHA256" ]; then \+ sums="https://github.com/trycua/cua/releases/download/cua-sdk-v$CUA_CLI_VERSION/checksums.txt"; \+ CUA_CLI_SHA256="$(curl -fsSL --retry 5 "$sums" | awk -v f="$(basename "$url")" '$2 == f || $2 == "*" f { print $1 }')"; \+ [ -n "$CUA_CLI_SHA256" ] || { echo "no sha256 for $(basename "$url") in $sums" >&2; exit 1; }; \+ fi; \+ echo "$CUA_CLI_SHA256 /tmp/cua-cli.tar.gz" | sha256sum -c -; \+ tar -xzf /tmp/cua-cli.tar.gz -C /usr/local/bin cua; \+ rm /tmp/cua-cli.tar.gz; \+ chmod 0755 "$bin"; \+ echo "$CUA_CLI_VERSION" >/tmp/cua-cli-version ;; \+ none) echo "building without the cua CLI" ;; \+ *) echo "unknown CUA_CLI_SOURCE=$CUA_CLI_SOURCE" >&2; exit 1 ;; \+ esac; \+ if [ -x "$bin" ]; then ldd "$bin" | grep 'not found' && exit 1 || true; "$bin" --version; fi; \+ mkdir -p /etc/cua-image; \+ echo "$CUA_CLI_SOURCE" >/etc/cua-image/cua-cli-source; \+ if [ -f /tmp/cua-cli-version ]; then mv /tmp/cua-cli-version /etc/cua-image/cua-cli-release; fi+COPY linux/files/supervisor/supervisord.conf /etc/supervisor/supervisord.confCOPY linux/files/start-spacesd.sh linux/files/ensure-env-token.sh \linux/files/env-token-mode.sh linux/files/start-token-sync.sh \diff --git a/libs/images/agent-home/build-cua-linux.sh b/libs/images/linux/build-cua-cli-linux.shsimilarity index 71%rename from libs/images/agent-home/build-cua-linux.shrename to libs/images/linux/build-cua-cli-linux.shindex a7480d3f43..196e7b2dcd 100755--- a/libs/images/agent-home/build-cua-linux.sh+++ b/libs/images/linux/build-cua-cli-linux.sh@@ -1,8 +1,11 @@#!/usr/bin/env bash-# Build the `cua` CLI for Linux inside Docker and stage it where the agent-home image build-# expects it: libs/images/agent-home/dist/<arch>/cua.+# Build the `cua` CLI for Linux inside Docker and stage it where the linux image build+# expects it: libs/images/linux/dist/<arch>/cua (the slim tier bakes it into /usr/local/bin).#-# build-cua-linux.sh [arm64|amd64 ...] (default: host arch)+# build-cua-cli-linux.sh [arm64|amd64 ...] (default: host arch)+#+# CUA_CLI_BIN=/path/to/cua stages that binary instead of building (CI builds the CLI once per+# arch and hands the same bytes to every job; it must be a linux build for the arch asked for).## Builds in rust:1-bookworm (glibc 2.36, so the binary runs on Ubuntu 24.04's 2.39). The repo# root is mounted read-only; cargo's registry and target dir live in named Docker volumes, not@@ -11,14 +14,14 @@## Env overrides:# RUST_IMAGE default rust:1-bookworm-# CUA_CLI_TARGET_VOLUME cargo target volume prefix (default cua-agent-home-target); give+# CUA_CLI_TARGET_VOLUME cargo target volume prefix (default cua-cli-linux-target); give# each worktree its own, since concurrent builds of different# sources in one target dir mix their artifactsset -euo pipefailHERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"REPO_ROOT="$(cd "$HERE/../../.." && pwd)"RUST_IMAGE="${RUST_IMAGE:-rust:1-bookworm}"-VOL="${CUA_CLI_TARGET_VOLUME:-cua-agent-home-target}"+VOL="${CUA_CLI_TARGET_VOLUME:-cua-cli-linux-target}"host_arch() { case "$(uname -m)" in arm64|aarch64) echo arm64 ;; *) echo amd64 ;; esac; }[ $# -gt 0 ] || set -- "$(host_arch)"@@ -26,10 +29,15 @@ for arch in "$@"; docase "$arch" in arm64|amd64) ;; *) echo "unknown arch $arch" >&2; exit 2 ;; esacout="$HERE/dist/$arch"mkdir -p "$out"+ if [ -n "${CUA_CLI_BIN:-}" ]; then+ install -m 0755 "$CUA_CLI_BIN" "$out/cua"+ ls -l "$out/cua"+ continue+ fiecho "==> cua for linux/$arch in $RUST_IMAGE"docker run --rm --platform "linux/$arch" \-v "$REPO_ROOT:/src:ro" -v "$out:/out" \- -v "$VOL-$arch:/target" -v "cua-agent-home-cargo-$arch:/usr/local/cargo/registry" \+ -v "$VOL-$arch:/target" -v "cua-cli-linux-cargo-$arch:/usr/local/cargo/registry" \-e CARGO_TARGET_DIR=/target -e CARGO_INCREMENTAL=0 \-w /src/libs/cua "$RUST_IMAGE" bash -euc 'apt-get update -qqdiff --git a/libs/images/linux/image.json b/libs/images/linux/image.jsonindex 7b636aa9ec..f314edc520 100644--- a/libs/images/linux/image.json+++ b/libs/images/linux/image.json@@ -4,7 +4,7 @@"aliases": ["cua-desktop-linux"],- "description": "Default recommended Spaces image: Ubuntu 24.04, XFCE on Xvfb :1, AT-SPI, headless PipeWire audio, Chromium, cua-spacesd (with the HTML5 viewer at /viewer), conformance fixtures. Tiers: slim (that, and nothing else), full (the default: slim plus developer tooling and Firefox) and docker (slim plus the Docker engine, a VM disk).",+ "description": "Default recommended Spaces image: Ubuntu 24.04, XFCE on Xvfb :1, AT-SPI, headless PipeWire audio, Chromium, cua-spacesd (with the HTML5 viewer at /viewer), conformance fixtures. Tiers: slim (that, plus the cua CLI so an agent in a Space can make child Spaces), full (the default: slim plus developer tooling and Firefox) and docker (slim plus the Docker engine, a VM disk).","repository": "ghcr.io/trycua/linux","platforms": ["linux/amd64",@@ -176,11 +176,11 @@"audio.desktop","audio.uplink","audio.opus",- "process.exec_ledger"+ "process.exec_ledger",+ "spawn"],"features_optional": ["hotspot",- "spawn","exit","host_ports","process.services",@@ -318,8 +318,18 @@"default_tier": "full","tiers": {"slim": {- "description": "The minimum for cua-spacesd doctor --strict with every feature: the desktop, audio, Chromium, cua-spacesd, the fixtures. No Firefox, no developer tooling.",- "claims": {}+ "description": "The minimum for cua-spacesd doctor --strict with every feature: the desktop, audio, Chromium, cua-spacesd, the fixtures, and the cua CLI (a spawn-capable cua-spacesd plus `cua spaces create|ls|delete` reach the Space's own spawn channel, so an agent in the Space can make child Spaces). No Firefox, no developer tooling.",+ "claims": {+ "tools": {+ "cua": {+ "argv": [+ "cua",+ "--version"+ ],+ "expect": "^cua [0-9]"+ }+ }+ }},"docker": {"from": "slim",diff --git a/libs/images/linux/release.json b/libs/images/linux/release.jsonindex a1fd36e8e3..c4b10d489a 100644--- a/libs/images/linux/release.json+++ b/libs/images/linux/release.json@@ -22,7 +22,9 @@"vars": {"spacesd_source": "local","spacesd_version": "latest",- "record_ledger": "false"+ "record_ledger": "false",+ "cli_source": "local",+ "cli_version": ""},"steps": [{@@ -39,6 +41,20 @@"{root}/libs/images/linux/dist/{arch}/cua-spacesd"]},+ {+ "id": "cli/{arch}",+ "phase": "prepare",+ "per_arch": true,+ "description": "the cua CLI for the image (cached in dist/; CI hands over the one it built from this commit)",+ "unless_exists": "{root}/libs/images/linux/dist/{arch}/cua",+ "run": [+ "{root}/libs/images/linux/build-cua-cli-linux.sh",+ "{arch}"+ ],+ "produces": [+ "{root}/libs/images/linux/dist/{arch}/cua"+ ]+ },{"id": "build/{arch}","phase": "build",@@ -66,7 +82,11 @@"--build-arg","CUA_SPACESD_SOURCE={spacesd_source}","--build-arg",- "CUA_SPACESD_VERSION={spacesd_version}"+ "CUA_SPACESD_VERSION={spacesd_version}",+ "--build-arg",+ "CUA_CLI_SOURCE={cli_source}",+ "--build-arg",+ "CUA_CLI_VERSION={cli_version}"],"produces": ["{out}/{name}-{tier}/{arch}/disk.img"@@ -231,6 +251,62 @@"{evidence}/claim-token/{arch}-runsc"]},+ {+ "id": "cua-cli/{arch}/runc",+ "phase": "gate",+ "per_arch": true,+ "requires": [+ "docker"+ ],+ "description": "the cua CLI in the image: version, cua-spacesd health, and `cua spaces ls` reaching the Space's spawn channel (smoke-cua-cli.sh)",+ "run": [+ "{root}/libs/images/linux/smoke-cua-cli.sh",+ "--image",+ "{repo}:docker-{tag}-{arch}",+ "--runtime",+ "runc",+ "--evidence",+ "{evidence}/cua-cli/{arch}-runc"+ ]+ },+ {+ "id": "cua-cli/{arch}/runsc",+ "phase": "gate",+ "per_arch": true,+ "requires": [+ "runsc",+ "native-{arch}"+ ],+ "description": "the cua CLI in the image: version, cua-spacesd health, and `cua spaces ls` reaching the Space's spawn channel (smoke-cua-cli.sh)",+ "run": [+ "{root}/libs/images/linux/smoke-cua-cli.sh",+ "--image",+ "{repo}:docker-{tag}-{arch}",+ "--runtime",+ "runsc",+ "--evidence",+ "{evidence}/cua-cli/{arch}-runsc"+ ]+ },+ {+ "id": "size/{arch}",+ "phase": "gate",+ "per_arch": true,+ "requires": [+ "docker"+ ],+ "tiers": [+ "slim"+ ],+ "description": "the slim tier stays bounded: the unpacked image (docker's Size) is at most 1.55 GB per arch. Before the cua CLI joined it, slim was 1.23 GB (amd64) and 1.27 GB (arm64) unpacked and 0.49 GB compressed; the released CLI archive adds about 200 MB unpacked (85 MB compressed on x64, 78 MB on arm64), 1.43 GB on amd64 measured in CI. A smaller in-Space CLI is the way to cut it.",+ "run": [+ "bash",+ "-c",+ "size=$(docker image inspect \"$0\" | python3 -c 'import json,sys; print(json.load(sys.stdin)[0][\"Size\"])') && echo \"unpacked image: $size bytes (budget $1)\" && [ \"$size\" -le \"$1\" ]",+ "{repo}:docker-{tag}-{arch}",+ "1550000000"+ ]+ },{"id": "parity/{arch}","phase": "gate",diff --git a/libs/images/linux/smoke-cua-cli.sh b/libs/images/linux/smoke-cua-cli.shnew file mode 100755index 0000000000..064376c6ca--- /dev/null+++ b/libs/images/linux/smoke-cua-cli.sh@@ -0,0 +1,92 @@+#!/usr/bin/env bash+# Smoke test for the cua CLI in linux (container rootfs variant), under runc or runsc (gVisor):+# the slim tier, and so every tier, lets an agent in a Space make child Spaces.+#+# Offline-safe: no registry, no account, no host. It checks, as the desktop user (the agent):+# health the container HEALTHCHECK passes and cua-spacesd's own check script answers+# version `cua --version` runs, from /usr/local/bin, on the user's PATH+# spawn `cua spaces ls` inside a Space that has a spawn channel goes to that channel:+# the Space's channel is CUA_SPAWN + CUA_SPAWN_TOKEN_FILE (what cua-spacesd sets+# for processes it starts once the host opened the channel); here a listener+# stands in for it and must receive the CLI's HTTP/2 (gRPC) connection+# no channel without a channel the CLI does not try one: `cua spaces ls` never connects+#+# Usage: smoke-cua-cli.sh [--image REF] [--runtime runc|runsc] [--evidence DIR] [--keep]+set -euo pipefail+host_arch() { case "$(uname -m)" in arm64|aarch64) echo arm64 ;; *) echo amd64 ;; esac; }+IMAGE="cua-e2e-local/linux:docker-local-$(host_arch)"+RUNTIME=runc+EVIDENCE="${SMOKE_EVIDENCE:-$PWD/smoke-evidence}"+KEEP=0+while [ $# -gt 0 ]; do+ case "$1" in+ --image) IMAGE="$2"; shift 2 ;;+ --runtime) RUNTIME="$2"; shift 2 ;;+ --evidence) EVIDENCE="$2"; shift 2 ;;+ --keep) KEEP=1; shift ;;+ *) echo "unknown option $1" >&2; exit 2 ;;+ esac+done+mkdir -p "$EVIDENCE"+NAME="cua-e2e-cua-cli-$RUNTIME-$$"+PASS=0; FAIL=0+t_start=$SECONDS++ok() { PASS=$((PASS + 1)); echo " ok $*"; }+bad() { FAIL=$((FAIL + 1)); echo " FAIL $*"; }+check() { local d="$1"; shift; if "$@" >/dev/null 2>&1; then ok "$d"; else bad "$d"; fi; }+cleanup() {+ docker exec "$NAME" sh -c 'tail -n 60 /var/log/supervisor/cua-spacesd.log' \+ >"$EVIDENCE/$RUNTIME-cua-cli-logs.txt" 2>&1 || true+ [ "$KEEP" = 1 ] || docker rm -f "$NAME" >/dev/null 2>&1 || true+}+trap cleanup EXIT+# Everything below runs as the desktop user, the way an agent's shell does.+as_cua() { docker exec -u cua -e CUA_TELEMETRY=0 "$NAME" "$@"; }++echo "==> $IMAGE under --runtime=$RUNTIME (cua CLI)"+docker run -d --name "$NAME" --runtime="$RUNTIME" --shm-size=512m \+ --memory="${SMOKE_MEMORY:-4g}" --memory-swap="${SMOKE_MEMORY:-4g}" \+ -e CUA_AUDIO=false -e CUA_ENV_TOKEN="smoke-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')" \+ "$IMAGE" >/dev/null++status=""+for _ in $(seq 1 120); do+ status="$(docker inspect -f '{{.State.Health.Status}}' "$NAME" 2>/dev/null || echo gone)"+ [ "$status" = healthy ] || [ "$status" = gone ] && break+ sleep 1+done+[ "$status" = healthy ] && ok "container healthy after $((SECONDS - t_start))s (HEALTHCHECK)" || { bad "container health=$status"; exit 1; }+check "cua-spacesd health check script answers" docker exec "$NAME" /opt/cua/healthcheck.d/10-spacesd.sh++echo "==> cua --version"+check "cua is /usr/local/bin/cua on the desktop user's PATH" bash -c "[ \"\$(docker exec -u cua $NAME sh -c 'command -v cua')\" = /usr/local/bin/cua ]"+ver="$(as_cua cua --version 2>&1 | head -1 || true)"+echo " $ver"+grep -Eq '^cua [0-9]+\.[0-9]+\.[0-9]+' <<<"$ver" && ok "cua --version: $ver" || bad "cua --version: '$ver'"+check "cua links against nothing missing" bash -c "! docker exec $NAME ldd /usr/local/bin/cua | grep -q 'not found'"+echo " source: $(docker exec "$NAME" cat /etc/cua-image/cua-cli-source 2>/dev/null) $(docker exec "$NAME" cat /etc/cua-image/cua-cli-release 2>/dev/null || true)"++echo "==> cua spaces ls reaches the Space's spawn channel"+PROBE_PORT=18999+probe() { # probe <label> <env...>: listen on the port, run the CLI, print the bytes the listener got+ local label="$1"; shift+ docker exec "$NAME" rm -f "/tmp/probe-$label"+ docker exec -d -u cua "$NAME" sh -c "timeout 25 nc -l 127.0.0.1 $PROBE_PORT >/tmp/probe-$label 2>/dev/null"+ sleep 1+ docker exec -u cua -e CUA_TELEMETRY=0 -e CUA_HOME=/tmp/cua-home-$label "$@" "$NAME" sh -c 'timeout 12 cua spaces ls >/tmp/ls-out 2>&1; echo $?' >"$EVIDENCE/$RUNTIME-cua-cli-$label-rc.txt" || true+ sleep 1+ docker exec "$NAME" sh -c "head -c 64 /tmp/probe-$label | od -An -c | head -2; cp /tmp/ls-out /tmp/ls-$label 2>/dev/null; true"+ docker exec "$NAME" sh -c "wc -c </tmp/probe-$label"+}+docker exec -u cua "$NAME" sh -c 'umask 077; echo smoke-capability >/tmp/spawn-token-probe'+got="$(probe channel -e CUA_SPAWN=http://127.0.0.1:$PROBE_PORT -e CUA_SPAWN_TOKEN_FILE=/tmp/spawn-token-probe | tail -1 | tr -d ' \r')"+[ "${got:-0}" -gt 0 ] && ok "with a spawn channel, cua spaces ls connected to it ($got bytes)" || bad "with a spawn channel, cua spaces ls never reached it"+docker exec "$NAME" cat /tmp/ls-channel >"$EVIDENCE/$RUNTIME-cua-cli-channel-out.txt" 2>&1 || true+grep -q "PRI \* HTTP/2" < <(docker exec "$NAME" sh -c 'head -c 24 /tmp/probe-channel') && ok "the connection is gRPC over HTTP/2 (the spawn channel's protocol)" || bad "the bytes at the spawn address are not HTTP/2"++got="$(probe none | tail -1 | tr -d ' \r')"+[ "${got:-0}" = 0 ] && ok "without a spawn channel, cua spaces ls does not connect to one" || bad "without a spawn channel, something connected ($got bytes)"++echo "==> $PASS passed, $FAIL failed in $((SECONDS - t_start))s ($RUNTIME, $IMAGE)"+[ "$FAIL" = 0 ]diff --git a/libs/images/sandbox-images.json b/libs/images/sandbox-images.jsonindex 96fddf14c6..c8a8f1add5 100644--- a/libs/images/sandbox-images.json+++ b/libs/images/sandbox-images.json@@ -67,7 +67,7 @@"distro": { "id": "ubuntu", "name": "Ubuntu 24.04" },"tier": "slim","variant": "container",- "summary": "The minimal Linux desktop: cua-spacesd and Chromium, no dev tooling. What CI and benchmarks run.",+ "summary": "The minimal Linux desktop: cua-spacesd, the cua CLI and Chromium, no dev tooling. What CI and benchmarks run, and the home of an agent that makes child Spaces.","spacesd": true,"digest": "sha256:3bb6e503da0a90dd38cd88d664308f45f7af4661fe89f81e758c3927b6efb156","sizes": {@@ -93,7 +93,7 @@"distro": { "id": "ubuntu", "name": "Ubuntu 24.04" },"tier": "slim","variant": "vm",- "summary": "The minimal Linux desktop as a full VM.",+ "summary": "The minimal Linux desktop, with the cua CLI, as a full VM.","spacesd": true,"digest": "sha256:3bdeff2c03f2d345c404a7e8090142f80ad8d3ccf56fe345ac095dd3e42046c4","sizes": {@@ -332,36 +332,6 @@"cloud": "kubevirt","published": true},- {- "ref": "ghcr.io/trycua/agent-home:24.04",- "group": "distro",- "os": "linux",- "name": "Agent home",- "distro": { "id": "ubuntu", "name": "Ubuntu 24.04" },- "variant": "container",- "summary": "The slim Linux image plus the cua CLI: a home an agent makes child Spaces from.",- "spacesd": true,- "browsers": ["chromium"],- "arch": ["amd64", "arm64"],- "local": "container",- "cloud": "gvisor",- "published": false- },- {- "ref": "ghcr.io/trycua/agent-home:24.04-disk",- "group": "distro",- "os": "linux",- "name": "Agent home VM",- "distro": { "id": "ubuntu", "name": "Ubuntu 24.04" },- "variant": "vm",- "summary": "The same agent home as a full VM.",- "spacesd": true,- "browsers": ["chromium"],- "arch": ["amd64", "arm64"],- "local": "qemu",- "cloud": "kubevirt",- "published": false- },{"ref": "ghcr.io/trycua/bench-web:1.0","group": "benchmark",