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(cua-driver-rs)(install/uninstall): local install/uninstall use the current macOS layout (CuaDriver.app + ~/.cua-driver) (#1758)

Francesco Bonacci057fdf106d08
diff --git a/libs/cua-driver/scripts/_install-local-rust.sh b/libs/cua-driver/scripts/_install-local-rust.sh
index b98ef20572..719fdd3fd8 100755
--- a/libs/cua-driver/scripts/_install-local-rust.sh
+++ b/libs/cua-driver/scripts/_install-local-rust.sh
@@ -256,11 +256,65 @@ ln -sfn "$VERSIONED_DIR" "$CURRENT_LINK"
echo "${GREEN}current -> $VERSIONED_DIR${NORMAL}"
echo ""
-# --- Visible-bin symlink ------------------------------------------------
+# --- macOS: wrap the binary in CuaDriver.app for a stable TCC identity ---
+#
+# TCC keys Accessibility / Screen-Recording grants on the bundle
+# identifier (com.trycua.driver), not the bare executable path. A loose
+# binary gets grants attributed to its ad-hoc cdhash, which changes on
+# every rebuild — so permissions silently reset and never appear cleanly
+# under System Settings. Mirror the production path (install.sh) + the CD
+# bundle-assembly step: drop the freshly built binary into the checked-in
+# CuaDriverBundle skeleton, install the bundle to /Applications, and point
+# the visible bin at the binary INSIDE the bundle. Linux/Windows have no
+# .app concept and keep the bare-binary symlink below.
+APP_DEST="/Applications/CuaDriver.app"
+if [ "$OS" = "Darwin" ]; then
+ SKELETON="$REPO_ROOT/scripts/CuaDriverBundle"
+ if [ ! -d "$SKELETON/Contents" ]; then
+ echo "${RED}Error: bundle skeleton missing at $SKELETON${NORMAL}" >&2
+ exit 1
+ fi
+ APP_STAGE="$VERSIONED_DIR/CuaDriver.app"
+ rm -rf "$APP_STAGE"
+ mkdir -p "$APP_STAGE/Contents/MacOS"
+ cp -R "$SKELETON/Contents/." "$APP_STAGE/Contents/"
+ cp "$VERSIONED_DIR/cua-driver" "$APP_STAGE/Contents/MacOS/cua-driver"
+ chmod +x "$APP_STAGE/Contents/MacOS/cua-driver"
+ rm -f "$APP_STAGE/Contents/MacOS/.gitkeep"
+ # Stamp the local build version so the bundle reports something sane.
+ if command -v plutil >/dev/null 2>&1; then
+ plutil -replace CFBundleShortVersionString -string "$VERSION_TAG" \
+ "$APP_STAGE/Contents/Info.plist" 2>/dev/null || true
+ plutil -replace CFBundleVersion -string "$VERSION_TAG" \
+ "$APP_STAGE/Contents/Info.plist" 2>/dev/null || true
+ fi
+ # Install to /Applications (user-writable for admins; no sudo — same
+ # as install.sh). Replace any prior bundle wholesale.
+ rm -rf "$APP_DEST"
+ ditto "$APP_STAGE" "$APP_DEST"
+ # Ad-hoc re-sign the whole bundle (--deep covers the inner binary).
+ # Required on macOS 26+ where Taskgated rejects a copied binary's
+ # stale signature, and gives the bundle a consistent cdhash for TCC.
+ if command -v codesign >/dev/null 2>&1; then
+ codesign --force --deep --sign - "$APP_DEST" 2>/dev/null \
+ || echo "${YELLOW}warning: codesign of $APP_DEST failed; first run may hit a Gatekeeper/Taskgated prompt${NORMAL}" >&2
+ fi
+ echo "${GREEN}installed $APP_DEST${NORMAL}"
+fi
+# --- Visible-bin symlink ------------------------------------------------
+#
+# On macOS point at the binary INSIDE the installed bundle so the process
+# that actually runs carries the com.trycua.driver identity (TCC keys
+# grants on it). On Linux/Windows point at the versioned-store binary.
mkdir -p "$BIN_DIR"
-ln -sf "$CURRENT_LINK/cua-driver" "$BIN_DIR/cua-driver"
-echo "${GREEN}$BIN_DIR/cua-driver -> $CURRENT_LINK/cua-driver${NORMAL}"
+if [ "$OS" = "Darwin" ]; then
+ BIN_TARGET="$APP_DEST/Contents/MacOS/cua-driver"
+else
+ BIN_TARGET="$CURRENT_LINK/cua-driver"
+fi
+ln -sf "$BIN_TARGET" "$BIN_DIR/cua-driver"
+echo "${GREEN}$BIN_DIR/cua-driver -> $BIN_TARGET${NORMAL}"
echo ""
INSTALLED_BIN="$BIN_DIR/cua-driver"
diff --git a/libs/cua-driver/scripts/uninstall.sh b/libs/cua-driver/scripts/uninstall.sh
index 342d872170..ab12948e55 100755
--- a/libs/cua-driver/scripts/uninstall.sh
+++ b/libs/cua-driver/scripts/uninstall.sh
@@ -25,22 +25,27 @@
# Rust uninstall removes:
# Linux:
# - ~/.local/bin/cua-driver symlink (only when it resolves to a
-# cua-driver-rs path — a Swift-driver symlink is left in place)
-# - ~/.cua-driver-rs/ (entire package home: telemetry id, install
-# marker, versioned releases, current symlink, lockfile)
+# cua-driver path — a Swift-driver symlink is left in place)
+# - ~/.cua-driver/ (current package home) + legacy ~/.cua-driver-rs/
+# (telemetry id, config.json, versioned releases, current symlink)
# - ~/.config/systemd/user/cua-driver-rs.service (if --autostart
# was used via install-local.sh — stop + disable + remove)
-# - Skill symlinks under ~/.claude/skills/cua-driver-rs, ~/.agents/
-# skills/cua-driver-rs, ~/.openclaw/skills/cua-driver-rs,
-# ~/.config/opencode/skills/cua-driver-rs
+# - Skill symlinks under ~/.claude/skills/cua-driver(-rs), ~/.agents/
+# skills/…, ~/.openclaw/skills/…, ~/.config/opencode/skills/…
# macOS:
# - /Applications/CuaDriver.app bundle (+ legacy CuaDriverRs.app)
# - ~/.local/bin/cua-driver symlink (only when it resolves into
# /Applications/CuaDriver.app)
-# - ~/.cua-driver-rs/ (entire package home)
+# - ~/.cua-driver/ (current package home) + legacy ~/.cua-driver-rs/
# - ~/Library/LaunchAgents/com.trycua.cua-driver-rs.plist (if
# --autostart was used via install-local.sh — unload + remove)
-# - Skill symlinks under ~/.claude/skills/cua-driver-rs, etc.
+# - Skill symlinks under ~/.claude/skills/cua-driver(-rs), etc.
+#
+# Shared-path safety: /Applications/CuaDriver.app + its ~/.local/bin
+# symlink use the same bundle id (com.trycua.driver) as the Swift driver,
+# so they're only removed when an unambiguous Rust marker is on disk
+# (~/.cua-driver/packages/, legacy ~/.cua-driver-rs/, CuaDriverRs.app,
+# or the LaunchAgent/systemd unit).
#
# Also scrubs Claude MCP registrations in ~/.claude.json that match
# the active backend.
@@ -131,7 +136,17 @@ if [[ "$USE_RUST_BACKEND" == "1" ]]; then
# Legacy bundle path from earlier Rust releases that coexisted with
# Swift under a separate name. Cleaned up if found.
LEGACY_APP_BUNDLE="/Applications/CuaDriverRs.app"
- HOME_DIR="${CUA_DRIVER_RS_HOME:-$HOME/.cua-driver-rs}"
+ # Canonical package home is ~/.cua-driver (renamed from ~/.cua-driver-rs
+ # in v0.2.16 / PR #1644). The old name is swept too — uninstall.sh
+ # was missed in that rename and kept defaulting to the stale dir, so a
+ # current install left nothing matching and the whole uninstall no-op'd.
+ HOME_DIR="${CUA_DRIVER_HOME:-${CUA_DRIVER_RS_HOME:-$HOME/.cua-driver}}"
+ LEGACY_HOME_DIR="$HOME/.cua-driver-rs"
+ # The versioned package store (`packages/releases/*` + `current`) is
+ # written only by the Rust install-local / self-updater path — it's the
+ # one unambiguous on-disk Rust discriminator now that the .app bundle +
+ # bundle id are shared with Swift.
+ PACKAGES_DIR="$HOME_DIR/packages"
LAUNCHAGENT_PLIST="$HOME/Library/LaunchAgents/com.trycua.cua-driver-rs.plist"
SYSTEMD_USER_UNIT="$HOME/.config/systemd/user/cua-driver-rs.service"
SKILL_PACK_NAME="cua-driver"
@@ -140,21 +155,21 @@ if [[ "$USE_RUST_BACKEND" == "1" ]]; then
# `uninstall.sh --backend=rust`.
LEGACY_SKILL_PACK_NAME="cua-driver-rs"
- # Rust-install marker. The post-rename Rust bundle path
- # `/Applications/CuaDriver.app` is shared with the Swift driver
- # (same bundle id `com.trycua.driver`), so we can't use that path
- # alone as a Rust-install discriminator — a Swift-only Mac that
- # runs `uninstall.sh --experimental-rust` by mistake would lose
- # its Swift bundle, symlink, and Claude MCP registrations. This
- # marker says "there's at least one unambiguously-Rust artifact
- # on disk." We gate every shared-path removal below on it.
+ # Rust-install marker. The Rust bundle path `/Applications/CuaDriver.app`
+ # is shared with the Swift driver (same bundle id `com.trycua.driver`),
+ # so we can't use that path alone as a discriminator — a Swift-only Mac
+ # that runs `uninstall.sh --backend=rust` by mistake would lose its
+ # Swift bundle, symlink, and Claude MCP registrations. This marker says
+ # "there's at least one unambiguously-Rust artifact on disk." We gate
+ # every shared-path removal below on it.
#
# Markers (any one suffices):
- # - $HOME_DIR exists (~/.cua-driver-rs/ — Rust-only state dir)
- # - /Applications/CuaDriverRs.app exists (legacy, pre-rename)
- # - LaunchAgent plist exists (autostart was used)
+ # - ~/.cua-driver/packages/ exists (Rust install-local / updater store)
+ # - ~/.cua-driver-rs/ exists (legacy Rust state dir, pre-rename)
+ # - /Applications/CuaDriverRs.app exists (legacy bundle, pre-rename)
+ # - LaunchAgent plist / systemd unit exists (autostart was used)
RUST_INSTALL_PRESENT=0
- if [[ -d "$HOME_DIR" || -d "$LEGACY_APP_BUNDLE" || -f "$LAUNCHAGENT_PLIST" || -f "$SYSTEMD_USER_UNIT" ]]; then
+ if [[ -d "$PACKAGES_DIR" || -d "$LEGACY_HOME_DIR" || -d "$LEGACY_APP_BUNDLE" || -f "$LAUNCHAGENT_PLIST" || -f "$SYSTEMD_USER_UNIT" ]]; then
RUST_INSTALL_PRESENT=1
fi
@@ -252,7 +267,7 @@ if [[ "$USE_RUST_BACKEND" == "1" ]]; then
$SUDO rm -rf "$APP_BUNDLE"
log "removed $APP_BUNDLE"
else
- log "$APP_BUNDLE exists but no Rust marker on disk (~/.cua-driver-rs/, CuaDriverRs.app, LaunchAgent, systemd unit); leaving it (looks like a Swift-only install)"
+ log "$APP_BUNDLE exists but no Rust marker on disk (~/.cua-driver/packages/, ~/.cua-driver-rs/, CuaDriverRs.app, LaunchAgent, systemd unit); leaving it (looks like a Swift-only install)"
fi
else
log "no app bundle at $APP_BUNDLE (skipping)"
@@ -260,15 +275,45 @@ if [[ "$USE_RUST_BACKEND" == "1" ]]; then
fi
# --- Package home ---
- # Everything under $CUA_DRIVER_RS_HOME (default ~/.cua-driver-rs):
- # telemetry id, install marker, versioned releases, current
- # symlink, lockfile, local skill copy, version_check.json cache.
+ # Everything under $HOME_DIR (default ~/.cua-driver): telemetry id,
+ # config.json, versioned releases, current symlink, local skill copy,
+ # version_check.json cache. This is the live runtime home now (post
+ # v0.2.16 rename), so gate its removal on the Rust marker — don't nuke
+ # a Swift-only Mac's ~/.cua-driver/config.json on a mistaken run.
if [[ -d "$HOME_DIR" ]]; then
- rm -rf "$HOME_DIR"
- log "removed $HOME_DIR"
+ if [[ "$RUST_INSTALL_PRESENT" == "1" ]]; then
+ rm -rf "$HOME_DIR"
+ log "removed $HOME_DIR"
+ else
+ log "$HOME_DIR exists but no Rust marker on disk; leaving it (looks like a Swift-only / shared config dir)"
+ fi
else
log "no package home at $HOME_DIR (skipping)"
fi
+ # Legacy pre-rename home is unambiguously Rust — always sweep it.
+ if [[ -d "$LEGACY_HOME_DIR" ]]; then
+ rm -rf "$LEGACY_HOME_DIR"
+ log "removed legacy package home $LEGACY_HOME_DIR"
+ fi
+
+ # --- Swift-era macOS data dirs (leave nothing behind) ---
+ # The .app bundle + bundle id are shared with the retired Swift driver,
+ # so a default (Rust) uninstall already removes the shared bundle. Sweep
+ # the two Swift-only support/cache dirs here too so one `uninstall.sh`
+ # leaves nothing behind regardless of which backend originally installed
+ # — no second `--backend=swift` pass needed. Gated on the Rust marker
+ # for the same reason the shared bundle is: a Swift-only Mac that runs
+ # the default uninstall by mistake keeps its data.
+ if [[ "$OS" == "Darwin" && "$RUST_INSTALL_PRESENT" == "1" ]]; then
+ for SWIFT_DATA_DIR in \
+ "$HOME/Library/Application Support/Cua Driver" \
+ "$HOME/Library/Caches/cua-driver"; do
+ if [[ -d "$SWIFT_DATA_DIR" ]]; then
+ rm -rf "$SWIFT_DATA_DIR"
+ log "removed $SWIFT_DATA_DIR"
+ fi
+ done
+ fi
# --- Agent skill symlinks ---
# Only remove when the link is a symlink — never clobber a real