@laoyuehanni/dsh-token-usage 0.4.13 → 0.4.14

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 (86) hide show
  1. package/README.md +17 -9
  2. package/README.zh.md +17 -9
  3. package/lib/aux-request.d.ts +4 -0
  4. package/lib/aux-request.d.ts.map +1 -1
  5. package/lib/aux-request.js +1 -0
  6. package/lib/aux-request.js.map +1 -1
  7. package/lib/client/DashboardCards.d.ts +18 -10
  8. package/lib/client/DashboardCards.d.ts.map +1 -1
  9. package/lib/client/DashboardCards.js +14 -8
  10. package/lib/client/DashboardCards.js.map +1 -1
  11. package/lib/client/RequestPool.d.ts.map +1 -1
  12. package/lib/client/RequestPool.js +42 -18
  13. package/lib/client/RequestPool.js.map +1 -1
  14. package/lib/client/TokenUsageSection.d.ts.map +1 -1
  15. package/lib/client/TokenUsageSection.js +25 -14
  16. package/lib/client/TokenUsageSection.js.map +1 -1
  17. package/lib/client/UsageRows.d.ts +19 -11
  18. package/lib/client/UsageRows.d.ts.map +1 -1
  19. package/lib/client/UsageRows.js +59 -16
  20. package/lib/client/UsageRows.js.map +1 -1
  21. package/lib/client/format.d.ts +5 -0
  22. package/lib/client/format.d.ts.map +1 -1
  23. package/lib/client/format.js +5 -0
  24. package/lib/client/format.js.map +1 -1
  25. package/lib/client/locales.d.ts +10 -0
  26. package/lib/client/locales.d.ts.map +1 -1
  27. package/lib/client/locales.js +20 -0
  28. package/lib/client/locales.js.map +1 -1
  29. package/lib/client.js +219 -48
  30. package/lib/client.js.map +1 -1
  31. package/lib/compaction-attribution.d.ts +72 -0
  32. package/lib/compaction-attribution.d.ts.map +1 -0
  33. package/lib/compaction-attribution.js +82 -0
  34. package/lib/compaction-attribution.js.map +1 -0
  35. package/lib/field-completion.d.ts +46 -0
  36. package/lib/field-completion.d.ts.map +1 -0
  37. package/lib/field-completion.js +71 -0
  38. package/lib/field-completion.js.map +1 -0
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/index.js +145 -15
  41. package/lib/index.js.map +1 -1
  42. package/lib/migrate.d.ts +2 -1
  43. package/lib/migrate.d.ts.map +1 -1
  44. package/lib/migrate.js +13 -1
  45. package/lib/migrate.js.map +1 -1
  46. package/lib/provider-label.d.ts +20 -0
  47. package/lib/provider-label.d.ts.map +1 -0
  48. package/lib/provider-label.js +21 -0
  49. package/lib/provider-label.js.map +1 -0
  50. package/lib/provider-names.d.ts +60 -0
  51. package/lib/provider-names.d.ts.map +1 -0
  52. package/lib/provider-names.js +156 -0
  53. package/lib/provider-names.js.map +1 -0
  54. package/lib/rollup.d.ts +10 -4
  55. package/lib/rollup.d.ts.map +1 -1
  56. package/lib/rollup.js +21 -4
  57. package/lib/rollup.js.map +1 -1
  58. package/lib/session-request-details.d.ts.map +1 -1
  59. package/lib/session-request-details.js +2 -0
  60. package/lib/session-request-details.js.map +1 -1
  61. package/lib/stats-route.d.ts +4 -0
  62. package/lib/stats-route.d.ts.map +1 -1
  63. package/lib/stats-route.js +14 -1
  64. package/lib/stats-route.js.map +1 -1
  65. package/lib/stats.d.ts.map +1 -1
  66. package/lib/stats.js +86 -19
  67. package/lib/stats.js.map +1 -1
  68. package/lib/sync-state.d.ts +43 -0
  69. package/lib/sync-state.d.ts.map +1 -1
  70. package/lib/sync-state.js +106 -0
  71. package/lib/sync-state.js.map +1 -1
  72. package/lib/sync.d.ts.map +1 -1
  73. package/lib/sync.js +26 -5
  74. package/lib/sync.js.map +1 -1
  75. package/lib/usage-log.d.ts +31 -0
  76. package/lib/usage-log.d.ts.map +1 -1
  77. package/lib/usage-log.js +172 -8
  78. package/lib/usage-log.js.map +1 -1
  79. package/lib/usage-record.d.ts +33 -8
  80. package/lib/usage-record.d.ts.map +1 -1
  81. package/lib/usage-record.js +79 -12
  82. package/lib/usage-record.js.map +1 -1
  83. package/lib/wire.d.ts +53 -1
  84. package/lib/wire.d.ts.map +1 -1
  85. package/lib/wire.js.map +1 -1
  86. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -547,6 +547,20 @@ window.__ModuleLoader__.load({
547
547
  }
548
548
  return points;
549
549
  }
550
+ // src/provider-label.ts
551
+ /**
552
+ * Label for a route key. The name registry wins; a missing or empty entry
553
+ * falls back to the key itself, so a route the registry never saw still
554
+ * displays. A route without a name is not an error — the registry is a
555
+ * convenience, the route key is the identity.
556
+ * @param id - the route key.
557
+ * @param names - the name registry, when the caller has one.
558
+ * @returns the display name, or the route key itself.
559
+ */
560
+ function providerLabel(id, names) {
561
+ const name = names?.[id];
562
+ return name !== void 0 && name !== "" ? name : id;
563
+ }
550
564
  // src/client/format.ts
