acp-kernel 0.0.69-pr.292.155 → 0.0.69-pr.293.158
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 +59 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -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;AAgBhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUvD,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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sort((left, right) => left.insertAt - right.insertAt);
|
|
166
166
|
return anchors;
|
|
167
167
|
}
|
|
168
|
+
function pairSafeAnchorIndex(messages, index) {
|
|
169
|
+
const resultIndexByCallId = /* @__PURE__ */ new Map();
|
|
170
|
+
messages.forEach((message, at) => {
|
|
171
|
+
if (message.contentType !== "tool-result") return;
|
|
172
|
+
if (typeof message.toolCallId !== "string") return;
|
|
173
|
+
if (!resultIndexByCallId.has(message.toolCallId)) {
|
|
174
|
+
resultIndexByCallId.set(message.toolCallId, at);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
let safe = index;
|
|
178
|
+
for (let guard = 0; guard < messages.length; guard++) {
|
|
179
|
+
let moved = safe;
|
|
180
|
+
for (let at = 0; at < safe && at < messages.length; at++) {
|
|
181
|
+
const message = messages[at];
|
|
182
|
+
if (message.role !== "assistant") continue;
|
|
183
|
+
if (message.contentType !== "tool-call") continue;
|
|
184
|
+
if (typeof message.toolCallId !== "string") continue;
|
|
185
|
+
const resultIndex = resultIndexByCallId.get(message.toolCallId);
|
|
186
|
+
if (resultIndex !== void 0 && resultIndex >= safe && resultIndex + 1 > moved) {
|
|
187
|
+
moved = resultIndex + 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (moved === safe) break;
|
|
191
|
+
safe = moved;
|
|
192
|
+
}
|
|
193
|
+
return safe;
|
|
194
|
+
}
|
|
168
195
|
function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
196
|
+
const safeAnchors = anchors.map((anchor) => ({
|
|
197
|
+
...anchor,
|
|
198
|
+
insertAt: pairSafeAnchorIndex(messages, anchor.insertAt)
|
|
199
|
+
})).sort((left, right) => left.insertAt - right.insertAt);
|
|
169
200
|
const result = [];
|
|
170
|
-
const pending = [...
|
|
201
|
+
const pending = [...safeAnchors];
|
|
171
202
|
const anchoredSummaryIds = new Set(
|
|
172
203
|
anchors.map((anchor) => summaryMessageId(anchor.blockId))
|
|
173
204
|
);
|
|
@@ -2631,17 +2662,42 @@ function applySingleRange(input) {
|
|
|
2631
2662
|
splitTurnCount++;
|
|
2632
2663
|
for (const id of group) withdrawIds.add(id);
|
|
2633
2664
|
}
|
|
2665
|
+
const resultIdByCallId = /* @__PURE__ */ new Map();
|
|
2666
|
+
for (const m of input.messages) {
|
|
2667
|
+
if (!m.id || m.contentType !== "tool-result") continue;
|
|
2668
|
+
if (typeof m.toolCallId !== "string") continue;
|
|
2669
|
+
if (!resultIdByCallId.has(m.toolCallId)) {
|
|
2670
|
+
resultIdByCallId.set(m.toolCallId, m.id);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
let splitPairCount = 0;
|
|
2674
|
+
for (const m of input.messages) {
|
|
2675
|
+
if (!m.id || m.contentType !== "tool-call") continue;
|
|
2676
|
+
if (typeof m.toolCallId !== "string") continue;
|
|
2677
|
+
const resultId = resultIdByCallId.get(m.toolCallId);
|
|
2678
|
+
if (resultId === void 0) continue;
|
|
2679
|
+
if (effectiveMessageIds.has(m.id) === effectiveMessageIds.has(resultId)) {
|
|
2680
|
+
continue;
|
|
2681
|
+
}
|
|
2682
|
+
withdrawIds.add(m.id);
|
|
2683
|
+
withdrawIds.add(resultId);
|
|
2684
|
+
splitPairCount++;
|
|
2685
|
+
}
|
|
2634
2686
|
if (withdrawIds.size > 0) {
|
|
2635
2687
|
for (const id of withdrawIds) effectiveMessageIds.delete(id);
|
|
2636
2688
|
const beforeWithdraw = filteredIds.length;
|
|
2637
2689
|
filteredIds = filteredIds.filter((id) => !withdrawIds.has(id));
|
|
2690
|
+
const splitDesc = [
|
|
2691
|
+
splitTurnCount > 0 ? `${splitTurnCount} turn(s)` : null,
|
|
2692
|
+
splitPairCount > 0 ? `${splitPairCount} tool call/result pair(s)` : null
|
|
2693
|
+
].filter((part) => part !== null).join(" and ");
|
|
2638
2694
|
if (filteredIds.length === 0 && consumedBlockIds.length === 0) {
|
|
2639
2695
|
throw new Error(
|
|
2640
|
-
`Range would split ${
|
|
2696
|
+
`Range would split ${splitDesc} at the protected-zone boundary: a visible tool-call must keep its reasoning run and its results (strict providers reject a rebuilt request that lost either). Shrink the range to end before the turn starts, or wait until the whole turn ages out of the protected zone.`
|
|
2641
2697
|
);
|
|
2642
2698
|
}
|
|
2643
2699
|
warnings.push(
|
|
2644
|
-
`Withdrawn ${beforeWithdraw - filteredIds.length} message(s) from compression range to keep ${
|
|
2700
|
+
`Withdrawn ${beforeWithdraw - filteredIds.length} message(s) from compression range to keep ${splitDesc} intact (visible tool-call would lose its reasoning run or its results).`
|
|
2645
2701
|
);
|
|
2646
2702
|
}
|
|
2647
2703
|
}
|