mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
fix(regression): auto-enable gateway bootstrap snapshots
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { primeConfiguredBindingRegistry } from "../channels/plugins/binding-registry.js";
|
||||
import type { loadConfig } from "../config/config.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import type { PluginRegistry } from "../plugins/registry.js";
|
||||
import { pinActivePluginChannelRegistry } from "../plugins/runtime.js";
|
||||
import { setGatewaySubagentRuntime } from "../plugins/runtime/index.js";
|
||||
@@ -56,9 +57,13 @@ function logGatewayPluginDiagnostics(params: {
|
||||
}
|
||||
|
||||
export function prepareGatewayPluginLoad(params: GatewayPluginBootstrapParams) {
|
||||
installGatewayPluginRuntimeEnvironment(params.cfg);
|
||||
const resolvedConfig = applyPluginAutoEnable({
|
||||
config: params.cfg,
|
||||
env: process.env,
|
||||
}).config;
|
||||
installGatewayPluginRuntimeEnvironment(resolvedConfig);
|
||||
const loaded = loadGatewayPlugins({
|
||||
cfg: params.cfg,
|
||||
cfg: resolvedConfig,
|
||||
workspaceDir: params.workspaceDir,
|
||||
log: params.log,
|
||||
coreGatewayHandlers: params.coreGatewayHandlers,
|
||||
@@ -66,7 +71,7 @@ export function prepareGatewayPluginLoad(params: GatewayPluginBootstrapParams) {
|
||||
preferSetupRuntimeForChannelPlugins: params.preferSetupRuntimeForChannelPlugins,
|
||||
});
|
||||
params.beforePrimeRegistry?.(loaded.pluginRegistry);
|
||||
primeConfiguredBindingRegistry({ cfg: params.cfg });
|
||||
primeConfiguredBindingRegistry({ cfg: resolvedConfig });
|
||||
if ((params.logDiagnostics ?? true) && loaded.pluginRegistry.diagnostics.length > 0) {
|
||||
logGatewayPluginDiagnostics({
|
||||
diagnostics: loaded.pluginRegistry.diagnostics,
|
||||
|
||||
@@ -571,9 +571,41 @@ describe("loadGatewayPlugins", () => {
|
||||
test("primes configured bindings during gateway startup", async () => {
|
||||
loadOpenClawPlugins.mockReturnValue(createRegistry([]));
|
||||
const cfg = {};
|
||||
const autoEnabledConfig = { channels: { slack: { enabled: true } }, autoEnabled: true };
|
||||
applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
loadGatewayStartupPluginsForTest({ cfg });
|
||||
|
||||
expect(primeConfiguredBindingRegistry).toHaveBeenCalledWith({ cfg });
|
||||
expect(primeConfiguredBindingRegistry).toHaveBeenCalledWith({ cfg: autoEnabledConfig });
|
||||
});
|
||||
|
||||
test("uses the auto-enabled config snapshot for gateway bootstrap policies", async () => {
|
||||
const serverPlugins = serverPluginsModule;
|
||||
const autoEnabledConfig = {
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: {
|
||||
subagent: { allowModelOverride: true, allowedModels: ["openai/gpt-5.4"] },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
const runtime = await createSubagentRuntime(serverPlugins, {});
|
||||
serverPlugins.setFallbackGatewayContext(createTestContext("auto-enabled-bootstrap-policy"));
|
||||
|
||||
await gatewayRequestScopeModule.withPluginRuntimePluginIdScope("demo", () =>
|
||||
runtime.run({
|
||||
sessionKey: "s-auto-enabled-bootstrap-policy",
|
||||
message: "use trusted override",
|
||||
model: "openai/gpt-5.4",
|
||||
deliver: false,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(getLastDispatchedParams()).toMatchObject({
|
||||
sessionKey: "s-auto-enabled-bootstrap-policy",
|
||||
model: "openai/gpt-5.4",
|
||||
});
|
||||
});
|
||||
|
||||
test("can suppress duplicate diagnostics when reloading full runtime plugins", async () => {
|
||||
|
||||
Reference in New Issue
Block a user