551
565
  /** Known `LlmFailure.code`s that have a `fail.*` locale label. An unknown
552
566
  * future code is not in this map and the tooltip renders it verbatim. */
@@ -4165,7 +4179,7 @@ window.__ModuleLoader__.load({
4165
4179
  });
4166
4180
  }
4167
4181
  // \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/UsageRows.module.css.mjs
4168
- const css$10 = ".qYVDeG_rows{flex-direction:column;min-height:120px;max-height:400px;padding-right:2px;display:flex;overflow-y:auto;container-type:inline-size}.qYVDeG_rows::-webkit-scrollbar{width:8px}.qYVDeG_rows::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.qYVDeG_rows.qYVDeG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.qYVDeG_rows::-webkit-scrollbar-track{background:0 0}.qYVDeG_row{border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:12px;padding:4px 0;display:flex}.qYVDeG_row:last-child{border-bottom:none}.qYVDeG_rowName{width:138px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;flex:none;font-size:12px;font-weight:400;overflow:hidden}.qYVDeG_nameLine{align-items:baseline;gap:4px;width:100%;min-width:0;display:flex}.qYVDeG_nameGrow{flex:1;width:auto}.qYVDeG_nameText{text-overflow:ellipsis;white-space:nowrap;min-width:0;font:inherit;color:inherit;text-align:left;background:0 0;border:none;border-bottom:1.5px dashed #0000;padding:0;font-size:12px;overflow:hidden}.qYVDeG_jumpable{cursor:pointer;border-bottom-color:var(--dsw-alias-label-secondary);color:var(--dsw-alias-label-primary);text-decoration:none}.qYVDeG_jumpable:hover{border-bottom-color:var(--dsw-alias-label-primary)}.qYVDeG_badge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:10px}.qYVDeG_track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:2px;flex:1;min-width:0;height:3px;overflow:hidden}.qYVDeG_fill{background:color-mix(in srgb, var(--dsw-alias-label-primary) 55%, transparent);border-radius:2px;height:100%;display:block}.qYVDeG_rowNums{text-align:right;width:118px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.qYVDeG_rowCost{text-align:right;font-variant-numeric:tabular-nums;width:64px;color:var(--dsw-alias-label-primary);flex:none;font-size:12px;font-weight:600}.qYVDeG_srow .qYVDeG_rowCost{width:auto}.qYVDeG_perfToggle{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;align-items:center;gap:5px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500;display:inline-flex}.qYVDeG_perfToggle:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_perfToggle:focus-visible{outline:2px solid var(--dsw-alias-border-l1);outline-offset:1px}.qYVDeG_perfGauge{font-size:11px;line-height:1}.qYVDeG_perfOn{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);border-color:#0000;font-weight:600}.qYVDeG_perfNums{text-align:right;width:260px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;font-size:12px}.qYVDeG_perfNums b{color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_perfDim,.qYVDeG_perfDim b{color:var(--dsw-alias-label-tertiary);font-weight:400}.qYVDeG_srow{cursor:default;display:block}.qYVDeG_srow .qYVDeG_rowName{flex:1;width:auto}.qYVDeG_rowTop{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.qYVDeG_rowSub{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:11px;overflow:hidden}.qYVDeG_empty{color:var(--dsw-alias-label-tertiary);text-align:center;padding:16px 0;font-size:12px}.qYVDeG_segmented{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.qYVDeG_segBtn{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500}.qYVDeG_segBtn:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_controlCompact .qYVDeG_segBtn{padding:2px 7px;font-size:10px}.qYVDeG_controlCompact{border-radius:6px;padding:1px}.qYVDeG_perfCompact{border-radius:6px;padding:3px 7px;font-size:10px}@container (width<=440px){.qYVDeG_row:not(.qYVDeG_srow){grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_row:not(.qYVDeG_srow)>.qYVDeG_rowName{grid-column:1/-1;width:auto}.qYVDeG_track{display:none}.qYVDeG_rowNums{text-align:left;width:auto}.qYVDeG_perfNums{text-align:left;white-space:normal;overflow-wrap:anywhere;grid-column:1/-1;width:auto}.qYVDeG_rowTop{grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_rowTop>.qYVDeG_rowName{grid-column:1/-1}}";
4182
+ const css$10 = ".qYVDeG_rows{flex-direction:column;min-height:120px;max-height:400px;padding-right:2px;display:flex;overflow-y:auto;container-type:inline-size}.qYVDeG_rows::-webkit-scrollbar{width:8px}.qYVDeG_rows::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.qYVDeG_rows.qYVDeG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.qYVDeG_rows::-webkit-scrollbar-track{background:0 0}.qYVDeG_row{border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:12px;padding:4px 0;display:flex}.qYVDeG_row:last-child{border-bottom:none}.qYVDeG_rowName{width:138px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;flex:none;font-size:12px;font-weight:400;overflow:hidden}.qYVDeG_nameLine{align-items:baseline;gap:4px;width:100%;min-width:0;display:flex}.qYVDeG_nameGrow{flex:1;width:auto}.qYVDeG_nameDim{color:var(--dsw-alias-label-secondary)}.qYVDeG_hintWrap{min-width:0;display:inline-flex}.qYVDeG_hintWrap [role=tooltip]{white-space:pre-wrap;overflow-wrap:anywhere;width:max-content;min-width:0;max-width:min(360px,100vw - 24px);font-size:12px;font-weight:400;line-height:1.4}.qYVDeG_nameHint{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:help;border-radius:4px;flex:none;align-items:center;padding:2px 5px;font-size:10px;line-height:1;display:inline-flex}.qYVDeG_nameText{text-overflow:ellipsis;white-space:nowrap;min-width:0;font:inherit;color:inherit;text-align:left;background:0 0;border:none;border-bottom:1.5px dashed #0000;padding:0;font-size:12px;overflow:hidden}.qYVDeG_jumpable{cursor:pointer;border-bottom-color:var(--dsw-alias-label-secondary);color:var(--dsw-alias-label-primary);text-decoration:none}.qYVDeG_jumpable:hover{border-bottom-color:var(--dsw-alias-label-primary)}.qYVDeG_badge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:10px}.qYVDeG_track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:2px;flex:1;min-width:0;height:3px;overflow:hidden}.qYVDeG_fill{background:color-mix(in srgb, var(--dsw-alias-label-primary) 55%, transparent);border-radius:2px;height:100%;display:block}.qYVDeG_rowNums{text-align:right;width:118px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.qYVDeG_rowCost{text-align:right;font-variant-numeric:tabular-nums;width:64px;color:var(--dsw-alias-label-primary);flex:none;font-size:12px;font-weight:600}.qYVDeG_srow .qYVDeG_rowCost{width:auto}.qYVDeG_perfToggle{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;align-items:center;gap:5px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500;display:inline-flex}.qYVDeG_perfToggle:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_perfToggle:focus-visible{outline:2px solid var(--dsw-alias-border-l1);outline-offset:1px}.qYVDeG_perfGauge{font-size:11px;line-height:1}.qYVDeG_perfOn{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);border-color:#0000;font-weight:600}.qYVDeG_perfNums{text-align:right;width:260px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;font-size:12px}.qYVDeG_perfNums b{color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_perfDim,.qYVDeG_perfDim b{color:var(--dsw-alias-label-tertiary);font-weight:400}.qYVDeG_srow{cursor:default;display:block}.qYVDeG_srow .qYVDeG_rowName{flex:1;width:auto}.qYVDeG_rowTop{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.qYVDeG_rowSub{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:11px;overflow:hidden}.qYVDeG_empty{color:var(--dsw-alias-label-tertiary);text-align:center;padding:16px 0;font-size:12px}.qYVDeG_segmented{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.qYVDeG_segBtn{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500}.qYVDeG_segBtn:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_controlCompact .qYVDeG_segBtn{padding:2px 7px;font-size:10px}.qYVDeG_controlCompact{border-radius:6px;padding:1px}.qYVDeG_perfCompact{border-radius:6px;padding:3px 7px;font-size:10px}@container (width<=440px){.qYVDeG_row:not(.qYVDeG_srow){grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_row:not(.qYVDeG_srow)>.qYVDeG_rowName{grid-column:1/-1;width:auto}.qYVDeG_track{display:none}.qYVDeG_rowNums{text-align:left;width:auto}.qYVDeG_perfNums{text-align:left;white-space:normal;overflow-wrap:anywhere;grid-column:1/-1;width:auto}.qYVDeG_rowTop{grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_rowTop>.qYVDeG_rowName{grid-column:1/-1}}";
4169
4183
  const tagId$10 = "@laoyuehanni/dsh-token-usage/UsageRows.module.css";
