Skip to content

Commit 45e6784

Browse files
authored
feat(gateway): run disposable cloud workers through node transport (#125288)
* feat(gateway): converge cloud workers onto nodes * fix(gateway): honor public URL for cloud enrollment * fix(crabbox): execute cloud bootstrap package binary * fix(gateway): bind cloud nodes in pairing transaction * fix(crabbox): prefer exact installed cloud bootstrap * fix(gateway): complete cloud node bootstrap * fix(gateway): enforce cloud worker capability boundaries * fix(gateway): complete cloud node migration * fix(gateway): preserve paired node roles on teardown
1 parent 0c9d1e4 commit 45e6784

74 files changed

Lines changed: 1594 additions & 774 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/cli/connect.md‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ npx openclaw connect https://gateway.example/j/<shortcode> --display-name "Build
4747

4848
The node stays in the foreground until you stop it.
4949

50+
## Environment-managed cloud nodes
51+
52+
Worker providers use `--ephemeral` for disposable cloud machines:
53+
54+
```bash
55+
npx openclaw connect <setup-code> --ephemeral
56+
```
57+
58+
This process hosts worker sessions even when the machine's durable node config has worker hosting disabled. It does not install a service and cannot be combined with `--service`. The Gateway owns the setup identity and paired-node lifetime: provider replay resumes the persisted device token after the one-shot setup credential is consumed, and environment teardown removes the node role after releasing the cloud lease.
59+
60+
`--ephemeral` is intended for provider-managed state directories on throwaway machines, not as a shortcut for enrolling a personal device.
61+
5062
## Install as a service
5163

5264
Pass `--service` to redeem the bootstrap credential and install the node host as
@@ -84,8 +96,9 @@ A join code and a paired device have separate lifecycles:
8496

8597
- Burning or expiring a join code prevents another enrollment with that code.
8698
- It does not disconnect or remove a node that already redeemed it.
87-
- To revoke an enrolled machine, remove its paired device with
99+
- To revoke a normal enrolled machine, remove its paired device with
88100
[`openclaw devices remove <deviceId>`](/cli/devices#openclaw-devices-remove-%3Cdeviceid%3E).
101+
- Environment-managed `--ephemeral` nodes are removed automatically when their owning cloud environment is destroyed.
89102

90103
## Troubleshooting
91104

‎docs/gateway/cloud-workers.md‎

Lines changed: 31 additions & 41 deletions
Large diffs are not rendered by default.

‎docs/plan/runners.md‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ advances a milestone.
2626
| 5 | Public worker ingress path | landed | #122578, #122643 |
2727
| 6 | Node worker provider (device runners) | in progress | #122683, #122769, #122829, #122939, #123013, #123033, #122966, #123157, #123280, #123612, #123641, #123665, #123673, #123700, #123696, #123785, #123859, #123889, #123901 |
2828
| 7 | Bundle push consent + runner updates | in progress | #123985, #124037, #124356, #124590 |
29-
| 8 | Stop-and-continue moves | not started | — |
29+
| 8 | Stop-and-continue moves | landed | #125036 |
3030
| 9 | Deletions (ssh sandbox, openshell, exec-host clones, …) | not started | — |
31-
| 10 | Cloud convergence (provisioners run `openclaw connect`) | not started | — |
31+
| 10 | Cloud convergence (provisioners run `openclaw connect`) | in progress | — |
3232

3333
Revision history: revision 1 (2026-08-08) established the session/runner
3434
vocabulary, the naming rulings, and the milestone skeleton after a
@@ -382,14 +382,16 @@ speak. Additions:
382382

383383
### Cloud convergence (milestone 10)
384384

385-
A cloud provider's job collapses to: boot box, run
386-
`openclaw connect <one-shot code> --ephemeral` in setup. Ephemeral enrollment
387-
(industry: GitHub `--ephemeral`/JIT, Buildkite `--acquire-job`, Tailscale
388-
ephemeral keys) auto-deregisters after the run and auto-purges the node
389-
record when it goes offline. `destroy` = release lease. After soak, the SSH
390-
reverse-tunnel stack, `PreparedWorkerSsh`, and the rsync transport are
391-
deleted; cloud leases and paired machines become the same runner with
392-
different lifecycles.
385+
The bundled Crabbox provider now boots the box and runs
386+
`openclaw connect <setup code> --ephemeral` in an isolated per-lease state
387+
directory. The Gateway persists one replay-safe setup identity, atomically
388+
binds the authenticated device identity to the worker environment, pushes the
389+
current bundle through the node channel, and removes the node role after
390+
provider teardown. `destroy` = release lease plus pairing cleanup. Codex
391+
remote-exec fails before allocation because it still requires an SSH-backed
392+
provider. The remaining milestone work is soak proof and deletion of the
393+
replaced reverse-tunnel/rsync cloud carrier; distinct SSH sandbox contracts
394+
stay until their own replacements are proved.
393395

394396
## What the adversarial reviews killed or reshaped
395397

‎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 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 `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 explicitly list each `supportedExecutionModes` value they support (`worker-turn`, `remote-exec`, or both); 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. 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 `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 explicitly list every supported `supportedExecutionModes` value (`worker-turn`, `remote-exec`, or both); 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-command.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export type CrabboxCommandRunner = (
1212
argv: string[],
1313
options: {
1414
killProcessTree: boolean;
15+
env?: NodeJS.ProcessEnv;
16+
input?: string | Uint8Array;
1517
maxOutputBytes: number;
1618
signal?: AbortSignal;
1719
timeoutMs: number;
@@ -23,6 +25,8 @@ export async function runCrabboxCommand(params: {
2325
args: string[];
2426
binary: string;
2527
runCommand: CrabboxCommandRunner;
28+
env?: NodeJS.ProcessEnv;
29+
input?: string | Uint8Array;
2630
signal?: AbortSignal;
2731
timeoutMs: number;
2832
}): Promise<SpawnResult> {
@@ -31,6 +35,8 @@ export async function runCrabboxCommand(params: {
3135
timeoutMs: params.timeoutMs,
3236
maxOutputBytes: MAX_OUTPUT_BYTES,
3337
killProcessTree: true,
38+
...(params.env === undefined ? {} : { env: params.env }),
39+
...(params.input === undefined ? {} : { input: params.input }),
3440
...(params.signal ? { signal: params.signal } : {}),
3541
});
3642
} catch {

0 commit comments

Comments
 (0)