From 554b32feeac0366da28275a586d86a539e2bd15d Mon Sep 17 00:00:00 2001 From: "clawsweeper[bot]" <274271284+clawsweeper[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 00:13:52 -0700 Subject: [PATCH] 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 --- .../capability-provider-runtime.test.ts | 73 ++++++++----------- src/plugins/capability-provider-runtime.ts | 20 +++-- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/src/plugins/capability-provider-runtime.test.ts b/src/plugins/capability-provider-runtime.test.ts index 47aea18ba33..ca1fb774ca6 100644 --- a/src/plugins/capability-provider-runtime.test.ts +++ b/src/plugins/capability-provider-runtime.test.ts @@ -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(); }); }); diff --git a/src/plugins/capability-provider-runtime.ts b/src/plugins/capability-provider-runtime.ts index 30c4934d8b8..c03b9f0fcc4 100644 --- a/src/plugins/capability-provider-runtime.ts +++ b/src/plugins/capability-provider-runtime.ts @@ -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( entries: PluginRegistry[K], providerId: string, @@ -225,6 +225,10 @@ export function resolvePluginCapabilityProvider | 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[] { + if (arePluginsGloballyDisabled(params.cfg)) { + return []; + } + const activeRegistry = resolveRuntimePluginRegistry(); const activeProviders = activeRegistry?.[params.key] ?? []; if ( @@ -293,7 +300,6 @@ export function resolvePluginCapabilityProviders