billion-context 0.1.98 → 0.1.99-pr.649.494

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 CHANGED
@@ -48514,6 +48514,7 @@ function loadOptions(env = process.env) {
48514
48514
  passthrough: passthrough.enabled,
48515
48515
  passthroughSource: passthrough.source,
48516
48516
  autoUpdate: (env.ACP_AUTO_UPDATE ?? (fileConfig.autoUpdate === false ? "0" : "1")) !== "0",
48517
+ hostUsageCredit: parseHostUsageCredit(env.BILI_HOST_USAGE_CREDIT ?? fileConfig.hostUsageCredit),
48517
48518
  updateTag: (env.ACP_UPDATE_TAG ?? fileConfig.updateTag ?? "latest").trim() || "latest",
48518
48519
  logFile: env.ACP_LOG_FILE !== void 0 ? env.ACP_LOG_FILE || void 0 : fileConfig.logFile,
48519
48520
  mitm: {
@@ -48590,6 +48591,9 @@ function parsePromptCacheRouting(value) {
48590
48591
  function parseUpstreamProxyMode(value) {
48591
48592
  return value === "manual" || value === "auto" ? value : "direct";
48592
48593
  }
48594
+ function parseHostUsageCredit(value) {
48595
+ return value === "off" ? "off" : "auto";
48596
+ }
48593
48597
  function parseCompressSettings(v2) {
48594
48598
  if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return void 0;
48595
48599
  const obj = v2;
@@ -59473,8 +59477,9 @@ function diagNudge(turn, sessionId, tokenCount, limit, model, willInject) {
59473
59477
  const modelTag = model ? ` model=${model}` : "";
59474
59478
  return `[${sessionId}] nudge ${inject}: usage=${pct2} (${tokenCount}/${limit}), growth=${growth}/${floor} (ref=${ref}, interval=${interval}), pendingT1=${pendingT1}/${interval}${modelTag}, reason="${n.reason.slice(0, 120)}"`;
59475
59479
  }
59476
- function armHostUsageCredit(session, originalMessages, processedMessages, log2) {
59480
+ function armHostUsageCredit(session, originalMessages, processedMessages, hostUsageCredit, log2) {
59477
59481
  session.hostCreditTokens = 0;
59482
+ if (hostUsageCredit === "off") return;
59478
59483
  if (session.metadata.pluginAgent === "pi" || session.metadata.pluginAgent === "omp") return;
59479
59484
  session.hostCreditTokens = processedMessages.length > 0 ? Math.max(0, estimateCoreMessages(originalMessages) - estimateCoreMessages(processedMessages)) : 0;
59480
59485
  if (session.hostCreditTokens > 0) {
@@ -59556,7 +59561,7 @@ function prepareAnthropic(parsed, req, opts, core, config, prompts, log2, sessio
59556
59561
  markDirty(session);
59557
59562
  const rebuilt = { ...parsed, messages: rebuiltMessages, system: systemOut, tools: toolsOut };
59558
59563
  delete rebuilt.prompt_cache_key;
59559
- armHostUsageCredit(session, originalMessages, processedMessages, log2);
59564
+ armHostUsageCredit(session, originalMessages, processedMessages, opts.hostUsageCredit, log2);
59560
59565
  return { body: JSON.stringify(rebuilt), session, processedMessages, originalMessages, anthropicSystem: parsed.system, protocol: "anthropic", stream: stream2, compressInjected: injectTools, pluginMode, nudge, prompts, renderTags: "text-only" };
59561
59566
  }
59562
59567
  var OUTPUT_CLAMP_MARGIN_PCT = 0.05;
@@ -59688,7 +59693,7 @@ function prepareOpenai(parsed, req, opts, core, config, prompts, log2, session,
59688
59693
  if (stream2 && rebuilt.stream_options === void 0) {
59689
59694
  rebuilt.stream_options = { include_usage: true };
59690
59695
  }
59691
- armHostUsageCredit(session, originalMessages, processedMessages, log2);
59696
+ armHostUsageCredit(session, originalMessages, processedMessages, opts.hostUsageCredit, log2);
59692
59697
  if (!isTitleGen && openaiOutboundSystem !== void 0) {
59693
59698
  session.metadata.systemPromptTokens = countSystemAndToolsTokens(openaiOutboundSystem, toolsOut);
59694
59699
  }
@@ -59840,7 +59845,7 @@ function prepareResponses(parsed, req, opts, core, config, prompts, log2, sessio
59840
59845
  });
59841
59846
  log2("info", `[${sessionId}] responses forward tools=[${fwdTools.join(",")}] injectTool=${injectTools}${pluginMode ? " (plugin mode: wire injection suppressed)" : ""} NO_INJECT_TOOL=${!!process.env.ACP_NO_INJECT_TOOL} NO_COMPRESS_PROMPT=${!!process.env.ACP_NO_COMPRESS_PROMPT}`);
59842
59847
  }
59843
- armHostUsageCredit(session, originalMessages, processedMessages, log2);
59848
+ armHostUsageCredit(session, originalMessages, processedMessages, opts.hostUsageCredit, log2);
59844
59849
  if (transformOk) {
59845
59850
  session.metadata.systemPromptTokens = countSystemAndToolsTokens(responsesDevContent ?? "", toolsOut);
59846
59851
  }