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

推荐订阅源

量子位
F
Fortinet All Blogs
小众软件
小众软件
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
有赞技术团队
有赞技术团队
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
A
About on SuperTechFans
I
InfoQ
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale 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(e2e): bound Telegram credential setup · openclaw/open...
vincentkoc · 2026-05-27 · via Recent Commits to openclaw:main

@@ -1,12 +1,12 @@

11

#!/usr/bin/env -S node --import tsx

223-

import { spawn } from "node:child_process";

43

import { createHash } from "node:crypto";

54

import { copyFile, mkdir, mkdtemp, readFile, rm, unlink, writeFile } from "node:fs/promises";

65

import { tmpdir } from "node:os";

76

import path from "node:path";

87

import { pathToFileURL } from "node:url";

98

import { normalizeCredentialPayloadForKind } from "../../qa/convex-credential-broker/convex/payload-validation.js";

9+

import { fetchJsonWithTimeout, runCommand } from "./telegram-user-credential-io.ts";

1010

import { expandHome, writePrivateJson } from "./telegram-user-credential-paths.ts";

11111212

type JsonObject = Record<string, unknown>;

@@ -17,6 +17,14 @@ const DEFAULT_BOT_CREDENTIALS_FILE =

1717

const DEFAULT_CONVEX_ENV_FILE = "~/.codex/skills/custom/telegram-e2e-bot-to-bot/convex.local.env";

1818

const CHUNKED_PAYLOAD_MARKER = "__openclawQaCredentialPayloadChunksV1";

1919

const TELEGRAM_USER_QA_CREDENTIAL_KIND = "telegram-user";

20+

const COMMAND_TIMEOUT_MS = optionalPositiveInteger(

21+

process.env.OPENCLAW_TELEGRAM_USER_CREDENTIAL_COMMAND_TIMEOUT_MS?.trim(),

22+

120_000,

23+

);

24+

const BROKER_TIMEOUT_MS = optionalPositiveInteger(

25+

process.env.OPENCLAW_TELEGRAM_USER_CREDENTIAL_BROKER_TIMEOUT_MS?.trim(),

26+

30_000,

27+

);

20282129

function usage(): never {

2230

throw new Error(

@@ -162,32 +170,6 @@ async function tgzBase64(path: string) {

162170

return (await readFile(path)).toString("base64");

163171

}

164172165-

function runCommand(command: string, args: string[], cwd?: string) {

166-

return new Promise<void>((resolve, reject) => {

167-

const child = spawn(command, args, {

168-

cwd,

169-

stdio: ["ignore", "pipe", "pipe"],

170-

});

171-

let stdout = "";

172-

let stderr = "";

173-

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

174-

stdout += chunk.toString();

175-

});

176-

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

177-

stderr += chunk.toString();

178-

});

179-

child.on("error", reject);

180-

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

181-

if (code === 0) {

182-

resolve();

183-

return;

184-

}

185-

const detail = signal ? `signal ${signal}` : `exit code ${code ?? "unknown"}`;

186-

reject(new Error(`${command} ${args.join(" ")} failed with ${detail}\n${stdout}${stderr}`));

187-

});

188-

});

189-

}

190-191173

function joinBrokerEndpoint(siteUrl: string, endpoint: string) {

192174

const normalized = siteUrl.replace(/\/+$/u, "");

193175

return `${normalized}/qa-credentials/v1/${endpoint}`;

@@ -210,15 +192,19 @@ async function postBroker(params: {

210192

siteUrl: string;

211193

token: string;

212194

}) {

213-

const response = await fetch(joinBrokerEndpoint(params.siteUrl, params.action), {

214-

method: "POST",

215-

headers: {

216-

authorization: `Bearer ${params.token}`,

217-

"content-type": "application/json",

195+

const { payload, response } = await fetchJsonWithTimeout({

196+

url: joinBrokerEndpoint(params.siteUrl, params.action),

197+

label: `credential broker ${params.action}`,

198+

timeoutMs: BROKER_TIMEOUT_MS,

199+

init: {

200+

method: "POST",

201+

headers: {

202+

authorization: `Bearer ${params.token}`,

203+

"content-type": "application/json",

204+

},

205+

body: JSON.stringify(params.body),

218206

},

219-

body: JSON.stringify(params.body),

220207

});

221-

const payload = (await response.json()) as JsonObject;

222208

if (!response.ok) {

223209

assertBrokerSuccess(payload, params.action);

224210

throw new Error(`${params.action} failed with HTTP ${response.status}.`);

@@ -371,29 +357,36 @@ async function createTelegramUserPayload(opts: Map<string, string>) {

371357

const tdlibArchive = path.join(tempRoot, "tdlib.tgz");

372358

const desktopArchive = path.join(tempRoot, "desktop-tdata.tgz");

373359

try {

374-

await runCommand("tar", ["-C", userDriverDir, "-czf", tdlibArchive, "db", "files"]);

360+

await runCommand("tar", ["-C", userDriverDir, "-czf", tdlibArchive, "db", "files"], undefined, {

361+

timeoutMs: COMMAND_TIMEOUT_MS,

362+

});

375363

if (desktopTdataArchiveInput) {

376364

await copyFile(expandHome(desktopTdataArchiveInput), desktopArchive);

377365

} else {

378-

await runCommand("tar", [

379-

"-C",

380-

path.dirname(expandHome(desktopTdataDir!)),

381-

"--exclude",

382-

"tdata/countries",

383-

"--exclude",

384-

"tdata/dictionaries",

385-

"--exclude",

386-

"tdata/dumps",

387-

"--exclude",

388-

"tdata/emoji",

389-

"--exclude",

390-

"tdata/user_data",

391-

"--exclude",

392-

"tdata/working",

393-

"-czf",

394-

desktopArchive,

395-

"tdata",

396-

]);

366+

await runCommand(

367+

"tar",

368+

[

369+

"-C",

370+

path.dirname(expandHome(desktopTdataDir!)),

371+

"--exclude",

372+

"tdata/countries",

373+

"--exclude",

374+

"tdata/dictionaries",

375+

"--exclude",

376+

"tdata/dumps",

377+

"--exclude",

378+

"tdata/emoji",

379+

"--exclude",

380+

"tdata/user_data",

381+

"--exclude",

382+

"tdata/working",

383+

"-czf",

384+

desktopArchive,

385+

"tdata",

386+

],

387+

undefined,

388+

{ timeoutMs: COMMAND_TIMEOUT_MS },

389+

);

397390

}

398391399392

const payload = parseTelegramUserQaCredentialPayload({

@@ -461,8 +454,12 @@ async function restoreTelegramUserPayload(params: {

461454

throw new Error("Telegram Desktop archive SHA-256 mismatch.");

462455

}

463456464-

await runCommand("tar", ["-C", expandHome(userDriverDir), "-xzf", tdlibArchive]);

465-

await runCommand("tar", ["-C", expandHome(desktopWorkdir), "-xzf", desktopArchive]);

457+

await runCommand("tar", ["-C", expandHome(userDriverDir), "-xzf", tdlibArchive], undefined, {

458+

timeoutMs: COMMAND_TIMEOUT_MS,

459+

});

460+

await runCommand("tar", ["-C", expandHome(desktopWorkdir), "-xzf", desktopArchive], undefined, {

461+

timeoutMs: COMMAND_TIMEOUT_MS,

462+

});

466463

await writePrivateJson(`${expandHome(userDriverDir)}/config.local.json`, {

467464

apiId: Number(requireString(payload, "telegramApiId")),

468465

apiHash: requireString(payload, "telegramApiHash"),