UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

50 lines (49 loc) • 1.78 kB
import { a as resolveGlobalSingleton } from "./global-singleton-D7yf05nR.mjs"; import { t as createPluginRuntimeStore } from "./runtime-store-BRjhAEZt.mjs"; //#region extensions/memory-core/src/memory/lifecycle.ts const lifecycleStore = createPluginRuntimeStore({ key: "memory-core:manager-lifecycle", errorMessage: "Memory manager lifecycle is not initialized" }); const liveIndexing = resolveGlobalSingleton(Symbol.for("openclaw.memoryCore.liveIndexing"), () => /* @__PURE__ */ new Set(), (e) => { e.clear(); }, "close-and-restart"); /** Records that a watched index manager ran in this process. */ function markMemoryIndexingLive(e) { liveIndexing.add(e); } /** Removed agents lose their demand; untouched roster additions stay lazy. */ function retainMemoryIndexingAgents(e) { const t = new Set(e); for (const e of liveIndexing) if (!t.has(e)) liveIndexing.delete(e); return [...liveIndexing]; } var MemoryManagerReloadError = class extends Error { constructor() { super("Memory provider is reloading; retry after the plugin operation completes."); } }; function getMemoryManagerLifecycle() { let e = lifecycleStore.tryGetRuntime(); if (!e) { e = {}; lifecycleStore.setRuntime(e); } return e; } /** Pause new acquisition while the plugin owner replaces its adapters. */ function prepareMemoryManagerReload(e, t = getMemoryManagerLifecycle()) { const n = { retireRuntime: e.retireRuntime, adapters: new Set(e.retiringEmbeddingProviders) }; t.reload = n; return { drain: t.prepare?.(n) ?? (async () => ({ errors: [] })), resume() { t.reload = void 0; } }; } //#endregion export { retainMemoryIndexingAgents as a, prepareMemoryManagerReload as i, getMemoryManagerLifecycle as n, markMemoryIndexingLive as r, MemoryManagerReloadError as t };