billion-context 0.1.53-pr.239.81 → 0.1.53-pr.241.82
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 +17 -0
- package/README.zh-CN.md +15 -0
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,6 +148,23 @@ bili --no-auto-update # disable self-update for this run
|
|
|
148
148
|
|
|
149
149
|
Flags override env vars and the config file. `bili --help` lists them all.
|
|
150
150
|
|
|
151
|
+
### Remote agents (`--host`)
|
|
152
|
+
|
|
153
|
+
By default the proxy binds `127.0.0.1` and only accepts loopback
|
|
154
|
+
connections. To serve agents on other machines, bind a non-loopback host:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
bili --host 0.0.0.0 # all interfaces (or use your LAN IP)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- Remote agents point their model `baseURL` at `http://<this-host>:<port>/bili/…`.
|
|
161
|
+
- MITM-mode `CONNECT` then also accepts remote clients — for **whitelisted
|
|
162
|
+
model hosts only**. Blind tunnels to arbitrary hosts stay loopback-only, so
|
|
163
|
+
the proxy can never be used as an open relay.
|
|
164
|
+
- There is **no authentication**: only do this on a trusted LAN or behind a
|
|
165
|
+
firewall. The `/__bili/` management endpoints remain loopback-only.
|
|
166
|
+
- A startup `[security]` warning reminds you of the above.
|
|
167
|
+
|
|
151
168
|
### Debugging
|
|
152
169
|
|
|
153
170
|
Three ways to enable verbose logging (priority: flag > env > config):
|
package/README.zh-CN.md
CHANGED
|
@@ -133,6 +133,21 @@ bili --no-auto-update # 本次启动禁用自动更新
|
|
|
133
133
|
|
|
134
134
|
参数优先级高于环境变量和配置文件。`bili --help` 列出全部。
|
|
135
135
|
|
|
136
|
+
### 远程 agent(`--host`)
|
|
137
|
+
|
|
138
|
+
默认绑定 `127.0.0.1`,只接受本机连接。要给其他机器上的 agent 用,绑定非 loopback 地址:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
bili --host 0.0.0.0 # 所有网卡(或直接用局域网 IP)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- 远程 agent 把模型 `baseURL` 指向 `http://<本机IP>:<端口>/bili/…`。
|
|
145
|
+
- MITM 模式的 `CONNECT` 也会接受远程客户端 —— 但仅限**白名单内的模型域名**;
|
|
146
|
+
到任意主机的盲隧道仍仅限本机,代理不会沦为开放中继。
|
|
147
|
+
- **没有任何鉴权**: 只应在可信局域网或防火墙内使用。`/__bili/` 管理
|
|
148
|
+
端点仍仅限本机访问。
|
|
149
|
+
- 启动时的 `[security]` 警告会提醒上述事项。
|
|
150
|
+
|
|
136
151
|
### 调试
|
|
137
152
|
|
|
138
153
|
三种方式打开详细日志(优先级:参数 > 环境变量 > 配置):
|
package/dist/index.js
CHANGED
|
@@ -50295,7 +50295,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
|
|
|
50295
50295
|
const calls = [];
|
|
50296
50296
|
let usage = {};
|
|
50297
50297
|
let finishReason;
|
|
50298
|
-
let sawDone = false;
|
|
50299
50298
|
let suppressCompletion = false;
|
|
50300
50299
|
for await (const ev of adapter.parseStream(currentUpstream, round)) {
|
|
50301
50300
|
if (signal?.aborted) break;
|
|
@@ -50333,7 +50332,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
|
|
|
50333
50332
|
cachedTokens: ev.cachedTokens
|
|
50334
50333
|
};
|
|
50335
50334
|
} else if (ev.kind === "done") {
|
|
50336
|
-
sawDone = true;
|
|
50337
50335
|
finishReason = ev.finishReason;
|
|
50338
50336
|
suppressCompletion = ev.suppressCompletion === true;
|
|
50339
50337
|
} else if (ev.kind === "meta") {
|
|
@@ -50455,15 +50453,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
|
|
|
50455
50453
|
}
|
|
50456
50454
|
const reRequest = proxyResults.length > 0 && realCalls === 0;
|
|
50457
50455
|
if (!reRequest) {
|
|
50458
|
-
if (!sawDone) {
|
|
50459
|
-
const partialText = assistantText.length;
|
|
50460
|
-
const partialReasoning = assistantReasoning.length;
|
|
50461
|
-
const msg = `upstream stream truncated (no completion event; round ${round}, ${partialText} text chars + ${partialReasoning} reasoning chars received)`;
|
|
50462
|
-
ctx.log(`[acp-loop] round ${round}: ${msg}`);
|
|
50463
|
-
log("error", `[acp-loop] ${msg}`);
|
|
50464
|
-
yield adapter.emitError(msg);
|
|
50465
|
-
return;
|
|
50466
|
-
}
|
|
50467
50456
|
if (!suppressCompletion) {
|
|
50468
50457
|
yield adapter.emitCompletion({ finishReason, usage });
|
|
50469
50458
|
}
|
|
@@ -53228,17 +53217,23 @@ function isMitmHost(host, extraDomains = []) {
|
|
|
53228
53217
|
return all.some((d) => h === d || h.endsWith("." + d));
|
|
53229
53218
|
}
|
|
53230
53219
|
function setupMitm(server, extraDomains = [], log2 = () => {
|
|
53231
|
-
}, resolveProxyUrl) {
|
|
53220
|
+
}, resolveProxyUrl, allowRemoteClients = false) {
|
|
53232
53221
|
ensureRootCA();
|
|
53233
53222
|
server.on("connect", (req, clientSocket, head) => {
|
|
53234
|
-
|
|
53235
|
-
|
|
53223
|
+
const remote = !isLoopbackAddress(clientSocket.remoteAddress);
|
|
53224
|
+
if (remote && !allowRemoteClients) {
|
|
53225
|
+
log2(`CONNECT ${req.url} rejected: non-loopback client ${clientSocket.remoteAddress} (bind a non-loopback --host to allow remote clients)`);
|
|
53236
53226
|
clientSocket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
|
|
53237
53227
|
return;
|
|
53238
53228
|
}
|
|
53239
53229
|
const { hostname, port } = parseHostPort(req.url ?? "");
|
|
53240
53230
|
const targetPort = port || 443;
|
|
53241
53231
|
if (!isMitmHost(hostname, extraDomains)) {
|
|
53232
|
+
if (remote) {
|
|
53233
|
+
log2(`CONNECT ${req.url} rejected: remote client ${clientSocket.remoteAddress} tunneling non-whitelisted host`);
|
|
53234
|
+
clientSocket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
|
|
53235
|
+
return;
|
|
53236
|
+
}
|
|
53242
53237
|
const proxyUrl = resolveProxyUrl?.(hostname);
|
|
53243
53238
|
tunnelThrough(clientSocket, hostname, targetPort, head, log2, proxyUrl);
|
|
53244
53239
|
return;
|
|
@@ -54158,10 +54153,12 @@ Content-Length: ${Buffer.byteLength(body)}\r
|
|
|
54158
54153
|
);
|
|
54159
54154
|
});
|
|
54160
54155
|
if (opts.mitm.enabled) {
|
|
54161
|
-
|
|
54156
|
+
const allowRemoteConnect = opts.host === "0.0.0.0" || opts.host === "::" || !isLoopbackAddress(opts.host);
|
|
54157
|
+
setupMitm(server, opts.mitm.domains, (msg) => log2("info", msg), (host) => resolveProxy(opts.routes, opts.proxy, `https://${host}`, opts.proxyFallback), allowRemoteConnect);
|
|
54162
54158
|
}
|
|
54163
54159
|
server.listen(opts.port, opts.host, () => {
|
|
54164
|
-
const
|
|
54160
|
+
const nonLoopbackBind = opts.host === "0.0.0.0" || opts.host === "::" || !isLoopbackAddress(opts.host);
|
|
54161
|
+
const displayHost = nonLoopbackBind ? opts.host : opts.host === "0.0.0.0" ? "localhost" : opts.host;
|
|
54165
54162
|
try {
|
|
54166
54163
|
fs6.mkdirSync(stateDir(), { recursive: true });
|
|
54167
54164
|
const originHost = opts.host === "0.0.0.0" || opts.host === "::" || opts.host === "localhost" ? "127.0.0.1" : opts.host.includes(":") && !opts.host.startsWith("[") ? `[${opts.host}]` : opts.host;
|
|
@@ -54174,6 +54171,12 @@ Content-Length: ${Buffer.byteLength(body)}\r
|
|
|
54174
54171
|
"info",
|
|
54175
54172
|
`acp-proxy listening on http://${displayHost}:${opts.port} \u2014 web UI: http://${displayHost}:${opts.port}/__bili/ \u2014 zero-config: prefix any baseURL with http://${displayHost}:${opts.port}/bili/` + (nOverrides ? ` \u2014 context overrides for ${nOverrides} upstream URL(s)` : "") + (opts.mitm.enabled ? ` \u2014 MITM proxy on (whitelist)${opts.mitm.domains.length ? ` +${opts.mitm.domains.join(",")}` : ""}` : "")
|
|
54176
54173
|
);
|
|
54174
|
+
if (nonLoopbackBind) {
|
|
54175
|
+
log2(
|
|
54176
|
+
"warn",
|
|
54177
|
+
`[security] bound to ${opts.host} \u2014 proxy endpoints (/bili/, CONNECT for whitelisted model hosts) are reachable from the network with NO authentication; /__bili/ management endpoints stay loopback-only. Restrict access with a firewall on untrusted networks. Remote agents: point baseURL at http://<this-host>:${opts.port}/bili/`
|
|
54178
|
+
);
|
|
54179
|
+
}
|
|
54177
54180
|
if (opts.debug) {
|
|
54178
54181
|
log2("info", `[debug] build features: raw-HTTP-capture(on) | remote_compaction_v2-strip(on) | cert-MITM-launcher(on) | strip-acp-summary(on) \u2014 seeing this line confirms the launcher build (not registry 0.1.34)`);
|
|
54179
54182
|
}
|