acp-kernel 0.0.59-pr.226.77 → 0.0.59-pr.229.79
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/{chunk-C4EQEGJ4.js → chunk-UX4LINT7.js} +2 -14
- package/dist/chunk-UX4LINT7.js.map +1 -0
- package/dist/compress.d.ts +0 -7
- package/dist/compress.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/hide-consumed.d.ts.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -111
- package/dist/index.js.map +1 -1
- package/dist/persist/index.js +1 -1
- package/dist/recommend.d.ts.map +1 -1
- package/dist/search/algorithms/hybrid.d.ts.map +1 -1
- package/dist/search/doc-cache.d.ts +15 -5
- package/dist/search/doc-cache.d.ts.map +1 -1
- package/dist/state.d.ts +0 -9
- package/dist/state.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/types.d.ts +0 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-C4EQEGJ4.js.map +0 -1
- package/dist/strip-reasoning.d.ts +0 -23
- package/dist/strip-reasoning.d.ts.map +0 -1
|
@@ -33,21 +33,11 @@ function blockById(state, blockId) {
|
|
|
33
33
|
function activeBlocks(state) {
|
|
34
34
|
return state.blocks.filter((block) => block.active);
|
|
35
35
|
}
|
|
36
|
-
function baseMessageId(id) {
|
|
37
|
-
const hash = id.indexOf("#");
|
|
38
|
-
return hash === -1 ? id : id.slice(0, hash);
|
|
39
|
-
}
|
|
40
|
-
function isIdCovered(covered, id) {
|
|
41
|
-
return covered.has(id) || covered.has(baseMessageId(id));
|
|
42
|
-
}
|
|
43
36
|
function coveredMessageIds(state) {
|
|
44
37
|
const covered = /* @__PURE__ */ new Set();
|
|
45
38
|
for (const block of state.blocks) {
|
|
46
39
|
if (!block.active) continue;
|
|
47
|
-
for (const id of block.effectiveMessageIds)
|
|
48
|
-
covered.add(id);
|
|
49
|
-
covered.add(baseMessageId(id));
|
|
50
|
-
}
|
|
40
|
+
for (const id of block.effectiveMessageIds) covered.add(id);
|
|
51
41
|
}
|
|
52
42
|
return covered;
|
|
53
43
|
}
|
|
@@ -74,10 +64,8 @@ export {
|
|
|
74
64
|
allocateRunId,
|
|
75
65
|
blockById,
|
|
76
66
|
activeBlocks,
|
|
77
|
-
baseMessageId,
|
|
78
|
-
isIdCovered,
|
|
79
67
|
coveredMessageIds,
|
|
80
68
|
highestActiveTier,
|
|
81
69
|
advanceSurvival
|
|
82
70
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
//# sourceMappingURL=chunk-UX4LINT7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state.ts"],"sourcesContent":["import type { CompressionBlock, CompressionState } from \"./types.js\";\n\nexport function createInitialState(): CompressionState {\n return {\n blocks: [],\n messageRefs: { byRaw: {}, byRef: {} },\n tokenSnapshot: {},\n nudge: {\n lastPerMessageNudgeTokens: 0,\n lastNudgeShownTokens: 0,\n baselineTokens: 0,\n anchors: {},\n lastShownByTier: {},\n },\n stats: { tokensCompressed: 0, compressionCount: 0, absorbedTokens: 0 },\n absorbed: [],\n nextBlockId: 1,\n nextRunId: 1,\n };\n}\n\nexport function allocateBlockId(state: CompressionState): string {\n const id = state.nextBlockId;\n state.nextBlockId = Math.max(1, id) + 1;\n return `b${id}`;\n}\n\nexport function allocateRunId(state: CompressionState): string {\n const id = state.nextRunId;\n state.nextRunId = Math.max(1, id) + 1;\n return `r${id}`;\n}\n\nexport function blockById(\n state: CompressionState,\n blockId: string,\n): CompressionBlock | undefined {\n return state.blocks.find((block) => block.blockId === blockId);\n}\n\nexport function activeBlocks(state: CompressionState): CompressionBlock[] {\n return state.blocks.filter((block) => block.active);\n}\n\nexport function coveredMessageIds(state: CompressionState): Set<string> {\n const covered = new Set<string>();\n for (const block of state.blocks) {\n if (!block.active) continue;\n for (const id of block.effectiveMessageIds) covered.add(id);\n }\n return covered;\n}\n\nexport function highestActiveTier(state: CompressionState): 0 | 1 | 2 | 3 {\n let highest: 0 | 1 | 2 | 3 = 0;\n for (const block of state.blocks) {\n if (block.active && block.tier > highest) highest = block.tier;\n }\n return highest;\n}\n\nexport function advanceSurvival(\n state: CompressionState,\n promotionThreshold: number,\n): void {\n for (const block of state.blocks) {\n if (!block.active) continue;\n block.survivedCount += 1;\n if (block.survivedCount >= promotionThreshold) {\n block.generation = \"old\";\n }\n }\n}\n"],"mappings":";AAEO,SAAS,qBAAuC;AACrD,SAAO;AAAA,IACL,QAAQ,CAAC;AAAA,IACT,aAAa,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,IACpC,eAAe,CAAC;AAAA,IAChB,OAAO;AAAA,MACL,2BAA2B;AAAA,MAC3B,sBAAsB;AAAA,MACtB,gBAAgB;AAAA,MAChB,SAAS,CAAC;AAAA,MACV,iBAAiB,CAAC;AAAA,IACpB;AAAA,IACA,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,EAAE;AAAA,IACrE,UAAU,CAAC;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AACF;AAEO,SAAS,gBAAgB,OAAiC;AAC/D,QAAM,KAAK,MAAM;AACjB,QAAM,cAAc,KAAK,IAAI,GAAG,EAAE,IAAI;AACtC,SAAO,IAAI,EAAE;AACf;AAEO,SAAS,cAAc,OAAiC;AAC7D,QAAM,KAAK,MAAM;AACjB,QAAM,YAAY,KAAK,IAAI,GAAG,EAAE,IAAI;AACpC,SAAO,IAAI,EAAE;AACf;AAEO,SAAS,UACd,OACA,SAC8B;AAC9B,SAAO,MAAM,OAAO,KAAK,CAAC,UAAU,MAAM,YAAY,OAAO;AAC/D;AAEO,SAAS,aAAa,OAA6C;AACxE,SAAO,MAAM,OAAO,OAAO,CAAC,UAAU,MAAM,MAAM;AACpD;AAEO,SAAS,kBAAkB,OAAsC;AACtE,QAAM,UAAU,oBAAI,IAAY;AAChC,aAAW,SAAS,MAAM,QAAQ;AAChC,QAAI,CAAC,MAAM,OAAQ;AACnB,eAAW,MAAM,MAAM,oBAAqB,SAAQ,IAAI,EAAE;AAAA,EAC5D;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,OAAwC;AACxE,MAAI,UAAyB;AAC7B,aAAW,SAAS,MAAM,QAAQ;AAChC,QAAI,MAAM,UAAU,MAAM,OAAO,QAAS,WAAU,MAAM;AAAA,EAC5D;AACA,SAAO;AACT;AAEO,SAAS,gBACd,OACA,oBACM;AACN,aAAW,SAAS,MAAM,QAAQ;AAChC,QAAI,CAAC,MAAM,OAAQ;AACnB,UAAM,iBAAiB;AACvB,QAAI,MAAM,iBAAiB,oBAAoB;AAC7C,YAAM,aAAa;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
package/dist/compress.d.ts
CHANGED
|
@@ -18,13 +18,6 @@ export interface ProcessTurnInput {
|
|
|
18
18
|
state: CompressionState;
|
|
19
19
|
config: Config;
|
|
20
20
|
tokenCount: number;
|
|
21
|
-
/**
|
|
22
|
-
* Host-reported context mass the kernel cannot see (wire-level replayed
|
|
23
|
-
* reasoning, system prompt, provider overhead). Folded into usage and
|
|
24
|
-
* pressure so the pressure band tracks real provider-side usage instead of
|
|
25
|
-
* only the kernel-visible view.
|
|
26
|
-
*/
|
|
27
|
-
extraTokens?: number;
|
|
28
21
|
/**
|
|
29
22
|
* Which messages get an <acp> ref tag injected into their text
|
|
30
23
|
* (the render-refs pipeline node). Refs are ALWAYS assigned regardless
|
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAehF,OAA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QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AA2DD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAyU7D;AAo8BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,OAAO,CAAC,MAAM,CAAM,GAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,OAAO,CAAC,MAAM,CAAM,GAC9B,MAAM,CA+CR;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAuDvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hide-consumed.d.ts","sourceRoot":"","sources":["../src/hide-consumed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAYhE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"hide-consumed.d.ts","sourceRoot":"","sources":["../src/hide-consumed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAYhE,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAClB;AA8BD,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,GACxB,kBAAkB,CAmFpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
2
|
export { createCore } from "./compress.js";
|
|
3
3
|
export type { Ports, CompressionCore, ProcessTurnInput, ApplyCompressionInput, } from "./compress.js";
|
|
4
|
-
export { createInitialState, allocateBlockId, allocateRunId, blockById, activeBlocks, coveredMessageIds, highestActiveTier, advanceSurvival,
|
|
4
|
+
export { createInitialState, allocateBlockId, allocateRunId, blockById, activeBlocks, coveredMessageIds, highestActiveTier, advanceSurvival, } from "./state.js";
|
|
5
5
|
export { defaultConfig, validateConfig } from "./config.js";
|
|
6
6
|
export * from "./compress-tools.js";
|
|
7
7
|
export { assignRefs, highestUsedIndex, emptyRefMap, indexToRef, refToIndex, refForRaw, rawForRef, BLOCKED_REF, } from "./refs.js";
|
|
@@ -25,8 +25,6 @@ export { renderHandoff, renderMessage, matchSession } from "./handoff.js";
|
|
|
25
25
|
export type { HandoffInput, HandoffMeta, HandoffBlockFull } from "./handoff.js";
|
|
26
26
|
export { hideConsumedCompressCalls } from "./hide-consumed.js";
|
|
27
27
|
export type { HideConsumedResult } from "./hide-consumed.js";
|
|
28
|
-
export { stripReasoningByRound, isRealUserMessage } from "./strip-reasoning.js";
|
|
29
|
-
export type { StripReasoningResult } from "./strip-reasoning.js";
|
|
30
28
|
export { ABSORB_TOOL_NAME, ABSORB_TOOL, ABSORB_TOOL_OPENAI, } from "./compress-tools.js";
|
|
31
29
|
export { ABSORB_PROMPT_MARKER, DEFAULT_ABSORB_CONFIG, resolveAbsorbConfig, buildAbsorbPrompt, buildAbsorbSystemPrompt, isAbsorbCandidate, hideAbsorbedMessages, appendAbsorbPrompts, parseAbsorbInput, applyAbsorb, } from "./absorb.js";
|
|
32
30
|
export type { AbsorbInput, AbsorbOutcome, ParsedAbsorb, AppendAbsorbPromptsResult, } from "./absorb.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO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EAClB,SAAS,EACT,aAAa,EACb,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,WAAW,EACX,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,13 +18,11 @@ import {
|
|
|
18
18
|
advanceSurvival,
|
|
19
19
|
allocateBlockId,
|
|
20
20
|
allocateRunId,
|
|
21
|
-
baseMessageId,
|
|
22
21
|
blockById,
|
|
23
22
|
coveredMessageIds,
|
|
24
23
|
createInitialState,
|
|
25
|
-
highestActiveTier
|
|
26
|
-
|
|
27
|
-
} from "./chunk-C4EQEGJ4.js";
|
|
24
|
+
highestActiveTier
|
|
25
|
+
} from "./chunk-UX4LINT7.js";
|
|
28
26
|
|
|
29
27
|
// src/refs.ts
|
|
30
28
|
var REF_WIDTH = 5;
|
|
@@ -179,7 +177,7 @@ function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
|
179
177
|
result.push(messages[index]);
|
|
180
178
|
continue;
|
|
181
179
|
}
|
|
182
|
-
if (
|
|
180
|
+
if (covered.has(messages[index].id)) continue;
|
|
183
181
|
if (isRenderedSummaryMessage(messages[index]) && anchoredSummaryIds.has(messages[index].id))
|
|
184
182
|
continue;
|
|
185
183
|
result.push(messages[index]);
|
|
@@ -245,7 +243,6 @@ function stripOrphanedReasoning(messages) {
|
|
|
245
243
|
// src/sync.ts
|
|
246
244
|
function syncBlocks(messages, state) {
|
|
247
245
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
248
|
-
const presentBases = new Set(messages.map((message) => baseMessageId(message.id)));
|
|
249
246
|
const deactivated = [];
|
|
250
247
|
const result = {
|
|
251
248
|
blocks: state.blocks.map((block) => ({
|
|
@@ -292,9 +289,7 @@ function syncBlocks(messages, state) {
|
|
|
292
289
|
continue;
|
|
293
290
|
}
|
|
294
291
|
block.active = true;
|
|
295
|
-
const stillPresent = block.effectiveMessageIds.some(
|
|
296
|
-
(id) => presentIds.has(id) || presentBases.has(baseMessageId(id))
|
|
297
|
-
) || presentIds.has(summaryMessageId(block.blockId));
|
|
292
|
+
const stillPresent = block.effectiveMessageIds.some((id) => presentIds.has(id)) || presentIds.has(summaryMessageId(block.blockId));
|
|
298
293
|
if (!stillPresent) {
|
|
299
294
|
block.active = false;
|
|
300
295
|
deactivated.push(block.blockId);
|
|
@@ -332,7 +327,6 @@ function defaultConfig(modelContextLimit, overrides = {}) {
|
|
|
332
327
|
preserveRecentMessages: 5,
|
|
333
328
|
preserveRecentTokens: 5e3,
|
|
334
329
|
modelContextLimit,
|
|
335
|
-
reasoningReplay: "always",
|
|
336
330
|
absorb: {
|
|
337
331
|
enabled: false,
|
|
338
332
|
toolName: "absorb",
|
|
@@ -369,9 +363,6 @@ function validateConfig(config) {
|
|
|
369
363
|
if (config.nudge.minPressureBenefitTokens !== void 0 && (!Number.isFinite(config.nudge.minPressureBenefitTokens) || config.nudge.minPressureBenefitTokens < 0)) {
|
|
370
364
|
errors.push("nudge.minPressureBenefitTokens must be finite and >= 0");
|
|
371
365
|
}
|
|
372
|
-
if (config.reasoningReplay !== void 0 && config.reasoningReplay !== "always" && config.reasoningReplay !== "open-round" && config.reasoningReplay !== "never") {
|
|
373
|
-
errors.push('reasoningReplay must be "always", "open-round", or "never"');
|
|
374
|
-
}
|
|
375
366
|
if (config.promotionThreshold < 1) {
|
|
376
367
|
errors.push("promotionThreshold must be >= 1");
|
|
377
368
|
}
|
|
@@ -675,30 +666,10 @@ var KEEP_LAST_ORPHANED = 2;
|
|
|
675
666
|
function rangeKey(startRef, endRef) {
|
|
676
667
|
return `${startRef}::${endRef}`;
|
|
677
668
|
}
|
|
678
|
-
var LT = "<";
|
|
679
|
-
var GT = ">";
|
|
680
|
-
var REF_TAG_PREFIX_RE = new RegExp(
|
|
681
|
-
"^" + LT + "acp [^" + GT + "]*" + GT + "m\\d{1,5}" + LT + "/acp" + GT + "\\n?"
|
|
682
|
-
);
|
|
683
|
-
var SUMMARY_STUB_CHARS = 200;
|
|
684
|
-
function stubSummary(entry) {
|
|
685
|
-
const summary = entry.summary;
|
|
686
|
-
if (typeof summary === "string" && summary.length > SUMMARY_STUB_CHARS) {
|
|
687
|
-
return { ...entry, summary: summary.slice(0, SUMMARY_STUB_CHARS) + "\u2026" };
|
|
688
|
-
}
|
|
689
|
-
return entry;
|
|
690
|
-
}
|
|
691
|
-
function entryRef(entry, ...fields) {
|
|
692
|
-
for (const field of fields) {
|
|
693
|
-
const value = entry[field];
|
|
694
|
-
if (typeof value === "string") return value;
|
|
695
|
-
}
|
|
696
|
-
return "";
|
|
697
|
-
}
|
|
698
669
|
function rewriteCompressText(text, liveKeys) {
|
|
699
670
|
let parsed;
|
|
700
671
|
try {
|
|
701
|
-
parsed = JSON.parse(
|
|
672
|
+
parsed = JSON.parse(text ?? "");
|
|
702
673
|
} catch {
|
|
703
674
|
return null;
|
|
704
675
|
}
|
|
@@ -708,11 +679,11 @@ function rewriteCompressText(text, liveKeys) {
|
|
|
708
679
|
if (!Array.isArray(content) || content.length === 0) return null;
|
|
709
680
|
const kept = content.filter((entry) => {
|
|
710
681
|
if (!entry || typeof entry !== "object") return false;
|
|
711
|
-
const s =
|
|
712
|
-
const e =
|
|
682
|
+
const s = typeof entry.startId === "string" ? entry.startId : typeof entry.messageId === "string" ? entry.messageId : "";
|
|
683
|
+
const e = typeof entry.endId === "string" ? entry.endId : typeof entry.messageId === "string" ? entry.messageId : "";
|
|
713
684
|
return liveKeys.has(rangeKey(s, e));
|
|
714
|
-
})
|
|
715
|
-
if (kept.length === 0) return null;
|
|
685
|
+
});
|
|
686
|
+
if (kept.length === content.length || kept.length === 0) return null;
|
|
716
687
|
return JSON.stringify({ ...obj, content: kept });
|
|
717
688
|
}
|
|
718
689
|
function hideConsumedCompressCalls(state, messages) {
|
|
@@ -1555,12 +1526,12 @@ function classifyType(message) {
|
|
|
1555
1526
|
function escapeRegex(s) {
|
|
1556
1527
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1557
1528
|
}
|
|
1558
|
-
var
|
|
1559
|
-
var
|
|
1560
|
-
var TAG_OPEN =
|
|
1561
|
-
var TAG_CLOSE =
|
|
1529
|
+
var LT = "<";
|
|
1530
|
+
var GT = ">";
|
|
1531
|
+
var TAG_OPEN = LT + "acp ";
|
|
1532
|
+
var TAG_CLOSE = LT + "/acp" + GT;
|
|
1562
1533
|
function acpTag(ref, tokens, type) {
|
|
1563
|
-
return TAG_OPEN + 'tokens="' + formatTokens(tokens) + '" type="' + type + '"' +
|
|
1534
|
+
return TAG_OPEN + 'tokens="' + formatTokens(tokens) + '" type="' + type + '"' + GT + ref + TAG_CLOSE;
|
|
1564
1535
|
}
|
|
1565
1536
|
function renderMessage(message, map, countTokens, strategy, snapshot = null) {
|
|
1566
1537
|
const ref = refForRaw(map, message.id);
|
|
@@ -1570,7 +1541,7 @@ function renderMessage(message, map, countTokens, strategy, snapshot = null) {
|
|
|
1570
1541
|
return message;
|
|
1571
1542
|
}
|
|
1572
1543
|
const ownTagRe = new RegExp(
|
|
1573
|
-
"^" + escapeRegex(TAG_OPEN) + "[^>]*" +
|
|
1544
|
+
"^" + escapeRegex(TAG_OPEN) + "[^>]*" + GT + escapeRegex(ref) + escapeRegex(TAG_CLOSE) + "\\n?"
|
|
1574
1545
|
);
|
|
1575
1546
|
const cleanText = (message.text || "").replace(ownTagRe, "");
|
|
1576
1547
|
const tokens = snapshot ? snapshot[ref] ?? (snapshot[ref] = countTokens(cleanText)) : countTokens(cleanText);
|
|
@@ -1680,39 +1651,6 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
|
|
|
1680
1651
|
return { startIndex: newStartIndex, endIndex: newEndIndex };
|
|
1681
1652
|
}
|
|
1682
1653
|
|
|
1683
|
-
// src/strip-reasoning.ts
|
|
1684
|
-
function isRealUserMessage(message) {
|
|
1685
|
-
return message.role === "user" && message.contentType === "text";
|
|
1686
|
-
}
|
|
1687
|
-
function stripReasoningByRound(messages, mode) {
|
|
1688
|
-
if (mode === "always") return { messages, stripped: 0 };
|
|
1689
|
-
let cutoff;
|
|
1690
|
-
if (mode === "never") {
|
|
1691
|
-
cutoff = messages.length;
|
|
1692
|
-
} else {
|
|
1693
|
-
let lastRealUserIndex = -1;
|
|
1694
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1695
|
-
if (isRealUserMessage(messages[i])) {
|
|
1696
|
-
lastRealUserIndex = i;
|
|
1697
|
-
break;
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
if (lastRealUserIndex === -1) return { messages, stripped: 0 };
|
|
1701
|
-
cutoff = lastRealUserIndex + 1;
|
|
1702
|
-
}
|
|
1703
|
-
let stripped = 0;
|
|
1704
|
-
const kept = [];
|
|
1705
|
-
for (let i = 0; i < messages.length; i++) {
|
|
1706
|
-
const message = messages[i];
|
|
1707
|
-
if (message.contentType === "reasoning" && i < cutoff) {
|
|
1708
|
-
stripped++;
|
|
1709
|
-
continue;
|
|
1710
|
-
}
|
|
1711
|
-
kept.push(message);
|
|
1712
|
-
}
|
|
1713
|
-
return { messages: kept, stripped };
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
1654
|
// src/recommend.ts
|
|
1717
1655
|
function estimateTextTokens(text) {
|
|
1718
1656
|
return Math.ceil(text.length / 4);
|
|
@@ -1722,12 +1660,8 @@ function isToolMessage(message) {
|
|
|
1722
1660
|
}
|
|
1723
1661
|
function isSyntheticOrPruned(message, state) {
|
|
1724
1662
|
if (message.text?.startsWith("[Compressed conversation section]")) return true;
|
|
1725
|
-
const base = baseMessageId(message.id);
|
|
1726
1663
|
for (const block of state.blocks) {
|
|
1727
|
-
if (block.active && block.effectiveMessageIds.
|
|
1728
|
-
(id) => id === message.id || baseMessageId(id) === base
|
|
1729
|
-
))
|
|
1730
|
-
return true;
|
|
1664
|
+
if (block.active && block.effectiveMessageIds.includes(message.id)) return true;
|
|
1731
1665
|
}
|
|
1732
1666
|
return false;
|
|
1733
1667
|
}
|
|
@@ -1948,11 +1882,8 @@ function danglingMessageRefs(state, messages, spec) {
|
|
|
1948
1882
|
if (!parsed || parsed.kind !== "message") continue;
|
|
1949
1883
|
const rawId = state.messageRefs.byRef[parsed.raw] ?? state.messageRefs.byRef[indexToRef(parsed.numericId)];
|
|
1950
1884
|
if (!rawId || visible.has(rawId)) continue;
|
|
1951
|
-
const base = baseMessageId(rawId);
|
|
1952
1885
|
const covered = state.blocks.some(
|
|
1953
|
-
(block) => block.active && block.effectiveMessageIds.
|
|
1954
|
-
(id) => id === rawId || baseMessageId(id) === base
|
|
1955
|
-
)
|
|
1886
|
+
(block) => block.active && block.effectiveMessageIds.includes(rawId)
|
|
1956
1887
|
);
|
|
1957
1888
|
if (!covered) dangling.push(parsed.raw);
|
|
1958
1889
|
}
|
|
@@ -1973,7 +1904,7 @@ function createCore(ports = {}) {
|
|
|
1973
1904
|
input.config,
|
|
1974
1905
|
countTokens
|
|
1975
1906
|
);
|
|
1976
|
-
const preExistingCoverage =
|
|
1907
|
+
const preExistingCoverage = collectCoverage(state);
|
|
1977
1908
|
const classifications = /* @__PURE__ */ new Map();
|
|
1978
1909
|
const classificationErrors = [];
|
|
1979
1910
|
const consumedRanges = [];
|
|
@@ -2137,7 +2068,7 @@ function createCore(ports = {}) {
|
|
|
2137
2068
|
}
|
|
2138
2069
|
const ctx = {
|
|
2139
2070
|
config: input.config,
|
|
2140
|
-
tokenCount: input.tokenCount
|
|
2071
|
+
tokenCount: input.tokenCount,
|
|
2141
2072
|
countTokens
|
|
2142
2073
|
};
|
|
2143
2074
|
const initial = {
|
|
@@ -2183,7 +2114,6 @@ function createCore(ports = {}) {
|
|
|
2183
2114
|
const base = [
|
|
2184
2115
|
assignRefsNode,
|
|
2185
2116
|
syncBlocksNode,
|
|
2186
|
-
stripReasoningNode,
|
|
2187
2117
|
pruneNode,
|
|
2188
2118
|
absorbHideNode,
|
|
2189
2119
|
absorbPromptNode,
|
|
@@ -2226,21 +2156,6 @@ var syncBlocksNode = {
|
|
|
2226
2156
|
return { ...io, state: synced.state };
|
|
2227
2157
|
}
|
|
2228
2158
|
};
|
|
2229
|
-
var stripReasoningNode = {
|
|
2230
|
-
name: "strip-reasoning",
|
|
2231
|
-
enabled: (_io, ctx) => ctx.config.reasoningReplay === "open-round" || ctx.config.reasoningReplay === "never",
|
|
2232
|
-
run(io, ctx) {
|
|
2233
|
-
const { messages, stripped } = stripReasoningByRound(
|
|
2234
|
-
io.messages,
|
|
2235
|
-
ctx.config.reasoningReplay
|
|
2236
|
-
);
|
|
2237
|
-
return {
|
|
2238
|
-
...io,
|
|
2239
|
-
messages,
|
|
2240
|
-
effects: { ...io.effects, reasoningStrippedCount: stripped }
|
|
2241
|
-
};
|
|
2242
|
-
}
|
|
2243
|
-
};
|
|
2244
2159
|
var pruneNode = {
|
|
2245
2160
|
name: "prune",
|
|
2246
2161
|
run(io) {
|
|
@@ -2598,6 +2513,13 @@ function resolveTargetTier(state, nestedBlockIds, isBlockBoundary) {
|
|
|
2598
2513
|
}
|
|
2599
2514
|
return minTier;
|
|
2600
2515
|
}
|
|
2516
|
+
function collectCoverage(state) {
|
|
2517
|
+
const coverage = /* @__PURE__ */ new Set();
|
|
2518
|
+
for (const block of activeBlocks(state)) {
|
|
2519
|
+
for (const id of block.effectiveMessageIds) coverage.add(id);
|
|
2520
|
+
}
|
|
2521
|
+
return coverage;
|
|
2522
|
+
}
|
|
2601
2523
|
function resolveAdaptiveGrowth(modelContextLimit, nudge) {
|
|
2602
2524
|
if (!modelContextLimit || modelContextLimit <= 0) return nudge.growthFloor;
|
|
2603
2525
|
return Math.min(
|
|
@@ -3835,7 +3757,11 @@ function build(text) {
|
|
|
3835
3757
|
}
|
|
3836
3758
|
function docFeatures(text) {
|
|
3837
3759
|
const hit = cache.get(text);
|
|
3838
|
-
if (hit)
|
|
3760
|
+
if (hit) {
|
|
3761
|
+
cache.delete(text);
|
|
3762
|
+
cache.set(text, hit);
|
|
3763
|
+
return hit;
|
|
3764
|
+
}
|
|
3839
3765
|
const f = build(text);
|
|
3840
3766
|
if (text.length > 0 && text.length <= capChars) {
|
|
3841
3767
|
while (cachedChars + text.length > capChars && cache.size > 0) {
|
|
@@ -3946,8 +3872,8 @@ var hybridAlgorithm = {
|
|
|
3946
3872
|
score(docs, query) {
|
|
3947
3873
|
const bm = bm25Algorithm.score(docs, query);
|
|
3948
3874
|
const fz = fuzzyAlgorithm.score(docs, query);
|
|
3949
|
-
const maxBm =
|
|
3950
|
-
const maxFz =
|
|
3875
|
+
const maxBm = bm.reduce((m, r) => r.score > m ? r.score : m, 1e-9);
|
|
3876
|
+
const maxFz = fz.reduce((m, r) => r.score > m ? r.score : m, 1e-9);
|
|
3951
3877
|
const bmMap = new Map(bm.map((r) => [r.ref, r.score / maxBm]));
|
|
3952
3878
|
const fzMap = new Map(fz.map((r) => [r.ref, r.score / maxFz]));
|
|
3953
3879
|
return docs.map((d) => ({
|
|
@@ -4138,7 +4064,6 @@ export {
|
|
|
4138
4064
|
applyAbsorb,
|
|
4139
4065
|
applyMessageFilters,
|
|
4140
4066
|
assignRefs,
|
|
4141
|
-
baseMessageId,
|
|
4142
4067
|
blockById,
|
|
4143
4068
|
blockDocs,
|
|
4144
4069
|
blockVisibleInRange,
|
|
@@ -4177,9 +4102,7 @@ export {
|
|
|
4177
4102
|
highestUsedIndex,
|
|
4178
4103
|
indexToRef,
|
|
4179
4104
|
isAbsorbCandidate,
|
|
4180
|
-
isIdCovered,
|
|
4181
4105
|
isMessageProtected,
|
|
4182
|
-
isRealUserMessage,
|
|
4183
4106
|
isRenderedSummaryMessage,
|
|
4184
4107
|
isSummaryMessageId,
|
|
4185
4108
|
listMessageFilters,
|
|
@@ -4213,7 +4136,6 @@ export {
|
|
|
4213
4136
|
searchBlocks,
|
|
4214
4137
|
searchBlocksAsync,
|
|
4215
4138
|
setDocCacheCap,
|
|
4216
|
-
stripReasoningByRound,
|
|
4217
4139
|
summaryMessageId,
|
|
4218
4140
|
syncBlocks,
|
|
4219
4141
|
truncateLargeToolOutputs,
|