UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

126 lines (125 loc) • 6.26 kB
import { o as getAsyncWorkSignal } from "./async-work-scope-BXagjUap.mjs"; import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; import { r as isIncognitoSessionKey } from "./session-key-DW1jcHbM.mjs"; import "./session-key-CqAyZeVk.mjs"; import { t as warnPluginSdkDeprecation } from "./sdk-deprecation-D5N9acnu.mjs"; import { t as captureSessionActorStorageOwner } from "./session-actor-storage-binding-DMwpDsij.mjs"; import { t as SessionTranscriptColdError } from "./session-transcript-cold-error-zvtkWn39.mjs"; import { n as listSessionTranscriptArchivesReadOnly, r as listSessionTranscriptInstances } from "./session-accessor.sqlite-participant-read-BeRe9wNU.mjs"; import { J as listSessionTranscriptInstancesInWorker } from "./session-accessor-CizTbDQj.mjs"; import { y as projectSessionMetadata } from "./session-actor-memory-owner-BkB9Vtu4.mjs"; import "./openclaw-runtime-paths-DuD50SoI.mjs"; import { t as readRestoredSessionTranscript } from "./session-cold-storage-read-DHL_Hyuu.mjs"; import "./query-expansion-ByczNsxI.mjs"; import { t as assertBoundIncognitoMemorySyncAccess } from "./session-memory-authority-C31Twnth.mjs"; import { i as readSessionResetRecallCutoffInWorker, t as captureIncognitoMemoryReader } from "./openclaw-runtime-session-CNB-CfG0.mjs"; import { l as listSessionTranscriptCorpusEntriesForAgent$1, n as buildSessionEntry$1 } from "./session-files-agcHHm9h.mjs"; import { i as readMemorySessionTargets, r as resolveMemorySessionTargetsInWorker } from "./session-transcript-inventory-runtime-0nKdYI_m.mjs"; import { isMainThread } from "node:worker_threads"; //#region packages/memory-host-sdk/src/host/session-reset-recall-read.ts async function readSessionResetRecallCutoff$1(e) { const t = captureIncognitoMemoryReader(e); if (t) return t.memoryResetRecall(); const read = () => readSessionResetRecallCutoffInWorker(e); try { return await read(); } catch (t) { if (!(t instanceof SessionTranscriptColdError) || t.sessionId !== e.sessionId) throw t; return readRestoredSessionTranscript(e, read); } } //#endregion //#region src/plugin-sdk/memory-core-host-engine-sessions.ts /** Private-local SDK subpath for memory session transcript helpers. */ /** Read only search-hit identities and their aliases through the canonical store owner. */ async function loadMemorySearchSessionStore(e, t) { const { agentId: n, ...r } = t; const { loadCombinedSessionStoreForGatewayCoreAsync: i } = await import("./combined-store-gateway-read-C69sWGwd.mjs"); const { store: a, storePath: o } = await i(e, { agentId: n, includeIncognito: false, projection: "list", transcriptSelection: r }); return { storePath: o, store: Object.fromEntries(Object.entries(a).filter(([e]) => !isIncognitoSessionKey(e))) }; } /** @deprecated Await loadArchivedSessionsAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */ function loadArchivedSessions(e) { warnPluginSdkDeprecation({ family: "memory-session-sync-inventory", method: "loadArchivedSessions", replacement: "loadArchivedSessionsAsync" }); assertBoundIncognitoMemorySyncAccess(e, "loadArchivedSessions", "loadArchivedSessionsAsync"); return listSessionTranscriptArchivesReadOnly(e); } const buildSessionEntry = buildSessionEntry$1; const listSessionTranscriptCorpusEntriesForAgent = listSessionTranscriptCorpusEntriesForAgent$1; const readSessionResetRecallCutoff = readSessionResetRecallCutoff$1; /** @deprecated Await loadMemorySessionMetadataAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */ function loadMemorySessionMetadata(e) { if (isMainThread) warnPluginSdkDeprecation({ family: "memory-session", method: "loadMemorySessionMetadata", replacement: "loadMemorySessionMetadataAsync" }); assertBoundIncognitoMemorySyncAccess(e, "loadMemorySessionMetadata", "loadMemorySessionMetadataAsync"); const t = listSessionTranscriptInstances(e, { includeAllWindows: true, sessionId: e.sessionId }).find((t) => t.agentId === normalizeAgentId(e.agentId) && (!e.sessionKey || t.sessionKey === e.sessionKey)); return t ? projectSessionMetadata(t) : void 0; } /** Read the selected transcript's recorded source metadata through its owner. */ async function loadMemorySessionMetadataAsync(e) { return (await loadMemorySessionMetadataBatchAsync({ ...e, sessions: [e] }))[0]; } /** One history read resolves the complete ingestion batch. */ async function loadMemorySessionMetadataBatchAsync(e) { const t = /* @__PURE__ */ new Map(); for (const { sessionId: n, sessionKey: r } of e.sessions) { const e = t.get(n) ?? /* @__PURE__ */ new Set(); e.add(r); t.set(n, e); } if (t.size === 0) return []; const n = normalizeAgentId(e.agentId); const r = { agentId: n, storePath: e.storePath }; const i = [...t.keys()]; const a = getAsyncWorkSignal(); const assertCurrent = () => a?.throwIfAborted(); return (captureSessionActorStorageOwner(r, { assertCurrent, authorize: assertCurrent }) ? (await resolveMemorySessionTargetsInWorker({ ...r, sessionIds: i })).filter((e) => e.resolution === "live") : (await listSessionTranscriptInstancesInWorker({ ...r, projection: "list" }, { includeAllWindows: true, sessionIds: i })).map((e) => projectSessionMetadata(e))).filter((e) => e.agentId === n && (t.get(e.sessionId)?.has(void 0) || t.get(e.sessionId)?.has(e.sessionKey))); } /** @deprecated Await resolveMemorySessionTargetsAsync. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */ function resolveMemorySessionTargets(e) { warnPluginSdkDeprecation({ family: "memory-session-sync-inventory", method: "resolveMemorySessionTargets", replacement: "resolveMemorySessionTargetsAsync" }); assertBoundIncognitoMemorySyncAccess(e, "resolveMemorySessionTargets", "resolveMemorySessionTargetsAsync"); return readMemorySessionTargets(e); } //#endregion export { loadMemorySessionMetadata as a, readSessionResetRecallCutoff as c, loadMemorySearchSessionStore as i, resolveMemorySessionTargets as l, listSessionTranscriptCorpusEntriesForAgent as n, loadMemorySessionMetadataAsync as o, loadArchivedSessions as r, loadMemorySessionMetadataBatchAsync as s, buildSessionEntry as t };