fix(config): prefer plugin ids for built-in channel claims

Prefer the manifest plugin id when auto-allowlisting configured built-in channel aliases, with regression coverage for alias/id split plugins and same-name official channel plugins.
This commit is contained in:
Brandon
2026-05-04 18:15:18 -04:00
committed by GitHub
parent 683d892eed
commit 70b1c17ae0
3 changed files with 52 additions and 1 deletions

View File

@@ -335,6 +335,56 @@ describe("applyPluginAutoEnable channels", () => {
});
describe("preferOver channel prioritization", () => {
it("uses the plugin manifest id for built-in channel claims", () => {
const result = applyPluginAutoEnable({
config: {
channels: {
wecom: { token: "enabled" },
},
plugins: {
allow: ["existing-plugin"],
},
},
env: makeIsolatedEnv(),
manifestRegistry: makeRegistry([
{
id: "wecom-openclaw-plugin",
channels: ["wecom"],
},
]),
});
expect(result.config.plugins?.entries?.["wecom-openclaw-plugin"]?.enabled).toBe(true);
expect(result.config.plugins?.entries?.wecom).toBeUndefined();
expect(result.config.plugins?.allow).toEqual(["existing-plugin", "wecom-openclaw-plugin"]);
expect(result.changes.join("\n")).toContain("enabled automatically.");
});
it("preserves same-name official channel plugin ids", () => {
const result = applyPluginAutoEnable({
config: {
channels: {
discord: { token: "enabled" },
},
plugins: {
allow: ["existing-plugin"],
},
},
env: makeIsolatedEnv(),
manifestRegistry: makeRegistry([
{
id: "discord",
channels: ["discord"],
},
]),
});
expect(result.config.channels?.discord?.enabled).toBe(true);
expect(result.config.plugins?.entries?.discord).toBeUndefined();
expect(result.config.plugins?.allow).toEqual(["existing-plugin", "discord"]);
expect(result.changes.join("\n")).toContain("Discord configured, enabled automatically.");
});
it("uses manifest channel config preferOver metadata for plugin channels", () => {
const result = applyPluginAutoEnable({
config: {

View File

@@ -303,7 +303,7 @@ function collectPluginIdsForConfiguredChannel(
if (preferredIds.size > 0) {
return [...preferredIds].toSorted((left, right) => left.localeCompare(right));
}
return [builtInId ?? claims[0]?.plugin.id ?? normalizedChannelId];
return [claims[0]?.plugin.id ?? builtInId ?? normalizedChannelId];
}
function collectConfiguredChannelIds(cfg: OpenClawConfig, env: NodeJS.ProcessEnv): string[] {