mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 17:43:05 +00:00
fix(regression): reload stale auto-enabled plugin tool registries
This commit is contained in:
@@ -20,6 +20,7 @@ vi.mock("../config/plugin-auto-enable.js", () => ({
|
||||
|
||||
let resolvePluginTools: typeof import("./tools.js").resolvePluginTools;
|
||||
let resetPluginRuntimeStateForTest: typeof import("./runtime.js").resetPluginRuntimeStateForTest;
|
||||
let setActivePluginRegistry: typeof import("./runtime.js").setActivePluginRegistry;
|
||||
|
||||
function makeTool(name: string) {
|
||||
return {
|
||||
@@ -140,6 +141,7 @@ describe("resolvePluginTools optional tools", () => {
|
||||
changes: [],
|
||||
}));
|
||||
({ resetPluginRuntimeStateForTest } = await import("./runtime.js"));
|
||||
({ setActivePluginRegistry } = await import("./runtime.js"));
|
||||
resetPluginRuntimeStateForTest();
|
||||
({ resolvePluginTools } = await import("./tools.js"));
|
||||
});
|
||||
@@ -273,4 +275,55 @@ describe("resolvePluginTools optional tools", () => {
|
||||
);
|
||||
expectLoaderCall({ config: autoEnabledConfig });
|
||||
});
|
||||
|
||||
it("does not reuse a cached active registry when auto-enable changes the config snapshot", () => {
|
||||
setOptionalDemoRegistry();
|
||||
const rawContext = createContext();
|
||||
const autoEnabledConfig = {
|
||||
...rawContext.config,
|
||||
plugins: {
|
||||
...rawContext.config.plugins,
|
||||
entries: {
|
||||
"optional-demo": { enabled: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
setActivePluginRegistry(
|
||||
{
|
||||
plugins: [],
|
||||
tools: [],
|
||||
hooks: [],
|
||||
typedHooks: [],
|
||||
channels: [],
|
||||
channelSetups: [],
|
||||
providers: [],
|
||||
cliBackends: [],
|
||||
speechProviders: [],
|
||||
mediaUnderstandingProviders: [],
|
||||
imageGenerationProviders: [],
|
||||
webSearchProviders: [],
|
||||
gatewayHandlers: {},
|
||||
gatewayMethodScopes: {},
|
||||
httpRoutes: [],
|
||||
cliRegistrars: [],
|
||||
services: [],
|
||||
commands: [],
|
||||
conversationBindingResolvedHandlers: [],
|
||||
diagnostics: [],
|
||||
} as never,
|
||||
"stale-registry",
|
||||
);
|
||||
|
||||
const tools = resolvePluginTools({
|
||||
context: {
|
||||
...rawContext,
|
||||
config: rawContext.config as never,
|
||||
} as never,
|
||||
toolAllowlist: ["optional_tool"],
|
||||
});
|
||||
|
||||
expectResolvedToolNames(tools, ["optional_tool"]);
|
||||
expectLoaderCall({ config: autoEnabledConfig });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ export function resolvePluginTools(params: {
|
||||
|
||||
const activeRegistry = getActivePluginRegistry();
|
||||
const registry =
|
||||
getActivePluginRegistryKey() && activeRegistry
|
||||
getActivePluginRegistryKey() && activeRegistry && effectiveConfig === baseConfig
|
||||
? activeRegistry
|
||||
: loadOpenClawPlugins({
|
||||
config: effectiveConfig,
|
||||
|
||||
Reference in New Issue
Block a user