acp-kernel 0.0.45 → 0.0.46-pr.165.20
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 +24 -13
- package/dist/index.js.map +1 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.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;AAchF,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,GAC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@@ function decideNudge(input) {
|
|
|
2549
2549
|
const t1Eff = tiers[1]?.pending ?? 0;
|
|
2550
2550
|
const t2Pen = tiers[2]?.pending ?? 0;
|
|
2551
2551
|
const t3Pen = tiers[3]?.pending ?? 0;
|
|
2552
|
+
const t2Count = tiers[2]?.targetBlocks.length ?? 0;
|
|
2553
|
+
const t3Count = tiers[3]?.targetBlocks.length ?? 0;
|
|
2552
2554
|
if (pressure) {
|
|
2553
2555
|
const candidates = [1];
|
|
2554
2556
|
if (config.tiers.enabled) {
|
|
@@ -2572,19 +2574,19 @@ function decideNudge(input) {
|
|
|
2572
2574
|
if (t1Eff >= nudgeGrowthTokens) {
|
|
2573
2575
|
injectedTier = 1;
|
|
2574
2576
|
injectedReason = `T1 effective ${t1Eff} >= ${nudgeGrowthTokens}, growth ${growthSinceReference}, usage ${Math.round(usage * 100)}%`;
|
|
2575
|
-
} else if (config.tiers.enabled && t2Pen >= tier2Threshold && t2Pen > t1Eff) {
|
|
2577
|
+
} else if (config.tiers.enabled && (t2Count >= config.tiers.tier2Trigger || t2Pen >= tier2Threshold && t2Pen > t1Eff)) {
|
|
2576
2578
|
const lastShown = state.nudge.lastShownByTier[2] ?? 0;
|
|
2577
2579
|
const cadenceMet = lastShown === 0 || tokenCount - lastShown >= growthFloor;
|
|
2578
2580
|
if (cadenceMet) {
|
|
2579
2581
|
injectedTier = 2;
|
|
2580
|
-
injectedReason = `T2 distill ready: ${tiers[2].targetBlocks.length} tier-1 blocks (${t2Pen} tokens) >= ${tier2Threshold} (1.5x) and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
|
|
2582
|
+
injectedReason = t2Count >= config.tiers.tier2Trigger ? `T2 distill ready: ${t2Count} tier-1 blocks >= tier2Trigger ${config.tiers.tier2Trigger} (${t2Pen} tokens), usage ${Math.round(usage * 100)}%` : `T2 distill ready: ${tiers[2].targetBlocks.length} tier-1 blocks (${t2Pen} tokens) >= ${tier2Threshold} (1.5x) and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
|
|
2581
2583
|
}
|
|
2582
|
-
} else if (config.tiers.enabled && t3Pen >= tier2Threshold && t3Pen > t2Pen && t3Pen > t1Eff) {
|
|
2584
|
+
} else if (config.tiers.enabled && (t3Count >= config.tiers.tier3Trigger || t3Pen >= tier2Threshold && t3Pen > t2Pen && t3Pen > t1Eff)) {
|
|
2583
2585
|
const lastShown = state.nudge.lastShownByTier[3] ?? 0;
|
|
2584
2586
|
const cadenceMet = lastShown === 0 || tokenCount - lastShown >= growthFloor;
|
|
2585
2587
|
if (cadenceMet) {
|
|
2586
2588
|
injectedTier = 3;
|
|
2587
|
-
injectedReason = `T3 condense ready: ${tiers[3].targetBlocks.length} tier-2 blocks (${t3Pen} tokens) >= ${tier2Threshold} (1.5x) and > T2 ${t2Pen} and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
|
|
2589
|
+
injectedReason = t3Count >= config.tiers.tier3Trigger ? `T3 condense ready: ${t3Count} tier-2 blocks >= tier3Trigger ${config.tiers.tier3Trigger} (${t3Pen} tokens), usage ${Math.round(usage * 100)}%` : `T3 condense ready: ${tiers[3].targetBlocks.length} tier-2 blocks (${t3Pen} tokens) >= ${tier2Threshold} (1.5x) and > T2 ${t2Pen} and > T1 effective ${t1Eff}, usage ${Math.round(usage * 100)}%`;
|
|
2588
2590
|
}
|
|
2589
2591
|
}
|
|
2590
2592
|
}
|
|
@@ -2598,10 +2600,13 @@ function decideNudge(input) {
|
|
|
2598
2600
|
} else {
|
|
2599
2601
|
const tiersList = [1, 2, 3];
|
|
2600
2602
|
const eligible = tiersList.filter((t) => config.tiers.enabled || t === 1);
|
|
2603
|
+
const countReady = (t) => t === 2 ? t2Count >= config.tiers.tier2Trigger : t === 3 ? t3Count >= config.tiers.tier3Trigger : false;
|
|
2601
2604
|
const ready = eligible.filter((t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens).map((t) => `T${t} ${tiers[t].pending}`);
|
|
2602
|
-
const
|
|
2605
|
+
const readyCount = eligible.filter((t) => (tiers[t]?.pending ?? 0) < nudgeGrowthTokens && countReady(t)).map((t) => `T${t} ${t === 2 ? t2Count : t3Count} blocks (count)`);
|
|
2606
|
+
const readyAll = [...ready, ...readyCount];
|
|
2607
|
+
const readyHint = readyAll.length > 0 ? `, ready: ${readyAll.join(", ")}` : "";
|
|
2603
2608
|
const blocked = eligible.filter(
|
|
2604
|
-
(t) => (tiers[t]?.pending ?? 0) >= nudgeGrowthTokens && (state.nudge.lastShownByTier[t] ?? 0) > 0 && tokenCount - (state.nudge.lastShownByTier[t] ?? 0) < growthFloor
|
|
2609
|
+
(t) => ((tiers[t]?.pending ?? 0) >= nudgeGrowthTokens || countReady(t)) && (state.nudge.lastShownByTier[t] ?? 0) > 0 && tokenCount - (state.nudge.lastShownByTier[t] ?? 0) < growthFloor
|
|
2605
2610
|
).map((t) => `T${t} (cadence)`);
|
|
2606
2611
|
const blockedHint = blocked.length > 0 ? `, blocked: ${blocked.join(", ")}` : "";
|
|
2607
2612
|
const maxPending = Math.max(
|
|
@@ -2909,7 +2914,7 @@ function collectVisible(messages, state, countTokens) {
|
|
|
2909
2914
|
if (!ref) return;
|
|
2910
2915
|
const tokens = countTokens(message.text ?? "");
|
|
2911
2916
|
const tool = message.toolName ?? "text";
|
|
2912
|
-
if (tokens > 0) visible.push({ ref, tokens, tool, index });
|
|
2917
|
+
if (tokens > 0) visible.push({ ref, tokens, tool, index, isUser: message.role === "user" });
|
|
2913
2918
|
});
|
|
2914
2919
|
return { visible, summaryTokens };
|
|
2915
2920
|
}
|
|
@@ -2928,7 +2933,7 @@ function buildStatusReport(state, messages, countTokens, options = {}) {
|
|
|
2928
2933
|
if (view === "messages") {
|
|
2929
2934
|
return renderMessageDrilldown(visible, toolFilter, sort, limit);
|
|
2930
2935
|
}
|
|
2931
|
-
return renderUncompressedRanges(visible);
|
|
2936
|
+
return renderUncompressedRanges(visible, sort, limit);
|
|
2932
2937
|
}
|
|
2933
2938
|
return renderOverview(visible, summaryTokens, activeBlocks2, state, countTokens, limit);
|
|
2934
2939
|
}
|
|
@@ -2983,7 +2988,7 @@ function renderOverview(visible, summaryTokens, blocks, state, countTokens, limi
|
|
|
2983
2988
|
);
|
|
2984
2989
|
return lines.join("\n");
|
|
2985
2990
|
}
|
|
2986
|
-
function renderUncompressedRanges(visible) {
|
|
2991
|
+
function renderUncompressedRanges(visible, sort, limit) {
|
|
2987
2992
|
const lines = [];
|
|
2988
2993
|
const totalTokens = visible.reduce((s, m) => s + m.tokens, 0);
|
|
2989
2994
|
lines.push(`UNCOMPRESSED \u2014 ${formatTokens2(totalTokens)} | ${visible.length} visible messages`);
|
|
@@ -3000,7 +3005,9 @@ function renderUncompressedRanges(visible) {
|
|
|
3000
3005
|
for (const m of visible) {
|
|
3001
3006
|
const num = refNum2(m.ref);
|
|
3002
3007
|
const last = merged[merged.length - 1];
|
|
3003
|
-
|
|
3008
|
+
const contiguous = !!last && num === last.startNum + last.count;
|
|
3009
|
+
const turnBoundary = !!last && m.isUser && last.count >= 3;
|
|
3010
|
+
if (contiguous && !turnBoundary) {
|
|
3004
3011
|
last.endRef = m.ref;
|
|
3005
3012
|
last.count += 1;
|
|
3006
3013
|
last.tokens += m.tokens;
|
|
@@ -3008,12 +3015,16 @@ function renderUncompressedRanges(visible) {
|
|
|
3008
3015
|
merged.push({ startRef: m.ref, endRef: m.ref, startNum: num, count: 1, tokens: m.tokens, tool: m.tool });
|
|
3009
3016
|
}
|
|
3010
3017
|
}
|
|
3011
|
-
|
|
3018
|
+
if (sort !== "time") merged.sort((a, b) => b.tokens - a.tokens || a.startNum - b.startNum);
|
|
3019
|
+
lines.push(`Sorted by ${sort === "time" ? "time" : "size"}`);
|
|
3020
|
+
lines.push("");
|
|
3021
|
+
const shown = merged.slice(0, limit);
|
|
3022
|
+
for (const r of shown) {
|
|
3012
3023
|
const range = r.count === 1 ? r.startRef : `${r.startRef}\u2013${r.endRef}`;
|
|
3013
3024
|
lines.push(` ${range} (${r.count} msgs, ${formatTokens2(r.tokens)}${r.count > 1 ? ` (${Math.round(r.tokens / r.count)}/msg)` : ""}) ${r.tool}`);
|
|
3014
3025
|
}
|
|
3015
|
-
if (merged.length >
|
|
3016
|
-
lines.push(` ... and ${merged.length -
|
|
3026
|
+
if (merged.length > shown.length) {
|
|
3027
|
+
lines.push(` ... and ${merged.length - shown.length} more ranges`);
|
|
3017
3028
|
}
|
|
3018
3029
|
return lines.join("\n");
|
|
3019
3030
|
}
|