acp-kernel 0.0.59-pr.235.82 → 0.0.60-pr.236.83

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.
@@ -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>, baseIndexById?: Map<string, number>): number | null;
46
- export declare function blockVisibleInRange(block: CompressionBlock, indexByMessageId: Map<string, number>, startIndex: number, endIndex: number, baseIndexById?: Map<string, number>): boolean;
47
- export declare function earliestIndexOfIds(ids: string[], indexByMessageId: Map<string, number>, baseIndexById?: Map<string, number>): number | null;
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
@@ -1 +1 @@
1
- {"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAMA,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,qBA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AAC;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"}
@@ -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;AA8BD,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,GACxB,kBAAkB,CAmFpB"}
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;AA8FD,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,GACxB,kBAAkB,CAwFpB"}
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, baseIdOf, isCovered, SUMMARY_HEADER, summaryMessageId, isSummaryMessageId, isRenderedSummaryMessage, } from "./prune.js";
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";
@@ -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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pB,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,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"}
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,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL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AkB,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 baseIndexById = /* @__PURE__ */ new Map();
120
+ const indexById = /* @__PURE__ */ new Map();
130
121
  const summaryIndexById = /* @__PURE__ */ new Map();
131
122
  messages.forEach((message, index) => {
132
- const base = baseIdOf(message.id);
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, baseIndexById, summaryIndexById) : [];
127
+ const anchors = inject ? collectSummaryAnchors(state, indexById, summaryIndexById) : [];
140
128
  return stripOrphanedReasoning(
141
129
  stripOrphanedToolResults(
142
130
  stripOrphanedToolCalls(
143
- rebuildMessages(messages, coveredBases, firstUserIndex, anchors)
131
+ rebuildMessages(messages, covered, firstUserIndex, anchors)
144
132
  )
145
133
  )
146
134
  );
147
135
  }
148
- function collectSummaryAnchors(state, baseIndexById, summaryIndexById) {
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 = baseIndexById.get(baseIdOf(id));
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, coveredBases, firstUserIndex, anchors) {
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 (isCovered(messages[index].id, coveredBases)) continue;
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) => presentBases.has(baseIdOf(id))) || presentIds.has(summaryMessageId(block.blockId));
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
- const baseIndexById = /* @__PURE__ */ new Map();
447
- input.messages.forEach((message, index) => {
448
- indexByMessageId.set(message.id, index);
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, baseIndexById, endpoint) {
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) ?? baseIndexById.get(baseIdOf(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, baseIndexById);
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, baseIndexById);
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, baseIndexById) {
549
+ function activeOwnerAnchor(state, ownedIds, indexByMessageId) {
578
550
  if (ownedIds.length === 0) return null;
579
- const owned = /* @__PURE__ */ new Set();
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, baseIndexById);
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(baseIdOf(id));
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, baseIndexById) {
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, baseIndexById) {
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, baseIndexById) {
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 = baseIndex.get(baseIdOf(id));
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]";
@@ -710,25 +666,71 @@ var KEEP_LAST_ORPHANED = 2;
710
666
  function rangeKey(startRef, endRef) {
711
667
  return `${startRef}::${endRef}`;
712
668
  }
