mirror of https://github.com/openclaw/openclaw.git
fix(regression): auto-enable plugin status loads
This commit is contained in:
parent
f3c8c27b3a
commit
e20823c741
|
|
@ -11,6 +11,7 @@ import {
|
|||
|
||||
const loadConfigMock = vi.fn();
|
||||
const loadOpenClawPluginsMock = vi.fn();
|
||||
const applyPluginAutoEnableMock = vi.fn();
|
||||
const resolveBundledProviderCompatPluginIdsMock = vi.fn();
|
||||
const withBundledPluginAllowlistCompatMock = vi.fn();
|
||||
const withBundledPluginEnablementCompatMock = vi.fn();
|
||||
|
|
@ -26,6 +27,10 @@ vi.mock("../config/config.js", () => ({
|
|||
loadConfig: () => loadConfigMock(),
|
||||
}));
|
||||
|
||||
vi.mock("../config/plugin-auto-enable.js", () => ({
|
||||
applyPluginAutoEnable: (...args: unknown[]) => applyPluginAutoEnableMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("./loader.js", () => ({
|
||||
loadOpenClawPlugins: (...args: unknown[]) => loadOpenClawPluginsMock(...args),
|
||||
}));
|
||||
|
|
@ -107,10 +112,15 @@ describe("buildPluginStatusReport", () => {
|
|||
vi.resetModules();
|
||||
loadConfigMock.mockReset();
|
||||
loadOpenClawPluginsMock.mockReset();
|
||||
applyPluginAutoEnableMock.mockReset();
|
||||
resolveBundledProviderCompatPluginIdsMock.mockReset();
|
||||
withBundledPluginAllowlistCompatMock.mockReset();
|
||||
withBundledPluginEnablementCompatMock.mockReset();
|
||||
loadConfigMock.mockReturnValue({});
|
||||
applyPluginAutoEnableMock.mockImplementation((params: { config: unknown }) => ({
|
||||
config: params.config,
|
||||
changes: [],
|
||||
}));
|
||||
resolveBundledProviderCompatPluginIdsMock.mockReturnValue([]);
|
||||
withBundledPluginAllowlistCompatMock.mockImplementation(
|
||||
(params: { config: unknown }) => params.config,
|
||||
|
|
@ -146,6 +156,32 @@ describe("buildPluginStatusReport", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("loads plugin status from the auto-enabled config snapshot", () => {
|
||||
const rawConfig = {
|
||||
plugins: {},
|
||||
channels: { demo: { enabled: true } },
|
||||
};
|
||||
const autoEnabledConfig = {
|
||||
...rawConfig,
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: { enabled: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
|
||||
buildPluginStatusReport({ config: rawConfig });
|
||||
|
||||
expect(applyPluginAutoEnableMock).toHaveBeenCalledWith({
|
||||
config: rawConfig,
|
||||
env: process.env,
|
||||
});
|
||||
expect(loadOpenClawPluginsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ config: autoEnabledConfig }),
|
||||
);
|
||||
});
|
||||
|
||||
it("applies the full bundled provider compat chain before loading plugins", () => {
|
||||
const config = { plugins: { allow: ["telegram"] } };
|
||||
loadConfigMock.mockReturnValue(config);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { normalizeOpenClawVersionBase } from "../config/version.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { resolveCompatibilityHostVersion } from "../version.js";
|
||||
|
|
@ -142,7 +143,11 @@ export function buildPluginStatusReport(params?: {
|
|||
/** Use an explicit env when plugin roots should resolve independently from process.env. */
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): PluginStatusReport {
|
||||
const config = params?.config ?? loadConfig();
|
||||
const rawConfig = params?.config ?? loadConfig();
|
||||
const config = applyPluginAutoEnable({
|
||||
config: rawConfig,
|
||||
env: params?.env ?? process.env,
|
||||
}).config;
|
||||
const workspaceDir = params?.workspaceDir
|
||||
? params.workspaceDir
|
||||
: (resolveAgentWorkspaceDir(config, resolveDefaultAgentId(config)) ??
|
||||
|
|
|
|||
Loading…
Reference in New Issue