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.

feat(spaces-macos): bundle the pinned Cua Driver in Contents/Helpers (CUA-2770) (#6144)

cua-agents[bot]a6a2713a25b2
diff --git a/.github/workflows/ci-cua-spaces-macos.yml b/.github/workflows/ci-cua-spaces-macos.yml
index a74037e981..ff055b02e6 100644
--- a/.github/workflows/ci-cua-spaces-macos.yml
+++ b/.github/workflows/ci-cua-spaces-macos.yml
@@ -201,6 +201,12 @@ jobs:
working-directory: apps/cua-spaces-macos
run: |
"$GITHUB_WORKSPACE/.github/scripts/flaky/flaky.sh" run --suite spaces-swift-mac --format log --rerun-failed -- scripts/test.sh
+ # The bundled Cua Driver is checked against the size and SHA-256
+ # committed in cua-driver.release.json and the Cua team's signature;
+ # a mismatched, incomplete or unsigned download is refused.
+ - name: fetch-cua-driver.sh refuses a download that isn't the pinned release
+ working-directory: apps/cua-spaces-macos
+ run: scripts/tests/fetch-cua-driver-test.sh
# install-local.sh and uninstall-local.sh against a fake HOME and a fake
# build: a Stable install stays byte-identical, a wrong bundle id is
# refused. Needs no build, certificate or network.
diff --git a/apps/cua-spaces-macos/cua-driver.release.json b/apps/cua-spaces-macos/cua-driver.release.json
new file mode 100644
index 0000000000..29bd021576
--- /dev/null
+++ b/apps/cua-spaces-macos/cua-driver.release.json
@@ -0,0 +1,9 @@
+{
+ "version": "0.38.0",
+ "tag": "cua-driver-rs-v0.38.0",
+ "asset": "cua-driver-rs-0.38.0-darwin-universal-binary.tar.gz",
+ "bytes": 53208248,
+ "sha256": "2bb8dc4a7e69185ffd04c4a9c0eab590bd2c54b72c2c1be13ab675be4f487732",
+ "teamId": "YCK386LBJ7",
+ "files": ["cua-driver", "cua-cursor-theme"]
+}
diff --git a/apps/cua-spaces-macos/scripts/build-app.sh b/apps/cua-spaces-macos/scripts/build-app.sh
index b37b02c753..22e4171caf 100755
--- a/apps/cua-spaces-macos/scripts/build-app.sh
+++ b/apps/cua-spaces-macos/scripts/build-app.sh
@@ -224,6 +224,20 @@ mkdir -p "$app/Contents/Library/LaunchAgents" "$app/Contents/Helpers"
spacesd="$("$here/scripts/fetch-spacesd.sh" ${archs:-$(uname -m)})"
cp "$spacesd" "$app/Contents/Helpers/cua-spacesd"
chmod 0755 "$app/Contents/Helpers/cua-spacesd"
+# Cua Driver, the computer-use server coding agents on this Mac use: the
+# release pinned in cua-driver.release.json (scripts/fetch-cua-driver.sh
+# checks its size, SHA-256 and Developer ID signature), next to the host
+# service. cua-spacesd runs it as its own child, so macOS counts its
+# Accessibility and Screen Recording as Cua Spaces'. In Contents/Helpers for
+# the same reason as cua-spacesd: its cursor overlay starts AppKit. The
+# release keeps its own signature here (it is not stripped or re-signed);
+# build-release.sh signs it with the release identity.
+# shellcheck disable=SC2086 # one word per architecture
+driver_dir="$("$here/scripts/fetch-cua-driver.sh" ${archs:-$(uname -m)})"
+for f in cua-driver cua-cursor-theme; do
+ cp "$driver_dir/$f" "$app/Contents/Helpers/$f"
+ chmod 0755 "$app/Contents/Helpers/$f"
+done
helper_plist="$app/Contents/Library/LaunchAgents/$helper_label.plist"
cp "$here/Support/Helper/com.trycua.spaces.helper.plist" "$helper_plist"
if [ "$channel" = local ]; then
@@ -310,7 +324,8 @@ fi
# only fail on the other kind of Mac).
if [ -n "$archs" ]; then
for f in "$app/Contents/MacOS/CuaSpacesMac" "$app/Contents/Frameworks/libcua_sdk.dylib" "$app/Contents/MacOS/cua" \
- "$app/Contents/Frameworks/Sparkle.framework/Versions/B/Sparkle" "$app/Contents/Helpers/cua-spacesd"; do
+ "$app/Contents/Frameworks/Sparkle.framework/Versions/B/Sparkle" "$app/Contents/Helpers/cua-spacesd" \
+ "$app/Contents/Helpers/cua-driver" "$app/Contents/Helpers/cua-cursor-theme"; do
[ -e "$f" ] || continue
for arch in $archs; do
lipo "$f" -verify_arch "$arch" || { echo "$f has no $arch slice ($(lipo -archs "$f"))" >&2; exit 1; }
diff --git a/apps/cua-spaces-macos/scripts/build-release.sh b/apps/cua-spaces-macos/scripts/build-release.sh
index cc842567e7..a19a91adce 100755
--- a/apps/cua-spaces-macos/scripts/build-release.sh
+++ b/apps/cua-spaces-macos/scripts/build-release.sh
@@ -22,7 +22,11 @@
# which the app's own executable runs as its
# login item; never in Contents/MacOS, where
# it would register as the app)
-# Cua Spaces.app com.trycua.spaces.macos, Support/CuaSpacesMac.entitlements
+# Contents/Helpers/cua-cursor-theme cua-cursor-theme (Cua Driver's cursor themes)
+# Contents/Helpers/cua-driver cua-driver, its own entitlements kept (Cua
+# Driver, pinned in cua-driver.release.json;
+# the host service runs it as its child)
+# Cua Spaces.app com.trycua.spaces.macos, Support/CuaSpacesMac.entitlements
#
# scripts/build-release.sh --version 0.2.0[-suffix][+build] [--build-number N]
# [--bundle-version A.B.C.D[.E]] [--arch universal|arm64|x86_64]
@@ -175,6 +179,9 @@ if [ -n "$feed_url" ]; then
/usr/libexec/PlistBuddy -c "Set :SUFeedURL $feed_url" "$plist"
fi
[ -x "$app/Contents/Helpers/cua-spacesd" ] || { echo "$app has no Contents/Helpers/cua-spacesd" >&2; exit 1; }
+for f in cua-driver cua-cursor-theme; do
+ [ -x "$app/Contents/Helpers/$f" ] || { echo "$app has no Contents/Helpers/$f" >&2; exit 1; }
+done
[ -f "$app/Contents/Library/LaunchAgents/com.trycua.spaces.helper.plist" ] ||
{ echo "$app has no com.trycua.spaces.helper.plist" >&2; exit 1; }
# The symbols build-app.sh took out of the binaries, for symbolicating crash
@@ -226,6 +233,11 @@ fi
# are the app's (designated requirement: identifier and team, checked
# below), and they stay granted across updates.
"${sign[@]}" --identifier com.trycua.cua-env-driver "$app/Contents/Helpers/cua-spacesd"
+# Cua Driver, which the host service runs as its child. Same identifiers as
+# the standalone release, and the driver keeps its entitlements.
+driver_parts=("$app/Contents/Helpers/cua-cursor-theme" "$app/Contents/Helpers/cua-driver")
+"${sign[@]}" --identifier cua-cursor-theme "$app/Contents/Helpers/cua-cursor-theme"
+"${sign[@]}" --identifier cua-driver --preserve-metadata=entitlements "$app/Contents/Helpers/cua-driver"
app_entitlements="$here/Support/CuaSpacesMac.entitlements"
if [ "$identity" = "-" ]; then
app_entitlements="$out/.adhoc.entitlements"
@@ -237,7 +249,7 @@ fi
codesign --verify --deep --strict --verbose=2 "$app" >&2
for f in "$app" "$app/Contents/MacOS/cua" "$app/Contents/Frameworks/libcua_sdk.dylib" "${sparkle_parts[@]}" \
- "$app/Contents/Helpers/cua-spacesd" ${vz_parts[@]+"${vz_parts[@]}"}; do
+ "$app/Contents/Helpers/cua-spacesd" "${driver_parts[@]}" ${vz_parts[@]+"${vz_parts[@]}"}; do
flags="$(codesign -dv "$f" 2>&1 | sed -n 's/^CodeDirectory.*flags=\([^ ]*\).*/\1/p')"
case "$flags" in *runtime*) ;; *) echo "$f is not signed with the hardened runtime ($flags)" >&2; exit 1 ;; esac
done
@@ -280,7 +292,7 @@ fi
# A Developer ID build signs Sparkle with the same team (library
# validation stays on: the app loads only its own team's code).
if [ "$identity" != "-" ]; then
- for f in "${sparkle_parts[@]}" "$app/Contents/Helpers/cua-spacesd"; do
+ for f in "${sparkle_parts[@]}" "$app/Contents/Helpers/cua-spacesd" "${driver_parts[@]}"; do
codesign --verify -R="anchor apple generic and certificate leaf[subject.OU] = \"$team\"" "$f" ||
{ echo "$f is not signed by team $team" >&2; exit 1; }
done
diff --git a/apps/cua-spaces-macos/scripts/check-bundle-layout.sh b/apps/cua-spaces-macos/scripts/check-bundle-layout.sh
index 0557e7535f..b32b3d79c1 100755
--- a/apps/cua-spaces-macos/scripts/check-bundle-layout.sh
+++ b/apps/cua-spaces-macos/scripts/check-bundle-layout.sh
@@ -6,7 +6,8 @@
#
# Contents/MacOS only the app's own executable (CFBundleExecutable),
# the `cua` CLI and the microVM monitor `cua-vz`
-# Contents/Helpers the host service, cua-spacesd
+# Contents/Helpers the host service, cua-spacesd, and Cua Driver
+# (cua-driver, cua-cursor-theme), which it runs
#
# Why: AppKit and LaunchServices take a process's bundle from its
# executable's path, and any executable in Contents/MacOS is the app. When
@@ -41,4 +42,10 @@ if [ ! -x "$app/Contents/Helpers/cua-spacesd" ]; then
echo "$app has no Contents/Helpers/cua-spacesd (the host service)" >&2
bad=1
fi
+for f in cua-driver cua-cursor-theme; do
+ if [ ! -x "$app/Contents/Helpers/$f" ]; then
+ echo "$app has no Contents/Helpers/$f (Cua Driver, which the host service runs)" >&2
+ bad=1
+ fi
+done
exit "$bad"
diff --git a/apps/cua-spaces-macos/scripts/fetch-cua-driver.sh b/apps/cua-spaces-macos/scripts/fetch-cua-driver.sh
new file mode 100755
index 0000000000..32d860e4e9
--- /dev/null
+++ b/apps/cua-spaces-macos/scripts/fetch-cua-driver.sh
@@ -0,0 +1,82 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: FSL-1.1-MIT
+# Copyright (c) 2026 Cua AI, Inc.
+
+# Prints the folder holding the Cua Driver the app bundles in
+# Contents/Helpers (cua-driver and cua-cursor-theme): $CUA_DRIVER_DIR when
+# set, else the release pinned in cua-driver.release.json, downloaded once
+# into .build/cua-driver/<version>/.
+#
+# scripts/fetch-cua-driver.sh [arm64 x86_64]
+#
+# The download is checked against the size and SHA-256 committed in
+# cua-driver.release.json, never against a checksum file from the release
+# itself: whoever can replace a release asset can replace its .sha256 too.
+# Each file must also be Developer ID signed by the team the table names,
+# with the hardened runtime, and carry every requested architecture.
+#
+# To move to a new driver release, change version, tag, asset, bytes and
+# sha256 together, copying bytes and sha256 from the release's assets.
+#
+# For tests: CUA_DRIVER_RELEASE_TABLE (another table) and
+# CUA_DRIVER_RELEASE_BASE_URL (where the asset is, instead of the GitHub
+# release download URL).
+set -euo pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+archs="${*:-$(uname -m)}"
+table="${CUA_DRIVER_RELEASE_TABLE:-$here/cua-driver.release.json}"
+
+field() {
+ plutil -extract "$1" raw -o - "$table" 2>/dev/null ||
+ { echo "$table has no $1" >&2; exit 1; }
+}
+version="$(field version)"
+tag="$(field tag)"
+asset="$(field asset)"
+bytes="$(field bytes)"
+sha256="$(field sha256)"
+team="$(field teamId)"
+files=()
+n="$(plutil -extract files raw -o - "$table")"
+for ((i = 0; i < n; i++)); do files+=("$(field "files.$i")"); done
+[ "${#files[@]}" -gt 0 ] || { echo "$table lists no files" >&2; exit 1; }
+
+if [ -n "${CUA_DRIVER_DIR:-}" ]; then
+ dir="$CUA_DRIVER_DIR"
+else
+ dir="$here/.build/cua-driver/$version"
+ if [ ! -f "$dir/.verified" ]; then
+ rm -rf "$dir"
+ tmp="$(mktemp -d)"
+ trap 'rm -rf "$tmp"' EXIT
+ base="${CUA_DRIVER_RELEASE_BASE_URL:-https://github.com/trycua/cua/releases/download/$tag}"
+ curl -fsSL --retry 3 -o "$tmp/$asset" "$base/$asset"
+ got_bytes="$(stat -f %z "$tmp/$asset")"
+ [ "$got_bytes" = "$bytes" ] ||
+ { echo "Cua Driver $version: $asset is $got_bytes bytes, cua-driver.release.json says $bytes" >&2; exit 1; }
+ got_sha="$(shasum -a 256 "$tmp/$asset" | awk '{print $1}')"
+ [ "$got_sha" = "$sha256" ] ||
+ { echo "Cua Driver $version: $asset has SHA-256 $got_sha, cua-driver.release.json says $sha256" >&2; exit 1; }
+ mkdir -p "$tmp/x"
+ tar -xzf "$tmp/$asset" -C "$tmp/x" "${files[@]}" ||
+ { echo "Cua Driver $version: $asset lacks one of: ${files[*]}" >&2; exit 1; }
+ mkdir -p "$dir"
+ for f in "${files[@]}"; do install -m 0755 "$tmp/x/$f" "$dir/$f"; done
+ fi
+fi
+
+for f in "${files[@]}"; do
+ bin="$dir/$f"
+ [ -x "$bin" ] || { echo "$bin is not an executable" >&2; exit 1; }
+ if [ -z "${CUA_DRIVER_DIR:-}" ]; then
+ codesign --verify --strict -R="anchor apple generic and certificate leaf[subject.OU] = \"$team\"" "$bin" 2>/dev/null ||
+ { echo "$bin is not signed by Cua's Developer ID (team $team)" >&2; exit 1; }
+ flags="$(codesign -dv "$bin" 2>&1 | sed -n 's/^CodeDirectory.*flags=\([^ ]*\).*/\1/p')"
+ case "$flags" in *runtime*) ;; *) echo "$bin is not signed with the hardened runtime ($flags)" >&2; exit 1 ;; esac
+ fi
+ for arch in $archs; do
+ lipo "$bin" -verify_arch "$arch" 2>/dev/null || { echo "$bin has no $arch slice" >&2; exit 1; }
+ done
+done
+[ -n "${CUA_DRIVER_DIR:-}" ] || touch "$dir/.verified"
+echo "$dir"
diff --git a/apps/cua-spaces-macos/scripts/tests/fetch-cua-driver-test.sh b/apps/cua-spaces-macos/scripts/tests/fetch-cua-driver-test.sh
new file mode 100755
index 0000000000..53752f32f2
--- /dev/null
+++ b/apps/cua-spaces-macos/scripts/tests/fetch-cua-driver-test.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: FSL-1.1-MIT
+# Copyright (c) 2026 Cua AI, Inc.
+#
+# scripts/fetch-cua-driver.sh refuses a Cua Driver download whose size or
+# SHA-256 differs from the committed table, one that lacks a listed file,
+# and one that is not signed by the table's team. Uses a local archive and a
+# temporary table: no network, no certificate.
+#
+# scripts/tests/fetch-cua-driver-test.sh
+set -euo pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+work="$(mktemp -d)"
+trap 'rm -rf "$work"; rm -rf "$here/.build/cua-driver/9.9.9-test"' EXIT
+
+mkdir -p "$work/src" "$work/srv"
+printf '#!/bin/sh\necho driver\n' >"$work/src/cua-driver"
+printf '#!/bin/sh\necho theme\n' >"$work/src/cua-cursor-theme"
+chmod 0755 "$work/src/"*
+asset=cua-driver-rs-9.9.9-test-darwin-universal-binary.tar.gz
+tar -czf "$work/srv/$asset" -C "$work/src" cua-driver cua-cursor-theme
+bytes="$(stat -f %z "$work/srv/$asset")"
+sha="$(shasum -a 256 "$work/srv/$asset" | awk '{print $1}')"
+
+table() { # bytes sha files-json
+ cat >"$work/table.json" <<EOF
+{"version": "9.9.9-test", "tag": "t", "asset": "$asset", "bytes": $1,
+ "sha256": "$2", "teamId": "YCK386LBJ7", "files": $3}
+EOF
+}
+fails_with() { # expected-message
+ rm -rf "$here/.build/cua-driver/9.9.9-test"
+ local out
+ if out="$(CUA_DRIVER_RELEASE_TABLE="$work/table.json" CUA_DRIVER_RELEASE_BASE_URL="file://$work/srv" \
+ "$here/scripts/fetch-cua-driver.sh" arm64 2>&1)"; then
+ echo "FAIL: accepted, wanted: $1" >&2
+ exit 1
+ fi
+ case "$out" in *"$1"*) echo "ok: $1" ;; *) echo "FAIL: wanted '$1', got: $out" >&2; exit 1 ;; esac
+}
+
+table $((bytes + 1)) "$sha" '["cua-driver", "cua-cursor-theme"]'
+fails_with "bytes, cua-driver.release.json says $((bytes + 1))"
+
+table "$bytes" "0000000000000000000000000000000000000000000000000000000000000000" '["cua-driver", "cua-cursor-theme"]'
+fails_with "has SHA-256 $sha"
+
+table "$bytes" "$sha" '["cua-driver", "cua-cursor-theme", "missing-helper"]'
+fails_with "lacks one of"
+
+# Size and checksum match, but the files are unsigned shell scripts.
+table "$bytes" "$sha" '["cua-driver", "cua-cursor-theme"]'
+fails_with "is not signed by Cua's Developer ID (team YCK386LBJ7)"
+
+# The committed table names a real release asset and every field.
+for k in version tag asset bytes sha256 teamId files; do
+ plutil -extract "$k" raw -o - "$here/cua-driver.release.json" >/dev/null
+done
+v="$(plutil -extract version raw -o - "$here/cua-driver.release.json")"
+[ "$(plutil -extract tag raw -o - "$here/cua-driver.release.json")" = "cua-driver-rs-v$v" ]
+[ "$(plutil -extract asset raw -o - "$here/cua-driver.release.json")" = "cua-driver-rs-$v-darwin-universal-binary.tar.gz" ]
+echo "ok: the committed table is consistent ($v)"