openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
71 lines (70 loc) • 3.96 kB
JavaScript
import { n as normalizeAgentId } from "./agent-id-D1-Q6vR4.mjs";
import "./session-key-DY3MOX4N.mjs";
import { n as listSessionTranscriptArchivesReadOnly } from "./session-accessor.sqlite-history-BHbnFYFh.mjs";
import { a as listSessionTranscriptInstances } from "./session-accessor.sqlite-entry-DLa7_9ui.mjs";
import "./query-expansion-8IlqIzbI.mjs";
import "./session-accessor-C3ljJ974.mjs";
import { t as assertBoundIncognitoMemorySyncAccess } from "./openclaw-runtime-session-Bhg6HfXN.mjs";
import { t as buildSessionEntry$1 } from "./session-files-D7wlSA0M.mjs";
import { t as listSessionTranscriptCorpusEntriesForAgent$1 } from "./session-transcript-corpus-CwNK6v_4.mjs";
import { t as readSessionResetRecallCutoff$1 } from "./session-reset-recall-read-B7Qulisg.mjs";
import { n as readMemorySessionTargets, t as projectSessionMetadata } from "./session-memory-targets-e1h9G0XD.mjs";
import "./session-transcript-inventory-runtime-C9iynxVu.mjs";
//#region src/plugin-sdk/memory-core-host-engine-sessions.ts
/** Private-local SDK subpath for memory session transcript helpers. */
/** @deprecated Use loadArchivedSessionsAsync; removed at the next Plugin SDK major. */
function loadArchivedSessions(params) {
assertBoundIncognitoMemorySyncAccess(params, "loadArchivedSessions", "loadArchivedSessionsAsync");
return listSessionTranscriptArchivesReadOnly(params);
}
const buildSessionEntry = buildSessionEntry$1;
const listSessionTranscriptCorpusEntriesForAgent = listSessionTranscriptCorpusEntriesForAgent$1;
const readSessionResetRecallCutoff = readSessionResetRecallCutoff$1;
/** Durable ingestion guard; runtime discovery should use resolveMemorySessionTargetsAsync. */
function loadMemorySessionMetadata(params) {
assertBoundIncognitoMemorySyncAccess(params, "loadMemorySessionMetadata", "resolveMemorySessionTargetsAsync");
const instance = listSessionTranscriptInstances(params, {
includeAllWindows: true,
sessionId: params.sessionId
}).find((candidate) => candidate.agentId === normalizeAgentId(params.agentId) && (!params.sessionKey || candidate.sessionKey === params.sessionKey));
return instance ? projectSessionMetadata(instance) : void 0;
}
/** Final synchronous admission guard for the durable ingestion owner. */
function loadMemorySessionMetadataBatch(params) {
for (const session of params.sessions) assertBoundIncognitoMemorySyncAccess({
...params,
...session
}, "loadMemorySessionMetadataBatch", "resolveMemorySessionTargetsAsync");
const selectors = /* @__PURE__ */ new Map();
for (const { sessionId, sessionKey } of params.sessions) {
const keys = selectors.get(sessionId) ?? /* @__PURE__ */ new Set();
keys.add(sessionKey);
selectors.set(sessionId, keys);
}
const sessionIds = [...selectors.keys()];
const agentId = normalizeAgentId(params.agentId);
const metadata = [];
const batchSize = 128;
for (let start = 0; start < sessionIds.length; start += batchSize) {
const instances = listSessionTranscriptInstances({
agentId,
storePath: params.storePath,
projection: "list"
}, {
includeAllWindows: true,
sessionIds: sessionIds.slice(start, start + batchSize)
});
for (const instance of instances) {
const keys = selectors.get(instance.sessionId);
if (instance.agentId === agentId && (keys?.has(void 0) || keys?.has(instance.sessionKey))) metadata.push(projectSessionMetadata(instance));
}
}
return metadata;
}
/** @deprecated Use resolveMemorySessionTargetsAsync; removed at the next Plugin SDK major. */
function resolveMemorySessionTargets(params) {
assertBoundIncognitoMemorySyncAccess(params, "resolveMemorySessionTargets", "resolveMemorySessionTargetsAsync");
return readMemorySessionTargets(params);
}
//#endregion
export { loadMemorySessionMetadataBatch as a, loadMemorySessionMetadata as i, listSessionTranscriptCorpusEntriesForAgent as n, readSessionResetRecallCutoff as o, loadArchivedSessions as r, resolveMemorySessionTargets as s, buildSessionEntry as t };