billion-context-omp 0.1.4 → 0.1.6
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-tool.d.ts +0 -1
- package/dist/index.js +194 -116
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +0 -11
- package/package.json +3 -2
package/dist/compress-tool.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { AcpRuntime } from "./runtime.js";
|
|
|
3
3
|
/** Label shown for a block when the model did not pass a topic: first
|
|
4
4
|
* sentence-ish slice of the summary (≤30 chars). Decorative only — never
|
|
5
5
|
* blocks compression. */
|
|
6
|
-
export declare function topicFallback(summary: string): string;
|
|
7
6
|
declare const CompressParams: import("@oh-my-pi/omptype").FluentType<{
|
|
8
7
|
content: {
|
|
9
8
|
endId: string;
|
package/dist/index.js
CHANGED
|
@@ -126,9 +126,11 @@ function prune(messages, state, options = {}) {
|
|
|
126
126
|
const indexById = /* @__PURE__ */ new Map();
|
|
127
127
|
messages.forEach((message, index) => indexById.set(message.id, index));
|
|
128
128
|
const anchors = inject ? collectSummaryAnchors(state, indexById) : [];
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
return stripOrphanedReasoning(
|
|
130
|
+
stripOrphanedToolResults(
|
|
131
|
+
stripOrphanedToolCalls(
|
|
132
|
+
rebuildMessages(messages, covered, firstUserIndex, anchors)
|
|
133
|
+
)
|
|
132
134
|
)
|
|
133
135
|
);
|
|
134
136
|
}
|
|
@@ -205,6 +207,24 @@ function stripOrphanedToolCalls(messages) {
|
|
|
205
207
|
(m) => m.contentType !== "tool-call" || !m.toolCallId || m.toolName === "compress" || knownResultIds.has(m.toolCallId)
|
|
206
208
|
);
|
|
207
209
|
}
|
|
210
|
+
function stripOrphanedReasoning(messages) {
|
|
211
|
+
const drop = /* @__PURE__ */ new Set();
|
|
212
|
+
for (let i = 0; i < messages.length; i++) {
|
|
213
|
+
if (drop.has(i)) continue;
|
|
214
|
+
if (messages[i].contentType !== "reasoning") continue;
|
|
215
|
+
let j = i;
|
|
216
|
+
while (j + 1 < messages.length && messages[j + 1].contentType === "reasoning") {
|
|
217
|
+
j++;
|
|
218
|
+
}
|
|
219
|
+
const companion = messages[j + 1];
|
|
220
|
+
const hasCompanion = companion !== void 0 && companion.role === "assistant" && (companion.contentType === "text" || companion.contentType === "tool-call");
|
|
221
|
+
if (!hasCompanion) {
|
|
222
|
+
for (let k = i; k <= j; k++) drop.add(k);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (drop.size === 0) return messages;
|
|
226
|
+
return messages.filter((_, i) => !drop.has(i));
|
|
227
|
+
}
|
|
208
228
|
function syncBlocks(messages, state) {
|
|
209
229
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
210
230
|
const deactivated = [];
|
|
@@ -814,6 +834,38 @@ function adjustBoundariesForToolPairs(startIndex, endIndex, messages, maxScan =
|
|
|
814
834
|
}
|
|
815
835
|
return { startIndex: newStartIndex, endIndex: newEndIndex };
|
|
816
836
|
}
|
|
837
|
+
function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
|
|
838
|
+
if (startIndex > endIndex) {
|
|
839
|
+
return { startIndex, endIndex };
|
|
840
|
+
}
|
|
841
|
+
let newStartIndex = startIndex;
|
|
842
|
+
let newEndIndex = endIndex;
|
|
843
|
+
for (let i = startIndex; i <= endIndex && i < messages.length; i++) {
|
|
844
|
+
const msg = messages[i];
|
|
845
|
+
if (!msg) continue;
|
|
846
|
+
if (msg.contentType === "reasoning") {
|
|
847
|
+
let j = i;
|
|
848
|
+
while (j + 1 < messages.length && messages[j + 1].contentType === "reasoning") {
|
|
849
|
+
j++;
|
|
850
|
+
}
|
|
851
|
+
const companion = messages[j + 1];
|
|
852
|
+
if (companion !== void 0 && companion.role === "assistant" && (companion.contentType === "text" || companion.contentType === "tool-call") && j + 1 > newEndIndex) {
|
|
853
|
+
newEndIndex = j + 1;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (msg.role === "assistant" && (msg.contentType === "text" || msg.contentType === "tool-call")) {
|
|
857
|
+
let k = i - 1;
|
|
858
|
+
while (k >= 0 && messages[k].contentType === "reasoning") {
|
|
859
|
+
k--;
|
|
860
|
+
}
|
|
861
|
+
const runStart = k + 1;
|
|
862
|
+
if (runStart < i && runStart >= 0 && messages[runStart].contentType === "reasoning" && runStart < newStartIndex) {
|
|
863
|
+
newStartIndex = runStart;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return { startIndex: newStartIndex, endIndex: newEndIndex };
|
|
868
|
+
}
|
|
817
869
|
function refNum(ref) {
|
|
818
870
|
const n = parseInt(ref.slice(1), 10);
|
|
819
871
|
return Number.isNaN(n) ? -1 : n;
|
|
@@ -1309,7 +1361,7 @@ function applySingleRange(input) {
|
|
|
1309
1361
|
messages: input.messages,
|
|
1310
1362
|
state: input.state
|
|
1311
1363
|
});
|
|
1312
|
-
const rangeMessageIds =
|
|
1364
|
+
const rangeMessageIds = applyPairBoundaryAdjustments(
|
|
1313
1365
|
resolved,
|
|
1314
1366
|
input.messages
|
|
1315
1367
|
);
|
|
@@ -1423,20 +1475,33 @@ function applySingleRange(input) {
|
|
|
1423
1475
|
}
|
|
1424
1476
|
return { tokens: compressedTokens, warnings };
|
|
1425
1477
|
}
|
|
1426
|
-
function
|
|
1478
|
+
function applyPairBoundaryAdjustments(resolved, messages) {
|
|
1427
1479
|
if (resolved.boundaryKind === "block") {
|
|
1428
1480
|
return resolved.messageIds;
|
|
1429
1481
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1482
|
+
let startIndex = resolved.startIndex;
|
|
1483
|
+
let endIndex = resolved.endIndex;
|
|
1484
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
1485
|
+
const reasoningAdjusted = adjustBoundariesForReasoningPairs(
|
|
1486
|
+
startIndex,
|
|
1487
|
+
endIndex,
|
|
1488
|
+
messages
|
|
1489
|
+
);
|
|
1490
|
+
const toolAdjusted = adjustBoundariesForToolPairs(
|
|
1491
|
+
reasoningAdjusted.startIndex,
|
|
1492
|
+
reasoningAdjusted.endIndex,
|
|
1493
|
+
messages
|
|
1494
|
+
);
|
|
1495
|
+
const changed = toolAdjusted.startIndex !== startIndex || toolAdjusted.endIndex !== endIndex;
|
|
1496
|
+
startIndex = toolAdjusted.startIndex;
|
|
1497
|
+
endIndex = toolAdjusted.endIndex;
|
|
1498
|
+
if (!changed) break;
|
|
1499
|
+
}
|
|
1500
|
+
if (startIndex === resolved.startIndex && endIndex === resolved.endIndex) {
|
|
1436
1501
|
return resolved.messageIds;
|
|
1437
1502
|
}
|
|
1438
1503
|
const ids = [];
|
|
1439
|
-
for (let i =
|
|
1504
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
1440
1505
|
const msg = messages[i];
|
|
1441
1506
|
if (msg) ids.push(msg.id);
|
|
1442
1507
|
}
|
|
@@ -3003,10 +3068,6 @@ function boundaryRaw(ref, byRef, blocks, pick) {
|
|
|
3003
3068
|
const pos = (id) => rawPos(byRef[id] ?? id);
|
|
3004
3069
|
return pick === "min" ? ids.reduce((a, b) => pos(a) <= pos(b) ? a : b) : ids.reduce((a, b) => pos(a) >= pos(b) ? a : b);
|
|
3005
3070
|
}
|
|
3006
|
-
var VIABLE_RANGE_MIN_TOKENS = 200;
|
|
3007
|
-
function viableRanges(ranges) {
|
|
3008
|
-
return ranges.filter((r) => r.tokens >= VIABLE_RANGE_MIN_TOKENS);
|
|
3009
|
-
}
|
|
3010
3071
|
function rangeFingerprints(ranges, coreMessages, byRef, blocks) {
|
|
3011
3072
|
return ranges.map((r) => {
|
|
3012
3073
|
const start = boundaryRaw(r.startRef, byRef, blocks, "min");
|
|
@@ -3240,11 +3301,6 @@ var RangeSpec = type({
|
|
|
3240
3301
|
summary: type("string").describe("Complete technical summary replacing all content in range. Keep only essential details (conclusions, file paths, decisions, exact values, etc.)."),
|
|
3241
3302
|
"topic?": type("string").describe("Short label (3-5 words) for THIS range, e.g. 'Auth System Exploration'. Recommended for every range; omit to use top-level topic.")
|
|
3242
3303
|
});
|
|
3243
|
-
function topicFallback(summary) {
|
|
3244
|
-
const first = summary.split(/[.\n]/)[0] ?? "";
|
|
3245
|
-
const t = first.trim().replace(/^["'`]+/, "").trim();
|
|
3246
|
-
return t.length <= 30 ? t : `${t.slice(0, 30).trimEnd()}\u2026`;
|
|
3247
|
-
}
|
|
3248
3304
|
var CompressParams = type({
|
|
3249
3305
|
"topic?": type("string").describe("Fallback topic for entries without their own. Omit when each content entry specifies its own topic."),
|
|
3250
3306
|
content: RangeSpec.array().describe("One or more ranges to compress, each with start/end boundaries and a summary. When compressing multiple unrelated ranges in one call, give each its own topic."),
|
|
@@ -3623,6 +3679,112 @@ function truncate(s, n) {
|
|
|
3623
3679
|
|
|
3624
3680
|
// src/status-tool.ts
|
|
3625
3681
|
import { type as type4 } from "@oh-my-pi/omptype";
|
|
3682
|
+
|
|
3683
|
+
// node_modules/billion-context-kit/dist/index.js
|
|
3684
|
+
var VIABLE_RANGE_MIN_TOKENS = 200;
|
|
3685
|
+
function viableRanges(ranges) {
|
|
3686
|
+
return ranges.filter((r) => r.tokens >= VIABLE_RANGE_MIN_TOKENS);
|
|
3687
|
+
}
|
|
3688
|
+
function topicFallback(summary) {
|
|
3689
|
+
const first = summary.split(/[.\n]/)[0] ?? "";
|
|
3690
|
+
const t = first.trim().replace(/^["'`]+/, "").trim();
|
|
3691
|
+
return t.length <= 30 ? t : `${t.slice(0, 30).trimEnd()}\u2026`;
|
|
3692
|
+
}
|
|
3693
|
+
function formatCompactTokens(count) {
|
|
3694
|
+
if (count < 1e3) return count.toString();
|
|
3695
|
+
if (count < 1e4) return `${(count / 1e3).toFixed(1)}k`;
|
|
3696
|
+
if (count < 1e6) return `${Math.round(count / 1e3)}k`;
|
|
3697
|
+
if (count < 1e7) return `${(count / 1e6).toFixed(1)}M`;
|
|
3698
|
+
return `${Math.round(count / 1e6)}M`;
|
|
3699
|
+
}
|
|
3700
|
+
function bar(value, total, width = 20) {
|
|
3701
|
+
if (total === 0) return "";
|
|
3702
|
+
const filled = Math.max(0, Math.min(width, Math.round(value / total * width)));
|
|
3703
|
+
return "\u2588".repeat(filled) + "\u2591".repeat(width - filled);
|
|
3704
|
+
}
|
|
3705
|
+
function buildStatusPanel(input) {
|
|
3706
|
+
const { tokenCount, state, nudge, modelContextLimit } = input;
|
|
3707
|
+
const fmt2 = input.fmtTokens ?? formatCompactTokens;
|
|
3708
|
+
const bd = nudge?.contextBreakdown;
|
|
3709
|
+
const limit = modelContextLimit;
|
|
3710
|
+
const classified = bd ? bd.system + bd.tool + bd.summaries + bd.code + bd.text : 0;
|
|
3711
|
+
const systemPromptTokens = input.systemPromptTokens;
|
|
3712
|
+
const sentTotal = classified + systemPromptTokens;
|
|
3713
|
+
const sessionOnly = Math.max(0, tokenCount - sentTotal);
|
|
3714
|
+
const displayTotal = tokenCount;
|
|
3715
|
+
const displayPct = limit > 0 ? Math.round(displayTotal / limit * 100) : 0;
|
|
3716
|
+
const activeBlocksList = state.blocks.filter((b) => b.active);
|
|
3717
|
+
const totalBlocksList = state.blocks;
|
|
3718
|
+
const lines = [];
|
|
3719
|
+
lines.push("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E");
|
|
3720
|
+
lines.push("\u2502 ACP Context Analysis \u2502");
|
|
3721
|
+
lines.push("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");
|
|
3722
|
+
if (input.version) lines.push(input.version);
|
|
3723
|
+
lines.push("");
|
|
3724
|
+
lines.push(`Context (session accounting): ${displayPct}% (${fmt2(displayTotal)} / ${fmt2(limit)})`);
|
|
3725
|
+
if (nudge && bd) {
|
|
3726
|
+
const growth = bd.growth;
|
|
3727
|
+
if (growth > 0 && displayTotal > 0) {
|
|
3728
|
+
lines.push(`Growth: +${fmt2(growth)} since last nudge`);
|
|
3729
|
+
}
|
|
3730
|
+
lines.push("");
|
|
3731
|
+
lines.push(`Sent to LLM (after compression): ${fmt2(sentTotal)}`);
|
|
3732
|
+
if (sessionOnly > 0) {
|
|
3733
|
+
lines.push(`Session-only (compressed originals + host overhead): ${fmt2(sessionOnly)} \u2014 pruned from every request; the footer counts it`);
|
|
3734
|
+
}
|
|
3735
|
+
lines.push("");
|
|
3736
|
+
lines.push("Token Breakdown (sent view):");
|
|
3737
|
+
const categories = [
|
|
3738
|
+
{ label: "Tool", value: bd.tool },
|
|
3739
|
+
{ label: "SysPrompt", value: systemPromptTokens },
|
|
3740
|
+
{ label: "Text", value: bd.text },
|
|
3741
|
+
{ label: "Code", value: bd.code },
|
|
3742
|
+
{ label: "Summaries", value: bd.summaries }
|
|
3743
|
+
];
|
|
3744
|
+
for (const cat of categories) {
|
|
3745
|
+
if (cat.value <= 0) continue;
|
|
3746
|
+
const pct2 = sentTotal > 0 ? Math.round(cat.value / sentTotal * 100) : 0;
|
|
3747
|
+
const b = bar(cat.value, sentTotal);
|
|
3748
|
+
lines.push(` ${cat.label.padEnd(10)} ${b} ${String(pct2).padStart(3)}% ${fmt2(cat.value)}`);
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
lines.push("");
|
|
3752
|
+
if (nudge) {
|
|
3753
|
+
if (nudge.shouldInject) {
|
|
3754
|
+
const tierInfo = nudge.tier ? ` [T${nudge.tier} distillation]` : "";
|
|
3755
|
+
lines.push(`Nudge: ACTIVE${tierInfo} \u2014 ${nudge.reason}`);
|
|
3756
|
+
} else {
|
|
3757
|
+
lines.push(`Nudge: idle \u2014 ${nudge.reason}`);
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
const ranges = viableRanges(nudge?.compressibleRanges ?? []);
|
|
3761
|
+
const protectedRanges = nudge?.protectedRanges ?? [];
|
|
3762
|
+
if (ranges.length > 0 || protectedRanges.length > 0) {
|
|
3763
|
+
lines.push("");
|
|
3764
|
+
lines.push(formatRanges(ranges, protectedRanges));
|
|
3765
|
+
}
|
|
3766
|
+
if (activeBlocksList.length > 0) {
|
|
3767
|
+
lines.push("");
|
|
3768
|
+
lines.push(`Blocks: ${activeBlocksList.length} active / ${totalBlocksList.length} total (${fmt2(state.stats.tokensCompressed)} tokens compressed)`);
|
|
3769
|
+
for (const b of activeBlocksList) {
|
|
3770
|
+
const topic = b.topic ? `: ${b.topic}` : `: ${topicFallback(b.summary || "")}`;
|
|
3771
|
+
const summaryTok = defaultCountTokens(b.summary || "");
|
|
3772
|
+
const origTok = b.compressedTokens > 0 ? b.compressedTokens : summaryTok;
|
|
3773
|
+
lines.push(` [${b.blockId}] T${b.tier} ${fmt2(origTok)}\u2192${fmt2(summaryTok)}${topic}`);
|
|
3774
|
+
}
|
|
3775
|
+
} else if (totalBlocksList.length > 0) {
|
|
3776
|
+
lines.push("");
|
|
3777
|
+
lines.push(`Blocks: 0 active / ${totalBlocksList.length} total (${fmt2(state.stats.tokensCompressed)} tokens compressed)`);
|
|
3778
|
+
} else {
|
|
3779
|
+
lines.push("");
|
|
3780
|
+
lines.push("Blocks: none (nothing compressed yet)");
|
|
3781
|
+
}
|
|
3782
|
+
lines.push("");
|
|
3783
|
+
lines.push("Tag visibility: tags injected to LLM only (deep copy), not persisted in session, not shown in terminal.");
|
|
3784
|
+
return lines.join("\n");
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
// src/status-tool.ts
|
|
3626
3788
|
var StatusParams = type4({
|
|
3627
3789
|
"scope?": type4('"compressed" | "uncompressed"').describe('"compressed" = drill into blocks; "uncompressed" = show visible messages/ranges. Default: overview.'),
|
|
3628
3790
|
"view?": type4('"ranges" | "messages"').describe('For uncompressed scope: "ranges" (default) or "messages" (per-message listing).'),
|
|
@@ -3703,15 +3865,6 @@ function getSystemPromptText(ctx) {
|
|
|
3703
3865
|
return normalizeSystemPrompt(result);
|
|
3704
3866
|
}
|
|
3705
3867
|
|
|
3706
|
-
// src/footer-status.ts
|
|
3707
|
-
function formatCompactTokens(count) {
|
|
3708
|
-
if (count < 1e3) return count.toString();
|
|
3709
|
-
if (count < 1e4) return `${(count / 1e3).toFixed(1)}k`;
|
|
3710
|
-
if (count < 1e6) return `${Math.round(count / 1e3)}k`;
|
|
3711
|
-
if (count < 1e7) return `${(count / 1e6).toFixed(1)}M`;
|
|
3712
|
-
return `${Math.round(count / 1e6)}M`;
|
|
3713
|
-
}
|
|
3714
|
-
|
|
3715
3868
|
// src/commands.ts
|
|
3716
3869
|
function safeHandler(handler) {
|
|
3717
3870
|
return async (args, ctx) => {
|
|
@@ -3789,97 +3942,22 @@ ${text}`);
|
|
|
3789
3942
|
}
|
|
3790
3943
|
];
|
|
3791
3944
|
}
|
|
3792
|
-
function fmtTokens(n) {
|
|
3793
|
-
return formatCompactTokens(n);
|
|
3794
|
-
}
|
|
3795
|
-
function bar(value, total, width = 20) {
|
|
3796
|
-
if (total === 0) return "";
|
|
3797
|
-
const filled = Math.max(0, Math.min(width, Math.round(value / total * width)));
|
|
3798
|
-
return "\u2588".repeat(filled) + "\u2591".repeat(width - filled);
|
|
3799
|
-
}
|
|
3800
3945
|
async function statusReport(runtime, ctx) {
|
|
3801
3946
|
const { state, coreMessages } = await runtime.stateFor(ctx);
|
|
3802
3947
|
const config = runtime.configFor(ctx);
|
|
3803
3948
|
const realUsage = ctx.getContextUsage?.();
|
|
3804
3949
|
const tokenCount = realUsage?.tokens && realUsage.tokens > 0 ? realUsage.tokens : defaultCountTokens(coreMessages.map((m) => m.text ?? "").join("\n"));
|
|
3805
3950
|
const turn = runtime.core.processTurn({ messages: coreMessages, state, config, tokenCount });
|
|
3806
|
-
const nudge = turn.nudge;
|
|
3807
|
-
const bd = nudge?.contextBreakdown;
|
|
3808
|
-
const limit = config.modelContextLimit;
|
|
3809
|
-
const classified = bd ? bd.system + bd.tool + bd.summaries + bd.code + bd.text : 0;
|
|
3810
3951
|
const systemPromptText = getSystemPromptText(ctx);
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
lines.push("\u2502 ACP Context Analysis \u2502");
|
|
3821
|
-
lines.push("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");
|
|
3822
|
-
if (versionStr) lines.push(versionStr);
|
|
3823
|
-
lines.push("");
|
|
3824
|
-
lines.push(`Context: ${displayPct}% (${fmtTokens(displayTotal)} / ${fmtTokens(limit)})`);
|
|
3825
|
-
if (nudge && bd) {
|
|
3826
|
-
const growth = bd.growth;
|
|
3827
|
-
if (growth > 0 && displayTotal > 0) {
|
|
3828
|
-
lines.push(`Growth: +${fmtTokens(growth)} since last nudge`);
|
|
3829
|
-
}
|
|
3830
|
-
if (displayTotal > 0) {
|
|
3831
|
-
lines.push("");
|
|
3832
|
-
lines.push("Token Breakdown:");
|
|
3833
|
-
const categories = [
|
|
3834
|
-
{ label: "Tool", value: bd.tool },
|
|
3835
|
-
{ label: "SysPrompt", value: systemPromptTokens },
|
|
3836
|
-
{ label: "Framework", value: framework },
|
|
3837
|
-
{ label: "Text", value: bd.text },
|
|
3838
|
-
{ label: "Code", value: bd.code },
|
|
3839
|
-
{ label: "Summaries", value: bd.summaries }
|
|
3840
|
-
];
|
|
3841
|
-
for (const cat of categories) {
|
|
3842
|
-
if (cat.value <= 0) continue;
|
|
3843
|
-
const pct2 = displayTotal > 0 ? Math.round(cat.value / displayTotal * 100) : 0;
|
|
3844
|
-
const b = bar(cat.value, displayTotal);
|
|
3845
|
-
lines.push(` ${cat.label.padEnd(10)} ${b} ${String(pct2).padStart(3)}% ${fmtTokens(cat.value)}`);
|
|
3846
|
-
}
|
|
3847
|
-
}
|
|
3848
|
-
}
|
|
3849
|
-
lines.push("");
|
|
3850
|
-
if (nudge) {
|
|
3851
|
-
if (nudge.shouldInject) {
|
|
3852
|
-
const tierInfo = nudge.tier ? ` [T${nudge.tier} distillation]` : "";
|
|
3853
|
-
lines.push(`Nudge: ACTIVE${tierInfo} \u2014 ${nudge.reason}`);
|
|
3854
|
-
} else {
|
|
3855
|
-
lines.push(`Nudge: idle \u2014 ${nudge.reason}`);
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
const ranges = nudge?.compressibleRanges ?? [];
|
|
3859
|
-
const protectedRanges = nudge?.protectedRanges ?? [];
|
|
3860
|
-
if (ranges.length > 0 || protectedRanges.length > 0) {
|
|
3861
|
-
lines.push("");
|
|
3862
|
-
lines.push(formatRanges(ranges, protectedRanges));
|
|
3863
|
-
}
|
|
3864
|
-
if (activeBlocksList.length > 0) {
|
|
3865
|
-
lines.push("");
|
|
3866
|
-
lines.push(`Blocks: ${activeBlocksList.length} active / ${totalBlocksList.length} total (${fmtTokens(state.stats.tokensCompressed)} tokens compressed)`);
|
|
3867
|
-
for (const b of activeBlocksList) {
|
|
3868
|
-
const topic = b.topic ? `: ${b.topic}` : `: ${topicFallback(b.summary || "")}`;
|
|
3869
|
-
const summaryTok = defaultCountTokens(b.summary || "");
|
|
3870
|
-
const origTok = b.compressedTokens > 0 ? b.compressedTokens : summaryTok;
|
|
3871
|
-
lines.push(` [${b.blockId}] T${b.tier} ${fmtTokens(origTok)}\u2192${fmtTokens(summaryTok)}${topic}`);
|
|
3872
|
-
}
|
|
3873
|
-
} else if (totalBlocksList.length > 0) {
|
|
3874
|
-
lines.push("");
|
|
3875
|
-
lines.push(`Blocks: 0 active / ${totalBlocksList.length} total (${fmtTokens(state.stats.tokensCompressed)} tokens compressed)`);
|
|
3876
|
-
} else {
|
|
3877
|
-
lines.push("");
|
|
3878
|
-
lines.push("Blocks: none (nothing compressed yet)");
|
|
3879
|
-
}
|
|
3880
|
-
lines.push("");
|
|
3881
|
-
lines.push("Tag visibility: tags injected to LLM only (deep copy), not persisted in session, not shown in terminal.");
|
|
3882
|
-
return lines.join("\n");
|
|
3952
|
+
const versionStr = "0.1.6" ? `billion-context-omp@${"0.1.6"}` : void 0;
|
|
3953
|
+
return buildStatusPanel({
|
|
3954
|
+
version: versionStr,
|
|
3955
|
+
tokenCount,
|
|
3956
|
+
systemPromptTokens: systemPromptText ? defaultCountTokens(systemPromptText) : 0,
|
|
3957
|
+
state: turn.state,
|
|
3958
|
+
nudge: turn.nudge,
|
|
3959
|
+
modelContextLimit: config.modelContextLimit
|
|
3960
|
+
});
|
|
3883
3961
|
}
|
|
3884
3962
|
|
|
3885
3963
|
// src/auto-compress.ts
|
|
@@ -4310,7 +4388,7 @@ async function checkForUpdate(autoUpdate, notify) {
|
|
|
4310
4388
|
const data = await res.json();
|
|
4311
4389
|
const latest = data.version;
|
|
4312
4390
|
if (!latest) return;
|
|
4313
|
-
const current = runtimeVersion ?? "0.1.
|
|
4391
|
+
const current = runtimeVersion ?? "0.1.6";
|
|
4314
4392
|
const hasUpdate = isNewer(latest, current);
|
|
4315
4393
|
debug.event("update-check", {
|
|
4316
4394
|
current,
|
|
@@ -4598,7 +4676,7 @@ function wireCompactionDisable(pi, runtime) {
|
|
|
4598
4676
|
function wireSessionLifecycle(pi, runtime) {
|
|
4599
4677
|
pi.on("session_start", async (_event, ctx) => {
|
|
4600
4678
|
const sid = ctx.sessionManager.getSessionId();
|
|
4601
|
-
logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.
|
|
4679
|
+
logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.6" : null });
|
|
4602
4680
|
try {
|
|
4603
4681
|
const user = await loadUserConfig(ctx.cwd);
|
|
4604
4682
|
runtime.setAdapter(applyUserConfig(runtime.adapter, user));
|