billion-context 0.1.43 → 0.1.44
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 +47 -0
- package/README.zh-CN.md +15 -0
- package/dist/index.js +1477 -503
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +159 -0
- package/dist/mcp.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,6 +61,24 @@ Three ways to use it — pick one:
|
|
|
61
61
|
or when you want to pin an exact value. Routing is the same `/bili/` prefix
|
|
62
62
|
either way — the config only changes which context window the proxy uses.
|
|
63
63
|
|
|
64
|
+
### Agent plugin mode (内外呼应)
|
|
65
|
+
|
|
66
|
+
For a native-plugin experience, an agent can run a small cooperative plugin
|
|
67
|
+
alongside the proxy: the plugin registers the four ACP tools
|
|
68
|
+
(`compress` / `decompress` / `search_context` / `acp_status`) natively with
|
|
69
|
+
the agent and drives the agent's own tool loop, while the proxy stays the
|
|
70
|
+
compression authority (state, history folding, philosophy prompt, nudges).
|
|
71
|
+
Tool schemas are served by the proxy itself (`GET /__bili/plugin/manifest`),
|
|
72
|
+
so plugin and proxy can never drift. See [PLUGIN.md](PLUGIN.md) for the
|
|
73
|
+
protocol spec. Plugin-equipped sessions are detected automatically via
|
|
74
|
+
request headers — wire-level tool injection is then suppressed for them
|
|
75
|
+
(no double compression, native tool UX). Works in both proxy modes: the
|
|
76
|
+
`/bili/` prefix baseURL **and MITM transparent mode** — the launcher
|
|
77
|
+
(`bili pi` / `bili codex` / `bili claude`) exports `BILLION_CONTEXT_PROXY`
|
|
78
|
+
for plugins to detect; the plugin can also report the agent's own model
|
|
79
|
+
context window (`x-bili-plugin-context-window`) and read live context
|
|
80
|
+
usage via `GET /__bili/plugin/status`.
|
|
81
|
+
|
|
64
82
|
Compression is injected automatically — you only configure routing, never
|
|
65
83
|
compression itself.
|
|
66
84
|
|
|
@@ -83,6 +101,35 @@ bili test pi # quick end-to-end smoke test of the pi pa
|
|
|
83
101
|
bili pi --mitm-domain api.foo.com # add a domain to the MITM whitelist
|
|
84
102
|
```
|
|
85
103
|
|
|
104
|
+
**Plugin-in-launcher mode (#162)** — for `claude` and `codex` the launcher
|
|
105
|
+
additionally injects a single `bili` MCP server (`--mcp-config` for claude,
|
|
106
|
+
`-c mcp_servers.bili.*` for codex — both ephemeral, nothing written to host
|
|
107
|
+
config). The traffic route is **unchanged by default** — the transparent-
|
|
108
|
+
MITM proxy as before — so existing setups keep working exactly as they did
|
|
109
|
+
(OAuth-subscription traffic, custom relay endpoints). Opt in to **direct URL
|
|
110
|
+
routing** (`BILI_LAUNCHER_DIRECT=1`) to drop MITM/CA trust entirely (claude's
|
|
111
|
+
`ANTHROPIC_BASE_URL` / codex's provider `base_url` pointing at the `/bili/`
|
|
112
|
+
prefix); the launcher prints a warning when direct mode changes your traffic
|
|
113
|
+
route. The result is the native-plugin experience of [PLUGIN.md](PLUGIN.md)
|
|
114
|
+
with zero setup: the four ACP tools appear as native MCP tools, executed on
|
|
115
|
+
the proxy under the session lock, while the proxy keeps state, folding,
|
|
116
|
+
philosophy prompt and nudges. Session binding is automatic — claude passes
|
|
117
|
+
its session id to MCP children and on every request; codex spawns bind on
|
|
118
|
+
first sight. Plugin mode is opt-in while host-flag compatibility soaks: set
|
|
119
|
+
`BILI_LAUNCHER_PLUGIN=1` to enable the native MCP tools (verified with
|
|
120
|
+
claude 2.1.227 / codex 0.147.0; `BILI_LAUNCHER_PLUGIN=0` forces the plain
|
|
121
|
+
wire-injected launcher once the default flips on).
|
|
122
|
+
`BILI_LAUNCHER_DIRECT=1` is an opt-in, not an opt-out.
|
|
123
|
+
|
|
124
|
+
Mode matrix:
|
|
125
|
+
|
|
126
|
+
| Mode | Tools surface | Setup | When |
|
|
127
|
+
|------|--------------|-------|------|
|
|
128
|
+
| Launcher + MCP (`BILI_LAUNCHER_PLUGIN=1`) | native MCP tools | one env var | best UX; opt-in while soaking |
|
|
129
|
+
| Launcher wire mode (default for claude/codex) | proxy-injected wire tools | none — just `bili claude` / `bili codex` | default until plugin mode soaks |
|
|
130
|
+
| Manual plugin (pi etc.) | agent-side plugin | install plugin | hosts with plugin APIs |
|
|
131
|
+
| Manual baseURL | proxy-injected wire tools | edit client config | exotic hosts |
|
|
132
|
+
|
|
86
133
|
How the client is pointed at the proxy (set automatically in the child env):
|
|
87
134
|
|
|
88
135
|
| Client | Proxy redirect | CA trust env var |
|
package/README.zh-CN.md
CHANGED
|
@@ -47,6 +47,21 @@ npm install -g billion-context
|
|
|
47
47
|
- **零配置(最简单):** 在客户端 baseURL 前面加上代理地址 + `/bili/`。无需配置文件 —— context 窗口自动从 [models.dev](https://models.dev) registry 查询。`/bili/` 前缀还是个自检测信号:billion-context 的客户端扩展(billion-context-pi / opencode-acp)能在自己的 baseUrl 里认出它并自禁用,避免双层压缩。
|
|
48
48
|
- **显式 context 窗口覆盖:** 在配置文件(或网页)里按 URL 声明 context 窗口,用于 registry 不认识的端点,或想钉死一个精确值的场景。两种方式路由都是同一个 `/bili/` 前缀 —— 配置只改变代理用哪个 context 窗口。
|
|
49
49
|
|
|
50
|
+
### Agent 插件模式(内外呼应)
|
|
51
|
+
|
|
52
|
+
想要原生插件体验,可以在 agent 内部装一个配合代理的插件:插件把四个
|
|
53
|
+
ACP 工具(`compress` / `decompress` / `search_context` / `acp_status`)
|
|
54
|
+
原生注册进 agent、由 agent 自己的工具循环驱动,而代理仍然是压缩引擎
|
|
55
|
+
(状态、历史折叠、压缩哲学 prompt、nudge 全归代理)。工具 schema 由
|
|
56
|
+
代理统一下发(`GET /__bili/plugin/manifest`),插件与代理永远不会版本
|
|
57
|
+
漂移。协议规范见 [PLUGIN.md](PLUGIN.md)。带插件的会话通过请求头自动
|
|
58
|
+
识别 —— 该会话的 wire 层工具注入自动关闭(不会双重压缩,工具体验原生)。
|
|
59
|
+
两种代理模式都支持:`/bili/` 前缀 baseURL **和 MITM 透明模式** ——
|
|
60
|
+
launcher(`bili pi` / `bili codex` / `bili claude`)会导出
|
|
61
|
+
`BILLION_CONTEXT_PROXY` 供插件检测;插件还可以上报 agent 自己的模型
|
|
62
|
+
上下文窗口(`x-bili-plugin-context-window`),并通过
|
|
63
|
+
`GET /__bili/plugin/status` 读取实时上下文水位。
|
|
64
|
+
|
|
50
65
|
压缩是自动注入的 —— 你只需配置路由,无需配置压缩本身。
|
|
51
66
|
|
|
52
67
|
### 方式 A —— 零配置(`/bili/` 前缀)
|