billion-context 0.1.90 → 0.1.91-pr.618.439

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
@@ -48218,13 +48218,17 @@ function parseCompressSettings(v2) {
48218
48218
  }
48219
48219
  out[key] = typeof obj[key] === "string" ? obj[key].trim() : obj[key];
48220
48220
  }
48221
- for (const key of ["nudgeGrowthTokens", "preserveRecentMessages", "preserveRecentTokens", "minCompressRange", "minCompressRangeChars"]) {
48221
+ for (const key of ["nudgeGrowthTokens", "preserveRecentMessages", "preserveRecentTokens", "minCompressRange", "minCompressRangeChars", "stripImagesKeepRecent"]) {
48222
48222
  takeNumber(key);
48223
48223
  }
48224
48224
  if ("tiers" in obj) {
48225
48225
  if (typeof obj.tiers !== "boolean") ok = false;
48226
48226
  else out.tiers = obj.tiers;
48227
48227
  }
48228
+ if ("stripImages" in obj) {
48229
+ if (typeof obj.stripImages !== "boolean") ok = false;
48230
+ else out.stripImages = obj.stripImages;
48231
+ }
48228
48232
  for (const key of ["injectTool", "injectNudge"]) {
48229
48233
  if (key in obj) {
48230
48234
  if (typeof obj[key] !== "boolean") ok = false;
@@ -48295,7 +48299,9 @@ function mergeCompress(global2, provider, model) {
48295
48299
  minCompressRangeChars: rangeOf(model) ?? rangeOf(provider) ?? rangeOf(global2),
48296
48300
  tiers: pick("tiers"),
48297
48301
  prompts: promptLevels.length > 0 ? Object.assign({}, ...promptLevels) : void 0,
48298
- acknowledgePromptsRisk: pick("acknowledgePromptsRisk")
48302
+ acknowledgePromptsRisk: pick("acknowledgePromptsRisk"),
48303
+ stripImages: pick("stripImages"),
48304
+ stripImagesKeepRecent: pick("stripImagesKeepRecent")
48299
48305
  };
48300
48306
  }
48301
48307
  function resolveCompress(routes, upstreamUrl, model, global2) {
@@ -48363,6 +48369,69 @@ function resolveRequestConfig(base, routes, embeddedUrl, model, native, globalCo
48363
48369
  return applyCompressSettings(base, limit, compress);
48364
48370
  }
48365
48371
 
48372
+ // src/strip-images.ts
48373
+ var DEFAULT_STRIP_IMAGES_KEEP_RECENT = 5;
48374
+ var IMAGE_PLACEHOLDER = "[image]";
48375
+ function isObj(v2) {
48376
+ return typeof v2 === "object" && v2 !== null;
48377
+ }
48378
+ function isImagePart(protocol, part) {
48379
+ if (!isObj(part)) return false;
48380
+ if (protocol === "responses") return part.type === "input_image";
48381
+ if (protocol === "openai") return part.type === "image_url";
48382
+ return part.type === "image";
48383
+ }
48384
+ function placeholderContent(protocol) {
48385
+ const type = protocol === "responses" ? "input_text" : "text";
48386
+ return [{ type, text: IMAGE_PLACEHOLDER }];
48387
+ }
48388
+ function stripHistoricalImages(body, protocol, keepRecent) {
48389
+ if (!protocol || !isObj(body)) return { body, removed: 0 };
48390
+ const recentCount = Math.max(0, Math.floor(keepRecent));
48391
+ if (protocol === "responses") {
48392
+ const input = body.input;
48393
+ if (!Array.isArray(input)) return { body, removed: 0 };
48394
+ const cutoff2 = input.length - recentCount;
48395
+ let removed2 = 0;
48396
+ let touched2 = false;
48397
+ const nextInput = input.map((item, i) => {
48398
+ if (i < cutoff2 && isObj(item) && Array.isArray(item.content)) {
48399
+ const content = item.content;
48400
+ const imgs = content.filter((p2) => isImagePart("responses", p2)).length;
48401
+ if (imgs > 0) {
48402
+ removed2 += imgs;
48403
+ touched2 = true;
48404
+ const kept = content.filter((p2) => !isImagePart("responses", p2));
48405
+ return { ...item, content: kept.length > 0 ? kept : placeholderContent("responses") };
48406
+ }
48407
+ }
48408
+ return item;
48409
+ });
48410
+ if (!touched2) return { body, removed: 0 };
48411
+ return { body: { ...body, input: nextInput }, removed: removed2 };
48412
+ }
48413
+ const messages = body.messages;
48414
+ if (!Array.isArray(messages)) return { body, removed: 0 };
48415
+ const cutoff = messages.length - recentCount;
48416
+ let removed = 0;
48417
+ let touched = false;
48418
+ const nextMessages = messages.map((m2, i) => {
48419
+ if (i < cutoff && isObj(m2) && Array.isArray(m2.content)) {
48420
+ const content = m2.content;
48421
+ const imgs = content.filter((p2) => isImagePart(protocol, p2)).length;
48422
+ if (imgs > 0) {
48423
+ removed += imgs;
48424
+ touched = true;
48425
+ const kept = content.filter((p2) => !isImagePart(protocol, p2));
48426
+ return { ...m2, content: kept.length > 0 ? kept : placeholderContent(protocol) };
48427
+ }
48428
+ }
48429
+ return m2;
48430
+ });
48431
+ if (!touched) return { body, removed: 0 };
48432
+ return { body: { ...body, messages: nextMessages }, removed };
48433
+ }
48434
+
48366
48435
  // src/registry.ts
48367
48436
  import { readFile, writeFile, mkdir } from "fs/promises";
48368
48437
  import { existsSync as existsSync2, statSync as statSync2 } from "fs";
@@ -51551,24 +51620,24 @@ function costForUrl(url) {
51551
51620
  }
51552
51621
  return applyCap(REMOTE_IMAGE_TOKENS);
51553
51622
  }
51554
- function isObj(v2) {
51623
+ function isObj2(v2) {
51555
51624
  return typeof v2 === "object" && v2 !== null;
51556
51625
  }
51557
51626
  function urlOf(v2) {
51558
51627
  if (typeof v2 === "string") return v2;
51559
- if (isObj(v2) && typeof v2.url === "string") return v2.url;
51628
+ if (isObj2(v2) && typeof v2.url === "string") return v2.url;
51560
51629
  return void 0;
51561
51630
  }
51562
51631
  function imageTokensInParsedBody(protocol, body) {
51563
- if (!isObj(body)) return 0;
51632
+ if (!isObj2(body)) return 0;
51564
51633
  let total = 0;
51565
51634
  if (protocol === "responses") {
51566
51635
  const input = body.input;
51567
51636
  if (!Array.isArray(input)) return 0;
51568
51637
  for (const item of input) {
51569
- if (!isObj(item) || !Array.isArray(item.content)) continue;
51638
+ if (!isObj2(item) || !Array.isArray(item.content)) continue;
51570
51639
  for (const part of item.content) {
51571
- if (!isObj(part) || part.type !== "input_image") continue;
51640
+ if (!isObj2(part) || part.type !== "input_image") continue;
51572
51641
  const url = urlOf(part.image_url);
51573
51642
  if (url) total += costForUrl(url);
51574
51643
  }
@@ -51578,9 +51647,9 @@ function imageTokensInParsedBody(protocol, body) {
51578
51647
  const messages = body.messages;
51579
51648
  if (!Array.isArray(messages)) return 0;
51580
51649
  for (const m2 of messages) {
51581
- if (!isObj(m2) || !Array.isArray(m2.content)) continue;
51650
+ if (!isObj2(m2) || !Array.isArray(m2.content)) continue;
51582
51651
  for (const part of m2.content) {
51583
- if (!isObj(part)) continue;
51652
+ if (!isObj2(part)) continue;
51584
51653
  if (protocol === "openai") {
51585
51654
  if (part.type !== "image_url") continue;
51586
51655
  const url = urlOf(part.image_url);
@@ -51588,8 +51657,8 @@ function imageTokensInParsedBody(protocol, body) {
51588
51657
  } else {
51589
51658
  if (part.type !== "image") continue;
51590
51659
  const src = part.source;
51591
- if (isObj(src) && src.type === "base64" && typeof src.data === "string") total += applyCap(Math.ceil(src.data.length / 4));
51592
- else if (isObj(src) && src.type === "url" && typeof src.url === "string") total += costForUrl(src.url);
51660
+ if (isObj2(src) && src.type === "base64" && typeof src.data === "string") total += applyCap(Math.ceil(src.data.length / 4));
51661
+ else if (isObj2(src) && src.type === "url" && typeof src.url === "string") total += costForUrl(src.url);
51593
51662
  }
51594
51663
  }
51595
51664
  }
@@ -51829,7 +51898,7 @@ function renderPage(origin, version2) {
51829
51898
  <div class="card"><div class="card-head"><h2>ZCode\uFF08\u7F16\u7A0B\u5957\u9910\uFF09</h2><span class="badge">MITM</span><button class="btn small copy-btn" data-copy="${caPathEsc}">\u590D\u5236 CA \u8DEF\u5F84</button></div><dl class="kv"><dt>\u65B9\u5F0F</dt><dd>MITM \u900F\u660E\u4EE3\u7406</dd><dt>\u8BBE\u7F6E</dt><dd>Settings \u2192 Network \u2192 HTTP Proxy = <span class="mono">${origin}</span></dd><dt>CA \u8BC1\u4E66</dt><dd class="mono">${caPathEsc}${caReady ? "" : "\uFF08\u5C1A\u672A\u751F\u6210\uFF0C\u542F\u52A8\u4EE3\u7406\u540E\u81EA\u52A8\u521B\u5EFA\uFF09"}</dd></dl><p class="hint">CA \u8DEF\u5F84\u662F\u672C\u673A bili \u5B9E\u9645\u751F\u6210\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u70B9"\u590D\u5236 CA \u8DEF\u5F84"\u540E\u76F4\u63A5\u7C98\u8D34\u8FDB ZCode\u3002\u26A0\uFE0F Windows \u4E0A ZCode \u4E0D\u4F1A\u5C55\u5F00 <span class="mono">~</span>\uFF0C\u8BF7\u52FF\u624B\u586B <span class="mono">~/\u2026</span> \u5F62\u5F0F\u7684\u8DEF\u5F84\u3002</p></div></section>
51830
51899
  <section id="page-upstream" class="page"><h1>\u4E0A\u6E38\u7F51\u7EDC</h1><p class="lead">\u63A7\u5236 bili \u5982\u4F55\u8BBF\u95EE\u771F\u5B9E Provider\uFF0C\u4E0D\u4F1A\u6539\u53D8\u5BA2\u6237\u7AEF\u7684\u672C\u5730\u8DEF\u7531\u5730\u5740\u3002</p><div class="card"><div class="card-head"><h2>\u5168\u5C40\u4EE3\u7406</h2></div><div class="modes"><label><input type="radio" name="proxy-mode" value="direct" checked>\u76F4\u8FDE\uFF08\u9ED8\u8BA4\uFF09</label><label><input type="radio" name="proxy-mode" value="manual">\u624B\u52A8\u4EE3\u7406</label><label><input type="radio" name="proxy-mode" value="auto">\u81EA\u52A8\uFF08\u8DDF\u968F\u7CFB\u7EDF\uFF09</label></div><div class="field"><label>HTTP / HTTPS Proxy</label><input id="proxy-url" class="mono" placeholder="http://127.0.0.1:7897"></div><dl class="kv"><dt>\u5F53\u524D\u6765\u6E90</dt><dd id="upstream-source">\u76F4\u8FDE</dd><dt>\u6709\u6548\u4EE3\u7406</dt><dd id="upstream-effective" class="mono">direct</dd><dt>\u7CFB\u7EDF PAC</dt><dd id="upstream-pac" class="mono">\u2014</dd><dt>\u72B6\u6001</dt><dd id="upstream-state" class="status">\u5C1A\u672A\u6D4B\u8BD5</dd></dl><div class="actions"><button id="save-upstream" class="btn primary">\u4FDD\u5B58\u5E76\u70ED\u66F4\u65B0</button><button id="test-upstream" class="btn">\u6D4B\u8BD5\u8FDE\u63A5</button></div></div><div class="card"><div class="card-head"><h2>\u6309 URL \u8986\u76D6</h2></div><p class="status">\u4E3A\u7279\u5B9A Provider \u5355\u72EC\u8BBE\u7F6E\u4E0A\u6E38\u4EE3\u7406\uFF0C\u8986\u76D6\u5168\u5C40\u8BBE\u7F6E\u3002\u7559\u7A7A = \u7EE7\u627F\u5168\u5C40\u3002</p><div id="upstream-overrides" class="status">\u52A0\u8F7D\u4E2D</div><div class="actions"><button id="save-overrides" class="btn primary">\u4FDD\u5B58\u8986\u76D6\u5E76\u70ED\u66F4\u65B0</button></div></div></section>
51831
51900
  <section id="page-sessions" class="page"><div class="card-head"><div><h1>\u4F1A\u8BDD</h1><p class="lead">ACP \u538B\u7F29\u72B6\u6001\u4E0E\u4E0A\u6E38\u7528\u91CF\u3002</p></div><button id="refresh-sessions" class="btn">\u5237\u65B0</button></div><div class="card"><table><thead><tr><th>\u6807\u9898</th><th>\u534F\u8BAE</th><th>\u6807\u8BC6</th><th>\u8BF7\u6C42</th><th>\u4E0A\u4E0B\u6587</th><th>\u6700\u540E\u6D3B\u52A8</th></tr></thead><tbody id="sessions-body"></tbody></table></div></section>
51832
- <section id="page-settings" class="page"><h1>\u9AD8\u7EA7\u8BBE\u7F6E</h1><p class="lead">\u76F4\u63A5\u7F16\u8F91 providers JSON\uFF08\u6DFB\u52A0\u65B0 Provider\u3001\u914D\u7F6E\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\u3001\u6309 URL \u4EE3\u7406\u7B49\uFF09\uFF1B\u4FDD\u5B58\u540E\u7ACB\u5373\u70ED\u66F4\u65B0\u3002</p><div class="card"><div class="field"><label>providers JSON</label><textarea id="providers-json">{}</textarea></div><div class="actions"><button id="save-providers" class="btn primary">\u4FDD\u5B58\u5E76\u5E94\u7528</button></div></div><div class="card"><div class="card-head"><h2>\u538B\u7F29\u53C2\u6570\uFF08\u5168\u5C40\uFF09</h2></div><p class="status">\u5168\u5C40 compress \u914D\u7F6E\uFF08modelContextLimit / maxContextLimit / emergencyThresholdPercent / nudgeGrowthTokens / preserveRecentMessages / preserveRecentTokens / minCompressRangeChars\uFF08\u5355\u4F4D\uFF1A\u5B57\u7B26\uFF0C\u65E7\u540D minCompressRange \u517C\u5BB9\uFF09 / tiers / injectTool / injectNudge\uFF09\u3002\u4FDD\u5B58\u540E\u70ED\u66F4\u65B0\uFF0C\u65E0\u9700\u91CD\u542F\u3002\u7F6E\u7A7A = \u6062\u590D\u9ED8\u8BA4\u3002</p><div class="field"><label>compress JSON</label><textarea id="compress-json" placeholder='{"modelContextLimit": 200000}'></textarea></div><div class="actions"><button id="save-compress" class="btn primary">\u4FDD\u5B58\u5E76\u70ED\u66F4\u65B0</button></div></div></section></main></div><div id="toast" class="toast"></div><script>${WEB_CLIENT}</script></body></html>`;
51901
+ <section id="page-settings" class="page"><h1>\u9AD8\u7EA7\u8BBE\u7F6E</h1><p class="lead">\u76F4\u63A5\u7F16\u8F91 providers JSON\uFF08\u6DFB\u52A0\u65B0 Provider\u3001\u914D\u7F6E\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\u3001\u6309 URL \u4EE3\u7406\u7B49\uFF09\uFF1B\u4FDD\u5B58\u540E\u7ACB\u5373\u70ED\u66F4\u65B0\u3002</p><div class="card"><div class="field"><label>providers JSON</label><textarea id="providers-json">{}</textarea></div><div class="actions"><button id="save-providers" class="btn primary">\u4FDD\u5B58\u5E76\u5E94\u7528</button></div></div><div class="card"><div class="card-head"><h2>\u538B\u7F29\u53C2\u6570\uFF08\u5168\u5C40\uFF09</h2></div><p class="status">\u5168\u5C40 compress \u914D\u7F6E\uFF08modelContextLimit / maxContextLimit / emergencyThresholdPercent / nudgeGrowthTokens / preserveRecentMessages / preserveRecentTokens / minCompressRangeChars\uFF08\u5355\u4F4D\uFF1A\u5B57\u7B26\uFF0C\u65E7\u540D minCompressRange \u517C\u5BB9\uFF09 / stripImages / stripImagesKeepRecent\uFF08\u5386\u53F2\u56FE\u50CF\u5265\u79BB\uFF0C\u9ED8\u8BA4\u5173\uFF09 / tiers / injectTool / injectNudge\uFF09\u3002\u4FDD\u5B58\u540E\u70ED\u66F4\u65B0\uFF0C\u65E0\u9700\u91CD\u542F\u3002\u7F6E\u7A7A = \u6062\u590D\u9ED8\u8BA4\u3002</p><div class="field"><label>compress JSON</label><textarea id="compress-json" placeholder='{"modelContextLimit": 200000}'></textarea></div><div class="actions"><button id="save-compress" class="btn primary">\u4FDD\u5B58\u5E76\u70ED\u66F4\u65B0</button></div></div></section></main></div><div id="toast" class="toast"></div><script>${WEB_CLIENT}</script></body></html>`;
51833
51902
  }
51834
51903
 
51835
51904
  // src/web/api.ts
@@ -58533,7 +58602,16 @@ ${bodyBuffer.toString("utf8")}`);
58533
58602
  acquireInFlight(session);
58534
58603
  try {
58535
58604
  await withSessionLock(session, async () => {
58536
- const runPrepare = () => countTokens ? prepareCountTokens(parsed, core, reqConfig, log2, session) : protocol === "anthropic" ? prepareAnthropic(parsed, req, opts, core, reqConfig, reqPrompts, log2, session, pluginMode) : protocol === "openai" ? prepareOpenai(parsed, req, opts, core, reqConfig, reqPrompts, log2, session, pluginMode, nativeWindow) : responsesCompact ? prepareResponsesCompact(bodyBuffer, parsed, session, req, core, reqConfig, log2) : prepareResponses(parsed, req, opts, core, reqConfig, reqPrompts, log2, session, responsesIdentity, pluginMode, upstreamOrigin, nativeWindow);
58605
+ const runPrepare = () => {
58606
+ const cs2 = resolveCompress(opts.routes, route?.rewrittenUrl, parsed.model, opts.compress);
58607
+ const keepRecent = cs2.stripImagesKeepRecent ?? DEFAULT_STRIP_IMAGES_KEEP_RECENT;
58608
+ const stripped = cs2.stripImages ? stripHistoricalImages(parsed, protocol, keepRecent) : { body: parsed, removed: 0 };
58609
+ if (opts.debug && stripped.removed > 0) {
58610
+ log2("info", `[debug] strip-images: dropped ${stripped.removed} historical image part(s), kept last ${keepRecent} (session=${session.id})`);
58611
+ }
58612
+ const work = stripped.body;
58613
+ return countTokens ? prepareCountTokens(work, core, reqConfig, log2, session) : protocol === "anthropic" ? prepareAnthropic(work, req, opts, core, reqConfig, reqPrompts, log2, session, pluginMode) : protocol === "openai" ? prepareOpenai(work, req, opts, core, reqConfig, reqPrompts, log2, session, pluginMode, nativeWindow) : responsesCompact ? prepareResponsesCompact(stripped.removed > 0 ? Buffer.from(JSON.stringify(work)) : bodyBuffer, work, session, req, core, reqConfig, log2) : prepareResponses(work, req, opts, core, reqConfig, reqPrompts, log2, session, responsesIdentity, pluginMode, upstreamOrigin, nativeWindow);
58614
+ };
58537
58615
  const isCodexCompactTrigger = protocol === "responses" && !responsesCompact && isCodexClient(req.headers) && hasCompactionTrigger(parsed.input);
58538
58616
  if (isCodexCompactTrigger) {
58539
58617
  const mode = codexCompactMode();
@@ -63303,6 +63381,12 @@ async function tryAcquireLock() {
63303
63381
  }
63304
63382
  };
63305
63383
  }
63384
+ function egressDispatcher(opts, url) {
63385
+ return proxyDispatcher(opts.resolveProxy?.(url));
63386
+ }
63387
+ function fetchWithEgress(url, init) {
63388
+ return fetch(url, init);
63389
+ }
63306
63390
  async function checkForUpdate(opts, force = false) {
63307
63391
  if (!opts.autoUpdate && !force) return;
63308
63392
  if (inFlight) return;
@@ -63325,9 +63409,11 @@ async function checkForUpdate(opts, force = false) {
63325
63409
  }
63326
63410
  log("info", `[update] checking npm registry for ${opts.packageName}${sinceLastSec < 0 ? " (startup check)" : sinceLastSec === 0 ? "" : ` (last check ${sinceLastSec}s ago)`}\u2026`);
63327
63411
  const url = `${REGISTRY_BASE}/${opts.packageName}/latest`;
63328
- const res = await fetch(url, {
63412
+ const registryDispatcher = egressDispatcher(opts, url);
63413
+ const res = await fetchWithEgress(url, {
63329
63414
  signal: AbortSignal.timeout(5e3),
63330
- headers: { Accept: "application/json" }
63415
+ headers: { Accept: "application/json" },
63416
+ ...registryDispatcher ? { dispatcher: registryDispatcher } : {}
63331
63417
  });
63332
63418
  if (!res.ok) {
63333
63419
  log("warn", `[update] registry returned ${res.status} ${res.statusText}, skipping`);
@@ -63363,7 +63449,7 @@ async function checkForUpdate(opts, force = false) {
63363
63449
  return;
63364
63450
  }
63365
63451
  try {
63366
- const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum);
63452
+ const result = await installViaTarball(latest, tarballUrl, installDir, integrity, shasum, egressDispatcher(opts, tarballUrl));
63367
63453
  if (result.ok) {
63368
63454
  log("info", `[update] installed ${currentVersion} \u2192 ${latest}. Restart to finish.`);
63369
63455
  } else {
@@ -63400,7 +63486,7 @@ function verifyTarballIntegrity(buf, integrity, shasum) {
63400
63486
  }
63401
63487
  return { ok: false, error: "no integrity or shasum from registry" };
63402
63488
  }
63403
- async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum) {
63489
+ async function installViaTarball(version2, tarballUrl, installDir, integrity, shasum, dispatcher) {
63404
63490
  if (!installDir) {
63405
63491
  return { ok: false, error: "cannot determine install directory (package.json not found walking up from running binary)" };
63406
63492
  }
@@ -63415,7 +63501,10 @@ async function installViaTarball(version2, tarballUrl, installDir, integrity, sh
63415
63501
  const MAX_TARBALL_BYTES = 100 * 1024 * 1024;
63416
63502
  let tgzBuffer;
63417
63503
  try {
63418
- const tgzRes = await fetch(tarballUrl, { signal: AbortSignal.timeout(6e4) });
63504
+ const tgzRes = await fetchWithEgress(tarballUrl, {
63505
+ signal: AbortSignal.timeout(6e4),
63506
+ ...dispatcher ? { dispatcher } : {}
63507
+ });
63419
63508
  if (!tgzRes.ok) {
63420
63509
  return { ok: false, error: `tarball download failed: HTTP ${tgzRes.status} ${tgzRes.statusText}` };
63421
63510
  }
@@ -65849,7 +65938,20 @@ async function main() {
65849
65938
  return;
65850
65939
  }
65851
65940
  if (command === "update") {
65852
- await checkForUpdate({ packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true }, true);
65941
+ for (const [k2, v2] of Object.entries(overrides)) {
65942
+ if (v2 !== void 0) process.env[k2] = v2;
65943
+ }
65944
+ let updaterResolveProxy;
65945
+ try {
65946
+ const o = loadOptions();
65947
+ updaterResolveProxy = (url) => resolveProxy(o.routes, o.proxy, url, o.proxyFallback);
65948
+ } catch (e) {
65949
+ console.error(`bili update: config load failed (${String(e)}); updater egress goes direct`);
65950
+ }
65951
+ await checkForUpdate(
65952
+ { packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true, resolveProxy: updaterResolveProxy },
65953
+ true
65954
+ );
65853
65955
  return;
65854
65956
  }
65855
65957
  if (command === "test") {
@@ -65871,7 +65973,12 @@ async function main() {
65871
65973
  const opts = loadOptions();
65872
65974
  await startServer(opts);
65873
65975
  if (opts.autoUpdate) {
65874
- startAutoUpdate({ packageName: PACKAGE_NAME, currentVersion: VERSION3, autoUpdate: true });
65976
+ startAutoUpdate({
65977
+ packageName: PACKAGE_NAME,
65978
+ currentVersion: VERSION3,
65979
+ autoUpdate: true,
65980
+ resolveProxy: (url) => resolveProxy(opts.routes, opts.proxy, url, opts.proxyFallback)
65981
+ });
65875
65982
  }
65876
65983
  }
65877
65984