acp-kernel 0.0.77-pr.326.191 → 0.0.77-pr.327.192
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 +38 -4
- 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,EAGlB,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,QAA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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;AA2GD,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAgV7D;AA0jCD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2411,6 +2411,39 @@ function danglingMessageRefs(state, messages, spec) {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
return dangling;
|
|
2413
2413
|
}
|
|
2414
|
+
function coveringBlockIds(state, spec) {
|
|
2415
|
+
const found = /* @__PURE__ */ new Set();
|
|
2416
|
+
for (const ref of [spec.startRef, spec.endRef]) {
|
|
2417
|
+
const parsed = parseBoundary(ref);
|
|
2418
|
+
if (!parsed) continue;
|
|
2419
|
+
let rawIds = [];
|
|
2420
|
+
if (parsed.kind === "message") {
|
|
2421
|
+
const rawId = state.messageRefs.byRef[parsed.raw] ?? state.messageRefs.byRef[indexToRef(parsed.numericId)];
|
|
2422
|
+
if (rawId) rawIds = [rawId];
|
|
2423
|
+
} else {
|
|
2424
|
+
rawIds = blockById(state, `b${parsed.numericId}`)?.effectiveMessageIds ?? [];
|
|
2425
|
+
}
|
|
2426
|
+
if (rawIds.length === 0) continue;
|
|
2427
|
+
for (const candidate of activeBlocks(state)) {
|
|
2428
|
+
if (rawIds.some((id) => candidate.effectiveMessageIds.includes(id))) {
|
|
2429
|
+
found.add(candidate.blockId);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
return [...found].sort((x, y) => numericBlockId(x) - numericBlockId(y));
|
|
2434
|
+
}
|
|
2435
|
+
function tierActionHint(config, state) {
|
|
2436
|
+
if (!config.tiers.enabled) return "";
|
|
2437
|
+
const t2 = activeBlocks(state).filter((b) => b.tier === 2);
|
|
2438
|
+
if (t2.length >= config.tiers.tier3Trigger) {
|
|
2439
|
+
return ` Tier condensation is actionable now: compress({ content: [{ startId: "${t2[0].blockId}", endId: "${t2[t2.length - 1].blockId}", summary: "...", topic: "..." }] }) merges those tier-2 blocks into one tier-3 block.`;
|
|
2440
|
+
}
|
|
2441
|
+
const t1 = activeBlocks(state).filter((b) => b.tier === 1);
|
|
2442
|
+
if (t1.length >= config.tiers.tier2Trigger) {
|
|
2443
|
+
return ` Tier distillation is actionable now: compress({ content: [{ startId: "${t1[0].blockId}", endId: "${t1[t1.length - 1].blockId}", summary: "...", topic: "..." }] }) merges those tier-1 blocks into one tier-2 block.`;
|
|
2444
|
+
}
|
|
2445
|
+
return "";
|
|
2446
|
+
}
|
|
2414
2447
|
function createCore(ports = {}) {
|
|
2415
2448
|
const countTokens = ports.countTokens ?? defaultCountTokens;
|
|
2416
2449
|
function applyCompression(input) {
|
|
@@ -2509,17 +2542,18 @@ function createCore(ports = {}) {
|
|
|
2509
2542
|
}
|
|
2510
2543
|
}
|
|
2511
2544
|
if (!hasBlockBoundaryRange && totalRangeChars < input.config.compress.minCompressRange) {
|
|
2512
|
-
const live = activeBlocks(state).map((b) => b.blockId).sort((x, y) => numericBlockId(x) - numericBlockId(y));
|
|
2513
|
-
const liveHint = live.length > 0 ? ` Current active blocks span ${live[0]}..${live[live.length - 1]} \u2014 retry with startId/endId set to active block IDs in that span.` : "";
|
|
2514
2545
|
const diagnostics = refGateDiagnostics(
|
|
2515
2546
|
state,
|
|
2516
2547
|
input.ranges.length,
|
|
2517
2548
|
unknownCount
|
|
2518
2549
|
);
|
|
2550
|
+
const firstConsumed = consumedRanges[0];
|
|
2551
|
+
const covering = firstConsumed ? coveringBlockIds(state, firstConsumed) : [];
|
|
2552
|
+
const coverDetail = covering.length > 0 ? `its content is already summarized in active block(s) ${covering.join(", ")}${covering.length === 1 ? ` \u2014 use search_context or decompress ${covering[0]} if you need details from it` : ""}` : `its refs no longer point to directly compressible content (stale block ref(s) distilled or consumed by higher-tier blocks)`;
|
|
2519
2553
|
const danglingRefs = consumedRanges.flatMap(
|
|
2520
2554
|
(spec) => danglingMessageRefs(state, input.messages, spec)
|
|
2521
2555
|
);
|
|
2522
|
-
const gateMessage = resolvableCount === 0 && consumedRanges.length === 0 && unknownCount > 0 ? `None of the ${input.ranges.length} requested range(s) resolved \u2014 every ref is unknown to this session. Refs are per-session snapshots, assigned once when a message is first rendered; no compress reassigns them, so unknown refs cannot come from an earlier compress in this session. They come from a different generation: a previous session instance (switching model or upstream mid-conversation starts a fresh session whose refs restart at m00001), the generation before a native-compaction rebase (which also resets refs to m00001), or a typo. ${diagnostics} Run acp_status, then call the compress tool again using only the refs it reports.` : consumedRanges.length > 0 ? danglingRefs.length > 0 ? `Requested range(s) cannot be anchored (e.g. ${
|
|
2556
|
+
const gateMessage = resolvableCount === 0 && consumedRanges.length === 0 && unknownCount > 0 ? `None of the ${input.ranges.length} requested range(s) resolved \u2014 every ref is unknown to this session. Refs are per-session snapshots, assigned once when a message is first rendered; no compress reassigns them, so unknown refs cannot come from an earlier compress in this session. They come from a different generation: a previous session instance (switching model or upstream mid-conversation starts a fresh session whose refs restart at m00001), the generation before a native-compaction rebase (which also resets refs to m00001), or a typo. ${diagnostics} Run acp_status, then call the compress tool again using only the refs it reports.` : consumedRanges.length > 0 ? danglingRefs.length > 0 ? `Requested range(s) cannot be anchored (e.g. ${firstConsumed.startRef}..${firstConsumed.endRef}) \u2014 the refs exist in this session's ref map, but the messages they point to are no longer in the visible context and no active block covers them: the message content changed (or the message was filtered out of the view) and now carries a new ref, leaving your old refs dangling. ${diagnostics} Run acp_status, then call the compress tool again using only the refs it reports.` : `Requested range(s) already compressed (e.g. ${firstConsumed.startRef}..${firstConsumed.endRef}) \u2014 ${coverDetail}. Nothing new to compress in that window. ${diagnostics} Continue the task, or run acp_status and target one of the CURRENT compressible ranges it reports.${tierActionHint(input.config, state)}` : `Total compressible content too small (${totalRangeChars} chars across ${countedRanges} range(s), min ${input.config.compress.minCompressRange}). Combine more messages into your range(s) to meet the threshold.`;
|
|
2523
2557
|
return {
|
|
2524
2558
|
state: input.state,
|
|
2525
2559
|
result: {
|
|
@@ -2926,7 +2960,7 @@ function applySingleRange(input) {
|
|
|
2926
2960
|
warnings.push(
|
|
2927
2961
|
`Excluded ${hitProtectedRaw.length} protected message(s) ${hitRefs.join(
|
|
2928
2962
|
", "
|
|
2929
|
-
)} from compression range (recent/last-user zone).`
|
|
2963
|
+
)} from compression range (recent/last-user zone) \u2014 they stay visible outside the new block; do not target them in another compress call.`
|
|
2930
2964
|
);
|
|
2931
2965
|
}
|
|
2932
2966
|
{
|