Skip to content

Commit 7c45542

Browse files
committed
CLI: scope task maintenance to gateway runtime
1 parent 1a78234 commit 7c45542

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/cli/run-main.exit.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const ensurePathMock = vi.hoisted(() => vi.fn());
88
const assertRuntimeMock = vi.hoisted(() => vi.fn());
99
const closeActiveMemorySearchManagersMock = vi.hoisted(() => vi.fn(async () => {}));
1010
const hasMemoryRuntimeMock = vi.hoisted(() => vi.fn(() => false));
11+
const ensureTaskRegistryReadyMock = vi.hoisted(() => vi.fn());
12+
const startTaskRegistryMaintenanceMock = vi.hoisted(() => vi.fn());
1113
const outputRootHelpMock = vi.hoisted(() => vi.fn());
1214
const buildProgramMock = vi.hoisted(() => vi.fn());
1315
const maybeRunCliInContainerMock = vi.hoisted(() =>
@@ -49,6 +51,14 @@ vi.mock("../plugins/memory-state.js", () => ({
4951
hasMemoryRuntime: hasMemoryRuntimeMock,
5052
}));
5153

54+
vi.mock("../tasks/task-registry.js", () => ({
55+
ensureTaskRegistryReady: ensureTaskRegistryReadyMock,
56+
}));
57+
58+
vi.mock("../tasks/task-registry.maintenance.js", () => ({
59+
startTaskRegistryMaintenance: startTaskRegistryMaintenanceMock,
60+
}));
61+
5262
vi.mock("./program/root-help.js", () => ({
5363
outputRootHelp: outputRootHelpMock,
5464
}));
@@ -76,6 +86,8 @@ describe("runCli exit behavior", () => {
7686
expect(maybeRunCliInContainerMock).toHaveBeenCalledWith(["node", "openclaw", "status"]);
7787
expect(tryRouteCliMock).toHaveBeenCalledWith(["node", "openclaw", "status"]);
7888
expect(closeActiveMemorySearchManagersMock).not.toHaveBeenCalled();
89+
expect(ensureTaskRegistryReadyMock).not.toHaveBeenCalled();
90+
expect(startTaskRegistryMaintenanceMock).not.toHaveBeenCalled();
7991
expect(exitSpy).not.toHaveBeenCalled();
8092
exitSpy.mockRestore();
8193
});

src/cli/run-main.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ export async function runCli(argv: string[] = process.argv) {
133133
// Enforce the minimum supported runtime before doing any work.
134134
assertSupportedRuntime();
135135

136-
const { ensureTaskRegistryReady } = await import("../tasks/task-registry.js");
137-
ensureTaskRegistryReady();
138-
const { startTaskRegistryMaintenance } = await import("../tasks/task-registry.maintenance.js");
139-
startTaskRegistryMaintenance();
140-
141136
try {
142137
if (shouldUseRootHelpFastPath(normalizedArgv)) {
143138
const { outputRootHelp } = await import("./program/root-help.js");

src/gateway/server.impl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
} from "../secrets/runtime.js";
7373
import { onSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js";
7474
import { onSessionTranscriptUpdate } from "../sessions/transcript-events.js";
75+
import { startTaskRegistryMaintenance } from "../tasks/task-registry.maintenance.js";
7576
import { runSetupWizard } from "../wizard/setup.js";
7677
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
7778
import { startChannelHealthMonitor } from "./channel-health-monitor.js";
@@ -876,6 +877,7 @@ export async function startGatewayServer(
876877
});
877878

878879
if (!minimalTestGateway) {
880+
startTaskRegistryMaintenance();
879881
({ tickInterval, healthInterval, dedupeCleanup, mediaCleanup } =
880882
startGatewayMaintenanceTimers({
881883
broadcast,

0 commit comments

Comments
 (0)