billion-context 0.1.67-pr.397.236 → 0.1.67-pr.398.237

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
@@ -50110,41 +50110,6 @@ function withStagedCompressGuidance(text) {
50110
50110
  return text + STAGED_COMPRESS_GUIDANCE;
50111
50111
  }
50112
50112
 
50113
- // src/acp-status.ts
50114
- function handleAcpStatus(args, ctx) {
50115
- const scope = typeof args.scope === "string" ? args.scope : void 0;
50116
- const view = typeof args.view === "string" ? args.view : void 0;
50117
- const tool = typeof args.tool === "string" ? args.tool : void 0;
50118
- const sort = typeof args.sort === "string" ? args.sort : void 0;
50119
- const limit = typeof args.limit === "number" ? args.limit : void 0;
50120
- const base = buildStatusReport(ctx.session.state, ctx.messages, estimateTokensFast, { scope, view, tool, sort, limit });
50121
- if (scope) return base;
50122
- const extra = [];
50123
- try {
50124
- const turn = ctx.core.processTurn({
50125
- messages: ctx.messages,
50126
- state: ctx.session.state,
50127
- config: ctx.config,
50128
- tokenCount: ctx.session.stats.lastInputTokens,
50129
- renderTags: "none"
50130
- });
50131
- const nudge = turn.nudge;
50132
- if (nudge) {
50133
- extra.push("");
50134
- extra.push(nudge.shouldInject ? `Nudge: ACTIVE \u2014 ${nudge.reason}` : `Nudge: idle \u2014 ${nudge.reason}`);
50135
- const ranges = viableRanges(nudge.compressibleRanges);
50136
- const protectedRanges = nudge.protectedRanges ?? [];
50137
- if (ranges.length > 0 || protectedRanges.length > 0) {
50138
- extra.push("");
50139
- extra.push(formatRanges(ranges, protectedRanges));
50140
- }
50141
- }
50142
- } catch {
50143
- }
50144
- return extra.length > 0 ? `${base}
50145
- ${extra.join("\n")}` : base;
50146
- }
50147
-
50148
50113
  // src/decompress-shared.ts
50149
50114
  import { mkdirSync as mkdirSync3, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
50150
50115
  import { dirname as dirname2, join as join2 } from "path";
@@ -50425,7 +50390,7 @@ function executeAnthropicProxyTool(toolName, args, ctx) {
50425
50390
  ${lines.join("\n\n")}`;
50426
50391
  }
50427
50392
  if (toolName === "acp_status") {
50428
- return handleAcpStatus(args, ctx);
50393
+ return buildStatusReport(ctx.session.state, ctx.messages, estimateTokensFast);
50429
50394
  }
50430
50395
  return `[Unknown proxy tool: ${toolName}]`;
50431
50396
  }
@@ -51247,6 +51212,29 @@ ${lines.join("\n\n")}`;
51247
51212
  }
51248
51213
  return `[Unknown proxy tool: ${toolName}]`;
51249
51214
  }
