acp-kernel 0.0.55-pr.206.58 → 0.0.55-pr.208.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/index.js CHANGED
@@ -1648,10 +1648,6 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
1648
1648
  }
1649
1649
 
1650
1650
  // src/recommend.ts
1651
- function refNum(ref) {
1652
- const n = parseInt(ref.slice(1), 10);
1653
- return Number.isNaN(n) ? -1 : n;
1654
- }
1655
1651
  function estimateTextTokens(text) {
1656
1652
  return Math.ceil(text.length / 4);
1657
1653
  }
@@ -1704,42 +1700,53 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1704
1700
  const compressibleMsgs = [];
1705
1701
  const protectedMsgs = [];
1706
1702
  const protectedCallIds = collectProtectedToolCallIds(messages, config);
1703
+ let pendingGapC = false;
1704
+ let pendingGapP = false;
1707
1705
  for (const msg of messages) {
1708
- if (isSyntheticOrPruned(msg, state)) continue;
1709
1706
  const ref = state.messageRefs.byRaw[msg.id];
1707
+ if (isSyntheticOrPruned(msg, state)) {
1708
+ if (ref && ref !== "BLOCKED") {
1709
+ pendingGapC = true;
1710
+ pendingGapP = true;
1711
+ }
1712
+ continue;
1713
+ }
1710
1714
  if (!ref || ref === "BLOCKED") continue;
1711
- const rn = refNum(ref);
1712
1715
  if (isMessageProtectedWithPairing(msg, config, protectedCallIds)) {
1713
1716
  protectedMsgs.push({
1714
1717
  ref,
1715
- refNum: rn,
1718
+ gapBefore: pendingGapP,
1716
1719
  tokens: countTokens(msg.text ?? ""),
1717
1720
  tools: msg.toolName ? [msg.toolName] : []
1718
1721
  });
1722
+ pendingGapC = true;
1723
+ pendingGapP = false;
1719
1724
  continue;
1720
1725
  }
1721
1726
  if (protectedZoneRefs?.has(ref)) {
1727
+ pendingGapC = true;
1728
+ pendingGapP = true;
1722
1729
  continue;
1723
1730
  }
1724
1731
  compressibleMsgs.push({
1725
1732
  ref,
1726
- refNum: rn,
1733
+ gapBefore: pendingGapC,
1727
1734
  tokens: countTokens(msg.text ?? ""),
1728
1735
  chars: (msg.text ?? "").length,
1729
1736
  isTool: isToolMessage(msg),
1730
1737
  isUser: msg.role === "user"
1731
1738
  });
1739
+ pendingGapC = false;
1740
+ pendingGapP = true;
1732
1741
  }
1733
1742
  const compressible = [];
1734
1743
  let cur = null;
1735
- let prevRefNum = -2;
1736
1744
  for (const info of compressibleMsgs) {
1737
- const hasGap = info.refNum > prevRefNum + 1;
1745
+ const hasGap = info.gapBefore;
1738
1746
  if (cur && (info.isUser && cur.count >= 3 || hasGap)) {
1739
1747
  compressible.push(cur);
1740
1748
  cur = null;
1741
1749
  }
1742
- prevRefNum = info.refNum;
1743
1750
  if (!cur) {
1744
1751
  cur = {
1745
1752
  startRef: info.ref,
@@ -1766,14 +1773,12 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1766
1773
  if (cur) compressible.push(cur);
1767
1774
  const protectedRanges = [];
1768
1775
  let pcur = null;
1769
- let pPrevRefNum = -2;
1770
1776
  for (const info of protectedMsgs) {
1771
- const hasGap = info.refNum > pPrevRefNum + 1;
1777
+ const hasGap = info.gapBefore;
1772
1778
  if (pcur && hasGap) {
1773
1779
  protectedRanges.push(pcur);
1774
1780
  pcur = null;
1775
1781
  }
1776
- pPrevRefNum = info.refNum;
1777
1782
  if (!pcur) {
1778
1783
  pcur = {
1779
1784
  startRef: info.ref,
@@ -3043,7 +3048,7 @@ function renderUncompressedRanges(visible) {
3043
3048
  lines.push(" (no uncompressed messages)");
3044
3049
  return lines.join("\n");
3045
3050
  }
3046
- const refNum2 = (ref) => {
3051
+ const refNum = (ref) => {
3047
3052
  const m = ref.match(/\d+/);
3048
3053
  return m ? parseInt(m[0], 10) : 0;
3049
3054
  };
@@ -3060,7 +3065,7 @@ function renderUncompressedRanges(visible) {
3060
3065
  };
3061
3066
  const merged = [];
3062
3067
  for (const m of visible) {
3063
- const num = refNum2(m.ref);
3068
+ const num = refNum(m.ref);
3064
3069
  const last = merged[merged.length - 1];
3065
3070
  if (last && num === last.startNum + last.count) {
3066
3071
  last.endRef = m.ref;