mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 10:41:23 +00:00
fix: don't bleed top-level interval/prompt into heartbeat task parsing
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_HEARTBEAT_ACK_MAX_CHARS,
|
||||
isHeartbeatContentEffectivelyEmpty,
|
||||
parseHeartbeatTasks,
|
||||
stripHeartbeatToken,
|
||||
} from "./heartbeat.js";
|
||||
import { HEARTBEAT_TOKEN } from "./tokens.js";
|
||||
@@ -25,6 +26,22 @@ describe("stripHeartbeatToken", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not bleed top-level interval/prompt fields into task parsing", () => {
|
||||
const content = `
|
||||
tasks:- name: email-check
|
||||
interval: 30m
|
||||
prompt: Check for urgent emails
|
||||
interval: should-not-bleed
|
||||
`;
|
||||
expect(parseHeartbeatTasks(content)).toEqual([
|
||||
{
|
||||
name: "email-check",
|
||||
interval: "30m",
|
||||
prompt: "Check for urgent emails",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("drops heartbeats with small junk in heartbeat mode", () => {
|
||||
expect(stripHeartbeatToken("HEARTBEAT_OK 🦞", { mode: "heartbeat" })).toEqual({
|
||||
shouldSkip: true,
|
||||
|
||||
@@ -249,12 +249,18 @@ export function parseHeartbeatTasks(content: string): HeartbeatTask[] {
|
||||
}
|
||||
|
||||
// Check for task fields BEFORE checking for end of block
|
||||
if (nextTrimmed.startsWith("interval:")) {
|
||||
if (
|
||||
nextTrimmed.startsWith("interval:") &&
|
||||
(nextLine.startsWith(" ") || nextLine.startsWith("\t"))
|
||||
) {
|
||||
interval = nextTrimmed
|
||||
.replace("interval:", "")
|
||||
.trim()
|
||||
.replace(/^["']|["']$/g, "");
|
||||
} else if (nextTrimmed.startsWith("prompt:")) {
|
||||
} else if (
|
||||
nextTrimmed.startsWith("prompt:") &&
|
||||
(nextLine.startsWith(" ") || nextLine.startsWith("\t"))
|
||||
) {
|
||||
prompt = nextTrimmed
|
||||
.replace("prompt:", "")
|
||||
.trim()
|
||||
|
||||
Reference in New Issue
Block a user