@laoyuehanni/dsh-token-usage 0.3.13 → 0.4.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.
Files changed (91) hide show
  1. package/README.md +21 -86
  2. package/README.zh.md +21 -90
  3. package/docs/pricing.md +79 -0
  4. package/lib/client/StatCard.d.ts +61 -5
  5. package/lib/client/StatCard.d.ts.map +1 -1
  6. package/lib/client/StatCard.js +39 -1
  7. package/lib/client/StatCard.js.map +1 -1
  8. package/lib/client/TokenUsageCard.d.ts.map +1 -1
  9. package/lib/client/TokenUsageCard.js +23 -12
  10. package/lib/client/TokenUsageCard.js.map +1 -1
  11. package/lib/client/TokenUsageSection.d.ts.map +1 -1
  12. package/lib/client/TokenUsageSection.js +5 -5
  13. package/lib/client/TokenUsageSection.js.map +1 -1
  14. package/lib/client/TrendChart.d.ts +12 -3
  15. package/lib/client/TrendChart.d.ts.map +1 -1
  16. package/lib/client/TrendChart.js +30 -19
  17. package/lib/client/TrendChart.js.map +1 -1
  18. package/lib/client/UsageView.d.ts +6 -5
  19. package/lib/client/UsageView.d.ts.map +1 -1
  20. package/lib/client/UsageView.js +19 -14
  21. package/lib/client/UsageView.js.map +1 -1
  22. package/lib/client/format.d.ts +18 -3
  23. package/lib/client/format.d.ts.map +1 -1
  24. package/lib/client/format.js +45 -3
  25. package/lib/client/format.js.map +1 -1
  26. package/lib/client/locales.d.ts +21 -1
  27. package/lib/client/locales.d.ts.map +1 -1
  28. package/lib/client/locales.js +42 -2
  29. package/lib/client/locales.js.map +1 -1
  30. package/lib/client/trend-chart/index.d.ts +1 -1
  31. package/lib/client/trend-chart/index.d.ts.map +1 -1
  32. package/lib/client/trend-chart/index.js +1 -1
  33. package/lib/client/trend-chart/index.js.map +1 -1
  34. package/lib/client/trend-chart/points.d.ts +11 -0
  35. package/lib/client/trend-chart/points.d.ts.map +1 -1
  36. package/lib/client/trend-chart/points.js +20 -0
  37. package/lib/client/trend-chart/points.js.map +1 -1
  38. package/lib/client.js +318 -50
  39. package/lib/client.js.map +1 -1
  40. package/lib/index.d.ts +14 -0
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/index.js +117 -28
  43. package/lib/index.js.map +1 -1
  44. package/lib/log.d.ts +18 -0
  45. package/lib/log.d.ts.map +1 -0
  46. package/lib/log.js +16 -0
  47. package/lib/log.js.map +1 -0
  48. package/lib/migrate.d.ts +2 -1
  49. package/lib/migrate.d.ts.map +1 -1
  50. package/lib/migrate.js +3 -2
  51. package/lib/migrate.js.map +1 -1
  52. package/lib/pricing.d.ts +5 -2
  53. package/lib/pricing.d.ts.map +1 -1
  54. package/lib/pricing.js +15 -12
  55. package/lib/pricing.js.map +1 -1
  56. package/lib/record-cache.d.ts +11 -4
  57. package/lib/record-cache.d.ts.map +1 -1
  58. package/lib/record-cache.js +16 -9
  59. package/lib/record-cache.js.map +1 -1
  60. package/lib/rollup.d.ts +15 -8
  61. package/lib/rollup.d.ts.map +1 -1
  62. package/lib/rollup.js +14 -9
  63. package/lib/rollup.js.map +1 -1
  64. package/lib/stats-route.d.ts +3 -0
  65. package/lib/stats-route.d.ts.map +1 -1
  66. package/lib/stats-route.js +6 -4
  67. package/lib/stats-route.js.map +1 -1
  68. package/lib/stats.d.ts +8 -5
  69. package/lib/stats.d.ts.map +1 -1
  70. package/lib/stats.js +74 -26
  71. package/lib/stats.js.map +1 -1
  72. package/lib/sync-state.d.ts +2 -1
  73. package/lib/sync-state.d.ts.map +1 -1
  74. package/lib/sync-state.js +3 -2
  75. package/lib/sync-state.js.map +1 -1
  76. package/lib/sync.d.ts +24 -3
  77. package/lib/sync.d.ts.map +1 -1
  78. package/lib/sync.js +42 -10
  79. package/lib/sync.js.map +1 -1
  80. package/lib/usage-log.d.ts +23 -8
  81. package/lib/usage-log.d.ts.map +1 -1
  82. package/lib/usage-log.js +129 -17
  83. package/lib/usage-log.js.map +1 -1
  84. package/lib/usage-record.d.ts +88 -7
  85. package/lib/usage-record.d.ts.map +1 -1
  86. package/lib/usage-record.js +140 -4
  87. package/lib/usage-record.js.map +1 -1
  88. package/lib/wire.d.ts +19 -1
  89. package/lib/wire.d.ts.map +1 -1
  90. package/lib/wire.js.map +1 -1
  91. package/package.json +7 -1
