openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
36 lines (35 loc) • 1.62 kB
JavaScript
import { r as registerMemoryHostEvent, t as listStoredMemoryHostEvents } from "./event-store-DZgExamE.mjs";
import path from "node:path";
//#region src/memory-host-sdk/events.ts
/** Legacy workspace JSONL path retained only for doctor migration discovery. */
const MEMORY_HOST_EVENT_LOG_RELATIVE_PATH = path.join("memory", ".dreams", "events.jsonl");
/** Resolve the retired JSONL source path without reading it at runtime. */
function resolveMemoryHostEventLogPath(e) {
return path.join(e, MEMORY_HOST_EVENT_LOG_RELATIVE_PATH);
}
/** Append one memory host event to shared SQLite plugin state. */
async function appendMemoryHostEvent(e, t, n = {}) {
await registerMemoryHostEvent({
workspaceDir: e,
event: t,
...n.env ? { env: n.env } : {}
});
}
/** Read recent records, applying any type filter before the storage limit. */
async function readMemoryHostEventRecords(e) {
return applyMemoryHostEventLimit((await listStoredMemoryHostEvents(e)).map((e) => e.value.event), e.limit);
}
function applyMemoryHostEventLimit(e, t) {
if (!Number.isFinite(t)) return e;
const n = Math.max(0, Math.floor(t));
return n === 0 ? [] : e.slice(-n);
}
/** Read recent memory host events, excluding opt-in diagnostic variants. */
async function readMemoryHostEvents(e) {
return applyMemoryHostEventLimit((await readMemoryHostEventRecords({
workspaceDir: e.workspaceDir,
...e.env ? { env: e.env } : {}
})).filter((e) => e.type !== "memory.recall.skipped"), e.limit);
}
//#endregion
export { resolveMemoryHostEventLogPath as i, readMemoryHostEventRecords as n, readMemoryHostEvents as r, appendMemoryHostEvent as t };