惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
WordPress大学
WordPress大学
爱范儿
爱范儿
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
博客园_首页
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
MyScale Blog
MyScale Blog
IT之家
IT之家
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: keep control ui bundle browser-safe · openclaw/openc...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -1,4 +1,3 @@

1-

import { isHeartbeatOkResponse } from "../../../../src/auto-reply/heartbeat-filter.js";

21

import { resetToolStream } from "../app-tool-stream.ts";

32

import { extractText } from "../chat/message-extract.ts";

43

import { formatConnectError } from "../connect-error.ts";

@@ -12,6 +11,8 @@ import {

1211

} from "./scope-errors.ts";

13121413

const SILENT_REPLY_PATTERN = /^\s*NO_REPLY\s*$/;

14+

const HEARTBEAT_TOKEN = "HEARTBEAT_OK";

15+

const DEFAULT_HEARTBEAT_ACK_MAX_CHARS = 300;

1516

const SYNTHETIC_TRANSCRIPT_REPAIR_RESULT =

1617

"[openclaw] missing tool result in session history; inserted synthetic error result for transcript repair.";

1718

const STARTUP_CHAT_HISTORY_RETRY_TIMEOUT_MS = 60_000;

@@ -41,6 +42,97 @@ function shouldApplyChatHistoryResult(

4142

function isSilentReplyStream(text: string): boolean {

4243

return SILENT_REPLY_PATTERN.test(text);

4344

}

45+46+

function escapeRegExp(value: string): string {

47+

return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");

48+

}

49+50+

function stripHeartbeatTokenForDisplay(

51+

raw: string,

52+

maxAckChars = DEFAULT_HEARTBEAT_ACK_MAX_CHARS,

53+

): { shouldSkip: boolean } {

54+

let text = raw.trim();

55+

if (!text) {

56+

return { shouldSkip: true };

57+

}

58+

const strippedMarkup = text

59+

.replace(/<[^>]*>/g, " ")

60+

.replace(/&nbsp;/gi, " ")

61+

.replace(/^[*`~_]+/, "")

62+

.replace(/[*`~_]+$/, "");

63+

if (!text.includes(HEARTBEAT_TOKEN) && !strippedMarkup.includes(HEARTBEAT_TOKEN)) {

64+

return { shouldSkip: false };

65+

}

66+67+

const tokenAtEnd = new RegExp(`${escapeRegExp(HEARTBEAT_TOKEN)}[^\\w]{0,4}$`);

68+

let changed = true;

69+

let didStrip = false;

70+

text = strippedMarkup.trim();

71+

while (changed) {

72+

changed = false;

73+

const next = text.trim();

74+

if (next.startsWith(HEARTBEAT_TOKEN)) {

75+

text = next.slice(HEARTBEAT_TOKEN.length).trimStart();

76+

didStrip = true;

77+

changed = true;

78+

continue;

79+

}

80+

if (tokenAtEnd.test(next)) {

81+

const index = next.lastIndexOf(HEARTBEAT_TOKEN);

82+

const before = next.slice(0, index).trimEnd();

83+

const after = next.slice(index + HEARTBEAT_TOKEN.length).trimStart();

84+

text = before ? `${before}${after}`.trimEnd() : "";

85+

didStrip = true;

86+

changed = true;

87+

}

88+

}

89+90+

if (!didStrip) {

91+

return { shouldSkip: false };

92+

}

93+

return { shouldSkip: !text || text.length <= maxAckChars };

94+

}

95+96+

function isHeartbeatOkResponse(message: { role: string; content?: unknown }): boolean {

97+

if (message.role !== "assistant") {

98+

return false;

99+

}

100+

const { text, hasNonTextContent } = resolveMessageText(message.content);

101+

if (hasNonTextContent) {

102+

return false;

103+

}

104+

return stripHeartbeatTokenForDisplay(text).shouldSkip;

105+

}

106+107+

function resolveMessageText(content: unknown): { text: string; hasNonTextContent: boolean } {

108+

if (typeof content === "string") {

109+

return { text: content, hasNonTextContent: false };

110+

}

111+

if (!Array.isArray(content)) {

112+

return { text: "", hasNonTextContent: content != null };

113+

}

114+

let hasNonTextContent = false;

115+

const text = content

116+

.filter((block): block is { type: "text"; text: string } => {

117+

if (!block || typeof block !== "object" || !("type" in block)) {

118+

hasNonTextContent = true;

119+

return false;

120+

}

121+

if ((block as { type?: unknown }).type !== "text") {

122+

hasNonTextContent = true;

123+

return false;

124+

}

125+

if (typeof (block as { text?: unknown }).text !== "string") {

126+

hasNonTextContent = true;

127+

return false;

128+

}

129+

return true;

130+

})

131+

.map((block) => block.text)

132+

.join("");

133+

return { text, hasNonTextContent };

134+

}

135+44136

/** Client-side defense-in-depth: detect assistant messages whose text is purely NO_REPLY. */

45137

function isAssistantSilentReply(message: unknown): boolean {

46138

if (!message || typeof message !== "object") {