mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 05:25:43 +02:00
fix(regression): auto-enable provider runtime loads
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import {
|
||||
withBundledPluginAllowlistCompat,
|
||||
@@ -27,10 +28,17 @@ export function resolvePluginProviders(params: {
|
||||
pluginSdkResolution?: PluginLoadOptions["pluginSdkResolution"];
|
||||
}): ProviderPlugin[] {
|
||||
const env = params.env ?? process.env;
|
||||
const autoEnabledConfig =
|
||||
params.config !== undefined
|
||||
? applyPluginAutoEnable({
|
||||
config: params.config,
|
||||
env,
|
||||
}).config
|
||||
: undefined;
|
||||
const bundledProviderCompatPluginIds =
|
||||
params.bundledProviderAllowlistCompat || params.bundledProviderVitestCompat
|
||||
? resolveBundledProviderCompatPluginIds({
|
||||
config: params.config,
|
||||
config: autoEnabledConfig,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env,
|
||||
onlyPluginIds: params.onlyPluginIds,
|
||||
@@ -38,10 +46,10 @@ export function resolvePluginProviders(params: {
|
||||
: [];
|
||||
const maybeAllowlistCompat = params.bundledProviderAllowlistCompat
|
||||
? withBundledPluginAllowlistCompat({
|
||||
config: params.config,
|
||||
config: autoEnabledConfig,
|
||||
pluginIds: bundledProviderCompatPluginIds,
|
||||
})
|
||||
: params.config;
|
||||
: autoEnabledConfig;
|
||||
const allowlistCompatConfig = params.bundledProviderAllowlistCompat
|
||||
? withBundledPluginEnablementCompat({
|
||||
config: maybeAllowlistCompat,
|
||||
|
||||
@@ -2,11 +2,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const loadOpenClawPluginsMock = vi.fn();
|
||||
const loadPluginManifestRegistryMock = vi.fn();
|
||||
const applyPluginAutoEnableMock = vi.fn();
|
||||
|
||||
vi.mock("./loader.js", () => ({
|
||||
loadOpenClawPlugins: (...args: unknown[]) => loadOpenClawPluginsMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("../config/plugin-auto-enable.js", () => ({
|
||||
applyPluginAutoEnable: (...args: unknown[]) => applyPluginAutoEnableMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("./manifest-registry.js", () => ({
|
||||
loadPluginManifestRegistry: (...args: unknown[]) => loadPluginManifestRegistryMock(...args),
|
||||
}));
|
||||
@@ -93,6 +98,11 @@ describe("resolvePluginProviders", () => {
|
||||
providers: [{ pluginId: "google", provider: { id: "demo-provider" } }],
|
||||
});
|
||||
loadPluginManifestRegistryMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockImplementation((params: { config: unknown }) => ({
|
||||
config: params.config,
|
||||
changes: [],
|
||||
}));
|
||||
loadPluginManifestRegistryMock.mockReturnValue({
|
||||
plugins: [
|
||||
{ id: "google", providers: ["google"], origin: "bundled" },
|
||||
@@ -228,6 +238,34 @@ describe("resolvePluginProviders", () => {
|
||||
onlyPluginIds: ["google", "kilocode", "moonshot"],
|
||||
});
|
||||
});
|
||||
|
||||
it("loads provider plugins from the auto-enabled config snapshot", () => {
|
||||
const rawConfig = {
|
||||
plugins: {},
|
||||
};
|
||||
const autoEnabledConfig = {
|
||||
...rawConfig,
|
||||
plugins: {
|
||||
entries: {
|
||||
google: { enabled: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
|
||||
resolvePluginProviders({ config: rawConfig });
|
||||
|
||||
expect(applyPluginAutoEnableMock).toHaveBeenCalledWith({
|
||||
config: rawConfig,
|
||||
env: process.env,
|
||||
});
|
||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: autoEnabledConfig,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("maps provider ids to owning plugin ids via manifests", () => {
|
||||
loadPluginManifestRegistryMock.mockReturnValue({
|
||||
plugins: [
|
||||
|
||||
Reference in New Issue
Block a user