package/lib/client.js CHANGED
@@ -1050,6 +1050,19 @@ window.__ModuleLoader__.load({
1050
1050
  }
1051
1051
  //#endregion
1052
1052
  //#region src/client/format.ts
1053
+ /** Known `LlmFailure.code`s that have a `fail.*` locale label. An unknown
1054
+ * future code is not in this map and the tooltip renders it verbatim. */
1055
+ const FAILURE_CODE_LABEL_KEYS = {
1056
+ RATE_LIMIT: "fail.RATE_LIMIT",
1057
+ SERVER: "fail.SERVER",
1058
+ TIMEOUT: "fail.TIMEOUT",
1059
+ TRANSPORT: "fail.TRANSPORT",
1060
+ EMPTY_RESPONSE: "fail.EMPTY_RESPONSE",
1061
+ QUOTA: "fail.QUOTA",
1062
+ CONTEXT_WINDOW_EXCEEDED: "fail.CONTEXT_WINDOW_EXCEEDED",
1063
+ INVALID_CREDENTIAL: "fail.INVALID_CREDENTIAL",
1064
+ UNKNOWN: "fail.UNKNOWN"
1065
+ };
1053
1066
  /** One decimal below 10, integer otherwise, trailing `.0` stripped. */
1054
1067
  function scale(value) {
1055
1068
  if (value >= 10) return String(Math.round(value));
@@ -1191,6 +1204,27 @@ window.__ModuleLoader__.load({
1191
1204
  const clamped = Math.max(0, tokensPerSecond);
1192
1205
  return clamped >= 10 ? String(Math.round(clamped)) : String(Math.round(clamped * 10) / 10);
1193
1206
  }
1207
+ /**
1208
+ * The failure pill's hover tooltip text: one `label ×count` line per failure
1209
+ * class, largest count first (code name ascending breaks ties), newline-joined —
1210
+ * the shell Tooltip renders `pre-line`, so each line lands on its own row.
1211
+ * Known `LlmFailure.code`s map through `fail.*` locale keys (限流 / Rate
1212
+ * limited); an unknown future code renders verbatim. A legacy shape without
1213
+ * the breakdown, or an empty map, yields '' and the caller suppresses the
1214
+ * tooltip.
1215
+ * @param byCode - the per-code failure counts from the totals (may be undefined).
1216
+ * @param t - locale lookup; codes without a `fail.*` key stay verbatim.
1217
+ * @returns the multi-line tooltip label, or '' when there is nothing to show.
1218
+ */
1219
+ function failuresTooltip(byCode, t) {
1220
+ if (byCode === void 0) return "";
1221
+ return Object.entries(byCode).filter(([, count]) => count > 0).sort((left, right) => right[1] - left[1] || left[0].localeCompare(right[0])).map(([code, count]) => `${failureCodeLabel(code, t)} ×${count}`).join("\n");
1222
+ }
1223
+ /** Locale label for one failure code; unknown codes stay verbatim. */
1224
+ function failureCodeLabel(code, t) {
1225
+ if (Object.hasOwn(FAILURE_CODE_LABEL_KEYS, code)) return t(FAILURE_CODE_LABEL_KEYS[code]);
1226
+ return code;
1227
+ }
1194
1228
  //#endregion
1195
1229
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\hit-rate-band.module.css.mjs
1196
1230
  const css$8 = ".t6JM8a_band_critical{color:var(--dsw-alias-state-error-primary,#dc2626)}.t6JM8a_band_amber{color:#f59e0b}.t6JM8a_band_lime{color:#84cc16}.t6JM8a_band_healthy{color:var(--dsw-alias-state-success-primary,#16a34a)}";
@@ -1875,7 +1909,8 @@ window.__ModuleLoader__.load({
1875
1909
  processed: body.processed,
1876
1910
  total: body.total,
1877
1911
  added: body.added,
1878
- skipped: body.skipped
1912
+ skipped: body.skipped,
1913
+ failedSessions: typeof body.failedSessions === "number" ? body.failedSessions : 0
1879
1914
  };
1880
1915
  return null;
1881
1916
  }
@@ -1920,7 +1955,8 @@ window.__ModuleLoader__.load({
1920
1955
  processed: 0,
1921
1956
  total: 0,
1922
1957
  added: 0,
1923
- skipped: 0
1958
+ skipped: 0,
1959
+ failedSessions: 0
1924
1960
  });
1925
1961
  return;
1926
1962
  }
@@ -2071,14 +2107,14 @@ window.__ModuleLoader__.load({
2071
2107
  fullSync.status === "running" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2072
2108
  className: TokenUsageCard_module_css_default.fullSyncProgress,
2073
2109
  role: "status",
2074
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2110
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2075
2111
  className: TokenUsageCard_module_css_default.fullSyncProgressLabel,
2076
- children: t("card.fullSync.progress", {
2112
+ children: [t("card.fullSync.progress", {
2077
2113
  processed: String(fullSync.processed),
2078
2114
  total: String(fullSync.total),
2079
2115
  added: String(fullSync.added),
2080
2116
  skipped: String(fullSync.skipped)
2081
- })
2117
+ }), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
2082
2118
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2083
2119
  className: TokenUsageCard_module_css_default.fullSyncBar,
2084
2120
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -2087,13 +2123,13 @@ window.__ModuleLoader__.load({
2087
2123
  })
2088
2124
  })]
2089
2125
  }) : null,
2090
- fullSync.status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2126
+ fullSync.status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
2091
2127
  className: TokenUsageCard_module_css_default.fullSyncResult,
2092
2128
  role: "status",
