fix(plugins): merge external catalog channel hints

This commit is contained in:
Vincent Koc
2026-05-03 16:24:07 -07:00
parent 392897304c
commit b520e40cf6
3 changed files with 74 additions and 1 deletions

View File

@@ -1133,6 +1133,48 @@ describe("loadPluginManifestRegistry", () => {
).toBe(false);
});
it("fills missing official external catalog descriptors for partial npm channel configs", () => {
const dir = makeTempDir();
writeManifest(dir, {
id: "wecom-openclaw-plugin",
channels: ["wecom"],
configSchema: { type: "object" },
channelConfigs: {
wecom: {
schema: {
type: "object",
additionalProperties: false,
properties: {
corpId: { type: "string" },
},
},
},
},
});
const registry = loadRegistry([
createPluginCandidate({
idHint: "wecom-openclaw-plugin",
rootDir: dir,
origin: "global",
packageName: "@wecom/wecom-openclaw-plugin",
}),
]);
expect(registry.plugins[0]?.channelConfigs?.wecom).toEqual(
expect.objectContaining({
label: "WeCom",
description: "Enterprise WeChat conversation channel.",
schema: expect.objectContaining({
additionalProperties: false,
properties: {
corpId: { type: "string" },
},
}),
}),
);
});
it("drops prototype-polluting channel config keys from plugin manifests", () => {
const dir = makeTempDir();
writeTextFile(

View File

@@ -322,7 +322,37 @@ function mergeCatalogChannelConfigs(params: {
}
for (const [key, value] of Object.entries(params.manifestChannelConfigs ?? {})) {
if (!isBlockedObjectKey(key)) {
merged[key] = value;
const catalogValue = merged[key];
merged[key] = catalogValue
? {
...catalogValue,
...value,
schema: value.schema ?? catalogValue.schema,
...(catalogValue.uiHints || value.uiHints
? {
uiHints: {
...catalogValue.uiHints,
...value.uiHints,
},
}
: {}),
...((value.runtime ?? catalogValue.runtime)
? { runtime: value.runtime ?? catalogValue.runtime }
: {}),
...((value.label ?? catalogValue.label)
? { label: value.label ?? catalogValue.label }
: {}),
...((value.description ?? catalogValue.description)
? { description: value.description ?? catalogValue.description }
: {}),
...((value.preferOver ?? catalogValue.preferOver)
? { preferOver: value.preferOver ?? catalogValue.preferOver }
: {}),
...((value.commands ?? catalogValue.commands)
? { commands: value.commands ?? catalogValue.commands }
: {}),
}
: value;
}
}
return Object.keys(merged).length > 0 ? merged : undefined;