billion-context 0.1.33 → 0.1.35
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 +70 -2
- package/dist/index.js +1244 -1619
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,8 +42,14 @@ This installs the `bili` command (`bili-proxy` is kept as an alias).
|
|
|
42
42
|
|
|
43
43
|
## Quickstart
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
Three ways to use it — pick one:
|
|
46
|
+
|
|
47
|
+
- **Launcher (no config-file edits):** run `bili pi`, `bili codex`, or
|
|
48
|
+
`bili claude` and billion-context brings up a proxy on an independent port,
|
|
49
|
+
then launches the client pointed at it. Both schemes are auto-proxied with no
|
|
50
|
+
config edits: HTTPS upstreams via `HTTPS_PROXY` + the proxy's MITM CA
|
|
51
|
+
(whitelisted for TLS interception), HTTP upstreams via a `/bili/` baseURL
|
|
52
|
+
rewrite (cert MITM can't intercept plaintext). See **Option 0** below.
|
|
47
53
|
- **Zero-config (simplest):** prefix your client's baseURL with the proxy
|
|
48
54
|
origin + `/bili/`. No config file needed — context windows are auto-detected
|
|
49
55
|
from the [models.dev](https://models.dev) registry. The `/bili/` prefix also
|
|
@@ -58,6 +64,68 @@ Two ways to use it — pick one:
|
|
|
58
64
|
Compression is injected automatically — you only configure routing, never
|
|
59
65
|
compression itself.
|
|
60
66
|
|
|
67
|
+
### Option 0 — Launcher (`bili pi` / `bili codex` / `bili claude`)
|
|
68
|
+
|
|
69
|
+
The launcher wraps a client in one command: it starts a proxy on an
|
|
70
|
+
independent port (reusing one already running there), then points the client
|
|
71
|
+
at it via **certificate-based MITM** — no config files are edited. The client's
|
|
72
|
+
own config is READ to discover which HTTPS upstream hosts it talks to; those
|
|
73
|
+
hosts are whitelisted for MITM so the proxy can TLS-terminate exactly them and
|
|
74
|
+
blind-tunnel everything else.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
bili pi # launch pi through the proxy
|
|
78
|
+
bili pi -- print "hi" # args after the client are passed through
|
|
79
|
+
bili pi-test # clean pi (extensions off) — proxy owns compression, no double-compress
|
|
80
|
+
bili codex # launch codex through the proxy
|
|
81
|
+
bili claude # launch claude through the proxy
|
|
82
|
+
bili test pi # quick end-to-end smoke test of the pi path
|
|
83
|
+
bili pi --mitm-domain api.foo.com # add a domain to the MITM whitelist
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
How the client is pointed at the proxy (set automatically in the child env):
|
|
87
|
+
|
|
88
|
+
| Client | Proxy redirect | CA trust env var |
|
|
89
|
+
|-------------|---------------------|-------------------------|
|
|
90
|
+
| pi | `HTTPS_PROXY` | `NODE_EXTRA_CA_CERTS` |
|
|
91
|
+
| claude | `HTTPS_PROXY` | `NODE_EXTRA_CA_CERTS` |
|
|
92
|
+
| codex | `HTTPS_PROXY` | `SSL_CERT_FILE` |
|
|
93
|
+
|
|
94
|
+
The real upstream HTTPS hosts are **discovered by reading** (never editing)
|
|
95
|
+
the client's own config, so whatever you already have set up keeps working:
|
|
96
|
+
|
|
97
|
+
| Client | Read from |
|
|
98
|
+
|-------------|----------------------------------------------|
|
|
99
|
+
| Pi | `~/.pi/agent/models.json` — each provider's `baseUrl` |
|
|
100
|
+
| Codex | `~/.codex/config.toml` — each `[model_providers.<name>]` `base_url` (+ top-level `openai_base_url`) |
|
|
101
|
+
| Claude Code | hardcoded `api.anthropic.com` (no per-config upstream) |
|
|
102
|
+
|
|
103
|
+
Only **HTTPS** hosts are MITM'd (a self-signed CA can't intercept plaintext
|
|
104
|
+
anyway); HTTP / `localhost` / `127.0.0.1` providers used to go direct, but are
|
|
105
|
+
now auto-proxied too. Both schemes are covered with no config edits:
|
|
106
|
+
|
|
107
|
+
- **HTTPS upstreams → cert MITM.** The MITM CA cert is the proxy's own root
|
|
108
|
+
(`~/.local/share/billion-context/ca/root-ca.pem`, generated lazily); the
|
|
109
|
+
client must trust it — pi/claude honor `NODE_EXTRA_CA_CERTS`, codex honors
|
|
110
|
+
`SSL_CERT_FILE`. Compression is injected on the intercepted TLS stream.
|
|
111
|
+
- **HTTP upstreams → `/bili/` baseURL rewrite** (since plaintext can't be
|
|
112
|
+
MITM'd). The launcher rewrites the client's base URL through the client's own
|
|
113
|
+
mechanism, leaving its config files untouched: codex via `-c key=value` flags,
|
|
114
|
+
claude via the `ANTHROPIC_BASE_URL` env var, pi via an isolated
|
|
115
|
+
`PI_CODING_AGENT_DIR` pointing at a temp copy of the pi home with a rewritten
|
|
116
|
+
`models.json` (`auth.json` and the rest are symlinked through unchanged; the
|
|
117
|
+
temp dir is removed when the client exits).
|
|
118
|
+
|
|
119
|
+
`--mitm-domain <domain>` (repeatable) adds extra domains to the whitelist
|
|
120
|
+
beyond what auto-discovery finds — useful for hosts the client fetches at
|
|
121
|
+
runtime rather than from its config file. The proxy port defaults to `8787`;
|
|
122
|
+
if it's taken, a free port is chosen automatically. Use `--passthrough` /
|
|
123
|
+
`--debug` / `--no-auto-update` just like plain `bili`.
|
|
124
|
+
|
|
125
|
+
> **Note:** the launcher ties the proxy's lifetime to the client — when the
|
|
126
|
+
> client exits, a proxy it started is stopped. If it reuses a proxy you already
|
|
127
|
+
> started with plain `bili`, that one is left running.
|
|
128
|
+
|
|
61
129
|
### Option A — Zero-config (`/bili/` prefix)
|
|
62
130
|
|
|
63
131
|
Start the proxy:
|