2093
- children: t("card.fullSync.done", {
2129
+ children: [t("card.fullSync.done", {
2094
2130
  added: String(fullSync.added),
2095
2131
  skipped: String(fullSync.skipped)
2096
- })
2132
+ }), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
2097
2133
  }) : null,
2098
2134
  fullSync.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2099
2135
  className: TokenUsageCard_module_css_default.fullSyncError,
@@ -2537,7 +2573,7 @@ window.__ModuleLoader__.load({
2537
2573
  }
2538
2574
  //#endregion
2539
2575
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\StatCard.module.css.mjs
2540
- const css$3 = ".F2LbNW_card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;flex-direction:column;gap:2px;min-width:0;padding:10px 12px;display:flex}.F2LbNW_cardLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;font-size:11px;overflow:hidden}.F2LbNW_cardValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:18px;font-weight:600;overflow:hidden}";
2576
+ const css$3 = ".F2LbNW_card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;flex-direction:column;gap:2px;min-width:0;padding:10px 12px;display:flex}.F2LbNW_cardLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;font-size:11px;overflow:hidden}.F2LbNW_cardValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);flex-wrap:wrap;align-items:baseline;gap:4px 8px;min-width:0;font-size:18px;font-weight:600;display:flex}.F2LbNW_cardValueMain{white-space:nowrap;text-overflow:ellipsis;min-width:0;overflow:hidden}.F2LbNW_pillWrap{flex-shrink:0;display:inline-flex}.F2LbNW_pillWrap [role=tooltip]{white-space:pre;width:max-content;min-width:max-content;max-width:none;font-size:12px;font-weight:400;line-height:1.4}.F2LbNW_split{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:baseline;column-gap:4px;width:100%;display:grid}.F2LbNW_splitOk{text-align:right;min-width:0}.F2LbNW_splitSep{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary))}.F2LbNW_splitFailHead{text-align:left;min-width:0}.F2LbNW_splitFail{text-align:left;min-width:0;color:var(--dsw-alias-state-error-primary);display:block}.F2LbNW_split>.F2LbNW_pillWrap{justify-self:stretch;min-width:0;display:block}.F2LbNW_pill{font-variant-numeric:tabular-nums;white-space:nowrap;color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 28%, transparent);border-radius:999px;flex-shrink:0;padding:1px 7px;font-size:12px;font-weight:400;line-height:1.4}";
2541
2577
  const tagId$3 = "@laoyuehanni/dsh-token-usage/StatCard.module.css";
2542
2578
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
2543
2579
  const tag = document.createElement("style");
@@ -2549,7 +2585,15 @@ window.__ModuleLoader__.load({
2549
2585
  var StatCard_module_css_default = {
2550
2586
  "card": "F2LbNW_card",
2551
2587
  "cardLabel": "F2LbNW_cardLabel",
2552
- "cardValue": "F2LbNW_cardValue"
2588
+ "cardValue": "F2LbNW_cardValue",
2589
+ "cardValueMain": "F2LbNW_cardValueMain",
2590
+ "pill": "F2LbNW_pill",
2591
+ "pillWrap": "F2LbNW_pillWrap",
2592
+ "split": "F2LbNW_split",
2593
+ "splitFail": "F2LbNW_splitFail",
2594
+ "splitFailHead": "F2LbNW_splitFailHead",
2595
+ "splitOk": "F2LbNW_splitOk",
2596
+ "splitSep": "F2LbNW_splitSep"
2553
2597
  };
2554
2598
  //#endregion
2555
2599
  //#region src/client/StatCard.tsx
@@ -2569,6 +2613,108 @@ window.__ModuleLoader__.load({
2569
2613
  })]
2570
2614
  });
2571
2615
  }
