fix(plugins): normalize compat allowlist aliases

This commit is contained in:
Peter Steinberger
2026-05-04 23:45:31 +01:00
parent 40e0844133
commit d362879282
2 changed files with 28 additions and 1 deletions

View File

@@ -153,6 +153,30 @@ describe("implicit provider plugin allowlist compatibility", () => {
});
});
it("re-enables globally disabled plugins when allowlist mode accepts a plugin alias", () => {
const config = withBundledPluginEnablementCompat({
config: {
plugins: {
enabled: false,
allow: [" Google-Gemini-Cli "],
bundledDiscovery: "allowlist",
},
},
pluginIds: ["google"],
});
expect(config).toEqual({
plugins: {
enabled: true,
allow: [" Google-Gemini-Cli "],
bundledDiscovery: "allowlist",
entries: {
google: { enabled: true },
},
},
});
});
it("still honors explicit plugin denies over compat allowlist injection", () => {
const config = withBundledPluginEnablementCompat({
config: withBundledPluginAllowlistCompat({

View File

@@ -1,6 +1,7 @@
import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { PluginEntryConfig } from "../config/types.plugins.js";
import { hasExplicitPluginConfig } from "./config-policy.js";
import { normalizePluginId } from "./config-state.js";
export function withBundledPluginAllowlistCompat(params: {
config: OpenClawConfig | undefined;
@@ -45,7 +46,9 @@ export function withBundledPluginEnablementCompat(params: {
const useCompatDiscovery = params.config?.plugins?.bundledDiscovery === "compat";
const allow = params.config?.plugins?.allow;
const allowSet =
!useCompatDiscovery && Array.isArray(allow) && allow.length > 0 ? new Set(allow) : undefined;
!useCompatDiscovery && Array.isArray(allow) && allow.length > 0
? new Set(allow.map((pluginId) => normalizePluginId(pluginId)).filter(Boolean))
: undefined;
let hasEligiblePlugin = false;
let changed = false;
const nextEntries: Record<string, PluginEntryConfig> = { ...existingEntries };