Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,8 @@ File keys resolve only when the matching env var is unset. Defaults in parenthes
| `BILI_UPDATE_REGISTRY` | Base URL override for the npm registry used by the auto-updater and `bili update` (default `https://registry.npmjs.org`). Intended for hermetic testing against a loopback registry (the verdaccio instance in the `ACP_TEST_REGISTRY` e2e suite); leave unset in production (#1153). |
| `BILI_UPDATE_CHECK_INTERVAL_MS` | Auto-update check period in milliseconds (default `180000`, i.e. 3 minutes; values ≤ 0 are ignored and the default applies). Shortened by the hermetic e2e suite so it never waits a full cycle (#1153). |
| `BILI_MODEL_INFO_RETRY_MS` | Cooldown (ms) before the dsh native plugin re-resolves the current model's context window after a resolve that failed or returned no window (#1812/#1836): a cached entry without a window is not final — instead of latching headerless for the process lifetime, the next request after this cooldown triggers a retry. Default `30000`; non-numeric or negative values fall back to `30000`. Test hook — shortened by the dsh-native unit test so it never waits wall-clock; leave unset in production. |
| `BILI_DSH_RETRY_INTERVAL_MS` | Back-off (ms) between dsh native plugin tool-registration retries (#2082): after a manifest fetch or tool registration fails transiently, the next retry happens no sooner than this cooldown. Default `10000`; non-numeric or non-positive values fall back to `10000`. Test hook — shortened by the dsh-native unit tests so they never wait wall-clock; leave unset in production. |
| `BILI_DSH_RECOVERY_INTERVAL_MS` | Interval (ms) of the dsh native plugin's detached recovery timer (#2082): while the tools are down it keeps driving registration retries with zero model traffic — the case where the model already gave up on the missing tools and nothing else re-arms the loop. Defaults to following `BILI_DSH_RETRY_INTERVAL_MS` (`10000`). Test hook — under NODE_TEST_CONTEXT the timer never starts unless this var is set explicitly; leave unset in production. |
| `BILI_ADVISORY_CHECK` | Set to `0` to disable the critical-defect advisory watcher (#1481). Default ON — it runs independently of `ACP_AUTO_UPDATE` so that installs with auto-update off still get force-updated out of a known-broken version range. Fail-open: an unreachable/malformed source only warns, never blocks model traffic. File-config key: `advisoryCheck`. |
| `BILI_ADVISORY_URL` | Override for the advisory document URL. Default: the companion package `billion-context-advisories` on the configured registry (`BILI_UPDATE_REGISTRY` aware). File-config key: `advisoryUrl`. |
| `BILI_RELEASE_NOTES_CHECK` | Set to `0` to disable the release-notes visibility watcher (#1870). Default ON — pure visibility, silent by default (#1977): fetches the companion release-notes doc and surfaces "CRITICAL update ready — restart to finish" (disk newer than running) or "critical update available" on `acp_status` and the `/acp` panel ONLY when the pending span contains a `critical`-tier entry; routine/recommended releases never surface. Never installs, never restarts; fail-open. File-config key: `releaseNotesCheck`. |
Expand Down
2 changes: 2 additions & 0 deletions CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@
| `BILI_UPDATE_REGISTRY` | 自动更新与 `bili update` 使用的 npm registry base URL 覆盖(默认 `https://registry.npmjs.org`)。仅供 hermetic 测试指向回环 registry(`ACP_TEST_REGISTRY` e2e 套件自带的 verdaccio 实例);生产环境请勿设置(#1153)。 |
| `BILI_UPDATE_CHECK_INTERVAL_MS` | 自动更新检查周期(毫秒,默认 `180000` 即 3 分钟;≤ 0 的值被忽略,回退默认)。hermetic e2e 套件用它缩短周期,避免等待完整间隔(#1153)。 |
| `BILI_MODEL_INFO_RETRY_MS` | dsh 原生模型窗口解析失败(或解析结果不带窗口)后的重试冷却(毫秒,#1812/#1836):匹配的缓存条目没有 context window 时不视为最终结果 —— 不再让整个进程生命周期 latching 成无 header 状态,而是该冷却过期后由下一个请求触发重新解析。默认 `30000`;非数字或负值回退 `30000`。测试钩子 —— dsh-native 单元测试用它缩短冷却、避免真实等待;生产环境保持 unset。 |
| `BILI_DSH_RETRY_INTERVAL_MS` | dsh 原生插件工具注册重试的退避冷却(毫秒,#2082):manifest 拉取或工具注册瞬时失败后,下一次重试不早于该冷却发生。默认 `10000`;非数字或非正值回退 `10000`。测试钩子 —— dsh-native 单元测试用它缩短冷却、避免真实等待;生产环境保持 unset。 |
| `BILI_DSH_RECOVERY_INTERVAL_MS` | dsh 原生插件独立恢复定时器的间隔(毫秒,#2082):工具处于 down 状态时,即使零模型流量也持续驱动注册重试 —— 正是模型已放弃缺失工具、其他路径都不会再触发重试的场景。默认跟随 `BILI_DSH_RETRY_INTERVAL_MS`(`10000`)。测试钩子 —— NODE_TEST_CONTEXT 下除非显式设置本变量,否则定时器永不启动;生产环境保持 unset。 |
| `BILI_ADVISORY_CHECK` | 设为 `0` 禁用严重缺陷公告监视器(#1481)。默认开启 —— 它独立于 `ACP_AUTO_UPDATE` 运行,确保关闭了自动更新的安装也能被强制移出已知缺陷版本范围。fail-open:公告源不可达/格式错误只告警,绝不阻断模型流量。文件配置键:`advisoryCheck`。 |
| `BILI_ADVISORY_URL` | 公告文档 URL 覆盖。默认:已配置 registry(感知 `BILI_UPDATE_REGISTRY`)上的伴生包 `billion-context-advisories`。文件配置键:`advisoryUrl`。 |
| `BILI_RELEASE_NOTES_CHECK` | 设为 `0` 禁用发版说明可见性监视器(#1870)。默认开启 —— 纯可见性,且默认静默(#1977):拉取伴生发版说明文档,仅当待更新跨度内含 `critical` 级条目时,才在 `acp_status` 与 `/acp` 面板提示「CRITICAL 更新已就绪待重启」(磁盘版本新于运行版本)或「存在 critical 更新」;routine/recommended 级发版永不上屏。绝不安装、绝不重启;fail-open。文件配置键:`releaseNotesCheck`。 |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "billion-context",
"version": "0.1.183",
"version": "0.1.184",
"description": "A context-compression plugin — small context windows (a 100K context is enough), 5x fewer tokens, month-long single sessions (billions of tokens), and compression quality — for all agents: pi, OpenCode, Codex, Claude Code, and more. billion-context is all you need.",
"type": "module",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions release-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"schema": 1,
"updated": "2026-10-04",
"releases": [
{
"version": "0.1.184",
"date": "2026-10-04",
"tier": "critical",
"summary": "Desktop (dsh): after 0.1.179, an update could make bili tools vanish until restart (#2082) — now self-healing, broken desktop updates roll back; also fixes tool-call misrouting (#2072). Restart dsh once. 丨 桌面版修复:0.1.179 后升级会使 bili 工具消失(#2082),现已自愈;损坏的桌面更新自动回滚;另修 #2072 调用错路由。升级后重启一次 dsh。"
},
{
"version": "0.1.182",
"date": "2026-10-04",
Expand Down
37 changes: 33 additions & 4 deletions src/agent/dsh-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,11 @@ async function registerTools(ctx: PluginContext): Promise<void> {
if (register.toolsReady || base === undefined) return;
register.pending = (async () => {
const tools = await fetchManifest(base, "anthropic");
for (const tool of tools) ctx.tools.register(toolDefinition(tool));
// #2082: land on the CURRENT context, not the one that started this
// flight — a re-activation mid-fetch must not register into (or die
// on) the deactivated context captured at call time.
const target = activeCtx ?? ctx;
for (const tool of tools) target.tools.register(toolDefinition(tool));
register.toolsReady = true;
})()
.catch((err: unknown) => {
Expand Down Expand Up @@ -491,12 +495,20 @@ async function registerTools(ctx: PluginContext): Promise<void> {
// ops knob); absent it tracks RETRY_INTERVAL_MS. Tests that do not opt in
// never start a timer at all (NODE_TEST_CONTEXT guard keeps suites quiet).
let recoveryTimer: NodeJS.Timeout | undefined;
// #2082: the LATEST context seen by apply()/maybeRetry. Every async recovery
// path (the timer tick below, an in-flight registration landing after a
// re-activation) must resolve its context at landing time, not from a capture
// taken when the retry was armed — a captured context may already be
// deactivated by then (dsh reload / profile switch), and registering into it
// throws "inactive context" and would re-poison register.dead, exactly what
// this fix removes.
let activeCtx: PluginContext | undefined;
function recoveryIntervalMs(): number {
const raw = process.env.BILI_DSH_RECOVERY_INTERVAL_MS;
const parsed = raw === undefined ? Number.NaN : Number(raw);
return Number.isFinite(parsed) && parsed > 0 ? parsed : RETRY_INTERVAL_MS;
}
function armRecoveryTimer(ctx: PluginContext): void {
function armRecoveryTimer(): void {
if (recoveryTimer !== undefined) return;
if (process.env.NODE_TEST_CONTEXT !== undefined && process.env.BILI_DSH_RECOVERY_INTERVAL_MS === undefined) return;
recoveryTimer = setInterval(() => {
Expand All @@ -505,13 +517,15 @@ function armRecoveryTimer(ctx: PluginContext): void {
recoveryTimer = undefined;
return;
}
maybeRetry(ctx);
const ctx = activeCtx;
if (ctx !== undefined) maybeRetry(ctx);
}, recoveryIntervalMs());
recoveryTimer.unref?.();
}

function maybeRetry(ctx: PluginContext): void {
if (!register.dead && !register.toolsReady) armRecoveryTimer(ctx);
activeCtx = ctx;
if (!register.dead && !register.toolsReady) armRecoveryTimer();
if (register.dead || register.toolsReady) return;
if (register.pending !== undefined) return;
if (Date.now() < register.retryAt) return;
Expand Down Expand Up @@ -712,7 +726,21 @@ export function apply(ctx: PluginContext): void {
// switch, a settings toggle) poisons register.dead for the whole process
// lifetime: every later maybeRetry() returns immediately and the bili
// tools never come back until dsh restarts.
const prevCtx = activeCtx;
register.dead = false;
activeCtx = ctx;
// #2101: a genuinely fresh context (dsh deactivated the prior one — profile
// switch / settings toggle / desktop copy swap — and re-applied on the SAME
// module instance) invalidates tools registered into the dead context.
// Keeping toolsReady would make registerTools short-circuit for the new
// context while headersFor keeps stamping x-bili-plugin, so the proxy
// suppresses wire tool injection and the model loses the bili tools until
// dsh restarts (the #2082 symptom via a different route). Clearing it lets
// the state.toolsReady gate below hold the first request until the new
// registration lands. Same-context re-apply must NOT clear it — no
// gratuitous re-registration churn. If the host re-imported the module
// instead, toolsReady is already false and this is a no-op.
if (prevCtx !== undefined && prevCtx !== ctx) register.toolsReady = false;

// #1590: the dsh web-profile settings panel shows a "bili设置" entry
// (dsh-native-client.js) that opens this proxy's Web UI. The origin is
Expand Down Expand Up @@ -1065,6 +1093,7 @@ export function _resetRegisterForTest(base: string | undefined): void {
clearInterval(recoveryTimer);
recoveryTimer = undefined;
}
activeCtx = undefined;
register.base = base;
register.toolsReady = false;
register.dead = false;
Expand Down
Loading
Loading