billion-context 0.1.63-pr.345.199 → 0.1.63-pr.347.201
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/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53902,6 +53902,9 @@ var rootCert;
|
|
|
53902
53902
|
var rootKey;
|
|
53903
53903
|
var secureContextCache = /* @__PURE__ */ new Map();
|
|
53904
53904
|
var SECURE_CONTEXT_CACHE_MAX = 64;
|
|
53905
|
+
function rootCaPath() {
|
|
53906
|
+
return path7.join(caDir(), ROOT_CERT_FILE);
|
|
53907
|
+
}
|
|
53905
53908
|
function collectSystemCaPems(env = process.env) {
|
|
53906
53909
|
const pems = [];
|
|
53907
53910
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -54536,6 +54539,15 @@ var DEFAULT_MITM_DOMAINS = [
|
|
|
54536
54539
|
"chatgpt.com"
|
|
54537
54540
|
];
|
|
54538
54541
|
var MITM_UPSTREAM_KEY = "__biliMitmUpstream";
|
|
54542
|
+
var warnedCertRejected = false;
|
|
54543
|
+
var CERT_REJECT_RE = /alert (?:certificate unknown|unknown ca|bad certificate|certificate expired|certificate revoked|unsupported certificate)/i;
|
|
54544
|
+
function noteMitmTlsError(host, port, message, log2) {
|
|
54545
|
+
log2(`mitm ${maskHostForLog(host)}:${port} TLS error: ${message}`);
|
|
54546
|
+
if (CERT_REJECT_RE.test(message) && !warnedCertRejected) {
|
|
54547
|
+
warnedCertRejected = true;
|
|
54548
|
+
log2(`mitm ${maskHostForLog(host)}:${port} client REJECTED the MITM certificate \u2014 it does not trust bili's root CA. Install it in the client's/system trust store, then restart the client. CA: ${rootCaPath()}`);
|
|
54549
|
+
}
|
|
54550
|
+
}
|
|
54539
54551
|
var MITM_HANDSHAKE_TIMEOUT_MS_DEFAULT = 1e4;
|
|
54540
54552
|
function mitmHandshakeTimeoutMs() {
|
|
54541
54553
|
const v2 = Number.parseInt(process.env.BILI_MITM_HANDSHAKE_TIMEOUT_MS ?? "", 10);
|
|
@@ -54601,6 +54613,7 @@ function tunnelThrough(clientSocket, host, port, head, log2, proxyUrl) {
|
|
|
54601
54613
|
if (head.length > 0) upstream.write(head);
|
|
54602
54614
|
upstream.pipe(clientSocket);
|
|
54603
54615
|
clientSocket.pipe(upstream);
|
|
54616
|
+
log2(`tunnel ${maskHostForLog(host)}:${port} established (blind TCP, not decrypted)`);
|
|
54604
54617
|
const cleanup = (where, err2) => {
|
|
54605
54618
|
log2(`tunnel ${maskHostForLog(host)}:${port} ${where} closed: ${maskHostInText(err2.message, host)}`);
|
|
54606
54619
|
upstream.destroy();
|
|
@@ -54635,7 +54648,7 @@ function doMitm(server, clientSocket, host, port, head, log2) {
|
|
|
54635
54648
|
}
|
|
54636
54649
|
tlsSocket[MITM_UPSTREAM_KEY] = `https://${host}`;
|
|
54637
54650
|
tlsSocket.on("error", (err2) => {
|
|
54638
|
-
|
|
54651
|
+
noteMitmTlsError(host, port, err2.message, log2);
|
|
54639
54652
|
tlsSocket.destroy();
|
|
54640
54653
|
clientSocket.destroy();
|
|
54641
54654
|
});
|
|
@@ -55752,6 +55765,11 @@ async function handle(req, res, opts, core, config, log2, instanceId) {
|
|
|
55752
55765
|
return;
|
|
55753
55766
|
}
|
|
55754
55767
|
}
|
|
55768
|
+
if (isAdminPath) {
|
|
55769
|
+
res.writeHead(404, { "content-type": "application/json" });
|
|
55770
|
+
res.end(JSON.stringify({ error: { type: "not_found", message: "no such management endpoint" } }));
|
|
55771
|
+
return;
|
|
55772
|
+
}
|
|
55755
55773
|
let bodyBuffer;
|
|
55756
55774
|
let urlPath;
|
|
55757
55775
|
let responsesCompact;
|
|
@@ -55838,9 +55856,9 @@ ${bodyBuffer.toString("utf8")}`);
|
|
|
55838
55856
|
const betaWindow = anthropicBetaContextWindow(req.headers);
|
|
55839
55857
|
const pluginWindow = pluginReportedContextWindow(req.headers);
|
|
55840
55858
|
const launcherWindow = launcherContextWindow(model);
|
|
55841
|
-
const configuredWindow = resolveConfiguredContextLimit(opts.routes, embeddedUrl, model);
|
|
55842
55859
|
const peekWindow = host ? peekRegistryContext(model, host) : void 0;
|
|
55843
|
-
|
|
55860
|
+
const configuredWindow = resolveConfiguredContextLimit(opts.routes, embeddedUrl, model);
|
|
55861
|
+
let native = betaWindow ?? pluginWindow ?? launcherWindow ?? peekWindow ?? configuredWindow ?? lookupContextLimit(model);
|
|
55844
55862
|
const operatorWindowTuned = resolveCompress(opts.routes, embeddedUrl, model, opts.compress).modelContextLimit !== void 0;
|
|
55845
55863
|
nativeFromFallback = !betaWindow && !pluginWindow && !launcherWindow && !peekWindow && !configuredWindow && !operatorWindowTuned;
|
|
55846
55864
|
if (!native && host) {
|