fix(gateway): lazy-load setup wizard runtime

This commit is contained in:
Vincent Koc
2026-04-26 22:03:32 -07:00
parent 5bba899a70
commit a108169127
2 changed files with 9 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ Docs: https://docs.openclaw.ai
- Exec/node: synthesize a local approval plan when a paired node advertises `system.run` without `system.run.prepare`, unblocking approval-required `host=node` exec on current macOS companion nodes while preserving remote prepare for node hosts that support it. Fixes #37591 and duplicate #66839; carries forward #69725. Thanks @soloclz.
- Memory/QMD: prefer QMD's `--mask` collection pattern flag so root memory indexing stays scoped to `MEMORY.md` instead of widening to every markdown file in the workspace. Thanks @codex.
- Gateway/memory: defer QMD startup for implicit non-default agents and scope memory runtime loading to the selected memory slot so Gateway boot and first memory recall avoid broad plugin runtime fanout. Thanks @vincentkoc.
- Gateway/startup: keep core request handlers and channel runtime helpers off the boot path until the first matching request or channel start, reducing no-plugin Gateway ready RSS and avoidable startup imports. Thanks @vincentkoc.
- Gateway/startup: keep core request handlers, setup wizard, and channel runtime helpers off the boot path until the first matching request, wizard run, or channel start, reducing no-plugin Gateway ready RSS and avoidable startup imports. Thanks @vincentkoc.
- CLI/Gateway: use a parse-only config snapshot for plain `gateway status` reads and reuse same-path service config context so status no longer spends tens of seconds in full config validation before printing. Thanks @vincentkoc.
- Lobster/Gateway: memoize repeated Ajv schema compilation before loading the embedded Lobster runtime so scheduled workflows and `llm.invoke` loops stop growing gateway heap on content-identical schemas. Fixes #71148. Thanks @cmi525, @vsolaz, and @vincentkoc.
- Codex harness: normalize cached input tokens before session/context accounting so prompt cache reads are not double-counted in `/status`, `session_status`, or persisted `sessionEntry.totalTokens`. Fixes #69298. Thanks @richardmqq.

View File

@@ -43,7 +43,6 @@ import {
getInspectableTaskRegistrySummary,
stopTaskRegistryMaintenance,
} from "../tasks/task-registry.maintenance.js";
import { runSetupWizard } from "../wizard/setup.js";
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
import { resolveGatewayAuth } from "./auth.js";
import { closeMcpLoopbackServer } from "./mcp-http.js";
@@ -242,6 +241,13 @@ export type GatewayServerOptions = {
startupStartedAt?: number;
};
type SetupWizardRunner = NonNullable<GatewayServerOptions["wizardRunner"]>;
const runDefaultSetupWizard: SetupWizardRunner = async (...args) => {
const { runSetupWizard } = await import("../wizard/setup.js");
return runSetupWizard(...args);
};
export async function startGatewayServer(
port = 18789,
opts: GatewayServerOptions = {},
@@ -458,7 +464,7 @@ export async function startGatewayServer(
}),
);
const wizardRunner = opts.wizardRunner ?? runSetupWizard;
const wizardRunner = opts.wizardRunner ?? runDefaultSetupWizard;
const { wizardSessions, findRunningWizard, purgeWizardSession } = createWizardSessionTracker();
const deps = createDefaultDeps();