2616
+ /**
2617
+ * Compact "失败 n" chip for the requests **card** only. Hovering or focusing
2618
+ * it lists `限流 ×count` per class. Zero failures render nothing. Per-model
2619
+ * tables do not use this — they print `A/B` via {@link RequestsCell}.
2620
+ */
2621
+ function FailurePill({ failures, failuresByCode, t }) {
2622
+ if (failures === 0) return null;
2623
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2624
+ className: StatCard_module_css_default["pillWrap"],
2625
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
2626
+ label: failuresTooltip(failuresByCode, t),
2627
+ side: "bottom",
2628
+ delayMs: 200,
2629
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2630
+ className: StatCard_module_css_default["pill"],
2631
+ tabIndex: 0,
2632
+ children: t("stat.failuresPill", { count: failures.toLocaleString() })
2633
+ })
2634
+ })
2635
+ });
2636
+ }
2637
+ /**
2638
+ * The requests tile both dashboards share: hero figure is the successful
2639
+ * count; a compact pill to its right carries the failure count.
2640
+ */
2641
+ function RequestsStatCard({ requests, failures, failuresByCode, t }) {
2642
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
2643
+ label: t("stat.requests"),
2644
+ value: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2645
+ className: StatCard_module_css_default["cardValueMain"],
2646
+ children: requests.toLocaleString()
2647
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailurePill, {
2648
+ failures,
2649
+ failuresByCode,
2650
+ t
2651
+ })] })
2652
+ });
2653
+ }
2654
+ /** Column header for the per-model success/fail split: same 3-track
2655
+ * grid as {@link RequestsCell} so the slash sits on the column midline. */
2656
+ function RequestsSplitHead({ t }) {
2657
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2658
+ className: StatCard_module_css_default["split"],
2659
+ children: [
2660
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2661
+ className: StatCard_module_css_default["splitOk"],
2662
+ children: t("stat.ok")
2663
+ }),
2664
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2665
+ className: StatCard_module_css_default["splitSep"],
2666
+ "aria-hidden": true,
2667
+ children: "/"
2668
+ }),
2669
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2670
+ className: StatCard_module_css_default["splitFailHead"],
2671
+ children: t("stat.fail")
2672
+ })
2673
+ ]
2674
+ });
2675
+ }
2676
+ /** One table cell: successful count, and when failures > 0 a slash on
2677
+ * the column midline plus the failure count in the error color.
2678
+ * Zero failures print only A (same left track, so the figure still
2679
+ * lines up with rows that have a B). Hovering B lists the per-code
2680
+ * breakdown. */
2681
+ function RequestsCell({ requests, failures, failuresByCode, t }) {
2682
+ const ok = requests.toLocaleString();
2683
+ const okFigure = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2684
+ className: StatCard_module_css_default["splitOk"],
2685
+ children: ok
2686
+ });
2687
+ if (failures === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2688
+ className: StatCard_module_css_default["split"],
2689
+ children: okFigure
2690
+ });
2691
+ const fail = failures.toLocaleString();
2692
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2693
+ className: StatCard_module_css_default["split"],
2694
+ children: [
2695
+ okFigure,
2696
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2697
+ className: StatCard_module_css_default["splitSep"],
2698
+ "aria-hidden": true,
2699
+ children: "/"
2700
+ }),
2701
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2702
+ className: StatCard_module_css_default["pillWrap"],
2703
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
2704
+ label: failuresTooltip(failuresByCode, t),
2705
+ side: "bottom",
2706
+ delayMs: 200,
2707
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2708
+ className: StatCard_module_css_default["splitFail"],
2709
+ tabIndex: 0,
2710
+ "aria-label": t("stat.failuresPill", { count: fail }),
2711
+ children: fail
2712
+ })
2713
+ })
2714
+ })
2715
+ ]
2716
+ });
2717
+ }
2572
2718
  //#endregion
2573
2719
  //#region src/client/trend-chart/axis.ts
2574
2720
  /**
@@ -2726,6 +2872,34 @@ window.__ModuleLoader__.load({
2726
2872
  };
2727
2873
  return null;
2728
2874
  }
2875
+ /**
2876
+ * The cumulative view of a series: every point's `tokens` replaced by the
2877
+ * running total up to and including that point (a prefix sum), so the chart
2878
+ * reads as a monotonic rise. Orthogonal to the mode — all three input
2879
+ * shapes are time-ascending, so a plain forward fold is order-correct. The
2880
+ * input series is left untouched; each point is copied with only `tokens`
2881
+ * rewritten, so the renderer's shape probes (`'time' in point`) keep working.
2882
+ * @param series - the series from {@link buildChartPoints}.
2883
+ * @returns a new series of the same mode and shape.
2884
+ */
2885
+ function cumulateSeries(series) {
2886
+ let running = 0;
2887
+ const fold = (points) => points.map((point) => {
2888
+ running += point.tokens;
2889
+ return {
2890
+ ...point,
2891
+ tokens: running
2892
+ };
2893
+ });
2894
+ if (series.mode === "equidistant") return {
2895
+ mode: "equidistant",
2896
+ points: fold(series.points)
2897
+ };
2898
+ return {
2899
+ mode: "temporal",
2900
+ points: fold(series.points)
2901
+ };
2902
+ }
2729
2903
  /** A series that already carries `count` (the host's `fields=session`
2730
2904
  * downsample) is plotted as-is; a raw per-request series is folded here. */
