billion-context 0.1.30 → 0.1.31
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 +19 -30
- package/README.zh-CN.md +15 -25
- package/dist/index.js +145 -1023
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,16 @@ base_url = "https://api.openai.com/v1"
|
|
|
102
102
|
base_url = "http://localhost:8787/bili/https://api.openai.com/v1"
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
**Codex (ChatGPT login)** — set the top-level `openai_base_url` field (keeps
|
|
106
|
+
`model_provider = "openai"` and OAuth login intact):
|
|
107
|
+
```toml
|
|
108
|
+
# ~/.codex/config.toml (top-level field, not a section)
|
|
109
|
+
model_provider = "openai"
|
|
110
|
+
openai_base_url = "http://localhost:8787/bili/https://chatgpt.com/backend-api/codex"
|
|
111
|
+
```
|
|
112
|
+
Run `codex login` as usual; the OAuth token travels in the `Authorization`
|
|
113
|
+
header, which bili forwards untouched to the upstream.
|
|
114
|
+
|
|
105
115
|
**Pi** — edit `~/.pi/agent/models.json`, change the provider's `baseUrl`:
|
|
106
116
|
```jsonc
|
|
107
117
|
// before:
|
|
@@ -114,43 +124,22 @@ base_url = "http://localhost:8787/bili/https://api.openai.com/v1"
|
|
|
114
124
|
upstream URL is configured, prepend `http://localhost:8787/bili/` to it.
|
|
115
125
|
Nothing else changes.
|
|
116
126
|
|
|
117
|
-
#### B.
|
|
118
|
-
|
|
119
|
-
Codex can be connected without changing its active `model_provider` and
|
|
120
|
-
without trusting a MITM certificate. Start bili, open
|
|
121
|
-
[http://localhost:8787/__bili/](http://localhost:8787/__bili/), then enable
|
|
122
|
-
**Codex Route** on the Routing page. For scripted startup, enable it before
|
|
123
|
-
starting the owning server:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
bili codex enable --port 8787
|
|
127
|
-
bili start --port 8787
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
billion-context resolves only the active Codex provider, records its real
|
|
131
|
-
`base_url`, and temporarily replaces that one field with
|
|
132
|
-
`http://127.0.0.1:8787/codex`. The provider id never changes, so existing Codex
|
|
133
|
-
history stays in the same bucket. Disabling the route or gracefully stopping
|
|
134
|
-
the owning bili process restores the original field; edits made by the user
|
|
135
|
-
while routing was active are preserved. A stale takeover is safely recovered
|
|
136
|
-
the next time bili starts.
|
|
137
|
-
|
|
138
|
-
The Routing page also offers a manual, backup-first repair for sessions created
|
|
139
|
-
by older bili test provider ids. Normal routing never migrates Codex history.
|
|
140
|
-
|
|
141
|
-
#### C. Other login/subscription clients (MITM transparent proxy)
|
|
127
|
+
#### B. Login/subscription clients with hardcoded endpoints (MITM transparent proxy)
|
|
142
128
|
|
|
143
129
|
Clients you sign **into an account** (ChatGPT Plus/Pro, Claude, ZCode coding
|
|
144
|
-
plan, …) authenticate via **OAuth
|
|
145
|
-
change the baseURL,
|
|
146
|
-
**MITM transparent-proxy mode** instead.
|
|
130
|
+
plan, …) authenticate via **OAuth**. Most such clients also **hardcode the
|
|
131
|
+
endpoint** — if you can't change the baseURL, the `/bili/` prefix trick
|
|
132
|
+
doesn't work. These need **MITM transparent-proxy mode** instead.
|
|
133
|
+
|
|
134
|
+
> **Codex exception:** Codex exposes a top-level `openai_base_url` config
|
|
135
|
+
> field, so the ChatGPT login version CAN use the `/bili/` prefix (see above).
|
|
136
|
+
> MITM is not needed for Codex.
|
|
147
137
|
|
|
148
|
-
Supported
|
|
138
|
+
Supported MITM clients:
|
|
149
139
|
|
|
150
140
|
| Client | Login | Endpoint hardcoded | Status |
|
|
151
141
|
|---|---|---|---|
|
|
152
142
|
| **ZCode** | bigmodel coding plan (OAuth) | `open.bigmodel.cn` (builtin provider) | ✅ tested |
|
|
153
|
-
| **Codex** | ChatGPT account (OAuth) | `chatgpt.com/backend-api` | ✅ use Codex Route above; MITM is fallback only |
|
|
154
143
|
| **Claude Code** | Claude subscription (OAuth) | `api.anthropic.com` | ❓ untested (may not work — needs verification) |
|
|
155
144
|
|
|
156
145
|
How MITM mode works: the client only offers an **HTTP proxy** setting, so it
|
package/README.zh-CN.md
CHANGED
|
@@ -86,6 +86,14 @@ base_url = "https://api.openai.com/v1"
|
|
|
86
86
|
base_url = "http://localhost:8787/bili/https://api.openai.com/v1"
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
**Codex(ChatGPT 登录)** —— 设顶层 `openai_base_url` 字段(保持 `model_provider = "openai"` 和 OAuth 登录不变):
|
|
90
|
+
```toml
|
|
91
|
+
# ~/.codex/config.toml(顶层字段,不是 section)
|
|
92
|
+
model_provider = "openai"
|
|
93
|
+
openai_base_url = "http://localhost:8787/bili/https://chatgpt.com/backend-api/codex"
|
|
94
|
+
```
|
|
95
|
+
照常运行 `codex login`;OAuth token 随 `Authorization` 头传输,bili 原样转发给上游。
|
|
96
|
+
|
|
89
97
|
**Pi** —— 编辑 `~/.pi/agent/models.json`,改 provider 的 `baseUrl`:
|
|
90
98
|
```jsonc
|
|
91
99
|
// 之前:
|
|
@@ -96,38 +104,20 @@ base_url = "http://localhost:8787/bili/https://api.openai.com/v1"
|
|
|
96
104
|
|
|
97
105
|
**其他 API-key 客户端(Cursor / Aider / Continue ……)** —— 只要配置了上游 URL,前面加 `http://localhost:8787/bili/` 就行,其他都不用改。
|
|
98
106
|
|
|
99
|
-
#### B.
|
|
100
|
-
|
|
101
|
-
Codex 不需要改 `model_provider`,也不需要信任 MITM 证书。启动 bili,打开
|
|
102
|
-
[http://localhost:8787/__bili/](http://localhost:8787/__bili/),在“路由”页启用
|
|
103
|
-
**Codex 路由**。脚本化启动时,先启用路由,再启动拥有它的服务:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
bili codex enable --port 8787
|
|
107
|
-
bili start --port 8787
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
billion-context 只解析当前激活的 Codex provider,记录它的真实 `base_url`,
|
|
111
|
-
并临时只把这个字段替换成 `http://127.0.0.1:8787/codex`。provider id 始终
|
|
112
|
-
不变,所以现有 Codex 历史仍在同一个分桶。关闭路由或正常停止拥有该路由的
|
|
113
|
-
bili 进程时会恢复原字段;路由期间用户自己做的新修改会被保留。异常退出留下
|
|
114
|
-
的接管状态会在下次启动 bili 时安全恢复。
|
|
115
|
-
|
|
116
|
-
“路由”页还提供旧版 bili 测试 provider 会话的手动修复:先预览、先备份、再
|
|
117
|
-
修复。正常路由绝不会自动迁移 Codex 历史。
|
|
118
|
-
|
|
119
|
-
#### C. 其他登录/订阅客户端(MITM 透明代理)
|
|
107
|
+
#### B. 登录/订阅客户端(硬编码端点,MITM 透明代理)
|
|
120
108
|
|
|
121
109
|
需要 **登录账号**的客户端(ChatGPT Plus/Pro、Claude、ZCode coding plan
|
|
122
|
-
……)通过 **OAuth
|
|
123
|
-
|
|
110
|
+
……)通过 **OAuth 认证**。多数这类客户端还 **硬编码了端点**——如果你改不了
|
|
111
|
+
baseURL,`/bili/` 前缀方式就无效。这类客户端要用 **MITM 透明代理模式**。
|
|
112
|
+
|
|
113
|
+
> **Codex 例外:** Codex 暴露了顶层 `openai_base_url` 配置字段,所以
|
|
114
|
+
> ChatGPT 登录版 CAN 用 `/bili/` 前缀(见上方)。Codex 不需要 MITM。
|
|
124
115
|
|
|
125
|
-
|
|
116
|
+
支持的 MITM 客户端:
|
|
126
117
|
|
|
127
118
|
| 客户端 | 登录方式 | 硬编码端点 | 状态 |
|
|
128
119
|
|---|---|---|---|
|
|
129
120
|
| **ZCode** | 智谱 coding plan(OAuth) | `open.bigmodel.cn`(内置 provider) | ✅ 已测试 |
|
|
130
|
-
| **Codex** | ChatGPT 账号(OAuth) | `chatgpt.com/backend-api` | ✅ 优先使用上面的 Codex 路由;MITM 仅作 fallback |
|
|
131
121
|
| **Claude Code** | Claude 订阅(OAuth) | `api.anthropic.com` | ❓ 未测试(可能不支持,需验证) |
|
|
132
122
|
|
|
133
123
|
MITM 模式原理:这类客户端只提供 **HTTP 代理**设置,所以它发送
|