Skip to content

Commit f1293e6

Browse files
fix: change disables bundled dependency repair when plugins.enabled: false, but the same fall...
1 parent 43ca739 commit f1293e6

2 files changed

Lines changed: 45 additions & 48 deletions

File tree

src/plugins/capability-provider-runtime.test.ts

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,19 @@ describe("resolvePluginCapabilityProviders", () => {
657657
});
658658
});
659659

660-
it("keeps bundled runtime dependency repair disabled when plugins are globally disabled", () => {
660+
it("does not load bundled capability providers when plugins are globally disabled", () => {
661661
const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
662-
const enablementCompat = {
663-
plugins: {
664-
enabled: true,
665-
allow: ["custom-plugin", "openai"],
666-
entries: { openai: { enabled: true } },
662+
const loaded = createEmptyPluginRegistry();
663+
loaded.mediaUnderstandingProviders.push({
664+
pluginId: "openai",
665+
pluginName: "openai",
666+
source: "test",
667+
provider: {
668+
id: "openai",
669+
capabilities: ["image"],
667670
},
668-
};
669-
setBundledCapabilityFixture("mediaUnderstandingProviders");
670-
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
671-
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
671+
} as never);
672+
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
672673

673674
expectNoResolvedCapabilityProviders(
674675
resolvePluginCapabilityProviders({
@@ -677,12 +678,11 @@ describe("resolvePluginCapabilityProviders", () => {
677678
}),
678679
);
679680

680-
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
681-
config: enablementCompat,
682-
onlyPluginIds: ["openai"],
683-
activate: false,
684-
installBundledRuntimeDeps: false,
685-
});
681+
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
682+
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
683+
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
684+
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
685+
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
686686
});
687687

688688
it.each([
@@ -845,27 +845,19 @@ describe("resolvePluginCapabilityProviders", () => {
845845
});
846846
});
847847

848-
it("keeps targeted provider fallback dependency repair disabled when plugins are globally disabled", () => {
848+
it("does not load targeted bundled capability providers when plugins are globally disabled", () => {
849849
const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
850-
const enablementCompat = {
851-
plugins: {
852-
enabled: true,
853-
allow: ["custom-plugin", "google"],
854-
entries: { google: { enabled: true } },
850+
const loaded = createEmptyPluginRegistry();
851+
loaded.memoryEmbeddingProviders.push({
852+
pluginId: "google",
853+
pluginName: "google",
854+
source: "test",
855+
provider: {
856+
id: "gemini",
857+
create: async () => ({ provider: null }),
855858
},
856-
};
857-
mocks.loadPluginManifestRegistry.mockReturnValue({
858-
plugins: [
859-
{
860-
id: "google",
861-
origin: "bundled",
862-
contracts: { memoryEmbeddingProviders: ["gemini"] },
863-
},
864-
] as never,
865-
diagnostics: [],
866-
});
867-
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
868-
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
859+
} as never);
860+
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
869861

870862
const provider = resolvePluginCapabilityProvider({
871863
key: "memoryEmbeddingProviders",
@@ -874,11 +866,10 @@ describe("resolvePluginCapabilityProviders", () => {
874866
});
875867

876868
expect(provider).toBeUndefined();
877-
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
878-
config: enablementCompat,
879-
onlyPluginIds: ["google"],
880-
activate: false,
881-
installBundledRuntimeDeps: false,
882-
});
869+
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
870+
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
871+
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
872+
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
873+
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
883874
});
884875
});

src/plugins/capability-provider-runtime.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ function resolveCapabilityProviderConfig(params: {
8787

8888
function createCapabilityProviderFallbackLoadOptions(params: {
8989
compatConfig?: OpenClawConfig;
90-
sourceConfig?: OpenClawConfig;
9190
pluginIds: string[];
9291
installBundledRuntimeDeps?: boolean;
9392
}): PluginLoadOptions {
@@ -96,15 +95,16 @@ function createCapabilityProviderFallbackLoadOptions(params: {
9695
onlyPluginIds: params.pluginIds,
9796
activate: false,
9897
};
99-
if (
100-
params.installBundledRuntimeDeps === false ||
101-
params.sourceConfig?.plugins?.enabled === false
102-
) {
98+
if (params.installBundledRuntimeDeps === false) {
10399
loadOptions.installBundledRuntimeDeps = false;
104100
}
105101
return loadOptions;
106102
}
107103

104+
function arePluginsGloballyDisabled(cfg: OpenClawConfig | undefined): boolean {
105+
return cfg?.plugins?.enabled === false;
106+
}
107+
108108
function findProviderById<K extends CapabilityProviderRegistryKey>(
109109
entries: PluginRegistry[K],
110110
providerId: string,
@@ -225,6 +225,10 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
225225
cfg?: OpenClawConfig;
226226
installBundledRuntimeDeps?: boolean;
227227
}): CapabilityProviderForKey<K> | undefined {
228+
if (arePluginsGloballyDisabled(params.cfg)) {
229+
return undefined;
230+
}
231+
228232
const activeRegistry = resolveRuntimePluginRegistry();
229233
const activeProvider = findProviderById(activeRegistry?.[params.key] ?? [], params.providerId);
230234
if (activeProvider) {
@@ -247,7 +251,6 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
247251
});
248252
const loadOptions = createCapabilityProviderFallbackLoadOptions({
249253
compatConfig,
250-
sourceConfig: params.cfg,
251254
pluginIds,
252255
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
253256
});
@@ -260,6 +263,10 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
260263
cfg?: OpenClawConfig;
261264
installBundledRuntimeDeps?: boolean;
262265
}): CapabilityProviderForKey<K>[] {
266+
if (arePluginsGloballyDisabled(params.cfg)) {
267+
return [];
268+
}
269+
263270
const activeRegistry = resolveRuntimePluginRegistry();
264271
const activeProviders = activeRegistry?.[params.key] ?? [];
265272
if (
@@ -293,7 +300,6 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
293300
});
294301
const loadOptions = createCapabilityProviderFallbackLoadOptions({
295302
compatConfig,
296-
sourceConfig: params.cfg,
297303
pluginIds,
298304
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
299305
});

0 commit comments

Comments
 (0)