acp-kernel 0.0.59-pr.235.82 → 0.0.59
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/boundaries.d.ts +3 -3
- package/dist/boundaries.d.ts.map +1 -1
- package/dist/compress.d.ts.map +1 -1
- package/dist/decompress.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -132
- package/dist/index.js.map +1 -1
- package/dist/prune.d.ts +0 -15
- package/dist/prune.d.ts.map +1 -1
- package/dist/recommend.d.ts.map +1 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/boundaries.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export declare function resolveBoundaries(input: ResolveBoundariesInput): Resolv
|
|
|
42
42
|
* active block whose raws were pruned becomes unresolvable and cannot be
|
|
43
43
|
* promoted (dog/billion-context-pi#195).
|
|
44
44
|
*/
|
|
45
|
-
export declare function visibleBlockAnchor(block: CompressionBlock, indexByMessageId: Map<string, number
|
|
46
|
-
export declare function blockVisibleInRange(block: CompressionBlock, indexByMessageId: Map<string, number>, startIndex: number, endIndex: number
|
|
47
|
-
export declare function earliestIndexOfIds(ids: string[], indexByMessageId: Map<string, number
|
|
45
|
+
export declare function visibleBlockAnchor(block: CompressionBlock, indexByMessageId: Map<string, number>): number | null;
|
|
46
|
+
export declare function blockVisibleInRange(block: CompressionBlock, indexByMessageId: Map<string, number>, startIndex: number, endIndex: number): boolean;
|
|
47
|
+
export declare function earliestIndexOfIds(ids: string[], indexByMessageId: Map<string, number>): number | null;
|
|
48
48
|
export declare function toResolvedBoundary(range: ResolvedRange): ResolvedBoundary;
|
|
49
49
|
//# sourceMappingURL=boundaries.d.ts.map
|
package/dist/boundaries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/bounda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E,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/decompress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAElF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO1D;AAED,wBAAgB,6BAA6B,CACzC,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../src/decompress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAElF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO1D;AAED,wBAAgB,6BAA6B,CACzC,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,gBAAgB,EAAE,CAUpB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiB1F;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,iBAAsB,GAChC,gBAAgB,CAkClB;AAED,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,WAAW,EAAE,EACvB,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,EACnC,KAAK,EAAE,gBAAgB,GACxB,qBAAqB,CA8BvB;AAED,MAAM,WAAW,sBAAsB;IACnC,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,6GAA6G;IAC7G,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IAClC,kKAAkK;IAClK,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,qBAA0B,GACpC,sBAAsB,CAsCxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { createInitialState, allocateBlockId, allocateRunId, blockById, activeBl
|
|
|
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";
|
|
8
|
-
export { prune,
|
|
8
|
+
export { prune, SUMMARY_HEADER, summaryMessageId, isSummaryMessageId, isRenderedSummaryMessage, } from "./prune.js";
|
|
9
9
|
export { syncBlocks } from "./sync.js";
|
|
10
10
|
export { resolveBoundaries, parseBoundary, BoundaryNotFoundError, visibleBlockAnchor, blockVisibleInRange, } from "./boundaries.js";
|
|
11
11
|
export { defaultCountTokens, estimateTokensFast, createBpeTokenizer, } from "./tokenize.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,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,EACL,KAAK,EACL,
|
|
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,EACL,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,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AAW,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
|
@@ -107,45 +107,33 @@ function summaryMessageId(blockId) {
|
|
|
107
107
|
function isSummaryMessageId(id) {
|
|
108
108
|
return id.startsWith(SUMMARY_ID_PREFIX);
|
|
109
109
|
}
|
|
110
|
-
function baseIdOf(id) {
|
|
111
|
-
const hash = id.indexOf("#");
|
|
112
|
-
return hash > 0 ? id.substring(0, hash) : id;
|
|
113
|
-
}
|
|
114
|
-
function isCovered(id, coveredBases) {
|
|
115
|
-
return coveredBases.has(baseIdOf(id));
|
|
116
|
-
}
|
|
117
110
|
function isRenderedSummaryMessage(message) {
|
|
118
111
|
return isSummaryMessageId(message.id) && message.role === "system" && message.contentType === "text";
|
|
119
112
|
}
|
|
120
113
|
function prune(messages, state, options = {}) {
|
|
121
114
|
const covered = coveredMessageIds(state);
|
|
122
115
|
if (covered.size === 0) return [...messages];
|
|
123
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
124
|
-
for (const id of covered) coveredBases.add(baseIdOf(id));
|
|
125
116
|
const inject = options.injectSummaries ?? true;
|
|
126
117
|
const firstUserIndex = messages.findIndex(
|
|
127
118
|
(message) => message.role === "user"
|
|
128
119
|
);
|
|
129
|
-
const
|
|
120
|
+
const indexById = /* @__PURE__ */ new Map();
|
|
130
121
|
const summaryIndexById = /* @__PURE__ */ new Map();
|
|
131
122
|
messages.forEach((message, index) => {
|
|
132
|
-
|
|
133
|
-
const existing = baseIndexById.get(base);
|
|
134
|
-
if (existing === void 0 || index < existing)
|
|
135
|
-
baseIndexById.set(base, index);
|
|
123
|
+
indexById.set(message.id, index);
|
|
136
124
|
if (isRenderedSummaryMessage(message))
|
|
137
125
|
summaryIndexById.set(message.id, index);
|
|
138
126
|
});
|
|
139
|
-
const anchors = inject ? collectSummaryAnchors(state,
|
|
127
|
+
const anchors = inject ? collectSummaryAnchors(state, indexById, summaryIndexById) : [];
|
|
140
128
|
return stripOrphanedReasoning(
|
|
141
129
|
stripOrphanedToolResults(
|
|
142
130
|
stripOrphanedToolCalls(
|
|
143
|
-
rebuildMessages(messages,
|
|
131
|
+
rebuildMessages(messages, covered, firstUserIndex, anchors)
|
|
144
132
|
)
|
|
145
133
|
)
|
|
146
134
|
);
|
|
147
135
|
}
|
|
148
|
-
function collectSummaryAnchors(state,
|
|
136
|
+
function collectSummaryAnchors(state, indexById, summaryIndexById) {
|
|
149
137
|
const anchors = [];
|
|
150
138
|
for (const block of activeBlocks(state)) {
|
|
151
139
|
const existingIndex = summaryIndexById.get(summaryMessageId(block.blockId));
|
|
@@ -160,7 +148,7 @@ function collectSummaryAnchors(state, baseIndexById, summaryIndexById) {
|
|
|
160
148
|
}
|
|
161
149
|
let earliest = null;
|
|
162
150
|
for (const id of block.effectiveMessageIds) {
|
|
163
|
-
const index =
|
|
151
|
+
const index = indexById.get(id);
|
|
164
152
|
if (index !== void 0 && (earliest === null || index < earliest)) {
|
|
165
153
|
earliest = index;
|
|
166
154
|
}
|
|
@@ -175,7 +163,7 @@ function collectSummaryAnchors(state, baseIndexById, summaryIndexById) {
|
|
|
175
163
|
anchors.sort((left, right) => left.insertAt - right.insertAt);
|
|
176
164
|
return anchors;
|
|
177
165
|
}
|
|
178
|
-
function rebuildMessages(messages,
|
|
166
|
+
function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
179
167
|
const result = [];
|
|
180
168
|
const pending = [...anchors];
|
|
181
169
|
const anchoredSummaryIds = new Set(
|
|
@@ -189,7 +177,7 @@ function rebuildMessages(messages, coveredBases, firstUserIndex, anchors) {
|
|
|
189
177
|
result.push(messages[index]);
|
|
190
178
|
continue;
|
|
191
179
|
}
|
|
192
|
-
if (
|
|
180
|
+
if (covered.has(messages[index].id)) continue;
|
|
193
181
|
if (isRenderedSummaryMessage(messages[index]) && anchoredSummaryIds.has(messages[index].id))
|
|
194
182
|
continue;
|
|
195
183
|
result.push(messages[index]);
|
|
@@ -255,8 +243,6 @@ function stripOrphanedReasoning(messages) {
|
|
|
255
243
|
// src/sync.ts
|
|
256
244
|
function syncBlocks(messages, state) {
|
|
257
245
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
258
|
-
const presentBases = /* @__PURE__ */ new Set();
|
|
259
|
-
for (const message of messages) presentBases.add(baseIdOf(message.id));
|
|
260
246
|
const deactivated = [];
|
|
261
247
|
const result = {
|
|
262
248
|
blocks: state.blocks.map((block) => ({
|
|
@@ -303,7 +289,7 @@ function syncBlocks(messages, state) {
|
|
|
303
289
|
continue;
|
|
304
290
|
}
|
|
305
291
|
block.active = true;
|
|
306
|
-
const stillPresent = block.effectiveMessageIds.some((id) =>
|
|
292
|
+
const stillPresent = block.effectiveMessageIds.some((id) => presentIds.has(id)) || presentIds.has(summaryMessageId(block.blockId));
|
|
307
293
|
if (!stillPresent) {
|
|
308
294
|
block.active = false;
|
|
309
295
|
deactivated.push(block.blockId);
|
|
@@ -443,20 +429,14 @@ function resolveBoundaries(input) {
|
|
|
443
429
|
);
|
|
444
430
|
}
|
|
445
431
|
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
const base = baseIdOf(message.id);
|
|
450
|
-
const existing = baseIndexById.get(base);
|
|
451
|
-
if (existing === void 0 || index < existing)
|
|
452
|
-
baseIndexById.set(base, index);
|
|
453
|
-
});
|
|
432
|
+
input.messages.forEach(
|
|
433
|
+
(message, index) => indexByMessageId.set(message.id, index)
|
|
434
|
+
);
|
|
454
435
|
let snappedBoundaries = [];
|
|
455
436
|
const startAnchor = resolveAnchorIndex(
|
|
456
437
|
start,
|
|
457
438
|
input.state,
|
|
458
439
|
indexByMessageId,
|
|
459
|
-
baseIndexById,
|
|
460
440
|
"start"
|
|
461
441
|
);
|
|
462
442
|
if (startAnchor.snapped) snappedBoundaries.push(startAnchor.snapped);
|
|
@@ -464,7 +444,6 @@ function resolveBoundaries(input) {
|
|
|
464
444
|
end,
|
|
465
445
|
input.state,
|
|
466
446
|
indexByMessageId,
|
|
467
|
-
baseIndexById,
|
|
468
447
|
"end"
|
|
469
448
|
);
|
|
470
449
|
if (endAnchor.snapped) snappedBoundaries.push(endAnchor.snapped);
|
|
@@ -483,13 +462,7 @@ function resolveBoundaries(input) {
|
|
|
483
462
|
const nestedBlockIds = [];
|
|
484
463
|
const nestedSeen = /* @__PURE__ */ new Set();
|
|
485
464
|
for (const block of activeBlocks(input.state)) {
|
|
486
|
-
if (blockVisibleInRange(
|
|
487
|
-
block,
|
|
488
|
-
indexByMessageId,
|
|
489
|
-
startIndex,
|
|
490
|
-
endIndex,
|
|
491
|
-
baseIndexById
|
|
492
|
-
)) {
|
|
465
|
+
if (blockVisibleInRange(block, indexByMessageId, startIndex, endIndex)) {
|
|
493
466
|
if (!nestedSeen.has(block.blockId)) {
|
|
494
467
|
nestedSeen.add(block.blockId);
|
|
495
468
|
nestedBlockIds.push(block.blockId);
|
|
@@ -507,7 +480,7 @@ function resolveBoundaries(input) {
|
|
|
507
480
|
snappedBoundaries
|
|
508
481
|
};
|
|
509
482
|
}
|
|
510
|
-
function resolveAnchorIndex(boundary, state, indexByMessageId,
|
|
483
|
+
function resolveAnchorIndex(boundary, state, indexByMessageId, endpoint) {
|
|
511
484
|
const label = endpoint === "start" ? "startId" : "endId";
|
|
512
485
|
if (boundary.kind === "message") {
|
|
513
486
|
const rawId = state.messageRefs.byRef[boundary.raw] ?? state.messageRefs.byRef[formatPaddedRef(boundary.numericId)];
|
|
@@ -518,11 +491,11 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
518
491
|
`${label}="${boundary.raw}" does not exist in this session (typo or wrong session) \u2014 run acp_status for current refs.`
|
|
519
492
|
);
|
|
520
493
|
}
|
|
521
|
-
const index = indexByMessageId.get(rawId)
|
|
494
|
+
const index = indexByMessageId.get(rawId);
|
|
522
495
|
if (index !== void 0) {
|
|
523
496
|
return { index, snapped: null };
|
|
524
497
|
}
|
|
525
|
-
const owner2 = activeOwnerAnchor(state, [rawId], indexByMessageId
|
|
498
|
+
const owner2 = activeOwnerAnchor(state, [rawId], indexByMessageId);
|
|
526
499
|
if (owner2 !== null) {
|
|
527
500
|
return {
|
|
528
501
|
index: owner2,
|
|
@@ -544,7 +517,7 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
544
517
|
);
|
|
545
518
|
}
|
|
546
519
|
if (block.active) {
|
|
547
|
-
const anchor = visibleBlockAnchor(block, indexByMessageId
|
|
520
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
548
521
|
if (anchor !== null) {
|
|
549
522
|
return { index: anchor, snapped: null };
|
|
550
523
|
}
|
|
@@ -552,8 +525,7 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
552
525
|
const owner = activeOwnerAnchor(
|
|
553
526
|
state,
|
|
554
527
|
block.effectiveMessageIds,
|
|
555
|
-
indexByMessageId
|
|
556
|
-
baseIndexById
|
|
528
|
+
indexByMessageId
|
|
557
529
|
);
|
|
558
530
|
if (owner !== null) {
|
|
559
531
|
return {
|
|
@@ -574,10 +546,9 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
574
546
|
`${label}="b${boundary.numericId}" is an active block but none of its content (raw messages or rendered summary) is visible in the current context \u2014 run acp_status to verify.`
|
|
575
547
|
);
|
|
576
548
|
}
|
|
577
|
-
function activeOwnerAnchor(state, ownedIds, indexByMessageId
|
|
549
|
+
function activeOwnerAnchor(state, ownedIds, indexByMessageId) {
|
|
578
550
|
if (ownedIds.length === 0) return null;
|
|
579
|
-
const owned =
|
|
580
|
-
for (const id of ownedIds) owned.add(baseIdOf(id));
|
|
551
|
+
const owned = new Set(ownedIds);
|
|
581
552
|
let best = null;
|
|
582
553
|
for (const block of state.blocks) {
|
|
583
554
|
if (!block.active) continue;
|
|
@@ -590,7 +561,7 @@ function activeOwnerAnchor(state, ownedIds, indexByMessageId, baseIndexById) {
|
|
|
590
561
|
}
|
|
591
562
|
}
|
|
592
563
|
if (!ownsInherited) continue;
|
|
593
|
-
const anchor = visibleBlockAnchor(block, indexByMessageId
|
|
564
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
594
565
|
if (anchor === null) continue;
|
|
595
566
|
if (best === null || anchor < best) {
|
|
596
567
|
best = anchor;
|
|
@@ -603,54 +574,39 @@ function inheritedContentIds(state, block) {
|
|
|
603
574
|
for (const childId of block.directBlockIds) {
|
|
604
575
|
const child = blockById(state, childId);
|
|
605
576
|
if (!child) continue;
|
|
606
|
-
for (const id of child.effectiveMessageIds) ids.add(
|
|
577
|
+
for (const id of child.effectiveMessageIds) ids.add(id);
|
|
607
578
|
}
|
|
608
579
|
return ids;
|
|
609
580
|
}
|
|
610
581
|
function formatPaddedRef(index) {
|
|
611
582
|
return `m${String(index).padStart(5, "0")}`;
|
|
612
583
|
}
|
|
613
|
-
function visibleBlockAnchor(block, indexByMessageId
|
|
584
|
+
function visibleBlockAnchor(block, indexByMessageId) {
|
|
614
585
|
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
615
586
|
if (summaryIndex !== void 0) return summaryIndex;
|
|
616
|
-
return earliestIndexOfIds(
|
|
617
|
-
block.effectiveMessageIds,
|
|
618
|
-
indexByMessageId,
|
|
619
|
-
baseIndexById
|
|
620
|
-
);
|
|
587
|
+
return earliestIndexOfIds(block.effectiveMessageIds, indexByMessageId);
|
|
621
588
|
}
|
|
622
|
-
function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex
|
|
589
|
+
function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex) {
|
|
623
590
|
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
624
591
|
if (summaryIndex !== void 0 && summaryIndex >= startIndex && summaryIndex <= endIndex) {
|
|
625
592
|
return true;
|
|
626
593
|
}
|
|
627
594
|
const rawIndex = earliestIndexOfIds(
|
|
628
595
|
block.effectiveMessageIds,
|
|
629
|
-
indexByMessageId
|
|
630
|
-
baseIndexById
|
|
596
|
+
indexByMessageId
|
|
631
597
|
);
|
|
632
598
|
return rawIndex !== null && rawIndex >= startIndex && rawIndex <= endIndex;
|
|
633
599
|
}
|
|
634
|
-
function earliestIndexOfIds(ids, indexByMessageId
|
|
635
|
-
const baseIndex = baseIndexById ?? deriveBaseIndex(indexByMessageId);
|
|
600
|
+
function earliestIndexOfIds(ids, indexByMessageId) {
|
|
636
601
|
let earliest = null;
|
|
637
602
|
for (const id of ids) {
|
|
638
|
-
const index =
|
|
603
|
+
const index = indexByMessageId.get(id);
|
|
639
604
|
if (index !== void 0 && (earliest === null || index < earliest)) {
|
|
640
605
|
earliest = index;
|
|
641
606
|
}
|
|
642
607
|
}
|
|
643
608
|
return earliest;
|
|
644
609
|
}
|
|
645
|
-
function deriveBaseIndex(indexByMessageId) {
|
|
646
|
-
const baseIndex = /* @__PURE__ */ new Map();
|
|
647
|
-
for (const [id, index] of indexByMessageId) {
|
|
648
|
-
const base = baseIdOf(id);
|
|
649
|
-
const existing = baseIndex.get(base);
|
|
650
|
-
if (existing === void 0 || index < existing) baseIndex.set(base, index);
|
|
651
|
-
}
|
|
652
|
-
return baseIndex;
|
|
653
|
-
}
|
|
654
610
|
|
|
655
611
|
// src/truncate-tools.ts
|
|
656
612
|
var TRUNCATION_MARKER = "[truncated for context space]";
|
|
@@ -1702,26 +1658,20 @@ function estimateTextTokens(text) {
|
|
|
1702
1658
|
function isToolMessage(message) {
|
|
1703
1659
|
return message.contentType === "tool-call" || message.contentType === "tool-result";
|
|
1704
1660
|
}
|
|
1705
|
-
function
|
|
1706
|
-
|
|
1661
|
+
function isSyntheticOrPruned(message, state) {
|
|
1662
|
+
if (message.text?.startsWith("[Compressed conversation section]")) return true;
|
|
1707
1663
|
for (const block of state.blocks) {
|
|
1708
|
-
if (
|
|
1709
|
-
for (const id of block.effectiveMessageIds) covered.add(baseIdOf(id));
|
|
1664
|
+
if (block.active && block.effectiveMessageIds.includes(message.id)) return true;
|
|
1710
1665
|
}
|
|
1711
|
-
return
|
|
1712
|
-
}
|
|
1713
|
-
function isSyntheticOrPruned(message, coveredBases) {
|
|
1714
|
-
if (message.text?.startsWith("[Compressed conversation section]")) return true;
|
|
1715
|
-
return coveredBases.has(baseIdOf(message.id));
|
|
1666
|
+
return false;
|
|
1716
1667
|
}
|
|
1717
1668
|
function computeProtectedRefs(messages, state, config, countTokens = estimateTextTokens) {
|
|
1718
1669
|
const preserveN = config.preserveRecentMessages;
|
|
1719
1670
|
const preserveTokens = config.preserveRecentTokens;
|
|
1720
1671
|
const result = /* @__PURE__ */ new Set();
|
|
1721
1672
|
const visible = [];
|
|
1722
|
-
const coveredBases = activeBlockCoveredBases(state);
|
|
1723
1673
|
for (const msg of messages) {
|
|
1724
|
-
if (isSyntheticOrPruned(msg,
|
|
1674
|
+
if (isSyntheticOrPruned(msg, state)) continue;
|
|
1725
1675
|
if (isNeverPreserveRecent(msg)) continue;
|
|
1726
1676
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
1727
1677
|
if (!ref || ref === "BLOCKED") continue;
|
|
@@ -1742,7 +1692,7 @@ function computeProtectedRefs(messages, state, config, countTokens = estimateTex
|
|
|
1742
1692
|
if (preserveN > 0) {
|
|
1743
1693
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1744
1694
|
const msg = messages[i];
|
|
1745
|
-
if (msg.role !== "user" || isSyntheticOrPruned(msg,
|
|
1695
|
+
if (msg.role !== "user" || isSyntheticOrPruned(msg, state)) continue;
|
|
1746
1696
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
1747
1697
|
if (ref && ref !== "BLOCKED") result.add(ref);
|
|
1748
1698
|
break;
|
|
@@ -1756,11 +1706,10 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1756
1706
|
const protectedCallIds = collectProtectedToolCallIds(messages, config);
|
|
1757
1707
|
let skipSinceCompressible = false;
|
|
1758
1708
|
let skipSinceProtected = false;
|
|
1759
|
-
const coveredBases = activeBlockCoveredBases(state);
|
|
1760
1709
|
for (const msg of messages) {
|
|
1761
1710
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
1762
1711
|
if (!ref || ref === "BLOCKED") continue;
|
|
1763
|
-
if (isSyntheticOrPruned(msg,
|
|
1712
|
+
if (isSyntheticOrPruned(msg, state)) {
|
|
1764
1713
|
skipSinceCompressible = true;
|
|
1765
1714
|
skipSinceProtected = true;
|
|
1766
1715
|
continue;
|
|
@@ -1927,22 +1876,16 @@ function refGateDiagnostics(state, requestedRanges, unknownCount) {
|
|
|
1927
1876
|
}
|
|
1928
1877
|
function danglingMessageRefs(state, messages, spec) {
|
|
1929
1878
|
const visible = new Set(messages.map((m) => m.id));
|
|
1930
|
-
const visibleBases = /* @__PURE__ */ new Set();
|
|
1931
|
-
for (const id of visible) visibleBases.add(baseIdOf(id));
|
|
1932
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
1933
|
-
for (const block of state.blocks) {
|
|
1934
|
-
if (!block.active) continue;
|
|
1935
|
-
for (const id of block.effectiveMessageIds) coveredBases.add(baseIdOf(id));
|
|
1936
|
-
}
|
|
1937
1879
|
const dangling = [];
|
|
1938
1880
|
for (const ref of [spec.startRef, spec.endRef]) {
|
|
1939
1881
|
const parsed = parseBoundary(ref);
|
|
1940
1882
|
if (!parsed || parsed.kind !== "message") continue;
|
|
1941
1883
|
const rawId = state.messageRefs.byRef[parsed.raw] ?? state.messageRefs.byRef[indexToRef(parsed.numericId)];
|
|
1942
|
-
if (!rawId) continue;
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1945
|
-
|
|
1884
|
+
if (!rawId || visible.has(rawId)) continue;
|
|
1885
|
+
const covered = state.blocks.some(
|
|
1886
|
+
(block) => block.active && block.effectiveMessageIds.includes(rawId)
|
|
1887
|
+
);
|
|
1888
|
+
if (!covered) dangling.push(parsed.raw);
|
|
1946
1889
|
}
|
|
1947
1890
|
return dangling;
|
|
1948
1891
|
}
|
|
@@ -2361,25 +2304,13 @@ function applySingleRange(input) {
|
|
|
2361
2304
|
).filter((id) => !isSummaryMessageId(id));
|
|
2362
2305
|
if (rangeMessageIds.length > resolved.messageIds.length) {
|
|
2363
2306
|
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
2364
|
-
|
|
2365
|
-
input.messages.forEach((m, i) => {
|
|
2366
|
-
indexByMessageId.set(m.id, i);
|
|
2367
|
-
const base = baseIdOf(m.id);
|
|
2368
|
-
const existing = baseIndexById.get(base);
|
|
2369
|
-
if (existing === void 0 || i < existing) baseIndexById.set(base, i);
|
|
2370
|
-
});
|
|
2307
|
+
input.messages.forEach((m, i) => indexByMessageId.set(m.id, i));
|
|
2371
2308
|
const adjustedStart = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[0]) ?? resolved.startIndex : resolved.startIndex;
|
|
2372
2309
|
const adjustedEnd = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[rangeMessageIds.length - 1]) ?? resolved.endIndex : resolved.endIndex;
|
|
2373
2310
|
const nestedSeen = new Set(resolved.nestedBlockIds);
|
|
2374
2311
|
for (const block2 of activeBlocks(input.state)) {
|
|
2375
2312
|
if (nestedSeen.has(block2.blockId)) continue;
|
|
2376
|
-
if (blockVisibleInRange(
|
|
2377
|
-
block2,
|
|
2378
|
-
indexByMessageId,
|
|
2379
|
-
adjustedStart,
|
|
2380
|
-
adjustedEnd,
|
|
2381
|
-
baseIndexById
|
|
2382
|
-
)) {
|
|
2313
|
+
if (blockVisibleInRange(block2, indexByMessageId, adjustedStart, adjustedEnd)) {
|
|
2383
2314
|
nestedSeen.add(block2.blockId);
|
|
2384
2315
|
resolved.nestedBlockIds.push(block2.blockId);
|
|
2385
2316
|
}
|
|
@@ -2405,7 +2336,7 @@ function applySingleRange(input) {
|
|
|
2405
2336
|
}
|
|
2406
2337
|
}
|
|
2407
2338
|
const directMessageIds = [...effectiveMessageIds].filter(
|
|
2408
|
-
(id) => !input.preExistingCoverage.has(
|
|
2339
|
+
(id) => !input.preExistingCoverage.has(id)
|
|
2409
2340
|
);
|
|
2410
2341
|
let filteredIds = filterProtectedToolMessages(
|
|
2411
2342
|
directMessageIds,
|
|
@@ -2585,7 +2516,7 @@ function resolveTargetTier(state, nestedBlockIds, isBlockBoundary) {
|
|
|
2585
2516
|
function collectCoverage(state) {
|
|
2586
2517
|
const coverage = /* @__PURE__ */ new Set();
|
|
2587
2518
|
for (const block of activeBlocks(state)) {
|
|
2588
|
-
for (const id of block.effectiveMessageIds) coverage.add(
|
|
2519
|
+
for (const id of block.effectiveMessageIds) coverage.add(id);
|
|
2589
2520
|
}
|
|
2590
2521
|
return coverage;
|
|
2591
2522
|
}
|
|
@@ -2846,12 +2777,10 @@ function parseBlockIdArg(arg) {
|
|
|
2846
2777
|
}
|
|
2847
2778
|
function findBlocksOverlappingMessages(state, messageIds) {
|
|
2848
2779
|
if (messageIds.size === 0) return [];
|
|
2849
|
-
const messageBases = /* @__PURE__ */ new Set();
|
|
2850
|
-
for (const id of messageIds) messageBases.add(baseIdOf(id));
|
|
2851
2780
|
const matched = [];
|
|
2852
2781
|
for (const block of state.blocks) {
|
|
2853
2782
|
if (!block.active) continue;
|
|
2854
|
-
if (block.effectiveMessageIds.some((id) =>
|
|
2783
|
+
if (block.effectiveMessageIds.some((id) => messageIds.has(id))) {
|
|
2855
2784
|
matched.push(block);
|
|
2856
2785
|
}
|
|
2857
2786
|
}
|
|
@@ -2908,15 +2837,13 @@ function deactivateBlock(state, blockIds, options = {}) {
|
|
|
2908
2837
|
return { ...state, blocks: final };
|
|
2909
2838
|
}
|
|
2910
2839
|
function buildRestoredContentPreview(messages, beforeActiveMessageIds, state) {
|
|
2911
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
2912
|
-
for (const b of state.blocks) {
|
|
2913
|
-
if (!b.active) continue;
|
|
2914
|
-
for (const id of b.effectiveMessageIds) coveredBases.add(baseIdOf(id));
|
|
2915
|
-
}
|
|
2916
2840
|
const restored = [];
|
|
2917
2841
|
for (const message of messages) {
|
|
2918
2842
|
if (!beforeActiveMessageIds.has(message.id)) continue;
|
|
2919
|
-
|
|
2843
|
+
const stillCovered = state.blocks.some(
|
|
2844
|
+
(b) => b.active && b.effectiveMessageIds.includes(message.id)
|
|
2845
|
+
);
|
|
2846
|
+
if (!stillCovered) restored.push(message);
|
|
2920
2847
|
}
|
|
2921
2848
|
if (restored.length === 0) return { preview: "", restoredCount: 0 };
|
|
2922
2849
|
const lines = [];
|
|
@@ -2935,10 +2862,9 @@ function buildRestoredContentPreview(messages, beforeActiveMessageIds, state) {
|
|
|
2935
2862
|
}
|
|
2936
2863
|
function collectBlockContent(state, block, messages, options = {}) {
|
|
2937
2864
|
const full = options.full ?? false;
|
|
2938
|
-
const
|
|
2939
|
-
for (const id of block.effectiveMessageIds) targetBases.add(baseIdOf(id));
|
|
2865
|
+
const targetIds = new Set(block.effectiveMessageIds);
|
|
2940
2866
|
if (full) {
|
|
2941
|
-
const msgs = messages.filter((m) =>
|
|
2867
|
+
const msgs = messages.filter((m) => targetIds.has(m.id));
|
|
2942
2868
|
if (msgs.length === 0) return { text: "", count: 0 };
|
|
2943
2869
|
return { text: msgs.map(formatMessage).join("\n\n"), count: msgs.length };
|
|
2944
2870
|
}
|
|
@@ -2948,7 +2874,7 @@ function collectBlockContent(state, block, messages, options = {}) {
|
|
|
2948
2874
|
const child = state.blocks.find((b) => b.blockId === childId);
|
|
2949
2875
|
if (!child?.active) continue;
|
|
2950
2876
|
nestedChildren.push(child);
|
|
2951
|
-
for (const id of child.effectiveMessageIds) nestedCovered.add(
|
|
2877
|
+
for (const id of child.effectiveMessageIds) nestedCovered.add(id);
|
|
2952
2878
|
}
|
|
2953
2879
|
const parts = [];
|
|
2954
2880
|
for (const child of nestedChildren) {
|
|
@@ -2958,8 +2884,7 @@ ${child.summary}`);
|
|
|
2958
2884
|
}
|
|
2959
2885
|
let directCount = 0;
|
|
2960
2886
|
for (const m of messages) {
|
|
2961
|
-
|
|
2962
|
-
if (targetBases.has(base) && !nestedCovered.has(base)) {
|
|
2887
|
+
if (targetIds.has(m.id) && !nestedCovered.has(m.id)) {
|
|
2963
2888
|
parts.push(formatMessage(m));
|
|
2964
2889
|
directCount++;
|
|
2965
2890
|
}
|
|
@@ -3021,7 +2946,7 @@ function collectVisible(messages, state, countTokens) {
|
|
|
3021
2946
|
const coveredIds = /* @__PURE__ */ new Set();
|
|
3022
2947
|
for (const block of state.blocks) {
|
|
3023
2948
|
if (!block.active) continue;
|
|
3024
|
-
for (const id of block.effectiveMessageIds) coveredIds.add(
|
|
2949
|
+
for (const id of block.effectiveMessageIds) coveredIds.add(id);
|
|
3025
2950
|
}
|
|
3026
2951
|
let summaryTokens = 0;
|
|
3027
2952
|
for (const block of state.blocks) {
|
|
@@ -3035,7 +2960,7 @@ function collectVisible(messages, state, countTokens) {
|
|
|
3035
2960
|
}
|
|
3036
2961
|
}
|
|
3037
2962
|
messages.forEach((message, index) => {
|
|
3038
|
-
if (coveredIds.has(
|
|
2963
|
+
if (coveredIds.has(message.id)) return;
|
|
3039
2964
|
const ref = refForRaw(state.messageRefs, message.id);
|
|
3040
2965
|
if (!ref) return;
|
|
3041
2966
|
const tokens = countTokens(message.text ?? "");
|
|
@@ -4135,7 +4060,6 @@ export {
|
|
|
4135
4060
|
applyAbsorb,
|
|
4136
4061
|
applyMessageFilters,
|
|
4137
4062
|
assignRefs,
|
|
4138
|
-
baseIdOf,
|
|
4139
4063
|
blockById,
|
|
4140
4064
|
blockDocs,
|
|
4141
4065
|
blockVisibleInRange,
|
|
@@ -4174,7 +4098,6 @@ export {
|
|
|
4174
4098
|
highestUsedIndex,
|
|
4175
4099
|
indexToRef,
|
|
4176
4100
|
isAbsorbCandidate,
|
|
4177
|
-
isCovered,
|
|
4178
4101
|
isMessageProtected,
|
|
4179
4102
|
isRenderedSummaryMessage,
|
|
4180
4103
|
isSummaryMessageId,
|