mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:40:44 +00:00
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:
@@ -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: {
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
Reference in New Issue
Block a user