Skip to content

Commit b5d5ec3

Browse files
authored
feat(cloud-workers): add desktop apps and browser autonomy (#121475)
* feat(cloud-workers): add desktop apps and browser autonomy provider-attested Browser/Terminal launchers, shared visible loopback CDP Browser tool, no MCP/cookies/generic command. * feat(ui): add cloud desktop app launcher * docs(gateway): document cloud desktop apps and browser autonomy * perf(ui): trim desktop launcher startup copy * refactor(ui): simplify desktop launch feedback * perf(ui): reuse desktop app labels * fix(ui): keep desktop launch failures actionable * fix(crabbox): allow browser bootstrap to finish * fix(cloud-workers): honor provider provision budgets * fix(cloud-workers): persist browser screenshot receipts * fix(cloud-workers): bound browser screenshot lifecycle * fix(cloud-workers): avoid replaying desktop launches * test(cloud-workers): isolate browser runtime integration * refactor(cloud-workers): tighten desktop runtime boundaries * test(cloud-workers): keep browser runtime mock synchronous * fix(cloud-workers): break gateway type import cycle * fix(ci): settle admitted setup sessions in tests * build(plugin-sdk): refresh desktop app contract * ci: refresh merge-tree validation * build(plugin-sdk): regenerate desktop app baseline * style(gateway): format merged method order test
1 parent cc9e75e commit b5d5ec3

65 files changed

Lines changed: 2978 additions & 314 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.

‎apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ data class WorkerDesktopObserveResult(
154154
val vncPassword: String? = null,
155155
)
156156

157+
@Serializable
158+
data class WorkerDesktopLaunchParams(
159+
val environmentId: String,
160+
val app: String,
161+
)
162+
163+
@Serializable
164+
data class WorkerDesktopLaunchResult(
165+
val app: String,
166+
val status: String = "ready",
167+
)
168+
157169
@Serializable
158170
data class GatewayEventFrameStateVersion(
159171
val presence: Long,
@@ -521,6 +533,7 @@ enum class GatewayMethod(
521533
ProjectsList("projects.list"),
522534
ProjectsRegister("projects.register"),
523535
ProjectsRemove("projects.remove"),
536+
WorkerDesktopLaunch("worker.desktop.launch"),
524537
}
525538

526539
enum class GatewayEvent(

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public enum WorkerTunnelStatus: String, Codable, Sendable {
7171
case reconnecting = "reconnecting"
7272
}
7373

74+
public enum WorkerDesktopAppId: String, Codable, Sendable {
75+
case browser = "browser"
76+
case terminal = "terminal"
77+
}
78+
7479
public enum WorktreeRepositoryStatus: String, Codable, Sendable {
7580
case git = "git"
7681
case notGit = "not_git"
@@ -1804,6 +1809,7 @@ public struct WorkerEnvironmentMetadata: Codable, Sendable {
18041809
public let tunnelstatus: WorkerTunnelStatus
18051810
public let error: String?
18061811
public let desktop: Bool?
1812+
public let desktopapps: [WorkerDesktopAppId]?
18071813

18081814
public init(
18091815
providerid: String,
@@ -1814,7 +1820,8 @@ public struct WorkerEnvironmentMetadata: Codable, Sendable {
18141820
attachedsessionids: [String],
18151821
tunnelstatus: WorkerTunnelStatus,
18161822
error: String? = nil,
1817-
desktop: Bool? = nil)
1823+
desktop: Bool? = nil,
1824+
desktopapps: [WorkerDesktopAppId]? = nil)
18181825
{
18191826
self.providerid = providerid
18201827
self.leaseid = leaseid
@@ -1825,6 +1832,7 @@ public struct WorkerEnvironmentMetadata: Codable, Sendable {
18251832
self.tunnelstatus = tunnelstatus
18261833
self.error = error
18271834
self.desktop = desktop
1835+
self.desktopapps = desktopapps
18281836
}
18291837

18301838
private enum CodingKeys: String, CodingKey {
@@ -1837,6 +1845,7 @@ public struct WorkerEnvironmentMetadata: Codable, Sendable {
18371845
case tunnelstatus = "tunnelStatus"
18381846
case error
18391847
case desktop
1848+
case desktopapps = "desktopApps"
18401849
}
18411850
}
18421851

@@ -2094,6 +2103,42 @@ public struct WorkerDesktopObserveResult: Codable, Sendable {
20942103
}
20952104
}
20962105

2106+
public struct WorkerDesktopLaunchParams: Codable, Sendable {
2107+
public let environmentid: String
2108+
public let app: WorkerDesktopAppId
2109+
2110+
public init(
2111+
environmentid: String,
2112+
app: WorkerDesktopAppId)
2113+
{
2114+
self.environmentid = environmentid
2115+
self.app = app
2116+
}
2117+
2118+
private enum CodingKeys: String, CodingKey {
2119+
case environmentid = "environmentId"
2120+
case app
2121+
}
2122+
}
2123+
2124+
public struct WorkerDesktopLaunchResult: Codable, Sendable {
2125+
public let app: WorkerDesktopAppId
2126+
public let status: String
2127+
2128+
public init(
2129+
app: WorkerDesktopAppId,
2130+
status: String)
2131+
{
2132+
self.app = app
2133+
self.status = status
2134+
}
2135+
2136+
private enum CodingKeys: String, CodingKey {
2137+
case app
2138+
case status
2139+
}
2140+
}
2141+
20972142
public struct SystemInfoParams: Codable, Sendable {}
20982143

20992144
public struct SystemInfoResult: Codable, Sendable {

‎docs/.generated/plugin-sdk-api-baseline.jsonl‎

Lines changed: 63 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/gateway/cloud-workers.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,15 @@ Placement moves through a durable state machine (`local → requested → provis
192192

193193
Cloud Worker Desktop is an experimental Labs feature and is off by default. Enable **Cloud Worker Desktop** in **Settings → Agents & Tools → Labs**, or set `cloudWorkers.desktop: true`, then restart the Gateway for the Desktop panel to appear.
194194

195-
Set `"desktop": true` in a crabbox profile's `settings` to lease worker boxes with an interactive desktop (TigerVNC on the box loopback with a per-lease password). The Labs gate enables the observer surface and panel; the profile setting gives newly leased workers the desktop capability. Desktop is a warm-time capability: it cannot be added to an already-provisioned environment, so enable it on the profile before dispatching.
195+
Set `"desktop": true` in a crabbox profile's `settings` to lease worker boxes with a branded XFCE desktop, Browser, and Terminal. Crabbox provisions TigerVNC on the box loopback with a per-lease password and reports the closed set of installed apps to the Gateway. The Labs gate enables the desktop RPCs and panel; the profile setting gives newly leased workers the desktop capability. Desktop is a warm-time capability: it cannot be added to an already-provisioned environment, so enable it on the profile before dispatching.
196196

197-
Operators with `operator.admin` access watch and control the desktop from the Control UI **Desktop** panel (also in the command palette). The panel lists desktop-capable environments from `environments.list` and connects through the Gateway, which forwards the box's loopback VNC over the same pinned SSH transport used for worker traffic — the desktop is never exposed on the box's network, and the VNC password is delivered only inside the authenticated `worker.desktop.observe` RPC result, never stored by the Gateway.
197+
Operators with `operator.admin` access watch and control the desktop from the Control UI **Desktop** panel (also in the command palette). The panel lists desktop-capable environments from `environments.list`, shows only apps the provider advertised, and launches those apps through `worker.desktop.launch`. It connects through the Gateway, which forwards the box's loopback VNC over the same pinned SSH transport used for worker traffic — the desktop is never exposed on the box's network, and the VNC password is delivered only inside the authenticated `worker.desktop.observe` RPC result, never stored by the Gateway.
198198

199199
Connections start view-only. **Take control** requests an input-capable connection; only one controller is active at a time, and taking control disconnects the previous controller (they are downgraded to view-only). Up to 8 observers can watch one environment. The desktop forward starts on first observe and shuts down about a minute after the last observer disconnects; stopping or reclaiming the environment tears it down immediately.
200200

201-
Desktop observe is not supported when the Gateway itself runs on Windows.
201+
The Browser launcher starts one visible Chrome or Chromium process on the worker display with raw CDP bound to `127.0.0.1` and a fresh lease-scoped user-data directory. It does not import cookies, attach the Chrome extension relay, or use Chrome MCP. The operator toolbar and cloud-worker agent share this process. A worker turn receives the normal `browser` tool only when the lease advertises Browser, the bundled Browser plugin is active, and normal tool policy allows `browser`; workers without that capability keep the existing coding-tool catalog. Generic desktop `computer` control is not part of this Labs surface.
202+
203+
Desktop observe and app launch are not supported when the Gateway itself runs on Windows.
202204

203205
## Security model
204206

‎docs/plugins/manifest.md‎

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

725725
General embedding providers should declare `contracts.embeddingProviders` for each adapter registered with `api.registerEmbeddingProvider(...)`. Use the general contract for reusable vector generation, including providers consumed by memory search. `contracts.memoryEmbeddingProviders` is deprecated memory-specific compatibility and remains only while existing providers migrate to the generic embedding provider seam.
726726

727-
Worker providers must declare each `api.registerWorkerProvider(...)` id in `contracts.workerProviders`. Core persists durable intent before calling `provision`; providers validate their settings before external allocation, and repeated calls with the same operation id must adopt the same lease. 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. 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.
727+
Worker providers must declare each `api.registerWorkerProvider(...)` id in `contracts.workerProviders`. Core persists durable intent before calling `provision`; providers validate their settings before external allocation, and repeated calls with the same operation id must adopt the same lease. 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.
728728

729729
`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.
730730

‎docs/plugins/sdk-overview.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ and external URLs. Registering another provider replaces the current provider.
118118
| `api.registerCompactionProvider(...)` | Pluggable transcript-compaction backend |
119119

120120
Worker providers must also declare their id in `contracts.workerProviders`.
121-
Core persists durable intent before `provision(profile, operationId)`. Providers validate settings before external allocation and throw `WorkerProviderError` for permanent profile rejection. `provision` must adopt the same lease when the operation id repeats.
121+
Core persists durable intent before `provision(profile, operationId)`. Providers validate settings before external allocation and throw `WorkerProviderError` for permanent profile rejection. `provision` must adopt the same lease when the operation id repeats. 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.
122122
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.
123-
`WorkerLease.desktop` is optional and has the shape `{ protocol: "rfb"; port: number; passwordFilePath?: string }`; `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.
123+
`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.
124124
Providers with renewable leases can also implement `renew(leaseId)`.
125125
`inspect` must throw on transient or indeterminate failures; return `unknown` only for authoritative absence. Core marks an active local record orphaned, or treats the absence as teardown completion after a persisted destroy request.
126126

‎extensions/browser/runtime-api.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* plugin consumers while keeping the entrypoint itself declarative.
44
*/
55
export { createBrowserTool } from "./src/browser-tool.js";
6+
export {
7+
createAttachedBrowserToolRuntime,
8+
type AttachedBrowserToolRuntime,
9+
type CreateAttachedBrowserToolRuntimeParams,
10+
} from "./src/attached-browser-tool-runtime.js";
611
export {
712
applyBrowserProxyPaths,
813
browserAct,

0 commit comments

Comments
 (0)