openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
52 lines (51 loc) • 2.04 kB
JavaScript
import { a as extractErrorCode } from "./error-coercion-hDrHOSGy.mjs";
import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs";
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs";
import { f as resolveAgentWorkspaceDir } from "./agent-scope-config-DmXgFGKP.mjs";
import { r as createLazyRuntimeModule } from "./lazy-runtime-zGjszCtt.mjs";
import { i as getAgentWorkspaceAccess } from "./workspace-access-CnjZBg1i.mjs";
import "./error-runtime-BM740gJj.mjs";
import "./agent-workspace-runtime-DsxJXUf2.mjs";
import "./routing-DmgGYTrU.mjs";
import { n as resolveMemorySearchConfig } from "./memory-search-dZuH_5z-.mjs";
import "./memory-core-host-engine-foundation-CvV28XoZ.mjs";
//#region extensions/memory-core/src/memory/search-manager.ts
const loadManagerRuntime = createLazyRuntimeModule(() => import("./extensions/memory-core/manager-runtime.js"));
async function getMemorySearchManager(e) {
const t = Date.now();
let n;
try {
const t = resolveMemorySearchConfig(e.cfg, e.agentId)?.sources.includes("memory") ? getAgentWorkspaceAccess(resolveAgentWorkspaceDir(e.cfg, e.agentId), "memoryFiles") : void 0;
const { MemoryIndexManager: r } = await loadManagerRuntime();
n = { manager: await r.get({
...e,
memoryFiles: t?.memoryFiles
}) };
} catch (e) {
n = {
manager: null,
error: formatErrorMessage(e),
code: extractErrorCode(e)
};
}
return {
...n,
debug: {
backend: "builtin",
purpose: e.purpose ?? "default",
managerMs: Math.max(0, Date.now() - t)
}
};
}
async function closeAllMemorySearchManagers() {
if (!loadManagerRuntime.peek()) return;
const { closeAllMemoryIndexManagers: e } = await loadManagerRuntime();
await e();
}
async function closeMemorySearchManager(e) {
if (!loadManagerRuntime.peek()) return;
const { closeMemoryIndexManagersForAgent: t } = await loadManagerRuntime();
await t({ agentId: normalizeAgentId(e.agentId) });
}
//#endregion
export { closeMemorySearchManager as n, getMemorySearchManager as r, closeAllMemorySearchManagers as t };