Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(spaces): say why a Space stopped on its own (out of memory) (CUA-1759) (#5303)

ddupont9737d6f22bad
diff --git a/apps/cua-spaces-desktop/src/model/backend.ts b/apps/cua-spaces-desktop/src/model/backend.ts
index ce88cb7425..a631cf98bc 100644
--- a/apps/cua-spaces-desktop/src/model/backend.ts
+++ b/apps/cua-spaces-desktop/src/model/backend.ts
@@ -242,6 +242,7 @@ export class LiveSpacesBackend implements SpacesBackend {
cloud: text(info.cloud),
cloudPlace: text(info.cloudPlace),
cloudDelete: text(info.cloudDelete),
+ stopReason: text(info.stopReason),
};
// Turned off on purpose: no probe (it would only time out).
if (info.powerState === "suspended" || info.powerState === "stopped") return row;
diff --git a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
index 3ff2f8d3ef..65924d1a89 100644
--- a/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
+++ b/apps/cua-spaces-desktop/src/native/generated/cua_sdk.ts
@@ -12899,7 +12899,12 @@ export type SandboxInfo = {
* `None` for direct connections, named pools, images not resolved from
* a registry, and the daemon topology.
*/
- imageInfo?: ImageInfo
+ imageInfo?: ImageInfo,
+ /**
+ * Why a local sandbox stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ */
+ stopReason?: string
}
/**
@@ -12907,7 +12912,8 @@ export type SandboxInfo = {
*/
export const SandboxInfo = (() => {
const defaults = () => ({
- imageInfo: undefined
+ imageInfo: undefined,
+ stopReason: undefined
});
const create = (() => {
return uniffiCreateRecord<SandboxInfo, ReturnType<typeof defaults>>(defaults);
@@ -12939,7 +12945,8 @@ const FfiConverterTypeSandboxInfo = (() => {
location: FfiConverterString.read(from),
expiresAtUnix: FfiConverterOptionalInt64.read(from),
providerDetails: FfiConverterMapStringString.read(from),
- imageInfo: FfiConverterOptionalTypeImageInfo.read(from)
+ imageInfo: FfiConverterOptionalTypeImageInfo.read(from),
+ stopReason: FfiConverterOptionalString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -12959,6 +12966,7 @@ const FfiConverterTypeSandboxInfo = (() => {
FfiConverterOptionalInt64.write(value.expiresAtUnix, into);
FfiConverterMapStringString.write(value.providerDetails, into);
FfiConverterOptionalTypeImageInfo.write(value.imageInfo, into);
+ FfiConverterOptionalString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterString.allocationSize(value.name) +
@@ -12976,7 +12984,8 @@ const FfiConverterTypeSandboxInfo = (() => {
FfiConverterString.allocationSize(value.location) +
FfiConverterOptionalInt64.allocationSize(value.expiresAtUnix) +
FfiConverterMapStringString.allocationSize(value.providerDetails) +
- FfiConverterOptionalTypeImageInfo.allocationSize(value.imageInfo);
+ FfiConverterOptionalTypeImageInfo.allocationSize(value.imageInfo) +
+ FfiConverterOptionalString.allocationSize(value.stopReason);
}
};
@@ -14368,7 +14377,13 @@ export type SpaceInfo = {
* through the relay) or `elsewhere` (only there; `remove` keeps it).
* Empty for other Spaces.
*/
- cloudDelete: string
+ cloudDelete: string,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ * and once it is started again.
+ */
+ stopReason: string
}
/**
@@ -14376,6 +14391,7 @@ export type SpaceInfo = {
*/
export const SpaceInfo = (() => {
const defaults = () => ({
+ stopReason: ""
});
const create = (() => {
return uniffiCreateRecord<SpaceInfo, ReturnType<typeof defaults>>(defaults);
@@ -14412,7 +14428,8 @@ const FfiConverterTypeSpaceInfo = (() => {
powerState: FfiConverterString.read(from),
cloud: FfiConverterString.read(from),
cloudPlace: FfiConverterString.read(from),
- cloudDelete: FfiConverterString.read(from)
+ cloudDelete: FfiConverterString.read(from),
+ stopReason: FfiConverterString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -14437,6 +14454,7 @@ const FfiConverterTypeSpaceInfo = (() => {
FfiConverterString.write(value.cloud, into);
FfiConverterString.write(value.cloudPlace, into);
FfiConverterString.write(value.cloudDelete, into);
+ FfiConverterString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterString.allocationSize(value.id) +
@@ -14459,7 +14477,8 @@ const FfiConverterTypeSpaceInfo = (() => {
FfiConverterString.allocationSize(value.powerState) +
FfiConverterString.allocationSize(value.cloud) +
FfiConverterString.allocationSize(value.cloudPlace) +
- FfiConverterString.allocationSize(value.cloudDelete);
+ FfiConverterString.allocationSize(value.cloudDelete) +
+ FfiConverterString.allocationSize(value.stopReason);
}
};
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.ts
index 576a45ef3d..fe68b67432 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
@@ -11093,7 +11093,12 @@ export type AppSpacePower = {
/**
* Why the last power action failed, until the next one.
*/
- error?: string
+ error?: string,
+ /**
+ * Why it stopped without being asked to, in plain words ("out of
+ * memory"), while it is off.
+ */
+ stopReason?: string
}
/**
@@ -11120,7 +11125,8 @@ const FfiConverterTypeAppSpacePower = (() => {
control: FfiConverterTypeAppPowerControl.read(from),
off: FfiConverterBool.read(from),
turningOn: FfiConverterOptionalBoolean.read(from),
- error: FfiConverterOptionalString.read(from)
+ error: FfiConverterOptionalString.read(from),
+ stopReason: FfiConverterOptionalString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -11128,12 +11134,14 @@ const FfiConverterTypeAppSpacePower = (() => {
FfiConverterBool.write(value.off, into);
FfiConverterOptionalBoolean.write(value.turningOn, into);
FfiConverterOptionalString.write(value.error, into);
+ FfiConverterOptionalString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterTypeAppPowerControl.allocationSize(value.control) +
FfiConverterBool.allocationSize(value.off) +
FfiConverterOptionalBoolean.allocationSize(value.turningOn) +
- FfiConverterOptionalString.allocationSize(value.error);
+ FfiConverterOptionalString.allocationSize(value.error) +
+ FfiConverterOptionalString.allocationSize(value.stopReason);
}
};
@@ -35096,7 +35104,13 @@ export type AppSpaceRow = {
* Where Delete permanently can delete it: `here`, `host:<machine>`
* (that machine created it) or `elsewhere` (another device did).
*/
- cloudDelete?: string
+ cloudDelete?: string,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"), as the SDK
+ * recorded it; absent otherwise.
+ */
+ stopReason?: string
}
/**
@@ -35141,7 +35155,8 @@ const FfiConverterTypeAppSpaceRow = (() => {
powerState: FfiConverterOptionalString.read(from),
cloud: FfiConverterOptionalString.read(from),
cloudPlace: FfiConverterOptionalString.read(from),
- cloudDelete: FfiConverterOptionalString.read(from)
+ cloudDelete: FfiConverterOptionalString.read(from),
+ stopReason: FfiConverterOptionalString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -35167,6 +35182,7 @@ const FfiConverterTypeAppSpaceRow = (() => {
FfiConverterOptionalString.write(value.cloud, into);
FfiConverterOptionalString.write(value.cloudPlace, into);
FfiConverterOptionalString.write(value.cloudDelete, into);
+ FfiConverterOptionalString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterString.allocationSize(value.id) +
@@ -35190,7 +35206,8 @@ const FfiConverterTypeAppSpaceRow = (() => {
FfiConverterOptionalString.allocationSize(value.powerState) +
FfiConverterOptionalString.allocationSize(value.cloud) +
FfiConverterOptionalString.allocationSize(value.cloudPlace) +
- FfiConverterOptionalString.allocationSize(value.cloudDelete);
+ FfiConverterOptionalString.allocationSize(value.cloudDelete) +
+ FfiConverterOptionalString.allocationSize(value.stopReason);
}
};
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
index 23a229ba99..d7d65156b0 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/SpacesBackend.swift
@@ -191,7 +191,8 @@ public final class LiveSpacesBackend: SpacesBackend, @unchecked Sendable {
powerState: info.powerState.isEmpty ? nil : info.powerState,
cloud: info.cloud.isEmpty ? nil : info.cloud,
cloudPlace: info.cloudPlace.isEmpty ? nil : info.cloudPlace,
- cloudDelete: info.cloudDelete.isEmpty ? nil : info.cloudDelete)
+ cloudDelete: info.cloudDelete.isEmpty ? nil : info.cloudDelete,
+ stopReason: info.stopReason.isEmpty ? nil : info.stopReason)
// Turned off on purpose: no probe (it would only time out).
if ["suspended", "stopped"].contains(info.powerState) {
return (index, row)
@@ -669,17 +670,17 @@ public final class FixtureSpacesBackend: SpacesBackend, @unchecked Sendable {
image: "ghcr.io/trycua/linux:24.04",
imageDigest: "sha256:4f1c2a9d8e7b6c5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a",
kind: .container, arch: "arm64", reachable: true, error: nil, host: nil, hostName: nil,
- power: "suspend", powerState: "running", cloud: nil, cloudPlace: nil, cloudDelete: nil),
+ power: "suspend", powerState: "running", cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil),
AppSpaceRow(id: "cloud:builder", name: "builder", provider: "cloud", spacesdVersion: "0.4.0",
features: ["desktop_stream"], addedAt: "2026-09-24T08:00:00Z",
os: .linux, osName: "Arch Linux", osPrettyName: nil, image: nil, imageDigest: nil,
kind: nil, arch: nil, reachable: false, error: "timed out", host: nil, hostName: nil,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil),
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil),
AppSpaceRow(id: "direct:10.0.0.5:3211", name: "10.0.0.5:3211", provider: "direct",
spacesdVersion: "0.4.0", features: [], addedAt: nil, os: .windows,
osName: "Windows", osPrettyName: "Windows Server 2022 Datacenter 10.0.20348",
image: nil, imageDigest: nil, kind: nil, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil),
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil),
]
public func rows() async throws -> [AppSpaceRow] { await MainActor.run { fixtureRows } }
@@ -733,7 +734,7 @@ public final class FixtureSpacesBackend: SpacesBackend, @unchecked Sendable {
addedAt: nil, os: .linux, osName: nil, osPrettyName: nil,
image: args.image, imageDigest: nil, kind: args.kind, arch: nil,
reachable: true, error: nil, host: nil, hostName: nil,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil))
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil))
return id
}
}
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/FactCopyTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/FactCopyTests.swift
index b45bbd8a21..ed204be7d6 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/FactCopyTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/FactCopyTests.swift
@@ -16,7 +16,7 @@ struct FactCopyTests {
spacesdVersion: "0.4.0", features: [], addedAt: nil, os: .linux,
osName: nil, osPrettyName: nil, image: nil, imageDigest: nil,
kind: nil, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
let facts = appSpaceDetail(space: appRowsToSpaces(rows: [row], nowMs: 0)[0]).facts
#expect(facts.filter { $0.copy != nil }.map(\.label) == ["Identifier"])
return facts.first { $0.copy != nil }!
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift
index 7be0c08ea0..2a0683c3cb 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/MachineAccessTests.swift
@@ -24,7 +24,7 @@ enum MachinesFixture {
osPrettyName: os == .macos ? "macOS 26.0" : "Ubuntu 24.04.3 LTS",
image: nil, imageDigest: nil, kind: nil, arch: "arm64", reachable: reachable,
error: error, host: host, hostName: hostName, power: power, powerState: powerState,
- cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
}
/// This Mac's relay machine id (its host setup).
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
index 61c3515f19..be2d39dabc 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/SnapshotTests.swift
@@ -181,7 +181,7 @@ struct SnapshotTests {
spacesdVersion: "0.4.1", features: [], addedAt: nil, os: os,
osName: nil, osPrettyName: nil, image: nil, imageDigest: nil,
kind: nil, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
let space = appRowsToSpaces(rows: [row], nowMs: 0)[0]
let facts = appSpaceDetail(space: space).facts
#expect(facts.first { $0.label == "System" }?.value == expected)
@@ -390,7 +390,7 @@ struct SnapshotTests {
os: os, osName: osName, osPrettyName: nil, image: nil, imageDigest: nil,
kind: os == .macos ? .vm : .container, arch: "arm64", reachable: reachable,
error: nil, host: nil, hostName: nil, power: power, powerState: state,
- cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
}
let backend = FixtureSpacesBackend(rows: [
row("local:aurora", .linux, "Ubuntu", power: "suspend", state: "suspended", reachable: false),
@@ -690,7 +690,7 @@ struct SnapshotTests {
features: ["desktop_stream"], addedAt: "2026-09-25T08:00:00Z",
os: os, osName: osName, osPrettyName: nil, image: nil, imageDigest: nil,
kind: nil, arch: "arm64", reachable: true, error: nil, host: host, hostName: hostName,
- power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ power: nil, powerState: nil, cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
}
let backend = FixtureSpacesBackend(rows: [
row("local:dev", "Dev box", .linux, "Ubuntu", provider: "local"),
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/StalePollTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/StalePollTests.swift
index 4314946d09..031dcd6508 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/StalePollTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/StalePollTests.swift
@@ -77,7 +77,7 @@ import Testing
spacesdVersion: "0.5.3", features: ["desktop_stream"], addedAt: nil, os: .linux,
osName: nil, osPrettyName: nil, image: "ghcr.io/trycua/linux:24.04", imageDigest: nil,
kind: .container, arch: nil, reachable: true, error: nil, host: nil, hostName: nil,
- power: nil, powerState: "running", cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ power: nil, powerState: "running", cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
}
func eventually(_ seconds: Double = 120, _ condition: @MainActor () -> Bool) async -> Bool {
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
index 9a0f470a8a..71b26fd6de 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
@@ -616,7 +616,7 @@ struct ViewModelTests {
features: [], addedAt: nil, os: nil, osName: nil, osPrettyName: nil, image: nil,
imageDigest: nil, kind: nil, arch: nil, reachable: false, error: nil,
host: "96fe", hostName: "gamma-4 Mac Studio", power: nil, powerState: nil,
- cloud: nil, cloudPlace: nil, cloudDelete: nil)
+ cloud: nil, cloudPlace: nil, cloudDelete: nil, stopReason: nil)
let backend = FixtureSpacesBackend(rows: [record])
backend.holdCreates = true
let model = makeModel(backend)
@@ -1005,7 +1005,7 @@ struct ViewModelTests {
AppSpaceRow(id: id, name: name, provider: "relay", spacesdVersion: "0.4.0", features: [], addedAt: nil,
os: .linux, osName: nil, osPrettyName: nil, image: nil, imageDigest: nil, kind: nil, arch: nil,
reachable: true, error: nil, host: nil, hostName: nil, power: nil, powerState: nil,
- cloud: cloud, cloudPlace: place, cloudDelete: delete)
+ cloud: cloud, cloudPlace: place, cloudDelete: delete, stopReason: nil)
}
let backend = FixtureSpacesBackend(rows: [
cloudRow("relay:cloud-0000000000000a01", "research-box", "aws", "AWS \u{b7} us-west-2", "here"),
diff --git a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts b/apps/cua-spaces-web/src/bridge/adapters/webkit.ts
index 7a1d2a4cce..a3fa0d9313 100644
--- a/apps/cua-spaces-web/src/bridge/adapters/webkit.ts
+++ b/apps/cua-spaces-web/src/bridge/adapters/webkit.ts
@@ -122,6 +122,7 @@ export function spaceToRow(s: WkSpace): SpaceRow {
hostName: opt(s.hostName),
power: s.power?.control,
powerState: running ? "running" : powerState,
+ stopReason: off ? opt(s.power?.stopReason) : undefined,
cloud: opt(s.cloud),
cloudPlace: opt(s.cloudPlace),
cloudDelete: opt(s.cloudDelete),
diff --git a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
index 09593b94d0..e8a0b650f0 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
+++ b/apps/cua-spaces-web/src/bridge/contracts/bridge-shapes.json
@@ -2479,6 +2479,9 @@
"powerState": {
"type": "string"
},
+ "stopReason": {
+ "type": "string"
+ },
"cloud": {
"type": "string"
},
@@ -3981,6 +3984,12 @@
"string",
"null"
]
+ },
+ "stopReason": {
+ "type": [
+ "string",
+ "null"
+ ]
}
},
"required": [
diff --git a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
index 1ef78501aa..d4fc9e635f 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/shapes.ts
@@ -104,6 +104,7 @@ const SpaceRowShape = ref(
hostName: opt(str),
power: opt(str),
powerState: opt(str),
+ stopReason: opt(str),
cloud: opt(str),
cloudPlace: opt(str),
cloudDelete: opt(str),
@@ -952,7 +953,7 @@ const WkSpaceShape = ref(
arch: optNull(str),
host: optNull(str),
hostName: optNull(str),
- power: optNull(object({ control: str, off: bool, turningOn: optNull(bool), error: optNull(str) })),
+ power: optNull(object({ control: str, off: bool, turningOn: optNull(bool), error: optNull(str), stopReason: optNull(str) })),
cloud: optNull(str),
cloudPlace: optNull(str),
cloudDelete: optNull(str),
diff --git a/apps/cua-spaces-web/src/bridge/contracts/spaces.ts b/apps/cua-spaces-web/src/bridge/contracts/spaces.ts
index 7fdd2839f8..4bf36baa41 100644
--- a/apps/cua-spaces-web/src/bridge/contracts/spaces.ts
+++ b/apps/cua-spaces-web/src/bridge/contracts/spaces.ts
@@ -138,6 +138,8 @@ export interface SpacePower {
turningOn?: boolean | null;
/** Why the last power action failed, until the next one. */
error?: string | null;
+ /** Why it stopped without being asked to ("out of memory"), while it is off. */
+ stopReason?: string | null;
}
/** How far a Space being created has come. */
@@ -194,6 +196,8 @@ export interface SpaceRow {
power?: string;
/** `running`, `suspended` or `stopped` as cua last left it, when known. */
powerState?: string;
+ /** Why a local Space stopped without being asked to ("out of memory"), when it did. */
+ stopReason?: string;
/** For a Space in your cloud: the provider word (`aws`, `gcp`, `modal`),
* its account and region in words ("AWS · us-west-2"), and where Delete
* Permanently can delete it (`here`, `host:<machine>`, `elsewhere`). */
diff --git a/apps/cua-spaces-web/src/bridge/derive.ts b/apps/cua-spaces-web/src/bridge/derive.ts
index 1f9941b3d2..0a3027e5f0 100644
--- a/apps/cua-spaces-web/src/bridge/derive.ts
+++ b/apps/cua-spaces-web/src/bridge/derive.ts
@@ -67,7 +67,8 @@ function fallbackRowToSpace(row: SpaceRow, now: number): Space {
name: displayName(row.name || row.id),
os,
status,
- detail: status === "running" ? "Running" : "Stopped",
+ // "Stopped: out of memory" when it stopped on its own (`spaces::off_text`).
+ detail: status === "running" ? "Running" : off && row.stopReason ? `Stopped: ${row.stopReason}` : "Stopped",
lastUsedAt: Number.isFinite(added) ? added : now,
scene: SCENES[os],
provider: row.provider,
@@ -80,7 +81,11 @@ function fallbackRowToSpace(row: SpaceRow, now: number): Space {
host: row.host,
hostName: row.hostName,
power: row.power
- ? { control: row.power === "stop" ? "stop" : "suspend", off: status !== "running" }
+ ? {
+ control: row.power === "stop" ? "stop" : "suspend",
+ off: status !== "running",
+ stopReason: off && row.stopReason ? row.stopReason : undefined,
+ }
: undefined,
};
}
diff --git a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts b/apps/cua-spaces-web/src/bridge/webkit-protocol.ts
index e1018d9fdf..1a6d81ab6f 100644
--- a/apps/cua-spaces-web/src/bridge/webkit-protocol.ts
+++ b/apps/cua-spaces-web/src/bridge/webkit-protocol.ts
@@ -236,7 +236,7 @@ export interface WkSpace {
arch?: string | null;
host?: string | null;
hostName?: string | null;
- power?: { control: "suspend" | "stop" | (string & {}); off: boolean; turningOn?: boolean | null; error?: string | null } | null;
+ power?: { control: "suspend" | "stop" | (string & {}); off: boolean; turningOn?: boolean | null; error?: string | null; stopReason?: string | null } | null;
cloud?: string | null;
cloudPlace?: string | null;
cloudDelete?: string | null;
diff --git a/apps/cua-spaces/src-tauri/src/core.rs b/apps/cua-spaces/src-tauri/src/core.rs
index f46c43315a..6239357eaf 100644
--- a/apps/cua-spaces/src-tauri/src/core.rs
+++ b/apps/cua-spaces/src-tauri/src/core.rs
@@ -426,6 +426,9 @@ pub struct SpaceRow {
pub cloud_place: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_delete: Option<String>,
+ /// Why a local Space stopped without being asked to ("out of memory").
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub stop_reason: Option<String>,
}
/// The name to show for a registered Space: the app core's rule (a
@@ -460,6 +463,7 @@ impl SpaceRow {
cloud: (!info.cloud.is_empty()).then_some(info.cloud),
cloud_place: (!info.cloud_place.is_empty()).then_some(info.cloud_place),
cloud_delete: (!info.cloud_delete.is_empty()).then_some(info.cloud_delete),
+ stop_reason: (!info.stop_reason.is_empty()).then_some(info.stop_reason),
}
}
diff --git a/apps/cua-spaces/src/model/types.ts b/apps/cua-spaces/src/model/types.ts
index 00388cf63e..35faa18673 100644
--- a/apps/cua-spaces/src/model/types.ts
+++ b/apps/cua-spaces/src/model/types.ts
@@ -121,6 +121,8 @@ export interface Space {
cloud?: string;
cloudPlace?: string;
cloudDelete?: string;
+ /** Why a local Space stopped without being asked to ("out of memory"). */
+ stopReason?: string;
}
/** A Space's power (the app core's `model::SpacePower`). */
@@ -133,6 +135,8 @@ export interface SpacePower {
turningOn?: boolean | null;
/** Why the last power action failed, until the next one. */
error?: string | null;
+ /** Why it stopped without being asked to ("out of memory"), while it is off. */
+ stopReason?: string | null;
}
/** How far a Space being created has come. */
diff --git a/docs/content/docs/cua-sdk/reference/protocol/daemon-sandboxes.mdx b/docs/content/docs/cua-sdk/reference/protocol/daemon-sandboxes.mdx
index 4992d9d7fa..1d4f91d749 100644
--- a/docs/content/docs/cua-sdk/reference/protocol/daemon-sandboxes.mdx
+++ b/docs/content/docs/cua-sdk/reference/protocol/daemon-sandboxes.mdx
@@ -214,6 +214,7 @@ A sandbox.
| `id` | 15 | `string` | Qualified ref: "local:&lt;name&gt;", "cloud:&lt;name&gt;" or "direct:&lt;host:port&gt;". Every request's `name` accepts it (and a bare name when that name is unique across locations). |
| `kind` | 16 | `string` | What kind of machine it runs as: "container" or "vm"; empty when not known (an existing machine, or a cloud sandbox this daemon did not create). |
| `runtime` | 17 | `string` | The engine that runs it: "gvisor", "runc", "qemu", "lume" or "kubevirt"; empty when not known. |
+| `stop_reason` | 18 | `string` | Why a local sandbox stopped without being asked to, in plain words: "out of memory", "killed", "exited" or "exited with code N". Empty otherwise, and once it is started again. |
### ReadinessProbe
diff --git a/docs/content/docs/cua-sdk/reference/protocol/daemon-spaces.mdx b/docs/content/docs/cua-sdk/reference/protocol/daemon-spaces.mdx
index b09c2c5ac1..dfa7ec9b2f 100644
--- a/docs/content/docs/cua-sdk/reference/protocol/daemon-spaces.mdx
+++ b/docs/content/docs/cua-sdk/reference/protocol/daemon-spaces.mdx
@@ -216,6 +216,7 @@ A registered Space.
| `cloud` | 18 | `string` | A Space in the owner's own cloud: the provider ("aws", "gcp", "modal"); empty otherwise. |
| `cloud_place` | 19 | `string` | Where it runs, for people ("AWS · us-west-2"); empty otherwise. |
| `cloud_delete` | 20 | `string` | How this device would delete it permanently: "here" (this cua home created it and records it), "host:&lt;machine&gt;" (ask the device that created it, through the relay) or "elsewhere" (only from the device that created it). Empty for other Spaces. |
+| `stop_reason` | 21 | `string` | Why a local Space stopped without being asked to, in plain words: "out of memory", "killed", "exited" or "exited with code N". Empty otherwise, and once it is started again. Filled in when listed, not stored. |
### AddSpaceRequest
diff --git a/docs/content/docs/cua-sdk/reference/rust/cua-sandbox-core.mdx b/docs/content/docs/cua-sdk/reference/rust/cua-sandbox-core.mdx
index dbd39e89a7..b381250e44 100644
--- a/docs/content/docs/cua-sdk/reference/rust/cua-sandbox-core.mdx
+++ b/docs/content/docs/cua-sdk/reference/rust/cua-sandbox-core.mdx
@@ -551,6 +551,7 @@ pub trait LocalRuntime: Send + Sync {
async fn suspend(&self, name: &str) -> RuntimeResult<()>;
async fn resume(&self, name: &str) -> RuntimeResult<LocalInstance>;
fn power_control(&self, runtime_type: &str) -> Option<PowerControl>;
+ async fn stop_reason(&self, name: &str, runtime_type: &str) -> RuntimeResult<Option<StopReason>>;
async fn fork(&self, source: &str, new_name: &str) -> RuntimeResult<()>;
async fn checkpoint(&self, name: &str, checkpoint: &str) -> RuntimeResult<()>;
async fn list(&self) -> RuntimeResult<Vec<LocalSummary>>;
@@ -1180,6 +1181,9 @@ impl Sandboxes {
fn remember_direct(&self, name: &str, url: &str) -> Result<()>;
async fn list(&self) -> Result<Vec<SandboxInfo>>;
async fn get(&self, name: &str) -> Result<SandboxInfo>;
+ fn stop_reason(&self, name: &str) -> Option<StopReason>;
+ async fn note_unasked_stops(&self) -> Vec<(String, StopReason)>;
+ fn spawn_stop_watch(&self) -> JoinHandle<()>;
async fn suspend(&self, name: &str) -> Result<()>;
async fn resume(&self, name: &str) -> Result<()>;
async fn restart(&self, name: &str) -> Result<()>;
@@ -1221,6 +1225,7 @@ pub struct SandboxInfo {
pub provider: ProviderKind,
pub runtime_type: String,
pub status: Status,
+ pub stop_reason: Option<StopReason>,
}
```
@@ -1263,6 +1268,7 @@ impl SandboxState {
fn name(&self) -> &str;
fn runtime_type(&self) -> &str;
fn status(&self) -> &str;
+ fn stop_reason(&self) -> Option<StopReason>;
}
```
@@ -1402,6 +1408,7 @@ impl StateStore {
fn load_raw(&self, name: &str) -> Option<Map<String, Value>>;
fn update(&self, name: &str, fields: Map<String, Value>) -> Result<()>;
fn set_status(&self, name: &str, status: &str) -> Result<()>;
+ fn record_stop(&self, name: &str, reason: &StopReason) -> Result<()>;
fn delete(&self, name: &str) -> Result<()>;
fn write_lease(&self, name: &str, pid: u32) -> Result<()>;
fn remove_lease(&self, name: &str) -> Result<()>;
@@ -1424,6 +1431,20 @@ pub enum Status {
}
```
+### `StopReason`
+
+Why a sandbox stopped without being asked to, as its ...
+
+```rust
+pub struct StopReason {
+ pub exit_code: i64,
+ pub out_of_memory: bool,
+}
+impl StopReason {
+ fn words(&self) -> String;
+}
+```
+
### `Tunnel`
TCP forwarding for a sandbox.
@@ -1613,6 +1634,10 @@ pub const DEFAULT_PATH: &str = "/mcp";
// mod settings
/// Every setting, in display order.
pub const KEYS: [Key; 9] = _;
+
+// mod state
+/// State-file key: why a local sandbox ...
+pub const STOP_REASON: &str = "stop_reason";
```
## Type aliases
diff --git a/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx b/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
index eb3f89852e..4a982c884a 100644
--- a/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
+++ b/docs/content/docs/cua-sdk/reference/rust/cua-spaces.mdx
@@ -1604,6 +1604,7 @@ pub struct SpaceInfo {
pub cloud_place: String,
pub cloud_delete: String,
pub status: String,
+ pub stop_reason: String,
}
```
@@ -1672,6 +1673,7 @@ impl Spaces {
async fn refresh_thumbnails(&self) -> usize;
fn spawn_thumbnail_refresh(&self) -> JoinHandle<()>;
fn power_of(&self, id: &str) -> (String, String);
+ fn stop_reason_of(&self, id: &str) -> String;
async fn stop(&self, space: &str) -> Result<SpacePower>;
async fn start(&self, space: &str) -> Result<SpacePower>;
fn download_dir(&self) -> &Path;
diff --git a/docs/content/docs/cua-sdk/reference/sandbox/index.mdx b/docs/content/docs/cua-sdk/reference/sandbox/index.mdx
index fff8b55467..e08aac890a 100644
--- a/docs/content/docs/cua-sdk/reference/sandbox/index.mdx
+++ b/docs/content/docs/cua-sdk/reference/sandbox/index.mdx
@@ -888,6 +888,7 @@ Returned by [`Sandbox.info`](#sandbox), [`Sandbox.refresh`](/cua-sdk/reference/s
| `expires_at_unix` / `expiresAtUnix` | `Option<i64>` | | When it expires unless kept alive (unix seconds), when known. |
| `provider_details` / `providerDetails` | `HashMap<String, String>` | | Provider internals (cloud: `pool`, `namespace`, `claim`; local: `backend`, `container_id`). Not part of the portable API. |
| `image_info` / `imageInfo` | [`Option<ImageInfo>`](/cua-sdk/reference/image#imageinfo-record) | `None` | The image as resolved and pinned at create time (digest, variant). `None` for direct connections, named pools, images not resolved from a registry, and the daemon topology. |
+| `stop_reason` / `stopReason` | `Option<String>` | `None` | Why a local sandbox stopped without being asked to, in plain words ("out of memory", "killed", "exited with code 1"); `None` otherwise. |
## `SandboxListing` record
diff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/power.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/power.mdx
index fd6315b001..2a378fe77a 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/power.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/power.mdx
@@ -77,6 +77,7 @@ Returned by [`app_power_button`](#app_power_button).
| `off` | `bool` | | It is off: suspended or stopped as the SDK recorded it, or not answering with no recorded state (a Space one of your machines provides). |
| `turning_on` / `turningOn` | `Option<bool>` | | Being turned on (`true`) or off (`false`) now. |
| `error` | `Option<String>` | | Why the last power action failed, until the next one. |
+| `stop_reason` / `stopReason` | `Option<String>` | | Why it stopped without being asked to, in plain words ("out of memory"), while it is off. |
## `AppPowerControl` enum
diff --git a/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx b/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
index 7ee617c056..38536cb92c 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/app-core/spaces.mdx
@@ -631,6 +631,7 @@ Returned by [`app_space_rows_from_json`](#app_space_rows_from_json).
| `cloud` | `Option<String>` | | For a Space in your cloud: the provider word (`aws`, `gcp`, `modal`). |
| `cloud_place` / `cloudPlace` | `Option<String>` | | Its account and region in words ("AWS · us-west-2"). |
| `cloud_delete` / `cloudDelete` | `Option<String>` | | Where Delete permanently can delete it: `here`, `host:<machine>` (that machine created it) or `elsewhere` (another device did). |
+| `stop_reason` / `stopReason` | `Option<String>` | | Why a local Space stopped without being asked to, in plain words ("out of memory", "killed", "exited with code 1"), as the SDK recorded it; absent otherwise. |
## `AppSpaceSdkRef` record
diff --git a/docs/content/docs/cua-sdk/reference/spaces/index.mdx b/docs/content/docs/cua-sdk/reference/spaces/index.mdx
index 3784b704a8..6d0b49dde8 100644
--- a/docs/content/docs/cua-sdk/reference/spaces/index.mdx
+++ b/docs/content/docs/cua-sdk/reference/spaces/index.mdx
@@ -1085,6 +1085,7 @@ Returned by [`Space.info`](/cua-sdk/reference/spaces/space#space), [`Spaces.add`
| `cloud` | `String` | | A Space in your own cloud: the provider (`aws`, `gcp`, `modal`); empty otherwise. |
| `cloud_place` / `cloudPlace` | `String` | | Where it runs ("AWS · us-west-2"). |
| `cloud_delete` / `cloudDelete` | `String` | | How `delete` would delete it permanently from here: `here` (this device created it), `host:<machine>` (the device that created it, through the relay) or `elsewhere` (only there; `remove` keeps it). Empty for other Spaces. |
+| `stop_reason` / `stopReason` | `String` | `""` | Why a local Space stopped without being asked to, in plain words ("out of memory", "killed", "exited with code 1"); empty otherwise, and once it is started again. |
## `SpacePowerReport` record
diff --git a/libs/cua/crates/cua-cli/src/host.rs b/libs/cua/crates/cua-cli/src/host.rs
index 528162b14c..9a9dc74d2b 100644
--- a/libs/cua/crates/cua-cli/src/host.rs
+++ b/libs/cua/crates/cua-cli/src/host.rs
@@ -546,6 +546,7 @@ fn space_json(s: &cua_sdk::SpaceInfo) -> serde_json::Value {
"host_name": s.host_name,
"power": s.power,
"power_state": s.power_state,
+ "stop_reason": s.stop_reason,
})
}
@@ -1939,6 +1940,10 @@ fn grouped_lines(list: &[cua_spaces::SpaceInfo]) -> Vec<String> {
// 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()) {
+ // One that stopped on its own says why ("stopped: out of memory").
+ ("stopped", _) if !s.stop_reason.is_empty() => {
+ format!("{} (stopped: {})", line.trim_end(), s.stop_reason)
+ }
("suspended" | "stopped", _) => format!("{} ({})", line.trim_end(), s.power_state),
(_, status) if !status.is_empty() => format!("{} ({status})", line.trim_end()),
_ => line,
@@ -2286,6 +2291,7 @@ mod tests {
cloud_place: String::new(),
cloud_delete: String::new(),
status: String::new(),
+ stop_reason: String::new(),
};
let mut list = vec![
space("local:box", ""),
@@ -2343,6 +2349,7 @@ mod tests {
cloud_place: String::new(),
cloud_delete: String::new(),
status: String::new(),
+ stop_reason: String::new(),
};
let lines = grouped_lines(&[
space("relay:space-1", "mini1234"),
@@ -2411,6 +2418,7 @@ mod tests {
cloud_place: String::new(),
cloud_delete: String::new(),
status: String::new(),
+ stop_reason: String::new(),
};
let lines = grouped_lines(std::slice::from_ref(&s));
let cols: Vec<&str> = lines[0].split_whitespace().collect();
@@ -2418,6 +2426,23 @@ mod tests {
cols,
["local:e2e-1005-cli", "e2e-1005-cli", "local", "0.5.3"]
);
+ // Stopped on its own: the line says why, and so does --json.
+ s.power = "stop".into();
+ s.power_state = "stopped".into();
+ s.stop_reason = "out of memory".into();
+ let lines = grouped_lines(std::slice::from_ref(&s));
+ assert!(
+ lines[0].ends_with("(stopped: out of memory)"),
+ "{}",
+ lines[0]
+ );
+ assert_eq!(
+ ls_json(std::slice::from_ref(&s))[0]["stop_reason"],
+ "out of memory"
+ );
+ s.stop_reason = String::new();
+ let lines = grouped_lines(std::slice::from_ref(&s));
+ assert!(lines[0].ends_with("(stopped)"), "{}", lines[0]);
let json = ls_json(std::slice::from_ref(&s));
assert_eq!(json[0]["id"], "local:e2e-1005-cli");
assert_eq!(json[0]["name"], "327b8dc70418");
diff --git a/libs/cua/crates/cua-cli/src/sandbox.rs b/libs/cua/crates/cua-cli/src/sandbox.rs
index ed5c4de893..3bc5cd9b32 100644
--- a/libs/cua/crates/cua-cli/src/sandbox.rs
+++ b/libs/cua/crates/cua-cli/src/sandbox.rs
@@ -1208,6 +1208,8 @@ pub fn info_json(i: &SandboxInfo) -> serde_json::Value {
"name": i.name,
"status": row_status(i),
"state": status_of(i),
+ // Why it stopped without being asked to ("out of memory"), or null.
+ "stop_reason": i.stop_reason,
"location": i.location,
"kind": i.kind,
"runtime": i.runtime,
@@ -1228,6 +1230,16 @@ pub fn info_json(i: &SandboxInfo) -> serde_json::Value {
})
}
+/// A listing's STATUS cell: the row's status, and why it stopped when it
+/// stopped on its own (`stopped (out of memory)`).
+fn status_cell(row: &serde_json::Value) -> String {
+ let status = row["status"].as_str().unwrap_or_default();
+ match row["stop_reason"].as_str().filter(|r| !r.is_empty()) {
+ Some(why) if status == "stopped" => format!("{status} ({why})"),
+ _ => status.to_string(),
+ }
+}
+
/// The status a listing shows: the portable phase, or `missing` for a
/// record whose VM or container is gone.
fn row_status(i: &SandboxInfo) -> &'static str {
@@ -1855,7 +1867,7 @@ pub async fn run(
} else {
line(out, format!("Name: {}", i.name));
line(out, format!("Id: {}", i.id));
- line(out, format!("Status: {}", row_status(&i)));
+ line(out, format!("Status: {}", status_cell(&info_json(&i))));
line(out, format!("Location: {}", i.location));
line(out, format!("Expires: {}", expires_of(i.expires_at_unix)));
if let Some(img) = &i.image {
@@ -2444,7 +2456,7 @@ async fn ls(
.map(|r| {
let mut row = vec![
s(&r["id"]),
- s(&r["status"]),
+ status_cell(r),
s(&r["location"]),
dash(&r["kind"]),
dash(&r["runtime"]),
@@ -3092,6 +3104,25 @@ pub(crate) fn confirm_delete(
mod tests {
use super::*;
+ #[test]
+ fn a_space_that_stopped_on_its_own_says_why_in_the_listing() {
+ let row = |status: &str, why: serde_json::Value| serde_json::json!({"status": status, "stop_reason": why});
+ assert_eq!(
+ status_cell(&row("stopped", "out of memory".into())),
+ "stopped (out of memory)"
+ );
+ assert_eq!(
+ status_cell(&row("stopped", serde_json::Value::Null)),
+ "stopped"
+ );
+ assert_eq!(status_cell(&row("ready", serde_json::Value::Null)), "ready");
+ // A row from a daemon that sends no reason.
+ assert_eq!(
+ status_cell(&serde_json::json!({"status": "stopped"})),
+ "stopped"
+ );
+ }
+
use cua_sandbox_core::{
InstanceStatus, LocalEndpoints, LocalInstance, LocalRuntime, LocalStartSpec, LocalSummary,
RuntimeError,
@@ -3422,6 +3453,7 @@ mod tests {
("namespace".to_string(), "cua-auto-abc".to_string()),
]),
image_info: None,
+ stop_reason: None,
};
let m = kept_message(&info);
assert!(m.contains("cloud:cua-e2e-kept"), "{m}");
diff --git a/libs/cua/crates/cua-daemon/src/convert.rs b/libs/cua/crates/cua-daemon/src/convert.rs
index 370fe02882..fba979b6c4 100644
--- a/libs/cua/crates/cua-daemon/src/convert.rs
+++ b/libs/cua/crates/cua-daemon/src/convert.rs
@@ -128,6 +128,7 @@ pub fn info_to_pb(r: &SandboxRecord) -> pb::Sandbox {
id: r.id.clone(),
kind: r.kind.clone(),
runtime: r.runtime.clone(),
+ stop_reason: r.stop_reason.clone().unwrap_or_default(),
}
}
@@ -168,6 +169,7 @@ pub fn info_from_pb(s: &pb::Sandbox) -> SandboxRecord {
provider_details: s.provider_details.clone().into_iter().collect(),
// Not on the daemon wire.
image_info: None,
+ stop_reason: (!s.stop_reason.is_empty()).then(|| s.stop_reason.clone()),
}
}
@@ -221,6 +223,7 @@ mod tests {
expires_at: Some(UNIX_EPOCH + Duration::from_secs(905)),
provider_details: [("claim".to_string(), "c-1".to_string())].into(),
image_info: None,
+ stop_reason: Some("out of memory".into()),
};
assert_eq!(info_from_pb(&info_to_pb(&r)), r);
// An older daemon sends no id: it is derived from the location.
diff --git a/libs/cua/crates/cua-daemon/src/local.rs b/libs/cua/crates/cua-daemon/src/local.rs
index e9f6083f6b..822c2f392b 100644
--- a/libs/cua/crates/cua-daemon/src/local.rs
+++ b/libs/cua/crates/cua-daemon/src/local.rs
@@ -1030,6 +1030,33 @@ impl LocalRuntime for VmmLocal {
Ok(out)
}
+ /// A container's exit record (its code and `OOMKilled`), read from the
+ /// engine only while it is up: the built-in Linux runtime is never
+ /// booted for it. Other runtimes keep no such record.
+ async fn stop_reason(
+ &self,
+ name: &str,
+ runtime_type: &str,
+ ) -> RuntimeResult<Option<cua_sandbox_core::StopReason>> {
+ if !matches!(
+ runtime_type.trim().to_ascii_lowercase().as_str(),
+ "gvisor" | "runsc" | "runc" | "container" | "docker"
+ ) {
+ return Ok(None);
+ }
+ let Some(rt) = self.container_if_up().await else {
+ return Ok(None);
+ };
+ Ok(rt
+ .exit_of(name)
+ .await
+ .map_err(rt_err)?
+ .map(|e| cua_sandbox_core::StopReason {
+ exit_code: e.exit_code,
+ out_of_memory: e.oom_killed,
+ }))
+ }
+
async fn status(&self, name: &str) -> RuntimeResult<InstanceStatus> {
let (_, rt) = self.owner(name).await?;
rt.status(name).await.map(status_of).map_err(rt_err)
diff --git a/libs/cua/crates/cua-daemon/src/runtime.rs b/libs/cua/crates/cua-daemon/src/runtime.rs
index de16a7771f..275d0da629 100644
--- a/libs/cua/crates/cua-daemon/src/runtime.rs
+++ b/libs/cua/crates/cua-daemon/src/runtime.rs
@@ -179,6 +179,9 @@ pub struct SandboxRecord {
/// The image as resolved and pinned at create time, when known (not
/// carried over the daemon wire).
pub image_info: Option<cua_sandbox_core::ImageInfo>,
+ /// Why a local sandbox stopped without being asked to, in plain words
+ /// ("out of memory"); `None` otherwise.
+ pub stop_reason: Option<String>,
}
/// How long a listing waits for Fleet before it lists without the cloud
@@ -249,6 +252,7 @@ async fn cloud_claims(fleet: &FleetClient) -> Result<Vec<SandboxRecord>> {
("claim".to_string(), name),
]),
image_info: None,
+ stop_reason: None,
});
}
}
@@ -1054,6 +1058,7 @@ impl Runtime {
expires_at: None,
provider_details: BTreeMap::new(),
image_info: None,
+ stop_reason: info.stop_reason.map(|r| r.words()),
});
}
return Err(e);
@@ -1118,6 +1123,7 @@ impl Runtime {
expires_at,
provider_details,
image_info: None,
+ stop_reason: info.stop_reason.map(|r| r.words()),
},
);
}
@@ -1128,7 +1134,14 @@ impl Runtime {
.get(key)
.map(|r| r.status.clone())
.unwrap_or(Status::Running);
- out.insert(key.clone(), record_of(key, h, status));
+ let stop_reason = out.get(key).and_then(|r| r.stop_reason.clone());
+ out.insert(
+ key.clone(),
+ SandboxRecord {
+ stop_reason,
+ ..record_of(key, h, status)
+ },
+ );
}
}
Ok(out
@@ -1725,6 +1738,7 @@ fn record_of(key: &str, h: &Handle, status: Status) -> SandboxRecord {
expires_at: sb.expires_at(),
provider_details: sb.provider_details(),
image_info: sb.image_info().cloned(),
+ stop_reason: None,
}
}
diff --git a/libs/cua/crates/cua-daemon/src/server.rs b/libs/cua/crates/cua-daemon/src/server.rs
index 911f1ad224..70ac9dfbf3 100644
--- a/libs/cua/crates/cua-daemon/src/server.rs
+++ b/libs/cua/crates/cua-daemon/src/server.rs
@@ -282,6 +282,9 @@ 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();
+ // 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();
let own = std::env::current_exe()
.ok()
.and_then(|e| crate::identity::of(&e));
diff --git a/libs/cua/crates/cua-daemon/src/spaces_svc.rs b/libs/cua/crates/cua-daemon/src/spaces_svc.rs
index dac0f7f9c1..f82319d98e 100644
--- a/libs/cua/crates/cua-daemon/src/spaces_svc.rs
+++ b/libs/cua/crates/cua-daemon/src/spaces_svc.rs
@@ -62,6 +62,7 @@ mod imp {
cloud: info.cloud.clone(),
cloud_place: info.cloud_place.clone(),
cloud_delete: info.cloud_delete.clone(),
+ stop_reason: info.stop_reason.clone(),
}
}
@@ -198,6 +199,7 @@ mod imp {
let mut spaces = self.spaces().registry().list().map_err(|e| st(e.into()))?;
for s in &mut spaces {
(s.power, s.power_state) = self.spaces().power_of(&s.id);
+ s.stop_reason = self.spaces().stop_reason_of(&s.id);
}
// Plus the signed-in account's relay machines (refreshed).
for info in self.spaces().list_all().await.map_err(|e| st(e.into()))? {
diff --git a/libs/cua/crates/cua-proto/tests/roundtrip.rs b/libs/cua/crates/cua-proto/tests/roundtrip.rs
index 87edba1f95..65467c7953 100644
--- a/libs/cua/crates/cua-proto/tests/roundtrip.rs
+++ b/libs/cua/crates/cua-proto/tests/roundtrip.rs
@@ -422,6 +422,7 @@ fn daemon_messages_roundtrip() {
id: "local:dev".into(),
kind: "container".into(),
runtime: "gvisor".into(),
+ stop_reason: "out of memory".into(),
}),
});
roundtrip(&daemon::CreateSpaceRequest {
diff --git a/libs/cua/crates/cua-sandbox-core/src/lib.rs b/libs/cua/crates/cua-sandbox-core/src/lib.rs
index c205572763..13646f4c9b 100644
--- a/libs/cua/crates/cua-sandbox-core/src/lib.rs
+++ b/libs/cua/crates/cua-sandbox-core/src/lib.rs
@@ -64,7 +64,7 @@ pub use fleet_local::{
pub use http::{HttpResponse, RequestBody, ServiceEndpoint, StreamingResponse};
pub use mcp::{McpClient, McpConfig};
pub use pool_image::pool_image_info;
-pub use power::{PowerControl, PowerState};
+pub use power::{PowerControl, PowerState, StopReason};
pub use provider::{
CLOUD_LOCATIONS, CONTRIB_LOCATIONS, ImageMode, PortExposure, Provider, ProviderCapabilities,
ProviderCreate, ProviderImage, ProviderInstance, RunKind, is_cloud_location,
diff --git a/libs/cua/crates/cua-sandbox-core/src/power.rs b/libs/cua/crates/cua-sandbox-core/src/power.rs
index 5f042c0c73..94b1ba536d 100644
--- a/libs/cua/crates/cua-sandbox-core/src/power.rs
+++ b/libs/cua/crates/cua-sandbox-core/src/power.rs
@@ -84,6 +84,32 @@ impl PowerState {
}
}
+/// Why a sandbox stopped without being asked to, as its engine recorded
+/// it (a container's exit code and `OOMKilled`).
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
+pub struct StopReason {
+ /// The exit code (137: killed with SIGKILL).
+ pub exit_code: i64,
+ /// The kernel killed it for memory.
+ #[serde(default)]
+ pub out_of_memory: bool,
+}
+
+impl StopReason {
+ /// The reason in plain words: "out of memory", "killed", "exited", or
+ /// "exited with code N".
+ pub fn words(&self) -> String {
+ if self.out_of_memory {
+ return "out of memory".into();
+ }
+ match self.exit_code {
+ 0 => "exited".into(),
+ 137 => "killed".into(),
+ code => format!("exited with code {code}"),
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -105,4 +131,19 @@ mod tests {
assert_eq!(PowerControl::Suspend.off_state(), PowerState::Suspended);
assert_eq!(PowerControl::Stop.off_state(), PowerState::Stopped);
}
+
+ #[test]
+ fn a_stop_reason_is_said_in_plain_words() {
+ let r = |exit_code, out_of_memory| StopReason {
+ exit_code,
+ out_of_memory,
+ };
+ assert_eq!(r(137, true).words(), "out of memory");
+ assert_eq!(r(137, false).words(), "killed");
+ assert_eq!(r(0, false).words(), "exited");
+ assert_eq!(r(1, false).words(), "exited with code 1");
+ // A record without the OOM flag (an older writer) reads as not OOM.
+ let old: StopReason = serde_json::from_str(r#"{"exit_code":137}"#).unwrap();
+ assert_eq!(old, r(137, false));
+ }
}
diff --git a/libs/cua/crates/cua-sandbox-core/src/runtime.rs b/libs/cua/crates/cua-sandbox-core/src/runtime.rs
index ad29d8e4fd..bd4caef190 100644
--- a/libs/cua/crates/cua-sandbox-core/src/runtime.rs
+++ b/libs/cua/crates/cua-sandbox-core/src/runtime.rs
@@ -336,6 +336,19 @@ pub trait LocalRuntime: Send + Sync {
None
}
+ /// Why the instance `name` (that `runtime_type` runs) stopped, once it
+ /// has: its engine's exit record. `None` while it runs, when the engine
+ /// keeps no such record, or when the engine is not up now (this never
+ /// boots one). Default: none.
+ async fn stop_reason(
+ &self,
+ name: &str,
+ runtime_type: &str,
+ ) -> RuntimeResult<Option<crate::StopReason>> {
+ let _ = (name, runtime_type);
+ Ok(None)
+ }
+
/// Copy-on-write clone of a stopped instance or checkpoint.
async fn fork(&self, source: &str, new_name: &str) -> RuntimeResult<()> {
Err(RuntimeError::Unsupported {
diff --git a/libs/cua/crates/cua-sandbox-core/src/sandbox.rs b/libs/cua/crates/cua-sandbox-core/src/sandbox.rs
index c08e19b72f..ee852f33c2 100644
--- a/libs/cua/crates/cua-sandbox-core/src/sandbox.rs
+++ b/libs/cua/crates/cua-sandbox-core/src/sandbox.rs
@@ -108,6 +108,10 @@ pub enum Probe {
},
}
+/// How often [`Sandboxes::spawn_stop_watch`] looks for local sandboxes
+/// that stopped on their own.
+pub const STOP_WATCH_EVERY: Duration = Duration::from_secs(15);
+
/// How long a local resume waits for the probes its create waited for.
pub const RESUME_READY_TIMEOUT: Duration = Duration::from_secs(180);
@@ -715,6 +719,9 @@ pub struct SandboxInfo {
pub runtime_type: String,
/// Status.
pub status: Status,
+ /// Why a local sandbox stopped without being asked to (out of memory,
+ /// killed, exited), until it is started again.
+ pub stop_reason: Option<crate::StopReason>,
}
// One per sandbox handle; size does not matter here.
@@ -2144,10 +2151,17 @@ impl Sandboxes {
provider,
runtime_type: s.runtime_type().into(),
status: status_word(s.status()),
+ stop_reason: s.stop_reason(),
},
);
}
if let Some(rt) = &self.inner.local {
+ // Those that stopped on their own since: recorded with why.
+ for (name, reason) in self.note_unasked_stops().await {
+ if let Some(row) = out.get_mut(&format!("local:{name}")) {
+ row.stop_reason = Some(reason);
+ }
+ }
let listed = rt.list().await?;
// Local state files the backend listing leaves out (a Lume VM,
// or a VM or container that is gone) get their live status: the
@@ -2180,6 +2194,12 @@ impl Sandboxes {
Some(known) if !known.runtime_type.is_empty() => known.runtime_type.clone(),
_ => i.backend,
};
+ let status: Status = i.status.into();
+ // A reason holds only while it is still stopped.
+ let stop_reason = out
+ .get(&id)
+ .and_then(|known| known.stop_reason)
+ .filter(|_| status == Status::Stopped);
out.insert(
id.clone(),
SandboxInfo {
@@ -2187,7 +2207,8 @@ impl Sandboxes {
name: i.name,
provider: ProviderKind::Local,
runtime_type,
- status: i.status.into(),
+ status,
+ stop_reason,
},
);
}
@@ -2212,20 +2233,28 @@ impl Sandboxes {
provider: ProviderKind::Contrib,
runtime_type: s.runtime_type().into(),
status,
+ stop_reason: None,
})
}
Some(SandboxState::Local(l)) if l.runtime_type != "direct" => {
- let status = match self.local()?.status_on(name, &l.runtime_type).await {
+ let status: Status = match self.local()?.status_on(name, &l.runtime_type).await {
Ok(s) => s.into(),
Err(crate::RuntimeError::NotFound(_)) => Status::Unknown(MISSING.into()),
Err(e) => return Err(e.into()),
};
+ let stop_reason = match (&status, l.status.as_str()) {
+ // Recorded as running but stopped: it stopped on its own.
+ (Status::Stopped, "running") => self.note_stop(name, &l.runtime_type).await,
+ (Status::Stopped, _) => state.as_ref().and_then(SandboxState::stop_reason),
+ _ => None,
+ };
Ok(SandboxInfo {
id: format!("local:{name}"),
name: name.into(),
provider: ProviderKind::Local,
runtime_type: l.runtime_type.clone(),
status,
+ stop_reason,
})
}
Some(s) => Ok(SandboxInfo {
@@ -2238,6 +2267,7 @@ impl Sandboxes {
},
runtime_type: s.runtime_type().into(),
status: status_word(s.status()),
+ stop_reason: None,
}),
None => {
if let Some(rt) = &self.inner.local
@@ -2249,6 +2279,7 @@ impl Sandboxes {
provider: ProviderKind::Local,
runtime_type: i.backend,
status: i.status.into(),
+ stop_reason: None,
});
}
Err(Error::NotFound(name.into()))
@@ -2256,6 +2287,67 @@ impl Sandboxes {
}
}
+ /// Why the local sandbox `name` stopped without being asked to, as
+ /// recorded ([`Self::note_unasked_stops`]); `None` once it is started
+ /// again. Reads only the state file.
+ pub fn stop_reason(&self, name: &str) -> Option<crate::StopReason> {
+ self.inner.state.load(name)?.stop_reason()
+ }
+
+ /// Finds the local sandboxes recorded as running whose engine says they
+ /// stopped (out of memory, a crash: nobody asked), records each as
+ /// stopped with why, and logs it once. Returns those it recorded. Never
+ /// boots an engine: one that is down answers nothing.
+ pub async fn note_unasked_stops(&self) -> Vec<(String, crate::StopReason)> {
+ let mut out = Vec::new();
+ if self.inner.local.is_none() {
+ return out;
+ }
+ for s in self.inner.state.list_all() {
+ if provider_of(&s) != ProviderKind::Local
+ || s.status() != "running"
+ || s.runtime_type() == "direct"
+ {
+ continue;
+ }
+ if let Some(reason) = self.note_stop(s.name(), s.runtime_type()).await {
+ out.push((s.name().to_string(), reason));
+ }
+ }
+ out
+ }
+
+ /// [`Self::note_unasked_stops`] for one sandbox.
+ async fn note_stop(&self, name: &str, runtime_type: &str) -> Option<crate::StopReason> {
+ let rt = self.inner.local.as_ref()?;
+ let reason = rt.stop_reason(name, runtime_type).await.ok()??;
+ tracing::warn!(
+ sandbox = %name,
+ exit_code = reason.exit_code,
+ out_of_memory = reason.out_of_memory,
+ "{name} stopped without being asked to: {}",
+ reason.words()
+ );
+ if let Err(e) = self.inner.state.record_stop(name, &reason) {
+ tracing::warn!(sandbox = %name, "recording why it stopped: {e}");
+ }
+ Some(reason)
+ }
+
+ /// Runs [`Self::note_unasked_stops`] every [`STOP_WATCH_EVERY`] until
+ /// every handle is dropped (the daemon starts it once), so a Space that
+ /// stops on its own shows as stopped, and why, without anyone listing.
+ pub fn spawn_stop_watch(&self) -> tokio::task::JoinHandle<()> {
+ let weak = Arc::downgrade(&self.inner);
+ tokio::spawn(async move {
+ loop {
+ tokio::time::sleep(STOP_WATCH_EVERY).await;
+ let Some(inner) = weak.upgrade() else { return };
+ Sandboxes { inner }.note_unasked_stops().await;
+ }
+ })
+ }
+
fn kind_of(&self, name: &str) -> Result<(ProviderKind, SandboxState)> {
let s = self
.inner
diff --git a/libs/cua/crates/cua-sandbox-core/src/state.rs b/libs/cua/crates/cua-sandbox-core/src/state.rs
index 7169f7d7ce..619d568085 100644
--- a/libs/cua/crates/cua-sandbox-core/src/state.rs
+++ b/libs/cua/crates/cua-sandbox-core/src/state.rs
@@ -113,14 +113,33 @@ impl SandboxState {
}
}
+ /// Sets `status`. A recorded [`STOP_REASON`] belonged to the stop
+ /// before: any lifecycle change clears it.
fn set_status(&mut self, status: &str) {
match self {
SandboxState::Fleet(f) => f.status = status.into(),
- SandboxState::Local(l) => l.status = status.into(),
+ SandboxState::Local(l) => {
+ l.status = status.into();
+ l.extra.remove(STOP_REASON);
+ }
+ }
+ }
+
+ /// Why it stopped without being asked to, when that was recorded.
+ pub fn stop_reason(&self) -> Option<crate::StopReason> {
+ match self {
+ SandboxState::Local(l) => {
+ serde_json::from_value(l.extra.get(STOP_REASON)?.clone()).ok()
+ }
+ SandboxState::Fleet(_) => None,
}
}
}
+/// State-file key: why a local sandbox stopped without being asked to
+/// ([`crate::StopReason`]), until it is started again.
+pub const STOP_REASON: &str = "stop_reason";
+
/// `datetime.now(timezone.utc).isoformat()`.
pub fn python_utc_now() -> String {
let s = humantime::format_rfc3339_micros(SystemTime::now()).to_string();
@@ -288,6 +307,21 @@ impl StateStore {
Ok(())
}
+ /// Records that `name` stopped without being asked to, and why: its
+ /// status becomes `stopped` and [`STOP_REASON`] says why, until the
+ /// next lifecycle change.
+ pub fn record_stop(&self, name: &str, reason: &crate::StopReason) -> Result<()> {
+ if let Some(mut s) = self.load(name) {
+ s.set_status("stopped");
+ if let SandboxState::Local(l) = &mut s {
+ l.extra
+ .insert(STOP_REASON.into(), serde_json::to_value(reason)?);
+ }
+ self.save(&s)?;
+ }
+ Ok(())
+ }
+
/// Removes a state file (missing is fine).
pub fn delete(&self, name: &str) -> Result<()> {
match std::fs::remove_file(self.path(name)?) {
diff --git a/libs/cua/crates/cua-sandbox-core/tests/power.rs b/libs/cua/crates/cua-sandbox-core/tests/power.rs
index 48928ac0a5..72ef2c82dd 100644
--- a/libs/cua/crates/cua-sandbox-core/tests/power.rs
+++ b/libs/cua/crates/cua-sandbox-core/tests/power.rs
@@ -8,7 +8,7 @@ use cua_sandbox_core::{
Error, FleetState, ImageMode, InstanceStatus, LocalEndpoints, LocalInstance, LocalRuntime,
LocalStartSpec, LocalState, LocalSummary, PortExposure, PowerControl, PowerState, Provider,
ProviderCapabilities, ProviderCreate, ProviderInstance, ProviderKind, Result, RunKind,
- RuntimeError, RuntimeResult, SandboxState, Sandboxes, ServiceEndpoint, Status,
+ RuntimeError, RuntimeResult, SandboxState, Sandboxes, ServiceEndpoint, Status, StopReason,
};
use serde_json::json;
use std::{
@@ -21,6 +21,8 @@ use std::{
struct Runtime {
instances: Mutex<HashMap<String, InstanceStatus>>,
calls: Mutex<Vec<String>>,
+ /// The engine's exit record of each stopped instance.
+ exits: Mutex<HashMap<String, StopReason>>,
}
impl Runtime {
@@ -28,6 +30,12 @@ impl Runtime {
self.instances.lock().unwrap().insert(name.into(), status);
}
+ /// The instance stopped on its own, the engine recording `reason`.
+ fn exit(&self, name: &str, reason: StopReason) {
+ self.set(name, InstanceStatus::Stopped);
+ self.exits.lock().unwrap().insert(name.into(), reason);
+ }
+
fn calls(&self) -> Vec<String> {
std::mem::take(&mut *self.calls.lock().unwrap())
}
@@ -82,6 +90,17 @@ impl LocalRuntime for Runtime {
Ok(vec![])
}
+ async fn stop_reason(&self, name: &str, _rt: &str) -> RuntimeResult<Option<StopReason>> {
+ let stopped = self.instances.lock().unwrap().get(name) == Some(&InstanceStatus::Stopped);
+ Ok(self
+ .exits
+ .lock()
+ .unwrap()
+ .get(name)
+ .copied()
+ .filter(|_| stopped))
+ }
+
async fn status(&self, name: &str) -> RuntimeResult<InstanceStatus> {
self.instances
.lock()
@@ -309,3 +328,73 @@ async fn a_provider_reports_its_own_power_control() {
["stop i-123", "start i-123"]
);
}
+
+#[tokio::test]
+async fn a_sandbox_that_stops_on_its_own_says_why_until_it_starts_again() {
+ let (_dir, rt, sbx) = env();
+ sbx.state().save(&local("box", "runc")).unwrap();
+ rt.set("box", InstanceStatus::Running);
+ assert!(sbx.note_unasked_stops().await.is_empty());
+ assert_eq!(sbx.get("box").await.unwrap().stop_reason, None);
+
+ // The guest kernel kills it for memory: nobody asked.
+ let oom = StopReason {
+ exit_code: 137,
+ out_of_memory: true,
+ };
+ rt.exit("box", oom);
+ let info = sbx.get("box").await.unwrap();
+ assert_eq!(info.status, Status::Stopped);
+ assert_eq!(info.stop_reason, Some(oom));
+ assert_eq!(oom.words(), "out of memory");
+ // Recorded once: stopped, and why, for every UI that reads the record.
+ assert_eq!(sbx.power_state("box"), Some(PowerState::Stopped));
+ assert_eq!(sbx.stop_reason("box"), Some(oom));
+ assert!(sbx.note_unasked_stops().await.is_empty());
+ let listed = sbx.list().await.unwrap();
+ let row = listed.iter().find(|i| i.name == "box").unwrap();
+ assert_eq!(row.stop_reason, Some(oom));
+
+ // Started again: the reason belonged to the last stop.
+ sbx.power_on("box").await.unwrap();
+ assert_eq!(sbx.power_state("box"), Some(PowerState::Running));
+ assert_eq!(sbx.stop_reason("box"), None);
+}
+
+#[tokio::test]
+async fn the_watch_finds_a_stop_nobody_listed() {
+ let (_dir, rt, sbx) = env();
+ sbx.state().save(&local("box", "runc")).unwrap();
+ let crash = StopReason {
+ exit_code: 1,
+ out_of_memory: false,
+ };
+ rt.exit("box", crash);
+ assert_eq!(
+ sbx.note_unasked_stops().await,
+ vec![("box".to_string(), crash)]
+ );
+ assert_eq!(
+ sbx.stop_reason("box").map(|r| r.words()).as_deref(),
+ Some("exited with code 1")
+ );
+}
+
+#[tokio::test]
+async fn a_stop_that_was_asked_for_has_no_reason() {
+ let (_dir, rt, sbx) = env();
+ sbx.state().save(&local("mac", "lume")).unwrap();
+ rt.set("mac", InstanceStatus::Running);
+ sbx.power_off("mac").await.unwrap();
+ // Whatever the engine kept about how it ended, it was asked to stop.
+ rt.exit(
+ "mac",
+ StopReason {
+ exit_code: 137,
+ out_of_memory: false,
+ },
+ );
+ assert!(sbx.note_unasked_stops().await.is_empty());
+ assert_eq!(sbx.get("mac").await.unwrap().stop_reason, None);
+ assert_eq!(sbx.stop_reason("mac"), None);
+}
diff --git a/libs/cua/crates/cua-sdk/src/native/sandbox.rs b/libs/cua/crates/cua-sdk/src/native/sandbox.rs
index 68580b8c09..f222b9ce1c 100644
--- a/libs/cua/crates/cua-sdk/src/native/sandbox.rs
+++ b/libs/cua/crates/cua-sdk/src/native/sandbox.rs
@@ -132,6 +132,10 @@ pub struct SandboxInfo {
/// a registry, and the daemon topology.
#[uniffi(default = None)]
pub image_info: Option<ImageInfo>,
+ /// Why a local sandbox stopped without being asked to, in plain words
+ /// ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ #[uniffi(default = None)]
+ pub stop_reason: Option<String>,
}
impl From<SandboxRecord> for SandboxInfo {
@@ -164,6 +168,7 @@ impl From<SandboxRecord> for SandboxInfo {
endpoints: r.endpoints.into_iter().collect(),
image: r.image,
image_info: r.image_info.map(Into::into),
+ stop_reason: r.stop_reason,
}
}
}
diff --git a/libs/cua/crates/cua-sdk/src/native/spaces.rs b/libs/cua/crates/cua-sdk/src/native/spaces.rs
index d93952a6c2..4343e872a2 100644
--- a/libs/cua/crates/cua-sdk/src/native/spaces.rs
+++ b/libs/cua/crates/cua-sdk/src/native/spaces.rs
@@ -232,6 +232,12 @@ pub struct SpaceInfo {
/// Empty for other Spaces.
#[serde(default)]
pub cloud_delete: String,
+ /// Why a local Space stopped without being asked to, in plain words
+ /// ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ /// and once it is started again.
+ #[serde(default)]
+ #[uniffi(default)]
+ pub stop_reason: String,
}
impl From<dpb::Space> for SpaceInfo {
@@ -265,6 +271,7 @@ impl From<dpb::Space> for SpaceInfo {
cloud: s.cloud,
cloud_place: s.cloud_place,
cloud_delete: s.cloud_delete,
+ stop_reason: s.stop_reason,
}
}
}
@@ -293,6 +300,7 @@ impl From<cua_spaces::SpaceInfo> for SpaceInfo {
cloud: s.cloud,
cloud_place: s.cloud_place,
cloud_delete: s.cloud_delete,
+ stop_reason: s.stop_reason,
}
}
}
diff --git a/libs/cua/crates/cua-spaces-app-core/src/keyvault/view.rs b/libs/cua/crates/cua-spaces-app-core/src/keyvault/view.rs
index a1fa23926d..8ceb37c109 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/keyvault/view.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/keyvault/view.rs
@@ -915,6 +915,7 @@ mod sharing_tests {
cloud: None,
cloud_place: None,
cloud_delete: None,
+ stop_reason: None,
};
crate::spaces::row_to_space(&row, 0)
}
diff --git a/libs/cua/crates/cua-spaces-app-core/src/model.rs b/libs/cua/crates/cua-spaces-app-core/src/model.rs
index 0de3445341..d4024bb823 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/model.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/model.rs
@@ -320,6 +320,10 @@ pub struct SpacePower {
/// Why the last power action failed, until the next one.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
+ /// Why it stopped without being asked to, in plain words ("out of
+ /// memory"), while it is off.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub stop_reason: Option<String>,
}
/// How far a Space being created has come.
@@ -422,6 +426,11 @@ pub struct SpaceRow {
/// (that machine created it) or `elsewhere` (another device did).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cloud_delete: Option<String>,
+ /// Why a local Space stopped without being asked to, in plain words
+ /// ("out of memory", "killed", "exited with code 1"), as the SDK
+ /// recorded it; absent otherwise.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub stop_reason: Option<String>,
}
/// `arm64` or `amd64` for any spelling of a CPU architecture (`aarch64`,
diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
index 8de32c9af8..792de24a2a 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/creating.rs
@@ -2701,6 +2701,7 @@ mod tests {
cloud: None,
cloud_place: None,
cloud_delete: None,
+ stop_reason: None,
},
SKEW_BASE,
);
diff --git a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
index e65abc0541..2d22c74468 100644
--- a/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
+++ b/libs/cua/crates/cua-spaces-app-core/src/spaces/mod.rs
@@ -139,13 +139,13 @@ fn provider_label(p: SpaceProvider) -> &'static str {
fn detail_for(row: &SpaceRow, status: SpaceStatus) -> String {
if status == SpaceStatus::Suspended {
// Turned off on purpose: said so, not "Unreachable".
- if let Some(control) = row.power.as_deref().and_then(PowerControl::parse)
- && matches!(
+ if let Some(power) = power_of_row(row).filter(|p| {
+ matches!(
row.power_state.as_deref(),
Some("suspended") | Some("stopped")
- )
- {
- return off_label(control).into();
+ ) && p.off
+ }) {
+ return off_text(&power);
}
return match &row.error {
Some(e) if !e.is_empty() => format!("Unreachable \u{b7} {e}"),
@@ -277,12 +277,17 @@ pub fn row_to_space(row: &SpaceRow, now: i64) -> Space {
fn power_of_row(row: &SpaceRow) -> Option<SpacePower> {
let control = row.power.as_deref().and_then(PowerControl::parse)?;
let state = row.power_state.as_deref().filter(|s| !s.trim().is_empty());
+ let off =
+ matches!(state, Some("suspended") | Some("stopped")) || (state.is_none() && !row.reachable);
Some(SpacePower {
control,
- off: matches!(state, Some("suspended") | Some("stopped"))
- || (state.is_none() && !row.reachable),
+ off,
turning_on: None,
error: None,
+ stop_reason: row
+ .stop_reason
+ .clone()
+ .filter(|r| off && !r.trim().is_empty()),
})
}
@@ -293,6 +298,19 @@ pub fn off_label(_control: PowerControl) -> &'static str {
"Stopped"
}
+/// [`off_label`], and why when it stopped without being asked to:
+/// "Stopped: out of memory".
+pub fn off_text(power: &SpacePower) -> String {
+ match power
+ .stop_reason
+ .as_deref()
+ .filter(|r| !r.trim().is_empty())
+ {
+ Some(why) => format!("{}: {why}", off_label(power.control)),
+ None => off_label(power.control).into(),
+ }
+}
+
/// How a stopped Space is off, for the Status fact's tooltip.
pub fn off_hint(control: PowerControl) -> &'static str {
match control {
@@ -466,6 +484,7 @@ mod tests {
cloud: None,
cloud_place: None,
cloud_delete: None,
+ stop_reason: None,
}
}
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.rs
index 74bae156cf..840bd2311c 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
@@ -43,7 +43,7 @@ pub fn status_text(space: &Space) -> String {
return power_verb(power.control, on).into();
}
if power.off && space.status == SpaceStatus::Suspended {
- return super::off_label(power.control).into();
+ return super::off_text(power);
}
}
match space.status {
@@ -1685,6 +1685,7 @@ mod tests {
cloud: None,
cloud_place: None,
cloud_delete: None,
+ stop_reason: None,
};
let d = detail(&super::super::row_to_space(&row, 0));
// Added by address: no image row, so only the identifier copies.
@@ -1733,6 +1734,7 @@ mod tests {
cloud: None,
cloud_place: None,
cloud_delete: None,
+ stop_reason: None,
};
let space = super::super::creating::deleting_space(&super::super::row_to_space(&row, 0));
let d = detail(&space);
@@ -1805,6 +1807,32 @@ mod tests {
super::super::row_to_space(&row, 0)
}
+ #[test]
+ fn a_space_that_stopped_on_its_own_says_why() {
+ let row: SpaceRow = serde_json::from_value(serde_json::json!({
+ "id": "local:a", "name": "box", "provider": "local", "os": "linux",
+ "reachable": false, "power": "stop", "powerState": "stopped",
+ "stopReason": "out of memory",
+ }))
+ .unwrap();
+ let s = super::super::row_to_space(&row, 0);
+ assert_eq!(status_text(&s), "Stopped: out of memory");
+ assert_eq!(s.detail, "Stopped: out of memory");
+ // Turned off on purpose: one word, as before.
+ let asked = powered("local:a", "stop", Some("stopped"), false);
+ assert_eq!(status_text(&asked), "Stopped");
+ // A reason never shows on a Space that runs again.
+ let running: SpaceRow = serde_json::from_value(serde_json::json!({
+ "id": "local:a", "name": "box", "provider": "local", "os": "linux",
+ "reachable": true, "power": "stop", "powerState": "running",
+ "stopReason": "out of memory",
+ }))
+ .unwrap();
+ let s = super::super::row_to_space(&running, 0);
+ assert_eq!(status_text(&s), "Running");
+ assert_eq!(s.power.and_then(|p| p.stop_reason), None);
+ }
+
fn help(s: &Space) -> Option<(String, bool, bool)> {
power_button(s).map(|b| (b.help, b.turn_on, b.enabled))
}
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.rs
index def402b344..a6b6ad6cf3 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
@@ -136,6 +136,9 @@ pub struct AppSpacePower {
pub turning_on: Option<bool>,
/// Why the last power action failed, until the next one.
pub error: Option<String>,
+ /// Why it stopped without being asked to, in plain words ("out of
+ /// memory"), while it is off.
+ pub stop_reason: Option<String>,
}
/// One Space as the shells show it.
@@ -257,6 +260,10 @@ pub struct AppSpaceRow {
/// Where Delete permanently can delete it: `here`, `host:<machine>`
/// (that machine created it) or `elsewhere` (another device did).
pub cloud_delete: Option<String>,
+ /// Why a local Space stopped without being asked to, in plain words
+ /// ("out of memory", "killed", "exited with code 1"), as the SDK
+ /// recorded it; absent otherwise.
+ pub stop_reason: Option<String>,
}
/// Where new Spaces can be created.
diff --git a/libs/cua/crates/cua-spaces/src/space.rs b/libs/cua/crates/cua-spaces/src/space.rs
index a8a237c335..e60781af5e 100644
--- a/libs/cua/crates/cua-spaces/src/space.rs
+++ b/libs/cua/crates/cua-spaces/src/space.rs
@@ -571,6 +571,11 @@ pub struct SpaceInfo {
/// sharing it). Empty when reachable, and for other Spaces.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub status: String,
+ /// Why a local Space stopped without being asked to, in plain words
+ /// ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ /// and once it is started again.
+ #[serde(default, skip_serializing_if = "String::is_empty")]
+ pub stop_reason: String,
}
impl SpaceInfo {
@@ -604,6 +609,7 @@ impl SpaceInfo {
cloud_place: record.cloud_place.clone(),
cloud_delete: record.cloud_delete.clone(),
status: String::new(),
+ stop_reason: record.stop_reason.clone(),
})
}
}
diff --git a/libs/cua/crates/cua-spaces/src/spaces.rs b/libs/cua/crates/cua-spaces/src/spaces.rs
index ca750e1c58..9a9b5a9886 100644
--- a/libs/cua/crates/cua-spaces/src/spaces.rs
+++ b/libs/cua/crates/cua-spaces/src/spaces.rs
@@ -541,6 +541,7 @@ pub(crate) fn relay_info(m: &crate::relay::RelayMachine) -> SpaceInfo {
} else {
String::new()
},
+ stop_reason: String::new(),
}
}
@@ -755,6 +756,7 @@ impl Spaces {
.map(|r| {
let mut info = SpaceInfo::from_record(r)?;
(info.power, info.power_state) = self.power_of(&info.id);
+ info.stop_reason = self.stop_reason_of(&info.id);
Ok(info)
})
.collect::<Result<_>>()?;
@@ -1210,6 +1212,7 @@ impl Spaces {
cloud_place: String::new(),
cloud_delete: String::new(),
status: String::new(),
+ stop_reason: String::new(),
}))
}
@@ -2912,6 +2915,20 @@ impl Spaces {
self.sandbox_power(&name)
}
+ /// [`SpaceInfo::stop_reason`] of the Space `id`: why its local sandbox
+ /// stopped without being asked to, in plain words, from its state file
+ /// (empty when it did not, or is not local).
+ pub fn stop_reason_of(&self, id: &str) -> String {
+ let Ok(SpaceId::Local { name }) = SpaceId::parse(id) else {
+ return String::new();
+ };
+ self.inner
+ .sandboxes
+ .stop_reason(&name)
+ .map(|r| r.words())
+ .unwrap_or_default()
+ }
+
/// [`Self::power_of`] for the sandbox `name` (a local Space's, or the
/// cloud sandbox behind a `relay:` Space).
fn sandbox_power(&self, name: &str) -> (String, String) {
diff --git a/libs/cua/crates/cua-vmm/src/container/mod.rs b/libs/cua/crates/cua-vmm/src/container/mod.rs
index 2e468fbbeb..4651ecf765 100644
--- a/libs/cua/crates/cua-vmm/src/container/mod.rs
+++ b/libs/cua/crates/cua-vmm/src/container/mod.rs
@@ -578,6 +578,33 @@ impl ContainerRuntime {
}
}
+ /// How the container `name` ended, when it has stopped: the engine's
+ /// exit code and whether the kernel killed it for memory
+ /// (`State.OOMKilled`). `None` while it runs, when it never ran, or
+ /// when there is no such container.
+ pub async fn exit_of(&self, name: &str) -> Result<Option<ExitRecord>> {
+ Ok(self.inspect(name).await?.as_ref().and_then(Self::exit_from))
+ }
+
+ fn exit_from(i: &bollard::models::ContainerInspectResponse) -> Option<ExitRecord> {
+ use bollard::models::ContainerStateStatusEnum as S;
+ let s = i.state.as_ref()?;
+ if !matches!(s.status, Some(S::EXITED) | Some(S::DEAD)) {
+ return None;
+ }
+ // Docker's zero time: created, never started.
+ if s.finished_at
+ .as_deref()
+ .is_none_or(|t| t.starts_with("0001-"))
+ {
+ return None;
+ }
+ Some(ExitRecord {
+ exit_code: s.exit_code.unwrap_or(0),
+ oom_killed: s.oom_killed.unwrap_or(false),
+ })
+ }
+
fn endpoints_from(i: &bollard::models::ContainerInspectResponse) -> Endpoints {
let mut ports = BTreeMap::new();
if let Some(map) = i.network_settings.as_ref().and_then(|n| n.ports.as_ref()) {
@@ -1903,6 +1930,54 @@ fn pull_fraction(download: Option<f64>, extract: Option<f64>) -> Option<f64> {
mod tests {
use super::*;
+ fn inspected(
+ status: bollard::models::ContainerStateStatusEnum,
+ finished: &str,
+ code: i64,
+ oom: bool,
+ ) -> bollard::models::ContainerInspectResponse {
+ bollard::models::ContainerInspectResponse {
+ state: Some(bollard::models::ContainerState {
+ status: Some(status),
+ finished_at: Some(finished.into()),
+ exit_code: Some(code),
+ oom_killed: Some(oom),
+ ..Default::default()
+ }),
+ ..Default::default()
+ }
+ }
+
+ #[test]
+ fn a_stopped_container_says_how_it_ended() {
+ use bollard::models::ContainerStateStatusEnum as S;
+ let at = "2026-10-15T20:40:01.60761462Z";
+ // What the engine recorded for a Space the guest kernel killed.
+ assert_eq!(
+ ContainerRuntime::exit_from(&inspected(S::EXITED, at, 137, true)),
+ Some(ExitRecord {
+ exit_code: 137,
+ oom_killed: true
+ })
+ );
+ assert_eq!(
+ ContainerRuntime::exit_from(&inspected(S::DEAD, at, 1, false)),
+ Some(ExitRecord {
+ exit_code: 1,
+ oom_killed: false
+ })
+ );
+ // Running, or created and never started: nothing ended.
+ assert_eq!(
+ ContainerRuntime::exit_from(&inspected(S::RUNNING, at, 0, false)),
+ None
+ );
+ assert_eq!(
+ ContainerRuntime::exit_from(&inspected(S::EXITED, "0001-01-01T00:00:00Z", 0, false)),
+ None
+ );
+ }
+
#[test]
fn manifest_layers_give_a_pull_its_total_and_count_what_exists() {
let a = format!("sha256:{}", "a1".repeat(32));
diff --git a/libs/cua/crates/cua-vmm/src/types.rs b/libs/cua/crates/cua-vmm/src/types.rs
index e8aca4e29e..6e51fb83d5 100644
--- a/libs/cua/crates/cua-vmm/src/types.rs
+++ b/libs/cua/crates/cua-vmm/src/types.rs
@@ -621,6 +621,15 @@ pub struct Instance {
pub arch: Option<Arch>,
}
+/// How a stopped instance ended, as its engine recorded it.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
+pub struct ExitRecord {
+ /// The exit code (137: killed with SIGKILL).
+ pub exit_code: i64,
+ /// The kernel killed it for memory (the engine's `OOMKilled`).
+ pub oom_killed: bool,
+}
+
/// One row of [`crate::Runtime::list`].
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InstanceSummary {
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.kt
index b2db44139a..47859a286b 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
@@ -33948,6 +33948,12 @@ data class SandboxInfo (
* a registry, and the daemon topology.
*/
var `imageInfo`: ImageInfo? = null
+ ,
+ /**
+ * Why a local sandbox stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ */
+ var `stopReason`: kotlin.String? = null
){
@@ -33980,6 +33986,7 @@ public object FfiConverterTypeSandboxInfo: FfiConverterRustBuffer<SandboxInfo> {
FfiConverterOptionalLong.read(buf),
FfiConverterMapStringString.read(buf),
FfiConverterOptionalTypeImageInfo.read(buf),
+ FfiConverterOptionalString.read(buf),
)
}
@@ -33999,7 +34006,8 @@ public object FfiConverterTypeSandboxInfo: FfiConverterRustBuffer<SandboxInfo> {
FfiConverterString.allocationSize(value.`location`) +
FfiConverterOptionalLong.allocationSize(value.`expiresAtUnix`) +
FfiConverterMapStringString.allocationSize(value.`providerDetails`) +
- FfiConverterOptionalTypeImageInfo.allocationSize(value.`imageInfo`)
+ FfiConverterOptionalTypeImageInfo.allocationSize(value.`imageInfo`) +
+ FfiConverterOptionalString.allocationSize(value.`stopReason`)
)
override fun write(value: SandboxInfo, buf: ByteBuffer) {
@@ -34019,6 +34027,7 @@ public object FfiConverterTypeSandboxInfo: FfiConverterRustBuffer<SandboxInfo> {
FfiConverterOptionalLong.write(value.`expiresAtUnix`, buf)
FfiConverterMapStringString.write(value.`providerDetails`, buf)
FfiConverterOptionalTypeImageInfo.write(value.`imageInfo`, buf)
+ FfiConverterOptionalString.write(value.`stopReason`, buf)
}
}
@@ -35703,6 +35712,13 @@ data class SpaceInfo (
* Empty for other Spaces.
*/
var `cloudDelete`: kotlin.String
+ ,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ * and once it is started again.
+ */
+ var `stopReason`: kotlin.String = ""
){
@@ -35740,6 +35756,7 @@ public object FfiConverterTypeSpaceInfo: FfiConverterRustBuffer<SpaceInfo> {
FfiConverterString.read(buf),
FfiConverterString.read(buf),
FfiConverterString.read(buf),
+ FfiConverterString.read(buf),
)
}
@@ -35764,7 +35781,8 @@ public object FfiConverterTypeSpaceInfo: FfiConverterRustBuffer<SpaceInfo> {
FfiConverterString.allocationSize(value.`powerState`) +
FfiConverterString.allocationSize(value.`cloud`) +
FfiConverterString.allocationSize(value.`cloudPlace`) +
- FfiConverterString.allocationSize(value.`cloudDelete`)
+ FfiConverterString.allocationSize(value.`cloudDelete`) +
+ FfiConverterString.allocationSize(value.`stopReason`)
)
override fun write(value: SpaceInfo, buf: ByteBuffer) {
@@ -35789,6 +35807,7 @@ public object FfiConverterTypeSpaceInfo: FfiConverterRustBuffer<SpaceInfo> {
FfiConverterString.write(value.`cloud`, buf)
FfiConverterString.write(value.`cloudPlace`, buf)
FfiConverterString.write(value.`cloudDelete`, buf)
+ FfiConverterString.write(value.`stopReason`, buf)
}
}
diff --git a/libs/cua/proto/cua/daemon/v1/sandboxes.proto b/libs/cua/proto/cua/daemon/v1/sandboxes.proto
index 666482734a..cd4aea0e47 100644
--- a/libs/cua/proto/cua/daemon/v1/sandboxes.proto
+++ b/libs/cua/proto/cua/daemon/v1/sandboxes.proto
@@ -160,6 +160,10 @@ message Sandbox {
// The engine that runs it: "gvisor", "runc", "qemu", "lume" or
// "kubevirt"; empty when not known.
string runtime = 17;
+ // Why a local sandbox stopped without being asked to, in plain words:
+ // "out of memory", "killed", "exited" or "exited with code N". Empty
+ // otherwise, and once it is started again.
+ string stop_reason = 18;
}
// A user-declared readiness probe. With no probes a sandbox is ready as soon
diff --git a/libs/cua/proto/cua/daemon/v1/spaces.proto b/libs/cua/proto/cua/daemon/v1/spaces.proto
index 6177a994d5..d65a592e33 100644
--- a/libs/cua/proto/cua/daemon/v1/spaces.proto
+++ b/libs/cua/proto/cua/daemon/v1/spaces.proto
@@ -155,6 +155,11 @@ message Space {
// created it, through the relay) or "elsewhere" (only from the device
// that created it). Empty for other Spaces.
string cloud_delete = 20;
+ // Why a local Space stopped without being asked to, in plain words: "out
+ // of memory", "killed", "exited" or "exited with code N". Empty
+ // otherwise, and once it is started again. Filled in when listed, not
+ // stored.
+ string stop_reason = 21;
}
// Request for `SpaceService.AddSpace`.
diff --git a/libs/cua/python/src/cua/_native.py b/libs/cua/python/src/cua/_native.py
index 0780e5d305..baa6848ec9 100644
--- a/libs/cua/python/src/cua/_native.py
+++ b/libs/cua/python/src/cua/_native.py
@@ -17637,7 +17637,7 @@ class SandboxInfo:
"""
A sandbox as listed.
"""
- def __init__(self, *, name:str, kind:str, runtime:str, runtime_type:str, status:SandboxStatus, status_detail:typing.Optional[str], ephemeral:bool, services:dict[str, int], endpoints:dict[str, str], image:typing.Optional[str], id:str, phase:SandboxPhase, location:str, expires_at_unix:typing.Optional[int], provider_details:dict[str, str], image_info:typing.Optional[ImageInfo] = _DEFAULT):
+ def __init__(self, *, name:str, kind:str, runtime:str, runtime_type:str, status:SandboxStatus, status_detail:typing.Optional[str], ephemeral:bool, services:dict[str, int], endpoints:dict[str, str], image:typing.Optional[str], id:str, phase:SandboxPhase, location:str, expires_at_unix:typing.Optional[int], provider_details:dict[str, str], image_info:typing.Optional[ImageInfo] = _DEFAULT, stop_reason:typing.Optional[str] = _DEFAULT):
self.name = name
self.kind = kind
self.runtime = runtime
@@ -17657,12 +17657,16 @@ class SandboxInfo:
self.image_info = None
else:
self.image_info = image_info
+ if stop_reason is _DEFAULT:
+ self.stop_reason = None
+ else:
+ self.stop_reason = stop_reason
def __str__(self):
- return "SandboxInfo(name={}, kind={}, runtime={}, runtime_type={}, status={}, status_detail={}, ephemeral={}, services={}, endpoints={}, image={}, id={}, phase={}, location={}, expires_at_unix={}, provider_details={}, image_info={})".format(self.name, self.kind, self.runtime, self.runtime_type, self.status, self.status_detail, self.ephemeral, self.services, self.endpoints, self.image, self.id, self.phase, self.location, self.expires_at_unix, self.provider_details, self.image_info)
+ return "SandboxInfo(name={}, kind={}, runtime={}, runtime_type={}, status={}, status_detail={}, ephemeral={}, services={}, endpoints={}, image={}, id={}, phase={}, location={}, expires_at_unix={}, provider_details={}, image_info={}, stop_reason={})".format(self.name, self.kind, self.runtime, self.runtime_type, self.status, self.status_detail, self.ephemeral, self.services, self.endpoints, self.image, self.id, self.phase, self.location, self.expires_at_unix, self.provider_details, self.image_info, self.stop_reason)
def __eq__(self, other):
if self.name != other.name:
return False
@@ -17696,6 +17700,8 @@ class SandboxInfo:
return False
if self.image_info != other.image_info:
return False
+ if self.stop_reason != other.stop_reason:
+ return False
return True
class _UniffiFfiConverterTypeSandboxInfo(_UniffiConverterRustBuffer):
@@ -17718,6 +17724,7 @@ class _UniffiFfiConverterTypeSandboxInfo(_UniffiConverterRustBuffer):
expires_at_unix=_UniffiFfiConverterOptionalInt64.read(buf),
provider_details=_UniffiFfiConverterMapStringString.read(buf),
image_info=_UniffiFfiConverterOptionalTypeImageInfo.read(buf),
+ stop_reason=_UniffiFfiConverterOptionalString.read(buf),
)
@staticmethod
@@ -17738,6 +17745,7 @@ class _UniffiFfiConverterTypeSandboxInfo(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalInt64.check_lower(value.expires_at_unix)
_UniffiFfiConverterMapStringString.check_lower(value.provider_details)
_UniffiFfiConverterOptionalTypeImageInfo.check_lower(value.image_info)
+ _UniffiFfiConverterOptionalString.check_lower(value.stop_reason)
@staticmethod
def write(value, buf):
@@ -17757,6 +17765,7 @@ class _UniffiFfiConverterTypeSandboxInfo(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalInt64.write(value.expires_at_unix, buf)
_UniffiFfiConverterMapStringString.write(value.provider_details, buf)
_UniffiFfiConverterOptionalTypeImageInfo.write(value.image_info, buf)
+ _UniffiFfiConverterOptionalString.write(value.stop_reason, buf)
class _UniffiFfiConverterSequenceTypeSandboxInfo(_UniffiConverterRustBuffer):
@classmethod
@@ -18917,7 +18926,7 @@ class SpaceInfo:
"""
A registered Space.
"""
- def __init__(self, *, id:str, name:str, provider:str, spacesd_version:str, features:typing.List[str], os:str, os_name:str, os_pretty_name:str, image:str, image_digest:str, kind:str, arch:str, services:typing.List[str], added_at:typing.Optional[str], host:str, host_name:str, power:str, power_state:str, cloud:str, cloud_place:str, cloud_delete:str):
+ def __init__(self, *, id:str, name:str, provider:str, spacesd_version:str, features:typing.List[str], os:str, os_name:str, os_pretty_name:str, image:str, image_digest:str, kind:str, arch:str, services:typing.List[str], added_at:typing.Optional[str], host:str, host_name:str, power:str, power_state:str, cloud:str, cloud_place:str, cloud_delete:str, stop_reason:str = ""):
self.id = id
self.name = name
self.provider = provider
@@ -18939,12 +18948,13 @@ class SpaceInfo:
self.cloud = cloud
self.cloud_place = cloud_place
self.cloud_delete = cloud_delete
+ self.stop_reason = stop_reason
def __str__(self):
- return "SpaceInfo(id={}, name={}, provider={}, spacesd_version={}, features={}, os={}, os_name={}, os_pretty_name={}, image={}, image_digest={}, kind={}, arch={}, services={}, added_at={}, host={}, host_name={}, power={}, power_state={}, cloud={}, cloud_place={}, cloud_delete={})".format(self.id, self.name, self.provider, self.spacesd_version, self.features, self.os, self.os_name, self.os_pretty_name, self.image, self.image_digest, self.kind, self.arch, self.services, self.added_at, self.host, self.host_name, self.power, self.power_state, self.cloud, self.cloud_place, self.cloud_delete)
+ return "SpaceInfo(id={}, name={}, provider={}, spacesd_version={}, features={}, os={}, os_name={}, os_pretty_name={}, image={}, image_digest={}, kind={}, arch={}, services={}, added_at={}, host={}, host_name={}, power={}, power_state={}, cloud={}, cloud_place={}, cloud_delete={}, stop_reason={})".format(self.id, self.name, self.provider, self.spacesd_version, self.features, self.os, self.os_name, self.os_pretty_name, self.image, self.image_digest, self.kind, self.arch, self.services, self.added_at, self.host, self.host_name, self.power, self.power_state, self.cloud, self.cloud_place, self.cloud_delete, self.stop_reason)
def __eq__(self, other):
if self.id != other.id:
return False
@@ -18988,6 +18998,8 @@ class SpaceInfo:
return False
if self.cloud_delete != other.cloud_delete:
return False
+ if self.stop_reason != other.stop_reason:
+ return False
return True
class _UniffiFfiConverterTypeSpaceInfo(_UniffiConverterRustBuffer):
@@ -19015,6 +19027,7 @@ class _UniffiFfiConverterTypeSpaceInfo(_UniffiConverterRustBuffer):
cloud=_UniffiFfiConverterString.read(buf),
cloud_place=_UniffiFfiConverterString.read(buf),
cloud_delete=_UniffiFfiConverterString.read(buf),
+ stop_reason=_UniffiFfiConverterString.read(buf),
)
@staticmethod
@@ -19040,6 +19053,7 @@ class _UniffiFfiConverterTypeSpaceInfo(_UniffiConverterRustBuffer):
_UniffiFfiConverterString.check_lower(value.cloud)
_UniffiFfiConverterString.check_lower(value.cloud_place)
_UniffiFfiConverterString.check_lower(value.cloud_delete)
+ _UniffiFfiConverterString.check_lower(value.stop_reason)
@staticmethod
def write(value, buf):
@@ -19064,6 +19078,7 @@ class _UniffiFfiConverterTypeSpaceInfo(_UniffiConverterRustBuffer):
_UniffiFfiConverterString.write(value.cloud, buf)
_UniffiFfiConverterString.write(value.cloud_place, buf)
_UniffiFfiConverterString.write(value.cloud_delete, buf)
+ _UniffiFfiConverterString.write(value.stop_reason, buf)
class _UniffiFfiConverterOptionalTypeSpaceInfo(_UniffiConverterRustBuffer):
@classmethod
diff --git a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
index ef7c01d13b..b252c95afa 100644
--- a/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
+++ b/libs/cua/swift/Sources/CuaSDK/CuaSDK.swift
@@ -27890,6 +27890,11 @@ public struct SandboxInfo: Equatable, Hashable {
* a registry, and the daemon topology.
*/
public var imageInfo: ImageInfo?
+ /**
+ * Why a local sandbox stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ */
+ public var stopReason: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
@@ -27951,7 +27956,11 @@ public struct SandboxInfo: Equatable, Hashable {
* The image as resolved and pinned at create time (digest, variant).
* `None` for direct connections, named pools, images not resolved from
* a registry, and the daemon topology.
- */imageInfo: ImageInfo? = nil) {
+ */imageInfo: ImageInfo? = nil,
+ /**
+ * Why a local sandbox stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ */stopReason: String? = nil) {
self.name = name
self.kind = kind
self.runtime = runtime
@@ -27968,6 +27977,7 @@ public struct SandboxInfo: Equatable, Hashable {
self.expiresAtUnix = expiresAtUnix
self.providerDetails = providerDetails
self.imageInfo = imageInfo
+ self.stopReason = stopReason
}
@@ -28001,7 +28011,8 @@ public struct FfiConverterTypeSandboxInfo: FfiConverterRustBuffer {
location: FfiConverterString.read(from: &buf),
expiresAtUnix: FfiConverterOptionInt64.read(from: &buf),
providerDetails: FfiConverterDictionaryStringString.read(from: &buf),
- imageInfo: FfiConverterOptionTypeImageInfo.read(from: &buf)
+ imageInfo: FfiConverterOptionTypeImageInfo.read(from: &buf),
+ stopReason: FfiConverterOptionString.read(from: &buf)
)
}
@@ -28022,6 +28033,7 @@ public struct FfiConverterTypeSandboxInfo: FfiConverterRustBuffer {
FfiConverterOptionInt64.write(value.expiresAtUnix, into: &buf)
FfiConverterDictionaryStringString.write(value.providerDetails, into: &buf)
FfiConverterOptionTypeImageInfo.write(value.imageInfo, into: &buf)
+ FfiConverterOptionString.write(value.stopReason, into: &buf)
}
}
@@ -30294,6 +30306,12 @@ public struct SpaceInfo: Equatable, Hashable {
* Empty for other Spaces.
*/
public var cloudDelete: String
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ * and once it is started again.
+ */
+ public var stopReason: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
@@ -30378,7 +30396,12 @@ public struct SpaceInfo: Equatable, Hashable {
* device created it), `host:<machine>` (the device that created it,
* through the relay) or `elsewhere` (only there; `remove` keeps it).
* Empty for other Spaces.
- */cloudDelete: String) {
+ */cloudDelete: String,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ * and once it is started again.
+ */stopReason: String = "") {
self.id = id
self.name = name
self.provider = provider
@@ -30400,6 +30423,7 @@ public struct SpaceInfo: Equatable, Hashable {
self.cloud = cloud
self.cloudPlace = cloudPlace
self.cloudDelete = cloudDelete
+ self.stopReason = stopReason
}
@@ -30438,7 +30462,8 @@ public struct FfiConverterTypeSpaceInfo: FfiConverterRustBuffer {
powerState: FfiConverterString.read(from: &buf),
cloud: FfiConverterString.read(from: &buf),
cloudPlace: FfiConverterString.read(from: &buf),
- cloudDelete: FfiConverterString.read(from: &buf)
+ cloudDelete: FfiConverterString.read(from: &buf),
+ stopReason: FfiConverterString.read(from: &buf)
)
}
@@ -30464,6 +30489,7 @@ public struct FfiConverterTypeSpaceInfo: FfiConverterRustBuffer {
FfiConverterString.write(value.cloud, into: &buf)
FfiConverterString.write(value.cloudPlace, into: &buf)
FfiConverterString.write(value.cloudDelete, into: &buf)
+ FfiConverterString.write(value.stopReason, into: &buf)
}
}
diff --git a/libs/cua/typescript/src/native/cua_sdk.ts b/libs/cua/typescript/src/native/cua_sdk.ts
index 8260aabbea..687666e498 100644
--- a/libs/cua/typescript/src/native/cua_sdk.ts
+++ b/libs/cua/typescript/src/native/cua_sdk.ts
@@ -12893,7 +12893,12 @@ export type SandboxInfo = {
* `None` for direct connections, named pools, images not resolved from
* a registry, and the daemon topology.
*/
- imageInfo?: ImageInfo
+ imageInfo?: ImageInfo,
+ /**
+ * Why a local sandbox stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); `None` otherwise.
+ */
+ stopReason?: string
}
/**
@@ -12901,7 +12906,8 @@ export type SandboxInfo = {
*/
export const SandboxInfo = (() => {
const defaults = () => ({
- imageInfo: undefined
+ imageInfo: undefined,
+ stopReason: undefined
});
const create = (() => {
return uniffiCreateRecord<SandboxInfo, ReturnType<typeof defaults>>(defaults);
@@ -12933,7 +12939,8 @@ const FfiConverterTypeSandboxInfo = (() => {
location: FfiConverterString.read(from),
expiresAtUnix: FfiConverterOptionalInt64.read(from),
providerDetails: FfiConverterMapStringString.read(from),
- imageInfo: FfiConverterOptionalTypeImageInfo.read(from)
+ imageInfo: FfiConverterOptionalTypeImageInfo.read(from),
+ stopReason: FfiConverterOptionalString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -12953,6 +12960,7 @@ const FfiConverterTypeSandboxInfo = (() => {
FfiConverterOptionalInt64.write(value.expiresAtUnix, into);
FfiConverterMapStringString.write(value.providerDetails, into);
FfiConverterOptionalTypeImageInfo.write(value.imageInfo, into);
+ FfiConverterOptionalString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterString.allocationSize(value.name) +
@@ -12970,7 +12978,8 @@ const FfiConverterTypeSandboxInfo = (() => {
FfiConverterString.allocationSize(value.location) +
FfiConverterOptionalInt64.allocationSize(value.expiresAtUnix) +
FfiConverterMapStringString.allocationSize(value.providerDetails) +
- FfiConverterOptionalTypeImageInfo.allocationSize(value.imageInfo);
+ FfiConverterOptionalTypeImageInfo.allocationSize(value.imageInfo) +
+ FfiConverterOptionalString.allocationSize(value.stopReason);
}
};
@@ -14362,7 +14371,13 @@ export type SpaceInfo = {
* through the relay) or `elsewhere` (only there; `remove` keeps it).
* Empty for other Spaces.
*/
- cloudDelete: string
+ cloudDelete: string,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"); empty otherwise,
+ * and once it is started again.
+ */
+ stopReason: string
}
/**
@@ -14370,6 +14385,7 @@ export type SpaceInfo = {
*/
export const SpaceInfo = (() => {
const defaults = () => ({
+ stopReason: ""
});
const create = (() => {
return uniffiCreateRecord<SpaceInfo, ReturnType<typeof defaults>>(defaults);
@@ -14406,7 +14422,8 @@ const FfiConverterTypeSpaceInfo = (() => {
powerState: FfiConverterString.read(from),
cloud: FfiConverterString.read(from),
cloudPlace: FfiConverterString.read(from),
- cloudDelete: FfiConverterString.read(from)
+ cloudDelete: FfiConverterString.read(from),
+ stopReason: FfiConverterString.read(from)
};
}
write(value: TypeName, into: RustBuffer): void {
@@ -14431,6 +14448,7 @@ const FfiConverterTypeSpaceInfo = (() => {
FfiConverterString.write(value.cloud, into);
FfiConverterString.write(value.cloudPlace, into);
FfiConverterString.write(value.cloudDelete, into);
+ FfiConverterString.write(value.stopReason, into);
}
allocationSize(value: TypeName): number {
return FfiConverterString.allocationSize(value.id) +
@@ -14453,7 +14471,8 @@ const FfiConverterTypeSpaceInfo = (() => {
FfiConverterString.allocationSize(value.powerState) +
FfiConverterString.allocationSize(value.cloud) +
FfiConverterString.allocationSize(value.cloudPlace) +
- FfiConverterString.allocationSize(value.cloudDelete);
+ FfiConverterString.allocationSize(value.cloudDelete) +
+ FfiConverterString.allocationSize(value.stopReason);
}
};
diff --git a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
index 31c433caa1..f57cc36b02 100644
--- a/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
+++ b/libs/spaces-app-swift/Sources/CuaSpacesFFI/CuaSpacesFFI.swift
@@ -30789,6 +30789,11 @@ public struct AppSpacePower: Equatable, Hashable {
* Why the last power action failed, until the next one.
*/
public var error: String?
+ /**
+ * Why it stopped without being asked to, in plain words ("out of
+ * memory"), while it is off.
+ */
+ public var stopReason: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
@@ -30806,11 +30811,16 @@ public struct AppSpacePower: Equatable, Hashable {
*/turningOn: Bool?,
/**
* Why the last power action failed, until the next one.
- */error: String?) {
+ */error: String?,
+ /**
+ * Why it stopped without being asked to, in plain words ("out of
+ * memory"), while it is off.
+ */stopReason: String?) {
self.control = control
self.off = off
self.turningOn = turningOn
self.error = error
+ self.stopReason = stopReason
}
@@ -30832,7 +30842,8 @@ public struct FfiConverterTypeAppSpacePower: FfiConverterRustBuffer {
control: FfiConverterTypeAppPowerControl.read(from: &buf),
off: FfiConverterBool.read(from: &buf),
turningOn: FfiConverterOptionBool.read(from: &buf),
- error: FfiConverterOptionString.read(from: &buf)
+ error: FfiConverterOptionString.read(from: &buf),
+ stopReason: FfiConverterOptionString.read(from: &buf)
)
}
@@ -30841,6 +30852,7 @@ public struct FfiConverterTypeAppSpacePower: FfiConverterRustBuffer {
FfiConverterBool.write(value.off, into: &buf)
FfiConverterOptionBool.write(value.turningOn, into: &buf)
FfiConverterOptionString.write(value.error, into: &buf)
+ FfiConverterOptionString.write(value.stopReason, into: &buf)
}
}
@@ -31084,6 +31096,12 @@ public struct AppSpaceRow: Equatable, Hashable {
* (that machine created it) or `elsewhere` (another device did).
*/
public var cloudDelete: String?
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"), as the SDK
+ * recorded it; absent otherwise.
+ */
+ public var stopReason: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
@@ -31158,7 +31176,12 @@ public struct AppSpaceRow: Equatable, Hashable {
/**
* Where Delete permanently can delete it: `here`, `host:<machine>`
* (that machine created it) or `elsewhere` (another device did).
- */cloudDelete: String?) {
+ */cloudDelete: String?,
+ /**
+ * Why a local Space stopped without being asked to, in plain words
+ * ("out of memory", "killed", "exited with code 1"), as the SDK
+ * recorded it; absent otherwise.
+ */stopReason: String?) {
self.id = id
self.name = name
self.provider = provider
@@ -31181,6 +31204,7 @@ public struct AppSpaceRow: Equatable, Hashable {
self.cloud = cloud
self.cloudPlace = cloudPlace
self.cloudDelete = cloudDelete
+ self.stopReason = stopReason
}
@@ -31220,7 +31244,8 @@ public struct FfiConverterTypeAppSpaceRow: FfiConverterRustBuffer {
powerState: FfiConverterOptionString.read(from: &buf),
cloud: FfiConverterOptionString.read(from: &buf),
cloudPlace: FfiConverterOptionString.read(from: &buf),
- cloudDelete: FfiConverterOptionString.read(from: &buf)
+ cloudDelete: FfiConverterOptionString.read(from: &buf),
+ stopReason: FfiConverterOptionString.read(from: &buf)
)
}
@@ -31247,6 +31272,7 @@ public struct FfiConverterTypeAppSpaceRow: FfiConverterRustBuffer {
FfiConverterOptionString.write(value.cloud, into: &buf)
FfiConverterOptionString.write(value.cloudPlace, into: &buf)
FfiConverterOptionString.write(value.cloudDelete, into: &buf)
+ FfiConverterOptionString.write(value.stopReason, into: &buf)
}
}