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

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

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(release): bound ClawHub trusted publisher reads · ope...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

@@ -2,6 +2,7 @@

22

import { execFileSync } from "node:child_process";

33

import { resolve } from "node:path";

44

import { validateExternalCodePluginPackageJson } from "../../packages/plugin-package-contract/src/index.ts";

5+

import { readBoundedResponseText } from "./bounded-response.ts";

56

import {

67

collectExtensionPackageJsonCandidates,

78

collectChangedPathsFromGitRange,

@@ -86,6 +87,8 @@ type ClawHubPublishablePluginPackageFilters = {

8687

};

87888889

const CLAWHUB_DEFAULT_REGISTRY = "https://clawhub.ai";

90+

const CLAWHUB_REQUEST_TIMEOUT_MS = 30_000;

91+

const CLAWHUB_RESPONSE_BODY_MAX_BYTES = 64 * 1024;

8992

const OPENCLAW_PLUGIN_CLAWHUB_REPOSITORY = "openclaw/openclaw";

9093

const OPENCLAW_PLUGIN_CLAWHUB_WORKFLOW_FILENAME = "plugin-clawhub-release.yml";

9194

const SAFE_EXTENSION_ID_RE = /^[a-z0-9][a-z0-9._-]*$/;

@@ -114,6 +117,58 @@ function getRegistryBaseUrl(explicit?: string) {

114117

);

115118

}

116119120+

type ClawHubRequestOptions = {

121+

fetchImpl?: typeof fetch;

122+

requestTimeoutMs?: number;

123+

};

124+125+

async function fetchClawHubRequest(

126+

url: URL,

127+

options: ClawHubRequestOptions = {},

128+

): Promise<{

129+

clearTimeout: () => void;

130+

response: Response;

131+

signal: AbortSignal;

132+

timeoutPromise: Promise<never>;

133+

}> {

134+

const timeoutMs = options.requestTimeoutMs ?? CLAWHUB_REQUEST_TIMEOUT_MS;

135+

const controller = new AbortController();

136+

const timeoutError = Object.assign(

137+

new Error(`ClawHub request timed out after ${timeoutMs}ms: ${url.href}`),

138+

{ code: "ETIMEDOUT" },

139+

);

140+

let timeout: ReturnType<typeof setTimeout> | undefined;

141+

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

142+

timeout = setTimeout(() => {

143+

controller.abort(timeoutError);

144+

reject(timeoutError);

145+

}, timeoutMs);

146+

timeout.unref?.();

147+

});

148+149+

try {

150+

const response = await Promise.race([

151+

(options.fetchImpl ?? fetch)(url, {

152+

method: "GET",

153+

headers: {

154+

Accept: "application/json",

155+

},

156+

signal: controller.signal,

157+

}),

158+

timeoutPromise,

159+

]);

160+

return {

161+

clearTimeout: () => clearTimeout(timeout),

162+

response,

163+

signal: controller.signal,

164+

timeoutPromise,

165+

};

166+

} catch (error) {

167+

clearTimeout(timeout);

168+

throw error;

169+

}

170+

}

171+117172

