acp-kernel 0.0.82-pr.235.211 → 0.0.82-pr.255.210
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/panel/index.d.ts +2 -0
- package/dist/panel/index.d.ts.map +1 -1
- package/dist/panel/index.js +105 -22
- package/dist/panel/index.js.map +1 -1
- package/dist/panel/labels.d.ts +68 -0
- package/dist/panel/labels.d.ts.map +1 -0
- package/dist/panel/panel.d.ts +5 -0
- package/dist/panel/panel.d.ts.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/boundaries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAehE;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,KAAK,CAAC;gBAGjC,IAAI,EAAE,SAAS,GAAG,UAAU,EAC5B,QAAQ,EAAE,OAAO,GAAG,KAAK,EACzB,OAAO,EAAE,MAAM;CAQlB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EA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AE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;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;AA2GD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAgV7D;AAmmCD,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":"AAEA,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":"AAEA,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, countMessageTokens, } 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,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EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,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,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,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
|
@@ -111,45 +111,33 @@ function summaryMessageId(blockId) {
|
|
|
111
111
|
function isSummaryMessageId(id) {
|
|
112
112
|
return id.startsWith(SUMMARY_ID_PREFIX);
|
|
113
113
|
}
|
|
114
|
-
function baseIdOf(id) {
|
|
115
|
-
const hash = id.indexOf("#");
|
|
116
|
-
return hash > 0 ? id.substring(0, hash) : id;
|
|
117
|
-
}
|
|
118
|
-
function isCovered(id, coveredBases) {
|
|
119
|
-
return coveredBases.has(baseIdOf(id));
|
|
120
|
-
}
|
|
121
114
|
function isRenderedSummaryMessage(message) {
|
|
122
115
|
return isSummaryMessageId(message.id) && message.role === "system" && message.contentType === "text";
|
|
123
116
|
}
|
|
124
117
|
function prune(messages, state, options = {}) {
|
|
125
118
|
const covered = coveredMessageIds(state);
|
|
126
119
|
if (covered.size === 0) return [...messages];
|
|
127
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
128
|
-
for (const id of covered) coveredBases.add(baseIdOf(id));
|
|
129
120
|
const inject = options.injectSummaries ?? true;
|
|
130
121
|
const firstUserIndex = messages.findIndex(
|
|
131
122
|
(message) => message.role === "user"
|
|
132
123
|
);
|
|
133
|
-
const
|
|
124
|
+
const indexById = /* @__PURE__ */ new Map();
|
|
134
125
|
const summaryIndexById = /* @__PURE__ */ new Map();
|
|
135
126
|
messages.forEach((message, index) => {
|
|
136
|
-
|
|
137
|
-
const existing = baseIndexById.get(base);
|
|
138
|
-
if (existing === void 0 || index < existing)
|
|
139
|
-
baseIndexById.set(base, index);
|
|
127
|
+
indexById.set(message.id, index);
|
|
140
128
|
if (isRenderedSummaryMessage(message))
|
|
141
129
|
summaryIndexById.set(message.id, index);
|
|
142
130
|
});
|
|
143
|
-
const anchors = inject ? collectSummaryAnchors(state,
|
|
131
|
+
const anchors = inject ? collectSummaryAnchors(state, indexById, summaryIndexById) : [];
|
|
144
132
|
return stripOrphanedReasoning(
|
|
145
133
|
stripOrphanedToolResults(
|
|
146
134
|
stripOrphanedToolCalls(
|
|
147
|
-
rebuildMessages(messages,
|
|
135
|
+
rebuildMessages(messages, covered, firstUserIndex, anchors)
|
|
148
136
|
)
|
|
149
137
|
)
|
|
150
138
|
);
|
|
151
139
|
}
|
|
152
|
-
function collectSummaryAnchors(state,
|
|
140
|
+
function collectSummaryAnchors(state, indexById, summaryIndexById) {
|
|
153
141
|
const anchors = [];
|
|
154
142
|
for (const block of activeBlocks(state)) {
|
|
155
143
|
const existingIndex = summaryIndexById.get(summaryMessageId(block.blockId));
|
|
@@ -164,7 +152,7 @@ function collectSummaryAnchors(state, baseIndexById, summaryIndexById) {
|
|
|
164
152
|
}
|
|
165
153
|
let earliest = null;
|
|
166
154
|
for (const id of block.effectiveMessageIds) {
|
|
167
|
-
const index =
|
|
155
|
+
const index = indexById.get(id);
|
|
168
156
|
if (index !== void 0 && (earliest === null || index < earliest)) {
|
|
169
157
|
earliest = index;
|
|
170
158
|
}
|
|
@@ -209,7 +197,7 @@ function pairSafeAnchorIndex(messages, index) {
|
|
|
209
197
|
}
|
|
210
198
|
return safe;
|
|
211
199
|
}
|
|
212
|
-
function rebuildMessages(messages,
|
|
200
|
+
function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
213
201
|
const safeAnchors = anchors.map((anchor) => ({
|
|
214
202
|
...anchor,
|
|
215
203
|
insertAt: pairSafeAnchorIndex(messages, anchor.insertAt)
|
|
@@ -227,7 +215,7 @@ function rebuildMessages(messages, coveredBases, firstUserIndex, anchors) {
|
|
|
227
215
|
result.push(messages[index]);
|
|
228
216
|
continue;
|
|
229
217
|
}
|
|
230
|
-
if (
|
|
218
|
+
if (covered.has(messages[index].id)) continue;
|
|
231
219
|
if (isRenderedSummaryMessage(messages[index]) && anchoredSummaryIds.has(messages[index].id))
|
|
232
220
|
continue;
|
|
233
221
|
result.push(messages[index]);
|
|
@@ -293,8 +281,6 @@ function stripOrphanedReasoning(messages) {
|
|
|
293
281
|
// src/sync.ts
|
|
294
282
|
function syncBlocks(messages, state) {
|
|
295
283
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
296
|
-
const presentBases = /* @__PURE__ */ new Set();
|
|
297
|
-
for (const message of messages) presentBases.add(baseIdOf(message.id));
|
|
298
284
|
const deactivated = [];
|
|
299
285
|
const result = {
|
|
300
286
|
blocks: state.blocks.map((block) => ({
|
|
@@ -344,7 +330,7 @@ function syncBlocks(messages, state) {
|
|
|
344
330
|
continue;
|
|
345
331
|
}
|
|
346
332
|
block.active = true;
|
|
347
|
-
const stillPresent = block.effectiveMessageIds.some((id) =>
|
|
333
|
+
const stillPresent = block.effectiveMessageIds.some((id) => presentIds.has(id)) || presentIds.has(summaryMessageId(block.blockId));
|
|
348
334
|
if (!stillPresent) {
|
|
349
335
|
block.active = false;
|
|
350
336
|
deactivated.push(block.blockId);
|
|
@@ -496,20 +482,14 @@ function resolveBoundaries(input) {
|
|
|
496
482
|
);
|
|
497
483
|
}
|
|
498
484
|
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const base = baseIdOf(message.id);
|
|
503
|
-
const existing = baseIndexById.get(base);
|
|
504
|
-
if (existing === void 0 || index < existing)
|
|
505
|
-
baseIndexById.set(base, index);
|
|
506
|
-
});
|
|
485
|
+
input.messages.forEach(
|
|
486
|
+
(message, index) => indexByMessageId.set(message.id, index)
|
|
487
|
+
);
|
|
507
488
|
let snappedBoundaries = [];
|
|
508
489
|
const startAnchor = resolveAnchorIndex(
|
|
509
490
|
start,
|
|
510
491
|
input.state,
|
|
511
492
|
indexByMessageId,
|
|
512
|
-
baseIndexById,
|
|
513
493
|
"start"
|
|
514
494
|
);
|
|
515
495
|
if (startAnchor.snapped) snappedBoundaries.push(startAnchor.snapped);
|
|
@@ -517,7 +497,6 @@ function resolveBoundaries(input) {
|
|
|
517
497
|
end,
|
|
518
498
|
input.state,
|
|
519
499
|
indexByMessageId,
|
|
520
|
-
baseIndexById,
|
|
521
500
|
"end"
|
|
522
501
|
);
|
|
523
502
|
if (endAnchor.snapped) snappedBoundaries.push(endAnchor.snapped);
|
|
@@ -536,13 +515,7 @@ function resolveBoundaries(input) {
|
|
|
536
515
|
const nestedBlockIds = [];
|
|
537
516
|
const nestedSeen = /* @__PURE__ */ new Set();
|
|
538
517
|
for (const block of activeBlocks(input.state)) {
|
|
539
|
-
if (blockVisibleInRange(
|
|
540
|
-
block,
|
|
541
|
-
indexByMessageId,
|
|
542
|
-
startIndex,
|
|
543
|
-
endIndex,
|
|
544
|
-
baseIndexById
|
|
545
|
-
)) {
|
|
518
|
+
if (blockVisibleInRange(block, indexByMessageId, startIndex, endIndex)) {
|
|
546
519
|
if (!nestedSeen.has(block.blockId)) {
|
|
547
520
|
nestedSeen.add(block.blockId);
|
|
548
521
|
nestedBlockIds.push(block.blockId);
|
|
@@ -560,7 +533,7 @@ function resolveBoundaries(input) {
|
|
|
560
533
|
snappedBoundaries
|
|
561
534
|
};
|
|
562
535
|
}
|
|
563
|
-
function resolveAnchorIndex(boundary, state, indexByMessageId,
|
|
536
|
+
function resolveAnchorIndex(boundary, state, indexByMessageId, endpoint) {
|
|
564
537
|
const label = endpoint === "start" ? "startId" : "endId";
|
|
565
538
|
if (boundary.kind === "message") {
|
|
566
539
|
const rawId = state.messageRefs.byRef[boundary.raw] ?? state.messageRefs.byRef[formatPaddedRef(boundary.numericId)];
|
|
@@ -571,11 +544,11 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
571
544
|
`${label}="${boundary.raw}" does not exist in this session (typo or wrong session) \u2014 run acp_status for current refs.`
|
|
572
545
|
);
|
|
573
546
|
}
|
|
574
|
-
const index = indexByMessageId.get(rawId)
|
|
547
|
+
const index = indexByMessageId.get(rawId);
|
|
575
548
|
if (index !== void 0) {
|
|
576
549
|
return { index, snapped: null };
|
|
577
550
|
}
|
|
578
|
-
const owner2 = activeOwnerAnchor(state, [rawId], indexByMessageId
|
|
551
|
+
const owner2 = activeOwnerAnchor(state, [rawId], indexByMessageId);
|
|
579
552
|
if (owner2 !== null) {
|
|
580
553
|
return {
|
|
581
554
|
index: owner2,
|
|
@@ -597,7 +570,7 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
597
570
|
);
|
|
598
571
|
}
|
|
599
572
|
if (block.active) {
|
|
600
|
-
const anchor = visibleBlockAnchor(block, indexByMessageId
|
|
573
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
601
574
|
if (anchor !== null) {
|
|
602
575
|
return { index: anchor, snapped: null };
|
|
603
576
|
}
|
|
@@ -605,8 +578,7 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
605
578
|
const owner = activeOwnerAnchor(
|
|
606
579
|
state,
|
|
607
580
|
block.effectiveMessageIds,
|
|
608
|
-
indexByMessageId
|
|
609
|
-
baseIndexById
|
|
581
|
+
indexByMessageId
|
|
610
582
|
);
|
|
611
583
|
if (owner !== null) {
|
|
612
584
|
return {
|
|
@@ -627,10 +599,9 @@ function resolveAnchorIndex(boundary, state, indexByMessageId, baseIndexById, en
|
|
|
627
599
|
`${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.`
|
|
628
600
|
);
|
|
629
601
|
}
|
|
630
|
-
function activeOwnerAnchor(state, ownedIds, indexByMessageId
|
|
602
|
+
function activeOwnerAnchor(state, ownedIds, indexByMessageId) {
|
|
631
603
|
if (ownedIds.length === 0) return null;
|
|
632
|
-
const owned =
|
|
633
|
-
for (const id of ownedIds) owned.add(baseIdOf(id));
|
|
604
|
+
const owned = new Set(ownedIds);
|
|
634
605
|
let best = null;
|
|
635
606
|
for (const block of state.blocks) {
|
|
636
607
|
if (!block.active) continue;
|
|
@@ -643,7 +614,7 @@ function activeOwnerAnchor(state, ownedIds, indexByMessageId, baseIndexById) {
|
|
|
643
614
|
}
|
|
644
615
|
}
|
|
645
616
|
if (!ownsInherited) continue;
|
|
646
|
-
const anchor = visibleBlockAnchor(block, indexByMessageId
|
|
617
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
647
618
|
if (anchor === null) continue;
|
|
648
619
|
if (best === null || anchor < best) {
|
|
649
620
|
best = anchor;
|
|
@@ -656,54 +627,39 @@ function inheritedContentIds(state, block) {
|
|
|
656
627
|
for (const childId of block.directBlockIds) {
|
|
657
628
|
const child = blockById(state, childId);
|
|
658
629
|
if (!child) continue;
|
|
659
|
-
for (const id of child.effectiveMessageIds) ids.add(
|
|
630
|
+
for (const id of child.effectiveMessageIds) ids.add(id);
|
|
660
631
|
}
|
|
661
632
|
return ids;
|
|
662
633
|
}
|
|
663
634
|
function formatPaddedRef(index) {
|
|
664
635
|
return `m${String(index).padStart(5, "0")}`;
|
|
665
636
|
}
|
|
666
|
-
function visibleBlockAnchor(block, indexByMessageId
|
|
637
|
+
function visibleBlockAnchor(block, indexByMessageId) {
|
|
667
638
|
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
668
639
|
if (summaryIndex !== void 0) return summaryIndex;
|
|
669
|
-
return earliestIndexOfIds(
|
|
670
|
-
block.effectiveMessageIds,
|
|
671
|
-
indexByMessageId,
|
|
672
|
-
baseIndexById
|
|
673
|
-
);
|
|
640
|
+
return earliestIndexOfIds(block.effectiveMessageIds, indexByMessageId);
|
|
674
641
|
}
|
|
675
|
-
function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex
|
|
642
|
+
function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex) {
|
|
676
643
|
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
677
644
|
if (summaryIndex !== void 0 && summaryIndex >= startIndex && summaryIndex <= endIndex) {
|
|
678
645
|
return true;
|
|
679
646
|
}
|
|
680
647
|
const rawIndex = earliestIndexOfIds(
|
|
681
648
|
block.effectiveMessageIds,
|
|
682
|
-
indexByMessageId
|
|
683
|
-
baseIndexById
|
|
649
|
+
indexByMessageId
|
|
684
650
|
);
|
|
685
651
|
return rawIndex !== null && rawIndex >= startIndex && rawIndex <= endIndex;
|
|
686
652
|
}
|
|
687
|
-
function earliestIndexOfIds(ids, indexByMessageId
|
|
688
|
-
const baseIndex = baseIndexById ?? deriveBaseIndex(indexByMessageId);
|
|
653
|
+
function earliestIndexOfIds(ids, indexByMessageId) {
|
|
689
654
|
let earliest = null;
|
|
690
655
|
for (const id of ids) {
|
|
691
|
-
const index =
|
|
656
|
+
const index = indexByMessageId.get(id);
|
|
692
657
|
if (index !== void 0 && (earliest === null || index < earliest)) {
|
|
693
658
|
earliest = index;
|
|
694
659
|
}
|
|
695
660
|
}
|
|
696
661
|
return earliest;
|
|
697
662
|
}
|
|
698
|
-
function deriveBaseIndex(indexByMessageId) {
|
|
699
|
-
const baseIndex = /* @__PURE__ */ new Map();
|
|
700
|
-
for (const [id, index] of indexByMessageId) {
|
|
701
|
-
const base = baseIdOf(id);
|
|
702
|
-
const existing = baseIndex.get(base);
|
|
703
|
-
if (existing === void 0 || index < existing) baseIndex.set(base, index);
|
|
704
|
-
}
|
|
705
|
-
return baseIndex;
|
|
706
|
-
}
|
|
707
663
|
|
|
708
664
|
// src/truncate-tools.ts
|
|
709
665
|
var TRUNCATION_MARKER = "[truncated for context space]";
|
|
@@ -2235,26 +2191,20 @@ function estimateTextTokens(text) {
|
|
|
2235
2191
|
function isToolMessage(message) {
|
|
2236
2192
|
return message.contentType === "tool-call" || message.contentType === "tool-result";
|
|
2237
2193
|
}
|
|
2238
|
-
function
|
|
2239
|
-
|
|
2194
|
+
function isSyntheticOrPruned(message, state) {
|
|
2195
|
+
if (message.text?.startsWith("[Compressed conversation section]")) return true;
|
|
2240
2196
|
for (const block of state.blocks) {
|
|
2241
|
-
if (
|
|
2242
|
-
for (const id of block.effectiveMessageIds) covered.add(baseIdOf(id));
|
|
2197
|
+
if (block.active && block.effectiveMessageIds.includes(message.id)) return true;
|
|
2243
2198
|
}
|
|
2244
|
-
return
|
|
2245
|
-
}
|
|
2246
|
-
function isSyntheticOrPruned(message, coveredBases) {
|
|
2247
|
-
if (message.text?.startsWith("[Compressed conversation section]")) return true;
|
|
2248
|
-
return coveredBases.has(baseIdOf(message.id));
|
|
2199
|
+
return false;
|
|
2249
2200
|
}
|
|
2250
2201
|
function computeProtectedRefs(messages, state, config, countTokens = estimateTextTokens) {
|
|
2251
2202
|
const preserveN = config.preserveRecentMessages;
|
|
2252
2203
|
const preserveTokens = config.preserveRecentTokens;
|
|
2253
2204
|
const result = /* @__PURE__ */ new Set();
|
|
2254
2205
|
const visible = [];
|
|
2255
|
-
const coveredBases = activeBlockCoveredBases(state);
|
|
2256
2206
|
for (const msg of messages) {
|
|
2257
|
-
if (isSyntheticOrPruned(msg,
|
|
2207
|
+
if (isSyntheticOrPruned(msg, state)) continue;
|
|
2258
2208
|
if (isNeverPreserveRecent(msg)) continue;
|
|
2259
2209
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
2260
2210
|
if (!ref || ref === "BLOCKED") continue;
|
|
@@ -2275,7 +2225,7 @@ function computeProtectedRefs(messages, state, config, countTokens = estimateTex
|
|
|
2275
2225
|
if (preserveN > 0) {
|
|
2276
2226
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2277
2227
|
const msg = messages[i];
|
|
2278
|
-
if (msg.role !== "user" || isSyntheticOrPruned(msg,
|
|
2228
|
+
if (msg.role !== "user" || isSyntheticOrPruned(msg, state)) continue;
|
|
2279
2229
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
2280
2230
|
if (ref && ref !== "BLOCKED") result.add(ref);
|
|
2281
2231
|
break;
|
|
@@ -2292,12 +2242,11 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
2292
2242
|
let skipSinceCompressible = false;
|
|
2293
2243
|
let skipSinceProtected = false;
|
|
2294
2244
|
let msgIndex = -1;
|
|
2295
|
-
const coveredBases = activeBlockCoveredBases(state);
|
|
2296
2245
|
for (const msg of messages) {
|
|
2297
2246
|
msgIndex++;
|
|
2298
2247
|
const ref = state.messageRefs.byRaw[msg.id];
|
|
2299
2248
|
if (!ref || ref === "BLOCKED") continue;
|
|
2300
|
-
if (isSyntheticOrPruned(msg,
|
|
2249
|
+
if (isSyntheticOrPruned(msg, state)) {
|
|
2301
2250
|
skipSinceCompressible = true;
|
|
2302
2251
|
skipSinceProtected = true;
|
|
2303
2252
|
continue;
|
|
@@ -2498,22 +2447,16 @@ function refGateDiagnostics(state, requestedRanges, unknownCount) {
|
|
|
2498
2447
|
}
|
|
2499
2448
|
function danglingMessageRefs(state, messages, spec) {
|
|
2500
2449
|
const visible = new Set(messages.map((m) => m.id));
|
|
2501
|
-
const visibleBases = /* @__PURE__ */ new Set();
|
|
2502
|
-
for (const id of visible) visibleBases.add(baseIdOf(id));
|
|
2503
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
2504
|
-
for (const block of state.blocks) {
|
|
2505
|
-
if (!block.active) continue;
|
|
2506
|
-
for (const id of block.effectiveMessageIds) coveredBases.add(baseIdOf(id));
|
|
2507
|
-
}
|
|
2508
2450
|
const dangling = [];
|
|
2509
2451
|
for (const ref of [spec.startRef, spec.endRef]) {
|
|
2510
2452
|
const parsed = parseBoundary(ref);
|
|
2511
2453
|
if (!parsed || parsed.kind !== "message") continue;
|
|
2512
2454
|
const rawId = state.messageRefs.byRef[parsed.raw] ?? state.messageRefs.byRef[indexToRef(parsed.numericId)];
|
|
2513
|
-
if (!rawId) continue;
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2516
|
-
|
|
2455
|
+
if (!rawId || visible.has(rawId)) continue;
|
|
2456
|
+
const covered = state.blocks.some(
|
|
2457
|
+
(block) => block.active && block.effectiveMessageIds.includes(rawId)
|
|
2458
|
+
);
|
|
2459
|
+
if (!covered) dangling.push(parsed.raw);
|
|
2517
2460
|
}
|
|
2518
2461
|
return dangling;
|
|
2519
2462
|
}
|
|
@@ -3020,25 +2963,13 @@ function applySingleRange(input) {
|
|
|
3020
2963
|
);
|
|
3021
2964
|
if (rangeMessageIds.length > resolved.messageIds.length) {
|
|
3022
2965
|
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
3023
|
-
|
|
3024
|
-
input.messages.forEach((m, i) => {
|
|
3025
|
-
indexByMessageId.set(m.id, i);
|
|
3026
|
-
const base = baseIdOf(m.id);
|
|
3027
|
-
const existing = baseIndexById.get(base);
|
|
3028
|
-
if (existing === void 0 || i < existing) baseIndexById.set(base, i);
|
|
3029
|
-
});
|
|
2966
|
+
input.messages.forEach((m, i) => indexByMessageId.set(m.id, i));
|
|
3030
2967
|
const adjustedStart = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[0]) ?? resolved.startIndex : resolved.startIndex;
|
|
3031
2968
|
const adjustedEnd = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[rangeMessageIds.length - 1]) ?? resolved.endIndex : resolved.endIndex;
|
|
3032
2969
|
const nestedSeen = new Set(resolved.nestedBlockIds);
|
|
3033
2970
|
for (const block2 of activeBlocks(input.state)) {
|
|
3034
2971
|
if (nestedSeen.has(block2.blockId)) continue;
|
|
3035
|
-
if (blockVisibleInRange(
|
|
3036
|
-
block2,
|
|
3037
|
-
indexByMessageId,
|
|
3038
|
-
adjustedStart,
|
|
3039
|
-
adjustedEnd,
|
|
3040
|
-
baseIndexById
|
|
3041
|
-
)) {
|
|
2972
|
+
if (blockVisibleInRange(block2, indexByMessageId, adjustedStart, adjustedEnd)) {
|
|
3042
2973
|
nestedSeen.add(block2.blockId);
|
|
3043
2974
|
resolved.nestedBlockIds.push(block2.blockId);
|
|
3044
2975
|
}
|
|
@@ -3064,7 +2995,7 @@ function applySingleRange(input) {
|
|
|
3064
2995
|
}
|
|
3065
2996
|
}
|
|
3066
2997
|
const directMessageIds = [...effectiveMessageIds].filter(
|
|
3067
|
-
(id) => !input.preExistingCoverage.has(
|
|
2998
|
+
(id) => !input.preExistingCoverage.has(id)
|
|
3068
2999
|
);
|
|
3069
3000
|
let filteredIds = filterProtectedToolMessages(
|
|
3070
3001
|
directMessageIds,
|
|
@@ -3270,7 +3201,7 @@ function resolveTargetTier(state, nestedBlockIds, isBlockBoundary) {
|
|
|
3270
3201
|
function collectCoverage(state) {
|
|
3271
3202
|
const coverage = /* @__PURE__ */ new Set();
|
|
3272
3203
|
for (const block of activeBlocks(state)) {
|
|
3273
|
-
for (const id of block.effectiveMessageIds) coverage.add(
|
|
3204
|
+
for (const id of block.effectiveMessageIds) coverage.add(id);
|
|
3274
3205
|
}
|
|
3275
3206
|
return coverage;
|
|
3276
3207
|
}
|
|
@@ -3785,12 +3716,10 @@ function parseBlockIdArg(arg) {
|
|
|
3785
3716
|
}
|
|
3786
3717
|
function findBlocksOverlappingMessages(state, messageIds) {
|
|
3787
3718
|
if (messageIds.size === 0) return [];
|
|
3788
|
-
const messageBases = /* @__PURE__ */ new Set();
|
|
3789
|
-
for (const id of messageIds) messageBases.add(baseIdOf(id));
|
|
3790
3719
|
const matched = [];
|
|
3791
3720
|
for (const block of state.blocks) {
|
|
3792
3721
|
if (!block.active) continue;
|
|
3793
|
-
if (block.effectiveMessageIds.some((id) =>
|
|
3722
|
+
if (block.effectiveMessageIds.some((id) => messageIds.has(id))) {
|
|
3794
3723
|
matched.push(block);
|
|
3795
3724
|
}
|
|
3796
3725
|
}
|
|
@@ -3847,15 +3776,13 @@ function deactivateBlock(state, blockIds, options = {}) {
|
|
|
3847
3776
|
return { ...state, blocks: final };
|
|
3848
3777
|
}
|
|
3849
3778
|
function buildRestoredContentPreview(messages, beforeActiveMessageIds, state) {
|
|
3850
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
3851
|
-
for (const b of state.blocks) {
|
|
3852
|
-
if (!b.active) continue;
|
|
3853
|
-
for (const id of b.effectiveMessageIds) coveredBases.add(baseIdOf(id));
|
|
3854
|
-
}
|
|
3855
3779
|
const restored = [];
|
|
3856
3780
|
for (const message of messages) {
|
|
3857
3781
|
if (!beforeActiveMessageIds.has(message.id)) continue;
|
|
3858
|
-
|
|
3782
|
+
const stillCovered = state.blocks.some(
|
|
3783
|
+
(b) => b.active && b.effectiveMessageIds.includes(message.id)
|
|
3784
|
+
);
|
|
3785
|
+
if (!stillCovered) restored.push(message);
|
|
3859
3786
|
}
|
|
3860
3787
|
if (restored.length === 0) return { preview: "", restoredCount: 0 };
|
|
3861
3788
|
const lines = [];
|
|
@@ -3874,10 +3801,9 @@ function buildRestoredContentPreview(messages, beforeActiveMessageIds, state) {
|
|
|
3874
3801
|
}
|
|
3875
3802
|
function collectBlockContent(state, block, messages, options = {}) {
|
|
3876
3803
|
const full = options.full ?? false;
|
|
3877
|
-
const
|
|
3878
|
-
for (const id of block.effectiveMessageIds) targetBases.add(baseIdOf(id));
|
|
3804
|
+
const targetIds = new Set(block.effectiveMessageIds);
|
|
3879
3805
|
if (full) {
|
|
3880
|
-
const msgs = messages.filter((m) =>
|
|
3806
|
+
const msgs = messages.filter((m) => targetIds.has(m.id));
|
|
3881
3807
|
if (msgs.length === 0) return { text: "", count: 0 };
|
|
3882
3808
|
return { text: msgs.map(formatMessage).join("\n\n"), count: msgs.length };
|
|
3883
3809
|
}
|
|
@@ -3887,7 +3813,7 @@ function collectBlockContent(state, block, messages, options = {}) {
|
|
|
3887
3813
|
const child = state.blocks.find((b) => b.blockId === childId);
|
|
3888
3814
|
if (!child?.active) continue;
|
|
3889
3815
|
nestedChildren.push(child);
|
|
3890
|
-
for (const id of child.effectiveMessageIds) nestedCovered.add(
|
|
3816
|
+
for (const id of child.effectiveMessageIds) nestedCovered.add(id);
|
|
3891
3817
|
}
|
|
3892
3818
|
const parts = [];
|
|
3893
3819
|
for (const child of nestedChildren) {
|
|
@@ -3897,8 +3823,7 @@ ${child.summary}`);
|
|
|
3897
3823
|
}
|
|
3898
3824
|
let directCount = 0;
|
|
3899
3825
|
for (const m of messages) {
|
|
3900
|
-
|
|
3901
|
-
if (targetBases.has(base) && !nestedCovered.has(base)) {
|
|
3826
|
+
if (targetIds.has(m.id) && !nestedCovered.has(m.id)) {
|
|
3902
3827
|
parts.push(formatMessage(m));
|
|
3903
3828
|
directCount++;
|
|
3904
3829
|
}
|
|
@@ -3960,7 +3885,7 @@ function collectVisible(messages, state, countTokens) {
|
|
|
3960
3885
|
const coveredIds = /* @__PURE__ */ new Set();
|
|
3961
3886
|
for (const block of state.blocks) {
|
|
3962
3887
|
if (!block.active) continue;
|
|
3963
|
-
for (const id of block.effectiveMessageIds) coveredIds.add(
|
|
3888
|
+
for (const id of block.effectiveMessageIds) coveredIds.add(id);
|
|
3964
3889
|
}
|
|
3965
3890
|
let summaryTokens = 0;
|
|
3966
3891
|
for (const block of state.blocks) {
|
|
@@ -3974,7 +3899,7 @@ function collectVisible(messages, state, countTokens) {
|
|
|
3974
3899
|
}
|
|
3975
3900
|
}
|
|
3976
3901
|
messages.forEach((message, index) => {
|
|
3977
|
-
if (coveredIds.has(
|
|
3902
|
+
if (coveredIds.has(message.id)) return;
|
|
3978
3903
|
const ref = refForRaw(state.messageRefs, message.id);
|
|
3979
3904
|
if (!ref) return;
|
|
3980
3905
|
const tokens = countMessageTokens(message, countTokens);
|
|
@@ -5775,7 +5700,6 @@ export {
|
|
|
5775
5700
|
applyMessageFilters,
|
|
5776
5701
|
applySectionOverrides,
|
|
5777
5702
|
assignRefs,
|
|
5778
|
-
baseIdOf,
|
|
5779
5703
|
blockById,
|
|
5780
5704
|
blockDocs,
|
|
5781
5705
|
blockVisibleInRange,
|
|
@@ -5830,7 +5754,6 @@ export {
|
|
|
5830
5754
|
highestUsedIndex,
|
|
5831
5755
|
indexToRef,
|
|
5832
5756
|
isAbsorbCandidate,
|
|
5833
|
-
isCovered,
|
|
5834
5757
|
isMessageLatestProtected,
|
|
5835
5758
|
isMessageProtected,
|
|
5836
5759
|
isRenderedSummaryMessage,
|