@@ -1307,6 +1307,82 @@ describe("gateway startup reconciliation", () => {
|
1307 | 1307 | clearInternalHooks(); |
1308 | 1308 | } |
1309 | 1309 | }); |
| 1310 | + |
| 1311 | +it("uses live runtime config for heartbeat dreaming reconciliation", async () => { |
| 1312 | +clearInternalHooks(); |
| 1313 | +const logger = createLogger(); |
| 1314 | +const harness = createCronHarness(); |
| 1315 | +const onMock = vi.fn(); |
| 1316 | +const runtimeLoadConfig = vi.fn( |
| 1317 | +() => |
| 1318 | +({ |
| 1319 | +plugins: { |
| 1320 | +entries: { |
| 1321 | +"memory-core": { |
| 1322 | +config: { |
| 1323 | +dreaming: { |
| 1324 | +enabled: false, |
| 1325 | +}, |
| 1326 | +}, |
| 1327 | +}, |
| 1328 | +}, |
| 1329 | +}, |
| 1330 | +}) as OpenClawConfig, |
| 1331 | +); |
| 1332 | +const api: DreamingPluginApiTestDouble = { |
| 1333 | +config: { |
| 1334 | +plugins: { |
| 1335 | +entries: { |
| 1336 | +"memory-core": { |
| 1337 | +config: { |
| 1338 | +dreaming: { |
| 1339 | +enabled: true, |
| 1340 | +frequency: "15 4 * * *", |
| 1341 | +timezone: "UTC", |
| 1342 | +}, |
| 1343 | +}, |
| 1344 | +}, |
| 1345 | +}, |
| 1346 | +}, |
| 1347 | +} as OpenClawConfig, |
| 1348 | +pluginConfig: {}, |
| 1349 | + logger, |
| 1350 | +runtime: { |
| 1351 | +config: { |
| 1352 | +loadConfig: runtimeLoadConfig, |
| 1353 | +}, |
| 1354 | +}, |
| 1355 | +on: onMock, |
| 1356 | +}; |
| 1357 | + |
| 1358 | +try { |
| 1359 | +registerShortTermPromotionDreamingForTest(api); |
| 1360 | +await triggerGatewayStart(onMock, { |
| 1361 | +config: api.config, |
| 1362 | +getCron: () => harness.cron, |
| 1363 | +}); |
| 1364 | + |
| 1365 | +const sessionKey = "agent:main:main"; |
| 1366 | +enqueueSystemEvent(constants.DREAMING_SYSTEM_EVENT_TEXT, { |
| 1367 | + sessionKey, |
| 1368 | +contextKey: "cron:memory-dreaming", |
| 1369 | +}); |
| 1370 | + |
| 1371 | +const beforeAgentReply = getBeforeAgentReplyHandler(onMock); |
| 1372 | +const result = await beforeAgentReply( |
| 1373 | +{ cleanedBody: constants.DREAMING_SYSTEM_EVENT_TEXT }, |
| 1374 | +{ trigger: "heartbeat", workspaceDir: ".", sessionKey }, |
| 1375 | +); |
| 1376 | + |
| 1377 | +expect(runtimeLoadConfig).toHaveBeenCalled(); |
| 1378 | +expect(result).toEqual({ |
| 1379 | +handled: true, |
| 1380 | +reason: "memory-core: short-term dreaming disabled", |
| 1381 | +}); |
| 1382 | +} finally { |
| 1383 | +clearInternalHooks(); |
| 1384 | +} |
| 1385 | +}); |
1310 | 1386 | }); |
1311 | 1387 | |
1312 | 1388 | describe("short-term dreaming trigger", () => { |
|