Skip to content

Commit 2aeff43

Browse files
committed
feat(ui): show machine CPU and RAM in the cloud picker
The cloud machine picker described each class in prose ("Cheap smoke checks and small repos"), which was the widest thing in the row, got ellipsized, and did not say what the operator actually picks on. Machine options now carry the class shape and the picker renders "32 vCPU · 64 GB" instead. Crabbox reports per-provider class shapes from `providers --json`; the plugin reads that catalog once per lifecycle and attaches cpu/memoryGb to each option. A missing binary, failed command, unparseable output, absent classes, or an unmatched provider all degrade to label-only rows, so an older Crabbox keeps working. `description` was never released, so it is removed rather than deprecated, and listMachineOptions becomes async for the catalog read. Deletes the duplicate machine-option projector in the environments server method.
1 parent 491dc7f commit 2aeff43

24 files changed

Lines changed: 388 additions & 79 deletions

‎docs/gateway/cloud-workers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ openclaw gateway call sessions.dispatch \
187187
--params '{"key":"agent:main:big-refactor","profileId":"aws","machineClass":"large"}'
188188
```
189189

190-
The bundled Crabbox provider advertises `standard` (small repos and smoke checks), `fast` (general testing), `large` (broad test shards or heavy builds), and `beast` (high-core runs) through `environments.list`. You can also pass a provider-native server or instance type such as `c7a.24xlarge`; Crabbox treats any other non-empty class as that exact type. The selected value is fixed for that placement and reused by safe provisioning retries. `machineClass` is valid only with `profileId`, not `deviceId`.
190+
The bundled Crabbox provider advertises `standard`, `fast`, `large`, and `beast` through `environments.list`. When the selected backend publishes machine shapes, the picker shows their vCPU and RAM; for AWS these classes are 32 vCPU · 64 GB, 64 vCPU · 128 GB, 96 vCPU · 192 GB, and 192 vCPU · 384 GB, respectively. You can also pass a provider-native server or instance type such as `c7a.24xlarge`; Crabbox treats any other non-empty class as that exact type. The selected value is fixed for that placement and reused by safe provisioning retries. `machineClass` is valid only with `profileId`, not `deviceId`.
191191

192192
`sessions.dispatch` closes local turn admission, drains active work, validates the eligible Git workspace inventory, provisions the lease, runs setup, enrolls the node, pushes the Gateway bundle, syncs the workspace, and returns once the placement reaches `active` ownership. Inventory validation happens before provider allocation and reports an invalid request with an actionable size or entry limit when the workspace cannot be dispatched. Budget several minutes for the first dispatch; leases and content-addressed bundles are reused where safe. After that, talk to the session as usual. OpenClaw turns route to the worker process; supported SSH-backed providers may still carry Codex remote-exec.
193193

‎docs/plugins/manifest.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ Provider plugins that implement both `resolveUsageAuth` and `fetchUsageSnapshot`
750750

751751
Embedding providers must declare `contracts.embeddingProviders` for each adapter registered with `api.registerEmbeddingProvider(...)`. The same generic contract serves reusable vector generation and memory search. The retired `contracts.memoryEmbeddingProviders` key is no longer accepted.
752752

753-
Worker providers must declare each `api.registerWorkerProvider(...)` id in `contracts.workerProviders`. Core persists durable intent before calling `provision`; providers validate their settings and any optional per-dispatch `machineClass` before external allocation, and repeated calls with the same operation id must adopt the same lease. Providers may implement `listMachineOptions(profile)` to expose process-stable picker metadata; omit it when machine selection is not meaningful. Machine options contain only `id`, `label`, optional `description`, and optional `default`. Providers used for session placement must declare exactly one `supportedExecutionModes` value: `worker-turn` providers return node leases and `remote-exec` providers return SSH leases. Omission advertises no session-placement modes while leaving direct lifecycle operations available. Providers whose bounded provisioning exceeds core's five-minute default may implement `resolveProvisionTimeoutMs(profile)` and include acquisition, provider-owned setup, and cleanup in the returned positive millisecond budget. Core also persists that validated settings snapshot and passes it with `leaseId` to `inspect({ leaseId, profile })` and `destroy({ leaseId, profile })`, including after the named profile is changed or removed. Destruction is idempotent, inspection returns the closed `active` / `destroyed` / `unknown` status union, and SSH private-key material is referenced only through `SecretRef`. Provisioned SSH endpoints must also include a public `hostKey` from trusted provisioning output as exactly `algorithm base64`, without a hostname or comment, so core can pin the host before connecting. They may include up to 10 ordered, unique `fallbackPorts`, excluding the primary `port`; core persists those candidates and rotates among them only for idempotent probes, content-addressed transfers, receipt/lock-guarded artifact installation, convergent managed-worktree mirroring, and tunnel reconnects. Ambiguous unguarded stateful commands fail closed and are not replayed across candidates. A lease may set `sharedHost: true` when the SSH account also owns unrelated processes; core then avoids host-wide process freezing during workspace reconciliation. Omitted or `false` means a dedicated worker host. Active inspection repeats this fact so core can reconcile provider-owned isolation for leases persisted before the field existed; tunnel startup waits for that first authoritative inspection. Optional desktop metadata may advertise up to eight unique closed apps: `browser` with an absolute `executablePath` and a CDP port from 1 through 65535, or `terminal` with an absolute `executablePath`. Core rejects unknown app ids and fields and persists the validated metadata with the existing desktop record. Providers that mint dynamic identity refs may implement authoritative `resolveSshIdentity({ leaseId, profile, keyRef })`; providers without it use core's generic secret resolver. An authoritative `unknown` orphans an active local record; after a persisted destroy request it confirms teardown.
753+
Worker providers must declare each `api.registerWorkerProvider(...)` id in `contracts.workerProviders`. Core persists durable intent before calling `provision`; providers validate their settings and any optional per-dispatch `machineClass` before external allocation, and repeated calls with the same operation id must adopt the same lease. Providers may implement asynchronous `listMachineOptions(profile)` to expose process-stable picker metadata; omit it when machine selection is not meaningful. Machine options contain only `id`, `label`, optional positive-integer `cpu` and `memoryGb`, and optional `default`. Providers used for session placement must declare exactly one `supportedExecutionModes` value: `worker-turn` providers return node leases and `remote-exec` providers return SSH leases. Omission advertises no session-placement modes while leaving direct lifecycle operations available. Providers whose bounded provisioning exceeds core's five-minute default may implement `resolveProvisionTimeoutMs(profile)` and include acquisition, provider-owned setup, and cleanup in the returned positive millisecond budget. Core also persists that validated settings snapshot and passes it with `leaseId` to `inspect({ leaseId, profile })` and `destroy({ leaseId, profile })`, including after the named profile is changed or removed. Destruction is idempotent, inspection returns the closed `active` / `destroyed` / `unknown` status union, and SSH private-key material is referenced only through `SecretRef`. Provisioned SSH endpoints must also include a public `hostKey` from trusted provisioning output as exactly `algorithm base64`, without a hostname or comment, so core can pin the host before connecting. They may include up to 10 ordered, unique `fallbackPorts`, excluding the primary `port`; core persists those candidates and rotates among them only for idempotent probes, content-addressed transfers, receipt/lock-guarded artifact installation, convergent managed-worktree mirroring, and tunnel reconnects. Ambiguous unguarded stateful commands fail closed and are not replayed across candidates. A lease may set `sharedHost: true` when the SSH account also owns unrelated processes; core then avoids host-wide process freezing during workspace reconciliation. Omitted or `false` means a dedicated worker host. Active inspection repeats this fact so core can reconcile provider-owned isolation for leases persisted before the field existed; tunnel startup waits for that first authoritative inspection. Optional desktop metadata may advertise up to eight unique closed apps: `browser` with an absolute `executablePath` and a CDP port from 1 through 65535, or `terminal` with an absolute `executablePath`. Core rejects unknown app ids and fields and persists the validated metadata with the existing desktop record. Providers that mint dynamic identity refs may implement authoritative `resolveSshIdentity({ leaseId, profile, keyRef })`; providers without it use core's generic secret resolver. An authoritative `unknown` orphans an active local record; after a persisted destroy request it confirms teardown.
754754

755755
`contracts.gatewayMethodDispatch` currently accepts `"authenticated-request"`. It is an API hygiene gate for native plugin HTTP routes that intentionally dispatch Gateway control-plane methods in-process, not a sandbox against malicious native plugins. Use it only for tightly reviewed bundled/operator surfaces that already require Gateway HTTP auth. An entitled route remains reachable while Gateway root-work admission is closed only when it also declares `auth: "gateway"` and the route-specific `gatewayRuntimeScopeSurface: "trusted-operator"`; ordinary sibling routes from the same plugin remain behind the admission boundary. This keeps suspension status and resume reachable without granting the whole plugin an admission bypass. Keep parsing and response shaping bounded outside dispatch; substantive or mutating work must go through Gateway method dispatch, which owns admission and scope enforcement.
756756

‎docs/plugins/sdk-overview.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ persists the start or invokes the provider. Provider aliases are lookup names
131131
only and must not be used for this declaration.
132132

133133
Worker providers must also declare their id in `contracts.workerProviders`.
134-
Core persists durable intent before `provision(profile, operationId, options?)`. Providers validate settings and any optional `options.machineClass` before external allocation and throw `WorkerProviderError` for permanent profile rejection. `provision` must adopt the same lease when the operation id repeats. Providers may expose process-stable picker metadata with `listMachineOptions(profile)`; omit the hook when the profile has no meaningful machine choice. Machine options contain only `id`, `label`, optional `description`, and optional `default` because the host has no authoritative cross-provider CPU, memory, or price source. Session-placement providers declare exactly one `supportedExecutionModes` value: `worker-turn` providers return node leases, while `remote-exec` providers return SSH leases. Omission advertises no placement modes while preserving direct environment lifecycle calls. Providers whose provisioning can legitimately exceed core's five-minute default may return a positive millisecond budget from `resolveProvisionTimeoutMs(profile)`; include acquisition, provider-owned setup, and cleanup in that bound.
134+
Core persists durable intent before `provision(profile, operationId, options?)`. Providers validate settings and any optional `options.machineClass` before external allocation and throw `WorkerProviderError` for permanent profile rejection. `provision` must adopt the same lease when the operation id repeats. Providers may expose process-stable picker metadata with asynchronous `listMachineOptions(profile)`; omit the hook when the profile has no meaningful machine choice. Machine options contain only `id`, `label`, optional positive-integer `cpu` and `memoryGb`, and optional `default`. Session-placement providers declare exactly one `supportedExecutionModes` value: `worker-turn` providers return node leases, while `remote-exec` providers return SSH leases. Omission advertises no placement modes while preserving direct environment lifecycle calls. Providers whose provisioning can legitimately exceed core's five-minute default may return a positive millisecond budget from `resolveProvisionTimeoutMs(profile)`; include acquisition, provider-owned setup, and cleanup in that bound.
135135
Core persists the validated profile settings with the lease and supplies that snapshot to `destroy({ leaseId, profile })`, which must be idempotent, and `inspect({ leaseId, profile })`, which returns `active`, `destroyed`, or `unknown`. This lets providers route lifecycle calls after a gateway restart or named-profile removal. SSH endpoints use a `SecretRef` for `keyRef`, never inline key material, and include a `hostKey` from trusted provisioning output as exactly `algorithm base64`, without a hostname or comment. Core pins `hostKey` and never trusts a key from the first connection. Providers may also return up to 10 ordered, unique `fallbackPorts` (integer ports from 1 through 65535, excluding the primary `port`); core validates and persists those advertised candidates for idempotent probes, content-addressed transfers, receipt/lock-guarded artifact installation, convergent managed-worktree mirroring, and tunnel reconnects. Ambiguous unguarded stateful commands fail closed and are not replayed across candidates. A lease may set `sharedHost: true` when the SSH account also owns unrelated processes; core then avoids host-wide process freezing during workspace reconciliation. Omitted or `false` means a dedicated worker host. Active inspection repeats this fact so core can reconcile provider-owned isolation for leases persisted before the field existed; tunnel startup waits for that first authoritative inspection. A provider that mints a dynamic `keyRef` can implement `resolveSshIdentity({ leaseId, profile, keyRef })`; when present, that resolver is authoritative, while providers without it use the configured generic secret resolver.
136136
`WorkerLease.desktop` is optional and has the shape `{ protocol: "rfb"; port: number; passwordFilePath?: string; apps?: WorkerDesktopApp[] }`; `passwordFilePath`, when present, must be absolute. Providers report this warm-time capability from `provision`; it cannot be retrofitted onto a live lease. The Gateway reads the password file over the provider's SSH endpoint when needed and never persists the password. `WorkerDesktopApp` is a closed union: `{ id: "browser"; executablePath: string; cdpPort: number }` or `{ id: "terminal"; executablePath: string }`. App ids must be unique, executable paths must be absolute, browser CDP ports must be integers from 1 through 65535, and the list accepts at most eight entries. Core rejects unknown ids and fields.
137137
Providers with renewable leases can also implement `renew(leaseId)`.

‎extensions/crabbox/src/crabbox-worker-profile.ts‎

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { createHash } from "node:crypto";
22
import fs from "node:fs";
33
import path from "node:path";
4-
import { WorkerProviderError, type WorkerProfile } from "openclaw/plugin-sdk/plugin-entry";
4+
import {
5+
WorkerProviderError,
6+
type WorkerMachineOption,
7+
type WorkerProfile,
8+
} from "openclaw/plugin-sdk/plugin-entry";
59
import { normalizeOptionalString as nonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
610

711
export { nonEmptyString };
@@ -42,12 +46,18 @@ type CrabboxProfile = {
4246
};
4347

4448
const CRABBOX_MACHINE_OPTIONS = [
45-
{ id: "standard", label: "Standard", description: "Cheap smoke checks and small repos" },
46-
{ id: "fast", label: "Fast", description: "General maintainer testing" },
47-
{ id: "large", label: "Large", description: "Broad test shards or heavy builds" },
48-
{ id: "beast", label: "Beast", description: "High-core changed-test runs" },
49+
{ id: "standard", label: "Standard" },
50+
{ id: "fast", label: "Fast" },
51+
{ id: "large", label: "Large" },
52+
{ id: "beast", label: "Beast" },
4953
] as const;
5054

55+
export type CrabboxMachineShape = Readonly<{
56+
class: string;
57+
cpu?: number;
58+
memoryGb?: number;
59+
}>;
60+
5161
type IsExecutable = (candidate: string) => boolean;
5262

5363
export const CRABBOX_WORKER_PROVIDER_ID = "crabbox";
@@ -148,18 +158,32 @@ export function parseCrabboxProfile(profile: WorkerProfile): CrabboxProfile {
148158
};
149159
}
150160

151-
export function listCrabboxMachineOptions(profile: WorkerProfile) {
152-
const configuredClass = parseCrabboxProfile(profile).class;
153-
const options = CRABBOX_MACHINE_OPTIONS.map((option) =>
154-
option.id === configuredClass
155-
? {
156-
id: option.id,
157-
label: option.label,
158-
description: option.description,
159-
default: true,
160-
}
161-
: option,
162-
);
161+
export function listCrabboxMachineOptions(
162+
configuredClass: string,
163+
shapes: readonly CrabboxMachineShape[] | undefined,
164+
): readonly WorkerMachineOption[] {
165+
// Built by assignment rather than conditional spread: oxlint's no-map-spread
166+
// rejects spreading to shape objects inside a map callback.
167+
const options = CRABBOX_MACHINE_OPTIONS.map((option) => {
168+
const shape = shapes?.find((candidate) => candidate.class === option.id);
169+
const result: {
170+
id: string;
171+
label: string;
172+
cpu?: number;
173+
memoryGb?: number;
174+
default?: boolean;
175+
} = { id: option.id, label: option.label };
176+
if (shape?.cpu !== undefined) {
177+
result.cpu = shape.cpu;
178+
}
179+
if (shape?.memoryGb !== undefined) {
180+
result.memoryGb = shape.memoryGb;
181+
}
182+
if (option.id === configuredClass) {
183+
result.default = true;
184+
}
185+
return result;
186+
});
163187
if (options.some((option) => option.id === configuredClass)) {
164188
return options;
165189
}
@@ -168,7 +192,6 @@ export function listCrabboxMachineOptions(profile: WorkerProfile) {
168192
{
169193
id: configuredClass,
170194
label: configuredClass,
171-
description: "Configured instance type",
172195
default: true,
173196
},
174197
];

0 commit comments

Comments
 (0)