From 2a86504723419e44f978909c1b526473c2196b99 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 18 Jan 2026 08:05:32 +0000 Subject: [PATCH] perf: lazy-load memory manager --- src/commands/status.scan.ts | 5 +++-- src/memory/index.ts | 2 +- src/memory/search-manager.ts | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commands/status.scan.ts b/src/commands/status.scan.ts index 94c7b6df9..860192325 100644 --- a/src/commands/status.scan.ts +++ b/src/commands/status.scan.ts @@ -6,7 +6,7 @@ import { probeGateway } from "../gateway/probe.js"; import { collectChannelStatusIssues } from "../infra/channels-status-issues.js"; import { resolveOsSummary } from "../infra/os-summary.js"; import { getTailnetHostname } from "../infra/tailscale.js"; -import { MemoryIndexManager } from "../memory/manager.js"; +import type { MemoryIndexManager } from "../memory/manager.js"; import { runExec } from "../process/exec.js"; import type { RuntimeEnv } from "../runtime.js"; import { getAgentLocalStatuses } from "./status.agent-local.js"; @@ -15,7 +15,7 @@ import { getStatusSummary } from "./status.summary.js"; import { getUpdateCheckResult } from "./status.update.js"; import { buildChannelsTable } from "./status-all/channels.js"; -type MemoryStatusSnapshot = ReturnType<(typeof MemoryIndexManager)["prototype"]["status"]> & { +type MemoryStatusSnapshot = ReturnType & { agentId: string; }; @@ -151,6 +151,7 @@ export async function scanStatus( if (!memoryPlugin.enabled) return null; if (memoryPlugin.slot !== "memory-core") return null; const agentId = agentStatus.defaultId ?? "main"; + const { MemoryIndexManager } = await import("../memory/manager.js"); const manager = await MemoryIndexManager.get({ cfg, agentId }).catch(() => null); if (!manager) return null; try { diff --git a/src/memory/index.ts b/src/memory/index.ts index 98d19d932..092c4b03c 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -1,2 +1,2 @@ -export { MemoryIndexManager, type MemorySearchResult } from "./manager.js"; +export type { MemoryIndexManager, MemorySearchResult } from "./manager.js"; export { getMemorySearchManager, type MemorySearchManagerResult } from "./search-manager.js"; diff --git a/src/memory/search-manager.ts b/src/memory/search-manager.ts index 5ec0d11bc..76612e88d 100644 --- a/src/memory/search-manager.ts +++ b/src/memory/search-manager.ts @@ -1,5 +1,5 @@ import type { ClawdbotConfig } from "../config/config.js"; -import { MemoryIndexManager } from "./manager.js"; +import type { MemoryIndexManager } from "./manager.js"; export type MemorySearchManagerResult = { manager: MemoryIndexManager | null; @@ -11,6 +11,7 @@ export async function getMemorySearchManager(params: { agentId: string; }): Promise { try { + const { MemoryIndexManager } = await import("./manager.js"); const manager = await MemoryIndexManager.get(params); return { manager }; } catch (err) {