billion-context 0.1.80 → 0.1.81-pr.512.334
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 +58 -1
- package/README.zh-CN.md +38 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -112,6 +112,63 @@ turn is a semantic mismatch the model tolerates (it is clearly marked
|
|
|
112
112
|
summaries (their tool call isn't in the agent's history and the agent's view
|
|
113
113
|
skips `acp_summary`) — but that needs the id match above, which doesn't occur.
|
|
114
114
|
|
|
115
|
+
## Which do I need? — billion-context vs billion-context-pi vs opencode-acp
|
|
116
|
+
|
|
117
|
+
Three names keep appearing around this project. They are **different layers of
|
|
118
|
+
the same idea** — context compression for coding agents — not three competing
|
|
119
|
+
products you must pick one of. Here is how they relate:
|
|
120
|
+
|
|
121
|
+
| Name | What it is | Where it runs | Status today |
|
|
122
|
+
|---|---|---|---|
|
|
123
|
+
| **billion-context** (`bili`) | The universal compression **proxy**, plus thin built-in client-side plugins for pi / omp / opencode. One install covers every client. | A local proxy process; a small plugin injected per client | ✅ **The one you install.** Active, maintained in this repo. |
|
|
124
|
+
| **billion-context-pi** | The original standalone **pi extension** (the 0.1.x reference implementation). Its pi plugin has since moved *into* `billion-context`. | Inside the pi process | 🟡 **Superseded.** Now lives inside `billion-context`; the old package self-disables when run behind `bili`. Do not install it separately. |
|
|
125
|
+
| **opencode-acp** | A standalone **opencode plugin** that provides native ACP compression with no proxy at all. | Inside the opencode process | 🟢 Standalone option, **opencode only**. Self-disables automatically when run behind `bili`. |
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
┌────────────────────────────────────────────────┐
|
|
129
|
+
│ billion-context (bili) ← install THIS │
|
|
130
|
+
│ │
|
|
131
|
+
│ the proxy ────── wire-level compression │
|
|
132
|
+
│ + built-in plugins (pi / omp / opencode) │
|
|
133
|
+
└────────────────────────────────────────────────┘
|
|
134
|
+
▲ ▲ ▲
|
|
135
|
+
any client ────┘ pi / omp ─────┘ opencode ───┘
|
|
136
|
+
via /bili/ or MITM bili pi / bili omp bili opencode
|
|
137
|
+
(built-in plugin) (built-in plugin)
|
|
138
|
+
|
|
139
|
+
billion-context-pi = legacy standalone pi ext → merged into billion-context
|
|
140
|
+
opencode-acp = standalone opencode-only native compression (no proxy)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**When to pick which:**
|
|
144
|
+
|
|
145
|
+
- **Default — use `billion-context` (`bili`).** Any coding agent that can set a
|
|
146
|
+
base URL: point it at `/bili/`, or run `bili <client>`. One tool handles every
|
|
147
|
+
client and owns all compression state. If you remember only one row above,
|
|
148
|
+
remember this one.
|
|
149
|
+
- **pi / omp** → use `billion-context`'s built-in plugin: `bili pi` / `bili omp`
|
|
150
|
+
(launcher), or `bili plugin install pi` for a persistent install. **Do not
|
|
151
|
+
install the old `billion-context-pi` package** — it was merged into
|
|
152
|
+
`billion-context` and self-disables behind `bili`. A stale `npm:billion-context-pi`
|
|
153
|
+
entry is replaced automatically by `bili plugin install pi`.
|
|
154
|
+
- **omp specifically:** omp is pi-based, so it rides the same mechanism as pi
|
|
155
|
+
but with its own plugin — `billion-context` ships `dist/agent/omp.js`,
|
|
156
|
+
injected by the launcher over a persistent overlay home (your real omp config
|
|
157
|
+
is never touched). In short: **omp goes through `billion-context`, not
|
|
158
|
+
`billion-context-pi`.**
|
|
159
|
+
- **opencode** → two options:
|
|
160
|
+
- **Standalone, no proxy:** install [`opencode-acp`](https://github.com/ranxianglei/opencode-acp)
|
|
161
|
+
alone → native ACP compression inside opencode, no `bili` process. Good if
|
|
162
|
+
opencode is your only client and you don't want a separate proxy running.
|
|
163
|
+
- **Behind `bili`:** run `bili opencode` → `billion-context`'s built-in
|
|
164
|
+
opencode plugin takes over, and your host's `opencode-acp` auto self-disables
|
|
165
|
+
so the proxy owns the ACP tools (no double compression). Good if you also
|
|
166
|
+
route other clients through the same proxy.
|
|
167
|
+
|
|
168
|
+
**TL;DR:** only opencode and no proxy wanted → `opencode-acp`. Anything else
|
|
169
|
+
(any client, or several clients) → `billion-context`. Never install
|
|
170
|
+
`billion-context-pi` on its own again — it lives inside `billion-context` now.
|
|
171
|
+
|
|
115
172
|
## Install
|
|
116
173
|
|
|
117
174
|
```bash
|
|
@@ -382,7 +439,7 @@ pass an explicit `x-acp-session` header per conversation to avoid collisions.
|
|
|
382
439
|
|
|
383
440
|
Early. Protocol handling and compression work against mock tests (500+ passing). Real-model integration testing is the next milestone. Expect rough edges.
|
|
384
441
|
|
|
385
|
-
|
|
442
|
+
The pi / omp / opencode client extensions now live **inside `billion-context`** (`dist/agent/*.js`). See the **"Which do I need?"** section above for how `billion-context`, the legacy `billion-context-pi` package, and `opencode-acp` relate.
|
|
386
443
|
|
|
387
444
|
## License
|
|
388
445
|
|
package/README.zh-CN.md
CHANGED
|
@@ -50,6 +50,43 @@ AI 编程助手的<strong>通用上下文压缩代理</strong>
|
|
|
50
50
|
|
|
51
51
|
代理向对话注入四个上下文管理工具(`compress`、`decompress`、`search_context`、`acp_status`)。模型在对话增长时调用 `compress`,代理在服务端执行 —— 压缩后的范围在下一轮之前折叠进对话历史。
|
|
52
52
|
|
|
53
|
+
## 该选哪个?—— billion-context / billion-context-pi / opencode-acp
|
|
54
|
+
|
|
55
|
+
围绕这个项目经常会出现三个名字。它们是<strong>同一件事(编程助手的上下文压缩)的不同层次</strong>,<em>不是三选一的对立产品</em>。它们的关系如下:
|
|
56
|
+
|
|
57
|
+
| 名字 | 是什么 | 跑在哪 | 现状 |
|
|
58
|
+
|---|---|---|---|
|
|
59
|
+
| **billion-context**(`bili`) | 通用压缩**代理** + 内置的 pi / omp / opencode 轻量客户端插件。一次安装覆盖所有客户端。 | 本地代理进程;每个客户端注入一个小插件 | ✅ <strong>就该装这个。</strong>活跃,在本仓库维护。 |
|
|
60
|
+
| **billion-context-pi** | 最早的独立 **pi 扩展**(0.1.x 参考实现)。它的 pi 插件后来已并入 `billion-context`。 | pi 进程内 | 🟡 <strong>已被取代。</strong>现已并入 `billion-context`;旧包在 `bili` 背后会自动禁用。不要再单独安装。 |
|
|
61
|
+
| **opencode-acp** | 独立的 **opencode 插件**,无需任何代理即可提供原生 ACP 压缩。 | opencode 进程内 | 🟢 独立选项,<strong>仅限 opencode</strong>。在 `bili` 背后运行时自动自禁用。 |
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
┌────────────────────────────────────────────────┐
|
|
65
|
+
│ billion-context (bili) ← 装这个 │
|
|
66
|
+
│ │
|
|
67
|
+
│ 代理 ────── wire-level 压缩 │
|
|
68
|
+
│ + 内置插件(pi / omp / opencode) │
|
|
69
|
+
└────────────────────────────────────────────────┘
|
|
70
|
+
▲ ▲ ▲
|
|
71
|
+
任意客户端 ────┘ pi / omp ─────┘ opencode ───┘
|
|
72
|
+
走 /bili/ 或 MITM bili pi / bili omp bili opencode
|
|
73
|
+
(内置插件) (内置插件)
|
|
74
|
+
|
|
75
|
+
billion-context-pi = 旧的独立 pi 扩展 → 已并入 billion-context
|
|
76
|
+
opencode-acp = 独立的 opencode-only 原生压缩(无需代理)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<strong>什么时候选哪个:</strong>
|
|
80
|
+
|
|
81
|
+
- <strong>默认 —— 用 `billion-context`(`bili`)。</strong>任何能设 base URL 的编程助手:把它指向 `/bili/`,或跑 `bili <client>`。一个工具搞定所有客户端,并统一持有压缩状态。如果只记一行,就记这行。
|
|
82
|
+
- <strong>pi / omp</strong> → 用 `billion-context` 的内置插件:`bili pi` / `bili omp`(启动器),或 `bili plugin install pi` 做持久安装。<strong>不要装旧的 `billion-context-pi` 包</strong> —— 它已并入 `billion-context`,且在 `bili` 背后会自禁用。残留的 `npm:billion-context-pi` 条目会被 `bili plugin install pi` 自动替换。
|
|
83
|
+
- <strong>omp 具体怎么选:</strong> omp 基于 pi,机制和 pi 一样但用的是它自己的插件 —— `billion-context` 自带 `dist/agent/omp.js`,由启动器通过一个持久的 overlay home 注入(你的真实 omp 配置从不被改动)。一句话:<strong>omp 走 `billion-context`,不走 `billion-context-pi`。</strong>
|
|
84
|
+
- <strong>opencode</strong> → 两个选择:
|
|
85
|
+
- <strong>独立、无代理:</strong>单独安装 [`opencode-acp`](https://github.com/ranxianglei/opencode-acp) → opencode 进程内的原生 ACP 压缩,不需要 `bili` 进程。适合只用 opencode、又不想多跑一个代理的情况。
|
|
86
|
+
- <strong>跑在 `bili` 背后:</strong>用 `bili opencode` → `billion-context` 的内置 opencode 插件接管,你宿主机上的 `opencode-acp` 会自动自禁用,让代理独占 ACP 工具(避免双层压缩)。适合同时用同一个代理跑其它客户端的情况。
|
|
87
|
+
|
|
88
|
+
<strong>一句话总结:</strong>只用 opencode 且不想跑代理 → `opencode-acp`;其余一切(任意客户端、或多个客户端)→ `billion-context`;`billion-context-pi` 不要再单独装了 —— 它现在住在 `billion-context` 里面。
|
|
89
|
+
|
|
53
90
|
## 安装
|
|
54
91
|
|
|
55
92
|
```bash
|
|
@@ -258,7 +295,7 @@ Windows 下会自动发现常见 Clash/Mihomo 静态系统代理;Web UI 会显
|
|
|
258
295
|
|
|
259
296
|
早期。协议处理和压缩已通过 mock 测试(500+ 项通过)。真实模型集成测试是下一里程碑。预期会有粗糙的地方。
|
|
260
297
|
|
|
261
|
-
pi
|
|
298
|
+
pi / omp / opencode 客户端插件现在<strong>就住在 `billion-context` 里面</strong>(`dist/agent/*.js`)。三者(`billion-context`、旧的 `billion-context-pi` 包、`opencode-acp`)如何取舍,见上文「该选哪个?」一节。
|
|
262
299
|
|
|
263
300
|
## 许可证
|
|
264
301
|
|
package/dist/index.js
CHANGED
|
@@ -49850,6 +49850,7 @@ var SessionStore = class {
|
|
|
49850
49850
|
const byLabel = /* @__PURE__ */ new Map();
|
|
49851
49851
|
let unlabeled = 0;
|
|
49852
49852
|
for (const [id, envelope] of loaded) {
|
|
49853
|
+
if (id.startsWith("pfa-")) continue;
|
|
49853
49854
|
const session = buildSession(envelope.payload);
|
|
49854
49855
|
const label = session.meta.label;
|
|
49855
49856
|
if (!label) {
|
|
@@ -58007,9 +58008,17 @@ async function preflightCompressIfNeeded(prepared, runPrepare, req, res, opts, c
|
|
|
58007
58008
|
const session = prepared.session;
|
|
58008
58009
|
const limit = config.modelContextLimit;
|
|
58009
58010
|
const imageTokens = imageTokensInRawBody(prepared.protocol, prepared.body);
|
|
58010
|
-
const
|
|
58011
|
+
const textEstimate = estimateCoreMessages(prepared.processedMessages);
|
|
58012
|
+
const payloadEstimate = textEstimate + imageTokens;
|
|
58011
58013
|
const tokenCount = Math.max(session.stats.lastInputTokens, payloadEstimate);
|
|
58012
58014
|
if (limit <= 0 || !model || tokenCount < limit) return prepared;
|
|
58015
|
+
const learnedMap = session.metadata.learnedContextLimits;
|
|
58016
|
+
const learnedLimit = (model ? learnedMap?.[model] : void 0) ?? session.metadata.learnedContextLimit;
|
|
58017
|
+
const noOverflowEvidence = session.stats.lastInputTokens < limit && learnedLimit === void 0;
|
|
58018
|
+
if (imageTokens > 0 && textEstimate < limit && noOverflowEvidence) {
|
|
58019
|
+
log2("warn", `[${session.id}] image-dominated payload (~${textEstimate} text + ~${imageTokens} image tokens) exceeds window ${limit} by estimate only, no upstream overflow evidence \u2014 forwarding once so the upstream arbitrates billing (#496)`);
|
|
58020
|
+
return prepared;
|
|
58021
|
+
}
|
|
58013
58022
|
const failFast = (status2, detail, retryable) => {
|
|
58014
58023
|
const imageNote = imageTokens >= limit ? ` Images alone account for ~${imageTokens} tokens (\u2265 window ${limit}); compression cannot remove them \u2014 shrink or remove the images, or raise the window.` : "";
|
|
58015
58024
|
const message = `context ~${tokenCount} tokens exceeds the model window ${limit} (model=${model}) and preflight compression could not bring it under: ${detail}.` + imageNote + ` The over-window payload was NOT forwarded.`;
|