Skip to content

Commit b5affa6

Browse files
committed
fix(plugins): supplement external catalog contracts
1 parent 4419a9d commit b5affa6

5 files changed

Lines changed: 165 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Docs: https://docs.openclaw.ai
3232

3333
### Fixes
3434

35+
- Plugins/catalog: supplement lagging official external WeCom and Yuanbao npm manifests with channel config descriptors and declared tool contracts from the OpenClaw catalog, so trusted package sweeps no longer fail because external package metadata trails the host contract. Thanks @vincentkoc.
3536
- Plugins/install: let trusted official `@openclaw/*` catalog installs recover when npm `latest` points at a prerelease by falling back to the newest stable version, or by allowing prerelease-only launch packages with a warning instead of making beta/development plugin sweeps fail at install time. Thanks @vincentkoc.
3637
- Google Meet: use the local call-control microphone button instead of disabled remote participant mute buttons, and block realtime speech when the OpenClaw Meet microphone remains muted.
3738
- Google Meet: refresh realtime browser state during status and retry delayed speech after Meet finishes joining, so a just-opened in-call tab no longer leaves speech stuck behind stale `not-in-call` health.

‎scripts/lib/official-external-channel-catalog.json‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"id": "wecom-openclaw-plugin",
1111
"label": "WeCom"
1212
},
13+
"contracts": {
14+
"tools": ["wecom_mcp"]
15+
},
1316
"channel": {
1417
"id": "wecom",
1518
"label": "WeCom",
@@ -21,6 +24,16 @@
2124
"aliases": ["qywx", "wework", "enterprise-wechat"],
2225
"order": 45
2326
},
27+
"channelConfigs": {
28+
"wecom": {
29+
"label": "WeCom",
30+
"description": "Enterprise WeChat conversation channel.",
31+
"schema": {
32+
"type": "object",
33+
"additionalProperties": true
34+
}
35+
}
36+
},
2437
"install": {
2538
"npmSpec": "@wecom/[email protected]",
2639
"defaultChoice": "npm",
@@ -38,6 +51,9 @@
3851
"id": "openclaw-plugin-yuanbao",
3952
"label": "Yuanbao"
4053
},
54+
"contracts": {
55+
"tools": ["query_group_info", "query_session_members", "yuanbao_remind"]
56+
},
4157
"channel": {
4258
"id": "yuanbao",
4359
"label": "Yuanbao",
@@ -49,6 +65,16 @@
4965
"aliases": ["yuanbao", "yb", "tencent-yuanbao", "元宝"],
5066
"order": 85
5167
},
68+
"channelConfigs": {
69+
"yuanbao": {
70+
"label": "Yuanbao",
71+
"description": "Tencent Yuanbao AI assistant channel.",
72+
"schema": {
73+
"type": "object",
74+
"additionalProperties": true
75+
}
76+
}
77+
},
5278
"install": {
5379
"npmSpec": "[email protected]",
5480
"defaultChoice": "npm",

‎src/plugins/manifest-registry.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function createPluginCandidate(params: {
6262
origin: "bundled" | "global" | "workspace" | "config";
6363
format?: "openclaw" | "bundle";
6464
bundleFormat?: "codex" | "claude" | "cursor";
65+
packageName?: string;
6566
packageManifest?: OpenClawPackageManifest;
6667
packageDir?: string;
6768
bundledManifest?: PluginCandidate["bundledManifest"];
@@ -74,6 +75,7 @@ function createPluginCandidate(params: {
7475
origin: params.origin,
7576
format: params.format,
7677
bundleFormat: params.bundleFormat,
78+
packageName: params.packageName,
7779
packageManifest: params.packageManifest,
7880
packageDir: params.packageDir,
7981
bundledManifest: params.bundledManifest,
@@ -1098,6 +1100,39 @@ describe("loadPluginManifestRegistry", () => {
10981100
).toBe(false);
10991101
});
11001102

1103+
it("hydrates supplemental official external catalog contracts for lagging npm manifests", () => {
1104+
const dir = makeTempDir();
1105+
writeManifest(dir, {
1106+
id: "wecom-openclaw-plugin",
1107+
channels: ["wecom"],
1108+
configSchema: { type: "object" },
1109+
});
1110+
1111+
const registry = loadRegistry([
1112+
createPluginCandidate({
1113+
idHint: "wecom-openclaw-plugin",
1114+
rootDir: dir,
1115+
origin: "global",
1116+
packageName: "@wecom/wecom-openclaw-plugin",
1117+
}),
1118+
]);
1119+
1120+
expect(registry.plugins[0]?.contracts?.tools).toEqual(["wecom_mcp"]);
1121+
expect(registry.plugins[0]?.channelConfigs?.wecom).toEqual(
1122+
expect.objectContaining({
1123+
label: "WeCom",
1124+
schema: expect.objectContaining({
1125+
type: "object",
1126+
}),
1127+
}),
1128+
);
1129+
expect(
1130+
registry.diagnostics.some((diagnostic) =>
1131+
diagnostic.message.includes("without channelConfigs metadata"),
1132+
),
1133+
).toBe(false);
1134+
});
1135+
11011136
it("drops prototype-polluting channel config keys from plugin manifests", () => {
11021137
const dir = makeTempDir();
11031138
writeTextFile(

‎src/plugins/manifest-registry.ts‎

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ import {
4343
type PluginPackageInstall,
4444
} from "./manifest.js";
4545
import { checkMinHostVersion } from "./min-host-version.js";
46+
import {
47+
getOfficialExternalPluginCatalogEntryForPackage,
48+
getOfficialExternalPluginCatalogManifest,
49+
} from "./official-external-plugin-catalog.js";
4650
import { isPathInside, safeRealpathSync } from "./path-safety.js";
4751
import type { PluginKind } from "./plugin-kind.types.js";
4852
import type { PluginOrigin } from "./plugin-origin.types.js";
@@ -258,6 +262,72 @@ function mergePackageChannelMetaIntoChannelConfigs(params: {
258262
return merged;
259263
}
260264

265+
function mergeContractLists(
266+
left: readonly string[] | undefined,
267+
right: readonly string[] | undefined,
268+
): string[] | undefined {
269+
const merged = [...(left ?? []), ...(right ?? [])]
270+
.map((value) => value.trim())
271+
.filter((value, index, all) => value.length > 0 && all.indexOf(value) === index);
272+
return merged.length > 0 ? merged : undefined;
273+
}
274+
275+
function mergeManifestContracts(
276+
manifestContracts: PluginManifestContracts | undefined,
277+
catalogContracts: PluginManifestContracts | undefined,
278+
): PluginManifestContracts | undefined {
279+
if (!catalogContracts) {
280+
return manifestContracts;
281+
}
282+
const contracts: PluginManifestContracts = {};
283+
for (const key of [
284+
"embeddedExtensionFactories",
285+
"agentToolResultMiddleware",
286+
"externalAuthProviders",
287+
"memoryEmbeddingProviders",
288+
"speechProviders",
289+
"realtimeTranscriptionProviders",
290+
"realtimeVoiceProviders",
291+
"mediaUnderstandingProviders",
292+
"documentExtractors",
293+
"imageGenerationProviders",
294+
"videoGenerationProviders",
295+
"musicGenerationProviders",
296+
"webContentExtractors",
297+
"webFetchProviders",
298+
"webSearchProviders",
299+
"migrationProviders",
300+
"tools",
301+
] as const) {
302+
const merged = mergeContractLists(manifestContracts?.[key], catalogContracts[key]);
303+
if (merged) {
304+
contracts[key] = merged;
305+
}
306+
}
307+
return Object.keys(contracts).length > 0 ? contracts : undefined;
308+
}
309+
310+
function mergeCatalogChannelConfigs(params: {
311+
manifestChannelConfigs?: Record<string, PluginManifestChannelConfig>;
312+
catalogChannelConfigs?: Record<string, PluginManifestChannelConfig>;
313+
}): Record<string, PluginManifestChannelConfig> | undefined {
314+
if (!params.catalogChannelConfigs) {
315+
return params.manifestChannelConfigs;
316+
}
317+
const merged: Record<string, PluginManifestChannelConfig> = Object.create(null);
318+
for (const [key, value] of Object.entries(params.catalogChannelConfigs)) {
319+
if (!isBlockedObjectKey(key)) {
320+
merged[key] = value;
321+
}
322+
}
323+
for (const [key, value] of Object.entries(params.manifestChannelConfigs ?? {})) {
324+
if (!isBlockedObjectKey(key)) {
325+
merged[key] = value;
326+
}
327+
}
328+
return Object.keys(merged).length > 0 ? merged : undefined;
329+
}
330+
261331
function buildRecord(params: {
262332
manifest: PluginManifest;
263333
candidate: PluginCandidate;
@@ -274,8 +344,17 @@ function buildRecord(params: {
274344
packageManifest: params.candidate.packageManifest,
275345
})
276346
: params.manifest.channelConfigs;
347+
const officialCatalogManifest =
348+
params.candidate.origin !== "bundled"
349+
? getOfficialExternalPluginCatalogManifest(
350+
getOfficialExternalPluginCatalogEntryForPackage(params.candidate.packageName) ?? {},
351+
)
352+
: undefined;
277353
const channelConfigs = mergePackageChannelMetaIntoChannelConfigs({
278-
channelConfigs: manifestChannelConfigs,
354+
channelConfigs: mergeCatalogChannelConfigs({
355+
manifestChannelConfigs,
356+
catalogChannelConfigs: officialCatalogManifest?.channelConfigs,
357+
}),
279358
packageChannel: params.candidate.packageManifest?.channel,
280359
});
281360
const packageChannelCommands = normalizePackageChannelCommands(
@@ -341,7 +420,10 @@ function buildRecord(params: {
341420
schemaCacheKey: params.schemaCacheKey,
342421
configSchema: params.configSchema,
343422
configUiHints: params.manifest.uiHints,
344-
contracts: params.manifest.contracts,
423+
contracts: mergeManifestContracts(
424+
params.manifest.contracts,
425+
officialCatalogManifest?.contracts,
426+
),
345427
mediaUnderstandingProviderMetadata: params.manifest.mediaUnderstandingProviderMetadata,
346428
imageGenerationProviderMetadata: params.manifest.imageGenerationProviderMetadata,
347429
videoGenerationProviderMetadata: params.manifest.videoGenerationProviderMetadata,

‎src/plugins/official-external-plugin-catalog.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import officialExternalProviderCatalog from "../../scripts/lib/official-external
44
import { MANIFEST_KEY } from "../compat/legacy-names.js";
55
import { normalizeOptionalString } from "../shared/string-coerce.js";
66
import { isRecord } from "../utils.js";
7-
import type { PluginPackageInstall } from "./manifest.js";
7+
import type {
8+
PluginManifestChannelConfig,
9+
PluginManifestContracts,
10+
PluginPackageInstall,
11+
} from "./manifest.js";
812

913
type ManifestKey = typeof MANIFEST_KEY;
1014

@@ -60,6 +64,8 @@ export type OfficialExternalPluginCatalogManifest = {
6064
providers?: readonly OfficialExternalProviderCatalogProvider[];
6165
webSearchProviders?: readonly OfficialExternalWebSearchProvider[];
6266
install?: PluginPackageInstall;
67+
contracts?: PluginManifestContracts;
68+
channelConfigs?: Record<string, PluginManifestChannelConfig>;
6369
};
6470

6571
export type OfficialExternalPluginCatalogEntry = {
@@ -198,3 +204,15 @@ export function getOfficialExternalPluginCatalogEntry(
198204
resolveOfficialExternalPluginLookupIds(entry).includes(normalized),
199205
);
200206
}
207+
208+
export function getOfficialExternalPluginCatalogEntryForPackage(
209+
packageName: string | undefined,
210+
): OfficialExternalPluginCatalogEntry | undefined {
211+
const normalized = packageName?.trim();
212+
if (!normalized) {
213+
return undefined;
214+
}
215+
return listOfficialExternalPluginCatalogEntries().find(
216+
(entry) => normalizeOptionalString(entry.name) === normalized,
217+
);
218+
}

0 commit comments

Comments
 (0)