4170
4184
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
4171
4185
  const tag = document.createElement("style");
@@ -4179,8 +4193,11 @@ window.__ModuleLoader__.load({
4179
4193
  "controlCompact": "qYVDeG_controlCompact",
4180
4194
  "empty": "qYVDeG_empty",
4181
4195
  "fill": "qYVDeG_fill",
4196
+ "hintWrap": "qYVDeG_hintWrap",
4182
4197
  "jumpable": "qYVDeG_jumpable",
4198
+ "nameDim": "qYVDeG_nameDim",
4183
4199
  "nameGrow": "qYVDeG_nameGrow",
4200
+ "nameHint": "qYVDeG_nameHint",
4184
4201
  "nameLine": "qYVDeG_nameLine",
4185
4202
  "nameText": "qYVDeG_nameText",
4186
4203
  "perfCompact": "qYVDeG_perfCompact",
@@ -4398,14 +4415,16 @@ window.__ModuleLoader__.load({
4398
4415
  }
4399
4416
  // src/client/UsageRows.tsx
4400
4417
  /**
4401
- * The dashboards' flat row lists (browser half): one component, three
4402
- * shapes — `project` (directory-tail folds), `model` (the priced rows) and
4403
- * `session` (two-line rows). All three read the same single-line grammar
4404
- * of the v3 demo: name | relative bar (projects/models only) | total
4405
- * tokens · cache share | cost; sessions swap the bar for a second identity
4406
- * line (directory · activity) under the same figures cells, all three
4407
- * lists rendering one figures style everywhere (no hover affordance — a
4408
- * former four-bucket popup read as clutter and went).
4418
+ * The dashboards' flat row lists (browser half): one component, four
4419
+ * shapes — `project` (directory-tail folds), `model` (the priced rows),
4420
+ * `session` (two-line rows) and `provider` (the per-route rows with the
4421
+ * unattributed remainder sunk to the bottom). All four read the same
4422
+ * single-line grammar of the v3 demo: name | relative bar (projects /
4423
+ * models / providers only) | total tokens · cache share | cost; sessions
4424
+ * swap the bar for a second identity line (directory · activity) under the
4425
+ * same figures cells, all four lists rendering one figures style everywhere
4426
+ * (no hover affordance — a former four-bucket popup read as clutter and
4427
+ * went).
4409
4428
  *
4410
4429
  * The relative bar scales to
4411
4430
  * the active sort's own measure — tokens while sorted by tokens, billed cost
@@ -4497,6 +4516,20 @@ window.__ModuleLoader__.load({
4497
4516
  function shortIdOf(sessionId) {
4498
4517
  return sessionId.length > 8 ? `${sessionId.slice(0, 8)}…` : sessionId;
4499
4518
  }
4519
+ /** The unattributed row's hover tooltip: an intro line, then the known
4520
+ * reasons a record can carry no route key as a numbered list, each line
4521
+ * indented by two spaces (the bubble renders `pre`, so the indent shows).
4522
+ * The list is the full closed set — deleted logs, pre-field history, and
4523
+ * bypass calls the host never gives a route key — so the reader sees this
4524
+ * row is expected, not a bug. */
4525
+ function unattributedTooltip(t) {
4526
+ const causes = [
4527
+ t("byProvider.cause.deletedLog"),
4528
+ t("byProvider.cause.preField"),
4529
+ t("byProvider.cause.bypass")
4530
+ ];
4531
+ return [t("byProvider.cause.intro"), ...causes.map((cause, index) => ` ${index + 1}. ${cause}`)].join("\n");
4532
+ }
4500
4533
  /** Relative last-active label (「3 小时前」): minutes inside the first hour,
4501
4534
  * hours inside the first day, days beyond. */
4502
4535
  function relativeTimeOf(time, t) {
@@ -4510,7 +4543,7 @@ window.__ModuleLoader__.load({
4510
4543
  * Render one flat row list. The list is the height-capped scroll container
4511
4544
  * (scrollbar appears while scrolling, fades 800ms after it stops).
4512
4545
  */
4513
- function UsageRows({ kind, projectRows, modelRows, sessionRows, sort, perfView, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName }) {
4546
+ function UsageRows({ kind, projectRows, modelRows, sessionRows, providerRows, providerNames, sort, perfView, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName }) {
4514
4547
  const ctrlHeld = useCtrlHeld();
4515
4548
  const scrollRef = (0, react.useRef)(null);
4516
4549
  const scrollTimer = (0, react.useRef)(void 0);
@@ -4528,7 +4561,7 @@ window.__ModuleLoader__.load({
4528
4561
  const perfMode = perfView === true && kind === "model";
4529
4562
  const active = sort ?? (kind === "session" ? "cost" : "tokens");
4530
4563
  const rows = (0, react.useMemo)(() => {
4531
- const base = kind === "project" ? projectRows : kind === "model" ? modelRows : sessionRows;
4564
+ const base = kind === "project" ? projectRows : kind === "model" ? modelRows : kind === "session" ? sessionRows : providerRows;
4532
4565
  if (base === void 0) return [];
4533
4566
  if (kind === "session") {
4534
4567
  if (active === "cost") return base;
@@ -4538,6 +4571,10 @@ window.__ModuleLoader__.load({
4538
4571
  if (active === "tokens") return base;
4539
4572
  return [...base].sort((left, right) => right.cost - left.cost || (left.name < right.name ? -1 : 1));
4540
4573
  }
4574
+ if (kind === "provider") {
4575
+ const unattributedLast = (row) => row.provider === "" ? 1 : 0;
4576
+ return [...base].sort((left, right) => unattributedLast(left) - unattributedLast(right) || (active === "cost" ? right.cost - left.cost : totalTokens$1(right.totals) - totalTokens$1(left.totals)) || (left.provider < right.provider ? -1 : 1));
4577
+ }
4541
4578
  const models = [...base];
4542
4579
  if (perfMode) {
4543
4580
  const ranked = (row) => row.perf !== void 0 && row.perf.samples >= 5;
@@ -4555,10 +4592,11 @@ window.__ModuleLoader__.load({
4555
4592
  projectRows,
4556
4593
  modelRows,
4557
4594
  sessionRows,
4595
+ providerRows,
4558
4596
  active,
4559
4597
  perfMode
4560
4598
  ]);
4561
- const barValueOf = (row) => perfMode ? "perf" in row && row.perf !== void 0 && row.perf.samples >= 5 ? row.perf.tokensPerSec : 0 : active === "cost" ? row.cost : totalTokens$1(row.totals);
4599
+ const barValueOf = (row) => perfMode ? "perf" in row && row.perf !== void 0 && row.perf.samples >= 5 ? row.perf.tokensPerSec : 0 : kind === "provider" && row.provider === "" ? 0 : active === "cost" ? row.cost : totalTokens$1(row.totals);
4562
4600
  const barMax = (0, react.useMemo)(() => {
4563
4601
  let max = 0;
4564
4602
  for (const row of rows) {
@@ -4628,7 +4666,7 @@ window.__ModuleLoader__.load({
4628
4666
  ]
4629
4667
  });
4630
4668
  };
4631
- const ariaLabel = kind === "project" ? t("byProject.title") : kind === "model" ? t("byModel.title") : t("bySession.title");
4669
+ const ariaLabel = kind === "project" ? t("byProject.title") : kind === "model" ? t("byModel.title") : kind === "session" ? t("bySession.title") : t("byProvider.title");
4632
4670
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4633
4671
  className: UsageRows_module_css_default["rows"],
4634
4672
  ref: scrollRef,
@@ -4725,6 +4763,56 @@ window.__ModuleLoader__.load({
4725
4763
  ]
4726
4764
  }, model.model);
4727
4765
  }
4766
+ if (kind === "provider") {
4767
+ const provider = row;
4768
+ const unattributed = provider.provider === "";
4769
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4770
+ className: UsageRows_module_css_default["row"],
4771
+ role: "listitem",
4772
+ children: [
4773
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4774
+ className: unattributed ? `${UsageRows_module_css_default["rowName"]} ${UsageRows_module_css_default["nameDim"]}` : UsageRows_module_css_default["rowName"],
4775
+ title: unattributed ? void 0 : provider.provider,
4776
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4777
+ className: UsageRows_module_css_default["nameLine"],
4778
+ children: unattributed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4779
+ className: UsageRows_module_css_default["hintWrap"],
4780
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
4781
+ label: unattributedTooltip(t),
4782
+ side: "bottom",
4783
+ delayMs: 100,
4784
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4785
+ className: UsageRows_module_css_default["nameText"],
4786
+ "aria-label": t("byProvider.unattributed"),
4787
+ tabIndex: 0,
4788
+ children: [t("byProvider.unattributed"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4789
+ className: UsageRows_module_css_default["nameHint"],
4790
+ "aria-hidden": true,
4791
+ children: "?"
4792
+ })]
4793
+ })
4794
+ })
4795
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4796
+ className: UsageRows_module_css_default["nameText"],
4797
+ children: providerLabel(provider.provider, providerNames)
4798
+ })
4799
+ })
4800
+ }),
4801
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4802
+ className: UsageRows_module_css_default["track"],
4803
+ children: barMax > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4804
+ className: UsageRows_module_css_default["fill"],
4805
+ style: { width: `${barValueOf(provider) / barMax * 100}%` }
4806
+ }) : null
4807
+ }),
4808
+ numsCell(provider.totals),
4809
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4810
+ className: UsageRows_module_css_default["rowCost"],
4811
+ children: costText(provider.cost)
4812
+ })
4813
+ ]
4814
+ }, unattributed ? "\0" : provider.provider);
4815
+ }
4728
4816
  const session = row;
