fix: change disables bundled dependency repair when plugins.enabled: false, but the same fall... (#74916)

Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
clawsweeper[bot]
2026-04-30 00:13:52 -07:00
committed by GitHub
parent 402b826ba2
commit 554b32feea
2 changed files with 45 additions and 48 deletions

View File

@@ -657,18 +657,19 @@ describe("resolvePluginCapabilityProviders", () => {
});
});
it("keeps bundled runtime dependency repair disabled when plugins are globally disabled", () => {
it("does not load bundled capability providers when plugins are globally disabled", () => {
const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
const enablementCompat = {
plugins: {
enabled: true,
allow: ["custom-plugin", "openai"],
entries: { openai: { enabled: true } },
const loaded = createEmptyPluginRegistry();
loaded.mediaUnderstandingProviders.push({
pluginId: "openai",
pluginName: "openai",
source: "test",
provider: {
id: "openai",
capabilities: ["image"],
},
};
setBundledCapabilityFixture("mediaUnderstandingProviders");
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
} as never);
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
expectNoResolvedCapabilityProviders(
resolvePluginCapabilityProviders({
@@ -677,12 +678,11 @@ describe("resolvePluginCapabilityProviders", () => {
}),
);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: enablementCompat,
onlyPluginIds: ["openai"],
activate: false,
installBundledRuntimeDeps: false,
});
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
});
it.each([
@@ -845,27 +845,19 @@ describe("resolvePluginCapabilityProviders", () => {
});
});
it("keeps targeted provider fallback dependency repair disabled when plugins are globally disabled", () => {
it("does not load targeted bundled capability providers when plugins are globally disabled", () => {
const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
const enablementCompat = {
plugins: {
enabled: true,
allow: ["custom-plugin", "google"],
entries: { google: { enabled: true } },
const loaded = createEmptyPluginRegistry();
loaded.memoryEmbeddingProviders.push({
pluginId: "google",
pluginName: "google",
source: "test",
provider: {
id: "gemini",
create: async () => ({ provider: null }),
},
};
mocks.loadPluginManifestRegistry.mockReturnValue({
plugins: [
{
id: "google",
origin: "bundled",
contracts: { memoryEmbeddingProviders: ["gemini"] },
},
] as never,
diagnostics: [],
});
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
} as never);
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
const provider = resolvePluginCapabilityProvider({
key: "memoryEmbeddingProviders",
@@ -874,11 +866,10 @@ describe("resolvePluginCapabilityProviders", () => {
});
expect(provider).toBeUndefined();
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: enablementCompat,
onlyPluginIds: ["google"],
activate: false,
installBundledRuntimeDeps: false,
});
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
});
});

View File

@@ -87,7 +87,6 @@ function resolveCapabilityProviderConfig(params: {
function createCapabilityProviderFallbackLoadOptions(params: {
compatConfig?: OpenClawConfig;
sourceConfig?: OpenClawConfig;
pluginIds: string[];
installBundledRuntimeDeps?: boolean;
}): PluginLoadOptions {
@@ -96,15 +95,16 @@ function createCapabilityProviderFallbackLoadOptions(params: {
onlyPluginIds: params.pluginIds,
activate: false,
};
if (
params.installBundledRuntimeDeps === false ||
params.sourceConfig?.plugins?.enabled === false
) {
if (params.installBundledRuntimeDeps === false) {
loadOptions.installBundledRuntimeDeps = false;
}
return loadOptions;
}
function arePluginsGloballyDisabled(cfg: OpenClawConfig | undefined): boolean {
return cfg?.plugins?.enabled === false;
}
function findProviderById<K extends CapabilityProviderRegistryKey>(
entries: PluginRegistry[K],
providerId: string,
@@ -225,6 +225,10 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
cfg?: OpenClawConfig;
installBundledRuntimeDeps?: boolean;
}): CapabilityProviderForKey<K> | undefined {
if (arePluginsGloballyDisabled(params.cfg)) {
return undefined;
}
const activeRegistry = resolveRuntimePluginRegistry();
const activeProvider = findProviderById(activeRegistry?.[params.key] ?? [], params.providerId);
if (activeProvider) {
@@ -247,7 +251,6 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
});
const loadOptions = createCapabilityProviderFallbackLoadOptions({
compatConfig,
sourceConfig: params.cfg,
pluginIds,
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
});
@@ -260,6 +263,10 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
cfg?: OpenClawConfig;
installBundledRuntimeDeps?: boolean;
}): CapabilityProviderForKey<K>[] {
if (arePluginsGloballyDisabled(params.cfg)) {
return [];
}
const activeRegistry = resolveRuntimePluginRegistry();
const activeProviders = activeRegistry?.[params.key] ?? [];
if (
@@ -293,7 +300,6 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
});
const loadOptions = createCapabilityProviderFallbackLoadOptions({
compatConfig,
sourceConfig: params.cfg,
pluginIds,
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
});