From a10816912715226a42f1d12ec88a824f3346295d Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 26 Apr 2026 22:03:32 -0700 Subject: [PATCH] fix(gateway): lazy-load setup wizard runtime --- CHANGELOG.md | 2 +- src/gateway/server.impl.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 676d1078972..4863d818205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/gateway/server.impl.ts b/src/gateway/server.impl.ts index b7e90bf1bc5..7ff39f5f243 100644 --- a/src/gateway/server.impl.ts +++ b/src/gateway/server.impl.ts @@ -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; + +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();