Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(spaces): resources view, daemon resource sampler, relay summaries, CLI columns and SDK resources API (CUA-1880) (#5469)
Francesco Bonacci5380f8005024
diff --git a/apps/cua-spaces-desktop/src/model/backend.ts b/apps/cua-spaces-desktop/src/model/backend.tsindex d17fab674b..1843cedc78 100644--- a/apps/cua-spaces-desktop/src/model/backend.ts+++ b/apps/cua-spaces-desktop/src/model/backend.ts@@ -407,7 +407,7 @@ export class LiveSpacesBackend implements SpacesBackend {async usage(id: string): Promise<AppSpaceUsage | null> {const u = await bounded(5, async () => (await this.cua.spaces().space(id)).usage());- return u ? { memoryUsed: u.memoryUsed, memoryTotal: u.memoryTotal, memoryLimited: u.memoryLimited, diskUsed: u.diskUsed, diskTotal: u.diskTotal, diskLimited: u.diskLimited } : null;+ return u ? { cpuCount: u.cpuCount, cpuPercent: u.cpuPercent, loadAverage1m: u.loadAverage1m, memoryUsed: u.memoryUsed, memoryTotal: u.memoryTotal, memoryLimited: u.memoryLimited, diskUsed: u.diskUsed, diskTotal: u.diskTotal, diskLimited: u.diskLimited } : null;}async agentRuns(id: string): Promise<AppSpaceAgentRun[]> {diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_sdk-ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_sdk-ffi.tsindex fe354b25b2..267dc8928a 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_sdk-ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_sdk-ffi.ts@@ -469,6 +469,26 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: true,},+ "uniffi_cua_sdk_fn_clone_resourceslistener": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_free_resourceslistener": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_clone_resourceswatch": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_free_resourceswatch": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_clone_sandbox": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -589,6 +609,11 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener": {+ args: [FfiType.Reference(FfiType.Struct("VTableCallbackInterfaceCuaSdkResourcesListener"))],+ ret: FfiType.Void,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_fn_init_callback_vtable_spacecreatelistener": {args: [FfiType.Reference(FfiType.Struct("VTableCallbackInterfaceCuaSdkSpaceCreateListener"))],ret: FfiType.Void,@@ -1679,6 +1704,21 @@ const DEFINITIONS = {ret: FfiType.RustBuffer,hasRustCallStatus: true,},+ "uniffi_cua_sdk_fn_method_resourceslistener_on_event": {+ args: [FfiType.Handle, FfiType.RustBuffer],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_method_resourceswatch_set_visible": {+ args: [FfiType.Handle, FfiType.Int8],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_method_resourceswatch_stop": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_method_sandbox_agents": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -2394,6 +2434,11 @@ const DEFINITIONS = {ret: FfiType.Handle,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_method_spaces_resources": {+ args: [FfiType.Handle, FfiType.Int8],+ ret: FfiType.Handle,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_fn_method_spaces_routine_add": {args: [FfiType.Handle, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer],ret: FfiType.Handle,@@ -2554,6 +2599,11 @@ const DEFINITIONS = {ret: FfiType.Handle,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_method_spaces_watch_resources": {+ args: [FfiType.Handle, FfiType.Int8, FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_method_spacesdclient_agents": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -3909,6 +3959,21 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_resourceslistener_on_event": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_sdk_checksum_method_resourceswatch_set_visible": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_sdk_checksum_method_resourceswatch_stop": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_sandbox_agents": {args: [],ret: FfiType.UInt16,@@ -4624,6 +4689,11 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_spaces_resources": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_spaces_routine_add": {args: [],ret: FfiType.UInt16,@@ -4784,6 +4854,11 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_spaces_watch_resources": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_spacesdclient_agents": {args: [],ret: FfiType.UInt16,@@ -5104,6 +5179,22 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: false,},+ "CallbackInterfaceCuaSdkResourcesListenerMethod0": {+ args: [FfiType.Handle, FfiType.RustBuffer],+ ret: FfiType.VoidPointer,+ hasRustCallStatus: true,+ outReturn: true,+ },+ "CallbackInterfaceCloneCuaSdk_ResourcesListener": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: false,+ },+ "CallbackInterfaceFreeCuaSdk_ResourcesListener": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: false,+ },"CallbackInterfaceCuaSdkSpaceCreateListenerMethod0": {args: [FfiType.Handle, FfiType.RustBuffer],ret: FfiType.VoidPointer,@@ -5153,6 +5244,11 @@ const DEFINITIONS = {{ name: "on_frame", type: FfiType.Callback("CallbackInterfaceCuaSdkFrameSinkMethod0") },{ name: "on_event", type: FfiType.Callback("CallbackInterfaceCuaSdkFrameSinkMethod1") },],+ "VTableCallbackInterfaceCuaSdkResourcesListener": [+ { name: "uniffi_free", type: FfiType.Callback("CallbackInterfaceFreeCuaSdk_ResourcesListener") },+ { name: "uniffi_clone", type: FfiType.Callback("CallbackInterfaceCloneCuaSdk_ResourcesListener") },+ { name: "on_event", type: FfiType.Callback("CallbackInterfaceCuaSdkResourcesListenerMethod0") },+ ],"VTableCallbackInterfaceCuaSdkSpaceCreateListener": [{ name: "uniffi_free", type: FfiType.Callback("CallbackInterfaceFreeCuaSdk_SpaceCreateListener") },{ name: "uniffi_clone", type: FfiType.Callback("CallbackInterfaceCloneCuaSdk_SpaceCreateListener") },@@ -5255,6 +5351,10 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_free_presenceview(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_relay(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_free_relay(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_clone_resourceslistener(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;+ uniffi_cua_sdk_fn_free_resourceslistener(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_clone_resourceswatch(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;+ uniffi_cua_sdk_fn_free_resourceswatch(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_sandbox(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_free_sandbox(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_sandboxes(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;@@ -5279,6 +5379,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_free_teleportapprover(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_init_callback_vtable_audiosink(vtable: UniffiVTableCallbackInterfaceCuaSdkAudioSink): void;uniffi_cua_sdk_fn_init_callback_vtable_framesink(vtable: UniffiVTableCallbackInterfaceCuaSdkFrameSink): void;+ uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(vtable: UniffiVTableCallbackInterfaceCuaSdkResourcesListener): void;uniffi_cua_sdk_fn_init_callback_vtable_spacecreatelistener(vtable: UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener): void;uniffi_cua_sdk_fn_init_callback_vtable_teleportapprover(vtable: UniffiVTableCallbackInterfaceCuaSdkTeleportApprover): void;uniffi_cua_sdk_fn_func_agent_event_category(kind: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;@@ -5497,6 +5598,9 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_relay_start_sharing(uniffiSelf: bigint, machineId: Uint8Array): bigint;uniffi_cua_sdk_fn_method_relay_stop_sharing(uniffiSelf: bigint, machineId: Uint8Array): bigint;uniffi_cua_sdk_fn_method_relay_url(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_sdk_fn_method_resourceslistener_on_event(uniffiSelf: bigint, event: Uint8Array, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_method_resourceswatch_set_visible(uniffiSelf: bigint, visible: number, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_method_resourceswatch_stop(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_method_sandbox_agents(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_sandbox_delete(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_sandbox_detach(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): void;@@ -5640,6 +5744,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_spaces_relay_unregister(uniffiSelf: bigint, space: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_remove(uniffiSelf: bigint, space: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_resolve(uniffiSelf: bigint, space: Uint8Array): bigint;+ uniffi_cua_sdk_fn_method_spaces_resources(uniffiSelf: bigint, visible: number): bigint;uniffi_cua_sdk_fn_method_spaces_routine_add(uniffiSelf: bigint, agent: Uint8Array, title: Uint8Array, prompt: Uint8Array, everyMinutes: Uint8Array, dailyAt: Uint8Array, weeklyOn: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_routine_remove(uniffiSelf: bigint, id: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_routine_set_enabled(uniffiSelf: bigint, id: Uint8Array, enabled: number): bigint;@@ -5672,6 +5777,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_spaces_volume_sync_status(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spaces_volume_unmount(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spaces_volume_write(uniffiSelf: bigint, path: Uint8Array, content: Uint8Array, ifEtag: Uint8Array, createOnly: number, view: Uint8Array): bigint;+ uniffi_cua_sdk_fn_method_spaces_watch_resources(uniffiSelf: bigint, visible: number, listener: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_method_spacesdclient_agents(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spacesdclient_attach(uniffiSelf: bigint, pid: Uint8Array, tag: Uint8Array, replay: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spacesdclient_call_json(uniffiSelf: bigint, method: Uint8Array, requestJson: Uint8Array): bigint;@@ -5943,6 +6049,9 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_relay_start_sharing(): number;uniffi_cua_sdk_checksum_method_relay_stop_sharing(): number;uniffi_cua_sdk_checksum_method_relay_url(): number;+ uniffi_cua_sdk_checksum_method_resourceslistener_on_event(): number;+ uniffi_cua_sdk_checksum_method_resourceswatch_set_visible(): number;+ uniffi_cua_sdk_checksum_method_resourceswatch_stop(): number;uniffi_cua_sdk_checksum_method_sandbox_agents(): number;uniffi_cua_sdk_checksum_method_sandbox_delete(): number;uniffi_cua_sdk_checksum_method_sandbox_detach(): number;@@ -6086,6 +6195,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_spaces_relay_unregister(): number;uniffi_cua_sdk_checksum_method_spaces_remove(): number;uniffi_cua_sdk_checksum_method_spaces_resolve(): number;+ uniffi_cua_sdk_checksum_method_spaces_resources(): number;uniffi_cua_sdk_checksum_method_spaces_routine_add(): number;uniffi_cua_sdk_checksum_method_spaces_routine_remove(): number;uniffi_cua_sdk_checksum_method_spaces_routine_set_enabled(): number;@@ -6118,6 +6228,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_spaces_volume_sync_status(): number;uniffi_cua_sdk_checksum_method_spaces_volume_unmount(): number;uniffi_cua_sdk_checksum_method_spaces_volume_write(): number;+ uniffi_cua_sdk_checksum_method_spaces_watch_resources(): number;uniffi_cua_sdk_checksum_method_spacesdclient_agents(): number;uniffi_cua_sdk_checksum_method_spacesdclient_attach(): number;uniffi_cua_sdk_checksum_method_spacesdclient_call_json(): number;@@ -6215,6 +6326,14 @@ export type UniffiVTableCallbackInterfaceCuaSdkFrameSink = {on_frame: UniffiCallbackInterfaceCuaSdkFrameSinkMethod0;on_event: UniffiCallbackInterfaceCuaSdkFrameSinkMethod1;};+type UniffiCallbackInterfaceCuaSdkResourcesListenerMethod0 = (uniffiHandle: bigint, event: Uint8Array) => UniffiResult<void>;+type UniffiCallbackInterfaceCloneCuaSdkResourcesListener = (handle: bigint) => UniffiResult<void>;+type UniffiCallbackInterfaceFreeCuaSdkResourcesListener = (handle: bigint) => void;+export type UniffiVTableCallbackInterfaceCuaSdkResourcesListener = {+ uniffi_free: UniffiCallbackInterfaceFreeCuaSdkResourcesListener;+ uniffi_clone: UniffiCallbackInterfaceCloneCuaSdkResourcesListener;+ on_event: UniffiCallbackInterfaceCuaSdkResourcesListenerMethod0;+};type UniffiCallbackInterfaceCuaSdkSpaceCreateListenerMethod0 = (uniffiHandle: bigint, progress: Uint8Array) => UniffiResult<void>;type UniffiCallbackInterfaceCloneCuaSdkSpaceCreateListener = (handle: bigint) => UniffiResult<void>;type UniffiCallbackInterfaceFreeCuaSdkSpaceCreateListener = (handle: bigint) => void;diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.tsindex 41ce5a1252..aab73a7d31 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts@@ -10,7 +10,7 @@/* eslint-disable */// @ts-nocheckimport nativeModule from "./cua_sdk-ffi";-import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaSdkAudioSink, type UniffiVTableCallbackInterfaceCuaSdkFrameSink, type UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener, type UniffiVTableCallbackInterfaceCuaSdkTeleportApprover,+import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaSdkAudioSink, type UniffiVTableCallbackInterfaceCuaSdkFrameSink, type UniffiVTableCallbackInterfaceCuaSdkResourcesListener, type UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener, type UniffiVTableCallbackInterfaceCuaSdkTeleportApprover,} from "./cua_sdk-ffi";import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterFloat64, FfiConverterInt32, FfiConverterInt64, FfiConverterMap, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, FfiConverterUInt16, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiEnum, UniffiError, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiRustCallAsync, uniffiTraitInterfaceCall, uniffiTypeNameSymbol, variantOrdinalSymbol,} from "@ubjs/core";@@ -4054,6 +4054,290 @@ const FfiConverterTypeComputerGrant = (() => {return new FFIConverter();})();+/**+ * How low the free disk is.+ */+export enum DiskLevel {+ /**+ * Plenty.+ */+ Ok = "ok",+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (the+ * line never rises above 100 GB).+ */+ Low = "low",+ /**+ * Under the floor where creating a Space already fails (5 GiB).+ */+ Critical = "critical"+}++const FfiConverterTypeDiskLevel = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = DiskLevel;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return DiskLevel.Ok;+ case 2: return DiskLevel.Low;+ case 3: return DiskLevel.Critical;+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value) {+ case DiskLevel.Ok: return ordinalConverter.write(1, into);+ case DiskLevel.Low: return ordinalConverter.write(2, into);+ case DiskLevel.Critical: return ordinalConverter.write(3, into);+ }+ }+ allocationSize(value: TypeName): number {+ return ordinalConverter.allocationSize(0);+ }+ }+ return new FFIConverter();+})();++/**+ * The low-disk signal for the app and the menu bar.+ */+export type DiskWarning = {+ /**+ * How low it is.+ */+ level: DiskLevel,+ /**+ * Free bytes on the volume that holds Spaces.+ */+ free: bigint,+ /**+ * Size of that volume.+ */+ total: bigint,+ /**+ * The line that was crossed (0 when `ok`).+ */+ threshold: bigint+}++/**+ * Generated factory for {@link DiskWarning} record objects.+ */+export const DiskWarning = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<DiskWarning, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<DiskWarning>,+ });+})();++const FfiConverterTypeDiskWarning = (() => {+ type TypeName = DiskWarning;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ level: FfiConverterTypeDiskLevel.read(from),+ free: FfiConverterUInt64.read(from),+ total: FfiConverterUInt64.read(from),+ threshold: FfiConverterUInt64.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterTypeDiskLevel.write(value.level, into);+ FfiConverterUInt64.write(value.free, into);+ FfiConverterUInt64.write(value.total, into);+ FfiConverterUInt64.write(value.threshold, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterTypeDiskLevel.allocationSize(value.level) ++ FfiConverterUInt64.allocationSize(value.free) ++ FfiConverterUInt64.allocationSize(value.total) ++ FfiConverterUInt64.allocationSize(value.threshold);++ }+ };+ return new FFIConverter();+})();++/**+ * A computer: this Mac, or one of your other computers (from the summary+ * it published).+ */+export type ComputerResources = {+ /**+ * `this-mac`, or the relay machine id.+ */+ id: string,+ /**+ * Display name (empty for this Mac).+ */+ name: string,+ /**+ * Reachable now (always true for this Mac).+ */+ online: boolean,+ /**+ * When the computer measured this, unix ms (another computer's can be+ * minutes old).+ */+ sampledAtMs: bigint,+ /**+ * Processor cores.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * Memory in use, bytes (without reclaimable cache).+ */+ memoryUsed: bigint,+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ diskTotal: bigint,+ /**+ * Free bytes on it.+ */+ diskFree: bigint,+ /**+ * Extra Spaces on it.+ */+ spacesCount: number,+ /**+ * Of those, running.+ */+ spacesRunning: number,+ /**+ * Cores given to the running ones.+ */+ spacesCpuAllocated: number,+ /**+ * Memory given to the running ones, bytes.+ */+ spacesMemoryAllocated: bigint,+ /**+ * Memory the running guests report in use, bytes.+ */+ spacesMemoryUsed: bigint,+ /**+ * Bytes all its extra Spaces take on it.+ */+ spacesDiskBytes: bigint,+ /**+ * False when some Space's disk could only be estimated.+ */+ spacesDiskExact: boolean,+ /**+ * The low-disk signal.+ */+ warning: DiskWarning+}++/**+ * Generated factory for {@link ComputerResources} record objects.+ */+export const ComputerResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ComputerResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ComputerResources>,+ });+})();++const FfiConverterTypeComputerResources = (() => {+ type TypeName = ComputerResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ name: FfiConverterString.read(from),+ online: FfiConverterBool.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskFree: FfiConverterUInt64.read(from),+ spacesCount: FfiConverterUInt32.read(from),+ spacesRunning: FfiConverterUInt32.read(from),+ spacesCpuAllocated: FfiConverterUInt32.read(from),+ spacesMemoryAllocated: FfiConverterUInt64.read(from),+ spacesMemoryUsed: FfiConverterUInt64.read(from),+ spacesDiskBytes: FfiConverterUInt64.read(from),+ spacesDiskExact: FfiConverterBool.read(from),+ warning: FfiConverterTypeDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.name, into);+ FfiConverterBool.write(value.online, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterUInt64.write(value.diskFree, into);+ FfiConverterUInt32.write(value.spacesCount, into);+ FfiConverterUInt32.write(value.spacesRunning, into);+ FfiConverterUInt32.write(value.spacesCpuAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryUsed, into);+ FfiConverterUInt64.write(value.spacesDiskBytes, into);+ FfiConverterBool.write(value.spacesDiskExact, into);+ FfiConverterTypeDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.name) ++ FfiConverterBool.allocationSize(value.online) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterUInt64.allocationSize(value.diskFree) ++ FfiConverterUInt32.allocationSize(value.spacesCount) ++ FfiConverterUInt32.allocationSize(value.spacesRunning) ++ FfiConverterUInt32.allocationSize(value.spacesCpuAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryUsed) ++ FfiConverterUInt64.allocationSize(value.spacesDiskBytes) ++ FfiConverterBool.allocationSize(value.spacesDiskExact) ++ FfiConverterTypeDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();+/*** One setting's effective value.*/@@ -5149,6 +5433,67 @@ const FfiConverterTypeDevicesSnapshot = (() => {return new FFIConverter();})();+/**+ * What a Space costs this computer's disk, as opposed to what the guest+ * sees.+ */+export type DiskOnHost = {+ /**+ * Bytes only this Space holds (what deleting it frees); absent when+ * they could not be measured.+ */+ bytes?: bigint,+ /**+ * Blocks its files occupy, clones counted in full: an upper bound.+ */+ allocated: bigint,+ /**+ * Part of it is shared with other copies.+ */+ sharesSpace: boolean+}++/**+ * Generated factory for {@link DiskOnHost} record objects.+ */+export const DiskOnHost = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<DiskOnHost, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<DiskOnHost>,+ });+})();++const FfiConverterTypeDiskOnHost = (() => {+ type TypeName = DiskOnHost;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ bytes: FfiConverterOptionalUInt64.read(from),+ allocated: FfiConverterUInt64.read(from),+ sharesSpace: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterOptionalUInt64.write(value.bytes, into);+ FfiConverterUInt64.write(value.allocated, into);+ FfiConverterBool.write(value.sharesSpace, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterOptionalUInt64.allocationSize(value.bytes) ++ FfiConverterUInt64.allocationSize(value.allocated) ++ FfiConverterBool.allocationSize(value.sharesSpace);++ }+ };+ return new FFIConverter();+})();+/*** Status of one local runtime component.*/@@ -8827,6 +9172,107 @@ const FfiConverterTypeGpuSupport = (() => {return new FFIConverter();})();+/**+ * What `SystemService.Metrics` reports from inside a Space.+ */+export type GuestUsage = {+ /**+ * Cores the guest sees.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory in use, bytes.+ */+ memoryUsed: bigint,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * `memory_total` is the guest's own limit.+ */+ memoryLimited: boolean,+ /**+ * Disk in use, bytes.+ */+ diskUsed: bigint,+ /**+ * Disk size, bytes.+ */+ diskTotal: bigint,+ /**+ * `disk_total` is the guest's own disk.+ */+ diskLimited: boolean+}++/**+ * Generated factory for {@link GuestUsage} record objects.+ */+export const GuestUsage = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<GuestUsage, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<GuestUsage>,+ });+})();++const FfiConverterTypeGuestUsage = (() => {+ type TypeName = GuestUsage;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryLimited: FfiConverterBool.read(from),+ diskUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskLimited: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterBool.write(value.memoryLimited, into);+ FfiConverterUInt64.write(value.diskUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterBool.write(value.diskLimited, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterBool.allocationSize(value.memoryLimited) ++ FfiConverterUInt64.allocationSize(value.diskUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterBool.allocationSize(value.diskLimited);++ }+ };+ return new FFIConverter();+})();+/*** One access to this machine.*/@@ -12331,6 +12777,254 @@ const FfiConverterTypeResolvedImage = (() => {return new FFIConverter();})();+/**+ * One extra Space on this Mac.+ */+export type SpaceResources = {+ /**+ * `local:<name>`.+ */+ id: string,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ powerState: string,+ /**+ * Cores given to it (0: unknown).+ */+ cpuAllocated: number,+ /**+ * Memory given to it, bytes (0: unknown).+ */+ memoryAllocated: bigint,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ diskAllocated: bigint,+ /**+ * The guest's own numbers; absent while it is off or unreachable.+ */+ usage?: GuestUsage,+ /**+ * What it costs this Mac; absent for a container.+ */+ diskOnHost?: DiskOnHost+}++/**+ * Generated factory for {@link SpaceResources} record objects.+ */+export const SpaceResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<SpaceResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<SpaceResources>,+ });+})();++const FfiConverterTypeSpaceResources = (() => {+ type TypeName = SpaceResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ powerState: FfiConverterString.read(from),+ cpuAllocated: FfiConverterUInt32.read(from),+ memoryAllocated: FfiConverterUInt64.read(from),+ diskAllocated: FfiConverterUInt64.read(from),+ usage: FfiConverterOptionalTypeGuestUsage.read(from),+ diskOnHost: FfiConverterOptionalTypeDiskOnHost.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.powerState, into);+ FfiConverterUInt32.write(value.cpuAllocated, into);+ FfiConverterUInt64.write(value.memoryAllocated, into);+ FfiConverterUInt64.write(value.diskAllocated, into);+ FfiConverterOptionalTypeGuestUsage.write(value.usage, into);+ FfiConverterOptionalTypeDiskOnHost.write(value.diskOnHost, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.powerState) ++ FfiConverterUInt32.allocationSize(value.cpuAllocated) ++ FfiConverterUInt64.allocationSize(value.memoryAllocated) ++ FfiConverterUInt64.allocationSize(value.diskAllocated) ++ FfiConverterOptionalTypeGuestUsage.allocationSize(value.usage) ++ FfiConverterOptionalTypeDiskOnHost.allocationSize(value.diskOnHost);++ }+ };+ return new FFIConverter();+})();++/**+ * One sample of everything.+ */+export type ResourcesSnapshot = {+ /**+ * Grows by one per sample.+ */+ sequence: bigint,+ /**+ * Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * This Mac.+ */+ thisMac: ComputerResources,+ /**+ * Extra Spaces on this Mac.+ */+ spaces: Array<SpaceResources>,+ /**+ * Your other computers, from the summaries they published.+ */+ computers: Array<ComputerResources>,+ /**+ * `this_mac.warning`, for the menu bar.+ */+ warning: DiskWarning+}++/**+ * Generated factory for {@link ResourcesSnapshot} record objects.+ */+export const ResourcesSnapshot = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ResourcesSnapshot, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ResourcesSnapshot>,+ });+})();++const FfiConverterTypeResourcesSnapshot = (() => {+ type TypeName = ResourcesSnapshot;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ sequence: FfiConverterUInt64.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ thisMac: FfiConverterTypeComputerResources.read(from),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from),+ computers: FfiConverterSequenceTypeComputerResources.read(from),+ warning: FfiConverterTypeDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt64.write(value.sequence, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterTypeComputerResources.write(value.thisMac, into);+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into);+ FfiConverterSequenceTypeComputerResources.write(value.computers, into);+ FfiConverterTypeDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt64.allocationSize(value.sequence) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterTypeComputerResources.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.spaces) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.computers) ++ FfiConverterTypeDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();++/**+ * What changed since the last event: only entries that moved by more than+ * 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+ */+export type ResourcesUpdate = {+ /**+ * The sample it brings you to.+ */+ sequence: bigint,+ /**+ * Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * This Mac, when it changed.+ */+ thisMac?: ComputerResources,+ /**+ * Extra Spaces that changed or appeared.+ */+ spaces: Array<SpaceResources>,+ /**+ * Other computers that changed or appeared.+ */+ computers: Array<ComputerResources>,+ /**+ * Ids (Spaces or computers) that are gone.+ */+ removed: Array<string>+}++/**+ * Generated factory for {@link ResourcesUpdate} record objects.+ */+export const ResourcesUpdate = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ResourcesUpdate, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ResourcesUpdate>,+ });+})();++const FfiConverterTypeResourcesUpdate = (() => {+ type TypeName = ResourcesUpdate;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ sequence: FfiConverterUInt64.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ thisMac: FfiConverterOptionalTypeComputerResources.read(from),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from),+ computers: FfiConverterSequenceTypeComputerResources.read(from),+ removed: FfiConverterSequenceString.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt64.write(value.sequence, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterOptionalTypeComputerResources.write(value.thisMac, into);+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into);+ FfiConverterSequenceTypeComputerResources.write(value.computers, into);+ FfiConverterSequenceString.write(value.removed, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt64.allocationSize(value.sequence) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterOptionalTypeComputerResources.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.spaces) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.computers) ++ FfiConverterSequenceString.allocationSize(value.removed);++ }+ };+ return new FFIConverter();+})();+/*** A routine: a recurring turn of a persistent agent, fired by the daemon.*/@@ -15853,11 +16547,23 @@ const FfiConverterTypeSpaceTransferReport = (() => {})();/**- * Memory and storage use ([`Space::usage`]). A size is the guest's own- * limit only when its `*_limited` flag says so (a VM's memory or disk, a- * container's cgroup memory limit).+ * Processor, memory and storage use ([`Space::usage`]). A size is the+ * guest's own limit only when its `*_limited` flag says so (a VM's memory+ * or disk, a container's cgroup memory limit).*/export type SpaceUsage = {+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,/*** Memory in use, bytes.*/@@ -15889,6 +16595,9 @@ export type SpaceUsage = {*/export const SpaceUsage = (() => {const defaults = () => ({+ cpuCount: 0,+ cpuPercent: 0.0,+ loadAverage1m: 0.0,});const create = (() => {return uniffiCreateRecord<SpaceUsage, ReturnType<typeof defaults>>(defaults);@@ -15905,6 +16614,9 @@ const FfiConverterTypeSpaceUsage = (() => {class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {read(from: RustBuffer): TypeName {return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),memoryUsed: FfiConverterUInt64.read(from),memoryTotal: FfiConverterUInt64.read(from),memoryLimited: FfiConverterBool.read(from),@@ -15914,6 +16626,9 @@ const FfiConverterTypeSpaceUsage = (() => {};}write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);FfiConverterUInt64.write(value.memoryUsed, into);FfiConverterUInt64.write(value.memoryTotal, into);FfiConverterBool.write(value.memoryLimited, into);@@ -15922,7 +16637,10 @@ const FfiConverterTypeSpaceUsage = (() => {FfiConverterBool.write(value.diskLimited, into);}allocationSize(value: TypeName): number {- return FfiConverterUInt64.allocationSize(value.memoryUsed) ++ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) +FfiConverterUInt64.allocationSize(value.memoryTotal) +FfiConverterBool.allocationSize(value.memoryLimited) +FfiConverterUInt64.allocationSize(value.diskUsed) +@@ -19072,6 +19790,204 @@ const FfiConverterTypeReplayMode = (() => {return new FFIConverter();})();++// Enum: ResourcesEvent+export enum ResourcesEvent_Tags {+ Snapshot = "Snapshot",+ Update = "Update",+ LowDisk = "LowDisk"+}+/**+ * What [`Spaces::watch_resources`] reports.+ */+export const ResourcesEvent = (() => {++ type Snapshot__interface = {+ tag: ResourcesEvent_Tags.Snapshot;+ inner:+Readonly<{snapshot: ResourcesSnapshot}>+ };+ /**+ * Everything, at the start (and again after a reconnect).+ */+ class Snapshot_ extends UniffiEnum implements Snapshot__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.Snapshot;+ readonly inner:+Readonly<{snapshot: ResourcesSnapshot}>;+ constructor(+inner: {snapshot: ResourcesSnapshot }) {+ super("ResourcesEvent", "Snapshot");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {snapshot: ResourcesSnapshot }): Snapshot_ {+ return new Snapshot_(inner);+ }++ static instanceOf(obj: any): obj is Snapshot_ {+ return obj.tag === ResourcesEvent_Tags.Snapshot;+ }++ }++ type Update__interface = {+ tag: ResourcesEvent_Tags.Update;+ inner:+Readonly<{update: ResourcesUpdate}>+ };+ /**+ * Only what changed.+ */+ class Update_ extends UniffiEnum implements Update__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.Update;+ readonly inner:+Readonly<{update: ResourcesUpdate}>;+ constructor(+inner: {update: ResourcesUpdate }) {+ super("ResourcesEvent", "Update");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {update: ResourcesUpdate }): Update_ {+ return new Update_(inner);+ }++ static instanceOf(obj: any): obj is Update_ {+ return obj.tag === ResourcesEvent_Tags.Update;+ }++ }++ type LowDisk__interface = {+ tag: ResourcesEvent_Tags.LowDisk;+ inner:+Readonly<{warning: DiskWarning}>+ };+ /**+ * The low-disk level changed (including back to `ok`).+ */+ class LowDisk_ extends UniffiEnum implements LowDisk__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.LowDisk;+ readonly inner:+Readonly<{warning: DiskWarning}>;+ constructor(+inner: {warning: DiskWarning }) {+ super("ResourcesEvent", "LowDisk");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {warning: DiskWarning }): LowDisk_ {+ return new LowDisk_(inner);+ }++ static instanceOf(obj: any): obj is LowDisk_ {+ return obj.tag === ResourcesEvent_Tags.LowDisk;+ }++ }++ function instanceOf(obj: any): obj is ResourcesEvent {+ return obj[uniffiTypeNameSymbol] === "ResourcesEvent";+ }++ return Object.freeze({+ instanceOf,+ Snapshot: Snapshot_,+ Update: Update_,+ LowDisk: LowDisk_+ });++})();+/**+ * What [`Spaces::watch_resources`] reports.+ */+export type ResourcesEvent = InstanceType<+ typeof ResourcesEvent['Snapshot' | 'Update' | 'LowDisk']+>;++// FfiConverter for enum ResourcesEvent+const FfiConverterTypeResourcesEvent = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = ResourcesEvent;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return new ResourcesEvent.Snapshot({snapshot: FfiConverterTypeResourcesSnapshot.read(from) });+ case 2: return new ResourcesEvent.Update({update: FfiConverterTypeResourcesUpdate.read(from) });+ case 3: return new ResourcesEvent.LowDisk({warning: FfiConverterTypeDiskWarning.read(from) });+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value.tag) {+ case ResourcesEvent_Tags.Snapshot: {+ ordinalConverter.write(1, into);+ const inner = value.inner;+ FfiConverterTypeResourcesSnapshot.write(inner.snapshot, into);+ return;+ }+ case ResourcesEvent_Tags.Update: {+ ordinalConverter.write(2, into);+ const inner = value.inner;+ FfiConverterTypeResourcesUpdate.write(inner.update, into);+ return;+ }+ case ResourcesEvent_Tags.LowDisk: {+ ordinalConverter.write(3, into);+ const inner = value.inner;+ FfiConverterTypeDiskWarning.write(inner.warning, into);+ return;+ }+ default:+ // Throwing from here means that ResourcesEvent_Tags hasn't matched an ordinal.+ throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ allocationSize(value: TypeName): number {+ switch (value.tag) {+ case ResourcesEvent_Tags.Snapshot: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(1);+ size += FfiConverterTypeResourcesSnapshot.allocationSize(inner.snapshot);+ return size;+ }+ case ResourcesEvent_Tags.Update: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(2);+ size += FfiConverterTypeResourcesUpdate.allocationSize(inner.update);+ return size;+ }+ case ResourcesEvent_Tags.LowDisk: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(3);+ size += FfiConverterTypeDiskWarning.allocationSize(inner.warning);+ return size;+ }+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ }+ return new FFIConverter();+})();+/*** One run.*/@@ -30941,8 +31857,8 @@ export interface SpaceLike {*/upload(localPath: string, dest: string | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceTransferReport>;/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/usage(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceUsage>;/**@@ -32347,8 +33263,8 @@ private constructor(pointer: UniffiHandle) {}/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/async usage(asyncOpts_?: { signal: AbortSignal }): Promise<SpaceUsage> /*throws*/ {const __stack = uniffiIsDebug ? new Error().stack : undefined;@@ -32605,6 +33521,326 @@ const uniffiTypeSpaceObjectFactory: UniffiObjectFactory<SpaceLike> = (() => {}})();const FfiConverterTypeSpace = new FfiConverterObject(uniffiTypeSpaceObjectFactory);+/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+export interface ResourcesListener {++/**+ * Something moved.+ */+ onEvent(event: ResourcesEvent): void;+}+++/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+export class ResourcesListenerImpl extends UniffiAbstractObject implements ResourcesListener {++ readonly [uniffiTypeNameSymbol] = "ResourcesListenerImpl";+ readonly [destructorGuardSymbol]: UniffiGcObject;+ readonly [pointerLiteralSymbol]: UniffiHandle;+ // No primary constructor declared for this class.+private constructor(pointer: UniffiHandle) {+ super();+ this[pointerLiteralSymbol] = pointer;+ this[destructorGuardSymbol] = uniffiTypeResourcesListenerImplObjectFactory.bless(pointer);+}+++++/**+ * Something moved.+ */+ onEvent(event: ResourcesEvent): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceslistener_on_event(+ uniffiTypeResourcesListenerImplObjectFactory.clonePointer(this),+ FfiConverterTypeResourcesEvent.lower(event, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }+++ uniffiDestroy(): void {+ const ptr = (this as any)[destructorGuardSymbol];+ if (ptr !== undefined) {+ const pointer = uniffiTypeResourcesListenerImplObjectFactory.pointer(this);+ uniffiTypeResourcesListenerImplObjectFactory.freePointer(pointer);+ uniffiTypeResourcesListenerImplObjectFactory.unbless(ptr);+ delete (this as any)[destructorGuardSymbol];+ }+ }++ static instanceOf(obj_: any): obj_ is ResourcesListenerImpl {+ return uniffiTypeResourcesListenerImplObjectFactory.isConcreteType(obj_);+ }+++}++const uniffiTypeResourcesListenerImplObjectFactory: UniffiObjectFactory<ResourcesListener> = (() => {++ /// <reference lib="es2021" />+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {+ uniffiTypeResourcesListenerImplObjectFactory.freePointer(heldValue);+ }) : null;++ return {+ create(pointer: UniffiHandle): ResourcesListener {+ const instance = Object.create(ResourcesListenerImpl.prototype);+ instance[pointerLiteralSymbol] = pointer;+ instance[destructorGuardSymbol] = this.bless(pointer);+ instance[uniffiTypeNameSymbol] = "ResourcesListenerImpl";+ return instance;+ },+++ bless(p: UniffiHandle): UniffiGcObject {+ const ptr = {+ p, // make sure this object doesn't get optimized away.+ markDestroyed: () => undefined,+ };+ if (registry) {+ registry.register(ptr, p, ptr);+ }+ return ptr;+ },++ unbless(ptr_: UniffiGcObject) {+ if (registry) {+ registry.unregister(ptr_);+ }+ },++ pointer(obj_: ResourcesListener): UniffiHandle {+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {+ throw new UniffiInternalError.UnexpectedNullPointer();+ }+ return (obj_ as any)[pointerLiteralSymbol];+ },++ clonePointer(obj_: ResourcesListener): UniffiHandle {+ const pointer = this.pointer(obj_);+ return uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_clone_resourceslistener(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ freePointer(pointer: UniffiHandle): void {+ uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_free_resourceslistener(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ isConcreteType(obj_: any): obj_ is ResourcesListener {+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ResourcesListenerImpl";+ },+}})();+const FfiConverterTypeResourcesListener = new FfiConverterObjectWithCallbacks(uniffiTypeResourcesListenerImplObjectFactory);++// Add a vtable for the callbacks that go in ResourcesListener.++// Put the implementation in a struct so we don't pollute the top-level namespace+const uniffiCallbackInterfaceResourcesListener: { vtable: any; register: () => void; } = {+ // Create the VTable using a series of closures.+ // ts automatically converts these into C callback functions.+ vtable: {+ on_event: (+ uniffiHandle: bigint,+ event: Uint8Array,) => {+ const uniffiMakeCall =+ ()+ : void => {+ const jsCallback = FfiConverterTypeResourcesListener.lift(uniffiHandle);+ return jsCallback.onEvent(+ FfiConverterTypeResourcesEvent.lift(event)+ )+ };+ const uniffiResult = UniffiResult.ready<void>();+ const uniffiHandleSuccess = (obj: any) => {};+ const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {+ UniffiResult.writeError(uniffiResult, code, errBuf);+ };+ uniffiTraitInterfaceCall(+ /*makeCall:*/ uniffiMakeCall,+ /*handleSuccess:*/ uniffiHandleSuccess,+ /*handleError:*/ uniffiHandleError,+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),+ /*alloc:*/ nativeModule().rustbuffer_alloc,+ )+ return uniffiResult;+ },+ uniffi_free: (uniffiHandle: UniffiHandle): void => {+ // this will throw a stale handle error if the handle isn't found.+ FfiConverterTypeResourcesListener.drop(uniffiHandle);+ },+ uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {+ return FfiConverterTypeResourcesListener.clone(uniffiHandle);+ }+ },+ register: () => {nativeModule().uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(+ uniffiCallbackInterfaceResourcesListener.vtable+ );+ },+};++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+export interface ResourcesWatchLike {++/**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ setVisible(visible: boolean): void;+/**+ * Ends the watch. No event is delivered after this returns.+ */+ stop(): void;+}+/**+ * @deprecated Use `ResourcesWatchLike` instead.+ */+export type ResourcesWatchInterface = ResourcesWatchLike;+++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+export class ResourcesWatch extends UniffiAbstractObject implements ResourcesWatchLike {++ readonly [uniffiTypeNameSymbol] = "ResourcesWatch";+ readonly [destructorGuardSymbol]: UniffiGcObject;+ readonly [pointerLiteralSymbol]: UniffiHandle;+ // No primary constructor declared for this class.+private constructor(pointer: UniffiHandle) {+ super();+ this[pointerLiteralSymbol] = pointer;+ this[destructorGuardSymbol] = uniffiTypeResourcesWatchObjectFactory.bless(pointer);+}+++++/**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ setVisible(visible: boolean): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceswatch_set_visible(+ uniffiTypeResourcesWatchObjectFactory.clonePointer(this),+ FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }++/**+ * Ends the watch. No event is delivered after this returns.+ */+ stop(): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceswatch_stop(+ uniffiTypeResourcesWatchObjectFactory.clonePointer(this),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }+++ uniffiDestroy(): void {+ const ptr = (this as any)[destructorGuardSymbol];+ if (ptr !== undefined) {+ const pointer = uniffiTypeResourcesWatchObjectFactory.pointer(this);+ uniffiTypeResourcesWatchObjectFactory.freePointer(pointer);+ uniffiTypeResourcesWatchObjectFactory.unbless(ptr);+ delete (this as any)[destructorGuardSymbol];+ }+ }++ static instanceOf(obj_: any): obj_ is ResourcesWatch {+ return uniffiTypeResourcesWatchObjectFactory.isConcreteType(obj_);+ }+++}++const uniffiTypeResourcesWatchObjectFactory: UniffiObjectFactory<ResourcesWatchLike> = (() => {++ /// <reference lib="es2021" />+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {+ uniffiTypeResourcesWatchObjectFactory.freePointer(heldValue);+ }) : null;++ return {+ create(pointer: UniffiHandle): ResourcesWatchLike {+ const instance = Object.create(ResourcesWatch.prototype);+ instance[pointerLiteralSymbol] = pointer;+ instance[destructorGuardSymbol] = this.bless(pointer);+ instance[uniffiTypeNameSymbol] = "ResourcesWatch";+ return instance;+ },+++ bless(p: UniffiHandle): UniffiGcObject {+ const ptr = {+ p, // make sure this object doesn't get optimized away.+ markDestroyed: () => undefined,+ };+ if (registry) {+ registry.register(ptr, p, ptr);+ }+ return ptr;+ },++ unbless(ptr_: UniffiGcObject) {+ if (registry) {+ registry.unregister(ptr_);+ }+ },++ pointer(obj_: ResourcesWatchLike): UniffiHandle {+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {+ throw new UniffiInternalError.UnexpectedNullPointer();+ }+ return (obj_ as any)[pointerLiteralSymbol];+ },++ clonePointer(obj_: ResourcesWatchLike): UniffiHandle {+ const pointer = this.pointer(obj_);+ return uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_clone_resourceswatch(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ freePointer(pointer: UniffiHandle): void {+ uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_free_resourceswatch(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ isConcreteType(obj_: any): obj_ is ResourcesWatchLike {+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ResourcesWatch";+ },+}})();+const FfiConverterTypeResourcesWatch = new FfiConverterObject(uniffiTypeResourcesWatchObjectFactory);+/*** The Spaces registry: add a machine by URL, provision a local one, and get* [`Space`] handles.@@ -32791,6 +34027,15 @@ export interface SpacesLike {* Resolves an id, legacy id, URL or display name.*/resolve(space: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceInfo>;+/**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ resources(visible: boolean, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ResourcesSnapshot>;/*** Adds a routine. Give exactly one of `every_minutes`, `daily_at`* (`HH:MM`) or `weekly_on` (`mon 09:00`).@@ -32931,6 +34176,14 @@ export interface SpacesLike {* compare-and-swap, `create_only` makes it create-only.*/volumeWrite(path: string, content: ArrayBuffer, ifEtag: string | undefined, createOnly: boolean, view: DriveView | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<DriveObject>;+/**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ watchResources(visible: boolean, listener: ResourcesListener): ResourcesWatchLike;}/*** @deprecated Use `SpacesLike` instead.@@ -34186,6 +35439,46 @@ private constructor(pointer: UniffiHandle) {}}+/**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ async resources(visible: boolean, asyncOpts_?: { signal: AbortSignal }): Promise<ResourcesSnapshot> /*throws*/ {+ const __stack = uniffiIsDebug ? new Error().stack : undefined;+ try {+ return await uniffiRustCallAsync(+ /*rustCaller:*/ uniffiCaller,+ /*rustFutureFunc:*/ () => {+ return nativeModule().uniffi_cua_sdk_fn_method_spaces_resources(+ uniffiTypeSpacesObjectFactory.clonePointer(this),FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc)+ );+ },+ /*pollFunc:*/ nativeModule().ffi_cua_sdk_rust_future_poll_rust_buffer,+ /*cancelFunc:*/ nativeModule().ffi_cua_sdk_rust_future_cancel_rust_buffer,+ /*completeFunc:*/ nativeModule().ffi_cua_sdk_rust_future_complete_rust_buffer,+ /*freeFunc:*/ nativeModule().ffi_cua_sdk_rust_future_free_rust_buffer,+ // Async returns always go through the JS-side converter: the+ // FFI symbol returns the future handle (u64), and the user-level+ // RustBuffer comes back via the shared `rust_future_complete_*`+ // export. The bytes the runtime hands back must be deserialized+ // here using the per-callable return-type converter.+ /*liftFunc:*/ FfiConverterTypeResourcesSnapshot.lift.bind(FfiConverterTypeResourcesSnapshot),+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ /*asyncOpts:*/ asyncOpts_,+ /*errorHandler:*/ FfiConverterTypeCuaError.lift.bind(FfiConverterTypeCuaError)+ );+ } catch (__error: any) {+ if (uniffiIsDebug && __error instanceof Error) {+ __error.stack = __stack;+ }+ throw __error;+ }+ }+/*** Adds a routine. Give exactly one of `every_minutes`, `daily_at`* (`HH:MM`) or `weekly_on` (`mon 09:00`).@@ -35298,6 +36591,26 @@ private constructor(pointer: UniffiHandle) {}}+/**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ watchResources(visible: boolean, listener: ResourcesListener): ResourcesWatchLike {+ return FfiConverterTypeResourcesWatch.lift(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_sdk_fn_method_spaces_watch_resources(+ uniffiTypeSpacesObjectFactory.clonePointer(this),+ FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc),+ FfiConverterTypeResourcesListener.lower(listener, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }+uniffiDestroy(): void {const ptr = (this as any)[destructorGuardSymbol];@@ -36774,6 +38087,21 @@ const FfiConverterOptionalTypePresenceCursor = new FfiConverterOptional(FfiConve// FfiConverter for ExitInfo | undefinedconst FfiConverterOptionalTypeExitInfo = new FfiConverterOptional(FfiConverterTypeExitInfo);+// FfiConverter for GuestUsage | undefined+const FfiConverterOptionalTypeGuestUsage = new FfiConverterOptional(FfiConverterTypeGuestUsage);++// FfiConverter for DiskOnHost | undefined+const FfiConverterOptionalTypeDiskOnHost = new FfiConverterOptional(FfiConverterTypeDiskOnHost);++// FfiConverter for Array<SpaceResources>+const FfiConverterSequenceTypeSpaceResources = new FfiConverterArray(FfiConverterTypeSpaceResources);++// FfiConverter for Array<ComputerResources>+const FfiConverterSequenceTypeComputerResources = new FfiConverterArray(FfiConverterTypeComputerResources);++// FfiConverter for ComputerResources | undefined+const FfiConverterOptionalTypeComputerResources = new FfiConverterOptional(FfiConverterTypeComputerResources);+// FfiConverter for Array<ReadinessProbe>const FfiConverterSequenceTypeReadinessProbe = new FfiConverterArray(FfiConverterTypeReadinessProbe);@@ -37654,6 +38982,15 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_relay_url() !== 31201) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_relay_url");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceslistener_on_event() !== 32126) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceslistener_on_event");+ }+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceswatch_set_visible() !== 54652) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceswatch_set_visible");+ }+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceswatch_stop() !== 52286) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceswatch_stop");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_sandbox_agents() !== 53699) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_sandbox_agents");}@@ -37921,7 +39258,7 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_space_upload() !== 30524) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_upload");}- if (nativeModule().uniffi_cua_sdk_checksum_method_space_usage() !== 15261) {+ if (nativeModule().uniffi_cua_sdk_checksum_method_space_usage() !== 43925) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_usage");}if (nativeModule().uniffi_cua_sdk_checksum_method_space_websocket_headers() !== 61370) {@@ -38083,6 +39420,9 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_resolve() !== 9986) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_resolve");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_resources() !== 12146) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_resources");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_routine_add() !== 27220) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_routine_add");}@@ -38179,6 +39519,9 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_volume_write() !== 64388) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_volume_write");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_watch_resources() !== 49660) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_watch_resources");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_spacesdclient_agents() !== 39176) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spacesdclient_agents");}@@ -38346,6 +39689,7 @@ function uniffiEnsureInitialized() {uniffiCallbackInterfaceFrameSink.register();uniffiCallbackInterfaceSpaceCreateListener.register();uniffiCallbackInterfaceTeleportApprover.register();+ uniffiCallbackInterfaceResourcesListener.register();}export default Object.freeze({@@ -38396,6 +39740,7 @@ export default Object.freeze({FfiConverterTypeCloudTarget,FfiConverterTypeCloudTestReport,FfiConverterTypeComputerGrant,+ FfiConverterTypeComputerResources,FfiConverterTypeConfigEntry,FfiConverterTypeContainer,FfiConverterTypeCua,@@ -38407,6 +39752,9 @@ export default Object.freeze({FfiConverterTypeDeviceEnrollment,FfiConverterTypeDevices,FfiConverterTypeDevicesSnapshot,+ FfiConverterTypeDiskLevel,+ FfiConverterTypeDiskOnHost,+ FfiConverterTypeDiskWarning,FfiConverterTypeDoctorReport,FfiConverterTypeDriveAccessRequest,FfiConverterTypeDriveAudit,@@ -38455,6 +39803,7 @@ export default Object.freeze({FfiConverterTypeGpuOption,FfiConverterTypeGpuSupport,FfiConverterTypeGuestDisplay,+ FfiConverterTypeGuestUsage,FfiConverterTypeHomeTransfer,FfiConverterTypeHost,FfiConverterTypeHostAccessRecord,@@ -38514,6 +39863,11 @@ export default Object.freeze({FfiConverterTypeRelayMachine,FfiConverterTypeReplayMode,FfiConverterTypeResolvedImage,+ FfiConverterTypeResourcesEvent,+ FfiConverterTypeResourcesListener,+ FfiConverterTypeResourcesSnapshot,+ FfiConverterTypeResourcesUpdate,+ FfiConverterTypeResourcesWatch,FfiConverterTypeRoutineInfo,FfiConverterTypeRuntimeCheck,FfiConverterTypeRuntimeCheckStatus,@@ -38549,6 +39903,7 @@ export default Object.freeze({FfiConverterTypeSpacePowerReport,FfiConverterTypeSpacePresence,FfiConverterTypeSpaceRelayRegistration,+ FfiConverterTypeSpaceResources,FfiConverterTypeSpaceSendFileOptions,FfiConverterTypeSpaceSendFileReport,FfiConverterTypeSpaceSentFile,diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.tsindex c203192b34..ab2b569ec7 100644--- a/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts+++ b/apps/cua-spaces-desktop/src/native/generated/cua_spaces_ffi-ffi.ts@@ -1267,6 +1267,31 @@ const DEFINITIONS = {ret: FfiType.RustBuffer,hasRustCallStatus: true,},+ "uniffi_cua_spaces_ffi_fn_func_app_resources_computer": {+ args: [FfiType.RustBuffer, FfiType.UInt64],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },+ "uniffi_cua_spaces_ffi_fn_func_app_resources_space": {+ args: [FfiType.RustBuffer],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },+ "uniffi_cua_spaces_ffi_fn_func_app_resources_this_mac": {+ args: [FfiType.RustBuffer],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },+ "uniffi_cua_spaces_ffi_fn_func_app_resources_view": {+ args: [FfiType.RustBuffer, FfiType.UInt64],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },+ "uniffi_cua_spaces_ffi_fn_func_app_resources_warning": {+ args: [FfiType.RustBuffer],+ ret: FfiType.RustBuffer,+ hasRustCallStatus: true,+ },"uniffi_cua_spaces_ffi_fn_func_app_review_remember": {args: [FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer],ret: FfiType.RustBuffer,@@ -2962,6 +2987,31 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_spaces_ffi_checksum_func_app_resources_computer": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_spaces_ffi_checksum_func_app_resources_space": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_spaces_ffi_checksum_func_app_resources_view": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_spaces_ffi_checksum_func_app_resources_warning": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_spaces_ffi_checksum_func_app_review_remember": {args: [],ret: FfiType.UInt16,@@ -4149,6 +4199,11 @@ interface NativeModuleInterface {uniffi_cua_spaces_ffi_fn_func_app_refresh_report_from_json(json: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_relay_usage(devices: bigint, accountToken: Uint8Array): bigint;uniffi_cua_spaces_ffi_fn_func_app_relay_usage_view(usage: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_resources_computer(computer: Uint8Array, nowMs: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_resources_space(space: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_resources_this_mac(computer: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_resources_view(snapshot: Uint8Array, nowMs: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_spaces_ffi_fn_func_app_resources_warning(warning: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_review_remember(choices: Uint8Array, key: Uint8Array, domains: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_review_remember_key(app: Uint8Array, space: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;uniffi_cua_spaces_ffi_fn_func_app_review_remembered(choices: Uint8Array, key: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;@@ -4488,6 +4543,11 @@ interface NativeModuleInterface {uniffi_cua_spaces_ffi_checksum_func_app_refresh_report_from_json(): number;uniffi_cua_spaces_ffi_checksum_func_app_relay_usage(): number;uniffi_cua_spaces_ffi_checksum_func_app_relay_usage_view(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_resources_computer(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_resources_space(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_resources_view(): number;+ uniffi_cua_spaces_ffi_checksum_func_app_resources_warning(): number;uniffi_cua_spaces_ffi_checksum_func_app_review_remember(): number;uniffi_cua_spaces_ffi_checksum_func_app_review_remember_key(): number;uniffi_cua_spaces_ffi_checksum_func_app_review_remembered(): number;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 d7cdb5063b..1ee09e93b1 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@@ -10,12 +10,12 @@import nativeModule from "./cua_spaces_ffi-ffi";import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaSpacesFfiDecodedFrameSink, type UniffiVTableCallbackInterfaceCuaSpacesFfiPcmSink, type UniffiVTableCallbackInterfaceCuaSpacesFfiTeleportApproval, type UniffiVTableCallbackInterfaceCuaSpacesFfiTeleportRunListener, type UniffiVTableCallbackInterfaceCuaSpacesFfiTeleportWindowDragListener,} from "./cua_spaces_ffi-ffi";-import { type AgentInfo, type AgentSetupOutcome, type CuaLike, type DevicesLike, type DevicesSnapshot, type FleetBillingStatus, type HostLike, type HostStatus, type MediaEvent, type MediaOpenOptions, type MediaSessionLike, type SandboxLike, type SpaceLike, type SpaceSendFileReport, type SpacesHost, type SpacesdClientLike, type TeleportItem, type TeleportManifest, CuaError,+import { type AgentInfo, type AgentSetupOutcome, type ComputerResources, type CuaLike, type DevicesLike, type DevicesSnapshot, type DiskWarning, type FleetBillingStatus, type HostLike, type HostStatus, type MediaEvent, type MediaOpenOptions, type MediaSessionLike, type ResourcesSnapshot, type SandboxLike, type SpaceLike, type SpaceResources, type SpaceSendFileReport, type SpacesHost, type SpacesdClientLike, type TeleportItem, type TeleportManifest, CuaError,} from "./cua_sdk";import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterFloat64, FfiConverterInt16, FfiConverterInt32, FfiConverterInt64, FfiConverterMap, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, FfiConverterUInt16, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiEnum, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiRustCallAsync, uniffiTraitInterfaceCall, uniffiTypeNameSymbol,} from "@ubjs/core";import uniffiCuaSdkModule from "./cua_sdk";-const { FfiConverterTypeAgentInfo, FfiConverterTypeAgentSetupOutcome, FfiConverterTypeCua, FfiConverterTypeCuaError, FfiConverterTypeDevices, FfiConverterTypeDevicesSnapshot, FfiConverterTypeFleetBillingStatus, FfiConverterTypeHost, FfiConverterTypeHostStatus, FfiConverterTypeMediaEvent, FfiConverterTypeMediaOpenOptions, FfiConverterTypeMediaSession, FfiConverterTypeSandbox, FfiConverterTypeSpace, FfiConverterTypeSpaceSendFileReport, FfiConverterTypeSpacesHost, FfiConverterTypeSpacesdClient, FfiConverterTypeTeleportItem, FfiConverterTypeTeleportManifest } = uniffiCuaSdkModule.converters;+const { FfiConverterTypeAgentInfo, FfiConverterTypeAgentSetupOutcome, FfiConverterTypeComputerResources, FfiConverterTypeCua, FfiConverterTypeCuaError, FfiConverterTypeDevices, FfiConverterTypeDevicesSnapshot, FfiConverterTypeDiskWarning, FfiConverterTypeFleetBillingStatus, FfiConverterTypeHost, FfiConverterTypeHostStatus, FfiConverterTypeMediaEvent, FfiConverterTypeMediaOpenOptions, FfiConverterTypeMediaSession, FfiConverterTypeResourcesSnapshot, FfiConverterTypeSandbox, FfiConverterTypeSpace, FfiConverterTypeSpaceResources, FfiConverterTypeSpaceSendFileReport, FfiConverterTypeSpacesHost, FfiConverterTypeSpacesdClient, FfiConverterTypeTeleportItem, FfiConverterTypeTeleportManifest } = uniffiCuaSdkModule.converters;const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));const uniffiIsDebug =@@ -3689,6 +3689,116 @@ export function appRelayUsageView(usage: AppRelayUsage): AppRelayUsageView | und));}+/**+ * Another of your computers' panel.+ */+export function appResourcesComputer(computer: ComputerResources, nowMs: bigint): AppComputerView {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterTypeAppComputerView.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_resources_computer(+ FfiConverterTypeComputerResources.lower(computer, nativeModule().rustbuffer_alloc),+ FfiConverterUInt64.lower(nowMs, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }++/**+ * One extra Space's panel: what it was given and uses now, and what it+ * costs this Mac.+ */+export function appResourcesSpace(space: SpaceResources): AppSpaceResourcesView {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterTypeAppSpaceResourcesView.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_resources_space(+ FfiConverterTypeSpaceResources.lower(space, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }++/**+ * This Mac's panel (Processor, Memory, Space for files, what the extra+ * Spaces use, the warning).+ */+export function appResourcesThisMac(computer: ComputerResources): AppThisMacView {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterTypeAppThisMacView.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_resources_this_mac(+ FfiConverterTypeComputerResources.lower(computer, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }++/**+ * Everything the apps draw from one snapshot of what this Mac, its extra+ * Spaces and your other computers use (`Spaces.resources`, or a snapshot+ * event of `Spaces.watch_resources`): this Mac's rows and warning, each+ * extra Space's rows and what it costs this Mac, each other computer's+ * rows. The words are the core's; no shell formats a number. `now_ms` is+ * the shell's clock (Unix ms), for how old another computer's numbers are.+ */+export function appResourcesView(snapshot: ResourcesSnapshot, nowMs: bigint): AppResourcesView {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterTypeAppResourcesView.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_resources_view(+ FfiConverterTypeResourcesSnapshot.lower(snapshot, nativeModule().rustbuffer_alloc),+ FfiConverterUInt64.lower(nowMs, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }++/**+ * The menu bar's low-disk warning (from a `LowDisk` event or a+ * snapshot's `warning`); none when the disk is fine.+ */+export function appResourcesWarning(warning: DiskWarning): AppWarningView | undefined {+ return ((__rb: Uint8Array) => {+ try {+ return FfiConverterOptionalTypeAppWarningView.lift(__rb);+ } finally {+ nativeModule().rustbuffer_free(__rb);+ }+ })(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_spaces_ffi_fn_func_app_resources_warning(+ FfiConverterTypeDiskWarning.lower(warning, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }+/*** `choices` with the sites just sent remembered for `key`.*/@@ -14012,6 +14122,524 @@ const FfiConverterTypeAppCloudPricing = (() => {return new FFIConverter();})();+export enum AppDiskLevel {+ /**+ * Plenty.+ */+ Ok = "ok",+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (never+ * above 100 GB).+ */+ Low = "low",+ /**+ * Under the floor where creating a Space already fails.+ */+ Critical = "critical"+}++const FfiConverterTypeAppDiskLevel = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = AppDiskLevel;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return AppDiskLevel.Ok;+ case 2: return AppDiskLevel.Low;+ case 3: return AppDiskLevel.Critical;+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value) {+ case AppDiskLevel.Ok: return ordinalConverter.write(1, into);+ case AppDiskLevel.Low: return ordinalConverter.write(2, into);+ case AppDiskLevel.Critical: return ordinalConverter.write(3, into);+ }+ }+ allocationSize(value: TypeName): number {+ return ordinalConverter.allocationSize(0);+ }+ }+ return new FFIConverter();+})();++export type AppDiskWarning = {+ /**+ * How low it is.+ */+ level: AppDiskLevel,+ /**+ * Free bytes on the volume that holds Spaces.+ */+ free: bigint,+ /**+ * Size of that volume.+ */+ total: bigint,+ /**+ * The line that was crossed (0 when ok).+ */+ threshold: bigint+}++/**+ * Generated factory for {@link AppDiskWarning} record objects.+ */+export const AppDiskWarning = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppDiskWarning, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppDiskWarning>,+ });+})();++const FfiConverterTypeAppDiskWarning = (() => {+ type TypeName = AppDiskWarning;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ level: FfiConverterTypeAppDiskLevel.read(from),+ free: FfiConverterUInt64.read(from),+ total: FfiConverterUInt64.read(from),+ threshold: FfiConverterUInt64.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterTypeAppDiskLevel.write(value.level, into);+ FfiConverterUInt64.write(value.free, into);+ FfiConverterUInt64.write(value.total, into);+ FfiConverterUInt64.write(value.threshold, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterTypeAppDiskLevel.allocationSize(value.level) ++ FfiConverterUInt64.allocationSize(value.free) ++ FfiConverterUInt64.allocationSize(value.total) ++ FfiConverterUInt64.allocationSize(value.threshold);++ }+ };+ return new FFIConverter();+})();++export type AppComputerResources = {+ /**+ * `this-mac`, or the relay machine id.+ */+ id: string,+ /**+ * Display name (empty for this Mac).+ */+ name: string,+ /**+ * Reachable now.+ */+ online: boolean,+ /**+ * When the computer measured this, Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * Processor cores.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * Memory in use, bytes.+ */+ memoryUsed: bigint,+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ diskTotal: bigint,+ /**+ * Free bytes on it.+ */+ diskFree: bigint,+ /**+ * Extra Spaces on it.+ */+ spacesCount: number,+ /**+ * Of those, running.+ */+ spacesRunning: number,+ /**+ * Cores given to the running ones.+ */+ spacesCpuAllocated: number,+ /**+ * Memory given to the running ones, bytes.+ */+ spacesMemoryAllocated: bigint,+ /**+ * Memory the running guests report in use, bytes.+ */+ spacesMemoryUsed: bigint,+ /**+ * Bytes all its extra Spaces take on it.+ */+ spacesDiskBytes: bigint,+ /**+ * False when some Space's disk could only be estimated.+ */+ spacesDiskExact: boolean,+ /**+ * The low-disk signal.+ */+ warning: AppDiskWarning+}++/**+ * Generated factory for {@link AppComputerResources} record objects.+ */+export const AppComputerResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppComputerResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppComputerResources>,+ });+})();++const FfiConverterTypeAppComputerResources = (() => {+ type TypeName = AppComputerResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ name: FfiConverterString.read(from),+ online: FfiConverterBool.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskFree: FfiConverterUInt64.read(from),+ spacesCount: FfiConverterUInt32.read(from),+ spacesRunning: FfiConverterUInt32.read(from),+ spacesCpuAllocated: FfiConverterUInt32.read(from),+ spacesMemoryAllocated: FfiConverterUInt64.read(from),+ spacesMemoryUsed: FfiConverterUInt64.read(from),+ spacesDiskBytes: FfiConverterUInt64.read(from),+ spacesDiskExact: FfiConverterBool.read(from),+ warning: FfiConverterTypeAppDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.name, into);+ FfiConverterBool.write(value.online, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterUInt64.write(value.diskFree, into);+ FfiConverterUInt32.write(value.spacesCount, into);+ FfiConverterUInt32.write(value.spacesRunning, into);+ FfiConverterUInt32.write(value.spacesCpuAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryUsed, into);+ FfiConverterUInt64.write(value.spacesDiskBytes, into);+ FfiConverterBool.write(value.spacesDiskExact, into);+ FfiConverterTypeAppDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.name) ++ FfiConverterBool.allocationSize(value.online) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterUInt64.allocationSize(value.diskFree) ++ FfiConverterUInt32.allocationSize(value.spacesCount) ++ FfiConverterUInt32.allocationSize(value.spacesRunning) ++ FfiConverterUInt32.allocationSize(value.spacesCpuAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryUsed) ++ FfiConverterUInt64.allocationSize(value.spacesDiskBytes) ++ FfiConverterBool.allocationSize(value.spacesDiskExact) ++ FfiConverterTypeAppDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();++export enum AppResourceTone {+ /**+ * Nothing to say.+ */+ Normal = "normal",+ /**+ * Running low.+ */+ Warning = "warning",+ /**+ * Out.+ */+ Critical = "critical"+}++const FfiConverterTypeAppResourceTone = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = AppResourceTone;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return AppResourceTone.Normal;+ case 2: return AppResourceTone.Warning;+ case 3: return AppResourceTone.Critical;+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value) {+ case AppResourceTone.Normal: return ordinalConverter.write(1, into);+ case AppResourceTone.Warning: return ordinalConverter.write(2, into);+ case AppResourceTone.Critical: return ordinalConverter.write(3, into);+ }+ }+ allocationSize(value: TypeName): number {+ return ordinalConverter.allocationSize(0);+ }+ }+ return new FFIConverter();+})();++export type AppResourceRow = {+ /**+ * "Processor", "Memory" or "Space for files".+ */+ label: string,+ /**+ * The numbers in words.+ */+ value: string,+ /**+ * How full the small bar is, 0 to 1; none for a row with no bar.+ */+ fraction?: number,+ /**+ * How to colour it.+ */+ tone: AppResourceTone+}++/**+ * Generated factory for {@link AppResourceRow} record objects.+ */+export const AppResourceRow = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppResourceRow, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppResourceRow>,+ });+})();++const FfiConverterTypeAppResourceRow = (() => {+ type TypeName = AppResourceRow;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ label: FfiConverterString.read(from),+ value: FfiConverterString.read(from),+ fraction: FfiConverterOptionalFloat64.read(from),+ tone: FfiConverterTypeAppResourceTone.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.label, into);+ FfiConverterString.write(value.value, into);+ FfiConverterOptionalFloat64.write(value.fraction, into);+ FfiConverterTypeAppResourceTone.write(value.tone, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.label) ++ FfiConverterString.allocationSize(value.value) ++ FfiConverterOptionalFloat64.allocationSize(value.fraction) ++ FfiConverterTypeAppResourceTone.allocationSize(value.tone);++ }+ };+ return new FFIConverter();+})();++export type AppWarningView = {+ /**+ * The sentence.+ */+ text: string,+ /**+ * The button ("See what's using space").+ */+ button: string,+ /**+ * Under the floor where creating a Space already fails.+ */+ critical: boolean+}++/**+ * Generated factory for {@link AppWarningView} record objects.+ */+export const AppWarningView = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppWarningView, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppWarningView>,+ });+})();++const FfiConverterTypeAppWarningView = (() => {+ type TypeName = AppWarningView;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ text: FfiConverterString.read(from),+ button: FfiConverterString.read(from),+ critical: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.text, into);+ FfiConverterString.write(value.button, into);+ FfiConverterBool.write(value.critical, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.text) ++ FfiConverterString.allocationSize(value.button) ++ FfiConverterBool.allocationSize(value.critical);++ }+ };+ return new FFIConverter();+})();++export type AppComputerView = {+ /**+ * The computer's id.+ */+ id: string,+ /**+ * Its name.+ */+ name: string,+ /**+ * Reachable now.+ */+ online: boolean,+ /**+ * "Offline, as of 5 min ago" or "Updated 2 min ago"; none when the+ * numbers are a moment old.+ */+ age?: string,+ /**+ * Processor, Memory, Space for files.+ */+ rows: Array<AppResourceRow>,+ /**+ * "Its extra Spaces use: ..." (see [`ThisMacView::extra_spaces`]).+ */+ extraSpaces?: string,+ /**+ * The warning, when its disk is low.+ */+ warning?: AppWarningView+}++/**+ * Generated factory for {@link AppComputerView} record objects.+ */+export const AppComputerView = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppComputerView, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppComputerView>,+ });+})();++const FfiConverterTypeAppComputerView = (() => {+ type TypeName = AppComputerView;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ name: FfiConverterString.read(from),+ online: FfiConverterBool.read(from),+ age: FfiConverterOptionalString.read(from),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from),+ extraSpaces: FfiConverterOptionalString.read(from),+ warning: FfiConverterOptionalTypeAppWarningView.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.name, into);+ FfiConverterBool.write(value.online, into);+ FfiConverterOptionalString.write(value.age, into);+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into);+ FfiConverterOptionalString.write(value.extraSpaces, into);+ FfiConverterOptionalTypeAppWarningView.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.name) ++ FfiConverterBool.allocationSize(value.online) ++ FfiConverterOptionalString.allocationSize(value.age) ++ FfiConverterSequenceTypeAppResourceRow.allocationSize(value.rows) ++ FfiConverterOptionalString.allocationSize(value.extraSpaces) ++ FfiConverterOptionalTypeAppWarningView.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();+export type AppConflictView = {/*** The file (what Resolve sends).@@ -17327,6 +17955,62 @@ const FfiConverterTypeAppDevicesView = (() => {return new FFIConverter();})();+export type AppDiskOnHost = {+ /**+ * Bytes only this Space holds; none when they could not be measured.+ */+ bytes?: bigint,+ /**+ * Blocks its files occupy, clones counted in full.+ */+ allocated: bigint,+ /**+ * Part of it is shared with other copies.+ */+ sharesSpace: boolean+}++/**+ * Generated factory for {@link AppDiskOnHost} record objects.+ */+export const AppDiskOnHost = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppDiskOnHost, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppDiskOnHost>,+ });+})();++const FfiConverterTypeAppDiskOnHost = (() => {+ type TypeName = AppDiskOnHost;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ bytes: FfiConverterOptionalUInt64.read(from),+ allocated: FfiConverterUInt64.read(from),+ sharesSpace: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterOptionalUInt64.write(value.bytes, into);+ FfiConverterUInt64.write(value.allocated, into);+ FfiConverterBool.write(value.sharesSpace, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterOptionalUInt64.allocationSize(value.bytes) ++ FfiConverterUInt64.allocationSize(value.allocated) ++ FfiConverterBool.allocationSize(value.sharesSpace);++ }+ };+ return new FFIConverter();+})();+export type AppLogicalRect = {x: number,y: number,@@ -21383,6 +22067,104 @@ const FfiConverterTypeAppGpuRow = (() => {return new FFIConverter();})();+export type AppGuestUsage = {+ /**+ * Cores the guest sees.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory in use, bytes.+ */+ memoryUsed: bigint,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * `memory_total` is the guest's own limit.+ */+ memoryLimited: boolean,+ /**+ * Disk in use, bytes.+ */+ diskUsed: bigint,+ /**+ * Disk size, bytes.+ */+ diskTotal: bigint,+ /**+ * `disk_total` is the guest's own disk.+ */+ diskLimited: boolean+}++/**+ * Generated factory for {@link AppGuestUsage} record objects.+ */+export const AppGuestUsage = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppGuestUsage, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppGuestUsage>,+ });+})();++const FfiConverterTypeAppGuestUsage = (() => {+ type TypeName = AppGuestUsage;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryLimited: FfiConverterBool.read(from),+ diskUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskLimited: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterBool.write(value.memoryLimited, into);+ FfiConverterUInt64.write(value.diskUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterBool.write(value.diskLimited, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterBool.allocationSize(value.memoryLimited) ++ FfiConverterUInt64.allocationSize(value.diskUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterBool.allocationSize(value.diskLimited);++ }+ };+ return new FFIConverter();+})();+export type AppHostAccess = {/*** Epoch ms.@@ -31996,6 +32778,366 @@ const FfiConverterTypeAppResourceEditView = (() => {return new FFIConverter();})();+export type AppSpaceResources = {+ /**+ * `local:<name>`.+ */+ id: string,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ powerState: string,+ /**+ * Cores given to it (0: unknown).+ */+ cpuAllocated: number,+ /**+ * Memory given to it, bytes (0: unknown).+ */+ memoryAllocated: bigint,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ diskAllocated: bigint,+ /**+ * The guest's own numbers; none while it is off or unreachable.+ */+ usage?: AppGuestUsage,+ /**+ * What it costs this Mac; none for a container.+ */+ diskOnHost?: AppDiskOnHost+}++/**+ * Generated factory for {@link AppSpaceResources} record objects.+ */+export const AppSpaceResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppSpaceResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppSpaceResources>,+ });+})();++const FfiConverterTypeAppSpaceResources = (() => {+ type TypeName = AppSpaceResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ powerState: FfiConverterString.read(from),+ cpuAllocated: FfiConverterUInt32.read(from),+ memoryAllocated: FfiConverterUInt64.read(from),+ diskAllocated: FfiConverterUInt64.read(from),+ usage: FfiConverterOptionalTypeAppGuestUsage.read(from),+ diskOnHost: FfiConverterOptionalTypeAppDiskOnHost.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.powerState, into);+ FfiConverterUInt32.write(value.cpuAllocated, into);+ FfiConverterUInt64.write(value.memoryAllocated, into);+ FfiConverterUInt64.write(value.diskAllocated, into);+ FfiConverterOptionalTypeAppGuestUsage.write(value.usage, into);+ FfiConverterOptionalTypeAppDiskOnHost.write(value.diskOnHost, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.powerState) ++ FfiConverterUInt32.allocationSize(value.cpuAllocated) ++ FfiConverterUInt64.allocationSize(value.memoryAllocated) ++ FfiConverterUInt64.allocationSize(value.diskAllocated) ++ FfiConverterOptionalTypeAppGuestUsage.allocationSize(value.usage) ++ FfiConverterOptionalTypeAppDiskOnHost.allocationSize(value.diskOnHost);++ }+ };+ return new FFIConverter();+})();++export type AppResourcesSnapshot = {+ /**+ * Grows by one per sample.+ */+ sequence: bigint,+ /**+ * Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * This Mac.+ */+ thisMac: AppComputerResources,+ /**+ * Extra Spaces on this Mac.+ */+ spaces: Array<AppSpaceResources>,+ /**+ * Your other computers.+ */+ computers: Array<AppComputerResources>,+ /**+ * This Mac's low-disk signal, for the menu bar.+ */+ warning: AppDiskWarning+}++/**+ * Generated factory for {@link AppResourcesSnapshot} record objects.+ */+export const AppResourcesSnapshot = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppResourcesSnapshot, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppResourcesSnapshot>,+ });+})();++const FfiConverterTypeAppResourcesSnapshot = (() => {+ type TypeName = AppResourcesSnapshot;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ sequence: FfiConverterUInt64.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ thisMac: FfiConverterTypeAppComputerResources.read(from),+ spaces: FfiConverterSequenceTypeAppSpaceResources.read(from),+ computers: FfiConverterSequenceTypeAppComputerResources.read(from),+ warning: FfiConverterTypeAppDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt64.write(value.sequence, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterTypeAppComputerResources.write(value.thisMac, into);+ FfiConverterSequenceTypeAppSpaceResources.write(value.spaces, into);+ FfiConverterSequenceTypeAppComputerResources.write(value.computers, into);+ FfiConverterTypeAppDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt64.allocationSize(value.sequence) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterTypeAppComputerResources.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeAppSpaceResources.allocationSize(value.spaces) ++ FfiConverterSequenceTypeAppComputerResources.allocationSize(value.computers) ++ FfiConverterTypeAppDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();++export type AppThisMacView = {+ /**+ * "This Mac".+ */+ title: string,+ /**+ * Processor, Memory, Space for files.+ */+ rows: Array<AppResourceRow>,+ /**+ * "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+ * files." None when there are no extra Spaces.+ */+ extraSpaces?: string,+ /**+ * The warning, when the disk is low.+ */+ warning?: AppWarningView+}++/**+ * Generated factory for {@link AppThisMacView} record objects.+ */+export const AppThisMacView = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppThisMacView, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppThisMacView>,+ });+})();++const FfiConverterTypeAppThisMacView = (() => {+ type TypeName = AppThisMacView;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ title: FfiConverterString.read(from),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from),+ extraSpaces: FfiConverterOptionalString.read(from),+ warning: FfiConverterOptionalTypeAppWarningView.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.title, into);+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into);+ FfiConverterOptionalString.write(value.extraSpaces, into);+ FfiConverterOptionalTypeAppWarningView.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.title) ++ FfiConverterSequenceTypeAppResourceRow.allocationSize(value.rows) ++ FfiConverterOptionalString.allocationSize(value.extraSpaces) ++ FfiConverterOptionalTypeAppWarningView.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();++export type AppSpaceResourcesView = {+ /**+ * The Space's id.+ */+ id: string,+ /**+ * Processor, Memory, Space for files: what it was given and, while it+ * runs, what it uses now.+ */+ rows: Array<AppResourceRow>,+ /**+ * What it costs this Mac, not what the guest sees: "Uses about 31 GB+ * on this Mac (shares space with other copies)". None for a container.+ */+ onThisMac?: string,+ /**+ * The Space is off: "Stopped · uses about 6 GB on this Mac".+ */+ offLine?: string,+ /**+ * Whether the numbers are live (the Space runs and answered).+ */+ live: boolean+}++/**+ * Generated factory for {@link AppSpaceResourcesView} record objects.+ */+export const AppSpaceResourcesView = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppSpaceResourcesView, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppSpaceResourcesView>,+ });+})();++const FfiConverterTypeAppSpaceResourcesView = (() => {+ type TypeName = AppSpaceResourcesView;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from),+ onThisMac: FfiConverterOptionalString.read(from),+ offLine: FfiConverterOptionalString.read(from),+ live: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into);+ FfiConverterOptionalString.write(value.onThisMac, into);+ FfiConverterOptionalString.write(value.offLine, into);+ FfiConverterBool.write(value.live, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterSequenceTypeAppResourceRow.allocationSize(value.rows) ++ FfiConverterOptionalString.allocationSize(value.onThisMac) ++ FfiConverterOptionalString.allocationSize(value.offLine) ++ FfiConverterBool.allocationSize(value.live);++ }+ };+ return new FFIConverter();+})();++export type AppResourcesView = {+ /**+ * This Mac.+ */+ thisMac: AppThisMacView,+ /**+ * Each extra Space.+ */+ spaces: Array<AppSpaceResourcesView>,+ /**+ * Each other computer.+ */+ computers: Array<AppComputerView>,+ /**+ * The menu bar's warning: none when the disk is fine.+ */+ warning?: AppWarningView+}++/**+ * Generated factory for {@link AppResourcesView} record objects.+ */+export const AppResourcesView = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<AppResourcesView, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<AppResourcesView>,+ });+})();++const FfiConverterTypeAppResourcesView = (() => {+ type TypeName = AppResourcesView;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ thisMac: FfiConverterTypeAppThisMacView.read(from),+ spaces: FfiConverterSequenceTypeAppSpaceResourcesView.read(from),+ computers: FfiConverterSequenceTypeAppComputerView.read(from),+ warning: FfiConverterOptionalTypeAppWarningView.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterTypeAppThisMacView.write(value.thisMac, into);+ FfiConverterSequenceTypeAppSpaceResourcesView.write(value.spaces, into);+ FfiConverterSequenceTypeAppComputerView.write(value.computers, into);+ FfiConverterOptionalTypeAppWarningView.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterTypeAppThisMacView.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeAppSpaceResourcesView.allocationSize(value.spaces) ++ FfiConverterSequenceTypeAppComputerView.allocationSize(value.computers) ++ FfiConverterOptionalTypeAppWarningView.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();+export type AppReviewDomain = {/*** The site (`github.com`).@@ -35501,6 +36643,18 @@ const FfiConverterTypeAppSpaceRow = (() => {})();export type AppSpaceUsage = {+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,/*** Memory in use, bytes.*/@@ -35548,6 +36702,9 @@ const FfiConverterTypeAppSpaceUsage = (() => {class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {read(from: RustBuffer): TypeName {return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),memoryUsed: FfiConverterUInt64.read(from),memoryTotal: FfiConverterUInt64.read(from),memoryLimited: FfiConverterBool.read(from),@@ -35557,6 +36714,9 @@ const FfiConverterTypeAppSpaceUsage = (() => {};}write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);FfiConverterUInt64.write(value.memoryUsed, into);FfiConverterUInt64.write(value.memoryTotal, into);FfiConverterBool.write(value.memoryLimited, into);@@ -35565,7 +36725,10 @@ const FfiConverterTypeAppSpaceUsage = (() => {FfiConverterBool.write(value.diskLimited, into);}allocationSize(value: TypeName): number {- return FfiConverterUInt64.allocationSize(value.memoryUsed) ++ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) +FfiConverterUInt64.allocationSize(value.memoryTotal) +FfiConverterBool.allocationSize(value.memoryLimited) +FfiConverterUInt64.allocationSize(value.diskUsed) +@@ -60013,6 +61176,15 @@ const FfiConverterSequenceTypeAppCloudCheckRow = new FfiConverterArray(FfiConver// FfiConverter for AppCloudConnectRequest | undefinedconst FfiConverterOptionalTypeAppCloudConnectRequest = new FfiConverterOptional(FfiConverterTypeAppCloudConnectRequest);+// FfiConverter for number | undefined+const FfiConverterOptionalFloat64 = new FfiConverterOptional(FfiConverterFloat64);++// FfiConverter for Array<AppResourceRow>+const FfiConverterSequenceTypeAppResourceRow = new FfiConverterArray(FfiConverterTypeAppResourceRow);++// FfiConverter for AppWarningView | undefined+const FfiConverterOptionalTypeAppWarningView = new FfiConverterOptional(FfiConverterTypeAppWarningView);+// FfiConverter for Array<AppCloudOffer>const FfiConverterSequenceTypeAppCloudOffer = new FfiConverterArray(FfiConverterTypeAppCloudOffer);@@ -60034,9 +61206,6 @@ const FfiConverterSequenceTypeAppPlatformSize = new FfiConverterArray(FfiConvert// FfiConverter for AppImageSizes | undefinedconst FfiConverterOptionalTypeAppImageSizes = new FfiConverterOptional(FfiConverterTypeAppImageSizes);-// FfiConverter for number | undefined-const FfiConverterOptionalFloat64 = new FfiConverterOptional(FfiConverterFloat64);-// FfiConverter for Array<AppPendingCreate>const FfiConverterSequenceTypeAppPendingCreate = new FfiConverterArray(FfiConverterTypeAppPendingCreate);@@ -60361,6 +61530,24 @@ const FfiConverterOptionalTypeAppRelayAllowanceNotice = new FfiConverterOptional// FfiConverter for Array<AppRemoteWindow>const FfiConverterSequenceTypeAppRemoteWindow = new FfiConverterArray(FfiConverterTypeAppRemoteWindow);+// FfiConverter for AppGuestUsage | undefined+const FfiConverterOptionalTypeAppGuestUsage = new FfiConverterOptional(FfiConverterTypeAppGuestUsage);++// FfiConverter for AppDiskOnHost | undefined+const FfiConverterOptionalTypeAppDiskOnHost = new FfiConverterOptional(FfiConverterTypeAppDiskOnHost);++// FfiConverter for Array<AppSpaceResources>+const FfiConverterSequenceTypeAppSpaceResources = new FfiConverterArray(FfiConverterTypeAppSpaceResources);++// FfiConverter for Array<AppComputerResources>+const FfiConverterSequenceTypeAppComputerResources = new FfiConverterArray(FfiConverterTypeAppComputerResources);++// FfiConverter for Array<AppSpaceResourcesView>+const FfiConverterSequenceTypeAppSpaceResourcesView = new FfiConverterArray(FfiConverterTypeAppSpaceResourcesView);++// FfiConverter for Array<AppComputerView>+const FfiConverterSequenceTypeAppComputerView = new FfiConverterArray(FfiConverterTypeAppComputerView);+// FfiConverter for Array<AppReviewToggle>const FfiConverterSequenceTypeAppReviewToggle = new FfiConverterArray(FfiConverterTypeAppReviewToggle);@@ -61268,6 +62455,21 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_relay_usage_view() !== 38605) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_relay_usage_view");}+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_resources_computer() !== 3991) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_resources_computer");+ }+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_resources_space() !== 24195) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_resources_space");+ }+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac() !== 29209) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac");+ }+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_resources_view() !== 22202) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_resources_view");+ }+ if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_resources_warning() !== 3548) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_resources_warning");+ }if (nativeModule().uniffi_cua_spaces_ffi_checksum_func_app_review_remember() !== 9631) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_spaces_ffi_checksum_func_app_review_remember");}@@ -61831,6 +63033,8 @@ export default Object.freeze({FfiConverterTypeAppCloudProviderRow,FfiConverterTypeAppCloudTargetArgs,FfiConverterTypeAppComputerGrantInput,+ FfiConverterTypeAppComputerResources,+ FfiConverterTypeAppComputerView,FfiConverterTypeAppConflictView,FfiConverterTypeAppConnectedCloud,FfiConverterTypeAppConsentItem,@@ -61857,6 +63061,9 @@ export default Object.freeze({FfiConverterTypeAppDevicesInput,FfiConverterTypeAppDevicesLabels,FfiConverterTypeAppDevicesView,+ FfiConverterTypeAppDiskLevel,+ FfiConverterTypeAppDiskOnHost,+ FfiConverterTypeAppDiskWarning,FfiConverterTypeAppDragDisplay,FfiConverterTypeAppDragKind,FfiConverterTypeAppDragOverlayEffect,@@ -61906,6 +63113,7 @@ export default Object.freeze({FfiConverterTypeAppFileView,FfiConverterTypeAppGpuChoice,FfiConverterTypeAppGpuRow,+ FfiConverterTypeAppGuestUsage,FfiConverterTypeAppHostAccess,FfiConverterTypeAppHostAccessRow,FfiConverterTypeAppHostAccount,@@ -62047,6 +63255,10 @@ export default Object.freeze({FfiConverterTypeAppResourceEdit,FfiConverterTypeAppResourceEditView,FfiConverterTypeAppResourceField,+ FfiConverterTypeAppResourceRow,+ FfiConverterTypeAppResourceTone,+ FfiConverterTypeAppResourcesSnapshot,+ FfiConverterTypeAppResourcesView,FfiConverterTypeAppReviewChoice,FfiConverterTypeAppReviewDomain,FfiConverterTypeAppReviewPassword,@@ -62093,6 +63305,8 @@ export default Object.freeze({FfiConverterTypeAppSpacePower,FfiConverterTypeAppSpaceProgress,FfiConverterTypeAppSpaceProvider,+ FfiConverterTypeAppSpaceResources,+ FfiConverterTypeAppSpaceResourcesView,FfiConverterTypeAppSpaceRow,FfiConverterTypeAppSpaceSdkRef,FfiConverterTypeAppSpaceStatus,@@ -62136,6 +63350,7 @@ export default Object.freeze({FfiConverterTypeAppTeleportRunPhase,FfiConverterTypeAppTeleportRunReport,FfiConverterTypeAppThisDevice,+ FfiConverterTypeAppThisMacView,FfiConverterTypeAppThumbnailPolicy,FfiConverterTypeAppThumbnailScene,FfiConverterTypeAppTile,@@ -62149,6 +63364,7 @@ export default Object.freeze({FfiConverterTypeAppUsageToggle,FfiConverterTypeAppVaultPassword,FfiConverterTypeAppVaultSource,+ FfiConverterTypeAppWarningView,FfiConverterTypeAppWindowMode,FfiConverterTypeAppWizardAction,FfiConverterTypeAppWizardEnv,diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swiftindex 3f0d0a84d3..7b4f306d56 100644--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift@@ -466,7 +466,8 @@ public final class LiveSpacesBackend: SpacesBackend, @unchecked Sendable {try await cua.spaces().space(space: id).usage()}guard let u = try? result.get() else { return nil }- return AppSpaceUsage(memoryUsed: u.memoryUsed, memoryTotal: u.memoryTotal, memoryLimited: u.memoryLimited,+ return AppSpaceUsage(cpuCount: u.cpuCount, cpuPercent: u.cpuPercent, loadAverage1m: u.loadAverage1m,+ memoryUsed: u.memoryUsed, memoryTotal: u.memoryTotal, memoryLimited: u.memoryLimited,diskUsed: u.diskUsed, diskTotal: u.diskTotal, diskLimited: u.diskLimited)}@@ -854,6 +855,7 @@ public final class FixtureSpacesBackend: SpacesBackend, @unchecked Sendable {/// The fixture Spaces' memory and storage: a 4 GB container limit on a/// host disk (Storage hides).public var fixtureUsage: AppSpaceUsage? = AppSpaceUsage(+ cpuCount: 4, cpuPercent: 12.5, loadAverage1m: 0.5,memoryUsed: 2_254_857_830, memoryTotal: 4 << 30, memoryLimited: true,diskUsed: 150_000_000_000, diskTotal: 494_000_000_000, diskLimited: false)public func usage(id: String) async -> AppSpaceUsage? { await MainActor.run { fixtureUsage } }diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swiftindex 03492fcc62..8ab86f4482 100644--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ParityTests.swift@@ -1600,7 +1600,10 @@ struct ParityTests {let rows = try appSpaceRowsFromJson(json: text([c["row"]!]))let space = appRowsToSpaces(rows: rows, nowMs: Int64(f["now"] as! Int))[0]let usage = (c["usage"] as? [String: Any]).map { u in- AppSpaceUsage(memoryUsed: (u["memoryUsed"] as! NSNumber).uint64Value,+ AppSpaceUsage(cpuCount: (u["cpuCount"] as? NSNumber)?.uint32Value ?? 0,+ cpuPercent: (u["cpuPercent"] as? NSNumber)?.doubleValue ?? 0,+ loadAverage1m: (u["loadAverage1m"] as? NSNumber)?.doubleValue ?? 0,+ memoryUsed: (u["memoryUsed"] as! NSNumber).uint64Value,memoryTotal: (u["memoryTotal"] as! NSNumber).uint64Value,memoryLimited: u["memoryLimited"] as! Bool,diskUsed: (u["diskUsed"] as! NSNumber).uint64Value,diff --git a/apps/cua-spaces/src-tauri/Cargo.lock b/apps/cua-spaces/src-tauri/Cargo.lockindex b15fd4735d..a6f90004a1 100644--- a/apps/cua-spaces/src-tauri/Cargo.lock+++ b/apps/cua-spaces/src-tauri/Cargo.lock@@ -1656,6 +1656,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -1674,6 +1675,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -1681,6 +1683,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",@@ -4377,6 +4380,15 @@ dependencies = ["zbus",]+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "num"version = "0.4.3"@@ -4617,6 +4629,16 @@ dependencies = ["objc2-core-foundation",]+[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "objc2-io-surface"version = "0.3.2"@@ -6643,6 +6665,20 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows 0.61.3",+]+[[package]]name = "system-configuration"version = "0.7.0"diff --git a/apps/cua-spaces/src-tauri/src/core.rs b/apps/cua-spaces/src-tauri/src/core.rsindex ee3ffadfb8..2cd3807718 100644--- a/apps/cua-spaces/src-tauri/src/core.rs+++ b/apps/cua-spaces/src-tauri/src/core.rs@@ -1445,11 +1445,15 @@ impl AppCore {.collect())}- /// Memory and storage use now (the app core's `SpaceUsage` shape).+ /// Processor, memory and storage use now (the app core's `SpaceUsage`+ /// shape).pub async fn space_usage(&self, space: &str) -> CmdResult<serde_json::Value> {let s = self.space(space).await?;let u = s.usage().await.map_err(msg)?;Ok(serde_json::json!({+ "cpuCount": u.cpu_count,+ "cpuPercent": u.cpu_percent,+ "loadAverage1m": u.load_average_1m,"memoryUsed": u.memory_used,"memoryTotal": u.memory_total,"memoryLimited": u.memory_limited,diff --git a/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx b/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdxindex 1b852894f4..50f77d6281 100644--- a/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx+++ b/docs/content/docs/cua-cli/reference/cli/spaces-and-computers.mdx@@ -85,6 +85,10 @@ cua spaces [OPTIONS] <COMMAND>Registered Spaces and your machines on the relay.+CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it+uses now (the numbers the Cua Spaces app shows); for another of your+computers they show what it last reported. Numbers only: no file names.+```text outputcua spaces ls [OPTIONS]```@@ -94,11 +98,13 @@ Alias: `cua spaces list`.| Flag | Type | Default | Description || --- | --- | --- | --- || <span id="cua-spaces-ls--relay"></span>`--relay` | string | | Relay URL (default $CUA_RELAY_URL, else the CUA_ENV relay, https://relay.cua.ai in production). |+| <span id="cua-spaces-ls--no-size"></span>`--no-size` | boolean | `false` | Do not measure what each Space takes on this computer's disk (that walk can take a moment with many Spaces). |**Examples**```bash test="cli-shape" id="ref-cua-spaces-ls"cua spaces ls+cua spaces ls --no-sizecua spaces ls --json```diff --git a/docs/content/docs/cua-sdk/reference/index.mdx b/docs/content/docs/cua-sdk/reference/index.mdxindex 35c8579536..9bd879868f 100644--- a/docs/content/docs/cua-sdk/reference/index.mdx+++ b/docs/content/docs/cua-sdk/reference/index.mdx@@ -58,6 +58,7 @@ The Cua SDK in Python, TypeScript, Swift, Kotlin and Rust, all generated from th| [Space](/cua-sdk/reference/spaces/space) | A connected Space: shell, files, tools, windows, icons, displays, the hotspot and teleport. || [Cua Volume](/cua-sdk/reference/spaces/volume) | The versioned volume every Space and agent shares: files, history, grants, requests, audit, storage and sync. || [Streams and presence](/cua-sdk/reference/spaces/streams) | Media sessions of a Space and presence (who is connected, and their cursors). |+| [Processor, memory and disk](/cua-sdk/reference/spaces/resources) | What this Mac, its extra Spaces and your other computers use: one snapshot, a stream of changes and the low-disk warning. || [Persistent agents and your cloud](/cua-sdk/reference/spaces/persistent-agents) | Named agents whose memory outlives their Space: homes in the Cua Volume, routines, notifications, pause and resume, access to your computers, and Spaces in your own AWS, Google Cloud or Modal account. || [Host, relay and devices](/cua-sdk/reference/spaces/host) | Unattended host setup, the cua-relay directory client, and this device's enrollment on the relay. |@@ -88,4 +89,4 @@ The Cua SDK in Python, TypeScript, Swift, Kotlin and Rust, all generated from th| --- | --- || [Protocol](/cua-sdk/reference/protocol) | The gRPC contracts of cua-spacesd (`cua.env.v1`) and the cua daemon (`cua.daemon.v1`). |-291 items, 385 methods. The [Types](/cua-sdk/reference/types) page lists them.+302 items, 390 methods. The [Types](/cua-sdk/reference/types) page lists them.diff --git a/docs/content/docs/cua-sdk/reference/protocol/daemon-resources.mdx b/docs/content/docs/cua-sdk/reference/protocol/daemon-resources.mdxnew file mode 100644index 0000000000..af1c2f0423--- /dev/null+++ b/docs/content/docs/cua-sdk/reference/protocol/daemon-resources.mdx@@ -0,0 +1,155 @@+---+title: "Daemon: resources"+description: "cua.daemon.v1 resource messages: processor, memory and disk of this Mac, its extra Spaces and your other computers."+---++{/*+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY+ Generated by: pnpm --dir docs docs:generate:cua-proto+ Source: buf build libs/cua/proto -o -#format=json+ Version: 0.5.0+*/}++What `SpaceService.GetResources` and `WatchResources` return: one snapshot, then updates and the low-disk warning. Numbers only.++Source: `libs/cua/proto/cua/daemon/v1/resources.proto`.++## Types in `cua/daemon/v1/resources.proto`++### GetResourcesRequest++Request for `SpaceService.GetResources`.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `visible` | 1 | `bool` | A window shows the numbers: sample every 10 seconds for the next 30. |++### GetResourcesResponse++Response for `SpaceService.GetResources`.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `snapshot` | 1 | [`ResourcesSnapshot`](#resourcessnapshot) | Everything, now. |++### WatchResourcesRequest++Request for `SpaceService.WatchResources`.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `visible` | 1 | `bool` | A window shows the numbers (sample every 10 seconds) rather than only the menu bar warning (every 5 minutes). |++### WatchResourcesResponse++One event of `SpaceService.WatchResources`.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `snapshot` | 1 | [`ResourcesSnapshot`](#resourcessnapshot) (oneof `event`) | Everything, once at the start. |+| `update` | 2 | [`ResourcesUpdate`](#resourcesupdate) (oneof `event`) | Only what changed. |+| `low_disk` | 3 | [`DiskWarning`](#diskwarning) (oneof `event`) | The free-disk warning level changed. |++### ResourcesSnapshot++One sample of everything.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `sequence` | 1 | `uint64` | Grows by one per sample. |+| `sampled_at_ms` | 2 | `uint64` | When it was sampled, in Unix milliseconds. |+| `this_mac` | 3 | [`ComputerResources`](#computerresources) | This computer. |+| `spaces` | 4 | repeated [`SpaceResources`](#spaceresources) | The extra Spaces on this computer (the local ones). |+| `computers` | 5 | repeated [`ComputerResources`](#computerresources) | Your other computers that published a summary (through the relay). |+| `warning` | 6 | [`DiskWarning`](#diskwarning) | `this_mac.warning`, for the menu bar. |++### ResourcesUpdate++What changed since the receiver's last update, past the thresholds.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `sequence` | 1 | `uint64` | The sample it brings the receiver to. |+| `sampled_at_ms` | 2 | `uint64` | When it was sampled, in Unix milliseconds. |+| `this_mac` | 3 | optional [`ComputerResources`](#computerresources) | This computer, when it changed. |+| `spaces` | 4 | repeated [`SpaceResources`](#spaceresources) | Extra Spaces that changed or appeared: replace by `id`. |+| `computers` | 5 | repeated [`ComputerResources`](#computerresources) | Other computers that changed or appeared: replace by `id`. |+| `removed` | 6 | repeated `string` | Ids (Spaces or computers) that are gone. |++### DiskWarning++The low-disk signal.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `level` | 1 | `string` | `ok`, `low` (under 50 GB or 15% of the volume, whichever line is higher, capped at 100 GB) or `critical` (under the floor where creates fail, 5 GiB unless `CUA_DISK_MIN_FREE` says otherwise). |+| `free` | 2 | `uint64` | Free bytes on the volume that holds Spaces. |+| `total` | 3 | `uint64` | Size of that volume in bytes. |+| `threshold` | 4 | `uint64` | The line that was crossed in bytes (0 when `ok`). |++### ComputerResources++A computer: this one, or one of your other computers.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `id` | 1 | `string` | `this-mac`, or the relay machine id. |+| `name` | 2 | `string` | Display name (empty for this computer). |+| `online` | 3 | `bool` | Reachable now (always true for this computer). |+| `sampled_at_ms` | 4 | `uint64` | When the computer measured this, in Unix milliseconds (another computer's can be minutes old). |+| `cpu_count` | 5 | `uint32` | Processor cores. |+| `cpu_percent` | 6 | `double` | Busy now, 0 to 100. |+| `load_average_1m` | 7 | `double` | 1-minute load average. |+| `memory_total` | 8 | `uint64` | Memory size in bytes. |+| `memory_used` | 9 | `uint64` | Memory in use in bytes, without reclaimable cache. |+| `disk_total` | 10 | `uint64` | Size of the volume that holds Spaces in bytes. |+| `disk_free` | 11 | `uint64` | Free bytes on that volume. |+| `spaces_count` | 12 | `uint32` | Extra Spaces on it. |+| `spaces_running` | 13 | `uint32` | Of those, running. |+| `spaces_cpu_allocated` | 14 | `uint32` | Cores given to the running ones. |+| `spaces_memory_allocated` | 15 | `uint64` | Memory given to the running ones in bytes. |+| `spaces_memory_used` | 16 | `uint64` | Memory the running guests report in use in bytes. |+| `spaces_disk_bytes` | 17 | `uint64` | Bytes all its extra Spaces take on it. |+| `spaces_disk_exact` | 18 | `bool` | False when some Space's disk could only be estimated. |+| `warning` | 19 | [`DiskWarning`](#diskwarning) | The low-disk signal. |++### GuestUsage++What `cua.env.v1.SystemService.Metrics` reports from inside a Space.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `cpu_count` | 1 | `uint32` | Cores the guest sees. |+| `cpu_percent` | 2 | `double` | Busy now, 0 to 100. |+| `load_average_1m` | 3 | `double` | 1-minute load average. |+| `memory_used` | 4 | `uint64` | Memory in use in bytes. |+| `memory_total` | 5 | `uint64` | Memory size in bytes. |+| `memory_limited` | 6 | `bool` | `memory_total` is the guest's own limit. |+| `disk_used` | 7 | `uint64` | Disk in use in bytes. |+| `disk_total` | 8 | `uint64` | Disk size in bytes. |+| `disk_limited` | 9 | `bool` | `disk_total` is the guest's own disk. |++### DiskOnHost++What a Space costs this computer's disk, as opposed to what the guest+sees.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `bytes` | 1 | optional `uint64` | Bytes only this Space holds: what deleting it frees. Unset when they could not be measured. |+| `allocated` | 2 | `uint64` | Blocks its files occupy, clones counted in full: an upper bound. |+| `shares_space` | 3 | `bool` | Part of it is shared with other copies. |++### SpaceResources++One extra Space on this computer.++| Field | # | Type | Description |+| --- | --- | --- | --- |+| `id` | 1 | `string` | The Space id, for example `local:aurora`. |+| `power_state` | 2 | `string` | `running`, `stopped`, `suspended`, or empty when unknown. |+| `cpu_allocated` | 3 | `uint32` | Cores given to it (0: unknown). |+| `memory_allocated` | 4 | `uint64` | Memory given to it in bytes (0: unknown). |+| `disk_allocated` | 5 | `uint64` | Its disk's size limit in bytes (0: unknown). |+| `usage` | 6 | [`GuestUsage`](#guestusage) | The guest's own numbers; unset while it is off or unreachable. |+| `disk_on_host` | 7 | [`DiskOnHost`](#diskonhost) | What it costs this computer; unset for a container. |diff --git a/docs/content/docs/cua-sdk/reference/protocol/daemon.mdx b/docs/content/docs/cua-sdk/reference/protocol/daemon.mdxindex c069dbb9a4..4c0e6dd38d 100644--- a/docs/content/docs/cua-sdk/reference/protocol/daemon.mdx+++ b/docs/content/docs/cua-sdk/reference/protocol/daemon.mdx@@ -269,6 +269,8 @@ without touching it.| [`CallSpaceTool`](#spaceservicecallspacetool) | [`CallSpaceToolRequest`](#callspacetoolrequest) | [`CallSpaceToolResponse`](#callspacetoolresponse) | unary || [`ListHosts`](#spaceservicelisthosts) | [`ListHostsRequest`](#listhostsrequest) | [`ListHostsResponse`](#listhostsresponse) | unary || [`GetSpaceThumbnail`](#spaceservicegetspacethumbnail) | [`GetSpaceThumbnailRequest`](#getspacethumbnailrequest) | [`GetSpaceThumbnailResponse`](#getspacethumbnailresponse) | unary |+| [`GetResources`](#spaceservicegetresources) | [`GetResourcesRequest`](/cua-sdk/reference/protocol/daemon-resources#getresourcesrequest) | [`GetResourcesResponse`](/cua-sdk/reference/protocol/daemon-resources#getresourcesresponse) | unary |+| [`WatchResources`](#spaceservicewatchresources) | [`WatchResourcesRequest`](/cua-sdk/reference/protocol/daemon-resources#watchresourcesrequest) | [`WatchResourcesResponse`](/cua-sdk/reference/protocol/daemon-resources#watchresourcesresponse) | server stream |### SpaceService.AddSpace@@ -409,6 +411,29 @@ capture through cua-spacesd (the cached one again, with its older`captured_at`, when the capture fails). Asking keeps the daemonrefreshing running Spaces' thumbnails in the background for a while.+### SpaceService.GetResources++`/cua.daemon.v1.SpaceService/GetResources`, unary: [`GetResourcesRequest`](/cua-sdk/reference/protocol/daemon-resources#getresourcesrequest) to [`GetResourcesResponse`](/cua-sdk/reference/protocol/daemon-resources#getresourcesresponse).++What this computer, its extra Spaces and your other computers use now:+processor, memory and disk, as one snapshot. The daemon's single+sampler measures it; a snapshot a few seconds old is returned as it is.+With `visible`, the call also says a window shows the numbers for the+next 30 seconds, so the sampler runs every 10 seconds (every 5 minutes+otherwise). Numbers only: no names, paths or processes.++### SpaceService.WatchResources++`/cua.daemon.v1.SpaceService/WatchResources`, server stream: [`WatchResourcesRequest`](/cua-sdk/reference/protocol/daemon-resources#watchresourcesrequest) to [`WatchResourcesResponse`](/cua-sdk/reference/protocol/daemon-resources#watchresourcesresponse).++The same numbers as a stream: one snapshot first, then an update with+only the entries that changed by more than 1 point or 256 MB, and a+`low_disk` event whenever the free-disk warning level changes+(including back to `ok`). A hidden watcher (`visible` false) is+sampled every 5 minutes and still hears `low_disk`, for the menu bar.+Cancel the stream to stop; call again with the other `visible` to+switch.+## DaemonService`cua.daemon.v1.DaemonService`diff --git a/docs/content/docs/cua-sdk/reference/protocol/index.mdx b/docs/content/docs/cua-sdk/reference/protocol/index.mdxindex 746e240343..ee74812745 100644--- a/docs/content/docs/cua-sdk/reference/protocol/index.mdx+++ b/docs/content/docs/cua-sdk/reference/protocol/index.mdx@@ -53,7 +53,7 @@ Tickets go in `?ticket=` or the WebSocket subprotocol `cua.ticket.<ticket>`. Tic| [`HostSpacesService`](/cua-sdk/reference/protocol/env-stream#hostspacesservice) | `cua.env.v1` | [Streams, teleport, tunnels and host Spaces](/cua-sdk/reference/protocol/env-stream) | 6 || [`SandboxService`](/cua-sdk/reference/protocol/daemon#sandboxservice) | `cua.daemon.v1` | [Cua daemon](/cua-sdk/reference/protocol/daemon) | 20 || [`RuntimeService`](/cua-sdk/reference/protocol/daemon#runtimeservice) | `cua.daemon.v1` | [Cua daemon](/cua-sdk/reference/protocol/daemon) | 5 |-| [`SpaceService`](/cua-sdk/reference/protocol/daemon#spaceservice) | `cua.daemon.v1` | [Cua daemon](/cua-sdk/reference/protocol/daemon) | 17 |+| [`SpaceService`](/cua-sdk/reference/protocol/daemon#spaceservice) | `cua.daemon.v1` | [Cua daemon](/cua-sdk/reference/protocol/daemon) | 19 || [`DaemonService`](/cua-sdk/reference/protocol/daemon#daemonservice) | `cua.daemon.v1` | [Cua daemon](/cua-sdk/reference/protocol/daemon) | 3 |## Metadata and HTTP routesdiff --git a/docs/content/docs/cua-sdk/reference/protocol/meta.json b/docs/content/docs/cua-sdk/reference/protocol/meta.jsonindex 672d0fdce4..12272e3340 100644--- a/docs/content/docs/cua-sdk/reference/protocol/meta.json+++ b/docs/content/docs/cua-sdk/reference/protocol/meta.json@@ -5,6 +5,7 @@"env-process","env-computer","env-stream",- "daemon"+ "daemon",+ "daemon-resources"]}diff --git a/docs/content/docs/cua-sdk/reference/rust/cua-sdk.mdx b/docs/content/docs/cua-sdk/reference/rust/cua-sdk.mdxindex e0eb936708..62dd2be552 100644--- a/docs/content/docs/cua-sdk/reference/rust/cua-sdk.mdx+++ b/docs/content/docs/cua-sdk/reference/rust/cua-sdk.mdx@@ -18,7 +18,7 @@ The cua SDK: the only `#[uniffi::export]` crate of `libs/cua`.These are the objects, records, enums and functions the language bindings export, documented once in the [Cua SDK reference](/cua-sdk/reference), whose Rust tabs show each signature. Objects are `Arc<T>` handles whose methods are `async fn` returning `Result<_, CuaError>`, records are structs with public fields, and names are snake_case.-[`agent_event_category`](/cua-sdk/reference/agents#agent_event_category), [`agent_harnesses`](/cua-sdk/reference/agents#agent_harnesses), [`AgentActionReport`](/cua-sdk/reference/spaces#agentactionreport-record), [`AgentArtifact`](/cua-sdk/reference/agents#agentartifact-record), [`AgentDelivery`](/cua-sdk/reference/spaces/persistent-agents#agentdelivery-record), [`AgentEvent`](/cua-sdk/reference/agents#agentevent-record), [`AgentEventPage`](/cua-sdk/reference/agents#agenteventpage-record), [`AgentFile`](/cua-sdk/reference/agents#agentfile-record), [`AgentInfo`](/cua-sdk/reference/agents#agentinfo-record), [`AgentMcpServer`](/cua-sdk/reference/agents#agentmcpserver-record), [`AgentPauseReport`](/cua-sdk/reference/spaces/persistent-agents#agentpausereport-record), [`AgentResumeReport`](/cua-sdk/reference/spaces/persistent-agents#agentresumereport-record), [`AgentRun`](/cua-sdk/reference/agents#agentrun), [`AgentRunInfo`](/cua-sdk/reference/agents#agentruninfo-record), [`AgentRunMcpServer`](/cua-sdk/reference/agents#agentrunmcpserver-record), [`AgentRunOptions`](/cua-sdk/reference/agents#agentrunoptions-record), [`AgentRunResult`](/cua-sdk/reference/agents#agentrunresult-record), [`AgentRunStatus`](/cua-sdk/reference/spaces#agentrunstatus-record), [`Agents`](/cua-sdk/reference/agents#agents), [`AgentSetup`](/cua-sdk/reference/agents#agentsetup), [`AgentSetupChange`](/cua-sdk/reference/agents#agentsetupchange-enum), [`AgentSetupOutcome`](/cua-sdk/reference/agents#agentsetupoutcome-record), [`AgentSetupTarget`](/cua-sdk/reference/agents#agentsetuptarget-enum), [`AgentStartReport`](/cua-sdk/reference/spaces#agentstartreport-record), [`AgentTranscript`](/cua-sdk/reference/agents#agenttranscript), [`AgentTranscriptItem`](/cua-sdk/reference/agents#agenttranscriptitem-record), [`ambiguous_sandbox_candidates`](/cua-sdk/reference/sandbox#ambiguous_sandbox_candidates), [`AudioPacket`](/cua-sdk/reference/spacesd/computer#audiopacket-record), [`AudioSink`](/cua-sdk/reference/spacesd/computer#audiosink), [`Auth`](/cua-sdk/reference/auth#auth), [`AuthIdentity`](/cua-sdk/reference/auth#authidentity-record), [`AuthStatus`](/cua-sdk/reference/auth#authstatus-record), [`BuildFile`](/cua-sdk/reference/image#buildfile-record), [`BundledSkill`](/cua-sdk/reference/agents#bundledskill-record), [`canonical_image`](/cua-sdk/reference/image#canonical_image), [`canonical_image_tier`](/cua-sdk/reference/image#canonical_image_tier), [`check_placement`](/cua-sdk/reference/cua#check_placement), [`CloudCheck`](/cua-sdk/reference/spaces/persistent-agents#cloudcheck-record), [`CloudConnected`](/cua-sdk/reference/spaces/persistent-agents#cloudconnected-record), [`CloudCredentials`](/cua-sdk/reference/spaces/persistent-agents#cloudcredentials-record), [`CloudDisconnected`](/cua-sdk/reference/spaces/persistent-agents#clouddisconnected-record), [`CloudKind`](/cua-sdk/reference/spaces/persistent-agents#cloudkind-record), [`CloudOptions`](/cua-sdk/reference/image#cloudoptions-record), [`CloudProvider`](/cua-sdk/reference/spaces/persistent-agents#cloudprovider-record), [`CloudResource`](/cua-sdk/reference/spaces/persistent-agents#cloudresource-record), [`CloudStatus`](/cua-sdk/reference/spaces/persistent-agents#cloudstatus-record), [`CloudSweepItem`](/cua-sdk/reference/spaces/persistent-agents#cloudsweepitem-record), [`CloudSweepReport`](/cua-sdk/reference/spaces/persistent-agents#cloudsweepreport-record), [`CloudTarget`](/cua-sdk/reference/spaces/persistent-agents#cloudtarget-record), [`CloudTestReport`](/cua-sdk/reference/spaces/persistent-agents#cloudtestreport-record), [`ComputerGrant`](/cua-sdk/reference/spaces/persistent-agents#computergrant-record), [`config_get`](/cua-sdk/reference/cua#config_get), [`config_list`](/cua-sdk/reference/cua#config_list), [`config_path`](/cua-sdk/reference/cua#config_path), [`config_set`](/cua-sdk/reference/cua#config_set), [`config_unset`](/cua-sdk/reference/cua#config_unset), [`ConfigEntry`](/cua-sdk/reference/cua#configentry-record), [`Container`](/cua-sdk/reference/image#container-record), [`contrib_providers_built`](/cua-sdk/reference/sandbox#contrib_providers_built), [`Cua`](/cua-sdk/reference/cua#cua), [`CuaConfig`](/cua-sdk/reference/cua#cuaconfig-record), [`CuaInfo`](/cua-sdk/reference/cua#cuainfo-record), [`CuaMode`](/cua-sdk/reference/cua#cuamode-enum), [`CursorArt`](/cua-sdk/reference/spaces/streams#cursorart-record), [`DeviceEnrollment`](/cua-sdk/reference/spaces/host#deviceenrollment-record), [`Devices`](/cua-sdk/reference/spaces/host#devices), [`DevicesSnapshot`](/cua-sdk/reference/spaces/host#devicessnapshot-record), [`DoctorReport`](/cua-sdk/reference/cua#doctorreport-record), [`DriveAccessRequest`](/cua-sdk/reference/spaces/volume#driveaccessrequest-record), [`DriveAudit`](/cua-sdk/reference/spaces/volume#driveaudit-record), [`DriveAuditEvent`](/cua-sdk/reference/spaces/volume#driveauditevent-record), [`DriveCacheStats`](/cua-sdk/reference/spaces/volume#drivecachestats-record), [`DriveConflict`](/cua-sdk/reference/spaces/volume#driveconflict-record), [`DriveDevice`](/cua-sdk/reference/spaces/volume#drivedevice-record), [`DriveEntry`](/cua-sdk/reference/spaces/volume#driveentry-record), [`DriveFile`](/cua-sdk/reference/spaces/volume#drivefile-record), [`DriveFileSync`](/cua-sdk/reference/spaces/volume#drivefilesync-record), [`DriveGrant`](/cua-sdk/reference/spaces/volume#drivegrant-record), [`DriveListing`](/cua-sdk/reference/spaces/volume#drivelisting-record), [`DriveMountStatus`](/cua-sdk/reference/spaces/volume#drivemountstatus-record), [`DriveObject`](/cua-sdk/reference/spaces/volume#driveobject-record), [`DrivePendingUpload`](/cua-sdk/reference/spaces/volume#drivependingupload-record), [`DriveS3Settings`](/cua-sdk/reference/spaces/volume#drives3settings-record), [`DriveSpaceVolume`](/cua-sdk/reference/spaces/volume#drivespacevolume-record), [`DriveStorage`](/cua-sdk/reference/spaces/volume#drivestorage-record), [`DriveStorageCheck`](/cua-sdk/reference/spaces/volume#drivestoragecheck-record), [`DriveStorageUpdate`](/cua-sdk/reference/spaces/volume#drivestorageupdate-record), [`DriveSyncEvent`](/cua-sdk/reference/spaces/volume#drivesyncevent-record), [`DriveSyncEvents`](/cua-sdk/reference/spaces/volume#drivesyncevents-record), [`DriveSyncStatus`](/cua-sdk/reference/spaces/volume#drivesyncstatus-record), [`DriveVersion`](/cua-sdk/reference/spaces/volume#driveversion-record), [`DriveView`](/cua-sdk/reference/spaces/volume#driveview-record), [`Fleet`](/cua-sdk/reference/errors#fleet), [`fleet_check_runtime`](/cua-sdk/reference/fleet/images#fleet_check_runtime), [`fleet_generate_claim_token`](/cua-sdk/reference/fleet#fleet_generate_claim_token), [`fleet_image_variant`](/cua-sdk/reference/fleet/images#fleet_image_variant), [`fleet_resolve_runtime`](/cua-sdk/reference/fleet/images#fleet_resolve_runtime), [`fleet_size_limits`](/cua-sdk/reference/fleet/images#fleet_size_limits), [`FleetBillingCard`](/cua-sdk/reference/fleet/images#fleetbillingcard-record), [`FleetBillingCredit`](/cua-sdk/reference/fleet/images#fleetbillingcredit-record), [`FleetBillingStatus`](/cua-sdk/reference/fleet/images#fleetbillingstatus-record), [`FleetClaim`](/cua-sdk/reference/fleet/claims#fleetclaim-record), [`FleetClaimOptions`](/cua-sdk/reference/fleet/claims#fleetclaimoptions-record), [`FleetGcReport`](/cua-sdk/reference/fleet#fleetgcreport-record), [`FleetManagedPool`](/cua-sdk/reference/fleet#fleetmanagedpool-record), [`FleetPool`](/cua-sdk/reference/fleet#fleetpool-record), [`FleetPoolExport`](/cua-sdk/reference/fleet#fleetpoolexport-record), [`FleetPools`](/cua-sdk/reference/fleet#fleetpools), [`FleetPoolSpec`](/cua-sdk/reference/fleet#fleetpoolspec-record), [`FleetSandbox`](/cua-sdk/reference/fleet/claims#fleetsandbox-record), [`FleetSettings`](/cua-sdk/reference/cua#fleetsettings-record), [`FleetSignedUrl`](/cua-sdk/reference/fleet/claims#fleetsignedurl-record), [`FleetSizeLimits`](/cua-sdk/reference/fleet/images#fleetsizelimits-record), [`FleetUsagePricing`](/cua-sdk/reference/fleet/images#fleetusagepricing-record), [`FrameSink`](/cua-sdk/reference/spacesd/computer#framesink), [`GpuOption`](/cua-sdk/reference/spaces#gpuoption-record), [`GpuSupport`](/cua-sdk/reference/spaces#gpusupport-record), [`GuestDisplay`](/cua-sdk/reference/spacesd#guestdisplay), [`HomeTransfer`](/cua-sdk/reference/spaces/persistent-agents#hometransfer-record), [`Host`](/cua-sdk/reference/spaces/host#host), [`HostAccessRecord`](/cua-sdk/reference/spaces/host#hostaccessrecord-record), [`HostPermission`](/cua-sdk/reference/spaces/host#hostpermission-record), [`HostProvidedSpace`](/cua-sdk/reference/spaces/host#hostprovidedspace-record), [`HostSettingsChange`](/cua-sdk/reference/spaces/host#hostsettingschange-record), [`HostSetupOptions`](/cua-sdk/reference/spaces/host#hostsetupoptions-record), [`HostSpacesAuditRecord`](/cua-sdk/reference/spaces/host#hostspacesauditrecord-record), [`HostStatus`](/cua-sdk/reference/spaces/host#hoststatus-record), [`HttpHeader`](/cua-sdk/reference/services#httpheader-record), [`HttpResponse`](/cua-sdk/reference/services#httpresponse-record), [`image_alias`](/cua-sdk/reference/image#image_alias), [`ImageBuild`](/cua-sdk/reference/image#imagebuild-record), [`ImageInfo`](/cua-sdk/reference/image#imageinfo-record), [`ImageLayer`](/cua-sdk/reference/image#imagelayer-enum), [`Local`](/cua-sdk/reference/cua#local), [`LocalImage`](/cua-sdk/reference/cua#localimage-record), [`LocalStorage`](/cua-sdk/reference/cua#localstorage-record), [`LocationInfo`](/cua-sdk/reference/cua#locationinfo-record), [`locations`](/cua-sdk/reference/cua#locations), [`LoginAttempt`](/cua-sdk/reference/auth#loginattempt), [`LoginMethod`](/cua-sdk/reference/auth#loginmethod-enum), [`may_have_fleet_session`](/cua-sdk/reference/auth#may_have_fleet_session), [`mcp_connect`](/cua-sdk/reference/services#mcp_connect), [`mcp_connect_url`](/cua-sdk/reference/services#mcp_connect_url), [`McpClient`](/cua-sdk/reference/services#mcpclient), [`McpConfig`](/cua-sdk/reference/services#mcpconfig-record), [`MediaBridge`](/cua-sdk/reference/spacesd/computer#mediabridge-record), [`MediaEvent`](/cua-sdk/reference/spacesd/computer#mediaevent-record), [`MediaSession`](/cua-sdk/reference/spacesd/computer#mediasession), [`MediaStats`](/cua-sdk/reference/spacesd/computer#mediastats-record), [`normalize_image`](/cua-sdk/reference/image#normalize_image), [`NotificationInfo`](/cua-sdk/reference/spaces/persistent-agents#notificationinfo-record), [`omarchy_image`](/cua-sdk/reference/image#omarchy_image), [`Overlay`](/cua-sdk/reference/sandbox#overlay-record), [`OverlayResult`](/cua-sdk/reference/sandbox#overlayresult-record), [`PairingCode`](/cua-sdk/reference/spaces/host#pairingcode-record), [`parse_sandbox_ref`](/cua-sdk/reference/sandbox#parse_sandbox_ref), [`PersistentAgentInfo`](/cua-sdk/reference/spaces/persistent-agents#persistentagentinfo-record), [`PersistentAgentOptions`](/cua-sdk/reference/spaces/persistent-agents#persistentagentoptions-record), [`PoolOptions`](/cua-sdk/reference/fleet#pooloptions-record), [`PortForward`](/cua-sdk/reference/services#portforward), [`presence_color`](/cua-sdk/reference/spaces/streams#presence_color), [`presence_conformance_json`](/cua-sdk/reference/spaces/streams#presence_conformance_json), [`presence_cursor_art`](/cua-sdk/reference/spaces/streams#presence_cursor_art), [`presence_cursor_art_all`](/cua-sdk/reference/spaces/streams#presence_cursor_art_all), [`presence_cursor_art_svg`](/cua-sdk/reference/spaces/streams#presence_cursor_art_svg), [`presence_now_ms`](/cua-sdk/reference/spaces/streams#presence_now_ms), [`presence_text_color`](/cua-sdk/reference/spaces/streams#presence_text_color), [`PresenceCursor`](/cua-sdk/reference/spaces/streams#presencecursor-record), [`PresenceDrawable`](/cua-sdk/reference/spaces/streams#presencedrawable-record), [`PresenceEvent`](/cua-sdk/reference/spaces/streams#presenceevent-record), [`PresenceIdentity`](/cua-sdk/reference/spaces/streams#presenceidentity-record), [`PresenceMember`](/cua-sdk/reference/spaces/streams#presencemember-record), [`PresenceParticipant`](/cua-sdk/reference/spaces/streams#presenceparticipant-record), [`PresencePoint`](/cua-sdk/reference/spaces/streams#presencepoint-record), [`PresenceView`](/cua-sdk/reference/spaces/streams#presenceview), [`PublicUrl`](/cua-sdk/reference/services#publicurl-record), [`qualify_sandbox_ref`](/cua-sdk/reference/sandbox#qualify_sandbox_ref), [`ReadinessProbe`](/cua-sdk/reference/image#readinessprobe-record), [`RegistrySecret`](/cua-sdk/reference/image#registrysecret-enum), [`Relay`](/cua-sdk/reference/spaces/host#relay), [`RelayAuditEvent`](/cua-sdk/reference/spaces/host#relayauditevent-record), [`RelayClientInfo`](/cua-sdk/reference/spaces/host#relayclientinfo-record), [`RelayDevice`](/cua-sdk/reference/spaces/host#relaydevice-record), [`RelayMachine`](/cua-sdk/reference/spaces/host#relaymachine-record), [`ReplayMode`](/cua-sdk/reference/spacesd#replaymode-enum), [`resolve_image`](/cua-sdk/reference/image#resolve_image), [`resolve_image_with_secret`](/cua-sdk/reference/image#resolve_image_with_secret), [`ResolvedImage`](/cua-sdk/reference/image#resolvedimage-record), [`RoutineInfo`](/cua-sdk/reference/spaces/persistent-agents#routineinfo-record), [`RuntimeCheck`](/cua-sdk/reference/cua#runtimecheck-record), [`RuntimeCheckStatus`](/cua-sdk/reference/cua#runtimecheckstatus-enum), [`Sandbox`](/cua-sdk/reference/sandbox#sandbox), [`sandbox_locations`](/cua-sdk/reference/sandbox#sandbox_locations), [`SandboxCreateOptions`](/cua-sdk/reference/image#sandboxcreateoptions-record), [`Sandboxes`](/cua-sdk/reference/sandbox#sandboxes), [`SandboxInfo`](/cua-sdk/reference/sandbox#sandboxinfo-record), [`SandboxListing`](/cua-sdk/reference/sandbox#sandboxlisting-record), [`SandboxPhase`](/cua-sdk/reference/sandbox#sandboxphase-enum), [`SandboxRefParts`](/cua-sdk/reference/sandbox#sandboxrefparts-record), [`SandboxSpec`](/cua-sdk/reference/fleet#sandboxspec-record), [`SandboxStatus`](/cua-sdk/reference/sandbox#sandboxstatus-enum), [`Service`](/cua-sdk/reference/services#service), [`ServiceEndpoint`](/cua-sdk/reference/services#serviceendpoint-record), [`SetupStep`](/cua-sdk/reference/cua#setupstep-record), [`SiteLoginOptions`](/cua-sdk/reference/spaces/space#siteloginoptions-record), [`SiteLoginReport`](/cua-sdk/reference/spaces/space#siteloginreport-record), [`Space`](/cua-sdk/reference/spaces/space#space), [`SpaceAgentOptions`](/cua-sdk/reference/spaces#spaceagentoptions-record), [`SpaceAppIcon`](/cua-sdk/reference/spaces/space#spaceappicon-record), [`SpaceAppIconRequest`](/cua-sdk/reference/spaces/space#spaceappiconrequest-record), [`SpaceBashResult`](/cua-sdk/reference/spaces/space#spacebashresult-record), [`SpaceCancelOutcome`](/cua-sdk/reference/spaces#spacecanceloutcome-record), [`SpaceCreateListener`](/cua-sdk/reference/spaces#spacecreatelistener), [`SpaceCreateOptions`](/cua-sdk/reference/spaces#spacecreateoptions-record), [`SpaceCreateProgress`](/cua-sdk/reference/spaces#spacecreateprogress-record), [`SpaceCreateResult`](/cua-sdk/reference/spaces#spacecreateresult-record), [`SpaceDisplay`](/cua-sdk/reference/spaces/space#spacedisplay-record), [`SpaceHotspotStatus`](/cua-sdk/reference/spaces/space#spacehotspotstatus-record), [`SpaceInfo`](/cua-sdk/reference/spaces#spaceinfo-record), [`SpacePowerReport`](/cua-sdk/reference/spaces#spacepowerreport-record), [`SpacePresence`](/cua-sdk/reference/spaces/streams#spacepresence), [`SpaceRelayRegistration`](/cua-sdk/reference/spaces/space#spacerelayregistration-record), [`Spaces`](/cua-sdk/reference/spaces#spaces), [`spaces_tool_methods`](/cua-sdk/reference/spaces#spaces_tool_methods), [`SpacesdClient`](/cua-sdk/reference/spacesd#spacesdclient), [`SpacesdHttpHeader`](/cua-sdk/reference/spacesd#spacesdhttpheader-record), [`SpacesdHttpRequest`](/cua-sdk/reference/spacesd#spacesdhttprequest-record), [`SpacesdHttpResponse`](/cua-sdk/reference/spacesd#spacesdhttpresponse-record), [`SpacesdProcess`](/cua-sdk/reference/spacesd#spacesdprocess), [`SpaceSendFileOptions`](/cua-sdk/reference/spaces/space#spacesendfileoptions-record), [`SpaceSendFileReport`](/cua-sdk/reference/spaces/space#spacesendfilereport-record), [`SpaceSentFile`](/cua-sdk/reference/spaces/space#spacesentfile-record), [`SpaceShareEntry`](/cua-sdk/reference/spaces/space#spaceshareentry-record), [`SpaceShares`](/cua-sdk/reference/spaces/space#spaceshares-record), [`SpacesHost`](/cua-sdk/reference/spaces/space#spaceshost-record), [`SpacesHostLimit`](/cua-sdk/reference/spaces/space#spaceshostlimit-record), [`SpacesToolMethod`](/cua-sdk/reference/spaces#spacestoolmethod-record), [`SpaceStreamOptions`](/cua-sdk/reference/spaces/streams#spacestreamoptions-record), [`SpaceStreamSession`](/cua-sdk/reference/spaces/streams#spacestreamsession), [`SpaceStreamStats`](/cua-sdk/reference/spaces/streams#spacestreamstats-record), [`SpaceStreamTicket`](/cua-sdk/reference/spaces/streams#spacestreamticket-record), [`SpaceToolInfo`](/cua-sdk/reference/spaces/space#spacetoolinfo-record), [`SpaceToolResult`](/cua-sdk/reference/spaces/space#spacetoolresult-record), [`SpaceTransferReport`](/cua-sdk/reference/spaces/space#spacetransferreport-record), [`SpaceUsage`](/cua-sdk/reference/spaces/space#spaceusage-record), [`SpaceWindow`](/cua-sdk/reference/spaces/space#spacewindow-record), [`SpaceWriteReport`](/cua-sdk/reference/spaces/space#spacewritereport-record), [`StorageVolume`](/cua-sdk/reference/cua#storagevolume-record), [`StreamStatsReport`](/cua-sdk/reference/auth#streamstatsreport-record), [`telemetry_acknowledge_notice`](/cua-sdk/reference/auth#telemetry_acknowledge_notice), [`telemetry_flush`](/cua-sdk/reference/auth#telemetry_flush), [`telemetry_notice_text`](/cua-sdk/reference/auth#telemetry_notice_text), [`telemetry_record_bench_run`](/cua-sdk/reference/auth#telemetry_record_bench_run), [`telemetry_record_feature`](/cua-sdk/reference/auth#telemetry_record_feature), [`telemetry_record_onboarding_step`](/cua-sdk/reference/auth#telemetry_record_onboarding_step), [`telemetry_record_stream_stats`](/cua-sdk/reference/auth#telemetry_record_stream_stats), [`telemetry_reset_id`](/cua-sdk/reference/auth#telemetry_reset_id), [`telemetry_schema_json`](/cua-sdk/reference/auth#telemetry_schema_json), [`telemetry_set_enabled`](/cua-sdk/reference/auth#telemetry_set_enabled), [`telemetry_set_surface`](/cua-sdk/reference/auth#telemetry_set_surface), [`telemetry_show_last`](/cua-sdk/reference/auth#telemetry_show_last), [`telemetry_status`](/cua-sdk/reference/auth#telemetry_status), [`telemetry_use_app_notice`](/cua-sdk/reference/auth#telemetry_use_app_notice), [`TelemetryStatus`](/cua-sdk/reference/auth#telemetrystatus-record), [`TeleportApprover`](/cua-sdk/reference/spaces/space#teleportapprover), [`TeleportDecision`](/cua-sdk/reference/spaces/space#teleportdecision-record), [`TeleportItem`](/cua-sdk/reference/spaces/space#teleportitem-record), [`TeleportManifest`](/cua-sdk/reference/spaces/space#teleportmanifest-record), [`TeleportReceipt`](/cua-sdk/reference/spaces/space#teleportreceipt-record), [`VideoFrame`](/cua-sdk/reference/spacesd/computer#videoframe-record), [`ViewerLink`](/cua-sdk/reference/sandbox#viewerlink-record), [`ViewerOptions`](/cua-sdk/reference/sandbox#vieweroptions-record).+[`agent_event_category`](/cua-sdk/reference/agents#agent_event_category), [`agent_harnesses`](/cua-sdk/reference/agents#agent_harnesses), [`AgentActionReport`](/cua-sdk/reference/spaces#agentactionreport-record), [`AgentArtifact`](/cua-sdk/reference/agents#agentartifact-record), [`AgentDelivery`](/cua-sdk/reference/spaces/persistent-agents#agentdelivery-record), [`AgentEvent`](/cua-sdk/reference/agents#agentevent-record), [`AgentEventPage`](/cua-sdk/reference/agents#agenteventpage-record), [`AgentFile`](/cua-sdk/reference/agents#agentfile-record), [`AgentInfo`](/cua-sdk/reference/agents#agentinfo-record), [`AgentMcpServer`](/cua-sdk/reference/agents#agentmcpserver-record), [`AgentPauseReport`](/cua-sdk/reference/spaces/persistent-agents#agentpausereport-record), [`AgentResumeReport`](/cua-sdk/reference/spaces/persistent-agents#agentresumereport-record), [`AgentRun`](/cua-sdk/reference/agents#agentrun), [`AgentRunInfo`](/cua-sdk/reference/agents#agentruninfo-record), [`AgentRunMcpServer`](/cua-sdk/reference/agents#agentrunmcpserver-record), [`AgentRunOptions`](/cua-sdk/reference/agents#agentrunoptions-record), [`AgentRunResult`](/cua-sdk/reference/agents#agentrunresult-record), [`AgentRunStatus`](/cua-sdk/reference/spaces#agentrunstatus-record), [`Agents`](/cua-sdk/reference/agents#agents), [`AgentSetup`](/cua-sdk/reference/agents#agentsetup), [`AgentSetupChange`](/cua-sdk/reference/agents#agentsetupchange-enum), [`AgentSetupOutcome`](/cua-sdk/reference/agents#agentsetupoutcome-record), [`AgentSetupTarget`](/cua-sdk/reference/agents#agentsetuptarget-enum), [`AgentStartReport`](/cua-sdk/reference/spaces#agentstartreport-record), [`AgentTranscript`](/cua-sdk/reference/agents#agenttranscript), [`AgentTranscriptItem`](/cua-sdk/reference/agents#agenttranscriptitem-record), [`ambiguous_sandbox_candidates`](/cua-sdk/reference/sandbox#ambiguous_sandbox_candidates), [`AudioPacket`](/cua-sdk/reference/spacesd/computer#audiopacket-record), [`AudioSink`](/cua-sdk/reference/spacesd/computer#audiosink), [`Auth`](/cua-sdk/reference/auth#auth), [`AuthIdentity`](/cua-sdk/reference/auth#authidentity-record), [`AuthStatus`](/cua-sdk/reference/auth#authstatus-record), [`BuildFile`](/cua-sdk/reference/image#buildfile-record), [`BundledSkill`](/cua-sdk/reference/agents#bundledskill-record), [`canonical_image`](/cua-sdk/reference/image#canonical_image), [`canonical_image_tier`](/cua-sdk/reference/image#canonical_image_tier), [`check_placement`](/cua-sdk/reference/cua#check_placement), [`CloudCheck`](/cua-sdk/reference/spaces/persistent-agents#cloudcheck-record), [`CloudConnected`](/cua-sdk/reference/spaces/persistent-agents#cloudconnected-record), [`CloudCredentials`](/cua-sdk/reference/spaces/persistent-agents#cloudcredentials-record), [`CloudDisconnected`](/cua-sdk/reference/spaces/persistent-agents#clouddisconnected-record), [`CloudKind`](/cua-sdk/reference/spaces/persistent-agents#cloudkind-record), [`CloudOptions`](/cua-sdk/reference/image#cloudoptions-record), [`CloudProvider`](/cua-sdk/reference/spaces/persistent-agents#cloudprovider-record), [`CloudResource`](/cua-sdk/reference/spaces/persistent-agents#cloudresource-record), [`CloudStatus`](/cua-sdk/reference/spaces/persistent-agents#cloudstatus-record), [`CloudSweepItem`](/cua-sdk/reference/spaces/persistent-agents#cloudsweepitem-record), [`CloudSweepReport`](/cua-sdk/reference/spaces/persistent-agents#cloudsweepreport-record), [`CloudTarget`](/cua-sdk/reference/spaces/persistent-agents#cloudtarget-record), [`CloudTestReport`](/cua-sdk/reference/spaces/persistent-agents#cloudtestreport-record), [`ComputerGrant`](/cua-sdk/reference/spaces/persistent-agents#computergrant-record), [`ComputerResources`](/cua-sdk/reference/spaces/resources#computerresources-record), [`config_get`](/cua-sdk/reference/cua#config_get), [`config_list`](/cua-sdk/reference/cua#config_list), [`config_path`](/cua-sdk/reference/cua#config_path), [`config_set`](/cua-sdk/reference/cua#config_set), [`config_unset`](/cua-sdk/reference/cua#config_unset), [`ConfigEntry`](/cua-sdk/reference/cua#configentry-record), [`Container`](/cua-sdk/reference/image#container-record), [`contrib_providers_built`](/cua-sdk/reference/sandbox#contrib_providers_built), [`Cua`](/cua-sdk/reference/cua#cua), [`CuaConfig`](/cua-sdk/reference/cua#cuaconfig-record), [`CuaInfo`](/cua-sdk/reference/cua#cuainfo-record), [`CuaMode`](/cua-sdk/reference/cua#cuamode-enum), [`CursorArt`](/cua-sdk/reference/spaces/streams#cursorart-record), [`DeviceEnrollment`](/cua-sdk/reference/spaces/host#deviceenrollment-record), [`Devices`](/cua-sdk/reference/spaces/host#devices), [`DevicesSnapshot`](/cua-sdk/reference/spaces/host#devicessnapshot-record), [`DiskLevel`](/cua-sdk/reference/spaces/resources#disklevel-enum), [`DiskOnHost`](/cua-sdk/reference/spaces/resources#diskonhost-record), [`DiskWarning`](/cua-sdk/reference/spaces/resources#diskwarning-record), [`DoctorReport`](/cua-sdk/reference/cua#doctorreport-record), [`DriveAccessRequest`](/cua-sdk/reference/spaces/volume#driveaccessrequest-record), [`DriveAudit`](/cua-sdk/reference/spaces/volume#driveaudit-record), [`DriveAuditEvent`](/cua-sdk/reference/spaces/volume#driveauditevent-record), [`DriveCacheStats`](/cua-sdk/reference/spaces/volume#drivecachestats-record), [`DriveConflict`](/cua-sdk/reference/spaces/volume#driveconflict-record), [`DriveDevice`](/cua-sdk/reference/spaces/volume#drivedevice-record), [`DriveEntry`](/cua-sdk/reference/spaces/volume#driveentry-record), [`DriveFile`](/cua-sdk/reference/spaces/volume#drivefile-record), [`DriveFileSync`](/cua-sdk/reference/spaces/volume#drivefilesync-record), [`DriveGrant`](/cua-sdk/reference/spaces/volume#drivegrant-record), [`DriveListing`](/cua-sdk/reference/spaces/volume#drivelisting-record), [`DriveMountStatus`](/cua-sdk/reference/spaces/volume#drivemountstatus-record), [`DriveObject`](/cua-sdk/reference/spaces/volume#driveobject-record), [`DrivePendingUpload`](/cua-sdk/reference/spaces/volume#drivependingupload-record), [`DriveS3Settings`](/cua-sdk/reference/spaces/volume#drives3settings-record), [`DriveSpaceVolume`](/cua-sdk/reference/spaces/volume#drivespacevolume-record), [`DriveStorage`](/cua-sdk/reference/spaces/volume#drivestorage-record), [`DriveStorageCheck`](/cua-sdk/reference/spaces/volume#drivestoragecheck-record), [`DriveStorageUpdate`](/cua-sdk/reference/spaces/volume#drivestorageupdate-record), [`DriveSyncEvent`](/cua-sdk/reference/spaces/volume#drivesyncevent-record), [`DriveSyncEvents`](/cua-sdk/reference/spaces/volume#drivesyncevents-record), [`DriveSyncStatus`](/cua-sdk/reference/spaces/volume#drivesyncstatus-record), [`DriveVersion`](/cua-sdk/reference/spaces/volume#driveversion-record), [`DriveView`](/cua-sdk/reference/spaces/volume#driveview-record), [`Fleet`](/cua-sdk/reference/errors#fleet), [`fleet_check_runtime`](/cua-sdk/reference/fleet/images#fleet_check_runtime), [`fleet_generate_claim_token`](/cua-sdk/reference/fleet#fleet_generate_claim_token), [`fleet_image_variant`](/cua-sdk/reference/fleet/images#fleet_image_variant), [`fleet_resolve_runtime`](/cua-sdk/reference/fleet/images#fleet_resolve_runtime), [`fleet_size_limits`](/cua-sdk/reference/fleet/images#fleet_size_limits), [`FleetBillingCard`](/cua-sdk/reference/fleet/images#fleetbillingcard-record), [`FleetBillingCredit`](/cua-sdk/reference/fleet/images#fleetbillingcredit-record), [`FleetBillingStatus`](/cua-sdk/reference/fleet/images#fleetbillingstatus-record), [`FleetClaim`](/cua-sdk/reference/fleet/claims#fleetclaim-record), [`FleetClaimOptions`](/cua-sdk/reference/fleet/claims#fleetclaimoptions-record), [`FleetGcReport`](/cua-sdk/reference/fleet#fleetgcreport-record), [`FleetManagedPool`](/cua-sdk/reference/fleet#fleetmanagedpool-record), [`FleetPool`](/cua-sdk/reference/fleet#fleetpool-record), [`FleetPoolExport`](/cua-sdk/reference/fleet#fleetpoolexport-record), [`FleetPools`](/cua-sdk/reference/fleet#fleetpools), [`FleetPoolSpec`](/cua-sdk/reference/fleet#fleetpoolspec-record), [`FleetSandbox`](/cua-sdk/reference/fleet/claims#fleetsandbox-record), [`FleetSettings`](/cua-sdk/reference/cua#fleetsettings-record), [`FleetSignedUrl`](/cua-sdk/reference/fleet/claims#fleetsignedurl-record), [`FleetSizeLimits`](/cua-sdk/reference/fleet/images#fleetsizelimits-record), [`FleetUsagePricing`](/cua-sdk/reference/fleet/images#fleetusagepricing-record), [`FrameSink`](/cua-sdk/reference/spacesd/computer#framesink), [`GpuOption`](/cua-sdk/reference/spaces#gpuoption-record), [`GpuSupport`](/cua-sdk/reference/spaces#gpusupport-record), [`GuestDisplay`](/cua-sdk/reference/spacesd#guestdisplay), [`GuestUsage`](/cua-sdk/reference/spaces/resources#guestusage-record), [`HomeTransfer`](/cua-sdk/reference/spaces/persistent-agents#hometransfer-record), [`Host`](/cua-sdk/reference/spaces/host#host), [`HostAccessRecord`](/cua-sdk/reference/spaces/host#hostaccessrecord-record), [`HostPermission`](/cua-sdk/reference/spaces/host#hostpermission-record), [`HostProvidedSpace`](/cua-sdk/reference/spaces/host#hostprovidedspace-record), [`HostSettingsChange`](/cua-sdk/reference/spaces/host#hostsettingschange-record), [`HostSetupOptions`](/cua-sdk/reference/spaces/host#hostsetupoptions-record), [`HostSpacesAuditRecord`](/cua-sdk/reference/spaces/host#hostspacesauditrecord-record), [`HostStatus`](/cua-sdk/reference/spaces/host#hoststatus-record), [`HttpHeader`](/cua-sdk/reference/services#httpheader-record), [`HttpResponse`](/cua-sdk/reference/services#httpresponse-record), [`image_alias`](/cua-sdk/reference/image#image_alias), [`ImageBuild`](/cua-sdk/reference/image#imagebuild-record), [`ImageInfo`](/cua-sdk/reference/image#imageinfo-record), [`ImageLayer`](/cua-sdk/reference/image#imagelayer-enum), [`Local`](/cua-sdk/reference/cua#local), [`LocalImage`](/cua-sdk/reference/cua#localimage-record), [`LocalStorage`](/cua-sdk/reference/cua#localstorage-record), [`LocationInfo`](/cua-sdk/reference/cua#locationinfo-record), [`locations`](/cua-sdk/reference/cua#locations), [`LoginAttempt`](/cua-sdk/reference/auth#loginattempt), [`LoginMethod`](/cua-sdk/reference/auth#loginmethod-enum), [`may_have_fleet_session`](/cua-sdk/reference/auth#may_have_fleet_session), [`mcp_connect`](/cua-sdk/reference/services#mcp_connect), [`mcp_connect_url`](/cua-sdk/reference/services#mcp_connect_url), [`McpClient`](/cua-sdk/reference/services#mcpclient), [`McpConfig`](/cua-sdk/reference/services#mcpconfig-record), [`MediaBridge`](/cua-sdk/reference/spacesd/computer#mediabridge-record), [`MediaEvent`](/cua-sdk/reference/spacesd/computer#mediaevent-record), [`MediaSession`](/cua-sdk/reference/spacesd/computer#mediasession), [`MediaStats`](/cua-sdk/reference/spacesd/computer#mediastats-record), [`normalize_image`](/cua-sdk/reference/image#normalize_image), [`NotificationInfo`](/cua-sdk/reference/spaces/persistent-agents#notificationinfo-record), [`omarchy_image`](/cua-sdk/reference/image#omarchy_image), [`Overlay`](/cua-sdk/reference/sandbox#overlay-record), [`OverlayResult`](/cua-sdk/reference/sandbox#overlayresult-record), [`PairingCode`](/cua-sdk/reference/spaces/host#pairingcode-record), [`parse_sandbox_ref`](/cua-sdk/reference/sandbox#parse_sandbox_ref), [`PersistentAgentInfo`](/cua-sdk/reference/spaces/persistent-agents#persistentagentinfo-record), [`PersistentAgentOptions`](/cua-sdk/reference/spaces/persistent-agents#persistentagentoptions-record), [`PoolOptions`](/cua-sdk/reference/fleet#pooloptions-record), [`PortForward`](/cua-sdk/reference/services#portforward), [`presence_color`](/cua-sdk/reference/spaces/streams#presence_color), [`presence_conformance_json`](/cua-sdk/reference/spaces/streams#presence_conformance_json), [`presence_cursor_art`](/cua-sdk/reference/spaces/streams#presence_cursor_art), [`presence_cursor_art_all`](/cua-sdk/reference/spaces/streams#presence_cursor_art_all), [`presence_cursor_art_svg`](/cua-sdk/reference/spaces/streams#presence_cursor_art_svg), [`presence_now_ms`](/cua-sdk/reference/spaces/streams#presence_now_ms), [`presence_text_color`](/cua-sdk/reference/spaces/streams#presence_text_color), [`PresenceCursor`](/cua-sdk/reference/spaces/streams#presencecursor-record), [`PresenceDrawable`](/cua-sdk/reference/spaces/streams#presencedrawable-record), [`PresenceEvent`](/cua-sdk/reference/spaces/streams#presenceevent-record), [`PresenceIdentity`](/cua-sdk/reference/spaces/streams#presenceidentity-record), [`PresenceMember`](/cua-sdk/reference/spaces/streams#presencemember-record), [`PresenceParticipant`](/cua-sdk/reference/spaces/streams#presenceparticipant-record), [`PresencePoint`](/cua-sdk/reference/spaces/streams#presencepoint-record), [`PresenceView`](/cua-sdk/reference/spaces/streams#presenceview), [`PublicUrl`](/cua-sdk/reference/services#publicurl-record), [`qualify_sandbox_ref`](/cua-sdk/reference/sandbox#qualify_sandbox_ref), [`ReadinessProbe`](/cua-sdk/reference/image#readinessprobe-record), [`RegistrySecret`](/cua-sdk/reference/image#registrysecret-enum), [`Relay`](/cua-sdk/reference/spaces/host#relay), [`RelayAuditEvent`](/cua-sdk/reference/spaces/host#relayauditevent-record), [`RelayClientInfo`](/cua-sdk/reference/spaces/host#relayclientinfo-record), [`RelayDevice`](/cua-sdk/reference/spaces/host#relaydevice-record), [`RelayMachine`](/cua-sdk/reference/spaces/host#relaymachine-record), [`ReplayMode`](/cua-sdk/reference/spacesd#replaymode-enum), [`resolve_image`](/cua-sdk/reference/image#resolve_image), [`resolve_image_with_secret`](/cua-sdk/reference/image#resolve_image_with_secret), [`ResolvedImage`](/cua-sdk/reference/image#resolvedimage-record), [`ResourcesEvent`](/cua-sdk/reference/spaces/resources#resourcesevent-enum), [`ResourcesListener`](/cua-sdk/reference/spaces/resources#resourceslistener), [`ResourcesSnapshot`](/cua-sdk/reference/spaces/resources#resourcessnapshot-record), [`ResourcesUpdate`](/cua-sdk/reference/spaces/resources#resourcesupdate-record), [`ResourcesWatch`](/cua-sdk/reference/spaces/resources#resourceswatch), [`RoutineInfo`](/cua-sdk/reference/spaces/persistent-agents#routineinfo-record), [`RuntimeCheck`](/cua-sdk/reference/cua#runtimecheck-record), [`RuntimeCheckStatus`](/cua-sdk/reference/cua#runtimecheckstatus-enum), [`Sandbox`](/cua-sdk/reference/sandbox#sandbox), [`sandbox_locations`](/cua-sdk/reference/sandbox#sandbox_locations), [`SandboxCreateOptions`](/cua-sdk/reference/image#sandboxcreateoptions-record), [`Sandboxes`](/cua-sdk/reference/sandbox#sandboxes), [`SandboxInfo`](/cua-sdk/reference/sandbox#sandboxinfo-record), [`SandboxListing`](/cua-sdk/reference/sandbox#sandboxlisting-record), [`SandboxPhase`](/cua-sdk/reference/sandbox#sandboxphase-enum), [`SandboxRefParts`](/cua-sdk/reference/sandbox#sandboxrefparts-record), [`SandboxSpec`](/cua-sdk/reference/fleet#sandboxspec-record), [`SandboxStatus`](/cua-sdk/reference/sandbox#sandboxstatus-enum), [`Service`](/cua-sdk/reference/services#service), [`ServiceEndpoint`](/cua-sdk/reference/services#serviceendpoint-record), [`SetupStep`](/cua-sdk/reference/cua#setupstep-record), [`SiteLoginOptions`](/cua-sdk/reference/spaces/space#siteloginoptions-record), [`SiteLoginReport`](/cua-sdk/reference/spaces/space#siteloginreport-record), [`Space`](/cua-sdk/reference/spaces/space#space), [`SpaceAgentOptions`](/cua-sdk/reference/spaces#spaceagentoptions-record), [`SpaceAppIcon`](/cua-sdk/reference/spaces/space#spaceappicon-record), [`SpaceAppIconRequest`](/cua-sdk/reference/spaces/space#spaceappiconrequest-record), [`SpaceBashResult`](/cua-sdk/reference/spaces/space#spacebashresult-record), [`SpaceCancelOutcome`](/cua-sdk/reference/spaces#spacecanceloutcome-record), [`SpaceCreateListener`](/cua-sdk/reference/spaces#spacecreatelistener), [`SpaceCreateOptions`](/cua-sdk/reference/spaces#spacecreateoptions-record), [`SpaceCreateProgress`](/cua-sdk/reference/spaces#spacecreateprogress-record), [`SpaceCreateResult`](/cua-sdk/reference/spaces#spacecreateresult-record), [`SpaceDisplay`](/cua-sdk/reference/spaces/space#spacedisplay-record), [`SpaceHotspotStatus`](/cua-sdk/reference/spaces/space#spacehotspotstatus-record), [`SpaceInfo`](/cua-sdk/reference/spaces#spaceinfo-record), [`SpacePowerReport`](/cua-sdk/reference/spaces#spacepowerreport-record), [`SpacePresence`](/cua-sdk/reference/spaces/streams#spacepresence), [`SpaceRelayRegistration`](/cua-sdk/reference/spaces/space#spacerelayregistration-record), [`SpaceResources`](/cua-sdk/reference/spaces/resources#spaceresources-record), [`Spaces`](/cua-sdk/reference/spaces#spaces), [`spaces_tool_methods`](/cua-sdk/reference/spaces#spaces_tool_methods), [`SpacesdClient`](/cua-sdk/reference/spacesd#spacesdclient), [`SpacesdHttpHeader`](/cua-sdk/reference/spacesd#spacesdhttpheader-record), [`SpacesdHttpRequest`](/cua-sdk/reference/spacesd#spacesdhttprequest-record), [`SpacesdHttpResponse`](/cua-sdk/reference/spacesd#spacesdhttpresponse-record), [`SpacesdProcess`](/cua-sdk/reference/spacesd#spacesdprocess), [`SpaceSendFileOptions`](/cua-sdk/reference/spaces/space#spacesendfileoptions-record), [`SpaceSendFileReport`](/cua-sdk/reference/spaces/space#spacesendfilereport-record), [`SpaceSentFile`](/cua-sdk/reference/spaces/space#spacesentfile-record), [`SpaceShareEntry`](/cua-sdk/reference/spaces/space#spaceshareentry-record), [`SpaceShares`](/cua-sdk/reference/spaces/space#spaceshares-record), [`SpacesHost`](/cua-sdk/reference/spaces/space#spaceshost-record), [`SpacesHostLimit`](/cua-sdk/reference/spaces/space#spaceshostlimit-record), [`SpacesToolMethod`](/cua-sdk/reference/spaces#spacestoolmethod-record), [`SpaceStreamOptions`](/cua-sdk/reference/spaces/streams#spacestreamoptions-record), [`SpaceStreamSession`](/cua-sdk/reference/spaces/streams#spacestreamsession), [`SpaceStreamStats`](/cua-sdk/reference/spaces/streams#spacestreamstats-record), [`SpaceStreamTicket`](/cua-sdk/reference/spaces/streams#spacestreamticket-record), [`SpaceToolInfo`](/cua-sdk/reference/spaces/space#spacetoolinfo-record), [`SpaceToolResult`](/cua-sdk/reference/spaces/space#spacetoolresult-record), [`SpaceTransferReport`](/cua-sdk/reference/spaces/space#spacetransferreport-record), [`SpaceUsage`](/cua-sdk/reference/spaces/space#spaceusage-record), [`SpaceWindow`](/cua-sdk/reference/spaces/space#spacewindow-record), [`SpaceWriteReport`](/cua-sdk/reference/spaces/space#spacewritereport-record), [`StorageVolume`](/cua-sdk/reference/cua#storagevolume-record), [`StreamStatsReport`](/cua-sdk/reference/auth#streamstatsreport-record), [`telemetry_acknowledge_notice`](/cua-sdk/reference/auth#telemetry_acknowledge_notice), [`telemetry_flush`](/cua-sdk/reference/auth#telemetry_flush), [`telemetry_notice_text`](/cua-sdk/reference/auth#telemetry_notice_text), [`telemetry_record_bench_run`](/cua-sdk/reference/auth#telemetry_record_bench_run), [`telemetry_record_feature`](/cua-sdk/reference/auth#telemetry_record_feature), [`telemetry_record_onboarding_step`](/cua-sdk/reference/auth#telemetry_record_onboarding_step), [`telemetry_record_stream_stats`](/cua-sdk/reference/auth#telemetry_record_stream_stats), [`telemetry_reset_id`](/cua-sdk/reference/auth#telemetry_reset_id), [`telemetry_schema_json`](/cua-sdk/reference/auth#telemetry_schema_json), [`telemetry_set_enabled`](/cua-sdk/reference/auth#telemetry_set_enabled), [`telemetry_set_surface`](/cua-sdk/reference/auth#telemetry_set_surface), [`telemetry_show_last`](/cua-sdk/reference/auth#telemetry_show_last), [`telemetry_status`](/cua-sdk/reference/auth#telemetry_status), [`telemetry_use_app_notice`](/cua-sdk/reference/auth#telemetry_use_app_notice), [`TelemetryStatus`](/cua-sdk/reference/auth#telemetrystatus-record), [`TeleportApprover`](/cua-sdk/reference/spaces/space#teleportapprover), [`TeleportDecision`](/cua-sdk/reference/spaces/space#teleportdecision-record), [`TeleportItem`](/cua-sdk/reference/spaces/space#teleportitem-record), [`TeleportManifest`](/cua-sdk/reference/spaces/space#teleportmanifest-record), [`TeleportReceipt`](/cua-sdk/reference/spaces/space#teleportreceipt-record), [`VideoFrame`](/cua-sdk/reference/spacesd/computer#videoframe-record), [`ViewerLink`](/cua-sdk/reference/sandbox#viewerlink-record), [`ViewerOptions`](/cua-sdk/reference/sandbox#vieweroptions-record).## Typesdiff --git a/docs/content/docs/cua-sdk/reference/spaces/index.mdx b/docs/content/docs/cua-sdk/reference/spaces/index.mdxindex fc66e8630c..9de7dd4c11 100644--- a/docs/content/docs/cua-sdk/reference/spaces/index.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/index.mdx@@ -61,6 +61,7 @@ Returned by [`Cua.spaces`](/cua-sdk/reference/cua#cua).| [`persistent_agent_save`](/cua-sdk/reference/spaces/persistent-agents#spacespersistent_agent_save) | Saves a persistent agent's home into the drive now. || [`persistent_agent_send`](/cua-sdk/reference/spaces/persistent-agents#spacespersistent_agent_send) | Gives a persistent agent a turn: a follow-up to its idle run, or a new run with its home restored. || [`persistent_agents`](/cua-sdk/reference/spaces/persistent-agents#spacespersistent_agents) | Every persistent agent. |+| [`resources`](/cua-sdk/reference/spaces/resources#spacesresources) | What this Mac, its extra Spaces and your other computers use now: processor, memory and disk, as one snapshot (a few seconds old at most). || [`routine_add`](/cua-sdk/reference/spaces/persistent-agents#spacesroutine_add) | Adds a routine. || [`routine_remove`](/cua-sdk/reference/spaces/persistent-agents#spacesroutine_remove) | Deletes a routine. || [`routine_set_enabled`](/cua-sdk/reference/spaces/persistent-agents#spacesroutine_set_enabled) | Turns a routine on or off. |@@ -90,6 +91,7 @@ Returned by [`Cua.spaces`](/cua-sdk/reference/cua#cua).| [`volume_sync_status`](/cua-sdk/reference/spaces/volume#spacesvolume_sync_status) | `volume_sync_status`: devices, pending uploads and conflicts. || [`volume_unmount`](/cua-sdk/reference/spaces/volume#spacesvolume_unmount) | `volume_unmount`: turns the mount off; pending uploads land first. || [`volume_write`](/cua-sdk/reference/spaces/volume#spacesvolume_write) | `volume_write`: a new version of a file. |+| [`watch_resources`](/cua-sdk/reference/spaces/resources#spaceswatch_resources) | The same numbers as events for `listener`: a snapshot first, then an update with only the entries that changed by more than 1 point or 256 MB, and `LowDisk` whenever the warning level changes. |### `Spaces.add`diff --git a/docs/content/docs/cua-sdk/reference/spaces/meta.json b/docs/content/docs/cua-sdk/reference/spaces/meta.jsonindex 41c5f58f80..f10ce6f950 100644--- a/docs/content/docs/cua-sdk/reference/spaces/meta.json+++ b/docs/content/docs/cua-sdk/reference/spaces/meta.json@@ -4,6 +4,7 @@"space","volume","streams",+ "resources","persistent-agents","host"]diff --git a/docs/content/docs/cua-sdk/reference/spaces/resources.mdx b/docs/content/docs/cua-sdk/reference/spaces/resources.mdxnew file mode 100644index 0000000000..c4fd5e7f03--- /dev/null+++ b/docs/content/docs/cua-sdk/reference/spaces/resources.mdx@@ -0,0 +1,479 @@+---+title: "Processor, memory and disk"+description: "What this Mac, its extra Spaces and your other computers use: one snapshot, a stream of changes and the low-disk warning."+---++{/*+ AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY+ Generated by: pnpm --dir docs docs:generate:cua-sdk+ Source: cua-bindgen docs (UniFFI metadata of libcua_sdk)+ Version: 0.5.0+*/}++import { Callout } from 'fumadocs-ui/components/callout';+import { Tab, Tabs } from 'fumadocs-ui/components/tabs';++`Spaces.resources` returns one `ResourcesSnapshot`: this Mac's cores, memory and free disk, each extra Space's allocation, use and cost on this Mac's disk, and the summary each of your other computers published. `Spaces.watch_resources` calls a `ResourcesListener` with a snapshot, then only the entries that changed by more than 1 point or 256 MB, and a `LowDisk` event when the free-disk level changes. Numbers only: counts, bytes and percentages.++## Resources++Methods of [`Spaces`](/cua-sdk/reference/spaces#spaces).++### `Spaces.resources`++What this Mac, its extra Spaces and your other computers use now:+processor, memory and disk, as one snapshot (a few seconds old at+most). With `visible`, the call also says a window shows the numbers+for the next 30 seconds, so the runtime samples every 10 seconds+instead of every 5 minutes: call it every 10 seconds while a window+is visible and stop when it is hidden.++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+async def resources(self, visible: bool) -> ResourcesSnapshot+```++</Tab>+<Tab value="TypeScript">++```ts+resources(visible: boolean, asyncOpts_?: { signal: AbortSignal }): Promise<ResourcesSnapshot>+```++</Tab>+<Tab value="Swift">++```swift+func resources(visible: Bool) async throws -> ResourcesSnapshot+```++</Tab>+<Tab value="Kotlin">++```kotlin+@Throws(CuaException::class)+suspend fun resources(visible: Boolean): ResourcesSnapshot+```++</Tab>+<Tab value="Rust">++```rust+pub async fn resources(&self, visible: bool) -> Result<ResourcesSnapshot, CuaError>+```++</Tab>+</Tabs>++| Parameter | Type | Default |+| --- | --- | --- |+| `visible` | `bool` | required |++**Returns** [`ResourcesSnapshot`](#resourcessnapshot-record) · **Async** · **Raises** [`CuaError`](/cua-sdk/reference/errors)++### `Spaces.watch_resources`++The same numbers as events for `listener`: a snapshot first, then an+update with only the entries that changed by more than 1 point or+256 MB, and `LowDisk` whenever the warning level changes. Reopens by+itself if the daemon restarts (the snapshot comes again). Stop it+with `ResourcesWatch.stop`.++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+def watch_resources(self, visible: bool, listener: ResourcesListener) -> ResourcesWatch+```++</Tab>+<Tab value="TypeScript">++```ts+watchResources(visible: boolean, listener: ResourcesListener): ResourcesWatchLike+```++</Tab>+<Tab value="Swift">++```swift+func watchResources(visible: Bool, listener: ResourcesListener) -> ResourcesWatch+```++</Tab>+<Tab value="Kotlin">++```kotlin+fun watchResources(visible: Boolean, listener: ResourcesListener): ResourcesWatch+```++</Tab>+<Tab value="Rust">++```rust+pub fn watch_resources(&self, visible: bool, listener: Arc<dyn ResourcesListener>) -> Arc<ResourcesWatch>+```++</Tab>+</Tabs>++| Parameter | Type | Default |+| --- | --- | --- |+| `visible` | `bool` | required |+| `listener` | [`ResourcesListener`](#resourceslistener) | required |++**Returns** [`ResourcesWatch`](#resourceswatch)++## `ResourcesSnapshot` record++One sample of everything.++Returned by [`Spaces.resources`](#spacesresources).++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `sequence` | `u64` | | Grows by one per sample. |+| `sampled_at_ms` / `sampledAtMs` | `u64` | | Unix ms. |+| `this_mac` / `thisMac` | [`ComputerResources`](#computerresources-record) | | This Mac. |+| `spaces` | [`Vec<SpaceResources>`](#spaceresources-record) | | Extra Spaces on this Mac. |+| `computers` | [`Vec<ComputerResources>`](#computerresources-record) | | Your other computers, from the summaries they published. |+| `warning` | [`DiskWarning`](#diskwarning-record) | | `this_mac.warning`, for the menu bar. |++## `ComputerResources` record++A computer: this Mac, or one of your other computers (from the summary+it published).++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `id` | `String` | | `this-mac`, or the relay machine id. |+| `name` | `String` | | Display name (empty for this Mac). |+| `online` | `bool` | | Reachable now (always true for this Mac). |+| `sampled_at_ms` / `sampledAtMs` | `u64` | | When the computer measured this, unix ms (another computer's can be minutes old). |+| `cpu_count` / `cpuCount` | `u32` | | Processor cores. |+| `cpu_percent` / `cpuPercent` | `f64` | | Busy now, 0 to 100. |+| `load_average_1m` / `loadAverage1m` | `f64` | | 1-minute load average. |+| `memory_total` / `memoryTotal` | `u64` | | Memory size, bytes. |+| `memory_used` / `memoryUsed` | `u64` | | Memory in use, bytes (without reclaimable cache). |+| `disk_total` / `diskTotal` | `u64` | | Size of the volume that holds Spaces, bytes. |+| `disk_free` / `diskFree` | `u64` | | Free bytes on it. |+| `spaces_count` / `spacesCount` | `u32` | | Extra Spaces on it. |+| `spaces_running` / `spacesRunning` | `u32` | | Of those, running. |+| `spaces_cpu_allocated` / `spacesCpuAllocated` | `u32` | | Cores given to the running ones. |+| `spaces_memory_allocated` / `spacesMemoryAllocated` | `u64` | | Memory given to the running ones, bytes. |+| `spaces_memory_used` / `spacesMemoryUsed` | `u64` | | Memory the running guests report in use, bytes. |+| `spaces_disk_bytes` / `spacesDiskBytes` | `u64` | | Bytes all its extra Spaces take on it. |+| `spaces_disk_exact` / `spacesDiskExact` | `bool` | | False when some Space's disk could only be estimated. |+| `warning` | [`DiskWarning`](#diskwarning-record) | | The low-disk signal. |++## `SpaceResources` record++One extra Space on this Mac.++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `id` | `String` | | `local:<name>`. |+| `power_state` / `powerState` | `String` | | `running`, `stopped`, `suspended`, or empty when unknown. |+| `cpu_allocated` / `cpuAllocated` | `u32` | | Cores given to it (0: unknown). |+| `memory_allocated` / `memoryAllocated` | `u64` | | Memory given to it, bytes (0: unknown). |+| `disk_allocated` / `diskAllocated` | `u64` | | Its disk's size limit, bytes (0: unknown). |+| `usage` | [`Option<GuestUsage>`](#guestusage-record) | | The guest's own numbers; absent while it is off or unreachable. |+| `disk_on_host` / `diskOnHost` | [`Option<DiskOnHost>`](#diskonhost-record) | | What it costs this Mac; absent for a container. |++## `GuestUsage` record++What `SystemService.Metrics` reports from inside a Space.++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `cpu_count` / `cpuCount` | `u32` | | Cores the guest sees. |+| `cpu_percent` / `cpuPercent` | `f64` | | Busy now, 0 to 100. |+| `load_average_1m` / `loadAverage1m` | `f64` | | 1-minute load average. |+| `memory_used` / `memoryUsed` | `u64` | | Memory in use, bytes. |+| `memory_total` / `memoryTotal` | `u64` | | Memory size, bytes. |+| `memory_limited` / `memoryLimited` | `bool` | | `memory_total` is the guest's own limit. |+| `disk_used` / `diskUsed` | `u64` | | Disk in use, bytes. |+| `disk_total` / `diskTotal` | `u64` | | Disk size, bytes. |+| `disk_limited` / `diskLimited` | `bool` | | `disk_total` is the guest's own disk. |++## `DiskOnHost` record++What a Space costs this computer's disk, as opposed to what the guest+sees.++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `bytes` | `Option<u64>` | | Bytes only this Space holds (what deleting it frees); absent when they could not be measured. |+| `allocated` | `u64` | | Blocks its files occupy, clones counted in full: an upper bound. |+| `shares_space` / `sharesSpace` | `bool` | | Part of it is shared with other copies. |++## `DiskWarning` record++The low-disk signal for the app and the menu bar.++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `level` | [`DiskLevel`](#disklevel-enum) | | How low it is. |+| `free` | `u64` | | Free bytes on the volume that holds Spaces. |+| `total` | `u64` | | Size of that volume. |+| `threshold` | `u64` | | The line that was crossed (0 when `ok`). |++## `DiskLevel` enum++How low the free disk is.++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+DiskLevel.OK+DiskLevel.LOW+DiskLevel.CRITICAL+```++</Tab>+<Tab value="TypeScript">++```ts+DiskLevel.Ok+DiskLevel.Low+DiskLevel.Critical+```++</Tab>+<Tab value="Swift">++```swift+.ok+.low+.critical+```++</Tab>+<Tab value="Kotlin">++```kotlin+DiskLevel.OK+DiskLevel.LOW+DiskLevel.CRITICAL+```++</Tab>+<Tab value="Rust">++```rust+DiskLevel::Ok+DiskLevel::Low+DiskLevel::Critical+```++</Tab>+</Tabs>++| Variant | Description |+| --- | --- |+| `Ok` | Plenty. |+| `Low` | Under 50 GB or 15% of the volume, whichever line is higher (the line never rises above 100 GB). |+| `Critical` | Under the floor where creating a Space already fails (5 GiB). |++## `ResourcesUpdate` record++What changed since the last event: only entries that moved by more than+1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.++| Field | Type | Default | Description |+| --- | --- | --- | --- |+| `sequence` | `u64` | | The sample it brings you to. |+| `sampled_at_ms` / `sampledAtMs` | `u64` | | Unix ms. |+| `this_mac` / `thisMac` | [`Option<ComputerResources>`](#computerresources-record) | | This Mac, when it changed. |+| `spaces` | [`Vec<SpaceResources>`](#spaceresources-record) | | Extra Spaces that changed or appeared. |+| `computers` | [`Vec<ComputerResources>`](#computerresources-record) | | Other computers that changed or appeared. |+| `removed` | `Vec<String>` | | Ids (Spaces or computers) that are gone. |++## `ResourcesEvent` enum++What `Spaces.watch_resources` reports.++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+ResourcesEvent.SNAPSHOT(snapshot: ResourcesSnapshot)+ResourcesEvent.UPDATE(update: ResourcesUpdate)+ResourcesEvent.LOW_DISK(warning: DiskWarning)+```++</Tab>+<Tab value="TypeScript">++```ts+new ResourcesEvent.Snapshot({ snapshot: ResourcesSnapshot })+new ResourcesEvent.Update({ update: ResourcesUpdate })+new ResourcesEvent.LowDisk({ warning: DiskWarning })+```++</Tab>+<Tab value="Swift">++```swift+.snapshot(snapshot: ResourcesSnapshot)+.update(update: ResourcesUpdate)+.lowDisk(warning: DiskWarning)+```++</Tab>+<Tab value="Kotlin">++```kotlin+ResourcesEvent.Snapshot(snapshot: ResourcesSnapshot)+ResourcesEvent.Update(update: ResourcesUpdate)+ResourcesEvent.LowDisk(warning: DiskWarning)+```++</Tab>+<Tab value="Rust">++```rust+ResourcesEvent::Snapshot { snapshot: ResourcesSnapshot }+ResourcesEvent::Update { update: ResourcesUpdate }+ResourcesEvent::LowDisk { warning: DiskWarning }+```++</Tab>+</Tabs>++| Variant | Description |+| --- | --- |+| `Snapshot` | Everything, at the start (and again after a reconnect). Fields: `snapshot: ResourcesSnapshot` |+| `Update` | Only what changed. Fields: `update: ResourcesUpdate` |+| `LowDisk` | The low-disk level changed (including back to `ok`). Fields: `warning: DiskWarning` |++## `ResourcesListener`++Receives `ResourcesEvent`s from `Spaces.watch_resources`, in order.+Called on an SDK worker thread; return quickly.++<Callout>+You implement `ResourcesListener` and pass it to the SDK (a callback interface): subclass it in Python, implement the interface in TypeScript, the `ResourcesListener` protocol in Swift, the interface in Kotlin and the trait in Rust.+</Callout>++| Method | Description |+| --- | --- |+| [`on_event`](#resourceslisteneron_event) | Something moved. |++### `ResourcesListener.on_event`++Something moved.++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+def on_event(self, event: ResourcesEvent) -> None+```++</Tab>+<Tab value="TypeScript">++```ts+onEvent(event: ResourcesEvent): void+```++</Tab>+<Tab value="Swift">++```swift+func onEvent(event: ResourcesEvent)+```++</Tab>+<Tab value="Kotlin">++```kotlin+fun onEvent(event: ResourcesEvent)+```++</Tab>+<Tab value="Rust">++```rust+pub fn on_event(&self, event: ResourcesEvent)+```++</Tab>+</Tabs>++| Parameter | Type | Default |+| --- | --- | --- |+| `event` | [`ResourcesEvent`](#resourcesevent-enum) | required |++## `ResourcesWatch`++A running `Spaces.watch_resources`: tell it whether a window shows+the numbers, and stop it when done. Dropping it also stops it.++Returned by [`Spaces.watch_resources`](#spaceswatch_resources).++| Method | Description |+| --- | --- |+| [`set_visible`](#resourceswatchset_visible) | Whether a window shows the numbers: visible watchers are sampled every 10 seconds, hidden ones every 5 minutes (and still hear `LowDisk`, for the menu bar). |++| Accessor | Returns | Description |+| --- | --- | --- |+| `stop()` | | Ends the watch. No event is delivered after this returns. |++### `ResourcesWatch.set_visible`++Whether a window shows the numbers: visible watchers are sampled+every 10 seconds, hidden ones every 5 minutes (and still hear+`LowDisk`, for the menu bar).++<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist>+<Tab value="Python">++```python+def set_visible(self, visible: bool) -> None+```++</Tab>+<Tab value="TypeScript">++```ts+setVisible(visible: boolean): void+```++</Tab>+<Tab value="Swift">++```swift+func setVisible(visible: Bool)+```++</Tab>+<Tab value="Kotlin">++```kotlin+fun setVisible(visible: Boolean)+```++</Tab>+<Tab value="Rust">++```rust+pub fn set_visible(&self, visible: bool)+```++</Tab>+</Tabs>++| Parameter | Type | Default |+| --- | --- | --- |+| `visible` | `bool` | required |++## All items++11 items, across this page and its subpages, grouped by page (each item's section is on its page). Methods are listed on their object.++**Processor, memory and disk**: [`ComputerResources`](#computerresources-record), [`DiskLevel`](#disklevel-enum), [`DiskOnHost`](#diskonhost-record), [`DiskWarning`](#diskwarning-record), [`GuestUsage`](#guestusage-record), [`ResourcesEvent`](#resourcesevent-enum), [`ResourcesListener`](#resourceslistener), [`ResourcesSnapshot`](#resourcessnapshot-record), [`ResourcesUpdate`](#resourcesupdate-record), [`ResourcesWatch`](#resourceswatch), [`SpaceResources`](#spaceresources-record)diff --git a/docs/content/docs/cua-sdk/reference/spaces/space.mdx b/docs/content/docs/cua-sdk/reference/spaces/space.mdxindex 0070763a57..c55fb6aca5 100644--- a/docs/content/docs/cua-sdk/reference/spaces/space.mdx+++ b/docs/content/docs/cua-sdk/reference/spaces/space.mdx@@ -62,7 +62,7 @@ Returned by [`Spaces.space`](/cua-sdk/reference/spaces#spacesspace).| [`teleport`](/cua-sdk/reference/spaces/space#spaceteleport) | Teleports `app`'s session into this Space. || [`teleport_manifest`](/cua-sdk/reference/spaces/space#spaceteleport_manifest) | What teleporting `app` (`full` or `tabs`) would move from this host. || [`thumbnail`](/cua-sdk/reference/spaces/space#spacethumbnail) | The Space's latest thumbnail (a small JPEG of its primary display) from the cache every client on this machine shares: returned at once when it is younger than `max_age_ms` (unset: any age), else captured fresh through cua-spacesd and kept for the next caller. |-| [`usage`](/cua-sdk/reference/spaces/space#spaceusage) | Memory and storage use now (cheap: poll it at a low rate while a detail is visible). |+| [`usage`](/cua-sdk/reference/spaces/space#spaceusage) | Processor, memory and storage use now (cheap: poll it at a low rate while a detail is visible). || [`websocket_headers`](/cua-sdk/reference/spaces/streams#spacewebsocket_headers) | Headers a media WebSocket to this Space needs besides its ticket. || [`window_thumbnail`](/cua-sdk/reference/spaces/space#spacewindow_thumbnail) | A small JPEG preview of one of the Space's windows (`window_id` and `epoch` from `windows`), at most `max_dimension` px, reused for a few seconds (the SDK's preview cache); `None` when the guest captured nothing. || [`windows`](/cua-sdk/reference/spaces/streams#spacewindows) | Streamable windows, optionally of one app. |@@ -1533,8 +1533,8 @@ pub async fn displays(&self) -> Result<Vec<SpaceDisplay>, CuaError>### `Space.usage`-Memory and storage use now (cheap: poll it at a low rate while a-detail is visible).+Processor, memory and storage use now (cheap: poll it at a low rate+while a detail is visible).<Tabs items={['Python', 'TypeScript', 'Swift', 'Kotlin', 'Rust']} groupId="sdk-lang" persist><Tab value="Python">@@ -1632,14 +1632,17 @@ Returned by [`Space.thumbnail`](#spacethumbnail).## `SpaceUsage` record-Memory and storage use (`Space.usage`). A size is the guest's own-limit only when its `*_limited` flag says so (a VM's memory or disk, a-container's cgroup memory limit).+Processor, memory and storage use (`Space.usage`). A size is the+guest's own limit only when its `*_limited` flag says so (a VM's memory+or disk, a container's cgroup memory limit).Returned by [`Space.usage`](#spaceusage).| Field | Type | Default | Description || --- | --- | --- | --- |+| `cpu_count` / `cpuCount` | `u32` | `0` | Cores the guest sees (0 from a guest that does not report it). |+| `cpu_percent` / `cpuPercent` | `f64` | `0.0` | Busy now, 0 to 100. |+| `load_average_1m` / `loadAverage1m` | `f64` | `0.0` | 1-minute load average. || `memory_used` / `memoryUsed` | `u64` | | Memory in use, bytes. || `memory_total` / `memoryTotal` | `u64` | | Memory size, bytes. || `memory_limited` / `memoryLimited` | `bool` | | `memory_total` is the guest's limit. |diff --git a/docs/content/docs/cua-sdk/reference/types.mdx b/docs/content/docs/cua-sdk/reference/types.mdxindex f965e8c1b2..9d6322d452 100644--- a/docs/content/docs/cua-sdk/reference/types.mdx+++ b/docs/content/docs/cua-sdk/reference/types.mdx@@ -50,6 +50,8 @@ Renamed members: in Kotlin, objects implement `AutoCloseable`, whose `close()` f292 items. Methods are listed on their object.+The 11 items of Processor, memory and disk are listed on [its page](/cua-sdk/reference/spaces/resources#all-items).+| Item | Kind | Summary || --- | --- | --- || [`agent_event_category`](/cua-sdk/reference/agents#agent_event_category) | function | The category of an event kind: `message`, `user`, `activity` or `hidden` (the rule `AgentEvent.category` and `AgentTranscript` use). |@@ -314,7 +316,7 @@ Renamed members: in Kotlin, objects implement `AutoCloseable`, whose `close()` f| [`SpaceToolInfo`](/cua-sdk/reference/spaces/space#spacetoolinfo-record) | record | A tool of a Space's MCP service. || [`SpaceToolResult`](/cua-sdk/reference/spaces/space#spacetoolresult-record) | record | The result of a tool call (MCP content as JSON). || [`SpaceTransferReport`](/cua-sdk/reference/spaces/space#spacetransferreport-record) | record | Result of `Space.upload` / `Space.download`. |-| [`SpaceUsage`](/cua-sdk/reference/spaces/space#spaceusage-record) | record | Memory and storage use (`Space.usage`). |+| [`SpaceUsage`](/cua-sdk/reference/spaces/space#spaceusage-record) | record | Processor, memory and storage use (`Space.usage`). || [`SpaceWindow`](/cua-sdk/reference/spaces/space#spacewindow-record) | record | A streamable window. || [`SpaceWriteReport`](/cua-sdk/reference/spaces/space#spacewritereport-record) | record | Result of `Space.write`. || [`StorageVolume`](/cua-sdk/reference/cua#storagevolume-record) | record | Space on the volume a local engine writes to. |diff --git a/examples/streaming/rust/Cargo.lock b/examples/streaming/rust/Cargo.lockindex 6d5a1c8440..7049b7d6c3 100644--- a/examples/streaming/rust/Cargo.lock+++ b/examples/streaming/rust/Cargo.lock@@ -990,7 +990,7 @@ dependencies = ["num-traits","serde","wasm-bindgen",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -1594,6 +1594,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -1612,6 +1613,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -1619,6 +1621,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",@@ -2658,7 +2661,7 @@ dependencies = ["js-sys","log","wasm-bindgen",- "windows-core",+ "windows-core 0.58.0",][[package]]@@ -2953,7 +2956,7 @@ dependencies = ["simd_cesu8","thiserror 2.0.20","walkdir",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -3246,6 +3249,15 @@ dependencies = ["minimal-lexical",]+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "num-bigint"version = "0.4.8"@@ -3280,6 +3292,25 @@ dependencies = ["autocfg",]+[[package]]+name = "objc2-core-foundation"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"+dependencies = [+ "bitflags 2.13.2",+]++[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "oci-client"version = "0.18.0"@@ -3408,7 +3439,7 @@ dependencies = ["libc","redox_syscall","smallvec",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -4711,6 +4742,20 @@ dependencies = ["syn 3.0.6",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows",+]+[[package]]name = "tar"version = "0.4.46"@@ -5679,19 +5724,65 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"+[[package]]+name = "windows"+version = "0.61.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"+dependencies = [+ "windows-collections",+ "windows-core 0.61.2",+ "windows-future",+ "windows-link 0.1.3",+ "windows-numerics",+]++[[package]]+name = "windows-collections"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"+dependencies = [+ "windows-core 0.61.2",+]+[[package]]name = "windows-core"version = "0.58.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"dependencies = [- "windows-implement",- "windows-interface",- "windows-result",- "windows-strings",+ "windows-implement 0.58.0",+ "windows-interface 0.58.0",+ "windows-result 0.2.0",+ "windows-strings 0.1.0","windows-targets 0.52.6",]+[[package]]+name = "windows-core"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"+dependencies = [+ "windows-implement 0.60.2",+ "windows-interface 0.59.3",+ "windows-link 0.1.3",+ "windows-result 0.3.4",+ "windows-strings 0.4.2",+]++[[package]]+name = "windows-future"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+ "windows-threading",+]+[[package]]name = "windows-implement"version = "0.58.0"@@ -5703,6 +5794,17 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-implement"+version = "0.60.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]+[[package]]name = "windows-interface"version = "0.58.0"@@ -5714,12 +5816,39 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-interface"+version = "0.59.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "windows-link"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"+[[package]]name = "windows-link"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"+[[package]]+name = "windows-numerics"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+]+[[package]]name = "windows-result"version = "0.2.0"@@ -5729,16 +5858,34 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-result"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-strings"version = "0.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"dependencies = [- "windows-result",+ "windows-result 0.2.0","windows-targets 0.52.6",]+[[package]]+name = "windows-strings"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-sys"version = "0.52.0"@@ -5772,7 +5919,7 @@ version = "0.61.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5797,7 +5944,7 @@ version = "0.53.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"dependencies = [- "windows-link",+ "windows-link 0.2.1","windows_aarch64_gnullvm 0.53.1","windows_aarch64_msvc 0.53.1","windows_i686_gnu 0.53.1",@@ -5808,6 +5955,15 @@ dependencies = ["windows_x86_64_msvc 0.53.1",]+[[package]]+name = "windows-threading"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows_aarch64_gnullvm"version = "0.52.6"diff --git a/libs/cua-spacesd/crates/cua-relay/src/directory.rs b/libs/cua-spacesd/crates/cua-relay/src/directory.rsindex 74da81be63..49017472ef 100644--- a/libs/cua-spacesd/crates/cua-relay/src/directory.rs+++ b/libs/cua-spacesd/crates/cua-relay/src/directory.rs@@ -175,6 +175,11 @@ pub struct MachinePatch {/// Sharing switch.#[serde(default)]pub sharing: Option<bool>,+ /// Meta keys to set, merged into [`MachineRecord::meta`]: an empty+ /// value removes the key. The merged result is checked with+ /// [`clean_meta`].+ #[serde(default)]+ pub meta: Option<BTreeMap<String, String>>,}/// The directory.@@ -455,6 +460,17 @@ impl Directory {let mut records = self.records.lock().expect("directory");let mut next = records.clone();let record = next.get_mut(id).ok_or(DirectoryError::NotFound)?;+ if let Some(meta) = &patch.meta {+ let mut merged = record.meta.clone();+ for (k, v) in meta {+ if v.is_empty() {+ merged.remove(k);+ } else {+ merged.insert(k.clone(), v.clone());+ }+ }+ record.meta = clean_meta(merged)?;+ }if let Some(name) = &patch.name {let name = clean_name(name);if name.is_empty() {@@ -589,6 +605,62 @@ mod tests {}}+ #[test]+ fn a_patch_merges_meta_removes_empty_values_and_checks_the_result() {+ let dir = tempfile::tempdir().unwrap();+ let path = dir.path().join("dir.json");+ let d = Directory::open(path.clone(), 32).unwrap();+ let who = who("acct", None);+ d.register(&who, "machine-0001", Some("n"), None, true)+ .unwrap();+ d.set_meta(+ "machine-0001",+ BTreeMap::from([("cua.host.os".to_string(), "macos".to_string())]),+ )+ .unwrap();+ let patch = |meta: &[(&str, &str)]| MachinePatch {+ meta: Some(+ meta.iter()+ .map(|(k, v)| (k.to_string(), v.to_string()))+ .collect(),+ ),+ ..Default::default()+ };+ // New keys join what is there.+ let r = d+ .update("machine-0001", &patch(&[("cua.res", "{\"v\":1}")]))+ .unwrap();+ assert_eq!(r.meta.len(), 2);+ assert_eq!(r.meta["cua.host.os"], "macos");+ assert_eq!(r.meta["cua.res"], "{\"v\":1}");+ // A later value replaces the earlier one; the other key stays.+ let r = d+ .update("machine-0001", &patch(&[("cua.res", "{\"v\":2}")]))+ .unwrap();+ assert_eq!(r.meta["cua.res"], "{\"v\":2}");+ assert_eq!(r.meta["cua.host.os"], "macos");+ // An empty value removes the key.+ let r = d+ .update("machine-0001", &patch(&[("cua.res", "")]))+ .unwrap();+ assert!(!r.meta.contains_key("cua.res"));+ assert_eq!(r.meta["cua.host.os"], "macos");+ // Bad meta changes nothing.+ assert!(matches!(+ d.update("machine-0001", &patch(&[("Bad Key", "x")])),+ Err(DirectoryError::Invalid(_))+ ));+ assert!(matches!(+ d.update("machine-0001", &patch(&[("cua.res", &"x".repeat(257))])),+ Err(DirectoryError::Invalid(_))+ ));+ let again = Directory::open(path, 32).unwrap();+ assert_eq!(again.get("machine-0001").unwrap().meta, r.meta);+ // A patch without meta leaves it alone.+ let r = d.update("machine-0001", &MachinePatch::default()).unwrap();+ assert_eq!(r.meta, again.get("machine-0001").unwrap().meta);+ }+#[test]fn register_share_and_persist() {let dir = tempfile::tempdir().unwrap();diff --git a/libs/cua-spacesd/crates/cua-relay/tests/host_spaces.rs b/libs/cua-spacesd/crates/cua-relay/tests/host_spaces.rsindex 0c2da58208..60632ce616 100644--- a/libs/cua-spacesd/crates/cua-relay/tests/host_spaces.rs+++ b/libs/cua-spacesd/crates/cua-relay/tests/host_spaces.rs@@ -214,3 +214,68 @@ async fn machine_metadata_round_trips_and_is_checked() {.await;assert_eq!(s, StatusCode::NOT_FOUND, "nothing was registered");}++/// A machine's owner updates its meta with a PATCH (the resource summary a+/// computer publishes): keys are merged into what registration set, and a+/// machine token cannot do it.+#[tokio::test]+async fn the_owner_patches_machine_meta_and_it_merges() {+ let issuer = FakeIssuer::new(ISSUER);+ let base = start(&issuer, 14 * 86_400).await;+ let ada = issuer.token("ada", Some("[email protected]"), "cua-relay", 600);+ let bob = issuer.token("bob", Some("[email protected]"), "cua-relay", 600);+ let (s, v) = call(+ reqwest::Method::POST,+ format!("{base}/v1/machines"),+ &ada,+ Some(json!({"id": "machine-00000000aa", "name": "mini", "meta": {"cua.host.os": "macos"}})),+ )+ .await;+ assert_eq!(s, StatusCode::CREATED, "{v}");+ let machine_token = v["machine_token"].as_str().unwrap().to_owned();+ let url = format!("{base}/v1/machines/machine-00000000aa");+ let (s, v) = call(+ reqwest::Method::PATCH,+ url.clone(),+ &ada,+ Some(json!({"meta": {"cua.res": "{\"v\":1,\"c\":12}"}})),+ )+ .await;+ assert_eq!(s, StatusCode::OK, "{v}");+ assert_eq!(v["meta"]["cua.host.os"], "macos");+ assert_eq!(v["meta"]["cua.res"], "{\"v\":1,\"c\":12}");+ // Listings carry it.+ let (_, one) = call(reqwest::Method::GET, url.clone(), &ada, None).await;+ assert_eq!(one["meta"]["cua.res"], "{\"v\":1,\"c\":12}");+ // Bad meta is refused and changes nothing.+ let (s, _) = call(+ reqwest::Method::PATCH,+ url.clone(),+ &ada,+ Some(json!({"meta": {"Bad Key": "x"}})),+ )+ .await;+ assert_eq!(s, StatusCode::BAD_REQUEST);+ // Neither the machine itself nor another account may.+ let (s, _) = call(+ reqwest::Method::PATCH,+ url.clone(),+ &machine_token,+ Some(json!({"meta": {"cua.res": "x"}})),+ )+ .await;+ assert_eq!(s, StatusCode::FORBIDDEN);+ let (s, _) = call(+ reqwest::Method::PATCH,+ url.clone(),+ &bob,+ Some(json!({"meta": {"cua.res": "x"}})),+ )+ .await;+ assert!(+ s == StatusCode::NOT_FOUND || s == StatusCode::FORBIDDEN,+ "{s}"+ );+ let (_, after) = call(reqwest::Method::GET, url, &ada, None).await;+ assert_eq!(after["meta"]["cua.res"], "{\"v\":1,\"c\":12}");+}diff --git a/libs/cua-spacesd/tests/spaces-e2e/Cargo.lock b/libs/cua-spacesd/tests/spaces-e2e/Cargo.lockindex 313d666f65..fe6399dc78 100644--- a/libs/cua-spacesd/tests/spaces-e2e/Cargo.lock+++ b/libs/cua-spacesd/tests/spaces-e2e/Cargo.lock@@ -2538,6 +2538,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -2556,6 +2557,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -2563,6 +2565,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",diff --git a/libs/cua/Cargo.lock b/libs/cua/Cargo.lockindex f6bc9b3a12..e88c744b38 100644--- a/libs/cua/Cargo.lock+++ b/libs/cua/Cargo.lock@@ -1755,7 +1755,7 @@ dependencies = ["num-traits","serde","wasm-bindgen",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -2889,6 +2889,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -2907,6 +2908,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -2914,6 +2916,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","tempfile","thiserror 2.0.20",@@ -4221,7 +4224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"dependencies = ["rustix 1.1.5",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5087,7 +5090,7 @@ dependencies = ["simd_cesu8","thiserror 2.0.20","walkdir",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5317,7 +5320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"dependencies = ["cfg-if",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5716,6 +5719,15 @@ version = "0.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "nu-ansi-term"version = "0.50.3"@@ -6012,6 +6024,16 @@ dependencies = ["objc2-core-foundation",]+[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "objc2-local-authentication"version = "0.3.2"@@ -6329,7 +6351,7 @@ dependencies = ["libc","redox_syscall 0.5.18","smallvec",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -7440,7 +7462,7 @@ dependencies = ["errno 0.3.14","libc","linux-raw-sys 0.4.15",- "windows-sys 0.52.0",+ "windows-sys 0.59.0",][[package]]@@ -8272,6 +8294,20 @@ dependencies = ["syn 3.0.6",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows 0.61.3",+]+[[package]]name = "system-deps"version = "7.0.8"@@ -9888,16 +9924,38 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows"+version = "0.61.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"+dependencies = [+ "windows-collections 0.2.0",+ "windows-core 0.61.2",+ "windows-future 0.2.1",+ "windows-link 0.1.3",+ "windows-numerics 0.2.0",+]+[[package]]name = "windows"version = "0.62.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"dependencies = [- "windows-collections",+ "windows-collections 0.3.2","windows-core 0.62.2",- "windows-future",- "windows-numerics",+ "windows-future 0.3.2",+ "windows-numerics 0.3.1",+]++[[package]]+name = "windows-collections"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"+dependencies = [+ "windows-core 0.61.2",][[package]]@@ -9932,6 +9990,19 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-core"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"+dependencies = [+ "windows-implement 0.60.2",+ "windows-interface 0.59.3",+ "windows-link 0.1.3",+ "windows-result 0.3.4",+ "windows-strings 0.4.2",+]+[[package]]name = "windows-core"version = "0.62.2"@@ -9940,11 +10011,22 @@ checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"dependencies = ["windows-implement 0.60.2","windows-interface 0.59.3",- "windows-link",+ "windows-link 0.2.1","windows-result 0.4.1","windows-strings 0.5.1",]+[[package]]+name = "windows-future"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+ "windows-threading 0.1.0",+]+[[package]]name = "windows-future"version = "0.3.2"@@ -9952,8 +10034,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"dependencies = ["windows-core 0.62.2",- "windows-link",- "windows-threading",+ "windows-link 0.2.1",+ "windows-threading 0.2.1",][[package]]@@ -10000,12 +10082,28 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-link"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"+[[package]]name = "windows-link"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"+[[package]]+name = "windows-numerics"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+]+[[package]]name = "windows-numerics"version = "0.3.1"@@ -10013,7 +10111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"dependencies = ["windows-core 0.62.2",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -10034,13 +10132,22 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-result"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-result"version = "0.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -10053,13 +10160,22 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-strings"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-strings"version = "0.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -10113,7 +10229,7 @@ version = "0.61.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -10168,7 +10284,7 @@ version = "0.53.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"dependencies = [- "windows-link",+ "windows-link 0.2.1","windows_aarch64_gnullvm 0.53.1","windows_aarch64_msvc 0.53.1","windows_i686_gnu 0.53.1",@@ -10179,13 +10295,22 @@ dependencies = ["windows_x86_64_msvc 0.53.1",]+[[package]]+name = "windows-threading"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-threading"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]diff --git a/libs/cua/crates/cua-cli/src/host.rs b/libs/cua/crates/cua-cli/src/host.rsindex bbd48f5d12..d370d08a39 100644--- a/libs/cua/crates/cua-cli/src/host.rs+++ b/libs/cua/crates/cua-cli/src/host.rs@@ -223,14 +223,23 @@ pub enum SpacesCmd {/// Registered Spaces and your machines on the relay.#[command(visible_alias = "list",- after_help = "Examples:+ after_help = "CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it+uses now (the numbers the Cua Spaces app shows); for another of your+computers they show what it last reported. Numbers only: no file names.++Examples:cua spaces ls+ cua spaces ls --no-sizecua spaces ls --json")]Ls {/// Relay URL (default $CUA_RELAY_URL, else the CUA_ENV relay, https://relay.cua.ai in production).#[arg(long)]relay: Option<String>,+ /// Do not measure what each Space takes on this computer's disk+ /// (that walk can take a moment with many Spaces).+ #[arg(long)]+ no_size: bool,},/// Register a Space after a capabilities handshake with its cua-spacesd/// (or, for another URL, an MCP initialize). Re-adding an address@@ -1436,7 +1445,25 @@ pub async fn run_host(}HostCmd::Status => {let s = host.status().await.map_err(host_err)?;- emit(&s, json, out)?;+ // This Mac's processor, memory and disk, with or without setup.+ let resources = crate::resources_view::fetch(+ &cua_spaces::Spaces::builder().home(home).build(),+ true,+ )+ .await;+ if json {+ let status =+ serde_json::to_value(&s).map_err(|e| CuaError::Internal(e.to_string()))?;+ line(+ out,+ crate::resources_view::status_json(status, &resources).to_string(),+ );+ } else {+ render(&s, out);+ for l in crate::resources_view::this_mac_lines(&resources) {+ line(out, l);+ }+ }if !s.configured {return Ok(1);}@@ -1928,16 +1955,51 @@ fn ls_json(list: &[cua_spaces::SpaceInfo]) -> Vec<serde_json::Value> {/// `cua spaces ls` rows: every Space (its id, then its name as the apps/// show it), with the Spaces a machine provides indented under it (or,/// when that machine is not listed, marked with its name).+/// [`grouped_lines_with`] for the tests of `resources_view`.+#[cfg(test)]+pub(crate) fn grouped_lines_for_tests(+ list: &[cua_spaces::SpaceInfo],+ columns: Option<&crate::resources_view::Columns<'_>>,+) -> Vec<String> {+ grouped_lines_with(list, columns)+}++#[cfg(test)]fn grouped_lines(list: &[cua_spaces::SpaceInfo]) -> Vec<String> {+ grouped_lines_with(list, None)+}++/// [`grouped_lines`] with the CPU, MEMORY and DISK ON THIS MAC columns (and+/// their header) when `columns` is given.+fn grouped_lines_with(+ list: &[cua_spaces::SpaceInfo],+ columns: Option<&crate::resources_view::Columns<'_>>,+) -> Vec<String> {+ use crate::resources_view::{CPU_WIDTH, MEMORY_WIDTH};let row = |s: &cua_spaces::SpaceInfo, indent: &str| {- let line = format!(- "{indent}{:<width$} {:<24} {:<7} {}",- s.id,- display_name(s),- s.provider.as_str(),- s.spacesd_version,- width = 48usize.saturating_sub(indent.len()),- );+ let width = 48usize.saturating_sub(indent.len());+ let line = match columns {+ None => format!(+ "{indent}{:<width$} {:<24} {:<7} {}",+ s.id,+ display_name(s),+ s.provider.as_str(),+ s.spacesd_version,+ ),+ Some(c) => {+ let cells = c.cells(s);+ format!(+ "{indent}{:<width$} {:<24} {:<8} {:<9} {:<CPU_WIDTH$} {:<MEMORY_WIDTH$} {}",+ s.id,+ display_name(s),+ s.provider.as_str(),+ s.spacesd_version,+ cells.cpu,+ cells.memory,+ cells.disk,+ )+ }+ };// A Space turned off says so (`cua spaces start` turns it on), as// does a machine the relay cannot reach now (offline, not sharing).match (s.power_state.as_str(), s.status.as_str()) {@@ -1951,6 +2013,9 @@ fn grouped_lines(list: &[cua_spaces::SpaceInfo]) -> Vec<String> {}};let mut out = Vec::new();+ if columns.is_some() && !list.is_empty() {+ out.push(crate::resources_view::header(48));+ }for s in list.iter().filter(|s| s.host.is_empty()) {// A Space in your cloud names its cloud ("AWS · us-west-2").if s.host_name.is_empty() {@@ -2091,7 +2156,7 @@ pub async fn run_spaces(json: bool,out: &mut dyn Write,) -> Result<i32, CuaError> {- let SpacesCmd::Ls { relay } = cmd else {+ let SpacesCmd::Ls { relay, no_size } = cmd else {return Err(CuaError::Internal("only `cua spaces ls` runs over the registry directly".into(),));@@ -2115,22 +2180,40 @@ pub async fn run_spaces(.list().map_err(|e| CuaError::Internal(e.to_string()))?;power_from_daemon(&mut list).await;+ let resources = crate::resources_view::fetch(&spaces, !no_size).await;+ let columns = crate::resources_view::Columns {+ resources: &resources,+ own_machine: spaces.this_relay_machine_id(),+ };if json {- line(- out,- serde_json::json!({ "spaces": ls_json(&list), "relay_error": relay_error }).to_string(),- );+ let mut rows = ls_json(&list);+ for (row, info) in rows.iter_mut().zip(&list) {+ columns.annotate(info, row);+ }+ let mut body = serde_json::json!({ "spaces": rows, "relay_error": relay_error });+ if let (Some(o), Some(extra)) = (+ body.as_object_mut(),+ crate::resources_view::ls_extras(&resources)+ .as_object()+ .cloned(),+ ) {+ o.extend(extra);+ }+ line(out, body.to_string());return Ok(0);}if list.is_empty() {line(out, "No Spaces.");}- for l in grouped_lines(&list) {+ for l in grouped_lines_with(&list, Some(&columns)) {line(out, l);}if let Some(e) = relay_error {line(out, format!("(relay machines unavailable: {e})"));}+ if let Some(w) = columns.warning() {+ line(out, w);+ }Ok(0)}@@ -2640,13 +2723,18 @@ mod tests {let v: serde_json::Value = serde_json::from_slice(&out).unwrap();assert_eq!(v["configured"], true);assert_eq!(v["mode"], "relay");+ // This Mac's numbers ride along.+ assert!(v["resources"]["thisMac"]["memoryTotal"].as_u64().unwrap() > 0);let id = v["machineId"].as_str().unwrap().to_string();// `cua spaces ls` as the owner shows the machine.let mut out = Vec::new();// No --relay: the relay this machine joined.run_spaces(- SpacesCmd::Ls { relay: None },+ SpacesCmd::Ls {+ relay: None,+ no_size: false,+ },&home,Some(Arc::new(StaticToken("acct".into()))),None,@@ -2658,6 +2746,43 @@ mod tests {let text = String::from_utf8(out).unwrap();assert!(text.contains(&format!("relay:{id}")), "{text}");assert!(text.contains("lab-box") && text.contains("relay"), "{text}");+ // The new columns, and this machine's own row shows this Mac.+ assert!(text.starts_with("ID "), "{text}");+ for column in ["CPU", "MEMORY", "DISK ON THIS MAC"] {+ assert!(text.lines().next().unwrap().contains(column), "{text}");+ }+ let row = text.lines().find(|l| l.contains("lab-box")).unwrap();+ assert!(row.contains(" busy"), "{row}");+ assert!(row.contains(" free of "), "{row}");++ // `--json` carries the same numbers.+ let mut out = Vec::new();+ run_spaces(+ SpacesCmd::Ls {+ relay: None,+ no_size: true,+ },+ &home,+ Some(Arc::new(StaticToken("acct".into()))),+ None,+ true,+ &mut out,+ )+ .await+ .unwrap();+ let v: serde_json::Value = serde_json::from_slice(&out).unwrap();+ assert!(v["thisMac"]["cpuCount"].as_u64().unwrap() >= 1, "{v}");+ assert!(v["warning"]["level"].as_str().is_some(), "{v}");+ let own = v["spaces"]+ .as_array()+ .unwrap()+ .iter()+ .find(|s| s["id"] == format!("relay:{id}"))+ .unwrap();+ assert!(+ own["resources"]["memoryTotal"].as_u64().unwrap() > 0,+ "{own}"+ );let mut out = Vec::new();run_host(diff --git a/libs/cua/crates/cua-cli/src/lib.rs b/libs/cua/crates/cua-cli/src/lib.rsindex 5e76ed8aca..783277f4e3 100644--- a/libs/cua/crates/cua-cli/src/lib.rs+++ b/libs/cua/crates/cua-cli/src/lib.rs@@ -44,6 +44,7 @@ pub mod keyvault_cmd;mod mcp;mod persistent_cmd;mod providers;+mod resources_view;pub mod sandbox;mod shell;mod skills;@@ -1523,7 +1524,10 @@ async fn run(cli: Cli, out: &mut dyn Write) -> Result<i32, CuaError> {}) {let rest = Cli {- command: Command::Spaces(host::SpacesCmd::Ls { relay: None }),+ command: Command::Spaces(host::SpacesCmd::Ls {+ relay: None,+ no_size: false,+ }),..cli};host::turn_off_provided_spaces(&home, || open(&rest, false)).await;@@ -1605,7 +1609,10 @@ async fn run(cli: Cli, out: &mut dyn Write) -> Result<i32, CuaError> {| host::SpacesCmd::Start { .. });let rest = Cli {- command: Command::Spaces(host::SpacesCmd::Ls { relay: None }),+ command: Command::Spaces(host::SpacesCmd::Ls {+ relay: None,+ no_size: false,+ }),..cli};let cua = open(&rest, false).await?;@@ -1631,7 +1638,10 @@ async fn run(cli: Cli, out: &mut dyn Write) -> Result<i32, CuaError> {}Command::Cloud(cmd) => {let rest = Cli {- command: Command::Spaces(host::SpacesCmd::Ls { relay: None }),+ command: Command::Spaces(host::SpacesCmd::Ls {+ relay: None,+ no_size: false,+ }),..cli};let cua = open(&rest, false).await?;diff --git a/libs/cua/crates/cua-cli/src/resources_view.rs b/libs/cua/crates/cua-cli/src/resources_view.rsnew file mode 100644index 0000000000..4d31970ae9--- /dev/null+++ b/libs/cua/crates/cua-cli/src/resources_view.rs@@ -0,0 +1,428 @@+//! How `cua spaces ls` and `cua host status` show processor, memory and+//! disk: this Mac's numbers, each extra Space's, and your other computers'.+//! The words come from [`cua_spaces::resources::words`] (the Spaces apps use+//! the same ones); `--json` carries exact bytes.++use cua_proto::daemon::v1 as pb;+use cua_spaces::resources::{+ ComputerResources, DiskLevel, Measure, Resources, SpaceResources, words,+};+use cua_spaces::{SpaceInfo, Spaces};+use serde_json::{Value, json};+use std::time::Duration;++/// How long a command waits for the daemon's numbers before it measures+/// them itself.+const DAEMON_WAIT: Duration = Duration::from_secs(3);++/// The numbers a command shows. A running daemon answers from its shared+/// sampler (live guest numbers, nothing measured twice); without one this+/// reads allocations and disks itself and asks no guest anything, so the+/// command stays fast. `disk` false skips the disk measurement+/// (`--no-size`). Your other computers always come from `spaces`' machine+/// list (read it first with [`Spaces::relay_machines`]).+pub async fn fetch(spaces: &Spaces, disk: bool) -> Resources {+ let mut r = match from_daemon().await {+ Some(r) => r,+ None => {+ spaces+ .resources_now(Measure {+ disk,+ guests: false,+ })+ .await+ }+ };+ if !disk {+ for s in &mut r.spaces {+ s.disk_on_host = None;+ }+ }+ r.computers = spaces.other_computers();+ r+}++async fn from_daemon() -> Option<Resources> {+ cua_daemon::client::live_address()?;+ tokio::time::timeout(DAEMON_WAIT, async {+ let client = cua_daemon::client::existing_daemon().await.ok()?;+ let reply = client+ .spaces()+ .get_resources(pb::GetResourcesRequest { visible: false })+ .await+ .ok()?;+ reply.into_inner().snapshot.map(Resources::from)+ })+ .await+ .ok()+ .flatten()+}++/// The three extra cells of a row.+#[derive(Clone, Debug, PartialEq, Eq)]+pub struct Cells {+ /// CPU.+ pub cpu: String,+ /// MEMORY.+ pub memory: String,+ /// DISK ON THIS MAC.+ pub disk: String,+}++impl Cells {+ fn none() -> Self {+ Cells {+ cpu: "-".into(),+ memory: "-".into(),+ disk: "-".into(),+ }+ }++ fn of_space(s: &SpaceResources) -> Self {+ Cells {+ cpu: words::space_cpu(s),+ memory: words::space_memory(s),+ disk: words::space_disk(s),+ }+ }++ fn of_computer(c: &ComputerResources) -> Self {+ Cells {+ cpu: words::computer_cpu(c),+ memory: words::computer_memory(c),+ disk: words::computer_disk(c),+ }+ }+}++/// Column widths: the row's id column is the list's own.+pub const CPU_WIDTH: usize = 22;+/// Width of the MEMORY column.+pub const MEMORY_WIDTH: usize = 15;++/// The header of the table the extra columns make.+pub fn header(id_width: usize) -> String {+ format!(+ "{:<id_width$} {:<24} {:<8} {:<9} {:<CPU_WIDTH$} {:<MEMORY_WIDTH$} DISK ON THIS MAC",+ "ID", "NAME", "PROVIDER", "VERSION", "CPU", "MEMORY"+ )+}++/// What `cua spaces ls` shows next to each Space.+pub struct Columns<'a> {+ /// The numbers.+ pub resources: &'a Resources,+ /// This install's own relay machine id, so its row shows this Mac.+ pub own_machine: Option<String>,+}++impl Columns<'_> {+ /// The cells of `info`'s row: a local Space's, a relay machine's from+ /// its published summary (this Mac's own row from this Mac), else+ /// dashes.+ pub fn cells(&self, info: &SpaceInfo) -> Cells {+ if let Some(s) = self.resources.spaces.iter().find(|s| s.id == info.id) {+ return Cells::of_space(s);+ }+ let Some(machine) = info.id.strip_prefix("relay:") else {+ return Cells::none();+ };+ if self.own_machine.as_deref() == Some(machine) {+ return Cells::of_computer(&self.resources.this_mac);+ }+ self.resources+ .computers+ .iter()+ .find(|c| c.id == machine)+ .map(Cells::of_computer)+ .unwrap_or_else(Cells::none)+ }++ /// `row` with this Space's numbers: the JSON the Space already has plus+ /// `resources` (a local Space's [`SpaceResources`], a relay machine's+ /// [`ComputerResources`], else null), in the camelCase the apps read.+ pub fn annotate(&self, info: &SpaceInfo, row: &mut Value) {+ let Some(o) = row.as_object_mut() else { return };+ let machine = info.id.strip_prefix("relay:");+ let value = if let Some(s) = self.resources.spaces.iter().find(|s| s.id == info.id) {+ serde_json::to_value(s).ok()+ } else if machine.is_some() && machine == self.own_machine.as_deref() {+ serde_json::to_value(&self.resources.this_mac).ok()+ } else {+ machine+ .and_then(|m| self.resources.computers.iter().find(|c| c.id == m))+ .and_then(|c| serde_json::to_value(c).ok())+ };+ o.insert("resources".into(), value.unwrap_or(Value::Null));+ }++ /// The warning sentence when this Mac is low on disk.+ pub fn warning(&self) -> Option<&'static str> {+ words::warning(&self.resources.warning)+ }+}++/// The "This Mac" block of `cua host status`.+pub fn this_mac_lines(r: &Resources) -> Vec<String> {+ let m = &r.this_mac;+ let mut out = vec!["This Mac".to_string()];+ if m.cpu_count > 0 {+ out.push(format!(+ " Processor: {}",+ words::processor(m.cpu_count, Some(m.cpu_percent))+ ));+ }+ if m.memory_total > 0 {+ out.push(format!(+ " Memory: {}",+ words::memory_in_use(m.memory_used, m.memory_total)+ ));+ }+ if m.disk_total > 0 {+ out.push(format!(+ " Space for files: {}",+ words::disk_free(m.disk_free, m.disk_total)+ ));+ }+ if let Some(extra) = words::extra_spaces_use(m) {+ out.push(format!(" {extra}"));+ }+ if let Some(w) = words::warning(&m.warning) {+ out.push(format!(" {w}"));+ }+ out+}++/// `cua host status --json`: the status plus `resources`.+pub fn status_json(status: Value, r: &Resources) -> Value {+ let mut status = status;+ if let Some(o) = status.as_object_mut() {+ o.insert(+ "resources".into(),+ serde_json::to_value(r).unwrap_or(Value::Null),+ );+ }+ status+}++/// `cua spaces ls --json` fields next to the Spaces: this Mac and its+/// warning.+pub fn ls_extras(r: &Resources) -> Value {+ json!({+ "thisMac": r.this_mac,+ "warning": r.warning,+ "warningText": words::warning(&r.warning),+ "lowDisk": r.warning.level != DiskLevel::Ok,+ })+}++#[cfg(test)]+mod tests {+ use super::*;+ use cua_spaces::resources::{DiskOnHost, DiskWarning, GuestUsage, THIS_MAC};++ const GIB: u64 = 1 << 30;+ const TB: u64 = 1024 * GIB;++ fn info(id: &str) -> SpaceInfo {+ SpaceInfo {+ id: id.into(),+ name: id.into(),+ provider: if id.starts_with("relay:") {+ cua_spaces::Provider::Relay+ } else {+ cua_spaces::Provider::Local+ },+ spacesd_version: "0.10.0".into(),+ features: vec![],+ os: String::new(),+ os_name: String::new(),+ os_pretty_name: String::new(),+ image: String::new(),+ image_digest: String::new(),+ kind: String::new(),+ arch: String::new(),+ services: vec![],+ added_at: None,+ host: String::new(),+ host_name: String::new(),+ power: String::new(),+ power_state: String::new(),+ cloud: String::new(),+ cloud_place: String::new(),+ cloud_delete: String::new(),+ status: String::new(),+ stop_reason: String::new(),+ }+ }++ fn resources() -> Resources {+ let warning = DiskWarning::assess(300 * GIB, TB, 5 * GIB, DiskLevel::Ok);+ Resources {+ sequence: 1,+ sampled_at_ms: 1,+ this_mac: ComputerResources {+ id: THIS_MAC.into(),+ online: true,+ cpu_count: 12,+ cpu_percent: 38.0,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: TB,+ disk_free: 300 * GIB,+ spaces_count: 1,+ spaces_running: 1,+ spaces_cpu_allocated: 4,+ spaces_memory_allocated: 8 * GIB,+ spaces_disk_bytes: 31 * GIB,+ spaces_disk_exact: true,+ warning,+ ..Default::default()+ },+ spaces: vec![SpaceResources {+ id: "local:aurora".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_used: 3 * GIB + GIB / 10,+ memory_total: 8 * GIB,+ memory_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(DiskOnHost {+ bytes: Some(31 * GIB),+ allocated: 87 * GIB,+ shares_space: true,+ }),+ }],+ computers: vec![ComputerResources {+ id: "mini1234".into(),+ name: "Mac mini".into(),+ online: true,+ cpu_count: 10,+ cpu_percent: 5.0,+ memory_total: 32 * GIB,+ memory_used: 12 * GIB,+ disk_total: 512 * GIB,+ disk_free: 300 * GIB,+ ..Default::default()+ }],+ warning,+ }+ }++ #[test]+ fn each_row_gets_its_own_numbers() {+ let r = resources();+ let c = Columns {+ resources: &r,+ own_machine: Some("studio99".into()),+ };+ let local = c.cells(&info("local:aurora"));+ assert_eq!(local.cpu, "4 cores \u{b7} 22% busy");+ assert_eq!(local.memory, "3.1 of 8 GB");+ assert_eq!(local.disk, "about 31 GB, shares space with other copies");+ // Another computer: what it last reported.+ let mini = c.cells(&info("relay:mini1234"));+ assert_eq!(mini.cpu, "10 cores \u{b7} 5% busy");+ assert_eq!(mini.memory, "12 of 32 GB");+ assert_eq!(mini.disk, "300 GB free of 512 GB");+ // This install's own relay row is this Mac.+ let own = c.cells(&info("relay:studio99"));+ assert_eq!(own.cpu, "12 cores \u{b7} 38% busy");+ assert_eq!(own.disk, "300 GB free of 1 TB");+ // A machine that published nothing, and a Space added by address.+ assert_eq!(c.cells(&info("relay:nobody")), Cells::none());+ assert_eq!(c.cells(&info("direct:10.0.0.5:3211")), Cells::none());+ }++ #[test]+ fn the_header_lines_up_with_the_rows() {+ let h = header(48);+ let r = resources();+ let c = Columns {+ resources: &r,+ own_machine: None,+ };+ let lines = crate::host::grouped_lines_for_tests(&[info("local:aurora")], Some(&c));+ // Every column starts where its header does.+ let row = &lines[1];+ for column in [+ "NAME",+ "PROVIDER",+ "VERSION",+ "CPU",+ "MEMORY",+ "DISK ON THIS MAC",+ ] {+ let at = h.find(column).unwrap();+ assert!(at > 0);+ assert_eq!(row.as_bytes()[at - 1], b' ', "{column}: {h}\n{row}");+ }+ assert!(row.contains("4 cores"), "{row}");+ assert_eq!(lines[0], h);+ }++ #[test]+ fn json_rows_carry_the_numbers_in_camel_case() {+ let r = resources();+ let c = Columns {+ resources: &r,+ own_machine: None,+ };+ let mut row = json!({"id": "local:aurora"});+ c.annotate(&info("local:aurora"), &mut row);+ assert_eq!(row["resources"]["cpuAllocated"], 4);+ assert_eq!(row["resources"]["usage"]["cpuPercent"], 22.0);+ assert_eq!(row["resources"]["diskOnHost"]["bytes"], 31 * GIB);+ let mut row = json!({"id": "relay:mini1234"});+ c.annotate(&info("relay:mini1234"), &mut row);+ assert_eq!(row["resources"]["name"], "Mac mini");+ let mut row = json!({"id": "direct:1"});+ c.annotate(&info("direct:1"), &mut row);+ assert_eq!(row["resources"], Value::Null);+ let extras = ls_extras(&r);+ assert_eq!(extras["thisMac"]["cpuCount"], 12);+ assert_eq!(extras["warning"]["level"], "ok");+ assert_eq!(extras["lowDisk"], false);+ }++ #[test]+ fn this_mac_in_words() {+ let r = resources();+ assert_eq!(+ this_mac_lines(&r),+ [+ "This Mac",+ " Processor: 12 cores \u{b7} 38% busy",+ " Memory: 41 of 64 GB in use",+ " Space for files: 300 GB free of 1 TB",+ " Your extra Spaces use: 4 cores, 8 GB of memory, about 31 GB for files.",+ ]+ );+ let mut low = resources();+ low.this_mac.warning = DiskWarning::assess(10 * GIB, TB, 5 * GIB, DiskLevel::Ok);+ let lines = this_mac_lines(&low);+ assert_eq!(+ lines.last().unwrap(),+ " This Mac is almost out of space. Delete old Spaces or snapshots."+ );+ let c = Columns {+ resources: &low,+ own_machine: None,+ };+ assert_eq!(c.warning(), None, "uses the snapshot's own warning");+ }++ #[test]+ fn status_json_gains_resources() {+ let v = status_json(json!({"configured": true}), &resources());+ assert_eq!(v["configured"], true);+ assert_eq!(v["resources"]["thisMac"]["memoryTotal"], 64 * GIB);+ assert_eq!(v["resources"]["spaces"][0]["id"], "local:aurora");+ }+}diff --git a/libs/cua/crates/cua-daemon/src/server.rs b/libs/cua/crates/cua-daemon/src/server.rsindex f1cac6c9c2..9742ee5fab 100644--- a/libs/cua/crates/cua-daemon/src/server.rs+++ b/libs/cua/crates/cua-daemon/src/server.rs@@ -282,6 +282,11 @@ pub async fn start(runtime: Runtime, config: ServerConfig) -> Result<DaemonHandl// (the Spaces apps' notch and previews, SDK scripts); idle otherwise.#[cfg(feature = "spaces")]let _thumbnails = runtime.spaces().spawn_thumbnail_refresh();+ // This computer's processor, memory and disk, sampled every five+ // minutes while nobody watches (the menu bar warning), and published+ // into its relay machine record when it is one.+ #[cfg(feature = "spaces")]+ let _resources = runtime.spaces().spawn_resources_publisher();// A local Space that stops on its own (out of memory, a crash) is// recorded as stopped, and why, for every client.let _stop_watch = runtime.sandboxes().spawn_stop_watch();diff --git a/libs/cua/crates/cua-daemon/src/spaces_svc.rs b/libs/cua/crates/cua-daemon/src/spaces_svc.rsindex 7c9da9c766..f8b5d60739 100644--- a/libs/cua/crates/cua-daemon/src/spaces_svc.rs+++ b/libs/cua/crates/cua-daemon/src/spaces_svc.rs@@ -564,6 +564,52 @@ mod imp {captured_at: Some(crate::convert::ts(t.captured_at)),})}++ async fn get_resources(+ &self,+ req: tonic::Request<pb::GetResourcesRequest>,+ ) -> R<pb::GetResourcesResponse> {+ let snapshot = self+ .spaces()+ .resources(req.into_inner().visible)+ .await+ .map_err(|e| st(e.into()))?;+ ok(pb::GetResourcesResponse {+ snapshot: Some((&snapshot).into()),+ })+ }++ type WatchResourcesStream = std::pin::Pin<+ Box<+ dyn tokio_stream::Stream<+ Item = std::result::Result<pb::WatchResourcesResponse, tonic::Status>,+ > + Send,+ >,+ >;++ async fn watch_resources(+ &self,+ req: tonic::Request<pb::WatchResourcesRequest>,+ ) -> R<Self::WatchResourcesStream> {+ let mut watch = self.spaces().watch_resources(req.into_inner().visible);+ let (tx, rx) = tokio::sync::mpsc::channel(8);+ // The watch is the interest: it ends with the stream, so the+ // sampler stops when the last reader is gone.+ tokio::spawn(async move {+ loop {+ tokio::select! {+ event = watch.next() => {+ let Some(event) = event else { break };+ if tx.send(Ok((&event).into())).await.is_err() {+ break;+ }+ }+ _ = tx.closed() => break,+ }+ }+ });+ ok(Box::pin(tokio_stream::wrappers::ReceiverStream::new(rx)))+ }}}@@ -680,5 +726,26 @@ mod imp {) -> R<pb::GetSpaceThumbnailResponse> {off()}+ async fn get_resources(+ &self,+ _: tonic::Request<pb::GetResourcesRequest>,+ ) -> R<pb::GetResourcesResponse> {+ off()+ }++ type WatchResourcesStream = std::pin::Pin<+ Box<+ dyn tokio_stream::Stream<+ Item = std::result::Result<pb::WatchResourcesResponse, tonic::Status>,+ > + Send,+ >,+ >;++ async fn watch_resources(+ &self,+ _: tonic::Request<pb::WatchResourcesRequest>,+ ) -> R<Self::WatchResourcesStream> {+ off()+ }}}diff --git a/libs/cua/crates/cua-daemon/tests/resources.rs b/libs/cua/crates/cua-daemon/tests/resources.rsnew file mode 100644index 0000000000..4aa42db09a--- /dev/null+++ b/libs/cua/crates/cua-daemon/tests/resources.rs@@ -0,0 +1,102 @@+//! `SpaceService.GetResources` and `WatchResources` over the daemon's+//! loopback listener: this Mac's numbers as one snapshot, then a stream+//! that starts with a snapshot and ends with the client. Temp dirs only.++use cua_daemon::client::{DaemonAddress, DaemonClient};+use cua_daemon::server::{DaemonHandle, ServerConfig, start};+use cua_daemon::{Runtime as DaemonRuntime, RuntimeConfig};+use cua_proto::daemon::v1 as pb;+use pb::watch_resources_response::Event;+use std::time::Duration;++async fn daemon(dir: &std::path::Path) -> (DaemonRuntime, DaemonHandle, DaemonClient) {+ let runtime = DaemonRuntime::new(RuntimeConfig {+ state_dir: Some(dir.join("sandboxes")),+ spaces_home: Some(dir.to_path_buf()),+ ..Default::default()+ })+ .unwrap();+ let handle = start(+ runtime.clone(),+ ServerConfig {+ socket_path: None,+ loopback: Some(([127, 0, 0, 1], 0).into()),+ token: "t0k3n".into(),+ discovery_path: None,+ bridge_ticket_ttl: Duration::from_secs(60),+ },+ )+ .await+ .unwrap();+ let client = DaemonClient::new(DaemonAddress::Url {+ url: handle.loopback_url.clone().unwrap(),+ token: handle.token.clone(),+ })+ .unwrap();+ (runtime, handle, client)+}++#[tokio::test]+async fn the_daemon_serves_this_macs_numbers() {+ let dir = tempfile::tempdir().unwrap();+ let (_runtime, handle, client) = daemon(dir.path()).await;+ let r = client+ .spaces()+ .get_resources(pb::GetResourcesRequest { visible: false })+ .await+ .unwrap()+ .into_inner()+ .snapshot+ .expect("a snapshot");+ let mac = r.this_mac.expect("this Mac");+ assert_eq!(mac.id, "this-mac");+ assert!(mac.online);+ assert!(mac.cpu_count >= 1);+ assert!(mac.memory_total > 0 && mac.memory_used <= mac.memory_total);+ assert!(mac.disk_total > 0 && mac.disk_free <= mac.disk_total);+ assert!((0.0..=100.0).contains(&mac.cpu_percent));+ assert!(r.spaces.is_empty());+ let level = r.warning.expect("a warning level").level;+ assert!(["ok", "low", "critical"].contains(&level.as_str()));+ // The same sample again within a few seconds.+ let again = client+ .spaces()+ .get_resources(pb::GetResourcesRequest { visible: true })+ .await+ .unwrap()+ .into_inner()+ .snapshot+ .unwrap();+ assert_eq!(again.sequence, r.sequence);+ handle.shutdown();+}++#[tokio::test]+async fn a_watch_streams_a_snapshot_first_and_stops_with_the_client() {+ let dir = tempfile::tempdir().unwrap();+ let (runtime, handle, client) = daemon(dir.path()).await;+ let mut stream = client+ .spaces()+ .watch_resources(pb::WatchResourcesRequest { visible: true })+ .await+ .unwrap()+ .into_inner();+ let first = tokio::time::timeout(Duration::from_secs(10), stream.message())+ .await+ .expect("an event arrives")+ .unwrap()+ .expect("the stream is open");+ match first.event {+ Some(Event::Snapshot(s)) => {+ assert!(s.this_mac.unwrap().cpu_count >= 1);+ assert_eq!(s.spaces.len(), 0);+ }+ other => panic!("the first event is a snapshot, got {other:?}"),+ }+ drop(stream);+ // The client left: the watch is gone, so a hidden poll still answers+ // and nothing keeps sampling for a window.+ tokio::time::sleep(Duration::from_millis(200)).await;+ assert!(runtime.spaces().resources(false).await.is_ok());+ handle.shutdown();+}diff --git a/libs/cua/crates/cua-host/src/host.rs b/libs/cua/crates/cua-host/src/host.rsindex 560f9e2b7e..bc3bd66c7f 100644--- a/libs/cua/crates/cua-host/src/host.rs+++ b/libs/cua/crates/cua-host/src/host.rs@@ -1573,6 +1573,7 @@ impl Host {allow: allow.clone(),viewers: None,sharing: None,+ meta: None,},).await?;diff --git a/libs/cua/crates/cua-host/src/relay.rs b/libs/cua/crates/cua-host/src/relay.rsindex 67eef3df26..04632de9cd 100644--- a/libs/cua/crates/cua-host/src/relay.rs+++ b/libs/cua/crates/cua-host/src/relay.rs@@ -235,6 +235,10 @@ pub struct MachinePatch {/// Sharing on/off.#[serde(skip_serializing_if = "Option::is_none")]pub sharing: Option<bool>,+ /// Meta keys to set (merged into the machine's [`Machine::meta`]; an+ /// empty value removes the key). Older relays ignore it.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub meta: Option<std::collections::BTreeMap<String, String>>,}/// `GET /v1/info`.diff --git a/libs/cua/crates/cua-host/src/testing.rs b/libs/cua/crates/cua-host/src/testing.rsindex be8098c7f3..5bac622619 100644--- a/libs/cua/crates/cua-host/src/testing.rs+++ b/libs/cua/crates/cua-host/src/testing.rs@@ -78,6 +78,8 @@ struct State_ {/// Every machine read answers 503, as the proxy in front of the/// relay does while it has no backend.reads_down: bool,+ /// A relay that predates meta patches: the key is ignored.+ ignore_meta_patches: bool,/// Machine registrations received (including refused ones).register_calls: usize,/// machine id → `(path prefix, base URL)` its `/m/<id>/…` gRPC-Web@@ -581,6 +583,20 @@ async fn patch(rec.machine.clients.clear();}}+ let ignore_meta = st.ignore_meta_patches;+ let rec = st.machines.get_mut(&id).unwrap();+ if let Some(meta) = body["meta"].as_object().filter(|_| !ignore_meta) {+ for (k, v) in meta {+ match v.as_str() {+ Some("") | None => {+ rec.machine.meta.remove(k);+ }+ Some(v) => {+ rec.machine.meta.insert(k.clone(), v.to_string());+ }+ }+ }+ }Json(rec.machine.clone()).into_response()}@@ -1210,6 +1226,12 @@ impl FakeRelay {self.state.lock().unwrap().reads_down = down;}+ /// While `on`, a PATCH with `meta` is accepted but its keys are+ /// dropped, as a relay that predates them does.+ pub fn set_ignore_meta_patches(&self, on: bool) {+ self.state.lock().unwrap().ignore_meta_patches = on;+ }+/// Machine registrations received so far (refused ones too).pub fn register_calls(&self) -> usize {self.state.lock().unwrap().register_callsdiff --git a/libs/cua/crates/cua-proto/build.rs b/libs/cua/crates/cua-proto/build.rsindex 0388444d69..2f85295543 100644--- a/libs/cua/crates/cua-proto/build.rs+++ b/libs/cua/crates/cua-proto/build.rs@@ -26,6 +26,7 @@ const PROTOS: &[&str] = &["cua/env/v1/host.proto","cua/daemon/v1/sandboxes.proto","cua/daemon/v1/spaces.proto",+ "cua/daemon/v1/resources.proto","cua/daemon/v1/runtime.proto","cua/daemon/v1/daemon.proto",];diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rsindex 3dca7bef87..08067f520f 100644--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs@@ -120,6 +120,8 @@ pub const SPACES_SDK_ONLY_METHODS: &[&str] = &["Spaces.space","Spaces.list_tools_json","Spaces.call_tool_json",+ "Spaces.resources",+ "Spaces.watch_resources","Space.home","Space.screenshot","Space.close_stream",@@ -815,11 +817,23 @@ pub struct SpaceWindow {pub limitation: String,}-/// Memory and storage use ([`Space::usage`]). A size is the guest's own-/// limit only when its `*_limited` flag says so (a VM's memory or disk, a-/// container's cgroup memory limit).-#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Record, Deserialize)]+/// Processor, memory and storage use ([`Space::usage`]). A size is the+/// guest's own limit only when its `*_limited` flag says so (a VM's memory+/// or disk, a container's cgroup memory limit).+#[derive(Debug, Clone, Copy, PartialEq, uniffi::Record, Deserialize)]pub struct SpaceUsage {+ /// Cores the guest sees (0 from a guest that does not report it).+ #[uniffi(default = 0)]+ #[serde(default)]+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ #[uniffi(default = 0.0)]+ #[serde(default)]+ pub cpu_percent: f64,+ /// 1-minute load average.+ #[uniffi(default = 0.0)]+ #[serde(default)]+ pub load_average_1m: f64,/// Memory in use, bytes.pub memory_used: u64,/// Memory size, bytes.@@ -2039,6 +2053,11 @@ impl ToolOut {}}+// The resource records and watch live in `spaces_resources.rs` (the docs+// generators read `native/*.rs`), included here so they share this module's+// private `Host` and `daemon_err`.+include!("spaces_resources.rs");+/// Where the Spaces runtime lives.#[derive(Clone)]enum Host {@@ -3237,8 +3256,8 @@ impl Space {run(async move { Ok(s.window_thumbnail(&window_id, epoch, max_dimension).await?) }).await}- /// Memory and storage use now (cheap: poll it at a low rate while a- /// detail is visible).+ /// Processor, memory and storage use now (cheap: poll it at a low rate+ /// while a detail is visible).pub async fn usage(&self) -> Result<SpaceUsage> {let s = self.inner.clone();run(async move { via_json(&s.usage().await?) }).awaitdiff --git a/libs/cua/crates/cua-sdk/src/native/spaces_resources.rs b/libs/cua/crates/cua-sdk/src/native/spaces_resources.rsnew file mode 100644index 0000000000..26873ab5ef--- /dev/null+++ b/libs/cua/crates/cua-sdk/src/native/spaces_resources.rs@@ -0,0 +1,525 @@+// What this Mac, its extra Spaces and your other computers use: processor,+// memory and disk (`Spaces.resources`, `Spaces.watch_resources`).+//+// The numbers are measured once, by the runtime that owns the Spaces (the+// daemon, or this process when embedded), so every window and the menu bar+// read the same sample. Numbers only: counts, bytes and percentages.++/// How low the free disk is.+#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum DiskLevel {+ /// Plenty.+ Ok,+ /// Under 50 GB or 15% of the volume, whichever line is higher (the+ /// line never rises above 100 GB).+ Low,+ /// Under the floor where creating a Space already fails (5 GiB).+ Critical,+}++/// The low-disk signal for the app and the menu bar.+#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct DiskWarning {+ /// How low it is.+ pub level: DiskLevel,+ /// Free bytes on the volume that holds Spaces.+ pub free: u64,+ /// Size of that volume.+ pub total: u64,+ /// The line that was crossed (0 when `ok`).+ pub threshold: u64,+}++/// A computer: this Mac, or one of your other computers (from the summary+/// it published).+#[derive(Debug, Clone, PartialEq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ComputerResources {+ /// `this-mac`, or the relay machine id.+ pub id: String,+ /// Display name (empty for this Mac).+ pub name: String,+ /// Reachable now (always true for this Mac).+ pub online: bool,+ /// When the computer measured this, unix ms (another computer's can be+ /// minutes old).+ pub sampled_at_ms: u64,+ /// Processor cores.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// Memory in use, bytes (without reclaimable cache).+ pub memory_used: u64,+ /// Size of the volume that holds Spaces, bytes.+ pub disk_total: u64,+ /// Free bytes on it.+ pub disk_free: u64,+ /// Extra Spaces on it.+ pub spaces_count: u32,+ /// Of those, running.+ pub spaces_running: u32,+ /// Cores given to the running ones.+ pub spaces_cpu_allocated: u32,+ /// Memory given to the running ones, bytes.+ pub spaces_memory_allocated: u64,+ /// Memory the running guests report in use, bytes.+ pub spaces_memory_used: u64,+ /// Bytes all its extra Spaces take on it.+ pub spaces_disk_bytes: u64,+ /// False when some Space's disk could only be estimated.+ pub spaces_disk_exact: bool,+ /// The low-disk signal.+ pub warning: DiskWarning,+}++/// What `SystemService.Metrics` reports from inside a Space.+#[derive(Debug, Clone, Copy, PartialEq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct GuestUsage {+ /// Cores the guest sees.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// `memory_total` is the guest's own limit.+ pub memory_limited: bool,+ /// Disk in use, bytes.+ pub disk_used: u64,+ /// Disk size, bytes.+ pub disk_total: u64,+ /// `disk_total` is the guest's own disk.+ pub disk_limited: bool,+}++/// What a Space costs this computer's disk, as opposed to what the guest+/// sees.+#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct DiskOnHost {+ /// Bytes only this Space holds (what deleting it frees); absent when+ /// they could not be measured.+ pub bytes: Option<u64>,+ /// Blocks its files occupy, clones counted in full: an upper bound.+ pub allocated: u64,+ /// Part of it is shared with other copies.+ pub shares_space: bool,+}++/// One extra Space on this Mac.+#[derive(Debug, Clone, PartialEq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct SpaceResources {+ /// `local:<name>`.+ pub id: String,+ /// `running`, `stopped`, `suspended`, or empty when unknown.+ pub power_state: String,+ /// Cores given to it (0: unknown).+ pub cpu_allocated: u32,+ /// Memory given to it, bytes (0: unknown).+ pub memory_allocated: u64,+ /// Its disk's size limit, bytes (0: unknown).+ pub disk_allocated: u64,+ /// The guest's own numbers; absent while it is off or unreachable.+ pub usage: Option<GuestUsage>,+ /// What it costs this Mac; absent for a container.+ pub disk_on_host: Option<DiskOnHost>,+}++/// One sample of everything.+#[derive(Debug, Clone, PartialEq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ResourcesSnapshot {+ /// Grows by one per sample.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac.+ pub this_mac: ComputerResources,+ /// Extra Spaces on this Mac.+ pub spaces: Vec<SpaceResources>,+ /// Your other computers, from the summaries they published.+ pub computers: Vec<ComputerResources>,+ /// `this_mac.warning`, for the menu bar.+ pub warning: DiskWarning,+}++/// What changed since the last event: only entries that moved by more than+/// 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+#[derive(Debug, Clone, PartialEq, uniffi::Record, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ResourcesUpdate {+ /// The sample it brings you to.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac, when it changed.+ pub this_mac: Option<ComputerResources>,+ /// Extra Spaces that changed or appeared.+ pub spaces: Vec<SpaceResources>,+ /// Other computers that changed or appeared.+ pub computers: Vec<ComputerResources>,+ /// Ids (Spaces or computers) that are gone.+ pub removed: Vec<String>,+}++/// What [`Spaces::watch_resources`] reports.+#[derive(Debug, Clone, PartialEq, uniffi::Enum)]+pub enum ResourcesEvent {+ /// Everything, at the start (and again after a reconnect).+ Snapshot {+ /// The sample.+ snapshot: ResourcesSnapshot,+ },+ /// Only what changed.+ Update {+ /// The changes.+ update: ResourcesUpdate,+ },+ /// The low-disk level changed (including back to `ok`).+ LowDisk {+ /// The warning now.+ warning: DiskWarning,+ },+}++/// Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+/// Called on an SDK worker thread; return quickly.+#[uniffi::export(with_foreign)]+pub trait ResourcesListener: Send + Sync {+ /// Something moved.+ fn on_event(&self, event: ResourcesEvent);+}++/// A running [`Spaces::watch_resources`]: tell it whether a window shows+/// the numbers, and stop it when done. Dropping it also stops it.+#[derive(uniffi::Object)]+pub struct ResourcesWatch {+ control: tokio::sync::watch::Sender<Control>,+ task: std::sync::Mutex<Option<tokio::task::JoinHandle<()>>>,+}++#[derive(Clone, Copy)]+struct Control {+ visible: bool,+ stopped: bool,+}++#[uniffi::export]+impl ResourcesWatch {+ /// Whether a window shows the numbers: visible watchers are sampled+ /// every 10 seconds, hidden ones every 5 minutes (and still hear+ /// `LowDisk`, for the menu bar).+ pub fn set_visible(&self, visible: bool) {+ self.control.send_modify(|c| c.visible = visible);+ }++ /// Ends the watch. No event is delivered after this returns.+ pub fn stop(&self) {+ self.control.send_modify(|c| c.stopped = true);+ if let Some(t) = self.task.lock().expect("watch task").take() {+ t.abort();+ }+ }+}++impl Drop for ResourcesWatch {+ fn drop(&mut self) {+ self.stop();+ }+}++/// A runtime value as the SDK's record (same JSON, same names).+fn record<T: serde::de::DeserializeOwned>(v: &impl serde::Serialize) -> Result<T> {+ serde_json::to_value(v)+ .and_then(serde_json::from_value)+ .map_err(|e| CuaError::Internal(e.to_string()))+}++/// A snapshot as the SDK's record.+pub(crate) fn snapshot_of(r: &cua_spaces::resources::Resources) -> Result<ResourcesSnapshot> {+ record(r)+}++fn event_of(e: &cua_spaces::resources::ResourcesEvent) -> Result<ResourcesEvent> {+ use cua_spaces::resources::ResourcesEvent as E;+ Ok(match e {+ E::Snapshot(s) => ResourcesEvent::Snapshot {+ snapshot: record(s)?,+ },+ E::Update(u) => ResourcesEvent::Update { update: record(u)? },+ E::LowDisk(w) => ResourcesEvent::LowDisk {+ warning: record(w)?,+ },+ })+}++/// How long a dropped daemon stream waits before it is opened again.+const REOPEN_AFTER: Duration = Duration::from_secs(5);++#[uniffi::export]+impl Spaces {+ /// What this Mac, its extra Spaces and your other computers use now:+ /// processor, memory and disk, as one snapshot (a few seconds old at+ /// most). With `visible`, the call also says a window shows the numbers+ /// for the next 30 seconds, so the runtime samples every 10 seconds+ /// instead of every 5 minutes: call it every 10 seconds while a window+ /// is visible and stop when it is hidden.+ pub async fn resources(&self, visible: bool) -> Result<ResourcesSnapshot> {+ let host = self.host.clone();+ run(async move {+ let r = match &host {+ Host::Embedded(s) => s.resources(visible).await?,+ Host::Daemon(d) => d+ .spaces()+ .get_resources(dpb::GetResourcesRequest { visible })+ .await+ .map_err(daemon_err)?+ .into_inner()+ .snapshot+ .map(cua_spaces::resources::Resources::from)+ .ok_or_else(|| CuaError::Internal("the daemon sent no snapshot".into()))?,+ };+ snapshot_of(&r)+ })+ .await+ }++ /// The same numbers as events for `listener`: a snapshot first, then an+ /// update with only the entries that changed by more than 1 point or+ /// 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ /// itself if the daemon restarts (the snapshot comes again). Stop it+ /// with [`ResourcesWatch::stop`].+ pub fn watch_resources(+ &self,+ visible: bool,+ listener: Arc<dyn ResourcesListener>,+ ) -> Arc<ResourcesWatch> {+ let (control, rx) = tokio::sync::watch::channel(Control {+ visible,+ stopped: false,+ });+ let host = self.host.clone();+ let task = super::runtime().spawn(async move {+ match host {+ Host::Embedded(s) => embedded_watch(s, rx, listener).await,+ Host::Daemon(d) => daemon_watch(d, rx, listener).await,+ }+ });+ Arc::new(ResourcesWatch {+ control,+ task: std::sync::Mutex::new(Some(task)),+ })+ }+}++async fn embedded_watch(+ spaces: cua_spaces::Spaces,+ mut control: tokio::sync::watch::Receiver<Control>,+ listener: Arc<dyn ResourcesListener>,+) {+ let mut watch = spaces.watch_resources(control.borrow().visible);+ loop {+ tokio::select! {+ event = watch.next() => {+ let Some(event) = event else { return };+ if let Ok(e) = event_of(&event) {+ listener.on_event(e);+ }+ }+ changed = control.changed() => {+ if changed.is_err() || control.borrow().stopped {+ return;+ }+ watch.set_visible(control.borrow().visible);+ }+ }+ }+}++async fn daemon_watch(+ daemon: cua_daemon::client::DaemonClient,+ mut control: tokio::sync::watch::Receiver<Control>,+ listener: Arc<dyn ResourcesListener>,+) {+ use dpb::watch_resources_response::Event;+ loop {+ let visible = control.borrow().visible;+ let opened = daemon+ .spaces()+ .watch_resources(dpb::WatchResourcesRequest { visible })+ .await;+ let mut stream = match opened {+ Ok(s) => s.into_inner(),+ Err(_) => {+ // A daemon that is not up, or predates this: try again.+ tokio::select! {+ _ = tokio::time::sleep(REOPEN_AFTER) => continue,+ changed = control.changed() => {+ if changed.is_err() || control.borrow().stopped {+ return;+ }+ continue;+ }+ }+ }+ };+ loop {+ tokio::select! {+ msg = stream.message() => match msg {+ Ok(Some(m)) => {+ let event = match m.event {+ Some(Event::Snapshot(s)) => {+ event_of(&cua_spaces::resources::ResourcesEvent::Snapshot(s.into()))+ }+ Some(Event::Update(u)) => {+ event_of(&cua_spaces::resources::ResourcesEvent::Update(u.into()))+ }+ Some(Event::LowDisk(w)) => {+ event_of(&cua_spaces::resources::ResourcesEvent::LowDisk(w.into()))+ }+ None => continue,+ };+ if let Ok(e) = event {+ listener.on_event(e);+ }+ }+ // The daemon ended the stream or went away.+ Ok(None) | Err(_) => break,+ },+ changed = control.changed() => {+ if changed.is_err() || control.borrow().stopped {+ return;+ }+ // The visibility changed: the server takes it as a new+ // call (the snapshot comes again).+ if control.borrow().visible != visible {+ break;+ }+ }+ }+ }+ // Reopen (at once for a visibility change, after a pause when the+ // daemon went away).+ if control.borrow().visible == visible {+ tokio::time::sleep(REOPEN_AFTER).await;+ }+ }+}++#[cfg(test)]+mod resources_tests {+ use super::*;+ use cua_spaces::resources as core;++ fn core_snapshot() -> core::Resources {+ let warning = core::DiskWarning {+ level: core::DiskLevel::Low,+ free: 90 << 30,+ total: 1 << 40,+ threshold: 100 << 30,+ };+ core::Resources {+ sequence: 4,+ sampled_at_ms: 99,+ this_mac: core::ComputerResources {+ id: "this-mac".into(),+ online: true,+ cpu_count: 12,+ cpu_percent: 38.5,+ memory_total: 64 << 30,+ memory_used: 41 << 30,+ disk_total: 1 << 40,+ disk_free: 90 << 30,+ spaces_count: 1,+ warning,+ ..Default::default()+ },+ spaces: vec![core::SpaceResources {+ id: "local:a".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 << 30,+ disk_allocated: 80 << 30,+ usage: Some(core::GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(core::DiskOnHost {+ bytes: None,+ allocated: 31 << 30,+ shares_space: true,+ }),+ }],+ computers: vec![],+ warning,+ }+ }++ #[test]+ fn the_sdk_records_carry_every_field_of_the_snapshot() {+ let r = core_snapshot();+ let s = snapshot_of(&r).unwrap();+ assert_eq!(s.sequence, 4);+ assert_eq!(s.this_mac.cpu_count, 12);+ assert_eq!(s.this_mac.warning.level, DiskLevel::Low);+ assert_eq!(s.warning.threshold, 100 << 30);+ let space = &s.spaces[0];+ assert_eq!(space.id, "local:a");+ assert_eq!((space.cpu_allocated, space.memory_allocated), (4, 8 << 30));+ assert_eq!(space.usage.unwrap().cpu_percent, 22.0);+ let d = space.disk_on_host.unwrap();+ assert_eq!(+ (d.bytes, d.allocated, d.shares_space),+ (None, 31 << 30, true)+ );+ // Nothing dropped: the record serializes back to the same JSON.+ let back = serde_json::to_value(&r).unwrap();+ assert_eq!(back["thisMac"]["loadAverage1m"], 0.0);+ }++ #[test]+ fn events_become_records() {+ let r = core_snapshot();+ match event_of(&core::ResourcesEvent::Snapshot(r.clone())).unwrap() {+ ResourcesEvent::Snapshot { snapshot } => assert_eq!(snapshot.sequence, 4),+ other => panic!("{other:?}"),+ }+ let update = core::ResourcesUpdate {+ sequence: 5,+ sampled_at_ms: 100,+ this_mac: None,+ spaces: vec![r.spaces[0].clone()],+ computers: vec![],+ removed: vec!["local:gone".into()],+ };+ match event_of(&core::ResourcesEvent::Update(update)).unwrap() {+ ResourcesEvent::Update { update } => {+ assert_eq!(update.sequence, 5);+ assert!(update.this_mac.is_none());+ assert_eq!(update.spaces.len(), 1);+ assert_eq!(update.removed, ["local:gone"]);+ }+ other => panic!("{other:?}"),+ }+ match event_of(&core::ResourcesEvent::LowDisk(r.warning)).unwrap() {+ ResourcesEvent::LowDisk { warning } => {+ assert_eq!(warning.level, DiskLevel::Low);+ assert_eq!(warning.free, 90 << 30);+ }+ other => panic!("{other:?}"),+ }+ }+}diff --git a/libs/cua/crates/cua-sdk/tests/resources.rs b/libs/cua/crates/cua-sdk/tests/resources.rsnew file mode 100644index 0000000000..f1bcb6a349--- /dev/null+++ b/libs/cua/crates/cua-sdk/tests/resources.rs@@ -0,0 +1,144 @@+//! `Spaces.resources`, `Spaces.watch_resources` and the CPU fields of+//! `Space.usage`, embedded and through a daemon: this Mac's processor,+//! memory and disk as one snapshot, then events a listener hears, ending+//! when the watch is stopped. No host effects.++use cua_daemon::{+ Runtime, RuntimeConfig,+ server::{self, DaemonHandle, ServerConfig},+};+use cua_sdk::{Cua, CuaConfig, DiskLevel, ResourcesEvent, ResourcesListener, ResourcesSnapshot};+use cua_spacesd_client::testing::MockServer;+use std::sync::{Arc, Mutex};+use std::time::Duration;++fn embedded(dir: &tempfile::TempDir) -> Arc<Cua> {+ Cua::embedded(CuaConfig {+ state_dir: Some(dir.path().join("sandboxes").display().to_string()),+ spaces_home: Some(dir.path().join("cua").display().to_string()),+ fleet_pool_home: Some(dir.path().join("pools").display().to_string()),+ fleet_from_env: false,+ fleet_from_session: false,+ ..Default::default()+ })+ .unwrap()+}++async fn daemon(dir: &tempfile::TempDir) -> (DaemonHandle, Arc<Cua>) {+ let runtime = Runtime::new(RuntimeConfig {+ state_dir: Some(dir.path().join("sandboxes")),+ spaces_home: Some(dir.path().join("cua")),+ ..Default::default()+ })+ .unwrap();+ let h = server::start(+ runtime,+ ServerConfig {+ socket_path: None,+ loopback: Some("127.0.0.1:0".parse().unwrap()),+ token: "daemon-token".into(),+ discovery_path: None,+ bridge_ticket_ttl: Duration::from_secs(30),+ },+ )+ .await+ .unwrap();+ let cua = Cua::connect(h.loopback_url.clone(), Some(h.token.clone())).unwrap();+ (h, cua)+}++/// Collects what the watch reports.+#[derive(Default)]+struct Heard(Mutex<Vec<ResourcesEvent>>);++impl ResourcesListener for Heard {+ fn on_event(&self, event: ResourcesEvent) {+ self.0.lock().unwrap().push(event);+ }+}++fn assert_this_mac(s: &ResourcesSnapshot) {+ let mac = &s.this_mac;+ assert_eq!(mac.id, "this-mac");+ assert!(mac.online && mac.cpu_count >= 1);+ assert!((0.0..=100.0).contains(&mac.cpu_percent));+ assert!(mac.memory_total > 0 && mac.memory_used <= mac.memory_total);+ assert!(mac.disk_total > 0 && mac.disk_free <= mac.disk_total);+ assert_eq!(s.warning, mac.warning);+ assert!(matches!(+ s.warning.level,+ DiskLevel::Ok | DiskLevel::Low | DiskLevel::Critical+ ));+}++async fn first_event(heard: &Arc<Heard>) -> ResourcesEvent {+ for _ in 0..100 {+ if let Some(e) = heard.0.lock().unwrap().first().cloned() {+ return e;+ }+ tokio::time::sleep(Duration::from_millis(100)).await;+ }+ panic!("no event within 10 s");+}++async fn exercise(cua: Arc<Cua>) {+ // One snapshot, polled the way a shell without a stream does.+ let polled = cua.spaces().resources(true).await.unwrap();+ assert_this_mac(&polled);+ assert!(polled.spaces.is_empty() && polled.computers.is_empty());+ let again = cua.spaces().resources(false).await.unwrap();+ assert_eq!(again.sequence, polled.sequence, "the same sample");++ // The same numbers as events: a snapshot first.+ let heard = Arc::new(Heard::default());+ let watch = cua.spaces().watch_resources(true, heard.clone());+ let ResourcesEvent::Snapshot { snapshot } = first_event(&heard).await else {+ panic!("the first event is a snapshot");+ };+ assert_this_mac(&snapshot);+ watch.set_visible(false);+ watch.set_visible(true);+ watch.stop();+ // Nothing is delivered after stop.+ let n = heard.0.lock().unwrap().len();+ tokio::time::sleep(Duration::from_millis(300)).await;+ assert_eq!(heard.0.lock().unwrap().len(), n);+}++#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn embedded_resources_and_watch() {+ let dir = tempfile::tempdir().unwrap();+ exercise(embedded(&dir)).await;+}++#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn resources_and_watch_through_a_daemon() {+ let dir = tempfile::tempdir().unwrap();+ let (handle, cua) = daemon(&dir).await;+ exercise(cua).await;+ handle.shutdown();+}++#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn a_space_usage_now_carries_the_processor() {+ let dir = tempfile::tempdir().unwrap();+ let server = MockServer::start(Default::default()).await;+ let c = embedded(&dir);+ let info = c+ .spaces()+ .add(server.url(), None, Some("lab".into()))+ .await+ .unwrap();+ let u = c+ .spaces()+ .space(info.id)+ .await+ .unwrap()+ .usage()+ .await+ .unwrap();+ assert_eq!((u.cpu_count, u.cpu_percent), (4, 12.5));+ assert_eq!(u.load_average_1m, 0.75);+ assert_eq!((u.memory_total, u.memory_limited), (4 << 30, true));+ assert_eq!((u.disk_total, u.disk_limited), (32 << 30, true));+}diff --git a/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs b/libs/cua/crates/cua-spaces-app-core/src/dispatch.rsindex d078af38b4..c40c0d5dce 100644--- a/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/dispatch.rs@@ -17,7 +17,7 @@ use crate::{CoreError, about, agent_keys, agents, checklist, cloud_connect, devices, diagnostics,drive_mount_preview, drive_page, drive_settings, driver_preview, experiments, host, login_item,machines, notch, notifications, onboarding, onboarding_preview, palette, paths, persistent,- presence, relay_usage, settings, share, telemetry, upsell, window, wizard,+ presence, relay_usage, resources, settings, share, telemetry, upsell, window, wizard,};use serde::Serialize;use serde::de::DeserializeOwned;@@ -289,6 +289,11 @@ pub const METHODS: &[&str] = &["experiments.choose","wizard.placementOptions","relayUsage.view",+ "resources.view",+ "resources.thisMac",+ "resources.space",+ "resources.computer",+ "resources.warning","upsell.prompt","upsell.allows","firstRun.view",@@ -484,6 +489,17 @@ pub fn call_value(method: &str, args: Value) -> Result<Value, CoreError> {_ => relay_usage::view(&usage),})}+ // Processor, memory and disk: the rows, bars and warning the apps+ // draw from the runtime's snapshot (`Spaces.resources`).+ // `nowMs` is the shell's clock: the core has none (wasm).+ "resources.view" => out(resources::view(&a.get("snapshot")?, a.get("nowMs")?)),+ "resources.thisMac" => out(resources::this_mac_view(&a.get("computer")?)),+ "resources.space" => out(resources::space_view(&a.get("space")?)),+ "resources.computer" => out(resources::computer_view(+ &a.get("computer")?,+ a.get("nowMs")?,+ )),+ "resources.warning" => out(resources::warning_view(&a.get("warning")?)),// The Pro and Teams prompts: the rules and words are `upsell`'s."upsell.prompt" => {let usage = a.get("usage")?;diff --git a/libs/cua/crates/cua-spaces-app-core/src/lib.rs b/libs/cua/crates/cua-spaces-app-core/src/lib.rsindex 7a65ef4739..993f67fc93 100644--- a/libs/cua/crates/cua-spaces-app-core/src/lib.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/lib.rs@@ -42,6 +42,7 @@//! | [`drive_page`] | the Drive page: browse the Cua Volume, access requests (with presence) and grants, sync per device, conflicts, Open in Finder |//! | [`drive_settings`] | Settings, Storage: this machine or an S3-compatible bucket, the Finder volume (a mount on Linux), the block cache |//! | [`drive_mount_preview`] | the first run's Cua Volume page (its animated miniature) |+//! | [`resources`] | processor, memory and disk of this Mac, each extra Space and your other computers: the rows, the bars, the low-disk warning |//! | [`notifications`] | which daemon notifications to post as system notifications, and the list |//! | [`share`] | who a Space is shared with (viewer or editor) and the Share sheet |//! | `installer` | the "Command line" step: plan and install the bundled `cua` (feature `installer`) |@@ -85,6 +86,7 @@ pub mod paths;pub mod persistent;pub mod presence;pub mod relay_usage;+pub mod resources;pub mod settings;pub mod share;pub mod spaces;diff --git a/libs/cua/crates/cua-spaces-app-core/src/resources.rs b/libs/cua/crates/cua-spaces-app-core/src/resources.rsnew file mode 100644index 0000000000..38e4389d3b--- /dev/null+++ b/libs/cua/crates/cua-spaces-app-core/src/resources.rs@@ -0,0 +1,867 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++//! Processor, memory and disk of this Mac, each extra Space on it and your+//! other computers, as every app shows them: Home's strips, the Space+//! detail, the menu bar warning.+//!+//! Plain data in (the runtime's `ResourcesSnapshot`, camelCase, as+//! `Spaces.resources` and `Spaces.watch_resources` return it) and plain+//! data out: rows of a label, a value in words and, for the small bars, a+//! fraction. The words live here, so no shell formats a number itself.+//!+//! Labels are only "Processor", "Memory" and "Space for files"; values say+//! "busy", "in use" and "free". Never vCPU, RSS, APFS, sparse, qcow2 or+//! cgroup. The CLI says the same things with the same numbers+//! (`cua_spaces::resources::words`).+//!+//! Numbers only: counts, bytes and percentages. Nothing here knows a file+//! name, a path, a process or a window.++use crate::spaces::sidebar::format_size;+use serde::{Deserialize, Serialize};++/// The Processor row's label.+pub const PROCESSOR: &str = "Processor";+/// The Memory row's label.+pub const MEMORY: &str = "Memory";+/// The disk row's label.+pub const FILES: &str = "Space for files";+/// The warning's button.+pub const SEE_WHAT_USES_SPACE: &str = "See what's using space";+/// The warning under the line.+pub const LOW_TEXT: &str = "This Mac is almost out of space. Delete old Spaces or snapshots.";+/// The warning under the floor where creating a Space already fails.+pub const CRITICAL_TEXT: &str =+ "This Mac is out of space, so new Spaces can't be created. Delete old Spaces or snapshots.";++/// How low the free disk is.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum DiskLevel {+ /// Plenty.+ #[default]+ Ok,+ /// Under 50 GB or 15% of the volume, whichever line is higher (never+ /// above 100 GB).+ Low,+ /// Under the floor where creating a Space already fails.+ Critical,+}++/// The low-disk signal.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct DiskWarning {+ /// How low it is.+ pub level: DiskLevel,+ /// Free bytes on the volume that holds Spaces.+ pub free: u64,+ /// Size of that volume.+ pub total: u64,+ /// The line that was crossed (0 when ok).+ pub threshold: u64,+}++/// A computer: this Mac, or one of your other computers.+#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct ComputerResources {+ /// `this-mac`, or the relay machine id.+ pub id: String,+ /// Display name (empty for this Mac).+ pub name: String,+ /// Reachable now.+ pub online: bool,+ /// When the computer measured this, Unix ms.+ pub sampled_at_ms: u64,+ /// Processor cores.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Size of the volume that holds Spaces, bytes.+ pub disk_total: u64,+ /// Free bytes on it.+ pub disk_free: u64,+ /// Extra Spaces on it.+ pub spaces_count: u32,+ /// Of those, running.+ pub spaces_running: u32,+ /// Cores given to the running ones.+ pub spaces_cpu_allocated: u32,+ /// Memory given to the running ones, bytes.+ pub spaces_memory_allocated: u64,+ /// Memory the running guests report in use, bytes.+ pub spaces_memory_used: u64,+ /// Bytes all its extra Spaces take on it.+ pub spaces_disk_bytes: u64,+ /// False when some Space's disk could only be estimated.+ pub spaces_disk_exact: bool,+ /// The low-disk signal.+ pub warning: DiskWarning,+}++/// What a Space's guest reports about itself.+#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct GuestUsage {+ /// Cores the guest sees.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// `memory_total` is the guest's own limit.+ pub memory_limited: bool,+ /// Disk in use, bytes.+ pub disk_used: u64,+ /// Disk size, bytes.+ pub disk_total: u64,+ /// `disk_total` is the guest's own disk.+ pub disk_limited: bool,+}++/// What a Space costs this Mac's disk.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct DiskOnHost {+ /// Bytes only this Space holds; none when they could not be measured.+ pub bytes: Option<u64>,+ /// Blocks its files occupy, clones counted in full.+ pub allocated: u64,+ /// Part of it is shared with other copies.+ pub shares_space: bool,+}++/// One extra Space on this Mac.+#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct SpaceResources {+ /// `local:<name>`.+ pub id: String,+ /// `running`, `stopped`, `suspended`, or empty when unknown.+ pub power_state: String,+ /// Cores given to it (0: unknown).+ pub cpu_allocated: u32,+ /// Memory given to it, bytes (0: unknown).+ pub memory_allocated: u64,+ /// Its disk's size limit, bytes (0: unknown).+ pub disk_allocated: u64,+ /// The guest's own numbers; none while it is off or unreachable.+ pub usage: Option<GuestUsage>,+ /// What it costs this Mac; none for a container.+ pub disk_on_host: Option<DiskOnHost>,+}++/// One sample of everything (`Spaces.resources`).+#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", default)]+pub struct ResourcesSnapshot {+ /// Grows by one per sample.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac.+ pub this_mac: ComputerResources,+ /// Extra Spaces on this Mac.+ pub spaces: Vec<SpaceResources>,+ /// Your other computers.+ pub computers: Vec<ComputerResources>,+ /// This Mac's low-disk signal, for the menu bar.+ pub warning: DiskWarning,+}++/// How a row's bar and value are coloured.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub enum ResourceTone {+ /// Nothing to say.+ #[default]+ Normal,+ /// Running low.+ Warning,+ /// Out.+ Critical,+}++/// One line of a panel: "Processor: 12 cores · 38% busy" with its bar.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ResourceRow {+ /// "Processor", "Memory" or "Space for files".+ pub label: String,+ /// The numbers in words.+ pub value: String,+ /// How full the small bar is, 0 to 1; none for a row with no bar.+ pub fraction: Option<f64>,+ /// How to colour it.+ pub tone: ResourceTone,+}++/// The low-disk warning with its button.+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct WarningView {+ /// The sentence.+ pub text: String,+ /// The button ("See what's using space").+ pub button: String,+ /// Under the floor where creating a Space already fails.+ pub critical: bool,+}++/// This Mac's panel.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ThisMacView {+ /// "This Mac".+ pub title: String,+ /// Processor, Memory, Space for files.+ pub rows: Vec<ResourceRow>,+ /// "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+ /// files." None when there are no extra Spaces.+ pub extra_spaces: Option<String>,+ /// The warning, when the disk is low.+ pub warning: Option<WarningView>,+}++/// One extra Space's panel.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct SpaceResourcesView {+ /// The Space's id.+ pub id: String,+ /// Processor, Memory, Space for files: what it was given and, while it+ /// runs, what it uses now.+ pub rows: Vec<ResourceRow>,+ /// What it costs this Mac, not what the guest sees: "Uses about 31 GB+ /// on this Mac (shares space with other copies)". None for a container.+ pub on_this_mac: Option<String>,+ /// The Space is off: "Stopped · uses about 6 GB on this Mac".+ pub off_line: Option<String>,+ /// Whether the numbers are live (the Space runs and answered).+ pub live: bool,+}++/// Another of your computers' panel.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ComputerView {+ /// The computer's id.+ pub id: String,+ /// Its name.+ pub name: String,+ /// Reachable now.+ pub online: bool,+ /// "Offline, as of 5 min ago" or "Updated 2 min ago"; none when the+ /// numbers are a moment old.+ pub age: Option<String>,+ /// Processor, Memory, Space for files.+ pub rows: Vec<ResourceRow>,+ /// "Its extra Spaces use: ..." (see [`ThisMacView::extra_spaces`]).+ pub extra_spaces: Option<String>,+ /// The warning, when its disk is low.+ pub warning: Option<WarningView>,+}++/// Everything the apps draw from one snapshot.+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ResourcesView {+ /// This Mac.+ pub this_mac: ThisMacView,+ /// Each extra Space.+ pub spaces: Vec<SpaceResourcesView>,+ /// Each other computer.+ pub computers: Vec<ComputerView>,+ /// The menu bar's warning: none when the disk is fine.+ pub warning: Option<WarningView>,+}++/// "12 cores · 38% busy".+pub fn processor_text(cores: u32, busy: Option<f64>) -> String {+ let cores = format!("{cores} core{}", if cores == 1 { "" } else { "s" });+ match busy {+ Some(p) => format!("{cores} \u{b7} {}% busy", p.round().clamp(0.0, 100.0)),+ None => cores,+ }+}++/// "3.1 of 8 GB": the used number with the total's unit.+pub fn of_text(used: u64, total: u64) -> String {+ let used = used.min(total);+ let (u, t) = (format_size(used), format_size(total));+ match (u.rsplit_once(' '), t.rsplit_once(' ')) {+ (Some((n, unit)), Some((_, tu))) if unit == tu => format!("{n} of {t}"),+ _ => format!("{u} of {t}"),+ }+}++fn fraction(part: u64, whole: u64) -> Option<f64> {+ (whole > 0).then(|| (part as f64 / whole as f64).clamp(0.0, 1.0))+}++fn row(label: &str, value: String, fraction: Option<f64>, tone: ResourceTone) -> ResourceRow {+ ResourceRow {+ label: label.into(),+ value,+ fraction,+ tone,+ }+}++/// The warning's sentence and button; none when the disk is fine.+pub fn warning_view(w: &DiskWarning) -> Option<WarningView> {+ let (text, critical) = match w.level {+ DiskLevel::Ok => return None,+ DiskLevel::Low => (LOW_TEXT, false),+ DiskLevel::Critical => (CRITICAL_TEXT, true),+ };+ Some(WarningView {+ text: text.into(),+ button: SEE_WHAT_USES_SPACE.into(),+ critical,+ })+}++fn level_tone(l: DiskLevel) -> ResourceTone {+ match l {+ DiskLevel::Ok => ResourceTone::Normal,+ DiskLevel::Low => ResourceTone::Warning,+ DiskLevel::Critical => ResourceTone::Critical,+ }+}++/// The Processor, Memory and disk rows of a computer.+fn computer_rows(c: &ComputerResources) -> Vec<ResourceRow> {+ let mut rows = Vec::new();+ if c.cpu_count > 0 {+ rows.push(row(+ PROCESSOR,+ processor_text(c.cpu_count, Some(c.cpu_percent)),+ Some((c.cpu_percent / 100.0).clamp(0.0, 1.0)),+ ResourceTone::Normal,+ ));+ }+ if c.memory_total > 0 {+ rows.push(row(+ MEMORY,+ format!("{} in use", of_text(c.memory_used, c.memory_total)),+ fraction(c.memory_used, c.memory_total),+ ResourceTone::Normal,+ ));+ }+ if c.disk_total > 0 {+ let free = c.disk_free.min(c.disk_total);+ rows.push(row(+ FILES,+ format!(+ "{} free of {}",+ format_size(free),+ format_size(c.disk_total)+ ),+ fraction(c.disk_total - free, c.disk_total),+ level_tone(c.warning.level),+ ));+ }+ rows+}++/// "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+/// files."+fn extra_spaces_text(c: &ComputerResources, whose: &str) -> Option<String> {+ if c.spaces_count == 0 {+ return None;+ }+ let cores = format!(+ "{} core{}",+ c.spaces_cpu_allocated,+ if c.spaces_cpu_allocated == 1 { "" } else { "s" }+ );+ let files = if c.spaces_disk_exact {+ format!("about {}", format_size(c.spaces_disk_bytes))+ } else {+ format!("up to about {}", format_size(c.spaces_disk_bytes))+ };+ Some(format!(+ "{whose} extra Spaces use: {cores}, {} of memory, {files} for files.",+ format_size(c.spaces_memory_allocated),+ ))+}++/// This Mac's panel.+pub fn this_mac_view(c: &ComputerResources) -> ThisMacView {+ ThisMacView {+ title: "This Mac".into(),+ rows: computer_rows(c),+ extra_spaces: extra_spaces_text(c, "Your"),+ warning: warning_view(&c.warning),+ }+}++/// What a Space costs this Mac, in words (the same for a running and a+/// stopped Space).+fn on_this_mac_text(d: &DiskOnHost) -> Option<String> {+ match (d.bytes, d.shares_space) {+ (Some(b), true) => Some(format!(+ "Uses about {} on this Mac (shares space with other copies)",+ format_size(b)+ )),+ (Some(b), false) => Some(format!("Uses about {} on this Mac", format_size(b))),+ (None, true) => Some("Shares space with other copies".into()),+ (None, false) => None,+ }+}++/// One extra Space's panel: what it was given and what it uses now, and+/// what it costs this Mac.+pub fn space_view(s: &SpaceResources) -> SpaceResourcesView {+ let off = matches!(s.power_state.as_str(), "stopped" | "suspended");+ let live = s.usage.is_some() && !off;+ let usage = s.usage.filter(|_| live);+ let mut rows = Vec::new();++ let cores = if s.cpu_allocated > 0 {+ s.cpu_allocated+ } else {+ usage.map(|u| u.cpu_count).unwrap_or(0)+ };+ if cores > 0 {+ rows.push(row(+ PROCESSOR,+ processor_text(cores, usage.map(|u| u.cpu_percent)),+ usage.map(|u| (u.cpu_percent / 100.0).clamp(0.0, 1.0)),+ ResourceTone::Normal,+ ));+ }+ let memory = if s.memory_allocated > 0 {+ s.memory_allocated+ } else {+ usage+ .filter(|u| u.memory_limited)+ .map(|u| u.memory_total)+ .unwrap_or(0)+ };+ if memory > 0 {+ rows.push(match usage {+ Some(u) => row(+ MEMORY,+ of_text(u.memory_used, memory),+ fraction(u.memory_used, memory),+ ResourceTone::Normal,+ ),+ None => row(MEMORY, format_size(memory), None, ResourceTone::Normal),+ });+ }+ let disk = if s.disk_allocated > 0 {+ s.disk_allocated+ } else {+ usage+ .filter(|u| u.disk_limited)+ .map(|u| u.disk_total)+ .unwrap_or(0)+ };+ if disk > 0 {+ rows.push(row(+ FILES,+ format!("up to {}", format_size(disk)),+ usage+ .filter(|u| u.disk_limited)+ .and_then(|u| fraction(u.disk_used, u.disk_total)),+ ResourceTone::Normal,+ ));+ }++ let on_this_mac = s.disk_on_host.as_ref().and_then(on_this_mac_text);+ let off_line = off.then(|| {+ let word = if s.power_state == "suspended" {+ "Suspended"+ } else {+ "Stopped"+ };+ match s.disk_on_host.as_ref().and_then(on_this_mac_text) {+ Some(t) => format!("{word} \u{b7} {}", lowercase_first(&t)),+ None => word.to_string(),+ }+ });+ SpaceResourcesView {+ id: s.id.clone(),+ rows,+ on_this_mac,+ off_line,+ live,+ }+}++fn lowercase_first(s: &str) -> String {+ let mut c = s.chars();+ match c.next() {+ Some(f) => f.to_lowercase().collect::<String>() + c.as_str(),+ None => String::new(),+ }+}++/// "just now", "5 min ago", "2 h ago", "3 d ago".+pub fn age_text(sampled_at_ms: u64, now_ms: u64) -> String {+ let secs = now_ms.saturating_sub(sampled_at_ms) / 1000;+ match secs {+ 0..=89 => "just now".into(),+ 90..=3_599 => format!("{} min ago", (secs + 30) / 60),+ 3_600..=86_399 => format!("{} h ago", secs / 3600),+ _ => format!("{} d ago", secs / 86_400),+ }+}++/// Another of your computers' panel. `now_ms` is the shell's clock.+pub fn computer_view(c: &ComputerResources, now_ms: u64) -> ComputerView {+ let age = match (c.online, age_text(c.sampled_at_ms, now_ms)) {+ (true, a) if a == "just now" => None,+ (true, a) => Some(format!("Updated {a}")),+ (false, a) => Some(format!("Offline, as of {a}")),+ }+ .filter(|_| c.sampled_at_ms > 0 || !c.online);+ ComputerView {+ id: c.id.clone(),+ name: c.name.clone(),+ online: c.online,+ age,+ rows: computer_rows(c),+ extra_spaces: extra_spaces_text(c, "Its"),+ warning: warning_view(&c.warning),+ }+}++/// Everything the apps draw from one snapshot.+pub fn view(s: &ResourcesSnapshot, now_ms: u64) -> ResourcesView {+ ResourcesView {+ this_mac: this_mac_view(&s.this_mac),+ spaces: s.spaces.iter().map(space_view).collect(),+ computers: s+ .computers+ .iter()+ .map(|c| computer_view(c, now_ms))+ .collect(),+ warning: warning_view(&s.warning),+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ const GIB: u64 = 1 << 30;+ const TB: u64 = 1024 * GIB;++ fn mac() -> ComputerResources {+ ComputerResources {+ id: "this-mac".into(),+ online: true,+ sampled_at_ms: 1_000_000,+ cpu_count: 12,+ cpu_percent: 38.0,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: TB,+ disk_free: 41 * GIB,+ spaces_count: 3,+ spaces_running: 2,+ spaces_cpu_allocated: 6,+ spaces_memory_allocated: 12 * GIB,+ spaces_disk_bytes: 25 * GIB,+ spaces_disk_exact: true,+ warning: DiskWarning {+ level: DiskLevel::Low,+ free: 41 * GIB,+ total: TB,+ threshold: 100 * GIB,+ },+ ..Default::default()+ }+ }++ fn space() -> SpaceResources {+ SpaceResources {+ id: "local:aurora".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_used: 3 * GIB + GIB / 10,+ memory_total: 8 * GIB,+ memory_limited: true,+ disk_used: 20 * GIB,+ disk_total: 80 * GIB,+ disk_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(DiskOnHost {+ bytes: Some(31 * GIB),+ allocated: 87 * GIB,+ shares_space: true,+ }),+ }+ }++ fn texts(rows: &[ResourceRow]) -> Vec<(String, String)> {+ rows.iter()+ .map(|r| (r.label.clone(), r.value.clone()))+ .collect()+ }++ #[test]+ fn this_mac_in_words_with_bars() {+ let v = this_mac_view(&mac());+ assert_eq!(v.title, "This Mac");+ assert_eq!(+ texts(&v.rows),+ [+ (+ "Processor".to_string(),+ "12 cores \u{b7} 38% busy".to_string()+ ),+ ("Memory".to_string(), "41 of 64 GB in use".to_string()),+ (+ "Space for files".to_string(),+ "41 GB free of 1 TB".to_string()+ ),+ ]+ );+ assert_eq!(v.rows[0].fraction, Some(0.38));+ assert_eq!(v.rows[1].fraction, Some(41.0 / 64.0));+ // The disk bar fills with what is used, in the warning's colour.+ assert!((v.rows[2].fraction.unwrap() - (1.0 - 41.0 / 1024.0)).abs() < 1e-9);+ assert_eq!(v.rows[2].tone, ResourceTone::Warning);+ assert_eq!(+ v.extra_spaces.as_deref(),+ Some("Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for files.")+ );+ }++ #[test]+ fn the_warning_has_its_words_and_button() {+ let w = warning_view(&mac().warning).unwrap();+ assert_eq!(+ w.text,+ "This Mac is almost out of space. Delete old Spaces or snapshots."+ );+ assert_eq!(w.button, "See what's using space");+ assert!(!w.critical);+ let critical = DiskWarning {+ level: DiskLevel::Critical,+ ..mac().warning+ };+ let w = warning_view(&critical).unwrap();+ assert!(w.critical && w.text.contains("out of space"));+ assert_eq!(warning_view(&DiskWarning::default()), None);+ let mut ok = mac();+ ok.warning.level = DiskLevel::Ok;+ let v = this_mac_view(&ok);+ assert_eq!(v.warning, None);+ assert_eq!(v.rows[2].tone, ResourceTone::Normal);+ }++ #[test]+ fn a_running_space_shows_what_it_uses_and_what_it_costs() {+ let v = space_view(&space());+ assert!(v.live);+ assert_eq!(+ texts(&v.rows),+ [+ (+ "Processor".to_string(),+ "4 cores \u{b7} 22% busy".to_string()+ ),+ ("Memory".to_string(), "3.1 of 8 GB".to_string()),+ ("Space for files".to_string(), "up to 80 GB".to_string()),+ ]+ );+ assert_eq!(v.rows[0].fraction, Some(0.22));+ assert_eq!(v.rows[2].fraction, Some(0.25));+ assert_eq!(+ v.on_this_mac.as_deref(),+ Some("Uses about 31 GB on this Mac (shares space with other copies)")+ );+ assert_eq!(v.off_line, None);+ }++ #[test]+ fn a_stopped_space_shows_its_allocation_and_disk_only() {+ let s = SpaceResources {+ power_state: "stopped".into(),+ usage: None,+ disk_on_host: Some(DiskOnHost {+ bytes: Some(6 * GIB),+ allocated: 6 * GIB,+ shares_space: false,+ }),+ ..space()+ };+ let v = space_view(&s);+ assert!(!v.live);+ assert_eq!(+ texts(&v.rows),+ [+ ("Processor".to_string(), "4 cores".to_string()),+ ("Memory".to_string(), "8 GB".to_string()),+ ("Space for files".to_string(), "up to 80 GB".to_string()),+ ]+ );+ assert!(v.rows.iter().all(|r| r.fraction.is_none()));+ assert_eq!(+ v.on_this_mac.as_deref(),+ Some("Uses about 6 GB on this Mac")+ );+ assert_eq!(+ v.off_line.as_deref(),+ Some("Stopped \u{b7} uses about 6 GB on this Mac")+ );+ let suspended = SpaceResources {+ power_state: "suspended".into(),+ ..s.clone()+ };+ assert!(+ space_view(&suspended)+ .off_line+ .unwrap()+ .starts_with("Suspended")+ );+ }++ #[test]+ fn a_disk_that_could_not_be_measured_says_it_shares_space() {+ let s = SpaceResources {+ disk_on_host: Some(DiskOnHost {+ bytes: None,+ allocated: 12 * GIB,+ shares_space: true,+ }),+ ..space()+ };+ assert_eq!(+ space_view(&s).on_this_mac.as_deref(),+ Some("Shares space with other copies")+ );+ // A container has nothing to say about its disk.+ let c = SpaceResources {+ disk_on_host: None,+ ..space()+ };+ assert_eq!(space_view(&c).on_this_mac, None);+ }++ #[test]+ fn a_space_with_nothing_known_has_no_rows() {+ let v = space_view(&SpaceResources {+ id: "local:x".into(),+ ..Default::default()+ });+ assert!(v.rows.is_empty() && !v.live);+ assert_eq!((v.on_this_mac, v.off_line), (None, None));+ }++ #[test]+ fn a_guest_that_reports_its_own_limits_fills_in_what_was_not_recorded() {+ let s = SpaceResources {+ cpu_allocated: 0,+ memory_allocated: 0,+ disk_allocated: 0,+ ..space()+ };+ let v = space_view(&s);+ assert_eq!(v.rows[0].value, "4 cores \u{b7} 22% busy");+ assert_eq!(v.rows[1].value, "3.1 of 8 GB");+ assert_eq!(v.rows[2].value, "up to 80 GB");+ }++ #[test]+ fn another_computer_says_how_old_its_numbers_are() {+ let c = ComputerResources {+ id: "m1".into(),+ name: "Mac mini".into(),+ online: true,+ sampled_at_ms: 1_000_000,+ ..mac()+ };+ let at = |secs: u64| computer_view(&c, 1_000_000 + secs * 1000);+ assert_eq!(at(10).age, None);+ assert_eq!(at(120).age.as_deref(), Some("Updated 2 min ago"));+ assert_eq!(at(7_300).age.as_deref(), Some("Updated 2 h ago"));+ let off = ComputerResources {+ online: false,+ ..c.clone()+ };+ assert_eq!(+ computer_view(&off, 1_000_000 + 300_000).age.as_deref(),+ Some("Offline, as of 5 min ago")+ );+ let v = at(10);+ assert_eq!(v.name, "Mac mini");+ assert_eq!(v.rows.len(), 3);+ assert!(v.extra_spaces.unwrap().starts_with("Its extra Spaces use"));+ }++ #[test]+ fn the_snapshot_reads_the_runtimes_json() {+ let json = serde_json::json!({+ "sequence": 3, "sampledAtMs": 5,+ "thisMac": {"id": "this-mac", "online": true, "cpuCount": 12, "cpuPercent": 38.0,+ "memoryTotal": 68719476736u64, "memoryUsed": 44023414784u64,+ "diskTotal": 1099511627776u64, "diskFree": 44023414784u64,+ "warning": {"level": "low", "free": 44023414784u64,+ "total": 1099511627776u64, "threshold": 107374182400u64}},+ "spaces": [{"id": "local:a", "powerState": "running", "cpuAllocated": 2,+ "usage": {"cpuCount": 2, "cpuPercent": 10.0,+ "memoryUsed": 1073741824u64, "memoryTotal": 2147483648u64,+ "memoryLimited": true},+ "diskOnHost": {"bytes": null, "allocated": 1, "sharesSpace": true}}],+ "computers": [],+ "warning": {"level": "low", "free": 44023414784u64,+ "total": 1099511627776u64, "threshold": 107374182400u64}+ });+ let s: ResourcesSnapshot = serde_json::from_value(json).unwrap();+ let v = view(&s, 5);+ assert_eq!(v.this_mac.rows[0].value, "12 cores \u{b7} 38% busy");+ assert!(v.warning.is_some());+ assert_eq!(v.spaces[0].rows[1].value, "1 of 2 GB");+ assert_eq!(+ v.spaces[0].on_this_mac.as_deref(),+ Some("Shares space with other copies")+ );+ // Older shells leave fields out: every one has a default.+ let bare: ResourcesSnapshot = serde_json::from_value(serde_json::json!({})).unwrap();+ assert!(view(&bare, 0).spaces.is_empty());+ }++ #[test]+ fn the_copy_has_no_jargon() {+ let v = view(+ &ResourcesSnapshot {+ this_mac: mac(),+ spaces: vec![space()],+ computers: vec![mac()],+ warning: mac().warning,+ ..Default::default()+ },+ 2_000_000,+ );+ let text = serde_json::to_string(&v).unwrap().to_lowercase();+ for jargon in [+ "vcpu", "rss", "apfs", "sparse", "qcow", "cgroup", "clone", "host",+ ] {+ assert!(!text.contains(jargon), "{jargon} in {text}");+ }+ }+}diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rsindex 840bd2311c..34899d6e13 100644--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/sidebar.rs@@ -733,12 +733,22 @@ pub fn delete_failed_text(name: &str, error: &str) -> String {)}-/// Memory and storage use of a Space (the SDK's `Space.usage`), for its-/// Memory and Storage facts. A size shows only when it is the guest's own+/// Processor, memory and storage use of a Space (the SDK's `Space.usage`),+/// for its Memory and Storage facts and its resource panel+/// ([`crate::resources`]). A size shows only when it is the guest's own/// limit (`*_limited`: a VM, a container's cgroup memory limit).-#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]+#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct SpaceUsage {+ /// Cores the guest sees (0 from a guest that does not report it).+ #[serde(default)]+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ #[serde(default)]+ pub cpu_percent: f64,+ /// 1-minute load average.+ #[serde(default)]+ pub load_average_1m: f64,/// Memory in use, bytes.pub memory_used: u64,/// Memory size, bytes.diff --git a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs b/libs/cua/crates/cua-spaces-ffi/src/app_core.rsindex 7aec1abc77..e044d39bc4 100644--- a/libs/cua/crates/cua-spaces-ffi/src/app_core.rs+++ b/libs/cua/crates/cua-spaces-ffi/src/app_core.rs@@ -1983,6 +1983,55 @@ pub fn app_relay_usage_view(usage: AppRelayUsage) -> Option<AppRelayUsageView> {core::relay_usage::view(&usage)}+/// An SDK record as the app core's (the same JSON, the same names).+fn core_of<T: serde::Serialize, U: serde::de::DeserializeOwned + Default>(v: &T) -> U {+ serde_json::to_value(v)+ .and_then(serde_json::from_value)+ .unwrap_or_default()+}++/// Everything the apps draw from one snapshot of what this Mac, its extra+/// Spaces and your other computers use (`Spaces.resources`, or a snapshot+/// event of `Spaces.watch_resources`): this Mac's rows and warning, each+/// extra Space's rows and what it costs this Mac, each other computer's+/// rows. The words are the core's; no shell formats a number. `now_ms` is+/// the shell's clock (Unix ms), for how old another computer's numbers are.+#[uniffi::export]+pub fn app_resources_view(snapshot: cua_sdk::ResourcesSnapshot, now_ms: u64) -> AppResourcesView {+ let snapshot: core::resources::ResourcesSnapshot = core_of(&snapshot);+ core::resources::view(&snapshot, now_ms)+}++/// This Mac's panel (Processor, Memory, Space for files, what the extra+/// Spaces use, the warning).+#[uniffi::export]+pub fn app_resources_this_mac(computer: cua_sdk::ComputerResources) -> AppThisMacView {+ core::resources::this_mac_view(&core_of(&computer))+}++/// One extra Space's panel: what it was given and uses now, and what it+/// costs this Mac.+#[uniffi::export]+pub fn app_resources_space(space: cua_sdk::SpaceResources) -> AppSpaceResourcesView {+ core::resources::space_view(&core_of(&space))+}++/// Another of your computers' panel.+#[uniffi::export]+pub fn app_resources_computer(+ computer: cua_sdk::ComputerResources,+ now_ms: u64,+) -> AppComputerView {+ core::resources::computer_view(&core_of(&computer), now_ms)+}++/// The menu bar's low-disk warning (from a `LowDisk` event or a+/// snapshot's `warning`); none when the disk is fine.+#[uniffi::export]+pub fn app_resources_warning(warning: cua_sdk::DiskWarning) -> Option<AppWarningView> {+ core::resources::warning_view(&core_of(&warning))+}+/// Reads the settings file (defaults when missing or damaged).#[uniffi::export]pub fn app_settings_load(path: String) -> AppSettings {@@ -2993,3 +3042,141 @@ mod agent_detection_tests {assert!(!s(info("gemini-cli", false, &[])));}}++#[cfg(test)]+mod resources_tests {+ use super::*;+ use cua_spaces::resources as rt;++ const GIB: u64 = 1 << 30;++ fn sdk_snapshot() -> cua_sdk::ResourcesSnapshot {+ let runtime = rt::Resources {+ sequence: 2,+ sampled_at_ms: 1_000_000,+ this_mac: rt::ComputerResources {+ id: rt::THIS_MAC.into(),+ online: true,+ sampled_at_ms: 1_000_000,+ cpu_count: 12,+ cpu_percent: 38.0,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: 1024 * GIB,+ disk_free: 41 * GIB,+ spaces_count: 1,+ spaces_running: 1,+ spaces_cpu_allocated: 4,+ spaces_memory_allocated: 8 * GIB,+ spaces_disk_bytes: 31 * GIB,+ spaces_disk_exact: true,+ warning: rt::DiskWarning::assess(41 * GIB, 1024 * GIB, 5 * GIB, rt::DiskLevel::Ok),+ ..Default::default()+ },+ spaces: vec![rt::SpaceResources {+ id: "local:aurora".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(rt::GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_used: 3 * GIB + GIB / 10,+ memory_total: 8 * GIB,+ memory_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(rt::DiskOnHost {+ bytes: Some(31 * GIB),+ allocated: 87 * GIB,+ shares_space: true,+ }),+ }],+ computers: vec![rt::ComputerResources {+ id: "mini".into(),+ name: "Mac mini".into(),+ online: true,+ sampled_at_ms: 1_000_000,+ cpu_count: 10,+ cpu_percent: 5.0,+ memory_total: 32 * GIB,+ memory_used: 12 * GIB,+ disk_total: 512 * GIB,+ disk_free: 300 * GIB,+ ..Default::default()+ }],+ warning: rt::DiskWarning::assess(41 * GIB, 1024 * GIB, 5 * GIB, rt::DiskLevel::Ok),+ };+ serde_json::from_value(serde_json::to_value(&runtime).unwrap()).unwrap()+ }++ /// The SDK's snapshot becomes the app core's without losing a field.+ #[test]+ fn the_sdk_snapshot_reaches_the_core_whole() {+ let sdk = sdk_snapshot();+ let core: core::resources::ResourcesSnapshot = core_of(&sdk);+ assert_eq!(core.sequence, 2);+ assert_eq!(core.this_mac.cpu_count, 12);+ assert_eq!(core.this_mac.warning.level, core::resources::DiskLevel::Low);+ assert_eq!(core.spaces[0].usage.unwrap().cpu_percent, 22.0);+ assert_eq!(core.spaces[0].disk_on_host.unwrap().bytes, Some(31 * GIB));+ assert_eq!(core.computers[0].name, "Mac mini");+ }++ /// What Swift draws from `app_resources_view`: the core's rows.+ #[test]+ fn the_view_has_the_rows_and_the_warning() {+ let v = app_resources_view(sdk_snapshot(), 1_000_000);+ assert_eq!(v.this_mac.rows[0].value, "12 cores \u{b7} 38% busy");+ assert_eq!(v.spaces[0].rows[1].value, "3.1 of 8 GB");+ assert_eq!(+ v.spaces[0].on_this_mac.as_deref(),+ Some("Uses about 31 GB on this Mac (shares space with other copies)")+ );+ assert_eq!(v.computers[0].rows[2].value, "300 GB free of 512 GB");+ assert!(v.warning.is_some());+ let w = app_resources_warning(sdk_snapshot().warning).unwrap();+ assert_eq!(w.button, "See what's using space");+ }++ /// The CLI and the apps say the same things with the same numbers.+ #[test]+ fn the_cli_and_the_apps_use_the_same_words() {+ let sdk = sdk_snapshot();+ let v = app_resources_view(sdk.clone(), 1_000_000);+ let runtime: rt::Resources =+ serde_json::from_value(serde_json::to_value(&sdk).unwrap()).unwrap();+ // This Mac.+ let m = &runtime.this_mac;+ assert_eq!(+ v.this_mac.rows[0].value,+ rt::words::processor(m.cpu_count, Some(m.cpu_percent))+ );+ assert_eq!(+ v.this_mac.rows[1].value,+ rt::words::memory_in_use(m.memory_used, m.memory_total)+ );+ assert_eq!(+ v.this_mac.rows[2].value,+ rt::words::disk_free(m.disk_free, m.disk_total)+ );+ assert_eq!(v.this_mac.extra_spaces, rt::words::extra_spaces_use(m));+ assert_eq!(+ v.this_mac.warning.as_ref().map(|w| w.text.as_str()),+ rt::words::warning(&runtime.warning)+ );+ // A running Space.+ let s = &runtime.spaces[0];+ assert_eq!(v.spaces[0].rows[0].value, rt::words::space_cpu(s));+ assert_eq!(v.spaces[0].rows[1].value, rt::words::space_memory(s));+ // Another computer.+ let c = &runtime.computers[0];+ assert_eq!(v.computers[0].rows[0].value, rt::words::computer_cpu(c));+ assert_eq!(+ v.computers[0].rows[1].value,+ format!("{} in use", rt::words::computer_memory(c))+ );+ assert_eq!(v.computers[0].rows[2].value, rt::words::computer_disk(c));+ }+}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 de6926ff89..53f0701809 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@@ -883,12 +883,19 @@ pub struct AppDetailCopy {pub teleport_symbol_active: String,}-/// Memory and storage use of a Space (the SDK's `Space.usage`), for its-/// Memory and Storage facts. A size shows only when it is the guest's own+/// Processor, memory and storage use of a Space (the SDK's `Space.usage`),+/// for its Memory and Storage facts and its resource panel+/// ([`crate::resources`]). A size shows only when it is the guest's own/// limit (`*_limited`: a VM, a container's cgroup memory limit).pub type AppSpaceUsage = core::spaces::sidebar::SpaceUsage;#[uniffi::remote(Record)]pub struct AppSpaceUsage {+ /// Cores the guest sees (0 from a guest that does not report it).+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,/// Memory in use, bytes.pub memory_used: u64,/// Memory size, bytes.@@ -9675,3 +9682,254 @@ pub struct AppRelayUsageView {/// Settings' plan card.pub plan_card: AppPlanCard,}++/// How low the free disk is.+pub type AppDiskLevel = core::resources::DiskLevel;+#[uniffi::remote(Enum)]+pub enum AppDiskLevel {+ /// Plenty.+ Ok,+ /// Under 50 GB or 15% of the volume, whichever line is higher (never+ /// above 100 GB).+ Low,+ /// Under the floor where creating a Space already fails.+ Critical,+}++/// The low-disk signal.+pub type AppDiskWarning = core::resources::DiskWarning;+#[uniffi::remote(Record)]+pub struct AppDiskWarning {+ /// How low it is.+ pub level: AppDiskLevel,+ /// Free bytes on the volume that holds Spaces.+ pub free: u64,+ /// Size of that volume.+ pub total: u64,+ /// The line that was crossed (0 when ok).+ pub threshold: u64,+}++/// A computer: this Mac, or one of your other computers.+pub type AppComputerResources = core::resources::ComputerResources;+#[uniffi::remote(Record)]+pub struct AppComputerResources {+ /// `this-mac`, or the relay machine id.+ pub id: String,+ /// Display name (empty for this Mac).+ pub name: String,+ /// Reachable now.+ pub online: bool,+ /// When the computer measured this, Unix ms.+ pub sampled_at_ms: u64,+ /// Processor cores.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Size of the volume that holds Spaces, bytes.+ pub disk_total: u64,+ /// Free bytes on it.+ pub disk_free: u64,+ /// Extra Spaces on it.+ pub spaces_count: u32,+ /// Of those, running.+ pub spaces_running: u32,+ /// Cores given to the running ones.+ pub spaces_cpu_allocated: u32,+ /// Memory given to the running ones, bytes.+ pub spaces_memory_allocated: u64,+ /// Memory the running guests report in use, bytes.+ pub spaces_memory_used: u64,+ /// Bytes all its extra Spaces take on it.+ pub spaces_disk_bytes: u64,+ /// False when some Space's disk could only be estimated.+ pub spaces_disk_exact: bool,+ /// The low-disk signal.+ pub warning: AppDiskWarning,+}++/// What a Space's guest reports about itself.+pub type AppGuestUsage = core::resources::GuestUsage;+#[uniffi::remote(Record)]+pub struct AppGuestUsage {+ /// Cores the guest sees.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// `memory_total` is the guest's own limit.+ pub memory_limited: bool,+ /// Disk in use, bytes.+ pub disk_used: u64,+ /// Disk size, bytes.+ pub disk_total: u64,+ /// `disk_total` is the guest's own disk.+ pub disk_limited: bool,+}++/// What a Space costs this Mac's disk.+pub type AppDiskOnHost = core::resources::DiskOnHost;+#[uniffi::remote(Record)]+pub struct AppDiskOnHost {+ /// Bytes only this Space holds; none when they could not be measured.+ pub bytes: Option<u64>,+ /// Blocks its files occupy, clones counted in full.+ pub allocated: u64,+ /// Part of it is shared with other copies.+ pub shares_space: bool,+}++/// One extra Space on this Mac.+pub type AppSpaceResources = core::resources::SpaceResources;+#[uniffi::remote(Record)]+pub struct AppSpaceResources {+ /// `local:<name>`.+ pub id: String,+ /// `running`, `stopped`, `suspended`, or empty when unknown.+ pub power_state: String,+ /// Cores given to it (0: unknown).+ pub cpu_allocated: u32,+ /// Memory given to it, bytes (0: unknown).+ pub memory_allocated: u64,+ /// Its disk's size limit, bytes (0: unknown).+ pub disk_allocated: u64,+ /// The guest's own numbers; none while it is off or unreachable.+ pub usage: Option<AppGuestUsage>,+ /// What it costs this Mac; none for a container.+ pub disk_on_host: Option<AppDiskOnHost>,+}++/// One sample of everything (`Spaces.resources`).+pub type AppResourcesSnapshot = core::resources::ResourcesSnapshot;+#[uniffi::remote(Record)]+pub struct AppResourcesSnapshot {+ /// Grows by one per sample.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac.+ pub this_mac: AppComputerResources,+ /// Extra Spaces on this Mac.+ pub spaces: Vec<AppSpaceResources>,+ /// Your other computers.+ pub computers: Vec<AppComputerResources>,+ /// This Mac's low-disk signal, for the menu bar.+ pub warning: AppDiskWarning,+}++/// How a row's bar and value are coloured.+pub type AppResourceTone = core::resources::ResourceTone;+#[uniffi::remote(Enum)]+pub enum AppResourceTone {+ /// Nothing to say.+ Normal,+ /// Running low.+ Warning,+ /// Out.+ Critical,+}++/// One line of a panel: "Processor: 12 cores · 38% busy" with its bar.+pub type AppResourceRow = core::resources::ResourceRow;+#[uniffi::remote(Record)]+pub struct AppResourceRow {+ /// "Processor", "Memory" or "Space for files".+ pub label: String,+ /// The numbers in words.+ pub value: String,+ /// How full the small bar is, 0 to 1; none for a row with no bar.+ pub fraction: Option<f64>,+ /// How to colour it.+ pub tone: AppResourceTone,+}++/// The low-disk warning with its button.+pub type AppWarningView = core::resources::WarningView;+#[uniffi::remote(Record)]+pub struct AppWarningView {+ /// The sentence.+ pub text: String,+ /// The button ("See what's using space").+ pub button: String,+ /// Under the floor where creating a Space already fails.+ pub critical: bool,+}++/// This Mac's panel.+pub type AppThisMacView = core::resources::ThisMacView;+#[uniffi::remote(Record)]+pub struct AppThisMacView {+ /// "This Mac".+ pub title: String,+ /// Processor, Memory, Space for files.+ pub rows: Vec<AppResourceRow>,+ /// "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+ /// files." None when there are no extra Spaces.+ pub extra_spaces: Option<String>,+ /// The warning, when the disk is low.+ pub warning: Option<AppWarningView>,+}++/// One extra Space's panel.+pub type AppSpaceResourcesView = core::resources::SpaceResourcesView;+#[uniffi::remote(Record)]+pub struct AppSpaceResourcesView {+ /// The Space's id.+ pub id: String,+ /// Processor, Memory, Space for files: what it was given and, while it+ /// runs, what it uses now.+ pub rows: Vec<AppResourceRow>,+ /// What it costs this Mac, not what the guest sees: "Uses about 31 GB+ /// on this Mac (shares space with other copies)". None for a container.+ pub on_this_mac: Option<String>,+ /// The Space is off: "Stopped · uses about 6 GB on this Mac".+ pub off_line: Option<String>,+ /// Whether the numbers are live (the Space runs and answered).+ pub live: bool,+}++/// Another of your computers' panel.+pub type AppComputerView = core::resources::ComputerView;+#[uniffi::remote(Record)]+pub struct AppComputerView {+ /// The computer's id.+ pub id: String,+ /// Its name.+ pub name: String,+ /// Reachable now.+ pub online: bool,+ /// "Offline, as of 5 min ago" or "Updated 2 min ago"; none when the+ /// numbers are a moment old.+ pub age: Option<String>,+ /// Processor, Memory, Space for files.+ pub rows: Vec<AppResourceRow>,+ /// "Its extra Spaces use: ..." (see [`ThisMacView::extra_spaces`]).+ pub extra_spaces: Option<String>,+ /// The warning, when its disk is low.+ pub warning: Option<AppWarningView>,+}++/// Everything the apps draw from one snapshot.+pub type AppResourcesView = core::resources::ResourcesView;+#[uniffi::remote(Record)]+pub struct AppResourcesView {+ /// This Mac.+ pub this_mac: AppThisMacView,+ /// Each extra Space.+ pub spaces: Vec<AppSpaceResourcesView>,+ /// Each other computer.+ pub computers: Vec<AppComputerView>,+ /// The menu bar's warning: none when the disk is fine.+ pub warning: Option<AppWarningView>,+}diff --git a/libs/cua/crates/cua-spaces/Cargo.toml b/libs/cua/crates/cua-spaces/Cargo.tomlindex 8a6e1d3ac9..8250d63cef 100644--- a/libs/cua/crates/cua-spaces/Cargo.toml+++ b/libs/cua/crates/cua-spaces/Cargo.toml@@ -62,6 +62,8 @@ cua-agents = { workspace = true, optional = true }cua-auth = { workspace = true, optional = true }cua-fleet.workspace = truecua-image.workspace = true+# Per-Space disk accounting (resources).+cua-disk.workspace = truecua-sandbox-core.workspace = truecua-vmm.workspace = true# The cua-relay machine directory (`space://relay/<id>`) and AccountTokens.@@ -86,6 +88,8 @@ tokio = { workspace = true }tonic = { workspace = true, default-features = false, features = ["codegen"] }tracing.workspace = trueurl.workspace = true+# This computer's processor and memory (resources).+sysinfo = { version = "0.37", default-features = false, features = ["system"] }# Routines: daily and weekly slots in local time.chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }@@ -99,6 +103,10 @@ tokio-tungstenite = { workspace = true, optional = true }reqwest = { version = "0.12", default-features = false, features = ["rustls-tls-native-roots"], optional = true }axum = { workspace = true, optional = true, features = ["json"] }+[target.'cfg(unix)'.dependencies]+# APFS private size (getattrlist).+libc = "0.2"+[dev-dependencies]cua-mesh = { workspace = true, features = ["testing"] }cua-sandbox-core = { workspace = true, features = ["testing"] }diff --git a/libs/cua/crates/cua-spaces/src/lib.rs b/libs/cua/crates/cua-spaces/src/lib.rsindex 57c30929f6..efad403dbc 100644--- a/libs/cua/crates/cua-spaces/src/lib.rs+++ b/libs/cua/crates/cua-spaces/src/lib.rs@@ -76,6 +76,7 @@ pub mod mesh;pub mod operator;pub mod registry;pub mod relay;+pub mod resources;pub mod routines;pub mod services;mod space;diff --git a/libs/cua/crates/cua-spaces/src/resources/disk.rs b/libs/cua/crates/cua-spaces/src/resources/disk.rsnew file mode 100644index 0000000000..e5522e4449--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/disk.rs@@ -0,0 +1,379 @@+//! What a local Space costs this computer's disk, as opposed to what the+//! guest sees, and what it was given (its allocation).+//!+//! A macOS Space is an APFS clone of its base image: its files share blocks+//! with other copies, so `st_blocks` counts the shared blocks again for each+//! copy. [`private_size`] asks APFS for the bytes only that file holds+//! (`ATTR_CMNEXT_PRIVATESIZE`), which is what deleting it frees. Where that+//! cannot be measured the number is left out and [`DiskOnHost::shares_space`]+//! says the Space shares with other copies.++use super::{DiskOnHost, MIB};+use cua_sandbox_core::state::{SandboxState, StateStore};+use cua_vmm::disk::allocated_size;+use std::path::{Path, PathBuf};++/// Allocated blocks beyond the private bytes that still count as "shares+/// space with other copies" (a few metadata blocks do not).+pub const SHARED_SLACK: u64 = 16 * MIB;++/// The bytes only one file holds.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Private {+ /// Measured: the bytes only this file holds.+ Bytes(u64),+ /// The volume cannot share blocks between files (not APFS), so the+ /// file's allocated blocks are its own.+ NotShared,+ /// It could not be measured (permissions, a vanished file).+ Unknown,+}++/// The bytes only `path` (a file) holds: `ATTR_CMNEXT_PRIVATESIZE` on APFS.+/// Off macOS no file system here shares blocks between files, so the answer+/// is [`Private::NotShared`].+pub fn private_size(path: &Path) -> Private {+ #[cfg(target_os = "macos")]+ {+ macos_private_size(path)+ }+ #[cfg(not(target_os = "macos"))]+ {+ let _ = path;+ Private::NotShared+ }+}++#[cfg(target_os = "macos")]+fn macos_private_size(path: &Path) -> Private {+ use std::os::unix::ffi::OsStrExt;+ // sys/attr.h: ATTR_BIT_MAP_COUNT, FSOPT_ATTR_CMN_EXTENDED and+ // ATTR_CMNEXT_PRIVATESIZE (a `forkattr`-word extended common attribute).+ const ATTR_BIT_MAP_COUNT: u16 = 5;+ const FSOPT_ATTR_CMN_EXTENDED: u32 = 0x20;+ const ATTR_CMNEXT_PRIVATESIZE: u32 = 0x8;+ #[repr(C, packed(4))]+ struct Reply {+ length: u32,+ private: i64,+ }+ let Ok(c) = std::ffi::CString::new(path.as_os_str().as_bytes()) else {+ return Private::Unknown;+ };+ // SAFETY: `attrlist` is plain data (zeroed is valid); `reply` is a+ // writable buffer of the size passed; `c` is NUL-terminated.+ let (rc, reply) = unsafe {+ let mut list: libc::attrlist = std::mem::zeroed();+ list.bitmapcount = ATTR_BIT_MAP_COUNT;+ list.forkattr = ATTR_CMNEXT_PRIVATESIZE;+ let mut reply = Reply {+ length: 0,+ private: 0,+ };+ let rc = libc::getattrlist(+ c.as_ptr(),+ (&mut list as *mut libc::attrlist).cast(),+ (&mut reply as *mut Reply).cast(),+ std::mem::size_of::<Reply>(),+ FSOPT_ATTR_CMN_EXTENDED,+ );+ (rc, reply)+ };+ if rc == 0 {+ return Private::Bytes(u64::try_from(reply.private).unwrap_or(0));+ }+ match std::io::Error::last_os_error().raw_os_error() {+ // A volume that does not know the attribute cannot share blocks.+ Some(libc::ENOTSUP | libc::EINVAL) => Private::NotShared,+ _ => Private::Unknown,+ }+}++fn allocated_file(path: &Path) -> u64 {+ allocated_size(path)+}++/// The private bytes of every file under `dir` (symlinks are not followed).+/// `Unknown` when any file could not be measured.+pub fn private_tree(dir: &Path) -> Private {+ let mut total = 0u64;+ let mut shared_capable = false;+ let mut stack = vec![dir.to_path_buf()];+ while let Some(next) = stack.pop() {+ let Ok(meta) = std::fs::symlink_metadata(&next) else {+ return Private::Unknown;+ };+ if meta.is_dir() {+ let Ok(rd) = std::fs::read_dir(&next) else {+ return Private::Unknown;+ };+ stack.extend(rd.flatten().map(|e| e.path()));+ } else if meta.is_file() {+ match private_size(&next) {+ Private::Bytes(b) => {+ shared_capable = true;+ total = total.saturating_add(b);+ }+ Private::NotShared => total = total.saturating_add(allocated_file(&next)),+ Private::Unknown => return Private::Unknown,+ }+ }+ }+ if shared_capable {+ Private::Bytes(total)+ } else {+ Private::NotShared+ }+}++/// What the Space whose files are under `dir` costs this computer. `None`+/// when there is nothing there to measure.+pub fn measure(dir: &Path) -> Option<DiskOnHost> {+ if !dir.exists() {+ return None;+ }+ let allocated = allocated_size(dir);+ Some(match private_tree(dir) {+ Private::Bytes(b) => DiskOnHost {+ bytes: Some(b),+ allocated,+ shares_space: allocated.saturating_sub(b) > SHARED_SLACK,+ },+ Private::NotShared => DiskOnHost {+ bytes: Some(allocated),+ allocated,+ shares_space: false,+ },+ // Could not measure: say only that a copy may share, never a number.+ Private::Unknown => DiskOnHost {+ bytes: None,+ allocated,+ shares_space: true,+ },+ })+}++/// A local Space's allocation and where its disk lives on this computer.+#[derive(Clone, Debug, Default, PartialEq, Eq)]+pub struct Footprint {+ /// The sandbox name (`local:<name>`).+ pub name: String,+ /// The engine word of its state file (`lume`, `qemu`, `gvisor`, ...).+ pub runtime: String,+ /// Cores given to it (0: unknown).+ pub cpus: u32,+ /// Memory given to it, bytes (0: unknown).+ pub memory: u64,+ /// Its disk's size limit, bytes (0: unknown).+ pub disk: u64,+ /// The directory holding its disk on this computer (VMs only).+ pub dir: Option<PathBuf>,+ /// Bytes `lume serve` reports its disk occupies, clones counted in+ /// full (0: not reported). The fallback when [`Footprint::dir`] cannot+ /// be read.+ pub reported: u64,+}++/// What `lume serve` says about one VM.+#[derive(Clone, Debug, Default, PartialEq, Eq)]+pub struct LumeFacts {+ /// VM name.+ pub name: String,+ /// Cores.+ pub cpus: u32,+ /// Memory, bytes.+ pub memory: u64,+ /// Disk size limit, bytes.+ pub disk_total: u64,+ /// Bytes its disk occupies, clones counted in full.+ pub reported: u64,+}++/// A qcow2 file's virtual size (what the guest can fill), from its header.+pub fn qcow2_virtual_size(path: &Path) -> Option<u64> {+ use std::io::Read;+ let mut f = std::fs::File::open(path).ok()?;+ let mut hdr = [0u8; 32];+ f.read_exact(&mut hdr).ok()?;+ (&hdr[..4] == b"QFI\xfb").then(|| u64::from_be_bytes(hdr[24..32].try_into().expect("8 bytes")))+}++/// The local Spaces' allocations, from their state files, `lume serve` and+/// each QEMU instance's disk. Nothing is started or connected.+pub fn footprints(+ store: &StateStore,+ layout: &cua_disk::Layout,+ lume: &[LumeFacts],+ lume_home: Option<&Path>,+) -> Vec<Footprint> {+ store+ .list_all()+ .into_iter()+ .filter_map(|s| match s {+ SandboxState::Local(l) if l.runtime_type != "direct" => Some(l),+ _ => None,+ })+ .map(|l| {+ let facts = lume.iter().find(|v| v.name == l.name);+ let mut f = Footprint {+ cpus: l.cpu_count.or(facts.map(|v| v.cpus)).unwrap_or(0),+ memory: l+ .memory_mb+ .map(|m| m.saturating_mul(MIB))+ .or(facts.map(|v| v.memory))+ .unwrap_or(0),+ disk: facts.map(|v| v.disk_total).unwrap_or(0),+ reported: facts.map(|v| v.reported).unwrap_or(0),+ name: l.name.clone(),+ runtime: l.runtime_type.clone(),+ dir: None,+ };+ match l.runtime_type.as_str() {+ "lume" => f.dir = lume_home.map(|h| h.join(&l.name)),+ "qemu" => {+ let dir = layout.qemu().join(&l.name);+ if f.disk == 0+ && let Some(state) =+ std::fs::read(dir.join("state.json")).ok().and_then(|b| {+ serde_json::from_slice::<cua_vmm::qemu::QemuState>(&b).ok()+ })+ {+ f.disk = qcow2_virtual_size(&state.disk).unwrap_or(0);+ }+ f.dir = Some(dir);+ }+ _ => {}+ }+ f+ })+ .collect()+}++#[cfg(test)]+mod tests {+ use super::*;+ use cua_sandbox_core::state::LocalState;++ fn write(path: &Path, mib: usize, byte: u8) {+ use std::io::Write;+ let mut f = std::fs::File::create(path).unwrap();+ let chunk = vec![byte; MIB as usize];+ for _ in 0..mib {+ f.write_all(&chunk).unwrap();+ }+ }++ #[test]+ fn a_plain_copy_counts_in_full() {+ let dir = tempfile::tempdir().unwrap();+ write(&dir.path().join("disk.img"), 4, 7);+ let d = measure(dir.path()).unwrap();+ assert!(d.allocated >= 4 * MIB);+ // Nothing else holds those blocks.+ assert_eq!(d.bytes, Some(d.allocated));+ assert!(!d.shares_space);+ }++ #[test]+ fn nothing_there_is_not_measured() {+ let dir = tempfile::tempdir().unwrap();+ assert_eq!(measure(&dir.path().join("gone")), None);+ }++ /// A clone shares its blocks with the original: only what the clone+ /// changed is its own (macOS, APFS).+ #[cfg(target_os = "macos")]+ #[test]+ fn a_clone_counts_only_what_it_changed() {+ use std::io::Write;+ use std::os::unix::ffi::OsStrExt;+ let dir = tempfile::tempdir().unwrap();+ let base = dir.path().join("base");+ let copy = dir.path().join("copy");+ std::fs::create_dir_all(&base).unwrap();+ std::fs::create_dir_all(©).unwrap();+ write(&base.join("disk.img"), 48, 9);+ let src = std::ffi::CString::new(base.join("disk.img").as_os_str().as_bytes()).unwrap();+ let dst = std::ffi::CString::new(copy.join("disk.img").as_os_str().as_bytes()).unwrap();+ // SAFETY: both are NUL-terminated paths.+ let rc = unsafe { libc::clonefile(src.as_ptr(), dst.as_ptr(), 0) };+ if rc != 0 {+ eprintln!("skipped: this volume cannot clone files");+ return;+ }+ if private_size(©.join("disk.img")) == Private::NotShared {+ eprintln!("skipped: not an APFS volume");+ return;+ }+ // 8 MiB of its own.+ let mut f = std::fs::OpenOptions::new()+ .append(true)+ .open(copy.join("disk.img"))+ .unwrap();+ f.write_all(&vec![1u8; (8 * MIB) as usize]).unwrap();+ f.sync_all().unwrap();+ let d = measure(©).unwrap();+ assert!(d.allocated >= 56 * MIB, "{d:?}");+ let own = d.bytes.expect("APFS reports private bytes");+ assert!((8 * MIB..24 * MIB).contains(&own), "own {own} of {d:?}");+ assert!(d.shares_space, "{d:?}");+ }++ #[test]+ fn a_qcow2_header_gives_the_virtual_size() {+ let dir = tempfile::tempdir().unwrap();+ let p = dir.path().join("disk.qcow2");+ let mut hdr = vec![0u8; 64];+ hdr[..4].copy_from_slice(b"QFI\xfb");+ hdr[24..32].copy_from_slice(&(80u64 << 30).to_be_bytes());+ std::fs::write(&p, hdr).unwrap();+ assert_eq!(qcow2_virtual_size(&p), Some(80 << 30));+ std::fs::write(&p, b"not a qcow2 file at all, just text........").unwrap();+ assert_eq!(qcow2_virtual_size(&p), None);+ }++ #[test]+ fn allocations_come_from_state_files_and_lume() {+ let home = tempfile::tempdir().unwrap();+ let store = StateStore::new(home.path().join("sandboxes"));+ for (name, runtime, cpus, mem) in [+ ("mac", "lume", None, None),+ ("box", "gvisor", Some(2), Some(2048)),+ ] {+ store+ .save(&SandboxState::Local(LocalState {+ name: name.into(),+ runtime_type: runtime.into(),+ status: "running".into(),+ cpu_count: cpus,+ memory_mb: mem,+ ..Default::default()+ }))+ .unwrap();+ }+ let lume = [LumeFacts {+ name: "mac".into(),+ cpus: 4,+ memory: 8 << 30,+ disk_total: 80 << 30,+ reported: 31 << 30,+ }];+ let layout = cua_disk::Layout::new(home.path());+ let lume_home = home.path().join("lume");+ let mut list = footprints(&store, &layout, &lume, Some(&lume_home));+ list.sort_by(|a, b| a.name.cmp(&b.name));+ assert_eq!(list.len(), 2);+ let b = &list[0];+ assert_eq!(+ (b.name.as_str(), b.cpus, b.memory, b.disk),+ ("box", 2, 2 << 30, 0)+ );+ assert_eq!(b.dir, None);+ let m = &list[1];+ assert_eq!(+ (m.cpus, m.memory, m.disk, m.reported),+ (4, 8 << 30, 80 << 30, 31 << 30)+ );+ assert_eq!(m.dir, Some(lume_home.join("mac")));+ }+}diff --git a/libs/cua/crates/cua-spaces/src/resources/host.rs b/libs/cua/crates/cua-spaces/src/resources/host.rsnew file mode 100644index 0000000000..2e8c1644ed--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/host.rs@@ -0,0 +1,135 @@+//! This computer's processor and memory (sysinfo) and the volume that holds+//! Spaces (`statvfs`).++use cua_vmm::disk;+use std::path::{Path, PathBuf};+use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System};++/// Processor and memory now.+#[derive(Clone, Copy, Debug, Default, PartialEq)]+pub struct HostSample {+ /// Cores.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// Memory in use, bytes, without reclaimable cache.+ pub memory_used: u64,+}++/// Reads this computer's processor and memory. Keep one: a busy percentage+/// is the change since the previous read, so a first read waits+/// [`sysinfo::MINIMUM_CPU_UPDATE_INTERVAL`] and later ones do not.+pub struct HostSampler {+ system: System,+ primed: bool,+}++impl Default for HostSampler {+ fn default() -> Self {+ Self::new()+ }+}++impl HostSampler {+ /// A sampler that has not read yet.+ pub fn new() -> Self {+ Self {+ system: System::new_with_specifics(+ RefreshKind::nothing()+ .with_cpu(CpuRefreshKind::nothing().with_cpu_usage())+ .with_memory(MemoryRefreshKind::everything()),+ ),+ primed: false,+ }+ }++ /// Reads now. Blocks for a moment on the first call: run it on a+ /// blocking thread.+ pub fn sample(&mut self) -> HostSample {+ if !self.primed {+ std::thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL);+ self.primed = true;+ }+ self.system.refresh_cpu_usage();+ self.system.refresh_memory();+ HostSample {+ cpu_count: self.system.cpus().len() as u32,+ cpu_percent: f64::from(self.system.global_cpu_usage()).clamp(0.0, 100.0),+ load_average_1m: System::load_average().one.max(0.0),+ memory_total: self.system.total_memory(),+ memory_used: self.system.used_memory().min(self.system.total_memory()),+ }+ }+}++/// Total and free bytes of the volume that holds Spaces.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub struct Volume {+ /// Volume size.+ pub total: u64,+ /// Free bytes available to this user.+ pub free: u64,+}++/// The volumes Spaces are stored on: the cua home (QEMU disks, images,+/// containers) and Lume's VM store. Only paths that exist.+pub fn space_paths(home: &Path) -> Vec<PathBuf> {+ let mut paths = vec![home.to_path_buf()];+ if let Some(lume) = lume_home() {+ paths.push(lume);+ }+ paths+}++/// Lume's VM store (`~/.lume`), when it exists.+pub fn lume_home() -> Option<PathBuf> {+ let dir = std::env::var_os("HOME")+ .or_else(|| std::env::var_os("USERPROFILE"))+ .map(PathBuf::from)?+ .join(".lume");+ dir.is_dir().then_some(dir)+}++/// The most constrained of the volumes at `paths` (the least free space):+/// what fills first is what matters. `None` when none can be read.+pub fn most_constrained(paths: &[PathBuf]) -> Option<Volume> {+ paths+ .iter()+ .filter_map(|p| disk::space(p).ok())+ .map(|s| Volume {+ total: s.total,+ free: s.available,+ })+ .min_by_key(|v| v.free)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn this_computer_has_cores_and_memory() {+ let mut s = HostSampler::new();+ let a = s.sample();+ assert!(a.cpu_count >= 1);+ assert!(a.memory_total > 0);+ assert!(a.memory_used <= a.memory_total);+ assert!((0.0..=100.0).contains(&a.cpu_percent));+ // A second read works without the first-read pause.+ assert_eq!(s.sample().cpu_count, a.cpu_count);+ }++ #[test]+ fn the_tightest_volume_wins() {+ let dir = tempfile::tempdir().unwrap();+ let v = most_constrained(&[dir.path().to_path_buf()]).unwrap();+ assert!(v.total > 0 && v.free <= v.total);+ assert_eq!(most_constrained(&[]), None);+ // A path that does not exist yet reads its nearest parent.+ assert!(most_constrained(&[dir.path().join("not/here")]).is_some());+ }+}diff --git a/libs/cua/crates/cua-spaces/src/resources/hub.rs b/libs/cua/crates/cua-spaces/src/resources/hub.rsnew file mode 100644index 0000000000..dbdf6664bf--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/hub.rs@@ -0,0 +1,591 @@+//! The sampler, its cache and its watchers.+//!+//! One [`Hub`] per runtime. Nothing runs until somebody is interested: a+//! watcher ([`Spaces::watch_resources`]) or a poll that says a window is+//! visible ([`Spaces::resources`] with `visible`). While interest lasts, a+//! task samples every [`VISIBLE_TICK`] (a visible window) or [`HIDDEN_TICK`]+//! (only hidden watchers, for the menu bar warning), then ends.++use super::disk::{self, Footprint, LumeFacts};+use super::host::{self, HostSampler};+use super::{+ ComputerResources, DISK_MEASURE_EVERY, DiskLevel, DiskOnHost, DiskWarning, GuestUsage,+ HIDDEN_TICK, MAX_AGE, POLL_LEASE, Resources, ResourcesEvent, SpaceResources, THIS_MAC,+ VISIBLE_TICK, now_ms, summary,+};+use crate::Spaces;+use std::collections::{HashMap, VecDeque};+use std::sync::{Arc, Mutex};+use std::time::{Duration, Instant};+use tokio::sync::{Notify, watch};++/// How long one Space gets to answer `Metrics` in a sample.+const METRICS_TIMEOUT: Duration = Duration::from_secs(3);+/// How long Lume's list is reused.+const LUME_REUSE: Duration = Duration::from_secs(30);+/// A snapshot this young is reused by whoever asks next.+const SAME_SAMPLE: Duration = Duration::from_millis(500);++/// What one sample asks for.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub struct Measure {+ /// Measure what each Space costs this computer's disk.+ pub disk: bool,+ /// Ask each running guest what it uses (`SystemService.Metrics`).+ pub guests: bool,+}++impl Measure {+ /// Everything: what the daemon's sampler does.+ pub const ALL: Measure = Measure {+ disk: true,+ guests: true,+ };+}++/// Who wants fresh numbers, and the last snapshot.+pub(crate) struct Hub {+ shared: Mutex<Shared>,+ wake: Notify,+ tx: watch::Sender<Option<Arc<Resources>>>,+ sampler: tokio::sync::Mutex<Sampler>,+}++#[derive(Default)]+struct Shared {+ visible: usize,+ hidden: usize,+ lease_until: Option<Instant>,+ running: bool,+ last: Option<(Arc<Resources>, Instant)>,+}++impl Shared {+ /// How long until the next sample, or `None` when nobody is+ /// interested.+ fn tick(&self, now: Instant) -> Option<Duration> {+ let leased = self.lease_until.is_some_and(|t| t > now);+ if self.visible > 0 || leased {+ Some(VISIBLE_TICK)+ } else if self.hidden > 0 {+ Some(HIDDEN_TICK)+ } else {+ None+ }+ }+}++struct Sampler {+ host: Arc<Mutex<HostSampler>>,+ sequence: u64,+ level: DiskLevel,+ disks: HashMap<String, Measured>,+ lume: Option<(Instant, Vec<LumeFacts>)>,+}++impl Sampler {+ fn new() -> Self {+ Sampler {+ host: Arc::new(Mutex::new(HostSampler::new())),+ sequence: 0,+ level: DiskLevel::Ok,+ disks: HashMap::new(),+ lume: None,+ }+ }+}++struct Measured {+ at: Instant,+ power_state: String,+ value: Option<DiskOnHost>,+}++impl Hub {+ pub(crate) fn new() -> Arc<Self> {+ Arc::new(Self {+ shared: Mutex::new(Shared::default()),+ wake: Notify::new(),+ tx: watch::channel(None).0,+ sampler: tokio::sync::Mutex::new(Sampler::new()),+ })+ }++ fn cached(&self) -> Option<(Arc<Resources>, Instant)> {+ self.shared.lock().expect("hub").last.clone()+ }++ fn publish(&self, snap: Arc<Resources>) {+ self.shared.lock().expect("hub").last = Some((snap.clone(), Instant::now()));+ self.tx.send_replace(Some(snap));+ }+}++/// A subscription to [`ResourcesEvent`]s: a snapshot first, then updates+/// that moved past the thresholds, and a [`ResourcesEvent::LowDisk`] each+/// time the warning level changes. Dropping it ends the interest.+pub struct ResourceWatch {+ hub: Arc<Hub>,+ rx: watch::Receiver<Option<Arc<Resources>>>,+ visible: bool,+ /// What the receiver holds after everything sent so far.+ sent: Option<Resources>,+ level: DiskLevel,+ pending: VecDeque<ResourcesEvent>,+ first: bool,+}++impl ResourceWatch {+ /// The next event; `None` when the runtime is gone.+ pub async fn next(&mut self) -> Option<ResourcesEvent> {+ loop {+ if let Some(e) = self.pending.pop_front() {+ return Some(e);+ }+ let snap = if self.first {+ self.first = false;+ // A snapshot a moment old is the start; otherwise the one+ // the sample this watcher woke is about to publish.+ let fresh = self+ .hub+ .cached()+ .filter(|(_, at)| at.elapsed() < VISIBLE_TICK + MAX_AGE)+ .map(|(s, _)| s);+ match fresh {+ Some(s) => {+ self.rx.borrow_and_update();+ s+ }+ None => self.next_published().await?,+ }+ } else {+ self.next_published().await?+ };+ match self.sent.as_mut() {+ None => {+ self.level = snap.warning.level;+ self.sent = Some((*snap).clone());+ self.pending+ .push_back(ResourcesEvent::Snapshot((*snap).clone()));+ }+ Some(sent) => {+ let update = snap.update_since(sent);+ if !update.is_empty() {+ sent.apply(&update);+ self.pending.push_back(ResourcesEvent::Update(update));+ }+ if snap.warning.level != self.level {+ self.level = snap.warning.level;+ self.pending+ .push_back(ResourcesEvent::LowDisk(snap.warning));+ }+ }+ }+ }+ }++ async fn next_published(&mut self) -> Option<Arc<Resources>> {+ loop {+ self.rx.changed().await.ok()?;+ if let Some(s) = self.rx.borrow_and_update().clone() {+ return Some(s);+ }+ }+ }++ /// Whether a window shows the numbers: visible watchers get a sample+ /// every [`VISIBLE_TICK`], hidden ones every [`HIDDEN_TICK`] (and still+ /// every warning change).+ pub fn set_visible(&mut self, visible: bool) {+ if visible == self.visible {+ return;+ }+ {+ let mut s = self.hub.shared.lock().expect("hub");+ if visible {+ s.hidden = s.hidden.saturating_sub(1);+ s.visible += 1;+ } else {+ s.visible = s.visible.saturating_sub(1);+ s.hidden += 1;+ }+ }+ self.visible = visible;+ self.hub.wake.notify_one();+ }+}++impl Drop for ResourceWatch {+ fn drop(&mut self) {+ {+ let mut s = self.hub.shared.lock().expect("hub");+ if self.visible {+ s.visible = s.visible.saturating_sub(1);+ } else {+ s.hidden = s.hidden.saturating_sub(1);+ }+ }+ self.hub.wake.notify_one();+ }+}++impl Spaces {+ /// What this Mac, its extra Spaces and your other computers use now.+ /// A snapshot a few seconds old is returned as it is. With `visible`,+ /// the call also says a window shows the numbers for the next+ /// [`POLL_LEASE`], so the daemon samples every [`VISIBLE_TICK`]: call+ /// it every 10 s while the window is visible.+ pub async fn resources(&self, visible: bool) -> crate::Result<Resources> {+ let hub = self.inner.resources.clone();+ if visible {+ hub.shared.lock().expect("hub").lease_until = Some(Instant::now() + POLL_LEASE);+ self.ensure_resources_loop();+ }+ let reuse = if visible {+ VISIBLE_TICK + MAX_AGE+ } else {+ MAX_AGE+ };+ if let Some((snap, at)) = hub.cached()+ && at.elapsed() < reuse+ {+ return Ok((*snap).clone());+ }+ Ok((*self.sample_resources().await).clone())+ }++ /// One sample taken now, outside the shared sampler: for a command that+ /// runs once (the CLI). Nothing is cached or kept running. With+ /// [`Measure::disk`] false the Spaces' disks are not measured (their+ /// `disk_on_host` is empty: `cua spaces ls --no-size`), and with+ /// [`Measure::guests`] false no guest is asked what it uses (`usage`+ /// is empty), which keeps a command fast when a Space does not answer.+ pub async fn resources_now(&self, ask: Measure) -> Resources {+ let mut st = Sampler::new();+ self.collect_resources(&mut st, ask).await+ }++ /// A subscription to resource events ([`ResourceWatch`]). `visible` says+ /// a window shows the numbers now ([`ResourceWatch::set_visible`]).+ pub fn watch_resources(&self, visible: bool) -> ResourceWatch {+ let hub = self.inner.resources.clone();+ {+ let mut s = hub.shared.lock().expect("hub");+ if visible {+ s.visible += 1;+ } else {+ s.hidden += 1;+ }+ }+ self.ensure_resources_loop();+ ResourceWatch {+ rx: hub.tx.subscribe(),+ hub,+ visible,+ sent: None,+ level: DiskLevel::Ok,+ pending: VecDeque::new(),+ first: true,+ }+ }++ /// Starts the sampling task when none runs; wakes it when one does.+ fn ensure_resources_loop(&self) {+ let hub = self.inner.resources.clone();+ {+ let mut s = hub.shared.lock().expect("hub");+ if s.running {+ drop(s);+ hub.wake.notify_one();+ return;+ }+ s.running = true;+ }+ let weak = Arc::downgrade(&self.inner);+ tokio::spawn(async move {+ loop {+ let tick = {+ let mut s = hub.shared.lock().expect("hub");+ match s.tick(Instant::now()) {+ Some(t) => t,+ None => {+ s.running = false;+ return;+ }+ }+ };+ {+ let Some(inner) = weak.upgrade() else { return };+ Spaces { inner }.sample_resources().await;+ }+ tokio::select! {+ _ = tokio::time::sleep(tick) => {}+ _ = hub.wake.notified() => {}+ }+ }+ });+ }++ /// Samples now (one sample at a time; a caller that waited gets the+ /// sample taken meanwhile).+ pub(crate) async fn sample_resources(&self) -> Arc<Resources> {+ let hub = self.inner.resources.clone();+ let mut st = hub.sampler.lock().await;+ if let Some((snap, at)) = hub.cached()+ && at.elapsed() < SAME_SAMPLE+ {+ return snap;+ }+ let snap = Arc::new(self.collect_resources(&mut st, Measure::ALL).await);+ hub.publish(snap.clone());+ snap+ }++ async fn lume_facts(&self, st: &mut Sampler) -> Vec<LumeFacts> {+ if let Some((at, facts)) = &st.lume+ && at.elapsed() < LUME_REUSE+ {+ return facts.clone();+ }+ let facts = lume_facts().await;+ st.lume = Some((Instant::now(), facts.clone()));+ facts+ }++ /// One sample of everything. Degrades instead of failing: a Space that+ /// does not answer simply has no `usage`.+ async fn collect_resources(&self, st: &mut Sampler, ask: Measure) -> Resources {+ let home = self.home_dir().to_path_buf();+ // This computer.+ let hs = st.host.clone();+ let host = tokio::task::spawn_blocking(move || hs.lock().expect("host sampler").sample())+ .await+ .unwrap_or_default();+ let paths = host::space_paths(&home);+ let volume = tokio::task::spawn_blocking(move || host::most_constrained(&paths))+ .await+ .ok()+ .flatten()+ .unwrap_or_default();+ let min_free = cua_vmm::disk::CacheConfig::load().min_free;+ let warning = DiskWarning::assess(volume.free, volume.total, min_free, st.level);+ st.level = warning.level;++ // Extra Spaces: the local ones.+ let infos: Vec<_> = self+ .list()+ .unwrap_or_default()+ .into_iter()+ .filter(|i| i.id.starts_with("local:") && i.host.is_empty())+ .collect();+ let lume = self.lume_facts(st).await;+ let store = self.inner.sandboxes.state().clone();+ let layout = cua_disk::Layout::new(&home);+ let lume_home = host::lume_home();+ let facts = {+ let (store, layout, lume_home) = (store.clone(), layout.clone(), lume_home.clone());+ let lume = lume.clone();+ tokio::task::spawn_blocking(move || {+ disk::footprints(&store, &layout, &lume, lume_home.as_deref())+ })+ .await+ .unwrap_or_default()+ };+ let now = Instant::now();+ let ids: Vec<String> = infos.iter().map(|i| i.id.clone()).collect();+ st.disks.retain(|id, _| ids.contains(id));+ // Disks: measured when new, after a power change, or when old.+ let mut due: Vec<(String, Footprint, String)> = Vec::new();+ for info in &infos {+ let name = info.id.trim_start_matches("local:");+ let Some(fp) = facts.iter().find(|f| f.name == name) else {+ continue;+ };+ let stale = st.disks.get(&info.id).is_none_or(|m| {+ m.power_state != info.power_state || now.duration_since(m.at) >= DISK_MEASURE_EVERY+ });+ if stale && ask.disk {+ due.push((info.id.clone(), fp.clone(), info.power_state.clone()));+ }+ }+ let measured =+ futures_util::future::join_all(due.into_iter().map(|(id, fp, power)| async move {+ let value = tokio::task::spawn_blocking(move || measure_footprint(&fp))+ .await+ .unwrap_or(None);+ (id, power, value)+ }))+ .await;+ for (id, power_state, value) in measured {+ st.disks.insert(+ id,+ Measured {+ at: Instant::now(),+ power_state,+ value,+ },+ );+ }+ // Guests: only the ones that run, each asked at once, each bounded.+ let usages = futures_util::future::join_all(infos.iter().map(|info| async move {+ let off = matches!(info.power_state.as_str(), "suspended" | "stopped");+ if !ask.guests || off || info.spacesd_version.is_empty() {+ return None;+ }+ let ask = async {+ let space = self.space(&info.id).await.ok()?;+ space.usage().await.ok()+ };+ tokio::time::timeout(METRICS_TIMEOUT, ask)+ .await+ .ok()+ .flatten()+ .map(GuestUsage::from)+ }))+ .await;+ let spaces: Vec<SpaceResources> = infos+ .iter()+ .zip(usages)+ .map(|(info, usage)| {+ let name = info.id.trim_start_matches("local:");+ let fp = facts.iter().find(|f| f.name == name);+ // A guest that reports its own limits fills what the state+ // file did not record.+ let own = usage.filter(|u| u.memory_limited || u.disk_limited);+ SpaceResources {+ id: info.id.clone(),+ power_state: info.power_state.clone(),+ cpu_allocated: fp+ .map(|f| f.cpus)+ .filter(|c| *c > 0)+ .or(own.map(|u| u.cpu_count))+ .unwrap_or(0),+ memory_allocated: fp+ .map(|f| f.memory)+ .filter(|m| *m > 0)+ .or(own.filter(|u| u.memory_limited).map(|u| u.memory_total))+ .unwrap_or(0),+ disk_allocated: fp+ .map(|f| f.disk)+ .filter(|d| *d > 0)+ .or(own.filter(|u| u.disk_limited).map(|u| u.disk_total))+ .unwrap_or(0),+ usage,+ disk_on_host: st.disks.get(&info.id).and_then(|m| m.value),+ }+ })+ .collect();++ let mut this_mac = ComputerResources {+ id: THIS_MAC.into(),+ online: true,+ sampled_at_ms: now_ms(),+ cpu_count: host.cpu_count,+ cpu_percent: host.cpu_percent,+ load_average_1m: host.load_average_1m,+ memory_total: host.memory_total,+ memory_used: host.memory_used,+ disk_total: volume.total,+ disk_free: volume.free,+ warning,+ spaces_disk_exact: true,+ ..Default::default()+ };+ totals(&mut this_mac, &spaces);++ st.sequence += 1;+ Resources {+ sequence: st.sequence,+ sampled_at_ms: this_mac.sampled_at_ms,+ warning,+ computers: self.other_computers(),+ this_mac,+ spaces,+ }+ }++ /// Your other computers, from the summary each published in its relay+ /// machine record. Reads the machine list already fetched+ /// ([`Spaces::relay_machines`]): no relay call of its own.+ pub fn other_computers(&self) -> Vec<ComputerResources> {+ let own = self.this_relay_machine_id();+ let cache = self.inner.relay_cache.lock().expect("relay cache");+ cache+ .iter()+ .filter(|m| own.as_deref() != Some(m.id.as_str()))+ .filter_map(|m| {+ let value = m.meta.get(summary::META_KEY)?;+ summary::decode(&m.id, &m.name, m.online, value)+ })+ .collect()+ }+}++/// The extra-Space totals of a computer.+pub(crate) fn totals(c: &mut ComputerResources, spaces: &[SpaceResources]) {+ c.spaces_count = spaces.len() as u32;+ c.spaces_disk_exact = true;+ for s in spaces {+ let running = s.power_state == "running" || (s.power_state.is_empty() && s.usage.is_some());+ if running {+ c.spaces_running += 1;+ c.spaces_cpu_allocated += s.cpu_allocated;+ c.spaces_memory_allocated += s.memory_allocated;+ c.spaces_memory_used += s.usage.map(|u| u.memory_used).unwrap_or(0);+ }+ if let Some(d) = &s.disk_on_host {+ match d.bytes {+ Some(b) => c.spaces_disk_bytes += b,+ None => {+ c.spaces_disk_bytes += d.allocated;+ c.spaces_disk_exact = false;+ }+ }+ }+ }+}++/// What the Space with `fp` costs this computer's disk.+fn measure_footprint(fp: &Footprint) -> Option<DiskOnHost> {+ let dir = fp.dir.as_deref()?;+ disk::measure(dir).or_else(|| {+ // Lume's directory is somewhere else: only Lume's own count, which+ // clones count in full.+ (fp.reported > 0).then_some(DiskOnHost {+ bytes: None,+ allocated: fp.reported,+ shares_space: true,+ })+ })+}++/// What `lume serve` says about its VMs, when it already answers (macOS+/// only; never started).+async fn lume_facts() -> Vec<LumeFacts> {+ if !cfg!(target_os = "macos") {+ return Vec::new();+ }+ let client = cua_vmm::lume::LumeClient::new(cua_vmm::lume::LumeConfig::default().url);+ let read = async {+ if !client.reachable().await {+ return Vec::new();+ }+ client.list().await.unwrap_or_default()+ };+ tokio::time::timeout(Duration::from_secs(2), read)+ .await+ .unwrap_or_default()+ .into_iter()+ .map(|v| LumeFacts {+ cpus: v.cpu_count,+ memory: v.memory_size,+ disk_total: cua_vmm::lume::client::disk_total_bytes(&v.disk_size).unwrap_or(0),+ reported: v+ .disk_size+ .get("allocated")+ .and_then(|a| a.as_u64())+ .unwrap_or(0),+ name: v.name,+ })+ .collect()+}diff --git a/libs/cua/crates/cua-spaces/src/resources/mod.rs b/libs/cua/crates/cua-spaces/src/resources/mod.rsnew file mode 100644index 0000000000..2e9f56ea94--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/mod.rs@@ -0,0 +1,466 @@+//! What this Mac, its extra Spaces and your other computers use: processor,+//! memory and disk, for the apps, the menu bar and the CLI.+//!+//! * [`Resources`] is one snapshot: [`ComputerResources`] for this Mac, a+//! [`SpaceResources`] per extra (local) Space, and one+//! [`ComputerResources`] per other computer that published a summary.+//! * [`Spaces::resources`] reads a snapshot (cached for a few seconds);+//! [`Spaces::watch_resources`] streams a snapshot, then changes only+//! ([`ResourcesUpdate`]), and a [`DiskWarning`] whenever the low-disk+//! level changes.+//! * One sampler per runtime does the work. It ticks every+//! [`VISIBLE_TICK`] while a client says a window is visible, every+//! [`HIDDEN_TICK`] otherwise (the menu bar warning still needs it), and+//! measures a Space's disk at most every [`DISK_MEASURE_EVERY`].+//! * Other computers publish [`summary`] numbers through the relay+//! machine record (`meta`); reading them costs nothing extra because the+//! machine list is already fetched.+//!+//! Numbers only: counts, bytes and percentages. Never file names, paths,+//! process names or window titles.++use serde::{Deserialize, Serialize};+use std::time::Duration;++pub mod disk;+pub mod host;+mod hub;+pub mod publish;+pub mod summary;+mod wire;+pub mod words;++pub(crate) use hub::Hub;+pub use hub::{Measure, ResourceWatch};++/// One GiB.+pub const GIB: u64 = 1 << 30;+/// One MiB.+pub const MIB: u64 = 1 << 20;++/// How often the sampler runs while a client says a window is visible.+pub const VISIBLE_TICK: Duration = Duration::from_secs(10);+/// How often it runs with no visible window (the menu bar warning).+pub const HIDDEN_TICK: Duration = Duration::from_secs(300);+/// A [`Spaces::resources`] poll with `visible` counts as a visible window+/// for this long.+pub const POLL_LEASE: Duration = Duration::from_secs(30);+/// A snapshot younger than this is returned as it is.+pub const MAX_AGE: Duration = Duration::from_secs(5);+/// One Space's disk is measured at most this often (and again after it is+/// created, deleted or changes power state).+pub const DISK_MEASURE_EVERY: Duration = Duration::from_secs(300);++/// An update carries an entry only when a percentage moved by more than+/// this many points ...+pub const DELTA_POINTS: f64 = 1.0;+/// ... or a size moved by more than this many bytes.+pub const DELTA_BYTES: u64 = 256 * MIB;++/// Free disk below this many bytes warns, unless the volume is so small that+/// [`LOW_FREE_PERCENT`] of it is more.+pub const LOW_FREE_FLOOR: u64 = 50 * GIB;+/// Free disk below this share of the volume warns ...+pub const LOW_FREE_PERCENT: u64 = 15;+/// ... but the line never rises above this, so a big disk does not nag.+pub const LOW_FREE_CAP: u64 = 100 * GIB;+/// A cleared warning stays until free space is this far above its line.+pub const WARNING_HYSTERESIS: u64 = 2 * GIB;++/// The id of this Mac in [`Resources::this_mac`].+pub const THIS_MAC: &str = "this-mac";++/// How low the free disk is.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum DiskLevel {+ /// Plenty.+ #[default]+ Ok,+ /// Under the warning line ([`low_line`]).+ Low,+ /// Under the floor where creates already fail (`CUA_DISK_MIN_FREE`).+ Critical,+}++impl DiskLevel {+ /// `ok`, `low` or `critical`.+ pub fn as_str(self) -> &'static str {+ match self {+ DiskLevel::Ok => "ok",+ DiskLevel::Low => "low",+ DiskLevel::Critical => "critical",+ }+ }++ /// The inverse of [`DiskLevel::as_str`]; anything else is `Ok`.+ pub fn parse(word: &str) -> Self {+ match word {+ "low" => DiskLevel::Low,+ "critical" => DiskLevel::Critical,+ _ => DiskLevel::Ok,+ }+ }+}++/// The low-disk signal for the UI and the menu bar.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct DiskWarning {+ /// How low it is.+ pub level: DiskLevel,+ /// Free bytes on the volume that holds Spaces.+ pub free: u64,+ /// Size of that volume.+ pub total: u64,+ /// The line that was crossed (0 when [`DiskLevel::Ok`]).+ pub threshold: u64,+}++/// The free-space line below which a volume of `total` bytes warns: 50 GiB+/// or 15% of the volume, whichever is higher, never above 100 GiB.+pub fn low_line(total: u64) -> u64 {+ (total / 100 * LOW_FREE_PERCENT).clamp(LOW_FREE_FLOOR, LOW_FREE_CAP)+}++impl DiskWarning {+ /// The warning for `free` of `total` bytes. `min_free` is the floor+ /// where creates fail. `previous` makes a raised warning stay until+ /// free space is [`WARNING_HYSTERESIS`] above its line, so it does not+ /// flicker.+ pub fn assess(free: u64, total: u64, min_free: u64, previous: DiskLevel) -> Self {+ let line = low_line(total);+ let keeps = |at_least: DiskLevel, line: u64| {+ previous >= at_least && free < line.saturating_add(WARNING_HYSTERESIS)+ };+ let (level, threshold) = if free < min_free || keeps(DiskLevel::Critical, min_free) {+ (DiskLevel::Critical, min_free)+ } else if free < line || keeps(DiskLevel::Low, line) {+ (DiskLevel::Low, line)+ } else {+ (DiskLevel::Ok, 0)+ };+ DiskWarning {+ level,+ free,+ total,+ threshold,+ }+ }+}++/// A computer: this Mac, or one of your other computers (from its summary).+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ComputerResources {+ /// [`THIS_MAC`], or the relay machine id.+ pub id: String,+ /// Display name (empty for this Mac).+ pub name: String,+ /// Reachable now (always true for this Mac).+ pub online: bool,+ /// When the computer measured this, unix ms (another computer's can be+ /// minutes old).+ pub sampled_at_ms: u64,+ /// Processor cores.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// Memory in use, bytes (without reclaimable cache).+ pub memory_used: u64,+ /// Size of the volume that holds Spaces, bytes.+ pub disk_total: u64,+ /// Free bytes on it.+ pub disk_free: u64,+ /// Extra Spaces on it.+ pub spaces_count: u32,+ /// Of those, running.+ pub spaces_running: u32,+ /// Cores given to the running ones.+ pub spaces_cpu_allocated: u32,+ /// Memory given to the running ones, bytes.+ pub spaces_memory_allocated: u64,+ /// Memory the running guests report in use, bytes.+ pub spaces_memory_used: u64,+ /// Bytes all its extra Spaces take on it.+ pub spaces_disk_bytes: u64,+ /// False when some Space's disk could only be estimated.+ pub spaces_disk_exact: bool,+ /// The low-disk signal.+ pub warning: DiskWarning,+}++/// What `SystemService.Metrics` reports from inside a Space.+#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct GuestUsage {+ /// Cores the guest sees.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average.+ pub load_average_1m: f64,+ /// Memory in use, bytes.+ pub memory_used: u64,+ /// Memory size, bytes.+ pub memory_total: u64,+ /// `memory_total` is the guest's own limit.+ pub memory_limited: bool,+ /// Disk in use, bytes.+ pub disk_used: u64,+ /// Disk size, bytes.+ pub disk_total: u64,+ /// `disk_total` is the guest's own disk.+ pub disk_limited: bool,+}++impl From<crate::stream::Usage> for GuestUsage {+ fn from(u: crate::stream::Usage) -> Self {+ GuestUsage {+ cpu_count: u.cpu_count,+ cpu_percent: u.cpu_percent,+ load_average_1m: u.load_average_1m,+ memory_used: u.memory_used,+ memory_total: u.memory_total,+ memory_limited: u.memory_limited,+ disk_used: u.disk_used,+ disk_total: u.disk_total,+ disk_limited: u.disk_limited,+ }+ }+}++/// What a Space costs this Mac, as opposed to what the guest sees.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct DiskOnHost {+ /// Bytes only this Space holds (what deleting it frees). `None` when+ /// they could not be measured.+ pub bytes: Option<u64>,+ /// Blocks its files occupy, clones counted in full: an upper bound.+ pub allocated: u64,+ /// Part of it is shared with other copies.+ pub shares_space: bool,+}++/// One extra Space on this Mac.+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct SpaceResources {+ /// `local:<name>`.+ pub id: String,+ /// `running`, `stopped`, `suspended`, or empty when unknown.+ pub power_state: String,+ /// Cores given to it (0: unknown).+ pub cpu_allocated: u32,+ /// Memory given to it, bytes (0: unknown).+ pub memory_allocated: u64,+ /// Its disk's size limit, bytes (0: unknown).+ pub disk_allocated: u64,+ /// The guest's own numbers; `None` while it is off or unreachable.+ pub usage: Option<GuestUsage>,+ /// What it costs this Mac; `None` for a container.+ pub disk_on_host: Option<DiskOnHost>,+}++/// One sample of everything.+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct Resources {+ /// Grows by one per sample.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac.+ pub this_mac: ComputerResources,+ /// Extra Spaces on this Mac.+ pub spaces: Vec<SpaceResources>,+ /// Your other computers, from their summaries.+ pub computers: Vec<ComputerResources>,+ /// [`ComputerResources::warning`] of this Mac, for the menu bar.+ pub warning: DiskWarning,+}++/// What changed between two snapshots, past [`DELTA_POINTS`] and+/// [`DELTA_BYTES`].+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct ResourcesUpdate {+ /// The snapshot it brings the receiver to.+ pub sequence: u64,+ /// Unix ms.+ pub sampled_at_ms: u64,+ /// This Mac, when it changed.+ pub this_mac: Option<ComputerResources>,+ /// Extra Spaces that changed or appeared (replace by `id`).+ pub spaces: Vec<SpaceResources>,+ /// Other computers that changed or appeared (replace by `id`).+ pub computers: Vec<ComputerResources>,+ /// Ids that are gone.+ pub removed: Vec<String>,+}++impl ResourcesUpdate {+ /// Nothing changed.+ pub fn is_empty(&self) -> bool {+ self.this_mac.is_none()+ && self.spaces.is_empty()+ && self.computers.is_empty()+ && self.removed.is_empty()+ }+}++/// What a watcher receives.+#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]+#[serde(rename_all = "camelCase", tag = "type", content = "value")]+pub enum ResourcesEvent {+ /// Everything, once at the start.+ Snapshot(Resources),+ /// Only what changed.+ Update(ResourcesUpdate),+ /// The low-disk level changed (including back to `ok`).+ LowDisk(DiskWarning),+}++fn moved(a: f64, b: f64) -> bool {+ (a - b).abs() > DELTA_POINTS+}++fn grew(a: u64, b: u64) -> bool {+ a.abs_diff(b) > DELTA_BYTES+}++impl ComputerResources {+ /// Whether `self` differs from `sent` by more than an update carries.+ pub fn differs(&self, sent: &ComputerResources) -> bool {+ self.id != sent.id+ || self.name != sent.name+ || self.online != sent.online+ || self.cpu_count != sent.cpu_count+ || moved(self.cpu_percent, sent.cpu_percent)+ || grew(self.memory_total, sent.memory_total)+ || grew(self.memory_used, sent.memory_used)+ || grew(self.disk_total, sent.disk_total)+ || grew(self.disk_free, sent.disk_free)+ || self.spaces_count != sent.spaces_count+ || self.spaces_running != sent.spaces_running+ || self.spaces_cpu_allocated != sent.spaces_cpu_allocated+ || grew(self.spaces_memory_allocated, sent.spaces_memory_allocated)+ || grew(self.spaces_memory_used, sent.spaces_memory_used)+ || grew(self.spaces_disk_bytes, sent.spaces_disk_bytes)+ || self.spaces_disk_exact != sent.spaces_disk_exact+ || self.warning.level != sent.warning.level+ }+}++impl SpaceResources {+ /// Whether `self` differs from `sent` by more than an update carries.+ pub fn differs(&self, sent: &SpaceResources) -> bool {+ let usage = match (&self.usage, &sent.usage) {+ (None, None) => false,+ (Some(a), Some(b)) => {+ a.cpu_count != b.cpu_count+ || moved(a.cpu_percent, b.cpu_percent)+ || grew(a.memory_used, b.memory_used)+ || grew(a.memory_total, b.memory_total)+ || grew(a.disk_used, b.disk_used)+ || grew(a.disk_total, b.disk_total)+ }+ _ => true,+ };+ let disk = match (&self.disk_on_host, &sent.disk_on_host) {+ (None, None) => false,+ (Some(a), Some(b)) => {+ a.shares_space != b.shares_space+ || a.bytes.is_some() != b.bytes.is_some()+ || grew(a.bytes.unwrap_or(0), b.bytes.unwrap_or(0))+ || grew(a.allocated, b.allocated)+ }+ _ => true,+ };+ usage+ || disk+ || self.id != sent.id+ || self.power_state != sent.power_state+ || self.cpu_allocated != sent.cpu_allocated+ || self.memory_allocated != sent.memory_allocated+ || self.disk_allocated != sent.disk_allocated+ }+}++impl Resources {+ /// What a receiver that holds `sent` needs to reach `self`: empty when+ /// nothing moved past the thresholds.+ pub fn update_since(&self, sent: &Resources) -> ResourcesUpdate {+ let mut u = ResourcesUpdate {+ sequence: self.sequence,+ sampled_at_ms: self.sampled_at_ms,+ ..Default::default()+ };+ if self.this_mac.differs(&sent.this_mac) {+ u.this_mac = Some(self.this_mac.clone());+ }+ for s in &self.spaces {+ match sent.spaces.iter().find(|o| o.id == s.id) {+ Some(old) if !s.differs(old) => {}+ _ => u.spaces.push(s.clone()),+ }+ }+ for c in &self.computers {+ match sent.computers.iter().find(|o| o.id == c.id) {+ Some(old) if !c.differs(old) => {}+ _ => u.computers.push(c.clone()),+ }+ }+ for old in &sent.spaces {+ if !self.spaces.iter().any(|s| s.id == old.id) {+ u.removed.push(old.id.clone());+ }+ }+ for old in &sent.computers {+ if !self.computers.iter().any(|c| c.id == old.id) {+ u.removed.push(old.id.clone());+ }+ }+ u+ }++ /// `self` after `update`, the way a receiver applies it.+ pub fn apply(&mut self, update: &ResourcesUpdate) {+ self.sequence = update.sequence;+ self.sampled_at_ms = update.sampled_at_ms;+ if let Some(m) = &update.this_mac {+ self.this_mac = m.clone();+ self.warning = m.warning;+ }+ self.spaces.retain(|s| !update.removed.contains(&s.id));+ self.computers.retain(|c| !update.removed.contains(&c.id));+ for s in &update.spaces {+ match self.spaces.iter_mut().find(|o| o.id == s.id) {+ Some(o) => *o = s.clone(),+ None => self.spaces.push(s.clone()),+ }+ }+ for c in &update.computers {+ match self.computers.iter_mut().find(|o| o.id == c.id) {+ Some(o) => *o = c.clone(),+ None => self.computers.push(c.clone()),+ }+ }+ }+}++/// Unix ms now.+pub fn now_ms() -> u64 {+ std::time::SystemTime::now()+ .duration_since(std::time::UNIX_EPOCH)+ .map(|d| d.as_millis() as u64)+ .unwrap_or(0)+}++#[cfg(test)]+mod tests;diff --git a/libs/cua/crates/cua-spaces/src/resources/publish.rs b/libs/cua/crates/cua-spaces/src/resources/publish.rsnew file mode 100644index 0000000000..a413d08fc4--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/publish.rs@@ -0,0 +1,105 @@+//! A computer that is registered on the relay publishes its summary+//! ([`summary`]) into its own machine record, so your other computers show+//! it from the machine list they already fetch.+//!+//! Rates: once a minute while someone is connected to the machine+//! ([`summary::WATCHED_EVERY`]; the relay's answer to each publish says who+//! is), every five minutes otherwise ([`summary::IDLE_EVERY`]), and at once+//! when the low-disk level changes. A relay that predates summaries drops+//! the key; the publisher then tries again only hourly.++use super::{ResourcesEvent, summary};+use crate::{Result, Spaces};+use std::collections::BTreeMap;+use std::sync::Arc;+use std::time::{Duration, Instant};++/// How long after the daemon starts the first summary goes out (so the+/// first sample has settled).+const FIRST_PUBLISH_DELAY: Duration = Duration::from_secs(20);+/// How long a relay that dropped the summary is left alone.+const UNSUPPORTED_BACKOFF: Duration = Duration::from_secs(3600);++/// What a publish did.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Published {+ /// This install is not a relay machine, or no account is signed in:+ /// nothing to publish into.+ NotAHost,+ /// The relay answered without the summary (an older relay).+ Unsupported,+ /// Published. `watchers` are the clients connected to the machine now.+ Sent {+ /// Clients connected to this machine.+ watchers: usize,+ },+}++impl Spaces {+ /// Publishes this computer's summary into its relay machine record.+ pub async fn publish_resources(&self) -> Result<Published> {+ let (Some(machine), Some(relay)) = (self.this_relay_machine_id(), self.relay_account())+ else {+ return Ok(Published::NotAHost);+ };+ let snapshot = self.resources(false).await?;+ let value = summary::encode(&snapshot.this_mac);+ let token = relay.tokens.access_token().await?;+ let client = relay.client().await?;+ let reply = client+ .patch(+ &token,+ &machine,+ &cua_host::MachinePatch {+ meta: Some(BTreeMap::from([(+ summary::META_KEY.to_string(),+ value.clone(),+ )])),+ ..Default::default()+ },+ )+ .await?;+ if reply.meta.get(summary::META_KEY) != Some(&value) {+ return Ok(Published::Unsupported);+ }+ Ok(Published::Sent {+ watchers: reply.clients.len(),+ })+ }++ /// Keeps this computer's summary published until the runtime is+ /// dropped (the daemon starts it once). The task is also a hidden+ /// watcher, which is what keeps the sampler running every five minutes+ /// when no app is open.+ pub fn spawn_resources_publisher(&self) -> tokio::task::JoinHandle<()> {+ let weak = Arc::downgrade(&self.inner);+ let mut watch = self.watch_resources(false);+ tokio::spawn(async move {+ let mut next = Instant::now() + FIRST_PUBLISH_DELAY;+ loop {+ tokio::select! {+ event = watch.next() => match event {+ None => return,+ // The level changed: say so at once.+ Some(ResourcesEvent::LowDisk(_)) => next = Instant::now(),+ Some(_) => {}+ },+ _ = tokio::time::sleep_until(next.into()) => {+ let Some(inner) = weak.upgrade() else { return };+ let spaces = Spaces { inner };+ let wait = match spaces.publish_resources().await {+ Ok(Published::Sent { watchers }) if watchers > 0 => summary::WATCHED_EVERY,+ Ok(Published::Unsupported) => UNSUPPORTED_BACKOFF,+ Ok(_) => summary::IDLE_EVERY,+ Err(e) => {+ tracing::debug!(error = %e, "publishing resources failed");+ summary::IDLE_EVERY+ }+ };+ next = Instant::now() + wait;+ }+ }+ }+ })+ }+}diff --git a/libs/cua/crates/cua-spaces/src/resources/summary.rs b/libs/cua/crates/cua-spaces/src/resources/summary.rsnew file mode 100644index 0000000000..aaa3528431--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/summary.rs@@ -0,0 +1,231 @@+//! The summary a computer publishes through its relay machine record, so+//! your other computers can show it without a connection to it.+//!+//! One `meta` key, [`META_KEY`], holds compact JSON of at most+//! [`MAX_LEN`] characters (the relay's value limit): sizes in MiB, times in+//! unix seconds. Numbers only: counts, bytes and percentages.++use super::{ComputerResources, DiskLevel, DiskWarning, MIB, low_line};+use serde::{Deserialize, Serialize};++/// The relay machine meta key.+pub const META_KEY: &str = "cua.res";+/// The relay's limit on a meta value, in characters.+pub const MAX_LEN: usize = 256;+/// The summary format.+pub const VERSION: u32 = 1;++/// How often a computer publishes while someone watches it.+pub const WATCHED_EVERY: std::time::Duration = std::time::Duration::from_secs(60);+/// How often it publishes otherwise.+pub const IDLE_EVERY: std::time::Duration = std::time::Duration::from_secs(300);++#[derive(Serialize, Deserialize)]+struct Wire {+ v: u32,+ /// Measured at, unix seconds.+ t: u64,+ /// Cores.+ c: u32,+ /// Busy, whole percent.+ b: u32,+ /// Memory size and in use, MiB.+ mt: u64,+ mu: u64,+ /// Volume size and free, MiB.+ dt: u64,+ df: u64,+ /// Extra Spaces: count, running.+ n: u32,+ r: u32,+ /// Cores and memory (MiB) given to the running ones.+ sc: u32,+ sm: u64,+ /// Memory in use by the running ones, MiB.+ su: u64,+ /// Disk the extra Spaces take, MiB.+ sd: u64,+ /// Every Space's disk was measured (1) or some were estimated (0).+ x: u8,+ /// Warning: 0 ok, 1 low, 2 critical.+ w: u8,+}++fn mib(bytes: u64) -> u64 {+ bytes / MIB+}++/// `c` as the value of [`META_KEY`].+pub fn encode(c: &ComputerResources) -> String {+ let wire = Wire {+ v: VERSION,+ t: c.sampled_at_ms / 1000,+ c: c.cpu_count,+ b: c.cpu_percent.round().clamp(0.0, 100.0) as u32,+ mt: mib(c.memory_total),+ mu: mib(c.memory_used),+ dt: mib(c.disk_total),+ df: mib(c.disk_free),+ n: c.spaces_count,+ r: c.spaces_running,+ sc: c.spaces_cpu_allocated,+ sm: mib(c.spaces_memory_allocated),+ su: mib(c.spaces_memory_used),+ sd: mib(c.spaces_disk_bytes),+ x: u8::from(c.spaces_disk_exact),+ w: c.warning.level as u8,+ };+ serde_json::to_string(&wire).expect("plain numbers serialize")+}++/// A computer's published summary, as the computer `id` named `name`+/// (`online` as the relay lists it). `None` for text that is not a summary+/// of a version this build knows.+pub fn decode(id: &str, name: &str, online: bool, value: &str) -> Option<ComputerResources> {+ let w: Wire = serde_json::from_str(value).ok()?;+ if w.v != VERSION {+ return None;+ }+ let level = match w.w {+ 1 => DiskLevel::Low,+ 2 => DiskLevel::Critical,+ _ => DiskLevel::Ok,+ };+ let total = w.dt.saturating_mul(MIB);+ let free = w.df.saturating_mul(MIB);+ Some(ComputerResources {+ id: id.into(),+ name: name.into(),+ online,+ sampled_at_ms: w.t.saturating_mul(1000),+ cpu_count: w.c,+ cpu_percent: f64::from(w.b.min(100)),+ load_average_1m: 0.0,+ memory_total: w.mt.saturating_mul(MIB),+ memory_used: w.mu.saturating_mul(MIB),+ disk_total: total,+ disk_free: free,+ spaces_count: w.n,+ spaces_running: w.r,+ spaces_cpu_allocated: w.sc,+ spaces_memory_allocated: w.sm.saturating_mul(MIB),+ spaces_memory_used: w.su.saturating_mul(MIB),+ spaces_disk_bytes: w.sd.saturating_mul(MIB),+ spaces_disk_exact: w.x == 1,+ warning: DiskWarning {+ level,+ free,+ total,+ threshold: match level {+ DiskLevel::Ok => 0,+ DiskLevel::Low => low_line(total),+ DiskLevel::Critical => cua_vmm::disk::DEFAULT_MIN_FREE,+ },+ },+ })+}++/// Whether two computers' summaries differ enough to publish again before+/// the interval is up: the warning level changed.+pub fn urgent(now: &ComputerResources, published: &ComputerResources) -> bool {+ now.warning.level != published.warning.level+}++#[cfg(test)]+mod tests {+ use super::*;++ fn big() -> ComputerResources {+ ComputerResources {+ id: crate::resources::THIS_MAC.into(),+ online: true,+ sampled_at_ms: 1_760_000_000_000,+ cpu_count: 128,+ cpu_percent: 100.0,+ memory_total: 8 * 1024 * 1024 * MIB,+ memory_used: 8 * 1024 * 1024 * MIB,+ disk_total: 64 * 1024 * 1024 * MIB,+ disk_free: 64 * 1024 * 1024 * MIB,+ spaces_count: 999,+ spaces_running: 999,+ spaces_cpu_allocated: 9999,+ spaces_memory_allocated: 8 * 1024 * 1024 * MIB,+ spaces_memory_used: 8 * 1024 * 1024 * MIB,+ spaces_disk_bytes: 64 * 1024 * 1024 * MIB,+ spaces_disk_exact: true,+ warning: DiskWarning {+ level: DiskLevel::Critical,+ free: 1,+ total: 2,+ threshold: 3,+ },+ ..Default::default()+ }+ }++ #[test]+ fn the_largest_summary_fits_the_relay_limit() {+ let s = encode(&big());+ assert!(s.len() <= MAX_LEN, "{} chars: {s}", s.len());+ assert!(s.chars().all(|c| !c.is_control()));+ }++ #[test]+ fn a_summary_round_trips_in_whole_units() {+ let c = ComputerResources {+ id: "m-1".into(),+ online: true,+ sampled_at_ms: 1_760_000_123_000,+ cpu_count: 12,+ cpu_percent: 38.4,+ memory_total: 64 * 1024 * MIB,+ memory_used: 41 * 1024 * MIB,+ disk_total: 1024 * 1024 * MIB,+ disk_free: 41 * 1024 * MIB,+ spaces_count: 3,+ spaces_running: 2,+ spaces_cpu_allocated: 6,+ spaces_memory_allocated: 12 * 1024 * MIB,+ spaces_memory_used: 5 * 1024 * MIB,+ spaces_disk_bytes: 25 * 1024 * MIB,+ spaces_disk_exact: true,+ warning: DiskWarning::assess(+ 41 * 1024 * MIB,+ 1024 * 1024 * MIB,+ 5 << 30,+ DiskLevel::Ok,+ ),+ ..Default::default()+ };+ let back = decode("m-1", "Mac mini", true, &encode(&c)).unwrap();+ assert_eq!(back.name, "Mac mini");+ assert_eq!(back.cpu_count, 12);+ assert_eq!(back.cpu_percent, 38.0);+ assert_eq!(back.memory_used, c.memory_used);+ assert_eq!(back.disk_free, c.disk_free);+ assert_eq!(back.spaces_running, 2);+ assert!(back.spaces_disk_exact);+ assert_eq!(back.warning.level, DiskLevel::Low);+ assert_eq!(back.sampled_at_ms, c.sampled_at_ms);+ }++ #[test]+ fn text_that_is_not_a_known_summary_is_ignored() {+ assert!(decode("m", "", true, "not json").is_none());+ assert!(decode("m", "", true, r#"{"v":99}"#).is_none());+ assert!(decode("m", "", true, "").is_none());+ }++ #[test]+ fn a_summary_carries_numbers_only() {+ let mut c = big();+ c.name = "Francesco's Mac".into();+ let s = encode(&c);+ assert!(!s.contains("Francesco"), "{s}");+ assert!(+ s.chars()+ .all(|ch| ch.is_ascii_digit() || "{}\":,vtcbmudnrsxwf".contains(ch)),+ "{s}"+ );+ }+}diff --git a/libs/cua/crates/cua-spaces/src/resources/tests.rs b/libs/cua/crates/cua-spaces/src/resources/tests.rsnew file mode 100644index 0000000000..e1facfed45--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/tests.rs@@ -0,0 +1,236 @@+use super::*;++const TB: u64 = 1024 * GIB;++#[test]+fn the_warning_line_is_50_gb_or_15_percent_whichever_is_higher_capped_at_100() {+ // A small disk: 15% is under the 50 GiB floor.+ assert_eq!(low_line(100 * GIB), 50 * GIB);+ // A 512 GiB disk: 15% is 76 GiB.+ assert_eq!(low_line(512 * GIB), 512 * GIB / 100 * 15);+ // A 1 TiB disk: 15% is 153 GiB, capped at 100.+ assert_eq!(low_line(TB), 100 * GIB);+ assert_eq!(low_line(8 * TB), 100 * GIB);+}++#[test]+fn free_disk_under_the_line_warns_and_under_the_floor_is_critical() {+ let min = 5 * GIB;+ let at = |free: u64, total: u64| DiskWarning::assess(free, total, min, DiskLevel::Ok);+ // Plenty.+ let ok = at(300 * GIB, TB);+ assert_eq!((ok.level, ok.threshold), (DiskLevel::Ok, 0));+ // 99 GiB free of 1 TiB: under the capped 100 GiB line.+ let low = at(99 * GIB, TB);+ assert_eq!((low.level, low.threshold), (DiskLevel::Low, 100 * GIB));+ // 40 GiB free of 100 GiB: under 50 GiB.+ assert_eq!(at(40 * GIB, 100 * GIB).level, DiskLevel::Low);+ // 60 GiB free of 100 GiB: fine (15% would be 15 GiB, the floor is 50).+ assert_eq!(at(60 * GIB, 100 * GIB).level, DiskLevel::Ok);+ // Under the floor where creates fail.+ let critical = at(4 * GIB, TB);+ assert_eq!(+ (critical.level, critical.threshold),+ (DiskLevel::Critical, min)+ );+ assert_eq!((critical.free, critical.total), (4 * GIB, TB));+}++#[test]+fn a_raised_warning_clears_only_above_its_line_with_margin() {+ let min = 5 * GIB;+ let total = TB;+ let line = low_line(total);+ // Just over the line, but a warning was up: it stays.+ let w = DiskWarning::assess(line + GIB, total, min, DiskLevel::Low);+ assert_eq!(w.level, DiskLevel::Low);+ // 2 GiB over: it clears.+ let w = DiskWarning::assess(line + 2 * GIB, total, min, DiskLevel::Low);+ assert_eq!(w.level, DiskLevel::Ok);+ // From critical, climbing past the floor with margin: now low, not ok.+ let w = DiskWarning::assess(min + 3 * GIB, total, min, DiskLevel::Critical);+ assert_eq!(w.level, DiskLevel::Low);+ // Critical stays within 2 GiB of the floor.+ let w = DiskWarning::assess(min + GIB, total, min, DiskLevel::Critical);+ assert_eq!(w.level, DiskLevel::Critical);+ // With no warning up, the line itself is where it starts.+ assert_eq!(+ DiskWarning::assess(line + GIB, total, min, DiskLevel::Ok).level,+ DiskLevel::Ok+ );+}++#[test]+fn levels_have_words_and_json_names() {+ for l in [DiskLevel::Ok, DiskLevel::Low, DiskLevel::Critical] {+ assert_eq!(DiskLevel::parse(l.as_str()), l);+ assert_eq!(serde_json::to_value(l).unwrap(), l.as_str());+ }+ assert_eq!(DiskLevel::parse("nonsense"), DiskLevel::Ok);+}++fn space(id: &str) -> SpaceResources {+ SpaceResources {+ id: id.into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_used: 3 * GIB,+ memory_total: 8 * GIB,+ memory_limited: true,+ disk_used: 20 * GIB,+ disk_total: 80 * GIB,+ disk_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(DiskOnHost {+ bytes: Some(6 * GIB),+ allocated: 31 * GIB,+ shares_space: true,+ }),+ }+}++fn snap(sequence: u64) -> Resources {+ let this_mac = ComputerResources {+ id: THIS_MAC.into(),+ online: true,+ cpu_count: 12,+ cpu_percent: 38.0,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: TB,+ disk_free: 300 * GIB,+ ..Default::default()+ };+ Resources {+ sequence,+ sampled_at_ms: sequence * 1000,+ warning: this_mac.warning,+ this_mac,+ spaces: vec![space("local:a"), space("local:b")],+ computers: vec![],+ }+}++#[test]+fn a_small_wobble_sends_nothing() {+ let sent = snap(1);+ let mut now = snap(2);+ // 1 point of processor, 200 MB of memory: under both thresholds.+ now.this_mac.cpu_percent += 1.0;+ now.this_mac.memory_used += 200 * MIB;+ now.spaces[0].usage.as_mut().unwrap().cpu_percent += 0.9;+ now.spaces[1].usage.as_mut().unwrap().memory_used += 255 * MIB;+ assert!(now.update_since(&sent).is_empty());+}++#[test]+fn a_change_past_a_threshold_sends_only_that_entry() {+ let sent = snap(1);+ let mut now = snap(2);+ now.spaces[1].usage.as_mut().unwrap().cpu_percent = 50.0;+ let u = now.update_since(&sent);+ assert_eq!(u.sequence, 2);+ assert_eq!(u.this_mac, None);+ assert_eq!(u.spaces.len(), 1);+ assert_eq!(u.spaces[0].id, "local:b");+ assert!(u.removed.is_empty());++ let mut now = snap(3);+ now.this_mac.memory_used += 300 * MIB;+ let u = now.update_since(&sent);+ assert!(u.this_mac.is_some());+ assert!(u.spaces.is_empty());+}++#[test]+fn power_and_allocation_changes_always_send() {+ let sent = snap(1);+ let mut now = snap(2);+ now.spaces[0].power_state = "stopped".into();+ now.spaces[0].usage = None;+ now.spaces[1].cpu_allocated = 6;+ let u = now.update_since(&sent);+ assert_eq!(u.spaces.len(), 2);+}++#[test]+fn spaces_that_appear_or_vanish_are_in_the_update() {+ let sent = snap(1);+ let mut now = snap(2);+ now.spaces.remove(0);+ now.spaces.push(space("local:c"));+ now.computers.push(ComputerResources {+ id: "m-1".into(),+ online: true,+ ..Default::default()+ });+ let u = now.update_since(&sent);+ assert_eq!(+ u.spaces.iter().map(|s| s.id.as_str()).collect::<Vec<_>>(),+ ["local:c"]+ );+ assert_eq!(u.removed, ["local:a"]);+ assert_eq!(u.computers.len(), 1);+ // The computer going away is a removal too.+ let back = snap(3).update_since(&now);+ assert!(back.removed.contains(&"m-1".to_string()));+ assert!(back.removed.contains(&"local:c".to_string()));+}++#[test]+fn applying_updates_reaches_the_same_picture() {+ let mut held = snap(1);+ let mut truth = snap(1);+ for step in 2..6u64 {+ truth.sequence = step;+ truth.sampled_at_ms = step * 1000;+ truth.this_mac.cpu_percent = 10.0 * step as f64;+ truth.spaces[0].usage.as_mut().unwrap().memory_used = step * GIB;+ if step == 4 {+ truth.spaces.pop();+ }+ let u = truth.update_since(&held);+ held.apply(&u);+ }+ assert_eq!(held, truth);+}++#[test]+fn the_snapshot_json_is_camel_case_and_numbers_only() {+ let mut s = snap(7);+ s.computers.push(ComputerResources {+ id: "m-1".into(),+ name: "Mac mini".into(),+ online: true,+ ..Default::default()+ });+ let v = serde_json::to_value(&s).unwrap();+ assert_eq!(v["sequence"], 7);+ assert!(v["thisMac"]["cpuPercent"].is_number());+ assert_eq!(v["thisMac"]["warning"]["level"], "ok");+ assert_eq!(v["spaces"][0]["powerState"], "running");+ assert_eq!(v["spaces"][0]["usage"]["memoryLimited"], true);+ assert_eq!(v["spaces"][0]["diskOnHost"]["sharesSpace"], true);+ let back: Resources = serde_json::from_value(v).unwrap();+ assert_eq!(back, s);+ // No field of a Space says where its files are or what it runs.+ let text = serde_json::to_string(&s.spaces[0]).unwrap();+ for word in ["path", "dir", "file", "process", "window", "name"] {+ assert!(!text.contains(word), "{word} in {text}");+ }+}++#[test]+fn events_have_a_stable_json_shape() {+ let e = ResourcesEvent::LowDisk(DiskWarning::assess(GIB, TB, 5 * GIB, DiskLevel::Ok));+ let v = serde_json::to_value(&e).unwrap();+ assert_eq!(v["type"], "lowDisk");+ assert_eq!(v["value"]["level"], "critical");+ assert_eq!(serde_json::from_value::<ResourcesEvent>(v).unwrap(), e);+}diff --git a/libs/cua/crates/cua-spaces/src/resources/wire.rs b/libs/cua/crates/cua-spaces/src/resources/wire.rsnew file mode 100644index 0000000000..1563bd644f--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/wire.rs@@ -0,0 +1,334 @@+//! `cua.daemon.v1` messages for [`Resources`]: the daemon serves them+//! (`SpaceService.GetResources`, `WatchResources`) and its clients read+//! them back, so both topologies hand the apps the same numbers.++use super::{+ ComputerResources, DiskLevel, DiskOnHost, DiskWarning, GuestUsage, Resources, ResourcesEvent,+ ResourcesUpdate, SpaceResources,+};+use cua_proto::daemon::v1 as pb;+use pb::watch_resources_response::Event;++impl From<&DiskWarning> for pb::DiskWarning {+ fn from(w: &DiskWarning) -> Self {+ pb::DiskWarning {+ level: w.level.as_str().into(),+ free: w.free,+ total: w.total,+ threshold: w.threshold,+ }+ }+}++impl From<pb::DiskWarning> for DiskWarning {+ fn from(w: pb::DiskWarning) -> Self {+ DiskWarning {+ level: DiskLevel::parse(&w.level),+ free: w.free,+ total: w.total,+ threshold: w.threshold,+ }+ }+}++impl From<&ComputerResources> for pb::ComputerResources {+ fn from(c: &ComputerResources) -> Self {+ pb::ComputerResources {+ id: c.id.clone(),+ name: c.name.clone(),+ online: c.online,+ sampled_at_ms: c.sampled_at_ms,+ cpu_count: c.cpu_count,+ cpu_percent: c.cpu_percent,+ load_average_1m: c.load_average_1m,+ memory_total: c.memory_total,+ memory_used: c.memory_used,+ disk_total: c.disk_total,+ disk_free: c.disk_free,+ spaces_count: c.spaces_count,+ spaces_running: c.spaces_running,+ spaces_cpu_allocated: c.spaces_cpu_allocated,+ spaces_memory_allocated: c.spaces_memory_allocated,+ spaces_memory_used: c.spaces_memory_used,+ spaces_disk_bytes: c.spaces_disk_bytes,+ spaces_disk_exact: c.spaces_disk_exact,+ warning: Some((&c.warning).into()),+ }+ }+}++impl From<pb::ComputerResources> for ComputerResources {+ fn from(c: pb::ComputerResources) -> Self {+ ComputerResources {+ id: c.id,+ name: c.name,+ online: c.online,+ sampled_at_ms: c.sampled_at_ms,+ cpu_count: c.cpu_count,+ cpu_percent: c.cpu_percent,+ load_average_1m: c.load_average_1m,+ memory_total: c.memory_total,+ memory_used: c.memory_used,+ disk_total: c.disk_total,+ disk_free: c.disk_free,+ spaces_count: c.spaces_count,+ spaces_running: c.spaces_running,+ spaces_cpu_allocated: c.spaces_cpu_allocated,+ spaces_memory_allocated: c.spaces_memory_allocated,+ spaces_memory_used: c.spaces_memory_used,+ spaces_disk_bytes: c.spaces_disk_bytes,+ spaces_disk_exact: c.spaces_disk_exact,+ warning: c.warning.map(Into::into).unwrap_or_default(),+ }+ }+}++impl From<&SpaceResources> for pb::SpaceResources {+ fn from(s: &SpaceResources) -> Self {+ pb::SpaceResources {+ id: s.id.clone(),+ power_state: s.power_state.clone(),+ cpu_allocated: s.cpu_allocated,+ memory_allocated: s.memory_allocated,+ disk_allocated: s.disk_allocated,+ usage: s.usage.map(|u| pb::GuestUsage {+ cpu_count: u.cpu_count,+ cpu_percent: u.cpu_percent,+ load_average_1m: u.load_average_1m,+ memory_used: u.memory_used,+ memory_total: u.memory_total,+ memory_limited: u.memory_limited,+ disk_used: u.disk_used,+ disk_total: u.disk_total,+ disk_limited: u.disk_limited,+ }),+ disk_on_host: s.disk_on_host.map(|d| pb::DiskOnHost {+ bytes: d.bytes,+ allocated: d.allocated,+ shares_space: d.shares_space,+ }),+ }+ }+}++impl From<pb::SpaceResources> for SpaceResources {+ fn from(s: pb::SpaceResources) -> Self {+ SpaceResources {+ id: s.id,+ power_state: s.power_state,+ cpu_allocated: s.cpu_allocated,+ memory_allocated: s.memory_allocated,+ disk_allocated: s.disk_allocated,+ usage: s.usage.map(|u| GuestUsage {+ cpu_count: u.cpu_count,+ cpu_percent: u.cpu_percent,+ load_average_1m: u.load_average_1m,+ memory_used: u.memory_used,+ memory_total: u.memory_total,+ memory_limited: u.memory_limited,+ disk_used: u.disk_used,+ disk_total: u.disk_total,+ disk_limited: u.disk_limited,+ }),+ disk_on_host: s.disk_on_host.map(|d| DiskOnHost {+ bytes: d.bytes,+ allocated: d.allocated,+ shares_space: d.shares_space,+ }),+ }+ }+}++impl From<&Resources> for pb::ResourcesSnapshot {+ fn from(r: &Resources) -> Self {+ pb::ResourcesSnapshot {+ sequence: r.sequence,+ sampled_at_ms: r.sampled_at_ms,+ this_mac: Some((&r.this_mac).into()),+ spaces: r.spaces.iter().map(Into::into).collect(),+ computers: r.computers.iter().map(Into::into).collect(),+ warning: Some((&r.warning).into()),+ }+ }+}++impl From<pb::ResourcesSnapshot> for Resources {+ fn from(r: pb::ResourcesSnapshot) -> Self {+ Resources {+ sequence: r.sequence,+ sampled_at_ms: r.sampled_at_ms,+ this_mac: r.this_mac.map(Into::into).unwrap_or_default(),+ spaces: r.spaces.into_iter().map(Into::into).collect(),+ computers: r.computers.into_iter().map(Into::into).collect(),+ warning: r.warning.map(Into::into).unwrap_or_default(),+ }+ }+}++impl From<&ResourcesUpdate> for pb::ResourcesUpdate {+ fn from(u: &ResourcesUpdate) -> Self {+ pb::ResourcesUpdate {+ sequence: u.sequence,+ sampled_at_ms: u.sampled_at_ms,+ this_mac: u.this_mac.as_ref().map(Into::into),+ spaces: u.spaces.iter().map(Into::into).collect(),+ computers: u.computers.iter().map(Into::into).collect(),+ removed: u.removed.clone(),+ }+ }+}++impl From<pb::ResourcesUpdate> for ResourcesUpdate {+ fn from(u: pb::ResourcesUpdate) -> Self {+ ResourcesUpdate {+ sequence: u.sequence,+ sampled_at_ms: u.sampled_at_ms,+ this_mac: u.this_mac.map(Into::into),+ spaces: u.spaces.into_iter().map(Into::into).collect(),+ computers: u.computers.into_iter().map(Into::into).collect(),+ removed: u.removed,+ }+ }+}++impl From<&ResourcesEvent> for pb::WatchResourcesResponse {+ fn from(e: &ResourcesEvent) -> Self {+ pb::WatchResourcesResponse {+ event: Some(match e {+ ResourcesEvent::Snapshot(s) => Event::Snapshot(s.into()),+ ResourcesEvent::Update(u) => Event::Update(u.into()),+ ResourcesEvent::LowDisk(w) => Event::LowDisk(w.into()),+ }),+ }+ }+}++impl TryFrom<pb::WatchResourcesResponse> for ResourcesEvent {+ type Error = &'static str;++ fn try_from(r: pb::WatchResourcesResponse) -> Result<Self, Self::Error> {+ match r.event {+ Some(Event::Snapshot(s)) => Ok(ResourcesEvent::Snapshot(s.into())),+ Some(Event::Update(u)) => Ok(ResourcesEvent::Update(u.into())),+ Some(Event::LowDisk(w)) => Ok(ResourcesEvent::LowDisk(w.into())),+ None => Err("an empty resources event"),+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::resources::{GIB, THIS_MAC};++ fn sample() -> Resources {+ let warning = DiskWarning::assess(40 * GIB, 1024 * GIB, 5 * GIB, DiskLevel::Ok);+ Resources {+ sequence: 9,+ sampled_at_ms: 1_760_000_000_000,+ this_mac: ComputerResources {+ id: THIS_MAC.into(),+ online: true,+ cpu_count: 12,+ cpu_percent: 38.5,+ load_average_1m: 2.5,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: 1024 * GIB,+ disk_free: 40 * GIB,+ spaces_count: 2,+ spaces_running: 1,+ spaces_cpu_allocated: 4,+ spaces_memory_allocated: 8 * GIB,+ spaces_memory_used: 3 * GIB,+ spaces_disk_bytes: 25 * GIB,+ spaces_disk_exact: false,+ warning,+ ..Default::default()+ },+ spaces: vec![+ SpaceResources {+ id: "local:a".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ load_average_1m: 0.5,+ memory_used: 3 * GIB,+ memory_total: 8 * GIB,+ memory_limited: true,+ disk_used: 20 * GIB,+ disk_total: 80 * GIB,+ disk_limited: true,+ }),+ disk_on_host: Some(DiskOnHost {+ bytes: Some(6 * GIB),+ allocated: 31 * GIB,+ shares_space: true,+ }),+ },+ SpaceResources {+ id: "local:b".into(),+ power_state: "stopped".into(),+ disk_on_host: Some(DiskOnHost {+ bytes: None,+ allocated: 12 * GIB,+ shares_space: true,+ }),+ ..Default::default()+ },+ ],+ computers: vec![ComputerResources {+ id: "m-1".into(),+ name: "Mac mini".into(),+ online: true,+ ..Default::default()+ }],+ warning,+ }+ }++ #[test]+ fn a_snapshot_survives_the_wire() {+ let r = sample();+ let back: Resources = pb::ResourcesSnapshot::from(&r).into();+ assert_eq!(back, r);+ }++ #[test]+ fn an_unmeasured_disk_stays_unmeasured_on_the_wire() {+ let r = sample();+ let wire = pb::ResourcesSnapshot::from(&r);+ assert_eq!(wire.spaces[1].disk_on_host.as_ref().unwrap().bytes, None);+ assert_eq!(+ wire.spaces[0].disk_on_host.as_ref().unwrap().bytes,+ Some(6 * GIB)+ );+ assert!(wire.spaces[1].usage.is_none());+ }++ #[test]+ fn every_event_survives_the_wire() {+ let r = sample();+ let update = ResourcesUpdate {+ sequence: 10,+ sampled_at_ms: 5,+ this_mac: Some(r.this_mac.clone()),+ spaces: vec![r.spaces[0].clone()],+ computers: vec![],+ removed: vec!["local:gone".into()],+ };+ for e in [+ ResourcesEvent::Snapshot(r.clone()),+ ResourcesEvent::Update(update),+ ResourcesEvent::LowDisk(r.warning),+ ] {+ let back = ResourcesEvent::try_from(pb::WatchResourcesResponse::from(&e)).unwrap();+ assert_eq!(back, e);+ }+ assert!(ResourcesEvent::try_from(pb::WatchResourcesResponse { event: None }).is_err());+ }+}diff --git a/libs/cua/crates/cua-spaces/src/resources/words.rs b/libs/cua/crates/cua-spaces/src/resources/words.rsnew file mode 100644index 0000000000..03aa0ebc9b--- /dev/null+++ b/libs/cua/crates/cua-spaces/src/resources/words.rs@@ -0,0 +1,375 @@+//! The plain words for the numbers, for the CLI. The Spaces apps use the+//! same words from the app core (`resources.rs` there); both are tested+//! against the same sentences.+//!+//! Never "vCPU", "RSS", "APFS", "sparse", "qcow2" or "cgroup": a processor is+//! "busy", memory is "in use", a disk is "space for files".++use super::{ComputerResources, DiskLevel, DiskOnHost, DiskWarning, SpaceResources};++/// A size in binary units labelled the way macOS labels memory: "512 MB",+/// "2.1 GB", "4 GB", "1 TB".+pub fn size(bytes: u64) -> String {+ const UNITS: [&str; 4] = ["MB", "GB", "TB", "PB"];+ let mut v = bytes as f64 / (1024.0 * 1024.0);+ if v < 1.0 {+ return format!("{} KB", (bytes as f64 / 1024.0).round() as u64);+ }+ let mut i = 0;+ while v >= 1024.0 && i < UNITS.len() - 1 {+ v /= 1024.0;+ i += 1;+ }+ let text = if v >= 100.0 {+ format!("{}", v.round() as u64)+ } else {+ let t = format!("{v:.1}");+ t.strip_suffix(".0").map(str::to_string).unwrap_or(t)+ };+ format!("{text} {}", UNITS[i])+}++/// "1 core", "12 cores".+pub fn cores(n: u32) -> String {+ format!("{n} core{}", if n == 1 { "" } else { "s" })+}++/// "12 cores · 38% busy"; "12 cores" without a reading.+pub fn processor(cores_n: u32, busy: Option<f64>) -> String {+ match busy {+ Some(p) => format!(+ "{} \u{b7} {}% busy",+ cores(cores_n),+ p.round().clamp(0.0, 100.0)+ ),+ None => cores(cores_n),+ }+}++/// "41 of 64 GB in use".+pub fn memory_in_use(used: u64, total: u64) -> String {+ format!("{} in use", of(used, total))+}++/// "3.1 of 8 GB": the number of the first with the unit of the second.+pub fn of(used: u64, total: u64) -> String {+ let used = used.min(total);+ let (u, t) = (size(used), size(total));+ match (u.rsplit_once(' '), t.rsplit_once(' ')) {+ (Some((n, unit)), Some((_, tu))) if unit == tu => format!("{n} of {t}"),+ _ => format!("{u} of {t}"),+ }+}++/// "41 GB free of 1 TB".+pub fn disk_free(free: u64, total: u64) -> String {+ format!("{} free of {}", size(free.min(total)), size(total))+}++/// What a Space costs this computer's disk: "about 6 GB", with "shares+/// space with other copies" when part of it is shared, or only that when+/// the number could not be measured. `None` when there is nothing to say.+pub fn disk_on_host(d: &DiskOnHost) -> Option<String> {+ match (d.bytes, d.shares_space) {+ (Some(b), true) => Some(format!("about {}, shares space with other copies", size(b))),+ (Some(b), false) => Some(format!("about {}", size(b))),+ (None, true) => Some("shares space with other copies".into()),+ (None, false) => None,+ }+}++/// "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+/// files." `None` when there are none.+pub fn extra_spaces_use(c: &ComputerResources) -> Option<String> {+ if c.spaces_count == 0 {+ return None;+ }+ let disk = if c.spaces_disk_exact {+ format!("about {}", size(c.spaces_disk_bytes))+ } else {+ format!("up to about {}", size(c.spaces_disk_bytes))+ };+ Some(format!(+ "Your extra Spaces use: {}, {} of memory, {disk} for files.",+ cores(c.spaces_cpu_allocated),+ size(c.spaces_memory_allocated),+ ))+}++/// The warning's sentence, when there is one.+pub fn warning(w: &DiskWarning) -> Option<&'static str> {+ match w.level {+ DiskLevel::Ok => None,+ DiskLevel::Low => Some("This Mac is almost out of space. Delete old Spaces or snapshots."),+ DiskLevel::Critical => Some(+ "This Mac is out of space, so new Spaces can't be created. Delete old Spaces or snapshots.",+ ),+ }+}++/// The CPU cell of a Space row: "4 cores · 22% busy", "4 cores" while it+/// is off, "-" when its allocation is unknown.+pub fn space_cpu(s: &SpaceResources) -> String {+ let cores_n = if s.cpu_allocated > 0 {+ s.cpu_allocated+ } else {+ s.usage.map(|u| u.cpu_count).unwrap_or(0)+ };+ match (cores_n, s.usage) {+ (0, _) => "-".into(),+ (n, Some(u)) => processor(n, Some(u.cpu_percent)),+ (n, None) => processor(n, None),+ }+}++/// The memory cell of a Space row: "3.1 of 8 GB", "8 GB" while it is off,+/// "-" when unknown.+pub fn space_memory(s: &SpaceResources) -> String {+ let total = if s.memory_allocated > 0 {+ s.memory_allocated+ } else {+ s.usage+ .filter(|u| u.memory_limited)+ .map(|u| u.memory_total)+ .unwrap_or(0)+ };+ match (total, s.usage) {+ (0, _) => "-".into(),+ (t, Some(u)) => of(u.memory_used, t),+ (t, None) => size(t),+ }+}++/// The disk cell of a Space row: what it costs this computer, else "up to+/// 80 GB" (its size limit), else "-".+pub fn space_disk(s: &SpaceResources) -> String {+ if let Some(text) = s.disk_on_host.as_ref().and_then(disk_on_host) {+ return text;+ }+ match s.disk_allocated {+ 0 => "-".into(),+ n => format!("up to {}", size(n)),+ }+}++/// The CPU cell of another computer's row.+pub fn computer_cpu(c: &ComputerResources) -> String {+ if c.cpu_count == 0 {+ "-".into()+ } else {+ processor(c.cpu_count, Some(c.cpu_percent))+ }+}++/// The memory cell of another computer's row.+pub fn computer_memory(c: &ComputerResources) -> String {+ if c.memory_total == 0 {+ "-".into()+ } else {+ of(c.memory_used, c.memory_total)+ }+}++/// The disk cell of another computer's row.+pub fn computer_disk(c: &ComputerResources) -> String {+ if c.disk_total == 0 {+ "-".into()+ } else {+ disk_free(c.disk_free, c.disk_total)+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::resources::{GIB, GuestUsage};++ const TB: u64 = 1024 * GIB;++ #[test]+ fn sizes_read_like_the_finder() {+ assert_eq!(size(512 * 1024 * 1024), "512 MB");+ assert_eq!(size(4 * GIB), "4 GB");+ assert_eq!(size(3 * GIB + GIB / 10), "3.1 GB");+ assert_eq!(size(41 * GIB), "41 GB");+ assert_eq!(size(TB), "1 TB");+ assert_eq!(size(120 * GIB), "120 GB");+ assert_eq!(size(100 * 1024), "100 KB");+ }++ #[test]+ fn the_words_are_the_ones_the_apps_use() {+ assert_eq!(processor(12, Some(38.0)), "12 cores \u{b7} 38% busy");+ assert_eq!(processor(1, Some(0.4)), "1 core \u{b7} 0% busy");+ assert_eq!(processor(4, None), "4 cores");+ assert_eq!(memory_in_use(41 * GIB, 64 * GIB), "41 of 64 GB in use");+ assert_eq!(of(3 * GIB + GIB / 10, 8 * GIB), "3.1 of 8 GB");+ assert_eq!(of(512 * 1024 * 1024, 8 * GIB), "512 MB of 8 GB");+ assert_eq!(disk_free(41 * GIB, TB), "41 GB free of 1 TB");+ }++ #[test]+ fn what_a_space_costs_this_computer() {+ let shared = DiskOnHost {+ bytes: Some(31 * GIB),+ allocated: 87 * GIB,+ shares_space: true,+ };+ assert_eq!(+ disk_on_host(&shared).unwrap(),+ "about 31 GB, shares space with other copies"+ );+ let own = DiskOnHost {+ bytes: Some(6 * GIB),+ allocated: 6 * GIB,+ shares_space: false,+ };+ assert_eq!(disk_on_host(&own).unwrap(), "about 6 GB");+ let unknown = DiskOnHost {+ bytes: None,+ allocated: 12 * GIB,+ shares_space: true,+ };+ assert_eq!(+ disk_on_host(&unknown).unwrap(),+ "shares space with other copies"+ );+ assert_eq!(disk_on_host(&DiskOnHost::default()), None);+ }++ fn running() -> SpaceResources {+ SpaceResources {+ id: "local:a".into(),+ power_state: "running".into(),+ cpu_allocated: 4,+ memory_allocated: 8 * GIB,+ disk_allocated: 80 * GIB,+ usage: Some(GuestUsage {+ cpu_count: 4,+ cpu_percent: 22.0,+ memory_used: 3 * GIB + GIB / 10,+ memory_total: 8 * GIB,+ memory_limited: true,+ ..Default::default()+ }),+ disk_on_host: Some(DiskOnHost {+ bytes: Some(31 * GIB),+ allocated: 87 * GIB,+ shares_space: true,+ }),+ }+ }++ #[test]+ fn a_running_space_row() {+ let s = running();+ assert_eq!(space_cpu(&s), "4 cores \u{b7} 22% busy");+ assert_eq!(space_memory(&s), "3.1 of 8 GB");+ assert_eq!(+ space_disk(&s),+ "about 31 GB, shares space with other copies"+ );+ }++ #[test]+ fn a_stopped_space_shows_what_it_was_given() {+ let s = SpaceResources {+ power_state: "stopped".into(),+ usage: None,+ disk_on_host: Some(DiskOnHost {+ bytes: Some(6 * GIB),+ allocated: 6 * GIB,+ shares_space: false,+ }),+ ..running()+ };+ assert_eq!(space_cpu(&s), "4 cores");+ assert_eq!(space_memory(&s), "8 GB");+ assert_eq!(space_disk(&s), "about 6 GB");+ // No measurement: its size limit.+ let s = SpaceResources {+ disk_on_host: None,+ ..s+ };+ assert_eq!(space_disk(&s), "up to 80 GB");+ // Nothing known.+ let none = SpaceResources {+ id: "local:x".into(),+ ..Default::default()+ };+ assert_eq!(+ (space_cpu(&none), space_memory(&none), space_disk(&none)),+ ("-".into(), "-".into(), "-".into())+ );+ }++ #[test]+ fn another_computers_row() {+ let c = ComputerResources {+ cpu_count: 12,+ cpu_percent: 38.0,+ memory_total: 64 * GIB,+ memory_used: 41 * GIB,+ disk_total: TB,+ disk_free: 41 * GIB,+ ..Default::default()+ };+ assert_eq!(computer_cpu(&c), "12 cores \u{b7} 38% busy");+ assert_eq!(computer_memory(&c), "41 of 64 GB");+ assert_eq!(computer_disk(&c), "41 GB free of 1 TB");+ assert_eq!(computer_cpu(&ComputerResources::default()), "-");+ }++ #[test]+ fn the_extra_spaces_sentence_and_the_warning() {+ let mut c = ComputerResources {+ spaces_count: 3,+ spaces_cpu_allocated: 6,+ spaces_memory_allocated: 12 * GIB,+ spaces_disk_bytes: 25 * GIB,+ spaces_disk_exact: true,+ ..Default::default()+ };+ assert_eq!(+ extra_spaces_use(&c).unwrap(),+ "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for files."+ );+ c.spaces_disk_exact = false;+ assert!(extra_spaces_use(&c).unwrap().contains("up to about 25 GB"));+ c.spaces_count = 0;+ assert_eq!(extra_spaces_use(&c), None);++ let low = DiskWarning::assess(10 * GIB, TB, 5 * GIB, DiskLevel::Ok);+ assert_eq!(+ warning(&low),+ Some("This Mac is almost out of space. Delete old Spaces or snapshots.")+ );+ let ok = DiskWarning::assess(500 * GIB, TB, 5 * GIB, DiskLevel::Ok);+ assert_eq!(warning(&ok), None);+ let crit = DiskWarning::assess(GIB, TB, 5 * GIB, DiskLevel::Ok);+ assert!(warning(&crit).unwrap().contains("out of space"));+ }++ #[test]+ fn the_copy_has_no_jargon() {+ let texts = [+ processor(12, Some(38.0)),+ memory_in_use(GIB, 2 * GIB),+ disk_free(GIB, 2 * GIB),+ disk_on_host(&DiskOnHost {+ bytes: Some(GIB),+ allocated: 2 * GIB,+ shares_space: true,+ })+ .unwrap(),+ warning(&DiskWarning::assess(GIB, TB, 5 * GIB, DiskLevel::Ok))+ .unwrap()+ .into(),+ ];+ for t in texts {+ for jargon in ["vcpu", "rss", "apfs", "sparse", "qcow", "cgroup", "clone"] {+ assert!(!t.to_lowercase().contains(jargon), "{jargon} in {t}");+ }+ }+ }+}diff --git a/libs/cua/crates/cua-spaces/src/spaces.rs b/libs/cua/crates/cua-spaces/src/spaces.rsindex 9a291ac3ad..ca8ca9ce12 100644--- a/libs/cua/crates/cua-spaces/src/spaces.rs+++ b/libs/cua/crates/cua-spaces/src/spaces.rs@@ -322,6 +322,7 @@ impl SpacesBuilder {hotspots: tokio::sync::Mutex::new(BTreeMap::new()),#[cfg(feature = "spaces-agents")]relay: std::sync::RwLock::new(self.relay),+ resources: crate::resources::Hub::new(),relay_cache: std::sync::Mutex::new(Vec::new()),relay_reported: std::sync::Mutex::new(relay_reported),relay_read: tokio::sync::Mutex::new(None),@@ -530,6 +531,8 @@ pub(crate) struct Inner {pub(crate) hotspots: tokio::sync::Mutex<BTreeMap<String, crate::hotspot::Hotspot>>,#[cfg(feature = "spaces-agents")]relay: std::sync::RwLock<Option<crate::relay::RelayAccount>>,+ /// The resource sampler and its watchers ([`crate::resources`]).+ pub(crate) resources: Arc<crate::resources::Hub>,/// The last directory listing (so `list` and `resolve` stay sync).pub(crate) relay_cache: std::sync::Mutex<Vec<crate::relay::RelayMachine>>,/// What each relay machine's cua-spacesd said about itself when thisdiff --git a/libs/cua/crates/cua-spaces/src/stream.rs b/libs/cua/crates/cua-spaces/src/stream.rsindex 9004563226..18501649e5 100644--- a/libs/cua/crates/cua-spaces/src/stream.rs+++ b/libs/cua/crates/cua-spaces/src/stream.rs@@ -147,11 +147,17 @@ pub struct StreamTicket {pub raw: pb::OpenMediaResponse,}-/// Memory and storage use (`SystemService.Metrics`). A size is the guest's-/// own limit only when its `*_limited` flag says so (a VM, a container's-/// cgroup limit); otherwise it is the host's.-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize)]+/// Processor, memory and storage use (`SystemService.Metrics`). A size is+/// the guest's own limit only when its `*_limited` flag says so (a VM, a+/// container's cgroup limit); otherwise it is the host's.+#[derive(Clone, Copy, Debug, Default, PartialEq, serde::Serialize)]pub struct Usage {+ /// Cores the guest sees.+ pub cpu_count: u32,+ /// Busy now, 0 to 100.+ pub cpu_percent: f64,+ /// 1-minute load average (0 on Windows).+ pub load_average_1m: f64,/// Memory in use, bytes.pub memory_used: u64,/// Memory size, bytes.@@ -169,6 +175,9 @@ pub struct Usage {impl From<pb::MetricsResponse> for Usage {fn from(m: pb::MetricsResponse) -> Self {Usage {+ cpu_count: m.cpu_count,+ cpu_percent: m.cpu_percent.clamp(0.0, 100.0),+ load_average_1m: m.load_average_1m.max(0.0),memory_used: m.memory_used_bytes,memory_total: m.memory_total_bytes,memory_limited: m.memory_limited,@@ -269,7 +278,7 @@ impl Space {Ok(cache.put(&key, image).map(|p| p.as_ref().clone()))}- /// Memory and storage use now (`SystemService.Metrics`).+ /// Processor, memory and storage use now (`SystemService.Metrics`).pub async fn usage(&self) -> Result<Usage> {Ok(self.spacesd()?.metrics().await?.into())}diff --git a/libs/cua/crates/cua-spaces/tests/resources.rs b/libs/cua/crates/cua-spaces/tests/resources.rsnew file mode 100644index 0000000000..e34cf8f557--- /dev/null+++ b/libs/cua/crates/cua-spaces/tests/resources.rs@@ -0,0 +1,297 @@+//! `Spaces::resources` and `Spaces::watch_resources` against a fake local+//! runtime whose one instance is a `MockServer` as the guest's cua-spacesd:+//! a Space's allocation and guest numbers, this Mac's totals, the summary+//! another computer publishes, and the watcher's snapshot, updates and+//! low-disk event.++use async_trait::async_trait;+use cua_host::testing::FakeRelay;+use cua_sandbox_core::placement::On;+use cua_sandbox_core::{+ InstanceStatus, LocalEndpoints, LocalInstance, LocalRuntime, LocalStartSpec, LocalSummary,+ RuntimeError,+};+use cua_spaces::resources::{DiskLevel, ResourcesEvent, THIS_MAC, summary};+use cua_spaces::{SpaceCreate, Spaces};+use cua_spacesd_client::testing::{MockAuth, MockServer};+use std::collections::BTreeMap;+use std::sync::{Arc, Mutex};+use std::time::Duration;++const GIB: u64 = 1 << 30;++/// A local runtime whose instances are all one `MockServer` on loopback.+struct FakeRuntime {+ port: u16,+ running: Mutex<BTreeMap<String, bool>>,+}++#[async_trait]+impl LocalRuntime for FakeRuntime {+ fn backend(&self) -> String {+ "fake".into()+ }+ async fn start(&self, spec: &LocalStartSpec) -> Result<LocalInstance, RuntimeError> {+ self.running.lock().unwrap().insert(spec.name.clone(), true);+ Ok(LocalInstance {+ name: spec.name.clone(),+ backend: "fake".into(),+ status: InstanceStatus::Running,+ endpoints: self.endpoints(&spec.name).await?,+ })+ }+ async fn stop(&self, name: &str) -> Result<(), RuntimeError> {+ self.running.lock().unwrap().insert(name.into(), false);+ Ok(())+ }+ async fn resume(&self, name: &str) -> Result<LocalInstance, RuntimeError> {+ Ok(LocalInstance {+ name: name.into(),+ backend: "fake".into(),+ status: InstanceStatus::Running,+ endpoints: self.endpoints(name).await?,+ })+ }+ async fn list(&self) -> Result<Vec<LocalSummary>, RuntimeError> {+ Ok(vec![])+ }+ async fn status(&self, name: &str) -> Result<InstanceStatus, RuntimeError> {+ match self.running.lock().unwrap().get(name) {+ Some(true) => Ok(InstanceStatus::Running),+ Some(false) => Ok(InstanceStatus::Stopped),+ None => Err(RuntimeError::NotFound(name.into())),+ }+ }+ async fn delete(&self, name: &str) -> Result<(), RuntimeError> {+ self.running.lock().unwrap().remove(name);+ Ok(())+ }+ async fn endpoints(&self, _name: &str) -> Result<LocalEndpoints, RuntimeError> {+ Ok(LocalEndpoints {+ host: "127.0.0.1".into(),+ ports: [(3211u16, self.port)].into(),+ ..Default::default()+ })+ }+}++struct Fixture {+ spaces: Spaces,+ _srv: MockServer,+ _home: tempfile::TempDir,+ _state: tempfile::TempDir,+}++async fn fixture() -> Fixture {+ let srv = MockServer::start(MockAuth::default()).await;+ let rt = Arc::new(FakeRuntime {+ port: srv.addr.port(),+ running: Mutex::new(BTreeMap::new()),+ });+ let home = tempfile::tempdir().unwrap();+ let state = tempfile::tempdir().unwrap();+ let spaces = Spaces::builder()+ .home(home.path())+ .sandboxes(+ cua_sandbox_core::Sandboxes::builder()+ .local(rt)+ .state_dir(state.path())+ .build(),+ )+ .build();+ Fixture {+ spaces,+ _srv: srv,+ _home: home,+ _state: state,+ }+}++async fn create(spaces: &Spaces, name: &str, cpus: u32, memory_mb: u64) {+ spaces+ .create(SpaceCreate {+ on: Some(On::Local),+ image: Some("cua-e2e-local/linux:docker-local-arm64".into()),+ spacesd: Some(true),+ name: Some(name.into()),+ cpus: Some(cpus),+ memory_mb: Some(memory_mb),+ timeout: Some(Duration::from_secs(20)),+ ..Default::default()+ })+ .await+ .unwrap()+ .ready()+ .unwrap();+}++#[tokio::test]+async fn a_local_space_reports_what_it_was_given_and_what_it_uses() {+ let f = fixture().await;+ create(&f.spaces, "aurora", 3, 3072).await;++ let r = f.spaces.resources(false).await.unwrap();+ // This Mac: cores and memory, the volume, and the extra-Space totals.+ let mac = &r.this_mac;+ assert_eq!(mac.id, THIS_MAC);+ assert!(mac.online);+ assert!(mac.cpu_count >= 1 && mac.memory_total > 0);+ assert!(mac.memory_used <= mac.memory_total);+ assert!(mac.disk_total > 0 && mac.disk_free <= mac.disk_total);+ assert_eq!(mac.spaces_count, 1);++ // The Space: allocation from its state file, guest numbers from Metrics.+ assert_eq!(r.spaces.len(), 1);+ let s = &r.spaces[0];+ assert_eq!(s.id, "local:aurora");+ assert_eq!((s.cpu_allocated, s.memory_allocated), (3, 3 * GIB));+ let u = s.usage.expect("the guest answered");+ assert_eq!((u.cpu_count, u.cpu_percent), (4, 12.5));+ assert_eq!(u.load_average_1m, 0.75);+ assert_eq!((u.memory_total, u.memory_limited), (4 * GIB, true));+ assert_eq!((u.disk_total, u.disk_limited), (32 * GIB, true));+ // A fake engine has no disk files to measure: no number, no claim.+ assert_eq!(s.disk_on_host, None);+ // The totals add the running Space up (its power word is empty: it+ // answered, so it runs).+ assert_eq!(mac.spaces_running, 1);+ assert_eq!(mac.spaces_cpu_allocated, 3);+ assert_eq!(mac.spaces_memory_allocated, 3 * GIB);+ assert_eq!(mac.spaces_memory_used, u.memory_used);+ assert_eq!(r.warning, mac.warning);+}++#[tokio::test]+async fn a_poll_within_a_few_seconds_is_the_same_sample() {+ let f = fixture().await;+ let a = f.spaces.resources(false).await.unwrap();+ let b = f.spaces.resources(false).await.unwrap();+ assert_eq!(a.sequence, b.sequence);+ assert_eq!(a.sampled_at_ms, b.sampled_at_ms);+}++#[tokio::test]+async fn nothing_is_reported_about_another_computer_without_its_summary() {+ let f = fixture().await;+ let r = f.spaces.resources(false).await.unwrap();+ assert!(r.computers.is_empty());+}++#[tokio::test]+async fn other_computers_come_from_the_summary_in_their_relay_record() {+ let relay = FakeRelay::start().await;+ let f = fixture().await;+ let summary_value = summary::encode(&cua_spaces::resources::ComputerResources {+ id: "aaaa000000000001".into(),+ online: true,+ sampled_at_ms: 1_760_000_000_000,+ cpu_count: 10,+ cpu_percent: 31.0,+ memory_total: 32 * GIB,+ memory_used: 12 * GIB,+ disk_total: 512 * GIB,+ disk_free: 40 * GIB,+ spaces_count: 2,+ spaces_running: 1,+ warning: cua_spaces::resources::DiskWarning::assess(+ 40 * GIB,+ 512 * GIB,+ 5 * GIB,+ DiskLevel::Ok,+ ),+ ..Default::default()+ });+ relay.add_account("owner-token", "user-1", Some("[email protected]"));+ let client = cua_host::RelayClient::new(&relay.url).unwrap();+ for (id, name, meta) in [+ (+ "aaaa000000000001",+ "Mac mini",+ BTreeMap::from([(summary::META_KEY.to_string(), summary_value)]),+ ),+ ("bbbb000000000002", "Old laptop", BTreeMap::new()),+ ] {+ client+ .register(+ "owner-token",+ &cua_host::relay::RegisterRequest {+ id: id.into(),+ name: name.into(),+ allow: vec![],+ host: None,+ meta,+ },+ )+ .await+ .unwrap();+ }+ let spaces = Spaces::builder()+ .home(f._home.path())+ .relay(cua_spaces::RelayAccount::new(+ &relay.url,+ Arc::new(cua_spaces::relay::StaticToken("owner-token".into())),+ ))+ .build();+ spaces.relay_machines().await.unwrap();+ let r = spaces.resources(false).await.unwrap();+ // Only the computer that published a summary is there.+ assert_eq!(r.computers.len(), 1);+ let c = &r.computers[0];+ assert_eq!(c.id, "aaaa000000000001");+ assert_eq!(c.name, "Mac mini");+ assert_eq!((c.cpu_count, c.cpu_percent), (10, 31.0));+ assert_eq!((c.memory_total, c.memory_used), (32 * GIB, 12 * GIB));+ assert_eq!(c.disk_free, 40 * GIB);+ assert_eq!(c.warning.level, DiskLevel::Low);+ assert_eq!((c.spaces_count, c.spaces_running), (2, 1));+}++#[tokio::test]+async fn a_watch_starts_with_a_snapshot_then_sends_only_what_changed() {+ let f = fixture().await;+ create(&f.spaces, "aurora", 2, 2048).await;+ let mut watch = f.spaces.watch_resources(true);+ let first = tokio::time::timeout(Duration::from_secs(10), watch.next())+ .await+ .expect("a snapshot arrives")+ .unwrap();+ let ResourcesEvent::Snapshot(snap) = first else {+ panic!("first event is the snapshot, got {first:?}");+ };+ assert_eq!(snap.spaces.len(), 1);++ // A second Space appears. Nudge the sampler (a window shows/hides) once+ // the last sample is old enough to be redone.+ create(&f.spaces, "borealis", 1, 1024).await;+ tokio::time::sleep(Duration::from_millis(700)).await;+ watch.set_visible(false);+ watch.set_visible(true);+ let next = tokio::time::timeout(Duration::from_secs(10), watch.next())+ .await+ .expect("an update arrives")+ .unwrap();+ let ResourcesEvent::Update(update) = next else {+ panic!("then an update, got {next:?}");+ };+ assert!(update.sequence > snap.sequence);+ // Only the new Space (and nothing about the unchanged one).+ assert_eq!(+ update+ .spaces+ .iter()+ .map(|s| s.id.as_str())+ .collect::<Vec<_>>(),+ ["local:borealis"]+ );+ assert!(update.removed.is_empty());+}++#[tokio::test]+async fn dropping_the_last_watch_ends_the_sampling() {+ let f = fixture().await;+ let watch = f.spaces.watch_resources(false);+ drop(watch);+ // Nobody is interested any more: the next poll without `visible` still+ // answers (it samples on demand).+ assert!(f.spaces.resources(false).await.is_ok());+}diff --git a/libs/cua/crates/cua-spaces/tests/resources_publish.rs b/libs/cua/crates/cua-spaces/tests/resources_publish.rsnew file mode 100644index 0000000000..20023f01bf--- /dev/null+++ b/libs/cua/crates/cua-spaces/tests/resources_publish.rs@@ -0,0 +1,176 @@+//! A relay machine publishes its resource summary into its own machine+//! record, and your other computers read it from the machine list: numbers+//! only, at a low rate, and quietly nothing against a relay that predates+//! summaries (`cua_host::testing::FakeRelay`).++use cua_host::ConnectedClient;+use cua_host::testing::FakeRelay;+use cua_spaces::resources::publish::Published;+use cua_spaces::resources::summary;+use cua_spaces::{RelayAccount, Spaces};+use std::sync::Arc;++const MACHINE: &str = "aaaa000000000001";++/// A host registered on the relay, with this install's host config.+async fn host(relay: &FakeRelay, home: &std::path::Path) -> Spaces {+ relay.add_account("owner-token", "user-1", Some("[email protected]"));+ cua_host::RelayClient::new(&relay.url)+ .unwrap()+ .register(+ "owner-token",+ &cua_host::relay::RegisterRequest {+ id: MACHINE.into(),+ name: "Studio Mac".into(),+ allow: vec![],+ host: None,+ meta: [("cua.host.os".to_string(), "macos".to_string())].into(),+ },+ )+ .await+ .unwrap();+ std::fs::create_dir_all(home.join("host")).unwrap();+ std::fs::write(+ home.join("host/config.json"),+ serde_json::json!({+ "mode": "relay",+ "name": "Studio Mac",+ "machine_id": MACHINE,+ "runner": "process",+ "driver_bin": "/nonexistent/cua-spacesd",+ })+ .to_string(),+ )+ .unwrap();+ Spaces::builder()+ .home(home)+ .relay(RelayAccount::new(+ &relay.url,+ Arc::new(cua_spaces::relay::StaticToken("owner-token".into())),+ ))+ .build()+}++#[tokio::test]+async fn a_host_publishes_numbers_into_its_machine_record() {+ let relay = FakeRelay::start().await;+ let home = tempfile::tempdir().unwrap();+ let spaces = host(&relay, home.path()).await;++ let out = spaces.publish_resources().await.unwrap();+ assert_eq!(out, Published::Sent { watchers: 0 });+ let meta = relay.machine(MACHINE).unwrap().meta;+ // What registration set stays; the summary joins it.+ assert_eq!(meta["cua.host.os"], "macos");+ let value = &meta[summary::META_KEY];+ assert!(value.len() <= summary::MAX_LEN, "{value}");+ let c = summary::decode(MACHINE, "Studio Mac", true, value).expect("a summary");+ assert!(c.cpu_count >= 1);+ assert!(c.memory_total > 0 && c.disk_total > 0);+ // Numbers only.+ assert!(+ value+ .chars()+ .all(|ch| ch.is_ascii_digit() || "{}\":,".contains(ch) || ch.is_ascii_lowercase()),+ "{value}"+ );+ assert!(!value.contains("Studio"));+}++#[tokio::test]+async fn somebody_connected_means_watched() {+ let relay = FakeRelay::start().await;+ let home = tempfile::tempdir().unwrap();+ let spaces = host(&relay, home.path()).await;+ relay.add_client(+ MACHINE,+ ConnectedClient {+ id: "u2".into(),+ email: Some("[email protected]".into()),+ streams: 1,+ since: 5,+ ..Default::default()+ },+ );+ assert_eq!(+ spaces.publish_resources().await.unwrap(),+ Published::Sent { watchers: 1 }+ );+}++#[tokio::test]+async fn a_computer_that_is_not_a_relay_host_publishes_nothing() {+ let relay = FakeRelay::start().await;+ let home = tempfile::tempdir().unwrap();+ // Signed in, but `cua host setup` never ran here.+ let spaces = Spaces::builder()+ .home(home.path())+ .relay(RelayAccount::new(+ &relay.url,+ Arc::new(cua_spaces::relay::StaticToken("owner-token".into())),+ ))+ .build();+ assert_eq!(+ spaces.publish_resources().await.unwrap(),+ Published::NotAHost+ );+ // And a host with nobody signed in.+ let signed_out = Spaces::builder().home(home.path()).build();+ assert_eq!(+ signed_out.publish_resources().await.unwrap(),+ Published::NotAHost+ );+}++#[tokio::test]+async fn a_relay_that_drops_the_summary_is_reported_as_unsupported() {+ let relay = FakeRelay::start().await;+ relay.set_ignore_meta_patches(true);+ let home = tempfile::tempdir().unwrap();+ let spaces = host(&relay, home.path()).await;+ assert_eq!(+ spaces.publish_resources().await.unwrap(),+ Published::Unsupported+ );+ assert!(+ !relay+ .machine(MACHINE)+ .unwrap()+ .meta+ .contains_key(summary::META_KEY)+ );+}++#[tokio::test]+async fn another_computer_reads_the_summary_from_the_machine_list() {+ let relay = FakeRelay::start().await;+ let home = tempfile::tempdir().unwrap();+ let host_spaces = host(&relay, home.path()).await;+ host_spaces.publish_resources().await.unwrap();++ // Your laptop: signed in to the same account, its own cua home.+ let laptop_home = tempfile::tempdir().unwrap();+ let laptop = Spaces::builder()+ .home(laptop_home.path())+ .relay(RelayAccount::new(+ &relay.url,+ Arc::new(cua_spaces::relay::StaticToken("owner-token".into())),+ ))+ .build();+ laptop.relay_machines().await.unwrap();+ let r = laptop.resources(false).await.unwrap();+ assert_eq!(r.computers.len(), 1);+ assert_eq!(r.computers[0].id, MACHINE);+ assert_eq!(r.computers[0].name, "Studio Mac");+ assert!(r.computers[0].cpu_count >= 1);+ // The host itself does not list its own record next to itself.+ host_spaces.relay_machines().await.unwrap();+ assert!(+ host_spaces+ .resources(false)+ .await+ .unwrap()+ .computers+ .is_empty()+ );+}diff --git a/libs/cua/crates/cua-spaces/tests/resources_warning.rs b/libs/cua/crates/cua-spaces/tests/resources_warning.rsnew file mode 100644index 0000000000..c91381751d--- /dev/null+++ b/libs/cua/crates/cua-spaces/tests/resources_warning.rs@@ -0,0 +1,95 @@+//! The low-disk signal: a watcher hears when free space crosses the warning+//! line and again when it recovers. The free-space source is process-wide+//! (`cua_vmm::disk::set_probe`), so this is the only test in its binary.++use cua_spaces::Spaces;+use cua_spaces::resources::{DiskLevel, ResourcesEvent};+use cua_vmm::disk::{Space, SpaceProbe, set_probe};+use std::path::Path;+use std::sync::Arc;+use std::sync::atomic::{AtomicU64, Ordering};+use std::time::Duration;++const GIB: u64 = 1 << 30;++/// A 1 TiB volume with as much free as the test says.+struct Volume(Arc<AtomicU64>);++impl SpaceProbe for Volume {+ fn space(&self, _: &Path) -> std::io::Result<Space> {+ Ok(Space {+ available: self.0.load(Ordering::SeqCst),+ total: 1024 * GIB,+ })+ }+}++async fn next(w: &mut cua_spaces::resources::ResourceWatch) -> ResourcesEvent {+ tokio::time::timeout(Duration::from_secs(10), w.next())+ .await+ .expect("an event arrives")+ .expect("the watch is open")+}++/// Redo the sample once the last one is old enough to be replaced.+async fn nudge(w: &mut cua_spaces::resources::ResourceWatch) {+ tokio::time::sleep(Duration::from_millis(700)).await;+ w.set_visible(false);+ w.set_visible(true);+}++#[tokio::test]+async fn crossing_the_line_and_recovering_are_events() {+ let free = Arc::new(AtomicU64::new(400 * GIB));+ set_probe(Some(Arc::new(Volume(free.clone()))));+ let home = tempfile::tempdir().unwrap();+ let spaces = Spaces::builder().home(home.path()).build();+ let mut watch = spaces.watch_resources(true);++ // Plenty free: a snapshot, level ok.+ let ResourcesEvent::Snapshot(snap) = next(&mut watch).await else {+ panic!("a snapshot first");+ };+ assert_eq!(snap.warning.level, DiskLevel::Ok);+ assert_eq!(snap.this_mac.disk_free, 400 * GIB);+ assert_eq!(snap.this_mac.disk_total, 1024 * GIB);++ // 90 GiB free of 1 TiB: under the 100 GiB line (15% is capped there).+ free.store(90 * GIB, Ordering::SeqCst);+ nudge(&mut watch).await;+ let ResourcesEvent::Update(u) = next(&mut watch).await else {+ panic!("the free space moved: an update");+ };+ assert_eq!(u.this_mac.unwrap().disk_free, 90 * GIB);+ let ResourcesEvent::LowDisk(w) = next(&mut watch).await else {+ panic!("then the warning");+ };+ assert_eq!(w.level, DiskLevel::Low);+ assert_eq!(+ (w.free, w.total, w.threshold),+ (90 * GIB, 1024 * GIB, 100 * GIB)+ );++ // Under the floor where creates already fail.+ free.store(3 * GIB, Ordering::SeqCst);+ nudge(&mut watch).await;+ let _update = next(&mut watch).await;+ let ResourcesEvent::LowDisk(w) = next(&mut watch).await else {+ panic!("the warning got worse");+ };+ assert_eq!(w.level, DiskLevel::Critical);++ // Space is freed: back to ok, said once.+ free.store(400 * GIB, Ordering::SeqCst);+ nudge(&mut watch).await;+ let _update = next(&mut watch).await;+ let ResourcesEvent::LowDisk(w) = next(&mut watch).await else {+ panic!("the warning cleared");+ };+ assert_eq!((w.level, w.threshold), (DiskLevel::Ok, 0));++ // A poll sees the same signal for the menu bar.+ let r = spaces.resources(false).await.unwrap();+ assert_eq!(r.warning.level, DiskLevel::Ok);+ set_probe(None);+}diff --git a/libs/cua/crates/cua-spacesd-client/src/testing.rs b/libs/cua/crates/cua-spacesd-client/src/testing.rsindex 5f894f14d4..0e64c2f4fa 100644--- a/libs/cua/crates/cua-spacesd-client/src/testing.rs+++ b/libs/cua/crates/cua-spacesd-client/src/testing.rs@@ -720,8 +720,12 @@ impl SystemService for Svc {&self,_: tonic::Request<pb::MetricsRequest>,) -> Result<tonic::Response<pb::MetricsResponse>, Status> {- // A 4 GiB guest with a 32 GiB disk, both its own.+ // A 4-core guest at 12.5% with a 4 GiB memory and a 32 GiB disk, both+ // its own.Ok(tonic::Response::new(pb::MetricsResponse {+ cpu_count: 4,+ cpu_percent: 12.5,+ load_average_1m: 0.75,memory_total_bytes: 4 << 30,memory_used_bytes: 1_610_612_736,memory_limited: true,diff --git a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.ktindex dc5c532deb..564bfbf4c4 100644--- a/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt+++ b/libs/cua/kotlin/src/main/kotlin/ai/cua/sdk/cua_sdk.kt@@ -629,6 +629,9 @@ internal interface UniffiCallbackInterfaceFrameSinkMethod0 : com.sun.jna.Callbacinternal interface UniffiCallbackInterfaceFrameSinkMethod1 : com.sun.jna.Callback {fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,)}+internal interface UniffiCallbackInterfaceResourcesListenerMethod0 : com.sun.jna.Callback {+ fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,)+}internal interface UniffiCallbackInterfaceSpaceCreateListenerMethod0 : com.sun.jna.Callback {fun callback(`uniffiHandle`: Long,`progress`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,)}@@ -675,6 +678,25 @@ internal open class UniffiVTableCallbackInterfaceFrameSink(`onEvent` = other.`onEvent`}+}[email protected]("uniffiFree", "uniffiClone", "onEvent")+internal open class UniffiVTableCallbackInterfaceResourcesListener(+ @JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null,+ @JvmField internal var `uniffiClone`: UniffiCallbackInterfaceClone? = null,+ @JvmField internal var `onEvent`: UniffiCallbackInterfaceResourcesListenerMethod0? = null,+) : Structure() {+ class UniffiByValue(+ `uniffiFree`: UniffiCallbackInterfaceFree? = null,+ `uniffiClone`: UniffiCallbackInterfaceClone? = null,+ `onEvent`: UniffiCallbackInterfaceResourcesListenerMethod0? = null,+ ): UniffiVTableCallbackInterfaceResourcesListener(`uniffiFree`,`uniffiClone`,`onEvent`,), Structure.ByValue++ internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceResourcesListener) {+ `uniffiFree` = other.`uniffiFree`+ `uniffiClone` = other.`uniffiClone`+ `onEvent` = other.`onEvent`+ }+}@Structure.FieldOrder("uniffiFree", "uniffiClone", "onProgress")internal open class UniffiVTableCallbackInterfaceSpaceCreateListener(@@ -1253,6 +1275,12 @@ external fun uniffi_cua_sdk_checksum_method_presenceview_shape_of(): Shortexternal fun uniffi_cua_sdk_checksum_method_presenceview_upsert(): Short+external fun uniffi_cua_sdk_checksum_method_resourceslistener_on_event(+): Short+external fun uniffi_cua_sdk_checksum_method_resourceswatch_set_visible(+): Short+external fun uniffi_cua_sdk_checksum_method_resourceswatch_stop(+): Shortexternal fun uniffi_cua_sdk_checksum_method_space_agent_events(): Shortexternal fun uniffi_cua_sdk_checksum_method_space_agent_interrupt(@@ -1449,6 +1477,8 @@ external fun uniffi_cua_sdk_checksum_method_spaces_remove(): Shortexternal fun uniffi_cua_sdk_checksum_method_spaces_resolve(): Short+external fun uniffi_cua_sdk_checksum_method_spaces_resources(+): Shortexternal fun uniffi_cua_sdk_checksum_method_spaces_space(): Shortexternal fun uniffi_cua_sdk_checksum_method_spaces_start(@@ -1505,6 +1535,8 @@ external fun uniffi_cua_sdk_checksum_method_spaces_volume_unmount(): Shortexternal fun uniffi_cua_sdk_checksum_method_spaces_volume_write(): Short+external fun uniffi_cua_sdk_checksum_method_spaces_watch_resources(+): Shortexternal fun uniffi_cua_sdk_checksum_method_teleportapprover_approve(): Shortexternal fun uniffi_cua_sdk_checksum_method_spacesdclient_agents(@@ -1645,6 +1677,7 @@ internal object UniffiLib {Native.register(UniffiLib::class.java, findLibraryName(componentName = "cua_sdk"))uniffiCallbackInterfaceAudioSink.register(this)uniffiCallbackInterfaceFrameSink.register(this)+ uniffiCallbackInterfaceResourcesListener.register(this)uniffiCallbackInterfaceSpaceCreateListener.register(this)uniffiCallbackInterfaceTeleportApprover.register(this)@@ -2169,6 +2202,22 @@ external fun uniffi_cua_sdk_fn_method_presenceview_shape_of(`ptr`: Long,`partici): RustBuffer.ByValueexternal fun uniffi_cua_sdk_fn_method_presenceview_upsert(`ptr`: Long,`participant`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,): Unit+external fun uniffi_cua_sdk_fn_clone_resourceslistener(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,+): Long+external fun uniffi_cua_sdk_fn_free_resourceslistener(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,+): Unit+external fun uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(`vtable`: UniffiVTableCallbackInterfaceResourcesListener,+): Unit+external fun uniffi_cua_sdk_fn_method_resourceslistener_on_event(`ptr`: Long,`event`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,+): Unit+external fun uniffi_cua_sdk_fn_clone_resourceswatch(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,+): Long+external fun uniffi_cua_sdk_fn_free_resourceswatch(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,+): Unit+external fun uniffi_cua_sdk_fn_method_resourceswatch_set_visible(`ptr`: Long,`visible`: Byte,uniffi_out_err: UniffiRustCallStatus,+): Unit+external fun uniffi_cua_sdk_fn_method_resourceswatch_stop(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus,+): Unitexternal fun uniffi_cua_sdk_fn_clone_space(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,): Longexternal fun uniffi_cua_sdk_fn_free_space(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,@@ -2387,6 +2436,8 @@ external fun uniffi_cua_sdk_fn_method_spaces_remove(`ptr`: Long,`space`: RustBuf): Longexternal fun uniffi_cua_sdk_fn_method_spaces_resolve(`ptr`: Long,`space`: RustBuffer.ByValue,): Long+external fun uniffi_cua_sdk_fn_method_spaces_resources(`ptr`: Long,`visible`: Byte,+): Longexternal fun uniffi_cua_sdk_fn_method_spaces_space(`ptr`: Long,`space`: RustBuffer.ByValue,): Longexternal fun uniffi_cua_sdk_fn_method_spaces_start(`ptr`: Long,`space`: RustBuffer.ByValue,@@ -2443,6 +2494,8 @@ external fun uniffi_cua_sdk_fn_method_spaces_volume_unmount(`ptr`: Long,): Longexternal fun uniffi_cua_sdk_fn_method_spaces_volume_write(`ptr`: Long,`path`: RustBuffer.ByValue,`content`: RustBuffer.ByValue,`ifEtag`: RustBuffer.ByValue,`createOnly`: Byte,`view`: RustBuffer.ByValue,): Long+external fun uniffi_cua_sdk_fn_method_spaces_watch_resources(`ptr`: Long,`visible`: Byte,`listener`: Long,uniffi_out_err: UniffiRustCallStatus,+): Longexternal fun uniffi_cua_sdk_fn_clone_teleportapprover(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,): Longexternal fun uniffi_cua_sdk_fn_free_teleportapprover(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,@@ -3564,6 +3617,15 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {if (lib.uniffi_cua_sdk_checksum_method_presenceview_upsert() != 29196.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}+ if (lib.uniffi_cua_sdk_checksum_method_resourceslistener_on_event() != 32126.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }+ if (lib.uniffi_cua_sdk_checksum_method_resourceswatch_set_visible() != 54652.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }+ if (lib.uniffi_cua_sdk_checksum_method_resourceswatch_stop() != 52286.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }if (lib.uniffi_cua_sdk_checksum_method_space_agent_events() != 25540.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}@@ -3684,7 +3746,7 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {if (lib.uniffi_cua_sdk_checksum_method_space_upload() != 30524.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}- if (lib.uniffi_cua_sdk_checksum_method_space_usage() != 15261.toShort()) {+ if (lib.uniffi_cua_sdk_checksum_method_space_usage() != 43925.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}if (lib.uniffi_cua_sdk_checksum_method_space_websocket_headers() != 61370.toShort()) {@@ -3858,6 +3920,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {if (lib.uniffi_cua_sdk_checksum_method_spaces_resolve() != 9986.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}+ if (lib.uniffi_cua_sdk_checksum_method_spaces_resources() != 12146.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }if (lib.uniffi_cua_sdk_checksum_method_spaces_space() != 26355.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}@@ -3942,6 +4007,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {if (lib.uniffi_cua_sdk_checksum_method_spaces_volume_write() != 64388.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}+ if (lib.uniffi_cua_sdk_checksum_method_spaces_watch_resources() != 49660.toShort()) {+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ }if (lib.uniffi_cua_sdk_checksum_method_teleportapprover_approve() != 36264.toShort()) {throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")}@@ -14033,6 +14101,612 @@ public object FfiConverterTypeRelay: FfiConverter<Relay, Long> {//+/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+public interface ResourcesListener {++ /**+ * Something moved.+ */+ fun `onEvent`(`event`: ResourcesEvent)++ companion object+}++/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+open class ResourcesListenerImpl: Disposable, AutoCloseable, ResourcesListener+{++ @Suppress("UNUSED_PARAMETER")+ /**+ * @suppress+ */+ constructor(withHandle: UniffiWithHandle, handle: Long) {+ this.handle = handle+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle))+ }++ /**+ * @suppress+ *+ * This constructor can be used to instantiate a fake object. Only used for tests. Any+ * attempt to actually use an object constructed this way will fail as there is no+ * connected Rust object.+ */+ @Suppress("UNUSED_PARAMETER")+ constructor(noHandle: NoHandle) {+ this.handle = 0+ this.cleanable = null+ }++ protected val handle: Long+ protected val cleanable: UniffiCleaner.Cleanable?++ private val wasDestroyed = AtomicBoolean(false)+ private val callCounter = AtomicLong(1)++ override fun destroy() {+ // Only allow a single call to this method.+ // TODO: maybe we should log a warning if called more than once?+ if (this.wasDestroyed.compareAndSet(false, true)) {+ // This decrement always matches the initial count of 1 given at creation time.+ if (this.callCounter.decrementAndGet() == 0L) {+ cleanable?.clean()+ }+ }+ }++ @Synchronized+ override fun close() {+ this.destroy()+ }++ internal inline fun <R> callWithHandle(block: (handle: Long) -> R): R {+ // Check and increment the call counter, to keep the object alive.+ // This needs a compare-and-set retry loop in case of concurrent updates.+ do {+ val c = this.callCounter.get()+ if (c == 0L) {+ throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")+ }+ if (c == Long.MAX_VALUE) {+ throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")+ }+ } while (! this.callCounter.compareAndSet(c, c + 1L))+ // Now we can safely do the method call without the handle being freed concurrently.+ try {+ return block(this.uniffiCloneHandle())+ } finally {+ // This decrement always matches the increment we performed above.+ if (this.callCounter.decrementAndGet() == 0L) {+ cleanable?.clean()+ }+ }+ }++ // Use a static inner class instead of a closure so as not to accidentally+ // capture `this` as part of the cleanable's action.+ private class UniffiCleanAction(private val handle: Long) : Runnable {+ override fun run() {+ if (handle == 0.toLong()) {+ // Fake object created with `NoHandle`, don't try to free.+ return;+ }+ uniffiRustCall { status ->+ UniffiLib.uniffi_cua_sdk_fn_free_resourceslistener(handle, status)+ }+ }+ }++ /**+ * @suppress+ */+ fun uniffiCloneHandle(): Long {+ if (handle == 0.toLong()) {+ throw InternalException("uniffiCloneHandle() called on NoHandle object");+ }+ return uniffiRustCall() { status ->+ UniffiLib.uniffi_cua_sdk_fn_clone_resourceslistener(handle, status)+ }+ }+++ /**+ * Something moved.+ */override fun `onEvent`(`event`: ResourcesEvent)+ =+ callWithHandle {+ uniffiRustCall() { _status ->+ UniffiLib.uniffi_cua_sdk_fn_method_resourceslistener_on_event(+ it,+ FfiConverterTypeResourcesEvent.lower(`event`),_status)+}+ }+++++++++++ /**+ * @suppress+ */+ companion object++}++++// Put the implementation in an object so we don't pollute the top-level namespace+internal object uniffiCallbackInterfaceResourcesListener {+ internal object `onEvent`: UniffiCallbackInterfaceResourcesListenerMethod0 {+ override fun callback(`uniffiHandle`: Long,`event`: RustBuffer.ByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) {+ val uniffiObj = FfiConverterTypeResourcesListener.handleMap.get(uniffiHandle)+ val makeCall = { ->+ uniffiObj.`onEvent`(+ FfiConverterTypeResourcesEvent.lift(`event`),+ )+ }+ val writeReturn = { _: Unit -> Unit }+ uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn)+ }+ }++ internal object uniffiFree: UniffiCallbackInterfaceFree {+ override fun callback(handle: Long) {+ FfiConverterTypeResourcesListener.handleMap.remove(handle)+ }+ }++ internal object uniffiClone: UniffiCallbackInterfaceClone {+ override fun callback(handle: Long): Long {+ return FfiConverterTypeResourcesListener.handleMap.clone(handle)+ }+ }++ internal var vtable = UniffiVTableCallbackInterfaceResourcesListener.UniffiByValue(+ uniffiFree,+ uniffiClone,+ `onEvent`,+ )++ // Registers the foreign callback with the Rust side.+ // This method is generated for each callback interface.+ internal fun register(lib: UniffiLib) {+ lib.uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(vtable)+ }+}++/**+ * @suppress+ */+public object FfiConverterTypeResourcesListener: FfiConverter<ResourcesListener, Long> {+ internal val handleMap = UniffiHandleMap<ResourcesListener>()++ override fun lower(value: ResourcesListener): Long {+ if (value is ResourcesListenerImpl) {+ // Rust-implemented object. Clone the handle and return it+ return value.uniffiCloneHandle()+ } else {+ // Kotlin object, generate a new vtable handle and return that.+ return handleMap.insert(value)+ }+ }++ override fun lift(value: Long): ResourcesListener {+ if ((value and 1.toLong()) == 0.toLong()) {+ // Rust-generated handle, construct a new class that uses the handle to implement the+ // interface+ return ResourcesListenerImpl(UniffiWithHandle, value)+ } else {+ // Kotlin-generated handle, get the object from the handle map+ return handleMap.remove(value)+ }+ }++ override fun read(buf: ByteBuffer): ResourcesListener {+ return lift(buf.getLong())+ }++ override fun allocationSize(value: ResourcesListener) = 8UL++ override fun write(value: ResourcesListener, buf: ByteBuffer) {+ buf.putLong(lower(value))+ }+}+++// This template implements a class for working with a Rust struct via a handle+// to the live Rust struct on the other side of the FFI.+//+// There's some subtlety here, because we have to be careful not to operate on a Rust+// struct after it has been dropped, and because we must expose a public API for freeing+// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:+//+// * Each instance holds an opaque handle to the underlying Rust struct.+// Method calls need to read this handle from the object's state and pass it in to+// the Rust FFI.+//+// * When an instance is no longer needed, its handle should be passed to a+// special destructor function provided by the Rust FFI, which will drop the+// underlying Rust struct.+//+// * Given an instance, calling code is expected to call the special+// `destroy` method in order to free it after use, either by calling it explicitly+// or by using a higher-level helper like the `use` method. Failing to do so risks+// leaking the underlying Rust struct.+//+// * We can't assume that calling code will do the right thing, and must be prepared+// to handle Kotlin method calls executing concurrently with or even after a call to+// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.+//+// * We must never allow Rust code to operate on the underlying Rust struct after+// the destructor has been called, and must never call the destructor more than once.+// Doing so may trigger memory unsafety.+//+// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`+// is implemented to call the destructor when the Kotlin object becomes unreachable.+// This is done in a background thread. This is not a panacea, and client code should be aware that+// 1. the thread may starve if some there are objects that have poorly performing+// `drop` methods or do significant work in their `drop` methods.+// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,+// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).+//+// If we try to implement this with mutual exclusion on access to the handle, there is the+// possibility of a race between a method call and a concurrent call to `destroy`:+//+// * Thread A starts a method call, reads the value of the handle, but is interrupted+// before it can pass the handle over the FFI to Rust.+// * Thread B calls `destroy` and frees the underlying Rust struct.+// * Thread A resumes, passing the already-read handle value to Rust and triggering+// a use-after-free.+//+// One possible solution would be to use a `ReadWriteLock`, with each method call taking+// a read lock (and thus allowed to run concurrently) and the special `destroy` method+// taking a write lock (and thus blocking on live method calls). However, we aim not to+// generate methods with any hidden blocking semantics, and a `destroy` method that might+// block if called incorrectly seems to meet that bar.+//+// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track+// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`+// has been called. These are updated according to the following rules:+//+// * The initial value of the counter is 1, indicating a live object with no in-flight calls.+// The initial value for the flag is false.+//+// * At the start of each method call, we atomically check the counter.+// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.+// If it is nonzero them we atomically increment it by 1 and proceed with the method call.+//+// * At the end of each method call, we atomically decrement and check the counter.+// If it has reached zero then we destroy the underlying Rust struct.+//+// * When `destroy` is called, we atomically flip the flag from false to true.+// If the flag was already true we silently fail.+// Otherwise we atomically decrement and check the counter.+// If it has reached zero then we destroy the underlying Rust struct.+//+// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,+// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.+//+// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been+// called *and* all in-flight method calls have completed, avoiding violating any of the expectations+// of the underlying Rust code.+//+// This makes a cleaner a better alternative to _not_ calling `destroy()` as+// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`+// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner+// thread may be starved, and the app will leak memory.+//+// In this case, `destroy`ing manually may be a better solution.+//+// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects+// with Rust peers are reclaimed:+//+// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:+// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:+// 3. The memory is reclaimed when the process terminates.+//+// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219+//+++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+public interface ResourcesWatchInterface {++ /**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ fun `setVisible`(`visible`: kotlin.Boolean)++ /**+ * Ends the watch. No event is delivered after this returns.+ */+ fun `stop`()++ companion object+}++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+open class ResourcesWatch: Disposable, AutoCloseable, ResourcesWatchInterface+{++ @Suppress("UNUSED_PARAMETER")+ /**+ * @suppress+ */+ constructor(withHandle: UniffiWithHandle, handle: Long) {+ this.handle = handle+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle))+ }++ /**+ * @suppress+ *+ * This constructor can be used to instantiate a fake object. Only used for tests. Any+ * attempt to actually use an object constructed this way will fail as there is no+ * connected Rust object.+ */+ @Suppress("UNUSED_PARAMETER")+ constructor(noHandle: NoHandle) {+ this.handle = 0+ this.cleanable = null+ }++ protected val handle: Long+ protected val cleanable: UniffiCleaner.Cleanable?++ private val wasDestroyed = AtomicBoolean(false)+ private val callCounter = AtomicLong(1)++ override fun destroy() {+ // Only allow a single call to this method.+ // TODO: maybe we should log a warning if called more than once?+ if (this.wasDestroyed.compareAndSet(false, true)) {+ // This decrement always matches the initial count of 1 given at creation time.+ if (this.callCounter.decrementAndGet() == 0L) {+ cleanable?.clean()+ }+ }+ }++ @Synchronized+ override fun close() {+ this.destroy()+ }++ internal inline fun <R> callWithHandle(block: (handle: Long) -> R): R {+ // Check and increment the call counter, to keep the object alive.+ // This needs a compare-and-set retry loop in case of concurrent updates.+ do {+ val c = this.callCounter.get()+ if (c == 0L) {+ throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")+ }+ if (c == Long.MAX_VALUE) {+ throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")+ }+ } while (! this.callCounter.compareAndSet(c, c + 1L))+ // Now we can safely do the method call without the handle being freed concurrently.+ try {+ return block(this.uniffiCloneHandle())+ } finally {+ // This decrement always matches the increment we performed above.+ if (this.callCounter.decrementAndGet() == 0L) {+ cleanable?.clean()+ }+ }+ }++ // Use a static inner class instead of a closure so as not to accidentally+ // capture `this` as part of the cleanable's action.+ private class UniffiCleanAction(private val handle: Long) : Runnable {+ override fun run() {+ if (handle == 0.toLong()) {+ // Fake object created with `NoHandle`, don't try to free.+ return;+ }+ uniffiRustCall { status ->+ UniffiLib.uniffi_cua_sdk_fn_free_resourceswatch(handle, status)+ }+ }+ }++ /**+ * @suppress+ */+ fun uniffiCloneHandle(): Long {+ if (handle == 0.toLong()) {+ throw InternalException("uniffiCloneHandle() called on NoHandle object");+ }+ return uniffiRustCall() { status ->+ UniffiLib.uniffi_cua_sdk_fn_clone_resourceswatch(handle, status)+ }+ }+++ /**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */override fun `setVisible`(`visible`: kotlin.Boolean)+ =+ callWithHandle {+ uniffiRustCall() { _status ->+ UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_set_visible(+ it,+ FfiConverterBoolean.lower(`visible`),_status)+}+ }+++++ /**+ * Ends the watch. No event is delivered after this returns.+ */override fun `stop`()+ =+ callWithHandle {+ uniffiRustCall() { _status ->+ UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_stop(+ it,+ _status)+}+ }+++++++++++ /**+ * @suppress+ */+ companion object++}+++/**+ * @suppress+ */+public object FfiConverterTypeResourcesWatch: FfiConverter<ResourcesWatch, Long> {+ override fun lower(value: ResourcesWatch): Long {+ return value.uniffiCloneHandle()+ }++ override fun lift(value: Long): ResourcesWatch {+ return ResourcesWatch(UniffiWithHandle, value)+ }++ override fun read(buf: ByteBuffer): ResourcesWatch {+ return lift(buf.getLong())+ }++ override fun allocationSize(value: ResourcesWatch) = 8UL++ override fun write(value: ResourcesWatch, buf: ByteBuffer) {+ buf.putLong(lower(value))+ }+}+++// This template implements a class for working with a Rust struct via a handle+// to the live Rust struct on the other side of the FFI.+//+// There's some subtlety here, because we have to be careful not to operate on a Rust+// struct after it has been dropped, and because we must expose a public API for freeing+// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:+//+// * Each instance holds an opaque handle to the underlying Rust struct.+// Method calls need to read this handle from the object's state and pass it in to+// the Rust FFI.+//+// * When an instance is no longer needed, its handle should be passed to a+// special destructor function provided by the Rust FFI, which will drop the+// underlying Rust struct.+//+// * Given an instance, calling code is expected to call the special+// `destroy` method in order to free it after use, either by calling it explicitly+// or by using a higher-level helper like the `use` method. Failing to do so risks+// leaking the underlying Rust struct.+//+// * We can't assume that calling code will do the right thing, and must be prepared+// to handle Kotlin method calls executing concurrently with or even after a call to+// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.+//+// * We must never allow Rust code to operate on the underlying Rust struct after+// the destructor has been called, and must never call the destructor more than once.+// Doing so may trigger memory unsafety.+//+// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`+// is implemented to call the destructor when the Kotlin object becomes unreachable.+// This is done in a background thread. This is not a panacea, and client code should be aware that+// 1. the thread may starve if some there are objects that have poorly performing+// `drop` methods or do significant work in their `drop` methods.+// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,+// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).+//+// If we try to implement this with mutual exclusion on access to the handle, there is the+// possibility of a race between a method call and a concurrent call to `destroy`:+//+// * Thread A starts a method call, reads the value of the handle, but is interrupted+// before it can pass the handle over the FFI to Rust.+// * Thread B calls `destroy` and frees the underlying Rust struct.+// * Thread A resumes, passing the already-read handle value to Rust and triggering+// a use-after-free.+//+// One possible solution would be to use a `ReadWriteLock`, with each method call taking+// a read lock (and thus allowed to run concurrently) and the special `destroy` method+// taking a write lock (and thus blocking on live method calls). However, we aim not to+// generate methods with any hidden blocking semantics, and a `destroy` method that might+// block if called incorrectly seems to meet that bar.+//+// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track+// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`+// has been called. These are updated according to the following rules:+//+// * The initial value of the counter is 1, indicating a live object with no in-flight calls.+// The initial value for the flag is false.+//+// * At the start of each method call, we atomically check the counter.+// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.+// If it is nonzero them we atomically increment it by 1 and proceed with the method call.+//+// * At the end of each method call, we atomically decrement and check the counter.+// If it has reached zero then we destroy the underlying Rust struct.+//+// * When `destroy` is called, we atomically flip the flag from false to true.+// If the flag was already true we silently fail.+// Otherwise we atomically decrement and check the counter.+// If it has reached zero then we destroy the underlying Rust struct.+//+// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,+// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.+//+// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been+// called *and* all in-flight method calls have completed, avoiding violating any of the expectations+// of the underlying Rust code.+//+// This makes a cleaner a better alternative to _not_ calling `destroy()` as+// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`+// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner+// thread may be starved, and the app will leak memory.+//+// In this case, `destroy`ing manually may be a better solution.+//+// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects+// with Rust peers are reclaimed:+//+// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:+// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:+// 3. The memory is reclaimed when the process terminates.+//+// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219+//++/*** A sandbox handle.*/@@ -16480,8 +17154,8 @@ public interface SpaceInterface {suspend fun `upload`(`localPath`: kotlin.String, `dest`: kotlin.String?): SpaceTransferReport/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/suspend fun `usage`(): SpaceUsage@@ -17594,8 +18268,8 @@ open class Space: Disposable, AutoCloseable, SpaceInterface/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/@Throws(CuaException::class)@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")@@ -19250,6 +19924,16 @@ public interface SpacesInterface {*/suspend fun `resolve`(`space`: kotlin.String): SpaceInfo+ /**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ suspend fun `resources`(`visible`: kotlin.Boolean): ResourcesSnapshot+/*** A connected handle to a registered Space.*/@@ -19401,6 +20085,15 @@ public interface SpacesInterface {*/suspend fun `volumeWrite`(`path`: kotlin.String, `content`: kotlin.ByteArray, `ifEtag`: kotlin.String?, `createOnly`: kotlin.Boolean, `view`: DriveView?): DriveObject+ /**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ fun `watchResources`(`visible`: kotlin.Boolean, `listener`: ResourcesListener): ResourcesWatch+companion object}@@ -20464,6 +21157,35 @@ open class Spaces: Disposable, AutoCloseable, SpacesInterface}+ /**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ @Throws(CuaException::class)+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")+ override suspend fun `resources`(`visible`: kotlin.Boolean) : ResourcesSnapshot {+ return uniffiRustCallAsync(+ callWithHandle { uniffiHandle ->+ UniffiLib.uniffi_cua_sdk_fn_method_spaces_resources(+ uniffiHandle,+ FfiConverterBoolean.lower(`visible`),+ )+ },+ { future, callback, continuation -> UniffiLib.ffi_cua_sdk_rust_future_poll_rust_buffer(future, callback, continuation) },+ { future, continuation -> UniffiLib.ffi_cua_sdk_rust_future_complete_rust_buffer(future, continuation) },+ { future -> UniffiLib.ffi_cua_sdk_rust_future_free_rust_buffer(future) },+ // lift function+ { FfiConverterTypeResourcesSnapshot.lift(it) },+ // Error FFI converter+ CuaException.ErrorHandler,+ )+ }++/*** A connected handle to a registered Space.*/@@ -21150,6 +21872,26 @@ open class Spaces: Disposable, AutoCloseable, SpacesInterface}+ /**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */override fun `watchResources`(`visible`: kotlin.Boolean, `listener`: ResourcesListener): ResourcesWatch {+ return FfiConverterTypeResourcesWatch.lift(+ callWithHandle {+ uniffiRustCall() { _status ->+ UniffiLib.uniffi_cua_sdk_fn_method_spaces_watch_resources(+ it,+ FfiConverterBoolean.lower(`visible`),FfiConverterTypeResourcesListener.lower(`listener`),_status)+}+ }+ )+ }+++@@ -26194,6 +26936,191 @@ public object FfiConverterTypeComputerGrant: FfiConverterRustBuffer<ComputerGran+/**+ * A computer: this Mac, or one of your other computers (from the summary+ * it published).+ */+data class ComputerResources (+ /**+ * `this-mac`, or the relay machine id.+ */+ var `id`: kotlin.String+ ,+ /**+ * Display name (empty for this Mac).+ */+ var `name`: kotlin.String+ ,+ /**+ * Reachable now (always true for this Mac).+ */+ var `online`: kotlin.Boolean+ ,+ /**+ * When the computer measured this, unix ms (another computer's can be+ * minutes old).+ */+ var `sampledAtMs`: kotlin.ULong+ ,+ /**+ * Processor cores.+ */+ var `cpuCount`: kotlin.UInt+ ,+ /**+ * Busy now, 0 to 100.+ */+ var `cpuPercent`: kotlin.Double+ ,+ /**+ * 1-minute load average.+ */+ var `loadAverage1m`: kotlin.Double+ ,+ /**+ * Memory size, bytes.+ */+ var `memoryTotal`: kotlin.ULong+ ,+ /**+ * Memory in use, bytes (without reclaimable cache).+ */+ var `memoryUsed`: kotlin.ULong+ ,+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ var `diskTotal`: kotlin.ULong+ ,+ /**+ * Free bytes on it.+ */+ var `diskFree`: kotlin.ULong+ ,+ /**+ * Extra Spaces on it.+ */+ var `spacesCount`: kotlin.UInt+ ,+ /**+ * Of those, running.+ */+ var `spacesRunning`: kotlin.UInt+ ,+ /**+ * Cores given to the running ones.+ */+ var `spacesCpuAllocated`: kotlin.UInt+ ,+ /**+ * Memory given to the running ones, bytes.+ */+ var `spacesMemoryAllocated`: kotlin.ULong+ ,+ /**+ * Memory the running guests report in use, bytes.+ */+ var `spacesMemoryUsed`: kotlin.ULong+ ,+ /**+ * Bytes all its extra Spaces take on it.+ */+ var `spacesDiskBytes`: kotlin.ULong+ ,+ /**+ * False when some Space's disk could only be estimated.+ */+ var `spacesDiskExact`: kotlin.Boolean+ ,+ /**+ * The low-disk signal.+ */+ var `warning`: DiskWarning++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeComputerResources: FfiConverterRustBuffer<ComputerResources> {+ override fun read(buf: ByteBuffer): ComputerResources {+ return ComputerResources(+ FfiConverterString.read(buf),+ FfiConverterString.read(buf),+ FfiConverterBoolean.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterUInt.read(buf),+ FfiConverterDouble.read(buf),+ FfiConverterDouble.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterUInt.read(buf),+ FfiConverterUInt.read(buf),+ FfiConverterUInt.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterBoolean.read(buf),+ FfiConverterTypeDiskWarning.read(buf),+ )+ }++ override fun allocationSize(value: ComputerResources) = (+ FfiConverterString.allocationSize(value.`id`) ++ FfiConverterString.allocationSize(value.`name`) ++ FfiConverterBoolean.allocationSize(value.`online`) ++ FfiConverterULong.allocationSize(value.`sampledAtMs`) ++ FfiConverterUInt.allocationSize(value.`cpuCount`) ++ FfiConverterDouble.allocationSize(value.`cpuPercent`) ++ FfiConverterDouble.allocationSize(value.`loadAverage1m`) ++ FfiConverterULong.allocationSize(value.`memoryTotal`) ++ FfiConverterULong.allocationSize(value.`memoryUsed`) ++ FfiConverterULong.allocationSize(value.`diskTotal`) ++ FfiConverterULong.allocationSize(value.`diskFree`) ++ FfiConverterUInt.allocationSize(value.`spacesCount`) ++ FfiConverterUInt.allocationSize(value.`spacesRunning`) ++ FfiConverterUInt.allocationSize(value.`spacesCpuAllocated`) ++ FfiConverterULong.allocationSize(value.`spacesMemoryAllocated`) ++ FfiConverterULong.allocationSize(value.`spacesMemoryUsed`) ++ FfiConverterULong.allocationSize(value.`spacesDiskBytes`) ++ FfiConverterBoolean.allocationSize(value.`spacesDiskExact`) ++ FfiConverterTypeDiskWarning.allocationSize(value.`warning`)+ )++ override fun write(value: ComputerResources, buf: ByteBuffer) {+ FfiConverterString.write(value.`id`, buf)+ FfiConverterString.write(value.`name`, buf)+ FfiConverterBoolean.write(value.`online`, buf)+ FfiConverterULong.write(value.`sampledAtMs`, buf)+ FfiConverterUInt.write(value.`cpuCount`, buf)+ FfiConverterDouble.write(value.`cpuPercent`, buf)+ FfiConverterDouble.write(value.`loadAverage1m`, buf)+ FfiConverterULong.write(value.`memoryTotal`, buf)+ FfiConverterULong.write(value.`memoryUsed`, buf)+ FfiConverterULong.write(value.`diskTotal`, buf)+ FfiConverterULong.write(value.`diskFree`, buf)+ FfiConverterUInt.write(value.`spacesCount`, buf)+ FfiConverterUInt.write(value.`spacesRunning`, buf)+ FfiConverterUInt.write(value.`spacesCpuAllocated`, buf)+ FfiConverterULong.write(value.`spacesMemoryAllocated`, buf)+ FfiConverterULong.write(value.`spacesMemoryUsed`, buf)+ FfiConverterULong.write(value.`spacesDiskBytes`, buf)+ FfiConverterBoolean.write(value.`spacesDiskExact`, buf)+ FfiConverterTypeDiskWarning.write(value.`warning`, buf)+ }+}+++/*** One setting's effective value.*/@@ -26774,6 +27701,126 @@ public object FfiConverterTypeDevicesSnapshot: FfiConverterRustBuffer<DevicesSna+/**+ * What a Space costs this computer's disk, as opposed to what the guest+ * sees.+ */+data class DiskOnHost (+ /**+ * Bytes only this Space holds (what deleting it frees); absent when+ * they could not be measured.+ */+ var `bytes`: kotlin.ULong?+ ,+ /**+ * Blocks its files occupy, clones counted in full: an upper bound.+ */+ var `allocated`: kotlin.ULong+ ,+ /**+ * Part of it is shared with other copies.+ */+ var `sharesSpace`: kotlin.Boolean++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeDiskOnHost: FfiConverterRustBuffer<DiskOnHost> {+ override fun read(buf: ByteBuffer): DiskOnHost {+ return DiskOnHost(+ FfiConverterOptionalULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterBoolean.read(buf),+ )+ }++ override fun allocationSize(value: DiskOnHost) = (+ FfiConverterOptionalULong.allocationSize(value.`bytes`) ++ FfiConverterULong.allocationSize(value.`allocated`) ++ FfiConverterBoolean.allocationSize(value.`sharesSpace`)+ )++ override fun write(value: DiskOnHost, buf: ByteBuffer) {+ FfiConverterOptionalULong.write(value.`bytes`, buf)+ FfiConverterULong.write(value.`allocated`, buf)+ FfiConverterBoolean.write(value.`sharesSpace`, buf)+ }+}++++/**+ * The low-disk signal for the app and the menu bar.+ */+data class DiskWarning (+ /**+ * How low it is.+ */+ var `level`: DiskLevel+ ,+ /**+ * Free bytes on the volume that holds Spaces.+ */+ var `free`: kotlin.ULong+ ,+ /**+ * Size of that volume.+ */+ var `total`: kotlin.ULong+ ,+ /**+ * The line that was crossed (0 when `ok`).+ */+ var `threshold`: kotlin.ULong++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeDiskWarning: FfiConverterRustBuffer<DiskWarning> {+ override fun read(buf: ByteBuffer): DiskWarning {+ return DiskWarning(+ FfiConverterTypeDiskLevel.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ )+ }++ override fun allocationSize(value: DiskWarning) = (+ FfiConverterTypeDiskLevel.allocationSize(value.`level`) ++ FfiConverterULong.allocationSize(value.`free`) ++ FfiConverterULong.allocationSize(value.`total`) ++ FfiConverterULong.allocationSize(value.`threshold`)+ )++ override fun write(value: DiskWarning, buf: ByteBuffer) {+ FfiConverterTypeDiskLevel.write(value.`level`, buf)+ FfiConverterULong.write(value.`free`, buf)+ FfiConverterULong.write(value.`total`, buf)+ FfiConverterULong.write(value.`threshold`, buf)+ }+}+++/*** Doctor output.*/@@ -29770,6 +30817,109 @@ public object FfiConverterTypeGpuSupport: FfiConverterRustBuffer<GpuSupport> {+/**+ * What `SystemService.Metrics` reports from inside a Space.+ */+data class GuestUsage (+ /**+ * Cores the guest sees.+ */+ var `cpuCount`: kotlin.UInt+ ,+ /**+ * Busy now, 0 to 100.+ */+ var `cpuPercent`: kotlin.Double+ ,+ /**+ * 1-minute load average.+ */+ var `loadAverage1m`: kotlin.Double+ ,+ /**+ * Memory in use, bytes.+ */+ var `memoryUsed`: kotlin.ULong+ ,+ /**+ * Memory size, bytes.+ */+ var `memoryTotal`: kotlin.ULong+ ,+ /**+ * `memory_total` is the guest's own limit.+ */+ var `memoryLimited`: kotlin.Boolean+ ,+ /**+ * Disk in use, bytes.+ */+ var `diskUsed`: kotlin.ULong+ ,+ /**+ * Disk size, bytes.+ */+ var `diskTotal`: kotlin.ULong+ ,+ /**+ * `disk_total` is the guest's own disk.+ */+ var `diskLimited`: kotlin.Boolean++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeGuestUsage: FfiConverterRustBuffer<GuestUsage> {+ override fun read(buf: ByteBuffer): GuestUsage {+ return GuestUsage(+ FfiConverterUInt.read(buf),+ FfiConverterDouble.read(buf),+ FfiConverterDouble.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterBoolean.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterBoolean.read(buf),+ )+ }++ override fun allocationSize(value: GuestUsage) = (+ FfiConverterUInt.allocationSize(value.`cpuCount`) ++ FfiConverterDouble.allocationSize(value.`cpuPercent`) ++ FfiConverterDouble.allocationSize(value.`loadAverage1m`) ++ FfiConverterULong.allocationSize(value.`memoryUsed`) ++ FfiConverterULong.allocationSize(value.`memoryTotal`) ++ FfiConverterBoolean.allocationSize(value.`memoryLimited`) ++ FfiConverterULong.allocationSize(value.`diskUsed`) ++ FfiConverterULong.allocationSize(value.`diskTotal`) ++ FfiConverterBoolean.allocationSize(value.`diskLimited`)+ )++ override fun write(value: GuestUsage, buf: ByteBuffer) {+ FfiConverterUInt.write(value.`cpuCount`, buf)+ FfiConverterDouble.write(value.`cpuPercent`, buf)+ FfiConverterDouble.write(value.`loadAverage1m`, buf)+ FfiConverterULong.write(value.`memoryUsed`, buf)+ FfiConverterULong.write(value.`memoryTotal`, buf)+ FfiConverterBoolean.write(value.`memoryLimited`, buf)+ FfiConverterULong.write(value.`diskUsed`, buf)+ FfiConverterULong.write(value.`diskTotal`, buf)+ FfiConverterBoolean.write(value.`diskLimited`, buf)+ }+}+++/*** What moved between the drive and a Space.*/@@ -33399,6 +34549,165 @@ public object FfiConverterTypeResolvedImage: FfiConverterRustBuffer<ResolvedImag+/**+ * One sample of everything.+ */+data class ResourcesSnapshot (+ /**+ * Grows by one per sample.+ */+ var `sequence`: kotlin.ULong+ ,+ /**+ * Unix ms.+ */+ var `sampledAtMs`: kotlin.ULong+ ,+ /**+ * This Mac.+ */+ var `thisMac`: ComputerResources+ ,+ /**+ * Extra Spaces on this Mac.+ */+ var `spaces`: List<SpaceResources>+ ,+ /**+ * Your other computers, from the summaries they published.+ */+ var `computers`: List<ComputerResources>+ ,+ /**+ * `this_mac.warning`, for the menu bar.+ */+ var `warning`: DiskWarning++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeResourcesSnapshot: FfiConverterRustBuffer<ResourcesSnapshot> {+ override fun read(buf: ByteBuffer): ResourcesSnapshot {+ return ResourcesSnapshot(+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterTypeComputerResources.read(buf),+ FfiConverterSequenceTypeSpaceResources.read(buf),+ FfiConverterSequenceTypeComputerResources.read(buf),+ FfiConverterTypeDiskWarning.read(buf),+ )+ }++ override fun allocationSize(value: ResourcesSnapshot) = (+ FfiConverterULong.allocationSize(value.`sequence`) ++ FfiConverterULong.allocationSize(value.`sampledAtMs`) ++ FfiConverterTypeComputerResources.allocationSize(value.`thisMac`) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.`spaces`) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.`computers`) ++ FfiConverterTypeDiskWarning.allocationSize(value.`warning`)+ )++ override fun write(value: ResourcesSnapshot, buf: ByteBuffer) {+ FfiConverterULong.write(value.`sequence`, buf)+ FfiConverterULong.write(value.`sampledAtMs`, buf)+ FfiConverterTypeComputerResources.write(value.`thisMac`, buf)+ FfiConverterSequenceTypeSpaceResources.write(value.`spaces`, buf)+ FfiConverterSequenceTypeComputerResources.write(value.`computers`, buf)+ FfiConverterTypeDiskWarning.write(value.`warning`, buf)+ }+}++++/**+ * What changed since the last event: only entries that moved by more than+ * 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+ */+data class ResourcesUpdate (+ /**+ * The sample it brings you to.+ */+ var `sequence`: kotlin.ULong+ ,+ /**+ * Unix ms.+ */+ var `sampledAtMs`: kotlin.ULong+ ,+ /**+ * This Mac, when it changed.+ */+ var `thisMac`: ComputerResources?+ ,+ /**+ * Extra Spaces that changed or appeared.+ */+ var `spaces`: List<SpaceResources>+ ,+ /**+ * Other computers that changed or appeared.+ */+ var `computers`: List<ComputerResources>+ ,+ /**+ * Ids (Spaces or computers) that are gone.+ */+ var `removed`: List<kotlin.String>++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeResourcesUpdate: FfiConverterRustBuffer<ResourcesUpdate> {+ override fun read(buf: ByteBuffer): ResourcesUpdate {+ return ResourcesUpdate(+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterOptionalTypeComputerResources.read(buf),+ FfiConverterSequenceTypeSpaceResources.read(buf),+ FfiConverterSequenceTypeComputerResources.read(buf),+ FfiConverterSequenceString.read(buf),+ )+ }++ override fun allocationSize(value: ResourcesUpdate) = (+ FfiConverterULong.allocationSize(value.`sequence`) ++ FfiConverterULong.allocationSize(value.`sampledAtMs`) ++ FfiConverterOptionalTypeComputerResources.allocationSize(value.`thisMac`) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.`spaces`) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.`computers`) ++ FfiConverterSequenceString.allocationSize(value.`removed`)+ )++ override fun write(value: ResourcesUpdate, buf: ByteBuffer) {+ FfiConverterULong.write(value.`sequence`, buf)+ FfiConverterULong.write(value.`sampledAtMs`, buf)+ FfiConverterOptionalTypeComputerResources.write(value.`thisMac`, buf)+ FfiConverterSequenceTypeSpaceResources.write(value.`spaces`, buf)+ FfiConverterSequenceTypeComputerResources.write(value.`computers`, buf)+ FfiConverterSequenceString.write(value.`removed`, buf)+ }+}+++/*** A routine: a recurring turn of a persistent agent, fired by the daemon.*/@@ -35931,6 +37240,93 @@ public object FfiConverterTypeSpaceRelayRegistration: FfiConverterRustBuffer<Spa+/**+ * One extra Space on this Mac.+ */+data class SpaceResources (+ /**+ * `local:<name>`.+ */+ var `id`: kotlin.String+ ,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ var `powerState`: kotlin.String+ ,+ /**+ * Cores given to it (0: unknown).+ */+ var `cpuAllocated`: kotlin.UInt+ ,+ /**+ * Memory given to it, bytes (0: unknown).+ */+ var `memoryAllocated`: kotlin.ULong+ ,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ var `diskAllocated`: kotlin.ULong+ ,+ /**+ * The guest's own numbers; absent while it is off or unreachable.+ */+ var `usage`: GuestUsage?+ ,+ /**+ * What it costs this Mac; absent for a container.+ */+ var `diskOnHost`: DiskOnHost?++){++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeSpaceResources: FfiConverterRustBuffer<SpaceResources> {+ override fun read(buf: ByteBuffer): SpaceResources {+ return SpaceResources(+ FfiConverterString.read(buf),+ FfiConverterString.read(buf),+ FfiConverterUInt.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterULong.read(buf),+ FfiConverterOptionalTypeGuestUsage.read(buf),+ FfiConverterOptionalTypeDiskOnHost.read(buf),+ )+ }++ override fun allocationSize(value: SpaceResources) = (+ FfiConverterString.allocationSize(value.`id`) ++ FfiConverterString.allocationSize(value.`powerState`) ++ FfiConverterUInt.allocationSize(value.`cpuAllocated`) ++ FfiConverterULong.allocationSize(value.`memoryAllocated`) ++ FfiConverterULong.allocationSize(value.`diskAllocated`) ++ FfiConverterOptionalTypeGuestUsage.allocationSize(value.`usage`) ++ FfiConverterOptionalTypeDiskOnHost.allocationSize(value.`diskOnHost`)+ )++ override fun write(value: SpaceResources, buf: ByteBuffer) {+ FfiConverterString.write(value.`id`, buf)+ FfiConverterString.write(value.`powerState`, buf)+ FfiConverterUInt.write(value.`cpuAllocated`, buf)+ FfiConverterULong.write(value.`memoryAllocated`, buf)+ FfiConverterULong.write(value.`diskAllocated`, buf)+ FfiConverterOptionalTypeGuestUsage.write(value.`usage`, buf)+ FfiConverterOptionalTypeDiskOnHost.write(value.`diskOnHost`, buf)+ }+}+++/*** Options for [`Space::send_file`].*/@@ -36910,11 +38306,26 @@ public object FfiConverterTypeSpaceTransferReport: FfiConverterRustBuffer<SpaceT/**- * Memory and storage use ([`Space::usage`]). A size is the guest's own- * limit only when its `*_limited` flag says so (a VM's memory or disk, a- * container's cgroup memory limit).+ * Processor, memory and storage use ([`Space::usage`]). A size is the+ * guest's own limit only when its `*_limited` flag says so (a VM's memory+ * or disk, a container's cgroup memory limit).*/data class SpaceUsage (+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ var `cpuCount`: kotlin.UInt = 0u+ ,+ /**+ * Busy now, 0 to 100.+ */+ var `cpuPercent`: kotlin.Double = 0.0+ ,+ /**+ * 1-minute load average.+ */+ var `loadAverage1m`: kotlin.Double = 0.0+ ,/*** Memory in use, bytes.*/@@ -36960,6 +38371,9 @@ data class SpaceUsage (public object FfiConverterTypeSpaceUsage: FfiConverterRustBuffer<SpaceUsage> {override fun read(buf: ByteBuffer): SpaceUsage {return SpaceUsage(+ FfiConverterUInt.read(buf),+ FfiConverterDouble.read(buf),+ FfiConverterDouble.read(buf),FfiConverterULong.read(buf),FfiConverterULong.read(buf),FfiConverterBoolean.read(buf),@@ -36970,6 +38384,9 @@ public object FfiConverterTypeSpaceUsage: FfiConverterRustBuffer<SpaceUsage> {}override fun allocationSize(value: SpaceUsage) = (+ FfiConverterUInt.allocationSize(value.`cpuCount`) ++ FfiConverterDouble.allocationSize(value.`cpuPercent`) ++ FfiConverterDouble.allocationSize(value.`loadAverage1m`) +FfiConverterULong.allocationSize(value.`memoryUsed`) +FfiConverterULong.allocationSize(value.`memoryTotal`) +FfiConverterBoolean.allocationSize(value.`memoryLimited`) +@@ -36979,6 +38396,9 @@ public object FfiConverterTypeSpaceUsage: FfiConverterRustBuffer<SpaceUsage> {)override fun write(value: SpaceUsage, buf: ByteBuffer) {+ FfiConverterUInt.write(value.`cpuCount`, buf)+ FfiConverterDouble.write(value.`cpuPercent`, buf)+ FfiConverterDouble.write(value.`loadAverage1m`, buf)FfiConverterULong.write(value.`memoryUsed`, buf)FfiConverterULong.write(value.`memoryTotal`, buf)FfiConverterBoolean.write(value.`memoryLimited`, buf)@@ -39341,6 +40761,54 @@ public object FfiConverterTypeCuaMode: FfiConverterRustBuffer<CuaMode> {+/**+ * How low the free disk is.+ */++enum class DiskLevel {++ /**+ * Plenty.+ */+ OK,+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (the+ * line never rises above 100 GB).+ */+ LOW,+ /**+ * Under the floor where creating a Space already fails (5 GiB).+ */+ CRITICAL;+++++ companion object+}+++/**+ * @suppress+ */+public object FfiConverterTypeDiskLevel: FfiConverterRustBuffer<DiskLevel> {+ override fun read(buf: ByteBuffer) = try {+ DiskLevel.values()[buf.getInt() - 1]+ } catch (e: IndexOutOfBoundsException) {+ throw RuntimeException("invalid enum value, something is very wrong!!", e)+ }++ override fun allocationSize(value: DiskLevel) = 4UL++ override fun write(value: DiskLevel, buf: ByteBuffer) {+ buf.putInt(value.ordinal + 1)+ }+}+++++/*** Screenshot encoding.*/@@ -39961,6 +41429,134 @@ public object FfiConverterTypeReplayMode : FfiConverterRustBuffer<ReplayMode>{+/**+ * What [`Spaces::watch_resources`] reports.+ */+sealed class ResourcesEvent {++ /**+ * Everything, at the start (and again after a reconnect).+ */+ data class Snapshot(+ /**+ * The sample.+ */+ val `snapshot`: ai.cua.sdk.ResourcesSnapshot) : ResourcesEvent()++ {+++ companion object+ }++ /**+ * Only what changed.+ */+ data class Update(+ /**+ * The changes.+ */+ val `update`: ai.cua.sdk.ResourcesUpdate) : ResourcesEvent()++ {+++ companion object+ }++ /**+ * The low-disk level changed (including back to `ok`).+ */+ data class LowDisk(+ /**+ * The warning now.+ */+ val `warning`: ai.cua.sdk.DiskWarning) : ResourcesEvent()++ {+++ companion object+ }+++++++++ companion object+}++/**+ * @suppress+ */+public object FfiConverterTypeResourcesEvent : FfiConverterRustBuffer<ResourcesEvent>{+ override fun read(buf: ByteBuffer): ResourcesEvent {+ return when(buf.getInt()) {+ 1 -> ResourcesEvent.Snapshot(+ FfiConverterTypeResourcesSnapshot.read(buf),+ )+ 2 -> ResourcesEvent.Update(+ FfiConverterTypeResourcesUpdate.read(buf),+ )+ 3 -> ResourcesEvent.LowDisk(+ FfiConverterTypeDiskWarning.read(buf),+ )+ else -> throw RuntimeException("invalid enum value, something is very wrong!!")+ }+ }++ override fun allocationSize(value: ResourcesEvent) = when(value) {+ is ResourcesEvent.Snapshot -> {+ // Add the size for the Int that specifies the variant plus the size needed for all fields+ (+ 4UL+ + FfiConverterTypeResourcesSnapshot.allocationSize(value.`snapshot`)+ )+ }+ is ResourcesEvent.Update -> {+ // Add the size for the Int that specifies the variant plus the size needed for all fields+ (+ 4UL+ + FfiConverterTypeResourcesUpdate.allocationSize(value.`update`)+ )+ }+ is ResourcesEvent.LowDisk -> {+ // Add the size for the Int that specifies the variant plus the size needed for all fields+ (+ 4UL+ + FfiConverterTypeDiskWarning.allocationSize(value.`warning`)+ )+ }+ }++ override fun write(value: ResourcesEvent, buf: ByteBuffer) {+ when(value) {+ is ResourcesEvent.Snapshot -> {+ buf.putInt(1)+ FfiConverterTypeResourcesSnapshot.write(value.`snapshot`, buf)+ Unit+ }+ is ResourcesEvent.Update -> {+ buf.putInt(2)+ FfiConverterTypeResourcesUpdate.write(value.`update`, buf)+ Unit+ }+ is ResourcesEvent.LowDisk -> {+ buf.putInt(3)+ FfiConverterTypeDiskWarning.write(value.`warning`, buf)+ Unit+ }+ }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }+ }+}+++++/*** Status of one local runtime component.*/@@ -40571,6 +42167,70 @@ public object FfiConverterOptionalTypeCloudOptions: FfiConverterRustBuffer<Cloud+/**+ * @suppress+ */+public object FfiConverterOptionalTypeComputerResources: FfiConverterRustBuffer<ComputerResources?> {+ override fun read(buf: ByteBuffer): ComputerResources? {+ if (buf.get().toInt() == 0) {+ return null+ }+ return FfiConverterTypeComputerResources.read(buf)+ }++ override fun allocationSize(value: ComputerResources?): ULong {+ if (value == null) {+ return 1UL+ } else {+ return 1UL + FfiConverterTypeComputerResources.allocationSize(value)+ }+ }++ override fun write(value: ComputerResources?, buf: ByteBuffer) {+ if (value == null) {+ buf.put(0)+ } else {+ buf.put(1)+ FfiConverterTypeComputerResources.write(value, buf)+ }+ }+}+++++/**+ * @suppress+ */+public object FfiConverterOptionalTypeDiskOnHost: FfiConverterRustBuffer<DiskOnHost?> {+ override fun read(buf: ByteBuffer): DiskOnHost? {+ if (buf.get().toInt() == 0) {+ return null+ }+ return FfiConverterTypeDiskOnHost.read(buf)+ }++ override fun allocationSize(value: DiskOnHost?): ULong {+ if (value == null) {+ return 1UL+ } else {+ return 1UL + FfiConverterTypeDiskOnHost.allocationSize(value)+ }+ }++ override fun write(value: DiskOnHost?, buf: ByteBuffer) {+ if (value == null) {+ buf.put(0)+ } else {+ buf.put(1)+ FfiConverterTypeDiskOnHost.write(value, buf)+ }+ }+}++++/*** @suppress*/@@ -40859,6 +42519,38 @@ public object FfiConverterOptionalTypeFleetUsagePricing: FfiConverterRustBuffer<+/**+ * @suppress+ */+public object FfiConverterOptionalTypeGuestUsage: FfiConverterRustBuffer<GuestUsage?> {+ override fun read(buf: ByteBuffer): GuestUsage? {+ if (buf.get().toInt() == 0) {+ return null+ }+ return FfiConverterTypeGuestUsage.read(buf)+ }++ override fun allocationSize(value: GuestUsage?): ULong {+ if (value == null) {+ return 1UL+ } else {+ return 1UL + FfiConverterTypeGuestUsage.allocationSize(value)+ }+ }++ override fun write(value: GuestUsage?, buf: ByteBuffer) {+ if (value == null) {+ buf.put(0)+ } else {+ buf.put(1)+ FfiConverterTypeGuestUsage.write(value, buf)+ }+ }+}++++/*** @suppress*/@@ -42219,6 +43911,34 @@ public object FfiConverterSequenceTypeComputerGrant: FfiConverterRustBuffer<List+/**+ * @suppress+ */+public object FfiConverterSequenceTypeComputerResources: FfiConverterRustBuffer<List<ComputerResources>> {+ override fun read(buf: ByteBuffer): List<ComputerResources> {+ val len = buf.getInt()+ return List<ComputerResources>(len) {+ FfiConverterTypeComputerResources.read(buf)+ }+ }++ override fun allocationSize(value: List<ComputerResources>): ULong {+ val sizeForLength = 4UL+ val sizeForItems = value.map { FfiConverterTypeComputerResources.allocationSize(it) }.sum()+ return sizeForLength + sizeForItems+ }++ override fun write(value: List<ComputerResources>, buf: ByteBuffer) {+ buf.putInt(value.size)+ value.iterator().forEach {+ FfiConverterTypeComputerResources.write(it, buf)+ }+ }+}++++/*** @suppress*/@@ -43479,6 +45199,34 @@ public object FfiConverterSequenceTypeSpaceInfo: FfiConverterRustBuffer<List<Spa+/**+ * @suppress+ */+public object FfiConverterSequenceTypeSpaceResources: FfiConverterRustBuffer<List<SpaceResources>> {+ override fun read(buf: ByteBuffer): List<SpaceResources> {+ val len = buf.getInt()+ return List<SpaceResources>(len) {+ FfiConverterTypeSpaceResources.read(buf)+ }+ }++ override fun allocationSize(value: List<SpaceResources>): ULong {+ val sizeForLength = 4UL+ val sizeForItems = value.map { FfiConverterTypeSpaceResources.allocationSize(it) }.sum()+ return sizeForLength + sizeForItems+ }++ override fun write(value: List<SpaceResources>, buf: ByteBuffer) {+ buf.putInt(value.size)+ value.iterator().forEach {+ FfiConverterTypeSpaceResources.write(it, buf)+ }+ }+}++++/*** @suppress*/diff --git a/libs/cua/proto/cua/daemon/v1/resources.proto b/libs/cua/proto/cua/daemon/v1/resources.protonew file mode 100644index 0000000000..6d4fed3199--- /dev/null+++ b/libs/cua/proto/cua/daemon/v1/resources.proto@@ -0,0 +1,181 @@+syntax = "proto3";++package cua.daemon.v1;++// What this computer, its extra Spaces and your other computers use:+// processor, memory and disk, measured once by the daemon's sampler and+// served by `SpaceService.GetResources` and `WatchResources`. Numbers only:+// counts, bytes and percentages, never a name, a path or a process.++// Request for `SpaceService.GetResources`.+message GetResourcesRequest {+ // A window shows the numbers: sample every 10 seconds for the next 30.+ bool visible = 1;+}++// Response for `SpaceService.GetResources`.+message GetResourcesResponse {+ // Everything, now.+ ResourcesSnapshot snapshot = 1;+}++// Request for `SpaceService.WatchResources`.+message WatchResourcesRequest {+ // A window shows the numbers (sample every 10 seconds) rather than only+ // the menu bar warning (every 5 minutes).+ bool visible = 1;+}++// One event of `SpaceService.WatchResources`.+message WatchResourcesResponse {+ // What happened.+ oneof event {+ // Everything, once at the start.+ ResourcesSnapshot snapshot = 1;+ // Only what changed.+ ResourcesUpdate update = 2;+ // The free-disk warning level changed.+ DiskWarning low_disk = 3;+ }+}++// One sample of everything.+message ResourcesSnapshot {+ // Grows by one per sample.+ uint64 sequence = 1;+ // When it was sampled, in Unix milliseconds.+ uint64 sampled_at_ms = 2;+ // This computer.+ ComputerResources this_mac = 3;+ // The extra Spaces on this computer (the local ones).+ repeated SpaceResources spaces = 4;+ // Your other computers that published a summary (through the relay).+ repeated ComputerResources computers = 5;+ // `this_mac.warning`, for the menu bar.+ DiskWarning warning = 6;+}++// What changed since the receiver's last update, past the thresholds.+message ResourcesUpdate {+ // The sample it brings the receiver to.+ uint64 sequence = 1;+ // When it was sampled, in Unix milliseconds.+ uint64 sampled_at_ms = 2;+ // This computer, when it changed.+ optional ComputerResources this_mac = 3;+ // Extra Spaces that changed or appeared: replace by `id`.+ repeated SpaceResources spaces = 4;+ // Other computers that changed or appeared: replace by `id`.+ repeated ComputerResources computers = 5;+ // Ids (Spaces or computers) that are gone.+ repeated string removed = 6;+}++// The low-disk signal.+message DiskWarning {+ // `ok`, `low` (under 50 GB or 15% of the volume, whichever line is+ // higher, capped at 100 GB) or `critical` (under the floor where creates+ // fail, 5 GiB unless `CUA_DISK_MIN_FREE` says otherwise).+ string level = 1;+ // Free bytes on the volume that holds Spaces.+ uint64 free = 2;+ // Size of that volume in bytes.+ uint64 total = 3;+ // The line that was crossed in bytes (0 when `ok`).+ uint64 threshold = 4;+}++// A computer: this one, or one of your other computers.+message ComputerResources {+ // `this-mac`, or the relay machine id.+ string id = 1;+ // Display name (empty for this computer).+ string name = 2;+ // Reachable now (always true for this computer).+ bool online = 3;+ // When the computer measured this, in Unix milliseconds (another+ // computer's can be minutes old).+ uint64 sampled_at_ms = 4;+ // Processor cores.+ uint32 cpu_count = 5;+ // Busy now, 0 to 100.+ double cpu_percent = 6;+ // 1-minute load average.+ double load_average_1m = 7;+ // Memory size in bytes.+ uint64 memory_total = 8;+ // Memory in use in bytes, without reclaimable cache.+ uint64 memory_used = 9;+ // Size of the volume that holds Spaces in bytes.+ uint64 disk_total = 10;+ // Free bytes on that volume.+ uint64 disk_free = 11;+ // Extra Spaces on it.+ uint32 spaces_count = 12;+ // Of those, running.+ uint32 spaces_running = 13;+ // Cores given to the running ones.+ uint32 spaces_cpu_allocated = 14;+ // Memory given to the running ones in bytes.+ uint64 spaces_memory_allocated = 15;+ // Memory the running guests report in use in bytes.+ uint64 spaces_memory_used = 16;+ // Bytes all its extra Spaces take on it.+ uint64 spaces_disk_bytes = 17;+ // False when some Space's disk could only be estimated.+ bool spaces_disk_exact = 18;+ // The low-disk signal.+ DiskWarning warning = 19;+}++// What `cua.env.v1.SystemService.Metrics` reports from inside a Space.+message GuestUsage {+ // Cores the guest sees.+ uint32 cpu_count = 1;+ // Busy now, 0 to 100.+ double cpu_percent = 2;+ // 1-minute load average.+ double load_average_1m = 3;+ // Memory in use in bytes.+ uint64 memory_used = 4;+ // Memory size in bytes.+ uint64 memory_total = 5;+ // `memory_total` is the guest's own limit.+ bool memory_limited = 6;+ // Disk in use in bytes.+ uint64 disk_used = 7;+ // Disk size in bytes.+ uint64 disk_total = 8;+ // `disk_total` is the guest's own disk.+ bool disk_limited = 9;+}++// What a Space costs this computer's disk, as opposed to what the guest+// sees.+message DiskOnHost {+ // Bytes only this Space holds: what deleting it frees. Unset when they+ // could not be measured.+ optional uint64 bytes = 1;+ // Blocks its files occupy, clones counted in full: an upper bound.+ uint64 allocated = 2;+ // Part of it is shared with other copies.+ bool shares_space = 3;+}++// One extra Space on this computer.+message SpaceResources {+ // The Space id, for example `local:aurora`.+ string id = 1;+ // `running`, `stopped`, `suspended`, or empty when unknown.+ string power_state = 2;+ // Cores given to it (0: unknown).+ uint32 cpu_allocated = 3;+ // Memory given to it in bytes (0: unknown).+ uint64 memory_allocated = 4;+ // Its disk's size limit in bytes (0: unknown).+ uint64 disk_allocated = 5;+ // The guest's own numbers; unset while it is off or unreachable.+ GuestUsage usage = 6;+ // What it costs this computer; unset for a container.+ DiskOnHost disk_on_host = 7;+}diff --git a/libs/cua/proto/cua/daemon/v1/spaces.proto b/libs/cua/proto/cua/daemon/v1/spaces.protoindex d65a592e33..a8da17abc2 100644--- a/libs/cua/proto/cua/daemon/v1/spaces.proto+++ b/libs/cua/proto/cua/daemon/v1/spaces.proto@@ -2,6 +2,7 @@ syntax = "proto3";package cua.daemon.v1;+import "cua/daemon/v1/resources.proto";import "google/protobuf/duration.proto";import "google/protobuf/timestamp.proto";@@ -87,6 +88,21 @@ service SpaceService {// `captured_at`, when the capture fails). Asking keeps the daemon// refreshing running Spaces' thumbnails in the background for a while.rpc GetSpaceThumbnail(GetSpaceThumbnailRequest) returns (GetSpaceThumbnailResponse);+ // What this computer, its extra Spaces and your other computers use now:+ // processor, memory and disk, as one snapshot. The daemon's single+ // sampler measures it; a snapshot a few seconds old is returned as it is.+ // With `visible`, the call also says a window shows the numbers for the+ // next 30 seconds, so the sampler runs every 10 seconds (every 5 minutes+ // otherwise). Numbers only: no names, paths or processes.+ rpc GetResources(GetResourcesRequest) returns (GetResourcesResponse);+ // The same numbers as a stream: one snapshot first, then an update with+ // only the entries that changed by more than 1 point or 256 MB, and a+ // `low_disk` event whenever the free-disk warning level changes+ // (including back to `ok`). A hidden watcher (`visible` false) is+ // sampled every 5 minutes and still hears `low_disk`, for the menu bar.+ // Cancel the stream to stop; call again with the other `visible` to+ // switch.+ rpc WatchResources(WatchResourcesRequest) returns (stream WatchResourcesResponse);}// A registered Space.diff --git a/libs/cua/python/src/cua/_native.py b/libs/cua/python/src/cua/_native.pyindex ec63ec2e2e..c699fb2460 100644--- a/libs/cua/python/src/cua/_native.py+++ b/libs/cua/python/src/cua/_native.py@@ -911,6 +911,12 @@ def _uniffi_check_api_checksums(lib):raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_relay_url() != 31201:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ if lib.uniffi_cua_sdk_checksum_method_resourceslistener_on_event() != 32126:+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ if lib.uniffi_cua_sdk_checksum_method_resourceswatch_set_visible() != 54652:+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ if lib.uniffi_cua_sdk_checksum_method_resourceswatch_stop() != 52286:+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_sandbox_agents() != 53699:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_sandbox_delete() != 17492:@@ -1089,7 +1095,7 @@ def _uniffi_check_api_checksums(lib):raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_space_upload() != 30524:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")- if lib.uniffi_cua_sdk_checksum_method_space_usage() != 15261:+ if lib.uniffi_cua_sdk_checksum_method_space_usage() != 43925:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_space_websocket_headers() != 61370:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")@@ -1197,6 +1203,8 @@ def _uniffi_check_api_checksums(lib):raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spaces_resolve() != 9986:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ if lib.uniffi_cua_sdk_checksum_method_spaces_resources() != 12146:+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spaces_routine_add() != 27220:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spaces_routine_remove() != 46906:@@ -1261,6 +1269,8 @@ def _uniffi_check_api_checksums(lib):raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spaces_volume_write() != 64388:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")+ if lib.uniffi_cua_sdk_checksum_method_spaces_watch_resources() != 49660:+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spacesdclient_agents() != 39176:raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")if lib.uniffi_cua_sdk_checksum_method_spacesdclient_attach() != 5563:@@ -1832,6 +1842,26 @@ _UniffiLib.uniffi_cua_sdk_fn_free_relay.argtypes = (ctypes.POINTER(_UniffiRustCallStatus),)_UniffiLib.uniffi_cua_sdk_fn_free_relay.restype = None+_UniffiLib.uniffi_cua_sdk_fn_clone_resourceslistener.argtypes = (+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_clone_resourceslistener.restype = ctypes.c_uint64+_UniffiLib.uniffi_cua_sdk_fn_free_resourceslistener.argtypes = (+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_free_resourceslistener.restype = None+_UniffiLib.uniffi_cua_sdk_fn_clone_resourceswatch.argtypes = (+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_clone_resourceswatch.restype = ctypes.c_uint64+_UniffiLib.uniffi_cua_sdk_fn_free_resourceswatch.argtypes = (+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_free_resourceswatch.restype = None_UniffiLib.uniffi_cua_sdk_fn_clone_sandbox.argtypes = (ctypes.c_uint64,ctypes.POINTER(_UniffiRustCallStatus),@@ -1980,6 +2010,23 @@ _UniffiLib.uniffi_cua_sdk_fn_init_callback_vtable_framesink.argtypes = (ctypes.POINTER(_UniffiVTableCallbackInterfaceCuaSdkFrameSink),)_UniffiLib.uniffi_cua_sdk_fn_init_callback_vtable_framesink.restype = None+_UNIFFI_CALLBACK_INTERFACE_CUA_SDK_RESOURCES_LISTENER_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UNIFFI_CALLBACK_INTERFACE_CLONE_CUA_SDK_RESOURCES_LISTENER = ctypes.CFUNCTYPE(ctypes.c_uint64,ctypes.c_uint64,+)+_UNIFFI_CALLBACK_INTERFACE_FREE_CUA_SDK_RESOURCES_LISTENER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,+)+class _UniffiVTableCallbackInterfaceCuaSdkResourcesListener(ctypes.Structure):+ _fields_ = [+ ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE_CUA_SDK_RESOURCES_LISTENER),+ ("uniffi_clone", _UNIFFI_CALLBACK_INTERFACE_CLONE_CUA_SDK_RESOURCES_LISTENER),+ ("on_event", _UNIFFI_CALLBACK_INTERFACE_CUA_SDK_RESOURCES_LISTENER_METHOD0),+ ]+_UniffiLib.uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener.argtypes = (+ ctypes.POINTER(_UniffiVTableCallbackInterfaceCuaSdkResourcesListener),+)+_UniffiLib.uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener.restype = None_UNIFFI_CALLBACK_INTERFACE_CUA_SDK_SPACE_CREATE_LISTENER_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_void_p,ctypes.POINTER(_UniffiRustCallStatus),)@@ -3134,6 +3181,23 @@ _UniffiLib.uniffi_cua_sdk_fn_method_relay_url.argtypes = (ctypes.POINTER(_UniffiRustCallStatus),)_UniffiLib.uniffi_cua_sdk_fn_method_relay_url.restype = _UniffiRustBuffer+_UniffiLib.uniffi_cua_sdk_fn_method_resourceslistener_on_event.argtypes = (+ ctypes.c_uint64,+ _UniffiRustBuffer,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_method_resourceslistener_on_event.restype = None+_UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_set_visible.argtypes = (+ ctypes.c_uint64,+ ctypes.c_int8,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_set_visible.restype = None+_UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_stop.argtypes = (+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_stop.restype = None_UniffiLib.uniffi_cua_sdk_fn_method_sandbox_agents.argtypes = (ctypes.c_uint64,)@@ -3893,6 +3957,11 @@ _UniffiLib.uniffi_cua_sdk_fn_method_spaces_resolve.argtypes = (_UniffiRustBuffer,)_UniffiLib.uniffi_cua_sdk_fn_method_spaces_resolve.restype = ctypes.c_uint64+_UniffiLib.uniffi_cua_sdk_fn_method_spaces_resources.argtypes = (+ ctypes.c_uint64,+ ctypes.c_int8,+)+_UniffiLib.uniffi_cua_sdk_fn_method_spaces_resources.restype = ctypes.c_uint64_UniffiLib.uniffi_cua_sdk_fn_method_spaces_routine_add.argtypes = (ctypes.c_uint64,_UniffiRustBuffer,@@ -4073,6 +4142,13 @@ _UniffiLib.uniffi_cua_sdk_fn_method_spaces_volume_write.argtypes = (_UniffiRustBuffer,)_UniffiLib.uniffi_cua_sdk_fn_method_spaces_volume_write.restype = ctypes.c_uint64+_UniffiLib.uniffi_cua_sdk_fn_method_spaces_watch_resources.argtypes = (+ ctypes.c_uint64,+ ctypes.c_int8,+ ctypes.c_uint64,+ ctypes.POINTER(_UniffiRustCallStatus),+)+_UniffiLib.uniffi_cua_sdk_fn_method_spaces_watch_resources.restype = ctypes.c_uint64_UniffiLib.uniffi_cua_sdk_fn_method_spacesdclient_agents.argtypes = (ctypes.c_uint64,)@@ -5010,6 +5086,15 @@ _UniffiLib.uniffi_cua_sdk_checksum_method_relay_stop_sharing.restype = ctypes.c__UniffiLib.uniffi_cua_sdk_checksum_method_relay_url.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_relay_url.restype = ctypes.c_uint16+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceslistener_on_event.argtypes = (+)+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceslistener_on_event.restype = ctypes.c_uint16+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceswatch_set_visible.argtypes = (+)+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceswatch_set_visible.restype = ctypes.c_uint16+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceswatch_stop.argtypes = (+)+_UniffiLib.uniffi_cua_sdk_checksum_method_resourceswatch_stop.restype = ctypes.c_uint16_UniffiLib.uniffi_cua_sdk_checksum_method_sandbox_agents.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_sandbox_agents.restype = ctypes.c_uint16@@ -5439,6 +5524,9 @@ _UniffiLib.uniffi_cua_sdk_checksum_method_spaces_remove.restype = ctypes.c_uint1_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_resolve.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_resolve.restype = ctypes.c_uint16+_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_resources.argtypes = (+)+_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_resources.restype = ctypes.c_uint16_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_routine_add.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_routine_add.restype = ctypes.c_uint16@@ -5535,6 +5623,9 @@ _UniffiLib.uniffi_cua_sdk_checksum_method_spaces_volume_unmount.restype = ctypes_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_volume_write.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_volume_write.restype = ctypes.c_uint16+_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_watch_resources.argtypes = (+)+_UniffiLib.uniffi_cua_sdk_checksum_method_spaces_watch_resources.restype = ctypes.c_uint16_UniffiLib.uniffi_cua_sdk_checksum_method_spacesdclient_agents.argtypes = ()_UniffiLib.uniffi_cua_sdk_checksum_method_spacesdclient_agents.restype = ctypes.c_uint16@@ -8904,6 +8995,260 @@ class _UniffiFfiConverterTypeComputerGrant(_UniffiConverterRustBuffer):_UniffiFfiConverterOptionalUInt64.write(value.expires_ms, buf)_UniffiFfiConverterBoolean.write(value.revoked, buf)++++++class DiskLevel(enum.Enum):+ """+ How low the free disk is.+"""++ OK = 0+ """+ Plenty.+"""++ LOW = 1+ """+ Under 50 GB or 15% of the volume, whichever line is higher (the+ line never rises above 100 GB).+"""++ CRITICAL = 2+ """+ Under the floor where creating a Space already fails (5 GiB).+"""++++class _UniffiFfiConverterTypeDiskLevel(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ variant = buf.read_i32()+ if variant == 1:+ return DiskLevel.OK+ if variant == 2:+ return DiskLevel.LOW+ if variant == 3:+ return DiskLevel.CRITICAL+ raise InternalError("Raw enum value doesn't match any cases")++ @staticmethod+ def check_lower(value):+ if value == DiskLevel.OK:+ return+ if value == DiskLevel.LOW:+ return+ if value == DiskLevel.CRITICAL:+ return+ raise ValueError(value)++ @staticmethod+ def write(value, buf):+ if value == DiskLevel.OK:+ buf.write_i32(1)+ if value == DiskLevel.LOW:+ buf.write_i32(2)+ if value == DiskLevel.CRITICAL:+ buf.write_i32(3)++++@dataclass+class DiskWarning:+ """+ The low-disk signal for the app and the menu bar.+"""+ def __init__(self, *, level:DiskLevel, free:int, total:int, threshold:int):+ self.level = level+ self.free = free+ self.total = total+ self.threshold = threshold+++++ def __str__(self):+ return "DiskWarning(level={}, free={}, total={}, threshold={})".format(self.level, self.free, self.total, self.threshold)+ def __eq__(self, other):+ if self.level != other.level:+ return False+ if self.free != other.free:+ return False+ if self.total != other.total:+ return False+ if self.threshold != other.threshold:+ return False+ return True++class _UniffiFfiConverterTypeDiskWarning(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return DiskWarning(+ level=_UniffiFfiConverterTypeDiskLevel.read(buf),+ free=_UniffiFfiConverterUInt64.read(buf),+ total=_UniffiFfiConverterUInt64.read(buf),+ threshold=_UniffiFfiConverterUInt64.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterTypeDiskLevel.check_lower(value.level)+ _UniffiFfiConverterUInt64.check_lower(value.free)+ _UniffiFfiConverterUInt64.check_lower(value.total)+ _UniffiFfiConverterUInt64.check_lower(value.threshold)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterTypeDiskLevel.write(value.level, buf)+ _UniffiFfiConverterUInt64.write(value.free, buf)+ _UniffiFfiConverterUInt64.write(value.total, buf)+ _UniffiFfiConverterUInt64.write(value.threshold, buf)++@dataclass+class ComputerResources:+ """+ A computer: this Mac, or one of your other computers (from the summary+ it published).+"""+ def __init__(self, *, id:str, name:str, online:bool, sampled_at_ms:int, cpu_count:int, cpu_percent:float, load_average_1m:float, memory_total:int, memory_used:int, disk_total:int, disk_free:int, spaces_count:int, spaces_running:int, spaces_cpu_allocated:int, spaces_memory_allocated:int, spaces_memory_used:int, spaces_disk_bytes:int, spaces_disk_exact:bool, warning:DiskWarning):+ self.id = id+ self.name = name+ self.online = online+ self.sampled_at_ms = sampled_at_ms+ self.cpu_count = cpu_count+ self.cpu_percent = cpu_percent+ self.load_average_1m = load_average_1m+ self.memory_total = memory_total+ self.memory_used = memory_used+ self.disk_total = disk_total+ self.disk_free = disk_free+ self.spaces_count = spaces_count+ self.spaces_running = spaces_running+ self.spaces_cpu_allocated = spaces_cpu_allocated+ self.spaces_memory_allocated = spaces_memory_allocated+ self.spaces_memory_used = spaces_memory_used+ self.spaces_disk_bytes = spaces_disk_bytes+ self.spaces_disk_exact = spaces_disk_exact+ self.warning = warning+++++ def __str__(self):+ return "ComputerResources(id={}, name={}, online={}, sampled_at_ms={}, cpu_count={}, cpu_percent={}, load_average_1m={}, memory_total={}, memory_used={}, disk_total={}, disk_free={}, spaces_count={}, spaces_running={}, spaces_cpu_allocated={}, spaces_memory_allocated={}, spaces_memory_used={}, spaces_disk_bytes={}, spaces_disk_exact={}, warning={})".format(self.id, self.name, self.online, self.sampled_at_ms, self.cpu_count, self.cpu_percent, self.load_average_1m, self.memory_total, self.memory_used, self.disk_total, self.disk_free, self.spaces_count, self.spaces_running, self.spaces_cpu_allocated, self.spaces_memory_allocated, self.spaces_memory_used, self.spaces_disk_bytes, self.spaces_disk_exact, self.warning)+ def __eq__(self, other):+ if self.id != other.id:+ return False+ if self.name != other.name:+ return False+ if self.online != other.online:+ return False+ if self.sampled_at_ms != other.sampled_at_ms:+ return False+ if self.cpu_count != other.cpu_count:+ return False+ if self.cpu_percent != other.cpu_percent:+ return False+ if self.load_average_1m != other.load_average_1m:+ return False+ if self.memory_total != other.memory_total:+ return False+ if self.memory_used != other.memory_used:+ return False+ if self.disk_total != other.disk_total:+ return False+ if self.disk_free != other.disk_free:+ return False+ if self.spaces_count != other.spaces_count:+ return False+ if self.spaces_running != other.spaces_running:+ return False+ if self.spaces_cpu_allocated != other.spaces_cpu_allocated:+ return False+ if self.spaces_memory_allocated != other.spaces_memory_allocated:+ return False+ if self.spaces_memory_used != other.spaces_memory_used:+ return False+ if self.spaces_disk_bytes != other.spaces_disk_bytes:+ return False+ if self.spaces_disk_exact != other.spaces_disk_exact:+ return False+ if self.warning != other.warning:+ return False+ return True++class _UniffiFfiConverterTypeComputerResources(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return ComputerResources(+ id=_UniffiFfiConverterString.read(buf),+ name=_UniffiFfiConverterString.read(buf),+ online=_UniffiFfiConverterBoolean.read(buf),+ sampled_at_ms=_UniffiFfiConverterUInt64.read(buf),+ cpu_count=_UniffiFfiConverterUInt32.read(buf),+ cpu_percent=_UniffiFfiConverterFloat64.read(buf),+ load_average_1m=_UniffiFfiConverterFloat64.read(buf),+ memory_total=_UniffiFfiConverterUInt64.read(buf),+ memory_used=_UniffiFfiConverterUInt64.read(buf),+ disk_total=_UniffiFfiConverterUInt64.read(buf),+ disk_free=_UniffiFfiConverterUInt64.read(buf),+ spaces_count=_UniffiFfiConverterUInt32.read(buf),+ spaces_running=_UniffiFfiConverterUInt32.read(buf),+ spaces_cpu_allocated=_UniffiFfiConverterUInt32.read(buf),+ spaces_memory_allocated=_UniffiFfiConverterUInt64.read(buf),+ spaces_memory_used=_UniffiFfiConverterUInt64.read(buf),+ spaces_disk_bytes=_UniffiFfiConverterUInt64.read(buf),+ spaces_disk_exact=_UniffiFfiConverterBoolean.read(buf),+ warning=_UniffiFfiConverterTypeDiskWarning.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterString.check_lower(value.id)+ _UniffiFfiConverterString.check_lower(value.name)+ _UniffiFfiConverterBoolean.check_lower(value.online)+ _UniffiFfiConverterUInt64.check_lower(value.sampled_at_ms)+ _UniffiFfiConverterUInt32.check_lower(value.cpu_count)+ _UniffiFfiConverterFloat64.check_lower(value.cpu_percent)+ _UniffiFfiConverterFloat64.check_lower(value.load_average_1m)+ _UniffiFfiConverterUInt64.check_lower(value.memory_total)+ _UniffiFfiConverterUInt64.check_lower(value.memory_used)+ _UniffiFfiConverterUInt64.check_lower(value.disk_total)+ _UniffiFfiConverterUInt64.check_lower(value.disk_free)+ _UniffiFfiConverterUInt32.check_lower(value.spaces_count)+ _UniffiFfiConverterUInt32.check_lower(value.spaces_running)+ _UniffiFfiConverterUInt32.check_lower(value.spaces_cpu_allocated)+ _UniffiFfiConverterUInt64.check_lower(value.spaces_memory_allocated)+ _UniffiFfiConverterUInt64.check_lower(value.spaces_memory_used)+ _UniffiFfiConverterUInt64.check_lower(value.spaces_disk_bytes)+ _UniffiFfiConverterBoolean.check_lower(value.spaces_disk_exact)+ _UniffiFfiConverterTypeDiskWarning.check_lower(value.warning)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterString.write(value.id, buf)+ _UniffiFfiConverterString.write(value.name, buf)+ _UniffiFfiConverterBoolean.write(value.online, buf)+ _UniffiFfiConverterUInt64.write(value.sampled_at_ms, buf)+ _UniffiFfiConverterUInt32.write(value.cpu_count, buf)+ _UniffiFfiConverterFloat64.write(value.cpu_percent, buf)+ _UniffiFfiConverterFloat64.write(value.load_average_1m, buf)+ _UniffiFfiConverterUInt64.write(value.memory_total, buf)+ _UniffiFfiConverterUInt64.write(value.memory_used, buf)+ _UniffiFfiConverterUInt64.write(value.disk_total, buf)+ _UniffiFfiConverterUInt64.write(value.disk_free, buf)+ _UniffiFfiConverterUInt32.write(value.spaces_count, buf)+ _UniffiFfiConverterUInt32.write(value.spaces_running, buf)+ _UniffiFfiConverterUInt32.write(value.spaces_cpu_allocated, buf)+ _UniffiFfiConverterUInt64.write(value.spaces_memory_allocated, buf)+ _UniffiFfiConverterUInt64.write(value.spaces_memory_used, buf)+ _UniffiFfiConverterUInt64.write(value.spaces_disk_bytes, buf)+ _UniffiFfiConverterBoolean.write(value.spaces_disk_exact, buf)+ _UniffiFfiConverterTypeDiskWarning.write(value.warning, buf)+@dataclassclass ConfigEntry:"""@@ -9977,6 +10322,52 @@ class _UniffiFfiConverterTypeDevicesSnapshot(_UniffiConverterRustBuffer):_UniffiFfiConverterMapStringString.write(value.machine_names, buf)_UniffiFfiConverterSequenceTypeRelayMachine.write(value.machines, buf)+@dataclass+class DiskOnHost:+ """+ What a Space costs this computer's disk, as opposed to what the guest+ sees.+"""+ def __init__(self, *, bytes:typing.Optional[int], allocated:int, shares_space:bool):+ self.bytes = bytes+ self.allocated = allocated+ self.shares_space = shares_space+++++ def __str__(self):+ return "DiskOnHost(bytes={}, allocated={}, shares_space={})".format(self.bytes, self.allocated, self.shares_space)+ def __eq__(self, other):+ if self.bytes != other.bytes:+ return False+ if self.allocated != other.allocated:+ return False+ if self.shares_space != other.shares_space:+ return False+ return True++class _UniffiFfiConverterTypeDiskOnHost(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return DiskOnHost(+ bytes=_UniffiFfiConverterOptionalUInt64.read(buf),+ allocated=_UniffiFfiConverterUInt64.read(buf),+ shares_space=_UniffiFfiConverterBoolean.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterOptionalUInt64.check_lower(value.bytes)+ _UniffiFfiConverterUInt64.check_lower(value.allocated)+ _UniffiFfiConverterBoolean.check_lower(value.shares_space)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterOptionalUInt64.write(value.bytes, buf)+ _UniffiFfiConverterUInt64.write(value.allocated, buf)+ _UniffiFfiConverterBoolean.write(value.shares_space, buf)+@@ -13798,6 +14189,87 @@ class _UniffiFfiConverterTypeGpuSupport(_UniffiConverterRustBuffer):_UniffiFfiConverterSequenceTypeGpuOption.write(value.options, buf)_UniffiFfiConverterString.write(value.reason, buf)+@dataclass+class GuestUsage:+ """+ What `SystemService.Metrics` reports from inside a Space.+"""+ def __init__(self, *, cpu_count:int, cpu_percent:float, load_average_1m:float, memory_used:int, memory_total:int, memory_limited:bool, disk_used:int, disk_total:int, disk_limited:bool):+ self.cpu_count = cpu_count+ self.cpu_percent = cpu_percent+ self.load_average_1m = load_average_1m+ self.memory_used = memory_used+ self.memory_total = memory_total+ self.memory_limited = memory_limited+ self.disk_used = disk_used+ self.disk_total = disk_total+ self.disk_limited = disk_limited+++++ def __str__(self):+ return "GuestUsage(cpu_count={}, cpu_percent={}, load_average_1m={}, memory_used={}, memory_total={}, memory_limited={}, disk_used={}, disk_total={}, disk_limited={})".format(self.cpu_count, self.cpu_percent, self.load_average_1m, self.memory_used, self.memory_total, self.memory_limited, self.disk_used, self.disk_total, self.disk_limited)+ def __eq__(self, other):+ if self.cpu_count != other.cpu_count:+ return False+ if self.cpu_percent != other.cpu_percent:+ return False+ if self.load_average_1m != other.load_average_1m:+ return False+ if self.memory_used != other.memory_used:+ return False+ if self.memory_total != other.memory_total:+ return False+ if self.memory_limited != other.memory_limited:+ return False+ if self.disk_used != other.disk_used:+ return False+ if self.disk_total != other.disk_total:+ return False+ if self.disk_limited != other.disk_limited:+ return False+ return True++class _UniffiFfiConverterTypeGuestUsage(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return GuestUsage(+ cpu_count=_UniffiFfiConverterUInt32.read(buf),+ cpu_percent=_UniffiFfiConverterFloat64.read(buf),+ load_average_1m=_UniffiFfiConverterFloat64.read(buf),+ memory_used=_UniffiFfiConverterUInt64.read(buf),+ memory_total=_UniffiFfiConverterUInt64.read(buf),+ memory_limited=_UniffiFfiConverterBoolean.read(buf),+ disk_used=_UniffiFfiConverterUInt64.read(buf),+ disk_total=_UniffiFfiConverterUInt64.read(buf),+ disk_limited=_UniffiFfiConverterBoolean.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterUInt32.check_lower(value.cpu_count)+ _UniffiFfiConverterFloat64.check_lower(value.cpu_percent)+ _UniffiFfiConverterFloat64.check_lower(value.load_average_1m)+ _UniffiFfiConverterUInt64.check_lower(value.memory_used)+ _UniffiFfiConverterUInt64.check_lower(value.memory_total)+ _UniffiFfiConverterBoolean.check_lower(value.memory_limited)+ _UniffiFfiConverterUInt64.check_lower(value.disk_used)+ _UniffiFfiConverterUInt64.check_lower(value.disk_total)+ _UniffiFfiConverterBoolean.check_lower(value.disk_limited)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterUInt32.write(value.cpu_count, buf)+ _UniffiFfiConverterFloat64.write(value.cpu_percent, buf)+ _UniffiFfiConverterFloat64.write(value.load_average_1m, buf)+ _UniffiFfiConverterUInt64.write(value.memory_used, buf)+ _UniffiFfiConverterUInt64.write(value.memory_total, buf)+ _UniffiFfiConverterBoolean.write(value.memory_limited, buf)+ _UniffiFfiConverterUInt64.write(value.disk_used, buf)+ _UniffiFfiConverterUInt64.write(value.disk_total, buf)+ _UniffiFfiConverterBoolean.write(value.disk_limited, buf)+@dataclassclass HostAccessRecord:"""@@ -16997,6 +17469,323 @@ class _UniffiFfiConverterTypeResolvedImage(_UniffiConverterRustBuffer):_UniffiFfiConverterString.write(value.os, buf)_UniffiFfiConverterOptionalBoolean.write(value.spacesd, buf)+class _UniffiFfiConverterOptionalTypeGuestUsage(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ if value is not None:+ _UniffiFfiConverterTypeGuestUsage.check_lower(value)++ @classmethod+ def write(cls, value, buf):+ if value is None:+ buf.write_u8(0)+ return++ buf.write_u8(1)+ _UniffiFfiConverterTypeGuestUsage.write(value, buf)++ @classmethod+ def read(cls, buf):+ flag = buf.read_u8()+ if flag == 0:+ return None+ elif flag == 1:+ return _UniffiFfiConverterTypeGuestUsage.read(buf)+ else:+ raise InternalError("Unexpected flag byte for optional type")++class _UniffiFfiConverterOptionalTypeDiskOnHost(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ if value is not None:+ _UniffiFfiConverterTypeDiskOnHost.check_lower(value)++ @classmethod+ def write(cls, value, buf):+ if value is None:+ buf.write_u8(0)+ return++ buf.write_u8(1)+ _UniffiFfiConverterTypeDiskOnHost.write(value, buf)++ @classmethod+ def read(cls, buf):+ flag = buf.read_u8()+ if flag == 0:+ return None+ elif flag == 1:+ return _UniffiFfiConverterTypeDiskOnHost.read(buf)+ else:+ raise InternalError("Unexpected flag byte for optional type")++@dataclass+class SpaceResources:+ """+ One extra Space on this Mac.+"""+ def __init__(self, *, id:str, power_state:str, cpu_allocated:int, memory_allocated:int, disk_allocated:int, usage:typing.Optional[GuestUsage], disk_on_host:typing.Optional[DiskOnHost]):+ self.id = id+ self.power_state = power_state+ self.cpu_allocated = cpu_allocated+ self.memory_allocated = memory_allocated+ self.disk_allocated = disk_allocated+ self.usage = usage+ self.disk_on_host = disk_on_host+++++ def __str__(self):+ return "SpaceResources(id={}, power_state={}, cpu_allocated={}, memory_allocated={}, disk_allocated={}, usage={}, disk_on_host={})".format(self.id, self.power_state, self.cpu_allocated, self.memory_allocated, self.disk_allocated, self.usage, self.disk_on_host)+ def __eq__(self, other):+ if self.id != other.id:+ return False+ if self.power_state != other.power_state:+ return False+ if self.cpu_allocated != other.cpu_allocated:+ return False+ if self.memory_allocated != other.memory_allocated:+ return False+ if self.disk_allocated != other.disk_allocated:+ return False+ if self.usage != other.usage:+ return False+ if self.disk_on_host != other.disk_on_host:+ return False+ return True++class _UniffiFfiConverterTypeSpaceResources(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return SpaceResources(+ id=_UniffiFfiConverterString.read(buf),+ power_state=_UniffiFfiConverterString.read(buf),+ cpu_allocated=_UniffiFfiConverterUInt32.read(buf),+ memory_allocated=_UniffiFfiConverterUInt64.read(buf),+ disk_allocated=_UniffiFfiConverterUInt64.read(buf),+ usage=_UniffiFfiConverterOptionalTypeGuestUsage.read(buf),+ disk_on_host=_UniffiFfiConverterOptionalTypeDiskOnHost.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterString.check_lower(value.id)+ _UniffiFfiConverterString.check_lower(value.power_state)+ _UniffiFfiConverterUInt32.check_lower(value.cpu_allocated)+ _UniffiFfiConverterUInt64.check_lower(value.memory_allocated)+ _UniffiFfiConverterUInt64.check_lower(value.disk_allocated)+ _UniffiFfiConverterOptionalTypeGuestUsage.check_lower(value.usage)+ _UniffiFfiConverterOptionalTypeDiskOnHost.check_lower(value.disk_on_host)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterString.write(value.id, buf)+ _UniffiFfiConverterString.write(value.power_state, buf)+ _UniffiFfiConverterUInt32.write(value.cpu_allocated, buf)+ _UniffiFfiConverterUInt64.write(value.memory_allocated, buf)+ _UniffiFfiConverterUInt64.write(value.disk_allocated, buf)+ _UniffiFfiConverterOptionalTypeGuestUsage.write(value.usage, buf)+ _UniffiFfiConverterOptionalTypeDiskOnHost.write(value.disk_on_host, buf)++class _UniffiFfiConverterSequenceTypeSpaceResources(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ for item in value:+ _UniffiFfiConverterTypeSpaceResources.check_lower(item)++ @classmethod+ def write(cls, value, buf):+ items = len(value)+ buf.write_i32(items)+ for item in value:+ _UniffiFfiConverterTypeSpaceResources.write(item, buf)++ @classmethod+ def read(cls, buf):+ count = buf.read_i32()+ if count < 0:+ raise InternalError("Unexpected negative sequence length")++ return [+ _UniffiFfiConverterTypeSpaceResources.read(buf) for i in range(count)+ ]++class _UniffiFfiConverterSequenceTypeComputerResources(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ for item in value:+ _UniffiFfiConverterTypeComputerResources.check_lower(item)++ @classmethod+ def write(cls, value, buf):+ items = len(value)+ buf.write_i32(items)+ for item in value:+ _UniffiFfiConverterTypeComputerResources.write(item, buf)++ @classmethod+ def read(cls, buf):+ count = buf.read_i32()+ if count < 0:+ raise InternalError("Unexpected negative sequence length")++ return [+ _UniffiFfiConverterTypeComputerResources.read(buf) for i in range(count)+ ]++@dataclass+class ResourcesSnapshot:+ """+ One sample of everything.+"""+ def __init__(self, *, sequence:int, sampled_at_ms:int, this_mac:ComputerResources, spaces:typing.List[SpaceResources], computers:typing.List[ComputerResources], warning:DiskWarning):+ self.sequence = sequence+ self.sampled_at_ms = sampled_at_ms+ self.this_mac = this_mac+ self.spaces = spaces+ self.computers = computers+ self.warning = warning+++++ def __str__(self):+ return "ResourcesSnapshot(sequence={}, sampled_at_ms={}, this_mac={}, spaces={}, computers={}, warning={})".format(self.sequence, self.sampled_at_ms, self.this_mac, self.spaces, self.computers, self.warning)+ def __eq__(self, other):+ if self.sequence != other.sequence:+ return False+ if self.sampled_at_ms != other.sampled_at_ms:+ return False+ if self.this_mac != other.this_mac:+ return False+ if self.spaces != other.spaces:+ return False+ if self.computers != other.computers:+ return False+ if self.warning != other.warning:+ return False+ return True++class _UniffiFfiConverterTypeResourcesSnapshot(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return ResourcesSnapshot(+ sequence=_UniffiFfiConverterUInt64.read(buf),+ sampled_at_ms=_UniffiFfiConverterUInt64.read(buf),+ this_mac=_UniffiFfiConverterTypeComputerResources.read(buf),+ spaces=_UniffiFfiConverterSequenceTypeSpaceResources.read(buf),+ computers=_UniffiFfiConverterSequenceTypeComputerResources.read(buf),+ warning=_UniffiFfiConverterTypeDiskWarning.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterUInt64.check_lower(value.sequence)+ _UniffiFfiConverterUInt64.check_lower(value.sampled_at_ms)+ _UniffiFfiConverterTypeComputerResources.check_lower(value.this_mac)+ _UniffiFfiConverterSequenceTypeSpaceResources.check_lower(value.spaces)+ _UniffiFfiConverterSequenceTypeComputerResources.check_lower(value.computers)+ _UniffiFfiConverterTypeDiskWarning.check_lower(value.warning)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterUInt64.write(value.sequence, buf)+ _UniffiFfiConverterUInt64.write(value.sampled_at_ms, buf)+ _UniffiFfiConverterTypeComputerResources.write(value.this_mac, buf)+ _UniffiFfiConverterSequenceTypeSpaceResources.write(value.spaces, buf)+ _UniffiFfiConverterSequenceTypeComputerResources.write(value.computers, buf)+ _UniffiFfiConverterTypeDiskWarning.write(value.warning, buf)++class _UniffiFfiConverterOptionalTypeComputerResources(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ if value is not None:+ _UniffiFfiConverterTypeComputerResources.check_lower(value)++ @classmethod+ def write(cls, value, buf):+ if value is None:+ buf.write_u8(0)+ return++ buf.write_u8(1)+ _UniffiFfiConverterTypeComputerResources.write(value, buf)++ @classmethod+ def read(cls, buf):+ flag = buf.read_u8()+ if flag == 0:+ return None+ elif flag == 1:+ return _UniffiFfiConverterTypeComputerResources.read(buf)+ else:+ raise InternalError("Unexpected flag byte for optional type")++@dataclass+class ResourcesUpdate:+ """+ What changed since the last event: only entries that moved by more than+ 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+"""+ def __init__(self, *, sequence:int, sampled_at_ms:int, this_mac:typing.Optional[ComputerResources], spaces:typing.List[SpaceResources], computers:typing.List[ComputerResources], removed:typing.List[str]):+ self.sequence = sequence+ self.sampled_at_ms = sampled_at_ms+ self.this_mac = this_mac+ self.spaces = spaces+ self.computers = computers+ self.removed = removed+++++ def __str__(self):+ return "ResourcesUpdate(sequence={}, sampled_at_ms={}, this_mac={}, spaces={}, computers={}, removed={})".format(self.sequence, self.sampled_at_ms, self.this_mac, self.spaces, self.computers, self.removed)+ def __eq__(self, other):+ if self.sequence != other.sequence:+ return False+ if self.sampled_at_ms != other.sampled_at_ms:+ return False+ if self.this_mac != other.this_mac:+ return False+ if self.spaces != other.spaces:+ return False+ if self.computers != other.computers:+ return False+ if self.removed != other.removed:+ return False+ return True++class _UniffiFfiConverterTypeResourcesUpdate(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ return ResourcesUpdate(+ sequence=_UniffiFfiConverterUInt64.read(buf),+ sampled_at_ms=_UniffiFfiConverterUInt64.read(buf),+ this_mac=_UniffiFfiConverterOptionalTypeComputerResources.read(buf),+ spaces=_UniffiFfiConverterSequenceTypeSpaceResources.read(buf),+ computers=_UniffiFfiConverterSequenceTypeComputerResources.read(buf),+ removed=_UniffiFfiConverterSequenceString.read(buf),+ )++ @staticmethod+ def check_lower(value):+ _UniffiFfiConverterUInt64.check_lower(value.sequence)+ _UniffiFfiConverterUInt64.check_lower(value.sampled_at_ms)+ _UniffiFfiConverterOptionalTypeComputerResources.check_lower(value.this_mac)+ _UniffiFfiConverterSequenceTypeSpaceResources.check_lower(value.spaces)+ _UniffiFfiConverterSequenceTypeComputerResources.check_lower(value.computers)+ _UniffiFfiConverterSequenceString.check_lower(value.removed)++ @staticmethod+ def write(value, buf):+ _UniffiFfiConverterUInt64.write(value.sequence, buf)+ _UniffiFfiConverterUInt64.write(value.sampled_at_ms, buf)+ _UniffiFfiConverterOptionalTypeComputerResources.write(value.this_mac, buf)+ _UniffiFfiConverterSequenceTypeSpaceResources.write(value.spaces, buf)+ _UniffiFfiConverterSequenceTypeComputerResources.write(value.computers, buf)+ _UniffiFfiConverterSequenceString.write(value.removed, buf)+@dataclassclass RoutineInfo:"""@@ -20243,11 +21032,14 @@ class _UniffiFfiConverterTypeSpaceTransferReport(_UniffiConverterRustBuffer):@dataclassclass SpaceUsage:"""- Memory and storage use ([`Space::usage`]). A size is the guest's own- limit only when its `*_limited` flag says so (a VM's memory or disk, a- container's cgroup memory limit).+ Processor, memory and storage use ([`Space::usage`]). A size is the+ guest's own limit only when its `*_limited` flag says so (a VM's memory+ or disk, a container's cgroup memory limit)."""- def __init__(self, *, memory_used:int, memory_total:int, memory_limited:bool, disk_used:int, disk_total:int, disk_limited:bool):+ def __init__(self, *, cpu_count:int = 0, cpu_percent:float = 0.0, load_average_1m:float = 0.0, memory_used:int, memory_total:int, memory_limited:bool, disk_used:int, disk_total:int, disk_limited:bool):+ self.cpu_count = cpu_count+ self.cpu_percent = cpu_percent+ self.load_average_1m = load_average_1mself.memory_used = memory_usedself.memory_total = memory_totalself.memory_limited = memory_limited@@ -20259,8 +21051,14 @@ class SpaceUsage:def __str__(self):- return "SpaceUsage(memory_used={}, memory_total={}, memory_limited={}, disk_used={}, disk_total={}, disk_limited={})".format(self.memory_used, self.memory_total, self.memory_limited, self.disk_used, self.disk_total, self.disk_limited)+ return "SpaceUsage(cpu_count={}, cpu_percent={}, load_average_1m={}, memory_used={}, memory_total={}, memory_limited={}, disk_used={}, disk_total={}, disk_limited={})".format(self.cpu_count, self.cpu_percent, self.load_average_1m, self.memory_used, self.memory_total, self.memory_limited, self.disk_used, self.disk_total, self.disk_limited)def __eq__(self, other):+ if self.cpu_count != other.cpu_count:+ return False+ if self.cpu_percent != other.cpu_percent:+ return False+ if self.load_average_1m != other.load_average_1m:+ return Falseif self.memory_used != other.memory_used:return Falseif self.memory_total != other.memory_total:@@ -20279,6 +21077,9 @@ class _UniffiFfiConverterTypeSpaceUsage(_UniffiConverterRustBuffer):@staticmethoddef read(buf):return SpaceUsage(+ cpu_count=_UniffiFfiConverterUInt32.read(buf),+ cpu_percent=_UniffiFfiConverterFloat64.read(buf),+ load_average_1m=_UniffiFfiConverterFloat64.read(buf),memory_used=_UniffiFfiConverterUInt64.read(buf),memory_total=_UniffiFfiConverterUInt64.read(buf),memory_limited=_UniffiFfiConverterBoolean.read(buf),@@ -20289,6 +21090,9 @@ class _UniffiFfiConverterTypeSpaceUsage(_UniffiConverterRustBuffer):@staticmethoddef check_lower(value):+ _UniffiFfiConverterUInt32.check_lower(value.cpu_count)+ _UniffiFfiConverterFloat64.check_lower(value.cpu_percent)+ _UniffiFfiConverterFloat64.check_lower(value.load_average_1m)_UniffiFfiConverterUInt64.check_lower(value.memory_used)_UniffiFfiConverterUInt64.check_lower(value.memory_total)_UniffiFfiConverterBoolean.check_lower(value.memory_limited)@@ -20298,6 +21102,9 @@ class _UniffiFfiConverterTypeSpaceUsage(_UniffiConverterRustBuffer):@staticmethoddef write(value, buf):+ _UniffiFfiConverterUInt32.write(value.cpu_count, buf)+ _UniffiFfiConverterFloat64.write(value.cpu_percent, buf)+ _UniffiFfiConverterFloat64.write(value.load_average_1m, buf)_UniffiFfiConverterUInt64.write(value.memory_used, buf)_UniffiFfiConverterUInt64.write(value.memory_total, buf)_UniffiFfiConverterBoolean.write(value.memory_limited, buf)@@ -22685,6 +23492,182 @@ class _UniffiFfiConverterTypeReplayMode(_UniffiConverterRustBuffer):++++++class ResourcesEvent:+ """+ What [`Spaces::watch_resources`] reports.+"""+ def __init__(self):+ raise RuntimeError("ResourcesEvent cannot be instantiated directly")++ # Each enum variant is a nested class of the enum itself.+ @dataclass+ class SNAPSHOT:+ """+ Everything, at the start (and again after a reconnect).+"""++ def __init__(self, snapshot:ResourcesSnapshot):+ self.snapshot = snapshot++ """+ The sample.+"""++ pass++++++ def __str__(self):+ return "ResourcesEvent.SNAPSHOT(snapshot={})".format(self.snapshot)+ def __eq__(self, other):+ if not isinstance(other, ResourcesEvent):+ return NotImplemented+ if not other.is_SNAPSHOT():+ return False+ if self.snapshot != other.snapshot:+ return False+ return True++ @dataclass+ class UPDATE:+ """+ Only what changed.+"""++ def __init__(self, update:ResourcesUpdate):+ self.update = update++ """+ The changes.+"""++ pass++++++ def __str__(self):+ return "ResourcesEvent.UPDATE(update={})".format(self.update)+ def __eq__(self, other):+ if not isinstance(other, ResourcesEvent):+ return NotImplemented+ if not other.is_UPDATE():+ return False+ if self.update != other.update:+ return False+ return True++ @dataclass+ class LOW_DISK:+ """+ The low-disk level changed (including back to `ok`).+"""++ def __init__(self, warning:DiskWarning):+ self.warning = warning++ """+ The warning now.+"""++ pass++++++ def __str__(self):+ return "ResourcesEvent.LOW_DISK(warning={})".format(self.warning)+ def __eq__(self, other):+ if not isinstance(other, ResourcesEvent):+ return NotImplemented+ if not other.is_LOW_DISK():+ return False+ if self.warning != other.warning:+ return False+ return True++++ # For each variant, we have `is_NAME` and `is_name` methods for easily checking+ # whether an instance is that variant.+ def is_SNAPSHOT(self) -> bool:+ return isinstance(self, ResourcesEvent.SNAPSHOT)+ def is_snapshot(self) -> bool:+ return isinstance(self, ResourcesEvent.SNAPSHOT)+ def is_UPDATE(self) -> bool:+ return isinstance(self, ResourcesEvent.UPDATE)+ def is_update(self) -> bool:+ return isinstance(self, ResourcesEvent.UPDATE)+ def is_LOW_DISK(self) -> bool:+ return isinstance(self, ResourcesEvent.LOW_DISK)+ def is_low_disk(self) -> bool:+ return isinstance(self, ResourcesEvent.LOW_DISK)+++# Now, a little trick - we make each nested variant class be a subclass of the main+# enum class, so that method calls and instance checks etc will work intuitively.+# We might be able to do this a little more neatly with a metaclass, but this'll do.+ResourcesEvent.SNAPSHOT = type("ResourcesEvent.SNAPSHOT", (ResourcesEvent.SNAPSHOT, ResourcesEvent,), {}) # type: ignore+ResourcesEvent.UPDATE = type("ResourcesEvent.UPDATE", (ResourcesEvent.UPDATE, ResourcesEvent,), {}) # type: ignore+ResourcesEvent.LOW_DISK = type("ResourcesEvent.LOW_DISK", (ResourcesEvent.LOW_DISK, ResourcesEvent,), {}) # type: ignore+++++class _UniffiFfiConverterTypeResourcesEvent(_UniffiConverterRustBuffer):+ @staticmethod+ def read(buf):+ variant = buf.read_i32()+ if variant == 1:+ return ResourcesEvent.SNAPSHOT(+ _UniffiFfiConverterTypeResourcesSnapshot.read(buf),+ )+ if variant == 2:+ return ResourcesEvent.UPDATE(+ _UniffiFfiConverterTypeResourcesUpdate.read(buf),+ )+ if variant == 3:+ return ResourcesEvent.LOW_DISK(+ _UniffiFfiConverterTypeDiskWarning.read(buf),+ )+ raise InternalError("Raw enum value doesn't match any cases")++ @staticmethod+ def check_lower(value):+ if value.is_SNAPSHOT():+ _UniffiFfiConverterTypeResourcesSnapshot.check_lower(value.snapshot)+ return+ if value.is_UPDATE():+ _UniffiFfiConverterTypeResourcesUpdate.check_lower(value.update)+ return+ if value.is_LOW_DISK():+ _UniffiFfiConverterTypeDiskWarning.check_lower(value.warning)+ return+ raise ValueError(value)++ @staticmethod+ def write(value, buf):+ if value.is_SNAPSHOT():+ buf.write_i32(1)+ _UniffiFfiConverterTypeResourcesSnapshot.write(value.snapshot, buf)+ if value.is_UPDATE():+ buf.write_i32(2)+ _UniffiFfiConverterTypeResourcesUpdate.write(value.update, buf)+ if value.is_LOW_DISK():+ buf.write_i32(3)+ _UniffiFfiConverterTypeDiskWarning.write(value.warning, buf)+++class _UniffiFfiConverterSequenceTypeAgentArtifact(_UniffiConverterRustBuffer):@classmethoddef check_lower(cls, value):@@ -32611,8 +33594,8 @@ class SpaceProtocol(typing.Protocol):raise NotImplementedErrorasync def usage(self, ) -> SpaceUsage:"""- Memory and storage use now (cheap: poll it at a low rate while a- detail is visible).+ Processor, memory and storage use now (cheap: poll it at a low rate+ while a detail is visible)."""raise NotImplementedErrorasync def websocket_headers(self, ) -> typing.List[HttpHeader]:@@ -33587,8 +34570,8 @@ class Space(SpaceProtocol):)async def usage(self, ) -> SpaceUsage:"""- Memory and storage use now (cheap: poll it at a low rate while a- detail is visible).+ Processor, memory and storage use now (cheap: poll it at a low rate+ while a detail is visible)."""_uniffi_lowered_args = (self._uniffi_clone_handle(),@@ -33817,6 +34800,275 @@ class _UniffiFfiConverterSequenceTypeDriveAccessRequest(_UniffiConverterRustBuff]+class ResourcesListener():+ """+ Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ Called on an SDK worker thread; return quickly.+"""++ def on_event(self, event: ResourcesEvent) -> None:+ """+ Something moved.+"""+ raise NotImplementedError++class ResourcesListenerImpl(ResourcesListener):+ """+ Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ Called on an SDK worker thread; return quickly.+"""++ _handle: ctypes.c_uint64++ def __init__(self, *args, **kwargs):+ raise ValueError("This class has no default constructor")++ def __del__(+ self,+ _uniffi_free=_UniffiLib.uniffi_cua_sdk_fn_free_resourceslistener,+ _uniffi_call=_uniffi_rust_call,+ _uniffi_finalizing=sys.is_finalizing,+ ):+ # In case of partial initialization of instances.+ handle = getattr(self, "_handle", None)+ # At interpreter exit the module globals are gone: skip the free (cua+ # post-process, libs/cua/scripts/uniffi-python-postprocess.mjs).+ if handle is not None and not _uniffi_finalizing():+ _uniffi_call(_uniffi_free, handle)++ def _uniffi_clone_handle(self):+ return _uniffi_rust_call(_UniffiLib.uniffi_cua_sdk_fn_clone_resourceslistener, self._handle)++ # Used by alternative constructors or any methods which return this type.+ @classmethod+ def _uniffi_make_instance(cls, handle):+ # Lightly yucky way to bypass the usual __init__ logic+ # and just create a new instance with the required handle.+ inst = cls.__new__(cls)+ inst._handle = handle+ return inst+ def on_event(self, event: ResourcesEvent) -> None:+ """+ Something moved.+"""++ _UniffiFfiConverterTypeResourcesEvent.check_lower(event)+ _uniffi_lowered_args = (+ self._uniffi_clone_handle(),+ _UniffiFfiConverterTypeResourcesEvent.lower(event),+ )+ _uniffi_lift_return = lambda val: None+ _uniffi_error_converter = None+ _uniffi_ffi_result = _uniffi_rust_call_with_error(+ _uniffi_error_converter,+ _UniffiLib.uniffi_cua_sdk_fn_method_resourceslistener_on_event,+ *_uniffi_lowered_args,+ )+ return _uniffi_lift_return(_uniffi_ffi_result)+++++# Put all the bits inside a class to keep the top-level namespace clean+class _UniffiTraitImplResourcesListenerImpl:+ # For each method, generate a callback function to pass to Rust++ @_UNIFFI_CALLBACK_INTERFACE_CUA_SDK_RESOURCES_LISTENER_METHOD0+ def on_event(+ uniffi_handle,+ event,+ uniffi_out_return,+ uniffi_call_status_ptr,+ ):+ uniffi_obj = _UniffiFfiConverterTypeResourcesListener._handle_map.get(uniffi_handle)+ def make_call():+ uniffi_args = (_UniffiFfiConverterTypeResourcesEvent.lift(event), )+ uniffi_method = uniffi_obj.on_event+ return uniffi_method(*uniffi_args)+ write_return_value = lambda v: None+ _uniffi_trait_interface_call(+ uniffi_call_status_ptr.contents,+ make_call,+ write_return_value,+ )++ @_UNIFFI_CALLBACK_INTERFACE_FREE_CUA_SDK_RESOURCES_LISTENER+ def _uniffi_free(uniffi_handle):+ _UniffiFfiConverterTypeResourcesListener._handle_map.remove(uniffi_handle)++ @_UNIFFI_CALLBACK_INTERFACE_CLONE_CUA_SDK_RESOURCES_LISTENER+ def _uniffi_clone(uniffi_handle):+ return _UniffiFfiConverterTypeResourcesListener._handle_map.clone(uniffi_handle)++ # Generate the FFI VTable. This has a field for each callback interface method.+ _uniffi_vtable = _UniffiVTableCallbackInterfaceCuaSdkResourcesListener(+ _uniffi_free,+ _uniffi_clone,+ on_event,+ )+ # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever,+ # or else bad things will happen when Rust tries to access it.+ _UniffiLib.uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(ctypes.byref(_uniffi_vtable))++class _UniffiFfiConverterTypeResourcesListener:+ _handle_map = _UniffiHandleMap()++ @staticmethod+ def lift(value: int):+ if (value & 1) == 0:+ # Rust-generated handle, construct a new class that uses the handle to implement the+ # interface+ return ResourcesListenerImpl._uniffi_make_instance(value)+ else:+ # Python-generated handle, get the object from the handle map+ return _UniffiFfiConverterTypeResourcesListener._handle_map.remove(value)++ @staticmethod+ def check_lower(value: ResourcesListener):+ if not isinstance(value, ResourcesListener):+ raise TypeError("Expected ResourcesListener subclass, {} found".format(type(value).__name__))++ @staticmethod+ def lower(value: ResourcesListener):+ if isinstance(value, ResourcesListenerImpl):+ # Rust-implementated object. Clone the handle and return it+ return value._uniffi_clone_handle()+ else:+ # Python-implementated object, generate a new vtable handle and return that.+ return _UniffiFfiConverterTypeResourcesListener._handle_map.insert(value)++ @classmethod+ def read(cls, buf: _UniffiRustBuffer):+ ptr = buf.read_u64()+ if ptr == 0:+ raise InternalError("Raw handle value was null")+ return cls.lift(ptr)++ @classmethod+ def write(cls, value: ResourcesListener, buf: _UniffiRustBuffer):+ buf.write_u64(cls.lower(value))+++class ResourcesWatchProtocol(typing.Protocol):+ """+ A running [`Spaces::watch_resources`]: tell it whether a window shows+ the numbers, and stop it when done. Dropping it also stops it.+"""++ def set_visible(self, visible: bool) -> None:+ """+ Whether a window shows the numbers: visible watchers are sampled+ every 10 seconds, hidden ones every 5 minutes (and still hear+ `LowDisk`, for the menu bar).+"""+ raise NotImplementedError+ def stop(self, ) -> None:+ """+ Ends the watch. No event is delivered after this returns.+"""+ raise NotImplementedError++class ResourcesWatch(ResourcesWatchProtocol):+ """+ A running [`Spaces::watch_resources`]: tell it whether a window shows+ the numbers, and stop it when done. Dropping it also stops it.+"""++ _handle: ctypes.c_uint64++ def __init__(self, *args, **kwargs):+ raise ValueError("This class has no default constructor")++ def __del__(+ self,+ _uniffi_free=_UniffiLib.uniffi_cua_sdk_fn_free_resourceswatch,+ _uniffi_call=_uniffi_rust_call,+ _uniffi_finalizing=sys.is_finalizing,+ ):+ # In case of partial initialization of instances.+ handle = getattr(self, "_handle", None)+ # At interpreter exit the module globals are gone: skip the free (cua+ # post-process, libs/cua/scripts/uniffi-python-postprocess.mjs).+ if handle is not None and not _uniffi_finalizing():+ _uniffi_call(_uniffi_free, handle)++ def _uniffi_clone_handle(self):+ return _uniffi_rust_call(_UniffiLib.uniffi_cua_sdk_fn_clone_resourceswatch, self._handle)++ # Used by alternative constructors or any methods which return this type.+ @classmethod+ def _uniffi_make_instance(cls, handle):+ # Lightly yucky way to bypass the usual __init__ logic+ # and just create a new instance with the required handle.+ inst = cls.__new__(cls)+ inst._handle = handle+ return inst+ def set_visible(self, visible: bool) -> None:+ """+ Whether a window shows the numbers: visible watchers are sampled+ every 10 seconds, hidden ones every 5 minutes (and still hear+ `LowDisk`, for the menu bar).+"""++ _UniffiFfiConverterBoolean.check_lower(visible)+ _uniffi_lowered_args = (+ self._uniffi_clone_handle(),+ _UniffiFfiConverterBoolean.lower(visible),+ )+ _uniffi_lift_return = lambda val: None+ _uniffi_error_converter = None+ _uniffi_ffi_result = _uniffi_rust_call_with_error(+ _uniffi_error_converter,+ _UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_set_visible,+ *_uniffi_lowered_args,+ )+ return _uniffi_lift_return(_uniffi_ffi_result)+ def stop(self, ) -> None:+ """+ Ends the watch. No event is delivered after this returns.+"""+ _uniffi_lowered_args = (+ self._uniffi_clone_handle(),+ )+ _uniffi_lift_return = lambda val: None+ _uniffi_error_converter = None+ _uniffi_ffi_result = _uniffi_rust_call_with_error(+ _uniffi_error_converter,+ _UniffiLib.uniffi_cua_sdk_fn_method_resourceswatch_stop,+ *_uniffi_lowered_args,+ )+ return _uniffi_lift_return(_uniffi_ffi_result)++++++class _UniffiFfiConverterTypeResourcesWatch:+ @staticmethod+ def lift(value: int) -> ResourcesWatch:+ return ResourcesWatch._uniffi_make_instance(value)++ @staticmethod+ def check_lower(value: ResourcesWatch):+ if not isinstance(value, ResourcesWatch):+ raise TypeError("Expected ResourcesWatch instance, {} found".format(type(value).__name__))++ @staticmethod+ def lower(value: ResourcesWatch) -> ctypes.c_uint64:+ return value._uniffi_clone_handle()++ @classmethod+ def read(cls, buf: _UniffiRustBuffer) -> ResourcesWatch:+ ptr = buf.read_u64()+ if ptr == 0:+ raise InternalError("Raw handle value was null")+ return cls.lift(ptr)++ @classmethod+ def write(cls, value: ResourcesWatch, buf: _UniffiRustBuffer):+ buf.write_u64(cls.lower(value))++class SpacesProtocol(typing.Protocol):"""The Spaces registry: add a machine by URL, provision a local one, and get@@ -34035,6 +35287,16 @@ class SpacesProtocol(typing.Protocol):async def resolve(self, space: str) -> SpaceInfo:"""Resolves an id, legacy id, URL or display name.+"""+ raise NotImplementedError+ async def resources(self, visible: bool) -> ResourcesSnapshot:+ """+ What this Mac, its extra Spaces and your other computers use now:+ processor, memory and disk, as one snapshot (a few seconds old at+ most). With `visible`, the call also says a window shows the numbers+ for the next 30 seconds, so the runtime samples every 10 seconds+ instead of every 5 minutes: call it every 10 seconds while a window+ is visible and stop when it is hidden."""raise NotImplementedErrorasync def routine_add(self, agent: str,title: str,prompt: str,every_minutes: typing.Optional[int],daily_at: typing.Optional[str],weekly_on: typing.Optional[str]) -> RoutineInfo:@@ -34207,6 +35469,15 @@ class SpacesProtocol(typing.Protocol):"""`volume_write`: a new version of a file. `if_etag` makes it acompare-and-swap, `create_only` makes it create-only.+"""+ raise NotImplementedError+ def watch_resources(self, visible: bool,listener: ResourcesListener) -> ResourcesWatch:+ """+ The same numbers as events for `listener`: a snapshot first, then an+ update with only the entries that changed by more than 1 point or+ 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ itself if the daemon restarts (the snapshot comes again). Stop it+ with [`ResourcesWatch::stop`]."""raise NotImplementedError@@ -35020,6 +36291,31 @@ class Spaces(SpacesProtocol):_uniffi_lift_return,_uniffi_error_converter,)+ async def resources(self, visible: bool) -> ResourcesSnapshot:+ """+ What this Mac, its extra Spaces and your other computers use now:+ processor, memory and disk, as one snapshot (a few seconds old at+ most). With `visible`, the call also says a window shows the numbers+ for the next 30 seconds, so the runtime samples every 10 seconds+ instead of every 5 minutes: call it every 10 seconds while a window+ is visible and stop when it is hidden.+"""++ _UniffiFfiConverterBoolean.check_lower(visible)+ _uniffi_lowered_args = (+ self._uniffi_clone_handle(),+ _UniffiFfiConverterBoolean.lower(visible),+ )+ _uniffi_lift_return = _UniffiFfiConverterTypeResourcesSnapshot.lift+ _uniffi_error_converter = _UniffiFfiConverterTypeCuaError+ return await _uniffi_rust_call_async(+ _UniffiLib.uniffi_cua_sdk_fn_method_spaces_resources(*_uniffi_lowered_args),+ _UniffiLib.ffi_cua_sdk_rust_future_poll_rust_buffer,+ _UniffiLib.ffi_cua_sdk_rust_future_complete_rust_buffer,+ _UniffiLib.ffi_cua_sdk_rust_future_free_rust_buffer,+ _uniffi_lift_return,+ _uniffi_error_converter,+ )async def routine_add(self, agent: str,title: str,prompt: str,every_minutes: typing.Optional[int],daily_at: typing.Optional[str],weekly_on: typing.Optional[str]) -> RoutineInfo:"""Adds a routine. Give exactly one of `every_minutes`, `daily_at`@@ -35732,6 +37028,31 @@ class Spaces(SpacesProtocol):_uniffi_lift_return,_uniffi_error_converter,)+ def watch_resources(self, visible: bool,listener: ResourcesListener) -> ResourcesWatch:+ """+ The same numbers as events for `listener`: a snapshot first, then an+ update with only the entries that changed by more than 1 point or+ 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ itself if the daemon restarts (the snapshot comes again). Stop it+ with [`ResourcesWatch::stop`].+"""++ _UniffiFfiConverterBoolean.check_lower(visible)++ _UniffiFfiConverterTypeResourcesListener.check_lower(listener)+ _uniffi_lowered_args = (+ self._uniffi_clone_handle(),+ _UniffiFfiConverterBoolean.lower(visible),+ _UniffiFfiConverterTypeResourcesListener.lower(listener),+ )+ _uniffi_lift_return = _UniffiFfiConverterTypeResourcesWatch.lift+ _uniffi_error_converter = None+ _uniffi_ffi_result = _uniffi_rust_call_with_error(+ _uniffi_error_converter,+ _UniffiLib.uniffi_cua_sdk_fn_method_spaces_watch_resources,+ *_uniffi_lowered_args,+ )+ return _uniffi_lift_return(_uniffi_ffi_result)@@ -37770,6 +39091,7 @@ __all__ = ["InternalError","AgentSetupTarget","AgentSetupChange",+ "DiskLevel","CuaMode","RuntimeCheckStatus","RegistrySecret",@@ -37781,6 +39103,7 @@ __all__ = ["CuaError","LoginMethod","ReplayMode",+ "ResourcesEvent","AgentActionReport","AgentArtifact","HomeTransfer",@@ -37819,6 +39142,8 @@ __all__ = ["CloudTarget","CloudTestReport","ComputerGrant",+ "DiskWarning",+ "ComputerResources","ConfigEntry","Container","FleetSettings",@@ -37831,6 +39156,7 @@ __all__ = ["RelayClientInfo","RelayMachine","DevicesSnapshot",+ "DiskOnHost","RuntimeCheck","DoctorReport","DriveAccessRequest",@@ -37878,6 +39204,7 @@ __all__ = ["FleetUsagePricing","GpuOption","GpuSupport",+ "GuestUsage","HostAccessRecord","HostPermission","HostProvidedSpace",@@ -37917,6 +39244,9 @@ __all__ = ["PtySize","PublicUrl","ResolvedImage",+ "SpaceResources",+ "ResourcesSnapshot",+ "ResourcesUpdate","RoutineInfo","SandboxCreateOptions","SandboxInfo",@@ -38083,6 +39413,10 @@ __all__ = ["TeleportApprover","Space","SpaceProtocol",+ "ResourcesListenerImpl",+ "ResourcesListener",+ "ResourcesWatch",+ "ResourcesWatchProtocol","Spaces","SpacesProtocol","Cua",diff --git a/libs/cua/scripts/generate-app-core-ffi.py b/libs/cua/scripts/generate-app-core-ffi.pyindex b8ed166ba9..6fdadecca0 100644--- a/libs/cua/scripts/generate-app-core-ffi.py+++ b/libs/cua/scripts/generate-app-core-ffi.py@@ -70,6 +70,7 @@ TYPES = [("palette.rs", "palette", ["Keybinding", "PaletteEntry"]),("teams.rs", "teams", ["TeamPersonInput", "TeamInput", "TeamsState", "TeamsInput"]),("relay_usage.rs", "relay_usage", ["RelayUsageTeam", "RelayUsage", "RelayAllowanceNotice", "PlanLink", "PlanCard", "RelayUsageView"]),+ ("resources.rs", "resources", ["DiskLevel", "DiskWarning", "ComputerResources", "GuestUsage", "DiskOnHost", "SpaceResources", "ResourcesSnapshot", "ResourceTone", "ResourceRow", "WarningView", "ThisMacView", "SpaceResourcesView", "ComputerView", "ResourcesView"]),]# FFI names that read better than the plain prefix.diff --git a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swiftindex 9183ed82b8..869faae98d 100644--- a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift+++ b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift@@ -6713,6 +6713,355 @@ public func FfiConverterTypeRelay_lower(_ value: Relay) -> UInt64 {+/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+public protocol ResourcesListener: AnyObject, Sendable {++ /**+ * Something moved.+ */+ func onEvent(event: ResourcesEvent)++}+/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+open class ResourcesListenerImpl: ResourcesListener, @unchecked Sendable {+ fileprivate let handle: UInt64++ /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public struct NoHandle {+ public init() {}+ }++ // TODO: We'd like this to be `private` but for Swifty reasons,+ // we can't implement `FfiConverter` without making this `required` and we can't+ // make it `required` without making it `public`.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ required public init(unsafeFromHandle handle: UInt64) {+ self.handle = handle+ }++ // This constructor can be used to instantiate a fake object.+ // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].+ //+ // - Warning:+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public init(noHandle: NoHandle) {+ self.handle = 0+ }++#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public func uniffiCloneHandle() -> UInt64 {+ return try! rustCall { uniffi_cua_sdk_fn_clone_resourceslistener(self.handle, $0) }+ }+ // No primary constructor declared for this class.++ deinit {+ if handle == 0 {+ // Mock objects have handle=0 don't try to free them+ return+ }++ try! rustCall { uniffi_cua_sdk_fn_free_resourceslistener(handle, $0) }+ }+++++ /**+ * Something moved.+ */+open func onEvent(event: ResourcesEvent) {try! rustCall() {+ uniffi_cua_sdk_fn_method_resourceslistener_on_event(+ self.uniffiCloneHandle(),+ FfiConverterTypeResourcesEvent_lower(event),$0+ )+}+}++++}++++// Put the implementation in a struct so we don't pollute the top-level namespace+fileprivate struct UniffiCallbackInterfaceResourcesListener {++ // Create the VTable using a series of closures.+ // Swift automatically converts these into C callback functions.+ //+ // This creates 1-element array, since this seems to be the only way to construct a const+ // pointer that we can pass to the Rust code.+ static let vtable: [UniffiVTableCallbackInterfaceResourcesListener] = [UniffiVTableCallbackInterfaceResourcesListener(+ uniffiFree: { (uniffiHandle: UInt64) -> () in+ do {+ try FfiConverterTypeResourcesListener.handleMap.remove(handle: uniffiHandle)+ } catch {+ print("Uniffi callback interface ResourcesListener: handle missing in uniffiFree")+ }+ },+ uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in+ do {+ return try FfiConverterTypeResourcesListener.handleMap.clone(handle: uniffiHandle)+ } catch {+ fatalError("Uniffi callback interface ResourcesListener: handle missing in uniffiClone")+ }+ },+ onEvent: { (+ uniffiHandle: UInt64,+ event: RustBuffer,+ uniffiOutReturn: UnsafeMutableRawPointer,+ uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>+ ) in+ let makeCall = {+ () throws -> () in+ guard let uniffiObj = try? FfiConverterTypeResourcesListener.handleMap.get(handle: uniffiHandle) else {+ throw UniffiInternalError.unexpectedStaleHandle+ }+ return uniffiObj.onEvent(+ event: try FfiConverterTypeResourcesEvent_lift(event)+ )+ }+++ let writeReturn = { () }+ uniffiTraitInterfaceCall(+ callStatus: uniffiCallStatus,+ makeCall: makeCall,+ writeReturn: writeReturn+ )+ }+ )]+}++private func uniffiCallbackInitResourcesListener() {+ uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(UniffiCallbackInterfaceResourcesListener.vtable)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeResourcesListener: FfiConverter {+ fileprivate static let handleMap = UniffiHandleMap<ResourcesListener>()++ typealias FfiType = UInt64+ typealias SwiftType = ResourcesListener++ public static func lift(_ handle: UInt64) throws -> ResourcesListener {+ if ((handle & 1) == 0) {+ // Rust-generated handle, construct a new class that uses the handle to implement the+ // interface+ return ResourcesListenerImpl(unsafeFromHandle: handle)+ } else {+ // Swift-generated handle, get the object from the handle map+ return try handleMap.remove(handle: handle)+ }+ }++ public static func lower(_ value: ResourcesListener) -> UInt64 {+ if let rustImpl = value as? ResourcesListenerImpl {+ // Rust-implemented object. Clone the handle and return it+ return rustImpl.uniffiCloneHandle()+ } else {+ // Swift object, generate a new vtable handle and return that.+ return handleMap.insert(obj: value)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourcesListener {+ let handle: UInt64 = try readInt(&buf)+ return try lift(handle)+ }++ public static func write(_ value: ResourcesListener, into buf: inout [UInt8]) {+ writeInt(&buf, lower(value))+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesListener_lift(_ handle: UInt64) throws -> ResourcesListener {+ return try FfiConverterTypeResourcesListener.lift(handle)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesListener_lower(_ value: ResourcesListener) -> UInt64 {+ return FfiConverterTypeResourcesListener.lower(value)+}+++++++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+public protocol ResourcesWatchProtocol: AnyObject, Sendable {++ /**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ func setVisible(visible: Bool)++ /**+ * Ends the watch. No event is delivered after this returns.+ */+ func stop()++}+/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+open class ResourcesWatch: ResourcesWatchProtocol, @unchecked Sendable {+ fileprivate let handle: UInt64++ /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public struct NoHandle {+ public init() {}+ }++ // TODO: We'd like this to be `private` but for Swifty reasons,+ // we can't implement `FfiConverter` without making this `required` and we can't+ // make it `required` without making it `public`.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ required public init(unsafeFromHandle handle: UInt64) {+ self.handle = handle+ }++ // This constructor can be used to instantiate a fake object.+ // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].+ //+ // - Warning:+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.+#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public init(noHandle: NoHandle) {+ self.handle = 0+ }++#if swift(>=5.8)+ @_documentation(visibility: private)+#endif+ public func uniffiCloneHandle() -> UInt64 {+ return try! rustCall { uniffi_cua_sdk_fn_clone_resourceswatch(self.handle, $0) }+ }+ // No primary constructor declared for this class.++ deinit {+ if handle == 0 {+ // Mock objects have handle=0 don't try to free them+ return+ }++ try! rustCall { uniffi_cua_sdk_fn_free_resourceswatch(handle, $0) }+ }+++++ /**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+open func setVisible(visible: Bool) {try! rustCall() {+ uniffi_cua_sdk_fn_method_resourceswatch_set_visible(+ self.uniffiCloneHandle(),+ FfiConverterBool.lower(visible),$0+ )+}+}++ /**+ * Ends the watch. No event is delivered after this returns.+ */+open func stop() {try! rustCall() {+ uniffi_cua_sdk_fn_method_resourceswatch_stop(+ self.uniffiCloneHandle(),$0+ )+}+}++++}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeResourcesWatch: FfiConverter {+ typealias FfiType = UInt64+ typealias SwiftType = ResourcesWatch++ public static func lift(_ handle: UInt64) throws -> ResourcesWatch {+ return ResourcesWatch(unsafeFromHandle: handle)+ }++ public static func lower(_ value: ResourcesWatch) -> UInt64 {+ return value.uniffiCloneHandle()+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourcesWatch {+ let handle: UInt64 = try readInt(&buf)+ return try lift(handle)+ }++ public static func write(_ value: ResourcesWatch, into buf: inout [UInt8]) {+ writeInt(&buf, lower(value))+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesWatch_lift(_ handle: UInt64) throws -> ResourcesWatch {+ return try FfiConverterTypeResourcesWatch.lift(handle)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesWatch_lower(_ value: ResourcesWatch) -> UInt64 {+ return FfiConverterTypeResourcesWatch.lower(value)+}++++++/*** A sandbox handle.*/@@ -8554,8 +8903,8 @@ public protocol SpaceProtocol: AnyObject, Sendable {func upload(localPath: String, dest: String?) async throws -> SpaceTransferReport/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/func usage() async throws -> SpaceUsage@@ -9453,8 +9802,8 @@ open func upload(localPath: String, dest: String?)async throws -> SpaceTransfer}/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/open func usage()async throws -> SpaceUsage {return@@ -10562,6 +10911,16 @@ public protocol SpacesProtocol: AnyObject, Sendable {*/func resolve(space: String) async throws -> SpaceInfo+ /**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ func resources(visible: Bool) async throws -> ResourcesSnapshot+/*** A connected handle to a registered Space.*/@@ -10713,6 +11072,15 @@ public protocol SpacesProtocol: AnyObject, Sendable {*/func volumeWrite(path: String, content: Data, ifEtag: String?, createOnly: Bool, view: DriveView?) async throws -> DriveObject+ /**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ func watchResources(visible: Bool, listener: ResourcesListener) -> ResourcesWatch+}/*** The Spaces registry: add a machine by URL, provision a local one, and get@@ -11576,6 +11944,31 @@ open func resolve(space: String)async throws -> SpaceInfo {)}+ /**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+open func resources(visible: Bool)async throws -> ResourcesSnapshot {+ return+ try await uniffiRustCallAsync(+ rustFutureFunc: {+ uniffi_cua_sdk_fn_method_spaces_resources(+ self.uniffiCloneHandle(),+ FfiConverterBool.lower(visible)+ )+ },+ pollFunc: ffi_cua_sdk_rust_future_poll_rust_buffer,+ completeFunc: ffi_cua_sdk_rust_future_complete_rust_buffer,+ freeFunc: ffi_cua_sdk_rust_future_free_rust_buffer,+ liftFunc: FfiConverterTypeResourcesSnapshot_lift,+ errorHandler: FfiConverterTypeCuaError_lift+ )+}+/*** A connected handle to a registered Space.*/@@ -12147,6 +12540,23 @@ open func volumeWrite(path: String, content: Data, ifEtag: String?, createOnly:)}+ /**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+open func watchResources(visible: Bool, listener: ResourcesListener) -> ResourcesWatch {+ return try! FfiConverterTypeResourcesWatch_lift(try! rustCall() {+ uniffi_cua_sdk_fn_method_spaces_watch_resources(+ self.uniffiCloneHandle(),+ FfiConverterBool.lower(visible),+ FfiConverterTypeResourcesListener_lower(listener),$0+ )+})+}+}@@ -17457,6 +17867,248 @@ public func FfiConverterTypeComputerGrant_lower(_ value: ComputerGrant) -> RustB}+/**+ * A computer: this Mac, or one of your other computers (from the summary+ * it published).+ */+public struct ComputerResources: Equatable, Hashable {+ /**+ * `this-mac`, or the relay machine id.+ */+ public var id: String+ /**+ * Display name (empty for this Mac).+ */+ public var name: String+ /**+ * Reachable now (always true for this Mac).+ */+ public var online: Bool+ /**+ * When the computer measured this, unix ms (another computer's can be+ * minutes old).+ */+ public var sampledAtMs: UInt64+ /**+ * Processor cores.+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double+ /**+ * Memory size, bytes.+ */+ public var memoryTotal: UInt64+ /**+ * Memory in use, bytes (without reclaimable cache).+ */+ public var memoryUsed: UInt64+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ public var diskTotal: UInt64+ /**+ * Free bytes on it.+ */+ public var diskFree: UInt64+ /**+ * Extra Spaces on it.+ */+ public var spacesCount: UInt32+ /**+ * Of those, running.+ */+ public var spacesRunning: UInt32+ /**+ * Cores given to the running ones.+ */+ public var spacesCpuAllocated: UInt32+ /**+ * Memory given to the running ones, bytes.+ */+ public var spacesMemoryAllocated: UInt64+ /**+ * Memory the running guests report in use, bytes.+ */+ public var spacesMemoryUsed: UInt64+ /**+ * Bytes all its extra Spaces take on it.+ */+ public var spacesDiskBytes: UInt64+ /**+ * False when some Space's disk could only be estimated.+ */+ public var spacesDiskExact: Bool+ /**+ * The low-disk signal.+ */+ public var warning: DiskWarning++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * `this-mac`, or the relay machine id.+ */id: String,+ /**+ * Display name (empty for this Mac).+ */name: String,+ /**+ * Reachable now (always true for this Mac).+ */online: Bool,+ /**+ * When the computer measured this, unix ms (another computer's can be+ * minutes old).+ */sampledAtMs: UInt64,+ /**+ * Processor cores.+ */cpuCount: UInt32,+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double,+ /**+ * 1-minute load average.+ */loadAverage1m: Double,+ /**+ * Memory size, bytes.+ */memoryTotal: UInt64,+ /**+ * Memory in use, bytes (without reclaimable cache).+ */memoryUsed: UInt64,+ /**+ * Size of the volume that holds Spaces, bytes.+ */diskTotal: UInt64,+ /**+ * Free bytes on it.+ */diskFree: UInt64,+ /**+ * Extra Spaces on it.+ */spacesCount: UInt32,+ /**+ * Of those, running.+ */spacesRunning: UInt32,+ /**+ * Cores given to the running ones.+ */spacesCpuAllocated: UInt32,+ /**+ * Memory given to the running ones, bytes.+ */spacesMemoryAllocated: UInt64,+ /**+ * Memory the running guests report in use, bytes.+ */spacesMemoryUsed: UInt64,+ /**+ * Bytes all its extra Spaces take on it.+ */spacesDiskBytes: UInt64,+ /**+ * False when some Space's disk could only be estimated.+ */spacesDiskExact: Bool,+ /**+ * The low-disk signal.+ */warning: DiskWarning) {+ self.id = id+ self.name = name+ self.online = online+ self.sampledAtMs = sampledAtMs+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1m+ self.memoryTotal = memoryTotal+ self.memoryUsed = memoryUsed+ self.diskTotal = diskTotal+ self.diskFree = diskFree+ self.spacesCount = spacesCount+ self.spacesRunning = spacesRunning+ self.spacesCpuAllocated = spacesCpuAllocated+ self.spacesMemoryAllocated = spacesMemoryAllocated+ self.spacesMemoryUsed = spacesMemoryUsed+ self.spacesDiskBytes = spacesDiskBytes+ self.spacesDiskExact = spacesDiskExact+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension ComputerResources: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeComputerResources: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComputerResources {+ return+ try ComputerResources(+ id: FfiConverterString.read(from: &buf),+ name: FfiConverterString.read(from: &buf),+ online: FfiConverterBool.read(from: &buf),+ sampledAtMs: FfiConverterUInt64.read(from: &buf),+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),+ memoryTotal: FfiConverterUInt64.read(from: &buf),+ memoryUsed: FfiConverterUInt64.read(from: &buf),+ diskTotal: FfiConverterUInt64.read(from: &buf),+ diskFree: FfiConverterUInt64.read(from: &buf),+ spacesCount: FfiConverterUInt32.read(from: &buf),+ spacesRunning: FfiConverterUInt32.read(from: &buf),+ spacesCpuAllocated: FfiConverterUInt32.read(from: &buf),+ spacesMemoryAllocated: FfiConverterUInt64.read(from: &buf),+ spacesMemoryUsed: FfiConverterUInt64.read(from: &buf),+ spacesDiskBytes: FfiConverterUInt64.read(from: &buf),+ spacesDiskExact: FfiConverterBool.read(from: &buf),+ warning: FfiConverterTypeDiskWarning.read(from: &buf)+ )+ }++ public static func write(_ value: ComputerResources, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterString.write(value.name, into: &buf)+ FfiConverterBool.write(value.online, into: &buf)+ FfiConverterUInt64.write(value.sampledAtMs, into: &buf)+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)+ FfiConverterUInt64.write(value.memoryTotal, into: &buf)+ FfiConverterUInt64.write(value.memoryUsed, into: &buf)+ FfiConverterUInt64.write(value.diskTotal, into: &buf)+ FfiConverterUInt64.write(value.diskFree, into: &buf)+ FfiConverterUInt32.write(value.spacesCount, into: &buf)+ FfiConverterUInt32.write(value.spacesRunning, into: &buf)+ FfiConverterUInt32.write(value.spacesCpuAllocated, into: &buf)+ FfiConverterUInt64.write(value.spacesMemoryAllocated, into: &buf)+ FfiConverterUInt64.write(value.spacesMemoryUsed, into: &buf)+ FfiConverterUInt64.write(value.spacesDiskBytes, into: &buf)+ FfiConverterBool.write(value.spacesDiskExact, into: &buf)+ FfiConverterTypeDiskWarning.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeComputerResources_lift(_ buf: RustBuffer) throws -> ComputerResources {+ return try FfiConverterTypeComputerResources.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeComputerResources_lower(_ value: ComputerResources) -> RustBuffer {+ return FfiConverterTypeComputerResources.lower(value)+}++/*** One setting's effective value.*/@@ -18259,6 +18911,177 @@ public func FfiConverterTypeDevicesSnapshot_lower(_ value: DevicesSnapshot) -> R}+/**+ * What a Space costs this computer's disk, as opposed to what the guest+ * sees.+ */+public struct DiskOnHost: Equatable, Hashable {+ /**+ * Bytes only this Space holds (what deleting it frees); absent when+ * they could not be measured.+ */+ public var bytes: UInt64?+ /**+ * Blocks its files occupy, clones counted in full: an upper bound.+ */+ public var allocated: UInt64+ /**+ * Part of it is shared with other copies.+ */+ public var sharesSpace: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Bytes only this Space holds (what deleting it frees); absent when+ * they could not be measured.+ */bytes: UInt64?,+ /**+ * Blocks its files occupy, clones counted in full: an upper bound.+ */allocated: UInt64,+ /**+ * Part of it is shared with other copies.+ */sharesSpace: Bool) {+ self.bytes = bytes+ self.allocated = allocated+ self.sharesSpace = sharesSpace+ }+++++}++#if compiler(>=6)+extension DiskOnHost: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeDiskOnHost: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DiskOnHost {+ return+ try DiskOnHost(+ bytes: FfiConverterOptionUInt64.read(from: &buf),+ allocated: FfiConverterUInt64.read(from: &buf),+ sharesSpace: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: DiskOnHost, into buf: inout [UInt8]) {+ FfiConverterOptionUInt64.write(value.bytes, into: &buf)+ FfiConverterUInt64.write(value.allocated, into: &buf)+ FfiConverterBool.write(value.sharesSpace, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskOnHost_lift(_ buf: RustBuffer) throws -> DiskOnHost {+ return try FfiConverterTypeDiskOnHost.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskOnHost_lower(_ value: DiskOnHost) -> RustBuffer {+ return FfiConverterTypeDiskOnHost.lower(value)+}+++/**+ * The low-disk signal for the app and the menu bar.+ */+public struct DiskWarning: Equatable, Hashable {+ /**+ * How low it is.+ */+ public var level: DiskLevel+ /**+ * Free bytes on the volume that holds Spaces.+ */+ public var free: UInt64+ /**+ * Size of that volume.+ */+ public var total: UInt64+ /**+ * The line that was crossed (0 when `ok`).+ */+ public var threshold: UInt64++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * How low it is.+ */level: DiskLevel,+ /**+ * Free bytes on the volume that holds Spaces.+ */free: UInt64,+ /**+ * Size of that volume.+ */total: UInt64,+ /**+ * The line that was crossed (0 when `ok`).+ */threshold: UInt64) {+ self.level = level+ self.free = free+ self.total = total+ self.threshold = threshold+ }+++++}++#if compiler(>=6)+extension DiskWarning: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeDiskWarning: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DiskWarning {+ return+ try DiskWarning(+ level: FfiConverterTypeDiskLevel.read(from: &buf),+ free: FfiConverterUInt64.read(from: &buf),+ total: FfiConverterUInt64.read(from: &buf),+ threshold: FfiConverterUInt64.read(from: &buf)+ )+ }++ public static func write(_ value: DiskWarning, into buf: inout [UInt8]) {+ FfiConverterTypeDiskLevel.write(value.level, into: &buf)+ FfiConverterUInt64.write(value.free, into: &buf)+ FfiConverterUInt64.write(value.total, into: &buf)+ FfiConverterUInt64.write(value.threshold, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskWarning_lift(_ buf: RustBuffer) throws -> DiskWarning {+ return try FfiConverterTypeDiskWarning.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskWarning_lower(_ value: DiskWarning) -> RustBuffer {+ return FfiConverterTypeDiskWarning.lower(value)+}++/*** Doctor output.*/@@ -22237,6 +23060,145 @@ public func FfiConverterTypeGpuSupport_lower(_ value: GpuSupport) -> RustBuffer}+/**+ * What `SystemService.Metrics` reports from inside a Space.+ */+public struct GuestUsage: Equatable, Hashable {+ /**+ * Cores the guest sees.+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double+ /**+ * Memory in use, bytes.+ */+ public var memoryUsed: UInt64+ /**+ * Memory size, bytes.+ */+ public var memoryTotal: UInt64+ /**+ * `memory_total` is the guest's own limit.+ */+ public var memoryLimited: Bool+ /**+ * Disk in use, bytes.+ */+ public var diskUsed: UInt64+ /**+ * Disk size, bytes.+ */+ public var diskTotal: UInt64+ /**+ * `disk_total` is the guest's own disk.+ */+ public var diskLimited: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Cores the guest sees.+ */cpuCount: UInt32,+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double,+ /**+ * 1-minute load average.+ */loadAverage1m: Double,+ /**+ * Memory in use, bytes.+ */memoryUsed: UInt64,+ /**+ * Memory size, bytes.+ */memoryTotal: UInt64,+ /**+ * `memory_total` is the guest's own limit.+ */memoryLimited: Bool,+ /**+ * Disk in use, bytes.+ */diskUsed: UInt64,+ /**+ * Disk size, bytes.+ */diskTotal: UInt64,+ /**+ * `disk_total` is the guest's own disk.+ */diskLimited: Bool) {+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1m+ self.memoryUsed = memoryUsed+ self.memoryTotal = memoryTotal+ self.memoryLimited = memoryLimited+ self.diskUsed = diskUsed+ self.diskTotal = diskTotal+ self.diskLimited = diskLimited+ }+++++}++#if compiler(>=6)+extension GuestUsage: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeGuestUsage: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GuestUsage {+ return+ try GuestUsage(+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),+ memoryUsed: FfiConverterUInt64.read(from: &buf),+ memoryTotal: FfiConverterUInt64.read(from: &buf),+ memoryLimited: FfiConverterBool.read(from: &buf),+ diskUsed: FfiConverterUInt64.read(from: &buf),+ diskTotal: FfiConverterUInt64.read(from: &buf),+ diskLimited: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: GuestUsage, into buf: inout [UInt8]) {+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)+ FfiConverterUInt64.write(value.memoryUsed, into: &buf)+ FfiConverterUInt64.write(value.memoryTotal, into: &buf)+ FfiConverterBool.write(value.memoryLimited, into: &buf)+ FfiConverterUInt64.write(value.diskUsed, into: &buf)+ FfiConverterUInt64.write(value.diskTotal, into: &buf)+ FfiConverterBool.write(value.diskLimited, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeGuestUsage_lift(_ buf: RustBuffer) throws -> GuestUsage {+ return try FfiConverterTypeGuestUsage.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeGuestUsage_lower(_ value: GuestUsage) -> RustBuffer {+ return FfiConverterTypeGuestUsage.lower(value)+}++/*** What moved between the drive and a Space.*/@@ -27204,6 +28166,225 @@ public func FfiConverterTypeResolvedImage_lower(_ value: ResolvedImage) -> RustB}+/**+ * One sample of everything.+ */+public struct ResourcesSnapshot: Equatable, Hashable {+ /**+ * Grows by one per sample.+ */+ public var sequence: UInt64+ /**+ * Unix ms.+ */+ public var sampledAtMs: UInt64+ /**+ * This Mac.+ */+ public var thisMac: ComputerResources+ /**+ * Extra Spaces on this Mac.+ */+ public var spaces: [SpaceResources]+ /**+ * Your other computers, from the summaries they published.+ */+ public var computers: [ComputerResources]+ /**+ * `this_mac.warning`, for the menu bar.+ */+ public var warning: DiskWarning++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Grows by one per sample.+ */sequence: UInt64,+ /**+ * Unix ms.+ */sampledAtMs: UInt64,+ /**+ * This Mac.+ */thisMac: ComputerResources,+ /**+ * Extra Spaces on this Mac.+ */spaces: [SpaceResources],+ /**+ * Your other computers, from the summaries they published.+ */computers: [ComputerResources],+ /**+ * `this_mac.warning`, for the menu bar.+ */warning: DiskWarning) {+ self.sequence = sequence+ self.sampledAtMs = sampledAtMs+ self.thisMac = thisMac+ self.spaces = spaces+ self.computers = computers+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension ResourcesSnapshot: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeResourcesSnapshot: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourcesSnapshot {+ return+ try ResourcesSnapshot(+ sequence: FfiConverterUInt64.read(from: &buf),+ sampledAtMs: FfiConverterUInt64.read(from: &buf),+ thisMac: FfiConverterTypeComputerResources.read(from: &buf),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from: &buf),+ computers: FfiConverterSequenceTypeComputerResources.read(from: &buf),+ warning: FfiConverterTypeDiskWarning.read(from: &buf)+ )+ }++ public static func write(_ value: ResourcesSnapshot, into buf: inout [UInt8]) {+ FfiConverterUInt64.write(value.sequence, into: &buf)+ FfiConverterUInt64.write(value.sampledAtMs, into: &buf)+ FfiConverterTypeComputerResources.write(value.thisMac, into: &buf)+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into: &buf)+ FfiConverterSequenceTypeComputerResources.write(value.computers, into: &buf)+ FfiConverterTypeDiskWarning.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesSnapshot_lift(_ buf: RustBuffer) throws -> ResourcesSnapshot {+ return try FfiConverterTypeResourcesSnapshot.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesSnapshot_lower(_ value: ResourcesSnapshot) -> RustBuffer {+ return FfiConverterTypeResourcesSnapshot.lower(value)+}+++/**+ * What changed since the last event: only entries that moved by more than+ * 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+ */+public struct ResourcesUpdate: Equatable, Hashable {+ /**+ * The sample it brings you to.+ */+ public var sequence: UInt64+ /**+ * Unix ms.+ */+ public var sampledAtMs: UInt64+ /**+ * This Mac, when it changed.+ */+ public var thisMac: ComputerResources?+ /**+ * Extra Spaces that changed or appeared.+ */+ public var spaces: [SpaceResources]+ /**+ * Other computers that changed or appeared.+ */+ public var computers: [ComputerResources]+ /**+ * Ids (Spaces or computers) that are gone.+ */+ public var removed: [String]++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * The sample it brings you to.+ */sequence: UInt64,+ /**+ * Unix ms.+ */sampledAtMs: UInt64,+ /**+ * This Mac, when it changed.+ */thisMac: ComputerResources?,+ /**+ * Extra Spaces that changed or appeared.+ */spaces: [SpaceResources],+ /**+ * Other computers that changed or appeared.+ */computers: [ComputerResources],+ /**+ * Ids (Spaces or computers) that are gone.+ */removed: [String]) {+ self.sequence = sequence+ self.sampledAtMs = sampledAtMs+ self.thisMac = thisMac+ self.spaces = spaces+ self.computers = computers+ self.removed = removed+ }+++++}++#if compiler(>=6)+extension ResourcesUpdate: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeResourcesUpdate: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourcesUpdate {+ return+ try ResourcesUpdate(+ sequence: FfiConverterUInt64.read(from: &buf),+ sampledAtMs: FfiConverterUInt64.read(from: &buf),+ thisMac: FfiConverterOptionTypeComputerResources.read(from: &buf),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from: &buf),+ computers: FfiConverterSequenceTypeComputerResources.read(from: &buf),+ removed: FfiConverterSequenceString.read(from: &buf)+ )+ }++ public static func write(_ value: ResourcesUpdate, into buf: inout [UInt8]) {+ FfiConverterUInt64.write(value.sequence, into: &buf)+ FfiConverterUInt64.write(value.sampledAtMs, into: &buf)+ FfiConverterOptionTypeComputerResources.write(value.thisMac, into: &buf)+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into: &buf)+ FfiConverterSequenceTypeComputerResources.write(value.computers, into: &buf)+ FfiConverterSequenceString.write(value.removed, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesUpdate_lift(_ buf: RustBuffer) throws -> ResourcesUpdate {+ return try FfiConverterTypeResourcesUpdate.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesUpdate_lower(_ value: ResourcesUpdate) -> RustBuffer {+ return FfiConverterTypeResourcesUpdate.lower(value)+}++/*** A routine: a recurring turn of a persistent agent, fired by the daemon.*/@@ -30678,6 +31859,125 @@ public func FfiConverterTypeSpaceRelayRegistration_lower(_ value: SpaceRelayRegi}+/**+ * One extra Space on this Mac.+ */+public struct SpaceResources: Equatable, Hashable {+ /**+ * `local:<name>`.+ */+ public var id: String+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ public var powerState: String+ /**+ * Cores given to it (0: unknown).+ */+ public var cpuAllocated: UInt32+ /**+ * Memory given to it, bytes (0: unknown).+ */+ public var memoryAllocated: UInt64+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ public var diskAllocated: UInt64+ /**+ * The guest's own numbers; absent while it is off or unreachable.+ */+ public var usage: GuestUsage?+ /**+ * What it costs this Mac; absent for a container.+ */+ public var diskOnHost: DiskOnHost?++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * `local:<name>`.+ */id: String,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */powerState: String,+ /**+ * Cores given to it (0: unknown).+ */cpuAllocated: UInt32,+ /**+ * Memory given to it, bytes (0: unknown).+ */memoryAllocated: UInt64,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */diskAllocated: UInt64,+ /**+ * The guest's own numbers; absent while it is off or unreachable.+ */usage: GuestUsage?,+ /**+ * What it costs this Mac; absent for a container.+ */diskOnHost: DiskOnHost?) {+ self.id = id+ self.powerState = powerState+ self.cpuAllocated = cpuAllocated+ self.memoryAllocated = memoryAllocated+ self.diskAllocated = diskAllocated+ self.usage = usage+ self.diskOnHost = diskOnHost+ }+++++}++#if compiler(>=6)+extension SpaceResources: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeSpaceResources: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SpaceResources {+ return+ try SpaceResources(+ id: FfiConverterString.read(from: &buf),+ powerState: FfiConverterString.read(from: &buf),+ cpuAllocated: FfiConverterUInt32.read(from: &buf),+ memoryAllocated: FfiConverterUInt64.read(from: &buf),+ diskAllocated: FfiConverterUInt64.read(from: &buf),+ usage: FfiConverterOptionTypeGuestUsage.read(from: &buf),+ diskOnHost: FfiConverterOptionTypeDiskOnHost.read(from: &buf)+ )+ }++ public static func write(_ value: SpaceResources, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterString.write(value.powerState, into: &buf)+ FfiConverterUInt32.write(value.cpuAllocated, into: &buf)+ FfiConverterUInt64.write(value.memoryAllocated, into: &buf)+ FfiConverterUInt64.write(value.diskAllocated, into: &buf)+ FfiConverterOptionTypeGuestUsage.write(value.usage, into: &buf)+ FfiConverterOptionTypeDiskOnHost.write(value.diskOnHost, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeSpaceResources_lift(_ buf: RustBuffer) throws -> SpaceResources {+ return try FfiConverterTypeSpaceResources.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeSpaceResources_lower(_ value: SpaceResources) -> RustBuffer {+ return FfiConverterTypeSpaceResources.lower(value)+}++/*** Options for [`Space::send_file`].*/@@ -32028,11 +33328,23 @@ public func FfiConverterTypeSpaceTransferReport_lower(_ value: SpaceTransferRepo/**- * Memory and storage use ([`Space::usage`]). A size is the guest's own- * limit only when its `*_limited` flag says so (a VM's memory or disk, a- * container's cgroup memory limit).+ * Processor, memory and storage use ([`Space::usage`]). A size is the+ * guest's own limit only when its `*_limited` flag says so (a VM's memory+ * or disk, a container's cgroup memory limit).*/public struct SpaceUsage: Equatable, Hashable {+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double/*** Memory in use, bytes.*/@@ -32061,6 +33373,15 @@ public struct SpaceUsage: Equatable, Hashable {// Default memberwise initializers are never public by default, so we// declare one manually.public init(+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */cpuCount: UInt32 = UInt32(0),+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double = Double(0.0),+ /**+ * 1-minute load average.+ */loadAverage1m: Double = Double(0.0),/*** Memory in use, bytes.*/memoryUsed: UInt64,@@ -32079,6 +33400,9 @@ public struct SpaceUsage: Equatable, Hashable {/*** `disk_total` is the guest's own disk.*/diskLimited: Bool) {+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1mself.memoryUsed = memoryUsedself.memoryTotal = memoryTotalself.memoryLimited = memoryLimited@@ -32103,6 +33427,9 @@ public struct FfiConverterTypeSpaceUsage: FfiConverterRustBuffer {public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SpaceUsage {returntry SpaceUsage(+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),memoryUsed: FfiConverterUInt64.read(from: &buf),memoryTotal: FfiConverterUInt64.read(from: &buf),memoryLimited: FfiConverterBool.read(from: &buf),@@ -32113,6 +33440,9 @@ public struct FfiConverterTypeSpaceUsage: FfiConverterRustBuffer {}public static func write(_ value: SpaceUsage, into buf: inout [UInt8]) {+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)FfiConverterUInt64.write(value.memoryUsed, into: &buf)FfiConverterUInt64.write(value.memoryTotal, into: &buf)FfiConverterBool.write(value.memoryLimited, into: &buf)@@ -35347,6 +36677,93 @@ public func FfiConverterTypeCuaMode_lower(_ value: CuaMode) -> RustBuffer {}+// Note that we don't yet support `indirect` for enums.+// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.+/**+ * How low the free disk is.+ */++public enum DiskLevel: Equatable, Hashable {++ /**+ * Plenty.+ */+ case ok+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (the+ * line never rises above 100 GB).+ */+ case low+ /**+ * Under the floor where creating a Space already fails (5 GiB).+ */+ case critical++++++}++#if compiler(>=6)+extension DiskLevel: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeDiskLevel: FfiConverterRustBuffer {+ typealias SwiftType = DiskLevel++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DiskLevel {+ let variant: Int32 = try readInt(&buf)+ switch variant {++ case 1: return .ok++ case 2: return .low++ case 3: return .critical++ default: throw UniffiInternalError.unexpectedEnumCase+ }+ }++ public static func write(_ value: DiskLevel, into buf: inout [UInt8]) {+ switch value {+++ case .ok:+ writeInt(&buf, Int32(1))+++ case .low:+ writeInt(&buf, Int32(2))+++ case .critical:+ writeInt(&buf, Int32(3))++ }+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskLevel_lift(_ buf: RustBuffer) throws -> DiskLevel {+ return try FfiConverterTypeDiskLevel.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeDiskLevel_lower(_ value: DiskLevel) -> RustBuffer {+ return FfiConverterTypeDiskLevel.lower(value)+}++// Note that we don't yet support `indirect` for enums.// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion./**@@ -35972,6 +37389,110 @@ public func FfiConverterTypeReplayMode_lower(_ value: ReplayMode) -> RustBuffer}+// Note that we don't yet support `indirect` for enums.+// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.+/**+ * What [`Spaces::watch_resources`] reports.+ */++public enum ResourcesEvent: Equatable, Hashable {++ /**+ * Everything, at the start (and again after a reconnect).+ */+ case snapshot(+ /**+ * The sample.+ */snapshot: ResourcesSnapshot+ )+ /**+ * Only what changed.+ */+ case update(+ /**+ * The changes.+ */update: ResourcesUpdate+ )+ /**+ * The low-disk level changed (including back to `ok`).+ */+ case lowDisk(+ /**+ * The warning now.+ */warning: DiskWarning+ )++++++}++#if compiler(>=6)+extension ResourcesEvent: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeResourcesEvent: FfiConverterRustBuffer {+ typealias SwiftType = ResourcesEvent++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResourcesEvent {+ let variant: Int32 = try readInt(&buf)+ switch variant {++ case 1: return .snapshot(snapshot: try FfiConverterTypeResourcesSnapshot.read(from: &buf)+ )++ case 2: return .update(update: try FfiConverterTypeResourcesUpdate.read(from: &buf)+ )++ case 3: return .lowDisk(warning: try FfiConverterTypeDiskWarning.read(from: &buf)+ )++ default: throw UniffiInternalError.unexpectedEnumCase+ }+ }++ public static func write(_ value: ResourcesEvent, into buf: inout [UInt8]) {+ switch value {+++ case let .snapshot(snapshot):+ writeInt(&buf, Int32(1))+ FfiConverterTypeResourcesSnapshot.write(snapshot, into: &buf)+++ case let .update(update):+ writeInt(&buf, Int32(2))+ FfiConverterTypeResourcesUpdate.write(update, into: &buf)+++ case let .lowDisk(warning):+ writeInt(&buf, Int32(3))+ FfiConverterTypeDiskWarning.write(warning, into: &buf)++ }+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesEvent_lift(_ buf: RustBuffer) throws -> ResourcesEvent {+ return try FfiConverterTypeResourcesEvent.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeResourcesEvent_lower(_ value: ResourcesEvent) -> RustBuffer {+ return FfiConverterTypeResourcesEvent.lower(value)+}++// Note that we don't yet support `indirect` for enums.// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion./**@@ -36616,6 +38137,54 @@ fileprivate struct FfiConverterOptionTypeCloudOptions: FfiConverterRustBuffer {}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeComputerResources: FfiConverterRustBuffer {+ typealias SwiftType = ComputerResources?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeComputerResources.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeComputerResources.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeDiskOnHost: FfiConverterRustBuffer {+ typealias SwiftType = DiskOnHost?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeDiskOnHost.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeDiskOnHost.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -36832,6 +38401,30 @@ fileprivate struct FfiConverterOptionTypeFleetUsagePricing: FfiConverterRustBuff}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeGuestUsage: FfiConverterRustBuffer {+ typealias SwiftType = GuestUsage?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeGuestUsage.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeGuestUsage.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -37932,6 +39525,31 @@ fileprivate struct FfiConverterSequenceTypeComputerGrant: FfiConverterRustBuffer}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeComputerResources: FfiConverterRustBuffer {+ typealias SwiftType = [ComputerResources]++ public static func write(_ value: [ComputerResources], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeComputerResources.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ComputerResources] {+ let len: Int32 = try readInt(&buf)+ var seq = [ComputerResources]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeComputerResources.read(from: &buf))+ }+ return seq+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -39057,6 +40675,31 @@ fileprivate struct FfiConverterSequenceTypeSpaceInfo: FfiConverterRustBuffer {}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeSpaceResources: FfiConverterRustBuffer {+ typealias SwiftType = [SpaceResources]++ public static func write(_ value: [SpaceResources], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeSpaceResources.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [SpaceResources] {+ let len: Int32 = try readInt(&buf)+ var seq = [SpaceResources]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeSpaceResources.read(from: &buf))+ }+ return seq+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -40909,6 +42552,15 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_sdk_checksum_method_presenceview_upsert() != 29196) {return InitializationResult.apiChecksumMismatch}+ if (uniffi_cua_sdk_checksum_method_resourceslistener_on_event() != 32126) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_sdk_checksum_method_resourceswatch_set_visible() != 54652) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_sdk_checksum_method_resourceswatch_stop() != 52286) {+ return InitializationResult.apiChecksumMismatch+ }if (uniffi_cua_sdk_checksum_method_space_agent_events() != 25540) {return InitializationResult.apiChecksumMismatch}@@ -41029,7 +42681,7 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_sdk_checksum_method_space_upload() != 30524) {return InitializationResult.apiChecksumMismatch}- if (uniffi_cua_sdk_checksum_method_space_usage() != 15261) {+ if (uniffi_cua_sdk_checksum_method_space_usage() != 43925) {return InitializationResult.apiChecksumMismatch}if (uniffi_cua_sdk_checksum_method_space_websocket_headers() != 61370) {@@ -41203,6 +42855,9 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_sdk_checksum_method_spaces_resolve() != 9986) {return InitializationResult.apiChecksumMismatch}+ if (uniffi_cua_sdk_checksum_method_spaces_resources() != 12146) {+ return InitializationResult.apiChecksumMismatch+ }if (uniffi_cua_sdk_checksum_method_spaces_space() != 26355) {return InitializationResult.apiChecksumMismatch}@@ -41287,6 +42942,9 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_sdk_checksum_method_spaces_volume_write() != 64388) {return InitializationResult.apiChecksumMismatch}+ if (uniffi_cua_sdk_checksum_method_spaces_watch_resources() != 49660) {+ return InitializationResult.apiChecksumMismatch+ }if (uniffi_cua_sdk_checksum_method_teleportapprover_approve() != 36264) {return InitializationResult.apiChecksumMismatch}@@ -41473,6 +43131,7 @@ private let initializationResult: InitializationResult = {uniffiCallbackInitAudioSink()uniffiCallbackInitFrameSink()+ uniffiCallbackInitResourcesListener()uniffiCallbackInitSpaceCreateListener()uniffiCallbackInitTeleportApprover()return InitializationResult.okdiff --git a/libs/cua/swift/Sources/cua_sdkFFI/include/cua_sdkFFI.h b/libs/cua/swift/Sources/cua_sdkFFI/include/cua_sdkFFI.hindex b97b9af4b2..0c68a2535e 100644--- a/libs/cua/swift/Sources/cua_sdkFFI/include/cua_sdkFFI.h+++ b/libs/cua/swift/Sources/cua_sdkFFI/include/cua_sdkFFI.h@@ -263,6 +263,13 @@ typedef void (*UniffiCallbackInterfaceFrameSinkMethod1)(uint64_t, RustBuffer, voRustCallStatus *_Nonnull uniffiCallStatus);+#endif+#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_RESOURCES_LISTENER_METHOD0+#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_RESOURCES_LISTENER_METHOD0+typedef void (*UniffiCallbackInterfaceResourcesListenerMethod0)(uint64_t, RustBuffer, void* _Nonnull,+ RustCallStatus *_Nonnull uniffiCallStatus+ );+#endif#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SPACE_CREATE_LISTENER_METHOD0#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SPACE_CREATE_LISTENER_METHOD0@@ -296,6 +303,15 @@ typedef struct UniffiVTableCallbackInterfaceFrameSink {UniffiCallbackInterfaceFrameSinkMethod1 _Nonnull onEvent;} UniffiVTableCallbackInterfaceFrameSink;+#endif+#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_RESOURCES_LISTENER+#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_RESOURCES_LISTENER+typedef struct UniffiVTableCallbackInterfaceResourcesListener {+ UniffiCallbackInterfaceFree _Nonnull uniffiFree;+ UniffiCallbackInterfaceClone _Nonnull uniffiClone;+ UniffiCallbackInterfaceResourcesListenerMethod0 _Nonnull onEvent;+} UniffiVTableCallbackInterfaceResourcesListener;+#endif#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_SPACE_CREATE_LISTENER#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_SPACE_CREATE_LISTENER@@ -1616,6 +1632,46 @@ RustBuffer uniffi_cua_sdk_fn_method_presenceview_shape_of(uint64_t ptr, RustBuffvoid uniffi_cua_sdk_fn_method_presenceview_upsert(uint64_t ptr, RustBuffer participant, RustCallStatus *_Nonnull out_status);#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_RESOURCESLISTENER+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_RESOURCESLISTENER+uint64_t uniffi_cua_sdk_fn_clone_resourceslistener(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_FREE_RESOURCESLISTENER+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_FREE_RESOURCESLISTENER+void uniffi_cua_sdk_fn_free_resourceslistener(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_INIT_CALLBACK_VTABLE_RESOURCESLISTENER+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_INIT_CALLBACK_VTABLE_RESOURCESLISTENER+void uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(const UniffiVTableCallbackInterfaceResourcesListener* _Nonnull vtable+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESLISTENER_ON_EVENT+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESLISTENER_ON_EVENT+void uniffi_cua_sdk_fn_method_resourceslistener_on_event(uint64_t ptr, RustBuffer event, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_RESOURCESWATCH+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_RESOURCESWATCH+uint64_t uniffi_cua_sdk_fn_clone_resourceswatch(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_FREE_RESOURCESWATCH+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_FREE_RESOURCESWATCH+void uniffi_cua_sdk_fn_free_resourceswatch(uint64_t handle, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESWATCH_SET_VISIBLE+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESWATCH_SET_VISIBLE+void uniffi_cua_sdk_fn_method_resourceswatch_set_visible(uint64_t ptr, int8_t visible, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESWATCH_STOP+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_RESOURCESWATCH_STOP+void uniffi_cua_sdk_fn_method_resourceswatch_stop(uint64_t ptr, RustCallStatus *_Nonnull out_status+);+#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_SPACE#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_SPACEuint64_t uniffi_cua_sdk_fn_clone_space(uint64_t handle, RustCallStatus *_Nonnull out_status@@ -2161,6 +2217,11 @@ uint64_t uniffi_cua_sdk_fn_method_spaces_remove(uint64_t ptr, RustBuffer spaceuint64_t uniffi_cua_sdk_fn_method_spaces_resolve(uint64_t ptr, RustBuffer space);#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_RESOURCES+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_RESOURCES+uint64_t uniffi_cua_sdk_fn_method_spaces_resources(uint64_t ptr, int8_t visible+);+#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_SPACE#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_SPACEuint64_t uniffi_cua_sdk_fn_method_spaces_space(uint64_t ptr, RustBuffer space@@ -2301,6 +2362,11 @@ uint64_t uniffi_cua_sdk_fn_method_spaces_volume_unmount(uint64_t ptruint64_t uniffi_cua_sdk_fn_method_spaces_volume_write(uint64_t ptr, RustBuffer path, RustBuffer content, RustBuffer if_etag, int8_t create_only, RustBuffer view);#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_WATCH_RESOURCES+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_METHOD_SPACES_WATCH_RESOURCES+uint64_t uniffi_cua_sdk_fn_method_spaces_watch_resources(uint64_t ptr, int8_t visible, uint64_t listener, RustCallStatus *_Nonnull out_status+);+#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_TELEPORTAPPROVER#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_FN_CLONE_TELEPORTAPPROVERuint64_t uniffi_cua_sdk_fn_clone_teleportapprover(uint64_t handle, RustCallStatus *_Nonnull out_status@@ -4697,6 +4763,24 @@ uint16_t uniffi_cua_sdk_checksum_method_presenceview_shape_of(void#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_PRESENCEVIEW_UPSERTuint16_t uniffi_cua_sdk_checksum_method_presenceview_upsert(void+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESLISTENER_ON_EVENT+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESLISTENER_ON_EVENT+uint16_t uniffi_cua_sdk_checksum_method_resourceslistener_on_event(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESWATCH_SET_VISIBLE+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESWATCH_SET_VISIBLE+uint16_t uniffi_cua_sdk_checksum_method_resourceswatch_set_visible(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESWATCH_STOP+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_RESOURCESWATCH_STOP+uint16_t uniffi_cua_sdk_checksum_method_resourceswatch_stop(void+);#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACE_AGENT_EVENTS@@ -5285,6 +5369,12 @@ uint16_t uniffi_cua_sdk_checksum_method_spaces_remove(void#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_RESOLVEuint16_t uniffi_cua_sdk_checksum_method_spaces_resolve(void+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_RESOURCES+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_RESOURCES+uint16_t uniffi_cua_sdk_checksum_method_spaces_resources(void+);#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_SPACE@@ -5453,6 +5543,12 @@ uint16_t uniffi_cua_sdk_checksum_method_spaces_volume_unmount(void#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_VOLUME_WRITEuint16_t uniffi_cua_sdk_checksum_method_spaces_volume_write(void+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_WATCH_RESOURCES+#define UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_SPACES_WATCH_RESOURCES+uint16_t uniffi_cua_sdk_checksum_method_spaces_watch_resources(void+);#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SDK_CHECKSUM_METHOD_TELEPORTAPPROVER_APPROVEdiff --git a/libs/cua/typescript/src/native/cua_sdk-ffi.ts b/libs/cua/typescript/src/native/cua_sdk-ffi.tsindex a1836b6cb8..85d6215b50 100644--- a/libs/cua/typescript/src/native/cua_sdk-ffi.ts+++ b/libs/cua/typescript/src/native/cua_sdk-ffi.ts@@ -463,6 +463,26 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: true,},+ "uniffi_cua_sdk_fn_clone_resourceslistener": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_free_resourceslistener": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_clone_resourceswatch": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_free_resourceswatch": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_clone_sandbox": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -583,6 +603,11 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener": {+ args: [FfiType.Reference(FfiType.Struct("VTableCallbackInterfaceCuaSdkResourcesListener"))],+ ret: FfiType.Void,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_fn_init_callback_vtable_spacecreatelistener": {args: [FfiType.Reference(FfiType.Struct("VTableCallbackInterfaceCuaSdkSpaceCreateListener"))],ret: FfiType.Void,@@ -1673,6 +1698,21 @@ const DEFINITIONS = {ret: FfiType.RustBuffer,hasRustCallStatus: true,},+ "uniffi_cua_sdk_fn_method_resourceslistener_on_event": {+ args: [FfiType.Handle, FfiType.RustBuffer],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_method_resourceswatch_set_visible": {+ args: [FfiType.Handle, FfiType.Int8],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },+ "uniffi_cua_sdk_fn_method_resourceswatch_stop": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_method_sandbox_agents": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -2388,6 +2428,11 @@ const DEFINITIONS = {ret: FfiType.Handle,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_method_spaces_resources": {+ args: [FfiType.Handle, FfiType.Int8],+ ret: FfiType.Handle,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_fn_method_spaces_routine_add": {args: [FfiType.Handle, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer, FfiType.RustBuffer],ret: FfiType.Handle,@@ -2548,6 +2593,11 @@ const DEFINITIONS = {ret: FfiType.Handle,hasRustCallStatus: false,},+ "uniffi_cua_sdk_fn_method_spaces_watch_resources": {+ args: [FfiType.Handle, FfiType.Int8, FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: true,+ },"uniffi_cua_sdk_fn_method_spacesdclient_agents": {args: [FfiType.Handle],ret: FfiType.Handle,@@ -3903,6 +3953,21 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_resourceslistener_on_event": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_sdk_checksum_method_resourceswatch_set_visible": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },+ "uniffi_cua_sdk_checksum_method_resourceswatch_stop": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_sandbox_agents": {args: [],ret: FfiType.UInt16,@@ -4618,6 +4683,11 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_spaces_resources": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_spaces_routine_add": {args: [],ret: FfiType.UInt16,@@ -4778,6 +4848,11 @@ const DEFINITIONS = {ret: FfiType.UInt16,hasRustCallStatus: false,},+ "uniffi_cua_sdk_checksum_method_spaces_watch_resources": {+ args: [],+ ret: FfiType.UInt16,+ hasRustCallStatus: false,+ },"uniffi_cua_sdk_checksum_method_spacesdclient_agents": {args: [],ret: FfiType.UInt16,@@ -5098,6 +5173,22 @@ const DEFINITIONS = {ret: FfiType.Void,hasRustCallStatus: false,},+ "CallbackInterfaceCuaSdkResourcesListenerMethod0": {+ args: [FfiType.Handle, FfiType.RustBuffer],+ ret: FfiType.VoidPointer,+ hasRustCallStatus: true,+ outReturn: true,+ },+ "CallbackInterfaceCloneCuaSdk_ResourcesListener": {+ args: [FfiType.Handle],+ ret: FfiType.Handle,+ hasRustCallStatus: false,+ },+ "CallbackInterfaceFreeCuaSdk_ResourcesListener": {+ args: [FfiType.Handle],+ ret: FfiType.Void,+ hasRustCallStatus: false,+ },"CallbackInterfaceCuaSdkSpaceCreateListenerMethod0": {args: [FfiType.Handle, FfiType.RustBuffer],ret: FfiType.VoidPointer,@@ -5147,6 +5238,11 @@ const DEFINITIONS = {{ name: "on_frame", type: FfiType.Callback("CallbackInterfaceCuaSdkFrameSinkMethod0") },{ name: "on_event", type: FfiType.Callback("CallbackInterfaceCuaSdkFrameSinkMethod1") },],+ "VTableCallbackInterfaceCuaSdkResourcesListener": [+ { name: "uniffi_free", type: FfiType.Callback("CallbackInterfaceFreeCuaSdk_ResourcesListener") },+ { name: "uniffi_clone", type: FfiType.Callback("CallbackInterfaceCloneCuaSdk_ResourcesListener") },+ { name: "on_event", type: FfiType.Callback("CallbackInterfaceCuaSdkResourcesListenerMethod0") },+ ],"VTableCallbackInterfaceCuaSdkSpaceCreateListener": [{ name: "uniffi_free", type: FfiType.Callback("CallbackInterfaceFreeCuaSdk_SpaceCreateListener") },{ name: "uniffi_clone", type: FfiType.Callback("CallbackInterfaceCloneCuaSdk_SpaceCreateListener") },@@ -5249,6 +5345,10 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_free_presenceview(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_relay(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_free_relay(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_clone_resourceslistener(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;+ uniffi_cua_sdk_fn_free_resourceslistener(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_clone_resourceswatch(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;+ uniffi_cua_sdk_fn_free_resourceswatch(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_sandbox(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_free_sandbox(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_clone_sandboxes(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;@@ -5273,6 +5373,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_free_teleportapprover(ptr: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_init_callback_vtable_audiosink(vtable: UniffiVTableCallbackInterfaceCuaSdkAudioSink): void;uniffi_cua_sdk_fn_init_callback_vtable_framesink(vtable: UniffiVTableCallbackInterfaceCuaSdkFrameSink): void;+ uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(vtable: UniffiVTableCallbackInterfaceCuaSdkResourcesListener): void;uniffi_cua_sdk_fn_init_callback_vtable_spacecreatelistener(vtable: UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener): void;uniffi_cua_sdk_fn_init_callback_vtable_teleportapprover(vtable: UniffiVTableCallbackInterfaceCuaSdkTeleportApprover): void;uniffi_cua_sdk_fn_func_agent_event_category(kind: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;@@ -5491,6 +5592,9 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_relay_start_sharing(uniffiSelf: bigint, machineId: Uint8Array): bigint;uniffi_cua_sdk_fn_method_relay_stop_sharing(uniffiSelf: bigint, machineId: Uint8Array): bigint;uniffi_cua_sdk_fn_method_relay_url(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;+ uniffi_cua_sdk_fn_method_resourceslistener_on_event(uniffiSelf: bigint, event: Uint8Array, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_method_resourceswatch_set_visible(uniffiSelf: bigint, visible: number, uniffi_out_err: UniffiRustCallStatus): void;+ uniffi_cua_sdk_fn_method_resourceswatch_stop(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): void;uniffi_cua_sdk_fn_method_sandbox_agents(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_sandbox_delete(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_sandbox_detach(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): void;@@ -5634,6 +5738,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_spaces_relay_unregister(uniffiSelf: bigint, space: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_remove(uniffiSelf: bigint, space: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_resolve(uniffiSelf: bigint, space: Uint8Array): bigint;+ uniffi_cua_sdk_fn_method_spaces_resources(uniffiSelf: bigint, visible: number): bigint;uniffi_cua_sdk_fn_method_spaces_routine_add(uniffiSelf: bigint, agent: Uint8Array, title: Uint8Array, prompt: Uint8Array, everyMinutes: Uint8Array, dailyAt: Uint8Array, weeklyOn: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_routine_remove(uniffiSelf: bigint, id: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spaces_routine_set_enabled(uniffiSelf: bigint, id: Uint8Array, enabled: number): bigint;@@ -5666,6 +5771,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_fn_method_spaces_volume_sync_status(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spaces_volume_unmount(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spaces_volume_write(uniffiSelf: bigint, path: Uint8Array, content: Uint8Array, ifEtag: Uint8Array, createOnly: number, view: Uint8Array): bigint;+ uniffi_cua_sdk_fn_method_spaces_watch_resources(uniffiSelf: bigint, visible: number, listener: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;uniffi_cua_sdk_fn_method_spacesdclient_agents(uniffiSelf: bigint): bigint;uniffi_cua_sdk_fn_method_spacesdclient_attach(uniffiSelf: bigint, pid: Uint8Array, tag: Uint8Array, replay: Uint8Array): bigint;uniffi_cua_sdk_fn_method_spacesdclient_call_json(uniffiSelf: bigint, method: Uint8Array, requestJson: Uint8Array): bigint;@@ -5937,6 +6043,9 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_relay_start_sharing(): number;uniffi_cua_sdk_checksum_method_relay_stop_sharing(): number;uniffi_cua_sdk_checksum_method_relay_url(): number;+ uniffi_cua_sdk_checksum_method_resourceslistener_on_event(): number;+ uniffi_cua_sdk_checksum_method_resourceswatch_set_visible(): number;+ uniffi_cua_sdk_checksum_method_resourceswatch_stop(): number;uniffi_cua_sdk_checksum_method_sandbox_agents(): number;uniffi_cua_sdk_checksum_method_sandbox_delete(): number;uniffi_cua_sdk_checksum_method_sandbox_detach(): number;@@ -6080,6 +6189,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_spaces_relay_unregister(): number;uniffi_cua_sdk_checksum_method_spaces_remove(): number;uniffi_cua_sdk_checksum_method_spaces_resolve(): number;+ uniffi_cua_sdk_checksum_method_spaces_resources(): number;uniffi_cua_sdk_checksum_method_spaces_routine_add(): number;uniffi_cua_sdk_checksum_method_spaces_routine_remove(): number;uniffi_cua_sdk_checksum_method_spaces_routine_set_enabled(): number;@@ -6112,6 +6222,7 @@ interface NativeModuleInterface {uniffi_cua_sdk_checksum_method_spaces_volume_sync_status(): number;uniffi_cua_sdk_checksum_method_spaces_volume_unmount(): number;uniffi_cua_sdk_checksum_method_spaces_volume_write(): number;+ uniffi_cua_sdk_checksum_method_spaces_watch_resources(): number;uniffi_cua_sdk_checksum_method_spacesdclient_agents(): number;uniffi_cua_sdk_checksum_method_spacesdclient_attach(): number;uniffi_cua_sdk_checksum_method_spacesdclient_call_json(): number;@@ -6214,6 +6325,14 @@ export type UniffiVTableCallbackInterfaceCuaSdkFrameSink = {on_frame: UniffiCallbackInterfaceCuaSdkFrameSinkMethod0;on_event: UniffiCallbackInterfaceCuaSdkFrameSinkMethod1;};+type UniffiCallbackInterfaceCuaSdkResourcesListenerMethod0 = (uniffiHandle: bigint, event: Uint8Array) => UniffiResult<void>;+type UniffiCallbackInterfaceCloneCuaSdkResourcesListener = (handle: bigint) => UniffiResult<void>;+type UniffiCallbackInterfaceFreeCuaSdkResourcesListener = (handle: bigint) => void;+export type UniffiVTableCallbackInterfaceCuaSdkResourcesListener = {+ uniffi_free: UniffiCallbackInterfaceFreeCuaSdkResourcesListener;+ uniffi_clone: UniffiCallbackInterfaceCloneCuaSdkResourcesListener;+ on_event: UniffiCallbackInterfaceCuaSdkResourcesListenerMethod0;+};type UniffiCallbackInterfaceCuaSdkSpaceCreateListenerMethod0 = (uniffiHandle: bigint, progress: Uint8Array) => UniffiResult<void>;type UniffiCallbackInterfaceCloneCuaSdkSpaceCreateListener = (handle: bigint) => UniffiResult<void>;type UniffiCallbackInterfaceFreeCuaSdkSpaceCreateListener = (handle: bigint) => void;diff --git a/libs/cua/typescript/src/native/cua_sdk.ts b/libs/cua/typescript/src/native/cua_sdk.tsindex 408af4d41f..a8809a80c9 100644--- a/libs/cua/typescript/src/native/cua_sdk.ts+++ b/libs/cua/typescript/src/native/cua_sdk.ts@@ -4,7 +4,7 @@/* eslint-disable */// @ts-nocheckimport nativeModule from "./cua_sdk-ffi.js";-import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaSdkAudioSink, type UniffiVTableCallbackInterfaceCuaSdkFrameSink, type UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener, type UniffiVTableCallbackInterfaceCuaSdkTeleportApprover,+import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaSdkAudioSink, type UniffiVTableCallbackInterfaceCuaSdkFrameSink, type UniffiVTableCallbackInterfaceCuaSdkResourcesListener, type UniffiVTableCallbackInterfaceCuaSdkSpaceCreateListener, type UniffiVTableCallbackInterfaceCuaSdkTeleportApprover,} from "./cua_sdk-ffi.js";import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterFloat64, FfiConverterInt32, FfiConverterInt64, FfiConverterMap, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, FfiConverterUInt16, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiEnum, UniffiError, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiRustCallAsync, uniffiTraitInterfaceCall, uniffiTypeNameSymbol, variantOrdinalSymbol,} from "@ubjs/core";@@ -4048,6 +4048,290 @@ const FfiConverterTypeComputerGrant = (() => {return new FFIConverter();})();+/**+ * How low the free disk is.+ */+export enum DiskLevel {+ /**+ * Plenty.+ */+ Ok,+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (the+ * line never rises above 100 GB).+ */+ Low,+ /**+ * Under the floor where creating a Space already fails (5 GiB).+ */+ Critical+}++const FfiConverterTypeDiskLevel = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = DiskLevel;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return DiskLevel.Ok;+ case 2: return DiskLevel.Low;+ case 3: return DiskLevel.Critical;+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value) {+ case DiskLevel.Ok: return ordinalConverter.write(1, into);+ case DiskLevel.Low: return ordinalConverter.write(2, into);+ case DiskLevel.Critical: return ordinalConverter.write(3, into);+ }+ }+ allocationSize(value: TypeName): number {+ return ordinalConverter.allocationSize(0);+ }+ }+ return new FFIConverter();+})();++/**+ * The low-disk signal for the app and the menu bar.+ */+export type DiskWarning = {+ /**+ * How low it is.+ */+ level: DiskLevel,+ /**+ * Free bytes on the volume that holds Spaces.+ */+ free: bigint,+ /**+ * Size of that volume.+ */+ total: bigint,+ /**+ * The line that was crossed (0 when `ok`).+ */+ threshold: bigint+}++/**+ * Generated factory for {@link DiskWarning} record objects.+ */+export const DiskWarning = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<DiskWarning, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<DiskWarning>,+ });+})();++const FfiConverterTypeDiskWarning = (() => {+ type TypeName = DiskWarning;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ level: FfiConverterTypeDiskLevel.read(from),+ free: FfiConverterUInt64.read(from),+ total: FfiConverterUInt64.read(from),+ threshold: FfiConverterUInt64.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterTypeDiskLevel.write(value.level, into);+ FfiConverterUInt64.write(value.free, into);+ FfiConverterUInt64.write(value.total, into);+ FfiConverterUInt64.write(value.threshold, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterTypeDiskLevel.allocationSize(value.level) ++ FfiConverterUInt64.allocationSize(value.free) ++ FfiConverterUInt64.allocationSize(value.total) ++ FfiConverterUInt64.allocationSize(value.threshold);++ }+ };+ return new FFIConverter();+})();++/**+ * A computer: this Mac, or one of your other computers (from the summary+ * it published).+ */+export type ComputerResources = {+ /**+ * `this-mac`, or the relay machine id.+ */+ id: string,+ /**+ * Display name (empty for this Mac).+ */+ name: string,+ /**+ * Reachable now (always true for this Mac).+ */+ online: boolean,+ /**+ * When the computer measured this, unix ms (another computer's can be+ * minutes old).+ */+ sampledAtMs: bigint,+ /**+ * Processor cores.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * Memory in use, bytes (without reclaimable cache).+ */+ memoryUsed: bigint,+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ diskTotal: bigint,+ /**+ * Free bytes on it.+ */+ diskFree: bigint,+ /**+ * Extra Spaces on it.+ */+ spacesCount: number,+ /**+ * Of those, running.+ */+ spacesRunning: number,+ /**+ * Cores given to the running ones.+ */+ spacesCpuAllocated: number,+ /**+ * Memory given to the running ones, bytes.+ */+ spacesMemoryAllocated: bigint,+ /**+ * Memory the running guests report in use, bytes.+ */+ spacesMemoryUsed: bigint,+ /**+ * Bytes all its extra Spaces take on it.+ */+ spacesDiskBytes: bigint,+ /**+ * False when some Space's disk could only be estimated.+ */+ spacesDiskExact: boolean,+ /**+ * The low-disk signal.+ */+ warning: DiskWarning+}++/**+ * Generated factory for {@link ComputerResources} record objects.+ */+export const ComputerResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ComputerResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ComputerResources>,+ });+})();++const FfiConverterTypeComputerResources = (() => {+ type TypeName = ComputerResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ name: FfiConverterString.read(from),+ online: FfiConverterBool.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskFree: FfiConverterUInt64.read(from),+ spacesCount: FfiConverterUInt32.read(from),+ spacesRunning: FfiConverterUInt32.read(from),+ spacesCpuAllocated: FfiConverterUInt32.read(from),+ spacesMemoryAllocated: FfiConverterUInt64.read(from),+ spacesMemoryUsed: FfiConverterUInt64.read(from),+ spacesDiskBytes: FfiConverterUInt64.read(from),+ spacesDiskExact: FfiConverterBool.read(from),+ warning: FfiConverterTypeDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.name, into);+ FfiConverterBool.write(value.online, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterUInt64.write(value.diskFree, into);+ FfiConverterUInt32.write(value.spacesCount, into);+ FfiConverterUInt32.write(value.spacesRunning, into);+ FfiConverterUInt32.write(value.spacesCpuAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryAllocated, into);+ FfiConverterUInt64.write(value.spacesMemoryUsed, into);+ FfiConverterUInt64.write(value.spacesDiskBytes, into);+ FfiConverterBool.write(value.spacesDiskExact, into);+ FfiConverterTypeDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.name) ++ FfiConverterBool.allocationSize(value.online) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterUInt64.allocationSize(value.diskFree) ++ FfiConverterUInt32.allocationSize(value.spacesCount) ++ FfiConverterUInt32.allocationSize(value.spacesRunning) ++ FfiConverterUInt32.allocationSize(value.spacesCpuAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryAllocated) ++ FfiConverterUInt64.allocationSize(value.spacesMemoryUsed) ++ FfiConverterUInt64.allocationSize(value.spacesDiskBytes) ++ FfiConverterBool.allocationSize(value.spacesDiskExact) ++ FfiConverterTypeDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();+/*** One setting's effective value.*/@@ -5143,6 +5427,67 @@ const FfiConverterTypeDevicesSnapshot = (() => {return new FFIConverter();})();+/**+ * What a Space costs this computer's disk, as opposed to what the guest+ * sees.+ */+export type DiskOnHost = {+ /**+ * Bytes only this Space holds (what deleting it frees); absent when+ * they could not be measured.+ */+ bytes?: bigint,+ /**+ * Blocks its files occupy, clones counted in full: an upper bound.+ */+ allocated: bigint,+ /**+ * Part of it is shared with other copies.+ */+ sharesSpace: boolean+}++/**+ * Generated factory for {@link DiskOnHost} record objects.+ */+export const DiskOnHost = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<DiskOnHost, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<DiskOnHost>,+ });+})();++const FfiConverterTypeDiskOnHost = (() => {+ type TypeName = DiskOnHost;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ bytes: FfiConverterOptionalUInt64.read(from),+ allocated: FfiConverterUInt64.read(from),+ sharesSpace: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterOptionalUInt64.write(value.bytes, into);+ FfiConverterUInt64.write(value.allocated, into);+ FfiConverterBool.write(value.sharesSpace, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterOptionalUInt64.allocationSize(value.bytes) ++ FfiConverterUInt64.allocationSize(value.allocated) ++ FfiConverterBool.allocationSize(value.sharesSpace);++ }+ };+ return new FFIConverter();+})();+/*** Status of one local runtime component.*/@@ -8821,6 +9166,107 @@ const FfiConverterTypeGpuSupport = (() => {return new FFIConverter();})();+/**+ * What `SystemService.Metrics` reports from inside a Space.+ */+export type GuestUsage = {+ /**+ * Cores the guest sees.+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,+ /**+ * Memory in use, bytes.+ */+ memoryUsed: bigint,+ /**+ * Memory size, bytes.+ */+ memoryTotal: bigint,+ /**+ * `memory_total` is the guest's own limit.+ */+ memoryLimited: boolean,+ /**+ * Disk in use, bytes.+ */+ diskUsed: bigint,+ /**+ * Disk size, bytes.+ */+ diskTotal: bigint,+ /**+ * `disk_total` is the guest's own disk.+ */+ diskLimited: boolean+}++/**+ * Generated factory for {@link GuestUsage} record objects.+ */+export const GuestUsage = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<GuestUsage, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<GuestUsage>,+ });+})();++const FfiConverterTypeGuestUsage = (() => {+ type TypeName = GuestUsage;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),+ memoryUsed: FfiConverterUInt64.read(from),+ memoryTotal: FfiConverterUInt64.read(from),+ memoryLimited: FfiConverterBool.read(from),+ diskUsed: FfiConverterUInt64.read(from),+ diskTotal: FfiConverterUInt64.read(from),+ diskLimited: FfiConverterBool.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);+ FfiConverterUInt64.write(value.memoryUsed, into);+ FfiConverterUInt64.write(value.memoryTotal, into);+ FfiConverterBool.write(value.memoryLimited, into);+ FfiConverterUInt64.write(value.diskUsed, into);+ FfiConverterUInt64.write(value.diskTotal, into);+ FfiConverterBool.write(value.diskLimited, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) ++ FfiConverterUInt64.allocationSize(value.memoryTotal) ++ FfiConverterBool.allocationSize(value.memoryLimited) ++ FfiConverterUInt64.allocationSize(value.diskUsed) ++ FfiConverterUInt64.allocationSize(value.diskTotal) ++ FfiConverterBool.allocationSize(value.diskLimited);++ }+ };+ return new FFIConverter();+})();+/*** One access to this machine.*/@@ -12325,6 +12771,254 @@ const FfiConverterTypeResolvedImage = (() => {return new FFIConverter();})();+/**+ * One extra Space on this Mac.+ */+export type SpaceResources = {+ /**+ * `local:<name>`.+ */+ id: string,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ powerState: string,+ /**+ * Cores given to it (0: unknown).+ */+ cpuAllocated: number,+ /**+ * Memory given to it, bytes (0: unknown).+ */+ memoryAllocated: bigint,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ diskAllocated: bigint,+ /**+ * The guest's own numbers; absent while it is off or unreachable.+ */+ usage?: GuestUsage,+ /**+ * What it costs this Mac; absent for a container.+ */+ diskOnHost?: DiskOnHost+}++/**+ * Generated factory for {@link SpaceResources} record objects.+ */+export const SpaceResources = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<SpaceResources, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<SpaceResources>,+ });+})();++const FfiConverterTypeSpaceResources = (() => {+ type TypeName = SpaceResources;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ id: FfiConverterString.read(from),+ powerState: FfiConverterString.read(from),+ cpuAllocated: FfiConverterUInt32.read(from),+ memoryAllocated: FfiConverterUInt64.read(from),+ diskAllocated: FfiConverterUInt64.read(from),+ usage: FfiConverterOptionalTypeGuestUsage.read(from),+ diskOnHost: FfiConverterOptionalTypeDiskOnHost.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterString.write(value.id, into);+ FfiConverterString.write(value.powerState, into);+ FfiConverterUInt32.write(value.cpuAllocated, into);+ FfiConverterUInt64.write(value.memoryAllocated, into);+ FfiConverterUInt64.write(value.diskAllocated, into);+ FfiConverterOptionalTypeGuestUsage.write(value.usage, into);+ FfiConverterOptionalTypeDiskOnHost.write(value.diskOnHost, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterString.allocationSize(value.id) ++ FfiConverterString.allocationSize(value.powerState) ++ FfiConverterUInt32.allocationSize(value.cpuAllocated) ++ FfiConverterUInt64.allocationSize(value.memoryAllocated) ++ FfiConverterUInt64.allocationSize(value.diskAllocated) ++ FfiConverterOptionalTypeGuestUsage.allocationSize(value.usage) ++ FfiConverterOptionalTypeDiskOnHost.allocationSize(value.diskOnHost);++ }+ };+ return new FFIConverter();+})();++/**+ * One sample of everything.+ */+export type ResourcesSnapshot = {+ /**+ * Grows by one per sample.+ */+ sequence: bigint,+ /**+ * Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * This Mac.+ */+ thisMac: ComputerResources,+ /**+ * Extra Spaces on this Mac.+ */+ spaces: Array<SpaceResources>,+ /**+ * Your other computers, from the summaries they published.+ */+ computers: Array<ComputerResources>,+ /**+ * `this_mac.warning`, for the menu bar.+ */+ warning: DiskWarning+}++/**+ * Generated factory for {@link ResourcesSnapshot} record objects.+ */+export const ResourcesSnapshot = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ResourcesSnapshot, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ResourcesSnapshot>,+ });+})();++const FfiConverterTypeResourcesSnapshot = (() => {+ type TypeName = ResourcesSnapshot;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ sequence: FfiConverterUInt64.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ thisMac: FfiConverterTypeComputerResources.read(from),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from),+ computers: FfiConverterSequenceTypeComputerResources.read(from),+ warning: FfiConverterTypeDiskWarning.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt64.write(value.sequence, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterTypeComputerResources.write(value.thisMac, into);+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into);+ FfiConverterSequenceTypeComputerResources.write(value.computers, into);+ FfiConverterTypeDiskWarning.write(value.warning, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt64.allocationSize(value.sequence) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterTypeComputerResources.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.spaces) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.computers) ++ FfiConverterTypeDiskWarning.allocationSize(value.warning);++ }+ };+ return new FFIConverter();+})();++/**+ * What changed since the last event: only entries that moved by more than+ * 1 point or 256 MB. Replace entries by `id`; drop the `removed` ids.+ */+export type ResourcesUpdate = {+ /**+ * The sample it brings you to.+ */+ sequence: bigint,+ /**+ * Unix ms.+ */+ sampledAtMs: bigint,+ /**+ * This Mac, when it changed.+ */+ thisMac?: ComputerResources,+ /**+ * Extra Spaces that changed or appeared.+ */+ spaces: Array<SpaceResources>,+ /**+ * Other computers that changed or appeared.+ */+ computers: Array<ComputerResources>,+ /**+ * Ids (Spaces or computers) that are gone.+ */+ removed: Array<string>+}++/**+ * Generated factory for {@link ResourcesUpdate} record objects.+ */+export const ResourcesUpdate = (() => {+ const defaults = () => ({+ });+ const create = (() => {+ return uniffiCreateRecord<ResourcesUpdate, ReturnType<typeof defaults>>(defaults);+ })();+ return Object.freeze({+ create,+ new: create,+ defaults: () => Object.freeze(defaults()) as Partial<ResourcesUpdate>,+ });+})();++const FfiConverterTypeResourcesUpdate = (() => {+ type TypeName = ResourcesUpdate;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ return {+ sequence: FfiConverterUInt64.read(from),+ sampledAtMs: FfiConverterUInt64.read(from),+ thisMac: FfiConverterOptionalTypeComputerResources.read(from),+ spaces: FfiConverterSequenceTypeSpaceResources.read(from),+ computers: FfiConverterSequenceTypeComputerResources.read(from),+ removed: FfiConverterSequenceString.read(from)+ };+ }+ write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt64.write(value.sequence, into);+ FfiConverterUInt64.write(value.sampledAtMs, into);+ FfiConverterOptionalTypeComputerResources.write(value.thisMac, into);+ FfiConverterSequenceTypeSpaceResources.write(value.spaces, into);+ FfiConverterSequenceTypeComputerResources.write(value.computers, into);+ FfiConverterSequenceString.write(value.removed, into);+ }+ allocationSize(value: TypeName): number {+ return FfiConverterUInt64.allocationSize(value.sequence) ++ FfiConverterUInt64.allocationSize(value.sampledAtMs) ++ FfiConverterOptionalTypeComputerResources.allocationSize(value.thisMac) ++ FfiConverterSequenceTypeSpaceResources.allocationSize(value.spaces) ++ FfiConverterSequenceTypeComputerResources.allocationSize(value.computers) ++ FfiConverterSequenceString.allocationSize(value.removed);++ }+ };+ return new FFIConverter();+})();+/*** A routine: a recurring turn of a persistent agent, fired by the daemon.*/@@ -15847,11 +16541,23 @@ const FfiConverterTypeSpaceTransferReport = (() => {})();/**- * Memory and storage use ([`Space::usage`]). A size is the guest's own- * limit only when its `*_limited` flag says so (a VM's memory or disk, a- * container's cgroup memory limit).+ * Processor, memory and storage use ([`Space::usage`]). A size is the+ * guest's own limit only when its `*_limited` flag says so (a VM's memory+ * or disk, a container's cgroup memory limit).*/export type SpaceUsage = {+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ cpuCount: number,+ /**+ * Busy now, 0 to 100.+ */+ cpuPercent: number,+ /**+ * 1-minute load average.+ */+ loadAverage1m: number,/*** Memory in use, bytes.*/@@ -15883,6 +16589,9 @@ export type SpaceUsage = {*/export const SpaceUsage = (() => {const defaults = () => ({+ cpuCount: 0,+ cpuPercent: 0.0,+ loadAverage1m: 0.0,});const create = (() => {return uniffiCreateRecord<SpaceUsage, ReturnType<typeof defaults>>(defaults);@@ -15899,6 +16608,9 @@ const FfiConverterTypeSpaceUsage = (() => {class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {read(from: RustBuffer): TypeName {return {+ cpuCount: FfiConverterUInt32.read(from),+ cpuPercent: FfiConverterFloat64.read(from),+ loadAverage1m: FfiConverterFloat64.read(from),memoryUsed: FfiConverterUInt64.read(from),memoryTotal: FfiConverterUInt64.read(from),memoryLimited: FfiConverterBool.read(from),@@ -15908,6 +16620,9 @@ const FfiConverterTypeSpaceUsage = (() => {};}write(value: TypeName, into: RustBuffer): void {+ FfiConverterUInt32.write(value.cpuCount, into);+ FfiConverterFloat64.write(value.cpuPercent, into);+ FfiConverterFloat64.write(value.loadAverage1m, into);FfiConverterUInt64.write(value.memoryUsed, into);FfiConverterUInt64.write(value.memoryTotal, into);FfiConverterBool.write(value.memoryLimited, into);@@ -15916,7 +16631,10 @@ const FfiConverterTypeSpaceUsage = (() => {FfiConverterBool.write(value.diskLimited, into);}allocationSize(value: TypeName): number {- return FfiConverterUInt64.allocationSize(value.memoryUsed) ++ return FfiConverterUInt32.allocationSize(value.cpuCount) ++ FfiConverterFloat64.allocationSize(value.cpuPercent) ++ FfiConverterFloat64.allocationSize(value.loadAverage1m) ++ FfiConverterUInt64.allocationSize(value.memoryUsed) +FfiConverterUInt64.allocationSize(value.memoryTotal) +FfiConverterBool.allocationSize(value.memoryLimited) +FfiConverterUInt64.allocationSize(value.diskUsed) +@@ -19066,6 +19784,204 @@ const FfiConverterTypeReplayMode = (() => {return new FFIConverter();})();++// Enum: ResourcesEvent+export enum ResourcesEvent_Tags {+ Snapshot = "Snapshot",+ Update = "Update",+ LowDisk = "LowDisk"+}+/**+ * What [`Spaces::watch_resources`] reports.+ */+export const ResourcesEvent = (() => {++ type Snapshot__interface = {+ tag: ResourcesEvent_Tags.Snapshot;+ inner:+Readonly<{snapshot: ResourcesSnapshot}>+ };+ /**+ * Everything, at the start (and again after a reconnect).+ */+ class Snapshot_ extends UniffiEnum implements Snapshot__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.Snapshot;+ readonly inner:+Readonly<{snapshot: ResourcesSnapshot}>;+ constructor(+inner: {snapshot: ResourcesSnapshot }) {+ super("ResourcesEvent", "Snapshot");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {snapshot: ResourcesSnapshot }): Snapshot_ {+ return new Snapshot_(inner);+ }++ static instanceOf(obj: any): obj is Snapshot_ {+ return obj.tag === ResourcesEvent_Tags.Snapshot;+ }++ }++ type Update__interface = {+ tag: ResourcesEvent_Tags.Update;+ inner:+Readonly<{update: ResourcesUpdate}>+ };+ /**+ * Only what changed.+ */+ class Update_ extends UniffiEnum implements Update__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.Update;+ readonly inner:+Readonly<{update: ResourcesUpdate}>;+ constructor(+inner: {update: ResourcesUpdate }) {+ super("ResourcesEvent", "Update");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {update: ResourcesUpdate }): Update_ {+ return new Update_(inner);+ }++ static instanceOf(obj: any): obj is Update_ {+ return obj.tag === ResourcesEvent_Tags.Update;+ }++ }++ type LowDisk__interface = {+ tag: ResourcesEvent_Tags.LowDisk;+ inner:+Readonly<{warning: DiskWarning}>+ };+ /**+ * The low-disk level changed (including back to `ok`).+ */+ class LowDisk_ extends UniffiEnum implements LowDisk__interface {+ /**+ * @private+ * This field is private and should not be used, use `tag` instead.+ */+ readonly [uniffiTypeNameSymbol] = "ResourcesEvent";+ readonly tag = ResourcesEvent_Tags.LowDisk;+ readonly inner:+Readonly<{warning: DiskWarning}>;+ constructor(+inner: {warning: DiskWarning }) {+ super("ResourcesEvent", "LowDisk");++ this.inner = Object.freeze(inner);+ }+ static new(+inner: {warning: DiskWarning }): LowDisk_ {+ return new LowDisk_(inner);+ }++ static instanceOf(obj: any): obj is LowDisk_ {+ return obj.tag === ResourcesEvent_Tags.LowDisk;+ }++ }++ function instanceOf(obj: any): obj is ResourcesEvent {+ return obj[uniffiTypeNameSymbol] === "ResourcesEvent";+ }++ return Object.freeze({+ instanceOf,+ Snapshot: Snapshot_,+ Update: Update_,+ LowDisk: LowDisk_+ });++})();+/**+ * What [`Spaces::watch_resources`] reports.+ */+export type ResourcesEvent = InstanceType<+ typeof ResourcesEvent['Snapshot' | 'Update' | 'LowDisk']+>;++// FfiConverter for enum ResourcesEvent+const FfiConverterTypeResourcesEvent = (() => {+ const ordinalConverter = FfiConverterInt32;+ type TypeName = ResourcesEvent;+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {+ read(from: RustBuffer): TypeName {+ switch (ordinalConverter.read(from)) {+ case 1: return new ResourcesEvent.Snapshot({snapshot: FfiConverterTypeResourcesSnapshot.read(from) });+ case 2: return new ResourcesEvent.Update({update: FfiConverterTypeResourcesUpdate.read(from) });+ case 3: return new ResourcesEvent.LowDisk({warning: FfiConverterTypeDiskWarning.read(from) });+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ write(value: TypeName, into: RustBuffer): void {+ switch (value.tag) {+ case ResourcesEvent_Tags.Snapshot: {+ ordinalConverter.write(1, into);+ const inner = value.inner;+ FfiConverterTypeResourcesSnapshot.write(inner.snapshot, into);+ return;+ }+ case ResourcesEvent_Tags.Update: {+ ordinalConverter.write(2, into);+ const inner = value.inner;+ FfiConverterTypeResourcesUpdate.write(inner.update, into);+ return;+ }+ case ResourcesEvent_Tags.LowDisk: {+ ordinalConverter.write(3, into);+ const inner = value.inner;+ FfiConverterTypeDiskWarning.write(inner.warning, into);+ return;+ }+ default:+ // Throwing from here means that ResourcesEvent_Tags hasn't matched an ordinal.+ throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ allocationSize(value: TypeName): number {+ switch (value.tag) {+ case ResourcesEvent_Tags.Snapshot: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(1);+ size += FfiConverterTypeResourcesSnapshot.allocationSize(inner.snapshot);+ return size;+ }+ case ResourcesEvent_Tags.Update: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(2);+ size += FfiConverterTypeResourcesUpdate.allocationSize(inner.update);+ return size;+ }+ case ResourcesEvent_Tags.LowDisk: {+ const inner = value.inner;+ let size = ordinalConverter.allocationSize(3);+ size += FfiConverterTypeDiskWarning.allocationSize(inner.warning);+ return size;+ }+ default: throw new UniffiInternalError.UnexpectedEnumCase();+ }+ }+ }+ return new FFIConverter();+})();+/*** One run.*/@@ -30935,8 +31851,8 @@ export interface SpaceLike {*/upload(localPath: string, dest: string | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceTransferReport>;/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/usage(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceUsage>;/**@@ -32341,8 +33257,8 @@ private constructor(pointer: UniffiHandle) {}/**- * Memory and storage use now (cheap: poll it at a low rate while a- * detail is visible).+ * Processor, memory and storage use now (cheap: poll it at a low rate+ * while a detail is visible).*/async usage(asyncOpts_?: { signal: AbortSignal }): Promise<SpaceUsage> /*throws*/ {const __stack = uniffiIsDebug ? new Error().stack : undefined;@@ -32599,6 +33515,326 @@ const uniffiTypeSpaceObjectFactory: UniffiObjectFactory<SpaceLike> = (() => {}})();const FfiConverterTypeSpace = new FfiConverterObject(uniffiTypeSpaceObjectFactory);+/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+export interface ResourcesListener {++/**+ * Something moved.+ */+ onEvent(event: ResourcesEvent): void;+}+++/**+ * Receives [`ResourcesEvent`]s from [`Spaces::watch_resources`], in order.+ * Called on an SDK worker thread; return quickly.+ */+export class ResourcesListenerImpl extends UniffiAbstractObject implements ResourcesListener {++ readonly [uniffiTypeNameSymbol] = "ResourcesListenerImpl";+ readonly [destructorGuardSymbol]: UniffiGcObject;+ readonly [pointerLiteralSymbol]: UniffiHandle;+ // No primary constructor declared for this class.+private constructor(pointer: UniffiHandle) {+ super();+ this[pointerLiteralSymbol] = pointer;+ this[destructorGuardSymbol] = uniffiTypeResourcesListenerImplObjectFactory.bless(pointer);+}+++++/**+ * Something moved.+ */+ onEvent(event: ResourcesEvent): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceslistener_on_event(+ uniffiTypeResourcesListenerImplObjectFactory.clonePointer(this),+ FfiConverterTypeResourcesEvent.lower(event, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }+++ uniffiDestroy(): void {+ const ptr = (this as any)[destructorGuardSymbol];+ if (ptr !== undefined) {+ const pointer = uniffiTypeResourcesListenerImplObjectFactory.pointer(this);+ uniffiTypeResourcesListenerImplObjectFactory.freePointer(pointer);+ uniffiTypeResourcesListenerImplObjectFactory.unbless(ptr);+ delete (this as any)[destructorGuardSymbol];+ }+ }++ static instanceOf(obj_: any): obj_ is ResourcesListenerImpl {+ return uniffiTypeResourcesListenerImplObjectFactory.isConcreteType(obj_);+ }+++}++const uniffiTypeResourcesListenerImplObjectFactory: UniffiObjectFactory<ResourcesListener> = (() => {++ /// <reference lib="es2021" />+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {+ uniffiTypeResourcesListenerImplObjectFactory.freePointer(heldValue);+ }) : null;++ return {+ create(pointer: UniffiHandle): ResourcesListener {+ const instance = Object.create(ResourcesListenerImpl.prototype);+ instance[pointerLiteralSymbol] = pointer;+ instance[destructorGuardSymbol] = this.bless(pointer);+ instance[uniffiTypeNameSymbol] = "ResourcesListenerImpl";+ return instance;+ },+++ bless(p: UniffiHandle): UniffiGcObject {+ const ptr = {+ p, // make sure this object doesn't get optimized away.+ markDestroyed: () => undefined,+ };+ if (registry) {+ registry.register(ptr, p, ptr);+ }+ return ptr;+ },++ unbless(ptr_: UniffiGcObject) {+ if (registry) {+ registry.unregister(ptr_);+ }+ },++ pointer(obj_: ResourcesListener): UniffiHandle {+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {+ throw new UniffiInternalError.UnexpectedNullPointer();+ }+ return (obj_ as any)[pointerLiteralSymbol];+ },++ clonePointer(obj_: ResourcesListener): UniffiHandle {+ const pointer = this.pointer(obj_);+ return uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_clone_resourceslistener(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ freePointer(pointer: UniffiHandle): void {+ uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_free_resourceslistener(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ isConcreteType(obj_: any): obj_ is ResourcesListener {+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ResourcesListenerImpl";+ },+}})();+const FfiConverterTypeResourcesListener = new FfiConverterObjectWithCallbacks(uniffiTypeResourcesListenerImplObjectFactory);++// Add a vtable for the callbacks that go in ResourcesListener.++// Put the implementation in a struct so we don't pollute the top-level namespace+const uniffiCallbackInterfaceResourcesListener: { vtable: any; register: () => void; } = {+ // Create the VTable using a series of closures.+ // ts automatically converts these into C callback functions.+ vtable: {+ on_event: (+ uniffiHandle: bigint,+ event: Uint8Array,) => {+ const uniffiMakeCall =+ ()+ : void => {+ const jsCallback = FfiConverterTypeResourcesListener.lift(uniffiHandle);+ return jsCallback.onEvent(+ FfiConverterTypeResourcesEvent.lift(event)+ )+ };+ const uniffiResult = UniffiResult.ready<void>();+ const uniffiHandleSuccess = (obj: any) => {};+ const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {+ UniffiResult.writeError(uniffiResult, code, errBuf);+ };+ uniffiTraitInterfaceCall(+ /*makeCall:*/ uniffiMakeCall,+ /*handleSuccess:*/ uniffiHandleSuccess,+ /*handleError:*/ uniffiHandleError,+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),+ /*alloc:*/ nativeModule().rustbuffer_alloc,+ )+ return uniffiResult;+ },+ uniffi_free: (uniffiHandle: UniffiHandle): void => {+ // this will throw a stale handle error if the handle isn't found.+ FfiConverterTypeResourcesListener.drop(uniffiHandle);+ },+ uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {+ return FfiConverterTypeResourcesListener.clone(uniffiHandle);+ }+ },+ register: () => {nativeModule().uniffi_cua_sdk_fn_init_callback_vtable_resourceslistener(+ uniffiCallbackInterfaceResourcesListener.vtable+ );+ },+};++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+export interface ResourcesWatchLike {++/**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ setVisible(visible: boolean): void;+/**+ * Ends the watch. No event is delivered after this returns.+ */+ stop(): void;+}+/**+ * @deprecated Use `ResourcesWatchLike` instead.+ */+export type ResourcesWatchInterface = ResourcesWatchLike;+++/**+ * A running [`Spaces::watch_resources`]: tell it whether a window shows+ * the numbers, and stop it when done. Dropping it also stops it.+ */+export class ResourcesWatch extends UniffiAbstractObject implements ResourcesWatchLike {++ readonly [uniffiTypeNameSymbol] = "ResourcesWatch";+ readonly [destructorGuardSymbol]: UniffiGcObject;+ readonly [pointerLiteralSymbol]: UniffiHandle;+ // No primary constructor declared for this class.+private constructor(pointer: UniffiHandle) {+ super();+ this[pointerLiteralSymbol] = pointer;+ this[destructorGuardSymbol] = uniffiTypeResourcesWatchObjectFactory.bless(pointer);+}+++++/**+ * Whether a window shows the numbers: visible watchers are sampled+ * every 10 seconds, hidden ones every 5 minutes (and still hear+ * `LowDisk`, for the menu bar).+ */+ setVisible(visible: boolean): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceswatch_set_visible(+ uniffiTypeResourcesWatchObjectFactory.clonePointer(this),+ FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }++/**+ * Ends the watch. No event is delivered after this returns.+ */+ stop(): void {uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => { nativeModule().uniffi_cua_sdk_fn_method_resourceswatch_stop(+ uniffiTypeResourcesWatchObjectFactory.clonePointer(this),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ );+ }+++ uniffiDestroy(): void {+ const ptr = (this as any)[destructorGuardSymbol];+ if (ptr !== undefined) {+ const pointer = uniffiTypeResourcesWatchObjectFactory.pointer(this);+ uniffiTypeResourcesWatchObjectFactory.freePointer(pointer);+ uniffiTypeResourcesWatchObjectFactory.unbless(ptr);+ delete (this as any)[destructorGuardSymbol];+ }+ }++ static instanceOf(obj_: any): obj_ is ResourcesWatch {+ return uniffiTypeResourcesWatchObjectFactory.isConcreteType(obj_);+ }+++}++const uniffiTypeResourcesWatchObjectFactory: UniffiObjectFactory<ResourcesWatchLike> = (() => {++ /// <reference lib="es2021" />+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {+ uniffiTypeResourcesWatchObjectFactory.freePointer(heldValue);+ }) : null;++ return {+ create(pointer: UniffiHandle): ResourcesWatchLike {+ const instance = Object.create(ResourcesWatch.prototype);+ instance[pointerLiteralSymbol] = pointer;+ instance[destructorGuardSymbol] = this.bless(pointer);+ instance[uniffiTypeNameSymbol] = "ResourcesWatch";+ return instance;+ },+++ bless(p: UniffiHandle): UniffiGcObject {+ const ptr = {+ p, // make sure this object doesn't get optimized away.+ markDestroyed: () => undefined,+ };+ if (registry) {+ registry.register(ptr, p, ptr);+ }+ return ptr;+ },++ unbless(ptr_: UniffiGcObject) {+ if (registry) {+ registry.unregister(ptr_);+ }+ },++ pointer(obj_: ResourcesWatchLike): UniffiHandle {+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {+ throw new UniffiInternalError.UnexpectedNullPointer();+ }+ return (obj_ as any)[pointerLiteralSymbol];+ },++ clonePointer(obj_: ResourcesWatchLike): UniffiHandle {+ const pointer = this.pointer(obj_);+ return uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_clone_resourceswatch(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ freePointer(pointer: UniffiHandle): void {+ uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => nativeModule().uniffi_cua_sdk_fn_free_resourceswatch(pointer, callStatus),+ /*liftString:*/ FfiConverterString.lift+ );+ },++ isConcreteType(obj_: any): obj_ is ResourcesWatchLike {+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ResourcesWatch";+ },+}})();+const FfiConverterTypeResourcesWatch = new FfiConverterObject(uniffiTypeResourcesWatchObjectFactory);+/*** The Spaces registry: add a machine by URL, provision a local one, and get* [`Space`] handles.@@ -32785,6 +34021,15 @@ export interface SpacesLike {* Resolves an id, legacy id, URL or display name.*/resolve(space: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SpaceInfo>;+/**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ resources(visible: boolean, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ResourcesSnapshot>;/*** Adds a routine. Give exactly one of `every_minutes`, `daily_at`* (`HH:MM`) or `weekly_on` (`mon 09:00`).@@ -32925,6 +34170,14 @@ export interface SpacesLike {* compare-and-swap, `create_only` makes it create-only.*/volumeWrite(path: string, content: ArrayBuffer, ifEtag: string | undefined, createOnly: boolean, view: DriveView | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<DriveObject>;+/**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ watchResources(visible: boolean, listener: ResourcesListener): ResourcesWatchLike;}/*** @deprecated Use `SpacesLike` instead.@@ -34180,6 +35433,46 @@ private constructor(pointer: UniffiHandle) {}}+/**+ * What this Mac, its extra Spaces and your other computers use now:+ * processor, memory and disk, as one snapshot (a few seconds old at+ * most). With `visible`, the call also says a window shows the numbers+ * for the next 30 seconds, so the runtime samples every 10 seconds+ * instead of every 5 minutes: call it every 10 seconds while a window+ * is visible and stop when it is hidden.+ */+ async resources(visible: boolean, asyncOpts_?: { signal: AbortSignal }): Promise<ResourcesSnapshot> /*throws*/ {+ const __stack = uniffiIsDebug ? new Error().stack : undefined;+ try {+ return await uniffiRustCallAsync(+ /*rustCaller:*/ uniffiCaller,+ /*rustFutureFunc:*/ () => {+ return nativeModule().uniffi_cua_sdk_fn_method_spaces_resources(+ uniffiTypeSpacesObjectFactory.clonePointer(this),FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc)+ );+ },+ /*pollFunc:*/ nativeModule().ffi_cua_sdk_rust_future_poll_rust_buffer,+ /*cancelFunc:*/ nativeModule().ffi_cua_sdk_rust_future_cancel_rust_buffer,+ /*completeFunc:*/ nativeModule().ffi_cua_sdk_rust_future_complete_rust_buffer,+ /*freeFunc:*/ nativeModule().ffi_cua_sdk_rust_future_free_rust_buffer,+ // Async returns always go through the JS-side converter: the+ // FFI symbol returns the future handle (u64), and the user-level+ // RustBuffer comes back via the shared `rust_future_complete_*`+ // export. The bytes the runtime hands back must be deserialized+ // here using the per-callable return-type converter.+ /*liftFunc:*/ FfiConverterTypeResourcesSnapshot.lift.bind(FfiConverterTypeResourcesSnapshot),+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ /*asyncOpts:*/ asyncOpts_,+ /*errorHandler:*/ FfiConverterTypeCuaError.lift.bind(FfiConverterTypeCuaError)+ );+ } catch (__error: any) {+ if (uniffiIsDebug && __error instanceof Error) {+ __error.stack = __stack;+ }+ throw __error;+ }+ }+/*** Adds a routine. Give exactly one of `every_minutes`, `daily_at`* (`HH:MM`) or `weekly_on` (`mon 09:00`).@@ -35292,6 +36585,26 @@ private constructor(pointer: UniffiHandle) {}}+/**+ * The same numbers as events for `listener`: a snapshot first, then an+ * update with only the entries that changed by more than 1 point or+ * 256 MB, and `LowDisk` whenever the warning level changes. Reopens by+ * itself if the daemon restarts (the snapshot comes again). Stop it+ * with [`ResourcesWatch::stop`].+ */+ watchResources(visible: boolean, listener: ResourcesListener): ResourcesWatchLike {+ return FfiConverterTypeResourcesWatch.lift(uniffiCaller.rustCall(+ /*caller:*/ (callStatus) => {+ return nativeModule().uniffi_cua_sdk_fn_method_spaces_watch_resources(+ uniffiTypeSpacesObjectFactory.clonePointer(this),+ FfiConverterBool.lower(visible, nativeModule().rustbuffer_alloc),+ FfiConverterTypeResourcesListener.lower(listener, nativeModule().rustbuffer_alloc),+ callStatus);+ },+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),+ ));+ }+uniffiDestroy(): void {const ptr = (this as any)[destructorGuardSymbol];@@ -36768,6 +38081,21 @@ const FfiConverterOptionalTypePresenceCursor = new FfiConverterOptional(FfiConve// FfiConverter for ExitInfo | undefinedconst FfiConverterOptionalTypeExitInfo = new FfiConverterOptional(FfiConverterTypeExitInfo);+// FfiConverter for GuestUsage | undefined+const FfiConverterOptionalTypeGuestUsage = new FfiConverterOptional(FfiConverterTypeGuestUsage);++// FfiConverter for DiskOnHost | undefined+const FfiConverterOptionalTypeDiskOnHost = new FfiConverterOptional(FfiConverterTypeDiskOnHost);++// FfiConverter for Array<SpaceResources>+const FfiConverterSequenceTypeSpaceResources = new FfiConverterArray(FfiConverterTypeSpaceResources);++// FfiConverter for Array<ComputerResources>+const FfiConverterSequenceTypeComputerResources = new FfiConverterArray(FfiConverterTypeComputerResources);++// FfiConverter for ComputerResources | undefined+const FfiConverterOptionalTypeComputerResources = new FfiConverterOptional(FfiConverterTypeComputerResources);+// FfiConverter for Array<ReadinessProbe>const FfiConverterSequenceTypeReadinessProbe = new FfiConverterArray(FfiConverterTypeReadinessProbe);@@ -37648,6 +38976,15 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_relay_url() !== 31201) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_relay_url");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceslistener_on_event() !== 32126) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceslistener_on_event");+ }+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceswatch_set_visible() !== 54652) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceswatch_set_visible");+ }+ if (nativeModule().uniffi_cua_sdk_checksum_method_resourceswatch_stop() !== 52286) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_resourceswatch_stop");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_sandbox_agents() !== 53699) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_sandbox_agents");}@@ -37915,7 +39252,7 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_space_upload() !== 30524) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_upload");}- if (nativeModule().uniffi_cua_sdk_checksum_method_space_usage() !== 15261) {+ if (nativeModule().uniffi_cua_sdk_checksum_method_space_usage() !== 43925) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_space_usage");}if (nativeModule().uniffi_cua_sdk_checksum_method_space_websocket_headers() !== 61370) {@@ -38077,6 +39414,9 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_resolve() !== 9986) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_resolve");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_resources() !== 12146) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_resources");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_routine_add() !== 27220) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_routine_add");}@@ -38173,6 +39513,9 @@ function uniffiEnsureInitialized() {if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_volume_write() !== 64388) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_volume_write");}+ if (nativeModule().uniffi_cua_sdk_checksum_method_spaces_watch_resources() !== 49660) {+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spaces_watch_resources");+ }if (nativeModule().uniffi_cua_sdk_checksum_method_spacesdclient_agents() !== 39176) {throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_sdk_checksum_method_spacesdclient_agents");}@@ -38340,6 +39683,7 @@ function uniffiEnsureInitialized() {uniffiCallbackInterfaceFrameSink.register();uniffiCallbackInterfaceSpaceCreateListener.register();uniffiCallbackInterfaceTeleportApprover.register();+ uniffiCallbackInterfaceResourcesListener.register();}export default Object.freeze({@@ -38390,6 +39734,7 @@ export default Object.freeze({FfiConverterTypeCloudTarget,FfiConverterTypeCloudTestReport,FfiConverterTypeComputerGrant,+ FfiConverterTypeComputerResources,FfiConverterTypeConfigEntry,FfiConverterTypeContainer,FfiConverterTypeCua,@@ -38401,6 +39746,9 @@ export default Object.freeze({FfiConverterTypeDeviceEnrollment,FfiConverterTypeDevices,FfiConverterTypeDevicesSnapshot,+ FfiConverterTypeDiskLevel,+ FfiConverterTypeDiskOnHost,+ FfiConverterTypeDiskWarning,FfiConverterTypeDoctorReport,FfiConverterTypeDriveAccessRequest,FfiConverterTypeDriveAudit,@@ -38449,6 +39797,7 @@ export default Object.freeze({FfiConverterTypeGpuOption,FfiConverterTypeGpuSupport,FfiConverterTypeGuestDisplay,+ FfiConverterTypeGuestUsage,FfiConverterTypeHomeTransfer,FfiConverterTypeHost,FfiConverterTypeHostAccessRecord,@@ -38508,6 +39857,11 @@ export default Object.freeze({FfiConverterTypeRelayMachine,FfiConverterTypeReplayMode,FfiConverterTypeResolvedImage,+ FfiConverterTypeResourcesEvent,+ FfiConverterTypeResourcesListener,+ FfiConverterTypeResourcesSnapshot,+ FfiConverterTypeResourcesUpdate,+ FfiConverterTypeResourcesWatch,FfiConverterTypeRoutineInfo,FfiConverterTypeRuntimeCheck,FfiConverterTypeRuntimeCheckStatus,@@ -38543,6 +39897,7 @@ export default Object.freeze({FfiConverterTypeSpacePowerReport,FfiConverterTypeSpacePresence,FfiConverterTypeSpaceRelayRegistration,+ FfiConverterTypeSpaceResources,FfiConverterTypeSpaceSendFileOptions,FfiConverterTypeSpaceSendFileReport,FfiConverterTypeSpaceSentFile,diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swiftindex 2e2398f92a..21a4c089aa 100644--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift@@ -8504,6 +8504,360 @@ public func FfiConverterTypeAppComputerGrantInput_lower(_ value: AppComputerGran}+public struct AppComputerResources: Equatable, Hashable {+ /**+ * `this-mac`, or the relay machine id.+ */+ public var id: String+ /**+ * Display name (empty for this Mac).+ */+ public var name: String+ /**+ * Reachable now.+ */+ public var online: Bool+ /**+ * When the computer measured this, Unix ms.+ */+ public var sampledAtMs: UInt64+ /**+ * Processor cores.+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double+ /**+ * Memory size, bytes.+ */+ public var memoryTotal: UInt64+ /**+ * Memory in use, bytes.+ */+ public var memoryUsed: UInt64+ /**+ * Size of the volume that holds Spaces, bytes.+ */+ public var diskTotal: UInt64+ /**+ * Free bytes on it.+ */+ public var diskFree: UInt64+ /**+ * Extra Spaces on it.+ */+ public var spacesCount: UInt32+ /**+ * Of those, running.+ */+ public var spacesRunning: UInt32+ /**+ * Cores given to the running ones.+ */+ public var spacesCpuAllocated: UInt32+ /**+ * Memory given to the running ones, bytes.+ */+ public var spacesMemoryAllocated: UInt64+ /**+ * Memory the running guests report in use, bytes.+ */+ public var spacesMemoryUsed: UInt64+ /**+ * Bytes all its extra Spaces take on it.+ */+ public var spacesDiskBytes: UInt64+ /**+ * False when some Space's disk could only be estimated.+ */+ public var spacesDiskExact: Bool+ /**+ * The low-disk signal.+ */+ public var warning: AppDiskWarning++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * `this-mac`, or the relay machine id.+ */id: String,+ /**+ * Display name (empty for this Mac).+ */name: String,+ /**+ * Reachable now.+ */online: Bool,+ /**+ * When the computer measured this, Unix ms.+ */sampledAtMs: UInt64,+ /**+ * Processor cores.+ */cpuCount: UInt32,+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double,+ /**+ * 1-minute load average.+ */loadAverage1m: Double,+ /**+ * Memory size, bytes.+ */memoryTotal: UInt64,+ /**+ * Memory in use, bytes.+ */memoryUsed: UInt64,+ /**+ * Size of the volume that holds Spaces, bytes.+ */diskTotal: UInt64,+ /**+ * Free bytes on it.+ */diskFree: UInt64,+ /**+ * Extra Spaces on it.+ */spacesCount: UInt32,+ /**+ * Of those, running.+ */spacesRunning: UInt32,+ /**+ * Cores given to the running ones.+ */spacesCpuAllocated: UInt32,+ /**+ * Memory given to the running ones, bytes.+ */spacesMemoryAllocated: UInt64,+ /**+ * Memory the running guests report in use, bytes.+ */spacesMemoryUsed: UInt64,+ /**+ * Bytes all its extra Spaces take on it.+ */spacesDiskBytes: UInt64,+ /**+ * False when some Space's disk could only be estimated.+ */spacesDiskExact: Bool,+ /**+ * The low-disk signal.+ */warning: AppDiskWarning) {+ self.id = id+ self.name = name+ self.online = online+ self.sampledAtMs = sampledAtMs+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1m+ self.memoryTotal = memoryTotal+ self.memoryUsed = memoryUsed+ self.diskTotal = diskTotal+ self.diskFree = diskFree+ self.spacesCount = spacesCount+ self.spacesRunning = spacesRunning+ self.spacesCpuAllocated = spacesCpuAllocated+ self.spacesMemoryAllocated = spacesMemoryAllocated+ self.spacesMemoryUsed = spacesMemoryUsed+ self.spacesDiskBytes = spacesDiskBytes+ self.spacesDiskExact = spacesDiskExact+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension AppComputerResources: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppComputerResources: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppComputerResources {+ return+ try AppComputerResources(+ id: FfiConverterString.read(from: &buf),+ name: FfiConverterString.read(from: &buf),+ online: FfiConverterBool.read(from: &buf),+ sampledAtMs: FfiConverterUInt64.read(from: &buf),+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),+ memoryTotal: FfiConverterUInt64.read(from: &buf),+ memoryUsed: FfiConverterUInt64.read(from: &buf),+ diskTotal: FfiConverterUInt64.read(from: &buf),+ diskFree: FfiConverterUInt64.read(from: &buf),+ spacesCount: FfiConverterUInt32.read(from: &buf),+ spacesRunning: FfiConverterUInt32.read(from: &buf),+ spacesCpuAllocated: FfiConverterUInt32.read(from: &buf),+ spacesMemoryAllocated: FfiConverterUInt64.read(from: &buf),+ spacesMemoryUsed: FfiConverterUInt64.read(from: &buf),+ spacesDiskBytes: FfiConverterUInt64.read(from: &buf),+ spacesDiskExact: FfiConverterBool.read(from: &buf),+ warning: FfiConverterTypeAppDiskWarning.read(from: &buf)+ )+ }++ public static func write(_ value: AppComputerResources, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterString.write(value.name, into: &buf)+ FfiConverterBool.write(value.online, into: &buf)+ FfiConverterUInt64.write(value.sampledAtMs, into: &buf)+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)+ FfiConverterUInt64.write(value.memoryTotal, into: &buf)+ FfiConverterUInt64.write(value.memoryUsed, into: &buf)+ FfiConverterUInt64.write(value.diskTotal, into: &buf)+ FfiConverterUInt64.write(value.diskFree, into: &buf)+ FfiConverterUInt32.write(value.spacesCount, into: &buf)+ FfiConverterUInt32.write(value.spacesRunning, into: &buf)+ FfiConverterUInt32.write(value.spacesCpuAllocated, into: &buf)+ FfiConverterUInt64.write(value.spacesMemoryAllocated, into: &buf)+ FfiConverterUInt64.write(value.spacesMemoryUsed, into: &buf)+ FfiConverterUInt64.write(value.spacesDiskBytes, into: &buf)+ FfiConverterBool.write(value.spacesDiskExact, into: &buf)+ FfiConverterTypeAppDiskWarning.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppComputerResources_lift(_ buf: RustBuffer) throws -> AppComputerResources {+ return try FfiConverterTypeAppComputerResources.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppComputerResources_lower(_ value: AppComputerResources) -> RustBuffer {+ return FfiConverterTypeAppComputerResources.lower(value)+}+++public struct AppComputerView: Equatable, Hashable {+ /**+ * The computer's id.+ */+ public var id: String+ /**+ * Its name.+ */+ public var name: String+ /**+ * Reachable now.+ */+ public var online: Bool+ /**+ * "Offline, as of 5 min ago" or "Updated 2 min ago"; none when the+ * numbers are a moment old.+ */+ public var age: String?+ /**+ * Processor, Memory, Space for files.+ */+ public var rows: [AppResourceRow]+ /**+ * "Its extra Spaces use: ..." (see [`ThisMacView::extra_spaces`]).+ */+ public var extraSpaces: String?+ /**+ * The warning, when its disk is low.+ */+ public var warning: AppWarningView?++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * The computer's id.+ */id: String,+ /**+ * Its name.+ */name: String,+ /**+ * Reachable now.+ */online: Bool,+ /**+ * "Offline, as of 5 min ago" or "Updated 2 min ago"; none when the+ * numbers are a moment old.+ */age: String?,+ /**+ * Processor, Memory, Space for files.+ */rows: [AppResourceRow],+ /**+ * "Its extra Spaces use: ..." (see [`ThisMacView::extra_spaces`]).+ */extraSpaces: String?,+ /**+ * The warning, when its disk is low.+ */warning: AppWarningView?) {+ self.id = id+ self.name = name+ self.online = online+ self.age = age+ self.rows = rows+ self.extraSpaces = extraSpaces+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension AppComputerView: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppComputerView: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppComputerView {+ return+ try AppComputerView(+ id: FfiConverterString.read(from: &buf),+ name: FfiConverterString.read(from: &buf),+ online: FfiConverterBool.read(from: &buf),+ age: FfiConverterOptionString.read(from: &buf),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from: &buf),+ extraSpaces: FfiConverterOptionString.read(from: &buf),+ warning: FfiConverterOptionTypeAppWarningView.read(from: &buf)+ )+ }++ public static func write(_ value: AppComputerView, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterString.write(value.name, into: &buf)+ FfiConverterBool.write(value.online, into: &buf)+ FfiConverterOptionString.write(value.age, into: &buf)+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into: &buf)+ FfiConverterOptionString.write(value.extraSpaces, into: &buf)+ FfiConverterOptionTypeAppWarningView.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppComputerView_lift(_ buf: RustBuffer) throws -> AppComputerView {+ return try FfiConverterTypeAppComputerView.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppComputerView_lower(_ value: AppComputerView) -> RustBuffer {+ return FfiConverterTypeAppComputerView.lower(value)+}++public struct AppConflictView: Equatable, Hashable {/*** The file (what Resolve sends).@@ -11018,6 +11372,168 @@ public func FfiConverterTypeAppDevicesView_lower(_ value: AppDevicesView) -> Rus}+public struct AppDiskOnHost: Equatable, Hashable {+ /**+ * Bytes only this Space holds; none when they could not be measured.+ */+ public var bytes: UInt64?+ /**+ * Blocks its files occupy, clones counted in full.+ */+ public var allocated: UInt64+ /**+ * Part of it is shared with other copies.+ */+ public var sharesSpace: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Bytes only this Space holds; none when they could not be measured.+ */bytes: UInt64?,+ /**+ * Blocks its files occupy, clones counted in full.+ */allocated: UInt64,+ /**+ * Part of it is shared with other copies.+ */sharesSpace: Bool) {+ self.bytes = bytes+ self.allocated = allocated+ self.sharesSpace = sharesSpace+ }+++++}++#if compiler(>=6)+extension AppDiskOnHost: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppDiskOnHost: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppDiskOnHost {+ return+ try AppDiskOnHost(+ bytes: FfiConverterOptionUInt64.read(from: &buf),+ allocated: FfiConverterUInt64.read(from: &buf),+ sharesSpace: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: AppDiskOnHost, into buf: inout [UInt8]) {+ FfiConverterOptionUInt64.write(value.bytes, into: &buf)+ FfiConverterUInt64.write(value.allocated, into: &buf)+ FfiConverterBool.write(value.sharesSpace, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskOnHost_lift(_ buf: RustBuffer) throws -> AppDiskOnHost {+ return try FfiConverterTypeAppDiskOnHost.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskOnHost_lower(_ value: AppDiskOnHost) -> RustBuffer {+ return FfiConverterTypeAppDiskOnHost.lower(value)+}+++public struct AppDiskWarning: Equatable, Hashable {+ /**+ * How low it is.+ */+ public var level: AppDiskLevel+ /**+ * Free bytes on the volume that holds Spaces.+ */+ public var free: UInt64+ /**+ * Size of that volume.+ */+ public var total: UInt64+ /**+ * The line that was crossed (0 when ok).+ */+ public var threshold: UInt64++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * How low it is.+ */level: AppDiskLevel,+ /**+ * Free bytes on the volume that holds Spaces.+ */free: UInt64,+ /**+ * Size of that volume.+ */total: UInt64,+ /**+ * The line that was crossed (0 when ok).+ */threshold: UInt64) {+ self.level = level+ self.free = free+ self.total = total+ self.threshold = threshold+ }+++++}++#if compiler(>=6)+extension AppDiskWarning: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppDiskWarning: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppDiskWarning {+ return+ try AppDiskWarning(+ level: FfiConverterTypeAppDiskLevel.read(from: &buf),+ free: FfiConverterUInt64.read(from: &buf),+ total: FfiConverterUInt64.read(from: &buf),+ threshold: FfiConverterUInt64.read(from: &buf)+ )+ }++ public static func write(_ value: AppDiskWarning, into buf: inout [UInt8]) {+ FfiConverterTypeAppDiskLevel.write(value.level, into: &buf)+ FfiConverterUInt64.write(value.free, into: &buf)+ FfiConverterUInt64.write(value.total, into: &buf)+ FfiConverterUInt64.write(value.threshold, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskWarning_lift(_ buf: RustBuffer) throws -> AppDiskWarning {+ return try FfiConverterTypeAppDiskWarning.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskWarning_lower(_ value: AppDiskWarning) -> RustBuffer {+ return FfiConverterTypeAppDiskWarning.lower(value)+}++public struct AppDragDisplay: Equatable, Hashable {/*** The display.@@ -14640,6 +15156,142 @@ public func FfiConverterTypeAppGpuRow_lower(_ value: AppGpuRow) -> RustBuffer {}+public struct AppGuestUsage: Equatable, Hashable {+ /**+ * Cores the guest sees.+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double+ /**+ * Memory in use, bytes.+ */+ public var memoryUsed: UInt64+ /**+ * Memory size, bytes.+ */+ public var memoryTotal: UInt64+ /**+ * `memory_total` is the guest's own limit.+ */+ public var memoryLimited: Bool+ /**+ * Disk in use, bytes.+ */+ public var diskUsed: UInt64+ /**+ * Disk size, bytes.+ */+ public var diskTotal: UInt64+ /**+ * `disk_total` is the guest's own disk.+ */+ public var diskLimited: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Cores the guest sees.+ */cpuCount: UInt32,+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double,+ /**+ * 1-minute load average.+ */loadAverage1m: Double,+ /**+ * Memory in use, bytes.+ */memoryUsed: UInt64,+ /**+ * Memory size, bytes.+ */memoryTotal: UInt64,+ /**+ * `memory_total` is the guest's own limit.+ */memoryLimited: Bool,+ /**+ * Disk in use, bytes.+ */diskUsed: UInt64,+ /**+ * Disk size, bytes.+ */diskTotal: UInt64,+ /**+ * `disk_total` is the guest's own disk.+ */diskLimited: Bool) {+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1m+ self.memoryUsed = memoryUsed+ self.memoryTotal = memoryTotal+ self.memoryLimited = memoryLimited+ self.diskUsed = diskUsed+ self.diskTotal = diskTotal+ self.diskLimited = diskLimited+ }+++++}++#if compiler(>=6)+extension AppGuestUsage: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppGuestUsage: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppGuestUsage {+ return+ try AppGuestUsage(+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),+ memoryUsed: FfiConverterUInt64.read(from: &buf),+ memoryTotal: FfiConverterUInt64.read(from: &buf),+ memoryLimited: FfiConverterBool.read(from: &buf),+ diskUsed: FfiConverterUInt64.read(from: &buf),+ diskTotal: FfiConverterUInt64.read(from: &buf),+ diskLimited: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: AppGuestUsage, into buf: inout [UInt8]) {+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)+ FfiConverterUInt64.write(value.memoryUsed, into: &buf)+ FfiConverterUInt64.write(value.memoryTotal, into: &buf)+ FfiConverterBool.write(value.memoryLimited, into: &buf)+ FfiConverterUInt64.write(value.diskUsed, into: &buf)+ FfiConverterUInt64.write(value.diskTotal, into: &buf)+ FfiConverterBool.write(value.diskLimited, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppGuestUsage_lift(_ buf: RustBuffer) throws -> AppGuestUsage {+ return try FfiConverterTypeAppGuestUsage.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppGuestUsage_lower(_ value: AppGuestUsage) -> RustBuffer {+ return FfiConverterTypeAppGuestUsage.lower(value)+}++public struct AppHostAccess: Equatable, Hashable {/*** Epoch ms.@@ -26706,6 +27358,284 @@ public func FfiConverterTypeAppResourceEditView_lower(_ value: AppResourceEditVi}+public struct AppResourceRow: Equatable, Hashable {+ /**+ * "Processor", "Memory" or "Space for files".+ */+ public var label: String+ /**+ * The numbers in words.+ */+ public var value: String+ /**+ * How full the small bar is, 0 to 1; none for a row with no bar.+ */+ public var fraction: Double?+ /**+ * How to colour it.+ */+ public var tone: AppResourceTone++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * "Processor", "Memory" or "Space for files".+ */label: String,+ /**+ * The numbers in words.+ */value: String,+ /**+ * How full the small bar is, 0 to 1; none for a row with no bar.+ */fraction: Double?,+ /**+ * How to colour it.+ */tone: AppResourceTone) {+ self.label = label+ self.value = value+ self.fraction = fraction+ self.tone = tone+ }+++++}++#if compiler(>=6)+extension AppResourceRow: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppResourceRow: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppResourceRow {+ return+ try AppResourceRow(+ label: FfiConverterString.read(from: &buf),+ value: FfiConverterString.read(from: &buf),+ fraction: FfiConverterOptionDouble.read(from: &buf),+ tone: FfiConverterTypeAppResourceTone.read(from: &buf)+ )+ }++ public static func write(_ value: AppResourceRow, into buf: inout [UInt8]) {+ FfiConverterString.write(value.label, into: &buf)+ FfiConverterString.write(value.value, into: &buf)+ FfiConverterOptionDouble.write(value.fraction, into: &buf)+ FfiConverterTypeAppResourceTone.write(value.tone, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourceRow_lift(_ buf: RustBuffer) throws -> AppResourceRow {+ return try FfiConverterTypeAppResourceRow.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourceRow_lower(_ value: AppResourceRow) -> RustBuffer {+ return FfiConverterTypeAppResourceRow.lower(value)+}+++public struct AppResourcesSnapshot: Equatable, Hashable {+ /**+ * Grows by one per sample.+ */+ public var sequence: UInt64+ /**+ * Unix ms.+ */+ public var sampledAtMs: UInt64+ /**+ * This Mac.+ */+ public var thisMac: AppComputerResources+ /**+ * Extra Spaces on this Mac.+ */+ public var spaces: [AppSpaceResources]+ /**+ * Your other computers.+ */+ public var computers: [AppComputerResources]+ /**+ * This Mac's low-disk signal, for the menu bar.+ */+ public var warning: AppDiskWarning++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * Grows by one per sample.+ */sequence: UInt64,+ /**+ * Unix ms.+ */sampledAtMs: UInt64,+ /**+ * This Mac.+ */thisMac: AppComputerResources,+ /**+ * Extra Spaces on this Mac.+ */spaces: [AppSpaceResources],+ /**+ * Your other computers.+ */computers: [AppComputerResources],+ /**+ * This Mac's low-disk signal, for the menu bar.+ */warning: AppDiskWarning) {+ self.sequence = sequence+ self.sampledAtMs = sampledAtMs+ self.thisMac = thisMac+ self.spaces = spaces+ self.computers = computers+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension AppResourcesSnapshot: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppResourcesSnapshot: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppResourcesSnapshot {+ return+ try AppResourcesSnapshot(+ sequence: FfiConverterUInt64.read(from: &buf),+ sampledAtMs: FfiConverterUInt64.read(from: &buf),+ thisMac: FfiConverterTypeAppComputerResources.read(from: &buf),+ spaces: FfiConverterSequenceTypeAppSpaceResources.read(from: &buf),+ computers: FfiConverterSequenceTypeAppComputerResources.read(from: &buf),+ warning: FfiConverterTypeAppDiskWarning.read(from: &buf)+ )+ }++ public static func write(_ value: AppResourcesSnapshot, into buf: inout [UInt8]) {+ FfiConverterUInt64.write(value.sequence, into: &buf)+ FfiConverterUInt64.write(value.sampledAtMs, into: &buf)+ FfiConverterTypeAppComputerResources.write(value.thisMac, into: &buf)+ FfiConverterSequenceTypeAppSpaceResources.write(value.spaces, into: &buf)+ FfiConverterSequenceTypeAppComputerResources.write(value.computers, into: &buf)+ FfiConverterTypeAppDiskWarning.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourcesSnapshot_lift(_ buf: RustBuffer) throws -> AppResourcesSnapshot {+ return try FfiConverterTypeAppResourcesSnapshot.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourcesSnapshot_lower(_ value: AppResourcesSnapshot) -> RustBuffer {+ return FfiConverterTypeAppResourcesSnapshot.lower(value)+}+++public struct AppResourcesView: Equatable, Hashable {+ /**+ * This Mac.+ */+ public var thisMac: AppThisMacView+ /**+ * Each extra Space.+ */+ public var spaces: [AppSpaceResourcesView]+ /**+ * Each other computer.+ */+ public var computers: [AppComputerView]+ /**+ * The menu bar's warning: none when the disk is fine.+ */+ public var warning: AppWarningView?++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * This Mac.+ */thisMac: AppThisMacView,+ /**+ * Each extra Space.+ */spaces: [AppSpaceResourcesView],+ /**+ * Each other computer.+ */computers: [AppComputerView],+ /**+ * The menu bar's warning: none when the disk is fine.+ */warning: AppWarningView?) {+ self.thisMac = thisMac+ self.spaces = spaces+ self.computers = computers+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension AppResourcesView: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppResourcesView: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppResourcesView {+ return+ try AppResourcesView(+ thisMac: FfiConverterTypeAppThisMacView.read(from: &buf),+ spaces: FfiConverterSequenceTypeAppSpaceResourcesView.read(from: &buf),+ computers: FfiConverterSequenceTypeAppComputerView.read(from: &buf),+ warning: FfiConverterOptionTypeAppWarningView.read(from: &buf)+ )+ }++ public static func write(_ value: AppResourcesView, into buf: inout [UInt8]) {+ FfiConverterTypeAppThisMacView.write(value.thisMac, into: &buf)+ FfiConverterSequenceTypeAppSpaceResourcesView.write(value.spaces, into: &buf)+ FfiConverterSequenceTypeAppComputerView.write(value.computers, into: &buf)+ FfiConverterOptionTypeAppWarningView.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourcesView_lift(_ buf: RustBuffer) throws -> AppResourcesView {+ return try FfiConverterTypeAppResourcesView.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourcesView_lower(_ value: AppResourcesView) -> RustBuffer {+ return FfiConverterTypeAppResourcesView.lower(value)+}++public struct AppReviewChoice: Equatable, Hashable {/*** Where to send from.@@ -31336,6 +32266,222 @@ public func FfiConverterTypeAppSpaceProgress_lower(_ value: AppSpaceProgress) ->}+public struct AppSpaceResources: Equatable, Hashable {+ /**+ * `local:<name>`.+ */+ public var id: String+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */+ public var powerState: String+ /**+ * Cores given to it (0: unknown).+ */+ public var cpuAllocated: UInt32+ /**+ * Memory given to it, bytes (0: unknown).+ */+ public var memoryAllocated: UInt64+ /**+ * Its disk's size limit, bytes (0: unknown).+ */+ public var diskAllocated: UInt64+ /**+ * The guest's own numbers; none while it is off or unreachable.+ */+ public var usage: AppGuestUsage?+ /**+ * What it costs this Mac; none for a container.+ */+ public var diskOnHost: AppDiskOnHost?++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * `local:<name>`.+ */id: String,+ /**+ * `running`, `stopped`, `suspended`, or empty when unknown.+ */powerState: String,+ /**+ * Cores given to it (0: unknown).+ */cpuAllocated: UInt32,+ /**+ * Memory given to it, bytes (0: unknown).+ */memoryAllocated: UInt64,+ /**+ * Its disk's size limit, bytes (0: unknown).+ */diskAllocated: UInt64,+ /**+ * The guest's own numbers; none while it is off or unreachable.+ */usage: AppGuestUsage?,+ /**+ * What it costs this Mac; none for a container.+ */diskOnHost: AppDiskOnHost?) {+ self.id = id+ self.powerState = powerState+ self.cpuAllocated = cpuAllocated+ self.memoryAllocated = memoryAllocated+ self.diskAllocated = diskAllocated+ self.usage = usage+ self.diskOnHost = diskOnHost+ }+++++}++#if compiler(>=6)+extension AppSpaceResources: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppSpaceResources: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppSpaceResources {+ return+ try AppSpaceResources(+ id: FfiConverterString.read(from: &buf),+ powerState: FfiConverterString.read(from: &buf),+ cpuAllocated: FfiConverterUInt32.read(from: &buf),+ memoryAllocated: FfiConverterUInt64.read(from: &buf),+ diskAllocated: FfiConverterUInt64.read(from: &buf),+ usage: FfiConverterOptionTypeAppGuestUsage.read(from: &buf),+ diskOnHost: FfiConverterOptionTypeAppDiskOnHost.read(from: &buf)+ )+ }++ public static func write(_ value: AppSpaceResources, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterString.write(value.powerState, into: &buf)+ FfiConverterUInt32.write(value.cpuAllocated, into: &buf)+ FfiConverterUInt64.write(value.memoryAllocated, into: &buf)+ FfiConverterUInt64.write(value.diskAllocated, into: &buf)+ FfiConverterOptionTypeAppGuestUsage.write(value.usage, into: &buf)+ FfiConverterOptionTypeAppDiskOnHost.write(value.diskOnHost, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppSpaceResources_lift(_ buf: RustBuffer) throws -> AppSpaceResources {+ return try FfiConverterTypeAppSpaceResources.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppSpaceResources_lower(_ value: AppSpaceResources) -> RustBuffer {+ return FfiConverterTypeAppSpaceResources.lower(value)+}+++public struct AppSpaceResourcesView: Equatable, Hashable {+ /**+ * The Space's id.+ */+ public var id: String+ /**+ * Processor, Memory, Space for files: what it was given and, while it+ * runs, what it uses now.+ */+ public var rows: [AppResourceRow]+ /**+ * What it costs this Mac, not what the guest sees: "Uses about 31 GB+ * on this Mac (shares space with other copies)". None for a container.+ */+ public var onThisMac: String?+ /**+ * The Space is off: "Stopped · uses about 6 GB on this Mac".+ */+ public var offLine: String?+ /**+ * Whether the numbers are live (the Space runs and answered).+ */+ public var live: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * The Space's id.+ */id: String,+ /**+ * Processor, Memory, Space for files: what it was given and, while it+ * runs, what it uses now.+ */rows: [AppResourceRow],+ /**+ * What it costs this Mac, not what the guest sees: "Uses about 31 GB+ * on this Mac (shares space with other copies)". None for a container.+ */onThisMac: String?,+ /**+ * The Space is off: "Stopped · uses about 6 GB on this Mac".+ */offLine: String?,+ /**+ * Whether the numbers are live (the Space runs and answered).+ */live: Bool) {+ self.id = id+ self.rows = rows+ self.onThisMac = onThisMac+ self.offLine = offLine+ self.live = live+ }+++++}++#if compiler(>=6)+extension AppSpaceResourcesView: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppSpaceResourcesView: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppSpaceResourcesView {+ return+ try AppSpaceResourcesView(+ id: FfiConverterString.read(from: &buf),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from: &buf),+ onThisMac: FfiConverterOptionString.read(from: &buf),+ offLine: FfiConverterOptionString.read(from: &buf),+ live: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: AppSpaceResourcesView, into buf: inout [UInt8]) {+ FfiConverterString.write(value.id, into: &buf)+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into: &buf)+ FfiConverterOptionString.write(value.onThisMac, into: &buf)+ FfiConverterOptionString.write(value.offLine, into: &buf)+ FfiConverterBool.write(value.live, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppSpaceResourcesView_lift(_ buf: RustBuffer) throws -> AppSpaceResourcesView {+ return try FfiConverterTypeAppSpaceResourcesView.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppSpaceResourcesView_lower(_ value: AppSpaceResourcesView) -> RustBuffer {+ return FfiConverterTypeAppSpaceResourcesView.lower(value)+}++public struct AppSpaceRow: Equatable, Hashable {/*** Sandbox ref.@@ -31713,6 +32859,18 @@ public func FfiConverterTypeAppSpaceSdkRef_lower(_ value: AppSpaceSdkRef) -> Ruspublic struct AppSpaceUsage: Equatable, Hashable {+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */+ public var cpuCount: UInt32+ /**+ * Busy now, 0 to 100.+ */+ public var cpuPercent: Double+ /**+ * 1-minute load average.+ */+ public var loadAverage1m: Double/*** Memory in use, bytes.*/@@ -31741,6 +32899,15 @@ public struct AppSpaceUsage: Equatable, Hashable {// Default memberwise initializers are never public by default, so we// declare one manually.public init(+ /**+ * Cores the guest sees (0 from a guest that does not report it).+ */cpuCount: UInt32,+ /**+ * Busy now, 0 to 100.+ */cpuPercent: Double,+ /**+ * 1-minute load average.+ */loadAverage1m: Double,/*** Memory in use, bytes.*/memoryUsed: UInt64,@@ -31759,6 +32926,9 @@ public struct AppSpaceUsage: Equatable, Hashable {/*** `disk_total` is the guest's own disk.*/diskLimited: Bool) {+ self.cpuCount = cpuCount+ self.cpuPercent = cpuPercent+ self.loadAverage1m = loadAverage1mself.memoryUsed = memoryUsedself.memoryTotal = memoryTotalself.memoryLimited = memoryLimited@@ -31783,6 +32953,9 @@ public struct FfiConverterTypeAppSpaceUsage: FfiConverterRustBuffer {public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppSpaceUsage {returntry AppSpaceUsage(+ cpuCount: FfiConverterUInt32.read(from: &buf),+ cpuPercent: FfiConverterDouble.read(from: &buf),+ loadAverage1m: FfiConverterDouble.read(from: &buf),memoryUsed: FfiConverterUInt64.read(from: &buf),memoryTotal: FfiConverterUInt64.read(from: &buf),memoryLimited: FfiConverterBool.read(from: &buf),@@ -31793,6 +32966,9 @@ public struct FfiConverterTypeAppSpaceUsage: FfiConverterRustBuffer {}public static func write(_ value: AppSpaceUsage, into buf: inout [UInt8]) {+ FfiConverterUInt32.write(value.cpuCount, into: &buf)+ FfiConverterDouble.write(value.cpuPercent, into: &buf)+ FfiConverterDouble.write(value.loadAverage1m, into: &buf)FfiConverterUInt64.write(value.memoryUsed, into: &buf)FfiConverterUInt64.write(value.memoryTotal, into: &buf)FfiConverterBool.write(value.memoryLimited, into: &buf)@@ -33962,6 +35138,94 @@ public func FfiConverterTypeAppThisDevice_lower(_ value: AppThisDevice) -> RustB}+public struct AppThisMacView: Equatable, Hashable {+ /**+ * "This Mac".+ */+ public var title: String+ /**+ * Processor, Memory, Space for files.+ */+ public var rows: [AppResourceRow]+ /**+ * "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+ * files." None when there are no extra Spaces.+ */+ public var extraSpaces: String?+ /**+ * The warning, when the disk is low.+ */+ public var warning: AppWarningView?++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * "This Mac".+ */title: String,+ /**+ * Processor, Memory, Space for files.+ */rows: [AppResourceRow],+ /**+ * "Your extra Spaces use: 6 cores, 12 GB of memory, about 25 GB for+ * files." None when there are no extra Spaces.+ */extraSpaces: String?,+ /**+ * The warning, when the disk is low.+ */warning: AppWarningView?) {+ self.title = title+ self.rows = rows+ self.extraSpaces = extraSpaces+ self.warning = warning+ }+++++}++#if compiler(>=6)+extension AppThisMacView: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppThisMacView: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppThisMacView {+ return+ try AppThisMacView(+ title: FfiConverterString.read(from: &buf),+ rows: FfiConverterSequenceTypeAppResourceRow.read(from: &buf),+ extraSpaces: FfiConverterOptionString.read(from: &buf),+ warning: FfiConverterOptionTypeAppWarningView.read(from: &buf)+ )+ }++ public static func write(_ value: AppThisMacView, into buf: inout [UInt8]) {+ FfiConverterString.write(value.title, into: &buf)+ FfiConverterSequenceTypeAppResourceRow.write(value.rows, into: &buf)+ FfiConverterOptionString.write(value.extraSpaces, into: &buf)+ FfiConverterOptionTypeAppWarningView.write(value.warning, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppThisMacView_lift(_ buf: RustBuffer) throws -> AppThisMacView {+ return try FfiConverterTypeAppThisMacView.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppThisMacView_lower(_ value: AppThisMacView) -> RustBuffer {+ return FfiConverterTypeAppThisMacView.lower(value)+}++public struct AppThumbnailPolicy: Equatable, Hashable {/*** While the notch is open: every running Space, this often.@@ -34702,6 +35966,82 @@ public func FfiConverterTypeAppVaultSource_lower(_ value: AppVaultSource) -> Rus}+public struct AppWarningView: Equatable, Hashable {+ /**+ * The sentence.+ */+ public var text: String+ /**+ * The button ("See what's using space").+ */+ public var button: String+ /**+ * Under the floor where creating a Space already fails.+ */+ public var critical: Bool++ // Default memberwise initializers are never public by default, so we+ // declare one manually.+ public init(+ /**+ * The sentence.+ */text: String,+ /**+ * The button ("See what's using space").+ */button: String,+ /**+ * Under the floor where creating a Space already fails.+ */critical: Bool) {+ self.text = text+ self.button = button+ self.critical = critical+ }+++++}++#if compiler(>=6)+extension AppWarningView: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppWarningView: FfiConverterRustBuffer {+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppWarningView {+ return+ try AppWarningView(+ text: FfiConverterString.read(from: &buf),+ button: FfiConverterString.read(from: &buf),+ critical: FfiConverterBool.read(from: &buf)+ )+ }++ public static func write(_ value: AppWarningView, into buf: inout [UInt8]) {+ FfiConverterString.write(value.text, into: &buf)+ FfiConverterString.write(value.button, into: &buf)+ FfiConverterBool.write(value.critical, into: &buf)+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppWarningView_lift(_ buf: RustBuffer) throws -> AppWarningView {+ return try FfiConverterTypeAppWarningView.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppWarningView_lower(_ value: AppWarningView) -> RustBuffer {+ return FfiConverterTypeAppWarningView.lower(value)+}++public struct AppWizardEnv: Equatable, Hashable {/*** Where "Run on" starts (Settings, `cua config set default.on`).@@ -45801,6 +47141,90 @@ public func FfiConverterTypeAppDeviceAction_lower(_ value: AppDeviceAction) -> R}+// Note that we don't yet support `indirect` for enums.+// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.++public enum AppDiskLevel: Equatable, Hashable {++ /**+ * Plenty.+ */+ case ok+ /**+ * Under 50 GB or 15% of the volume, whichever line is higher (never+ * above 100 GB).+ */+ case low+ /**+ * Under the floor where creating a Space already fails.+ */+ case critical++++++}++#if compiler(>=6)+extension AppDiskLevel: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppDiskLevel: FfiConverterRustBuffer {+ typealias SwiftType = AppDiskLevel++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppDiskLevel {+ let variant: Int32 = try readInt(&buf)+ switch variant {++ case 1: return .ok++ case 2: return .low++ case 3: return .critical++ default: throw UniffiInternalError.unexpectedEnumCase+ }+ }++ public static func write(_ value: AppDiskLevel, into buf: inout [UInt8]) {+ switch value {+++ case .ok:+ writeInt(&buf, Int32(1))+++ case .low:+ writeInt(&buf, Int32(2))+++ case .critical:+ writeInt(&buf, Int32(3))++ }+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskLevel_lift(_ buf: RustBuffer) throws -> AppDiskLevel {+ return try FfiConverterTypeAppDiskLevel.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppDiskLevel_lower(_ value: AppDiskLevel) -> RustBuffer {+ return FfiConverterTypeAppDiskLevel.lower(value)+}++// Note that we don't yet support `indirect` for enums.// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.@@ -51137,6 +52561,89 @@ public func FfiConverterTypeAppResourceField_lower(_ value: AppResourceField) ->}+// Note that we don't yet support `indirect` for enums.+// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.++public enum AppResourceTone: Equatable, Hashable {++ /**+ * Nothing to say.+ */+ case normal+ /**+ * Running low.+ */+ case warning+ /**+ * Out.+ */+ case critical++++++}++#if compiler(>=6)+extension AppResourceTone: Sendable {}+#endif++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public struct FfiConverterTypeAppResourceTone: FfiConverterRustBuffer {+ typealias SwiftType = AppResourceTone++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppResourceTone {+ let variant: Int32 = try readInt(&buf)+ switch variant {++ case 1: return .normal++ case 2: return .warning++ case 3: return .critical++ default: throw UniffiInternalError.unexpectedEnumCase+ }+ }++ public static func write(_ value: AppResourceTone, into buf: inout [UInt8]) {+ switch value {+++ case .normal:+ writeInt(&buf, Int32(1))+++ case .warning:+ writeInt(&buf, Int32(2))+++ case .critical:+ writeInt(&buf, Int32(3))++ }+ }+}+++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourceTone_lift(_ buf: RustBuffer) throws -> AppResourceTone {+ return try FfiConverterTypeAppResourceTone.lift(buf)+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+public func FfiConverterTypeAppResourceTone_lower(_ value: AppResourceTone) -> RustBuffer {+ return FfiConverterTypeAppResourceTone.lower(value)+}++// Note that we don't yet support `indirect` for enums.// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.@@ -58396,6 +59903,30 @@ fileprivate struct FfiConverterOptionTypeAppDeviceConfirm: FfiConverterRustBuffe}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeAppDiskOnHost: FfiConverterRustBuffer {+ typealias SwiftType = AppDiskOnHost?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeAppDiskOnHost.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeAppDiskOnHost.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -58684,6 +60215,30 @@ fileprivate struct FfiConverterOptionTypeAppGpuRow: FfiConverterRustBuffer {}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeAppGuestUsage: FfiConverterRustBuffer {+ typealias SwiftType = AppGuestUsage?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeAppGuestUsage.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeAppGuestUsage.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -59884,6 +61439,30 @@ fileprivate struct FfiConverterOptionTypeAppUsageToggle: FfiConverterRustBuffer}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionTypeAppWarningView: FfiConverterRustBuffer {+ typealias SwiftType = AppWarningView?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterTypeAppWarningView.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterTypeAppWarningView.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -61348,6 +62927,56 @@ fileprivate struct FfiConverterSequenceTypeAppComputerGrantInput: FfiConverterRu}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeAppComputerResources: FfiConverterRustBuffer {+ typealias SwiftType = [AppComputerResources]++ public static func write(_ value: [AppComputerResources], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeAppComputerResources.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AppComputerResources] {+ let len: Int32 = try readInt(&buf)+ var seq = [AppComputerResources]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeAppComputerResources.read(from: &buf))+ }+ return seq+ }+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeAppComputerView: FfiConverterRustBuffer {+ typealias SwiftType = [AppComputerView]++ public static func write(_ value: [AppComputerView], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeAppComputerView.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AppComputerView] {+ let len: Int32 = try readInt(&buf)+ var seq = [AppComputerView]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeAppComputerView.read(from: &buf))+ }+ return seq+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -62973,6 +64602,31 @@ fileprivate struct FfiConverterSequenceTypeAppRemoteWindowGroup: FfiConverterRus}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeAppResourceRow: FfiConverterRustBuffer {+ typealias SwiftType = [AppResourceRow]++ public static func write(_ value: [AppResourceRow], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeAppResourceRow.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AppResourceRow] {+ let len: Int32 = try readInt(&buf)+ var seq = [AppResourceRow]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeAppResourceRow.read(from: &buf))+ }+ return seq+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -63448,6 +65102,56 @@ fileprivate struct FfiConverterSequenceTypeAppSpaceHost: FfiConverterRustBuffer}}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeAppSpaceResources: FfiConverterRustBuffer {+ typealias SwiftType = [AppSpaceResources]++ public static func write(_ value: [AppSpaceResources], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeAppSpaceResources.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AppSpaceResources] {+ let len: Int32 = try readInt(&buf)+ var seq = [AppSpaceResources]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeAppSpaceResources.read(from: &buf))+ }+ return seq+ }+}++#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterSequenceTypeAppSpaceResourcesView: FfiConverterRustBuffer {+ typealias SwiftType = [AppSpaceResourcesView]++ public static func write(_ value: [AppSpaceResourcesView], into buf: inout [UInt8]) {+ let len = Int32(value.count)+ writeInt(&buf, len)+ for item in value {+ FfiConverterTypeAppSpaceResourcesView.write(item, into: &buf)+ }+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AppSpaceResourcesView] {+ let len: Int32 = try readInt(&buf)+ var seq = [AppSpaceResourcesView]()+ seq.reserveCapacity(Int(len))+ for _ in 0 ..< len {+ seq.append(try FfiConverterTypeAppSpaceResourcesView.read(from: &buf))+ }+ return seq+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endif@@ -66712,6 +68416,66 @@ public func appRelayUsageView(usage: AppRelayUsage) -> AppRelayUsageView? {)})}+/**+ * Another of your computers' panel.+ */+public func appResourcesComputer(computer: ComputerResources, nowMs: UInt64) -> AppComputerView {+ return try! FfiConverterTypeAppComputerView_lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_resources_computer(+ FfiConverterTypeComputerResources_lower(computer),+ FfiConverterUInt64.lower(nowMs),$0+ )+})+}+/**+ * One extra Space's panel: what it was given and uses now, and what it+ * costs this Mac.+ */+public func appResourcesSpace(space: SpaceResources) -> AppSpaceResourcesView {+ return try! FfiConverterTypeAppSpaceResourcesView_lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_resources_space(+ FfiConverterTypeSpaceResources_lower(space),$0+ )+})+}+/**+ * This Mac's panel (Processor, Memory, Space for files, what the extra+ * Spaces use, the warning).+ */+public func appResourcesThisMac(computer: ComputerResources) -> AppThisMacView {+ return try! FfiConverterTypeAppThisMacView_lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_resources_this_mac(+ FfiConverterTypeComputerResources_lower(computer),$0+ )+})+}+/**+ * Everything the apps draw from one snapshot of what this Mac, its extra+ * Spaces and your other computers use (`Spaces.resources`, or a snapshot+ * event of `Spaces.watch_resources`): this Mac's rows and warning, each+ * extra Space's rows and what it costs this Mac, each other computer's+ * rows. The words are the core's; no shell formats a number. `now_ms` is+ * the shell's clock (Unix ms), for how old another computer's numbers are.+ */+public func appResourcesView(snapshot: ResourcesSnapshot, nowMs: UInt64) -> AppResourcesView {+ return try! FfiConverterTypeAppResourcesView_lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_resources_view(+ FfiConverterTypeResourcesSnapshot_lower(snapshot),+ FfiConverterUInt64.lower(nowMs),$0+ )+})+}+/**+ * The menu bar's low-disk warning (from a `LowDisk` event or a+ * snapshot's `warning`); none when the disk is fine.+ */+public func appResourcesWarning(warning: DiskWarning) -> AppWarningView? {+ return try! FfiConverterOptionTypeAppWarningView.lift(try! rustCall() {+ uniffi_cua_spaces_ffi_fn_func_app_resources_warning(+ FfiConverterTypeDiskWarning_lower(warning),$0+ )+})+}/*** `choices` with the sites just sent remembered for `key`.*/@@ -68618,6 +70382,21 @@ private let initializationResult: InitializationResult = {if (uniffi_cua_spaces_ffi_checksum_func_app_relay_usage_view() != 38605) {return InitializationResult.apiChecksumMismatch}+ if (uniffi_cua_spaces_ffi_checksum_func_app_resources_computer() != 3991) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_spaces_ffi_checksum_func_app_resources_space() != 24195) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac() != 29209) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_spaces_ffi_checksum_func_app_resources_view() != 22202) {+ return InitializationResult.apiChecksumMismatch+ }+ if (uniffi_cua_spaces_ffi_checksum_func_app_resources_warning() != 3548) {+ return InitializationResult.apiChecksumMismatch+ }if (uniffi_cua_spaces_ffi_checksum_func_app_review_remember() != 9631) {return InitializationResult.apiChecksumMismatch}diff --git a/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h b/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.hindex 7611091b93..5d35fd416a 100644--- a/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h+++ b/libs/spaces-app-swift/Sources/cua_spaces_ffiFFI/include/cua_spaces_ffiFFI.h@@ -1557,6 +1557,31 @@ uint64_t uniffi_cua_spaces_ffi_fn_func_app_relay_usage(uint64_t devices, RustBufRustBuffer uniffi_cua_spaces_ffi_fn_func_app_relay_usage_view(RustBuffer usage, RustCallStatus *_Nonnull out_status);#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_COMPUTER+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_COMPUTER+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_resources_computer(RustBuffer computer, uint64_t now_ms, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_SPACE+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_SPACE+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_resources_space(RustBuffer space, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_THIS_MAC+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_THIS_MAC+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_resources_this_mac(RustBuffer computer, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_VIEW+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_VIEW+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_resources_view(RustBuffer snapshot, uint64_t now_ms, RustCallStatus *_Nonnull out_status+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_WARNING+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_RESOURCES_WARNING+RustBuffer uniffi_cua_spaces_ffi_fn_func_app_resources_warning(RustBuffer warning, RustCallStatus *_Nonnull out_status+);+#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_REVIEW_REMEMBER#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_FN_FUNC_APP_REVIEW_REMEMBERRustBuffer uniffi_cua_spaces_ffi_fn_func_app_review_remember(RustBuffer choices, RustBuffer key, RustBuffer domains, RustCallStatus *_Nonnull out_status@@ -3484,6 +3509,36 @@ uint16_t uniffi_cua_spaces_ffi_checksum_func_app_relay_usage(void#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RELAY_USAGE_VIEWuint16_t uniffi_cua_spaces_ffi_checksum_func_app_relay_usage_view(void+);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_COMPUTER+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_COMPUTER+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_resources_computer(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_SPACE+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_SPACE+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_resources_space(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_THIS_MAC+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_THIS_MAC+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_resources_this_mac(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_VIEW+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_VIEW+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_resources_view(void++);+#endif+#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_WARNING+#define UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_RESOURCES_WARNING+uint16_t uniffi_cua_spaces_ffi_checksum_func_app_resources_warning(void+);#endif#ifndef UNIFFI_FFIDEF_UNIFFI_CUA_SPACES_FFI_CHECKSUM_FUNC_APP_REVIEW_REMEMBERdiff --git a/samples/openkoalabot-example-tauri/src-tauri/Cargo.lock b/samples/openkoalabot-example-tauri/src-tauri/Cargo.lockindex 5d2e1377ae..c95097caea 100644--- a/samples/openkoalabot-example-tauri/src-tauri/Cargo.lock+++ b/samples/openkoalabot-example-tauri/src-tauri/Cargo.lock@@ -1646,6 +1646,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -1664,6 +1665,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -1671,6 +1673,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",@@ -4259,6 +4262,15 @@ dependencies = ["minimal-lexical",]+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "num"version = "0.4.3"@@ -4498,6 +4510,16 @@ dependencies = ["objc2-core-foundation",]+[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "objc2-io-surface"version = "0.3.2"@@ -6512,6 +6534,20 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows 0.61.3",+]+[[package]]name = "system-deps"version = "6.2.2"diff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.jsonindex 6ef0997e11..dc745bb34c 100644--- a/scripts/docs-generators/cli-specs/cua.json+++ b/scripts/docs-generators/cli-specs/cua.json@@ -9628,12 +9628,24 @@"subcommands": [{"abstract": "Registered Spaces and your machines on the relay",- "after_help": "Examples:\n cua spaces ls\n cua spaces ls --json",+ "after_help": "CPU, MEMORY and DISK ON THIS MAC show what each Space was given and what it\nuses now (the numbers the Cua Spaces app shows); for another of your\ncomputers they show what it last reported. Numbers only: no file names.\n\nExamples:\n cua spaces ls\n cua spaces ls --no-size\n cua spaces ls --json","aliases": ["list"],"arguments": [],- "flags": [],+ "flags": [+ {+ "aliases": [],+ "default_value": false,+ "env": null,+ "help": "Do not measure what each Space takes on this computer's disk (that walk can take a moment with many Spaces)",+ "hidden": false,+ "name": "no-size",+ "repeatable": false,+ "short_name": null,+ "takes_value": false+ }+ ],"hidden": false,"hidden_aliases": [],"name": "ls",diff --git a/scripts/docs-generators/config.json b/scripts/docs-generators/config.jsonindex 3385b9f153..909100b3d0 100644--- a/scripts/docs-generators/config.json+++ b/scripts/docs-generators/config.json@@ -575,6 +575,11 @@"outputFile": "daemon.mdx","extractCommand": null},+ {+ "type": "reference",+ "outputFile": "daemon-resources.mdx",+ "extractCommand": null+ },{"type": "nav","outputFile": "meta.json",diff --git a/scripts/docs-generators/cua-sdk.ts b/scripts/docs-generators/cua-sdk.tsindex 19ef483f64..259473364c 100644--- a/scripts/docs-generators/cua-sdk.ts+++ b/scripts/docs-generators/cua-sdk.ts@@ -602,6 +602,28 @@ export const PAGES: PageSpec[] = [],items: ['SpaceAppIcon', 'SpaceAppIconRequest', 'SpaceDisplay', 'SpaceThumbnail', 'SpaceUsage'],},+ {+ slug: 'spaces/resources',+ title: 'Processor, memory and disk',+ description: 'What this Mac, its extra Spaces and your other computers use: one snapshot, a stream of changes and the low-disk warning.',+ intro:+ '`Spaces.resources` returns one `ResourcesSnapshot`: this Mac\'s cores, memory and free disk, each extra Space\'s allocation, use and cost on this Mac\'s disk, and the summary each of your other computers published. `Spaces.watch_resources` calls a `ResourcesListener` with a snapshot, then only the entries that changed by more than 1 point or 256 MB, and a `LowDisk` event when the free-disk level changes. Numbers only: counts, bytes and percentages.',+ members: [{ object: 'Spaces', title: 'Resources', methods: ['resources', 'watch_resources'] }],+ items: [+ 'ResourcesSnapshot',+ 'ComputerResources',+ 'SpaceResources',+ 'GuestUsage',+ 'DiskOnHost',+ 'DiskWarning',+ 'DiskLevel',+ 'ResourcesUpdate',+ 'ResourcesEvent',+ 'ResourcesListener',+ 'ResourcesWatch',+ ],+ catalog: true,+ },{slug: 'spaces/agents',title: 'Agents in a Space',diff --git a/scripts/docs-generators/proto.ts b/scripts/docs-generators/proto.tsindex 456ed74e83..e79a5bd02e 100644--- a/scripts/docs-generators/proto.ts+++ b/scripts/docs-generators/proto.ts@@ -181,6 +181,13 @@ export const PAGES: PageSpec[] = ['The local `cua daemon` API (a Unix socket on the host, not cua-spacesd): sandbox lifecycle across locations, the local runtimes and images it orchestrates, Spaces and the machines that provide them, its identity (`GetInfo`) and the loopback media bridge for webviews.',files: ['cua/daemon/v1/sandboxes.proto', 'cua/daemon/v1/runtime.proto', 'cua/daemon/v1/spaces.proto', 'cua/daemon/v1/daemon.proto'],},+ {+ slug: 'daemon-resources',+ title: 'Daemon: resources',+ description: 'cua.daemon.v1 resource messages: processor, memory and disk of this Mac, its extra Spaces and your other computers.',+ intro: 'What `SpaceService.GetResources` and `WatchResources` return: one snapshot, then updates and the low-disk warning. Numbers only.',+ files: ['cua/daemon/v1/resources.proto'],+ },];// ============================================================================diff --git a/tests/e2e/cua-sdk/rust/Cargo.lock b/tests/e2e/cua-sdk/rust/Cargo.lockindex 08f34bff74..c3a074fb21 100644--- a/tests/e2e/cua-sdk/rust/Cargo.lock+++ b/tests/e2e/cua-sdk/rust/Cargo.lock@@ -990,7 +990,7 @@ dependencies = ["num-traits","serde","wasm-bindgen",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -1605,6 +1605,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -1623,6 +1624,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -1630,6 +1632,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",@@ -2659,7 +2662,7 @@ dependencies = ["js-sys","log","wasm-bindgen",- "windows-core",+ "windows-core 0.58.0",][[package]]@@ -2954,7 +2957,7 @@ dependencies = ["simd_cesu8","thiserror 2.0.20","walkdir",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -3247,6 +3250,15 @@ dependencies = ["minimal-lexical",]+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "num-bigint"version = "0.4.8"@@ -3281,6 +3293,25 @@ dependencies = ["autocfg",]+[[package]]+name = "objc2-core-foundation"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"+dependencies = [+ "bitflags 2.13.2",+]++[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "oci-client"version = "0.18.0"@@ -3409,7 +3440,7 @@ dependencies = ["libc","redox_syscall","smallvec",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -4712,6 +4743,20 @@ dependencies = ["syn 3.0.6",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows",+]+[[package]]name = "tar"version = "0.4.46"@@ -5680,19 +5725,65 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"+[[package]]+name = "windows"+version = "0.61.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"+dependencies = [+ "windows-collections",+ "windows-core 0.61.2",+ "windows-future",+ "windows-link 0.1.3",+ "windows-numerics",+]++[[package]]+name = "windows-collections"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"+dependencies = [+ "windows-core 0.61.2",+]+[[package]]name = "windows-core"version = "0.58.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"dependencies = [- "windows-implement",- "windows-interface",- "windows-result",- "windows-strings",+ "windows-implement 0.58.0",+ "windows-interface 0.58.0",+ "windows-result 0.2.0",+ "windows-strings 0.1.0","windows-targets 0.52.6",]+[[package]]+name = "windows-core"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"+dependencies = [+ "windows-implement 0.60.2",+ "windows-interface 0.59.3",+ "windows-link 0.1.3",+ "windows-result 0.3.4",+ "windows-strings 0.4.2",+]++[[package]]+name = "windows-future"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+ "windows-threading",+]+[[package]]name = "windows-implement"version = "0.58.0"@@ -5704,6 +5795,17 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-implement"+version = "0.60.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]+[[package]]name = "windows-interface"version = "0.58.0"@@ -5715,12 +5817,39 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-interface"+version = "0.59.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "windows-link"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"+[[package]]name = "windows-link"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"+[[package]]+name = "windows-numerics"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+]+[[package]]name = "windows-result"version = "0.2.0"@@ -5730,16 +5859,34 @@ dependencies = ["windows-targets 0.52.6",]+[[package]]+name = "windows-result"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-strings"version = "0.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"dependencies = [- "windows-result",+ "windows-result 0.2.0","windows-targets 0.52.6",]+[[package]]+name = "windows-strings"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-sys"version = "0.52.0"@@ -5773,7 +5920,7 @@ version = "0.61.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5798,7 +5945,7 @@ version = "0.53.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"dependencies = [- "windows-link",+ "windows-link 0.2.1","windows_aarch64_gnullvm 0.53.1","windows_aarch64_msvc 0.53.1","windows_i686_gnu 0.53.1",@@ -5809,6 +5956,15 @@ dependencies = ["windows_x86_64_msvc 0.53.1",]+[[package]]+name = "windows-threading"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows_aarch64_gnullvm"version = "0.52.6"diff --git a/tests/e2e/local-runtimes/Cargo.lock b/tests/e2e/local-runtimes/Cargo.lockindex a7125f87cf..d3caf00275 100644--- a/tests/e2e/local-runtimes/Cargo.lock+++ b/tests/e2e/local-runtimes/Cargo.lock@@ -524,7 +524,7 @@ dependencies = ["num-traits","serde","wasm-bindgen",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -1026,6 +1026,7 @@ dependencies = ["cua-agents","cua-auth","cua-create-failure",+ "cua-disk","cua-fleet","cua-home","cua-host",@@ -1044,6 +1045,7 @@ dependencies = ["http","humantime","ignore",+ "libc","pbjson-types","prost","rand 0.9.5",@@ -1051,6 +1053,7 @@ dependencies = ["serde","serde_json","sha2 0.10.9",+ "sysinfo","tar","thiserror 2.0.20","tokio",@@ -2002,7 +2005,7 @@ dependencies = ["js-sys","log","wasm-bindgen",- "windows-core",+ "windows-core 0.62.2",][[package]]@@ -2306,7 +2309,7 @@ dependencies = ["simd_cesu8","thiserror 2.0.20","walkdir",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -2608,6 +2611,15 @@ dependencies = ["minimal-lexical",]+[[package]]+name = "ntapi"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"+dependencies = [+ "winapi",+]+[[package]]name = "nu-ansi-term"version = "0.50.3"@@ -2651,6 +2663,25 @@ dependencies = ["autocfg",]+[[package]]+name = "objc2-core-foundation"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"+dependencies = [+ "bitflags 2.13.2",+]++[[package]]+name = "objc2-io-kit"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"+dependencies = [+ "libc",+ "objc2-core-foundation",+]+[[package]]name = "oci-client"version = "0.18.0"@@ -2761,7 +2792,7 @@ dependencies = ["libc","redox_syscall","smallvec",- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -3989,6 +4020,20 @@ dependencies = ["syn 3.0.6",]+[[package]]+name = "sysinfo"+version = "0.37.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"+dependencies = [+ "libc",+ "memchr",+ "ntapi",+ "objc2-core-foundation",+ "objc2-io-kit",+ "windows",+]+[[package]]name = "tar"version = "0.4.46"@@ -4942,6 +4987,41 @@ version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"+[[package]]+name = "windows"+version = "0.61.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"+dependencies = [+ "windows-collections",+ "windows-core 0.61.2",+ "windows-future",+ "windows-link 0.1.3",+ "windows-numerics",+]++[[package]]+name = "windows-collections"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"+dependencies = [+ "windows-core 0.61.2",+]++[[package]]+name = "windows-core"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"+dependencies = [+ "windows-implement",+ "windows-interface",+ "windows-link 0.1.3",+ "windows-result 0.3.4",+ "windows-strings 0.4.2",+]+[[package]]name = "windows-core"version = "0.62.2"@@ -4950,9 +5030,20 @@ checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"dependencies = ["windows-implement","windows-interface",- "windows-link",- "windows-result",- "windows-strings",+ "windows-link 0.2.1",+ "windows-result 0.4.1",+ "windows-strings 0.5.1",+]++[[package]]+name = "windows-future"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+ "windows-threading",][[package]]@@ -4977,19 +5068,53 @@ dependencies = ["syn 2.0.119",]+[[package]]+name = "windows-link"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"+[[package]]name = "windows-link"version = "0.2.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"+[[package]]+name = "windows-numerics"+version = "0.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"+dependencies = [+ "windows-core 0.61.2",+ "windows-link 0.1.3",+]++[[package]]+name = "windows-result"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows-result"version = "0.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"dependencies = [- "windows-link",+ "windows-link 0.2.1",+]++[[package]]+name = "windows-strings"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"+dependencies = [+ "windows-link 0.1.3",][[package]]@@ -4998,7 +5123,7 @@ version = "0.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5034,7 +5159,7 @@ version = "0.61.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"dependencies = [- "windows-link",+ "windows-link 0.2.1",][[package]]@@ -5059,7 +5184,7 @@ version = "0.53.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"dependencies = [- "windows-link",+ "windows-link 0.2.1","windows_aarch64_gnullvm 0.53.1","windows_aarch64_msvc 0.53.1","windows_i686_gnu 0.53.1",@@ -5070,6 +5195,15 @@ dependencies = ["windows_x86_64_msvc 0.53.1",]+[[package]]+name = "windows-threading"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"+dependencies = [+ "windows-link 0.1.3",+]+[[package]]name = "windows_aarch64_gnullvm"version = "0.52.6"