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

推荐订阅源

I
InfoQ
博客园_首页
美团技术团队
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
J
Java Code Geeks
T
Tailwind CSS Blog
Jina AI
Jina AI
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
爱范儿
爱范儿
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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(dev): bound gh-read API waits · openclaw/openclaw@5fb...
vincentkoc · 2026-05-27 · via Recent Commits to openclaw:main

@@ -2,12 +2,14 @@ import { execFileSync, spawnSync } from "node:child_process";

22

import { createPrivateKey, createSign } from "node:crypto";

33

import { readFileSync } from "node:fs";

44

import { pathToFileURL } from "node:url";

5+

import { parseStrictIntegerOption } from "./lib/dev-tooling-safety.ts";

5667

const APP_ID_ENV = "OPENCLAW_GH_READ_APP_ID";

78

const KEY_FILE_ENV = "OPENCLAW_GH_READ_PRIVATE_KEY_FILE";

89

const INSTALLATION_ID_ENV = "OPENCLAW_GH_READ_INSTALLATION_ID";

910

const PERMISSIONS_ENV = "OPENCLAW_GH_READ_PERMISSIONS";

1011

const API_VERSION = "2022-11-28";

12+

const DEFAULT_GITHUB_FETCH_TIMEOUT_MS = 30_000;

1113

const DEFAULT_READ_PERMISSION_KEYS = [

1214

"actions",

1315

"checks",

@@ -32,6 +34,11 @@ type AccessTokenResponse = {

3234

token: string;

3335

};

343637+

type GitHubJsonOptions = {

38+

fetchImpl?: typeof fetch;

39+

timeoutMs?: number;

40+

};

41+3542

export function parseRepoArg(args: string[]): string | null {

3643

for (let i = 0; i < args.length; i += 1) {

3744

const arg = args[i];

@@ -91,6 +98,15 @@ export function buildReadPermissions(

9198

return permissions;

9299

}

93100101+

export function resolveGitHubFetchTimeoutMs(raw = process.env.OPENCLAW_GH_READ_FETCH_TIMEOUT_MS) {

102+

return parseStrictIntegerOption({

103+

fallback: DEFAULT_GITHUB_FETCH_TIMEOUT_MS,

104+

label: "OPENCLAW_GH_READ_FETCH_TIMEOUT_MS",

105+

min: 1,

106+

raw,

107+

});

108+

}

109+94110

function isMainModule() {

95111

const entry = process.argv[1];

96112

return entry ? import.meta.url === pathToFileURL(entry).href : false;

@@ -151,32 +167,65 @@ function createAppJwt(appId: string, privateKeyPem: string) {

151167

return `${signingInput}.${base64UrlEncode(signature)}`;

152168

}

153169154-

async function githubJson<T>(

170+

async function withGitHubFetchTimeout<T>(

171+

label: string,

172+

timeoutMs: number,

173+

run: (signal: AbortSignal) => Promise<T>,

174+

): Promise<T> {

175+

const controller = new AbortController();

176+

let timeout: ReturnType<typeof setTimeout> | undefined;

177+

const timeoutPromise = new Promise<T>((_resolve, reject) => {

178+

timeout = setTimeout(() => {

179+

const error = new Error(`${label} exceeded timeout of ${timeoutMs}ms`);

180+

reject(error);

181+

controller.abort(error);

182+

}, timeoutMs);

183+

});

184+

try {

185+

return await Promise.race([run(controller.signal), timeoutPromise]);

186+

} finally {

187+

if (timeout) {

188+

clearTimeout(timeout);

189+

}

190+

}

191+

}

192+193+

export async function githubJson<T>(

155194

path: string,

156195

bearerToken: string,

157196

init?: {

158197

method?: "GET" | "POST";

159198

body?: unknown;

160199

},

200+

options: GitHubJsonOptions = {},

161201

): Promise<T> {

162-

const response = await fetch(`https://api.github.com${path}`, {

163-

method: init?.method ?? "GET",

164-

headers: {

165-

Accept: "application/vnd.github+json",

166-

Authorization: `Bearer ${bearerToken}`,

167-

"Content-Type": "application/json",

168-

"User-Agent": "openclaw-gh-read",

169-

"X-GitHub-Api-Version": API_VERSION,

170-

},

171-

body: init?.body === undefined ? undefined : JSON.stringify(init.body),

172-

});

202+

const fetchImpl = options.fetchImpl ?? fetch;

203+

const timeoutMs = options.timeoutMs ?? resolveGitHubFetchTimeoutMs();

204+

return await withGitHubFetchTimeout(

205+

`GitHub API ${init?.method ?? "GET"} ${path}`,

206+

timeoutMs,

207+

async (signal) => {

208+

const response = await fetchImpl(`https://api.github.com${path}`, {

209+

method: init?.method ?? "GET",

210+

headers: {

211+

Accept: "application/vnd.github+json",

212+

Authorization: `Bearer ${bearerToken}`,

213+

"Content-Type": "application/json",

214+

"User-Agent": "openclaw-gh-read",

215+

"X-GitHub-Api-Version": API_VERSION,

216+

},

217+

body: init?.body === undefined ? undefined : JSON.stringify(init.body),

218+

signal,

219+

});

173220174-

if (!response.ok) {

175-

const text = await response.text();

176-

fail(`${init?.method ?? "GET"} ${path} failed (${response.status}): ${text}`);

177-

}

221+

if (!response.ok) {

222+

const text = await response.text();

223+

fail(`${init?.method ?? "GET"} ${path} failed (${response.status}): ${text}`);

224+

}

178225179-

return (await response.json()) as T;

226+

return (await response.json()) as T;

227+

},

228+

);

180229

}

181230182231

async function resolveInstallation(