2731
2905
  function bucketsOf(requests) {
@@ -2886,21 +3060,28 @@ window.__ModuleLoader__.load({
2886
3060
  /**
2887
3061
  * Apply the `t`-based localisation to a point's `full` tooltip. The pre-shape
2888
3062
  * labels live in points.ts; the chart's aria-label and the floating tooltip
2889
- * both use this single source so the two stay consistent.
3063
+ * both use this single source so the two stay consistent. Cumulative mode
3064
+ * swaps in its own phrasing so "total" never reads ambiguous next to a
3065
+ * running sum.
2890
3066
  * @param t - the locale seat.
2891
3067
  * @param point - the pre-shaped point.
3068
+ * @param mode - the active y-axis mode.
2892
3069
  * @returns the tooltip / aria-label text.
2893
3070
  */
2894
- function tipOf(t, point) {
2895
- if (point.time !== void 0) return t("chart.bucket", {
2896
- window: point.full,
2897
- count: String(point.count ?? 0),
2898
- tokens: formatTokens(point.tokens)
2899
- });
2900
- return t("chart.pointLabel", {
3071
+ function tipOf(t, point, mode) {
3072
+ if (point.time !== void 0) {
3073
+ const params = {
3074
+ window: point.full,
3075
+ count: String(point.count ?? 0),
3076
+ tokens: formatTokens(point.tokens)
3077
+ };
3078
+ return mode === "cumulative" ? t("chart.cumulativeBucket", params) : t("chart.bucket", params);
3079
+ }
3080
+ const params = {
2901
3081
  day: point.full,
2902
3082
  tokens: formatTokens(point.tokens)
2903
- });
3083
+ };
3084
+ return mode === "cumulative" ? t("chart.cumulativePoint", params) : t("chart.pointLabel", params);
2904
3085
  }
2905
3086
  /**
2906
3087
  * Render the daily / hourly / request-bucketed token line chart. Pure
@@ -2915,22 +3096,25 @@ window.__ModuleLoader__.load({
2915
3096
  * @param props - the filtered per-day rows plus the optional per-hour rows
2916
3097
  * (when present the chart plots hours instead of days), the optional
2917
3098
  * per-request series (session-scoped reads), the active range bounds
2918
- * (absent when unfiltered; the chart then spans first to last row), and
3099
+ * (absent when unfiltered; the chart then spans first to last row), the
3100
+ * optional y-axis mode (interval totals, or their running cumulative sum),
3101
+ * and
2919
3102
  * the `t` seat for the empty hint and chart aria-label.
2920
3103
  * @returns the SVG chart, or a placeholder for an empty range.
2921
3104
  */
2922
- function TrendChart({ rows, hours, requests, from, to, t }) {
2923
- const series = buildChartPoints({
3105
+ function TrendChart({ rows, hours, requests, from, to, mode = "interval", t }) {
3106
+ const base = buildChartPoints({
2924
3107
  rows,
2925
3108
  hours,
2926
3109
  requests,
2927
3110
  from,
2928
3111
  to
2929
3112
  });
2930
- if (series === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3113
+ if (base === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2931
3114
  className: TrendChart_module_css_default.empty,
2932
3115
  children: t("chart.empty")
2933
3116
  });
3117
+ const series = mode === "cumulative" ? cumulateSeries(base) : base;
2934
3118
  const points = series.points.map((point) => ({
2935
3119
  key: point.key,
2936
3120
  label: point.label,
@@ -2947,7 +3131,7 @@ window.__ModuleLoader__.load({
2947
3131
  const activePoint = active === null ? null : points[active] ?? null;
2948
3132
  const y = (tokens) => 152 - tokens / top * innerHeight;
2949
3133
  const path = points.map((point, index) => `${index === 0 ? "M" : "L"}${xs[index].toFixed(1)},${y(point.tokens).toFixed(1)}`).join(" ");
2950
- const chartAria = series.mode === "temporal" ? t("chart.ariaRequests") : hours !== void 0 ? t("chart.ariaHour") : t("chart.aria");
3134
+ const chartAria = mode === "cumulative" ? t("chart.ariaCumulative") : series.mode === "temporal" ? t("chart.ariaRequests") : hours !== void 0 ? t("chart.ariaHour") : t("chart.aria");
2951
3135
  const hitExtent = (index) => {
2952
3136
  if (points.length === 1) return {
2953
3137
  start: LEFT,
@@ -3016,7 +3200,7 @@ window.__ModuleLoader__.load({
3016
3200
  width: hit.width,
3017
3201
  height: innerHeight,
3018
3202
  fill: "transparent",
3019
- "aria-label": tipOf(t, point),
3203
+ "aria-label": tipOf(t, point, mode),
3020
3204
  role: "button",
3021
3205
  tabIndex: 0,
3022
3206
  className: TrendChart_module_css_default.hit,
@@ -3026,7 +3210,7 @@ window.__ModuleLoader__.load({
3026
3210
  }, point.key);
3027
3211
  }),
3028
3212
  activePoint !== null ? (() => {
3029
- const label = tipOf(t, activePoint);
3213
+ const label = tipOf(t, activePoint, mode);
3030
3214
  const labelWidth = label.length * 6.2 + 12;
3031
3215
  const center = xs[active];
3032
3216
  const left = Math.min(Math.max(center - labelWidth / 2, LEFT), 784 - labelWidth);
@@ -3469,16 +3653,18 @@ window.__ModuleLoader__.load({
3469
3653
  onChange: setFilters,
3470
3654
  t
3471
3655
  }),
3472
- total.requests === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3656
+ total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3473
3657
  className: TokenUsageSection_module_css_default["empty"],
3474
3658
  children: t("empty")
3475
3659
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3476
3660
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3477
3661
  className: TokenUsageSection_module_css_default["cards"],
3478
3662
  children: [
3479
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
3480
- label: t("stat.requests"),
3481
- value: total.requests.toLocaleString()
3663
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
3664
+ requests: total.requests,
3665
+ failures: total.failures ?? 0,
3666
+ failuresByCode: total.failuresByCode,
3667
+ t
3482
3668
  }),
3483
3669
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
3484
3670
  label: t("stat.cost"),
@@ -3544,7 +3730,10 @@ window.__ModuleLoader__.load({
3544
3730
  className: TokenUsageSection_module_css_default["modelHead"],
3545
3731
  children: t("filter.model")
3546
3732
  }),
3547
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.requests") }),
3733
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
3734
+ "aria-label": t("stat.successFail"),
3735
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
3736
+ }),
3548
3737
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cost") }),
3549
3738
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.totalTokens") }),
3550
3739
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
@@ -3574,7 +3763,12 @@ window.__ModuleLoader__.load({
3574
3763
  })]
3575
3764
  })
3576
3765
  }),
3577
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.totals.requests.toLocaleString() }),
3766
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
3767
+ requests: row.totals.requests,
3768
+ failures: row.totals.failures ?? 0,
3769
+ failuresByCode: row.totals.failuresByCode,
3770
+ t
3771
+ }) }),
3578
3772
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: rules !== void 0 ? formatCost(row.cost, view) : "—" }),
3579
3773
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
3580
3774
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.inputTokens) }),
@@ -3599,7 +3793,7 @@ window.__ModuleLoader__.load({
3599
3793
  }
3600
3794
  //#endregion
3601
3795
  //#region \0dsh-css:D:\Code\dsh-token-usage\src\client\UsageView.module.css.mjs
3602
- const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;margin:0 auto;display:flex;overflow-y:auto}._0MkXVa_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}._0MkXVa_headRight{align-items:center;gap:10px;display:flex}._0MkXVa_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}._0MkXVa_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}._0MkXVa_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}._0MkXVa_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}._0MkXVa_segBtn:hover:not(._0MkXVa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._0MkXVa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._0MkXVa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._0MkXVa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._0MkXVa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._0MkXVa_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}._0MkXVa_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}._0MkXVa_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}._0MkXVa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}._0MkXVa_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}._0MkXVa_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}._0MkXVa_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}._0MkXVa_mid{grid-template-columns:minmax(0,3fr) minmax(0,2fr);align-items:start;gap:14px;display:grid}._0MkXVa_chartCol,._0MkXVa_modelCol,._0MkXVa_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}._0MkXVa_subagentsHead{align-items:center;gap:8px;display:flex}._0MkXVa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}._0MkXVa_tableWrap{overflow-x:auto}._0MkXVa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}._0MkXVa_table th,._0MkXVa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}._0MkXVa_table th:first-child,._0MkXVa_table td:first-child,._0MkXVa_modelHead{text-align:left}._0MkXVa_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}._0MkXVa_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}._0MkXVa_childLink:hover{text-decoration:underline}._0MkXVa_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}@media (width<=900px){._0MkXVa_cards{grid-template-columns:repeat(3,minmax(0,1fr))}._0MkXVa_mid{grid-template-columns:1fr}}";
3796
+ const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;margin:0 auto;display:flex;overflow-y:auto}._0MkXVa_head{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:12px;display:flex}._0MkXVa_headRight{align-items:center;gap:10px;display:flex}._0MkXVa_back{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;padding:3px 10px;font-size:12px}._0MkXVa_back:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}._0MkXVa_segmented{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}._0MkXVa_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 12px;font-size:12px;font-weight:500}._0MkXVa_segBtn:hover:not(._0MkXVa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._0MkXVa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._0MkXVa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._0MkXVa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._0MkXVa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._0MkXVa_empty{color:var(--dsw-alias-label-secondary);text-align:center;margin:24px 0 0;font-size:13px}._0MkXVa_button{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border-radius:6px;align-self:flex-start;padding:3px 10px;font-size:12px}._0MkXVa_warning{color:var(--dsw-alias-state-warning-primary,var(--dsw-alias-label-secondary));margin:0;font-size:12px}._0MkXVa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px}._0MkXVa_cards{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;display:grid}._0MkXVa_tokenStrip{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:18px;padding:6px 2px 0;font-size:12px;display:flex}._0MkXVa_tokenStrip b{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}._0MkXVa_mid{grid-template-columns:minmax(0,3fr) minmax(0,2fr);align-items:start;gap:14px;display:grid}._0MkXVa_chartCol,._0MkXVa_modelCol,._0MkXVa_subagents{flex-direction:column;gap:6px;min-width:0;display:flex}._0MkXVa_subagentsHead,._0MkXVa_chartHead{align-items:center;gap:8px;display:flex}._0MkXVa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px;font-weight:600}._0MkXVa_tableWrap{overflow-x:auto}._0MkXVa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}._0MkXVa_table th,._0MkXVa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}._0MkXVa_table th:first-child,._0MkXVa_table td:first-child,._0MkXVa_modelHead{text-align:left}._0MkXVa_modelCell{font-variant-numeric:normal;text-overflow:ellipsis;max-width:180px;overflow:hidden}._0MkXVa_childLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;max-width:220px;padding:0;font-size:12px;overflow:hidden}._0MkXVa_childLink:hover{text-decoration:underline}._0MkXVa_nestedBadge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px;font-size:11px}@media (width<=900px){._0MkXVa_cards{grid-template-columns:repeat(3,minmax(0,1fr))}._0MkXVa_mid{grid-template-columns:1fr}}";
3603
3797
  const tagId = "@laoyuehanni/dsh-token-usage/UsageView.module.css";
