acp-kernel 0.0.59-pr.223.75 → 0.0.59-pr.225.76
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/absorb.d.ts +1 -2
- package/dist/absorb.d.ts.map +1 -1
- package/dist/compress.d.ts +5 -0
- package/dist/compress.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/hide-consumed.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -56
- package/dist/index.js.map +1 -1
- package/dist/protected.d.ts +0 -17
- package/dist/protected.d.ts.map +1 -1
- package/dist/recommend.d.ts.map +1 -1
- package/dist/types.d.ts +13 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/absorb.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type LatestProtected } from "./protected.js";
|
|
2
1
|
import type { AbsorbConfig, Config, CompressionState, CoreMessage } from "./types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Instant tool-result absorption ("absorb") — the middle layer between
|
|
@@ -18,7 +17,7 @@ export declare function buildAbsorbPrompt(ref: string, tokens: number, toolName?
|
|
|
18
17
|
export declare function buildAbsorbSystemPrompt(toolName?: string): string;
|
|
19
18
|
/** True when a tool-result message is in scope for absorption prompting:
|
|
20
19
|
* a tool-result of a non-ACP, non-excluded, non-protected tool. */
|
|
21
|
-
export declare function isAbsorbCandidate(msg: CoreMessage, config: Config
|
|
20
|
+
export declare function isAbsorbCandidate(msg: CoreMessage, config: Config): boolean;
|
|
22
21
|
/** Drop tool-call + tool-result pairs recorded in state.absorbed. Both halves
|
|
23
22
|
* go together so the provider-visible conversation stays structurally valid;
|
|
24
23
|
* prune's orphan stripping cleans up any straddling leftovers. */
|
package/dist/absorb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"absorb.d.ts","sourceRoot":"","sources":["../src/absorb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;4DAE4D;AAC5D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GACjC,YAAY,GAAG,IAAI,CA+BrB;AAaD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,gBAAgB,CAAC;IACxB,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;0DAE0D;AAC1D,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAsG7D"}
|
package/dist/compress.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface ProcessTurnInput {
|
|
|
18
18
|
state: CompressionState;
|
|
19
19
|
config: Config;
|
|
20
20
|
tokenCount: number;
|
|
21
|
+
/** Host-side prompt mass the kernel cannot see (replayed reasoning that
|
|
22
|
+
* will be sent despite reasoningReplay, provider-mandated metadata, …).
|
|
23
|
+
* Folded into every usage/pressure decision downstream. Hosts that pass
|
|
24
|
+
* it must do so consistently — cadence baselines persist tokenCount. */
|
|
25
|
+
extraTokens?: number;
|
|
21
26
|
/**
|
|
22
27
|
* Which messages get an <acp> ref tag injected into their text
|
|
23
28
|
* (the render-refs pipeline node). Refs are ALWAYS assigned regardless
|
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":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WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;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,CA0U7D;AAu+BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,OAAO,CAAC,MAAM,CAAM,GAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,OAAO,CAAC,MAAM,CAAM,GAC9B,MAAM,CA+CR;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAuDvD"}
|
|
@@ -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;
|
|
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;AAuED,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,GACxB,kBAAkB,CAwFpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export { searchBlocks, searchBlocksAsync, blockDocs, messageDocs, } from "./sear
|
|
|
40
40
|
export { clearDocFeatures, docCacheInfo, docFeatures, setDocCacheCap, } from "./search.js";
|
|
41
41
|
export type { SearchResult, SearchOptions, SearchAlgorithm, AsyncSearchAlgorithm, AnySearchAlgorithm, SearchDoc, SearchDocKind, ScoredBlock, MessageRole, RoleWeights, MessageInput, } from "./search.js";
|
|
42
42
|
export { DEFAULT_ALGORITHM, DEFAULT_ROLE_WEIGHTS, registerSearchAlgorithm, getSearchAlgorithm, listSearchAlgorithms, } from "./search.js";
|
|
43
|
-
export {
|
|
43
|
+
export { isMessageProtected, matchToolPattern } from "./protected.js";
|
|
44
44
|
export { runPipeline, makeIO, type PipelineNode, type PipelineContext, type NodeIO, type NodeEffects, } from "./pipeline.js";
|
|
45
45
|
export * from "./filter/index.js";
|
|
46
46
|
export { VIABLE_RANGE_MIN_TOKENS, viableRanges } from "./viable.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,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,wBA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AAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAClH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,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,
|
|
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;AAC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AAY,EACZ,iBAAiB,EACjB,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,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,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
|
@@ -133,6 +133,17 @@ function prune(messages, state, options = {}) {
|
|
|
133
133
|
)
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
|
+
function isCovered(id, covered) {
|
|
137
|
+
if (covered.has(id)) return true;
|
|
138
|
+
const hash = id.indexOf("#");
|
|
139
|
+
if (hash <= 0) return false;
|
|
140
|
+
const base = id.substring(0, hash);
|
|
141
|
+
if (covered.has(base)) return true;
|
|
142
|
+
for (const coveredId of covered) {
|
|
143
|
+
if (coveredId.startsWith(`${base}#`)) return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
136
147
|
function collectSummaryAnchors(state, indexById, summaryIndexById) {
|
|
137
148
|
const anchors = [];
|
|
138
149
|
for (const block of activeBlocks(state)) {
|
|
@@ -177,7 +188,7 @@ function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
|
177
188
|
result.push(messages[index]);
|
|
178
189
|
continue;
|
|
179
190
|
}
|
|
180
|
-
if (
|
|
191
|
+
if (isCovered(messages[index].id, covered)) continue;
|
|
181
192
|
if (isRenderedSummaryMessage(messages[index]) && anchoredSummaryIds.has(messages[index].id))
|
|
182
193
|
continue;
|
|
183
194
|
result.push(messages[index]);
|
|
@@ -324,7 +335,6 @@ function defaultConfig(modelContextLimit, overrides = {}) {
|
|
|
324
335
|
minSummaryLength: 50
|
|
325
336
|
},
|
|
326
337
|
protectedTools: [],
|
|
327
|
-
protectedLatestTools: [],
|
|
328
338
|
preserveRecentMessages: 5,
|
|
329
339
|
preserveRecentTokens: 5e3,
|
|
330
340
|
modelContextLimit,
|
|
@@ -667,25 +677,57 @@ var KEEP_LAST_ORPHANED = 2;
|
|
|
667
677
|
function rangeKey(startRef, endRef) {
|
|
668
678
|
return `${startRef}::${endRef}`;
|
|
669
679
|
}
|
|
670
|
-
function
|
|
680
|
+
function parseCallText(text) {
|
|
681
|
+
const raw = text ?? "";
|
|
682
|
+
const start = raw.indexOf("{");
|
|
683
|
+
if (start < 0) return null;
|
|
671
684
|
let parsed;
|
|
672
685
|
try {
|
|
673
|
-
parsed = JSON.parse(
|
|
686
|
+
parsed = JSON.parse(raw.slice(start));
|
|
674
687
|
} catch {
|
|
675
688
|
return null;
|
|
676
689
|
}
|
|
677
690
|
if (!parsed || typeof parsed !== "object") return null;
|
|
678
691
|
const obj = parsed;
|
|
679
|
-
|
|
680
|
-
|
|
692
|
+
if (!Array.isArray(obj.content) || obj.content.length === 0) return null;
|
|
693
|
+
return { prefix: raw.slice(0, start), obj, content: obj.content };
|
|
694
|
+
}
|
|
695
|
+
function rewriteCompressText(text, liveKeys) {
|
|
696
|
+
const parsed = parseCallText(text);
|
|
697
|
+
if (!parsed) return null;
|
|
698
|
+
const { prefix, obj, content } = parsed;
|
|
681
699
|
const kept = content.filter((entry) => {
|
|
682
700
|
if (!entry || typeof entry !== "object") return false;
|
|
683
|
-
const
|
|
684
|
-
const
|
|
685
|
-
|
|
701
|
+
const e = entry;
|
|
702
|
+
const s = typeof e.startId === "string" ? e.startId : typeof e.messageId === "string" ? e.messageId : "";
|
|
703
|
+
const end = typeof e.endId === "string" ? e.endId : typeof e.messageId === "string" ? e.messageId : "";
|
|
704
|
+
return liveKeys.has(rangeKey(s, end));
|
|
705
|
+
});
|
|
706
|
+
if (kept.length === 0) return null;
|
|
707
|
+
return prefix + serializeCompacted(obj, kept).text;
|
|
708
|
+
}
|
|
709
|
+
var SUMMARY_STUB_CHARS = 200;
|
|
710
|
+
function compactEntry(entry) {
|
|
711
|
+
if (!entry || typeof entry !== "object") return entry;
|
|
712
|
+
const e = entry;
|
|
713
|
+
if (typeof e.summary !== "string" || e.summary.length <= SUMMARY_STUB_CHARS) return entry;
|
|
714
|
+
return { ...e, summary: `${e.summary.slice(0, SUMMARY_STUB_CHARS - 1)}\u2026` };
|
|
715
|
+
}
|
|
716
|
+
function serializeCompacted(obj, content) {
|
|
717
|
+
let changed = false;
|
|
718
|
+
const compacted = content.map((entry) => {
|
|
719
|
+
const out = compactEntry(entry);
|
|
720
|
+
if (out !== entry) changed = true;
|
|
721
|
+
return out;
|
|
686
722
|
});
|
|
687
|
-
|
|
688
|
-
|
|
723
|
+
return { text: JSON.stringify({ ...obj, content: compacted }), changed };
|
|
724
|
+
}
|
|
725
|
+
function compactCompressText(text) {
|
|
726
|
+
const parsed = parseCallText(text);
|
|
727
|
+
if (!parsed) return null;
|
|
728
|
+
const { prefix, obj, content } = parsed;
|
|
729
|
+
const { text: out, changed } = serializeCompacted(obj, content);
|
|
730
|
+
return changed ? prefix + out : null;
|
|
689
731
|
}
|
|
690
732
|
function hideConsumedCompressCalls(state, messages) {
|
|
691
733
|
const allBlockCallIds = /* @__PURE__ */ new Set();
|
|
@@ -744,6 +786,11 @@ function hideConsumedCompressCalls(state, messages) {
|
|
|
744
786
|
continue;
|
|
745
787
|
}
|
|
746
788
|
}
|
|
789
|
+
const compacted = compactCompressText(message.text);
|
|
790
|
+
if (compacted !== null) {
|
|
791
|
+
result.push({ ...message, text: compacted });
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
747
794
|
}
|
|
748
795
|
result.push(message);
|
|
749
796
|
}
|
|
@@ -1192,31 +1239,6 @@ function isMessageProtectedWithPairing(msg, config, protectedCallIds) {
|
|
|
1192
1239
|
}
|
|
1193
1240
|
return false;
|
|
1194
1241
|
}
|
|
1195
|
-
function collectLatestProtected(messages, config) {
|
|
1196
|
-
const callIds = /* @__PURE__ */ new Set();
|
|
1197
|
-
const msgIds = /* @__PURE__ */ new Set();
|
|
1198
|
-
const patterns = config.protectedLatestTools ?? [];
|
|
1199
|
-
if (patterns.length === 0) return { callIds, msgIds };
|
|
1200
|
-
for (const pattern of patterns) {
|
|
1201
|
-
let last;
|
|
1202
|
-
for (const m of messages) {
|
|
1203
|
-
if (m.contentType === "tool-call" && m.toolName && matchToolPattern(m.toolName, pattern)) {
|
|
1204
|
-
last = m;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
if (!last) continue;
|
|
1208
|
-
if (last.toolCallId) callIds.add(last.toolCallId);
|
|
1209
|
-
else msgIds.add(last.id);
|
|
1210
|
-
}
|
|
1211
|
-
return { callIds, msgIds };
|
|
1212
|
-
}
|
|
1213
|
-
function isMessageLatestProtected(msg, latest) {
|
|
1214
|
-
if (msg.contentType === "tool-call" && latest.msgIds.has(msg.id)) return true;
|
|
1215
|
-
if ((msg.contentType === "tool-call" || msg.contentType === "tool-result") && msg.toolCallId && latest.callIds.has(msg.toolCallId)) {
|
|
1216
|
-
return true;
|
|
1217
|
-
}
|
|
1218
|
-
return false;
|
|
1219
|
-
}
|
|
1220
1242
|
|
|
1221
1243
|
// src/absorb.ts
|
|
1222
1244
|
var ABSORB_PROMPT_MARKER = "[ACP absorb]";
|
|
@@ -1248,12 +1270,11 @@ function isAcpOrConfiguredTool(toolName, cfg) {
|
|
|
1248
1270
|
if (toolName === cfg.toolName) return true;
|
|
1249
1271
|
return ACP_TOOL_NAMES.has(toolName);
|
|
1250
1272
|
}
|
|
1251
|
-
function isAbsorbCandidate(msg, config
|
|
1273
|
+
function isAbsorbCandidate(msg, config) {
|
|
1252
1274
|
if (msg.contentType !== "tool-result" || !msg.toolCallId) return false;
|
|
1253
1275
|
const cfg = resolveAbsorbConfig(config);
|
|
1254
1276
|
if (isAcpOrConfiguredTool(msg.toolName, cfg)) return false;
|
|
1255
1277
|
if (isMessageProtected(msg, config)) return false;
|
|
1256
|
-
if (latest && isMessageLatestProtected(msg, latest)) return false;
|
|
1257
1278
|
for (const pattern of cfg.excludeTools) {
|
|
1258
1279
|
if (msg.toolName && matchToolPattern(msg.toolName, pattern)) return false;
|
|
1259
1280
|
}
|
|
@@ -1281,9 +1302,8 @@ function appendAbsorbPrompts(messages, state, config, tokenCount, countTokens) {
|
|
|
1281
1302
|
if (record.resultMessageId) absorbedIds.add(record.resultMessageId);
|
|
1282
1303
|
}
|
|
1283
1304
|
let promptedCount = 0;
|
|
1284
|
-
const latest = collectLatestProtected(messages, config);
|
|
1285
1305
|
const out = messages.map((msg) => {
|
|
1286
|
-
if (!isAbsorbCandidate(msg, config
|
|
1306
|
+
if (!isAbsorbCandidate(msg, config)) return msg;
|
|
1287
1307
|
if (absorbedIds.has(msg.id)) return msg;
|
|
1288
1308
|
const text = msg.text ?? "";
|
|
1289
1309
|
if (text.includes(ABSORB_PROMPT_MARKER)) return msg;
|
|
@@ -1389,10 +1409,7 @@ function applyAbsorb(input) {
|
|
|
1389
1409
|
resultText: `absorb failed: ${target.toolName} is an ACP-managed tool result \u2014 it is not absorbable.`
|
|
1390
1410
|
};
|
|
1391
1411
|
}
|
|
1392
|
-
if (isMessageProtected(target, input.config)
|
|
1393
|
-
target,
|
|
1394
|
-
collectLatestProtected(input.messages, input.config)
|
|
1395
|
-
)) {
|
|
1412
|
+
if (isMessageProtected(target, input.config)) {
|
|
1396
1413
|
return {
|
|
1397
1414
|
state: input.state,
|
|
1398
1415
|
ok: false,
|
|
@@ -1735,8 +1752,6 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1735
1752
|
const compressibleMsgs = [];
|
|
1736
1753
|
const protectedMsgs = [];
|
|
1737
1754
|
const protectedCallIds = collectProtectedToolCallIds(messages, config);
|
|
1738
|
-
const latest = collectLatestProtected(messages, config);
|
|
1739
|
-
for (const id of latest.callIds) protectedCallIds.add(id);
|
|
1740
1755
|
let skipSinceCompressible = false;
|
|
1741
1756
|
let skipSinceProtected = false;
|
|
1742
1757
|
for (const msg of messages) {
|
|
@@ -1747,7 +1762,7 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
|
|
|
1747
1762
|
skipSinceProtected = true;
|
|
1748
1763
|
continue;
|
|
1749
1764
|
}
|
|
1750
|
-
if (isMessageProtectedWithPairing(msg, config, protectedCallIds)
|
|
1765
|
+
if (isMessageProtectedWithPairing(msg, config, protectedCallIds)) {
|
|
1751
1766
|
protectedMsgs.push({
|
|
1752
1767
|
ref,
|
|
1753
1768
|
gapBefore: skipSinceProtected,
|
|
@@ -2101,7 +2116,7 @@ function createCore(ports = {}) {
|
|
|
2101
2116
|
}
|
|
2102
2117
|
const ctx = {
|
|
2103
2118
|
config: input.config,
|
|
2104
|
-
tokenCount: input.tokenCount,
|
|
2119
|
+
tokenCount: input.tokenCount + (input.extraTokens ?? 0),
|
|
2105
2120
|
countTokens
|
|
2106
2121
|
};
|
|
2107
2122
|
const initial = {
|
|
@@ -2148,6 +2163,7 @@ function createCore(ports = {}) {
|
|
|
2148
2163
|
assignRefsNode,
|
|
2149
2164
|
syncBlocksNode,
|
|
2150
2165
|
pruneNode,
|
|
2166
|
+
stripReasoningNode,
|
|
2151
2167
|
absorbHideNode,
|
|
2152
2168
|
absorbPromptNode,
|
|
2153
2169
|
filterNode,
|
|
@@ -2171,9 +2187,8 @@ function createCore(ports = {}) {
|
|
|
2171
2187
|
var assignRefsNode = {
|
|
2172
2188
|
name: "assign-refs",
|
|
2173
2189
|
run(io, ctx) {
|
|
2174
|
-
const hasProtection = ctx.config.protectedTools.length > 0 || !!ctx.config.isToolProtected
|
|
2175
|
-
const
|
|
2176
|
-
const protectedFn = hasProtection ? (m) => isMessageProtected(m, ctx.config) || (latest ? isMessageLatestProtected(m, latest) : false) : void 0;
|
|
2190
|
+
const hasProtection = ctx.config.protectedTools.length > 0 || !!ctx.config.isToolProtected;
|
|
2191
|
+
const protectedFn = hasProtection ? (m) => isMessageProtected(m, ctx.config) : void 0;
|
|
2177
2192
|
const refResult = assignRefs(io.messages, {
|
|
2178
2193
|
existing: io.state.messageRefs,
|
|
2179
2194
|
nextIndex: highestUsedIndex(io.state.messageRefs) + 1,
|
|
@@ -2196,6 +2211,34 @@ var pruneNode = {
|
|
|
2196
2211
|
return { ...io, messages: prune(io.messages, io.state) };
|
|
2197
2212
|
}
|
|
2198
2213
|
};
|
|
2214
|
+
var stripReasoningNode = {
|
|
2215
|
+
name: "strip-reasoning",
|
|
2216
|
+
run(io, ctx) {
|
|
2217
|
+
const policy = ctx.config.reasoningReplay ?? "always";
|
|
2218
|
+
if (policy === "always") return io;
|
|
2219
|
+
const messages = io.messages;
|
|
2220
|
+
if (policy === "never") {
|
|
2221
|
+
const kept2 = messages.filter((m) => m.contentType !== "reasoning");
|
|
2222
|
+
return kept2.length === messages.length ? io : { ...io, messages: kept2 };
|
|
2223
|
+
}
|
|
2224
|
+
let boundary = -1;
|
|
2225
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2226
|
+
const m = messages[i];
|
|
2227
|
+
if (m.role === "user" && m.contentType === "text") {
|
|
2228
|
+
boundary = i;
|
|
2229
|
+
break;
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
if (boundary < 0) return io;
|
|
2233
|
+
let changed = false;
|
|
2234
|
+
const kept = messages.filter((m, i) => {
|
|
2235
|
+
if (m.contentType !== "reasoning" || i >= boundary) return true;
|
|
2236
|
+
changed = true;
|
|
2237
|
+
return false;
|
|
2238
|
+
});
|
|
2239
|
+
return changed ? { ...io, messages: kept } : io;
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2199
2242
|
var absorbHideNode = {
|
|
2200
2243
|
name: "absorb-hide",
|
|
2201
2244
|
enabled: (io) => (io.state.absorbed?.length ?? 0) > 0,
|
|
@@ -2514,8 +2557,6 @@ function validateCompressionRange(input, directMessageIds, consumedBlockCount) {
|
|
|
2514
2557
|
function filterProtectedToolMessages(directMessageIds, messages, config) {
|
|
2515
2558
|
const protectedCallIds = /* @__PURE__ */ new Set();
|
|
2516
2559
|
const removedIds = /* @__PURE__ */ new Set();
|
|
2517
|
-
const latest = collectLatestProtected(messages, config);
|
|
2518
|
-
for (const id of latest.callIds) protectedCallIds.add(id);
|
|
2519
2560
|
for (const msg of messages) {
|
|
2520
2561
|
if (isMessageProtected(msg, config) && msg.toolCallId) {
|
|
2521
2562
|
protectedCallIds.add(msg.toolCallId);
|
|
@@ -2524,7 +2565,7 @@ function filterProtectedToolMessages(directMessageIds, messages, config) {
|
|
|
2524
2565
|
for (const id of directMessageIds) {
|
|
2525
2566
|
const msg = messages.find((m) => m.id === id);
|
|
2526
2567
|
if (!msg) continue;
|
|
2527
|
-
if (isMessageProtected(msg, config)
|
|
2568
|
+
if (isMessageProtected(msg, config)) {
|
|
2528
2569
|
removedIds.add(id);
|
|
2529
2570
|
if (msg.toolCallId) protectedCallIds.add(msg.toolCallId);
|
|
2530
2571
|
}
|
|
@@ -4110,7 +4151,6 @@ export {
|
|
|
4110
4151
|
clearDocFeatures,
|
|
4111
4152
|
clearMessageFilters,
|
|
4112
4153
|
collectBlockContent,
|
|
4113
|
-
collectLatestProtected,
|
|
4114
4154
|
coveredMessageIds,
|
|
4115
4155
|
createBpeTokenizer,
|
|
4116
4156
|
createCore,
|
|
@@ -4135,7 +4175,6 @@ export {
|
|
|
4135
4175
|
highestUsedIndex,
|
|
4136
4176
|
indexToRef,
|
|
4137
4177
|
isAbsorbCandidate,
|
|
4138
|
-
isMessageLatestProtected,
|
|
4139
4178
|
isMessageProtected,
|
|
4140
4179
|
isRenderedSummaryMessage,
|
|
4141
4180
|
isSummaryMessageId,
|