713
- function rewriteCompressText(text, liveKeys) {
669
+ function parseCallText(text) {
670
+ const raw = text ?? "";
671
+ const start = raw.indexOf("{");
672
+ if (start < 0) return null;
714
673
  let parsed;
715
674
  try {
716
- parsed = JSON.parse(text ?? "");
675
+ parsed = JSON.parse(raw.slice(start));
717
676
  } catch {
718
677
  return null;
719
678
  }
720
679
  if (!parsed || typeof parsed !== "object") return null;
721
680
  const obj = parsed;
722
- const content = obj.content;
723
- if (!Array.isArray(content) || content.length === 0) return null;
681
+ let content = null;
682
+ let contentWasString = false;
683
+ if (Array.isArray(obj.content)) {
684
+ content = obj.content;
685
+ } else if (typeof obj.content === "string") {
686
+ contentWasString = true;
687
+ try {
688
+ const inner = JSON.parse(obj.content);
689
+ if (Array.isArray(inner)) content = inner;
690
+ } catch {
691
+ content = null;
692
+ }
693
+ }
694
+ if (!content || content.length === 0) return null;
695
+ return { prefix: raw.slice(0, start), obj, content, contentWasString };
696
+ }
697
+ function rewriteCompressText(text, liveKeys) {
698
+ const parsed = parseCallText(text);
699
+ if (!parsed) return null;
700
+ const { prefix, obj, content, contentWasString } = parsed;
724
701
  const kept = content.filter((entry) => {
725
702
  if (!entry || typeof entry !== "object") return false;
726
- const s = typeof entry.startId === "string" ? entry.startId : typeof entry.messageId === "string" ? entry.messageId : "";
727
- const e = typeof entry.endId === "string" ? entry.endId : typeof entry.messageId === "string" ? entry.messageId : "";
728
- return liveKeys.has(rangeKey(s, e));
703
+ const e = entry;
704
+ const s = typeof e.startId === "string" ? e.startId : typeof e.messageId === "string" ? e.messageId : "";
705
+ const end = typeof e.endId === "string" ? e.endId : typeof e.messageId === "string" ? e.messageId : "";
706
+ return liveKeys.has(rangeKey(s, end));
729
707
  });
730
- if (kept.length === content.length || kept.length === 0) return null;
731
- return JSON.stringify({ ...obj, content: kept });
708
+ if (kept.length === 0) return null;
709
+ return prefix + serializeCompacted(obj, kept, contentWasString).text;
710
+ }
711
+ var SUMMARY_STUB_CHARS = 200;
712
+ function compactEntry(entry) {
713
+ if (!entry || typeof entry !== "object") return entry;
714
+ const e = entry;
715
+ if (typeof e.summary !== "string" || e.summary.length <= SUMMARY_STUB_CHARS) return entry;
716
+ return { ...e, summary: `${e.summary.slice(0, SUMMARY_STUB_CHARS - 1)}\u2026` };
717
+ }
718
+ function serializeCompacted(obj, content, contentWasString) {
719
+ let changed = false;
720
+ const compacted = content.map((entry) => {
721
+ const out = compactEntry(entry);
722
+ if (out !== entry) changed = true;
723
+ return out;
724
+ });
725
+ const outContent = contentWasString ? JSON.stringify(compacted) : compacted;
726
+ return { text: JSON.stringify({ ...obj, content: outContent }), changed };
727
+ }
728
+ function compactCompressText(text) {
729
+ const parsed = parseCallText(text);
730
+ if (!parsed) return null;
731
+ const { prefix, obj, content, contentWasString } = parsed;
732
+ const { text: out, changed } = serializeCompacted(obj, content, contentWasString);
733
+ return changed ? prefix + out : null;
732
734
  }
733
735
  function hideConsumedCompressCalls(state, messages) {
734
736
  const allBlockCallIds = /* @__PURE__ */ new Set();
@@ -787,6 +789,11 @@ function hideConsumedCompressCalls(state, messages) {
787
789
  continue;
788
790
  }
789
791
  }
792
+ const compacted = compactCompressText(message.text);
793
+ if (compacted !== null) {
794
+ result.push({ ...message, text: compacted });
795
+ continue;
796
+ }
790
797
  }
791
798
  result.push(message);
792
799
  }
