billion-context 0.1.69-pr.448.271 → 0.1.69-pr.455.273
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 +69 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51584,6 +51584,20 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
|
|
|
51584
51584
|
coreMessages.push(...hidden.messages);
|
|
51585
51585
|
}
|
|
51586
51586
|
}
|
|
51587
|
+
if (ctx.refreshFolded && proxyResults.some((pr2) => pr2.name === "compress" && !pr2.result.includes("FAILED"))) {
|
|
51588
|
+
try {
|
|
51589
|
+
const refreshed = ctx.refreshFolded(coreMessages);
|
|
51590
|
+
if (refreshed.length > 0) {
|
|
51591
|
+
coreMessages.length = 0;
|
|
51592
|
+
coreMessages.push(...refreshed);
|
|
51593
|
+
ctx.session.stats.compressCreditTokens = 0;
|
|
51594
|
+
ctx.log(`[acp-loop] round ${round}: re-request view refreshed to post-compress fold`);
|
|
51595
|
+
}
|
|
51596
|
+
} catch (err2) {
|
|
51597
|
+
ctx.log(`[acp-loop] round ${round}: fold refresh failed (${String(err2)}); keeping pre-compress view`);
|
|
51598
|
+
log("warn", `[acp-loop] fold refresh failed: ${String(err2)}`);
|
|
51599
|
+
}
|
|
51600
|
+
}
|
|
51587
51601
|
}
|
|
51588
51602
|
for (const tc of realToolCalls) {
|
|
51589
51603
|
if (tc.passthrough) continue;
|
|
@@ -56654,7 +56668,7 @@ function prepareAnthropic(parsed, req, opts, core, config, prompts, log2, sessio
|
|
|
56654
56668
|
markDirty(session);
|
|
56655
56669
|
const rebuilt = { ...parsed, messages: rebuiltMessages, system: systemOut, tools: toolsOut };
|
|
56656
56670
|
delete rebuilt.prompt_cache_key;
|
|
56657
|
-
return { body: JSON.stringify(rebuilt), session, processedMessages, originalMessages, anthropicSystem: parsed.system, protocol: "anthropic", stream: stream2, compressInjected: injectTools, pluginMode, nudge, prompts };
|
|
56671
|
+
return { body: JSON.stringify(rebuilt), session, processedMessages, originalMessages, anthropicSystem: parsed.system, protocol: "anthropic", stream: stream2, compressInjected: injectTools, pluginMode, nudge, prompts, renderTags: "text-only" };
|
|
56658
56672
|
}
|
|
56659
56673
|
function prepareOpenai(parsed, req, opts, core, config, prompts, log2, session, pluginMode) {
|
|
56660
56674
|
const sessionId = session.id;
|
|
@@ -56717,7 +56731,7 @@ function prepareOpenai(parsed, req, opts, core, config, prompts, log2, session,
|
|
|
56717
56731
|
}
|
|
56718
56732
|
snapshotMessages(session, originalMessages);
|
|
56719
56733
|
markDirty(session);
|
|
56720
|
-
return { body: JSON.stringify(rebuilt), session, processedMessages, originalMessages, protocol: "openai", stream: stream2, compressInjected: injectTools, pluginMode, nudge, prompts, openaiSystemText };
|
|
56734
|
+
return { body: JSON.stringify(rebuilt), session, processedMessages, originalMessages, protocol: "openai", stream: stream2, compressInjected: injectTools, pluginMode, nudge, prompts, openaiSystemText, renderTags: "text-only" };
|
|
56721
56735
|
}
|
|
56722
56736
|
function prepareResponses(parsed, req, opts, core, config, prompts, log2, session, identity, pluginMode, upstreamOrigin) {
|
|
56723
56737
|
const sessionId = session.id;
|
|
@@ -56755,6 +56769,7 @@ function prepareResponses(parsed, req, opts, core, config, prompts, log2, sessio
|
|
|
56755
56769
|
const injectTools = shouldInject && !pluginMode;
|
|
56756
56770
|
const isCompactionTrigger = hasCompactionTrigger(parsed.input);
|
|
56757
56771
|
const responsesTextProtocol = FORCE_TEXT_PROTOCOL || resolveCompressProtocol(opts.routes, upstreamOrigin) === "marker";
|
|
56772
|
+
const renderTags = process.env.ACP_RENDER_NONE || isCompactionTrigger ? "none" : "text-only";
|
|
56758
56773
|
try {
|
|
56759
56774
|
const projection = responsesToCore(parsed);
|
|
56760
56775
|
responsesProjection = projection;
|
|
@@ -56764,7 +56779,7 @@ function prepareResponses(parsed, req, opts, core, config, prompts, log2, sessio
|
|
|
56764
56779
|
log2("info", `[${sessionId}] input items: ${Array.isArray(parsed.input) ? parsed.input.map((i) => i.type).join(",") : "(string)"}`);
|
|
56765
56780
|
}
|
|
56766
56781
|
const tokenCount = session.stats.lastInputTokens;
|
|
56767
|
-
const turn = core.processTurn({ messages: msgs, state: session.state, config, tokenCount, renderTags
|
|
56782
|
+
const turn = core.processTurn({ messages: msgs, state: session.state, config, tokenCount, renderTags });
|
|
56768
56783
|
session.state = turn.state;
|
|
56769
56784
|
session.stats.compressCreditTokens = 0;
|
|
56770
56785
|
if (turn.nudge) turn.nudge.compressibleRanges = viableRanges(turn.nudge.compressibleRanges);
|
|
@@ -56858,6 +56873,7 @@ function prepareResponses(parsed, req, opts, core, config, prompts, log2, sessio
|
|
|
56858
56873
|
responsesTextProtocol,
|
|
56859
56874
|
nudge,
|
|
56860
56875
|
prompts,
|
|
56876
|
+
renderTags,
|
|
56861
56877
|
resetAfterSuccess: isCompactionTrigger,
|
|
56862
56878
|
codexForge
|
|
56863
56879
|
};
|
|
@@ -57360,9 +57376,21 @@ ${hdrText}
|
|
|
57360
57376
|
const textProtocol = prepared.protocol === "responses" && !!prepared.responsesTextProtocol;
|
|
57361
57377
|
const systemPrompt = textProtocol ? buildCompressHybridSystemPrompt(prepared.prompts ?? defaultPrompts) : buildCompressSystemPrompt(prepared.prompts ?? defaultPrompts);
|
|
57362
57378
|
const adapter = pickAdapter(prepared.protocol, parsedReq, textProtocol, prepared.responsesProjection, prepared.anthropicSystem, prepared.openaiSystemText);
|
|
57379
|
+
const refreshFolded = (current) => {
|
|
57380
|
+
const turn = core.processTurn({
|
|
57381
|
+
messages: prepared.originalMessages,
|
|
57382
|
+
state: prepared.session.state,
|
|
57383
|
+
config,
|
|
57384
|
+
tokenCount: prepared.session.stats.lastInputTokens,
|
|
57385
|
+
renderTags: prepared.renderTags ?? "text-only"
|
|
57386
|
+
});
|
|
57387
|
+
prepared.session.state = turn.state;
|
|
57388
|
+
const records = current.filter((m2) => typeof m2.id === "string" && m2.id.startsWith("acp_loop_"));
|
|
57389
|
+
return stripKernelSummaries([...turn.messages, ...records], turn.state);
|
|
57390
|
+
};
|
|
57363
57391
|
const loop = runCompressLoop(
|
|
57364
57392
|
streamToRead,
|
|
57365
|
-
{ 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 },
|
|
57393
|
+
{ 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, refreshFolded },
|
|
57366
57394
|
parsedReq,
|
|
57367
57395
|
{ url: upstreamUrl, headers: reqHeaders },
|
|
57368
57396
|
adapter,
|
|
@@ -61947,8 +61975,6 @@ function mergeSqliteSet(overlay, realHome, base) {
|
|
|
61947
61975
|
}
|
|
61948
61976
|
}
|
|
61949
61977
|
function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
61950
|
-
const generatedFiles = new Set(Array.isArray(generatedFile) ? generatedFile : [generatedFile]);
|
|
61951
|
-
const isGeneratedDraft = (name) => [...generatedFiles].some((g2) => name.startsWith(`.${g2}.`) && name.endsWith(".tmp"));
|
|
61952
61978
|
try {
|
|
61953
61979
|
fs11.mkdirSync(overlay, { recursive: true });
|
|
61954
61980
|
} catch {
|
|
@@ -61979,7 +62005,7 @@ function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
|
61979
62005
|
}
|
|
61980
62006
|
const dbSets = [];
|
|
61981
62007
|
for (const entry of overlayEntries) {
|
|
61982
|
-
if (!entry.endsWith(".db") ||
|
|
62008
|
+
if (!entry.endsWith(".db") || entry === generatedFile) continue;
|
|
61983
62009
|
const members = sqliteSetMembers(entry);
|
|
61984
62010
|
if (!members.some((m2) => m2 !== entry && overlayEntries.includes(m2))) continue;
|
|
61985
62011
|
let mainSt;
|
|
@@ -61997,9 +62023,9 @@ function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
|
61997
62023
|
}
|
|
61998
62024
|
}
|
|
61999
62025
|
for (const entry of overlayEntries) {
|
|
62000
|
-
if (
|
|
62026
|
+
if (entry === generatedFile) continue;
|
|
62001
62027
|
const overlayPath = path14.join(overlay, entry);
|
|
62002
|
-
if (
|
|
62028
|
+
if (entry.startsWith(`.${generatedFile}.`) && entry.endsWith(".tmp")) {
|
|
62003
62029
|
try {
|
|
62004
62030
|
fs11.unlinkSync(overlayPath);
|
|
62005
62031
|
} catch {
|
|
@@ -62033,7 +62059,7 @@ function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
|
62033
62059
|
fs11.unlinkSync(overlayPath);
|
|
62034
62060
|
} catch {
|
|
62035
62061
|
}
|
|
62036
|
-
} else if (mergeOverlayEntry(overlayPath, realPath,
|
|
62062
|
+
} else if (mergeOverlayEntry(overlayPath, realPath, generatedFile)) {
|
|
62037
62063
|
try {
|
|
62038
62064
|
fs11.rmSync(overlayPath, { recursive: true, force: true });
|
|
62039
62065
|
} catch {
|
|
@@ -62055,7 +62081,7 @@ function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
|
62055
62081
|
let total = 0;
|
|
62056
62082
|
const linkFailures = [];
|
|
62057
62083
|
for (const entry of realEntries) {
|
|
62058
|
-
if (
|
|
62084
|
+
if (entry === generatedFile) continue;
|
|
62059
62085
|
total += 1;
|
|
62060
62086
|
const overlayPath = path14.join(overlay, entry);
|
|
62061
62087
|
let present = false;
|
|
@@ -62089,7 +62115,7 @@ function refreshOverlayHome(realHome, overlay, generatedFile) {
|
|
|
62089
62115
|
}
|
|
62090
62116
|
return true;
|
|
62091
62117
|
}
|
|
62092
|
-
function mergeOverlayEntry(src, dst,
|
|
62118
|
+
function mergeOverlayEntry(src, dst, excludedName) {
|
|
62093
62119
|
let st2;
|
|
62094
62120
|
try {
|
|
62095
62121
|
st2 = fs11.lstatSync(src);
|
|
@@ -62123,8 +62149,8 @@ function mergeOverlayEntry(src, dst, excludedNames) {
|
|
|
62123
62149
|
}
|
|
62124
62150
|
let ok = true;
|
|
62125
62151
|
for (const entry of entries) {
|
|
62126
|
-
if (
|
|
62127
|
-
if (!mergeOverlayEntry(path14.join(src, entry), path14.join(dst, entry),
|
|
62152
|
+
if (excludedName !== void 0 && entry === excludedName) continue;
|
|
62153
|
+
if (!mergeOverlayEntry(path14.join(src, entry), path14.join(dst, entry), excludedName)) ok = false;
|
|
62128
62154
|
}
|
|
62129
62155
|
return ok;
|
|
62130
62156
|
}
|
|
@@ -62196,58 +62222,45 @@ function writeOverlayFileAtomic(overlay, fileName, contents) {
|
|
|
62196
62222
|
}
|
|
62197
62223
|
}
|
|
62198
62224
|
}
|
|
62199
|
-
function
|
|
62200
|
-
|
|
62225
|
+
function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
|
|
62226
|
+
if (httpRewrites.length === 0 && httpsRewrites.length === 0) return void 0;
|
|
62227
|
+
const modelsPath = path14.join(piHome, "models.json");
|
|
62228
|
+
let txt;
|
|
62201
62229
|
try {
|
|
62202
|
-
|
|
62203
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
62204
|
-
settings = parsed;
|
|
62205
|
-
}
|
|
62230
|
+
txt = fs11.readFileSync(modelsPath, "utf8");
|
|
62206
62231
|
} catch {
|
|
62232
|
+
return void 0;
|
|
62207
62233
|
}
|
|
62208
|
-
|
|
62209
|
-
const compaction = compactionRaw && typeof compactionRaw === "object" && !Array.isArray(compactionRaw) ? { ...compactionRaw } : {};
|
|
62210
|
-
compaction.enabled = false;
|
|
62211
|
-
settings.compaction = compaction;
|
|
62212
|
-
writeOverlayFileAtomic(overlay, "settings.json", JSON.stringify(settings, null, 2));
|
|
62213
|
-
}
|
|
62214
|
-
function preparePiHttpRewrite(piHome, origin, httpRewrites, httpsRewrites) {
|
|
62215
|
-
if (!fs11.existsSync(piHome)) return void 0;
|
|
62216
|
-
const overlay = `${piHome}-bili`;
|
|
62217
|
-
const generated = ["settings.json"];
|
|
62218
|
-
let modelsRoot;
|
|
62234
|
+
let parsed;
|
|
62219
62235
|
try {
|
|
62220
|
-
|
|
62221
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
62222
|
-
modelsRoot = parsed;
|
|
62223
|
-
generated.push("models.json");
|
|
62224
|
-
}
|
|
62236
|
+
parsed = JSON.parse(txt);
|
|
62225
62237
|
} catch {
|
|
62238
|
+
return void 0;
|
|
62226
62239
|
}
|
|
62227
|
-
if (!
|
|
62228
|
-
|
|
62229
|
-
|
|
62230
|
-
|
|
62231
|
-
|
|
62232
|
-
|
|
62233
|
-
|
|
62234
|
-
|
|
62235
|
-
|
|
62236
|
-
|
|
62237
|
-
|
|
62238
|
-
}
|
|
62240
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
62241
|
+
const root = parsed;
|
|
62242
|
+
const providersVal = root.providers;
|
|
62243
|
+
if (providersVal && typeof providersVal === "object" && !Array.isArray(providersVal)) {
|
|
62244
|
+
const providers = providersVal;
|
|
62245
|
+
for (const r of httpRewrites) {
|
|
62246
|
+
const prov = providers[r.key];
|
|
62247
|
+
if (prov && typeof prov === "object" && !Array.isArray(prov)) {
|
|
62248
|
+
const p2 = prov;
|
|
62249
|
+
const existing = typeof p2.baseUrl === "string" ? p2.baseUrl : r.realUpstream;
|
|
62250
|
+
p2.baseUrl = wrapUpstream(origin, unwrapUpstream2(existing));
|
|
62239
62251
|
}
|
|
62240
|
-
|
|
62241
|
-
|
|
62242
|
-
|
|
62243
|
-
|
|
62244
|
-
|
|
62245
|
-
|
|
62252
|
+
}
|
|
62253
|
+
for (const r of httpsRewrites) {
|
|
62254
|
+
const prov = providers[r.key];
|
|
62255
|
+
if (prov && typeof prov === "object" && !Array.isArray(prov)) {
|
|
62256
|
+
const p2 = prov;
|
|
62257
|
+
p2.baseUrl = r.realUpstream;
|
|
62246
62258
|
}
|
|
62247
62259
|
}
|
|
62248
|
-
writeOverlayFileAtomic(overlay, "models.json", JSON.stringify(modelsRoot));
|
|
62249
62260
|
}
|
|
62250
|
-
|
|
62261
|
+
const overlay = `${piHome}-bili`;
|
|
62262
|
+
if (!refreshOverlayHome(piHome, overlay, "models.json")) return void 0;
|
|
62263
|
+
writeOverlayFileAtomic(overlay, "models.json", JSON.stringify(root));
|
|
62251
62264
|
return overlay;
|
|
62252
62265
|
}
|
|
62253
62266
|
function atomicWriteTextFile(filePath, contents) {
|