mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:08:26 +00:00
Fix #12767: Heartbeat strip responsePrefix before HEARTBEAT_OK suppression
This commit is contained in:
committed by
Peter Steinberger
parent
feed570984
commit
f476c8b48b
@@ -40,6 +40,7 @@ import { getQueueSize } from "../process/command-queue.js";
|
||||
import { CommandLane } from "../process/lanes.js";
|
||||
import { normalizeAgentId, toAgentStoreSessionKey } from "../routing/session-key.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { escapeRegExp } from "../utils.js";
|
||||
import { formatErrorMessage } from "./errors.js";
|
||||
import { isWithinActiveHours } from "./heartbeat-active-hours.js";
|
||||
import {
|
||||
@@ -62,7 +63,7 @@ import {
|
||||
} from "./outbound/targets.js";
|
||||
import { peekSystemEventEntries } from "./system-events.js";
|
||||
|
||||
type HeartbeatDeps = OutboundSendDeps &
|
||||
export type HeartbeatDeps = OutboundSendDeps &
|
||||
ChannelHeartbeatDeps & {
|
||||
runtime?: RuntimeEnv;
|
||||
getQueueSize?: (lane?: string) => number;
|
||||
@@ -355,7 +356,13 @@ function normalizeHeartbeatReply(
|
||||
responsePrefix: string | undefined,
|
||||
ackMaxChars: number,
|
||||
) {
|
||||
const stripped = stripHeartbeatToken(payload.text, {
|
||||
const rawText = typeof payload.text === "string" ? payload.text : "";
|
||||
// Normalize away responsePrefix so a prefixed HEARTBEAT_OK still strips.
|
||||
const prefixPattern = responsePrefix?.trim()
|
||||
? new RegExp(`^${escapeRegExp(responsePrefix.trim())}\\s*`, "i")
|
||||
: null;
|
||||
const textForStrip = prefixPattern ? rawText.replace(prefixPattern, "") : rawText;
|
||||
const stripped = stripHeartbeatToken(textForStrip, {
|
||||
mode: "heartbeat",
|
||||
maxAckChars: ackMaxChars,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user