diff --git a/app/config.example.yml b/app/config.example.yml index cbd684d..32e25e6 100644 --- a/app/config.example.yml +++ b/app/config.example.yml @@ -42,7 +42,10 @@ terminal: fetch: timeout_ms: 30000 # 抓取总超时(ms),覆盖响应头到 body 读完 - max_bytes: 1048576 # 单次响应最多抓多少字节,超限即断开 + max_bytes: 1048576 # 单次响应最多抓多少字节,超限即断开(下载不占上下文,可宽松) + max_chars: 12000 # 返回给模型的默认字符上限(与下载上限解耦;超窗尾部提示 offset 续读) + max_chars_hard: 64000 # 模型显式传 max_chars 时的硬帽 + allow_private: false # SSRF 防护:false=拒抓解析到内网/回环地址的目标;确需抓内网服务才开 true agent: temperature: 1.0 # 采样温度 diff --git a/app/server/config.js b/app/server/config.js index 09b8bec..48c7fba 100644 --- a/app/server/config.js +++ b/app/server/config.js @@ -78,7 +78,11 @@ const DEFAULTS = { // 本配置文件内含密钥,只给 core 进程读,executor/wxbot 一律不挂不读。 terminal: { default_timeout_ms: 30000, max_output_chars: 10000 }, // fetch:timeout_ms 覆盖请求发出到 body 读完的全生命周期;max_bytes 为流式抓取字节上限(超限即断开)。 - fetch: { timeout_ms: 30000, max_bytes: 1048576 }, + // 下载与返回两上限解耦:下载不进上下文可宽松,返回默认收紧(max_chars),模型显式传 max_chars 时 + // 夹在 max_chars_hard 硬帽内;超窗尾部提示 offset,续读走 ctx.run 上的回合缓存不重抓。 + // allow_private=false 开 SSRF 防护:目标主机名解析到回环/私有/链路本地地址即拒绝(重定向逐跳复查); + // 确需抓内网服务再显式开 true(注意 DNS 重绑定属残余风险)。 + fetch: { timeout_ms: 30000, max_bytes: 1048576, max_chars: 12000, max_chars_hard: 64000, allow_private: false }, // auto_compress_tokens:本轮 In token 峰值 ≥ 此值时推送「自动压缩」提议(0=关)。 // auto_complete_ms:held(保持中)超过此时长自动收口为 completed(0=关)。key 非独占后 held 不占任何资源, // 收口是纯视觉动作:历史/绑定不动,再发言照常由 completed 分支续跑(见 engine.sweepHeldTimeouts)。 diff --git a/app/server/tools/definitions.json b/app/server/tools/definitions.json index 68e2297..681b1f6 100644 --- a/app/server/tools/definitions.json +++ b/app/server/tools/definitions.json @@ -90,7 +90,7 @@ "type": "function", "function": { "name": "fetch", - "description": "Fetches a URL and returns its content as Markdown. Only http and https are supported; if the scheme is omitted, https is assumed.\n\nHTML pages are converted to Markdown. JSON, XML, plain text, and Markdown responses are returned as-is. Binary responses are not returned — only their HTTP status, content-type, and size.\n\nThe response always starts with a line `HTTP `, followed by the body. Check the status line: a non-2xx status means the fetch did not succeed, even if body content is present.\n\nRequests are subject to a timeout, and oversized responses are truncated. Redirects are followed automatically.", + "description": "Fetches a URL and returns its content as Markdown. Only http and https are supported; if the scheme is omitted, https is assumed.\n\nHTML pages are converted to Markdown. JSON, XML, plain text, and Markdown responses are returned as-is. Binary responses are not returned — only their HTTP status, content-type, and size.\n\nThe response always starts with a line `HTTP `, followed by the body. Check the status line: a non-2xx status means the fetch did not succeed, even if body content is present.\n\nReturned text is capped per call (default is modest; raise one call with `max_chars` up to a hard cap). When truncated, the tail hint gives the total length and the `offset` to continue from — re-call with that `offset` to page through WITHOUT re-downloading. Most pages fit in the first window; only page further when you actually need more.\n\nTargets that resolve to private/loopback addresses are refused (SSRF guard). Redirects are followed up to 5 hops, each hop checked.", "parameters": { "type": "object", "required": [ @@ -100,6 +100,17 @@ "url": { "type": "string", "description": "The URL to fetch. Must be http or https; if no scheme is given, https is assumed." + }, + "offset": { + "type": "integer", + "minimum": 0, + "default": 0, + "description": "Character offset into the converted page body, for continuing a truncated fetch. Use the offset value given in the previous truncation hint. Requires no re-download." + }, + "max_chars": { + "type": "integer", + "minimum": 1, + "description": "Max characters to return for this call. Optional; raise only when the default window clearly cut off content you need. Values above the hard cap are clamped." } } } diff --git a/app/server/tools/executor.js b/app/server/tools/executor.js index 458bd7f..4867136 100644 --- a/app/server/tools/executor.js +++ b/app/server/tools/executor.js @@ -2,6 +2,8 @@ // 工具名与参数 schema 来自 definitions.json;MCP 工具不在这里,见 ../mcp.js。 const fs = require('fs'); const path = require('path'); +const net = require('net'); // fetch SSRF 防护:IP 字面量/解析结果判私网 +const dns = require('dns').promises; // 同上:主机名 → IP 后统一判定 const fsp = require('fs').promises; const { spawn } = require('child_process'); const mcp = require('../mcp'); @@ -557,7 +559,9 @@ function killGroup(child) { } // fetch:抓取并转 Markdown。超时/取消覆盖到 body 读取完成(非仅响应头); -// 流式读取至多 cfg.fetch.max_bytes 字节;按响应 charset 解码(gbk 等依赖内置 full-icu)。 +// 流式读取至多 cfg.fetch.max_bytes 字节(下载上限,宽松);按响应 charset 解码(gbk 等依赖内置 full-icu)。 +// 返回上限与下载解耦(cfg.fetch.max_chars/max_chars_hard):超窗尾部拼 offset 续读提示, +// 全文缓在 ctx.run 上(回合级),续读不重抓。SSRF 防护:主机名解析结果含私网即拒,重定向逐跳复查。 // undici 网络错误的 message 恒为 "fetch failed",真因窝在 err.cause 里——不解包模型分不清 // 域名已死/被拒连/TLS 问题(评审实测:只能靠另跑 curl 才能诊断)。常见码翻成中文直述。 const FETCH_NET_ERRORS = { @@ -588,6 +592,89 @@ function isTextualContentType(ct) { return false; } +// ---------- fetch 的 SSRF 防护 ---------- +// 私网/保留地址判定(IPv4:回环/私有/链路本地含云元数据 169.254.169.254/CGNAT/基准测试/文档段/组播及保留; +// IPv6:未指定/回环/v4-mapped/ULA fc00::/7/链路本地 fe80::/10/组播)。 +function isPrivateIp(ip) { + const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ip); + if (v4) { + const a = Number(v4[1]), b = Number(v4[2]); + if (a === 0 || a === 10 || a === 127) return true; + if (a === 100 && b >= 64 && b <= 127) return true; + if (a === 169 && b === 254) return true; + if (a === 172 && b >= 16 && b <= 31) return true; + if (a === 192 && (b === 0 || b === 168)) return true; + if (a === 198 && (b === 18 || b === 19 || b === 51)) return true; + if (a === 203 && b === 113) return true; + if (a >= 224) return true; + return false; + } + const s = String(ip).toLowerCase(); + const mapped = s.replace(/^::ffff:/, ''); + if (mapped.includes('.')) return isPrivateIp(mapped); + if (s === '::' || s === '::1') return true; + if (/^f[cd][0-9a-f]{2}:/.test(s)) return true; + if (/^fe[89ab][0-9a-f]:/.test(s)) return true; + if (/^ff/.test(s)) return true; + return false; +} + +// 主机名 → 全部解析结果逐个判,任一私网即拒(不能假定 undici 会连哪一条记录)。 +// 残余风险:本函数解析后 undici 建连时还会再解析一次,DNS 重绑定理论上可绕过; +// 目标是拦住直球打内网与重定向借刀这两类主要路径,不承诺硬边界。fetchUserError 标记: +// 这类已直述清楚的错误不走 describeFetchError 再包一层。 +async function assertFetchTargetAllowed(u, allowPrivate) { + const host = u.hostname.replace(/^\[|\]$/g, ''); // IPv6 字面量带方括号(URL.hostname 保留) + if (!host) throw Object.assign(new Error('URL 无主机名:' + u.href), { fetchUserError: true }); + let ips; + if (net.isIP(host)) ips = [host]; + else { + let recs; + try { recs = await dns.lookup(host, { all: true, verbatim: true }); } + catch (e) { throw Object.assign(new Error('无法解析主机 ' + host + (e && e.code ? '(' + e.code + ')' : '')), { fetchUserError: true }); } + ips = recs.map(r => r.address); + } + if (!allowPrivate && ips.some(isPrivateIp)) { + throw Object.assign(new Error('SSRF 防护:目标解析到回环/私有/内网地址(' + host + ' → ' + ips.join(', ') + '),拒绝抓取;' + + '确需抓内网服务请在 config 配 fetch.allow_private: true'), { fetchUserError: true }); + } +} + +// ---------- fetch 的回合级缓存 ---------- +// 返回窗截断时把转换后全文挂到 ctx.run(随 run 消亡,不跨轮污染):offset 续读纯本地切片, +// 不重走网络。键为请求 URL(归一化后);LRU 保留 3 条,每条 ≤ max_bytes,内存上限个位数 MB。 +function fetchCacheGet(run, key) { + const c = run && run.fetchCache; + if (!c) return null; + const e = c.get(key); + if (e) { c.delete(key); c.set(key, e); } // 命中挪到最近使用端 + return e || null; +} +function fetchCacheSet(run, key, entry) { + if (!run) return; + if (!run.fetchCache) run.fetchCache = new Map(); + run.fetchCache.set(key, entry); + while (run.fetchCache.size > 3) run.fetchCache.delete(run.fetchCache.keys().next().value); +} + +// 从全文切 [off, off+maxOut) 窗,尾部拼续读提示;窗内无内容单独说明。 +// 字节级截断(truncated)时本地「全文」本身就不完整,如实告知末尾可能缺失, +// 避免模型对着不完整文本用 offset 无限续读。 +function fetchWindow(text, off, maxOut, hard, truncated, maxBytes) { + if (off >= text.length) { + return '(offset=' + off + ' 超出全文长度 ' + text.length + ' 字符,无内容可读)' + + (truncated ? '\n(源响应体超过抓取上限 ' + maxBytes + ' 字节,可用更大 max_bytes 重抓)' : ''); + } + const end = Math.min(text.length, off + maxOut); + let out = text.slice(off, end); + if (end < text.length) { + out += '\n\n(已截断:全文 ' + text.length + ' 字符,本段 ' + off + '–' + end + '。' + + '续读传 offset=' + end + '(不重新下载);单段可传 max_chars 放大,硬帽 ' + hard + ')'; + } + if (truncated) out += '\n(源响应体超过抓取上限 ' + maxBytes + ' 字节,内容末尾可能不完整)'; + return out; +} + function charsetOf(ct) { const m = /charset\s*=\s*["']?([\w-]+)/i.exec(ct || ''); return m ? m[1].toLowerCase() : ''; @@ -629,17 +716,46 @@ async function toolFetch(ctx, args) { const fcfg = (ctx.cfg && ctx.cfg.fetch) || {}; const timeoutMs = fcfg.timeout_ms || 30000; const maxBytes = fcfg.max_bytes || 1024 * 1024; + // 返回窗与下载上限解耦:下载不进上下文可宽松,返回收紧。模型显式传 max_chars 时夹在硬帽内, + // 非法值(0/负数/NaN)退回默认。 + const hard = fcfg.max_chars_hard || 64000; + const want = Math.floor(Number(args.max_chars)); + const maxOut = want > 0 ? Math.min(want, hard) : (fcfg.max_chars || 12000); + const off = Math.max(0, Math.floor(Number(args.offset)) || 0); + + // 续读/重复抓:命中回合缓存直接本地切片,不再碰网络(回合内页面陈旧可接受,缓存续读场景)。 + const hit = fetchCacheGet(ctx.run, url); + if (hit) { + return truncate('HTTP ' + hit.status + '\n' + + fetchWindow(hit.text, off, maxOut, hard, hit.byteTruncated, maxBytes), 1024 * 1024); + } const ctrl = new AbortController(); const timer = setTimeout(() => ctrl.abort(), timeoutMs); // 与 toolTerminal 同模式:等待中用户取消也能 abort 掉进行中的请求/读流。 const cancelWatch = setInterval(() => { if (ctx.run.cancelled) ctrl.abort(); }, 200); try { - const res = await fetch(url, { - signal: ctrl.signal, - redirect: 'follow', - headers: { 'User-Agent': 'Mozilla/5.0 (agent-app)' }, - }); + // redirect:'manual' + 逐跳 SSRF 校验:自动跟随会让外站 302 直接把我们带进内网(SSRF 主路径)。 + let res = null; + let cur = url; + for (let hop = 0; ; hop++) { + await assertFetchTargetAllowed(new URL(cur), !!fcfg.allow_private); + res = await fetch(cur, { + signal: ctrl.signal, + redirect: 'manual', + headers: { 'User-Agent': 'Mozilla/5.0 (agent-app)' }, + }); + const loc = res.headers.get('location'); + if (!loc || res.status < 300 || res.status >= 400) break; // 非跳转:本跳即终答 + if (hop >= 5) throw Object.assign(new Error('重定向次数超过上限(5 次):' + url), { fetchUserError: true }); + let next; + try { next = new URL(loc, cur); } + catch (_) { throw Object.assign(new Error('重定向 Location 非法:' + loc), { fetchUserError: true }); } + if (next.protocol !== 'http:' && next.protocol !== 'https:') { + throw Object.assign(new Error('重定向目标不是 http/https:' + next.href), { fetchUserError: true }); + } + cur = next.href; + } const ct = (res.headers.get('content-type') || '').toLowerCase(); // 非文本:不读 body,直接回报元信息(避免二进制白下载 + 乱码)。 if (!isTextualContentType(ct)) { @@ -664,10 +780,17 @@ async function toolFetch(ctx, args) { catch (_) { text = buf.toString('utf8'); } } let body = ct.includes('html') ? htmlToMarkdown(text) : text; - if (truncated) body += '\n(响应超过 ' + maxBytes + ' 字节,已截断)'; - // 输出字符数兜底:engine 不截工具结果,这是返回值上最后一道护栏。 - return 'HTTP ' + res.status + '\n' + truncate(body, 1024 * 1024); + // 字节截断可能切在多字节字符中间,尾部的 U+FFFD 是噪音,去掉。 + if (truncated) body = body.replace(/\uFFFD+$/, ''); + const win = fetchWindow(body, off, maxOut, hard, truncated, maxBytes); + // 窗后本地还有未读内容才缓存(续读场景);一窗吃下全文的不值得存。 + if (off + maxOut < body.length) { + fetchCacheSet(ctx.run, url, { status: res.status, text: body, byteTruncated: truncated }); + } + // engine 不截工具结果;上面的返回窗是主闸门,这行 1MB 字符只是最后兜底。 + return truncate('HTTP ' + res.status + '\n' + win, 1024 * 1024); } catch (err) { + if (err && err.fetchUserError) throw err; // SSRF/重定向等已直述清楚的错误,不再套一层 // 超时与取消都表现为 signal.aborted(body 读流阶段的报错形态不定,按信号判定最稳)。 if (ctrl.signal.aborted) { if (ctx.run.cancelled) throw new Error('已终止'); @@ -713,9 +836,17 @@ function decodeEntities(s) { } function htmlToMarkdown(html) { + // 标题在剥 head 之前取:head 整块删后页面身份只剩正文,一行标题是性价比最高的上下文。 + const tm = /]*>([\s\S]*?)<\/title>/i.exec(html); + const title = tm ? decodeEntities(strip(tm[1])).trim() : ''; let s = html .replace(/<(script|style|noscript|svg|head)[\s\S]*?<\/\1>/gi, '') - .replace(//g, ''); + // 语义样板整块剥:导航/页眉/页脚/侧栏/表单这类页壳的正文密度普遍低于信噪比门槛。 + .replace(/<(nav|header|footer|aside|form)[\s\S]*?<\/\1>/gi, '') + .replace(//g, '') + // class/id 命样板词的分块:按启发式整块丢(子串匹配,覆盖 navbar/comments/ad-slot 等变体; + // 同名标签嵌套时惰匹配只删到第一个闭标签,与既有剥除同样接受不完美)。 + .replace(/<(div|section|ul|ol|article)\b[^>]*\b(?:class|id)\s*=\s*["'][^"']*(?:nav|menu|sidebar|breadcrumb|comment|footer|related|banner|promo|advert|popup|share|subscribe|masthead|cookie|social|toolbar)[^"']*["'][^>]*>[\s\S]*?<\/\1>/gi, ''); s = s .replace(/]*>([\s\S]*?)<\/h\1>/gi, (m, lv, t) => '\n' + '#'.repeat(Number(lv)) + ' ' + strip(t).trim() + '\n') .replace(/]*>([\s\S]*?)<\/li>/gi, (m, t) => '\n- ' + strip(t).trim()) @@ -724,7 +855,8 @@ function htmlToMarkdown(html) { .replace(/<\/(p|div|section|article|tr|ul|ol|table|blockquote)>/gi, '\n') .replace(/<[^>]+>/g, ''); // 实体解码放在剥标签之后:<p> 这类转义文本不会被当成标签剥掉。 - return decodeEntities(s).replace(/\n{3,}/g, '\n\n').trim(); + const body = decodeEntities(s).replace(/\n{3,}/g, '\n\n').trim(); + return (title ? '# ' + title + '\n\n' : '') + body; } function strip(s) { return s.replace(/<[^>]+>/g, ''); } diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index af71e0c..0e1f3a6 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -338,7 +338,7 @@ stateDiagram-v2 | `write_file` / `edit_file` | `edit_file` 用模糊定位(Zed 风格):先精确匹配,失败后用 Levenshtein DP 找最相似行;超 32MB 拒绝整文件读写(OOM 防护);DP 候选区间不连续(中间跳过无关 buffer 行)即弃用,防静默吞行;空 `new_text` = 整行干净删除(精确/模糊两层统一,对齐 `"".lines()` 零行语义);`old_text`/`new_text` 协议见 `definitions.json` | | 已移除的工具 | `list_directory` / `create_directory` / `delete_path` / `move_path` / `copy_path` / `find_path` / `grep`:环境固定,文件操作与检索统一走 `terminal`(ls / mkdir / rm / mv / cp / find / rg),内置工具 17 → 10;技能三件套又并为 `skill` 后为 8;再增元工具 `lab` 为 9(默认被全局 `tools_deny` 屏蔽);后续增 `db`、`profile` 各一 → 现 12 项 | | `terminal` | **唯一一个走 executor 的内置工具**(当 `rexec.isRemote(cfg)`);本地分支用 `spawn` + `detached` + 进程组 kill;远端分支 `rexec.run` SSE 收流,结果套上超时/截断/取消注解后 `truncate(text, cfg.terminal.max_output_chars)` 返回 | -| `fetch` | `AbortController` 覆盖全生命周期(响应头之后的 body 读流同样被超时/取消打断,取消用与 terminal 同款的 200ms 轮询);content-type 先行,非文本只回状态/类型/尺寸不读 body;流式读到 `cfg.fetch.max_bytes`(默认 1MB)即断开并标注截断;按响应 charset 解码(full-icu 支持 gbk/gb18030 等,未知编码退回 UTF-8);HTML 用 `htmlToMarkdown` 转;HTML 实体单遍解码(常见命名实体+数字实体通吃,修 `&` 双重解码);网络错误解包 `err.cause` 直述 ENOTFOUND/TLS 等真因;engine 不截工具结果,返回值末尾另有 `truncate` 1MB 字符护栏 | +| `fetch` | `AbortController` 覆盖全生命周期(响应头之后的 body 读流同样被超时/取消打断,取消用与 terminal 同款的 200ms 轮询);content-type 先行,非文本只回状态/类型/尺寸不读 body;**下载/返回双上限解耦**:流式读到 `cfg.fetch.max_bytes`(默认 1MB)即断开(下载不占上下文可宽松),返回窗默认 `max_chars`(12000)字符,模型显式传 `max_chars` 夹在 `max_chars_hard`(64000)硬帽内;超窗尾部拼 `offset` 续读提示,转换后全文缓在 `ctx.run.fetchCache`(回合级 LRU 3 条),续读纯本地切片不重抓;**SSRF 防护**:主机名解析结果含回环/私有/链路本地地址即拒(`allow_private: true` 才放行),`redirect:'manual'` 逐跳复查至多 5 次(残余风险:undici 建连时二次解析,DNS 重绑定不可根治);按响应 charset 解码(full-icu 支持 gbk/gb18030 等,未知编码退回 UTF-8);HTML 用 `htmlToMarkdown` 转(剥 script/style/head 及 nav/header/footer/aside/form 整块,class/id 样板词启发式丢块,`` 提成首行);HTML 实体单遍解码(常见命名实体+数字实体通吃,修 `&` 双重解码);字节截断切在多字节字符中时尾 U+FFFD 去噪;网络错误解包 `err.cause` 直述 ENOTFOUND/TLS 等真因,SSRF/重定向类错误带 `fetchUserError` 标记直接冒泡;engine 不截工具结果,返回值末尾另有 `truncate` 1MB 字符兜底护栏 | | `mint_public_link` | **唯一的 mint 入口**:与 core 同进程,直接 `publicFiles.mint()`,不绕任何 HTTP;`ctx.taskDir` 就是会话目录,`relOf` 的结果正是取用侧要的 `rel`。校验:`public_link.base_url` 已配 + `resolveInTask` 沙箱 + 确认是文件 + `realpath` 未沿符号链接跳出任务目录;返回单行 URL | | `skill` | op 分派 list/get/run(三件套合并:同一 `name` 标识空间 + 同一生命周期,见 `docs/tool-design.md` §一);委托 `tools/skills.js`;`input_args` 仅 op=run 且可缺省 `{}`,缺参由各技能 `input_schema` 校验点名报错;front matter 带 `visit_url` 的技能在 op=run 成功后由 executor 层拼 `public_link.base_url`(与 mint 同源)追加完整「访问地址」行(技能进程不知公网前缀,AI 拿相对路径会原样转给用户) | | `schedule` | **当前会话**(`ctx.sessionId`,AI 不可指定他会话)定时任务的完整生命周期:op 分派 get/create/update/delete(表主键 session_id → 每会话至多一条,无 id 参数);条件必填在代码里校验、错误回显 op 与缺失字段;数据层在 `scheduler.js`(cron 可解析 → 间隔 ≥1h → prompt ≤20000 → 查重/存在性检查),delete 不落 scheduler_note;描述里限定「仅用户明确要求时调用」(安全缓解,见 §5.12) | @@ -548,7 +548,9 @@ AI 通过 `schedule` 工具为所在会话建周期性任务(`scheduled_tasks` - `model_profiles`(顶层)—— 多套可复用的 prompt+tools 组合(`{tools_allow?, tools_deny?, system_prompt_file?}`);模型层用 `profile: <名>` 引用,不配 = 默认全量(仍受顶层 `tools_deny` 屏蔽)。内置 `advising`/`lab`/`zero` 三套默认组合,可用同名覆盖;`advising` 不经模型引用——会话处于顾问阶段时强制命中(见 §4.1 phase 状态机)。元工具自测/纯文本场景用,详见 §5.8;运行期手动切换已全部移除(消息级参数与会话绑定均废弃)。 - `agent.max_tool_iterations`(默认 100)—— 单轮迭代上限(含工具调用),到顶自动停止并提示用户继续输入。 - `terminal.max_output_chars`(默认 10000)—— AI 看到的命令输出上限;executor 侧另有 `EXECUTOR_MAX_OUTPUT_CHARS=200000` 兕底。 -- `fetch.timeout_ms`(默认 30000)/ `fetch.max_bytes`(默认 1MB)—— 网页抓取的全生命周期超时与流式抓取字节上限;返回值另有 1MB 字符 `truncate` 护栏。 +- `fetch.timeout_ms`(默认 30000)/ `fetch.max_bytes`(默认 1MB)—— 网页抓取的全生命周期超时与流式抓取**字节**上限(超限即断开;下载不占上下文,保持宽松)。 +- `fetch.max_chars`(默认 12000)/ `fetch.max_chars_hard`(默认 64000)—— 回给模型的**字符**返回窗(与下载上限解耦);模型可传 `max_chars` 放宽到硬帽,超窗尾部提示 `offset`,续读走回合缓存不重抓(见 §5.4)。 +- `fetch.allow_private`(默认 false)—— SSRF 防护开关:目标主机名解析到回环/私有/链路本地地址即拒抓(重定向逐跳复查);确需抓内网服务才显式开 true。 - `skills.skills_root` —— 缺省取 `workspace_root` 的同级 `skills/`。 - ~~`model_hold`~~ —— 已废弃(旧版保持租约:held 到期自动释放);新调度下 key 不独占、不排队,held 不再到期,字段仅为旧配置解析兼容保留。 - 上下文压缩 —— 无配置项:压缩回合沿用当前 profile 的 system prompt(无 profile = 默认模板)+ 正常历史,末尾追加一条 user(固定模板 `server/templates/compress-prompt.txt` 原文),该回合不传 tools;调整压缩策略直接改该文件。