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

推荐订阅源

V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
A
Arctic Wolf
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
Cyberwarzone
Cyberwarzone
S
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
J
Java Code Geeks
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
I
Intezer
L
LangChain Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
refactor(gateway): reuse chat state registries · openclaw/openclaw@1f8ccf2
steipete · 2026-04-29 · via Recent Commits to openclaw:main

@@ -11,12 +11,33 @@ import {

1111

resolveMergedAssistantText,

1212

shouldSuppressAssistantEventForLiveChat,

1313

} from "./live-chat-projector.js";

14+

import type {

15+

ChatRunState,

16+

SessionEventSubscriberRegistry,

17+

ToolEventRecipientRegistry,

18+

} from "./server-chat-state.js";

1419

import { loadGatewaySessionRow } from "./server-chat.load-gateway-session-row.runtime.js";

1520

import { persistGatewaySessionLifecycleEvent } from "./server-chat.persist-session-lifecycle.runtime.js";

1621

import { deriveGatewaySessionLifecycleSnapshot } from "./session-lifecycle-state.js";

1722

import { loadSessionEntry } from "./session-utils.js";

1823

import { formatForLog } from "./ws-log.js";

192425+

export {

26+

createChatRunRegistry,

27+

createChatRunState,

28+

createSessionEventSubscriberRegistry,

29+

createSessionMessageSubscriberRegistry,

30+

createToolEventRecipientRegistry,

31+

} from "./server-chat-state.js";

32+

export type {

33+

ChatRunEntry,

34+

ChatRunRegistry,

35+

ChatRunState,

36+

SessionEventSubscriberRegistry,

37+

SessionMessageSubscriberRegistry,

38+

ToolEventRecipientRegistry,

39+

} from "./server-chat-state.js";

40+2041