3604
3798
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
3605
3799
  const tag = document.createElement("style");
@@ -3613,6 +3807,7 @@ window.__ModuleLoader__.load({
3613
3807
  "button": "_0MkXVa_button",
3614
3808
  "cards": "_0MkXVa_cards",
3615
3809
  "chartCol": "_0MkXVa_chartCol",
3810
+ "chartHead": "_0MkXVa_chartHead",
3616
3811
  "childLink": "_0MkXVa_childLink",
3617
3812
  "empty": "_0MkXVa_empty",
3618
3813
  "error": "_0MkXVa_error",
@@ -3643,11 +3838,12 @@ window.__ModuleLoader__.load({
3643
3838
  * The conversation view tab "Usage" (browser half): one entry of the
3644
3839
  * `conversation.view` slot ring (beside Chat / Trajectory), rendering the
3645
3840
  * per-session token & cost dashboard for the ACTIVE conversation. The tab
3646
- * shows the focused session's totals (4 token buckets, cost, hit rate,
3647
- * TTFT average, decode throughput) with a scope switch between the session
3648
- * alone and its whole subagent subtree, a per-hour trend chart and the
3649
- * per-model table from the host stats route (`sessionId`-scoped), and a
3650
- * subagent table below — each row drill-in switches the focus to that child.
3841
+ * shows the focused session's totals (successful requests with a failure
3842
+ * pill, 4 token buckets, cost, hit rate, TTFT average, decode throughput) with a
3843
+ * scope switch between the session alone and its whole subagent subtree, a
3844
+ * per-hour trend chart and the per-model table from the host stats route
3845
+ * (`sessionId`-scoped), and a subagent table below — each row drill-in
3846
+ * switches the focus to that child.
3651
3847
  *
3652
3848
  * Data sources: token/cost figures come from the host route (the pricing
3653
3849
  * rule chain's authority); TTFT and throughput come from the framework's
@@ -3688,6 +3884,7 @@ window.__ModuleLoader__.load({
3688
3884
  const rootRef = (0, react.useRef)(null);
3689
3885
  useColorSchemeMirror(rootRef);
3690
3886
  const [scope, setScope] = (0, react.useState)("session");
3887
+ const [chartMode, setChartMode] = (0, react.useState)("interval");
3691
3888
  const [focusId, setFocusId] = (0, react.useState)(sessionId);
3692
3889
  (0, react.useEffect)(() => {
3693
3890
  setFocusId(sessionId);
@@ -3800,16 +3997,18 @@ window.__ModuleLoader__.load({
3800
3997
  className: UsageView_module_css_default["root"],
3801
3998
  children: [
3802
3999
  header,
3803
- total.requests === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4000
+ total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3804
4001
  className: UsageView_module_css_default["empty"],
3805
4002
  children: t("view.empty")
3806
4003
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3807
4004
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3808
4005
  className: UsageView_module_css_default["cards"],
3809
4006
  children: [
3810
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
3811
- label: t("stat.requests"),
3812
- value: total.requests.toLocaleString()
4007
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsStatCard, {
4008
+ requests: total.requests,
4009
+ failures: total.failures ?? 0,
4010
+ failuresByCode: total.failuresByCode,
4011
+ t
3813
4012
  }),
3814
4013
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
3815
4014
  label: t("stat.cost"),
@@ -3871,11 +4070,32 @@ window.__ModuleLoader__.load({
3871
4070
  className: UsageView_module_css_default["mid"],
3872
4071
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3873
4072
  className: UsageView_module_css_default["chartCol"],
3874
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3875
- className: UsageView_module_css_default["subtitle"],
3876
- children: t("view.chart.title")
4073
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4074
+ className: UsageView_module_css_default["chartHead"],
4075
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
4076
+ className: UsageView_module_css_default["subtitle"],
4077
+ children: t("view.chart.title")
4078
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4079
+ className: UsageView_module_css_default["segmented"],
4080
+ role: "group",
4081
+ "aria-label": t("chart.mode.label"),
4082
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4083
+ type: "button",
4084
+ className: chartMode === "interval" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
4085
+ "aria-pressed": chartMode === "interval",
4086
+ onClick: () => setChartMode("interval"),
4087
+ children: t("chart.mode.interval")
4088
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4089
+ type: "button",
4090
+ className: chartMode === "cumulative" ? `${UsageView_module_css_default["segBtn"]} ${UsageView_module_css_default["segActive"]}` : UsageView_module_css_default["segBtn"],
4091
+ "aria-pressed": chartMode === "cumulative",
4092
+ onClick: () => setChartMode("cumulative"),
4093
+ children: t("chart.mode.cumulative")
4094
+ })]
4095
+ })]
3877
4096
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrendChart, {
3878
4097
  rows: summary.byDay,
4098
+ mode: chartMode,
3879
4099
  t,
3880
4100
  ...summary.requestSeries !== void 0 ? { requests: summary.requestSeries } : {},
3881
4101
  ...summary.byDay.length === 1 ? { hours: summary.byHour } : {}
@@ -3895,7 +4115,10 @@ window.__ModuleLoader__.load({
3895
4115
  className: UsageView_module_css_default["modelHead"],
3896
4116
  children: t("filter.model")
3897
4117
  }),
3898
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.requests") }),
4118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4119
+ "aria-label": t("stat.successFail"),
4120
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
4121
+ }),
3899
4122
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.input") }),
3900
4123
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.output") }),
3901
4124
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: t("stat.cacheRead") }),
@@ -3907,7 +4130,12 @@ window.__ModuleLoader__.load({
3907
4130
  className: UsageView_module_css_default["modelCell"],
3908
4131
  children: row.model
3909
4132
  }),
3910
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: row.totals.requests.toLocaleString() }),
4133
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
4134
+ requests: row.totals.requests,
4135
+ failures: row.totals.failures ?? 0,
4136
+ failuresByCode: row.totals.failuresByCode,
4137
+ t
4138
+ }) }),
3911
4139
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.inputTokens) }),
3912
4140
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.outputTokens) }),
3913
4141
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(row.totals.cacheReadTokens) }),
@@ -3995,7 +4223,7 @@ window.__ModuleLoader__.load({
3995
4223
  })