4729
4817
  const jump = ctrlHeld && sessionListed !== void 0 && onSessionOpen !== void 0 && sessionListed(session.sessionId);
4730
4818
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -4793,9 +4881,9 @@ window.__ModuleLoader__.load({
4793
4881
  "panelTitle": "dNNuRW_panelTitle"
4794
4882
  };
4795
4883
  // src/client/DashboardCards.tsx
4796
- /** The three cards' fixed sort options: projects and models pick between
4797
- * token size and billed cost; sessions add last activity. The models'
4798
- * performance view is a separate head toggle, not a sort pick. */
4884
+ /** The cards' fixed sort options: projects, models and providers pick
4885
+ * between token size and billed cost; sessions add last activity. The
4886
+ * models' performance view is a separate head toggle, not a sort pick. */
4799
4887
  const SORT_PROJECT = ["tokens", "cost"];
4800
4888
  const SORT_SESSION = [
4801
4889
  "tokens",
@@ -4803,12 +4891,14 @@ window.__ModuleLoader__.load({
4803
4891
  "recent"
4804
4892
  ];
4805
4893
  const SORT_MODEL = ["tokens", "cost"];
4894
+ const SORT_PROVIDER = ["tokens", "cost"];
4806
4895
  /**
4807
- * Render the four-card dashboard: projects | sessions on the first row,
4808
- * models | runtime overhead on the second. The lists cap their own height
4809
- * and scroll inside the cards.
4896
+ * Render the dashboard: projects | sessions on the first row, models |
4897
+ * providers on the second, runtime overhead on the last. The lists cap
4898
+ * their own height and scroll inside the cards.
4810
4899
  */
4811
- function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, sessionSort, onSessionSortChange, aux, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
4900
+ function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, providerRows, providerNames, providerSort, onProviderSortChange, sessionSort, onSessionSortChange, aux, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
4901
+ const namedProviderCount = providerRows.filter((row) => row.provider !== "").length;
4812
4902
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4813
4903
  className: DashboardCards_module_css_default["grid2"],
4814
4904
  children: [
@@ -4910,6 +5000,33 @@ window.__ModuleLoader__.load({
4910
5000
  onModelName
4911
5001
  })]
4912
5002
  }),
5003
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5004
+ className: DashboardCards_module_css_default["panel"],
5005
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5006
+ className: DashboardCards_module_css_default["panelHead"],
5007
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5008
+ className: DashboardCards_module_css_default["panelTitle"],
5009
+ children: [t("board.providers"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5010
+ className: DashboardCards_module_css_default["panelCount"],
5011
+ children: providerSort === "cost" ? t("board.byCost", { count: namedProviderCount.toLocaleString() }) : t("board.byTokens", { count: namedProviderCount.toLocaleString() })
5012
+ })]
5013
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowSortControl, {
5014
+ value: providerSort,
5015
+ options: SORT_PROVIDER,
5016
+ onChange: onProviderSortChange,
5017
+ ariaLabel: t("board.providers"),
5018
+ t
5019
+ })]
5020
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageRows, {
5021
+ kind: "provider",
5022
+ providerRows,
5023
+ providerNames,
5024
+ sort: providerSort,
5025
+ costState,
5026
+ view,
5027
+ t
5028
+ })]
5029
+ }),
4913
5030
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4914
5031
  ref: overheadCardRef,
