|
|
|
@@ -924,7 +924,7 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("loads the default agent session from templated stores", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storeTemplate = path.join(tmpDir, "agents", "{agentId}", "sessions.json");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
|
try {
|
|
|
|
@@ -983,11 +983,12 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
);
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("skips heartbeat when HEARTBEAT.md is effectively empty (saves API calls)", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storePath = path.join(tmpDir, "sessions.json");
|
|
|
|
|
const workspaceDir = path.join(tmpDir, "workspace");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
@@ -1054,11 +1055,12 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
expect(sendWhatsApp).not.toHaveBeenCalled();
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not skip wake-triggered heartbeat when HEARTBEAT.md is effectively empty", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storePath = path.join(tmpDir, "sessions.json");
|
|
|
|
|
const workspaceDir = path.join(tmpDir, "workspace");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
@@ -1121,11 +1123,12 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
expect(sendWhatsApp).toHaveBeenCalledTimes(1);
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not skip hook-triggered heartbeat when HEARTBEAT.md is effectively empty", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storePath = path.join(tmpDir, "sessions.json");
|
|
|
|
|
const workspaceDir = path.join(tmpDir, "workspace");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
@@ -1188,11 +1191,12 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
expect(sendWhatsApp).toHaveBeenCalledTimes(1);
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("runs heartbeat when HEARTBEAT.md has actionable content", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storePath = path.join(tmpDir, "sessions.json");
|
|
|
|
|
const workspaceDir = path.join(tmpDir, "workspace");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
@@ -1257,11 +1261,12 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
expect(sendWhatsApp).toHaveBeenCalledTimes(1);
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("runs heartbeat when HEARTBEAT.md does not exist (lets LLM decide)", async () => {
|
|
|
|
|
const tmpDir = await createCaseDir("openclaw-hb");
|
|
|
|
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-hb-"));
|
|
|
|
|
const storePath = path.join(tmpDir, "sessions.json");
|
|
|
|
|
const workspaceDir = path.join(tmpDir, "workspace");
|
|
|
|
|
const replySpy = vi.spyOn(replyModule, "getReplyFromConfig");
|
|
|
|
@@ -1319,6 +1324,7 @@ describe("runHeartbeatOnce", () => {
|
|
|
|
|
expect(replySpy).toHaveBeenCalled();
|
|
|
|
|
} finally {
|
|
|
|
|
replySpy.mockRestore();
|
|
|
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|