function resolveHeartbeatAckMaxChars(): number {

2142

try {

2243

const cfg = getRuntimeConfig();

@@ -84,307 +105,12 @@ function normalizeHeartbeatChatFinalText(params: {

84105

return { suppress: false, text: stripped.text };

85106

}

8610787-

export type ChatRunEntry = {

88-

sessionKey: string;

89-

clientRunId: string;

90-

};

91-92-

export type ChatRunRegistry = {

93-

add: (sessionId: string, entry: ChatRunEntry) => void;

94-

peek: (sessionId: string) => ChatRunEntry | undefined;

95-

shift: (sessionId: string) => ChatRunEntry | undefined;

96-

remove: (sessionId: string, clientRunId: string, sessionKey?: string) => ChatRunEntry | undefined;

97-

clear: () => void;

98-

};

99-100-

export function createChatRunRegistry(): ChatRunRegistry {

101-

const chatRunSessions = new Map<string, ChatRunEntry[]>();

102-103-

const add = (sessionId: string, entry: ChatRunEntry) => {

104-

const queue = chatRunSessions.get(sessionId);

105-

if (queue) {

106-

queue.push(entry);

107-

} else {

108-

chatRunSessions.set(sessionId, [entry]);

109-

}

110-

};

111-112-

const peek = (sessionId: string) => chatRunSessions.get(sessionId)?.[0];

113-114-

const shift = (sessionId: string) => {

115-

const queue = chatRunSessions.get(sessionId);

116-

if (!queue || queue.length === 0) {

117-

return undefined;

118-

}

119-

const entry = queue.shift();

120-

if (!queue.length) {

121-

chatRunSessions.delete(sessionId);

122-

}

123-

return entry;

124-

};

125-126-

const remove = (sessionId: string, clientRunId: string, sessionKey?: string) => {

127-

const queue = chatRunSessions.get(sessionId);

128-

if (!queue || queue.length === 0) {

129-

return undefined;

130-

}

131-

const idx = queue.findIndex(

132-

(entry) =>

133-

entry.clientRunId === clientRunId && (sessionKey ? entry.sessionKey === sessionKey : true),

134-

);

135-

if (idx < 0) {

136-

return undefined;

137-

}

138-

const [entry] = queue.splice(idx, 1);

139-

if (!queue.length) {

140-

chatRunSessions.delete(sessionId);

141-

}

142-

return entry;

143-

};

144-145-

const clear = () => {

146-

chatRunSessions.clear();

147-

};

148-149-

return { add, peek, shift, remove, clear };

150-

}

151-152-

export type ChatRunState = {

153-

registry: ChatRunRegistry;

154-

rawBuffers: Map<string, string>;

155-

buffers: Map<string, string>;

156-

deltaSentAt: Map<string, number>;

157-

/** Length of text at the time of the last broadcast, used to avoid duplicate flushes. */

158-

deltaLastBroadcastLen: Map<string, number>;

159-

abortedRuns: Map<string, number>;

160-

clear: () => void;

161-

};

162-163-

export function createChatRunState(): ChatRunState {

164-

const registry = createChatRunRegistry();

165-

const rawBuffers = new Map<string, string>();

166-

const buffers = new Map<string, string>();

167-

const deltaSentAt = new Map<string, number>();

168-

const deltaLastBroadcastLen = new Map<string, number>();

169-

const abortedRuns = new Map<string, number>();

170-171-

const clear = () => {

172-

registry.clear();

173-

rawBuffers.clear();

174-

buffers.clear();

175-

deltaSentAt.clear();

176-

deltaLastBroadcastLen.clear();

177-

abortedRuns.clear();

178-

};

179-180-

return {

181-

registry,

182-

rawBuffers,

183-

buffers,

184-

deltaSentAt,

185-

deltaLastBroadcastLen,

186-

abortedRuns,

187-

clear,

188-

};

189-

}

190-191-

export type ToolEventRecipientRegistry = {

192-

add: (runId: string, connId: string) => void;

193-

get: (runId: string) => ReadonlySet<string> | undefined;

194-

markFinal: (runId: string) => void;

195-

};

196-197-

export type SessionEventSubscriberRegistry = {

198-

subscribe: (connId: string) => void;

199-

unsubscribe: (connId: string) => void;

200-

getAll: () => ReadonlySet<string>;

201-

clear: () => void;

202-

};

203-204-

export type SessionMessageSubscriberRegistry = {

205-

subscribe: (connId: string, sessionKey: string) => void;

206-

unsubscribe: (connId: string, sessionKey: string) => void;

207-

unsubscribeAll: (connId: string) => void;

208-

get: (sessionKey: string) => ReadonlySet<string>;

209-

clear: () => void;

210-

};

211-212-

type ToolRecipientEntry = {

213-

connIds: Set<string>;

214-

updatedAt: number;

215-

finalizedAt?: number;

216-

};

217-218-

const TOOL_EVENT_RECIPIENT_TTL_MS = 10 * 60 * 1000;

219-

const TOOL_EVENT_RECIPIENT_FINAL_GRACE_MS = 30 * 1000;

220108

/**

221109

* Keep this aligned with the agent.wait lifecycle-error grace so chat surfaces

222110

* do not finalize a run before fallback or retry reuses the same runId.

223111

*/

224112

const AGENT_LIFECYCLE_ERROR_RETRY_GRACE_MS = 15_000;

225113226-

export function createSessionEventSubscriberRegistry(): SessionEventSubscriberRegistry {

227-

const connIds = new Set<string>();

228-

const empty = new Set<string>();

229-230-

return {

231-

subscribe: (connId: string) => {

232-

const normalized = connId.trim();

233-

if (!normalized) {

234-

return;

235-

}

236-

connIds.add(normalized);

237-

},

238-

unsubscribe: (connId: string) => {

239-

const normalized = connId.trim();

240-

if (!normalized) {

241-

return;

242-

}

243-

connIds.delete(normalized);

244-

},

245-

getAll: () => (connIds.size > 0 ? connIds : empty),

246-

clear: () => {

247-

connIds.clear();

248-

},

249-

};

250-

}

251-252-

export function createSessionMessageSubscriberRegistry(): SessionMessageSubscriberRegistry {

253-

const sessionToConnIds = new Map<string, Set<string>>();

254-

const connToSessionKeys = new Map<string, Set<string>>();

255-

const empty = new Set<string>();

256-257-

const normalize = (value: string): string => value.trim();

258-259-

return {

260-

subscribe: (connId: string, sessionKey: string) => {

261-

const normalizedConnId = normalize(connId);

262-

const normalizedSessionKey = normalize(sessionKey);

263-

if (!normalizedConnId || !normalizedSessionKey) {

264-

return;

265-

}

266-

const connIds = sessionToConnIds.get(normalizedSessionKey) ?? new Set<string>();

267-

connIds.add(normalizedConnId);

268-

sessionToConnIds.set(normalizedSessionKey, connIds);

269-270-

const sessionKeys = connToSessionKeys.get(normalizedConnId) ?? new Set<string>();

271-

sessionKeys.add(normalizedSessionKey);

272-

connToSessionKeys.set(normalizedConnId, sessionKeys);

273-

},

274-

unsubscribe: (connId: string, sessionKey: string) => {

275-

const normalizedConnId = normalize(connId);

276-

const normalizedSessionKey = normalize(sessionKey);

277-

if (!normalizedConnId || !normalizedSessionKey) {

278-

return;

279-

}

280-

const connIds = sessionToConnIds.get(normalizedSessionKey);

281-

if (connIds) {

282-

connIds.delete(normalizedConnId);

283-

if (connIds.size === 0) {

284-

sessionToConnIds.delete(normalizedSessionKey);

285-

}

286-

}

287-

const sessionKeys = connToSessionKeys.get(normalizedConnId);

288-

if (sessionKeys) {

289-

sessionKeys.delete(normalizedSessionKey);

290-

if (sessionKeys.size === 0) {

291-

connToSessionKeys.delete(normalizedConnId);

292-

}

293-

}

294-

},

295-

unsubscribeAll: (connId: string) => {

296-

const normalizedConnId = normalize(connId);

297-

if (!normalizedConnId) {

298-

return;

299-

}

300-

const sessionKeys = connToSessionKeys.get(normalizedConnId);

301-

if (!sessionKeys) {

302-

return;

303-

}

304-

for (const sessionKey of sessionKeys) {

305-

const connIds = sessionToConnIds.get(sessionKey);

306-

if (!connIds) {

307-

continue;

308-

}

309-

connIds.delete(normalizedConnId);

310-

if (connIds.size === 0) {

311-

sessionToConnIds.delete(sessionKey);

312-

}

313-

}

314-

connToSessionKeys.delete(normalizedConnId);

315-

},

316-

get: (sessionKey: string) => {

317-

const normalizedSessionKey = normalize(sessionKey);

318-

if (!normalizedSessionKey) {

319-

return empty;

320-

}

321-

return sessionToConnIds.get(normalizedSessionKey) ?? empty;

322-

},

323-

clear: () => {

324-

sessionToConnIds.clear();

325-

connToSessionKeys.clear();

326-

},

327-

};

328-

}

329-330-

export function createToolEventRecipientRegistry(): ToolEventRecipientRegistry {

331-

const recipients = new Map<string, ToolRecipientEntry>();

332-333-

const prune = () => {

334-

if (recipients.size === 0) {

335-

return;

336-

}

337-

const now = Date.now();

338-

for (const [runId, entry] of recipients) {

339-

const cutoff = entry.finalizedAt

340-

? entry.finalizedAt + TOOL_EVENT_RECIPIENT_FINAL_GRACE_MS

341-

: entry.updatedAt + TOOL_EVENT_RECIPIENT_TTL_MS;

342-

if (now >= cutoff) {

343-

recipients.delete(runId);

344-

}

345-

}

346-

};

347-348-

const add = (runId: string, connId: string) => {

349-

if (!runId || !connId) {

350-

return;

351-

}

352-

const now = Date.now();

353-

const existing = recipients.get(runId);

354-

if (existing) {

355-

existing.connIds.add(connId);

356-

existing.updatedAt = now;

357-

} else {

358-

recipients.set(runId, {

359-

connIds: new Set([connId]),

360-

updatedAt: now,

361-

});

362-

}

363-

prune();

364-

};

365-366-

const get = (runId: string) => {

367-

const entry = recipients.get(runId);

368-

if (!entry) {

369-

return undefined;

370-

}

371-

entry.updatedAt = Date.now();

372-

prune();

373-

return entry.connIds;

374-

};

375-376-

const markFinal = (runId: string) => {

377-

const entry = recipients.get(runId);

378-

if (!entry) {

379-

return;

380-

}

381-

entry.finalizedAt = Date.now();

382-

prune();

383-

};

384-385-

return { add, get, markFinal };

386-

}

387-388114

export type ChatEventBroadcast = (

389115

event: string,

390116

payload: unknown,