perf: lazy-load memory manager

This commit is contained in:
Peter Steinberger
2026-01-18 08:05:32 +00:00
parent de3b68740a
commit 2a86504723
3 changed files with 6 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ import { probeGateway } from "../gateway/probe.js";
import { collectChannelStatusIssues } from "../infra/channels-status-issues.js"; import { collectChannelStatusIssues } from "../infra/channels-status-issues.js";
import { resolveOsSummary } from "../infra/os-summary.js"; import { resolveOsSummary } from "../infra/os-summary.js";
import { getTailnetHostname } from "../infra/tailscale.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 { runExec } from "../process/exec.js";
import type { RuntimeEnv } from "../runtime.js"; import type { RuntimeEnv } from "../runtime.js";
import { getAgentLocalStatuses } from "./status.agent-local.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 { getUpdateCheckResult } from "./status.update.js";
import { buildChannelsTable } from "./status-all/channels.js"; import { buildChannelsTable } from "./status-all/channels.js";
type MemoryStatusSnapshot = ReturnType<(typeof MemoryIndexManager)["prototype"]["status"]> & { type MemoryStatusSnapshot = ReturnType<MemoryIndexManager["status"]> & {
agentId: string; agentId: string;
}; };
@@ -151,6 +151,7 @@ export async function scanStatus(
if (!memoryPlugin.enabled) return null; if (!memoryPlugin.enabled) return null;
if (memoryPlugin.slot !== "memory-core") return null; if (memoryPlugin.slot !== "memory-core") return null;
const agentId = agentStatus.defaultId ?? "main"; const agentId = agentStatus.defaultId ?? "main";
const { MemoryIndexManager } = await import("../memory/manager.js");
const manager = await MemoryIndexManager.get({ cfg, agentId }).catch(() => null); const manager = await MemoryIndexManager.get({ cfg, agentId }).catch(() => null);
if (!manager) return null; if (!manager) return null;
try { try {

View File

@@ -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"; export { getMemorySearchManager, type MemorySearchManagerResult } from "./search-manager.js";

View File

@@ -1,5 +1,5 @@
import type { ClawdbotConfig } from "../config/config.js"; import type { ClawdbotConfig } from "../config/config.js";
import { MemoryIndexManager } from "./manager.js"; import type { MemoryIndexManager } from "./manager.js";
export type MemorySearchManagerResult = { export type MemorySearchManagerResult = {
manager: MemoryIndexManager | null; manager: MemoryIndexManager | null;
@@ -11,6 +11,7 @@ export async function getMemorySearchManager(params: {
agentId: string; agentId: string;
}): Promise<MemorySearchManagerResult> { }): Promise<MemorySearchManagerResult> {
try { try {
const { MemoryIndexManager } = await import("./manager.js");
const manager = await MemoryIndexManager.get(params); const manager = await MemoryIndexManager.get(params);
return { manager }; return { manager };
} catch (err) { } catch (err) {