mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 20:51:10 +00:00
test: cache memory manager helper imports
This commit is contained in:
@@ -1,13 +1,29 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/memory-core-host-engine-foundation";
|
||||
import type { MemoryIndexManager } from "./index.js";
|
||||
|
||||
type MemoryIndexModule = typeof import("./index.js");
|
||||
|
||||
let ensureEmbeddingMocksLoadedPromise: Promise<void> | null = null;
|
||||
let getMemorySearchManagerPromise: Promise<MemoryIndexModule["getMemorySearchManager"]> | null =
|
||||
null;
|
||||
|
||||
async function ensureEmbeddingMocksLoaded(): Promise<void> {
|
||||
ensureEmbeddingMocksLoadedPromise ??= import("./embedding.test-mocks.js").then(() => undefined);
|
||||
await ensureEmbeddingMocksLoadedPromise;
|
||||
}
|
||||
|
||||
async function loadGetMemorySearchManager(): Promise<MemoryIndexModule["getMemorySearchManager"]> {
|
||||
getMemorySearchManagerPromise ??= import("./index.js").then((mod) => mod.getMemorySearchManager);
|
||||
return await getMemorySearchManagerPromise;
|
||||
}
|
||||
|
||||
export async function getRequiredMemoryIndexManager(params: {
|
||||
cfg: OpenClawConfig;
|
||||
agentId?: string;
|
||||
purpose?: "default" | "status";
|
||||
}): Promise<MemoryIndexManager> {
|
||||
await import("./embedding.test-mocks.js");
|
||||
const { getMemorySearchManager } = await import("./index.js");
|
||||
await ensureEmbeddingMocksLoaded();
|
||||
const getMemorySearchManager = await loadGetMemorySearchManager();
|
||||
const result = await getMemorySearchManager({
|
||||
cfg: params.cfg,
|
||||
agentId: params.agentId ?? "main",
|
||||
|
||||
Reference in New Issue
Block a user