mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:40:44 +00:00
fix(plugins): honor runtime deps fallback install option
Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
@@ -103,7 +103,6 @@ function expectBundledCompatLoadPath(params: {
|
||||
config: params.enablementCompat,
|
||||
onlyPluginIds: ["openai"],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -409,7 +408,6 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
}),
|
||||
onlyPluginIds: ["microsoft"],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -584,7 +582,6 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
config: expect.anything(),
|
||||
onlyPluginIds: [],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -629,6 +626,33 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
config: compatConfig,
|
||||
onlyPluginIds: ["google"],
|
||||
activate: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("honors explicit bundled runtime dependency install opt-out for fallback snapshots", () => {
|
||||
const cfg = { plugins: { allow: ["custom-plugin"] } } as OpenClawConfig;
|
||||
const enablementCompat = {
|
||||
plugins: {
|
||||
allow: ["custom-plugin", "openai"],
|
||||
entries: { openai: { enabled: true } },
|
||||
},
|
||||
};
|
||||
setBundledCapabilityFixture("mediaUnderstandingProviders");
|
||||
mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
|
||||
mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
|
||||
|
||||
expectNoResolvedCapabilityProviders(
|
||||
resolvePluginCapabilityProviders({
|
||||
key: "mediaUnderstandingProviders",
|
||||
cfg,
|
||||
installBundledRuntimeDeps: false,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
|
||||
config: enablementCompat,
|
||||
onlyPluginIds: ["openai"],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
});
|
||||
@@ -653,7 +677,6 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
config: expect.anything(),
|
||||
onlyPluginIds: [],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -791,7 +814,6 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
config: enablementCompat,
|
||||
onlyPluginIds: ["google"],
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
withBundledPluginEnablementCompat,
|
||||
withBundledPluginVitestCompat,
|
||||
} from "./bundled-compat.js";
|
||||
import { resolveRuntimePluginRegistry } from "./loader.js";
|
||||
import { resolveRuntimePluginRegistry, type PluginLoadOptions } from "./loader.js";
|
||||
import { loadPluginManifestRegistryForPluginRegistry } from "./plugin-registry.js";
|
||||
import type { PluginRegistry } from "./registry-types.js";
|
||||
|
||||
@@ -85,6 +85,22 @@ function resolveCapabilityProviderConfig(params: {
|
||||
});
|
||||
}
|
||||
|
||||
function createCapabilityProviderFallbackLoadOptions(params: {
|
||||
compatConfig?: OpenClawConfig;
|
||||
pluginIds: string[];
|
||||
installBundledRuntimeDeps?: boolean;
|
||||
}): PluginLoadOptions {
|
||||
const loadOptions: PluginLoadOptions = {
|
||||
...(params.compatConfig === undefined ? {} : { config: params.compatConfig }),
|
||||
onlyPluginIds: params.pluginIds,
|
||||
activate: false,
|
||||
};
|
||||
if (params.installBundledRuntimeDeps === false) {
|
||||
loadOptions.installBundledRuntimeDeps = false;
|
||||
}
|
||||
return loadOptions;
|
||||
}
|
||||
|
||||
function findProviderById<K extends CapabilityProviderRegistryKey>(
|
||||
entries: PluginRegistry[K],
|
||||
providerId: string,
|
||||
@@ -203,6 +219,7 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
|
||||
key: K;
|
||||
providerId: string;
|
||||
cfg?: OpenClawConfig;
|
||||
installBundledRuntimeDeps?: boolean;
|
||||
}): CapabilityProviderForKey<K> | undefined {
|
||||
const activeRegistry = resolveRuntimePluginRegistry();
|
||||
const activeProvider = findProviderById(activeRegistry?.[params.key] ?? [], params.providerId);
|
||||
@@ -224,15 +241,11 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
|
||||
cfg: params.cfg,
|
||||
pluginIds,
|
||||
});
|
||||
const loadOptions =
|
||||
compatConfig === undefined
|
||||
? { onlyPluginIds: pluginIds, activate: false, installBundledRuntimeDeps: false }
|
||||
: {
|
||||
config: compatConfig,
|
||||
onlyPluginIds: pluginIds,
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
};
|
||||
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
||||
compatConfig,
|
||||
pluginIds,
|
||||
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
||||
});
|
||||
const registry = resolveRuntimePluginRegistry(loadOptions);
|
||||
return findProviderById(registry?.[params.key] ?? [], params.providerId);
|
||||
}
|
||||
@@ -240,6 +253,7 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
|
||||
export function resolvePluginCapabilityProviders<K extends CapabilityProviderRegistryKey>(params: {
|
||||
key: K;
|
||||
cfg?: OpenClawConfig;
|
||||
installBundledRuntimeDeps?: boolean;
|
||||
}): CapabilityProviderForKey<K>[] {
|
||||
const activeRegistry = resolveRuntimePluginRegistry();
|
||||
const activeProviders = activeRegistry?.[params.key] ?? [];
|
||||
@@ -272,15 +286,11 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
|
||||
cfg: params.cfg,
|
||||
pluginIds,
|
||||
});
|
||||
const loadOptions =
|
||||
compatConfig === undefined
|
||||
? { onlyPluginIds: pluginIds, activate: false, installBundledRuntimeDeps: false }
|
||||
: {
|
||||
config: compatConfig,
|
||||
onlyPluginIds: pluginIds,
|
||||
activate: false,
|
||||
installBundledRuntimeDeps: false,
|
||||
};
|
||||
const loadOptions = createCapabilityProviderFallbackLoadOptions({
|
||||
compatConfig,
|
||||
pluginIds,
|
||||
installBundledRuntimeDeps: params.installBundledRuntimeDeps,
|
||||
});
|
||||
const registry = resolveRuntimePluginRegistry(loadOptions);
|
||||
const loadedProviders = registry?.[params.key] ?? [];
|
||||
if (params.key !== "memoryEmbeddingProviders") {
|
||||
|
||||
Reference in New Issue
Block a user