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
Spaces: record create failure kind, gate macOS 15 disk and GPU from the catalog, ask Local Network at launch (#4873)
injaneity7b5e8b1ca45e
diff --git a/apps/cua-spaces-desktop/src/bridge/telemetry.ts b/apps/cua-spaces-desktop/src/bridge/telemetry.tsindex 8c020078cf..ce9b054261 100644--- a/apps/cua-spaces-desktop/src/bridge/telemetry.ts+++ b/apps/cua-spaces-desktop/src/bridge/telemetry.ts@@ -11,6 +11,7 @@ import type { BridgeContext } from "./context";import { Failure, type Handlers } from "./host";const WORD = /^[a-z0-9_]{1,64}$/;+const VARIANT = /^[A-Za-z0-9_]{0,64}$/;/** One page signal as the core's, or null when any part is not a fixed word, flag or duration. */export function telemetrySignal(native: Native, raw: unknown): AppTelemetrySignal | null {@@ -50,8 +51,9 @@ export function telemetrySignal(native: Native, raw: unknown): AppTelemetrySignacase "space-create": {const [location, guestOs, kind, outcome, failedPhase] = [word("location"), word("guestOs"), word("kind"), word("outcome"), word("failedPhase")];const [stalled, gpu, elapsedMs] = [flag("stalled"), flag("gpu"), ms("elapsedMs")];- if (!location || !guestOs || !kind || !outcome || !failedPhase || stalled === null || gpu === null || elapsedMs === null) return null;- return new S.SpaceCreate({ location, guestOs, kind, outcome, failedPhase, stalled, elapsedMs, gpu });+ const errorVariant = typeof s.errorVariant === "string" && VARIANT.test(s.errorVariant) ? s.errorVariant : null;+ if (!location || !guestOs || !kind || !outcome || !failedPhase || stalled === null || gpu === null || elapsedMs === null || errorVariant === null) return null;+ return new S.SpaceCreate({ location, guestOs, kind, outcome, failedPhase, stalled, elapsedMs, gpu, errorVariant });}case "space-create-started": {const [location, guestOs, kind, gpu] = [word("location"), word("guestOs"), word("kind"), flag("gpu")];diff --git a/apps/cua-spaces-desktop/src/model/app-model.ts b/apps/cua-spaces-desktop/src/model/app-model.tsindex 27a6360121..28d4f525cc 100644--- a/apps/cua-spaces-desktop/src/model/app-model.ts+++ b/apps/cua-spaces-desktop/src/model/app-model.ts@@ -558,7 +558,7 @@ export class AppModel {return id;} catch (error) {if (isCancelled(error)) this.sendCreate(new this.native.AppCreateAction.CancelDone({ id: pendingId }));- else this.sendCreate(new this.native.AppCreateAction.Fail({ id: pendingId, error: words(error) }));+ else this.sendCreate(new this.native.AppCreateAction.Fail({ id: pendingId, error: words(error), errorVariant: "" }));throw error;}}diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.tsindex 4a7acb2ba1..1e396eda8e 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi.ts@@ -12348,7 +12348,11 @@ export type AppSandboxImage = {/*** How big it is per platform, when measured.*/- sizes?: AppImageSizes+ sizes?: AppImageSizes,+ /**+ * `false`: its guest cannot use GPU acceleration.+ */+ gpu: boolean}/**@@ -12385,7 +12389,8 @@ const FfiConverterTypeAppSandboxImage = (() => {published: FfiConverterBool.read(from),distro: FfiConverterOptionalTypeAppImageDistro.read(from),arch: FfiConverterSequenceString.read(from),- sizes: FfiConverterOptionalTypeAppImageSizes.read(from)+ sizes: FfiConverterOptionalTypeAppImageSizes.read(from),+ gpu: FfiConverterBool.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -12403,6 +12408,7 @@ const FfiConverterTypeAppSandboxImage = (() => {FfiConverterOptionalTypeAppImageDistro.write(value.distro, into);FfiConverterSequenceString.write(value.arch, into);FfiConverterOptionalTypeAppImageSizes.write(value.sizes, into);+ FfiConverterBool.write(value.gpu, into);}allocationSize(value: TypeName): number {return FfiConverterString.allocationSize(value.imageRef) +@@ -12418,7 +12424,8 @@ const FfiConverterTypeAppSandboxImage = (() => {FfiConverterBool.allocationSize(value.published) +FfiConverterOptionalTypeAppImageDistro.allocationSize(value.distro) +FfiConverterSequenceString.allocationSize(value.arch) +- FfiConverterOptionalTypeAppImageSizes.allocationSize(value.sizes);+ FfiConverterOptionalTypeAppImageSizes.allocationSize(value.sizes) ++ FfiConverterBool.allocationSize(value.gpu);}};@@ -43127,7 +43134,7 @@ inner: {id: string; spaceId: string }): Finish_ {type Fail__interface = {tag: AppCreateAction_Tags.Fail;inner:-Readonly<{id: string; error: string}>+Readonly<{id: string; error: string; errorVariant: string}>};/*** The create failed.@@ -43140,15 +43147,15 @@ Readonly<{id: string; error: string}>readonly [uniffiTypeNameSymbol] = "AppCreateAction";readonly tag = AppCreateAction_Tags.Fail;readonly inner:-Readonly<{id: string; error: string}>;+Readonly<{id: string; error: string; errorVariant: string}>;constructor(-inner: {id: string; error: string }) {+inner: {id: string; error: string; errorVariant: string }) {super("AppCreateAction", "Fail");this.inner = Object.freeze(inner);}static new(-inner: {id: string; error: string }): Fail_ {+inner: {id: string; error: string; errorVariant: string }): Fail_ {return new Fail_(inner);}@@ -43443,7 +43450,7 @@ const FfiConverterTypeAppCreateAction = (() => {case 5: return new AppCreateAction.CancelFail({id: FfiConverterString.read(from), error: FfiConverterString.read(from) });case 6: return new AppCreateAction.Tick({now: FfiConverterInt64.read(from) });case 7: return new AppCreateAction.Finish({id: FfiConverterString.read(from), spaceId: FfiConverterString.read(from) });- case 8: return new AppCreateAction.Fail({id: FfiConverterString.read(from), error: FfiConverterString.read(from) });+ case 8: return new AppCreateAction.Fail({id: FfiConverterString.read(from), error: FfiConverterString.read(from), errorVariant: FfiConverterString.read(from) });case 9: return new AppCreateAction.Dismiss({id: FfiConverterString.read(from) });case 10: return new AppCreateAction.DeleteStart({id: FfiConverterString.read(from), now: FfiConverterInt64.read(from) });case 11: return new AppCreateAction.DeleteFail({id: FfiConverterString.read(from) });@@ -43521,6 +43528,7 @@ const FfiConverterTypeAppCreateAction = (() => {const inner = value.inner;FfiConverterString.write(inner.id, into);FfiConverterString.write(inner.error, into);+ FfiConverterString.write(inner.errorVariant, into);return;}case AppCreateAction_Tags.Dismiss: {@@ -43641,6 +43649,7 @@ const FfiConverterTypeAppCreateAction = (() => {let size = ordinalConverter.allocationSize(8);size += FfiConverterString.allocationSize(inner.id);size += FfiConverterString.allocationSize(inner.error);+ size += FfiConverterString.allocationSize(inner.errorVariant);return size;}case AppCreateAction_Tags.Dismiss: {@@ -50772,7 +50781,7 @@ inner: {action: string }): SpaceWizard_ {type SpaceCreate__interface = {tag: AppTelemetrySignal_Tags.SpaceCreate;inner:-Readonly<{location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean}>+Readonly<{location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean; errorVariant: string}>};/*** A Space create reached ready or failed (`cua_space_create`).@@ -50785,15 +50794,15 @@ Readonly<{location: string; guestOs: string; kind: string; outcome: string; failreadonly [uniffiTypeNameSymbol] = "AppTelemetrySignal";readonly tag = AppTelemetrySignal_Tags.SpaceCreate;readonly inner:-Readonly<{location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean}>;+Readonly<{location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean; errorVariant: string}>;constructor(-inner: {location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean }) {+inner: {location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean; errorVariant: string }) {super("AppTelemetrySignal", "SpaceCreate");this.inner = Object.freeze(inner);}static new(-inner: {location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean }): SpaceCreate_ {+inner: {location: string; guestOs: string; kind: string; outcome: string; failedPhase: string; stalled: boolean; elapsedMs: bigint; gpu: boolean; errorVariant: string }): SpaceCreate_ {return new SpaceCreate_(inner);}@@ -51084,7 +51093,7 @@ const FfiConverterTypeAppTelemetrySignal = (() => {case 4: return new AppTelemetrySignal.SignInFailed({errorKind: FfiConverterString.read(from) });case 5: return new AppTelemetrySignal.OnboardingPage({page: FfiConverterString.read(from), action: FfiConverterString.read(from), choice: FfiConverterString.read(from) });case 6: return new AppTelemetrySignal.SpaceWizard({action: FfiConverterString.read(from) });- case 7: return new AppTelemetrySignal.SpaceCreate({location: FfiConverterString.read(from), guestOs: FfiConverterString.read(from), kind: FfiConverterString.read(from), outcome: FfiConverterString.read(from), failedPhase: FfiConverterString.read(from), stalled: FfiConverterBool.read(from), elapsedMs: FfiConverterUInt64.read(from), gpu: FfiConverterBool.read(from) });+ case 7: return new AppTelemetrySignal.SpaceCreate({location: FfiConverterString.read(from), guestOs: FfiConverterString.read(from), kind: FfiConverterString.read(from), outcome: FfiConverterString.read(from), failedPhase: FfiConverterString.read(from), stalled: FfiConverterBool.read(from), elapsedMs: FfiConverterUInt64.read(from), gpu: FfiConverterBool.read(from), errorVariant: FfiConverterString.read(from) });case 8: return new AppTelemetrySignal.SpaceCreateStarted({location: FfiConverterString.read(from), guestOs: FfiConverterString.read(from), kind: FfiConverterString.read(from), gpu: FfiConverterBool.read(from) });case 9: return new AppTelemetrySignal.VolumeSetup({surface: FfiConverterString.read(from), storage: FfiConverterString.read(from), addToFinder: FfiConverterBool.read(from), mountMethod: FfiConverterString.read(from), outcome: FfiConverterString.read(from) });case 10: return new AppTelemetrySignal.Share({action: FfiConverterString.read(from), role: FfiConverterString.read(from), outcome: FfiConverterString.read(from) });@@ -51147,6 +51156,7 @@ const FfiConverterTypeAppTelemetrySignal = (() => {FfiConverterBool.write(inner.stalled, into);FfiConverterUInt64.write(inner.elapsedMs, into);FfiConverterBool.write(inner.gpu, into);+ FfiConverterString.write(inner.errorVariant, into);return;}case AppTelemetrySignal_Tags.SpaceCreateStarted: {@@ -51261,6 +51271,7 @@ const FfiConverterTypeAppTelemetrySignal = (() => {size += FfiConverterBool.allocationSize(inner.stalled);size += FfiConverterUInt64.allocationSize(inner.elapsedMs);size += FfiConverterBool.allocationSize(inner.gpu);+ size += FfiConverterString.allocationSize(inner.errorVariant);return size;}case AppTelemetrySignal_Tags.SpaceCreateStarted: {diff --git a/apps/cua-spaces-desktop/test/bridge-native.test.ts b/apps/cua-spaces-desktop/test/bridge-native.test.tsindex d70696c31d..cae3908201 100644--- a/apps/cua-spaces-desktop/test/bridge-native.test.ts+++ b/apps/cua-spaces-desktop/test/bridge-native.test.ts@@ -298,7 +298,7 @@ describe.skipIf(!built)("the bridge on the app core", () => {signals: [{ type: "feature", feature: "space_open" },{ type: "feature", feature: "Not A Word" },- { type: "space-create", location: "local", guestOs: "linux", kind: "container", outcome: "ready", failedPhase: "none", stalled: false, elapsedMs: 1200, gpu: false },+ { type: "space-create", location: "local", guestOs: "linux", kind: "container", outcome: "ready", failedPhase: "none", stalled: false, elapsedMs: 1200, gpu: false, errorVariant: "" },],});const after = telemetry.recorded.slice(-2);@@ -309,6 +309,7 @@ describe.skipIf(!built)("the bridge on the app core", () => {expect(telemetry.recorded.length).toBe(before);expect(await code("telemetry.track", {})).toBe("bad_args");expect(telemetrySignal(native, { type: "experiments-on", experiments: ["cua_volume", "BAD"] })).toBeNull();+ expect(telemetrySignal(native, { type: "space-create", location: "local", guestOs: "linux", kind: "container", outcome: "ready", failedPhase: "none", stalled: false, elapsedMs: 1200, gpu: false })).toBeNull();expect(telemetrySignal(native, { type: "launched", onboardingEligible: null })).not.toBeNull();});diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppEnvironment.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppEnvironment.swiftindex a7cfab0e83..78ff3a893d 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppEnvironment.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppEnvironment.swift@@ -114,6 +114,7 @@ public enum AppEnvironment {loginItem: fixtures ? fixtureLoginItem(env["CUA_SPACES_LOGIN_ITEM"]) : MainAppLoginItem(),startup: startup)if !fixtures {+ LiveLocalNetworkPermission().request()// Signed out is nil (setup signs in first); anything else (no// network, the credential vault) is the error itself, never a// silent nil that reads as "not signed in".@@ -196,12 +197,6 @@ public enum AppEnvironment {static func attach(_ services: LiveServices, to model: AppModel, supervisor: DaemonSupervisor?,refresh: UpdateRefresh?) {if let live = services.live {- // Ask for Local Network access while someone is at this Mac- // (the first run's setup, and launch on a Mac that provides- // Spaces); one request shared by both.- let localNetwork = LiveLocalNetworkPermission()- model.host.localNetwork = localNetwork- model.onboarding.host.localNetwork = localNetworkif let supervisor {if live.cua.mode() == .daemon {supervise(live, supervisor: supervisor, model: model)diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swiftindex e660ff70a1..8305c546fd 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift@@ -795,10 +795,6 @@ public final class AppModel {/// The pending row (selected when `open`).private func startCreate(_ args: AppCreateSpaceArgs, os: AppSpaceOs, pendingId: String, select open: Bool) {- // A Space on this Mac is reached over the local network (a macOS- // VM on vmnet): ask now, while the person who pressed Create is- // here, not when the VM boots after the download.- if args.on == "local" { host.requestLocalNetwork() }// A create on one of your machines (`host:<machine>`) says which, so// that machine's own record of the Space it is creating is not a// second row next to this one, and a failure names the machine.@@ -865,7 +861,8 @@ public final class AppModel {sendCreate(.cancelDone(id: pendingId))throw error} catch {- sendCreate(.fail(id: pendingId, error: LiveSpacesBackend.words(error)))+ sendCreate(.fail(id: pendingId, error: LiveSpacesBackend.words(error),+ errorVariant: (error as? CuaError).flatMap { Mirror(reflecting: $0).children.first?.label } ?? ""))throw error}}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/HostModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/HostModel.swiftindex 3aebaeb505..76c858eae8 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/HostModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/HostModel.swift@@ -198,10 +198,6 @@ public final class HostModel {"Sign in to Cua in your browser to continue. Setup finishes on its own after that."/// Called whenever the state changes (the roster's entry follows it).public var onChange: (() -> Void)?- /// Asks macOS for Local Network access once this Mac provides Spaces- /// (see `LocalNetworkPermissionRequesting`); nil in fixtures and tests.- public var localNetwork: LocalNetworkPermissionRequesting?- private var askedLocalNetwork = falsepublic init(host: HostRunning?) {self.host = host@@ -217,28 +213,9 @@ public final class HostModel {next.account = accountstate = nextmachineId = status.machineId- // Setup that provides Spaces, launch on a Mac that already does, or- // Spaces turned on: ask now, while someone is at this Mac, not when- // the first Space boots (see `LocalNetworkPermissionRequesting`).- if let state, state.configured, state.provideSpaces {- requestLocalNetwork()- }onChange?()}- /// Asks for Local Network access once (see- /// `LocalNetworkPermissionRequesting`). Not only hosts need it: any Mac- /// that runs a macOS Space reaches the VM on vmnet (192.168.64.x), and- /// a client Mac that was never asked gets the prompt only when that VM- /// boots, often after a long download with nobody watching, and the- /// create fails. So the app also asks when onboarding ends and when a- /// Space is created on this Mac.- public func requestLocalNetwork() {- guard !askedLocalNetwork, let localNetwork else { return }- askedLocalNetwork = true- localNetwork.request()- }-public func refresh() async {guard let host else { return }do {diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/LocalNetworkPermission.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/LocalNetworkPermission.swiftindex a8bf5ca61b..b1db71ed9b 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/LocalNetworkPermission.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/LocalNetworkPermission.swift@@ -5,32 +5,9 @@ import Darwinimport Foundationimport Network-/// Asks macOS for Local Network access for this app (fire and forget).-///-/// Why: a Mac that provides Spaces boots macOS VMs (Lume, on vmnet-/// 192.168.64.x) and its `cua daemon` (inside this app's bundle) must reach-/// the guest. macOS blocks that ("No route to host") until Local Network-/// access is allowed, and it asks only the first time the app reaches the-/// local network, at most once per boot, on this Mac's own screen. The app-/// is not even listed under System Settings > Privacy & Security > Local-/// Network until it has been asked. Left alone, the prompt appears when the-/// first Space is created, often from another Mac while nobody is at this-/// one, and the create fails. So the app asks while the user is here: when-/// "Set up for access" succeeds with Spaces provided, and when it launches-/// on a Mac already set up to provide them.-public protocol LocalNetworkPermissionRequesting: AnyObject, Sendable {- /// Triggers the prompt if macOS has not decided yet. Never blocks.- func request()-}--/// The live request: a short-lived UDP datagram to an address on this Mac's-/// local network (the first active IPv4 interface's subnet, and vmnet's-/// 192.168.64.1, where the VMs live). Each connection is cancelled after a-/// few seconds whatever happens; nothing waits for it. Asks once per-/// process (macOS asks at most once per boot anyway).-public final class LiveLocalNetworkPermission: LocalNetworkPermissionRequesting, @unchecked Sendable {- private let lock = NSLock()- private var asked = false+/// Asks once at launch, on every Mac: controllers reach other Macs' Spaces+/// over the LAN, and providers reach their VMs over vmnet.+public final class LiveLocalNetworkPermission: @unchecked Sendable {private let queue = DispatchQueue(label: "com.trycua.cua-spaces.local-network")/// How long each probe may live.let lifetime: TimeInterval@@ -40,11 +17,6 @@ public final class LiveLocalNetworkPermission: LocalNetworkPermissionRequesting,}public func request() {- lock.lock()- let first = !asked- asked = true- lock.unlock()- guard first else { return }queue.async { [self] infor host in Self.targets() { probe(host) }}diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/OnboardingModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/OnboardingModel.swiftindex a189f1a5a7..73a1d2f443 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/OnboardingModel.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/OnboardingModel.swift@@ -348,9 +348,6 @@ public final class OnboardingModel {public func finish() {telemetry?.record(appTelemetryOnboardingFinished(state: state))completed = true- // Every Mac, host or not: its own macOS Spaces live on the local- // network (vmnet), so ask while someone is here.- host.requestLocalNetwork()onLaunchAtLogin?(state.launchAtLogin)guard let statePath else { return }let mode = state.mode == .host ? "host" : "client"diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge+Pages.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge+Pages.swiftindex 1462365a50..1b592e85a6 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge+Pages.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/WebHost/WebUIBridge+Pages.swift@@ -352,6 +352,11 @@ extension WebUIBridge {n.doubleValue == n.doubleValue.rounded() else { return nil }return n.uint64Value}+ func variant(_ k: String) -> String? {+ guard let v = s[k] as? String, v.count <= 64,+ v.allSatisfy({ $0.isASCII && ($0.isLetter || $0.isNumber || $0 == "_") }) else { return nil }+ return v+ }switch type {case "feature":guard let f = word("feature") else { return nil }@@ -375,9 +380,9 @@ extension WebUIBridge {case "space-create":guard let location = word("location"), let os = word("guestOs"), let kind = word("kind"),let outcome = word("outcome"), let phase = word("failedPhase"), let stalled = flag("stalled"),- let elapsed = ms("elapsedMs"), let gpu = flag("gpu") else { return nil }+ let elapsed = ms("elapsedMs"), let gpu = flag("gpu"), let errorVariant = variant("errorVariant") else { return nil }return .spaceCreate(location: location, guestOs: os, kind: kind, outcome: outcome, failedPhase: phase,- stalled: stalled, elapsedMs: elapsed, gpu: gpu)+ stalled: stalled, elapsedMs: elapsed, gpu: gpu, errorVariant: errorVariant)case "space-create-started":guard let location = word("location"), let os = word("guestOs"), let kind = word("kind"),let gpu = flag("gpu") else { return nil }diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/LocalNetworkPermissionTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/LocalNetworkPermissionTests.swiftindex 95c25ae66e..4c814de210 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/LocalNetworkPermissionTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/LocalNetworkPermissionTests.swift@@ -7,99 +7,9 @@ import CuaSpacesFFIimport Foundationimport Testing-/// Counts Local Network requests; never touches the network.-final class FakeLocalNetwork: LocalNetworkPermissionRequesting, @unchecked Sendable {- private(set) var requests = 0- func request() { requests += 1 }-}-@MainActor@Suite("Local Network access")struct LocalNetworkPermissionTests {- func setUp(profile: String, host: FixtureHost = FixtureHost()) async -> (HostModel, FakeLocalNetwork) {- let m = HostModel(host: host)- let fake = FakeLocalNetwork()- m.localNetwork = fake- m.openForm()- m.send(.setProfile(profile: profile))- await m.submit()- return (m, fake)- }-- @Test func setupThatProvidesSpacesAsksOnce() async {- let (m, fake) = await setUp(profile: "spare")- #expect(m.form == nil)- #expect(m.state?.provideSpaces == true)- #expect(fake.requests == 1)- // Later refreshes do not ask again.- await m.refresh()- await m.refresh()- #expect(fake.requests == 1)- }-- @Test func desktopOnlySetupDoesNotAsk() async {- let (m, fake) = await setUp(profile: "desktop")- #expect(m.state?.configured == true)- #expect(m.state?.provideSpaces == false)- #expect(fake.requests == 0)- }-- @Test func failedSetupDoesNotAsk() async {- let host = FixtureHost()- host.failSetup = "boom"- let (_, fake) = await setUp(profile: "spare", host: host)- #expect(fake.requests == 0)- }-- @Test func launchOnAMacThatProvidesSpacesAsks() async throws {- // A Mac set up earlier: the first status read at launch asks.- let earlier = FixtureHost()- _ = try await earlier.setupRequest(- request: AppHostSetupRequest(mode: "relay", relayUrl: nil, direct: nil, name: nil, allow: nil,- profile: "spare", shareDesktop: nil, provideSpaces: nil),- accountToken: nil)- let m = HostModel(host: FixtureHost(status: earlier.current))- let fake = FakeLocalNetwork()- m.localNetwork = fake- await m.refresh()- #expect(fake.requests == 1)- }-- /// A client Mac runs its own macOS Spaces on vmnet too: the end of- /// onboarding asks, whatever was chosen, once.- @Test func onboardingEndAsksOnEveryMac() {- let o = OnboardingModel(statePath: nil)- let fake = FakeLocalNetwork()- o.host.localNetwork = fake- #expect(o.host.state?.provideSpaces != true)- o.finish()- #expect(fake.requests == 1)- o.finish()- #expect(fake.requests == 1)- }-- /// Create on this Mac asks (the person who pressed Create is here); a- /// Space elsewhere does not need it.- @Test func aCreateOnThisMacAsksACloudOneDoesNot() async throws {- let dir = FileManager.default.temporaryDirectory.appendingPathComponent("cua-mac-tests-\(UUID().uuidString)")- defer { try? FileManager.default.removeItem(at: dir) }- let model = AppModel(backend: FixtureSpacesBackend(),- keyvault: KeyvaultModel(client: nil, clock: { fixtureNow }),- onboarding: OnboardingModel(statePath: nil),- settingsPath: dir.appendingPathComponent("settings.json").path,- telemetry: FixtureTelemetry())- let fake = FakeLocalNetwork()- model.host.localNetwork = fake- await model.openNewSpace()- var args = appWizardCreateArgs(plan: model.wizard.view.plan)- args.on = "cloud"- _ = try? await model.runCreate(args, os: .linux, pendingId: "pending:cloud")- #expect(fake.requests == 0)- args.on = "local"- _ = try? await model.runCreate(args, os: .linux, pendingId: "pending:local")- #expect(fake.requests == 1)- }-@Test func subnetHostIsTheFirstAddress() {let ip: UInt32 = 0xC0A8_0117 // 192.168.1.23#expect(LiveLocalNetworkPermission.subnetHost(ip: ip, mask: 0xFFFF_FF00) == "192.168.1.1")@@ -107,4 +17,9 @@ struct LocalNetworkPermissionTests {#expect(LiveLocalNetworkPermission.subnetHost(ip: 0xA9FE_0102, mask: 0xFFFF_0000) == nil)#expect(LiveLocalNetworkPermission.subnetHost(ip: ip, mask: 0xFFFF_FFFF) == nil)}++ @Test func insufficientDiskCaseNameIsTheMirrorLabel() {+ let error = CuaError.InsufficientDisk(message: "need 52 GB")+ #expect(Mirror(reflecting: error).children.first?.label == "InsufficientDisk")+ }}diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swiftindex 2a68bfdc46..465daaeff2 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift@@ -332,7 +332,8 @@ struct ParityTests {bytesPerSecond: (a["bytesPerSecond"] as? NSNumber)?.doubleValue)case "tick": return .tick(now: Int64(a["now"] as! Int))case "finish": return .finish(id: id, spaceId: a["spaceId"] as! String)- case "fail": return .fail(id: id, error: a["error"] as! String)+ case "fail": return .fail(id: id, error: a["error"] as! String,+ errorVariant: a["errorVariant"] as? String ?? "")case "dismiss": return .dismiss(id: id)case "delete-start": return .deleteStart(id: id, now: Int64(a["now"] as! Int))case "delete-fail": return .deleteFail(id: id)@@ -2114,10 +2115,10 @@ struct ParityTests {case let .onboardingPage(page, action, choice):return ["type": "onboarding-page", "page": page, "action": action, "choice": choice]case let .spaceWizard(action): return ["type": "space-wizard", "action": action]- case let .spaceCreate(location, guestOs, kind, outcome, failedPhase, stalled, elapsedMs, gpu):+ case let .spaceCreate(location, guestOs, kind, outcome, failedPhase, stalled, elapsedMs, gpu, errorVariant):return ["type": "space-create", "location": location, "guestOs": guestOs, "kind": kind,"outcome": outcome, "failedPhase": failedPhase, "stalled": stalled, "elapsedMs": Int(elapsedMs),- "gpu": gpu]+ "gpu": gpu, "errorVariant": errorVariant]case let .spaceCreateStarted(location, guestOs, kind, gpu):return ["type": "space-create-started", "location": location, "guestOs": guestOs, "kind": kind, "gpu": gpu]case let .volumeSetup(surface, storage, addToFinder, mountMethod, outcome):diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swiftindex 2f7add71a4..908ad2b74a 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift@@ -1313,7 +1313,8 @@ struct ViewModelTests {now: 0, image: nil, kind: nil, hostArch: nil, gpu: false,host: nil, hostName: nil))creates = appCreatesReduce(state: creates, action: .fail(- id: "pending:1", error: "You're out of Cua Cloud credit. Add credit at https://run.cua.ai/billing"))+ id: "pending:1", error: "You're out of Cua Cloud credit. Add credit at https://run.cua.ai/billing",+ errorVariant: ""))let space = appCreatesCompose(spaces: [], state: creates)[0]#expect(space.detail == "You're out of Cua Cloud credit.")#expect(appSpaceDetail(space: space).creditNotice == nil)diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WebUIHostTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WebUIHostTests.swiftindex 9b3c61398c..9fdb2d3dfa 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WebUIHostTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/WebUIHostTests.swift@@ -345,7 +345,9 @@ struct WebUIHostTests {let signals: [Any] = [["type": "feature", "feature": "space_open"],["type": "feature", "feature": "/Users/ada"],["type": "step", "step": "signed_in", "ok": "yes"],- ["type": "nope"]]+ ["type": "nope"],+ ["type": "space-create", "location": "local", "guestOs": "linux", "kind": "vm",+ "outcome": "ready", "failedPhase": "none", "stalled": false, "elapsedMs": 10, "gpu": false]]_ = try await bridge.handle("telemetry.track", ["signals": signals])#expect(Array(telemetry.recorded.dropFirst(before)) == [.feature(feature: "space_open")])_ = try telemetry.setEnabled(false)diff --git a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.tsindex 40e8ab3bfe..4bd5b5b4d1 100644--- a/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts+++ b/apps/cua-spaces-web/src/bridge/__tests__/detail.test.ts@@ -33,12 +33,16 @@ describe("usage events", () => {{ type: "feature", feature: "/Users/ada" },{ type: "space-create-started", location: "local", guestOs: "linux", kind: "container", gpu: false },{ type: "space-create", location: "local", guestOs: "linux", kind: "vm", outcome: "ok", failedPhase: "none", stalled: false, elapsedMs: -1, gpu: false },+ { type: "space-create", location: "local", guestOs: "linux", kind: "vm", outcome: "ready", failedPhase: "none", stalled: false, elapsedMs: 10, gpu: false },+ { type: "space-create", location: "cloud", guestOs: "windows", kind: "vm", outcome: "error", failedPhase: "booting", stalled: false, elapsedMs: 10, gpu: false, errorVariant: "InsufficientDisk" },+ { type: "space-create", location: "local", guestOs: "linux", kind: "vm", outcome: "error", failedPhase: "booting", stalled: false, elapsedMs: 10, gpu: false, errorVariant: "need 52 GB" },{ type: "made-up", word: "x" },"step",]),).toEqual([{ type: "step", step: "app_launched", ok: true },{ type: "space-create-started", location: "local", guestOs: "linux", kind: "container", gpu: false },+ { type: "space-create", location: "cloud", guestOs: "windows", kind: "vm", outcome: "error", failedPhase: "booting", stalled: false, elapsedMs: 10, gpu: false, errorVariant: "InsufficientDisk" },]);});diff --git a/apps/cua-spaces-web/src/bridge/ops/telemetry.ts b/apps/cua-spaces-web/src/bridge/ops/telemetry.tsindex df3e284d4f..14411a6c33 100644--- a/apps/cua-spaces-web/src/bridge/ops/telemetry.ts+++ b/apps/cua-spaces-web/src/bridge/ops/telemetry.ts@@ -35,6 +35,7 @@ export type TelemetrySignal =stalled: boolean;elapsedMs: number;gpu: boolean;+ errorVariant: string;}| { type: "space-create-started"; location: string; guestOs: string; kind: string; gpu: boolean }| { type: "volume-setup"; surface: string; storage: string; addToFinder: boolean; mountMethod: string; outcome: string }@@ -53,7 +54,7 @@ export interface TelemetryOps {/* ---- What may cross the bridge ------------------------------------------------ */-type Field = "word" | "flag" | "maybe-flag" | "ms" | "words";+type Field = "word" | "flag" | "maybe-flag" | "ms" | "words" | "variant";/** Every signal's fields and what each may hold. */const SHAPES: Record<TelemetrySignal["type"], Record<string, Field>> = {@@ -72,6 +73,7 @@ const SHAPES: Record<TelemetrySignal["type"], Record<string, Field>> = {stalled: "flag",elapsedMs: "ms",gpu: "flag",+ errorVariant: "variant",},"space-create-started": { location: "word", guestOs: "word", kind: "word", gpu: "flag" },"volume-setup": { surface: "word", storage: "word", addToFinder: "flag", mountMethod: "word", outcome: "word" },@@ -85,6 +87,7 @@ const SHAPES: Record<TelemetrySignal["type"], Record<string, Field>> = {/** A fixed word from the schema (`space_create_local`, `this_mac`). Names,* emails, paths and URLs never match. */const WORD = /^[a-z0-9_]{1,64}$/;+const VARIANT = /^[A-Za-z0-9_]{0,64}$/;function valid(kind: Field, v: unknown): boolean {switch (kind) {@@ -98,6 +101,8 @@ function valid(kind: Field, v: unknown): boolean {return typeof v === "number" && Number.isSafeInteger(v) && v >= 0;case "words":return Array.isArray(v) && v.length <= 16 && v.every((w) => typeof w === "string" && WORD.test(w));+ case "variant":+ return typeof v === "string" && VARIANT.test(v);}}diff --git a/apps/cua-spaces/src/model/telemetry.ts b/apps/cua-spaces/src/model/telemetry.tsindex b49e029897..2a58a1d779 100644--- a/apps/cua-spaces/src/model/telemetry.ts+++ b/apps/cua-spaces/src/model/telemetry.ts@@ -32,6 +32,7 @@ export type TelemetrySignal =stalled: boolean;elapsedMs: number;gpu: boolean;+ errorVariant: string;}| { type: "space-create-started"; location: string; guestOs: string; kind: string; gpu: boolean }| {diff --git a/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx b/docs/content/docs/cua-sdk/concepts/telemetry-events.mdxindex 6649337659..0ea2a81840 100644--- a/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx+++ b/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx@@ -38,7 +38,7 @@ Every event carries: `telemetry_schema_version`, `event_version`, `product`| `cua_onboarding_page` | `page` (`welcome`, `signin`, `agents`, `presentation`, `volume`, `this_machine`, `done`), `action` (`shown`, `completed`, `skipped`, `back`), `choice` (a fixed word such as `signed_in`, `menu_bar_only`, `s3`, `host`, or `none`) | Which first-run page people leave on, and what they pick. || `cua_space_wizard` | `action` (`opened`, `cancelled`, `submitted`) | How often a New Space is started and abandoned. || `cua_space_create_started` | `location`, `guest_os`, `kind`, `gpu` (GPU acceleration turned on) | Which Spaces are started, and how often with GPU acceleration. |-| `cua_space_create` | `location`, `guest_os`, `kind`, `outcome` (`ok`, `error`, or `cancelled` when Cancel was pressed while it was being created), `failed_phase` (the phase it failed or was cancelled in, or `none`), `stalled`, `time_bucket` (to ready, the failure, or the cancel finishing), `gpu` | Space create success, failure and cancel rates, time to ready, and which phase fails. |+| `cua_space_create` | `location`, `guest_os`, `kind`, `outcome` (`ok`, `error`, or `cancelled` when Cancel was pressed while it was being created), `error_kind`, `failed_phase` (the phase it failed or was cancelled in, or `none`), `stalled`, `time_bucket` (to ready, the failure, or cancel finishing), `gpu` | Space create success, failure and cancel rates, time to ready, and which phase fails. || `cua_volume_setup` | `surface` (`onboarding` or `settings`), `storage` (`this_mac`, `s3`, `later`), `add_to_finder`, `mount_method` (`fskit`, `nfs`, `fuse`, `none`, `unknown`), `outcome` | Cua Volume adoption. || `cua_persistent_agent` | `action` (`create`, `pause`, `resume`, `routine_add`, ...), `harness`, `outcome`, `error_kind` | Persistent agents and routines adoption. || `cua_host_setup` | `mode` (`relay` or `direct`), `profile` (`desktop`, `spare`, `both`), `outcome`, `error_kind`, `signed_in`, `token_state` (`provided`, `expired`, `missing`, `not_needed`; never the token), `failed_stage` (`none`, `preflight`, `token`, `register`, `download`, `service`), `http_status` (the status a server answered a failure with, `0` when none) | Machines set up for access, and where a failed setup stopped. |diff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/creates.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/creates.mdxindex 2dde215044..7feebf3215 100644--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/creates.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/creates.mdx@@ -42,7 +42,7 @@ Returned by [`app_creates_reduce`](#app_creates_reduce), [`app_creates_settle`](.cancelFail(id: String, error: String).tick(now: Int64).finish(id: String, spaceId: String)-.fail(id: String, error: String)+.fail(id: String, error: String, errorVariant: String).dismiss(id: String).deleteStart(id: String, now: Int64).deleteFail(id: String)@@ -63,7 +63,7 @@ AppCreateAction::CancelDone { id: String }AppCreateAction::CancelFail { id: String, error: String }AppCreateAction::Tick { now: i64 }AppCreateAction::Finish { id: String, space_id: String }-AppCreateAction::Fail { id: String, error: String }+AppCreateAction::Fail { id: String, error: String, error_variant: String }AppCreateAction::Dismiss { id: String }AppCreateAction::DeleteStart { id: String, now: i64 }AppCreateAction::DeleteFail { id: String }@@ -85,7 +85,7 @@ AppCreateAction::PowerFail { id: String, error: String }| `CancelFail` | The cancel itself failed: the row shows why. Fields: `id: String`, `error: String` || `Tick` | Time passed (a shell's timer, a few times a second while a create is pending): progress within a phase that reports no fraction advances with the time the phase usually takes. Fields: `now: i64` || `Finish` | The create returned the Space. Fields: `id: String`, `space_id: String` |-| `Fail` | The create failed. Fields: `id: String`, `error: String` |+| `Fail` | The create failed. Fields: `id: String`, `error: String`, `error_variant: String` || `Dismiss` | Remove a failed row. Fields: `id: String` || `DeleteStart` | The user confirmed Delete: the row shows Deleting now. A second start for a Space already deleting does nothing. Fields: `id: String`, `now: i64` || `DeleteFail` | The delete failed: the row is back as the registry lists it. Fields: `id: String` |diff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/images.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/images.mdxindex 2b7f8d8b20..c29d42d64a 100644--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/images.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/images.mdx@@ -37,6 +37,7 @@ The catalog behind the New Space image field: each `AppSandboxImage` with its gr| `distro` | [`Option<AppImageDistro>`](#appimagedistro-record) | | The guest's distribution. || `arch` | `Vec<String>` | | Platforms it is built for (`amd64`, `arm64`); empty when unknown. || `sizes` | [`Option<AppImageSizes>`](#appimagesizes-record) | | How big it is per platform, when measured. |+| `gpu` | `bool` | | `false`: its guest cannot use GPU acceleration. |## `AppImageGroup` recorddiff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/telemetry.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/telemetry.mdxindex 32be1a71e1..80b3fd2e51 100644--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/telemetry.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/telemetry.mdx@@ -31,7 +31,7 @@ Each `app_telemetry_*` function takes a reducer step (the state before it and th.signInFailed(errorKind: String).onboardingPage(page: String, action: String, choice: String).spaceWizard(action: String)-.spaceCreate(location: String, guestOs: String, kind: String, outcome: String, failedPhase: String, stalled: Bool, elapsedMs: UInt64, gpu: Bool)+.spaceCreate(location: String, guestOs: String, kind: String, outcome: String, failedPhase: String, stalled: Bool, elapsedMs: UInt64, gpu: Bool, errorVariant: String).spaceCreateStarted(location: String, guestOs: String, kind: String, gpu: Bool).volumeSetup(surface: String, storage: String, addToFinder: Bool, mountMethod: String, outcome: String).share(action: String, role: String, outcome: String)@@ -51,7 +51,7 @@ AppTelemetrySignal::Launched { onboarding_eligible: Option<bool> }AppTelemetrySignal::SignInFailed { error_kind: String }AppTelemetrySignal::OnboardingPage { page: String, action: String, choice: String }AppTelemetrySignal::SpaceWizard { action: String }-AppTelemetrySignal::SpaceCreate { location: String, guest_os: String, kind: String, outcome: String, failed_phase: String, stalled: bool, elapsed_ms: u64, gpu: bool }+AppTelemetrySignal::SpaceCreate { location: String, guest_os: String, kind: String, outcome: String, failed_phase: String, stalled: bool, elapsed_ms: u64, gpu: bool, error_variant: String }AppTelemetrySignal::SpaceCreateStarted { location: String, guest_os: String, kind: String, gpu: bool }AppTelemetrySignal::VolumeSetup { surface: String, storage: String, add_to_finder: bool, mount_method: String, outcome: String }AppTelemetrySignal::Share { action: String, role: String, outcome: String }@@ -72,7 +72,7 @@ AppTelemetrySignal::ExperimentsOn { experiments: Vec<String> }| `SignInFailed` | A sign-in failed, timed out or was cancelled (`cua_onboarding_step`, step `signed_in`, outcome `error`). Fields: `error_kind: String` || `OnboardingPage` | A first-run page was shown or left (`cua_onboarding_page`). Fields: `page: String`, `action: String`, `choice: String` || `SpaceWizard` | The New Space panel (`cua_space_wizard`). Fields: `action: String` |-| `SpaceCreate` | A Space create reached ready or failed (`cua_space_create`). Fields: `location: String`, `guest_os: String`, `kind: String`, `outcome: String`, `failed_phase: String`, `stalled: bool`, `elapsed_ms: u64`, `gpu: bool` |+| `SpaceCreate` | A Space create reached ready or failed (`cua_space_create`). Fields: `location: String`, `guest_os: String`, `kind: String`, `outcome: String`, `failed_phase: String`, `stalled: bool`, `elapsed_ms: u64`, `gpu: bool`, `error_variant: String` || `SpaceCreateStarted` | A Space create started (`cua_space_create_started`). Fields: `location: String`, `guest_os: String`, `kind: String`, `gpu: bool` || `VolumeSetup` | A Cua Volume setting was saved (`cua_volume_setup`). Fields: `surface: String`, `storage: String`, `add_to_finder: bool`, `mount_method: String`, `outcome: String` || `Share` | A Space was shared, unshared or its role changed (`cua_share`). Fields: `action: String`, `role: String`, `outcome: String` |diff --git a/libs/cua/crates/cua-daemon/src/local.rs b/libs/cua/crates/cua-daemon/src/local.rsindex ce6ff0d383..6e7713d175 100644--- a/libs/cua/crates/cua-daemon/src/local.rs+++ b/libs/cua/crates/cua-daemon/src/local.rs@@ -242,6 +242,19 @@ pub async fn resolve_placement_for(first}+#[rustfmt::skip]+fn refuse_gpu(image: &str, gpu: bool, r: &Resolved) -> RuntimeResult<()> {+ let digest = r.image.as_ref().map(|i| i.digest.as_str());+ let Some(e) = gpu.then(|| cua_image::catalog::entries().iter().find(|e| {+ e.gpu == Some(false) && (e.reference == image.trim() || e.digest.is_some() && e.digest.as_deref() == digest)+ })).flatten() else { return Ok(()) };+ let name = e.distro.as_ref().map_or(e.reference.as_str(), |d| d.name.as_str());+ Err(RuntimeError::Unsupported {+ backend: r.placement.backend.as_str().into(),+ op: format!("GPU acceleration on {name}"),+ })+}+async fn resolve_placement_inner(image: &str,os: &str,@@ -792,6 +805,7 @@ impl LocalRuntime for VmmLocal {op: "a disk size (disk_gb sizes VM disks; a container uses its engine's)".into(),});}+ refuse_gpu(&spec.image, spec.gpu.is_some(), &r)?;let rt = self.runtime(p.backend).await.map_err(rt_err)?;let mut s = StartSpec::new(&spec.name, p.image).os(os_of(&spec.os))@@ -1437,6 +1451,57 @@ async fn build_with(#[cfg(test)]mod tests {+ #[test]+ fn refuse_gpu_follows_the_catalog() {+ use super::{BackendKind, Placement, Resolved, RuntimeError, refuse_gpu};+ use cua_vmm::ImageSource;++ let digest = cua_image::catalog::entries()+ .iter()+ .find(|e| e.reference == "ghcr.io/trycua/macos:15")+ .and_then(|e| e.digest.clone())+ .expect("macos:15 digest");+ let resolved = |digest: Option<&str>| Resolved {+ placement: Placement {+ backend: BackendKind::Lume,+ image: ImageSource::oci("ignored"),+ },+ arch: None,+ image: digest.map(|d| cua_image::ResolvedImage {+ reference: "ghcr.io/trycua/macos".into(),+ variant_ref: "ghcr.io/trycua/macos:15".into(),+ pinned_ref: format!("ghcr.io/trycua/macos@{d}"),+ digest: d.into(),+ variant: cua_image::Variant::Lume,+ arch: Some("arm64".into()),+ architectures: vec!["arm64".into()],+ emulated: false,+ os: "macos".into(),+ spacesd: Some(false),+ layers: vec![],+ }),+ };+ let refused = RuntimeError::Unsupported {+ backend: "lume".into(),+ op: "GPU acceleration on macOS Sequoia 15".into(),+ };+ assert_eq!(+ refuse_gpu("ghcr.io/trycua/macos:15", true, &resolved(None)).unwrap_err(),+ refused+ );+ assert_eq!(+ refuse_gpu(+ &format!("ghcr.io/trycua/macos@{digest}"),+ true,+ &resolved(Some(&digest))+ )+ .unwrap_err(),+ refused+ );+ assert!(refuse_gpu("ghcr.io/trycua/macos:15", false, &resolved(None)).is_ok());+ assert!(refuse_gpu("ghcr.io/trycua/macos:26", true, &resolved(None)).is_ok());+ }+#[test]fn an_engine_that_could_not_be_asked_is_not_reported_as_not_found() {use super::{BackendKind, RuntimeError, VmmError, pick_owner};diff --git a/libs/cua/crates/cua-daemon/tests/placement.rs b/libs/cua/crates/cua-daemon/tests/placement.rsindex 4852156f64..1fa76205c6 100644--- a/libs/cua/crates/cua-daemon/tests/placement.rs+++ b/libs/cua/crates/cua-daemon/tests/placement.rs@@ -44,6 +44,7 @@ async fn refs_land_on_the_backend_their_variant_needs() {.clone();let mac = r.lume(&macos_full);r.darwin_index("ghcr.io/me/mac:1");+ r.lume("ghcr.io/trycua/macos:15");cua_image::resolve::set_source(Some(Arc::new(r)));// Short ref: docker.io, pinned, container.@@ -113,5 +114,17 @@ async fn refs_land_on_the_backend_their_variant_needs() {assert_eq!(p.placement.backend, BackendKind::Container);assert_eq!(p.placement.image, ImageSource::oci("cua-e2e-mcp-probe:1"));assert!(p.image.is_none());+ let spec: cua_sandbox_core::LocalStartSpec = serde_json::from_value(serde_json::json!({+ "name": "t", "image": "ghcr.io/trycua/macos:15", "os": "macos", "cpus": 1, "memory_mb": 256,+ "ports": [], "env": {}, "ready_timeout": {"secs": 1, "nanos": 0}, "gpu": "auto"}))+ .unwrap();+ let local = cua_daemon::local::VmmLocal::default();+ let err = cua_sandbox_core::LocalRuntime::start(&local, &spec)+ .await+ .unwrap_err();+ assert!(+ matches!(&err, cua_sandbox_core::RuntimeError::Unsupported { op, .. } if op == "GPU acceleration on macOS Sequoia 15"),+ "{err:?}"+ );cua_image::resolve::set_source(None);}diff --git a/libs/cua/crates/cua-image/src/catalog.rs b/libs/cua/crates/cua-image/src/catalog.rsindex 570f02d201..6672afdfe7 100644--- a/libs/cua/crates/cua-image/src/catalog.rs+++ b/libs/cua/crates/cua-image/src/catalog.rs@@ -49,6 +49,9 @@ pub struct CatalogEntry {/// (`scripts/images/record-image-sizes.py`).#[serde(default)]pub sizes: Option<CatalogSizes>,+ /// `Some(false)`: the guest cannot use GPU acceleration (absent: no claim).+ #[serde(default)]+ pub gpu: Option<bool>,}/// The guest distribution a catalog entry names (`distro`).@@ -272,6 +275,7 @@ mod tests {digest: None,local: None,sizes: None,+ gpu: None,distro: Some(Distro {id: id.into(),name: n.into(),diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rsindex c7fa863403..171114f983 100644--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs@@ -4157,6 +4157,18 @@ mod tests {use super::*;use std::collections::BTreeSet;+ #[test]+ fn an_embedded_insufficient_disk_becomes_insufficient_disk() {+ let err = cua_spaces::Error::from(cua_sandbox_core::Error::Runtime(+ cua_sandbox_core::RuntimeError::InsufficientDisk("need 52 GB".into()),+ ));+ assert_eq!(err.tag(), "insufficient_disk");+ match CuaError::from(err) {+ CuaError::InsufficientDisk(message) => assert!(message.contains("need 52 GB")),+ other => panic!("expected InsufficientDisk, got {other:?}"),+ }+ }+#[test]fn send_file_keeps_both_copies_unless_overwrite_is_explicit() {use cua_spaces::files::Conflict;diff --git a/libs/cua/crates/cua-spaces-app-core/parity/golden/telemetry-funnel.json b/libs/cua/crates/cua-spaces-app-core/parity/golden/telemetry-funnel.jsonindex 737cb4f6fc..be9ce22f90 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/golden/telemetry-funnel.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/golden/telemetry-funnel.json@@ -632,6 +632,7 @@"signals": [{"elapsedMs": 47000,+ "errorVariant": "","failedPhase": "none","gpu": false,"guestOs": "linux",@@ -681,6 +682,7 @@"signals": [{"elapsedMs": 45000,+ "errorVariant": "InsufficientDisk","failedPhase": "booting","gpu": false,"guestOs": "windows",@@ -735,6 +737,7 @@"signals": [{"elapsedMs": 7201000,+ "errorVariant": "","failedPhase": "pulling","gpu": false,"guestOs": "linux",@@ -784,6 +787,7 @@"signals": [{"elapsedMs": 31000,+ "errorVariant": "","failedPhase": "pulling","gpu": true,"guestOs": "macos",@@ -833,6 +837,7 @@"signals": [{"elapsedMs": 40000,+ "errorVariant": "","failedPhase": "none","gpu": false,"guestOs": "linux",@@ -882,6 +887,7 @@"signals": [{"elapsedMs": 4000,+ "errorVariant": "","failedPhase": "preparing","gpu": true,"guestOs": "linux",diff --git a/libs/cua/crates/cua-spaces-app-core/parity/telemetry-funnel.json b/libs/cua/crates/cua-spaces-app-core/parity/telemetry-funnel.jsonindex 3d0f519340..f358c1cd17 100644--- a/libs/cua/crates/cua-spaces-app-core/parity/telemetry-funnel.json+++ b/libs/cua/crates/cua-spaces-app-core/parity/telemetry-funnel.json@@ -224,7 +224,8 @@"action": {"type": "fail","id": "pending:2",- "error": "boot failed at /Users/maya/.cua/vmm"+ "error": "boot failed at /Users/maya/.cua/vmm",+ "errorVariant": "InsufficientDisk"}},{diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rsindex d0abf23f47..7097f25cf3 100644--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs@@ -253,6 +253,9 @@ pub enum CreateAction {id: String,/// Why, one line.error: String,+ /// The error enum's case name, when the shell has one.+ #[serde(default)]+ error_variant: String,},/// Remove a failed row.Dismiss {@@ -992,7 +995,7 @@ pub fn reduce(state: &CreatesState, action: &CreateAction) -> CreatesState {p.space_id = Some(space_id.clone());}}- CreateAction::Fail { id, error } => {+ CreateAction::Fail { id, error, .. } => {// A create that ends while being cancelled was cancelled: its// row goes, it did not fail.if next.pending.iter().any(|p| &p.id == id && p.cancelling) {@@ -1560,6 +1563,7 @@ mod tests {&CreateAction::Fail {id: "pending:c".into(),error: "cancelled: Cancelled local:space-1".into(),+ error_variant: String::new(),},);assert!(gone.pending.is_empty());@@ -1696,6 +1700,7 @@ mod tests {&CreateAction::Fail {id: "pending:o".into(),error: "x".into(),+ error_variant: String::new(),},);assert_eq!(tick(&failed, 50.0), failed);@@ -1757,6 +1762,7 @@ mod tests {&CreateAction::Fail {id: "pending:c".into(),error: "boom".into(),+ error_variant: String::new(),},);let after = reduce(&failed, &at("pending:c", "connecting", None, 9_000));@@ -1913,6 +1919,7 @@ mod tests {&CreateAction::Fail {id: "pending:1".into(),error: "no local runtime".into(),+ error_variant: String::new(),},);let row = &compose(&[], &s)[0];@@ -2025,6 +2032,7 @@ mod tests {id: "pending:1".into(),error: "You're out of Cua Cloud credit. Add credit at https://run.cua.ai/billing".into(),+ error_variant: String::new(),},);let space = pending_space(&s.pending[0]);@@ -2056,6 +2064,7 @@ mod tests {&CreateAction::Fail {id: "pending:2".into(),error: "no local runtime".into(),+ error_variant: String::new(),},);assert!(@@ -2250,6 +2259,7 @@ mod tests {&CreateAction::Fail {id: "pending:w".into(),error: spacesd("0ns"),+ error_variant: String::new(),},);assert!(@@ -2417,6 +2427,7 @@ mod tests {error: "Local Network access is not available: cua cannot reach the VM at \192.168.64.45:3211 (No route to host (os error 65))".into(),+ error_variant: String::new(),},);let rows = compose(®istry, &failed);diff --git a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rsindex 9b44b8d7c6..5b1c64513e 100644--- a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs@@ -95,6 +95,9 @@ pub enum TelemetrySignal {/// GPU acceleration was turned on.#[serde(default)]gpu: bool,+ /// The error enum's case name, when the shell sent one.+ #[serde(default)]+ error_variant: String,},/// A Space create started (`cua_space_create_started`).SpaceCreateStarted {@@ -421,7 +424,8 @@ fn kind_word(k: Option<SpaceKind>) -> &'static str {}}-fn create_event(p: &PendingCreate, outcome: &str, stalled: bool, now_ms: i64) -> TelemetrySignal {+#[rustfmt::skip]+fn create_event(p: &PendingCreate, outcome: &str, stalled: bool, error_variant: &str, now_ms: i64) -> TelemetrySignal {TelemetrySignal::SpaceCreate {location: p.provider.as_str().into(),guest_os: p.os.as_str().into(),@@ -435,6 +439,7 @@ fn create_event(p: &PendingCreate, outcome: &str, stalled: bool, now_ms: i64) ->stalled: outcome == "error" && stalled,elapsed_ms: (now_ms - p.started_at).max(0) as u64,gpu: p.gpu,+ error_variant: error_variant.into(),}}@@ -478,29 +483,31 @@ pub fn creates(before: &CreatesState, action: &CreateAction, now_ms: i64) -> Vec}CreateAction::Finish { id, .. } => match find(id) {Some(p) if p.space_id.is_none() => vec![- create_event(p, "ok", false, now_ms),+ create_event(p, "ok", false, "", now_ms),step("first_space_ready", true),],_ => vec![],},- CreateAction::Fail { id, .. } => match find(id) {+ CreateAction::Fail {+ id, error_variant, ..+ } => match find(id) {Some(p) if p.space_id.is_none() && p.cancelling => {- vec![create_event(p, "cancelled", false, now_ms)]+ vec![create_event(p, "cancelled", false, "", now_ms)]}Some(p) if p.space_id.is_none() && (p.error.is_none() || stalled(p)) => {- vec![create_event(p, "error", stalled(p), now_ms)]+ vec![create_event(p, "error", stalled(p), error_variant, now_ms)]}_ => vec![],},CreateAction::CancelDone { id } => match find(id) {Some(p) if p.space_id.is_none() && p.cancelling => {- vec![create_event(p, "cancelled", false, now_ms)]+ vec![create_event(p, "cancelled", false, "", now_ms)]}_ => vec![],},CreateAction::Dismiss { id } => match find(id) {Some(p) if p.space_id.is_none() && stalled(p) => {- vec![create_event(p, "error", true, now_ms)]+ vec![create_event(p, "error", true, "", now_ms)]}_ => vec![],},@@ -704,6 +711,7 @@ pub fn record(t: &cua_telemetry::Telemetry, signals: &[TelemetrySignal]) -> usizstalled,elapsed_ms,gpu,+ error_variant,} => Some(t.capture(events::space_create(&events::SpaceCreate {on: location,@@ -712,6 +720,7 @@ pub fn record(t: &cua_telemetry::Telemetry, signals: &[TelemetrySignal]) -> usizlast_phase: failed_phase,stalled: *stalled,gpu: *gpu,+ error_variant,},Outcome::from_word(outcome),Duration::from_millis(*elapsed_ms),@@ -1080,7 +1089,7 @@ mod tests {] {let mut p = pending("pending:os", "booting", None);p.os = os;- let finished = create_event(&p, "ok", false, 2_000);+ let finished = create_event(&p, "ok", false, "", 2_000);let finished = serde_json::to_value(finished).unwrap();let started = creates(&CreatesState::default(),@@ -1136,6 +1145,7 @@ mod tests {stalled: false,elapsed_ms: 47_000,gpu: false,+ error_variant: String::new(),});assert_eq!(ready[1], step("first_space_ready", true));@@ -1144,13 +1154,14 @@ mod tests {&CreateAction::Fail {id: "pending:a".into(),error: "boom at /Users/alice".into(),+ error_variant: "InsufficientDisk".into(),},5_000,);assert!(matches!(&failed[0],- TelemetrySignal::SpaceCreate { failed_phase, stalled: false, outcome, .. }- if failed_phase == "booting" && outcome == "error"+ TelemetrySignal::SpaceCreate { failed_phase, stalled: false, outcome, error_variant, .. }+ if failed_phase == "booting" && outcome == "error" && error_variant == "InsufficientDisk"));// A stalled row is counted when dismissed, not when it stalls.let stall = crate::spaces::creating::stall_error("pulling", 900.0);@@ -1169,7 +1180,27 @@ mod tests {);assert!(matches!(&gone[0],- TelemetrySignal::SpaceCreate { stalled: true, failed_phase, .. } if failed_phase == "pulling"+ TelemetrySignal::SpaceCreate { stalled: true, failed_phase, error_variant, .. }+ if failed_phase == "pulling" && error_variant.is_empty()+ ));+ let mut cancelling = pending("pending:d", "pulling", None);+ cancelling.cancelling = true;+ let st = CreatesState {+ pending: vec![cancelling],+ deleting: vec![],+ powering: vec![],+ };+ let cancelled = creates(+ &st,+ &CreateAction::CancelDone {+ id: "pending:d".into(),+ },+ 9_000,+ );+ assert!(matches!(+ &cancelled[0],+ TelemetrySignal::SpaceCreate { outcome, error_variant, .. }+ if outcome == "cancelled" && error_variant.is_empty()));// A failed (not stalled) row dismissed was already counted.let st = CreatesState {diff --git a/libs/cua/crates/cua-spaces-app-core/src/wizard.rs b/libs/cua/crates/cua-spaces-app-core/src/wizard.rsindex 2186a3d128..fe174c3f79 100644--- a/libs/cua/crates/cua-spaces-app-core/src/wizard.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/wizard.rs@@ -140,6 +140,9 @@ pub struct SandboxImage {/// How big it is per platform, when measured.#[serde(default, skip_serializing_if = "Option::is_none")]pub sizes: Option<ImageSizes>,+ /// `false`: its guest cannot use GPU acceleration.+ #[serde(default = "offered")]+ pub gpu: bool,}/// The guest distribution a catalog image names: its id picks the OS icon@@ -1502,6 +1505,7 @@ fn image_of(state: &WizardState) -> SandboxImage {distro: None,arch: vec![],sizes: None,+ gpu: true,..base},None => base,@@ -1940,7 +1944,8 @@ pub fn gpu_row(else {return (None, None);};- let on = state.gpu && choice.supported;+ let supported = choice.supported && image.gpu;+ let on = state.gpu && supported;let row = GpuRow {label: if choice.experimental {format!("{} (Experimental)", choice.label)@@ -1948,10 +1953,11 @@ pub fn gpu_row(choice.label.clone()},on,- enabled: choice.supported,+ enabled: supported,reason: (!choice.supported).then(|| choice.reason.clone().filter(|r| !r.is_empty()))- .flatten(),+ .flatten()+ .or_else(|| (!image.gpu).then(|| format!("Not available for {}", image.name))),learn_more_label: "Learn more".into(),learn_more_url: choice.learn_more.clone(),};@@ -3260,6 +3266,46 @@ mod tests {Some("Needs a Mac with Apple silicon"));assert_eq!(v.plan.gpu, None);+ e.gpus = Some(vec![lume_gpu(true)]);+ let sequoia = reduce(+ &initial(&e),+ &WizardAction::ChooseImage {+ image_ref: "ghcr.io/trycua/macos:15".into(),+ },+ &e,+ );+ let row = view(&sequoia, &e).gpu.expect("sequoia still shows the row");+ assert!(!row.enabled && !row.on);+ assert_eq!(+ row.reason.as_deref(),+ Some("Not available for macOS Sequoia 15")+ );+ let switched = reduce(&sequoia, &WizardAction::SetGpu { on: true }, &e);+ assert_eq!(view(&switched, &e).plan.gpu, None);+ let tahoe = reduce(+ &sequoia,+ &WizardAction::ChooseImage {+ image_ref: "ghcr.io/trycua/macos:26".into(),+ },+ &e,+ );+ assert!(view(&tahoe, &e).gpu.unwrap().enabled);+ e.gpus = Some(vec![lume_gpu(false)]);+ let row = view(&sequoia, &e).gpu.unwrap();+ assert_eq!(+ row.reason.as_deref(),+ Some("Needs a Mac with Apple silicon")+ );+ e.gpus = Some(vec![lume_gpu(true)]);+ let custom = reduce(+ &sequoia,+ &WizardAction::SetImageText {+ text: "ghcr.io/me/macos:15".into(),+ },+ &e,+ );+ let row = view(&custom, &e).gpu.unwrap();+ assert!(row.enabled && row.reason.is_none());}fn vol(gb: u64, name: &str) -> StorageVolume {@@ -3362,10 +3408,7 @@ mod tests {#[test]fn every_offered_image_has_sizes() {- for i in picker_images()- .into_iter()- .filter(|i| i.image_ref != "ghcr.io/trycua/macos:15")- {+ for i in picker_images() {let s = i.sizes.as_ref()@@ -3426,6 +3469,24 @@ mod tests {// Pulled, it needs nothing new.e.storage.as_mut().unwrap().pulled = vec!["ghcr.io/trycua/linux:24.04".into()];assert!(view(&s, &e).can_continue);+ let mut mac = storage_env();+ mac.storage.as_mut().unwrap().lume = Some(vol(20, "Macintosh HD"));+ let sequoia = on("ghcr.io/trycua/macos:15", &mac);+ let v = view(&sequoia, &mac);+ let p = sizes("ghcr.io/trycua/macos:15", "arm64");+ assert_eq!(+ v.resources_error,+ Some(format!(+ "Not enough space on Macintosh HD: needs {}, 20 GB available.",+ size_text(p.download + p.unpacked + 5 * GIB)+ ))+ );+ assert!(!v.can_continue);+ mac.storage.as_mut().unwrap().lume = Some(vol(60, "Macintosh HD"));+ assert!(view(&sequoia, &mac).can_continue);+ mac.storage.as_mut().unwrap().lume = Some(vol(20, "Macintosh HD"));+ mac.storage.as_mut().unwrap().pulled = vec!["ghcr.io/trycua/macos:15".into()];+ assert!(view(&sequoia, &mac).can_continue);}#[test]diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rsindex 6d615daa0c..6e1779e9fb 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core_types.rs@@ -600,6 +600,8 @@ pub enum AppCreateAction {id: String,/// Why, one line.error: String,+ /// The error enum's case name, when the shell has one.+ error_variant: String,},/// Remove a failed row.Dismiss {@@ -2956,6 +2958,8 @@ pub struct AppSandboxImage {pub arch: Vec<String>,/// How big it is per platform, when measured.pub sizes: Option<AppImageSizes>,+ /// `false`: its guest cannot use GPU acceleration.+ pub gpu: bool,}/// A titled group of images.@@ -8949,6 +8953,8 @@ pub enum AppTelemetrySignal {elapsed_ms: u64,/// GPU acceleration was turned on.gpu: bool,+ /// The error enum's case name, when the shell sent one.+ error_variant: String,},/// A Space create started (`cua_space_create_started`).SpaceCreateStarted {diff --git a/libs/cua/crates/cua-spaces/src/error.rs b/libs/cua/crates/cua-spaces/src/error.rsindex 01e64bdf29..4f2f241164 100644--- a/libs/cua/crates/cua-spaces/src/error.rs+++ b/libs/cua/crates/cua-spaces/src/error.rs@@ -168,6 +168,9 @@ impl Error {Error::Sandbox(cua_sandbox_core::Error::AmbiguousSandbox { .. }) => "ambiguous_sandbox",Error::Sandbox(cua_sandbox_core::Error::NotFound(_)) => "not_found",Error::Sandbox(cua_sandbox_core::Error::InvalidPlacement(_)) => "invalid_placement",+ Error::Sandbox(cua_sandbox_core::Error::Runtime(+ cua_sandbox_core::RuntimeError::InsufficientDisk(_),+ )) => "insufficient_disk",Error::Sandbox(_) => "sandbox",Error::Io(_) => "io",Error::Mcp(_) => "mcp",diff --git a/libs/cua/crates/cua-telemetry/src/events.rs b/libs/cua/crates/cua-telemetry/src/events.rsindex 984f82875c..b149c75dcc 100644--- a/libs/cua/crates/cua-telemetry/src/events.rs+++ b/libs/cua/crates/cua-telemetry/src/events.rs@@ -875,6 +875,8 @@ pub struct SpaceCreate<'a> {pub stalled: bool,/// GPU acceleration was turned on.pub gpu: bool,+ /// The error enum's case name (`InsufficientDisk`); empty when the shell had none.+ pub error_variant: &'a str,}/// `cua_space_create`.@@ -891,11 +893,17 @@ pub fn space_create(s: &SpaceCreate<'_>, outcome: Outcome, elapsed: Duration) ->p => p,},};+ let error_kind = match outcome {+ Outcome::Error if s.stalled && s.error_variant.is_empty() => "timeout",+ Outcome::Error => error_kind(s.error_variant),+ _ => "none",+ };Event::new(event::SPACE_CREATE).s("location", location(s.on)).s("guest_os", guest_os(s.guest_os)).s("kind", sandbox_kind(s.kind)).s("outcome", outcome.as_str())+ .s("error_kind", error_kind).s("failed_phase", failed_phase).b("stalled", s.stalled && outcome == Outcome::Error).s("time_bucket", create_time_bucket(elapsed))diff --git a/libs/cua/crates/cua-telemetry/src/schema.rs b/libs/cua/crates/cua-telemetry/src/schema.rsindex cdb8e898ea..8d74702dda 100644--- a/libs/cua/crates/cua-telemetry/src/schema.rs+++ b/libs/cua/crates/cua-telemetry/src/schema.rs@@ -1042,6 +1042,7 @@ pub const EVENTS: &[EventSpec] = &[p("guest_os", Kind::Enum(GUEST_OS), "Guest OS family."),p("kind", Kind::Enum(SANDBOX_KINDS), "container or vm."),OUTCOME,+ ERROR_KIND,p("failed_phase",Kind::Enum(CREATE_PHASES),diff --git a/libs/cua/crates/cua-telemetry/tests/privacy.rs b/libs/cua/crates/cua-telemetry/tests/privacy.rsindex 3a8bdab955..888526f512 100644--- a/libs/cua/crates/cua-telemetry/tests/privacy.rs+++ b/libs/cua/crates/cua-telemetry/tests/privacy.rs@@ -149,6 +149,7 @@ fn all_builders(s: &str) -> Vec<Event> {last_phase: s,stalled: true,gpu: true,+ error_variant: s,},Outcome::Error,d,@@ -946,13 +947,15 @@ fn activation_builders_keep_vocabulary_and_coarsen_the_rest() {last_phase: "pulling",stalled: true,gpu: false,+ error_variant: "InsufficientDisk",},Outcome::Ok,d,);- // Success never names a phase or a stall.+ // Success never names a phase, a stall, or the variant.assert_eq!(e.props["failed_phase"], "none");assert_eq!(e.props["stalled"], false);+ assert_eq!(e.props["error_kind"], "none");assert_eq!(e.props["time_bucket"], "40_59s");let e = events::space_create(&events::SpaceCreate {@@ -962,14 +965,72 @@ fn activation_builders_keep_vocabulary_and_coarsen_the_rest() {last_phase: "none",stalled: false,gpu: true,+ error_variant: "",},Outcome::Error,Duration::from_secs(4000),);assert_eq!(e.props["failed_phase"], "other");+ assert_eq!(e.props["error_kind"], "other");assert_eq!(e.props["time_bucket"], "gte_30m");assert_eq!(e.props["location"], "cloud");assert_eq!(e.props["gpu"], true);+ let disk = events::space_create(+ &events::SpaceCreate {+ on: "local",+ guest_os: "macos",+ kind: "vm",+ last_phase: "pulling",+ stalled: false,+ gpu: false,+ error_variant: "InsufficientDisk",+ },+ Outcome::Error,+ d,+ );+ assert_eq!(disk.props["error_kind"], "insufficient_disk");+ let stalled = events::space_create(+ &events::SpaceCreate {+ on: "local",+ guest_os: "linux",+ kind: "vm",+ last_phase: "pulling",+ stalled: true,+ gpu: false,+ error_variant: "",+ },+ Outcome::Error,+ d,+ );+ assert_eq!(stalled.props["error_kind"], "timeout");+ let transport = events::space_create(+ &events::SpaceCreate {+ on: "local",+ guest_os: "linux",+ kind: "vm",+ last_phase: "pulling",+ stalled: true,+ gpu: false,+ error_variant: "Transport",+ },+ Outcome::Error,+ d,+ );+ assert_eq!(transport.props["error_kind"], "transport");+ let sentence = events::space_create(+ &events::SpaceCreate {+ on: "local",+ guest_os: "linux",+ kind: "vm",+ last_phase: "pulling",+ stalled: false,+ gpu: false,+ error_variant: "the disk filled up",+ },+ Outcome::Error,+ d,+ );+ assert_eq!(sentence.props["error_kind"], "other");// A cancel names the phase it was cancelled in, and is never a stall.let c = events::space_create(&events::SpaceCreate {@@ -979,6 +1040,7 @@ fn activation_builders_keep_vocabulary_and_coarsen_the_rest() {last_phase: "pulling",stalled: true,gpu: true,+ error_variant: "InsufficientDisk",},Outcome::Cancelled,Duration::from_secs(25),@@ -986,6 +1048,7 @@ fn activation_builders_keep_vocabulary_and_coarsen_the_rest() {assert_eq!(c.props["outcome"], "cancelled");assert_eq!(c.props["failed_phase"], "pulling");assert_eq!(c.props["stalled"], false);+ assert_eq!(c.props["error_kind"], "none");assert_eq!(c.props["time_bucket"], "20_39s");let s = events::space_create_started("cloud", "windows", "vm", true);assert_eq!(diff --git a/libs/images/sandbox-images.json b/libs/images/sandbox-images.jsonindex d466749bb7..0b7ed286e3 100644--- a/libs/images/sandbox-images.json+++ b/libs/images/sandbox-images.json@@ -1,5 +1,5 @@{- "$comment": "The sandbox images the apps offer (Cua Spaces, the OpenKoalaBots samples) and the docs list (os-image-catalog, generated by scripts/docs-generators/sandbox.ts). One source: edit here, then run `pnpm docs:generate:sandbox` in docs/ and `node samples/openkoalabot-example-swift/scripts/gen-images.mjs`. Canonical entries are checked against libs/cua/crates/cua-image/src/canonical.rs. Benchmark entries name their `lock` (the digests the bench publisher promoted; `python3 scripts/images/gen-image-constants.py` turns them into cua_bench/images.py) and the `benchmarks` they run. Every image ref elsewhere in the repo must be one of these, a lock pin, or an entry of scripts/images/image-refs-allowlist.json (scripts/images/check-image-refs.py). Pickers (the Spaces apps, the samples) and the image tables offer the entries with published=true whose group does not set `picker: false` (benchmark images are for cua-bench, not Spaces). `distro` names the guest: `id` (`ubuntu`, `omarchy`, `macos`, `windows`; it picks the OS icon) and `name`, the pretty name the apps show while a Space is created and until it reports its own. `arch` lists its platforms, `sdk` the SDK constructor that names it and `guide` its docs page. `browsers` lists the browsers the image ships; cua-driver browser tools (CDP) drive the Chromium-family ones when the image has cua-spacesd. `digest` (optional) is the published digest the moving tag was verified at. `sizes` (every entry with a digest) records, per platform, the bytes a pull downloads, what the pulled image takes on the host (`unpacked`) and the disk the Space sees (`disk`), measured at `sizes.digest` by `python3 scripts/images/record-image-sizes.py` (the release pipelines' `catalog` step; CI fails when it is stale). `tier` (canonical images) is `slim` (the minimum that passes `cua-spacesd doctor --strict` with every feature; CI and benchmarks use it), `full` (the default: slim plus dev tooling, no tag suffix) or `xcode` (macOS: full plus one pinned Xcode); the tag grammar is `<os-version>[-<tier>][-disk]`.",+ "$comment": "The sandbox images the apps offer (Cua Spaces, the OpenKoalaBots samples) and the docs list (os-image-catalog, generated by scripts/docs-generators/sandbox.ts). One source: edit here, then run `pnpm docs:generate:sandbox` in docs/ and `node samples/openkoalabot-example-swift/scripts/gen-images.mjs`. Canonical entries are checked against libs/cua/crates/cua-image/src/canonical.rs. Benchmark entries name their `lock` (the digests the bench publisher promoted; `python3 scripts/images/gen-image-constants.py` turns them into cua_bench/images.py) and the `benchmarks` they run. Every image ref elsewhere in the repo must be one of these, a lock pin, or an entry of scripts/images/image-refs-allowlist.json (scripts/images/check-image-refs.py). Pickers (the Spaces apps, the samples) and the image tables offer the entries with published=true whose group does not set `picker: false` (benchmark images are for cua-bench, not Spaces). `distro` names the guest: `id` (`ubuntu`, `omarchy`, `macos`, `windows`; it picks the OS icon) and `name`, the pretty name the apps show while a Space is created and until it reports its own. `arch` lists its platforms, `sdk` the SDK constructor that names it and `guide` its docs page. `browsers` lists the browsers the image ships; cua-driver browser tools (CDP) drive the Chromium-family ones when the image has cua-spacesd. `digest` (optional) is the published digest the moving tag was verified at. `sizes` (every entry with a digest) records, per platform, the bytes a pull downloads, what the pulled image takes on the host (`unpacked`) and the disk the Space sees (`disk`), measured at `sizes.digest` by `python3 scripts/images/record-image-sizes.py` (the release pipelines' `catalog` step; CI fails when it is stale). `tier` (canonical images) is `slim` (the minimum that passes `cua-spacesd doctor --strict` with every feature; CI and benchmarks use it), `full` (the default: slim plus dev tooling, no tag suffix) or `xcode` (macOS: full plus one pinned Xcode); the tag grammar is `<os-version>[-<tier>][-disk]`. `gpu: false` (optional; absent means offered): the guest cannot use GPU acceleration (macOS 15 predates the paravirtual GPU); the apps don't offer it and local creates refuse it.","schemaVersion": 1,"groups": [{ "id": "canonical", "label": "Desktop images" },@@ -236,6 +236,14 @@"variant": "vm","summary": "macOS VM on Apple silicon through Lume. Local only; exec, screenshots and view over SSH and VNC.","spacesd": false,+ "gpu": false,+ "digest": "sha256:92f2a3b60cfb9b3edf91fe3d52356771eaa67c719eee9a35e080c73854562fe9",+ "sizes": {+ "digest": "sha256:92f2a3b60cfb9b3edf91fe3d52356771eaa67c719eee9a35e080c73854562fe9",+ "platforms": [+ { "arch": "arm64", "manifest": "sha256:92f2a3b60cfb9b3edf91fe3d52356771eaa67c719eee9a35e080c73854562fe9", "download": 19832636973, "unpacked": 30098350236, "disk": 85899345920 }+ ]+ },"browsers": ["safari"],"arch": ["arm64"],"local": "lume",diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex 8b2772a67c..3c0c785e23 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -25955,6 +25955,10 @@ public struct AppSandboxImage: Equatable, Hashable {* How big it is per platform, when measured.*/public var sizes: AppImageSizes?+ /**+ * `false`: its guest cannot use GPU acceleration.+ */+ public var gpu: Bool// Default memberwise initializers are never public by default, so we// declare one manually.@@ -26000,7 +26004,10 @@ public struct AppSandboxImage: Equatable, Hashable {*/arch: [String],/*** How big it is per platform, when measured.- */sizes: AppImageSizes?) {+ */sizes: AppImageSizes?,+ /**+ * `false`: its guest cannot use GPU acceleration.+ */gpu: Bool) {self.imageRef = imageRefself.group = groupself.os = os@@ -26015,6 +26022,7 @@ public struct AppSandboxImage: Equatable, Hashable {self.distro = distroself.arch = archself.sizes = sizes+ self.gpu = gpu}@@ -26046,7 +26054,8 @@ public struct FfiConverterTypeAppSandboxImage: FfiConverterRustBuffer {published: FfiConverterBool.read(from: &buf),distro: FfiConverterOptionTypeAppImageDistro.read(from: &buf),arch: FfiConverterSequenceString.read(from: &buf),- sizes: FfiConverterOptionTypeAppImageSizes.read(from: &buf)+ sizes: FfiConverterOptionTypeAppImageSizes.read(from: &buf),+ gpu: FfiConverterBool.read(from: &buf))}@@ -26065,6 +26074,7 @@ public struct FfiConverterTypeAppSandboxImage: FfiConverterRustBuffer {FfiConverterOptionTypeAppImageDistro.write(value.distro, into: &buf)FfiConverterSequenceString.write(value.arch, into: &buf)FfiConverterOptionTypeAppImageSizes.write(value.sizes, into: &buf)+ FfiConverterBool.write(value.gpu, into: &buf)}}@@ -42298,7 +42308,10 @@ public enum AppCreateAction: Equatable, Hashable {*/id: String,/*** Why, one line.- */error: String+ */error: String,+ /**+ * The error enum's case name, when the shell has one.+ */errorVariant: String)/*** Remove a failed row.@@ -42415,7 +42428,7 @@ public struct FfiConverterTypeAppCreateAction: FfiConverterRustBuffer {case 7: return .finish(id: try FfiConverterString.read(from: &buf), spaceId: try FfiConverterString.read(from: &buf))- case 8: return .fail(id: try FfiConverterString.read(from: &buf), error: try FfiConverterString.read(from: &buf)+ case 8: return .fail(id: try FfiConverterString.read(from: &buf), error: try FfiConverterString.read(from: &buf), errorVariant: try FfiConverterString.read(from: &buf))case 9: return .dismiss(id: try FfiConverterString.read(from: &buf)@@ -42500,10 +42513,11 @@ public struct FfiConverterTypeAppCreateAction: FfiConverterRustBuffer {FfiConverterString.write(spaceId, into: &buf)- case let .fail(id,error):+ case let .fail(id,error,errorVariant):writeInt(&buf, Int32(8))FfiConverterString.write(id, into: &buf)FfiConverterString.write(error, into: &buf)+ FfiConverterString.write(errorVariant, into: &buf)case let .dismiss(id):@@ -50482,7 +50496,10 @@ public enum AppTelemetrySignal: Equatable, Hashable {*/elapsedMs: UInt64,/*** GPU acceleration was turned on.- */gpu: Bool+ */gpu: Bool,+ /**+ * The error enum's case name, when the shell sent one.+ */errorVariant: String)/*** A Space create started (`cua_space_create_started`).@@ -50621,7 +50638,7 @@ public struct FfiConverterTypeAppTelemetrySignal: FfiConverterRustBuffer {case 6: return .spaceWizard(action: try FfiConverterString.read(from: &buf))- case 7: return .spaceCreate(location: try FfiConverterString.read(from: &buf), guestOs: try FfiConverterString.read(from: &buf), kind: try FfiConverterString.read(from: &buf), outcome: try FfiConverterString.read(from: &buf), failedPhase: try FfiConverterString.read(from: &buf), stalled: try FfiConverterBool.read(from: &buf), elapsedMs: try FfiConverterUInt64.read(from: &buf), gpu: try FfiConverterBool.read(from: &buf)+ case 7: return .spaceCreate(location: try FfiConverterString.read(from: &buf), guestOs: try FfiConverterString.read(from: &buf), kind: try FfiConverterString.read(from: &buf), outcome: try FfiConverterString.read(from: &buf), failedPhase: try FfiConverterString.read(from: &buf), stalled: try FfiConverterBool.read(from: &buf), elapsedMs: try FfiConverterUInt64.read(from: &buf), gpu: try FfiConverterBool.read(from: &buf), errorVariant: try FfiConverterString.read(from: &buf))case 8: return .spaceCreateStarted(location: try FfiConverterString.read(from: &buf), guestOs: try FfiConverterString.read(from: &buf), kind: try FfiConverterString.read(from: &buf), gpu: try FfiConverterBool.read(from: &buf)@@ -50686,7 +50703,7 @@ public struct FfiConverterTypeAppTelemetrySignal: FfiConverterRustBuffer {FfiConverterString.write(action, into: &buf)- case let .spaceCreate(location,guestOs,kind,outcome,failedPhase,stalled,elapsedMs,gpu):+ case let .spaceCreate(location,guestOs,kind,outcome,failedPhase,stalled,elapsedMs,gpu,errorVariant):writeInt(&buf, Int32(7))FfiConverterString.write(location, into: &buf)FfiConverterString.write(guestOs, into: &buf)@@ -50696,6 +50713,7 @@ public struct FfiConverterTypeAppTelemetrySignal: FfiConverterRustBuffer {FfiConverterBool.write(stalled, into: &buf)FfiConverterUInt64.write(elapsedMs, into: &buf)FfiConverterBool.write(gpu, into: &buf)+ FfiConverterString.write(errorVariant, into: &buf)case let .spaceCreateStarted(location,guestOs,kind,gpu):diff --git a/scripts/docs-generators/sandbox.ts b/scripts/docs-generators/sandbox.tsindex 0a070e2b98..96a688bbdf 100644--- a/scripts/docs-generators/sandbox.ts+++ b/scripts/docs-generators/sandbox.ts@@ -321,6 +321,8 @@ export type SandboxImage = {variant: 'container' | 'vm';summary: string;spacesd: boolean;+ /** `false`: the guest cannot use GPU acceleration. */+ gpu?: false;/** Browsers the image ships; cua-driver's browser tools drive the Chromium-family ones. */browsers: string[];/** Platforms the image is published for. */@@ -354,7 +356,7 @@ export type SandboxImageList = {export const IMAGE_LIST_PATH = 'libs/images/sandbox-images.json';-const OPTIONAL_IMAGE_FIELDS = ['guide', 'lock', 'benchmarks', 'sdk', 'digest', 'sizes', 'tier'];+const OPTIONAL_IMAGE_FIELDS = ['guide', 'lock', 'benchmarks', 'sdk', 'digest', 'sizes', 'tier', 'gpu'];/** The tag suffix each tier puts before `-disk`: `<os-version>[-<tier>][-disk]`. */const TIER_SUFFIX: Record<string, string> = { slim: '-slim', full: '', xcode: '-xcode' };