billion-context 0.1.110-pr.775.618 → 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 +6 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
49053
|
-
|
|
49054
|
-
if (slash > 0 && slash < model.length - 1) roots.push(model.slice(slash + 1));
|
|
49055
|
-
for (const root of roots) {
|
|
49056
|
-
for (const entry of CONTEXT_LIMIT_TABLE) {
|
|
49057
|
-
if (entry.match.test(root)) 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
|
}
|
|
@@ -49877,16 +49872,7 @@ function modelVariants(name) {
|
|
|
49877
49872
|
function registryLookup(reg, model, host) {
|
|
49878
49873
|
if (!reg || !model) return void 0;
|
|
49879
49874
|
const provider = host ? providerFromHost(host) : void 0;
|
|
49880
|
-
const
|
|
49881
|
-
const slash = model.lastIndexOf("/");
|
|
49882
|
-
if (slash > 0 && slash < model.length - 1) roots.push(model.slice(slash + 1));
|
|
49883
|
-
const names = [];
|
|
49884
|
-
for (const root of roots) {
|
|
49885
|
-
for (const variant of modelVariants(root)) {
|
|
49886
|
-
if (!names.includes(variant)) names.push(variant);
|
|
49887
|
-
}
|
|
49888
|
-
}
|
|
49889
|
-
for (const name of names) {
|
|
49875
|
+
for (const name of modelVariants(model)) {
|
|
49890
49876
|
const candidates = provider ? [`${provider}/${name}`, name] : [name];
|
|
49891
49877
|
for (const key of candidates) {
|
|
49892
49878
|
const entry = reg[key];
|
|
@@ -54362,66 +54348,6 @@ ${icon} [ACP] ${inner}
|
|
|
54362
54348
|
`;
|
|
54363
54349
|
}
|
|
54364
54350
|
|
|
54365
|
-
// src/tool-pair-order.ts
|
|
54366
|
-
var CALL_TYPES = /* @__PURE__ */ new Set(["function_call", "custom_tool_call"]);
|
|
54367
|
-
var OUTPUT_TYPES = /* @__PURE__ */ new Set(["function_call_output", "custom_tool_call_output"]);
|
|
54368
|
-
function isCall(type) {
|
|
54369
|
-
return type !== void 0 && CALL_TYPES.has(type);
|
|
54370
|
-
}
|
|
54371
|
-
function isOutput(type) {
|
|
54372
|
-
return type !== void 0 && OUTPUT_TYPES.has(type);
|
|
54373
|
-
}
|
|
54374
|
-
function idOf(item) {
|
|
54375
|
-
return typeof item.call_id === "string" ? item.call_id : "";
|
|
54376
|
-
}
|
|
54377
|
-
function hoistTrappedToolItems(items) {
|
|
54378
|
-
const n = items.length;
|
|
54379
|
-
if (n < 3) return items;
|
|
54380
|
-
const callPos = /* @__PURE__ */ new Map();
|
|
54381
|
-
const outPos = /* @__PURE__ */ new Map();
|
|
54382
|
-
for (let i = 0; i < n; i++) {
|
|
54383
|
-
const id = idOf(items[i]);
|
|
54384
|
-
if (!id) continue;
|
|
54385
|
-
const t = items[i].type;
|
|
54386
|
-
if (isCall(t) && !callPos.has(id)) callPos.set(id, i);
|
|
54387
|
-
else if (isOutput(t) && !outPos.has(id)) outPos.set(id, i);
|
|
54388
|
-
}
|
|
54389
|
-
if (callPos.size === 0) return items;
|
|
54390
|
-
const hoistBefore = new Array(n).fill(null);
|
|
54391
|
-
let anyTrapped = false;
|
|
54392
|
-
for (let p2 = 0; p2 < n; p2++) {
|
|
54393
|
-
const t = items[p2].type;
|
|
54394
|
-
if (isCall(t) || isOutput(t)) continue;
|
|
54395
|
-
let target = -1;
|
|
54396
|
-
for (const [id, c] of callPos) {
|
|
54397
|
-
const o = outPos.get(id);
|
|
54398
|
-
if (o === void 0 || !(c < p2 && o > p2)) continue;
|
|
54399
|
-
if (target === -1 || c < target) target = c;
|
|
54400
|
-
}
|
|
54401
|
-
if (target >= 0) {
|
|
54402
|
-
hoistBefore[p2] = target;
|
|
54403
|
-
anyTrapped = true;
|
|
54404
|
-
}
|
|
54405
|
-
}
|
|
54406
|
-
if (!anyTrapped) return items;
|
|
54407
|
-
const pendingByTarget = /* @__PURE__ */ new Map();
|
|
54408
|
-
for (let p2 = 0; p2 < n; p2++) {
|
|
54409
|
-
const target = hoistBefore[p2];
|
|
54410
|
-
if (target === null) continue;
|
|
54411
|
-
const batch = pendingByTarget.get(target);
|
|
54412
|
-
if (batch) batch.push(items[p2]);
|
|
54413
|
-
else pendingByTarget.set(target, [items[p2]]);
|
|
54414
|
-
}
|
|
54415
|
-
const result = [];
|
|
54416
|
-
for (let p2 = 0; p2 < n; p2++) {
|
|
54417
|
-
if (hoistBefore[p2] !== null) continue;
|
|
54418
|
-
const batch = pendingByTarget.get(p2);
|
|
54419
|
-
if (batch) result.push(...batch);
|
|
54420
|
-
result.push(items[p2]);
|
|
54421
|
-
}
|
|
54422
|
-
return result;
|
|
54423
|
-
}
|
|
54424
|
-
|
|
54425
54351
|
// src/weak-overflow.ts
|
|
54426
54352
|
var MIN_USAGE = 0.9;
|
|
54427
54353
|
var WINDOW_MS = 15 * 60 * 1e3;
|
|
@@ -55371,7 +55297,6 @@ data: ${JSON.stringify({ type: "response.created", response: { id: createdRespId
|
|
|
55371
55297
|
} else {
|
|
55372
55298
|
inputItems = coreToResponses(coreMessages, customToolCallIds);
|
|
55373
55299
|
}
|
|
55374
|
-
inputItems = hoistTrappedToolItems(inputItems);
|
|
55375
55300
|
const devParts = projection && projection.systemParts.length > 0 ? [...projection.systemParts, systemPrompt] : [systemPrompt];
|
|
55376
55301
|
const withDev = injectResponsesDeveloperMessage(inputItems, devParts.join("\n\n---\n\n"));
|
|
55377
55302
|
const rebuilt = { ...requestBody, input: withDev };
|
|
@@ -56605,16 +56530,7 @@ function surfaceReadonlyJson(current, proxyCalls, ctx) {
|
|
|
56605
56530
|
}
|
|
56606
56531
|
if (markers.length === 0) return current;
|
|
56607
56532
|
const out = Array.isArray(current.output) ? [...current.output] : [];
|
|
56608
|
-
|
|
56609
|
-
let insertAt = out.length;
|
|
56610
|
-
for (let i = 0; i < out.length; i++) {
|
|
56611
|
-
const t = out[i]?.type;
|
|
56612
|
-
if (t === "function_call" || t === "custom_tool_call") {
|
|
56613
|
-
insertAt = i;
|
|
56614
|
-
break;
|
|
56615
|
-
}
|
|
56616
|
-
}
|
|
56617
|
-
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") }] });
|
|
56618
56534
|
return { ...current, output: out };
|
|
56619
56535
|
}
|
|
56620
56536
|
async function compressLoopResponsesJson(initialResponse, ctx, requestBody, requestOptions) {
|
|
@@ -56649,7 +56565,7 @@ async function compressLoopResponsesJson(initialResponse, ctx, requestBody, requ
|
|
|
56649
56565
|
ctx.log(`[acp-proxy: responses JSON ${call.name} \u2192 ${result2.slice(0, 120).replace(/\n/g, " ")}]`);
|
|
56650
56566
|
inputItems.push({ type: "message", role: "developer", content: buildVisibilityMarker(call.name, result2) });
|
|
56651
56567
|
}
|
|
56652
|
-
requestBody.input =
|
|
56568
|
+
requestBody.input = inputItems;
|
|
56653
56569
|
const result = await fetchWithRetry(requestOptions.url, {
|
|
56654
56570
|
method: "POST",
|
|
56655
56571
|
headers: requestOptions.headers,
|
|
@@ -62161,7 +62077,6 @@ function prepareResponses(parsed, req, opts, core, config, prompts, surface, log
|
|
|
62161
62077
|
processedMessages = repairResponsesAssistantOrdering(stripReasoning(stripKernelSummaries(turn.messages, turn.state)), originalMessages);
|
|
62162
62078
|
reapOrphanBlocks(session, msgs, deactivateBlock);
|
|
62163
62079
|
rebuiltInput = patchResponsesInput(projection, processedMessages);
|
|
62164
|
-
if (Array.isArray(rebuiltInput)) rebuiltInput = hoistTrappedToolItems(rebuiltInput);
|
|
62165
62080
|
const forgedSummaries = echoReplaced ? [] : session.metadata.codexForgedSummaries ?? [];
|
|
62166
62081
|
if (shouldInject && !isCompactionTrigger && !process.env.ACP_NO_COMPRESS_PROMPT) {
|
|
62167
62082
|
const prompt = withMarkerIntegrityNote(responsesTextProtocol ? buildCompressHybridSystemPrompt(prompts, surface?.promptSections) : buildCompressSystemPrompt(prompts, surface?.promptSections));
|
|
@@ -62327,12 +62242,11 @@ function prepareResponsesCompact(body, parsed, session, req, core, config, log2)
|
|
|
62327
62242
|
}
|
|
62328
62243
|
const viewed = applyAbsorbView(turn.messages, turn.state, compactConfig, session.stats.lastInputTokens);
|
|
62329
62244
|
const processed = repairResponsesAssistantOrdering(stripKernelSummaries(viewed, turn.state), projection.msgs);
|
|
62330
|
-
|
|
62245
|
+
const output = patchResponsesInput(projection, processed);
|
|
62331
62246
|
if (typeof output === "string") {
|
|
62332
62247
|
session.state = prevState;
|
|
62333
62248
|
return base;
|
|
62334
62249
|
}
|
|
62335
|
-
output = hoistTrappedToolItems(output);
|
|
62336
62250
|
snapshotMessages(session, projection.msgs);
|
|
62337
62251
|
markDirty(session);
|
|
62338
62252
|
log2("info", `[${session.id}] codex compact intercepted (endpoint); forged history with ${output.length} item(s), upstream not contacted`);
|