






















@@ -1383,6 +1383,93 @@ describe("gateway startup reconciliation", () => {
13831383clearInternalHooks();
13841384}
13851385});
1386+1387+it("uses live runtime config for the heartbeat dreaming run payload", async () => {
1388+clearInternalHooks();
1389+const logger = createLogger();
1390+const harness = createCronHarness();
1391+const onMock = vi.fn();
1392+const workspaceDir = await createTempWorkspace("memory-dreaming-live-config-workspace-");
1393+const runtimeLoadConfig = vi.fn(
1394+() =>
1395+({
1396+agents: {
1397+list: [{ id: "main", default: true, workspace: workspaceDir }],
1398+},
1399+plugins: {
1400+entries: {
1401+"memory-core": {
1402+config: {
1403+dreaming: {
1404+enabled: true,
1405+frequency: "15 4 * * *",
1406+timezone: "UTC",
1407+limit: 0,
1408+},
1409+},
1410+},
1411+},
1412+},
1413+}) as OpenClawConfig,
1414+);
1415+const api: DreamingPluginApiTestDouble = {
1416+config: {
1417+plugins: {
1418+entries: {
1419+"memory-core": {
1420+config: {
1421+dreaming: {
1422+enabled: true,
1423+frequency: "15 4 * * *",
1424+timezone: "UTC",
1425+limit: 5,
1426+},
1427+},
1428+},
1429+},
1430+},
1431+} as OpenClawConfig,
1432+pluginConfig: {},
1433+ logger,
1434+runtime: {
1435+config: {
1436+loadConfig: runtimeLoadConfig,
1437+},
1438+},
1439+on: onMock,
1440+};
1441+1442+try {
1443+registerShortTermPromotionDreamingForTest(api);
1444+await triggerGatewayStart(onMock, {
1445+config: api.config,
1446+getCron: () => harness.cron,
1447+});
1448+1449+const sessionKey = "agent:main:main";
1450+enqueueSystemEvent(constants.DREAMING_SYSTEM_EVENT_TEXT, {
1451+ sessionKey,
1452+contextKey: "cron:memory-dreaming",
1453+});
1454+1455+const beforeAgentReply = getBeforeAgentReplyHandler(onMock);
1456+const result = await beforeAgentReply(
1457+{ cleanedBody: constants.DREAMING_SYSTEM_EVENT_TEXT },
1458+{ trigger: "heartbeat", sessionKey },
1459+);
1460+1461+expect(result).toEqual({
1462+handled: true,
1463+reason: "memory-core: short-term dreaming processed",
1464+});
1465+expect(runtimeLoadConfig).toHaveBeenCalled();
1466+expect(logger.warn).not.toHaveBeenCalledWith(
1467+"memory-core: dreaming promotion skipped because no memory workspace is available.",
1468+);
1469+} finally {
1470+clearInternalHooks();
1471+}
1472+});
13861473});
1387147413881475describe("short-term dreaming trigger", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。