UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

35 lines (34 loc) • 1.58 kB
import { t as formatErrorMessage } from "../../errors-BKzCeTYb.mjs"; import "../../error-runtime-BM740gJj.mjs"; import { t as MANAGED_DREAMING_DECLARATION_KEY } from "../../dreaming-cron-contract-BaLk3g0c.mjs"; //#region extensions/memory-core/dreaming-status-api.ts /** Diagnostic reads do not register the plugin or initialize its memory runtime. */ 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}.`]; } //#endregion export { readMemoryCoreDreamingRuns };