acp-kernel 0.0.62-pr.247.92 → 0.0.62
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/compress.d.ts.map +1 -1
- package/dist/index.js +2 -102
- package/dist/index.js.map +1 -1
- package/dist/reasoning-pairs.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/turn-integrity.d.ts +0 -23
- package/dist/turn-integrity.d.ts.map +0 -1
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAehF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAehF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,EAEN,WAAW,EAGX,iBAAiB,EAEjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACxD,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAAC;IACvE,YAAY,IAAI,YAAY,EAAE,CAAC;IAC/B,UAAU,CACR,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IACnE,MAAM,CACJ,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,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;AA2DD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAyU7D;AAy9BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1687,12 +1687,8 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
|
|
|
1687
1687
|
j++;
|
|
1688
1688
|
}
|
|
1689
1689
|
const companion = messages[j + 1];
|
|
1690
|
-
if (companion !== void 0 && companion.role === "assistant" && (companion.contentType === "text" || companion.contentType === "tool-call")) {
|
|
1691
|
-
|
|
1692
|
-
while (e + 1 < messages.length && messages[e + 1].role === "assistant" && (messages[e + 1].contentType === "text" || messages[e + 1].contentType === "tool-call")) {
|
|
1693
|
-
e++;
|
|
1694
|
-
}
|
|
1695
|
-
if (e > newEndIndex) newEndIndex = e;
|
|
1690
|
+
if (companion !== void 0 && companion.role === "assistant" && (companion.contentType === "text" || companion.contentType === "tool-call") && j + 1 > newEndIndex) {
|
|
1691
|
+
newEndIndex = j + 1;
|
|
1696
1692
|
}
|
|
1697
1693
|
}
|
|
1698
1694
|
if (msg.role === "assistant" && (msg.contentType === "text" || msg.contentType === "tool-call")) {
|
|
@@ -1709,66 +1705,6 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
|
|
|
1709
1705
|
return { startIndex: newStartIndex, endIndex: newEndIndex };
|
|
1710
1706
|
}
|
|
1711
1707
|
|
|
1712
|
-
// src/turn-integrity.ts
|
|
1713
|
-
function isAssistantAct(msg) {
|
|
1714
|
-
return msg.role === "assistant" && (msg.contentType === "text" || msg.contentType === "tool-call");
|
|
1715
|
-
}
|
|
1716
|
-
function computeTurnGroups(messages) {
|
|
1717
|
-
const resultIdByCallId = /* @__PURE__ */ new Map();
|
|
1718
|
-
for (const msg of messages) {
|
|
1719
|
-
if (msg.contentType === "tool-result" && typeof msg.toolCallId === "string" && msg.id) {
|
|
1720
|
-
if (!resultIdByCallId.has(msg.toolCallId))
|
|
1721
|
-
resultIdByCallId.set(msg.toolCallId, msg.id);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
const grouped = /* @__PURE__ */ new Set();
|
|
1725
|
-
const groups = [];
|
|
1726
|
-
for (let i = 0; i < messages.length; i++) {
|
|
1727
|
-
const msg = messages[i];
|
|
1728
|
-
if (!msg.id || grouped.has(msg.id)) continue;
|
|
1729
|
-
if (!(msg.contentType === "reasoning" || isAssistantAct(msg))) continue;
|
|
1730
|
-
let reasoningStart = i;
|
|
1731
|
-
if (msg.contentType === "reasoning") {
|
|
1732
|
-
while (reasoningStart > 0 && messages[reasoningStart - 1].contentType === "reasoning") {
|
|
1733
|
-
reasoningStart--;
|
|
1734
|
-
}
|
|
1735
|
-
} else {
|
|
1736
|
-
let s = i;
|
|
1737
|
-
while (s > 0 && isAssistantAct(messages[s - 1])) s--;
|
|
1738
|
-
reasoningStart = s;
|
|
1739
|
-
while (reasoningStart > 0 && messages[reasoningStart - 1].contentType === "reasoning") {
|
|
1740
|
-
reasoningStart--;
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
const burstStart = (() => {
|
|
1744
|
-
let s = reasoningStart;
|
|
1745
|
-
while (s < messages.length && messages[s].contentType === "reasoning")
|
|
1746
|
-
s++;
|
|
1747
|
-
return s;
|
|
1748
|
-
})();
|
|
1749
|
-
if (burstStart >= messages.length || !isAssistantAct(messages[burstStart])) {
|
|
1750
|
-
continue;
|
|
1751
|
-
}
|
|
1752
|
-
let burstEnd = burstStart;
|
|
1753
|
-
while (burstEnd + 1 < messages.length && isAssistantAct(messages[burstEnd + 1])) {
|
|
1754
|
-
burstEnd++;
|
|
1755
|
-
}
|
|
1756
|
-
const members = /* @__PURE__ */ new Set();
|
|
1757
|
-
for (let k = reasoningStart; k <= burstEnd; k++) {
|
|
1758
|
-
const m = messages[k];
|
|
1759
|
-
if (!m.id) continue;
|
|
1760
|
-
members.add(m.id);
|
|
1761
|
-
if (m.role === "assistant" && m.contentType === "tool-call" && typeof m.toolCallId === "string") {
|
|
1762
|
-
const rid = resultIdByCallId.get(m.toolCallId);
|
|
1763
|
-
if (rid) members.add(rid);
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
for (const id of members) grouped.add(id);
|
|
1767
|
-
groups.push([...members]);
|
|
1768
|
-
}
|
|
1769
|
-
return groups;
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
1708
|
// src/recommend.ts
|
|
1773
1709
|
function estimateTextTokens(text) {
|
|
1774
1710
|
return Math.ceil(text.length / 4);
|
|
@@ -2491,42 +2427,6 @@ function applySingleRange(input) {
|
|
|
2491
2427
|
)} from compression range (recent/last-user zone).`
|
|
2492
2428
|
);
|
|
2493
2429
|
}
|
|
2494
|
-
{
|
|
2495
|
-
const reasoningIds = /* @__PURE__ */ new Set();
|
|
2496
|
-
const callIds = /* @__PURE__ */ new Set();
|
|
2497
|
-
for (const m of input.messages) {
|
|
2498
|
-
if (!m.id) continue;
|
|
2499
|
-
if (m.contentType === "reasoning") reasoningIds.add(m.id);
|
|
2500
|
-
if (m.role === "assistant" && m.contentType === "tool-call") callIds.add(m.id);
|
|
2501
|
-
}
|
|
2502
|
-
const withdrawIds = /* @__PURE__ */ new Set();
|
|
2503
|
-
let splitTurnCount = 0;
|
|
2504
|
-
for (const group of computeTurnGroups(input.messages)) {
|
|
2505
|
-
const foldHasReasoning = group.some(
|
|
2506
|
-
(id) => effectiveMessageIds.has(id) && reasoningIds.has(id)
|
|
2507
|
-
);
|
|
2508
|
-
if (!foldHasReasoning) continue;
|
|
2509
|
-
const keptHasCall = group.some(
|
|
2510
|
-
(id) => !effectiveMessageIds.has(id) && callIds.has(id)
|
|
2511
|
-
);
|
|
2512
|
-
if (!keptHasCall) continue;
|
|
2513
|
-
splitTurnCount++;
|
|
2514
|
-
for (const id of group) withdrawIds.add(id);
|
|
2515
|
-
}
|
|
2516
|
-
if (withdrawIds.size > 0) {
|
|
2517
|
-
for (const id of withdrawIds) effectiveMessageIds.delete(id);
|
|
2518
|
-
const beforeWithdraw = filteredIds.length;
|
|
2519
|
-
filteredIds = filteredIds.filter((id) => !withdrawIds.has(id));
|
|
2520
|
-
if (filteredIds.length === 0 && consumedBlockIds.length === 0) {
|
|
2521
|
-
throw new Error(
|
|
2522
|
-
`Range would split ${splitTurnCount} turn(s) at the protected-zone boundary: a visible tool-call must keep its reasoning run (strict-echo providers reject a rebuilt request that lost it). Shrink the range to end before the turn starts, or wait until the whole turn ages out of the protected zone.`
|
|
2523
|
-
);
|
|
2524
|
-
}
|
|
2525
|
-
warnings.push(
|
|
2526
|
-
`Withdrawn ${beforeWithdraw - filteredIds.length} message(s) from compression range to keep ${splitTurnCount} turn(s) intact (visible tool-call would lose its reasoning run).`
|
|
2527
|
-
);
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
2430
|
if (!isBlockBoundary && filteredIds.length === 0 && consumedBlockIds.length > 0) {
|
|
2531
2431
|
const first = consumedBlockIds[0];
|
|
2532
2432
|
const last = consumedBlockIds[consumedBlockIds.length - 1];
|