billion-context 0.1.89-pr.612.430 → 0.1.89-pr.613.432
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 +3 -0
- package/dist/index.js +68 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +24 -1
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -344,6 +344,9 @@ Rules:
|
|
|
344
344
|
- Both outbound paths are covered: `/bili/` path-mode (fetch) AND MITM CONNECT
|
|
345
345
|
tunnels (the proxy's connection to the real upstream goes through the HTTP
|
|
346
346
|
CONNECT proxy).
|
|
347
|
+
- The auto-updater's own egress (npm registry check + tarball download) uses
|
|
348
|
+
the same decision for its hosts, so `bili update` and auto-update work on
|
|
349
|
+
hosts where npm is only reachable through the proxy (#609).
|
|
347
350
|
|
|
348
351
|
Env override: `BILI_UPSTREAM_PROXY=http://127.0.0.1:20172` (higher priority than
|
|
349
352
|
the config file). On Windows, common Clash/Mihomo static system proxies are
|
package/dist/index.js
CHANGED
|
@@ -57645,6 +57645,7 @@ var LAUNCHER_MODEL_WINDOWS = parseLauncherModelWindows(process.env.BILI_LAUNCHER
|
|
|
57645
57645
|
function launcherContextWindow(model) {
|
|
57646
57646
|
return LAUNCHER_MODEL_WINDOWS[model];
|
|
57647
57647
|
}
|
|
57648
|
+
var windowSourceLogged = /* @__PURE__ */ new Set();
|
|
57648
57649
|
function anthropicBetaContextWindow(headers) {
|
|
57649
57650
|
const raw = headers["anthropic-beta"];
|
|
57650
57651
|
if (raw === void 0) return void 0;
|
|
@@ -58253,6 +58254,13 @@ ${bodyBuffer.toString("utf8")}`);
|
|
|
58253
58254
|
if (native) nativeFromFallback = false;
|
|
58254
58255
|
}
|
|
58255
58256
|
reqConfig = resolveRequestConfig(config, opts.routes, embeddedUrl, model, native, opts.compress);
|
|
58257
|
+
{
|
|
58258
|
+
if (!windowSourceLogged.has(model)) {
|
|
58259
|
+
windowSourceLogged.add(model);
|
|
58260
|
+
const wsSource = betaWindow ? "anthropic-beta" : pluginWindow ? "plugin" : launcherWindow ? "launcher" : configuredWindow ? "configured" : peekWindow ? "registry-peek" : native ? "table-or-registry" : "default";
|
|
58261
|
+
log2("info", `[window] model=${model} source=${wsSource} native=${native ?? "none"} effective=${reqConfig.modelContextLimit} launcher=${launcherWindow ?? "none"} configured=${configuredWindow ?? "none"} peek=${peekWindow ?? "none"} fallback=${nativeFromFallback}`);
|
|
58262
|
+
}
|
|
58263
|
+
}
|
|
58256
58264
|
const aligned = operatorWindowTuned ? { limit: reqConfig.modelContextLimit, clamped: false } : codexAlignedWindow(reqConfig.modelContextLimit, model, req.headers);
|
|
58257
58265
|
if (aligned.clamped) {
|
|
58258
58266
|
const before = reqConfig.modelContextLimit;
|
|
@@ -63185,6 +63193,12 @@ async function tryAcquireLock() {
|
|
|
63185
63193
|
}
|
|
63186
63194
|
};
|
|
63187
63195
|
}
|
|
63196
|
+
function egressDispatcher(opts, url) {
|
|
63197
|
+
return proxyDispatcher(opts.resolveProxy?.(url));
|
|
63198
|
+
}
|
|
63199
|
+
function fetchWithEgress(url, init) {
|
|
63200
|
+
return fetch(url, init);
|
|
63201
|
+
}
|
|
63188
63202
|
async function checkForUpdate(opts, force = false) {
|
|
63189
63203
|
if (!opts.autoUpdate && !force) return;
|
|
63190
63204
|
if (inFlight) return;
|
|
@@ -63207,9 +63221,11 @@ async function checkForUpdate(opts, force = false) {
|
|
|
63207
63221
|
}
|
|
63208
63222
|
log("info", `[update] checking npm registry for ${opts.packageName}${sinceLastSec < 0 ? " (startup check)" : sinceLastSec === 0 ? "" : ` (last check ${sinceLastSec}s ago)`}\u2026`);
|
|
63209
63223
|
const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
|
|
63210
|
-
const
|
|
63224
|
+
const registryDispatcher = egressDispatcher(opts, url);
|
|
63225
|
+
const res = await fetchWithEgress(url, {
|
|
63211
63226
|
signal: AbortSignal.timeout(5e3),
|
|
63212
|
-
headers: { Accept: "application/json" }
|
|
63227
|
+
headers: { Accept: "application/json" },
|
|
63228
|
+
...registryDispatcher ? { dispatcher: registryDispatcher } : {}
|
|
63213
63229
|
});
|
|
63214
63230
|
if (!res.ok) {
|
|
63215
63231
|
log("warn", `[update] registry returned ${res.status} ${res.statusText}, skipping`);
|
|
@@ -63245,7 +63261,7 @@ async function checkForUpdate(opts, force = false) {
|
|
|
63245
63261
|
return;
|
|
63246
63262
|
}
|
|
63247
63263
|
try {
|
|
63248
|
-
const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum);
|
|
63264
|
+
const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum, egressDispatcher(opts, tarballUrl));
|
|
63249
63265
|
if (result.ok) {
|
|
63250
63266
|
log("info", `[update] installed ${currentVersion} \u2192 ${latest}. Restart to finish.`);
|
|
63251
63267
|
} else {
|
|
@@ -63282,7 +63298,7 @@ function verifyTarballIntegrity(buf, integrity, shasum) {
|
|
|
63282
63298
|
}
|
|
63283
63299
|
return { ok: false, error: "no integrity or shasum from registry" };
|
|
63284
63300
|
}
|
|
63285
|
-
async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum) {
|
|
63301
|
+
async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum, dispatcher) {
|
|
63286
63302
|
if (!installDir) {
|
|
63287
63303
|
return { ok: false, error: "cannot determine install directory (package.json not found walking up from running binary)" };
|
|
63288
63304
|
}
|
|
@@ -63297,7 +63313,10 @@ async function installViaTarball(version2, tarballUrl, installDir, integrity, sh
|
|
|
63297
63313
|
const MAX_TARBALL_BYTES = 100 * 1024 * 1024;
|
|
63298
63314
|
let tgzBuffer;
|
|
63299
63315
|
try {
|
|
63300
|
-
const tgzRes = await
|
|
63316
|
+
const tgzRes = await fetchWithEgress(tarballUrl, {
|
|
63317
|
+
signal: AbortSignal.timeout(6e4),
|
|
63318
|
+
...dispatcher ? { dispatcher } : {}
|
|
63319
|
+
});
|
|
63301
63320
|
if (!tgzRes.ok) {
|
|
63302
63321
|
return { ok: false, error: `tarball download failed: HTTP ${tgzRes.status} ${tgzRes.statusText}` };
|
|
63303
63322
|
}
|
|
@@ -63426,11 +63445,22 @@ var VERSION2 = (() => {
|
|
|
63426
63445
|
}
|
|
63427
63446
|
})();
|
|
63428
63447
|
var DEFAULT_PROXY_ORIGIN = "http://127.0.0.1:8787";
|
|
63448
|
+
var warnedStaleRecord = false;
|
|
63429
63449
|
function resolveProxyOrigin() {
|
|
63430
63450
|
const fromEnv = process.env.BILI_MCP_PROXY?.trim();
|
|
63431
63451
|
if (fromEnv && fromEnv.length > 0) return fromEnv;
|
|
63432
63452
|
const discovered = readProxyInstanceFile();
|
|
63433
|
-
if (discovered && /^https?:\/\/\S+$/.test(discovered.origin))
|
|
63453
|
+
if (discovered && /^https?:\/\/\S+$/.test(discovered.origin)) {
|
|
63454
|
+
if (isProxyInstanceFile(discovered) && discovered.pid > 0 && !isPidAlive(discovered.pid)) {
|
|
63455
|
+
if (!warnedStaleRecord) {
|
|
63456
|
+
warnedStaleRecord = true;
|
|
63457
|
+
process.stderr.write(`[bili-mcp] recorded bili proxy (${discovered.origin}, pid ${discovered.pid}) is not running \u2014 falling back to ${DEFAULT_PROXY_ORIGIN}; set BILI_MCP_PROXY if your proxy listens elsewhere
|
|
63458
|
+
`);
|
|
63459
|
+
}
|
|
63460
|
+
return DEFAULT_PROXY_ORIGIN;
|
|
63461
|
+
}
|
|
63462
|
+
return discovered.origin;
|
|
63463
|
+
}
|
|
63434
63464
|
return DEFAULT_PROXY_ORIGIN;
|
|
63435
63465
|
}
|
|
63436
63466
|
var TOOL_TIMEOUT_MS = 6e4;
|
|
@@ -64910,8 +64940,16 @@ async function ensureProxyRunning(opts, deps = {}) {
|
|
|
64910
64940
|
child.unref?.();
|
|
64911
64941
|
} catch {
|
|
64912
64942
|
}
|
|
64943
|
+
let childExit;
|
|
64944
|
+
child.on?.("exit", (...rest) => {
|
|
64945
|
+
childExit = {
|
|
64946
|
+
code: typeof rest[0] === "number" ? rest[0] : null,
|
|
64947
|
+
signal: typeof rest[1] === "string" ? rest[1] : null
|
|
64948
|
+
};
|
|
64949
|
+
});
|
|
64913
64950
|
const deadline = now() + SPAWN_WAIT_MS;
|
|
64914
64951
|
while (now() < deadline) {
|
|
64952
|
+
if (childExit) break;
|
|
64915
64953
|
await sleepImpl(HEALTH_POLL_INTERVAL_MS);
|
|
64916
64954
|
const inst = readInstance();
|
|
64917
64955
|
if (isProxyInstanceFile(inst) && inst.launchToken === launchToken) {
|
|
@@ -64925,6 +64963,10 @@ async function ensureProxyRunning(opts, deps = {}) {
|
|
|
64925
64963
|
return { origin: proxyOrigin(opts.host, port), port, child, logPath: logPath2 };
|
|
64926
64964
|
}
|
|
64927
64965
|
}
|
|
64966
|
+
if (childExit) {
|
|
64967
|
+
const detail = childExit.code !== null ? `code ${childExit.code}` : childExit.signal ? `signal ${childExit.signal}` : "unknown reason";
|
|
64968
|
+
throw new Error(`bili: proxy child exited before becoming healthy (${detail}) (log: ${logPath2})`);
|
|
64969
|
+
}
|
|
64928
64970
|
throw new Error(`bili: proxy did not become healthy within ${SPAWN_WAIT_MS}ms (log: ${logPath2})`);
|
|
64929
64971
|
}
|
|
64930
64972
|
function stopProxy(handle2) {
|
|
@@ -65708,7 +65750,20 @@ async function main() {
|
|
|
65708
65750
|
return;
|
|
65709
65751
|
}
|
|
65710
65752
|
if (command === "update") {
|
|
65711
|
-
|
|
65753
|
+
for (const [k2, v2] of Object.entries(overrides)) {
|
|
65754
|
+
if (v2 !== void 0) process.env[k2] = v2;
|
|
65755
|
+
}
|
|
65756
|
+
let updaterResolveProxy;
|
|
65757
|
+
try {
|
|
65758
|
+
const o = loadOptions();
|
|
65759
|
+
updaterResolveProxy = (url) => resolveProxy(o.routes, o.proxy, url, o.proxyFallback);
|
|
65760
|
+
} catch (e) {
|
|
65761
|
+
console.error(`bili update: config load failed (${String(e)}); updater egress goes direct`);
|
|
65762
|
+
}
|
|
65763
|
+
await checkForUpdate(
|
|
65764
|
+
{ packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true, resolveProxy: updaterResolveProxy },
|
|
65765
|
+
true
|
|
65766
|
+
);
|
|
65712
65767
|
return;
|
|
65713
65768
|
}
|
|
65714
65769
|
if (command === "test") {
|
|
@@ -65730,7 +65785,12 @@ async function main() {
|
|
|
65730
65785
|
const opts = loadOptions();
|
|
65731
65786
|
await startServer(opts);
|
|
65732
65787
|
if (opts.autoUpdate) {
|
|
65733
|
-
startAutoUpdate({
|
|
65788
|
+
startAutoUpdate({
|
|
65789
|
+
packageName: PACKAGE_NAME,
|
|
65790
|
+
currentVersion: VERSION3,
|
|
65791
|
+
autoUpdate: true,
|
|
65792
|
+
resolveProxy: (url) => resolveProxy(opts.routes, opts.proxy, url, opts.proxyFallback)
|
|
65793
|
+
});
|
|
65734
65794
|
}
|
|
65735
65795
|
}
|
|
65736
65796
|
|