billion-context 0.1.133 → 0.1.134-pr.1084.966
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -24
- package/README.zh-CN.md +4 -10
- package/dist/index.js +519 -401
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -810,30 +810,6 @@ The file auto-rotates at 10 MB (renamed to `bili.log.old`). Cache-hit stats
|
|
|
810
810
|
per request are logged as `[acp-usage] round N input=X cached=Y (cache hit Z%)`
|
|
811
811
|
so you can measure prefix-cache health directly from the log.
|
|
812
812
|
|
|
813
|
-
### Chaining bili instances (bili → bili)
|
|
814
|
-
|
|
815
|
-
When one bili's upstream is another bili (`client → A → B → LLM`), only the
|
|
816
|
-
instance closest to the client should run the compression pipeline — a second
|
|
817
|
-
pass would double-compress and corrupt session state. Any of three signals on
|
|
818
|
-
the inbound request makes the downstream instance pass it through **verbatim**
|
|
819
|
-
(no tool/tag injection, no acp-loop, no session state):
|
|
820
|
-
|
|
821
|
-
- `x-bili-hop` — stamped with the processing instance's id on every processed
|
|
822
|
-
emission (#300). Clients never send this header, so its presence always means
|
|
823
|
-
"came from a bili".
|
|
824
|
-
- `x-bili-sig` — sha256 digest of the exact emitted body bytes (#1078). Proves
|
|
825
|
-
no middlebox rewrote the request in transit; on mismatch the downstream
|
|
826
|
-
instance passes through anyway, because it must not process content it did
|
|
827
|
-
not produce.
|
|
828
|
-
- ACP artifacts in the body (render tags / context-management tool names) —
|
|
829
|
-
fallback for relays that strip bili's headers.
|
|
830
|
-
|
|
831
|
-
Every detection logs a prominent `[chain]` line (to `bili.log` and stderr)
|
|
832
|
-
naming the signal that fired. Older versions that stamp only `x-bili-hop` keep
|
|
833
|
-
working unchanged. If a third-party relay in your chain rewrites or strips
|
|
834
|
-
request bodies/headers, a `[chain]` warning on the downstream instance is the
|
|
835
|
-
safety mechanism working, not an error.
|
|
836
|
-
|
|
837
813
|
### Self-update
|
|
838
814
|
|
|
839
815
|
The proxy checks npm for a newer version on startup and every 3 minutes. When a
|
|
@@ -1025,6 +1001,20 @@ protection → Manage settings → Exclusions → Add an exclusion → Folder) a
|
|
|
1025
1001
|
make sure no sync tool (OneDrive / Dropbox / …) is syncing that path. Full
|
|
1026
1002
|
steps in [CONFIGURATION.md](CONFIGURATION.md#windows-exclude-the-sessions-dir-from-antivirus-362).
|
|
1027
1003
|
|
|
1004
|
+
### Session file cleanup (#1082)
|
|
1005
|
+
|
|
1006
|
+
Short-lived sessions leave small state files behind that are never resumed.
|
|
1007
|
+
With persistence enabled, bili sweeps the sessions dir at boot and hourly:
|
|
1008
|
+
files older than `BILI_SESSION_GC_MAX_AGE_DAYS` (default 7 days) whose newest
|
|
1009
|
+
request body was ≤ `BILI_SESSION_GC_MAX_TOKENS` tokens (default 1M) are
|
|
1010
|
+
deleted — resuming the conversation rebuilds the context from the client's
|
|
1011
|
+
own history, so the cost is one cold rebuild. Older files without a recorded
|
|
1012
|
+
size need no active compression blocks and `contextTokens` under the same
|
|
1013
|
+
ceiling. Live sessions, unreadable files, and encrypted files are handled
|
|
1014
|
+
conservatively (decoded via `BILI_ENCRYPTION_KEY` before judging). Set
|
|
1015
|
+
`BILI_SESSION_GC=0` to disable. Details in
|
|
1016
|
+
[CONFIGURATION.md](CONFIGURATION.md#environment-variables).
|
|
1017
|
+
|
|
1028
1018
|
## Status
|
|
1029
1019
|
|
|
1030
1020
|
Early. Protocol handling and compression work against mock tests (500+ passing). Real-model integration testing is the next milestone. Expect rough edges.
|
package/README.zh-CN.md
CHANGED
|
@@ -402,16 +402,6 @@ bili --host 0.0.0.0 # 所有网卡(或直接用局域网 IP)
|
|
|
402
402
|
|
|
403
403
|
文件超过 10 MB 自动轮转(重命名为 `bili.log.old`)。每个请求的缓存命中统计会以 `[acp-usage] round N input=X cached=Y (cache hit Z%)` 打印,可直接从日志衡量前缀缓存健康度。
|
|
404
404
|
|
|
405
|
-
### 串联多个 bili(bili → bili)
|
|
406
|
-
|
|
407
|
-
当一个 bili 的 upstream 指向另一个 bili(`客户端 → A → B → LLM`)时,只有离客户端最近的那个实例应该执行压缩管线——二次处理会重复压缩并破坏会话状态。入站请求上任意一个信号命中,下游实例都会**原样透传**该请求(不注入工具/标签、不跑 acp-loop、不建会话状态):
|
|
408
|
-
|
|
409
|
-
- `x-bili-hop` —— 处理方实例在每次处理后的转发上盖自己的实例 id(#300)。客户端永远不会发这个头,所以它的出现一定意味着"来自某个 bili"。
|
|
410
|
-
- `x-bili-sig` —— 转发体字节的 sha256 摘要(#1078)。用来证明请求在途中没有被中间设备改写;摘要不符时下游同样直接透传,因为它不能处理自己没有产出的内容。
|
|
411
|
-
- 请求体中的 ACP 产物(render 标签 / 上下文管理工具名)—— 针对会剥掉 bili 请求头的中转站的兜底检测。
|
|
412
|
-
|
|
413
|
-
每次命中都会在 `bili.log`(及 stderr)打一条醒目的 `[chain]` 日志,标明触发信号。只盖 `x-bili-hop` 的旧版本行为不变。如果你的链路里有第三方中转站会改写或剥离请求体/头,下游实例出现的 `[chain]` 警告是安全机制在工作,不是错误。
|
|
414
|
-
|
|
415
405
|
### 自动更新
|
|
416
406
|
|
|
417
407
|
代理启动时和每 3 分钟检查 npm 是否有新版本。发现新版本就全局安装(`npm install -g`)并打印通知 —— **重启 `bili` 才能生效**。
|
|
@@ -505,6 +495,10 @@ Windows 下会自动发现常见 Clash/Mihomo 静态系统代理;Web UI 会显
|
|
|
505
495
|
|
|
506
496
|
当同一会话连续 N 次写失败(默认 `5`)时,代理会打一条一次性、可操作的告警,明确指出要排除的目录。要从根上修复:把 `%USERPROFILE%\.local\share\billion-context\` 加入杀软**排除项**(Windows Defender:设置 → 病毒和威胁防护 → 管理设置 → 排除项 → 添加排除 → 文件夹),并确认没有同步工具(OneDrive / Dropbox / …)在同步该路径。完整步骤见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md) 的「Windows:把会话目录加入杀软排除项」章节。
|
|
507
497
|
|
|
498
|
+
### 会话文件清理(#1082)
|
|
499
|
+
|
|
500
|
+
短命会话会留下永远不会再被恢复的小状态文件。持久化开启时,bili 在启动时和每小时扫描一次会话目录:年龄超过 `BILI_SESSION_GC_MAX_AGE_DAYS`(默认 7 天)且最近一次请求体 token 数 ≤ `BILI_SESSION_GC_MAX_TOKENS`(默认 1M)的文件会被删除 —— 继续对话会用客户端自己的历史重建上下文,代价只是一次冷重建。没有记录大小的旧文件则要求**没有活跃压缩块**且 `contextTokens` 不超过同一上限。活会话、不可读文件和加密文件(判断前先用 `BILI_ENCRYPTION_KEY` 解码)都按保守策略处理。设 `BILI_SESSION_GC=0` 可关闭。详见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md)。
|
|
501
|
+
|
|
508
502
|
## 状态
|
|
509
503
|
|
|
510
504
|
早期。协议处理和压缩已通过 mock 测试(500+ 项通过)。真实模型集成测试是下一里程碑。预期会有粗糙的地方。
|