mirror of https://github.com/openclaw/openclaw.git
fix(gateway): preserve raw activation source for startup plugin loads
This commit is contained in:
parent
93d514f816
commit
cee5f960b5
|
|
@ -20,6 +20,7 @@ type GatewayPluginBootstrapLog = {
|
|||
|
||||
type GatewayPluginBootstrapParams = {
|
||||
cfg: ReturnType<typeof loadConfig>;
|
||||
activationSourceConfig?: ReturnType<typeof loadConfig>;
|
||||
workspaceDir: string;
|
||||
log: GatewayPluginBootstrapLog;
|
||||
coreGatewayHandlers: Record<string, GatewayRequestHandler>;
|
||||
|
|
@ -59,14 +60,14 @@ function logGatewayPluginDiagnostics(params: {
|
|||
|
||||
export function prepareGatewayPluginLoad(params: GatewayPluginBootstrapParams) {
|
||||
const autoEnabled = applyPluginAutoEnable({
|
||||
config: params.cfg,
|
||||
config: params.activationSourceConfig ?? params.cfg,
|
||||
env: process.env,
|
||||
});
|
||||
const resolvedConfig = autoEnabled.config;
|
||||
installGatewayPluginRuntimeEnvironment(resolvedConfig);
|
||||
const loaded = loadGatewayPlugins({
|
||||
cfg: resolvedConfig,
|
||||
activationSourceConfig: params.cfg,
|
||||
activationSourceConfig: params.activationSourceConfig ?? params.cfg,
|
||||
autoEnabledReasons: autoEnabled.autoEnabledReasons,
|
||||
workspaceDir: params.workspaceDir,
|
||||
log: params.log,
|
||||
|
|
|
|||
|
|
@ -278,6 +278,44 @@ describe("loadGatewayPlugins", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("keeps the raw activation source when a precomputed startup scope is reused", async () => {
|
||||
const rawConfig = { channels: { slack: { botToken: "x" } } };
|
||||
const resolvedConfig = {
|
||||
channels: { slack: { botToken: "x", enabled: true } },
|
||||
autoEnabled: true,
|
||||
};
|
||||
applyPluginAutoEnable.mockReturnValue({
|
||||
config: resolvedConfig,
|
||||
changes: [],
|
||||
autoEnabledReasons: {
|
||||
slack: ["slack configured"],
|
||||
},
|
||||
});
|
||||
loadOpenClawPlugins.mockReturnValue(createRegistry([]));
|
||||
|
||||
loadGatewayStartupPluginsForTest({
|
||||
cfg: resolvedConfig,
|
||||
activationSourceConfig: rawConfig,
|
||||
pluginIds: ["slack"],
|
||||
});
|
||||
|
||||
expect(resolveGatewayStartupPluginIds).not.toHaveBeenCalled();
|
||||
expect(applyPluginAutoEnable).toHaveBeenCalledWith({
|
||||
config: rawConfig,
|
||||
env: process.env,
|
||||
});
|
||||
expect(loadOpenClawPlugins).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: resolvedConfig,
|
||||
activationSourceConfig: rawConfig,
|
||||
onlyPluginIds: ["slack"],
|
||||
autoEnabledReasons: {
|
||||
slack: ["slack configured"],
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test("treats an empty startup scope as no plugin load instead of an unscoped load", async () => {
|
||||
resolveGatewayStartupPluginIds.mockReturnValue([]);
|
||||
|
||||
|
|
|
|||
|
|
@ -613,6 +613,7 @@ export async function startGatewayServer(
|
|||
if (!minimalTestGateway) {
|
||||
({ pluginRegistry, gatewayMethods: baseGatewayMethods } = loadGatewayStartupPlugins({
|
||||
cfg: gatewayPluginConfigAtStart,
|
||||
activationSourceConfig: cfgAtStart,
|
||||
workspaceDir: defaultWorkspaceDir,
|
||||
log,
|
||||
coreGatewayHandlers,
|
||||
|
|
|
|||
Loading…
Reference in New Issue