4915
5032
  className: overheadFlash ? `${DashboardCards_module_css_default["panel"]} ${DashboardCards_module_css_default["flash"]}` : DashboardCards_module_css_default["panel"],
@@ -6718,7 +6835,7 @@ window.__ModuleLoader__.load({
6718
6835
  });
6719
6836
  }
6720
6837
  // \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/TokenUsageSection.module.css.mjs
6721
- const css$2 = "._1fNFvW_section{flex-direction:column;gap:16px;width:100%;min-width:0;display:flex;container-type:inline-size}._1fNFvW_pageVariant ._1fNFvW_title{font-size:20px;font-weight:500;line-height:28px}._1fNFvW_head{justify-content:space-between;align-items:center;gap:12px;display:flex}._1fNFvW_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}._1fNFvW_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._1fNFvW_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._1fNFvW_sortRow{justify-content:flex-end;align-items:center;gap:6px;margin-left:auto;display:flex}._1fNFvW_sortHidden{visibility:hidden}._1fNFvW_detailPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0}._1fNFvW_detailToolbar{border-bottom:1px solid var(--dsw-alias-border-l1);flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 12px;padding:10px 12px;display:flex}._1fNFvW_detailBody{min-width:0;padding:2px 12px 6px}._1fNFvW_segmented{align-items:stretch;gap:2px;padding:0;display:inline-flex}._1fNFvW_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 8px;font-size:11px;font-weight:500}._1fNFvW_segBtn:hover:not(._1fNFvW_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._1fNFvW_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._1fNFvW_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._1fNFvW_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}._1fNFvW_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}._1fNFvW_button:hover{background:var(--dsw-interactive-bg-hover)}._1fNFvW_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}._1fNFvW_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}._1fNFvW_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}@container (width<=480px){._1fNFvW_filters{flex-wrap:wrap}}";
6838
+ const css$2 = "._1fNFvW_section{flex-direction:column;gap:16px;width:100%;min-width:0;display:flex;container-type:inline-size}._1fNFvW_pageVariant ._1fNFvW_title{font-size:20px;font-weight:500;line-height:28px}._1fNFvW_head{justify-content:space-between;align-items:center;gap:12px;display:flex}._1fNFvW_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}._1fNFvW_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._1fNFvW_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._1fNFvW_sortRow{justify-content:flex-end;align-items:center;gap:6px;margin-left:auto;display:flex}._1fNFvW_sortHidden{visibility:hidden}._1fNFvW_detailPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0}._1fNFvW_detailToolbar{border-bottom:1px solid var(--dsw-alias-border-l1);flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 12px;padding:10px 12px;display:flex}._1fNFvW_detailBody{min-width:0;padding:2px 12px 6px}._1fNFvW_segmented{flex-wrap:wrap;align-items:stretch;gap:2px;padding:0;display:inline-flex}._1fNFvW_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 8px;font-size:11px;font-weight:500}._1fNFvW_segBtn:hover:not(._1fNFvW_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._1fNFvW_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._1fNFvW_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._1fNFvW_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}._1fNFvW_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}._1fNFvW_button:hover{background:var(--dsw-interactive-bg-hover)}._1fNFvW_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}._1fNFvW_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}._1fNFvW_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}@container (width<=480px){._1fNFvW_filters{flex-wrap:wrap}}";
6722
6839
  const tagId$2 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
