mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:10:43 +00:00
fix(plugins): merge external catalog channel hints
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user