openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.1 kB
JavaScript
import{r as registerMemoryHostEvent,t as listStoredMemoryHostEvents}from"./event-store-DaRWHXuF.mjs";import path from"node:path";
//!src/memory-host-sdk/events.ts
const MEMORY_HOST_EVENT_LOG_RELATIVE_PATH=path.join(`memory`,`.dreams`,`events.jsonl`);function resolveMemoryHostEventLogPath(e){return path.join(e,MEMORY_HOST_EVENT_LOG_RELATIVE_PATH)}async function appendMemoryHostEvent(e,t,n={}){await registerMemoryHostEvent({workspaceDir:e,event:t,...n.env?{env:n.env}:{}})}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)}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)}export{resolveMemoryHostEventLogPath as i,readMemoryHostEventRecords as n,readMemoryHostEvents as r,appendMemoryHostEvent as t};