billion-context 0.1.90 → 0.1.91-pr.621.436

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 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
@@ -63303,6 +63303,12 @@ async function tryAcquireLock() {
63303
63303
  }
63304
63304
  };
63305
63305
  }
63306
+ function egressDispatcher(opts, url) {
63307
+ return proxyDispatcher(opts.resolveProxy?.(url));
63308
+ }
63309
+ function fetchWithEgress(url, init) {
63310
+ return fetch(url, init);
63311
+ }
63306
63312
  async function checkForUpdate(opts, force = false) {
63307
63313
  if (!opts.autoUpdate && !force) return;
63308
63314
  if (inFlight) return;
@@ -63325,9 +63331,11 @@ async function checkForUpdate(opts, force = false) {
63325
63331
  }
63326
63332
  log("info", `[update] checking npm registry for ${opts.packageName}${sinceLastSec < 0 ? " (startup check)" : sinceLastSec === 0 ? "" : ` (last check ${sinceLastSec}s ago)`}\u2026`);
63327
63333
  const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
63328
- const res = await fetch(url, {
63334
+ const registryDispatcher = egressDispatcher(opts, url);
63335
+ const res = await fetchWithEgress(url, {
63329
63336
  signal: AbortSignal.timeout(5e3),
63330
- headers: { Accept: "application/json" }
63337
+ headers: { Accept: "application/json" },
63338
+ ...registryDispatcher ? { dispatcher: registryDispatcher } : {}
63331
63339
  });
63332
63340
  if (!res.ok) {
63333
63341
  log("warn", `[update] registry returned ${res.status} ${res.statusText}, skipping`);
@@ -63363,7 +63371,7 @@ async function checkForUpdate(opts, force = false) {
63363
63371
  return;
63364
63372
  }
63365
63373
  try {
63366
- const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum);
63374
+ const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum, egressDispatcher(opts, tarballUrl));
63367
63375
  if (result.ok) {
63368
63376
  log("info", `[update] installed ${currentVersion} \u2192 ${latest}. Restart to finish.`);
63369
63377
  } else {
@@ -63400,7 +63408,7 @@ function verifyTarballIntegrity(buf, integrity, shasum) {
63400
63408
  }
63401
63409
  return { ok: false, error: "no integrity or shasum from registry" };
63402
63410
  }
63403
- async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum) {
63411
+ async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum, dispatcher) {
63404
63412
  if (!installDir) {
63405
63413
  return { ok: false, error: "cannot determine install directory (package.json not found walking up from running binary)" };
63406
63414
  }
@@ -63415,7 +63423,10 @@ async function installViaTarball(version2, tarballUrl, installDir, integrity, sh
63415
63423
  const MAX_TARBALL_BYTES = 100 * 1024 * 1024;
63416
63424
  let tgzBuffer;
63417
63425
  try {
63418
- const tgzRes = await fetch(tarballUrl, { signal: AbortSignal.timeout(6e4) });
63426
+ const tgzRes = await fetchWithEgress(tarballUrl, {
63427
+ signal: AbortSignal.timeout(6e4),
63428
+ ...dispatcher ? { dispatcher } : {}
63429
+ });
63419
63430
  if (!tgzRes.ok) {
63420
63431
  return { ok: false, error: `tarball download failed: HTTP ${tgzRes.status} ${tgzRes.statusText}` };
63421
63432
  }
@@ -65849,7 +65860,20 @@ async function main() {
65849
65860
  return;
65850
65861
  }
65851
65862
  if (command === "update") {
65852
- await checkForUpdate({ packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true }, true);
65863
+ for (const [k2, v2] of Object.entries(overrides)) {
65864
+ if (v2 !== void 0) process.env[k2] = v2;
65865
+ }
65866
+ let updaterResolveProxy;
65867
+ try {
65868
+ const o = loadOptions();
65869
+ updaterResolveProxy = (url) => resolveProxy(o.routes, o.proxy, url, o.proxyFallback);
65870
+ } catch (e) {
65871
+ console.error(`bili update: config load failed (${String(e)}); updater egress goes direct`);
65872
+ }
65873
+ await checkForUpdate(
65874
+ { packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true, resolveProxy: updaterResolveProxy },
65875
+ true
65876
+ );
65853
65877
  return;
65854
65878
  }
65855
65879
  if (command === "test") {
@@ -65871,7 +65895,12 @@ async function main() {
65871
65895
  const opts = loadOptions();
65872
65896
  await startServer(opts);
65873
65897
  if (opts.autoUpdate) {
65874
- startAutoUpdate({ packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true });
65898
+ startAutoUpdate({
65899
+ packageName: PACKAGE_NAME,
65900
+ currentVersion: VERSION3,
65901
+ autoUpdate: true,
65902
+ resolveProxy: (url) => resolveProxy(opts.routes, opts.proxy, url, opts.proxyFallback)
65903
+ });
65875
65904
  }
65876
65905
  }
65877
65906