3996
4224
  })]
3997
4225
  }),
3998
- total.requests > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4226
+ (total.requests > 0 || (total.failures ?? 0) > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3999
4227
  className: UsageView_module_css_default["note"],
4000
4228
  children: t("view.note")
4001
4229
  })
@@ -4036,7 +4264,20 @@ window.__ModuleLoader__.load({
4036
4264
  "calendar.weekday.4": "五",
4037
4265
  "calendar.weekday.5": "六",
4038
4266
  "calendar.weekday.6": "日",
4039
- "stat.requests": "请求数",
4267
+ "stat.requests": "成功请求数",
4268
+ "stat.successFail": "成功/失败",
4269
+ "stat.ok": "成功",
4270
+ "stat.fail": "失败",
4271
+ "stat.failuresPill": "失败 {count}",
4272
+ "fail.RATE_LIMIT": "限流",
4273
+ "fail.SERVER": "服务异常",
4274
+ "fail.TIMEOUT": "超时",
4275
+ "fail.TRANSPORT": "网络异常",
4276
+ "fail.EMPTY_RESPONSE": "空响应",
4277
+ "fail.QUOTA": "配额耗尽",
4278
+ "fail.CONTEXT_WINDOW_EXCEEDED": "上下文超限",
4279
+ "fail.INVALID_CREDENTIAL": "凭证无效",
4280
+ "fail.UNKNOWN": "未知错误",
4040
4281
  "stat.totalTokens": "总 token",
4041
4282
  "stat.hitRate": "命中率",
4042
4283
  "stat.cost": "费用",
@@ -4092,6 +4333,7 @@ window.__ModuleLoader__.load({
4092
4333
  "card.fullSync.button": "开始扫描",
4093
4334
  "card.fullSync.running": "扫描中…",
4094
4335
  "card.fullSync.progress": "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条",
4336
+ "card.fullSync.failuresNote": ",无法读取 {count} 个 session 已跳过",
4095
4337
  "card.fullSync.done": "扫描完成:新增 {added} 条,跳过 {skipped} 条",
4096
4338
  "card.fullSync.failed": "扫描失败:{error}",
4097
4339
  "loadFailed": "统计加载失败:{message}",
@@ -4102,6 +4344,12 @@ window.__ModuleLoader__.load({
4102
4344
  "chart.ariaRequests": "按时间分段的 token 曲线",
4103
4345
  "chart.pointLabel": "{day} 总量 {tokens}",
4104
4346
  "chart.bucket": "{window} · {count} 请求 · {tokens}",
4347
+ "chart.mode.label": "趋势模式",
4348
+ "chart.mode.interval": "分时",
4349
+ "chart.mode.cumulative": "累计",
4350
+ "chart.ariaCumulative": "累计 token 曲线",
4351
+ "chart.cumulativePoint": "{day} 累计 {tokens}",
4352
+ "chart.cumulativeBucket": "{window} · {count} 请求 · 累计 {tokens}",
4105
4353
  "view.usage": "用量",
4106
4354
  "view.scope.label": "统计范围",
4107
4355
  "view.scope.session": "本会话",
@@ -4156,7 +4404,20 @@ window.__ModuleLoader__.load({
4156
4404
  "calendar.weekday.4": "Fr",
4157
4405
  "calendar.weekday.5": "Sa",
4158
4406
  "calendar.weekday.6": "Su",
4159
- "stat.requests": "Requests",
4407
+ "stat.requests": "Successful requests",
4408
+ "stat.successFail": "OK/Fail",
4409
+ "stat.ok": "OK",
4410
+ "stat.fail": "Fail",
4411
+ "stat.failuresPill": "Failed {count}",
4412
+ "fail.RATE_LIMIT": "Rate limited",
4413
+ "fail.SERVER": "Server error",
4414
+ "fail.TIMEOUT": "Timed out",
4415
+ "fail.TRANSPORT": "Network error",
4416
+ "fail.EMPTY_RESPONSE": "Empty response",
4417
+ "fail.QUOTA": "Quota exceeded",
4418
+ "fail.CONTEXT_WINDOW_EXCEEDED": "Context exceeded",
4419
+ "fail.INVALID_CREDENTIAL": "Invalid credential",
4420
+ "fail.UNKNOWN": "Unknown error",
4160
4421
  "stat.totalTokens": "Total",
4161
4422
  "stat.hitRate": "Hit %",
4162
4423
  "stat.cost": "Cost",
@@ -4212,6 +4473,7 @@ window.__ModuleLoader__.load({
4212
4473
  "card.fullSync.button": "Start scan",
4213
4474
  "card.fullSync.running": "Scanning…",
4214
4475
  "card.fullSync.progress": "Processed {processed}/{total} sessions, added {added}, skipped {skipped}",
4476
+ "card.fullSync.failuresNote": ", {count} unreadable sessions skipped",
4215
4477
  "card.fullSync.done": "Scan complete: added {added}, skipped {skipped}",
4216
4478
  "card.fullSync.failed": "Scan failed: {error}",
4217
4479
  "loadFailed": "Failed to load stats: {message}",
@@ -4222,6 +4484,12 @@ window.__ModuleLoader__.load({
4222
4484
  "chart.ariaRequests": "Time-bucketed token trend",
4223
4485
  "chart.pointLabel": "{day} total {tokens}",
4224
4486
  "chart.bucket": "{window} · {count} requests · {tokens}",
4487
+ "chart.mode.label": "Trend mode",
4488
+ "chart.mode.interval": "Interval",
4489
+ "chart.mode.cumulative": "Cumulative",
4490
+ "chart.ariaCumulative": "Cumulative token trend",
4491
+ "chart.cumulativePoint": "{day} cumulative {tokens}",
4492
+ "chart.cumulativeBucket": "{window} · {count} requests · cumulative {tokens}",
4225
4493
  "view.usage": "Usage",
4226
4494
  "view.scope.label": "Scope",
4227
4495
  "view.scope.session": "Session",