fix(regression): auto-enable provider runtime loads

This commit is contained in:
Tak Hoffman
2026-03-27 22:53:26 -05:00
parent cc9b2df97c
commit 09e35e69b2
2 changed files with 49 additions and 3 deletions

View File

@@ -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,

View File

@@ -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: [