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

推荐订阅源

J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
D
Docker
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
量子位
有赞技术团队
有赞技术团队
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
B
Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
月光博客
月光博客

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(agents): forward ACP spawn attachments · openclaw/ope...
zhangguiping · 2026-05-30 · via Recent Commits to openclaw:main

@@ -28,13 +28,18 @@ export function decodeStrictBase64(value: string, maxDecodedBytes: number): Buff

2828

return decoded;

2929

}

303031-

type SubagentInlineAttachment = {

31+

export type SubagentInlineAttachment = {

3232

name: string;

3333

content: string;

3434

encoding?: "utf8" | "base64";

3535

mimeType?: string;

3636

};

373738+

type AcpInlineImageAttachment = {

39+

mediaType: string;

40+

data: string;

41+

};

42+3843

type AttachmentLimits = {

3944

enabled: boolean;

4045

maxTotalBytes: number;

@@ -94,6 +99,120 @@ function resolveAttachmentLimits(config: OpenClawConfig): AttachmentLimits {

9499

};

95100

}

96101102+

export function resolveAcpSessionsSpawnImageAttachments(params: {

103+

config: OpenClawConfig;

104+

attachments?: SubagentInlineAttachment[];

105+

}):

106+

| { status: "ok"; attachments: AcpInlineImageAttachment[] }

107+

| { status: "forbidden"; error: string }

108+

| { status: "error"; error: string }

109+

| null {

110+

const requestedAttachments = Array.isArray(params.attachments) ? params.attachments : [];

111+

if (requestedAttachments.length === 0) {

112+

return null;

113+

}

114+115+

const limits = resolveAttachmentLimits(params.config);

116+

if (!limits.enabled) {

117+

return {

118+

status: "forbidden",

119+

error:

120+

"attachments are disabled for sessions_spawn (enable tools.sessions_spawn.attachments.enabled)",

121+

};

122+

}

123+

if (requestedAttachments.length > limits.maxFiles) {

124+

return {

125+

status: "error",

126+

error: `attachments_file_count_exceeded (maxFiles=${limits.maxFiles})`,

127+

};

128+

}

129+130+

const fail = (error: string): never => {

131+

throw new Error(error);

132+

};

133+134+

try {

135+

const seen = new Set<string>();

136+

const attachments: AcpInlineImageAttachment[] = [];

137+

let totalBytes = 0;

138+139+

for (const raw of requestedAttachments) {

140+

const name = normalizeOptionalString(raw?.name) ?? "";

141+

const contentVal = typeof raw?.content === "string" ? raw.content : "";

142+

const encodingRaw = normalizeOptionalString(raw?.encoding) ?? "utf8";

143+

const encoding = encodingRaw === "base64" ? "base64" : "utf8";

144+

const mimeType = normalizeOptionalString(raw?.mimeType) ?? "";

145+146+

if (!name) {

147+

fail("attachments_invalid_name (empty)");

148+

}

149+

if (name.includes("/") || name.includes("\\") || name.includes("\u0000")) {

150+

fail(`attachments_invalid_name (${name})`);

151+

}

152+

if (

153+

Array.from(name).some((char) => {

154+

const code = char.codePointAt(0) ?? 0;

155+

return code < 0x20 || code === 0x7f;

156+

})

157+

) {

158+

fail(`attachments_invalid_name (${name})`);

159+

}

160+

if (name === "." || name === ".." || name === ".manifest.json") {

161+

fail(`attachments_invalid_name (${name})`);

162+

}

163+

if (seen.has(name)) {

164+

fail(`attachments_duplicate_name (${name})`);

165+

}

166+

seen.add(name);

167+

if (!mimeType.startsWith("image/")) {

168+

fail(`attachments_unsupported_for_acp (name=${name} mimeType=${mimeType || "unknown"})`);

169+

}

170+171+

let buf: Buffer;

172+

if (encoding === "base64") {

173+

const strictBuf = decodeStrictBase64(contentVal, limits.maxFileBytes);

174+

if (strictBuf === null) {

175+

throw new Error("attachments_invalid_base64_or_too_large");

176+

}

177+

buf = strictBuf;

178+

} else {

179+

const estimatedBytes = Buffer.byteLength(contentVal, "utf8");

180+

if (estimatedBytes > limits.maxFileBytes) {

181+

fail(

182+

`attachments_file_bytes_exceeded (name=${name} bytes=${estimatedBytes} maxFileBytes=${limits.maxFileBytes})`,

183+

);

184+

}

185+

buf = Buffer.from(contentVal, "utf8");

186+

}

187+188+

const bytes = buf.byteLength;

189+

if (bytes > limits.maxFileBytes) {

190+

fail(

191+

`attachments_file_bytes_exceeded (name=${name} bytes=${bytes} maxFileBytes=${limits.maxFileBytes})`,

192+

);

193+

}

194+

totalBytes += bytes;

195+

if (totalBytes > limits.maxTotalBytes) {

196+

fail(

197+

`attachments_total_bytes_exceeded (totalBytes=${totalBytes} maxTotalBytes=${limits.maxTotalBytes})`,

198+

);

199+

}

200+201+

attachments.push({

202+

mediaType: mimeType,

203+

data: buf.toString("base64"),

204+

});

205+

}

206+207+

return { status: "ok", attachments };

208+

} catch (err) {

209+

return {

210+

status: "error",

211+

error: err instanceof Error ? err.message : "attachments_materialization_failed",

212+

};

213+

}

214+

}

215+97216

export async function materializeSubagentAttachments(params: {

98217

config: OpenClawConfig;

99218

targetAgentId: string;