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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
罗磊的独立博客
量子位
Jina AI
Jina AI
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
美团技术团队
雷峰网
雷峰网
爱范儿
爱范儿
S
SegmentFault 最新的问题
小众软件
小众软件
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

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(gateway): bound artifact transcript scans · openclaw/...
vincentkoc · 2026-05-28 · via Recent Commits to openclaw:main

@@ -43,6 +43,11 @@ type ArtifactQuery = {

4343

agentId?: string;

4444

};

454546+

type ArtifactCollectionOptions = {

47+

includeDownloadData?: boolean;

48+

downloadArtifactId?: string;

49+

};

50+4651

type ResolvedArtifactSession = {

4752

sessionKey: string;

4853

agentId?: string;

@@ -137,19 +142,50 @@ function mimeFromDataUrl(value: string): string | undefined {

137142

}

138143139144

function base64FromDataUrl(value: string): string | undefined {

140-

const match = /^data:[^,]*;base64,(.*)$/is.exec(value.trim());

141-

return match?.[1]?.replace(/\s+/g, "");

145+

const trimmed = value.trim();

146+

const commaIndex = trimmed.indexOf(",");

147+

if (commaIndex < 0 || trimmed.slice(0, 5).toLowerCase() !== "data:") {

148+

return undefined;

149+

}

150+

const metadata = trimmed.slice(0, commaIndex).toLowerCase();

151+

if (!metadata.includes(";base64")) {

152+

return undefined;

153+

}

154+

return trimmed.slice(commaIndex + 1).replace(/\s+/g, "");

155+

}

156+157+

function isBase64Whitespace(value: string): boolean {

158+

return value === " " || value === "\n" || value === "\r" || value === "\t";

142159

}

143160144161

function estimateBase64Size(value: string | undefined): number | undefined {

145162

if (!value) {

146163

return undefined;

147164

}

148-

try {

149-

return Buffer.from(value, "base64").byteLength;

150-

} catch {

165+

let encodedLength = 0;

166+

let padding = 0;

167+

for (let index = 0; index < value.length; index += 1) {

168+

const char = value[index];

169+

if (!char || isBase64Whitespace(char)) {

170+

continue;

171+

}

172+

encodedLength += 1;

173+

}

174+

for (let index = value.length - 1; index >= 0 && padding < 2; index -= 1) {

175+

const char = value[index];

176+

if (!char || isBase64Whitespace(char)) {

177+

continue;

178+

}

179+

if (char === "=") {

180+

padding += 1;

181+

continue;

182+

}

183+

break;

184+

}

185+

if (encodedLength === 0) {

151186

return undefined;

152187

}

188+

return Math.max(0, Math.floor((encodedLength * 3) / 4) - padding);

153189

}

154190155191

function mediaUrlValue(value: unknown): string | undefined {

@@ -213,7 +249,10 @@ function resolveMessageTaskId(message: Record<string, unknown>): string | undefi

213249

);

214250

}

215251216-

function resolveBlockDownload(block: Record<string, unknown>): {

252+

function resolveBlockDownload(

253+

block: Record<string, unknown>,

254+

opts: { includeData: boolean },

255+

): {

217256

mode: ArtifactDownloadMode;

218257

data?: string;

219258

url?: string;

@@ -251,7 +290,7 @@ function resolveBlockDownload(block: Record<string, unknown>): {

251290

? Math.floor(explicitSize)

252291

: estimateBase64Size(base64);

253292

if (base64) {

254-

return { mode: "bytes", data: base64, mimeType, sizeBytes };

293+

return { mode: "bytes", ...(opts.includeData ? { data: base64 } : {}), mimeType, sizeBytes };

255294

}

256295

if (remoteUrl) {

257296

return { mode: "url", url: remoteUrl, mimeType, sizeBytes };

@@ -282,6 +321,8 @@ export function collectArtifactsFromMessages(params: {

282321

sessionKey: string;

283322

runId?: string;

284323

taskId?: string;

324+

includeDownloadData?: boolean;

325+

downloadArtifactId?: string;

285326

}): ArtifactRecord[] {

286327

const artifacts: ArtifactRecord[] = [];

287328

let messageFallbackSeq = 0;

@@ -299,6 +340,8 @@ function collectArtifactsFromMessage(params: {

299340

sessionKey: string;

300341

runId?: string;

301342

taskId?: string;

343+

includeDownloadData?: boolean;

344+

downloadArtifactId?: string;

302345

}): void {

303346

const msg = asOptionalRecord(params.message);

304347

if (!msg) {

@@ -326,15 +369,19 @@ function collectArtifactsFromMessage(params: {

326369

asNonEmptyString(block.filename) ??

327370

asNonEmptyString(block.alt) ??

328371

`${type} ${params.artifacts.length + 1}`;

329-

const download = resolveBlockDownload(block);

372+

const id = artifactId({

373+

sessionKey: params.sessionKey,

374+

messageSeq,

375+

contentIndex,

376+

title,

377+

type,

378+

});

379+

const includeData = params.downloadArtifactId

380+

? params.downloadArtifactId === id

381+

: params.includeDownloadData !== false;

382+

const download = resolveBlockDownload(block, { includeData });

330383

const summary: ArtifactRecord = {

331-

id: artifactId({

332-

sessionKey: params.sessionKey,

333-

messageSeq,

334-

contentIndex,

335-

title,

336-

type,

337-

}),

384+

id,

338385

type,

339386

title,

340387

...(download.mimeType ? { mimeType: download.mimeType } : {}),

@@ -397,6 +444,7 @@ function resolveQuerySession(

397444

async function loadArtifacts(

398445

query: ArtifactQuery,

399446

cfg?: OpenClawConfig,

447+

opts: ArtifactCollectionOptions = {},

400448

): Promise<{ artifacts: ArtifactRecord[]; sessionKey?: string }> {

401449

const resolved = resolveQuerySession(query, cfg);

402450

if (!resolved) {

@@ -425,11 +473,14 @@ async function loadArtifacts(

425473

sessionKey,

426474

runId: query.runId,

427475

taskId: query.taskId,

476+

includeDownloadData: opts.includeDownloadData,

477+

downloadArtifactId: opts.downloadArtifactId,

428478

});

429479

},

430480

{

431481

mode: "full",

432482

reason: "artifact query transcript scan",

483+

cache: "skip",

433484

},

434485

);

435486

return {

@@ -456,11 +507,12 @@ function requireQueryable(params: ArtifactQuery, respond: RespondFn): boolean {

456507

async function findArtifact(

457508

params: ArtifactsGetParams,

458509

cfg?: OpenClawConfig,

510+

opts: ArtifactCollectionOptions = {},

459511

): Promise<{

460512

artifact?: ArtifactRecord;

461513

sessionKey?: string;

462514

}> {

463-

const loaded = await loadArtifacts(params, cfg);

515+

const loaded = await loadArtifacts(params, cfg, opts);

464516

return {

465517

sessionKey: loaded.sessionKey,

466518

artifact: loaded.artifacts.find((artifact) => artifact.id === params.artifactId),

@@ -480,7 +532,9 @@ export const artifactsHandlers: GatewayRequestHandlers = {

480532

if (!requireQueryable(params, respond)) {

481533

return;

482534

}

483-

const { artifacts, sessionKey } = await loadArtifacts(params, context.getRuntimeConfig?.());

535+

const { artifacts, sessionKey } = await loadArtifacts(params, context.getRuntimeConfig?.(), {

536+

includeDownloadData: false,

537+

});

484538

if (!sessionKey && (params.runId || params.taskId)) {

485539

respond(

486540

false,

@@ -498,7 +552,9 @@ export const artifactsHandlers: GatewayRequestHandlers = {

498552

if (!requireQueryable(params, respond)) {

499553

return;

500554

}

501-

const { artifact } = await findArtifact(params, context.getRuntimeConfig?.());

555+

const { artifact } = await findArtifact(params, context.getRuntimeConfig?.(), {

556+

includeDownloadData: false,

557+

});

502558

if (!artifact) {

503559

respond(

504560

false,

@@ -520,7 +576,9 @@ export const artifactsHandlers: GatewayRequestHandlers = {

520576

if (!requireQueryable(params, respond)) {

521577

return;

522578

}

523-

const { artifact } = await findArtifact(params, context.getRuntimeConfig?.());

579+

const { artifact } = await findArtifact(params, context.getRuntimeConfig?.(), {

580+

downloadArtifactId: params.artifactId,

581+

});

524582

if (!artifact) {

525583

respond(

526584

false,