openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.29 kB
JavaScript
import{t as formatErrorMessage}from"../../errors-D37BJTfI.mjs";import"../../error-runtime-DW-sj0iq.mjs";import{t as MANAGED_DREAMING_DECLARATION_KEY}from"../../dreaming-cron-contract-D5v9Jx22.mjs";
//!extensions/memory-core/dreaming-status-api.ts
async function readMemoryCoreDreamingRuns(e){const lastRun=async()=>{try{const{readMemoryHostEventRecords:t}=await import(`../../plugin-sdk/memory-host-events.js`);const n=(await t({workspaceDir:e.workspaceDir,type:`memory.dream.completed`,limit:1})).findLast(e=>e.type===`memory.dream.completed`);return n?`${new Date(n.timestamp).toISOString()} (${n.phase}, ${n.outcome??`completed`})`:`none recorded`}catch(e){return`unavailable (${formatErrorMessage(e)})`}};const nextRun=async()=>{if(!e.dreamingEnabled)return`dreaming disabled`;if(!e.cronEnabled)return`cron disabled`;try{const t=(await e.readCronJobs()).flatMap(e=>e.declarationKey===`memory-core:memory-dreaming-promotion`&&e.enabled&&e.state.nextRunAtMs!==void 0?[e.state.nextRunAtMs]:[]);return t.length>0?new Date(Math.min(...t)).toISOString():`none scheduled`}catch(e){return`unavailable (${formatErrorMessage(e)})`}};const[t,n]=await Promise.all([lastRun(),nextRun()]);return[`Last recorded dreaming run: ${t}.`,`Next scheduled run: ${n}.`]}export{readMemoryCoreDreamingRuns};