Skip to content

Commit 45a6a82

Browse files
committed
fix(cua-computer): migrate retired driver path
1 parent 1e5eec1 commit 45a6a82

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// CUA tests cover the doctor-only migration for the retired daemon path.
2+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
3+
import { describe, expect, it } from "vitest";
4+
import { legacyConfigRules, normalizeCompatibilityConfig } from "./doctor-contract-api.js";
5+
6+
describe("cua-computer doctor contract", () => {
7+
it("flags the retired driver path for openclaw doctor --fix", () => {
8+
expect(legacyConfigRules).toEqual([
9+
expect.objectContaining({
10+
path: ["plugins", "entries", "cua-computer", "config", "driverPath"],
11+
message: expect.stringContaining("openclaw doctor --fix"),
12+
}),
13+
]);
14+
});
15+
16+
it("removes the shipped daemon path before strict plugin validation", () => {
17+
const config = {
18+
plugins: {
19+
entries: {
20+
"cua-computer": {
21+
enabled: true,
22+
config: { driverPath: "/usr/local/bin/cua-driver" },
23+
},
24+
},
25+
},
26+
} as OpenClawConfig;
27+
28+
const result = normalizeCompatibilityConfig({ cfg: config });
29+
30+
expect(result.changes).toEqual([
31+
"Removed retired plugins.entries.cua-computer.config.driverPath; CUA Driver SDK is configured directly by OpenClaw.",
32+
]);
33+
expect(result.config.plugins?.entries?.["cua-computer"]).toEqual({
34+
enabled: true,
35+
config: {},
36+
});
37+
expect(config.plugins?.entries?.["cua-computer"]?.config).toEqual({
38+
driverPath: "/usr/local/bin/cua-driver",
39+
});
40+
expect(normalizeCompatibilityConfig({ cfg: result.config })).toEqual({
41+
config: result.config,
42+
changes: [],
43+
});
44+
});
45+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// CUA config migrations belong to the plugin so doctor can repair a shipped
2+
// driverPath setting before strict manifest validation reaches this plugin.
3+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
4+
import { asObjectRecord } from "openclaw/plugin-sdk/runtime-doctor";
5+
6+
const DRIVER_PATH = ["plugins", "entries", "cua-computer", "config", "driverPath"];
7+
8+
/** Retired CUA daemon configuration that `openclaw doctor --fix` removes. */
9+
export const legacyConfigRules = [
10+
{
11+
path: DRIVER_PATH,
12+
message:
13+
'plugins.entries.cua-computer.config.driverPath is retired; the CUA Driver SDK is configured directly by OpenClaw. Run "openclaw doctor --fix".',
14+
},
15+
];
16+
17+
/** Removes the retired daemon path without making it a runtime compatibility key. */
18+
export function normalizeCompatibilityConfig({ cfg }: { cfg: OpenClawConfig }): {
19+
config: OpenClawConfig;
20+
changes: string[];
21+
} {
22+
const entry = asObjectRecord(cfg.plugins?.entries?.["cua-computer"]);
23+
const pluginConfig = asObjectRecord(entry?.config);
24+
if (!pluginConfig || !Object.hasOwn(pluginConfig, "driverPath")) {
25+
return { config: cfg, changes: [] };
26+
}
27+
28+
const nextConfig = structuredClone(cfg);
29+
const nextEntry = asObjectRecord(nextConfig.plugins?.entries?.["cua-computer"]);
30+
const nextPluginConfig = asObjectRecord(nextEntry?.config);
31+
if (!nextPluginConfig) {
32+
return { config: cfg, changes: [] };
33+
}
34+
delete nextPluginConfig.driverPath;
35+
36+
return {
37+
config: nextConfig,
38+
changes: [
39+
"Removed retired plugins.entries.cua-computer.config.driverPath; CUA Driver SDK is configured directly by OpenClaw.",
40+
],
41+
};
42+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ 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+
433440
it("keeps iMessage message-tool discovery on a narrow public surface", () => {
434441
const imessage = listRepoBundledPluginMetadata().find((entry) => entry.dirName === "imessage");
435442
expectArtifactPresence(imessage?.publicSurfaceArtifacts, {

0 commit comments

Comments
 (0)