feat: v0.8.2 安全纵深补全 · 协议保真 · 断链修复 — 图片SSRF/根MEMORY.md保护根治 · Anthropic thinking回传+pause_turn续传 · 2523 用例全量回归 + E2E 扩充
CI / 类型检查 + Lint + 单元测试 (push) Failing after 9m45s
CI / 全量测试 (Electron ABI) (push) Failing after 6m28s
CI / 产物编译验证 (push) Successful in 11m18s

This commit is contained in:
2026-09-08 14:30:27 +08:00
parent 69776e447f
commit 4cd6e997b5
86 changed files with 4303 additions and 956 deletions
+10 -11
View File
@@ -137,7 +137,11 @@ export class OllamaAdapter extends BaseAdapter {
while (true) {
// v0.7.4 P1-2: 空闲超时 — 本地模型加载/推理期间服务器可能长时间不推数据,
// 共享辅助在连续 60s 无数据时抛 SseUpstreamError(504) 进重试通道
const { done, value } = await readStreamChunkWithIdleTimeout(reader);
const { done, value } = await readStreamChunkWithIdleTimeout(
reader,
60_000,
this.getExternalAbortSignal(),
);
if (done) break;
buffer += decoder.decode(value, { stream: true });
@@ -578,16 +582,11 @@ export class OllamaAdapter extends BaseAdapter {
*/
private async resolveImageToBase64(url: string): Promise<string> {
try {
// 审查修复: 使用基类 fetchWithTimeout 合并 externalAbortSignal 和 30s 超时,
// 避免用户中断时图片下载最多阻塞 30s×NexternalAbortSignal 是 BaseAdapter 的
// private 属性,子类无法直接访问,故复用已合并 signal 的 fetchWithTimeout
// 该方法同时处理了 listener 泄漏问题)
const res = await this.fetchWithTimeout(url, {}, 30_000);
if (!res.ok) {
throw new Error(`HTTP ${res.status}`);
}
const buf = Buffer.from(await res.arrayBuffer());
return buf.toString('base64');
// v0.8.2 P0-1: 图片 URL 下载收口到 SSRF 安全通道(此前直连 fetch 无校验、
// 无大小上限;现含 DNS pinning/重定向复检/10MB 上限/类型白名单),外部
// 中断信号由 BaseAdapter.fetchImageAsBase64 透传。
const { base64 } = await this.fetchImageAsBase64(url, 30_000);
return base64;
} catch (error) {
log.warn(
`[Ollama] Failed to download image ${url.slice(0, 100)}: ${(error as Error).message}`,