acp-kernel 0.0.37 → 0.0.39
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/boundaries.d.ts +11 -2
- package/dist/boundaries.d.ts.map +1 -1
- package/dist/compress.d.ts.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +194 -66
- package/dist/index.js.map +1 -1
- package/dist/prune.d.ts +15 -0
- package/dist/prune.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/boundaries.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompressionState, CoreMessage, ResolvedBoundary } from "./types.js";
|
|
1
|
+
import type { CompressionBlock, CompressionState, CoreMessage, ResolvedBoundary } from "./types.js";
|
|
2
2
|
export type BoundaryKind = "message" | "block";
|
|
3
3
|
export interface ParsedBoundary {
|
|
4
4
|
kind: BoundaryKind;
|
|
@@ -35,6 +35,15 @@ export interface ResolvedRange {
|
|
|
35
35
|
snappedBoundaries: string[];
|
|
36
36
|
}
|
|
37
37
|
export declare function resolveBoundaries(input: ResolveBoundariesInput): ResolvedRange;
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Visible anchor index for a block: its rendered summary message if present
|
|
40
|
+
* (post-prune views replace raw messages with `acp_summary_bN`), else the
|
|
41
|
+
* earliest visible raw message it covers. Without the summary fallback an
|
|
42
|
+
* active block whose raws were pruned becomes unresolvable and cannot be
|
|
43
|
+
* promoted (dog/billion-context-pi#195).
|
|
44
|
+
*/
|
|
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;
|
|
39
48
|
export declare function toResolvedBoundary(range: ResolvedRange): ResolvedBoundary;
|
|
40
49
|
//# sourceMappingURL=boundaries.d.ts.map
|
package/dist/boundaries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAEA,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,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,wBAAwB;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,KAAK,CAAC;gBAGjC,IAAI,EAAE,SAAS,GAAG,UAAU,EAC5B,QAAQ,EAAE,OAAO,GAAG,KAAK,EACzB,OAAO,EAAE,MAAM;CAQlB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,GAC5B,aAAa,CAuEf;AAgJD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,EACvB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,GAAG,IAAI,CAIf;AAOD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,gBAAgB,EACvB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAcT;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EAAE,EACb,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,GAAG,IAAI,CASf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,CAMzE"}
|
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,
|
|
1
|
+
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAahF,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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B,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CA6T7D;AAg1BD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,34 +4,34 @@ export type { Ports, CompressionCore, ProcessTurnInput, ApplyCompressionInput, }
|
|
|
4
4
|
export { createInitialState, allocateBlockId, allocateRunId, blockById, activeBlocks, coveredMessageIds, highestActiveTier, advanceSurvival, } from "./state.js";
|
|
5
5
|
export { defaultConfig, validateConfig } from "./config.js";
|
|
6
6
|
export { assignRefs, highestUsedIndex, emptyRefMap, indexToRef, refToIndex, refForRaw, rawForRef, BLOCKED_REF, } from "./refs.js";
|
|
7
|
-
export { prune, SUMMARY_HEADER } from "./prune.js";
|
|
7
|
+
export { prune, SUMMARY_HEADER, summaryMessageId, isSummaryMessageId, isRenderedSummaryMessage, } from "./prune.js";
|
|
8
8
|
export { syncBlocks } from "./sync.js";
|
|
9
|
-
export { resolveBoundaries, parseBoundary, BoundaryNotFoundError } from "./boundaries.js";
|
|
10
|
-
export { defaultCountTokens, estimateTokensFast, createBpeTokenizer } from "./tokenize.js";
|
|
9
|
+
export { resolveBoundaries, parseBoundary, BoundaryNotFoundError, visibleBlockAnchor, blockVisibleInRange, } from "./boundaries.js";
|
|
10
|
+
export { defaultCountTokens, estimateTokensFast, createBpeTokenizer, } from "./tokenize.js";
|
|
11
11
|
export type { TokenCountFn } from "./tokenize.js";
|
|
12
12
|
export { renderNudgeText, formatRanges } from "./nudge-text.js";
|
|
13
13
|
export type { NudgeVoice, RenderedNudge } from "./nudge-text.js";
|
|
14
|
-
export { COMPRESS_PHILOSOPHY, HOW_TO_COMPRESS_RULES, TIER2_DISTILL_RULES, TIER3_CONDENSE_RULES } from "./compression-rules.js";
|
|
14
|
+
export { COMPRESS_PHILOSOPHY, HOW_TO_COMPRESS_RULES, TIER2_DISTILL_RULES, TIER3_CONDENSE_RULES, } from "./compression-rules.js";
|
|
15
15
|
export { defaultPrompts, resolvePrompts } from "./prompts.js";
|
|
16
16
|
export type { Prompts, ResolvePromptsOptions } from "./prompts.js";
|
|
17
17
|
export { truncateLargeToolOutputs } from "./truncate-tools.js";
|
|
18
18
|
export type { TruncateOptions, TruncateResult } from "./truncate-tools.js";
|
|
19
19
|
export { parseBlockIdArg, findBlocksOverlappingMessages, findActiveAncestor, deactivateBlock, buildRestoredContentPreview, collectBlockContent, } from "./decompress.js";
|
|
20
|
-
export type { DeactivateOptions, CollectedContentResult, CollectContentOptions } from "./decompress.js";
|
|
20
|
+
export type { DeactivateOptions, CollectedContentResult, CollectContentOptions, } from "./decompress.js";
|
|
21
21
|
export { buildStatusReport, buildRecap } from "./report.js";
|
|
22
22
|
export type { StatusReportOptions } from "./report.js";
|
|
23
23
|
export { hideConsumedCompressCalls } from "./hide-consumed.js";
|
|
24
24
|
export type { HideConsumedResult } from "./hide-consumed.js";
|
|
25
25
|
export { rebuildCompressionState } from "./rebuild.js";
|
|
26
26
|
export type { RebuildResult, RebuildPorts } from "./rebuild.js";
|
|
27
|
-
export { renderVisibleRefs, renderRefsNode, createRenderRefsNode } from "./render-refs.js";
|
|
27
|
+
export { renderVisibleRefs, renderRefsNode, createRenderRefsNode, } from "./render-refs.js";
|
|
28
28
|
export type { RenderStrategy } from "./render-refs.js";
|
|
29
29
|
export { resolveTransformChannel } from "./transform-channel.js";
|
|
30
30
|
export type { TransformChannel } from "./transform-channel.js";
|
|
31
|
-
export { searchBlocks, searchBlocksAsync, blockDocs, messageDocs } from "./search.js";
|
|
32
|
-
export { clearDocFeatures, docCacheInfo, docFeatures, setDocCacheCap } from "./search.js";
|
|
33
|
-
export type { SearchResult, SearchOptions, SearchAlgorithm, AsyncSearchAlgorithm, AnySearchAlgorithm, SearchDoc, SearchDocKind, ScoredBlock, MessageRole, RoleWeights, MessageInput } from "./search.js";
|
|
34
|
-
export { DEFAULT_ALGORITHM, DEFAULT_ROLE_WEIGHTS, registerSearchAlgorithm, getSearchAlgorithm, listSearchAlgorithms } from "./search.js";
|
|
31
|
+
export { searchBlocks, searchBlocksAsync, blockDocs, messageDocs, } from "./search.js";
|
|
32
|
+
export { clearDocFeatures, docCacheInfo, docFeatures, setDocCacheCap, } from "./search.js";
|
|
33
|
+
export type { SearchResult, SearchOptions, SearchAlgorithm, AsyncSearchAlgorithm, AnySearchAlgorithm, SearchDoc, SearchDocKind, ScoredBlock, MessageRole, RoleWeights, MessageInput, } from "./search.js";
|
|
34
|
+
export { DEFAULT_ALGORITHM, DEFAULT_ROLE_WEIGHTS, registerSearchAlgorithm, getSearchAlgorithm, listSearchAlgorithms, } from "./search.js";
|
|
35
35
|
export { isMessageProtected, matchToolPattern } from "./protected.js";
|
|
36
36
|
export { runPipeline, makeIO, type PipelineNode, type PipelineContext, type NodeIO, type NodeEffects, } from "./pipeline.js";
|
|
37
37
|
export * from "./filter/index.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,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAA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AAkB,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
|
@@ -149,6 +149,16 @@ function advanceSurvival(state, promotionThreshold) {
|
|
|
149
149
|
|
|
150
150
|
// src/prune.ts
|
|
151
151
|
var SUMMARY_HEADER = "[Compressed conversation section]";
|
|
152
|
+
var SUMMARY_ID_PREFIX = "acp_summary_";
|
|
153
|
+
function summaryMessageId(blockId) {
|
|
154
|
+
return `${SUMMARY_ID_PREFIX}${blockId}`;
|
|
155
|
+
}
|
|
156
|
+
function isSummaryMessageId(id) {
|
|
157
|
+
return id.startsWith(SUMMARY_ID_PREFIX);
|
|
158
|
+
}
|
|
159
|
+
function isRenderedSummaryMessage(message) {
|
|
160
|
+
return isSummaryMessageId(message.id) && message.role === "system" && message.contentType === "text";
|
|
161
|
+
}
|
|
152
162
|
function prune(messages, state, options = {}) {
|
|
153
163
|
const covered = coveredMessageIds(state);
|
|
154
164
|
if (covered.size === 0) return [...messages];
|
|
@@ -157,8 +167,13 @@ function prune(messages, state, options = {}) {
|
|
|
157
167
|
(message) => message.role === "user"
|
|
158
168
|
);
|
|
159
169
|
const indexById = /* @__PURE__ */ new Map();
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
const summaryIndexById = /* @__PURE__ */ new Map();
|
|
171
|
+
messages.forEach((message, index) => {
|
|
172
|
+
indexById.set(message.id, index);
|
|
173
|
+
if (isRenderedSummaryMessage(message))
|
|
174
|
+
summaryIndexById.set(message.id, index);
|
|
175
|
+
});
|
|
176
|
+
const anchors = inject ? collectSummaryAnchors(state, indexById, summaryIndexById) : [];
|
|
162
177
|
return stripOrphanedReasoning(
|
|
163
178
|
stripOrphanedToolResults(
|
|
164
179
|
stripOrphanedToolCalls(
|
|
@@ -167,9 +182,19 @@ function prune(messages, state, options = {}) {
|
|
|
167
182
|
)
|
|
168
183
|
);
|
|
169
184
|
}
|
|
170
|
-
function collectSummaryAnchors(state, indexById) {
|
|
185
|
+
function collectSummaryAnchors(state, indexById, summaryIndexById) {
|
|
171
186
|
const anchors = [];
|
|
172
187
|
for (const block of activeBlocks(state)) {
|
|
188
|
+
const existingIndex = summaryIndexById.get(summaryMessageId(block.blockId));
|
|
189
|
+
if (existingIndex !== void 0) {
|
|
190
|
+
anchors.push({
|
|
191
|
+
blockId: block.blockId,
|
|
192
|
+
summary: block.summary,
|
|
193
|
+
topic: block.topic,
|
|
194
|
+
insertAt: existingIndex
|
|
195
|
+
});
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
173
198
|
let earliest = null;
|
|
174
199
|
for (const id of block.effectiveMessageIds) {
|
|
175
200
|
const index = indexById.get(id);
|
|
@@ -190,6 +215,9 @@ function collectSummaryAnchors(state, indexById) {
|
|
|
190
215
|
function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
191
216
|
const result = [];
|
|
192
217
|
const pending = [...anchors];
|
|
218
|
+
const anchoredSummaryIds = new Set(
|
|
219
|
+
anchors.map((anchor) => summaryMessageId(anchor.blockId))
|
|
220
|
+
);
|
|
193
221
|
for (let index = 0; index < messages.length; index++) {
|
|
194
222
|
while (pending.length > 0 && pending[0].insertAt === index) {
|
|
195
223
|
result.push(renderSummary(pending.shift()));
|
|
@@ -199,6 +227,8 @@ function rebuildMessages(messages, covered, firstUserIndex, anchors) {
|
|
|
199
227
|
continue;
|
|
200
228
|
}
|
|
201
229
|
if (covered.has(messages[index].id)) continue;
|
|
230
|
+
if (isRenderedSummaryMessage(messages[index]) && anchoredSummaryIds.has(messages[index].id))
|
|
231
|
+
continue;
|
|
202
232
|
result.push(messages[index]);
|
|
203
233
|
}
|
|
204
234
|
while (pending.length > 0) {
|
|
@@ -212,7 +242,7 @@ function renderSummary(anchor) {
|
|
|
212
242
|
const text = body.length === 0 ? topicLine : `${topicLine}
|
|
213
243
|
${body}`;
|
|
214
244
|
return {
|
|
215
|
-
id:
|
|
245
|
+
id: summaryMessageId(anchor.blockId),
|
|
216
246
|
role: "system",
|
|
217
247
|
contentType: "text",
|
|
218
248
|
text
|
|
@@ -303,9 +333,7 @@ function syncBlocks(messages, state) {
|
|
|
303
333
|
continue;
|
|
304
334
|
}
|
|
305
335
|
block.active = true;
|
|
306
|
-
const stillPresent = block.effectiveMessageIds.some(
|
|
307
|
-
(id) => presentIds.has(id)
|
|
308
|
-
);
|
|
336
|
+
const stillPresent = block.effectiveMessageIds.some((id) => presentIds.has(id)) || presentIds.has(summaryMessageId(block.blockId));
|
|
309
337
|
if (!stillPresent) {
|
|
310
338
|
block.active = false;
|
|
311
339
|
deactivated.push(block.blockId);
|
|
@@ -422,14 +450,24 @@ function resolveBoundaries(input) {
|
|
|
422
450
|
`Invalid boundary ref(s): startId="${input.startRef}", endId="${input.endRef}". Use mNNNNN or bN.`
|
|
423
451
|
);
|
|
424
452
|
}
|
|
425
|
-
const
|
|
453
|
+
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
426
454
|
input.messages.forEach(
|
|
427
|
-
(message, index) =>
|
|
455
|
+
(message, index) => indexByMessageId.set(message.id, index)
|
|
428
456
|
);
|
|
429
457
|
let snappedBoundaries = [];
|
|
430
|
-
const startAnchor = resolveAnchorIndex(
|
|
458
|
+
const startAnchor = resolveAnchorIndex(
|
|
459
|
+
start,
|
|
460
|
+
input.state,
|
|
461
|
+
indexByMessageId,
|
|
462
|
+
"start"
|
|
463
|
+
);
|
|
431
464
|
if (startAnchor.snapped) snappedBoundaries.push(startAnchor.snapped);
|
|
432
|
-
const endAnchor = resolveAnchorIndex(
|
|
465
|
+
const endAnchor = resolveAnchorIndex(
|
|
466
|
+
end,
|
|
467
|
+
input.state,
|
|
468
|
+
indexByMessageId,
|
|
469
|
+
"end"
|
|
470
|
+
);
|
|
433
471
|
if (endAnchor.snapped) snappedBoundaries.push(endAnchor.snapped);
|
|
434
472
|
let startIndex = startAnchor.index;
|
|
435
473
|
let endIndex = endAnchor.index;
|
|
@@ -439,14 +477,14 @@ function resolveBoundaries(input) {
|
|
|
439
477
|
const messageIds = [];
|
|
440
478
|
for (let index = startIndex; index <= endIndex; index++) {
|
|
441
479
|
const message = input.messages[index];
|
|
442
|
-
if (message
|
|
480
|
+
if (message && !isRenderedSummaryMessage(message))
|
|
481
|
+
messageIds.push(message.id);
|
|
443
482
|
}
|
|
444
483
|
const boundaryKind = start.kind === "block" || end.kind === "block" ? "block" : "message";
|
|
445
484
|
const nestedBlockIds = [];
|
|
446
485
|
const nestedSeen = /* @__PURE__ */ new Set();
|
|
447
486
|
for (const block of activeBlocks(input.state)) {
|
|
448
|
-
|
|
449
|
-
if (anchor !== null && anchor >= startIndex && anchor <= endIndex) {
|
|
487
|
+
if (blockVisibleInRange(block, indexByMessageId, startIndex, endIndex)) {
|
|
450
488
|
if (!nestedSeen.has(block.blockId)) {
|
|
451
489
|
nestedSeen.add(block.blockId);
|
|
452
490
|
nestedBlockIds.push(block.blockId);
|
|
@@ -464,7 +502,7 @@ function resolveBoundaries(input) {
|
|
|
464
502
|
snappedBoundaries
|
|
465
503
|
};
|
|
466
504
|
}
|
|
467
|
-
function resolveAnchorIndex(boundary, state,
|
|
505
|
+
function resolveAnchorIndex(boundary, state, indexByMessageId, endpoint) {
|
|
468
506
|
const label = endpoint === "start" ? "startId" : "endId";
|
|
469
507
|
if (boundary.kind === "message") {
|
|
470
508
|
const rawId = state.messageRefs.byRef[boundary.raw] ?? state.messageRefs.byRef[formatPaddedRef(boundary.numericId)];
|
|
@@ -475,15 +513,15 @@ function resolveAnchorIndex(boundary, state, indexByRawId, endpoint) {
|
|
|
475
513
|
`${label}="${boundary.raw}" does not exist in this session (typo or wrong session) \u2014 run acp_status for current refs.`
|
|
476
514
|
);
|
|
477
515
|
}
|
|
478
|
-
const index =
|
|
516
|
+
const index = indexByMessageId.get(rawId);
|
|
479
517
|
if (index !== void 0) {
|
|
480
518
|
return { index, snapped: null };
|
|
481
519
|
}
|
|
482
|
-
const owner2 = activeOwnerAnchor(state, [rawId],
|
|
520
|
+
const owner2 = activeOwnerAnchor(state, [rawId], indexByMessageId);
|
|
483
521
|
if (owner2 !== null) {
|
|
484
522
|
return {
|
|
485
523
|
index: owner2,
|
|
486
|
-
snapped: `${label}="${boundary.raw}" refers to a message already compressed into an active block \u2014 anchored to
|
|
524
|
+
snapped: `${label}="${boundary.raw}" refers to a message already compressed into an active block \u2014 anchored to the active block covering it instead.`
|
|
487
525
|
};
|
|
488
526
|
}
|
|
489
527
|
throw new BoundaryNotFoundError(
|
|
@@ -501,12 +539,16 @@ function resolveAnchorIndex(boundary, state, indexByRawId, endpoint) {
|
|
|
501
539
|
);
|
|
502
540
|
}
|
|
503
541
|
if (block.active) {
|
|
504
|
-
const anchor =
|
|
542
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
505
543
|
if (anchor !== null) {
|
|
506
544
|
return { index: anchor, snapped: null };
|
|
507
545
|
}
|
|
508
546
|
}
|
|
509
|
-
const owner = activeOwnerAnchor(
|
|
547
|
+
const owner = activeOwnerAnchor(
|
|
548
|
+
state,
|
|
549
|
+
block.effectiveMessageIds,
|
|
550
|
+
indexByMessageId
|
|
551
|
+
);
|
|
510
552
|
if (owner !== null) {
|
|
511
553
|
return {
|
|
512
554
|
index: owner,
|
|
@@ -523,31 +565,64 @@ function resolveAnchorIndex(boundary, state, indexByRawId, endpoint) {
|
|
|
523
565
|
throw new BoundaryNotFoundError(
|
|
524
566
|
"consumed",
|
|
525
567
|
endpoint,
|
|
526
|
-
`${label}="b${boundary.numericId}"
|
|
568
|
+
`${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.`
|
|
527
569
|
);
|
|
528
570
|
}
|
|
529
|
-
function activeOwnerAnchor(state, ownedIds,
|
|
571
|
+
function activeOwnerAnchor(state, ownedIds, indexByMessageId) {
|
|
530
572
|
if (ownedIds.length === 0) return null;
|
|
531
573
|
const owned = new Set(ownedIds);
|
|
532
574
|
let best = null;
|
|
533
575
|
for (const block of state.blocks) {
|
|
534
576
|
if (!block.active) continue;
|
|
535
|
-
const
|
|
577
|
+
const inherited = inheritedContentIds(state, block);
|
|
578
|
+
let ownsInherited = false;
|
|
579
|
+
for (const id of owned) {
|
|
580
|
+
if (inherited.has(id)) {
|
|
581
|
+
ownsInherited = true;
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (!ownsInherited) continue;
|
|
586
|
+
const anchor = visibleBlockAnchor(block, indexByMessageId);
|
|
536
587
|
if (anchor === null) continue;
|
|
537
|
-
|
|
538
|
-
if (ownsContent && (best === null || anchor < best)) {
|
|
588
|
+
if (best === null || anchor < best) {
|
|
539
589
|
best = anchor;
|
|
540
590
|
}
|
|
541
591
|
}
|
|
542
592
|
return best;
|
|
543
593
|
}
|
|
594
|
+
function inheritedContentIds(state, block) {
|
|
595
|
+
const ids = /* @__PURE__ */ new Set();
|
|
596
|
+
for (const childId of block.directBlockIds) {
|
|
597
|
+
const child = blockById(state, childId);
|
|
598
|
+
if (!child) continue;
|
|
599
|
+
for (const id of child.effectiveMessageIds) ids.add(id);
|
|
600
|
+
}
|
|
601
|
+
return ids;
|
|
602
|
+
}
|
|
544
603
|
function formatPaddedRef(index) {
|
|
545
604
|
return `m${String(index).padStart(5, "0")}`;
|
|
546
605
|
}
|
|
547
|
-
function
|
|
606
|
+
function visibleBlockAnchor(block, indexByMessageId) {
|
|
607
|
+
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
608
|
+
if (summaryIndex !== void 0) return summaryIndex;
|
|
609
|
+
return earliestIndexOfIds(block.effectiveMessageIds, indexByMessageId);
|
|
610
|
+
}
|
|
611
|
+
function blockVisibleInRange(block, indexByMessageId, startIndex, endIndex) {
|
|
612
|
+
const summaryIndex = indexByMessageId.get(summaryMessageId(block.blockId));
|
|
613
|
+
if (summaryIndex !== void 0 && summaryIndex >= startIndex && summaryIndex <= endIndex) {
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
const rawIndex = earliestIndexOfIds(
|
|
617
|
+
block.effectiveMessageIds,
|
|
618
|
+
indexByMessageId
|
|
619
|
+
);
|
|
620
|
+
return rawIndex !== null && rawIndex >= startIndex && rawIndex <= endIndex;
|
|
621
|
+
}
|
|
622
|
+
function earliestIndexOfIds(ids, indexByMessageId) {
|
|
548
623
|
let earliest = null;
|
|
549
624
|
for (const id of ids) {
|
|
550
|
-
const index =
|
|
625
|
+
const index = indexByMessageId.get(id);
|
|
551
626
|
if (index !== void 0 && (earliest === null || index < earliest)) {
|
|
552
627
|
earliest = index;
|
|
553
628
|
}
|
|
@@ -1219,7 +1294,12 @@ function createCore(ports = {}) {
|
|
|
1219
1294
|
let tokensCompressed = 0;
|
|
1220
1295
|
const errors = [];
|
|
1221
1296
|
const warnings = [];
|
|
1222
|
-
const protectedMessageIds = input.protectedMessageIds ?? computeProtectedRefs(
|
|
1297
|
+
const protectedMessageIds = input.protectedMessageIds ?? computeProtectedRefs(
|
|
1298
|
+
input.messages,
|
|
1299
|
+
input.state,
|
|
1300
|
+
input.config,
|
|
1301
|
+
countTokens
|
|
1302
|
+
);
|
|
1223
1303
|
const preExistingCoverage = collectCoverage(state);
|
|
1224
1304
|
const classifications = /* @__PURE__ */ new Map();
|
|
1225
1305
|
const classificationErrors = [];
|
|
@@ -1250,7 +1330,10 @@ function createCore(ports = {}) {
|
|
|
1250
1330
|
error: error instanceof Error ? error : new Error(String(error))
|
|
1251
1331
|
});
|
|
1252
1332
|
classificationErrors.push(
|
|
1253
|
-
rangeError(
|
|
1333
|
+
rangeError(
|
|
1334
|
+
spec,
|
|
1335
|
+
error instanceof Error ? error.message : String(error)
|
|
1336
|
+
)
|
|
1254
1337
|
);
|
|
1255
1338
|
}
|
|
1256
1339
|
}
|
|
@@ -1261,32 +1344,27 @@ function createCore(ports = {}) {
|
|
|
1261
1344
|
if (resolution.status === "ok") resolvableCount++;
|
|
1262
1345
|
else if (resolution.status === "unknown") unknownCount++;
|
|
1263
1346
|
}
|
|
1264
|
-
const
|
|
1347
|
+
const rangeSpans = [];
|
|
1265
1348
|
for (const [spec, resolution] of classifications) {
|
|
1266
1349
|
if (resolution.status !== "ok") continue;
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
const bMin = b.indices.length > 0 ? Math.min(...b.indices) : Infinity;
|
|
1275
|
-
return aMin - bMin;
|
|
1276
|
-
});
|
|
1350
|
+
rangeSpans.push({
|
|
1351
|
+
spec,
|
|
1352
|
+
start: resolution.resolved.startIndex,
|
|
1353
|
+
end: resolution.resolved.endIndex
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
const sortedRanges = [...rangeSpans].sort((a, b) => a.start - b.start);
|
|
1277
1357
|
const skipSpecs = /* @__PURE__ */ new Set();
|
|
1278
1358
|
let acceptedMaxIndex = -1;
|
|
1279
1359
|
for (const entry of sortedRanges) {
|
|
1280
|
-
|
|
1281
|
-
const entryMin = entry.indices.length > 0 ? Math.min(...entry.indices) : -1;
|
|
1282
|
-
if (entryMin >= 0 && entryMin <= acceptedMaxIndex) {
|
|
1360
|
+
if (entry.start <= acceptedMaxIndex) {
|
|
1283
1361
|
skipSpecs.add(entry.spec);
|
|
1284
1362
|
warnings.push(
|
|
1285
1363
|
`Skipped range (${entry.spec.startRef}..${entry.spec.endRef}) \u2014 overlaps an earlier range in the batch; the earlier range takes precedence. Keep ranges disjoint.`
|
|
1286
1364
|
);
|
|
1287
1365
|
continue;
|
|
1288
1366
|
}
|
|
1289
|
-
if (
|
|
1367
|
+
if (entry.end > acceptedMaxIndex) acceptedMaxIndex = entry.end;
|
|
1290
1368
|
}
|
|
1291
1369
|
if (input.config.compress.minCompressRange > 0 && input.ranges.length > 0) {
|
|
1292
1370
|
let totalRangeChars = 0;
|
|
@@ -1349,7 +1427,12 @@ function createCore(ports = {}) {
|
|
|
1349
1427
|
tokensCompressed += outcome.tokens;
|
|
1350
1428
|
warnings.push(...outcome.warnings);
|
|
1351
1429
|
} catch (error) {
|
|
1352
|
-
errors.push(
|
|
1430
|
+
errors.push(
|
|
1431
|
+
rangeError(
|
|
1432
|
+
spec,
|
|
1433
|
+
error instanceof Error ? error.message : String(error)
|
|
1434
|
+
)
|
|
1435
|
+
);
|
|
1353
1436
|
}
|
|
1354
1437
|
}
|
|
1355
1438
|
state.stats.compressionCount += blocksCreated;
|
|
@@ -1359,12 +1442,17 @@ function createCore(ports = {}) {
|
|
|
1359
1442
|
state.nudge.lastNudgeShownTokens = 0;
|
|
1360
1443
|
state.nudge.lastShownByTier = {};
|
|
1361
1444
|
}
|
|
1362
|
-
return {
|
|
1445
|
+
return {
|
|
1446
|
+
state,
|
|
1447
|
+
result: { blocksCreated, tokensCompressed, errors, warnings }
|
|
1448
|
+
};
|
|
1363
1449
|
}
|
|
1364
1450
|
function processTurn(input) {
|
|
1365
1451
|
const configErrors = validateConfig(input.config);
|
|
1366
1452
|
if (configErrors.length > 0) {
|
|
1367
|
-
console.warn(
|
|
1453
|
+
console.warn(
|
|
1454
|
+
`[acp-kernel] Config validation warnings: ${configErrors.join("; ")}. Thresholds may not fire correctly.`
|
|
1455
|
+
);
|
|
1368
1456
|
}
|
|
1369
1457
|
const ctx = {
|
|
1370
1458
|
config: input.config,
|
|
@@ -1424,7 +1512,14 @@ function createCore(ports = {}) {
|
|
|
1424
1512
|
if (strategy === "none") return base;
|
|
1425
1513
|
return [...base, createRenderRefsNode(strategy)];
|
|
1426
1514
|
}
|
|
1427
|
-
return {
|
|
1515
|
+
return {
|
|
1516
|
+
processTurn,
|
|
1517
|
+
applyCompression,
|
|
1518
|
+
defaultNodes,
|
|
1519
|
+
decompress,
|
|
1520
|
+
search,
|
|
1521
|
+
status
|
|
1522
|
+
};
|
|
1428
1523
|
}
|
|
1429
1524
|
var assignRefsNode = {
|
|
1430
1525
|
name: "assign-refs",
|
|
@@ -1524,7 +1619,10 @@ var nudgeNode = {
|
|
|
1524
1619
|
if (nudge.shouldInject) {
|
|
1525
1620
|
stamped.lastNudgeShownTokens = ctx.tokenCount;
|
|
1526
1621
|
if (nudge.tier !== null) {
|
|
1527
|
-
stamped.lastShownByTier = {
|
|
1622
|
+
stamped.lastShownByTier = {
|
|
1623
|
+
...stamped.lastShownByTier,
|
|
1624
|
+
[nudge.tier]: ctx.tokenCount
|
|
1625
|
+
};
|
|
1528
1626
|
}
|
|
1529
1627
|
}
|
|
1530
1628
|
return {
|
|
@@ -1564,17 +1662,16 @@ function applySingleRange(input) {
|
|
|
1564
1662
|
const rangeMessageIds = applyPairBoundaryAdjustments(
|
|
1565
1663
|
resolved,
|
|
1566
1664
|
input.messages
|
|
1567
|
-
);
|
|
1665
|
+
).filter((id) => !isSummaryMessageId(id));
|
|
1568
1666
|
if (rangeMessageIds.length > resolved.messageIds.length) {
|
|
1569
|
-
const
|
|
1570
|
-
input.messages.forEach((m, i) =>
|
|
1571
|
-
const adjustedStart =
|
|
1572
|
-
const adjustedEnd =
|
|
1667
|
+
const indexByMessageId = /* @__PURE__ */ new Map();
|
|
1668
|
+
input.messages.forEach((m, i) => indexByMessageId.set(m.id, i));
|
|
1669
|
+
const adjustedStart = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[0]) ?? resolved.startIndex : resolved.startIndex;
|
|
1670
|
+
const adjustedEnd = rangeMessageIds.length > 0 ? indexByMessageId.get(rangeMessageIds[rangeMessageIds.length - 1]) ?? resolved.endIndex : resolved.endIndex;
|
|
1573
1671
|
const nestedSeen = new Set(resolved.nestedBlockIds);
|
|
1574
1672
|
for (const block2 of activeBlocks(input.state)) {
|
|
1575
1673
|
if (nestedSeen.has(block2.blockId)) continue;
|
|
1576
|
-
|
|
1577
|
-
if (anchor !== null && anchor >= adjustedStart && anchor <= adjustedEnd) {
|
|
1674
|
+
if (blockVisibleInRange(block2, indexByMessageId, adjustedStart, adjustedEnd)) {
|
|
1578
1675
|
nestedSeen.add(block2.blockId);
|
|
1579
1676
|
resolved.nestedBlockIds.push(block2.blockId);
|
|
1580
1677
|
}
|
|
@@ -1789,12 +1886,21 @@ function pendingByTier(state, recommendation, countTokens, minCompressRange) {
|
|
|
1789
1886
|
const out = {};
|
|
1790
1887
|
const merged = recommendation?.recommendedRanges ?? [];
|
|
1791
1888
|
const effective = minCompressRange > 0 ? merged.filter((r) => (r.chars ?? r.tokens * 4) >= minCompressRange) : merged;
|
|
1792
|
-
out[1] = {
|
|
1889
|
+
out[1] = {
|
|
1890
|
+
pending: effective.reduce((s, r) => s + r.tokens, 0),
|
|
1891
|
+
targetBlocks: []
|
|
1892
|
+
};
|
|
1793
1893
|
const active = activeBlocks(state);
|
|
1794
1894
|
const t1 = active.filter((b) => b.tier === 1);
|
|
1795
1895
|
const t2 = active.filter((b) => b.tier === 2);
|
|
1796
|
-
out[2] = {
|
|
1797
|
-
|
|
1896
|
+
out[2] = {
|
|
1897
|
+
pending: t1.reduce((s, b) => s + countTokens(b.summary), 0),
|
|
1898
|
+
targetBlocks: t1
|
|
1899
|
+
};
|
|
1900
|
+
out[3] = {
|
|
1901
|
+
pending: t2.reduce((s, b) => s + countTokens(b.summary), 0),
|
|
1902
|
+
targetBlocks: t2
|
|
1903
|
+
};
|
|
1798
1904
|
return out;
|
|
1799
1905
|
}
|
|
1800
1906
|
function decideNudge(input) {
|
|
@@ -1882,18 +1988,35 @@ function decideNudge(input) {
|
|
|
1882
1988
|
const eligible = tiersList.filter((t) => config.tiers.enabled || t === 1);
|
|
1883
1989
|
const ready = eligible.filter((t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens).map((t) => `T${t} ${tiers[t].pending}`);
|
|
1884
1990
|
const readyHint = ready.length > 0 ? `, ready: ${ready.join(", ")}` : "";
|
|
1885
|
-
const blocked = eligible.filter(
|
|
1991
|
+
const blocked = eligible.filter(
|
|
1992
|
+
(t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens && (state.nudge.lastShownByTier[t] ?? 0) > 0 && tokenCount - (state.nudge.lastShownByTier[t] ?? 0) < growthFloor
|
|
1993
|
+
).map((t) => `T${t} (cadence)`);
|
|
1886
1994
|
const blockedHint = blocked.length > 0 ? `, blocked: ${blocked.join(", ")}` : "";
|
|
1887
|
-
const maxPending = Math.max(
|
|
1995
|
+
const maxPending = Math.max(
|
|
1996
|
+
0,
|
|
1997
|
+
...Object.values(tiers).map((t) => t.pending)
|
|
1998
|
+
);
|
|
1888
1999
|
const pendingShort = maxPending < nudgeGrowthTokens;
|
|
1889
2000
|
const growthShort = growthSinceReference < growthFloor;
|
|
1890
2001
|
const parts = [];
|
|
1891
|
-
if (pendingShort)
|
|
1892
|
-
|
|
1893
|
-
|
|
2002
|
+
if (pendingShort)
|
|
2003
|
+
parts.push(
|
|
2004
|
+
`max compressible ${maxPending} < threshold ${nudgeGrowthTokens}`
|
|
2005
|
+
);
|
|
2006
|
+
if (growthShort)
|
|
2007
|
+
parts.push(`growth ${growthSinceReference} < floor ${growthFloor}`);
|
|
2008
|
+
if (parts.length === 0)
|
|
2009
|
+
parts.push(
|
|
2010
|
+
`max compressible ${maxPending}, growth ${growthSinceReference}`
|
|
2011
|
+
);
|
|
1894
2012
|
reason = `${parts.join("; ")}${readyHint}${blockedHint}`;
|
|
1895
2013
|
}
|
|
1896
|
-
const ctxBreakdown = computeContextBreakdown(
|
|
2014
|
+
const ctxBreakdown = computeContextBreakdown(
|
|
2015
|
+
input.messages,
|
|
2016
|
+
tokenCount,
|
|
2017
|
+
growthSinceReference,
|
|
2018
|
+
countTokens
|
|
2019
|
+
);
|
|
1897
2020
|
return {
|
|
1898
2021
|
shouldInject,
|
|
1899
2022
|
reason,
|
|
@@ -2782,6 +2905,7 @@ export {
|
|
|
2782
2905
|
assignRefs,
|
|
2783
2906
|
blockById,
|
|
2784
2907
|
blockDocs,
|
|
2908
|
+
blockVisibleInRange,
|
|
2785
2909
|
buildRecap,
|
|
2786
2910
|
buildRestoredContentPreview,
|
|
2787
2911
|
buildStatusReport,
|
|
@@ -2811,6 +2935,8 @@ export {
|
|
|
2811
2935
|
highestUsedIndex,
|
|
2812
2936
|
indexToRef,
|
|
2813
2937
|
isMessageProtected,
|
|
2938
|
+
isRenderedSummaryMessage,
|
|
2939
|
+
isSummaryMessageId,
|
|
2814
2940
|
listMessageFilters,
|
|
2815
2941
|
listSearchAlgorithms,
|
|
2816
2942
|
makeIO,
|
|
@@ -2835,9 +2961,11 @@ export {
|
|
|
2835
2961
|
searchBlocks,
|
|
2836
2962
|
searchBlocksAsync,
|
|
2837
2963
|
setDocCacheCap,
|
|
2964
|
+
summaryMessageId,
|
|
2838
2965
|
syncBlocks,
|
|
2839
2966
|
truncateLargeToolOutputs,
|
|
2840
2967
|
validateConfig,
|
|
2841
|
-
viableRanges
|
|
2968
|
+
viableRanges,
|
|
2969
|
+
visibleBlockAnchor
|
|
2842
2970
|
};
|
|
2843
2971
|
//# sourceMappingURL=index.js.map
|