dsh-usage-peak 1.5.0 → 1.6.0
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/CHANGELOG.md +10 -0
- package/README.md +4 -1
- package/client.js +398 -112
- package/index.js +16 -7
- package/package.json +1 -1
- package/test/client.test.js +10 -1
- package/test/core.test.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
- 图表新增自定义详情浮层:悬停或聚焦小时图 / 每日趋势,显示该时段的花费、请求、tokens、缓存命中率与峰谷;浮层按列居中并 clamp 在图表内,窄侧栏也不溢出,原生 title 双提示已移除。
|
|
6
|
+
- 图表支持键盘浏览:Tab 聚焦后 `←` `→` 循环、`Home` / `End` 跳首尾、`Esc` 关闭;浮层内容通过 `aria-live` 播报,聚焦时有可见描边。
|
|
7
|
+
- 小时数据补充 tokens 与命中率:host 的小时桶新增 input/cache/output tokens,`hoursOf` 输出 `tokens` 与 `hitRate`,用于浮层明细。
|
|
8
|
+
- 窄侧栏适配:图表从固定两列改为 flex 换行,24 根柱子收窄到 minWidth 3;每日趋势按可用宽度进入 dense 模式(隐藏柱顶金额、日期标签稀疏);KPI 网格改为 `minmax(min(100%, 140px), 1fr)`。
|
|
9
|
+
- 自定义价目表改为每个模型一组、字段自动换行(缓存命中 / 输入 / 输出各自谷峰两输入),窄宽度下不再横向溢出;价目表与模型表加横向滚动容器,价目表当前时段用加粗和底色标记。
|
|
10
|
+
- 侧栏胶囊的 tokens 段改为可收缩省略,窄侧栏下优先保住倒计时。
|
|
11
|
+
- 新增 `tipAnchor` 与小时 tokens/命中率测试,测试从 43 条增至 45 条。
|
|
12
|
+
|
|
3
13
|
## 1.5.0
|
|
4
14
|
|
|
5
15
|
- 峰谷改为按请求开始时刻判断:取每条 `assistant/message` 第一个流式 chunk 的时间,而不是回复完成时间,跨切价点的回复不再整条算到错误的时段。
|
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
- **侧栏常驻胶囊**:`● 峰 ¥14.70 · 12.8M tok · 2:43 后转谷`,点一下打开完整面板。侧栏折叠时收成一个小圆点。默认可撑天数不足 7 天时胶囊转琥珀色,不足 3 天转红色;可在面板调整阈值。
|
|
16
16
|
- **峰谷状态**:当前时段、距离下次切换的倒计时、当前时段单价(缓存命中 / 全价输入 / 输出)。
|
|
17
17
|
- **今日概况**:花费、请求数、tokens、缓存命中率、峰时花费占比、**谷时更省**(把这些峰时用量挪到谷时能省下的钱)、余额、**余额可撑天数**(余额 ÷ 近 7 天日均花费)。
|
|
18
|
-
- **今日 24
|
|
18
|
+
- **今日 24 小时分布**:每小时花费柱状,峰时与谷时用不同颜色,当前小时高亮;悬停或聚焦柱子可看该小时的花费、请求、tokens 与缓存命中率,键盘 `←` `→` / `Home` / `End` 浏览、`Esc` 关闭。
|
|
19
|
+
- **窄侧栏自适应**:侧栏变窄或窗口变小时,图表自动换行、24 根柱子收窄、每日趋势的日期标签按宽度变稀疏;价目表按模型分组、单价输入自动换行,过宽的表格可横向滚动,胶囊的 tokens 段优先省略而不挤掉倒计时。
|
|
19
20
|
- **花费构成**:缓存命中 / 全价输入 / 输出 三段占比,直接看出钱花在哪。
|
|
20
21
|
- **近 7 / 14 / 30 天趋势**:右上角切换窗口,按天堆叠柱状,缺数据的日期补零,列数恒定;可对照峰时占比判断"贵在哪天"。
|
|
21
22
|
- **按项目与下钻**:按会话头里的工作目录(`cwd`)聚合,倒序列出每个项目的请求数、tokens、花费与占比条。点击项目可只看该项目的概况、24 小时、趋势和模型明细,通过顶部「全部项目」恢复。
|
|
@@ -102,6 +103,8 @@ A usage and cost dashboard for DeepSeek Harness. It reads the local session logs
|
|
|
102
103
|
- China public holidays and makeup workdays: holidays are valley all day, makeup weekend workdays follow the weekday windows (2026–2027 calendars shipped; missing years fall back to Mon-Fri with a visible warning);
|
|
103
104
|
- a footer with the GitHub repository link, the running version and the covered calendar years;
|
|
104
105
|
- a details page (Settings → Usage dashboard) with KPIs (including balance runway), an hourly breakdown, cost composition, a 7/14/30-day trend switch, spend by project, a per-model table, CSV export and the price list;
|
|
106
|
+
- hover or keyboard focus on the hourly/daily charts for that bucket's spend, requests, tokens and cache-hit rate (arrows/Home/End to browse, Esc to close), with a clamped tooltip that fits narrow panels;
|
|
107
|
+
- narrow sidebars and small windows: charts wrap, the 24 hourly bars compress, day labels thin out, the custom price form stacks its fields and wide tables scroll horizontally;
|
|
105
108
|
- a custom price parameter (`pricing=`) on `/data` and `/export.csv`; malformed values fall back to the defaults with a `pricing-invalid` warning;
|
|
106
109
|
- project drilldown: select a project to filter KPIs, hourly/daily charts, models and both CSV exports; clear the filter to return to all projects;
|
|
107
110
|
- configurable browser-local runway thresholds (warning 7 days / critical 3 days by default) and an optional daily budget (warning above 100%, critical at 120%); settings sync between the sidebar and dashboard;
|
package/client.js
CHANGED
|
@@ -117,9 +117,14 @@ window.__ModuleLoader__.load({
|
|
|
117
117
|
'export.projectsTitle': '导出项目数据 CSV',
|
|
118
118
|
|
|
119
119
|
'chart.hours': '今日每小时花费',
|
|
120
|
-
'chart.hoursHint': '橙 峰时 · 绿 谷时',
|
|
120
|
+
'chart.hoursHint': '橙 峰时 · 绿 谷时 · 悬停或聚焦看详情',
|
|
121
121
|
'chart.days': '每天花费',
|
|
122
|
-
'chart.daysHint': '橙 峰时 · 绿 谷时',
|
|
122
|
+
'chart.daysHint': '橙 峰时 · 绿 谷时 · 悬停或聚焦看详情',
|
|
123
|
+
'tip.cost': '花费',
|
|
124
|
+
'tip.calls': '请求',
|
|
125
|
+
'tip.tokens': 'tokens',
|
|
126
|
+
'tip.hit': '缓存命中',
|
|
127
|
+
'tip.hint': '用 ← → 浏览每小时 / 每天,Esc 关闭',
|
|
123
128
|
|
|
124
129
|
'cost.title': '今日花费构成',
|
|
125
130
|
'cost.cache': '缓存命中',
|
|
@@ -133,7 +138,6 @@ window.__ModuleLoader__.load({
|
|
|
133
138
|
'price.hit': '命中',
|
|
134
139
|
'price.miss': '未命中',
|
|
135
140
|
'price.out': '输出',
|
|
136
|
-
'price.current': '当前',
|
|
137
141
|
'price.custom': '自定义价目',
|
|
138
142
|
'pricing.title': '自定义价目表',
|
|
139
143
|
'pricing.hint': '仅保存在本机;保存后所有金额与 CSV 立即按新价目重算。',
|
|
@@ -244,9 +248,14 @@ window.__ModuleLoader__.load({
|
|
|
244
248
|
'export.projectsTitle': 'Export project CSV',
|
|
245
249
|
|
|
246
250
|
'chart.hours': 'Cost per hour today',
|
|
247
|
-
'chart.hoursHint': 'orange peak · green valley',
|
|
251
|
+
'chart.hoursHint': 'orange peak · green valley · hover or focus for details',
|
|
248
252
|
'chart.days': 'Spend by day',
|
|
249
|
-
'chart.daysHint': 'orange peak · green valley',
|
|
253
|
+
'chart.daysHint': 'orange peak · green valley · hover or focus for details',
|
|
254
|
+
'tip.cost': 'Spend',
|
|
255
|
+
'tip.calls': 'Requests',
|
|
256
|
+
'tip.tokens': 'tokens',
|
|
257
|
+
'tip.hit': 'Cache hit',
|
|
258
|
+
'tip.hint': 'Use ← → to browse hours or days, Esc to close',
|
|
250
259
|
|
|
251
260
|
'cost.title': 'Today by token type',
|
|
252
261
|
'cost.cache': 'Cache hits',
|
|
@@ -260,7 +269,6 @@ window.__ModuleLoader__.load({
|
|
|
260
269
|
'price.hit': 'Hit',
|
|
261
270
|
'price.miss': 'Miss',
|
|
262
271
|
'price.out': 'Output',
|
|
263
|
-
'price.current': 'now',
|
|
264
272
|
'price.custom': 'custom pricing',
|
|
265
273
|
'pricing.title': 'Custom price list',
|
|
266
274
|
'pricing.hint': 'Stored only in this browser; saving recalculates every figure and CSV immediately.',
|
|
@@ -516,6 +524,12 @@ window.__ModuleLoader__.load({
|
|
|
516
524
|
return alertActive ? `⚠ ${switchText}` : switchText;
|
|
517
525
|
}
|
|
518
526
|
|
|
527
|
+
/** Clamp a tooltip's left edge so it stays inside its chart box. */
|
|
528
|
+
function tipAnchor(center, tipWidth, boxWidth, inset = 4) {
|
|
529
|
+
const limit = Math.max(inset, boxWidth - tipWidth - inset);
|
|
530
|
+
return Math.min(Math.max(center - tipWidth / 2, inset), limit);
|
|
531
|
+
}
|
|
532
|
+
|
|
519
533
|
// Generation guard rejects old filter responses and older same-filter reloads.
|
|
520
534
|
function requestGate() {
|
|
521
535
|
let key = null;
|
|
@@ -685,7 +699,17 @@ window.__ModuleLoader__.load({
|
|
|
685
699
|
h(Sep),
|
|
686
700
|
h(
|
|
687
701
|
'span',
|
|
688
|
-
{
|
|
702
|
+
{
|
|
703
|
+
style: {
|
|
704
|
+
color: C.text2,
|
|
705
|
+
flex: '0 1 auto',
|
|
706
|
+
minWidth: 0,
|
|
707
|
+
overflow: 'hidden',
|
|
708
|
+
textOverflow: 'ellipsis',
|
|
709
|
+
fontVariantNumeric: 'tabular-nums',
|
|
710
|
+
whiteSpace: 'nowrap',
|
|
711
|
+
},
|
|
712
|
+
},
|
|
689
713
|
data && data.today ? shortTokens(data.today.tokens) : '—',
|
|
690
714
|
h('span', { style: { color: C.text3, marginLeft: 2 } }, 'tok'),
|
|
691
715
|
),
|
|
@@ -779,81 +803,317 @@ window.__ModuleLoader__.load({
|
|
|
779
803
|
);
|
|
780
804
|
}
|
|
781
805
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
806
|
+
/* ------------------------------- chart tips ------------------------------ */
|
|
807
|
+
|
|
808
|
+
const srOnly = {
|
|
809
|
+
position: 'absolute',
|
|
810
|
+
width: 1,
|
|
811
|
+
height: 1,
|
|
812
|
+
margin: -1,
|
|
813
|
+
padding: 0,
|
|
814
|
+
overflow: 'hidden',
|
|
815
|
+
clip: 'rect(0 0 0 0)',
|
|
816
|
+
whiteSpace: 'nowrap',
|
|
817
|
+
border: 0,
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
/** Live width of an element, so dense charts can thin their labels. */
|
|
821
|
+
function useBoxWidth(ref) {
|
|
822
|
+
const [width, setWidth] = useState(0);
|
|
823
|
+
useEffect(() => {
|
|
824
|
+
const node = ref.current;
|
|
825
|
+
if (!node) return undefined;
|
|
826
|
+
const update = () => setWidth(node.clientWidth);
|
|
827
|
+
update();
|
|
828
|
+
if (typeof ResizeObserver === 'undefined') return undefined;
|
|
829
|
+
const observer = new ResizeObserver(update);
|
|
830
|
+
observer.observe(node);
|
|
831
|
+
return () => observer.disconnect();
|
|
832
|
+
}, []);
|
|
833
|
+
return width;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Hover plus keyboard state for one chart.
|
|
838
|
+
*
|
|
839
|
+
* The tooltip is anchored to the hovered column's centre and clamped to the
|
|
840
|
+
* chart box, so it never spills out of a narrow panel.
|
|
841
|
+
*/
|
|
842
|
+
function useChartTip(count) {
|
|
843
|
+
const [active, setActive] = useState(-1);
|
|
844
|
+
const [focused, setFocused] = useState(false);
|
|
845
|
+
const [anchor, setAnchor] = useState(null);
|
|
846
|
+
const boxRef = useRef(null);
|
|
847
|
+
const columns = useRef([]);
|
|
848
|
+
const width = useBoxWidth(boxRef);
|
|
849
|
+
const tipWidth = Math.min(216, Math.max(150, (width || 240) - 8));
|
|
850
|
+
|
|
851
|
+
useEffect(() => {
|
|
852
|
+
const column = active >= 0 ? columns.current[active] : null;
|
|
853
|
+
if (!column || !width) {
|
|
854
|
+
setAnchor(null);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
setAnchor({ left: tipAnchor(column.offsetLeft + column.offsetWidth / 2, tipWidth, width), width: tipWidth });
|
|
858
|
+
}, [active, width, tipWidth]);
|
|
859
|
+
|
|
860
|
+
const step = (delta) =>
|
|
861
|
+
setActive((current) => {
|
|
862
|
+
const from = current < 0 ? (delta > 0 ? -1 : 0) : current;
|
|
863
|
+
return (from + delta + count) % count;
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
const onKeyDown = (event) => {
|
|
867
|
+
if (!count) return;
|
|
868
|
+
if (event.key === 'ArrowRight') {
|
|
869
|
+
event.preventDefault();
|
|
870
|
+
step(1);
|
|
871
|
+
} else if (event.key === 'ArrowLeft') {
|
|
872
|
+
event.preventDefault();
|
|
873
|
+
step(-1);
|
|
874
|
+
} else if (event.key === 'Home') {
|
|
875
|
+
event.preventDefault();
|
|
876
|
+
setActive(0);
|
|
877
|
+
} else if (event.key === 'End') {
|
|
878
|
+
event.preventDefault();
|
|
879
|
+
setActive(count - 1);
|
|
880
|
+
} else if (event.key === 'Escape') {
|
|
881
|
+
setActive(-1);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
const onBlur = (event) => {
|
|
886
|
+
if (event.currentTarget.contains(event.relatedTarget)) return;
|
|
887
|
+
setFocused(false);
|
|
888
|
+
setActive(-1);
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
return {
|
|
892
|
+
active,
|
|
893
|
+
anchor,
|
|
894
|
+
boxRef,
|
|
895
|
+
columns,
|
|
896
|
+
width,
|
|
897
|
+
focused,
|
|
898
|
+
tipWidth,
|
|
899
|
+
onKeyDown,
|
|
900
|
+
onBlur,
|
|
901
|
+
onFocus: () => setFocused(true),
|
|
902
|
+
show: setActive,
|
|
903
|
+
clear: () => setActive(-1),
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function ChartTip(props) {
|
|
785
908
|
return h(
|
|
786
909
|
'div',
|
|
787
|
-
{
|
|
788
|
-
|
|
910
|
+
{
|
|
911
|
+
role: 'tooltip',
|
|
912
|
+
style: {
|
|
913
|
+
position: 'absolute',
|
|
914
|
+
top: 0,
|
|
915
|
+
left: props.left,
|
|
916
|
+
width: props.width,
|
|
917
|
+
zIndex: 3,
|
|
918
|
+
pointerEvents: 'none',
|
|
919
|
+
boxSizing: 'border-box',
|
|
920
|
+
padding: '6px 9px',
|
|
921
|
+
borderRadius: 8,
|
|
922
|
+
border: `1px solid ${C.border}`,
|
|
923
|
+
background: C.layer1,
|
|
924
|
+
boxShadow: '0 8px 24px rgba(0, 0, 0, 0.22)',
|
|
925
|
+
fontSize: 10.5,
|
|
926
|
+
lineHeight: '15px',
|
|
927
|
+
color: C.text2,
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
h(
|
|
931
|
+
'div',
|
|
932
|
+
{
|
|
933
|
+
style: {
|
|
934
|
+
color: C.text,
|
|
935
|
+
fontWeight: 600,
|
|
936
|
+
marginBottom: 3,
|
|
937
|
+
fontVariantNumeric: 'tabular-nums',
|
|
938
|
+
whiteSpace: 'nowrap',
|
|
939
|
+
overflow: 'hidden',
|
|
940
|
+
textOverflow: 'ellipsis',
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
props.title,
|
|
944
|
+
),
|
|
945
|
+
(props.rows || []).map((row, index) =>
|
|
789
946
|
h(
|
|
790
947
|
'div',
|
|
791
|
-
{
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
style: {
|
|
795
|
-
flex: 1,
|
|
796
|
-
display: 'flex',
|
|
797
|
-
flexDirection: 'column',
|
|
798
|
-
justifyContent: 'flex-end',
|
|
799
|
-
height: '100%',
|
|
800
|
-
minWidth: 5,
|
|
801
|
-
borderRadius: 4,
|
|
802
|
-
outline: entry.hour === props.nowHour ? `1px solid ${C.border}` : 'none',
|
|
803
|
-
outlineOffset: 1,
|
|
804
|
-
},
|
|
805
|
-
},
|
|
806
|
-
h('div', {
|
|
807
|
-
style: {
|
|
808
|
-
height: `${Math.max(entry.cost > 0 ? 3 : 0, (entry.cost / max) * 100)}%`,
|
|
809
|
-
background: entry.peak ? C.peak : C.valley,
|
|
810
|
-
opacity: entry.cost > 0 ? 0.9 : 0,
|
|
811
|
-
borderRadius: 3,
|
|
812
|
-
},
|
|
813
|
-
}),
|
|
948
|
+
{ key: index, style: { display: 'flex', justifyContent: 'space-between', gap: 12 } },
|
|
949
|
+
h('span', { style: { color: C.text3, flex: 'none' } }, row[0]),
|
|
950
|
+
h('span', { style: { color: C.text, fontVariantNumeric: 'tabular-nums', textAlign: 'right' } }, row[1]),
|
|
814
951
|
),
|
|
815
952
|
),
|
|
816
953
|
);
|
|
817
954
|
}
|
|
818
955
|
|
|
819
|
-
function
|
|
820
|
-
const
|
|
821
|
-
const
|
|
956
|
+
function HourChart(props) {
|
|
957
|
+
const hours = props.hours || [];
|
|
958
|
+
const t = props.t;
|
|
959
|
+
const max = Math.max(0.0001, ...hours.map((entry) => entry.cost));
|
|
960
|
+
const tip = useChartTip(hours.length);
|
|
961
|
+
const active = tip.active >= 0 ? hours[tip.active] : null;
|
|
962
|
+
const label = active ? `${String(active.hour).padStart(2, '0')}:00 · ${active.peak ? t('status.peak') : t('status.valley')}` : '';
|
|
963
|
+
const rows = active
|
|
964
|
+
? [
|
|
965
|
+
[t('tip.cost'), yuan(active.cost)],
|
|
966
|
+
[t('tip.calls'), `${active.calls} ${t('unit.calls')}`],
|
|
967
|
+
[t('tip.tokens'), tokens(active.tokens || 0, t)],
|
|
968
|
+
[t('tip.hit'), percent(active.hitRate || 0)],
|
|
969
|
+
]
|
|
970
|
+
: [];
|
|
822
971
|
return h(
|
|
823
972
|
'div',
|
|
824
|
-
{
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
973
|
+
{
|
|
974
|
+
role: 'group',
|
|
975
|
+
tabIndex: 0,
|
|
976
|
+
'aria-label': t('chart.hours'),
|
|
977
|
+
title: t('tip.hint'),
|
|
978
|
+
onKeyDown: tip.onKeyDown,
|
|
979
|
+
onFocus: tip.onFocus,
|
|
980
|
+
onBlur: tip.onBlur,
|
|
981
|
+
style: {
|
|
982
|
+
position: 'relative',
|
|
983
|
+
marginTop: 2,
|
|
984
|
+
borderRadius: 6,
|
|
985
|
+
outline: tip.focused ? `2px solid ${C.out}` : 'none',
|
|
986
|
+
outlineOffset: 2,
|
|
987
|
+
},
|
|
988
|
+
},
|
|
989
|
+
h(
|
|
990
|
+
'div',
|
|
991
|
+
{
|
|
992
|
+
ref: tip.boxRef,
|
|
993
|
+
onMouseLeave: tip.clear,
|
|
994
|
+
style: { display: 'flex', alignItems: 'flex-end', gap: 3, height: 108 },
|
|
995
|
+
},
|
|
996
|
+
hours.map((entry, index) =>
|
|
837
997
|
h(
|
|
838
998
|
'div',
|
|
839
999
|
{
|
|
840
|
-
|
|
1000
|
+
key: entry.hour,
|
|
1001
|
+
ref: (node) => {
|
|
1002
|
+
tip.columns.current[index] = node;
|
|
1003
|
+
},
|
|
1004
|
+
onMouseEnter: () => tip.show(index),
|
|
841
1005
|
style: {
|
|
842
1006
|
flex: 1,
|
|
843
|
-
width: '100%',
|
|
844
1007
|
display: 'flex',
|
|
845
1008
|
flexDirection: 'column',
|
|
846
1009
|
justifyContent: 'flex-end',
|
|
1010
|
+
height: '100%',
|
|
1011
|
+
minWidth: 3,
|
|
847
1012
|
borderRadius: 4,
|
|
848
|
-
|
|
1013
|
+
outline: entry.hour === props.nowHour ? `1px solid ${C.border}` : 'none',
|
|
1014
|
+
outlineOffset: 1,
|
|
849
1015
|
},
|
|
850
1016
|
},
|
|
851
|
-
h('div', {
|
|
852
|
-
|
|
1017
|
+
h('div', {
|
|
1018
|
+
style: {
|
|
1019
|
+
height: `${Math.max(entry.cost > 0 ? 3 : 0, (entry.cost / max) * 100)}%`,
|
|
1020
|
+
background: entry.peak ? C.peak : C.valley,
|
|
1021
|
+
opacity: entry.cost > 0 ? (tip.active < 0 || tip.active === index ? 0.9 : 0.4) : 0,
|
|
1022
|
+
borderRadius: 3,
|
|
1023
|
+
transition: 'opacity 120ms',
|
|
1024
|
+
},
|
|
1025
|
+
}),
|
|
853
1026
|
),
|
|
854
|
-
h('span', { style: { fontSize: 9.5, color: C.text2 } }, entry.day.slice(5)),
|
|
855
1027
|
),
|
|
856
1028
|
),
|
|
1029
|
+
tip.anchor ? h(ChartTip, { title: label, rows, left: tip.anchor.left, width: tip.anchor.width }) : null,
|
|
1030
|
+
active ? h('span', { 'aria-live': 'polite', style: srOnly }, `${label} · ${rows.map((row) => `${row[0]} ${row[1]}`).join(' · ')}`) : null,
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function DayChart(props) {
|
|
1035
|
+
const days = props.days || [];
|
|
1036
|
+
const t = props.t;
|
|
1037
|
+
const max = Math.max(0.0001, ...days.map((entry) => entry.cost));
|
|
1038
|
+
const tip = useChartTip(days.length);
|
|
1039
|
+
const dense = tip.width > 0 && days.length > 0 && tip.width / days.length < 26;
|
|
1040
|
+
const gap = dense ? 2 : 8;
|
|
1041
|
+
const labelStride = dense ? Math.max(1, Math.ceil(days.length / 7)) : 1;
|
|
1042
|
+
const active = tip.active >= 0 ? days[tip.active] : null;
|
|
1043
|
+
const label = active ? `${active.day}${active.holiday ? ` · ${active.holiday}` : ''}` : '';
|
|
1044
|
+
const rows = active
|
|
1045
|
+
? [
|
|
1046
|
+
[t('tip.cost'), yuan(active.cost)],
|
|
1047
|
+
[t('tip.calls'), `${active.calls} ${t('unit.calls')}`],
|
|
1048
|
+
[t('tip.tokens'), tokens(active.tokens || 0, t)],
|
|
1049
|
+
[t('tip.hit'), percent(active.hitRate || 0)],
|
|
1050
|
+
]
|
|
1051
|
+
: [];
|
|
1052
|
+
return h(
|
|
1053
|
+
'div',
|
|
1054
|
+
{
|
|
1055
|
+
role: 'group',
|
|
1056
|
+
tabIndex: 0,
|
|
1057
|
+
'aria-label': t('chart.days'),
|
|
1058
|
+
title: t('tip.hint'),
|
|
1059
|
+
onKeyDown: tip.onKeyDown,
|
|
1060
|
+
onFocus: tip.onFocus,
|
|
1061
|
+
onBlur: tip.onBlur,
|
|
1062
|
+
style: {
|
|
1063
|
+
position: 'relative',
|
|
1064
|
+
marginTop: 4,
|
|
1065
|
+
borderRadius: 6,
|
|
1066
|
+
outline: tip.focused ? `2px solid ${C.out}` : 'none',
|
|
1067
|
+
outlineOffset: 2,
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
h(
|
|
1071
|
+
'div',
|
|
1072
|
+
{
|
|
1073
|
+
ref: tip.boxRef,
|
|
1074
|
+
onMouseLeave: tip.clear,
|
|
1075
|
+
style: { display: 'flex', alignItems: 'flex-end', gap, height: 128 },
|
|
1076
|
+
},
|
|
1077
|
+
days.map((entry, index) =>
|
|
1078
|
+
h(
|
|
1079
|
+
'div',
|
|
1080
|
+
{
|
|
1081
|
+
key: entry.day,
|
|
1082
|
+
ref: (node) => {
|
|
1083
|
+
tip.columns.current[index] = node;
|
|
1084
|
+
},
|
|
1085
|
+
onMouseEnter: () => tip.show(index),
|
|
1086
|
+
style: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 3, height: '100%' },
|
|
1087
|
+
},
|
|
1088
|
+
dense
|
|
1089
|
+
? null
|
|
1090
|
+
: h('span', { style: { fontSize: 9.5, color: C.text3, fontVariantNumeric: 'tabular-nums' } }, entry.cost > 0 ? entry.cost.toFixed(1) : ''),
|
|
1091
|
+
h(
|
|
1092
|
+
'div',
|
|
1093
|
+
{
|
|
1094
|
+
style: {
|
|
1095
|
+
flex: 1,
|
|
1096
|
+
width: '100%',
|
|
1097
|
+
display: 'flex',
|
|
1098
|
+
flexDirection: 'column',
|
|
1099
|
+
justifyContent: 'flex-end',
|
|
1100
|
+
borderRadius: 4,
|
|
1101
|
+
overflow: 'hidden',
|
|
1102
|
+
opacity: tip.active < 0 || tip.active === index ? 1 : 0.45,
|
|
1103
|
+
transition: 'opacity 120ms',
|
|
1104
|
+
},
|
|
1105
|
+
},
|
|
1106
|
+
h('div', { style: { height: `${(entry.peakCost / max) * 100}%`, background: C.peak, opacity: 0.9 } }),
|
|
1107
|
+
h('div', { style: { height: `${(entry.valleyCost / max) * 100}%`, background: C.valley, opacity: 0.9 } }),
|
|
1108
|
+
),
|
|
1109
|
+
index % labelStride === 0
|
|
1110
|
+
? h('span', { style: { fontSize: dense ? 9 : 9.5, color: C.text2, whiteSpace: 'nowrap' } }, dense ? entry.day.slice(8) : entry.day.slice(5))
|
|
1111
|
+
: h('span', { style: { height: dense ? 11 : 12 } }),
|
|
1112
|
+
),
|
|
1113
|
+
),
|
|
1114
|
+
),
|
|
1115
|
+
tip.anchor ? h(ChartTip, { title: label, rows, left: tip.anchor.left, width: tip.anchor.width }) : null,
|
|
1116
|
+
active ? h('span', { 'aria-live': 'polite', style: srOnly }, `${label} · ${rows.map((row) => `${row[0]} ${row[1]}`).join(' · ')}`) : null,
|
|
857
1117
|
);
|
|
858
1118
|
}
|
|
859
1119
|
|
|
@@ -906,9 +1166,8 @@ window.__ModuleLoader__.load({
|
|
|
906
1166
|
h('td', { style: { padding: '4px 8px', color: C.text } }, offset === 0 ? model.label : ''),
|
|
907
1167
|
h(
|
|
908
1168
|
'td',
|
|
909
|
-
{ style: { padding: '4px 8px', color: C.text2 } },
|
|
1169
|
+
{ style: { padding: '4px 8px', color: C.text2, fontWeight: current ? 600 : 400 } },
|
|
910
1170
|
isPeak ? t('status.peak') : t('status.valley'),
|
|
911
|
-
current ? ` · ${t('price.current')}` : '',
|
|
912
1171
|
),
|
|
913
1172
|
h('td', { style: { padding: '4px 8px', textAlign: 'right', color: C.text } }, model.hit[offset]),
|
|
914
1173
|
h('td', { style: { padding: '4px 8px', textAlign: 'right', color: C.text } }, model.miss[offset]),
|
|
@@ -918,33 +1177,38 @@ window.__ModuleLoader__.load({
|
|
|
918
1177
|
}
|
|
919
1178
|
}
|
|
920
1179
|
return h(
|
|
921
|
-
'
|
|
922
|
-
{ style: {
|
|
1180
|
+
'div',
|
|
1181
|
+
{ style: { overflowX: 'auto', margin: '0 -2px' } },
|
|
923
1182
|
h(
|
|
924
|
-
'
|
|
925
|
-
|
|
1183
|
+
'table',
|
|
1184
|
+
{ style: { width: '100%', borderCollapse: 'collapse', fontSize: 11.5 } },
|
|
926
1185
|
h(
|
|
927
|
-
'
|
|
1186
|
+
'thead',
|
|
928
1187
|
null,
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1188
|
+
h(
|
|
1189
|
+
'tr',
|
|
1190
|
+
null,
|
|
1191
|
+
head.map((label, index) =>
|
|
1192
|
+
h(
|
|
1193
|
+
'th',
|
|
1194
|
+
{
|
|
1195
|
+
key: label,
|
|
1196
|
+
style: {
|
|
1197
|
+
padding: '3px 8px',
|
|
1198
|
+
textAlign: index >= 2 ? 'right' : 'left',
|
|
1199
|
+
fontWeight: 500,
|
|
1200
|
+
color: C.text3,
|
|
1201
|
+
whiteSpace: 'nowrap',
|
|
1202
|
+
borderBottom: `1px solid ${C.border}`,
|
|
1203
|
+
},
|
|
940
1204
|
},
|
|
941
|
-
|
|
942
|
-
|
|
1205
|
+
label,
|
|
1206
|
+
),
|
|
943
1207
|
),
|
|
944
1208
|
),
|
|
945
1209
|
),
|
|
1210
|
+
h('tbody', null, rows),
|
|
946
1211
|
),
|
|
947
|
-
h('tbody', null, rows),
|
|
948
1212
|
);
|
|
949
1213
|
}
|
|
950
1214
|
|
|
@@ -1030,30 +1294,34 @@ window.__ModuleLoader__.load({
|
|
|
1030
1294
|
}
|
|
1031
1295
|
const head = [t('price.model'), t('projects.calls'), t('projects.tokens'), t('projects.cost')];
|
|
1032
1296
|
return h(
|
|
1033
|
-
'
|
|
1034
|
-
{ style: {
|
|
1297
|
+
'div',
|
|
1298
|
+
{ style: { overflowX: 'auto', margin: '0 -2px' } },
|
|
1035
1299
|
h(
|
|
1036
|
-
'
|
|
1037
|
-
|
|
1300
|
+
'table',
|
|
1301
|
+
{ style: { width: '100%', borderCollapse: 'collapse', fontSize: 11.5 } },
|
|
1038
1302
|
h(
|
|
1039
|
-
'
|
|
1303
|
+
'thead',
|
|
1040
1304
|
null,
|
|
1041
|
-
head.map((label, index) =>
|
|
1042
|
-
h('th', { key: label, style: cellHead(index === 0 ? 'left' : 'right') }, label),
|
|
1043
|
-
),
|
|
1044
|
-
),
|
|
1045
|
-
),
|
|
1046
|
-
h(
|
|
1047
|
-
'tbody',
|
|
1048
|
-
null,
|
|
1049
|
-
rows.map((model) =>
|
|
1050
1305
|
h(
|
|
1051
1306
|
'tr',
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1307
|
+
null,
|
|
1308
|
+
head.map((label, index) =>
|
|
1309
|
+
h('th', { key: label, style: cellHead(index === 0 ? 'left' : 'right') }, label),
|
|
1310
|
+
),
|
|
1311
|
+
),
|
|
1312
|
+
),
|
|
1313
|
+
h(
|
|
1314
|
+
'tbody',
|
|
1315
|
+
null,
|
|
1316
|
+
rows.map((model) =>
|
|
1317
|
+
h(
|
|
1318
|
+
'tr',
|
|
1319
|
+
{ key: model.id },
|
|
1320
|
+
h('td', { style: { ...cellBody, color: C.text } }, model.label),
|
|
1321
|
+
h('td', { style: { ...cellBody, textAlign: 'right' } }, model.calls),
|
|
1322
|
+
h('td', { style: { ...cellBody, textAlign: 'right' } }, tokens(model.tokens, t)),
|
|
1323
|
+
h('td', { style: { ...cellBody, textAlign: 'right' } }, yuan(model.cost)),
|
|
1324
|
+
),
|
|
1057
1325
|
),
|
|
1058
1326
|
),
|
|
1059
1327
|
),
|
|
@@ -1096,21 +1364,39 @@ window.__ModuleLoader__.load({
|
|
|
1096
1364
|
setDraft((previous) => previous.map((entry, index) => (index === modelIndex ? { ...entry, [field]: entry[field].map((value, i) => (i === offset ? raw : value)) } : entry)));
|
|
1097
1365
|
setMessage('');
|
|
1098
1366
|
},
|
|
1099
|
-
style: { width:
|
|
1367
|
+
style: { width: '100%', minWidth: 0, padding: '4px 5px', borderRadius: 5, border: `1px solid ${C.border}`, color: C.text, background: C.layer2, fontVariantNumeric: 'tabular-nums', boxSizing: 'border-box' },
|
|
1100
1368
|
});
|
|
1101
|
-
const
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
h(
|
|
1107
|
-
|
|
1369
|
+
const fieldGrid = { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(146px, 1fr))', gap: 8 };
|
|
1370
|
+
const fieldRow = (model, modelIndex, field, key) => h(
|
|
1371
|
+
'label',
|
|
1372
|
+
{ key: field, style: { display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 } },
|
|
1373
|
+
h('span', { style: { fontSize: 10.5, color: C.text3 } }, `${t(key)} · ${t('pricing.valley')}/${t('pricing.peak')}`),
|
|
1374
|
+
h(
|
|
1375
|
+
'span',
|
|
1376
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 4, minWidth: 0 } },
|
|
1108
1377
|
priceInput(model, modelIndex, field, 0),
|
|
1109
|
-
h('span', { key: 'sep', style: { color: C.text3, fontSize: 10 } }, '/'),
|
|
1110
|
-
priceInput(model, modelIndex, field, 1)
|
|
1378
|
+
h('span', { key: 'sep', style: { color: C.text3, fontSize: 10, flex: 'none' } }, '/'),
|
|
1379
|
+
priceInput(model, modelIndex, field, 1),
|
|
1380
|
+
),
|
|
1381
|
+
);
|
|
1382
|
+
const rows = draft.map((model, modelIndex) => h(
|
|
1383
|
+
'div',
|
|
1384
|
+
{
|
|
1385
|
+
key: model.id,
|
|
1386
|
+
style: {
|
|
1387
|
+
display: 'flex',
|
|
1388
|
+
flexDirection: 'column',
|
|
1389
|
+
gap: 6,
|
|
1390
|
+
paddingBottom: 8,
|
|
1391
|
+
borderBottom: modelIndex === draft.length - 1 ? 'none' : `1px solid ${C.border}`,
|
|
1392
|
+
},
|
|
1393
|
+
},
|
|
1394
|
+
h('span', { key: 'label', style: { fontSize: 11.5, color: C.text, fontWeight: 600 } }, model.label),
|
|
1395
|
+
h('div', { key: 'fields', style: fieldGrid }, fields.map(([field, key]) => fieldRow(model, modelIndex, field, key))),
|
|
1396
|
+
));
|
|
1111
1397
|
return h(Card, null,
|
|
1112
1398
|
h(CardTitle, { title: t('pricing.title'), hint: t('pricing.hint') }),
|
|
1113
|
-
h('div', { style: { display: 'flex', flexDirection: 'column', gap:
|
|
1399
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } }, rows),
|
|
1114
1400
|
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
|
|
1115
1401
|
h('button', {
|
|
1116
1402
|
type: 'button',
|
|
@@ -1269,7 +1555,7 @@ window.__ModuleLoader__.load({
|
|
|
1269
1555
|
body.push(
|
|
1270
1556
|
h(
|
|
1271
1557
|
'div',
|
|
1272
|
-
{ key: 'kpi', style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(140px, 1fr))', gap: 10 } },
|
|
1558
|
+
{ key: 'kpi', style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 140px), 1fr))', gap: 10 } },
|
|
1273
1559
|
h(Kpi, {
|
|
1274
1560
|
label: t('kpi.runway'),
|
|
1275
1561
|
value: wallet && wallet.runwayDays !== null ? runway(wallet.runwayDays, t) : '—',
|
|
@@ -1308,10 +1594,10 @@ window.__ModuleLoader__.load({
|
|
|
1308
1594
|
body.push(
|
|
1309
1595
|
h(
|
|
1310
1596
|
'div',
|
|
1311
|
-
{ key: 'charts', style: { display: '
|
|
1597
|
+
{ key: 'charts', style: { display: 'flex', flexWrap: 'wrap', gap: 10, alignItems: 'stretch' } },
|
|
1312
1598
|
h(
|
|
1313
1599
|
Card,
|
|
1314
|
-
|
|
1600
|
+
{ style: { flex: '1.5 1 340px', minWidth: 0 } },
|
|
1315
1601
|
h(CardTitle, { title: t('chart.hours'), hint: t('chart.hoursHint') }),
|
|
1316
1602
|
h(HourChart, { hours: data.hours, nowHour: data.now.hour, t }),
|
|
1317
1603
|
h(
|
|
@@ -1322,7 +1608,7 @@ window.__ModuleLoader__.load({
|
|
|
1322
1608
|
),
|
|
1323
1609
|
h(
|
|
1324
1610
|
Card,
|
|
1325
|
-
|
|
1611
|
+
{ style: { flex: '1 1 220px', minWidth: 0 } },
|
|
1326
1612
|
h(CardTitle, { title: t('cost.title') }),
|
|
1327
1613
|
h(CostSplit, {
|
|
1328
1614
|
t,
|
package/index.js
CHANGED
|
@@ -342,7 +342,8 @@ export function collectTurns() {
|
|
|
342
342
|
|
|
343
343
|
export function emptyDay(day) {
|
|
344
344
|
const hours = [];
|
|
345
|
-
for (let hour = 0; hour < 24; hour += 1)
|
|
345
|
+
for (let hour = 0; hour < 24; hour += 1)
|
|
346
|
+
hours.push({ hour, cost: 0, calls: 0, inputTokens: 0, cacheTokens: 0, outputTokens: 0 });
|
|
346
347
|
return {
|
|
347
348
|
day,
|
|
348
349
|
calls: 0,
|
|
@@ -395,6 +396,9 @@ export function addTurn(day, turn, pricing = PRICING) {
|
|
|
395
396
|
const bucket = day.hours[hour];
|
|
396
397
|
bucket.cost += cost;
|
|
397
398
|
bucket.calls += 1;
|
|
399
|
+
bucket.inputTokens += turn.input;
|
|
400
|
+
bucket.cacheTokens += turn.cache;
|
|
401
|
+
bucket.outputTokens += turn.output;
|
|
398
402
|
|
|
399
403
|
const modelKey = price.id;
|
|
400
404
|
const slot = day.models[modelKey] || (day.models[modelKey] = { calls: 0, cost: 0, tokens: 0 });
|
|
@@ -459,12 +463,17 @@ export function round(value) {
|
|
|
459
463
|
|
|
460
464
|
export function hoursOf(day) {
|
|
461
465
|
const midnight = Date.parse(`${day.day}T00:00:00Z`) - BJ_OFFSET;
|
|
462
|
-
return day.hours.map((bucket) =>
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
466
|
+
return day.hours.map((bucket) => {
|
|
467
|
+
const billable = bucket.inputTokens + bucket.cacheTokens;
|
|
468
|
+
return {
|
|
469
|
+
hour: bucket.hour,
|
|
470
|
+
cost: round(bucket.cost),
|
|
471
|
+
calls: bucket.calls,
|
|
472
|
+
peak: isPeakAt(midnight + bucket.hour * 3600_000),
|
|
473
|
+
tokens: bucket.inputTokens + bucket.cacheTokens + bucket.outputTokens,
|
|
474
|
+
hitRate: billable > 0 ? bucket.cacheTokens / billable : 0,
|
|
475
|
+
};
|
|
476
|
+
});
|
|
468
477
|
}
|
|
469
478
|
|
|
470
479
|
/** Calendar years touched by the window that have no holiday data yet. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-usage-peak",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DeepSeek Harness 用量峰谷仪表盘:峰/谷时段(含节假日与调休)、按请求开始时刻计价、自定义价目表、今日花费与 tokens、项目下钻/模型统计、可配置预算预警、余额可撑天数、CSV 导出、7/14/30 天窗口、缓存命中、谷时更省,侧栏常驻胶囊 + 设置页详情。",
|
|
6
6
|
"exports": {
|
package/test/client.test.js
CHANGED
|
@@ -10,7 +10,7 @@ function helpers(storage = {}) {
|
|
|
10
10
|
const context = { window: { localStorage: storage, dispatchEvent: (event) => events.push(event) }, CustomEvent: class { constructor(type, options) { this.type = type; this.detail = options.detail; } }, C: { error: 'red', peak: 'amber', text3: 'gray' }, DATA_URL: '/data', DEFAULT_DAYS: 14 };
|
|
11
11
|
const start = source.indexOf(" const PREFS_KEY =");
|
|
12
12
|
const stop = source.indexOf(' function useFeed(', start);
|
|
13
|
-
vm.runInNewContext(source.slice(start, stop) + '\nthis.api = { validatePrefs, readPrefs, savePrefs, alertState, feedUrl, requestGate, tint, pillStatus, validatePricing, readPricing, savePricing, encodePricing, pricingParam, clonePricing, DEFAULT_PRICING };', context);
|
|
13
|
+
vm.runInNewContext(source.slice(start, stop) + '\nthis.api = { validatePrefs, readPrefs, savePrefs, alertState, feedUrl, requestGate, tint, pillStatus, tipAnchor, validatePricing, readPricing, savePricing, encodePricing, pricingParam, clonePricing, DEFAULT_PRICING };', context);
|
|
14
14
|
return { ...context.api, events };
|
|
15
15
|
}
|
|
16
16
|
const plain = (value) => JSON.parse(JSON.stringify(value));
|
|
@@ -80,6 +80,15 @@ test('client alert prefix keeps the peak/valley countdown visible', () => {
|
|
|
80
80
|
assert.equal(api.pillStatus(false, '2:43 后转谷'), '2:43 后转谷');
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
+
test('client tooltip anchor stays inside the chart box', () => {
|
|
84
|
+
const api = helpers();
|
|
85
|
+
assert.equal(api.tipAnchor(100, 200, 400), 4);
|
|
86
|
+
assert.equal(api.tipAnchor(300, 200, 400), 196);
|
|
87
|
+
assert.equal(api.tipAnchor(20, 200, 400), 4);
|
|
88
|
+
assert.equal(api.tipAnchor(399, 200, 400), 196);
|
|
89
|
+
assert.equal(api.tipAnchor(50, 120, 100), 4);
|
|
90
|
+
});
|
|
91
|
+
|
|
83
92
|
test('client request generation guard rejects old filters, refreshes, and unmount results', () => {
|
|
84
93
|
const gate = helpers().requestGate();
|
|
85
94
|
gate.select('alpha');
|
package/test/core.test.js
CHANGED
|
@@ -242,6 +242,23 @@ test('emptyDay starts with 24 empty hour buckets', () => {
|
|
|
242
242
|
assert.equal(day.lastAt, 0);
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
+
test('hour buckets carry tokens and the cache hit rate', () => {
|
|
246
|
+
const now = bj(2026, 11, 10, 10);
|
|
247
|
+
const agg = aggregateTurns(
|
|
248
|
+
[
|
|
249
|
+
{ t: now, model: 'deepseek-flash', input: 1e6, cache: 3e6, output: 0.5e6 },
|
|
250
|
+
{ t: now + 30 * 60_000, model: 'deepseek-flash', input: 1e6, cache: 0, output: 0.5e6 },
|
|
251
|
+
],
|
|
252
|
+
{ now, days: 7 },
|
|
253
|
+
);
|
|
254
|
+
const hour = agg.hours[10];
|
|
255
|
+
assert.equal(hour.calls, 2);
|
|
256
|
+
assert.equal(hour.tokens, 6e6);
|
|
257
|
+
assert.equal(hour.hitRate, 0.6);
|
|
258
|
+
assert.equal(agg.hours[11].tokens, 0);
|
|
259
|
+
assert.equal(agg.hours[11].hitRate, 0);
|
|
260
|
+
});
|
|
261
|
+
|
|
245
262
|
test('window edges stay stable across a day boundary', () => {
|
|
246
263
|
const now = bj(2026, 11, 10, 0, 0) + 1; // one ms past midnight
|
|
247
264
|
const agg = aggregateTurns([], { now, days: 7 });
|