function formatClawHubPackageArtifactName(

118173

plugin: Pick<PublishablePluginPackage, "packageName" | "version">,

119174

) {

@@ -346,98 +401,116 @@ async function isPluginVersionPublishedOnClawHub(

346401

options: {

347402

fetchImpl?: typeof fetch;

348403

registryBaseUrl?: string;

404+

requestTimeoutMs?: number;

349405

} = {},

350406

): Promise<boolean> {

351-

const fetchImpl = options.fetchImpl ?? fetch;

352407

const url = new URL(

353408

`/api/v1/packages/${encodeURIComponent(packageName)}/versions/${encodeURIComponent(version)}`,

354409

getRegistryBaseUrl(options.registryBaseUrl),

355410

);

356-

const response = await fetchImpl(url, {

357-

method: "GET",

358-

headers: {

359-

Accept: "application/json",

360-

},

411+

const request = await fetchClawHubRequest(url, {

412+

fetchImpl: options.fetchImpl,

413+

requestTimeoutMs: options.requestTimeoutMs,

361414

});

415+

const { response } = request;

362416363-

if (response.status === 404) {

364-

return false;

365-

}

366-

if (response.ok) {

367-

return true;

368-

}

417+

try {

418+

if (response.status === 404) {

419+

return false;

420+

}

421+

if (response.ok) {

422+

return true;

423+

}

369424370-

throw new Error(

371-

`Failed to query ClawHub for ${packageName}@${version}: ${response.status} ${response.statusText}`,

372-

);

425+

throw new Error(

426+

`Failed to query ClawHub for ${packageName}@${version}: ${response.status} ${response.statusText}`,

427+

);

428+

} finally {

429+

request.clearTimeout();

430+

}

373431

}

374432375433

async function doesClawHubPackageExist(

376434

packageName: string,

377435

options: {

378436

fetchImpl?: typeof fetch;

379437

registryBaseUrl?: string;

438+

requestTimeoutMs?: number;

380439

} = {},

381440

): Promise<boolean> {

382-

const fetchImpl = options.fetchImpl ?? fetch;

383441

const url = new URL(

384442

`/api/v1/packages/${encodeURIComponent(packageName)}`,

385443

getRegistryBaseUrl(options.registryBaseUrl),

386444

);

387-

const response = await fetchImpl(url, {

388-

method: "GET",

389-

headers: {

390-

Accept: "application/json",

391-

},

445+

const request = await fetchClawHubRequest(url, {

446+

fetchImpl: options.fetchImpl,

447+

requestTimeoutMs: options.requestTimeoutMs,

392448

});

449+

const { response } = request;

393450394-

if (response.status === 404) {

395-

return false;

396-

}

397-

if (!response.ok) {

398-

throw new Error(

399-

`Failed to query ClawHub package ${packageName}: ${response.status} ${response.statusText}`,

400-

);

401-

}

451+

try {

452+

if (response.status === 404) {

453+

return false;

454+

}

455+

if (!response.ok) {

456+

throw new Error(

457+

`Failed to query ClawHub package ${packageName}: ${response.status} ${response.statusText}`,

458+

);

459+

}

402460403-

return true;

461+

return true;

462+

} finally {

463+

request.clearTimeout();

464+

}

404465

}

405466406467

async function hasClawHubTrustedPublisher(

407468

packageName: string,

408469

options: {

409470

fetchImpl?: typeof fetch;

410471

registryBaseUrl?: string;

472+

requestTimeoutMs?: number;

411473

} = {},

412474

): Promise<boolean> {

413-

const fetchImpl = options.fetchImpl ?? fetch;

414475

const url = new URL(

415476

`/api/v1/packages/${encodeURIComponent(packageName)}/trusted-publisher`,

416477

getRegistryBaseUrl(options.registryBaseUrl),

417478

);

418-

const response = await fetchImpl(url, {

419-

method: "GET",

420-

headers: {

421-

Accept: "application/json",

422-

},

479+

const request = await fetchClawHubRequest(url, {

480+

fetchImpl: options.fetchImpl,

481+

requestTimeoutMs: options.requestTimeoutMs,

423482

});

483+

const { response } = request;

424484425-

if (!response.ok) {

426-

throw new Error(

427-

`Failed to query ClawHub trusted publisher for ${packageName}: ${response.status} ${response.statusText}`,

485+

try {

486+

if (!response.ok) {

487+

throw new Error(

488+

`Failed to query ClawHub trusted publisher for ${packageName}: ${response.status} ${response.statusText}`,

489+

);

490+

}

491+492+

let trustedPublisherDetail: ClawHubTrustedPublisherDetail;

493+

const text = await readBoundedResponseText(

494+

response,

495+

`ClawHub trusted publisher ${packageName}`,

496+

CLAWHUB_RESPONSE_BODY_MAX_BYTES,

497+

{

498+

signal: request.signal,

499+

timeoutPromise: request.timeoutPromise,

500+

},

428501

);

429-

}

502+

try {

503+

trustedPublisherDetail = JSON.parse(text) as ClawHubTrustedPublisherDetail;

504+

} catch (error) {

505+

throw new Error(`Failed to parse ClawHub trusted publisher ${packageName} response.`, {

506+

cause: error,

507+

});

508+

}

430509431-

let trustedPublisherDetail: ClawHubTrustedPublisherDetail;

432-

try {

433-

trustedPublisherDetail = (await response.json()) as ClawHubTrustedPublisherDetail;

434-

} catch (error) {

435-

throw new Error(`Failed to parse ClawHub trusted publisher ${packageName} response.`, {

436-

cause: error,

437-

});

510+

return isOpenClawPluginTrustedPublisher(trustedPublisherDetail.trustedPublisher);

511+

} finally {

512+

request.clearTimeout();

438513

}

439-440-

return isOpenClawPluginTrustedPublisher(trustedPublisherDetail.trustedPublisher);

441514

}

442515443516

function isOpenClawPluginTrustedPublisher(value: unknown): boolean {

@@ -470,6 +543,7 @@ export async function collectPluginClawHubReleasePlan(params?: {

470543

gitRange?: GitRangeSelection;

471544

registryBaseUrl?: string;

472545

fetchImpl?: typeof fetch;

546+

requestTimeoutMs?: number;

473547

}): Promise<PluginReleasePlan> {

474548

const rootDir = params?.rootDir;

475549

const selection = params?.selection ?? [];

@@ -506,17 +580,20 @@ export async function collectPluginClawHubReleasePlan(params?: {

506580

const packageExists = await doesClawHubPackageExist(plugin.packageName, {

507581

registryBaseUrl: params?.registryBaseUrl,

508582

fetchImpl: params?.fetchImpl,

583+

requestTimeoutMs: params?.requestTimeoutMs,

509584

});

510585

const hasTrustedPublisher = packageExists

511586

? await hasClawHubTrustedPublisher(plugin.packageName, {

512587

registryBaseUrl: params?.registryBaseUrl,

513588

fetchImpl: params?.fetchImpl,

589+

requestTimeoutMs: params?.requestTimeoutMs,

514590

})

515591

: false;

516592

const alreadyPublished = packageExists

517593

? await isPluginVersionPublishedOnClawHub(plugin.packageName, plugin.version, {

518594

registryBaseUrl: params?.registryBaseUrl,

519595

fetchImpl: params?.fetchImpl,

596+

requestTimeoutMs: params?.requestTimeoutMs,

520597

})

521598

: false;

522599