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

推荐订阅源

量子位
WordPress大学
WordPress大学
小众软件
小众软件
云风的 BLOG
云风的 BLOG
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
宝玉的分享
宝玉的分享
博客园 - Franky
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
D
Docker
博客园 - 聂微东
C
Check Point Blog
H
Help Net Security

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(whatsapp): support Baileys rc10 postinstall patch · o...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";

44

import path from "node:path";

55

import { describe, expect, it, vi } from "vitest";

66

import {

7+

applyBaileysEncryptedStreamFinishHotfix,

78

collectLegacyPluginRuntimeDepsStateRoots,

89

isSourceCheckoutRoot,

910

isDirectPostinstallInvocation,

@@ -58,6 +59,21 @@ async function writePluginPackage(

5859

}

5960

}

606162+

async function writeBaileysMediaFile(packageRoot: string, text: string) {

63+

const mediaFile = path.join(

64+

packageRoot,

65+

"node_modules",

66+

"@whiskeysockets",

67+

"baileys",

68+

"lib",

69+

"Utils",

70+

"messages-media.js",

71+

);

72+

await fs.mkdir(path.dirname(mediaFile), { recursive: true });

73+

await fs.writeFile(mediaFile, text);

74+

return mediaFile;

75+

}

76+6177

describe("bundled plugin postinstall", () => {

6278

function existsSyncWithoutGlobalCompileCache(value: string) {

6379

if (path.resolve(value) === path.join(tmpdir(), "node-compile-cache")) {

@@ -206,6 +222,83 @@ describe("bundled plugin postinstall", () => {

206222

expect(warn).not.toHaveBeenCalled();

207223

});

208224225+

it("patches the Baileys rc10 upload helper dispatcher guard", async () => {

226+

const packageRoot = await createTempDirAsync("openclaw-baileys-postinstall-");

227+

const mediaFile = await writeBaileysMediaFile(

228+

packageRoot,

229+

[

230+

"import { once } from 'events';",

231+

"const encryptedStream = async () => {",

232+

" encFileWriteStream.write(mac);",

233+

" const encFinishPromise = once(encFileWriteStream, 'finish');",

234+

" const originalFinishPromise = originalFileStream ? once(originalFileStream, 'finish') : Promise.resolve();",

235+

" encFileWriteStream.end();",

236+

" originalFileStream?.end?.();",

237+

" stream.destroy();",

238+

" await encFinishPromise;",

239+

" await originalFinishPromise;",

240+

" logger?.debug('encrypted data successfully');",

241+

"};",

242+

"const uploadWithFetch = async ({ url, filePath, headers, timeoutMs, agent }) => {",

243+

" const nodeStream = createReadStream(filePath);",

244+

" const webStream = Readable.toWeb(nodeStream);",

245+

" const response = await fetch(url, {",

246+

" dispatcher: agent,",

247+

" method: 'POST',",

248+

" body: webStream,",

249+

" headers,",

250+

" duplex: 'half',",

251+

" signal: timeoutMs ? AbortSignal.timeout(timeoutMs) : undefined",

252+

" });",

253+

"};",

254+

"",

255+

].join("\n"),

256+

);

257+258+

expect(applyBaileysEncryptedStreamFinishHotfix({ packageRoot })).toMatchObject({

259+

applied: true,

260+

reason: "patched",

261+

});

262+

const patchedText = await fs.readFile(mediaFile, "utf8");

263+

expect(patchedText).toContain(

264+

"...(typeof agent?.dispatch === 'function' ? { dispatcher: agent } : {}),",

265+

);

266+

expect(patchedText).not.toContain(" dispatcher: agent,");

267+

});

268+269+

it("recognizes already patched Baileys rc10 upload helpers", async () => {

270+

const packageRoot = await createTempDirAsync("openclaw-baileys-postinstall-");

271+

await writeBaileysMediaFile(

272+

packageRoot,

273+

[

274+

"import { once } from 'events';",

275+

"const encryptedStream = async () => {",

276+

" encFileWriteStream.write(mac);",

277+

" const encFinishPromise = once(encFileWriteStream, 'finish');",

278+

" const originalFinishPromise = originalFileStream ? once(originalFileStream, 'finish') : Promise.resolve();",

279+

" encFileWriteStream.end();",

280+

" originalFileStream?.end?.();",

281+

" stream.destroy();",

282+

" await encFinishPromise;",

283+

" await originalFinishPromise;",

284+

" logger?.debug('encrypted data successfully');",

285+

"};",

286+

"const uploadWithFetch = async ({ url, filePath, headers, timeoutMs, agent }) => {",

287+

" const response = await fetch(url, {",

288+

" ...(typeof agent?.dispatch === 'function' ? { dispatcher: agent } : {}),",

289+

" method: 'POST',",

290+

" });",

291+

"};",

292+

"",

293+

].join("\n"),

294+

);

295+296+

expect(applyBaileysEncryptedStreamFinishHotfix({ packageRoot })).toMatchObject({

297+

applied: false,

298+

reason: "already_patched",

299+

});

300+

});

301+209302

it("does not classify published packages with source files as source checkouts", () => {

210303

const packageRoot = "/pkg";

211304

const existingPaths = new Set([