Skip to content

Commit 4847655

Browse files
authored
fix(cua-computer): ignore retired driver path (#120502)
1 parent 266ad72 commit 4847655

6 files changed

Lines changed: 48 additions & 99 deletions

File tree

‎extensions/cua-computer/doctor-contract-api.test.ts‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎extensions/cua-computer/doctor-contract-api.ts‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import fs from "node:fs";
2+
import {
3+
validateJsonSchemaValue,
4+
type JsonSchemaObject,
5+
} from "openclaw/plugin-sdk/json-schema-runtime";
16
import type {
27
OpenClawPluginApi,
38
OpenClawPluginNodeHostCommand,
@@ -7,6 +12,17 @@ import type {
712
import { describe, expect, it, vi } from "vitest";
813
import plugin from "./index.js";
914

15+
function validateManifestConfig(value: unknown) {
16+
const manifest = JSON.parse(
17+
fs.readFileSync(new URL("./openclaw.plugin.json", import.meta.url), "utf8"),
18+
) as { configSchema: JsonSchemaObject };
19+
return validateJsonSchemaValue({
20+
cacheKey: "cua-computer.manifest.config.test",
21+
schema: manifest.configSchema,
22+
value,
23+
});
24+
}
25+
1026
describe("cua-computer plugin registration", () => {
1127
it("registers the screen and dangerous computer node-host commands", () => {
1228
const commands: OpenClawPluginNodeHostCommand[] = [];
@@ -26,6 +42,28 @@ describe("cua-computer plugin registration", () => {
2642
expect(policies[0]?.defaultPlatforms).toBeUndefined();
2743
});
2844

45+
it("accepts the retired driver path as a no-op while keeping both schemas strict", () => {
46+
const config = { driverPath: "/usr/local/bin/cua-driver" };
47+
const runtimeResult = plugin.configSchema.safeParse?.(config);
48+
49+
expect(runtimeResult).toEqual({ success: true, data: config });
50+
expect(validateManifestConfig(config).ok).toBe(true);
51+
expect(plugin.configSchema.safeParse?.({ unexpected: true }).success).toBe(false);
52+
expect(validateManifestConfig({ unexpected: true }).ok).toBe(false);
53+
54+
const commands: OpenClawPluginNodeHostCommand[] = [];
55+
plugin.register({
56+
pluginConfig: config,
57+
registerNodeHostCommand: (command: OpenClawPluginNodeHostCommand) => commands.push(command),
58+
registerNodeInvokePolicy: () => {},
59+
} as unknown as OpenClawPluginApi);
60+
61+
expect(commands.map(({ command, cap, dangerous }) => ({ command, cap, dangerous }))).toEqual([
62+
{ command: "screen.snapshot", cap: "screen", dangerous: false },
63+
{ command: "computer.act", cap: "computer", dangerous: true },
64+
]);
65+
});
66+
2967
it("forwards an explicitly armed computer action and preserves node refusals", async () => {
3068
const policies: OpenClawPluginNodeInvokePolicy[] = [];
3169
plugin.register({

‎extensions/cua-computer/index.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { buildPluginConfigSchema, definePluginEntry } from "openclaw/plugin-sdk/
22
import { z } from "zod";
33
import { createCuaComputerCommands } from "./src/commands.js";
44

5-
const CuaComputerConfigSchema = z.strictObject({});
5+
const CuaComputerConfigSchema = z.strictObject({
6+
// Keep the shipped daemon setting as a named no-op: strict validation accepts
7+
// existing config, but direct SDK commands never receive a binary path.
8+
driverPath: z.string().optional(),
9+
});
610

711
const configSchema = buildPluginConfigSchema(CuaComputerConfigSchema, {
812
uiHints: {},
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"id": "cua-computer",
3-
"doctorContract": {
4-
"configRepair": true
5-
},
63
"activation": {
74
"onStartup": true
85
},
@@ -12,6 +9,10 @@
129
"configSchema": {
1310
"type": "object",
1411
"additionalProperties": false,
15-
"properties": {}
12+
"properties": {
13+
"driverPath": {
14+
"type": "string"
15+
}
16+
}
1617
}
1718
}

‎src/plugins/bundled-plugin-metadata.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,6 @@ describe("bundled plugin metadata", () => {
430430
});
431431
});
432432

433-
it("keeps CUA's doctor contract sidecar on the bundled public surface", () => {
434-
const cua = listRepoBundledPluginMetadata().find((entry) => entry.dirName === "cua-computer");
435-
expectArtifactPresence(cua?.publicSurfaceArtifacts, {
436-
contains: ["doctor-contract-api.js"],
437-
});
438-
});
439-
440433
it("keeps iMessage message-tool discovery on a narrow public surface", () => {
441434
const imessage = listRepoBundledPluginMetadata().find((entry) => entry.dirName === "imessage");
442435
expectArtifactPresence(imessage?.publicSurfaceArtifacts, {

0 commit comments

Comments
 (0)