6723
6840
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
6724
6841
  const tag = document.createElement("style");
@@ -6763,15 +6880,28 @@ window.__ModuleLoader__.load({
6763
6880
  *
6764
6881
  * @module token-usage/client/TokenUsageSection
6765
6882
  */
6766
- /** The three tabs' fixed sort options: projects and models pick between
6767
- * token size and billed cost; sessions add last activity. */
6883
+ /** The detail tabs' fixed sort options: projects, models and providers pick
6884
+ * between token size and billed cost; sessions add last activity. */
6768
6885
  const PROJECT_SORT = ["tokens", "cost"];
6769
6886
  const MODEL_SORT = ["tokens", "cost"];
6887
+ const PROVIDER_SORT = ["tokens", "cost"];
6770
6888
  const SESSION_SORT = [
6771
6889
  "tokens",
6772
6890
  "cost",
6773
6891
  "recent"
6774
6892
  ];
6893
+ /** The detail switch's tab labels, one per mode. */
6894
+ const DETAIL_MODES = [
6895
+ "project",
6896
+ "model",
6897
+ "session",
6898
+ "provider",
6899
+ "aux"
6900
+ ];
6901
+ /** One detail mode's label key. */
6902
+ function detailLabelOf(mode) {
6903
+ return mode === "project" ? "byProject.title" : mode === "model" ? "byModel.title" : mode === "session" ? "bySession.title" : mode === "provider" ? "byProvider.title" : "aux.tab";
6904
+ }
6775
6905
  /** Fetch the summary for one query string; the caller owns the failure
6776
6906
  * presentation. The AbortSignal wires into the request so a filter change
6777
6907
  * cancels the in-flight fetch instead of letting its response overwrite
@@ -6944,6 +7074,7 @@ window.__ModuleLoader__.load({
6944
7074
  const [projectSort, setProjectSort] = (0, react.useState)("tokens");
6945
7075
  const [modelSort, setModelSort] = (0, react.useState)("tokens");
6946
7076
  const [modelPerfView, setModelPerfView] = (0, react.useState)(false);
7077
+ const [providerSort, setProviderSort] = (0, react.useState)("tokens");
6947
7078
  const [sessionSort, setSessionSort] = (0, react.useState)("cost");
6948
7079
  const handleToggleModel = (0, react.useCallback)((model) => {
6949
7080
  setFilters((previous) => ({
@@ -7118,6 +7249,10 @@ window.__ModuleLoader__.load({
7118
7249
  onModelSortChange: setModelSort,
7119
7250
  modelPerfView,
7120
7251
  onModelPerfToggle: setModelPerfView,
7252
+ providerRows: state.value.byProvider ?? [],
7253
+ providerNames: state.value.providerNames,
7254
+ providerSort,
7255
+ onProviderSortChange: setProviderSort,
7121
7256
  sessionSort,
7122
7257
  onSessionSortChange: setSessionSort,
7123
7258
  aux: state.value.aux,
@@ -7141,17 +7276,12 @@ window.__ModuleLoader__.load({
7141
7276
  className: TokenUsageSection_module_css_default["segmented"],
7142
7277
  role: "group",
7143
7278
  "aria-label": t("detail.switch.label"),
7144
- children: [
7145
- "project",
7146
- "model",
7147
- "session",
7148
- "aux"
7149
- ].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
7279
+ children: DETAIL_MODES.map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
7150
7280
  type: "button",
7151
7281
  className: detailMode === mode ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
7152
7282
  "aria-pressed": detailMode === mode,
7153
7283
  onClick: () => setDetailMode(mode),
7154
- children: t(mode === "project" ? "byProject.title" : mode === "model" ? "byModel.title" : mode === "session" ? "bySession.title" : "aux.tab")
7284
+ children: t(detailLabelOf(mode))
7155
7285
  }, mode))
7156
7286
  }), detailMode !== "aux" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
7157
7287
  className: TokenUsageSection_module_css_default["sortRow"],
@@ -7159,10 +7289,10 @@ window.__ModuleLoader__.load({
7159
7289
  className: detailMode === "model" && modelPerfView ? TokenUsageSection_module_css_default["sortHidden"] : void 0,
7160
7290
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowSortControl, {
7161
7291
  compact: true,
7162
- value: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : sessionSort,
7163
- options: detailMode === "project" ? PROJECT_SORT : detailMode === "model" ? MODEL_SORT : SESSION_SORT,
7164
- onChange: detailMode === "project" ? setProjectSort : detailMode === "model" ? setModelSort : setSessionSort,
7165
- ariaLabel: t(detailMode === "project" ? "byProject.title" : detailMode === "model" ? "byModel.title" : "bySession.title"),
7292
+ value: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : detailMode === "provider" ? providerSort : sessionSort,
7293
+ options: detailMode === "project" ? PROJECT_SORT : detailMode === "model" ? MODEL_SORT : detailMode === "provider" ? PROVIDER_SORT : SESSION_SORT,
7294
+ onChange: detailMode === "project" ? setProjectSort : detailMode === "model" ? setModelSort : detailMode === "provider" ? setProviderSort : setSessionSort,
7295
+ ariaLabel: t(detailLabelOf(detailMode)),
7166
7296
  t
7167
7297
  })
7168
7298
  }), detailMode === "model" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PerfToggle, {
@@ -7184,7 +7314,9 @@ window.__ModuleLoader__.load({
7184
7314
  projectRows,
7185
7315
  modelRows: state.value.byModel,
7186
7316
  sessionRows: state.value.sessionRows ?? [],
7187
- sort: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : sessionSort,
7317
+ providerRows: state.value.byProvider ?? [],
7318
+ providerNames: state.value.providerNames,
7319
+ sort: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : detailMode === "provider" ? providerSort : sessionSort,
7188
7320
  perfView: detailMode === "model" && modelPerfView,
7189
7321
  pricing: state.value.pricing,
7190
7322
  costState: state.value.costState,
@@ -7376,22 +7508,39 @@ window.__ModuleLoader__.load({
7376
7508
  }
7377
7509
  /** The hit cell's tooltip: the low-hit explanation (with the raw-precision
7378
7510
  * note when rounding would hide a sub-threshold rate) or the exclusion
7379
- * reason. Unknown figures explain their unknown instead of going silent. */
7380
- function hitTooltipOf(cache, t) {
7381
- if (cache.rate === void 0) return cache.reason !== void 0 ? t(`pool.excluded.${cache.reason}`) : "";
7382
- const display = formatRequestRate(cache.rate);
7383
- if (cache.band === "loss") {
7384
- const lines = [t("pool.cache.tooltip", { rate: display })];
7385
- if (Number.parseFloat(display) >= 50) lines.push(t("pool.cache.roundedDown", { rate: formatRequestRateExact(cache.rate) }));
7386
- return lines.join("\n");
7511
+ * reason. Unknown figures explain their unknown instead of going silent.
7512
+ * The compaction attribution (when the row carries one) rides the same
7513
+ * tooltip as its closing section — real-world feedback dropped the standalone
7514
+ * badge as redundant next to the 缓存过低 marker, and the causal chain reads
7515
+ * exactly where the rate is questioned. The wording says the prefix WAS
7516
+ * rewritten and cache behaviour MAY be affected — never that compaction
7517
+ * caused a cache loss, because a high-hit row can carry the same attribution
7518
+ * (the miss severity depends on the earliest rewritten position, which the
7519
+ * plugin cannot see). */
7520
+ function hitTooltipOf(cache, t, attribution) {
7521
+ const lines = [];
7522
+ if (cache.rate === void 0) {
7523
+ if (cache.reason !== void 0) lines.push(t(`pool.excluded.${cache.reason}`));
7524
+ } else {
7525
+ const display = formatRequestRate(cache.rate);
7526
+ if (cache.band === "loss") {
7527
+ lines.push(t("pool.cache.tooltip", { rate: display }));
7528
+ if (Number.parseFloat(display) >= 50) lines.push(t("pool.cache.roundedDown", { rate: formatRequestRateExact(cache.rate) }));
7529
+ } else if (cache.reason !== void 0) lines.push(t(`pool.excluded.${cache.reason}`));
7387
7530
  }
7388
- if (cache.reason !== void 0) return t(`pool.excluded.${cache.reason}`);
7389
- return "";
7531
+ if (attribution !== void 0) {
7532
+ lines.push(t("pool.attribution.prefix"));
7533
+ for (const item of attribution) lines.push(item.kind === "prune" ? t("pool.attribution.prune", {
7534
+ count: String(item.count),
7535
+ tokens: formatTokens(item.shadowedTokenCount)
7536
+ }) : t("pool.attribution.summary", { tokens: formatTokens(item.shadowedTokenCount) }));
7537
+ }
7538
+ return lines.join("\n");
7390
7539
  }
7391
7540
  /** The hit cell keeps request precision, shared numeric colours, and its explanation. */
7392
- function HitCell({ cache, t }) {
7541
+ function HitCell({ cache, attribution, t }) {
7393
7542
  const text = formatRequestRate(cache.rate);
7394
- const tooltip = hitTooltipOf(cache, t);
7543
+ const tooltip = hitTooltipOf(cache, t, attribution);
7395
7544
  const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
7396
7545
  className: hitClassOf(cache),
7397
7546
  children: text
@@ -7443,7 +7592,7 @@ window.__ModuleLoader__.load({
7443
7592
  children: kindLabel
7444
7593
  }),
7445
7594
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
7446
- label: hitTooltipOf(cache, t),
7595
+ label: hitTooltipOf(cache, t, detail.compactionAttribution),
7447
7596
  side: "top",
7448
7597
  delayMs: 100,
7449
7598
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -7623,6 +7772,7 @@ window.__ModuleLoader__.load({
7623
7772
  "data-label": t("pool.col.hit"),
7624
7773
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitCell, {
7625
7774
  cache: detail.cache,
7775
+ attribution: detail.compactionAttribution,
7626
7776
  t
7627
7777
  })
7628
7778
  }),
@@ -7751,6 +7901,7 @@ window.__ModuleLoader__.load({
7751
7901
  className: UsageView_module_css_default["metricValue"],
7752
7902
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitCell, {
7753
7903
  cache: latest.cache,
7904
+ attribution: latest.compactionAttribution,
7754
7905
  t
7755
7906
  })
7756
7907
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -8573,6 +8724,12 @@ window.__ModuleLoader__.load({
8573
8724
  "perf.lowSamples": "样本不足",
8574
8725
  "perf.requestCount": "{count} 次",
8575
8726
  "byModel.title": "按模型",
8727
+ "byProvider.title": "按供应商",
8728
+ "byProvider.unattributed": "缺失供应商",
8729
+ "byProvider.cause.intro": "可能是:",
8730
+ "byProvider.cause.deletedLog": "会话日志已删除的历史会话",
8731
+ "byProvider.cause.preField": "路由键字段加入前的旧会话",
8732
+ "byProvider.cause.bypass": "不带路由键的运行开销",
8576
8733
  "bySession.title": "按会话",
8577
8734
  "byProject.title": "按项目",
8578
8735
  "aux.tab": "运行开销",
@@ -8591,6 +8748,7 @@ window.__ModuleLoader__.load({
8591
8748
  "board.projects": "项目",
8592
8749
  "board.sessions": "会话",
8593
8750
  "board.models": "模型",
8751
+ "board.providers": "供应商",
8594
8752
  "board.byTokens": "{count} 个 · 按总 token",
8595
8753
  "board.byCost": "{count} 个 · 按费用",
8596
8754
  "board.bySpeed": "{count} 个 · 按输出速度",
@@ -8735,6 +8893,9 @@ window.__ModuleLoader__.load({
8735
8893
  "pool.kind.session-title": "标题",
8736
8894
  "pool.kind.translation": "翻译",
8737
8895
  "pool.kind.other": "辅助",
8896
+ "pool.attribution.prefix": "此请求发出前,宿主的压缩操作改写了上下文前缀,缓存表现可能受影响:",
8897
+ "pool.attribution.prune": "工具结果剪枝改写了请求前缀({count} 条,剪除消息的影子 token 合计 {tokens})",
8898
+ "pool.attribution.summary": "LLM 摘要替换了会话历史(影子 token {tokens})",
8738
8899
  "pool.state.waiting": "等待首 token",
8739
8900
  "pool.state.streaming": "生成中",
8740
8901
  "pool.state.completed": "已完成",
@@ -8929,6 +9090,12 @@ window.__ModuleLoader__.load({
8929
9090
  "perf.lowSamples": "Low samples",
8930
9091
  "perf.requestCount": "{count} reqs",
8931
9092
  "byModel.title": "By model",
9093
+ "byProvider.title": "By provider",
9094
+ "byProvider.unattributed": "Missing provider",
9095
+ "byProvider.cause.intro": "Could be:",
9096
+ "byProvider.cause.deletedLog": "History sessions whose logs were deleted",
9097
+ "byProvider.cause.preField": "Sessions older than the route-key field",
9098
+ "byProvider.cause.bypass": "Bypass calls that carry no route key",
8932
9099
  "bySession.title": "By session",
8933
9100
  "byProject.title": "By project",
8934
9101
  "aux.tab": "Runtime overhead",
@@ -8947,6 +9114,7 @@ window.__ModuleLoader__.load({
8947
9114
  "board.projects": "Projects",
8948
9115
  "board.sessions": "Sessions",
8949
9116
  "board.models": "Models",
9117
+ "board.providers": "Providers",
8950
9118
  "board.byTokens": "{count} · by tokens",
8951
9119
  "board.byCost": "{count} · by cost",
8952
9120
  "board.bySpeed": "{count} · by speed",
@@ -9091,6 +9259,9 @@ window.__ModuleLoader__.load({
9091
9259
  "pool.kind.session-title": "Title",
9092
9260
  "pool.kind.translation": "Translation",
9093
9261
  "pool.kind.other": "Auxiliary",
9262
+ "pool.attribution.prefix": "Before this request, host compaction rewrote the context prefix; cache behaviour may be affected:",
9263
+ "pool.attribution.prune": "Tool-result pruning rewrote the request prefix ({count} event(s), shadow tokens of pruned messages {tokens})",
9264
+ "pool.attribution.summary": "An LLM summary replaced the conversation history (shadow tokens {tokens})",
9094
9265
  "pool.state.waiting": "Waiting for first token",
9095
9266
  "pool.state.streaming": "Generating",
9096
9267
  "pool.state.completed": "Completed",