billion-context-omp 0.3.3-pr.146.13 → 0.3.3-pr.147.16
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/index.js +55 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2679,14 +2679,14 @@ function renderUncompressedRanges(visible) {
|
|
|
2679
2679
|
};
|
|
2680
2680
|
const merged = [];
|
|
2681
2681
|
for (const m of visible) {
|
|
2682
|
-
const
|
|
2682
|
+
const num2 = refNum2(m.ref);
|
|
2683
2683
|
const last = merged[merged.length - 1];
|
|
2684
|
-
if (last &&
|
|
2684
|
+
if (last && num2 === last.startNum + last.count) {
|
|
2685
2685
|
last.endRef = m.ref;
|
|
2686
2686
|
last.count += 1;
|
|
2687
2687
|
last.tokens += m.tokens;
|
|
2688
2688
|
} else {
|
|
2689
|
-
merged.push({ startRef: m.ref, endRef: m.ref, startNum:
|
|
2689
|
+
merged.push({ startRef: m.ref, endRef: m.ref, startNum: num2, count: 1, tokens: m.tokens, tool: m.tool });
|
|
2690
2690
|
}
|
|
2691
2691
|
}
|
|
2692
2692
|
for (const r of merged.slice(0, 30)) {
|
|
@@ -5768,6 +5768,37 @@ function formatCompactTokens(count) {
|
|
|
5768
5768
|
if (count < 1e7) return `${(count / 1e6).toFixed(1)}M`;
|
|
5769
5769
|
return `${Math.round(count / 1e6)}M`;
|
|
5770
5770
|
}
|
|
5771
|
+
function num(v) {
|
|
5772
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0;
|
|
5773
|
+
}
|
|
5774
|
+
function cacheHitStats(usages) {
|
|
5775
|
+
let cacheRead = 0;
|
|
5776
|
+
let billedPrompt = 0;
|
|
5777
|
+
let requests = 0;
|
|
5778
|
+
let last;
|
|
5779
|
+
for (const u of usages) {
|
|
5780
|
+
const read = num(u?.cacheRead);
|
|
5781
|
+
const write = num(u?.cacheWrite);
|
|
5782
|
+
const input = num(u?.input);
|
|
5783
|
+
if (read + write <= 0) continue;
|
|
5784
|
+
const total = read + write + input;
|
|
5785
|
+
if (total <= 0) continue;
|
|
5786
|
+
cacheRead += read;
|
|
5787
|
+
billedPrompt += total;
|
|
5788
|
+
requests += 1;
|
|
5789
|
+
last = read / total;
|
|
5790
|
+
}
|
|
5791
|
+
return {
|
|
5792
|
+
session: requests > 0 ? cacheRead / billedPrompt : void 0,
|
|
5793
|
+
last,
|
|
5794
|
+
requests,
|
|
5795
|
+
cacheRead,
|
|
5796
|
+
billedPrompt
|
|
5797
|
+
};
|
|
5798
|
+
}
|
|
5799
|
+
function formatHitRate(rate) {
|
|
5800
|
+
return `${(Math.max(0, Math.min(1, rate)) * 100).toFixed(1)}%`;
|
|
5801
|
+
}
|
|
5771
5802
|
function bar(value, total, width = 20) {
|
|
5772
5803
|
if (total === 0) return "";
|
|
5773
5804
|
const filled = Math.max(0, Math.min(width, Math.round(value / total * width)));
|
|
@@ -5820,6 +5851,15 @@ function buildStatusPanel(input) {
|
|
|
5820
5851
|
lines.push(` ${cat.label.padEnd(10)} ${b} ${String(pct2).padStart(3)}% ${fmt2(cat.value)}`);
|
|
5821
5852
|
}
|
|
5822
5853
|
}
|
|
5854
|
+
if (input.cacheUsages) {
|
|
5855
|
+
const cache2 = cacheHitStats(input.cacheUsages);
|
|
5856
|
+
if (cache2.requests > 0 && cache2.session !== void 0 && cache2.last !== void 0) {
|
|
5857
|
+
lines.push("");
|
|
5858
|
+
lines.push(
|
|
5859
|
+
`Prompt cache (provider-reported): ${formatHitRate(cache2.last)} last \xB7 ${formatHitRate(cache2.session)} session avg \u2014 ${fmt2(cache2.cacheRead)} of ${fmt2(cache2.billedPrompt)} billed prompt tokens served from cache (${cache2.requests} req)`
|
|
5860
|
+
);
|
|
5861
|
+
}
|
|
5862
|
+
}
|
|
5823
5863
|
lines.push("");
|
|
5824
5864
|
if (nudge) {
|
|
5825
5865
|
if (nudge.shouldInject) {
|
|
@@ -5857,6 +5897,16 @@ function buildStatusPanel(input) {
|
|
|
5857
5897
|
}
|
|
5858
5898
|
|
|
5859
5899
|
// src/commands.ts
|
|
5900
|
+
function cacheUsageSamples(entries) {
|
|
5901
|
+
const out = [];
|
|
5902
|
+
for (const e of entries) {
|
|
5903
|
+
if (e.type !== "message" || !e.message) continue;
|
|
5904
|
+
const m = e.message;
|
|
5905
|
+
if (m.role !== "assistant" || !m.usage) continue;
|
|
5906
|
+
out.push({ input: m.usage.input ?? 0, cacheRead: m.usage.cacheRead ?? 0, cacheWrite: m.usage.cacheWrite ?? 0 });
|
|
5907
|
+
}
|
|
5908
|
+
return out;
|
|
5909
|
+
}
|
|
5860
5910
|
function safeHandler(handler) {
|
|
5861
5911
|
return async (args, ctx) => {
|
|
5862
5912
|
try {
|
|
@@ -5951,7 +6001,8 @@ async function statusReport(runtime, ctx) {
|
|
|
5951
6001
|
state: turn.state,
|
|
5952
6002
|
nudge: turn.nudge,
|
|
5953
6003
|
modelContextLimit: config.modelContextLimit,
|
|
5954
|
-
unprunedTokens: coreMessages.reduce((sum, m) => sum + defaultCountTokens(m.text ?? ""), 0)
|
|
6004
|
+
unprunedTokens: coreMessages.reduce((sum, m) => sum + defaultCountTokens(m.text ?? ""), 0),
|
|
6005
|
+
cacheUsages: ctx.sessionManager?.getEntries ? cacheUsageSamples(ctx.sessionManager.getEntries()) : void 0
|
|
5955
6006
|
});
|
|
5956
6007
|
}
|
|
5957
6008
|
|