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

推荐订阅源

G
Google Developers Blog
S
SegmentFault 最新的问题
Jina AI
Jina AI
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
B
Blog
博客园 - 【当耐特】
博客园 - Franky
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Engineering at Meta
Engineering at Meta

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(imessage): bound cli output capture · openclaw/opencl...
vincentkoc · 2026-05-28 · via Recent Commits to openclaw:main

@@ -3,6 +3,7 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";

33

import { extname, join } from "node:path";

44

import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";

55

import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";

6+

import { appendIMessageCliStderrTail, appendIMessageCliStdout } from "./cli-output.js";

67

import { createIMessageRpcClient } from "./client.js";

78

import { extractMarkdownFormatRuns } from "./markdown-format.js";

89

import { resolveIMessageMessageId as resolveIMessageMessageIdImpl } from "./monitor-reply-cache.js";

@@ -182,6 +183,31 @@ async function runIMessageCliJson(

182183

let stdout = "";

183184

let stderr = "";

184185

let killEscalation: ReturnType<typeof setTimeout> | null = null;

186+

let settled = false;

187+

const clearTimers = (options: { keepKillEscalation?: boolean } = {}): void => {

188+

if (timer) {

189+

clearTimeout(timer);

190+

}

191+

if (killEscalation && !options.keepKillEscalation) {

192+

clearTimeout(killEscalation);

193+

}

194+

};

195+

const fail = (error: Error, options: { keepKillEscalation?: boolean } = {}): void => {

196+

if (settled) {

197+

return;

198+

}

199+

settled = true;

200+

clearTimers(options);

201+

reject(error);

202+

};

203+

const succeed = (value: Record<string, unknown>): void => {

204+

if (settled) {

205+

return;

206+

}

207+

settled = true;

208+

clearTimers();

209+

resolve(value);

210+

};

185211

const timer =

186212

options.timeoutMs && options.timeoutMs > 0

187213

? setTimeout(() => {

@@ -196,32 +222,43 @@ async function runIMessageCliJson(

196222

// best-effort

197223

}

198224

}, 2000);

199-

reject(new Error(`iMessage action timed out after ${options.timeoutMs}ms`));

225+

fail(new Error(`iMessage action timed out after ${options.timeoutMs}ms`), {

226+

keepKillEscalation: true,

227+

});

200228

}, options.timeoutMs)

201229

: null;

202230

child.stdout.setEncoding("utf8");

203231

child.stderr.setEncoding("utf8");

204232

child.stdout.on("data", (chunk) => {

205-

stdout += chunk;

233+

if (settled) {

234+

return;

235+

}

236+

const appended = appendIMessageCliStdout(stdout, chunk);

237+

if (!appended.ok) {

238+

try {

239+

child.kill("SIGKILL");

240+

} catch {

241+

// best-effort

242+

}

243+

fail(new Error(appended.message));

244+

return;

245+

}

246+

stdout = appended.value;

206247

});

207248

child.stderr.on("data", (chunk) => {

208-

stderr += chunk;

249+

stderr = appendIMessageCliStderrTail(stderr, chunk);

209250

});

210251

child.on("error", (error) => {

211-

if (timer) {

212-

clearTimeout(timer);

213-

}

214-

if (killEscalation) {

215-

clearTimeout(killEscalation);

252+

if (settled) {

253+

clearTimers();

254+

return;

216255

}

217-

reject(error);

256+

fail(error);

218257

});

219258

child.on("close", (code) => {

220-

if (timer) {

221-

clearTimeout(timer);

222-

}

223-

if (killEscalation) {

224-

clearTimeout(killEscalation);

259+

if (settled) {

260+

clearTimers();

261+

return;

225262

}

226263

const lines = normalizeStringEntries(stdout.split(/\r?\n/));

227264

const last = lines.at(-1);

@@ -242,22 +279,22 @@ async function runIMessageCliJson(

242279

stderr.trim() ||

243280

stdout.trim() ||

244281

`imsg exited with code ${code}`;

245-

reject(new Error(detail));

282+

fail(new Error(detail));

246283

return;

247284

}

248285

if (!parsed) {

249-

reject(new Error(`imsg returned non-JSON output: ${stdout.trim() || stderr.trim()}`));

286+

fail(new Error(`imsg returned non-JSON output: ${stdout.trim() || stderr.trim()}`));

250287

return;

251288

}

252289

if (parsed.success === false) {

253290

const error =

254291

typeof parsed.error === "string" && parsed.error.trim()

255292

? parsed.error.trim()

256293

: "iMessage action failed";

257-

reject(new Error(error));

294+

fail(new Error(error));

258295

return;

259296

}

260-

resolve(parsed);

297+

succeed(parsed);

261298

});

262299

});

263300

}