Skip to content

Commit a32a7ae

Browse files
authored
feat(cua-computer): verify the managed driver artifact on Windows and Linux node hosts (#123986)
1 parent 05c64cb commit a32a7ae

15 files changed

Lines changed: 701 additions & 16 deletions

‎docs/nodes/computer-use.md‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Provider selection never falls back per action. Switching providers closes the a
1919
- **macOS fulfiller:** app setting **Allow Computer Control** enabled. It defaults on; an explicit off choice stays off.
2020
- **macOS fulfiller:** choose **Peekaboo** (default) or **CUA**. CUA is selectable only when the pinned driver is present in the signed app bundle; development builds without that artifact show **driver not bundled**.
2121
- **macOS fulfiller:** **Accessibility** and **Screen Recording** granted to OpenClaw. The native Peekaboo path also requires Event Posting access for its CoreGraphics input primitives.
22-
- **Windows/Linux fulfiller:** bundled `cua-computer` plugin enabled. Its package includes the pinned CUA Driver SDK 0.19.3 runtime; no `cua-driver` executable, daemon, or MCP server is configured.
22+
- **Windows/Linux fulfiller:** bundled `cua-computer` plugin enabled on Windows x64/ARM64 or glibc-based Linux x64/ARM64. Its package includes the pinned CUA Driver SDK 0.19.3 runtime; no `cua-driver` executable, daemon, or MCP server is configured.
2323
- The pairing update that includes `computer.act` approved on the gateway.
2424
- A vision-capable agent model.
2525
- Tool policy that exposes `computer`. The default `coding` profile does not. Add `computer` to `tools.alsoAllow`; sandboxed agents also need it in `tools.sandbox.tools.alsoAllow`.
@@ -72,9 +72,17 @@ The bundled `cua-computer` plugin provides an experimental fulfiller for Windows
7272
openclaw plugins enable cua-computer
7373
```
7474

75-
2. Start `openclaw node run` from the interactive desktop session. The plugin creates its configured SDK runtime lazily, then creates one OpenClaw-owned trusted session for the node-host command execution. It closes that session and shuts down the runtime when the command host stops or restarts.
75+
2. Verify the node-local SDK package before starting the node:
7676

77-
3. Add `computer.act` to the Gateway allowlist. This plugin registers `computer.act` as a dangerous plugin node command, so enabling the plugin alone is not enough; the operator must opt in explicitly:
77+
```bash
78+
openclaw doctor --lint --only cua-computer/driver-artifacts
79+
```
80+
81+
OpenClaw checks the SDK package version, the selected OS/CPU package version, regular-file identity, and the pinned SHA-256 digest of the native library and Node runtime. A clean check prints `no findings`. If it reports a `COMPUTER_DRIVER_*` error, reinstall or update OpenClaw on this node host and run the check again. Do not download a standalone `cua-driver` executable or add one to `PATH`; Windows and Linux use the npm-installed in-process SDK.
82+
83+
3. Start `openclaw node run` from the interactive desktop session. The plugin repeats the artifact verification at startup before it imports native code, creates its configured SDK runtime lazily, then creates one OpenClaw-owned trusted session for the node-host command execution. It closes that session and shuts down the runtime when the command host stops or restarts.
84+
85+
4. Add `computer.act` to the Gateway allowlist. This plugin registers `computer.act` as a dangerous plugin node command, so enabling the plugin alone is not enough; the operator must opt in explicitly:
7886

7987
```json5
8088
{
@@ -92,13 +100,19 @@ The plugin calls `CuaDriver.createConfigured`, never bare `create()`. Its author
92100

93101
On Windows and Linux this is a hard replacement of the former 0.10 daemon/MCP integration: OpenClaw does not spawn a CUA process or proxy an MCP client. macOS deliberately uses the app-owned embedded daemon described above so the driver remains in `OpenClaw.app`'s TCC responsibility chain. Neither path falls back to another provider for an individual action.
94102

103+
The accepted driver record lives with the `cua-computer` package and supplies both the npm native-file digests and the macOS archive digest. Updating OpenClaw updates that record and the SDK packages together. There is no independent Windows/Linux driver updater or rollback directory because there is no separate driver installation on those hosts; roll back by installing the previous known-good OpenClaw package, then rerun the focused doctor check before restarting the node.
104+
95105
### Troubleshooting
96106

97107
The `cua-computer` fulfiller surfaces typed error codes in the tool result and node logs. Common ones:
98108

99109
| Code | Cause | Fix |
100110
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
101111
| `COMPUTER_DRIVER_UNAVAILABLE` | The CUA runtime cannot initialize, the macOS app-owned endpoint is absent, or the desktop permissions/session are unavailable. | On macOS, verify CUA is selected and the bundled driver is ready; on Windows/Linux, run `openclaw node run` inside the interactive desktop session. Reinstall OpenClaw if the pinned runtime is missing. |
112+
| `COMPUTER_DRIVER_PACKAGE_MISSING` | The pinned SDK package, OS/CPU native package, native library, or Node runtime is absent or unreadable. | Reinstall OpenClaw on the node host, rerun `openclaw doctor --lint --only cua-computer/driver-artifacts`, then restart the node. |
113+
| `COMPUTER_DRIVER_VERSION_MISMATCH` | The SDK package or selected native package does not match the accepted 0.19.3 version. | Update or reinstall OpenClaw so both packages come from the same release; rerun the focused doctor check. |
114+
| `COMPUTER_DRIVER_DIGEST_MISMATCH` | A native SDK library or Node runtime is not a regular package file or does not match its pinned SHA-256 digest. | Do not run or replace the file manually. Reinstall OpenClaw, rerun the focused doctor check, then restart the node. |
115+
| `COMPUTER_DRIVER_PLATFORM_UNSUPPORTED` | The node host has no published 0.19.3 native SDK package, such as musl Linux or an unsupported CPU architecture. | Use Windows x64/ARM64 or glibc-based Linux x64/ARM64 for this provider. |
102116
| `COMPUTER_REFUSED_<code>` | The driver refused the action with a structured code such as `background_unavailable`, `background_occluded`, or `foreground_unavailable` (KDE/KWin Wayland). | Bring the target window forward, switch to X11, or use a supported compositor. See the compatibility notes above. |
103117
| `COMPUTER_STALE_FRAME` | The coordinates referenced a screenshot that is no longer current (context compaction, a display geometry change, or a reference-width change). | Take a fresh `screenshot` before the coordinate action. |
104118
| `COMPUTER_STALE_OBSERVATION` | A window or browser reference belongs to an older observation, navigation, execution, or driver generation. | Run `get_window_state` or `get_browser_state` again and retry with the new opaque references. |

‎extensions/cua-computer/api.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { CUA_DRIVER_ARTIFACT_CHECK_ID, registerCuaDriverDoctorChecks } from "./src/doctor.js";

‎extensions/cua-computer/index.test.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ import type {
99
OpenClawPluginNodeInvokePolicy,
1010
OpenClawPluginNodeInvokePolicyContext,
1111
} from "openclaw/plugin-sdk/plugin-entry";
12-
import { describe, expect, it, vi } from "vitest";
12+
import { beforeEach, describe, expect, it, vi } from "vitest";
13+
14+
const artifactMocks = vi.hoisted(() => ({
15+
verify: vi.fn(),
16+
}));
17+
18+
vi.mock("./src/driver-artifacts.js", () => ({
19+
verifyInstalledCuaDriverArtifacts: artifactMocks.verify,
20+
}));
21+
1322
import plugin from "./index.js";
1423

1524
function validateManifestConfig(value: unknown) {
@@ -24,6 +33,10 @@ function validateManifestConfig(value: unknown) {
2433
}
2534

2635
describe("cua-computer plugin registration", () => {
36+
beforeEach(() => {
37+
artifactMocks.verify.mockReset().mockReturnValue({ ok: true, applicable: false });
38+
});
39+
2740
it("defaults on only for the app-gated macOS provider path", () => {
2841
const manifest = JSON.parse(
2942
fs.readFileSync(new URL("./openclaw.plugin.json", import.meta.url), "utf8"),
@@ -74,6 +87,28 @@ describe("cua-computer plugin registration", () => {
7487
]);
7588
});
7689

90+
it("logs the typed artifact diagnostic during plugin startup", () => {
91+
const error = vi.fn();
92+
artifactMocks.verify.mockReturnValue({
93+
ok: false,
94+
code: "COMPUTER_DRIVER_PACKAGE_MISSING",
95+
diagnostic:
96+
"COMPUTER_DRIVER_PACKAGE_MISSING: native package absent. Fix: reinstall OpenClaw.",
97+
fixHint: "Reinstall OpenClaw.",
98+
});
99+
100+
plugin.register({
101+
pluginConfig: {},
102+
logger: { error },
103+
registerNodeHostCommand: () => {},
104+
registerNodeInvokePolicy: () => {},
105+
} as unknown as OpenClawPluginApi);
106+
107+
expect(error).toHaveBeenCalledWith(
108+
"COMPUTER_DRIVER_PACKAGE_MISSING: native package absent. Fix: reinstall OpenClaw.",
109+
);
110+
});
111+
77112
it("forwards an explicitly armed computer action and preserves node refusals", async () => {
78113
const policies: OpenClawPluginNodeInvokePolicy[] = [];
79114
plugin.register({

‎extensions/cua-computer/index.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { registerComputerUseProvider } from "openclaw/plugin-sdk/computer-use";
22
import { buildPluginConfigSchema, definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
33
import { z } from "zod";
4+
import { registerCuaDriverDoctorChecks } from "./api.js";
45
import { createCuaComputerProvider } from "./src/commands.js";
6+
import { verifyInstalledCuaDriverArtifacts } from "./src/driver-artifacts.js";
57

68
const CuaComputerConfigSchema = z.strictObject({
79
// Keep the shipped daemon setting as a named no-op: strict validation accepts
@@ -17,12 +19,17 @@ export default definePluginEntry({
1719
description: "Experimental CUA Driver computer control for macOS, Windows, and Linux node hosts.",
1820
configSchema,
1921
register(api) {
22+
registerCuaDriverDoctorChecks();
2023
const parsed = CuaComputerConfigSchema.safeParse(api.pluginConfig ?? {});
2124
if (!parsed.success) {
2225
throw new Error(
2326
`Invalid cua-computer plugin config: ${parsed.error.issues[0]?.message ?? "invalid config"}`,
2427
);
2528
}
29+
const artifactVerification = verifyInstalledCuaDriverArtifacts();
30+
if (!artifactVerification.ok) {
31+
api.logger?.error(artifactVerification.diagnostic);
32+
}
2633
registerComputerUseProvider(api, createCuaComputerProvider());
2734
// Dangerous plugin command: excluded from default allowlists, and the
2835
// Gateway fails closed when this policy registration is missing.

‎extensions/cua-computer/package.json‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@
1111
"devDependencies": {
1212
"@openclaw/plugin-sdk": "workspace:*"
1313
},
14+
"cuaDriverArtifacts": {
15+
"darwin-universal-binary": {
16+
"archiveSha256": "733e28a3782ac8d325f8fce8b5d97486c1054af755b40dfd086151b34c79377e"
17+
},
18+
"linux-arm64-gnu": {
19+
"files": {
20+
"cua_driver_node_runtime.node": "8347edcfd0a6e842d2e76bd90f465b228f36bf402c0e59da90bfac3fe6004d58",
21+
"libcua_driver_sdk.so": "7263f8980f91585d5a02e0001042b619322bfc5cc56ca9fb626ae56fcccceb2a"
22+
}
23+
},
24+
"linux-x64-gnu": {
25+
"files": {
26+
"cua_driver_node_runtime.node": "52b70432d2eb167e69632246a38d895c9e7aa61618a31638d393ad6838117293",
27+
"libcua_driver_sdk.so": "31c142f5c67443a1fa933160bfa20d93b9914220fb9a47f2884d38df20ab0671"
28+
}
29+
},
30+
"win32-arm64-msvc": {
31+
"files": {
32+
"cua_driver_node_runtime.node": "fe025669d1614b1ac9a82d1b6a331acd15b44caef81e5bda6a0b02e1d9a4b71f",
33+
"cua_driver_sdk.dll": "f1f25699dbdcc05169230b8286800b69a10407abb20effd5b767629fe725f21b"
34+
}
35+
},
36+
"win32-x64-msvc": {
37+
"files": {
38+
"cua_driver_node_runtime.node": "fa9231bfa0c3c9d6deb8ed32d29dd0ef96921b51ea6864c963fd36c99b716b1c",
39+
"cua_driver_sdk.dll": "d7e67baef87fac1a315d86113eeb485fbf8e03e5906797f0bf79d24a990fa38b"
40+
}
41+
}
42+
},
1443
"openclaw": {
1544
"extensions": [
1645
"./index.ts"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { HealthCheck } from "openclaw/plugin-sdk/health";
2+
import { beforeEach, describe, expect, it, vi } from "vitest";
3+
4+
const mocks = vi.hoisted(() => ({
5+
verify: vi.fn(),
6+
}));
7+
8+
vi.mock("./driver-artifacts.js", () => ({
9+
verifyInstalledCuaDriverArtifacts: mocks.verify,
10+
}));
11+
12+
import { CUA_DRIVER_ARTIFACT_CHECK_ID, registerCuaDriverDoctorChecks } from "./doctor.js";
13+
14+
describe("CUA Driver doctor check", () => {
15+
beforeEach(() => {
16+
mocks.verify.mockReset();
17+
});
18+
19+
it("returns the typed artifact failure with the operator repair", async () => {
20+
mocks.verify.mockReturnValue({
21+
ok: false,
22+
code: "COMPUTER_DRIVER_VERSION_MISMATCH",
23+
diagnostic: "COMPUTER_DRIVER_VERSION_MISMATCH: expected 0.19.3. Fix: reinstall OpenClaw.",
24+
fixHint: "Reinstall OpenClaw.",
25+
});
26+
let check: HealthCheck | undefined;
27+
registerCuaDriverDoctorChecks({
28+
registerHealthCheck(value) {
29+
check = value;
30+
},
31+
});
32+
33+
expect(check?.id).toBe(CUA_DRIVER_ARTIFACT_CHECK_ID);
34+
await expect(check?.detect({} as never)).resolves.toEqual([
35+
expect.objectContaining({
36+
checkId: CUA_DRIVER_ARTIFACT_CHECK_ID,
37+
severity: "error",
38+
message: expect.stringContaining("COMPUTER_DRIVER_VERSION_MISMATCH"),
39+
fixHint: "Reinstall OpenClaw.",
40+
}),
41+
]);
42+
});
43+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
getHealthCheck,
3+
registerHealthCheck as registerPluginHealthCheck,
4+
type HealthCheck,
5+
} from "openclaw/plugin-sdk/health";
6+
import { verifyInstalledCuaDriverArtifacts } from "./driver-artifacts.js";
7+
8+
export const CUA_DRIVER_ARTIFACT_CHECK_ID = "cua-computer/driver-artifacts";
9+
10+
const cuaDriverArtifactCheck: HealthCheck = {
11+
id: CUA_DRIVER_ARTIFACT_CHECK_ID,
12+
kind: "plugin",
13+
description: "Verify the installed Windows/Linux CUA Driver SDK artifact.",
14+
source: "cua-computer",
15+
async detect() {
16+
const verification = verifyInstalledCuaDriverArtifacts();
17+
if (verification.ok) {
18+
return [];
19+
}
20+
return [
21+
{
22+
checkId: CUA_DRIVER_ARTIFACT_CHECK_ID,
23+
severity: "error",
24+
source: "cua-computer",
25+
message: verification.diagnostic,
26+
target: "@trycua/cua-driver",
27+
requirement: "the accepted CUA Driver SDK version and native package digests",
28+
fixHint: verification.fixHint,
29+
},
30+
];
31+
},
32+
};
33+
34+
type CuaDriverDoctorRegistrationHost = {
35+
readonly registerHealthCheck: (check: HealthCheck) => void;
36+
};
37+
38+
const registeredHosts = new WeakSet<(check: HealthCheck) => void>();
39+
40+
export function registerCuaDriverDoctorChecks(host?: CuaDriverDoctorRegistrationHost): void {
41+
const registerHealthCheck = host?.registerHealthCheck ?? registerPluginHealthCheck;
42+
if (registeredHosts.has(registerHealthCheck)) {
43+
return;
44+
}
45+
if (
46+
host === undefined &&
47+
getHealthCheck(CUA_DRIVER_ARTIFACT_CHECK_ID) === cuaDriverArtifactCheck
48+
) {
49+
return;
50+
}
51+
registerHealthCheck(cuaDriverArtifactCheck);
52+
registeredHosts.add(registerHealthCheck);
53+
}

0 commit comments

Comments
 (0)