@@ -10,6 +10,7 @@ import {
|
10 | 10 | replaceManagedMarkdownBlock, |
11 | 11 | withTrailingNewline, |
12 | 12 | } from "openclaw/plugin-sdk/memory-host-markdown"; |
| 13 | +import { resolveMemoryCoreNowMs, resolveMemoryCoreTimestamp } from "./time.js"; |
13 | 14 | |
14 | 15 | const DAILY_PHASE_HEADINGS: Record<Exclude<MemoryDreamingPhaseName, "deep">, string> = { |
15 | 16 | light: "## Light Sleep", |
@@ -63,7 +64,7 @@ export async function writeDailyDreamingPhaseBlock(params: {
|
63 | 64 | timezone?: string; |
64 | 65 | storage: MemoryDreamingStorageConfig; |
65 | 66 | }): Promise<{ inlinePath?: string; reportPath?: string }> { |
66 | | -const nowMs = Number.isFinite(params.nowMs) ? (params.nowMs as number) : Date.now(); |
| 67 | +const nowMs = resolveMemoryCoreNowMs(params.nowMs); |
67 | 68 | const body = params.bodyLines.length > 0 ? params.bodyLines.join("\n") : "- No notable updates."; |
68 | 69 | let inlinePath: string | undefined; |
69 | 70 | let reportPath: string | undefined; |
@@ -107,7 +108,7 @@ export async function writeDailyDreamingPhaseBlock(params: {
|
107 | 108 | |
108 | 109 | await appendMemoryHostEvent(params.workspaceDir, { |
109 | 110 | type: "memory.dream.completed", |
110 | | -timestamp: new Date(nowMs).toISOString(), |
| 111 | +timestamp: resolveMemoryCoreTimestamp(nowMs), |
111 | 112 | phase: params.phase, |
112 | 113 | ...(inlinePath ? { inlinePath } : {}), |
113 | 114 | ...(reportPath ? { reportPath } : {}), |
@@ -131,14 +132,14 @@ export async function writeDeepDreamingReport(params: {
|
131 | 132 | if (!shouldWriteSeparate(params.storage)) { |
132 | 133 | return undefined; |
133 | 134 | } |
134 | | -const nowMs = Number.isFinite(params.nowMs) ? (params.nowMs as number) : Date.now(); |
| 135 | +const nowMs = resolveMemoryCoreNowMs(params.nowMs); |
135 | 136 | const reportPath = resolveSeparateReportPath(params.workspaceDir, "deep", nowMs, params.timezone); |
136 | 137 | await fs.mkdir(path.dirname(reportPath), { recursive: true }); |
137 | 138 | const body = params.bodyLines.length > 0 ? params.bodyLines.join("\n") : "- No durable changes."; |
138 | 139 | await fs.writeFile(reportPath, `# Deep Sleep\n\n${body}\n`, "utf-8"); |
139 | 140 | await appendMemoryHostEvent(params.workspaceDir, { |
140 | 141 | type: "memory.dream.completed", |
141 | | -timestamp: new Date(nowMs).toISOString(), |
| 142 | +timestamp: resolveMemoryCoreTimestamp(nowMs), |
142 | 143 | phase: "deep", |
143 | 144 | reportPath, |
144 | 145 | lineCount: params.bodyLines.length, |
|