diff --git a/README.md b/README.md index b52b072107..96811c90d8 100644 --- a/README.md +++ b/README.md @@ -272,7 +272,7 @@ bili claude # launch claude through the proxy bili omp # pi-style, file-free (#535): env + extension registerProvider + compaction cancel, real ~/.omp untouched bili opencode # OpenCode (1.x & 2.x): full guide in the [OpenCode](docs/clients.md#opencode) section below bili hermes # file-free (#535): hermes proxy env (HTTPS_PROXY + combined CA bundle via SSL_CERT_FILE) — https via CONNECT MITM, http via absolute-form forward proxy; real ~/.hermes untouched -bili dsh # deepseek-harness: full native plugin injected via --patch (#941) — real dsh tools, session-bound /acp + /acp-cache (plugin mode); non-loopback upstreams ride proxy envs, loopback keeps the overlay DSH_HOME rewrite (#535); dsh auto-compaction off everywhere — host plane via the bundle patch, web-profile presets at load time (#1772/#2474/#3354) +bili dsh # deepseek-harness: full native plugin injected via --patch (#941) — real dsh tools, session-bound /acp + /acp-cache (plugin mode); non-loopback upstreams ride proxy envs, loopback keeps the overlay DSH_HOME rewrite (#535); dsh auto-compaction off while bili-native owns the lane — host plane via the bundle patch, web-profile presets at load time; restored to stock on disable since #5245 (#1772/#2474/#3354) bili codebuddy # Tencent CodeBuddy Code CLI: CODEBUDDY_BASE_URL /bili/ rewrite (OpenAI chat completions wire), budget aligned via CODEBUDDY_AUTO_COMPACT_WINDOW; real ~/.codebuddy untouched bili qoder # qoder CLI (`qoder`/`qodercli`): model endpoint is hardcoded https (no /bili/ rewrite possible) — cert-MITM via HTTPS_PROXY + NODE_EXTRA_CA_CERTS, default model hosts whitelisted (#653). Qoder Desktop is a separate BYOK/custom channel that speaks plaintext OpenAI over a `/bili/` prefix — point it at bili as a normal custom provider (not this MITM lane); its official-subscription traffic is encrypted and out of scope (#764) bili trae # Trae CLI (ByteDance, closed Go binary, no base-URL override) — cert-MITM via HTTPS_PROXY + SSL_CERT_FILE, model host from TRAE_CLI_API_HOST or the default enterprise gateway (#655) diff --git a/README.zh-CN.md b/README.zh-CN.md index ee02e832f4..ef3911c909 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -212,7 +212,7 @@ bili claude # 拉起 claude bili omp # pi 同款,file-free(#535):环境变量 + 扩展 registerProvider + 压缩取消,真实 ~/.omp 不动 bili opencode # OpenCode(1.x 与 2.x):完整指南见下文 [OpenCode](docs/clients.zh-CN.md#opencode) 一节 bili hermes # file-free(#535):hermes 代理环境变量(HTTPS_PROXY + SSL_CERT_FILE 组合 CA bundle)—— https 走 CONNECT MITM,http 走绝对形式转发;真实 ~/.hermes 不动 -bili dsh # deepseek-harness:经 --patch 注入完整原生插件(#941) —— 真实 dsh 工具、会话绑定 /acp(plugin 模式);非回环上游走代理 env,回环保留 overlay DSH_HOME 改写(#535);dsh 自动压缩处处关闭(宿主平面经 bundle patch,web profile 的 preset 经 #3354 加载期 overlay,#1772/#2474/#3354) +bili dsh # deepseek-harness:经 --patch 注入完整原生插件(#941) —— 真实 dsh 工具、会话绑定 /acp(plugin 模式);非回环上游走代理 env,回环保留 overlay DSH_HOME 改写(#535);dsh 自动压缩在 bili-native 持有泳道期间处处关闭(宿主平面经 bundle patch,web profile 的 preset 经 #3354 加载期 overlay,#5245 起禁用时还原出厂,#1772/#2474/#3354) bili codebuddy # Tencent CodeBuddy Code CLI:CODEBUDDY_BASE_URL /bili/ 重写(OpenAI chat completions wire),预算对齐走 CODEBUDDY_AUTO_COMPACT_WINDOW;真实 ~/.codebuddy 不动 bili qoder # qoder CLI(`qoder`/`qodercli`):模型端点硬编码 https(无法 /bili/ 改写)—— 证书 MITM(HTTPS_PROXY + NODE_EXTRA_CA_CERTS),默认模型主机已加白名单(#653)。Qoder Desktop 是另一条 BYOK/自定义渠道,走 `/bili/` 前缀的明文 OpenAI wire —— 当作普通自定义 provider 指向 bili 即可(不走这条 MITM 车道);其官方订阅流量是加密的,不在范围内(#764) bili trae # Trae CLI(字节跳动,闭源 Go 二进制,无 base-URL 覆盖)—— 证书 MITM(HTTPS_PROXY + SSL_CERT_FILE),模型主机取 TRAE_CLI_API_HOST 或默认企业网关(#655) diff --git a/docs/clients.md b/docs/clients.md index 2529dbfde6..946f356dac 100644 --- a/docs/clients.md +++ b/docs/clients.md @@ -19,8 +19,9 @@ Two lanes, same plugin (#941): `x-bili-plugin` + the dsh session id (plugin mode), and `/acp` is session-bound. dsh's native auto-compaction is disabled in the same patch (host-plane `compaction-basic` → `auto: false`; web-profile preset - instances are disabled at load time by the #3354 overlay); manual - `/compact` stays available in non-web profiles. The + instances are disabled at load time by the #3354 overlay; when + `bili-native` is disabled or absent the gate restores the host-plane row + to stock, #5245); manual `/compact` stays available in non-web profiles. The same patch also adds `MALFORMED_RESPONSE` to the built-in DeepSeek routes' retry whitelist, so one sampling flake that breaks a tool-call argument JSON retries instead of killing the turn (#2605). @@ -203,9 +204,10 @@ spawn mode (a loopback proxy target is never proxied, so the MITM envs are simply bypassed); already-routed `/bili/`-prefixed requests pass through untouched except for header stamping. Known limitation: manual `/compact` has no dsh-side event hook, so its boundary is left to the -kernel's natural ingest diff (auto-compaction is now off everywhere — host -plane via the bundle patch, web-profile presets via the #3354 load-time -overlay; see the web-profile note above). +kernel's natural ingest diff (auto-compaction is off everywhere while +bili-native owns the lane — host plane via the bundle patch, web-profile +presets via the #3354 load-time overlay; a disable restores stock since +#5245; see the web-profile note above). **Host-side context meters diverge from the model's view by design (#2837):** in plugin mode the host's durable session log diff --git a/docs/clients.zh-CN.md b/docs/clients.zh-CN.md index 96cd01e225..cab3756522 100644 --- a/docs/clients.zh-CN.md +++ b/docs/clients.zh-CN.md @@ -9,7 +9,7 @@ 两条通道,同一个插件(#941): -- **启动器:** `bili dsh` 经 `--patch` overlay(`~/.dsh-bili/.bili-acp.patch.yml`)注入完整原生插件 —— 每个 profile 启动即注册 bili 工具,模型请求盖 `x-bili-plugin` + dsh 会话 id(plugin 模式),`/acp` 会话绑定。同一份 patch 同时禁用 dsh 原生自动压缩(宿主平面 `compaction-basic` → `auto: false`,web profile 的 preset 实例由 #3354 加载期 overlay 关闭);非 web profile 下手动 `/compact` 仍可用。 +- **启动器:** `bili dsh` 经 `--patch` overlay(`~/.dsh-bili/.bili-acp.patch.yml`)注入完整原生插件 —— 每个 profile 启动即注册 bili 工具,模型请求盖 `x-bili-plugin` + dsh 会话 id(plugin 模式),`/acp` 会话绑定。同一份 patch 同时禁用 dsh 原生自动压缩(宿主平面 `compaction-basic` → `auto: false`,web profile 的 preset 实例由 #3354 加载期 overlay 关闭;`bili-native` 被禁用或缺席时 gate 把宿主平面行还原为出厂 `auto: true`,#5245);非 web profile 下手动 `/compact` 仍可用。 - **Profile 安装(免启动器)——统一泳道(#966):** `bili plugin install dsh` 对每个已存在的 profile 执行 `dsh plugin --profile add billion-context` —— pnpm 把包装进各 profile 自己的 `node_modules`,dsh 自动挂载包内 patch 层(`dsh.bundle.patch.yml`)。装哪个源取决于 bili 自身的安装形态(#925):npm 安装传注册表名,checkout/dev 构建传绝对路径(`link:` 依赖,本地改动实时生效)。旧版受管块(`# bili begin` / `# bili end`,#966 之前的安装所写)在安装与卸载时都会被剥离 —— 用户条目与注释保留,清空的文件还原占位 `[]`。先在每个 profile 里跑过一次 dsh 让目录存在。插件加载时自拉起代理(已有健康实例则附看,不重复拉;父进程 pid 看门狗),经全局 fetch 与 Codex Responses WebSocket 补丁把模型流量改写为 `/bili/<上游URL>`(#5838),原样注册清单工具,并按工具就绪门控 plugin 模式头。WS 握手等待工具注册并携带 DSH 会话/模型头;每个 `response.create` 都等待归属判定与 fork 准备。缓存连接遇到身份/模型、插件激活代次或代理地址变化时拒绝发送,须重连(或由 provider 回退 SSE),其他 WebSocket 不变。退出开关:`BILI_NATIVE_DSH=0`。卸载:`bili plugin remove dsh` 或 `dsh plugin --profile remove billion-context` —— 两者走同一通道。经注册表安装要求 npm 上已发布含 `dsh.bundle.patch.yml` 的版本;请装 npm 形态 —— 直接填 GitHub 地址装到的是没有 `dist/` 的源码(入口悬空、dsh 静默跳过该 bundle;安装期守卫现在会响亮失败并给出正确装法,#2471)。若 add 后 dsh 启动即报 `billion-context/dsh` 的 `ERR_MODULE_NOT_FOUND`,说明 profile 从陈旧的包元数据缓存里解析到了不含 bundle 子路径导出的旧版本(#953)——固定版本重装:`dsh plugin --profile add billion-context@latest`。 - **Codex WebSocket 腿(#5838):** 内嵌 pi-ai 的 `openai-codex` provider 默认 `transport: auto`,优先走直连 WebSocket——成功的 WS 交换从不调用 fetch。WS 车道修复之前的构建因此完全看不到这些模型请求:ACP 工具 404、上下文到顶前没有任何压缩。在这类构建上把 DSH 现有的 `providers.openai-codex.transport` 设为 `sse`(热设置,无需新增 bili 配置),让流量改走 fetch 腿;自携带该修复的版本起,WebSocket 腿会被自动拦截并盖章路由。 - **边界——第三方 Codex 传输:** 自建 Codex WebSocket 客户端的插件会按构造绕开 bili 的拦截。2026-11-08 实机发现的例子:`dsh-codex-subscription` 在 `connectionMode: websocket` 下直接 import `ws` 包,并把 `globalThis.WebSocket` 换成按主机的 Proxy,模型帧根本不经过全局 fetch/WS 补丁——代理零可见、ACP 工具 404、native compaction 又被门禁关闭,压缩路径全无(#5838 的第二来源)。在插件改为「无 CONNECT 代理需求时透传环境里的 `globalThis.WebSocket`」之前,请用 `connectionMode: sse`(插件默认值);bili 无法拦截宿主自有 profile bundle 里模块作用域的 `ws` import。 @@ -17,10 +17,10 @@ - **自动更新保持各 profile 同步:** 刷新有两个触发器 —— 全局自更新完成后,以及**profile 自己的代理**在周期检查里发现注册表有新版本时(全局 bili 从不运行也一样刷新,#1196 —— 插件市场安装的用户往往根本没有全局安装)。两种触发器都扫描 `~/.dsh/profiles/*/package.json`,把注册表钉住的 `billion-context` 依赖刷新到目标版本(全局触发器刷到新全局版本,自触发刷到注册表最新),统一经 dsh 自己的 `plugin add` 通道,绝不在位覆盖 —— 加载的插件与代理从此不再漂移(#953);钉在本地源的 profile 不动。刷新是尽力而为,失败下个周期重试,绝不会让代理或更新本身失败。 - **已报告:Profile 安装下部分传输零代理流量(#1158,调查中):** dsh `llm-pi-ai` 层的部分传输服务会话**从未有任何模型请求到达代理**(日志无 `processTurn`,调用 bili 工具返回 404 "no model request has arrived"),而同宿主的其他 provider 正常。根因仍在用运行时证据定性 —— 候选:传输层 fetch 形态(SDK 注入 fetch / 非全局 dispatcher)或宿主侧归属缺口导致流量未被 takeover gate 认领。检测:此类情况会打一次性 `[plugin] NO MODEL REQUESTS seen for conversation …` 告警,dsh 插件还会把归属 gate 放行的每个端点各记一条日志(每进程一次)。期间可靠规避:改用 `bili dsh` 启动 —— 启动器的 settings overlay 会把那些 provider 的 `baseURL` 重写为 `/bili/` URL,无论传输层使用哪种 fetch、归属状态如何,流量都必然过代理。 - **Web profile 压缩(#1772,#3354 解决):** 当 profile 的 bundles 含 `@deepseek-ai/dsh-web-app` 时,真正运行的 `compaction-basic` 实例位于 agent preset(`preset-standard.config.plugins`)内部 —— dsh 的 patch 引擎只按 id 索引顶层条目与真 group(`group: true` 且 config 为数组)的子项,preset 内的嵌套行任何 patch 层都无法**按 id 直寻**。于是 bundle 里的 `auto: false` 落在 web-app 已禁用的宿主平面行上、什么都没改。#3354 起 bili 在**加载期**补上这一环:一个**常驻**的 bundle 条目 `bili-compaction-gate`(与 `bili-native` 并列的独立 cordis 条目,由同一组 patch 层挂载,因此 `bili-native` 被禁用或 kill-switch 时它仍然存活,#3662)注册一个 cordis `internal/config` overlay(移植自 deshark42/dsh-compaction-basic-disable,MIT),在 bili 持有该泳道期间把 preset 里的 `compaction-basic` 与 `command-compact` 行标记为 `disabled: true`;#4147 起该匹配是**结构化**的 —— 任何 entry 的 `config.plugins` 里嵌套了这两个包的行都会被禁用,自定义/本地 preset 与官方 preset 一视同仁(`dsh.bundle.patch.yml` 里的四个门控 id 只是对官方 roster 的顺序保险,不是覆盖边界);bundle patch 里的 preset 门控行让每个 Web preset 在注册前等待该 overlay 的服务。这些 profile 里原生自动压缩同样关闭(且 `/compact` 在那里不可用 —— 这是**预期行为而非 bug**(#4002):该泳道的压缩由 bili 接管,preset 的 compact 命令与自动压缩被有意一并撤下;按设计**没有**重新打开的开关(#3651/#3666),见 configuration.md);ACP 压缩不受影响。启动的一次性 `[dsh-client]` 日志会列出 overlay 实际改写过的 entry(#3962),patch 行落空(如 roster 改名)无需翻宿主 loader 日志即可见。overlay 依赖 dsh 的内部钩子、对版本敏感 —— 若在新/旧 dsh 构建上仍见到 dsh 压缩 checkpoint 落地,回退到 #2474 配方:profile 层 patch(你 profile 自己的 `cordis.patch.yml`,在所有 bundle 之后生效)用同 id + **完整快照** `config` 整体覆盖 preset-standard —— 从 `dsh --profile --dump-config` 抄下完整的 preset config,在其 `compaction-basic` 行下加 `config.auto: false`,把结果追加进 `cordis.patch.yml`。Config 替换是**整体语义**(片段会静默丢掉一切未重述的键 —— 不只是其他插件,连 preset 自己的 `id`/`order` 身份也会丢,可能使 roster 无法识别该 preset);`- insert:` 同 id 则是在末尾追加一条死行而非合并。dsh 升级 preset 后快照冻结 roster、需重抄一次。此类 profile 启动时插件打一条一次性 `[dsh-client]` 日志,说明两条路径。 -- **禁用与移除插件的区别(#3662):** #3662 之前,禁用 `bili-native`(dsh 插件管理器,或任何 patch 层里写 `disabled: true`)会把门控服务的**唯一**提供方一并移除,而 preset 行仍在等它 —— 四个 Web preset 永久 pending,新建/恢复会话全部报 `Unknown agent preset: standard`。现在该服务住在独立的常驻条目 `bili-compaction-gate` 里:禁用或 kill-switch(`BILLION_CONTEXT_PLUGIN=0`)`bili-native` 只是把泳道交还 dsh **原生行为** —— preset 正常注册、原生自动压缩恢复,bili 压缩则完全关闭。请勿禁用 `bili-compaction-gate` 本身 —— 那会重新造成「砖」。要彻底卸载:从 profile 的 `dsh.profile.bundles`(及其依赖)里移除 `billion-context` 后重启 —— 整个 patch 层消失,`compaction-basic` 回到原生默认 `auto: true`。若卡在 #3662 之前的版本且插件已被禁用:升级即自愈(patch 层按 bundles 里列出的包装载,与 `bili-native` 的启用状态无关);手动解砖是在 HOME 层 patch `$DSH_HOME/cordis.patch.yml`(`DSH_HOME` 未设时为 `~/.dsh/cordis.patch.yml`)追加四行 `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`,各配 `inject: null` —— 顶层键为整体替换,清掉 pending 锁。 +- **禁用与移除插件的区别(#3662):** #3662 之前,禁用 `bili-native`(dsh 插件管理器,或任何 patch 层里写 `disabled: true`)会把门控服务的**唯一**提供方一并移除,而 preset 行仍在等它 —— 四个 Web preset 永久 pending,新建/恢复会话全部报 `Unknown agent preset: standard`。现在该服务住在独立的常驻条目 `bili-compaction-gate` 里:禁用或 kill-switch(`BILLION_CONTEXT_PLUGIN=0`)`bili-native` 只是把泳道交还 dsh **原生行为** —— preset 正常注册、原生自动压缩恢复(#5245 起含非 web profile 的宿主平面行:静态 `auto: false` 被 gate 还原为出厂 `auto: true`,此前它一直留着),bili 压缩则完全关闭。请勿禁用 `bili-compaction-gate` 本身 —— 那会重新造成「砖」。要彻底卸载:从 profile 的 `dsh.profile.bundles`(及其依赖)里移除 `billion-context` 后重启 —— 整个 patch 层消失,`compaction-basic` 回到原生默认 `auto: true`。若卡在 #3662 之前的版本且插件已被禁用:升级即自愈(patch 层按 bundles 里列出的包装载,与 `bili-native` 的启用状态无关);手动解砖是在 HOME 层 patch `$DSH_HOME/cordis.patch.yml`(`DSH_HOME` 未设时为 `~/.dsh/cordis.patch.yml`)追加四行 `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`,各配 `inject: null` —— 顶层键为整体替换,清掉 pending 锁。 - **全局副本在加载期抢占 profile 副本(#2891):** dsh 解析 `dsh.profile.bundles` 里的裸包名 `billion-context` 时是 installation-anchor-first —— 先在自己的安装树(全局 npm root)里找,再找 profile 的 `node_modules`。因此只要机器上存在一份全局 `billion-context`,dsh 就加载**全局那份**,profile 里装的被静默忽略 —— 不崩溃、无日志。两者版本不一致时,实际运行的可能与 profile 声明的不同(例如 #1590 之前的全局没有 `dsh.client` web 面,设置页菜单凭空消失)。这一事实默认情况下处处不可见:`bili doctor` 现在会按 profile 逐一标记任何版本不一致的全局/本地对(#2891);用 `dsh --profile --dump-config`(读该 bundle 的 `name:` 行)可核对 dsh 实际加载了哪份。 -`bili dsh` 启动下插件**附看**(attach)启动器的代理(不二次拉起)。裸上游 URL 与 spawn 模式一样重写为 `/bili/`(回环代理目标永不被代理 env 拦截,等于直接绕开 MITM);已经路由的 `/bili/` 前缀请求原样放行、只盖章。已知局限:手动 `/compact` 没有 dsh 侧事件钩子,其边界交给内核的自然 ingest diff(自动压缩现已处处关闭 —— 宿主平面经 bundle patch,web profile 的 preset 经 #3354 加载期 overlay;见上方 Web profile 说明)。 +`bili dsh` 启动下插件**附看**(attach)启动器的代理(不二次拉起)。裸上游 URL 与 spawn 模式一样重写为 `/bili/`(回环代理目标永不被代理 env 拦截,等于直接绕开 MITM);已经路由的 `/bili/` 前缀请求原样放行、只盖章。已知局限:手动 `/compact` 没有 dsh 侧事件钩子,其边界交给内核的自然 ingest diff(bili-native 持有泳道期间自动压缩处处关闭 —— 宿主平面经 bundle patch,web profile 的 preset 经 #3354 加载期 overlay,#5245 起禁用时还原出厂;见上方 Web profile 说明)。 **宿主侧上下文计量与模型实际视图按设计不一致(#2837):**plugin 模式下宿主本地持久会话日志有意保持无损 —— 完整未折叠历史会因前缀缓存与严格回显而重发(见 technical-notes.md「两种压缩模式」)。因此宿主或其插件从该本地日志算出的任何计量,量的都是**未折叠的本地表面**,而不是下一次请求实际携带的量;压缩生效期间本地数字远高于真实输入属预期,不是压缩卡死。有效尺寸以代理为准:读 `/acp`(或 `GET /__bili/plugin/status` 的 `contextTokens`,来源见 `contextTokensSource`),不要本地重新推算。 diff --git a/docs/configuration.md b/docs/configuration.md index d2bddf9df9..a821656e08 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2541,7 +2541,7 @@ Two compressors on one conversation double-compress and corrupt message refs, so - **Scan** (read-only, best-effort, 5-minute cache): opencode global + project config `plugin` arrays; pi global + project `.pi/settings.json` `packages`; omp `config.yml` `extensions`; claude settings `enabledPlugins`/`plugins` keys + `~/.claude/plugins/` dir; kimi `plugins/installed.json`; hermes `~/.hermes/plugins/` dir; dsh profile `package.json` dependencies. Two tiers: **known conflicts** (`opencode-acp`, legacy `billion-context-pi`, and dsh's `dsh-live-compact` (#5984) — deterministic) and **keyword-suspected** entries (names matching compress* / compact* / acp / summar*; bare `context` deliberately does NOT match — it names the domain, not the act of compressing, so read-only tools like `context7`/`dsh-context` do not flag); verified non-compressing plugins are exempt outright by EXACT package name — read-only/display-only tools (e.g. `pi-compact-transcript`, `pi-context-inspector`) and protocol adapters whose name merely collides with a keyword (`@openma/deepseek-harness-acp`: its `acp` means Agent Client Protocol, not the acp-kernel ecosystem marker; #2969) — lookalike names still flag. dsh's `dsh-live-compact` is a known conflict, not a keyword suspicion: it is a competing compaction engine — its bundled `cordis.patch.yml` disables the stock `compaction-basic` row and registers its own engine row, and its preset takeover renames the preset's compaction row to itself, so bili's load-time compaction-disable overlay (#3354), which recognizes only the stock row names, is structurally blind to it and its checkpoints land outside bili's knowledge (#5984). - **Where findings surface:** launcher stderr before the client starts; a proxy warn log on each session's first request (client identified from the `x-bili-plugin` header or wire headers); and the session's conflict ledger — `acp_status`'s `COMPRESSION CONFLICTS` section, `GET /__bili/stats` → `conflicts`, web-UI banner. - **Runtime evidence, tiered for display (#2545):** unannounced history rewrites (#1001) and orphan-gc deactivations (summarized content deleted out of the client's history) are recorded in the same ledger as *suspected* coexistence. Severity surfaces grade by EVIDENCE TIER: **confirmed** = a detected client-native compaction landing (bili rebases onto it, #2372/#2432) or a non-suspected plugin finding — only this triggers the imperative "keep one compressor" warning; **unconfirmed signals** = unannounced rewrites + orphan-gc deactivations — observed changes whose cause is NOT identified ("history changed, cause unknown"), never presented as native auto-compaction or a second compressor; name-only [suspected] matches stay in the soft "verify first" tier (#1736) and a PURE [suspected] ledger gets verify-first advice only — no imperative per-client fix footer ("disable auto-compaction / start a fresh session") while nothing is confirmed (#2969). Stock ledger records naming verified non-compressing plugins (read-only viewers, or protocol adapters such as #2969's ACP adapter) are neutralized at display time instead of persisting as alarms, and cross-session aggregate counts of unconfirmed signals never escalate to a same-conversation double-compression claim. -- **dsh's `auto: false` disables only the automatic triggers.** The `compaction-basic: { auto: false }` line installed by the profile bundle patch (`dsh.bundle.patch.yml`) skips pressure/overflow auto-compaction — a manual `/compact` (and idle-session compaction) still fires. Calls routed through bili are refused by the server-side guard (#1729/#2360); calls that reach the provider without transiting bili (desktop-lane paths the plugin's takeover gate does not attribute) land, and bili detects them on the next replay — checkpoint framing + decimated fold coverage — rebasing its compression state in one turn instead of failing every later compress forever (#2432). When the goal is turning dsh compaction off **entirely** — including manual `/compact` — the delta belongs on that same row as `disabled: true`, not `auto: false` (recipe below). +- **dsh's `auto: false` disables only the automatic triggers.** The `compaction-basic: { auto: false }` line installed by the profile bundle patch (`dsh.bundle.patch.yml`) skips pressure/overflow auto-compaction — a manual `/compact` (and idle-session compaction) still fires. Since #5245, when `bili-native` is absent or disabled the gate transform undoes this installed line entirely (host-plane `auto` back to `true`) — a market disable reverses completely. Calls routed through bili are refused by the server-side guard (#1729/#2360); calls that reach the provider without transiting bili (desktop-lane paths the plugin's takeover gate does not attribute) land, and bili detects them on the next replay — checkpoint framing + decimated fold coverage — rebasing its compression state in one turn instead of failing every later compress forever (#2432). When the goal is turning dsh compaction off **entirely** — including manual `/compact` — the delta belongs on that same row as `disabled: true`, not `auto: false` (recipe below). #### Turning dsh native auto-compaction OFF in a web profile (#1772/#3354, automatic since #3354; #2474 recipe as fallback) @@ -2549,7 +2549,7 @@ Two compressors on one conversation double-compress and corrupt message refs, so The overlay rides an INTERNAL dsh hook and is version-sensitive. If you still see a dsh compaction checkpoint land on a newer/older dsh build, use the fallback below. - **Disabling vs removing (#3662).** Disabling `bili-native` (dsh plugin manager or `disabled: true` in a patch layer) no longer bricks session creation: the gate service survives in the separate always-on `bili-compaction-gate` entry, so the presets fall back to STOCK native compaction instead of pending forever — compression off, dsh fully usable. Never disable `bili-compaction-gate` itself (that re-creates the brick); to fully uninstall remove `billion-context` from the profile's `dsh.profile.bundles` and restart. Pre-#3662 installs left bricked self-heal on upgrade; manually, append `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`, each with `inject: null`, to `$DSH_HOME/cordis.patch.yml` (home layer; default `~/.dsh/cordis.patch.yml`) — top-level keys replace wholesale, clearing the pending latch. + **Disabling vs removing (#3662).** Disabling `bili-native` (dsh plugin manager or `disabled: true` in a patch layer) no longer bricks session creation: the gate service survives in the separate always-on `bili-compaction-gate` entry, so the presets fall back to STOCK native compaction instead of pending forever, and since #5245 the gate transform also undoes the bundle patch's static host-plane `auto: false` line (before that, non-web profiles kept their native auto-compaction off after a disable) — compression off, dsh fully usable. Never disable `bili-compaction-gate` itself (that re-creates the brick); to fully uninstall remove `billion-context` from the profile's `dsh.profile.bundles` and restart. Pre-#3662 installs left bricked self-heal on upgrade; manually, append `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`, each with `inject: null`, to `$DSH_HOME/cordis.patch.yml` (home layer; default `~/.dsh/cordis.patch.yml`) — top-level keys replace wholesale, clearing the pending latch. **Fallback recipe (#2474)** (verified on dsh `0.2.1-alpha.1`, Windows 11, profile bundles including `@deepseek-ai/dsh-web-app`). A profile-layer patch can turn it off — presets are ordinary top-level rows inserted by the bundle layer, and the profile patch layer is applied after it. What does not work is addressing the nested row by id; what does work is overriding the preset row's `config` wholesale. diff --git a/docs/configuration.zh-CN.md b/docs/configuration.zh-CN.md index 3ad7b20267..9764e85131 100644 --- a/docs/configuration.zh-CN.md +++ b/docs/configuration.zh-CN.md @@ -2504,7 +2504,7 @@ bili plugin remove pi # 撤销(原文件一次性备份为 *.bili-bak) - **扫描**(只读、尽力而为、5 分钟缓存):opencode 全局 + 项目配置的 `plugin` 数组;pi 全局 + 项目 `.pi/settings.json` 的 `packages`;omp `config.yml` 的 `extensions`;claude 设置的 `enabledPlugins`/`plugins` 键 + `~/.claude/plugins/` 目录;kimi `plugins/installed.json`;hermes `~/.hermes/plugins/` 目录;dsh profile 的 `package.json` 依赖。两个层级:**已知冲突**(`opencode-acp`、遗留 `billion-context-pi`、dsh 的 `dsh-live-compact`(#5984),确定性判定)和**关键词疑似**条目(名称匹配 compress* / compact* / acp / summar*;裸 `context` 刻意不匹配——它指领域而非压缩动作本身,`context7`/`dsh-context` 这类只读工具不会误报);已验证的只读/仅显示插件(如 `pi-compact-transcript`、`pi-context-inspector`)直接豁免。dsh 的 `dsh-live-compact` 列为已知冲突而非关键词疑似:它是竞争压缩引擎——随包 `cordis.patch.yml` 禁用 stock `compaction-basic` 行、注册自己的引擎行(`compaction-spine`/`dsh-live-compact`)、preset 接管时把 preset 的压缩行改名成自己,而 bili 的加载期压缩禁用 overlay(#3354)只认 stock 行名,对它在结构上不可见,其压缩 checkpoint 会落在 bili 知识之外(#5984)。 - **发现结果的出口**:客户端启动前的 launcher stderr;每个会话首个请求的一次性代理 warn 日志(client 由 `x-bili-plugin` 头或 wire 头识别);会话冲突台账 —— `acp_status` 的 `COMPRESSION CONFLICTS` 段、`GET /__bili/stats` → `conflicts`、Web UI 横幅。 - **运行时证据,按证据层级展示(#2545)**:未宣告的历史改写(#1001)与孤儿块废弃(被摘要的内容从客户端历史中被删掉)与「疑似并存」记入同一台账。严重程度表面按**证据层级**分级:**已确认** = 检测到的客户端原生压缩落点(bili 会 rebase 到其上,#2372/#2432)或非 suspected 的插件发现——只有它会触发「请只保留一个压缩器」的强制告警;**未确认信号** = 未宣告改写 + 孤儿块废弃——观测到变化但原因未确认(「历史发生了变化,原因未知」),绝不呈现为原生自动压缩或第二个压缩器;纯名称匹配的 [suspected] 停留在软性的「先核实」层级(#1736)。指向已验证只读插件的存量台账记录在显示期被中和,而不是持续作为告警残留;跨会话聚合的未确认信号计数永远不会升级成「同一会话双压缩」的结论。 -- **dsh 的 `auto: false` 只关闭自动触发**。profile bundle patch(`dsh.bundle.patch.yml`)写入的 `compaction-basic: { auto: false }` 跳过压力/溢出自压缩 —— 手动 `/compact`(以及空闲会话压缩)仍会触发。经 bili 路由的调用会被服务端闸门拒绝(#1729/#2360);未经过 bili 直达上游的调用(桌面端插件接管门无法归因的路径)会落地,bili 在下次重放时检测出来(checkpoint 框架 + 折叠覆盖缺口),一个 turn 内重建自己的压缩状态,而不是让之后每次 compress 永久失败(#2432)。若目标是把 dsh 压缩**整个关掉**(含手动 `/compact`),delta 应写成同一行上的 `disabled: true`,而不是 `auto: false`(配方见下)。 +- **dsh 的 `auto: false` 只关闭自动触发**。profile bundle patch(`dsh.bundle.patch.yml`)写入的 `compaction-basic: { auto: false }` 跳过压力/溢出自压缩 —— 手动 `/compact`(以及空闲会话压缩)仍会触发。#5245 起,`bili-native` 缺席或被禁用时,gate transform 会把这行整体还原(宿主平面 `auto` 回到 `true`)—— 市场禁用可完整逆转。经 bili 路由的调用会被服务端闸门拒绝(#1729/#2360);未经过 bili 直达上游的调用(桌面端插件接管门无法归因的路径)会落地,bili 在下次重放时检测出来(checkpoint 框架 + 折叠覆盖缺口),一个 turn 内重建自己的压缩状态,而不是让之后每次 compress 永久失败(#2432)。若目标是把 dsh 压缩**整个关掉**(含手动 `/compact`),delta 应写成同一行上的 `disabled: true`,而不是 `auto: false`(配方见下)。 #### 在 web profile 下关掉 dsh 原生自动压缩(#1772/#3354,#3354 起自动;#2474 配方为回退) @@ -2512,7 +2512,7 @@ bili plugin remove pi # 撤销(原文件一次性备份为 *.bili-bak) overlay 依赖 dsh 的内部钩子,对版本敏感。若在新/旧 dsh 构建上仍见到 dsh 压缩 checkpoint 落地,用下面的回退配方。 - **禁用与移除的区别(#3662)。** 禁用 `bili-native`(dsh 插件管理器或 patch 层里的 `disabled: true`)不再会导致会话创建被「砖」:门控服务存活在独立的常驻条目 `bili-compaction-gate` 里,preset 回落到**原生**自动压缩而不是永久 pending —— 压缩关闭、dsh 完全可用。请勿禁用 `bili-compaction-gate` 本身(那会重新造成「砖」);要彻底卸载,从 profile 的 `dsh.profile.bundles` 移除 `billion-context` 后重启。卡在 #3662 之前版本且已被禁用的安装,升级即自愈;手动解砖是在 `$DSH_HOME/cordis.patch.yml`(HOME 层;默认 `~/.dsh/cordis.patch.yml`)追加 `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`,各配 `inject: null` —— 顶层键为整体替换,清掉 pending 锁。 + **禁用与移除的区别(#3662)。** 禁用 `bili-native`(dsh 插件管理器或 patch 层里的 `disabled: true`)不再会导致会话创建被「砖」:门控服务存活在独立的常驻条目 `bili-compaction-gate` 里,preset 回落到**原生**自动压缩而不是永久 pending,#5245 起 gate transform 还会还原 bundle patch 里宿主平面行的静态 `auto: false`(此前非 web profile 禁用后原生自动压缩一直关着)—— 压缩关闭、dsh 完全可用。请勿禁用 `bili-compaction-gate` 本身(那会重新造成「砖」);要彻底卸载,从 profile 的 `dsh.profile.bundles` 移除 `billion-context` 后重启。卡在 #3662 之前版本且已被禁用的安装,升级即自愈;手动解砖是在 `$DSH_HOME/cordis.patch.yml`(HOME 层;默认 `~/.dsh/cordis.patch.yml`)追加 `- id: preset-standard` / `preset-ptc` / `preset-minimal` / `preset-cordis`,各配 `inject: null` —— 顶层键为整体替换,清掉 pending 锁。 **回退配方(#2474)**(已在 dsh `0.2.1-alpha.1`、Windows 11、bundles 含 `@deepseek-ai/dsh-web-app` 的 profile 上实测)。profile 层补丁可以关掉它 —— preset 是 bundle 层插入的普通顶层条目,而 profile 补丁层在其之后应用。不能用「按 id 定位嵌套行」的写法,可行的是**整体覆盖 preset 行的 `config`**。 diff --git a/dsh.bundle.patch.yml b/dsh.bundle.patch.yml index d7b815f249..ebfa5ccd9b 100644 --- a/dsh.bundle.patch.yml +++ b/dsh.bundle.patch.yml @@ -11,6 +11,10 @@ # #3354; see src/agent/dsh-compaction-disable.ts). A profile-level full-snapshot # override of preset-standard (#2474) remains the fallback for dsh builds # whose internal 'internal/config' hook moved. +# #5245: this line stays declarative ON PURPOSE — fail-safe: if the gate entry +# fails to load while bili-native loads, the host plane must stay stood down. +# When bili-native is absent/disabled (no process verdict), the gate transform +# undoes exactly this line: host-plane auto returns to stock (dsh fully back). # #3662: the gate lives in its OWN always-on entry, not in bili-native — # disabling or kill-switching bili-native must leave the gate service alive so # the presets fall back to STOCK dsh compaction instead of pending forever diff --git a/src/agent/dsh-compaction-disable.ts b/src/agent/dsh-compaction-disable.ts index 4970e3d159..c67629d6fd 100644 --- a/src/agent/dsh-compaction-disable.ts +++ b/src/agent/dsh-compaction-disable.ts @@ -10,10 +10,12 @@ // Why it exists: when bili carries a dsh conversation it owns compression // (#1729); a dsh compaction checkpoint landing outside bili's knowledge // durably shadows the raw history and destroys the compression substrate. -// Non-web profiles already stand down the host-plane row via the bundle patch -// (auto:false); web profiles run their instance INSIDE an agent preset whose -// nested rows no patch layer can address by id (#1772/#2360) — this module is -// what reaches them. +// Non-web profiles stand down the host-plane row via the bundle patch +// (auto:false) WHILE bili owns the lane — and since #5245 the transform below +// undoes exactly that line when bili-native never declares itself active, so a +// market disable fully reverses to stock. Web profiles run their instance +// INSIDE an agent preset whose nested rows no patch layer can address by id +// (#1772/#2360) — this module is what reaches them. // #3662: the overlay lives in its OWN always-on entry (dsh-compaction-gate.ts) // rather than in bili-native — disabling or kill-switching bili-native must // leave the gate service alive so the presets fall back to STOCK dsh @@ -183,11 +185,27 @@ type MiddlewareSelf = { entry?: { options?: { name?: unknown } } | undefined }; export function registerCompactionDisable(ctx: CompactionDisableHost): void { if (typeof ctx.on === "function") { // Preset entries must carry the gate: sibling imports may finish out of order. - ctx.on("internal/config", function (this: MiddlewareSelf, _raw: unknown, next: () => unknown): unknown { + ctx.on("internal/config", function (fiber: unknown, next: () => unknown): unknown { const resolved = next(); // #3662: honor the process verdict — without an active declaration // from bili-native every row passes through stock. - if (!isDshCompactionActive()) return resolved; + if (!isDshCompactionActive()) { + // #5245: the bundle patch's static `compaction-basic → auto:false` + // line applies whenever the bundle is mounted — including while + // bili-native is disabled or dead — which left non-web profiles' + // native auto-compaction permanently off after a market disable. + // Undo exactly that line: only the host-plane compaction-basic + // entry, only when the patch armed it (auto === false). A user's + // own manual auto:false is indistinguishable at this layer and is + // restored too (documented edge); if a build never fires this + // hook for that entry, this degrades to the old behavior. + const rawName = (fiber as MiddlewareSelf | null | undefined)?.entry?.options?.name; + if (rawName === DSH_COMPACTION_BASIC_PACKAGE && resolved !== null && typeof resolved === "object" && !Array.isArray(resolved)) { + const cfg = resolved as Record; + if (cfg.auto === false) return { ...cfg, auto: true }; + } + return resolved; + } // #4147: match STRUCTURALLY, not by entry name — custom presets run // their compaction inside nested rows under their own entry, and a // name filter leaves exactly those armed. Rewrite only when the @@ -197,7 +215,7 @@ export function registerCompactionDisable(ctx: CompactionDisableHost): void { if (!Array.isArray(config.plugins)) return resolved; const compactionRows = countCompactionRows(config.plugins); if (compactionRows === 0) return resolved; - const rawName = this?.entry?.options?.name; + const rawName = (fiber as MiddlewareSelf | null | undefined)?.entry?.options?.name; const entryName = typeof rawName === "string" ? rawName : "unnamed-entry"; noteGateCoverage(entryName.slice(0, 120), compactionRows, entryName === DSH_AGENT_PRESET_PACKAGE); return { ...config, plugins: disableBasicCompaction(config.plugins) }; diff --git a/src/launcher.ts b/src/launcher.ts index b09d4a80ad..6ccae01bb3 100644 --- a/src/launcher.ts +++ b/src/launcher.ts @@ -3611,7 +3611,7 @@ export function writeDshAcpPatch(dshHome: string, entryName?: string): string | writeOverlayFileAtomic( dir, ".bili-acp.patch.yml", - `- insert:\n - id: bili-native\n name: ${pluginUrl}\n - id: bili-compaction-gate\n name: ${gateUrl}\n- id: compaction-basic\n config:\n auto: false\n# #3354/#3662: keep in sync with dsh.bundle.patch.yml — web-profile presets run their own compaction-basic in nested rows no patch layer can address by id (#1772); these gates make them wait for the load-time overlay the always-on bili-compaction-gate entry registers (vendored from deshark42/dsh-compaction-basic-disable, MIT)\n${compactionDisablePatchRows()}# #2605: keep in sync with dsh.bundle.patch.yml — a patch replaces the row's whole config, so every default code is restated\n- id: llm-deepseek\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n- id: llm-deepseek-account\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n`, + `- insert:\n - id: bili-native\n name: ${pluginUrl}\n - id: bili-compaction-gate\n name: ${gateUrl}\n- id: compaction-basic\n config:\n auto: false\n# #3354/#3662: keep in sync with dsh.bundle.patch.yml — web-profile presets run their own compaction-basic in nested rows no patch layer can address by id (#1772); these gates make them wait for the load-time overlay the always-on bili-compaction-gate entry registers (vendored from deshark42/dsh-compaction-basic-disable, MIT); #5245: with no bili-native verdict the gate transform restores the static auto:false line above to stock\n${compactionDisablePatchRows()}# #2605: keep in sync with dsh.bundle.patch.yml — a patch replaces the row's whole config, so every default code is restated\n- id: llm-deepseek\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n- id: llm-deepseek-account\n config:\n retryPolicy:\n mode: normal\n retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, MALFORMED_RESPONSE]\n`, ); const file = path.join(dir, ".bili-acp.patch.yml"); try { diff --git a/tests/issue3354-dsh-compaction-disable.test.ts b/tests/issue3354-dsh-compaction-disable.test.ts index 0474d9ef2a..6b47678fb7 100644 --- a/tests/issue3354-dsh-compaction-disable.test.ts +++ b/tests/issue3354-dsh-compaction-disable.test.ts @@ -120,7 +120,7 @@ test("#3354 registerCompactionDisable: transform honors the entry predicate and ]; const cfg: Record = { plugins, isolate: { compaction: true } }; const self = { entry: { options: { name: "@deepseek-ai/dsh-agent-preset" } } }; - const out = mw?.call(self, null, () => cfg) as { plugins?: Array>; isolate?: Record }; + const out = mw?.call(null, self, () => cfg) as { plugins?: Array>; isolate?: Record }; assert.deepEqual(out.isolate, { compaction: true }); assert.equal(out.plugins?.[0]?.disabled, true); assert.equal(out.plugins?.[1]?.disabled, true); @@ -129,13 +129,13 @@ test("#3354 registerCompactionDisable: transform honors the entry predicate and // compaction rows is rewritten too (custom presets), while an entry // whose plugins carry none keeps its resolved config object identity. const custom: Record = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - const customOut = mw?.call({ entry: { options: { name: "preset-general" } } }, null, () => custom) as { plugins?: Array> }; + const customOut = mw?.call(null, { entry: { options: { name: "preset-general" } } }, () => custom) as { plugins?: Array> }; assert.equal(customOut.plugins?.[0]?.disabled, true); const untouched: Record = { plugins: [{ name: "@deepseek-ai/dsh-other" }] }; - assert.equal(mw?.call({ entry: { options: { name: "other-entry" } } }, null, () => untouched), untouched); - assert.equal(mw?.call(undefined, null, () => untouched), untouched); + assert.equal(mw?.call(null, { entry: { options: { name: "other-entry" } } }, () => untouched), untouched); + assert.equal(mw?.call(null, undefined, () => untouched), untouched); // next() returning nothing → verbatim passthrough - assert.equal(mw?.call(self, null, () => undefined), undefined); + assert.equal(mw?.call(null, self, () => undefined), undefined); } finally { _resetDshCompactionVerdictForTest(); } diff --git a/tests/issue3662-dsh-gate-fallback.test.ts b/tests/issue3662-dsh-gate-fallback.test.ts index dfd5869d12..c3ef08dde1 100644 --- a/tests/issue3662-dsh-gate-fallback.test.ts +++ b/tests/issue3662-dsh-gate-fallback.test.ts @@ -46,6 +46,9 @@ function mockGateHost() { }; } const PRESET_SELF = { entry: { options: { name: "@deepseek-ai/dsh-agent-preset" } } }; +// #5245: the host-plane compaction-basic entry — its resolved config is the +// plugin's own config, which the bundle patch replaces wholesale with {auto:false} +const BASIC_SELF = { entry: { options: { name: "@deepseek-ai/dsh-compaction-basic" } } }; function presetPlugins(): Array> { return [ { name: "@deepseek-ai/dsh-compaction-basic", config: { auto: true } }, @@ -94,7 +97,7 @@ test("#3662: bili-native absent (disabled / kill-switched) — service still pro const mw = raw as (raw: unknown, next: () => unknown) => unknown; const plugins = presetPlugins(); const cfg: Record = { plugins, x: 1 }; - const out = mw.call(PRESET_SELF, null, () => cfg) as Record; + const out = mw.call(null, PRESET_SELF, () => cfg) as Record; assert.equal(out, cfg, "absent verdict must pass the resolved config through verbatim"); for (const row of plugins) assert.equal(row.disabled, undefined); } finally { @@ -102,6 +105,47 @@ test("#3662: bili-native absent (disabled / kill-switched) — service still pro } }); +test("#5245: bili-native absent — the static bundle-patch auto:false line is undone, host plane back to stock", () => { + try { + _resetDshCompactionVerdictForTest(); + assert.ok(!isDshCompactionActive()); + const m = mockGateHost(); + gate.apply(m.host); + const mw = m.middleware() as (raw: unknown, next: () => unknown) => unknown; + // the bundle patch replaced the host-plane row's config wholesale with {auto:false} + const patched: Record = { auto: false }; + const out = mw.call(null, BASIC_SELF, () => patched) as Record; + assert.notEqual(out, patched, "the patched row must be rewritten, not passed through"); + assert.deepEqual(out, { auto: true }, "host-plane auto compaction restored to stock"); + assert.equal(patched.auto, false, "the input config must not be mutated"); + const multi: Record = { auto: false, foo: "bar" }; + assert.deepEqual(mw.call(null, BASIC_SELF, () => multi), { auto: true, foo: "bar" }, "other keys survive the restore"); + // negatives: nothing to restore ⇒ identity passthrough + const stock: Record = { auto: true }; + assert.equal(mw.call(null, BASIC_SELF, () => stock), stock, "already-stock row passes through verbatim"); + const otherEntry: Record = { auto: false }; + assert.equal(mw.call(null, { entry: { options: { name: "@deepseek-ai/dsh-other" } } }, () => otherEntry), otherEntry, "only the compaction-basic entry is targeted"); + const arr = [{ auto: false }]; + assert.equal(mw.call(null, BASIC_SELF, () => arr), arr, "array configs are not a compaction-basic shape"); + } finally { + _resetDshCompactionVerdictForTest(); + } +}); + +test("#5245: verdict active — the static line stays authoritative, host plane NOT restored", () => { + try { + _resetDshCompactionVerdictForTest(); + declareDshCompactionActive(); + const m = mockGateHost(); + gate.apply(m.host); + const mw = m.middleware() as (raw: unknown, next: () => unknown) => unknown; + const patched: Record = { auto: false }; + assert.equal(mw.call(null, BASIC_SELF, () => patched), patched, "active verdict leaves the host-plane row exactly as the patch wrote it"); + } finally { + _resetDshCompactionVerdictForTest(); + } +}); + test("#3662: normal boot (verdict active) — the gate entry disables the compaction rows", () => { try { _resetDshCompactionVerdictForTest(); @@ -114,7 +158,7 @@ test("#3662: normal boot (verdict active) — the gate entry disables the compac const mw = raw as (raw: unknown, next: () => unknown) => unknown; const plugins = presetPlugins(); const cfg: Record = { plugins, x: 1 }; - const out = mw.call(PRESET_SELF, null, () => cfg) as { plugins?: Array>; x?: number }; + const out = mw.call(null, PRESET_SELF, () => cfg) as { plugins?: Array>; x?: number }; assert.equal(out.x, 1); assert.deepEqual(out.plugins?.[0]?.config, { auto: true }); assert.equal(out.plugins?.[0]?.disabled, true); @@ -124,9 +168,9 @@ test("#3662: normal boot (verdict active) — the gate entry disables the compac // they nest no compaction rows — a custom preset nesting them is // rewritten (structural match), unrelated config keeps identity. const otherCfg: Record = { plugins: [{ name: "@deepseek-ai/dsh-other" }] }; - assert.equal(mw.call({ entry: { options: { name: "something-else" } } }, null, () => otherCfg), otherCfg); + assert.equal(mw.call(null, { entry: { options: { name: "something-else" } } }, () => otherCfg), otherCfg); const customCfg: Record = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - const customOut = mw.call({ entry: { options: { name: "preset-general" } } }, null, () => customCfg) as { plugins?: Array> }; + const customOut = mw.call(null, { entry: { options: { name: "preset-general" } } }, () => customCfg) as { plugins?: Array> }; assert.equal(customOut.plugins?.[0]?.disabled, true); } finally { _resetDshCompactionVerdictForTest(); diff --git a/tests/issue4147-dsh-overlay-structural.test.ts b/tests/issue4147-dsh-overlay-structural.test.ts index 6cadef1222..2780ec4a67 100644 --- a/tests/issue4147-dsh-overlay-structural.test.ts +++ b/tests/issue4147-dsh-overlay-structural.test.ts @@ -43,7 +43,7 @@ test("#4147: custom preset entries nesting compaction rows are rewritten (group { name: "@deepseek-ai/dsh-command-compact" }, ], }; - const out = mw.call({ entry: { options: { name: "preset-general" } } }, null, () => cfg) as { plugins: Array> }; + const out = mw.call(null, { entry: { options: { name: "preset-general" } } }, () => cfg) as { plugins: Array> }; assert.equal(out.plugins[0].disabled, undefined, "unrelated sibling row untouched"); const group = out.plugins[1] as { config: Array> }; assert.equal(group.config[0].disabled, true, "nested group row disabled"); @@ -66,9 +66,9 @@ test("#4147 negative: no compaction rows → resolved config object identity kep declareDshCompactionActive(); const mw = middleware(); const unrelated = { plugins: [{ name: "@deepseek-ai/dsh-tool-result-pruner" }] }; - assert.equal(mw.call({ entry: { options: { name: "preset-shipin" } } }, null, () => unrelated), unrelated); + assert.equal(mw.call(null, { entry: { options: { name: "preset-shipin" } } }, () => unrelated), unrelated); const noPlugins = { other: 1 }; - assert.equal(mw.call({ entry: { options: { name: "preset-shipin" } } }, null, () => noPlugins), noPlugins); + assert.equal(mw.call(null, { entry: { options: { name: "preset-shipin" } } }, () => noPlugins), noPlugins); assert.equal(dshCompactionGateTelemetry(), null, "no rewrite, no coverage record"); } finally { _resetDshCompactionVerdictForTest(); @@ -82,7 +82,7 @@ test("#4147/#3662 negative: absent verdict → stock passthrough records nothing _resetDshCompactionGateTelemetryForTest(); const mw = middleware(); const cfg = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - const out = mw.call({ entry: { options: { name: "preset-general" } } }, null, () => cfg) as { plugins: Array> }; + const out = mw.call(null, { entry: { options: { name: "preset-general" } } }, () => cfg) as { plugins: Array> }; assert.equal(out, cfg, "verbatim passthrough"); assert.equal((cfg.plugins as Array>)[0].disabled, undefined); assert.equal(dshCompactionGateTelemetry(), null, "stock passthrough leaves no coverage record"); @@ -99,13 +99,13 @@ test("#3962: telemetry dedups per entry, keeps the max row count, flags the fact declareDshCompactionActive(); const mw = middleware(); const one = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - mw.call({ entry: { options: { name: "preset-general" } } }, null, () => one); + mw.call(null, { entry: { options: { name: "preset-general" } } }, () => one); const two = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }, { name: "@deepseek-ai/dsh-command-compact" }] }; - mw.call({ entry: { options: { name: "preset-general" } } }, null, () => two); + mw.call(null, { entry: { options: { name: "preset-general" } } }, () => two); const factory = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - mw.call({ entry: { options: { name: "@deepseek-ai/dsh-agent-preset" } } }, null, () => factory); + mw.call(null, { entry: { options: { name: "@deepseek-ai/dsh-agent-preset" } } }, () => factory); const unnamed = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - mw.call(undefined, null, () => unnamed); + mw.call(null, undefined, () => unnamed); const t = dshCompactionGateTelemetry()!; assert.deepEqual(t.covered.find((c) => c.entry === "preset-general"), { entry: "preset-general", rows: 2 }, "dedup keeps the max count"); assert.equal(t.covered.some((c) => c.entry === "unnamed-entry"), true, "missing entry name still recorded"); @@ -126,7 +126,7 @@ test("#3962: long entry names (URLs) are truncated for the durable note", () => const mw = middleware(); const longName = "file:///".padEnd(200, "x"); const cfg = { plugins: [{ name: "@deepseek-ai/dsh-compaction-basic" }] }; - mw.call({ entry: { options: { name: longName } } }, null, () => cfg); + mw.call(null, { entry: { options: { name: longName } } }, () => cfg); const t = dshCompactionGateTelemetry()!; assert.equal(t.covered[0].entry.length, 120); } finally {