billion-context 0.1.110-pr.776.620 → 0.1.110

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
@@ -49049,13 +49049,8 @@ var CONTEXT_LIMIT_TABLE = [
49049
49049
  ];
49050
49050
  function lookupContextLimit(model) {
49051
49051
  if (!model) return void 0;
49052
- const slash = model.lastIndexOf("/");
49053
- const base = slash >= 0 ? model.slice(slash + 1) : "";
49054
- const names = base ? [model, base] : [model];
49055
- for (const name of names) {
49056
- for (const entry of CONTEXT_LIMIT_TABLE) {
49057
- if (entry.match.test(name)) return entry.limit;
49058
- }
49052
+ for (const entry of CONTEXT_LIMIT_TABLE) {
49053
+ if (entry.match.test(model)) return entry.limit;
49059
49054
  }
49060
49055
  return void 0;
49061
49056
  }
@@ -49878,36 +49873,31 @@ function registryLookup(reg, model, host) {
49878
49873
  if (!reg || !model) return void 0;
49879
49874
  const provider = host ? providerFromHost(host) : void 0;
49880
49875
  for (const name of modelVariants(model)) {
49881
- const slash = name.lastIndexOf("/");
49882
- const base = slash >= 0 ? name.slice(slash + 1) : "";
49883
- const names = base ? [name, base] : [name];
49884
- for (const n of names) {
49885
- const candidates = provider ? [`${provider}/${n}`, n] : [n];
49886
- for (const key of candidates) {
49887
- const entry = reg[key];
49888
- const ctx = entry?.limit?.context;
49889
- if (typeof ctx === "number" && ctx > 0) return ctx;
49890
- }
49891
- if (provider === void 0) {
49892
- const suffix = `/${n}`;
49893
- let max;
49894
- const distinct = /* @__PURE__ */ new Set();
49895
- const parts = [];
49896
- for (const key of Object.keys(reg)) {
49897
- if (!key.endsWith(suffix)) continue;
49898
- const ctx = reg[key].limit?.context;
49899
- if (typeof ctx !== "number" || ctx <= 0) continue;
49900
- if (max === void 0 || ctx > max) max = ctx;
49901
- distinct.add(ctx);
49902
- parts.push(`${key}=${ctx}`);
49903
- }
49904
- if (max !== void 0) {
49905
- if (distinct.size > 1 && !warnedConflicts.has(n)) {
49906
- warnedConflicts.add(n);
49907
- log("warn", `[acp-registry] conflicting context windows for "${n}" (${parts.join(", ")}) \u2014 using max ${max}`);
49908
- }
49909
- return max;
49876
+ const candidates = provider ? [`${provider}/${name}`, name] : [name];
49877
+ for (const key of candidates) {
49878
+ const entry = reg[key];
49879
+ const ctx = entry?.limit?.context;
49880
+ if (typeof ctx === "number" && ctx > 0) return ctx;
49881
+ }
49882
+ if (provider === void 0) {
49883
+ const suffix = `/${name}`;
49884
+ let max;
49885
+ const distinct = /* @__PURE__ */ new Set();
49886
+ const parts = [];
49887
+ for (const key of Object.keys(reg)) {
49888
+ if (!key.endsWith(suffix)) continue;
49889
+ const ctx = reg[key].limit?.context;
49890
+ if (typeof ctx !== "number" || ctx <= 0) continue;
49891
+ if (max === void 0 || ctx > max) max = ctx;
49892
+ distinct.add(ctx);
49893
+ parts.push(`${key}=${ctx}`);
49894
+ }
49895
+ if (max !== void 0) {
49896
+ if (distinct.size > 1 && !warnedConflicts.has(name)) {
49897
+ warnedConflicts.add(name);
49898
+ log("warn", `[acp-registry] conflicting context windows for "${name}" (${parts.join(", ")}) \u2014 using max ${max}`);
49910
49899
  }
49900
+ return max;
49911
49901
  }
49912
49902
  }
49913
49903
  }
@@ -54358,66 +54348,6 @@ ${icon} [ACP] ${inner}
54358
54348
  `;
54359
54349
  }
54360
54350
 
54361
- // src/tool-pair-order.ts
54362
- var CALL_TYPES = /* @__PURE__ */ new Set(["function_call", "custom_tool_call"]);
54363
- var OUTPUT_TYPES = /* @__PURE__ */ new Set(["function_call_output", "custom_tool_call_output"]);
54364
- function isCall(type) {
54365
- return type !== void 0 && CALL_TYPES.has(type);
54366
- }
54367
- function isOutput(type) {
54368
- return type !== void 0 && OUTPUT_TYPES.has(type);
54369
- }
54370
- function idOf(item) {
54371
- return typeof item.call_id === "string" ? item.call_id : "";
54372
- }
54373
- function hoistTrappedToolItems(items) {
54374
- const n = items.length;
54375
- if (n < 3) return items;
54376
- const callPos = /* @__PURE__ */ new Map();
54377
- const outPos = /* @__PURE__ */ new Map();
54378
- for (let i = 0; i < n; i++) {
54379
- const id = idOf(items[i]);
54380
- if (!id) continue;
54381
- const t = items[i].type;
54382
- if (isCall(t) && !callPos.has(id)) callPos.set(id, i);
54383
- else if (isOutput(t) && !outPos.has(id)) outPos.set(id, i);
54384
- }
54385
- if (callPos.size === 0) return items;
54386
- const hoistBefore = new Array(n).fill(null);
54387
- let anyTrapped = false;
54388
- for (let p2 = 0; p2 < n; p2++) {
54389
- const t = items[p2].type;
54390
- if (isCall(t) || isOutput(t)) continue;
54391
- let target = -1;
54392
- for (const [id, c] of callPos) {
54393
- const o = outPos.get(id);
54394
- if (o === void 0 || !(c < p2 && o > p2)) continue;
54395
- if (target === -1 || c < target) target = c;
54396
- }
54397
- if (target >= 0) {
54398
- hoistBefore[p2] = target;
54399
- anyTrapped = true;
54400
- }
54401
- }
54402
- if (!anyTrapped) return items;
54403
- const pendingByTarget = /* @__PURE__ */ new Map();
54404
- for (let p2 = 0; p2 < n; p2++) {
54405
- const target = hoistBefore[p2];
54406
- if (target === null) continue;
54407
- const batch = pendingByTarget.get(target);
54408
- if (batch) batch.push(items[p2]);
54409
- else pendingByTarget.set(target, [items[p2]]);
54410
- }
54411
- const result = [];
54412
- for (let p2 = 0; p2 < n; p2++) {
54413
- if (hoistBefore[p2] !== null) continue;
54414
- const batch = pendingByTarget.get(p2);
54415
- if (batch) result.push(...batch);
54416
- result.push(items[p2]);
54417
- }
54418
- return result;
54419
- }
54420
-
54421
54351
  // src/weak-overflow.ts
54422
54352
  var MIN_USAGE = 0.9;
54423
54353
  var WINDOW_MS = 15 * 60 * 1e3;
@@ -55367,7 +55297,6 @@ data: ${JSON.stringify({ type: "response.created", response: { id: createdRespId
55367
55297
  } else {
55368
55298
  inputItems = coreToResponses(coreMessages, customToolCallIds);
55369
55299
  }
55370
- inputItems = hoistTrappedToolItems(inputItems);
55371
55300
  const devParts = projection && projection.systemParts.length > 0 ? [...projection.systemParts, systemPrompt] : [systemPrompt];
55372
55301
  const withDev = injectResponsesDeveloperMessage(inputItems, devParts.join("\n\n---\n\n"));
55373
55302
  const rebuilt = { ...requestBody, input: withDev };
@@ -56601,16 +56530,7 @@ function surfaceReadonlyJson(current, proxyCalls, ctx) {
56601
56530
  }
56602
56531
  if (markers.length === 0) return current;
56603
56532
  const out = Array.isArray(current.output) ? [...current.output] : [];
56604
- const markerItem = { type: "message", id: `msg_acp_ro_${Date.now()}_${markers.length}`, role: "assistant", content: [{ type: "output_text", text: markers.join("\n") }] };
56605
- let insertAt = out.length;
56606
- for (let i = 0; i < out.length; i++) {
56607
- const t = out[i]?.type;
56608
- if (t === "function_call" || t === "custom_tool_call") {
56609
- insertAt = i;
56610
- break;
56611
- }
56612
- }
56613
- out.splice(insertAt, 0, markerItem);
56533
+ out.push({ type: "message", id: `msg_acp_ro_${Date.now()}_${markers.length}`, role: "assistant", content: [{ type: "output_text", text: markers.join("\n") }] });
56614
56534
  return { ...current, output: out };
56615
56535
  }
56616
56536
  async function compressLoopResponsesJson(initialResponse, ctx, requestBody, requestOptions) {
@@ -56645,7 +56565,7 @@ async function compressLoopResponsesJson(initialResponse, ctx, requestBody, requ
56645
56565
  ctx.log(`[acp-proxy: responses JSON ${call.name} \u2192 ${result2.slice(0, 120).replace(/\n/g, " ")}]`);
56646
56566
  inputItems.push({ type: "message", role: "developer", content: buildVisibilityMarker(call.name, result2) });
56647
56567
  }
56648
- requestBody.input = hoistTrappedToolItems(inputItems);
56568
+ requestBody.input = inputItems;
56649
56569
  const result = await fetchWithRetry(requestOptions.url, {
56650
56570
  method: "POST",
56651
56571
  headers: requestOptions.headers,
@@ -62157,7 +62077,6 @@ function prepareResponses(parsed, req, opts, core, config, prompts, surface, log
62157
62077
  processedMessages = repairResponsesAssistantOrdering(stripReasoning(stripKernelSummaries(turn.messages, turn.state)), originalMessages);
62158
62078
  reapOrphanBlocks(session, msgs, deactivateBlock);
62159
62079
  rebuiltInput = patchResponsesInput(projection, processedMessages);
62160
- if (Array.isArray(rebuiltInput)) rebuiltInput = hoistTrappedToolItems(rebuiltInput);
62161
62080
  const forgedSummaries = echoReplaced ? [] : session.metadata.codexForgedSummaries ?? [];
62162
62081
  if (shouldInject && !isCompactionTrigger && !process.env.ACP_NO_COMPRESS_PROMPT) {
62163
62082
  const prompt = withMarkerIntegrityNote(responsesTextProtocol ? buildCompressHybridSystemPrompt(prompts, surface?.promptSections) : buildCompressSystemPrompt(prompts, surface?.promptSections));
@@ -62323,12 +62242,11 @@ function prepareResponsesCompact(body, parsed, session, req, core, config, log2)
62323
62242
  }
62324
62243
  const viewed = applyAbsorbView(turn.messages, turn.state, compactConfig, session.stats.lastInputTokens);
62325
62244
  const processed = repairResponsesAssistantOrdering(stripKernelSummaries(viewed, turn.state), projection.msgs);
62326
- let output = patchResponsesInput(projection, processed);
62245
+ const output = patchResponsesInput(projection, processed);
62327
62246
  if (typeof output === "string") {
62328
62247
  session.state = prevState;
62329
62248
  return base;
62330
62249
  }
62331
- output = hoistTrappedToolItems(output);
62332
62250
  snapshotMessages(session, projection.msgs);
62333
62251
  markDirty(session);
62334
62252
  log2("info", `[${session.id}] codex compact intercepted (endpoint); forged history with ${output.length} item(s), upstream not contacted`);