fix(plugins): avoid unscoped media generation fallback loads

This commit is contained in:
brokemac79
2026-04-29 00:59:47 +01:00
committed by Shakker
parent f22ff47822
commit c6a1dcbca7
2 changed files with 34 additions and 0 deletions

View File

@@ -678,6 +678,37 @@ describe("resolvePluginCapabilityProviders", () => {
]);
});
it("does not unscoped-load media generation capabilities without bundled owners", () => {
const cfg = { plugins: { allow: ["openai"] } } as OpenClawConfig;
mocks.loadPluginManifestRegistry.mockReturnValue({
plugins: [
{
id: "openai",
origin: "bundled",
contracts: {
imageGenerationProviders: ["openai"],
},
},
] as never,
diagnostics: [],
});
expectNoResolvedCapabilityProviders(
resolvePluginCapabilityProviders({ key: "imageGenerationProviders", cfg }),
);
expectNoResolvedCapabilityProviders(
resolvePluginCapabilityProviders({ key: "musicGenerationProviders", cfg }),
);
const snapshotLoadOptions = mocks.resolveRuntimePluginRegistry.mock.calls
.map(([options]) => options)
.filter(
(options): options is { activate: boolean; onlyPluginIds?: string[] } =>
Boolean(options && typeof options === "object" && "activate" in options),
);
expect(snapshotLoadOptions.map((options) => options.onlyPluginIds)).toEqual([["openai"]]);
});
it("loads only the bundled owner plugin for a targeted provider lookup", () => {
const cfg = { plugins: { allow: ["custom-plugin"] } } as OpenClawConfig;
const allowlistCompat = {

View File

@@ -262,6 +262,9 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
key: params.key,
cfg: params.cfg,
});
if (pluginIds.length === 0 && MEDIA_GENERATION_CAPABILITY_KEYS.has(params.key)) {
return activeProviders.map((entry) => entry.provider) as CapabilityProviderForKey<K>[];
}
const compatConfig = resolveCapabilityProviderConfig({
key: params.key,
cfg: params.cfg,