@@ -1702,26 +1709,20 @@ function estimateTextTokens(text) {
1702
1709
  function isToolMessage(message) {
1703
1710
  return message.contentType === "tool-call" || message.contentType === "tool-result";
1704
1711
  }
1705
- function activeBlockCoveredBases(state) {
1706
- const covered = /* @__PURE__ */ new Set();
1712
+ function isSyntheticOrPruned(message, state) {
1713
+ if (message.text?.startsWith("[Compressed conversation section]")) return true;
1707
1714
  for (const block of state.blocks) {
1708
- if (!block.active) continue;
1709
- for (const id of block.effectiveMessageIds) covered.add(baseIdOf(id));
1715
+ if (block.active && block.effectiveMessageIds.includes(message.id)) return true;
1710
1716
  }
1711
- return covered;
1712
- }
1713
- function isSyntheticOrPruned(message, coveredBases) {
1714
- if (message.text?.startsWith("[Compressed conversation section]")) return true;
1715
- return coveredBases.has(baseIdOf(message.id));
1717
+ return false;
1716
1718
  }
1717
1719
  function computeProtectedRefs(messages, state, config, countTokens = estimateTextTokens) {
1718
1720
  const preserveN = config.preserveRecentMessages;
1719
1721
  const preserveTokens = config.preserveRecentTokens;
1720
1722
  const result = /* @__PURE__ */ new Set();
1721
1723
  const visible = [];
1722
- const coveredBases = activeBlockCoveredBases(state);
1723
1724
  for (const msg of messages) {
1724
- if (isSyntheticOrPruned(msg, coveredBases)) continue;
1725
+ if (isSyntheticOrPruned(msg, state)) continue;
1725
1726
  if (isNeverPreserveRecent(msg)) continue;
1726
1727
  const ref = state.messageRefs.byRaw[msg.id];
1727
1728
  if (!ref || ref === "BLOCKED") continue;
@@ -1742,7 +1743,7 @@ function computeProtectedRefs(messages, state, config, countTokens = estimateTex
1742
1743
  if (preserveN > 0) {
1743
1744
  for (let i = messages.length - 1; i >= 0; i--) {
1744
1745
  const msg = messages[i];
1745
- if (msg.role !== "user" || isSyntheticOrPruned(msg, coveredBases)) continue;
1746
+ if (msg.role !== "user" || isSyntheticOrPruned(msg, state)) continue;
1746
1747
  const ref = state.messageRefs.byRaw[msg.id];
1747
1748
  if (ref && ref !== "BLOCKED") result.add(ref);
1748
1749
  break;
@@ -1756,11 +1757,10 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1756
1757
  const protectedCallIds = collectProtectedToolCallIds(messages, config);
1757
1758
  let skipSinceCompressible = false;
1758
1759
  let skipSinceProtected = false;
1759
- const coveredBases = activeBlockCoveredBases(state);
1760
1760
  for (const msg of messages) {
1761
1761
  const ref = state.messageRefs.byRaw[msg.id];
1762
1762
  if (!ref || ref === "BLOCKED") continue;
1763
- if (isSyntheticOrPruned(msg, coveredBases)) {
1763
+ if (isSyntheticOrPruned(msg, state)) {
1764
1764
  skipSinceCompressible = true;
1765
1765
  skipSinceProtected = true;
1766
1766
  continue;
@@ -1927,22 +1927,16 @@ function refGateDiagnostics(state, requestedRanges, unknownCount) {
1927
1927
  }
1928
1928
  function danglingMessageRefs(state, messages, spec) {
1929
1929
  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
1930
  const dangling = [];
1938
1931
  for (const ref of [spec.startRef, spec.endRef]) {
1939
1932
  const parsed = parseBoundary(ref);
1940
1933
  if (!parsed || parsed.kind !== "message") continue;
1941
1934
  const rawId = state.messageRefs.byRef[parsed.raw] ?? state.messageRefs.byRef[indexToRef(parsed.numericId)];
1942
- if (!rawId) continue;
1943
- const base = baseIdOf(rawId);
1944
- if (visible.has(rawId) || visibleBases.has(base)) continue;
1945
- if (!coveredBases.has(base)) dangling.push(parsed.raw);
1935
+ if (!rawId || visible.has(rawId)) continue;
1936
+ const covered = state.blocks.some(
1937
+ (block) => block.active && block.effectiveMessageIds.includes(rawId)
1938
+ );
1939
+ if (!covered) dangling.push(parsed.raw);
1946
1940
  }
1947
1941
  return dangling;
1948
1942
  }
@@ -2361,25 +2355,13 @@ function applySingleRange(input) {
2361
2355
  ).filter((id) => !isSummaryMessageId(id));
2362
2356
  if (rangeMessageIds.length > resolved.messageIds.length) {
2363
2357
  const indexByMessageId = /* @__PURE__ */ new Map();
2364
- const baseIndexById = /* @__PURE__ */ new Map();
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
- });
2358
+ input.messages.forEach((m, i) => indexByMessageId.set(m.id, i));
2371
2359
  const adjustedStart = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[0]) ?? resolved.startIndex : resolved.startIndex;
2372
2360
  const adjustedEnd = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[rangeMessageIds.length - 1]) ?? resolved.endIndex : resolved.endIndex;
2373
2361
  const nestedSeen = new Set(resolved.nestedBlockIds);
2374
2362
  for (const block2 of activeBlocks(input.state)) {
2375
2363
  if (nestedSeen.has(block2.blockId)) continue;
2376
- if (blockVisibleInRange(
2377
- block2,
2378
- indexByMessageId,
2379
- adjustedStart,
2380
- adjustedEnd,
2381
- baseIndexById
2382
- )) {
2364
+ if (blockVisibleInRange(block2, indexByMessageId, adjustedStart, adjustedEnd)) {
2383
2365
  nestedSeen.add(block2.blockId);
2384
2366
  resolved.nestedBlockIds.push(block2.blockId);
2385
2367
  }
@@ -2405,7 +2387,7 @@ function applySingleRange(input) {
2405
2387
  }
2406
2388
  }
2407
2389
  const directMessageIds = [...effectiveMessageIds].filter(
2408
- (id) => !input.preExistingCoverage.has(baseIdOf(id))
2390
+ (id) => !input.preExistingCoverage.has(id)
2409
2391
  );
2410
2392
  let filteredIds = filterProtectedToolMessages(
2411
2393
  directMessageIds,
@@ -2585,7 +2567,7 @@ function resolveTargetTier(state, nestedBlockIds, isBlockBoundary) {
2585
2567
  function collectCoverage(state) {
2586
2568
  const coverage = /* @__PURE__ */ new Set();
2587
2569
  for (const block of activeBlocks(state)) {
2588
- for (const id of block.effectiveMessageIds) coverage.add(baseIdOf(id));
2570
+ for (const id of block.effectiveMessageIds) coverage.add(id);
2589
2571
  }
2590
2572
  return coverage;
2591
2573
  }
@@ -2846,12 +2828,10 @@ function parseBlockIdArg(arg) {
2846
2828
  }
2847
2829
  function findBlocksOverlappingMessages(state, messageIds) {
2848
2830
  if (messageIds.size === 0) return [];
2849
- const messageBases = /* @__PURE__ */ new Set();
2850
- for (const id of messageIds) messageBases.add(baseIdOf(id));
2851
2831
  const matched = [];
2852
2832
  for (const block of state.blocks) {
2853
2833
  if (!block.active) continue;
2854
- if (block.effectiveMessageIds.some((id) => messageBases.has(baseIdOf(id)))) {
2834
+ if (block.effectiveMessageIds.some((id) => messageIds.has(id))) {
2855
2835
  matched.push(block);
2856
2836
  }
2857
2837
  }
@@ -2908,15 +2888,13 @@ function deactivateBlock(state, blockIds, options = {}) {
2908
2888
  return { ...state, blocks: final };
2909
2889
  }
2910
2890
  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
2891
  const restored = [];
2917
2892
  for (const message of messages) {
2918
2893
  if (!beforeActiveMessageIds.has(message.id)) continue;
2919
- if (!coveredBases.has(baseIdOf(message.id))) restored.push(message);
2894
+ const stillCovered = state.blocks.some(
2895
+ (b) => b.active && b.effectiveMessageIds.includes(message.id)
2896
+ );
2897
+ if (!stillCovered) restored.push(message);
2920
2898
  }
2921
2899
  if (restored.length === 0) return { preview: "", restoredCount: 0 };
2922
2900
  const lines = [];
@@ -2935,10 +2913,9 @@ function buildRestoredContentPreview(messages, beforeActiveMessageIds, state) {
2935
2913
  }
2936
2914
  function collectBlockContent(state, block, messages, options = {}) {
2937
2915
  const full = options.full ?? false;
2938
- const targetBases = /* @__PURE__ */ new Set();
2939
- for (const id of block.effectiveMessageIds) targetBases.add(baseIdOf(id));
2916
+ const targetIds = new Set(block.effectiveMessageIds);
2940
2917
  if (full) {
2941
- const msgs = messages.filter((m) => targetBases.has(baseIdOf(m.id)));
2918
+ const msgs = messages.filter((m) => targetIds.has(m.id));
2942
2919
  if (msgs.length === 0) return { text: "", count: 0 };
2943
2920
  return { text: msgs.map(formatMessage).join("\n\n"), count: msgs.length };
2944
2921
  }
@@ -2948,7 +2925,7 @@ function collectBlockContent(state, block, messages, options = {}) {
2948
2925
  const child = state.blocks.find((b) => b.blockId === childId);
2949
2926
  if (!child?.active) continue;
2950
2927
  nestedChildren.push(child);
2951
- for (const id of child.effectiveMessageIds) nestedCovered.add(baseIdOf(id));
2928
+ for (const id of child.effectiveMessageIds) nestedCovered.add(id);
2952
2929
  }
2953
2930
  const parts = [];
2954
2931
  for (const child of nestedChildren) {
@@ -2958,8 +2935,7 @@ ${child.summary}`);
2958
2935
  }
2959
2936
  let directCount = 0;
2960
2937
  for (const m of messages) {
2961
- const base = baseIdOf(m.id);
2962
- if (targetBases.has(base) && !nestedCovered.has(base)) {
2938
+ if (targetIds.has(m.id) && !nestedCovered.has(m.id)) {
2963
2939
  parts.push(formatMessage(m));
2964
2940
  directCount++;
2965
2941
  }
@@ -3021,7 +2997,7 @@ function collectVisible(messages, state, countTokens) {
3021
2997
  const coveredIds = /* @__PURE__ */ new Set();
3022
2998
  for (const block of state.blocks) {
3023
2999
  if (!block.active) continue;
3024
- for (const id of block.effectiveMessageIds) coveredIds.add(baseIdOf(id));
3000
+ for (const id of block.effectiveMessageIds) coveredIds.add(id);
3025
3001
  }
3026
3002
  let summaryTokens = 0;
3027
3003
  for (const block of state.blocks) {
@@ -3035,7 +3011,7 @@ function collectVisible(messages, state, countTokens) {
3035
3011
  }
3036
3012
  }
3037
3013
  messages.forEach((message, index) => {
3038
- if (coveredIds.has(baseIdOf(message.id))) return;
3014
+ if (coveredIds.has(message.id)) return;
3039
3015
  const ref = refForRaw(state.messageRefs, message.id);
3040
3016
  if (!ref) return;
3041
3017
  const tokens = countTokens(message.text ?? "");
@@ -4135,7 +4111,6 @@ export {
4135
4111
  applyAbsorb,
4136
4112
  applyMessageFilters,
4137
4113
  assignRefs,
4138
- baseIdOf,
4139
4114
  blockById,
4140
4115
  blockDocs,
4141
4116
  blockVisibleInRange,
@@ -4174,7 +4149,6 @@ export {
4174
4149
  highestUsedIndex,
4175
4150
  indexToRef,
4176
4151
  isAbsorbCandidate,
4177
- isCovered,
4178
4152
  isMessageProtected,
4179
4153
  isRenderedSummaryMessage,
4180
4154
  isSummaryMessageId,