mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:00:42 +00:00
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:
@@ -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 cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
|
||||||
const enablementCompat = {
|
const loaded = createEmptyPluginRegistry();
|
||||||
plugins: {
|
loaded.mediaUnderstandingProviders.push({
|
||||||
enabled: true,
|
pluginId: "openai",
|
||||||
allow: ["custom-plugin", "openai"],
|
pluginName: "openai",
|
||||||
entries: { openai: { enabled: true } },
|
source: "test",
|
||||||
|
provider: {
|
||||||
|
id: "openai",
|
||||||
|
capabilities: ["image"],
|
||||||
},
|
},
|
||||||
};
|
} as never);
|
||||||
setBundledCapabilityFixture("mediaUnderstandingProviders");
|
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
|
||||||
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
|
|
||||||
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
|
|
||||||
|
|
||||||
expectNoResolvedCapabilityProviders(
|
expectNoResolvedCapabilityProviders(
|
||||||
resolvePluginCapabilityProviders({
|
resolvePluginCapabilityProviders({
|
||||||
@@ -677,12 +678,11 @@ describe("resolvePluginCapabilityProviders", () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
|
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
|
||||||
config: enablementCompat,
|
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
|
||||||
onlyPluginIds: ["openai"],
|
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
|
||||||
activate: false,
|
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
|
||||||
installBundledRuntimeDeps: false,
|
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
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 cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
|
||||||
const enablementCompat = {
|
const loaded = createEmptyPluginRegistry();
|
||||||
plugins: {
|
loaded.memoryEmbeddingProviders.push({
|
||||||
enabled: true,
|
pluginId: "google",
|
||||||
allow: ["custom-plugin", "google"],
|
pluginName: "google",
|
||||||
entries: { google: { enabled: true } },
|
source: "test",
|
||||||
|
provider: {
|
||||||
|
id: "gemini",
|
||||||
|
create: async () => ({ provider: null }),
|
||||||
},
|
},
|
||||||
};
|
} as never);
|
||||||
mocks.loadPluginManifestRegistry.mockReturnValue({
|
mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
id: "google",
|
|
||||||
origin: "bundled",
|
|
||||||
contracts: { memoryEmbeddingProviders: ["gemini"] },
|
|
||||||
},
|
|
||||||
] as never,
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
|
|
||||||
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
|
|
||||||
|
|
||||||
const provider = resolvePluginCapabilityProvider({
|
const provider = resolvePluginCapabilityProvider({
|
||||||
key: "memoryEmbeddingProviders",
|
key: "memoryEmbeddingProviders",
|
||||||
@@ -874,11 +866,10 @@ describe("resolvePluginCapabilityProviders", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(provider).toBeUndefined();
|
expect(provider).toBeUndefined();
|
||||||
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
|
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
|
||||||
config: enablementCompat,
|
expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
|
||||||
onlyPluginIds: ["google"],
|
expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
|
||||||
activate: false,
|
expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
|
||||||
installBundledRuntimeDeps: false,
|
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ function resolveCapabilityProviderConfig(params: {
|
|||||||
|
|
||||||
function createCapabilityProviderFallbackLoadOptions(params: {
|
function createCapabilityProviderFallbackLoadOptions(params: {
|
||||||
compatConfig?: OpenClawConfig;
|
compatConfig?: OpenClawConfig;
|
||||||
sourceConfig?: OpenClawConfig;
|
|
||||||
pluginIds: string[];
|
pluginIds: string[];
|
||||||
installBundledRuntimeDeps?: boolean;
|
installBundledRuntimeDeps?: boolean;
|
||||||
}): PluginLoadOptions {
|
}): PluginLoadOptions {
|
||||||
@@ -96,15 +95,16 @@ function createCapabilityProviderFallbackLoadOptions(params: {
|
|||||||
onlyPluginIds: params.pluginIds,
|
onlyPluginIds: params.pluginIds,
|
||||||
activate: false,
|
activate: false,
|
||||||
};
|
};
|
||||||
if (
|
if (params.installBundledRuntimeDeps === false) {
|
||||||
params.installBundledRuntimeDeps === false ||
|
|
||||||
params.sourceConfig?.plugins?.enabled === false
|
|
||||||
) {
|
|
||||||
loadOptions.installBundledRuntimeDeps = false;
|
loadOptions.installBundledRuntimeDeps = false;
|
||||||
}
|
}
|
||||||
return loadOptions;
|
return loadOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arePluginsGloballyDisabled(cfg: OpenClawConfig | undefined): boolean {
|
||||||
|
return cfg?.plugins?.enabled === false;
|
||||||
|
}
|
||||||
|
|
||||||
function findProviderById<K extends CapabilityProviderRegistryKey>(
|
function findProviderById<K extends CapabilityProviderRegistryKey>(
|
||||||
entries: PluginRegistry[K],
|
entries: PluginRegistry[K],
|
||||||
providerId: string,
|
providerId: string,
|
||||||
@@ -225,6 +225,10 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
|
|||||||
cfg?: OpenClawConfig;
|
cfg?: OpenClawConfig;
|
||||||
installBundledRuntimeDeps?: boolean;
|
installBundledRuntimeDeps?: boolean;
|
||||||
}): CapabilityProviderForKey<K> | undefined {
|
}): CapabilityProviderForKey<K> | undefined {
|
||||||
|
if (arePluginsGloballyDisabled(params.cfg)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const activeRegistry = resolveRuntimePluginRegistry();
|
const activeRegistry = resolveRuntimePluginRegistry();
|
||||||
const activeProvider = findProviderById(activeRegistry?.[params.key] ?? [], params.providerId);
|
const activeProvider = findProviderById(activeRegistry?.[params.key] ?? [], params.providerId);
|
||||||
if (activeProvider) {
|
if (activeProvider) {
|
||||||
@@ -247,7 +251,6 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
|
|||||||
});
|
});
|
||||||
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
||||||
compatConfig,
|
compatConfig,
|
||||||
sourceConfig: params.cfg,
|
|
||||||
pluginIds,
|
pluginIds,
|
||||||
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
||||||
});
|
});
|
||||||
@@ -260,6 +263,10 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
|
|||||||
cfg?: OpenClawConfig;
|
cfg?: OpenClawConfig;
|
||||||
installBundledRuntimeDeps?: boolean;
|
installBundledRuntimeDeps?: boolean;
|
||||||
}): CapabilityProviderForKey<K>[] {
|
}): CapabilityProviderForKey<K>[] {
|
||||||
|
if (arePluginsGloballyDisabled(params.cfg)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const activeRegistry = resolveRuntimePluginRegistry();
|
const activeRegistry = resolveRuntimePluginRegistry();
|
||||||
const activeProviders = activeRegistry?.[params.key] ?? [];
|
const activeProviders = activeRegistry?.[params.key] ?? [];
|
||||||
if (
|
if (
|
||||||
@@ -293,7 +300,6 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
|
|||||||
});
|
});
|
||||||
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
||||||
compatConfig,
|
compatConfig,
|
||||||
sourceConfig: params.cfg,
|
|
||||||
pluginIds,
|
pluginIds,
|
||||||
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user