From 09e35e69b2e9c8a438a0f193f727d4f4eba32331 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 22:53:26 -0500 Subject: [PATCH] fix(regression): auto-enable provider runtime loads --- src/plugins/providers.runtime.ts | 14 +++++++++--- src/plugins/providers.test.ts | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/plugins/providers.runtime.ts b/src/plugins/providers.runtime.ts index 6cc7aaf8884..fa4d008bf45 100644 --- a/src/plugins/providers.runtime.ts +++ b/src/plugins/providers.runtime.ts @@ -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, diff --git a/src/plugins/providers.test.ts b/src/plugins/providers.test.ts index 2f26ca83dfc..ce8245771b2 100644 --- a/src/plugins/providers.test.ts +++ b/src/plugins/providers.test.ts @@ -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: [