51215
+ function handleAcpStatus(args, ctx) {
51216
+ const scope = typeof args.scope === "string" ? args.scope : void 0;
51217
+ const view = typeof args.view === "string" ? args.view : void 0;
51218
+ const tool = typeof args.tool === "string" ? args.tool : void 0;
51219
+ const sort = typeof args.sort === "string" ? args.sort : void 0;
51220
+ const limit = typeof args.limit === "number" ? args.limit : void 0;
51221
+ const base = buildStatusReport(ctx.session.state, ctx.messages, estimateTokensFast, { scope, view, tool, sort, limit });
51222
+ if (scope) return base;
51223
+ const nudge = ctx.nudge;
51224
+ const ranges = nudge?.compressibleRanges ?? [];
51225
+ const protectedRanges = nudge?.protectedRanges ?? [];
51226
+ const extra = [];
51227
+ if (nudge) {
51228
+ extra.push("");
51229
+ extra.push(nudge.shouldInject ? `Nudge: ACTIVE \u2014 ${nudge.reason}` : `Nudge: idle \u2014 ${nudge.reason}`);
51230
+ }
51231
+ if (ranges.length > 0 || protectedRanges.length > 0) {
51232
+ extra.push("");
51233
+ extra.push(formatRanges(ranges, protectedRanges));
51234
+ }
51235
+ return extra.length > 0 ? `${base}
51236
+ ${extra.join("\n")}` : base;
51237
+ }
51250
51238
  function recordUsage(ctx, usage, round) {
51251
51239
  const prompt = usage.inputTokens;
51252
51240
  const cached = usage.cachedTokens;
@@ -52913,7 +52901,7 @@ function executeProxyTool2(toolName, args, ctx) {
52913
52901
  ${lines.join("\n\n")}`;
52914
52902
  }
52915
52903
  if (toolName === "acp_status") {
52916
- return handleAcpStatus(args, ctx);
52904
+ return buildStatusReport(ctx.session.state, ctx.messages, estimateTokensFast);
52917
52905
  }
52918
52906
  return `[Unknown proxy tool: ${toolName}]`;
52919
52907
  }
@@ -53911,7 +53899,8 @@ async function handlePluginTool(payload, res, deps) {
53911
53899
  config: deps.config,
53912
53900
  messages,
53913
53901
  session,
53914
- log: (m2) => deps.log("info", `[${session.id}] [plugin] ${m2}`)
53902
+ log: (m2) => deps.log("info", `[${session.id}] [plugin] ${m2}`),
53903
+ nudge: mem?.nudge
53915
53904
  }, callId);
53916
53905
  });
53917
53906
  } catch (err2) {
@@ -55786,6 +55775,13 @@ Content-Length: ${Buffer.byteLength(body)}\r
55786
55775
  }
55787
55776
  return server;
55788
55777
  }
55778
+ var SIDE_REQUEST_MAX_TOKENS = 200;
55779
+ function isSideRequest(parsed) {
55780
+ if (!parsed || typeof parsed !== "object") return false;
55781
+ const p2 = parsed;
55782
+ const raw = p2.max_tokens ?? p2.max_completion_tokens ?? p2.max_output_tokens;
55783
+ return typeof raw === "number" && raw > 0 && raw <= SIDE_REQUEST_MAX_TOKENS;
55784
+ }
55789
55785
  function isTrustedAdminOrigin(origin, host, trustedHosts) {
55790
55786
  if (!host || !trustedHosts.has(host.toLowerCase())) return false;
55791
55787
  if (!origin) return true;
@@ -56147,6 +56143,11 @@ ${bodyBuffer.toString("utf8")}`);
56147
56143
  }
56148
56144
  }
56149
56145
  const pluginMode = pluginAgent !== void 0;
56146
+ if (!countTokens && !responsesCompact && protocol !== null && isSideRequest(parsed)) {
56147
+ log2("info", `[${session.id}] side request (max_tokens<=${SIDE_REQUEST_MAX_TOKENS}) \u2192 pure passthrough, kernel state untouched`);
56148
+ await forward(req, res, opts, bodyBuffer, null, core, reqConfig, log2, route, instanceId, affinity);
56149
+ return;
56150
+ }
56150
56151
  const reqModel = parsed.model;
56151
56152
  const learnedMap = session.metadata.learnedContextLimits;
56152
56153
  const learnedLimit = (reqModel && learnedMap ? learnedMap[reqModel] : void 0) ?? session.metadata.learnedContextLimit;
@@ -57021,7 +57022,7 @@ ${hdrText}
57021
57022
  const adapter = pickAdapter(prepared.protocol, parsedReq, textProtocol, prepared.responsesProjection, prepared.anthropicSystem, prepared.openaiSystemText);
57022
57023
  const loop = runCompressLoop(
57023
57024
  streamToRead,
57024
- { core, config, messages: prepared.processedMessages.length > 0 ? prepared.processedMessages : prepared.originalMessages, compressMessages: prepared.originalMessages, session: prepared.session, log: ctx.log, proxyUrl, protocol: prepared.protocol, textProtocol, debug: opts.debug },
57025
+ { core, config, messages: prepared.processedMessages.length > 0 ? prepared.processedMessages : prepared.originalMessages, compressMessages: prepared.originalMessages, session: prepared.session, log: ctx.log, proxyUrl, protocol: prepared.protocol, textProtocol, debug: opts.debug, nudge: prepared.nudge },
57025
57026
  parsedReq,
57026
57027
  { url: upstreamUrl, headers: reqHeaders },
57027
57028
  adapter,