@laoyuehanni/dsh-token-usage 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -10
- package/README.zh.md +2 -10
- package/docs/pricing.md +3 -13
- package/lib/client/PricingDialog.d.ts +51 -0
- package/lib/client/PricingDialog.d.ts.map +1 -0
- package/lib/client/PricingDialog.js +127 -0
- package/lib/client/PricingDialog.js.map +1 -0
- package/lib/client/PricingOverviewDialog.d.ts +76 -0
- package/lib/client/PricingOverviewDialog.d.ts.map +1 -0
- package/lib/client/PricingOverviewDialog.js +361 -0
- package/lib/client/PricingOverviewDialog.js.map +1 -0
- package/lib/client/QuotaButton.d.ts.map +1 -1
- package/lib/client/QuotaButton.js.map +1 -1
- package/lib/client/SessionStatsChip.d.ts.map +1 -1
- package/lib/client/SessionStatsChip.js.map +1 -1
- package/lib/client/SessionTable.d.ts +39 -0
- package/lib/client/SessionTable.d.ts.map +1 -0
- package/lib/client/SessionTable.js +181 -0
- package/lib/client/SessionTable.js.map +1 -0
- package/lib/client/TokenUsageSection.d.ts +16 -9
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +66 -128
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/TrendChart.d.ts +1 -1
- package/lib/client/TrendChart.d.ts.map +1 -1
- package/lib/client/TrendChart.js +13 -5
- package/lib/client/TrendChart.js.map +1 -1
- package/lib/client/UsageView.d.ts +10 -3
- package/lib/client/UsageView.d.ts.map +1 -1
- package/lib/client/UsageView.js +12 -3
- package/lib/client/UsageView.js.map +1 -1
- package/lib/client/card-form.d.ts +1 -1
- package/lib/client/card-form.d.ts.map +1 -1
- package/lib/client/index.d.ts +7 -6
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +27 -7
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +25 -0
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +50 -0
- package/lib/client/locales.js.map +1 -1
- package/lib/client/trend-chart/index.d.ts +2 -0
- package/lib/client/trend-chart/index.d.ts.map +1 -1
- package/lib/client/trend-chart/index.js +1 -0
- package/lib/client/trend-chart/index.js.map +1 -1
- package/lib/client/trend-chart/path.d.ts +36 -0
- package/lib/client/trend-chart/path.d.ts.map +1 -0
- package/lib/client/trend-chart/path.js +51 -0
- package/lib/client/trend-chart/path.js.map +1 -0
- package/lib/client/trend-chart/points.d.ts +1 -0
- package/lib/client/trend-chart/points.d.ts.map +1 -1
- package/lib/client/trend-chart/points.js +1 -0
- package/lib/client/trend-chart/points.js.map +1 -1
- package/lib/client/trend-chart/scale.d.ts +8 -3
- package/lib/client/trend-chart/scale.d.ts.map +1 -1
- package/lib/client/trend-chart/scale.js +22 -14
- package/lib/client/trend-chart/scale.js.map +1 -1
- package/lib/client.js +1478 -304
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +72 -28
- package/lib/index.js.map +1 -1
- package/lib/migrate.d.ts +3 -2
- package/lib/migrate.d.ts.map +1 -1
- package/lib/migrate.js +4 -2
- package/lib/migrate.js.map +1 -1
- package/lib/pricing.d.ts +29 -23
- package/lib/pricing.d.ts.map +1 -1
- package/lib/pricing.js +38 -50
- package/lib/pricing.js.map +1 -1
- package/lib/rollup.d.ts +7 -1
- package/lib/rollup.d.ts.map +1 -1
- package/lib/rollup.js +15 -0
- package/lib/rollup.js.map +1 -1
- package/lib/session-meta.d.ts +68 -0
- package/lib/session-meta.d.ts.map +1 -0
- package/lib/session-meta.js +174 -0
- package/lib/session-meta.js.map +1 -0
- package/lib/stats-route.d.ts +22 -0
- package/lib/stats-route.d.ts.map +1 -1
- package/lib/stats-route.js +85 -6
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts +35 -3
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +185 -6
- package/lib/stats.js.map +1 -1
- package/lib/sync-state.d.ts +42 -10
- package/lib/sync-state.d.ts.map +1 -1
- package/lib/sync-state.js +61 -19
- package/lib/sync-state.js.map +1 -1
- package/lib/sync.d.ts +55 -9
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +55 -10
- package/lib/sync.js.map +1 -1
- package/lib/wire.d.ts +114 -10
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js +3 -0
- package/lib/wire.js.map +1 -1
- package/package.json +26 -21
package/lib/client.js
CHANGED
|
@@ -10,6 +10,9 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
//#region src/wire.ts
|
|
11
11
|
/** The stats endpoint path, served by the host half's webServer route. */
|
|
12
12
|
const STATS_PATH = "/token-usage/stats";
|
|
13
|
+
/** The pricing-overview endpoint path: the full cloud-mirror model list,
|
|
14
|
+
* filter-free by design — the overview is not a filtered usage view. */
|
|
15
|
+
const PRICING_PATH = "/token-usage/pricing";
|
|
13
16
|
/** Encode one repeated query key (`sessionId=a&sessionId=b`). Empty list yields ''. */
|
|
14
17
|
function encodeRepeatedParam(key, values) {
|
|
15
18
|
return values.map((value) => `${key}=${encodeURIComponent(value)}`).join("&");
|
|
@@ -541,13 +544,13 @@ window.__ModuleLoader__.load({
|
|
|
541
544
|
}
|
|
542
545
|
//#endregion
|
|
543
546
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\QuotaButton.module.css.mjs
|
|
544
|
-
const css$
|
|
545
|
-
const tagId$
|
|
546
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
547
|
+
const css$12 = ".jYASuG_root{flex:none;display:inline-flex;position:relative}.jYASuG_trigger{width:28px;height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:999px;flex:none;place-items:center;padding:0;display:grid}.jYASuG_trigger svg{display:block}.jYASuG_trigger:hover,.jYASuG_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jYASuG_trigger.jYASuG_icon-ok:hover,.jYASuG_trigger.jYASuG_icon-ok[aria-expanded=true]{color:var(--dsw-alias-state-success-primary)}.jYASuG_trigger.jYASuG_icon-warn:hover,.jYASuG_trigger.jYASuG_icon-warn[aria-expanded=true]{color:var(--dsw-alias-state-warn-primary)}.jYASuG_trigger.jYASuG_icon-exhausted:hover,.jYASuG_trigger.jYASuG_icon-exhausted[aria-expanded=true]{color:var(--dsw-alias-state-error-primary)}.jYASuG_icon-ok{color:var(--dsw-alias-state-success-primary)}.jYASuG_icon-warn{color:var(--dsw-alias-state-warn-primary)}.jYASuG_icon-exhausted{color:var(--dsw-alias-state-error-primary)}.jYASuG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:320px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:12px;font-size:12px;line-height:20px;position:absolute;bottom:calc(100% + 8px)}.jYASuG_header{justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:10px;display:flex}.jYASuG_title{color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:500;overflow:hidden}.jYASuG_plan{color:var(--dsw-alias-label-tertiary);font-weight:400}.jYASuG_updated{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:11px}.jYASuG_grid{grid-template-columns:repeat(var(--cols,3), 1fr);gap:14px;display:grid}.jYASuG_col{min-width:0}.jYASuG_label{color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-overflow:ellipsis;margin-bottom:2px;font-size:11px;line-height:16px;overflow:hidden}.jYASuG_value{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-bottom:6px;font-size:13px;font-weight:600;line-height:18px}.jYASuG_meta{color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:400}.jYASuG_bar{background:var(--dsw-alias-interactive-bg-hover);border-radius:999px;height:4px;overflow:hidden}.jYASuG_fill{border-radius:999px;height:100%;transition:width .3s}.jYASuG_ok{background:var(--dsw-alias-state-success-primary)}.jYASuG_warn{background:var(--dsw-alias-state-warn-primary)}.jYASuG_exhausted{background:var(--dsw-alias-state-error-primary)}.jYASuG_aux{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap;margin-top:4px;font-size:11px;line-height:14px}.jYASuG_dot{vertical-align:middle;border-radius:50%;width:5px;height:5px;margin-right:3px;display:inline-block}.jYASuG_error{flex-direction:column;gap:8px;display:flex}.jYASuG_errorText{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.jYASuG_retry{color:var(--dsw-alias-label-primary);cursor:pointer;text-underline-offset:2px;background:0 0;border:none;align-self:flex-start;padding:0;font-size:12px;text-decoration:underline}.jYASuG_retry:hover{color:var(--dsw-alias-brand-primary)}";
|
|
548
|
+
const tagId$12 = "@laoyuehanni/dsh-token-usage/QuotaButton.module.css";
|
|
549
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$12) + "]") === null) {
|
|
547
550
|
const tag = document.createElement("style");
|
|
548
551
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
549
|
-
tag.dataset.pluginCss = tagId$
|
|
550
|
-
tag.textContent = css$
|
|
552
|
+
tag.dataset.pluginCss = tagId$12;
|
|
553
|
+
tag.textContent = css$12;
|
|
551
554
|
document.head.appendChild(tag);
|
|
552
555
|
}
|
|
553
556
|
var QuotaButton_module_css_default = {
|
|
@@ -1227,13 +1230,13 @@ window.__ModuleLoader__.load({
|
|
|
1227
1230
|
}
|
|
1228
1231
|
//#endregion
|
|
1229
1232
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\hit-rate-band.module.css.mjs
|
|
1230
|
-
const css$
|
|
1231
|
-
const tagId$
|
|
1232
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1233
|
+
const css$11 = ".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)}";
|
|
1234
|
+
const tagId$11 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
|
|
1235
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$11) + "]") === null) {
|
|
1233
1236
|
const tag = document.createElement("style");
|
|
1234
1237
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1235
|
-
tag.dataset.pluginCss = tagId$
|
|
1236
|
-
tag.textContent = css$
|
|
1238
|
+
tag.dataset.pluginCss = tagId$11;
|
|
1239
|
+
tag.textContent = css$11;
|
|
1237
1240
|
document.head.appendChild(tag);
|
|
1238
1241
|
}
|
|
1239
1242
|
var hit_rate_band_module_css_default = {
|
|
@@ -1453,13 +1456,13 @@ window.__ModuleLoader__.load({
|
|
|
1453
1456
|
}
|
|
1454
1457
|
//#endregion
|
|
1455
1458
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\SessionStatsChip.module.css.mjs
|
|
1456
|
-
const css$
|
|
1457
|
-
const tagId$
|
|
1458
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1459
|
+
const css$10 = ".d5ISLa_strip{border:1px solid var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border-radius:14px;flex:none;align-items:stretch;min-width:0;height:28px;font-size:12px;line-height:18px;display:inline-flex;overflow:hidden}.d5ISLa_stripFlyOverflow{z-index:2;position:relative;overflow:visible}.d5ISLa_cell{color:var(--dsw-alias-label-primary);white-space:nowrap;align-items:center;padding:0 10px;display:inline-flex}.d5ISLa_cell+.d5ISLa_cell{border-left:1px solid var(--dsw-alias-border-l1)}.d5ISLa_cellHit{font-weight:500}.d5ISLa_costCell{z-index:1;position:relative;overflow:visible}.d5ISLa_costInner{transform-origin:50%;z-index:2;justify-content:center;align-items:center;display:inline-flex;position:relative}.d5ISLa_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.d5ISLa_deltaFly{color:var(--dsw-alias-state-warn-primary);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;text-shadow:0 0 8px color-mix(in srgb, var(--dsw-alias-state-warn-primary) 35%, transparent);font-size:11px;font-weight:600;position:absolute;top:0;left:50%;transform:translate(-50%,-100%)}@media (prefers-reduced-motion:reduce){.d5ISLa_deltaFly{display:none}}@media (width<=560px){.d5ISLa_strip{font-size:11px}.d5ISLa_cell{padding:0 7px}}";
|
|
1460
|
+
const tagId$10 = "@laoyuehanni/dsh-token-usage/SessionStatsChip.module.css";
|
|
1461
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
|
|
1459
1462
|
const tag = document.createElement("style");
|
|
1460
1463
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1461
|
-
tag.dataset.pluginCss = tagId$
|
|
1462
|
-
tag.textContent = css$
|
|
1464
|
+
tag.dataset.pluginCss = tagId$10;
|
|
1465
|
+
tag.textContent = css$10;
|
|
1463
1466
|
document.head.appendChild(tag);
|
|
1464
1467
|
}
|
|
1465
1468
|
var SessionStatsChip_module_css_default = {
|
|
@@ -1795,13 +1798,13 @@ window.__ModuleLoader__.load({
|
|
|
1795
1798
|
}
|
|
1796
1799
|
//#endregion
|
|
1797
1800
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageCard.module.css.mjs
|
|
1798
|
-
const css$
|
|
1799
|
-
const tagId$
|
|
1800
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
1801
|
+
const css$9 = "._1bMeTa_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}._1bMeTa_card:hover{border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}._1bMeTa_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}._1bMeTa_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}._1bMeTa_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}._1bMeTa_description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}._1bMeTa_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}._1bMeTa_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}._1bMeTa_chevronOpen{transform:rotate(180deg)}._1bMeTa_body{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;gap:10px;margin:0 16px;padding:12px 0 8px;display:flex}._1bMeTa_note{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_field{flex-direction:column;gap:4px;display:flex}._1bMeTa_fieldLabel{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.5}._1bMeTa_input{box-sizing:border-box;width:100%;font:inherit;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);appearance:none;border-radius:6px;padding:4px 8px;font-size:13px;line-height:20px}._1bMeTa_input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-1px}._1bMeTa_input:disabled{opacity:.6}._1bMeTa_inputRow{align-items:center;gap:6px;display:flex}._1bMeTa_inputRow ._1bMeTa_input{flex:1;min-width:0}._1bMeTa_browse{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}._1bMeTa_browse:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_browse:disabled{opacity:.4;cursor:default}._1bMeTa_browse:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}._1bMeTa_migration{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-direction:column;gap:4px;padding:8px 10px;display:flex}._1bMeTa_migrationLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_migrationBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_migrationFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 4px;display:flex}._1bMeTa_failed{min-width:0;color:var(--dsw-alias-label-error);flex:1;margin:0;font-size:12px;line-height:1.5}._1bMeTa_discard,._1bMeTa_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}._1bMeTa_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}._1bMeTa_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}._1bMeTa_discard:disabled,._1bMeTa_save:disabled{opacity:.4;cursor:default}._1bMeTa_discard:focus-visible,._1bMeTa_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSync{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:8px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}._1bMeTa_fullSyncHeader{flex-direction:column;gap:2px;display:flex}._1bMeTa_fullSyncTitle{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:1.4}._1bMeTa_fullSyncHint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5}._1bMeTa_fullSyncButton{appearance:none;border:1px solid var(--dsw-alias-border-l2);font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;align-self:flex-start;padding:4px 12px;font-size:13px;line-height:20px}._1bMeTa_fullSyncButton:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._1bMeTa_fullSyncButton:disabled{opacity:.5;cursor:default}._1bMeTa_fullSyncButton:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._1bMeTa_fullSyncProgress{flex-direction:column;gap:4px;display:flex}._1bMeTa_fullSyncProgressLabel{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;font-size:12px;line-height:1.5}._1bMeTa_fullSyncBar{background:var(--dsw-alias-bg-multi-select);border-radius:2px;height:4px;display:block;overflow:hidden}._1bMeTa_fullSyncFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}._1bMeTa_fullSyncResult{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;margin:0;font-size:12px;line-height:1.5}._1bMeTa_fullSyncError{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}";
|
|
1802
|
+
const tagId$9 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
|
|
1803
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
|
|
1801
1804
|
const tag = document.createElement("style");
|
|
1802
1805
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1803
|
-
tag.dataset.pluginCss = tagId$
|
|
1804
|
-
tag.textContent = css$
|
|
1806
|
+
tag.dataset.pluginCss = tagId$9;
|
|
1807
|
+
tag.textContent = css$9;
|
|
1805
1808
|
document.head.appendChild(tag);
|
|
1806
1809
|
}
|
|
1807
1810
|
var TokenUsageCard_module_css_default = {
|
|
@@ -2168,13 +2171,13 @@ window.__ModuleLoader__.load({
|
|
|
2168
2171
|
}
|
|
2169
2172
|
//#endregion
|
|
2170
2173
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\DateRangePicker.module.css.mjs
|
|
2171
|
-
const css$
|
|
2172
|
-
const tagId$
|
|
2173
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
2174
|
+
const css$8 = ".aSiNOq_wrapper{flex:none;display:inline-flex;position:relative}.aSiNOq_trigger{box-sizing:border-box;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;border-radius:6px;flex:none;padding:4px 10px;font-size:13px;line-height:20px}.aSiNOq_trigger:hover,.aSiNOq_trigger[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);width:266px;max-width:calc(100vw - 32px);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:10px;font-size:12px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0}.aSiNOq_head{justify-content:space-between;align-items:center;gap:4px;margin-bottom:6px;display:flex}.aSiNOq_nav{width:24px;height:24px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:0;font-size:14px;line-height:1}.aSiNOq_nav:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_monthTitle{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;font-weight:500}.aSiNOq_weekdays,.aSiNOq_grid{grid-template-columns:repeat(7,1fr);gap:2px;display:grid}.aSiNOq_weekday{text-align:center;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.aSiNOq_blank{visibility:hidden;height:26px}.aSiNOq_day{font-variant-numeric:tabular-nums;text-align:center;height:26px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:0;font-size:12px;line-height:26px}.aSiNOq_day:hover{background:var(--dsw-alias-interactive-bg-hover)}.aSiNOq_dayToday{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2)}.aSiNOq_dayAnchor,.aSiNOq_daySelected{color:var(--dsw-alias-brand-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary);font-weight:600}.aSiNOq_dayInRange{background:var(--dsw-alias-interactive-bg-hover);border-radius:0}.aSiNOq_foot{border-top:1px solid var(--dsw-alias-border-l1);justify-content:flex-end;margin-top:8px;padding-top:8px;display:flex}.aSiNOq_clear{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;padding:2px 8px;font-size:12px;line-height:18px}.aSiNOq_clear:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}";
|
|
2175
|
+
const tagId$8 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
|
|
2176
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
|
|
2174
2177
|
const tag = document.createElement("style");
|
|
2175
2178
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2176
|
-
tag.dataset.pluginCss = tagId$
|
|
2177
|
-
tag.textContent = css$
|
|
2179
|
+
tag.dataset.pluginCss = tagId$8;
|
|
2180
|
+
tag.textContent = css$8;
|
|
2178
2181
|
document.head.appendChild(tag);
|
|
2179
2182
|
}
|
|
2180
2183
|
var DateRangePicker_module_css_default = {
|
|
@@ -2398,13 +2401,13 @@ window.__ModuleLoader__.load({
|
|
|
2398
2401
|
}
|
|
2399
2402
|
//#endregion
|
|
2400
2403
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\MenuSelect.module.css.mjs
|
|
2401
|
-
const css$
|
|
2402
|
-
const tagId$
|
|
2403
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
2404
|
+
const css$7 = ".KUIXpG_wrapper{display:inline-flex;position:relative}.KUIXpG_trigger{box-sizing:border-box;color:var(--dsw-alias-label-primary);background-color:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E/%3C/svg%3E\");background-position:right 6px center;background-repeat:no-repeat;background-size:12px 12px;border-radius:6px;flex:none;padding:4px 24px 4px 8px;font-size:13px;line-height:20px;overflow:hidden}.KUIXpG_trigger:hover,.KUIXpG_trigger[aria-expanded=true]{background-color:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_grow{flex:0 auto;min-width:0;max-width:220px}.KUIXpG_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);min-width:100%;max-width:260px;max-height:240px;box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-secondary);text-align:left;cursor:default;border-radius:12px;padding:6px;font-size:13px;line-height:20px;position:absolute;top:calc(100% + 6px);left:0;overflow-y:auto}.KUIXpG_option{width:100%;color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;justify-content:space-between;align-items:center;gap:12px;padding:4px 8px;font-size:13px;line-height:20px;display:flex}.KUIXpG_option:hover{background:var(--dsw-alias-interactive-bg-hover)}.KUIXpG_optionLabel{text-overflow:ellipsis;overflow:hidden}.KUIXpG_optionSelected{color:var(--dsw-alias-brand-primary)}.KUIXpG_check{color:var(--dsw-alias-brand-primary);flex:none}";
|
|
2405
|
+
const tagId$7 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
|
|
2406
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
|
|
2404
2407
|
const tag = document.createElement("style");
|
|
2405
2408
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2406
|
-
tag.dataset.pluginCss = tagId$
|
|
2407
|
-
tag.textContent = css$
|
|
2409
|
+
tag.dataset.pluginCss = tagId$7;
|
|
2410
|
+
tag.textContent = css$7;
|
|
2408
2411
|
document.head.appendChild(tag);
|
|
2409
2412
|
}
|
|
2410
2413
|
var MenuSelect_module_css_default = {
|
|
@@ -2572,111 +2575,975 @@ window.__ModuleLoader__.load({
|
|
|
2572
2575
|
});
|
|
2573
2576
|
}
|
|
2574
2577
|
//#endregion
|
|
2575
|
-
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\
|
|
2576
|
-
const css$
|
|
2577
|
-
const tagId$
|
|
2578
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$
|
|
2578
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingDialog.module.css.mjs
|
|
2579
|
+
const css$6 = ".gh1SLa_dialog{width:min(600px,100vw - 48px);max-height:calc(100vh - 48px);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:10px;padding:14px 16px;overflow-y:auto}.gh1SLa_dialog::backdrop{background:#0006}.gh1SLa_dialogHead{justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;display:flex}.gh1SLa_dialogTitle{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:14px;font-weight:600;overflow:hidden}.gh1SLa_dialogClose{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:6px;flex:none;padding:2px 8px;font-size:12px;line-height:18px}.gh1SLa_dialogClose:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-interactive-bg-hover)}.gh1SLa_rateNote{color:var(--dsw-alias-label-secondary);margin:6px 0 0;font-size:12px}.gh1SLa_tableWrap{max-height:420px;overflow:auto}.gh1SLa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:420px;font-size:12px}.gh1SLa_table th,.gh1SLa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.gh1SLa_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.gh1SLa_table td{color:var(--dsw-alias-label-primary)}th.gh1SLa_conditionHead,td.gh1SLa_conditionCell{text-align:left;white-space:normal;min-width:200px}td.gh1SLa_conditionCell{color:var(--dsw-alias-label-secondary);padding-left:20px}.gh1SLa_groupRow>td{text-align:left;white-space:normal;color:var(--dsw-alias-label-secondary);border-bottom:none;padding-top:8px;font-size:11px;font-weight:600}.gh1SLa_groupRow:not(:first-child)>td{border-top:1px solid var(--dsw-alias-border-l1)}";
|
|
2580
|
+
const tagId$6 = "@laoyuehanni/dsh-token-usage/PricingDialog.module.css";
|
|
2581
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
|
|
2579
2582
|
const tag = document.createElement("style");
|
|
2580
2583
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2581
|
-
tag.dataset.pluginCss = tagId$
|
|
2582
|
-
tag.textContent = css$
|
|
2584
|
+
tag.dataset.pluginCss = tagId$6;
|
|
2585
|
+
tag.textContent = css$6;
|
|
2583
2586
|
document.head.appendChild(tag);
|
|
2584
2587
|
}
|
|
2585
|
-
var
|
|
2586
|
-
"
|
|
2587
|
-
"
|
|
2588
|
-
"
|
|
2589
|
-
"
|
|
2590
|
-
"
|
|
2591
|
-
"
|
|
2592
|
-
"
|
|
2593
|
-
"
|
|
2594
|
-
"
|
|
2595
|
-
"
|
|
2596
|
-
"splitSep": "F2LbNW_splitSep"
|
|
2588
|
+
var PricingDialog_module_css_default = {
|
|
2589
|
+
"conditionCell": "gh1SLa_conditionCell",
|
|
2590
|
+
"conditionHead": "gh1SLa_conditionHead",
|
|
2591
|
+
"dialog": "gh1SLa_dialog",
|
|
2592
|
+
"dialogClose": "gh1SLa_dialogClose",
|
|
2593
|
+
"dialogHead": "gh1SLa_dialogHead",
|
|
2594
|
+
"dialogTitle": "gh1SLa_dialogTitle",
|
|
2595
|
+
"groupRow": "gh1SLa_groupRow",
|
|
2596
|
+
"rateNote": "gh1SLa_rateNote",
|
|
2597
|
+
"table": "gh1SLa_table",
|
|
2598
|
+
"tableWrap": "gh1SLa_tableWrap"
|
|
2597
2599
|
};
|
|
2598
2600
|
//#endregion
|
|
2599
|
-
//#region src/client/
|
|
2601
|
+
//#region src/client/PricingDialog.tsx
|
|
2600
2602
|
/**
|
|
2601
|
-
*
|
|
2602
|
-
*
|
|
2603
|
+
* The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
|
|
2604
|
+
* is trapped, the backdrop dims, and the top layer renders it above the
|
|
2605
|
+
* table's scroll shell) holding that model's full price table — billing
|
|
2606
|
+
* conditions (default / context tiers / peak slots / time rules) × the four
|
|
2607
|
+
* per-million rates, converted for a USD view. Shared by the settings
|
|
2608
|
+
* page's per-model “定价” affordance and the pricing-overview dialog's
|
|
2609
|
+
* drill-in rows; a native showModal naturally stacks a second instance
|
|
2610
|
+
* above the overview.
|
|
2611
|
+
*
|
|
2612
|
+
* @module token-usage/client/PricingDialog
|
|
2603
2613
|
*/
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
+
/** The four base rates of one model as display text (symbol included,
|
|
2615
|
+
* converted for a USD view); a missing cache rate bills at the input rate. */
|
|
2616
|
+
function billedRates(rates, view) {
|
|
2617
|
+
return {
|
|
2618
|
+
input: formatRateWithSymbol(rates.inputPerMillion, view),
|
|
2619
|
+
output: formatRateWithSymbol(rates.outputPerMillion, view),
|
|
2620
|
+
cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
|
|
2621
|
+
cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
/** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
|
|
2625
|
+
function windowText(window) {
|
|
2626
|
+
const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
|
|
2627
|
+
return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
|
|
2628
|
+
}
|
|
2629
|
+
/** The when-it-applies text of one peak slot: its label plus its windows. */
|
|
2630
|
+
function slotCondition(slot, t) {
|
|
2631
|
+
return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
|
|
2632
|
+
}
|
|
2633
|
+
/**
|
|
2634
|
+
* The price rows of one rate node (a time rule's or the model root's): the
|
|
2635
|
+
* node's own base rates, then its peak slots, then its context tiers
|
|
2636
|
+
* (ascending), each tier followed by the peak slots hanging on that tier —
|
|
2637
|
+
* mirroring {@link resolveRate}'s node chain, where a matching tier's slots
|
|
2638
|
+
* replace the node's and peak rates replace the node's rates wholesale.
|
|
2639
|
+
*/
|
|
2640
|
+
function nodePriceRows(node, t) {
|
|
2641
|
+
const rows = [{
|
|
2642
|
+
condition: t("pricing.default"),
|
|
2643
|
+
rates: node.rates
|
|
2644
|
+
}];
|
|
2645
|
+
const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
|
|
2646
|
+
for (const tier of tiers) {
|
|
2647
|
+
const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
|
|
2648
|
+
rows.push({
|
|
2649
|
+
condition: tierCondition,
|
|
2650
|
+
rates: tier.rates
|
|
2651
|
+
});
|
|
2652
|
+
for (const slot of tier.dailySlots ?? []) rows.push({
|
|
2653
|
+
condition: `${tierCondition} · ${slotCondition(slot, t)}`,
|
|
2654
|
+
rates: slot.rates
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
for (const slot of node.slots ?? []) rows.push({
|
|
2658
|
+
condition: slotCondition(slot, t),
|
|
2659
|
+
rates: slot.rates
|
|
2614
2660
|
});
|
|
2661
|
+
return rows;
|
|
2615
2662
|
}
|
|
2616
2663
|
/**
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2619
|
-
*
|
|
2664
|
+
* One model's price table: rows are billing conditions — grouped into the
|
|
2665
|
+
* model root (“常规”, omitted when it is the only group) and one group per
|
|
2666
|
+
* time rule with its date window — so tier, peak, and time-rule pricing
|
|
2667
|
+
* each show when they apply and what they bill. The structure mirrors
|
|
2668
|
+
* {@link resolveRate}'s node chain.
|
|
2620
2669
|
*/
|
|
2621
|
-
function
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2670
|
+
function ModelPriceTable({ rules, view, t }) {
|
|
2671
|
+
const groups = [{
|
|
2672
|
+
title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
|
|
2673
|
+
rows: nodePriceRows({
|
|
2674
|
+
rates: rules.base,
|
|
2675
|
+
tiers: rules.contextTiers,
|
|
2676
|
+
slots: rules.dailySlots
|
|
2677
|
+
}, t)
|
|
2678
|
+
}, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
|
|
2679
|
+
title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
|
|
2680
|
+
rows: nodePriceRows({
|
|
2681
|
+
rates: rule.rates,
|
|
2682
|
+
tiers: rule.contextTiers,
|
|
2683
|
+
slots: rule.dailySlots
|
|
2684
|
+
}, t)
|
|
2685
|
+
}))];
|
|
2686
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2687
|
+
className: PricingDialog_module_css_default["tableWrap"],
|
|
2688
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
2689
|
+
className: PricingDialog_module_css_default["table"],
|
|
2690
|
+
"aria-label": t("pricing.title"),
|
|
2691
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2692
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2693
|
+
className: PricingDialog_module_css_default["conditionHead"],
|
|
2694
|
+
children: t("pricing.condition")
|
|
2695
|
+
}),
|
|
2696
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
2697
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
2698
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
2699
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
|
|
2700
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
2701
|
+
className: PricingDialog_module_css_default["groupRow"],
|
|
2702
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2703
|
+
colSpan: 5,
|
|
2704
|
+
children: group.title
|
|
2705
|
+
})
|
|
2706
|
+
}, group.title)] : [], ...group.rows.map((row, index) => {
|
|
2707
|
+
const billed = billedRates(row.rates, view);
|
|
2708
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2709
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2710
|
+
className: PricingDialog_module_css_default["conditionCell"],
|
|
2711
|
+
children: row.condition
|
|
2712
|
+
}),
|
|
2713
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
2714
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
2715
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
2716
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
|
|
2717
|
+
] }, `${group.title ?? ""}-${index}-${row.condition}`);
|
|
2718
|
+
})]) })]
|
|
2719
|
+
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2720
|
+
className: PricingDialog_module_css_default["rateNote"],
|
|
2721
|
+
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
2722
|
+
}) : null]
|
|
2635
2723
|
});
|
|
2636
2724
|
}
|
|
2637
2725
|
/**
|
|
2638
|
-
* The
|
|
2639
|
-
*
|
|
2726
|
+
* The pricing dialog of one model. Mounts only while a model is selected;
|
|
2727
|
+
* every close path funnels through the dialog's `close` event, which clears
|
|
2728
|
+
* the selection and unmounts it.
|
|
2640
2729
|
*/
|
|
2641
|
-
function
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2730
|
+
function PricingDialog({ model, rules, view, onClose, t }) {
|
|
2731
|
+
const dialogRef = (0, react.useRef)(null);
|
|
2732
|
+
const backdropPress = (0, react.useRef)(false);
|
|
2733
|
+
(0, react.useEffect)(() => {
|
|
2734
|
+
const dialog = dialogRef.current;
|
|
2735
|
+
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
2736
|
+
}, []);
|
|
2737
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
2738
|
+
ref: dialogRef,
|
|
2739
|
+
className: PricingDialog_module_css_default["dialog"],
|
|
2740
|
+
"aria-label": t("pricing.title"),
|
|
2741
|
+
onClose,
|
|
2742
|
+
onMouseDown: (event) => {
|
|
2743
|
+
backdropPress.current = event.target === dialogRef.current;
|
|
2744
|
+
},
|
|
2745
|
+
onClick: (event) => {
|
|
2746
|
+
if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
|
|
2747
|
+
},
|
|
2748
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2749
|
+
className: PricingDialog_module_css_default["dialogHead"],
|
|
2750
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2751
|
+
className: PricingDialog_module_css_default["dialogTitle"],
|
|
2752
|
+
children: model
|
|
2753
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2754
|
+
type: "button",
|
|
2755
|
+
className: PricingDialog_module_css_default["dialogClose"],
|
|
2756
|
+
"aria-label": t("pricing.close"),
|
|
2757
|
+
onClick: () => dialogRef.current?.close(),
|
|
2758
|
+
children: "✕"
|
|
2759
|
+
})]
|
|
2760
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
|
|
2761
|
+
rules,
|
|
2762
|
+
view,
|
|
2650
2763
|
t
|
|
2651
|
-
})]
|
|
2764
|
+
})]
|
|
2652
2765
|
});
|
|
2653
2766
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2767
|
+
//#endregion
|
|
2768
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingOverviewDialog.module.css.mjs
|
|
2769
|
+
const css$5 = ".bVRC-q_overview{width:min(720px,100vw - 48px)}.bVRC-q_note{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.bVRC-q_failRow{align-items:center;gap:8px;display:flex}.bVRC-q_retryButton{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;flex:none;padding:2px 12px;font-size:12px;line-height:18px}.bVRC-q_retryButton:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_search{width:100%;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:6px;margin-bottom:8px;padding:4px 8px;font-size:13px}.bVRC-q_buckets{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:6px;flex-wrap:nowrap;align-items:stretch;margin-bottom:8px;padding:4px;display:flex}.bVRC-q_bucket{flex:1 1 0;align-items:center;gap:4px;min-width:0;padding:0 10px;display:flex}.bVRC-q_bucket+.bVRC-q_bucket{border-left:1px solid var(--dsw-alias-border-l1)}.bVRC-q_bucketLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;flex:none;font-size:11px;line-height:14px}.bVRC-q_unitGroup{flex:none;display:flex}.bVRC-q_unit{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;background:0 0;padding:0 5px;font-size:10px;line-height:14px}.bVRC-q_unit:first-child{border-radius:3px 0 0 3px}.bVRC-q_unit:last-child{border-radius:0 3px 3px 0}.bVRC-q_unit+.bVRC-q_unit{border-left:none}.bVRC-q_unit:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_unit[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);font-weight:600}.bVRC-q_bucketInput{width:100%;min-width:0;color:var(--dsw-alias-label-primary);box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l2);font-variant-numeric:tabular-nums;background:0 0;border:none;border-radius:4px;flex:1 1 0;padding:2px 18px 2px 6px;font-size:12px}.bVRC-q_bucketInput::-webkit-outer-spin-button,.bVRC-q_bucketInput::-webkit-inner-spin-button{opacity:1;cursor:pointer;height:100%}.bVRC-q_bucketInput:focus{background:var(--dsw-alias-bg-layer-3);outline:none}.bVRC-q_scenarios{flex-wrap:wrap;gap:6px;margin-bottom:8px;display:flex}.bVRC-q_scenario{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:12px;line-height:18px}.bVRC-q_scenario:hover{background:var(--dsw-interactive-bg-hover)}.bVRC-q_scenario[aria-pressed=true]{border-color:var(--dsw-alias-label-primary)}.bVRC-q_tableWrap{height:min(60vh,520px);overflow:auto}.bVRC-q_table{table-layout:fixed;border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:560px;font-size:12px}.bVRC-q_table th,.bVRC-q_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.bVRC-q_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.bVRC-q_table td{color:var(--dsw-alias-label-primary)}th.bVRC-q_modelHead,td.bVRC-q_modelCell{text-align:left}th.bVRC-q_modelHead{width:40%}.bVRC-q_sortHead{font:inherit;font-weight:inherit;color:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0}.bVRC-q_sortHead:hover{text-decoration:underline}.bVRC-q_sortArrow{font-size:10px}.bVRC-q_sortArrowIdle{opacity:.5}.bVRC-q_modelRow{cursor:pointer}.bVRC-q_modelRow:hover>td{background:var(--dsw-interactive-bg-hover)}.bVRC-q_cellInner{align-items:center;gap:6px;max-width:100%;display:inline-flex}.bVRC-q_modelName{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;font-weight:500;overflow:hidden}.bVRC-q_usedTag{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-3);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.bVRC-q_expandArrow{width:16px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-size:10px;line-height:16px}.bVRC-q_expandArrow:hover{color:var(--dsw-alias-label-primary)}.bVRC-q_arrowGap{flex:none;width:16px}.bVRC-q_expansionRow>td{padding:0 6px 4px}.bVRC-q_specialRows{flex-direction:column;gap:2px;display:flex}.bVRC-q_specialRow{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;grid-template-columns:3.2fr 1fr 1fr 1fr 1fr 1fr;gap:4px;padding:1px 0 1px 28px;font-size:11px;display:grid}.bVRC-q_specialLabel{color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;text-align:left;overflow:hidden}.bVRC-q_specialRate{text-align:right;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
|
|
2770
|
+
const tagId$5 = "@laoyuehanni/dsh-token-usage/PricingOverviewDialog.module.css";
|
|
2771
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$5) + "]") === null) {
|
|
2772
|
+
const tag = document.createElement("style");
|
|
2773
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2774
|
+
tag.dataset.pluginCss = tagId$5;
|
|
2775
|
+
tag.textContent = css$5;
|
|
2776
|
+
document.head.appendChild(tag);
|
|
2777
|
+
}
|
|
2778
|
+
var PricingOverviewDialog_module_css_default = {
|
|
2779
|
+
"arrowGap": "bVRC-q_arrowGap",
|
|
2780
|
+
"bucket": "bVRC-q_bucket",
|
|
2781
|
+
"bucketInput": "bVRC-q_bucketInput",
|
|
2782
|
+
"bucketLabel": "bVRC-q_bucketLabel",
|
|
2783
|
+
"buckets": "bVRC-q_buckets",
|
|
2784
|
+
"cellInner": "bVRC-q_cellInner",
|
|
2785
|
+
"expandArrow": "bVRC-q_expandArrow",
|
|
2786
|
+
"expansionRow": "bVRC-q_expansionRow",
|
|
2787
|
+
"failRow": "bVRC-q_failRow",
|
|
2788
|
+
"modelCell": "bVRC-q_modelCell",
|
|
2789
|
+
"modelHead": "bVRC-q_modelHead",
|
|
2790
|
+
"modelName": "bVRC-q_modelName",
|
|
2791
|
+
"modelRow": "bVRC-q_modelRow",
|
|
2792
|
+
"note": "bVRC-q_note",
|
|
2793
|
+
"overview": "bVRC-q_overview",
|
|
2794
|
+
"retryButton": "bVRC-q_retryButton",
|
|
2795
|
+
"scenario": "bVRC-q_scenario",
|
|
2796
|
+
"scenarios": "bVRC-q_scenarios",
|
|
2797
|
+
"search": "bVRC-q_search",
|
|
2798
|
+
"sortArrow": "bVRC-q_sortArrow",
|
|
2799
|
+
"sortArrowIdle": "bVRC-q_sortArrowIdle",
|
|
2800
|
+
"sortHead": "bVRC-q_sortHead",
|
|
2801
|
+
"specialLabel": "bVRC-q_specialLabel",
|
|
2802
|
+
"specialRate": "bVRC-q_specialRate",
|
|
2803
|
+
"specialRow": "bVRC-q_specialRow",
|
|
2804
|
+
"specialRows": "bVRC-q_specialRows",
|
|
2805
|
+
"table": "bVRC-q_table",
|
|
2806
|
+
"tableWrap": "bVRC-q_tableWrap",
|
|
2807
|
+
"unit": "bVRC-q_unit",
|
|
2808
|
+
"unitGroup": "bVRC-q_unitGroup",
|
|
2809
|
+
"usedTag": "bVRC-q_usedTag"
|
|
2810
|
+
};
|
|
2811
|
+
//#endregion
|
|
2812
|
+
//#region src/client/PricingOverviewDialog.tsx
|
|
2813
|
+
/**
|
|
2814
|
+
* The pricing-overview dialog of the settings page: the full cloud-mirror
|
|
2815
|
+
* model list served by the filter-free `/token-usage/pricing` route — one
|
|
2816
|
+
* flat row per model, sorted by the feed's upstream `family` field (zero
|
|
2817
|
+
* client-side mapping) then by modelId, each row's four base rates in the
|
|
2818
|
+
* page's display currency. Families drive order and search only — there is
|
|
2819
|
+
* no grouping UI, every row is directly visible. Rows the page's filters
|
|
2820
|
+
* have used carry a “已用” tag; clicking a row opens that model's full
|
|
2821
|
+
* price table as a second native dialog stacked above.
|
|
2822
|
+
*
|
|
2823
|
+
* Above the table, four token-bucket inputs drive a simulated-cost column:
|
|
2824
|
+
* what the buckets would bill at each model's base rates. Each bucket is
|
|
2825
|
+
* an amount under a picked K/M/B unit — switching converts the amount, the
|
|
2826
|
+
* token count stands still. Preset case buttons (「案例1」, hover-titled
|
|
2827
|
+
* with the workload picture) refill the buckets compact in one click; the
|
|
2828
|
+
* first case is prefilled on open, and the pressed highlight tracks exact
|
|
2829
|
+
* token matches, so a manual edit un-presses. The column sorts by a
|
|
2830
|
+
* three-state header cycle (family order → cost desc → cost asc → family);
|
|
2831
|
+
* the header's glyph never disappears: a dim ⇅ in the default family
|
|
2832
|
+
* order, then ▾ desc and ▴ asc.
|
|
2833
|
+
*
|
|
2834
|
+
* Aliases never render — they stay a search dimension only (a hit on an
|
|
2835
|
+
* alias surfaces the model, whose id then reads as the result).
|
|
2836
|
+
*
|
|
2837
|
+
* @module token-usage/client/PricingOverviewDialog
|
|
2838
|
+
*/
|
|
2839
|
+
/** The family a model row without a feed `family` lands in; the feed
|
|
2840
|
+
* itself already uses this value for uncategorized rows. */
|
|
2841
|
+
const OTHER_FAMILY = "other";
|
|
2842
|
+
/** The family of one row (absent → `other`): the sort key's first half
|
|
2843
|
+
* and one of the search dimensions. */
|
|
2844
|
+
function familyOf(model) {
|
|
2845
|
+
return model.family ?? OTHER_FAMILY;
|
|
2846
|
+
}
|
|
2847
|
+
/**
|
|
2848
|
+
* Sort models by family (alphabetical, absent → `other`), then by modelId —
|
|
2849
|
+
* the feed's own classification drives the browsing order so same-family
|
|
2850
|
+
* models stay adjacent, with zero client-side mapping.
|
|
2851
|
+
*/
|
|
2852
|
+
function sortPricingModels(models) {
|
|
2853
|
+
return [...models].sort((a, b) => {
|
|
2854
|
+
const familyA = familyOf(a);
|
|
2855
|
+
const familyB = familyOf(b);
|
|
2856
|
+
if (familyA !== familyB) return familyA < familyB ? -1 : 1;
|
|
2857
|
+
return a.modelId < b.modelId ? -1 : a.modelId > b.modelId ? 1 : 0;
|
|
2674
2858
|
});
|
|
2675
2859
|
}
|
|
2676
|
-
/**
|
|
2677
|
-
*
|
|
2678
|
-
*
|
|
2679
|
-
*
|
|
2860
|
+
/**
|
|
2861
|
+
* Whether one model row matches the search: a case-insensitive substring
|
|
2862
|
+
* hit on the modelId, any alias, or the family. An empty query
|
|
2863
|
+
* matches everything.
|
|
2864
|
+
*/
|
|
2865
|
+
function matchesPricingSearch(model, query) {
|
|
2866
|
+
if (query === "") return true;
|
|
2867
|
+
const needle = query.toLowerCase();
|
|
2868
|
+
if (model.modelId.toLowerCase().includes(needle)) return true;
|
|
2869
|
+
if (familyOf(model).toLowerCase().includes(needle)) return true;
|
|
2870
|
+
return model.aliases.some((alias) => alias.toLowerCase().includes(needle));
|
|
2871
|
+
}
|
|
2872
|
+
/** The preset cases the buttons fill the inputs with (maintainer-curated
|
|
2873
|
+
* classic workloads). The first prefills the inputs on open. */
|
|
2874
|
+
const SIM_SCENARIOS = [
|
|
2875
|
+
{
|
|
2876
|
+
inputTokens: 2e6,
|
|
2877
|
+
cacheReadTokens: 98e6,
|
|
2878
|
+
outputTokens: 457e3,
|
|
2879
|
+
cacheWriteTokens: 0
|
|
2880
|
+
},
|
|
2881
|
+
{
|
|
2882
|
+
inputTokens: 5e6,
|
|
2883
|
+
cacheReadTokens: 95e6,
|
|
2884
|
+
outputTokens: 6e5,
|
|
2885
|
+
cacheWriteTokens: 0
|
|
2886
|
+
},
|
|
2887
|
+
{
|
|
2888
|
+
inputTokens: 1e8,
|
|
2889
|
+
cacheReadTokens: 0,
|
|
2890
|
+
outputTokens: 1e8,
|
|
2891
|
+
cacheWriteTokens: 0
|
|
2892
|
+
}
|
|
2893
|
+
];
|
|
2894
|
+
/** The units a bucket's amount can carry. */
|
|
2895
|
+
const BUCKET_UNITS = [
|
|
2896
|
+
"K",
|
|
2897
|
+
"M",
|
|
2898
|
+
"B"
|
|
2899
|
+
];
|
|
2900
|
+
const UNIT_MULT = {
|
|
2901
|
+
K: 1e3,
|
|
2902
|
+
M: 1e6,
|
|
2903
|
+
B: 1e9
|
|
2904
|
+
};
|
|
2905
|
+
/** The whole-token count a bucket stands for: amount × unit, float fuzz
|
|
2906
|
+
* rounded off; empty, negative, or non-numeric amounts read as zero. */
|
|
2907
|
+
function tokensOf(bucket) {
|
|
2908
|
+
const parsed = Number(bucket.amount);
|
|
2909
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 0;
|
|
2910
|
+
return Math.round(parsed * UNIT_MULT[bucket.unit]);
|
|
2911
|
+
}
|
|
2912
|
+
/** The amount string for the same tokens under a new unit — converting so
|
|
2913
|
+
* the token count stands still (98M reads 98000K). Trims float fuzz to
|
|
2914
|
+
* six decimals so 0.457M ↔ 457K round-trips cleanly. */
|
|
2915
|
+
function convertBucketAmount(bucket, unit) {
|
|
2916
|
+
const parsed = Number(bucket.amount);
|
|
2917
|
+
if (!Number.isFinite(parsed)) return "";
|
|
2918
|
+
const converted = parsed * UNIT_MULT[bucket.unit] / UNIT_MULT[unit];
|
|
2919
|
+
return String(Math.round(converted * 1e6) / 1e6);
|
|
2920
|
+
}
|
|
2921
|
+
/** The compact refill shape of one token count: a short amount under the
|
|
2922
|
+
* fitting unit (98M, 457K), K as the floor for the sub-1K tail. */
|
|
2923
|
+
function compactBucket(tokens) {
|
|
2924
|
+
if (tokens >= UNIT_MULT.B) return {
|
|
2925
|
+
amount: String(tokens / UNIT_MULT.B),
|
|
2926
|
+
unit: "B"
|
|
2927
|
+
};
|
|
2928
|
+
if (tokens >= UNIT_MULT.M) return {
|
|
2929
|
+
amount: String(tokens / UNIT_MULT.M),
|
|
2930
|
+
unit: "M"
|
|
2931
|
+
};
|
|
2932
|
+
return {
|
|
2933
|
+
amount: String(tokens / UNIT_MULT.K),
|
|
2934
|
+
unit: "K"
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
/** The refill shape of a whole case: every bucket compact. */
|
|
2938
|
+
function bucketsOfCase(scenario) {
|
|
2939
|
+
return {
|
|
2940
|
+
inputTokens: compactBucket(scenario.inputTokens),
|
|
2941
|
+
cacheReadTokens: compactBucket(scenario.cacheReadTokens),
|
|
2942
|
+
outputTokens: compactBucket(scenario.outputTokens),
|
|
2943
|
+
cacheWriteTokens: compactBucket(scenario.cacheWriteTokens)
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* The simulated cost (¥) of one scenario under a model's base rates —
|
|
2948
|
+
* the same arithmetic as the host half's `costOf` (a missing cache rate
|
|
2949
|
+
* bills at the input rate), re-implemented here because pricing.ts lives
|
|
2950
|
+
* on the node side of the bundle boundary.
|
|
2951
|
+
*/
|
|
2952
|
+
function simCostOf(scenario, rates) {
|
|
2953
|
+
const M = 1e6;
|
|
2954
|
+
const cacheRead = rates.cacheReadPerMillion ?? rates.inputPerMillion;
|
|
2955
|
+
const cacheWrite = rates.cacheWritePerMillion ?? rates.inputPerMillion;
|
|
2956
|
+
return (scenario.inputTokens * rates.inputPerMillion + scenario.outputTokens * rates.outputPerMillion + scenario.cacheReadTokens * cacheRead + scenario.cacheWriteTokens * cacheWrite) / M;
|
|
2957
|
+
}
|
|
2958
|
+
/** The largest tier whose threshold the context clears. */
|
|
2959
|
+
function hitTier(tiers, ctxTokens) {
|
|
2960
|
+
let hit;
|
|
2961
|
+
for (const tier of tiers) if (ctxTokens >= tier.threshold && (hit === void 0 || tier.threshold > hit.threshold)) hit = tier;
|
|
2962
|
+
return hit;
|
|
2963
|
+
}
|
|
2964
|
+
function hitNodeOf(rules, ctxTokens, nowMs) {
|
|
2965
|
+
const nowSec = Math.floor(nowMs / 1e3);
|
|
2966
|
+
const rule = rules.timeRules.find((candidate) => candidate.startTime <= nowSec && nowSec <= candidate.endTime);
|
|
2967
|
+
if (rule !== void 0) return {
|
|
2968
|
+
baseRates: rule.rates,
|
|
2969
|
+
slots: rule.dailySlots ?? [],
|
|
2970
|
+
tier: hitTier(rule.contextTiers ?? [], ctxTokens)
|
|
2971
|
+
};
|
|
2972
|
+
return {
|
|
2973
|
+
baseRates: rules.base,
|
|
2974
|
+
slots: rules.dailySlots,
|
|
2975
|
+
tier: hitTier(rules.contextTiers, ctxTokens)
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
/** The workload picture of one case — the input line (input-side total
|
|
2979
|
+
* with its cache-hit share) and the output line — joined into the case
|
|
2980
|
+
* button's hover title. */
|
|
2981
|
+
function scenarioLabel(scenario, t) {
|
|
2982
|
+
const total = scenario.inputTokens + scenario.cacheReadTokens;
|
|
2983
|
+
const pct = Math.round(scenario.cacheReadTokens / total * 100);
|
|
2984
|
+
return {
|
|
2985
|
+
inputLine: `${t("pricing.simInput", { tokens: formatTokens(total) })}${t("pricing.simCache", { pct: String(pct) })}`,
|
|
2986
|
+
outputLine: t("pricing.simOutput", { tokens: formatTokens(scenario.outputTokens) })
|
|
2987
|
+
};
|
|
2988
|
+
}
|
|
2989
|
+
/** One bucket's K/M/B unit segment. Switching converts the amount so the
|
|
2990
|
+
* token count stands still. */
|
|
2991
|
+
function UnitPicker({ t, bucket, unit, onPick }) {
|
|
2992
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2993
|
+
className: PricingOverviewDialog_module_css_default["unitGroup"],
|
|
2994
|
+
children: BUCKET_UNITS.map((candidate) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2995
|
+
type: "button",
|
|
2996
|
+
className: PricingOverviewDialog_module_css_default["unit"],
|
|
2997
|
+
"aria-pressed": candidate === unit,
|
|
2998
|
+
"aria-label": t("pricing.simUnitOf", {
|
|
2999
|
+
bucket,
|
|
3000
|
+
unit: candidate
|
|
3001
|
+
}),
|
|
3002
|
+
onClick: () => {
|
|
3003
|
+
if (candidate !== unit) onPick(candidate);
|
|
3004
|
+
},
|
|
3005
|
+
children: candidate
|
|
3006
|
+
}, candidate))
|
|
3007
|
+
});
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Fetch the pricing overview from the local route — deliberately without
|
|
3011
|
+
* any query parameters: the overview is not a filtered view, so changing
|
|
3012
|
+
* the page's filters never changes what this dialog shows. An empty model
|
|
3013
|
+
* list (a first startup whose sync has not landed a mirror yet) reads as
|
|
3014
|
+
* the same failure the fetch error does: nothing to show, retry offered.
|
|
3015
|
+
*/
|
|
3016
|
+
function fetchPricingOverview(signal) {
|
|
3017
|
+
return fetch(PRICING_PATH, { signal }).then((response) => {
|
|
3018
|
+
if (!response.ok) throw new Error(`HTTP ${String(response.status)}`);
|
|
3019
|
+
return response.json();
|
|
3020
|
+
}).then((value) => {
|
|
3021
|
+
if (typeof value !== "object" || value === null || !Array.isArray(value.models)) throw new Error("unexpected pricing response");
|
|
3022
|
+
if (value.models.length === 0) throw new Error("pricing mirror is empty");
|
|
3023
|
+
return value;
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
/**
|
|
3027
|
+
* The pricing-overview dialog. `usedModels` is the open-time snapshot of
|
|
3028
|
+
* the page's filtered model selection (the modal's backdrop covers the
|
|
3029
|
+
* filter row, so it cannot change while the dialog is open); `view` is the
|
|
3030
|
+
* page's display currency. Mounts only while open; every close path
|
|
3031
|
+
* funnels through the dialog's `close` event, which unmounts it.
|
|
3032
|
+
*/
|
|
3033
|
+
function PricingOverviewDialog({ usedModels, view, onClose, t }) {
|
|
3034
|
+
const dialogRef = (0, react.useRef)(null);
|
|
3035
|
+
const backdropPress = (0, react.useRef)(false);
|
|
3036
|
+
(0, react.useEffect)(() => {
|
|
3037
|
+
const dialog = dialogRef.current;
|
|
3038
|
+
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
3039
|
+
}, []);
|
|
3040
|
+
const [state, retry] = useAsyncResource(fetchPricingOverview, [], { retryToken: 0 });
|
|
3041
|
+
const [search, setSearch] = (0, react.useState)("");
|
|
3042
|
+
const [buckets, setBuckets] = (0, react.useState)(() => bucketsOfCase(SIM_SCENARIOS[0]));
|
|
3043
|
+
const [sortMode, setSortMode] = (0, react.useState)("family");
|
|
3044
|
+
const [detail, setDetail] = (0, react.useState)(null);
|
|
3045
|
+
const [nowMs] = (0, react.useState)(() => Date.now());
|
|
3046
|
+
const [expandedId, setExpandedId] = (0, react.useState)(null);
|
|
3047
|
+
const sorted = (0, react.useMemo)(() => sortPricingModels(state.status === "ready" ? state.value.models : []), [state]);
|
|
3048
|
+
const scenario = (0, react.useMemo)(() => ({
|
|
3049
|
+
inputTokens: tokensOf(buckets.inputTokens),
|
|
3050
|
+
cacheReadTokens: tokensOf(buckets.cacheReadTokens),
|
|
3051
|
+
outputTokens: tokensOf(buckets.outputTokens),
|
|
3052
|
+
cacheWriteTokens: tokensOf(buckets.cacheWriteTokens)
|
|
3053
|
+
}), [buckets]);
|
|
3054
|
+
const ctxTokens = scenario.inputTokens + scenario.cacheReadTokens;
|
|
3055
|
+
const pressedCase = SIM_SCENARIOS.find((candidate) => candidate.inputTokens === scenario.inputTokens && candidate.cacheReadTokens === scenario.cacheReadTokens && candidate.outputTokens === scenario.outputTokens && candidate.cacheWriteTokens === scenario.cacheWriteTokens);
|
|
3056
|
+
const query = search.trim();
|
|
3057
|
+
const rows = (0, react.useMemo)(() => {
|
|
3058
|
+
const withCost = sorted.map((model) => {
|
|
3059
|
+
const node = hitNodeOf(model.rules, ctxTokens, nowMs);
|
|
3060
|
+
return {
|
|
3061
|
+
model,
|
|
3062
|
+
node,
|
|
3063
|
+
cost: simCostOf(scenario, node.baseRates),
|
|
3064
|
+
specials: [...node.tier !== void 0 ? [{
|
|
3065
|
+
kind: "tier",
|
|
3066
|
+
tier: node.tier,
|
|
3067
|
+
slot: void 0,
|
|
3068
|
+
cost: simCostOf(scenario, node.tier.rates)
|
|
3069
|
+
}] : [], ...node.slots.map((slot) => ({
|
|
3070
|
+
kind: "slot",
|
|
3071
|
+
tier: void 0,
|
|
3072
|
+
slot,
|
|
3073
|
+
cost: simCostOf(scenario, slot.rates)
|
|
3074
|
+
}))]
|
|
3075
|
+
};
|
|
3076
|
+
}).filter(({ model }) => query === "" || matchesPricingSearch(model, query));
|
|
3077
|
+
if (sortMode === "family") return withCost;
|
|
3078
|
+
return [...withCost].sort((a, b) => sortMode === "cost-desc" ? b.cost - a.cost : a.cost - b.cost);
|
|
3079
|
+
}, [
|
|
3080
|
+
sorted,
|
|
3081
|
+
scenario,
|
|
3082
|
+
query,
|
|
3083
|
+
sortMode,
|
|
3084
|
+
ctxTokens,
|
|
3085
|
+
nowMs
|
|
3086
|
+
]);
|
|
3087
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
3088
|
+
ref: dialogRef,
|
|
3089
|
+
className: `${PricingDialog_module_css_default["dialog"]} ${PricingOverviewDialog_module_css_default["overview"]}`,
|
|
3090
|
+
"aria-label": t("pricing.table"),
|
|
3091
|
+
onClose: (event) => {
|
|
3092
|
+
if (event.target === dialogRef.current) onClose();
|
|
3093
|
+
},
|
|
3094
|
+
onMouseDown: (event) => {
|
|
3095
|
+
backdropPress.current = event.target === dialogRef.current;
|
|
3096
|
+
},
|
|
3097
|
+
onClick: (event) => {
|
|
3098
|
+
if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
|
|
3099
|
+
},
|
|
3100
|
+
children: [
|
|
3101
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3102
|
+
className: PricingDialog_module_css_default["dialogHead"],
|
|
3103
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3104
|
+
className: PricingDialog_module_css_default["dialogTitle"],
|
|
3105
|
+
children: t("pricing.table")
|
|
3106
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3107
|
+
type: "button",
|
|
3108
|
+
className: PricingDialog_module_css_default["dialogClose"],
|
|
3109
|
+
"aria-label": t("pricing.close"),
|
|
3110
|
+
onClick: () => dialogRef.current?.close(),
|
|
3111
|
+
children: "✕"
|
|
3112
|
+
})]
|
|
3113
|
+
}),
|
|
3114
|
+
state.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3115
|
+
className: PricingOverviewDialog_module_css_default["note"],
|
|
3116
|
+
children: t("loading")
|
|
3117
|
+
}) : null,
|
|
3118
|
+
state.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3119
|
+
className: PricingOverviewDialog_module_css_default["failRow"],
|
|
3120
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3121
|
+
className: PricingOverviewDialog_module_css_default["note"],
|
|
3122
|
+
children: t("pricing.overviewFailed")
|
|
3123
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3124
|
+
type: "button",
|
|
3125
|
+
className: PricingOverviewDialog_module_css_default["retryButton"],
|
|
3126
|
+
onClick: retry,
|
|
3127
|
+
children: t("retry")
|
|
3128
|
+
})]
|
|
3129
|
+
}) : null,
|
|
3130
|
+
state.status === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3131
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3132
|
+
type: "search",
|
|
3133
|
+
className: PricingOverviewDialog_module_css_default["search"],
|
|
3134
|
+
placeholder: t("pricing.search"),
|
|
3135
|
+
"aria-label": t("pricing.search"),
|
|
3136
|
+
value: search,
|
|
3137
|
+
onChange: (event) => setSearch(event.target.value)
|
|
3138
|
+
}),
|
|
3139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3140
|
+
className: PricingOverviewDialog_module_css_default["buckets"],
|
|
3141
|
+
children: [
|
|
3142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3143
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3144
|
+
children: [
|
|
3145
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3146
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3147
|
+
children: t("pricing.simBucketInput")
|
|
3148
|
+
}),
|
|
3149
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3150
|
+
type: "number",
|
|
3151
|
+
min: 0,
|
|
3152
|
+
step: "any",
|
|
3153
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3154
|
+
"aria-label": t("pricing.simBucketInput"),
|
|
3155
|
+
value: buckets.inputTokens.amount,
|
|
3156
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3157
|
+
...previous,
|
|
3158
|
+
inputTokens: {
|
|
3159
|
+
...previous.inputTokens,
|
|
3160
|
+
amount: event.target.value
|
|
3161
|
+
}
|
|
3162
|
+
}))
|
|
3163
|
+
}),
|
|
3164
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3165
|
+
t,
|
|
3166
|
+
bucket: t("pricing.simBucketInput"),
|
|
3167
|
+
unit: buckets.inputTokens.unit,
|
|
3168
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3169
|
+
...previous,
|
|
3170
|
+
inputTokens: {
|
|
3171
|
+
amount: convertBucketAmount(previous.inputTokens, unit),
|
|
3172
|
+
unit
|
|
3173
|
+
}
|
|
3174
|
+
}))
|
|
3175
|
+
})
|
|
3176
|
+
]
|
|
3177
|
+
}),
|
|
3178
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3179
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3180
|
+
children: [
|
|
3181
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3182
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3183
|
+
children: t("pricing.simBucketCacheRead")
|
|
3184
|
+
}),
|
|
3185
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3186
|
+
type: "number",
|
|
3187
|
+
min: 0,
|
|
3188
|
+
step: "any",
|
|
3189
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3190
|
+
"aria-label": t("pricing.simBucketCacheRead"),
|
|
3191
|
+
value: buckets.cacheReadTokens.amount,
|
|
3192
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3193
|
+
...previous,
|
|
3194
|
+
cacheReadTokens: {
|
|
3195
|
+
...previous.cacheReadTokens,
|
|
3196
|
+
amount: event.target.value
|
|
3197
|
+
}
|
|
3198
|
+
}))
|
|
3199
|
+
}),
|
|
3200
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3201
|
+
t,
|
|
3202
|
+
bucket: t("pricing.simBucketCacheRead"),
|
|
3203
|
+
unit: buckets.cacheReadTokens.unit,
|
|
3204
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3205
|
+
...previous,
|
|
3206
|
+
cacheReadTokens: {
|
|
3207
|
+
amount: convertBucketAmount(previous.cacheReadTokens, unit),
|
|
3208
|
+
unit
|
|
3209
|
+
}
|
|
3210
|
+
}))
|
|
3211
|
+
})
|
|
3212
|
+
]
|
|
3213
|
+
}),
|
|
3214
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3215
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3216
|
+
children: [
|
|
3217
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3218
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3219
|
+
children: t("pricing.simBucketOutput")
|
|
3220
|
+
}),
|
|
3221
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3222
|
+
type: "number",
|
|
3223
|
+
min: 0,
|
|
3224
|
+
step: "any",
|
|
3225
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3226
|
+
"aria-label": t("pricing.simBucketOutput"),
|
|
3227
|
+
value: buckets.outputTokens.amount,
|
|
3228
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3229
|
+
...previous,
|
|
3230
|
+
outputTokens: {
|
|
3231
|
+
...previous.outputTokens,
|
|
3232
|
+
amount: event.target.value
|
|
3233
|
+
}
|
|
3234
|
+
}))
|
|
3235
|
+
}),
|
|
3236
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3237
|
+
t,
|
|
3238
|
+
bucket: t("pricing.simBucketOutput"),
|
|
3239
|
+
unit: buckets.outputTokens.unit,
|
|
3240
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3241
|
+
...previous,
|
|
3242
|
+
outputTokens: {
|
|
3243
|
+
amount: convertBucketAmount(previous.outputTokens, unit),
|
|
3244
|
+
unit
|
|
3245
|
+
}
|
|
3246
|
+
}))
|
|
3247
|
+
})
|
|
3248
|
+
]
|
|
3249
|
+
}),
|
|
3250
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3251
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3252
|
+
children: [
|
|
3253
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3254
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3255
|
+
children: t("pricing.simBucketCacheWrite")
|
|
3256
|
+
}),
|
|
3257
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3258
|
+
type: "number",
|
|
3259
|
+
min: 0,
|
|
3260
|
+
step: "any",
|
|
3261
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3262
|
+
"aria-label": t("pricing.simBucketCacheWrite"),
|
|
3263
|
+
value: buckets.cacheWriteTokens.amount,
|
|
3264
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3265
|
+
...previous,
|
|
3266
|
+
cacheWriteTokens: {
|
|
3267
|
+
...previous.cacheWriteTokens,
|
|
3268
|
+
amount: event.target.value
|
|
3269
|
+
}
|
|
3270
|
+
}))
|
|
3271
|
+
}),
|
|
3272
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3273
|
+
t,
|
|
3274
|
+
bucket: t("pricing.simBucketCacheWrite"),
|
|
3275
|
+
unit: buckets.cacheWriteTokens.unit,
|
|
3276
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3277
|
+
...previous,
|
|
3278
|
+
cacheWriteTokens: {
|
|
3279
|
+
amount: convertBucketAmount(previous.cacheWriteTokens, unit),
|
|
3280
|
+
unit
|
|
3281
|
+
}
|
|
3282
|
+
}))
|
|
3283
|
+
})
|
|
3284
|
+
]
|
|
3285
|
+
})
|
|
3286
|
+
]
|
|
3287
|
+
}),
|
|
3288
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3289
|
+
className: PricingOverviewDialog_module_css_default["scenarios"],
|
|
3290
|
+
children: SIM_SCENARIOS.map((candidate, index) => {
|
|
3291
|
+
const label = scenarioLabel(candidate, t);
|
|
3292
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3293
|
+
type: "button",
|
|
3294
|
+
className: PricingOverviewDialog_module_css_default["scenario"],
|
|
3295
|
+
"aria-pressed": pressedCase === candidate,
|
|
3296
|
+
title: `${label.inputLine} ${label.outputLine}`,
|
|
3297
|
+
onClick: () => {
|
|
3298
|
+
setBuckets(bucketsOfCase(candidate));
|
|
3299
|
+
},
|
|
3300
|
+
children: t("pricing.simCase", { index: String(index + 1) })
|
|
3301
|
+
}, index);
|
|
3302
|
+
})
|
|
3303
|
+
}),
|
|
3304
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3305
|
+
className: PricingOverviewDialog_module_css_default["tableWrap"],
|
|
3306
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3307
|
+
className: PricingOverviewDialog_module_css_default["table"],
|
|
3308
|
+
"aria-label": t("pricing.table"),
|
|
3309
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3310
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3311
|
+
className: PricingOverviewDialog_module_css_default["modelHead"],
|
|
3312
|
+
children: t("filter.model")
|
|
3313
|
+
}),
|
|
3314
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
3315
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
3316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
3317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] }),
|
|
3318
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3319
|
+
type: "button",
|
|
3320
|
+
className: PricingOverviewDialog_module_css_default["sortHead"],
|
|
3321
|
+
onClick: () => {
|
|
3322
|
+
setSortMode((previous) => previous === "family" ? "cost-desc" : previous === "cost-desc" ? "cost-asc" : "family");
|
|
3323
|
+
},
|
|
3324
|
+
children: [t("pricing.simCost"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3325
|
+
className: sortMode === "family" ? `${PricingOverviewDialog_module_css_default["sortArrow"]} ${PricingOverviewDialog_module_css_default["sortArrowIdle"]}` : PricingOverviewDialog_module_css_default["sortArrow"],
|
|
3326
|
+
"aria-hidden": true,
|
|
3327
|
+
children: sortMode === "family" ? " ⇅" : sortMode === "cost-desc" ? " ▾" : " ▴"
|
|
3328
|
+
})]
|
|
3329
|
+
}) })
|
|
3330
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: rows.map(({ model, node, cost, specials }) => {
|
|
3331
|
+
const billed = billedRates(node.baseRates, view);
|
|
3332
|
+
const expanded = expandedId === model.modelId;
|
|
3333
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
3334
|
+
className: PricingOverviewDialog_module_css_default["modelRow"],
|
|
3335
|
+
role: "button",
|
|
3336
|
+
tabIndex: 0,
|
|
3337
|
+
"aria-label": t("pricing.view", { model: model.modelId }),
|
|
3338
|
+
onClick: () => setDetail(model),
|
|
3339
|
+
onKeyDown: (event) => {
|
|
3340
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3341
|
+
event.preventDefault();
|
|
3342
|
+
setDetail(model);
|
|
3343
|
+
}
|
|
3344
|
+
},
|
|
3345
|
+
children: [
|
|
3346
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3347
|
+
className: PricingOverviewDialog_module_css_default["modelCell"],
|
|
3348
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3349
|
+
className: PricingOverviewDialog_module_css_default["cellInner"],
|
|
3350
|
+
children: [
|
|
3351
|
+
specials.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3352
|
+
type: "button",
|
|
3353
|
+
className: PricingOverviewDialog_module_css_default["expandArrow"],
|
|
3354
|
+
"aria-expanded": expanded,
|
|
3355
|
+
"aria-label": t("pricing.expand"),
|
|
3356
|
+
onClick: (event) => {
|
|
3357
|
+
event.stopPropagation();
|
|
3358
|
+
setExpandedId((previous) => previous === model.modelId ? null : model.modelId);
|
|
3359
|
+
},
|
|
3360
|
+
children: expanded ? "▾" : "▸"
|
|
3361
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3362
|
+
className: PricingOverviewDialog_module_css_default["arrowGap"],
|
|
3363
|
+
"aria-hidden": true
|
|
3364
|
+
}),
|
|
3365
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3366
|
+
className: PricingOverviewDialog_module_css_default["modelName"],
|
|
3367
|
+
children: model.modelId
|
|
3368
|
+
}),
|
|
3369
|
+
usedModels.has(model.modelId) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3370
|
+
className: PricingOverviewDialog_module_css_default["usedTag"],
|
|
3371
|
+
children: t("pricing.used")
|
|
3372
|
+
}) : null
|
|
3373
|
+
]
|
|
3374
|
+
})
|
|
3375
|
+
}),
|
|
3376
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
3377
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
3378
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
3379
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite }),
|
|
3380
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatCost(cost, view) })
|
|
3381
|
+
]
|
|
3382
|
+
}), expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3383
|
+
className: PricingOverviewDialog_module_css_default["expansionRow"],
|
|
3384
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3385
|
+
colSpan: 6,
|
|
3386
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3387
|
+
className: PricingOverviewDialog_module_css_default["specialRows"],
|
|
3388
|
+
children: specials.map((special, index) => {
|
|
3389
|
+
const specialBilled = billedRates(special.tier?.rates ?? special.slot.rates, view);
|
|
3390
|
+
const label = special.kind === "tier" ? t("pricing.tier", { threshold: formatTokens(special.tier.threshold) }) : `${special.slot.label ?? t("pricing.peak")} ${special.slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
|
|
3391
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3392
|
+
className: PricingOverviewDialog_module_css_default["specialRow"],
|
|
3393
|
+
children: [
|
|
3394
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3395
|
+
className: PricingOverviewDialog_module_css_default["specialLabel"],
|
|
3396
|
+
children: label
|
|
3397
|
+
}),
|
|
3398
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3399
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3400
|
+
children: specialBilled.input
|
|
3401
|
+
}),
|
|
3402
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3403
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3404
|
+
children: specialBilled.output
|
|
3405
|
+
}),
|
|
3406
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3407
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3408
|
+
children: specialBilled.cacheRead
|
|
3409
|
+
}),
|
|
3410
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3411
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3412
|
+
children: specialBilled.cacheWrite
|
|
3413
|
+
}),
|
|
3414
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3415
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3416
|
+
children: formatCost(special.cost, view)
|
|
3417
|
+
})
|
|
3418
|
+
]
|
|
3419
|
+
}, index);
|
|
3420
|
+
})
|
|
3421
|
+
})
|
|
3422
|
+
})
|
|
3423
|
+
}) : null] }, model.modelId);
|
|
3424
|
+
}) })]
|
|
3425
|
+
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3426
|
+
className: PricingDialog_module_css_default["rateNote"],
|
|
3427
|
+
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
3428
|
+
}) : null]
|
|
3429
|
+
})
|
|
3430
|
+
] }) : null,
|
|
3431
|
+
detail !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
|
|
3432
|
+
model: detail.modelId,
|
|
3433
|
+
rules: detail.rules,
|
|
3434
|
+
view,
|
|
3435
|
+
onClose: () => setDetail(null),
|
|
3436
|
+
t
|
|
3437
|
+
}) : null
|
|
3438
|
+
]
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3441
|
+
//#endregion
|
|
3442
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\StatCard.module.css.mjs
|
|
3443
|
+
const css$4 = ".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}";
|
|
3444
|
+
const tagId$4 = "@laoyuehanni/dsh-token-usage/StatCard.module.css";
|
|
3445
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
3446
|
+
const tag = document.createElement("style");
|
|
3447
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
3448
|
+
tag.dataset.pluginCss = tagId$4;
|
|
3449
|
+
tag.textContent = css$4;
|
|
3450
|
+
document.head.appendChild(tag);
|
|
3451
|
+
}
|
|
3452
|
+
var StatCard_module_css_default = {
|
|
3453
|
+
"card": "F2LbNW_card",
|
|
3454
|
+
"cardLabel": "F2LbNW_cardLabel",
|
|
3455
|
+
"cardValue": "F2LbNW_cardValue",
|
|
3456
|
+
"cardValueMain": "F2LbNW_cardValueMain",
|
|
3457
|
+
"pill": "F2LbNW_pill",
|
|
3458
|
+
"pillWrap": "F2LbNW_pillWrap",
|
|
3459
|
+
"split": "F2LbNW_split",
|
|
3460
|
+
"splitFail": "F2LbNW_splitFail",
|
|
3461
|
+
"splitFailHead": "F2LbNW_splitFailHead",
|
|
3462
|
+
"splitOk": "F2LbNW_splitOk",
|
|
3463
|
+
"splitSep": "F2LbNW_splitSep"
|
|
3464
|
+
};
|
|
3465
|
+
//#endregion
|
|
3466
|
+
//#region src/client/StatCard.tsx
|
|
3467
|
+
/**
|
|
3468
|
+
* Render one stat card. The value uses the standard label-primary color.
|
|
3469
|
+
* The label clamps to one line and ellipsizes if the column is squeezed.
|
|
3470
|
+
*/
|
|
3471
|
+
function StatCard({ label, value }) {
|
|
3472
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3473
|
+
className: StatCard_module_css_default["card"],
|
|
3474
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3475
|
+
className: StatCard_module_css_default["cardLabel"],
|
|
3476
|
+
children: label
|
|
3477
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3478
|
+
className: StatCard_module_css_default["cardValue"],
|
|
3479
|
+
children: value
|
|
3480
|
+
})]
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Compact "失败 n" chip for the requests **card** only. Hovering or focusing
|
|
3485
|
+
* it lists `限流 ×count` per class. Zero failures render nothing. Per-model
|
|
3486
|
+
* tables do not use this — they print `A/B` via {@link RequestsCell}.
|
|
3487
|
+
*/
|
|
3488
|
+
function FailurePill({ failures, failuresByCode, t }) {
|
|
3489
|
+
if (failures === 0) return null;
|
|
3490
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3491
|
+
className: StatCard_module_css_default["pillWrap"],
|
|
3492
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3493
|
+
label: failuresTooltip(failuresByCode, t),
|
|
3494
|
+
side: "bottom",
|
|
3495
|
+
delayMs: 200,
|
|
3496
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3497
|
+
className: StatCard_module_css_default["pill"],
|
|
3498
|
+
tabIndex: 0,
|
|
3499
|
+
children: t("stat.failuresPill", { count: failures.toLocaleString() })
|
|
3500
|
+
})
|
|
3501
|
+
})
|
|
3502
|
+
});
|
|
3503
|
+
}
|
|
3504
|
+
/**
|
|
3505
|
+
* The requests tile both dashboards share: hero figure is the successful
|
|
3506
|
+
* count; a compact pill to its right carries the failure count.
|
|
3507
|
+
*/
|
|
3508
|
+
function RequestsStatCard({ requests, failures, failuresByCode, t }) {
|
|
3509
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
|
|
3510
|
+
label: t("stat.requests"),
|
|
3511
|
+
value: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3512
|
+
className: StatCard_module_css_default["cardValueMain"],
|
|
3513
|
+
children: requests.toLocaleString()
|
|
3514
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailurePill, {
|
|
3515
|
+
failures,
|
|
3516
|
+
failuresByCode,
|
|
3517
|
+
t
|
|
3518
|
+
})] })
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
/** Column header for the per-model success/fail split: same 3-track
|
|
3522
|
+
* grid as {@link RequestsCell} so the slash sits on the column midline. */
|
|
3523
|
+
function RequestsSplitHead({ t }) {
|
|
3524
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3525
|
+
className: StatCard_module_css_default["split"],
|
|
3526
|
+
children: [
|
|
3527
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3528
|
+
className: StatCard_module_css_default["splitOk"],
|
|
3529
|
+
children: t("stat.ok")
|
|
3530
|
+
}),
|
|
3531
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3532
|
+
className: StatCard_module_css_default["splitSep"],
|
|
3533
|
+
"aria-hidden": true,
|
|
3534
|
+
children: "/"
|
|
3535
|
+
}),
|
|
3536
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3537
|
+
className: StatCard_module_css_default["splitFailHead"],
|
|
3538
|
+
children: t("stat.fail")
|
|
3539
|
+
})
|
|
3540
|
+
]
|
|
3541
|
+
});
|
|
3542
|
+
}
|
|
3543
|
+
/** One table cell: successful count, and when failures > 0 a slash on
|
|
3544
|
+
* the column midline plus the failure count in the error color.
|
|
3545
|
+
* Zero failures print only A (same left track, so the figure still
|
|
3546
|
+
* lines up with rows that have a B). Hovering B lists the per-code
|
|
2680
3547
|
* breakdown. */
|
|
2681
3548
|
function RequestsCell({ requests, failures, failuresByCode, t }) {
|
|
2682
3549
|
const ok = requests.toLocaleString();
|
|
@@ -2716,6 +3583,272 @@ window.__ModuleLoader__.load({
|
|
|
2716
3583
|
});
|
|
2717
3584
|
}
|
|
2718
3585
|
//#endregion
|
|
3586
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\SessionTable.module.css.mjs
|
|
3587
|
+
const css$3 = ".DW1kVq_head{justify-content:flex-start;align-items:center;gap:8px;display:flex}.DW1kVq_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}.DW1kVq_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}.DW1kVq_segBtn:hover:not(.DW1kVq_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.DW1kVq_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.DW1kVq_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.DW1kVq_tableWrap{max-height:420px;overflow:auto}.DW1kVq_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:480px;font-size:12px}.DW1kVq_table th,.DW1kVq_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.DW1kVq_table th.DW1kVq_sessionHead,.DW1kVq_table td.DW1kVq_sessionCol{text-align:left;width:220px;max-width:220px}.DW1kVq_table td.DW1kVq_sessionIndent{padding-left:18px}.DW1kVq_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.DW1kVq_table td{color:var(--dsw-alias-label-primary)}.DW1kVq_sortBtn{font:inherit;color:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:none;padding:0;font-weight:500}.DW1kVq_sortBtn:hover{color:var(--dsw-alias-label-primary)}.DW1kVq_sortMark{margin-left:3px;font-size:9px}.DW1kVq_sessionCell{align-items:baseline;gap:4px;max-width:208px;display:inline-flex}.DW1kVq_sessionName{text-overflow:ellipsis;white-space:nowrap;font:inherit;color:inherit;text-align:left;background:0 0;border:none;max-width:100%;padding:0;overflow:hidden}.DW1kVq_jumpable{cursor:pointer;text-decoration:underline dashed;text-decoration-color:var(--dsw-alias-label-tertiary);text-underline-offset:3px}.DW1kVq_badge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:10px}.DW1kVq_dirTail{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;font-size:10px;display:block;overflow:hidden}.DW1kVq_table td.DW1kVq_groupRow{border-bottom:none;padding-top:8px}.DW1kVq_table td.DW1kVq_groupHead{color:var(--dsw-alias-label-secondary);text-align:left;white-space:nowrap;font-size:11px;font-weight:600}.DW1kVq_groupCount{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:6px}";
|
|
3588
|
+
const tagId$3 = "@laoyuehanni/dsh-token-usage/SessionTable.module.css";
|
|
3589
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
|
|
3590
|
+
const tag = document.createElement("style");
|
|
3591
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
3592
|
+
tag.dataset.pluginCss = tagId$3;
|
|
3593
|
+
tag.textContent = css$3;
|
|
3594
|
+
document.head.appendChild(tag);
|
|
3595
|
+
}
|
|
3596
|
+
var SessionTable_module_css_default = {
|
|
3597
|
+
"badge": "DW1kVq_badge",
|
|
3598
|
+
"dirTail": "DW1kVq_dirTail",
|
|
3599
|
+
"groupCount": "DW1kVq_groupCount",
|
|
3600
|
+
"groupHead": "DW1kVq_groupHead",
|
|
3601
|
+
"groupRow": "DW1kVq_groupRow",
|
|
3602
|
+
"head": "DW1kVq_head",
|
|
3603
|
+
"jumpable": "DW1kVq_jumpable",
|
|
3604
|
+
"segActive": "DW1kVq_segActive",
|
|
3605
|
+
"segBtn": "DW1kVq_segBtn",
|
|
3606
|
+
"segmented": "DW1kVq_segmented",
|
|
3607
|
+
"sessionCell": "DW1kVq_sessionCell",
|
|
3608
|
+
"sessionCol": "DW1kVq_sessionCol",
|
|
3609
|
+
"sessionHead": "DW1kVq_sessionHead",
|
|
3610
|
+
"sessionIndent": "DW1kVq_sessionIndent",
|
|
3611
|
+
"sessionName": "DW1kVq_sessionName",
|
|
3612
|
+
"sortBtn": "DW1kVq_sortBtn",
|
|
3613
|
+
"sortMark": "DW1kVq_sortMark",
|
|
3614
|
+
"table": "DW1kVq_table",
|
|
3615
|
+
"tableWrap": "DW1kVq_tableWrap"
|
|
3616
|
+
};
|
|
3617
|
+
//#endregion
|
|
3618
|
+
//#region src/client/SessionTable.tsx
|
|
3619
|
+
/**
|
|
3620
|
+
* The settings page's per-session detail table (browser half): the "by
|
|
3621
|
+
* session" mode of the detail-table block. Rows arrive FINAL from the host
|
|
3622
|
+
* route — folded over subagent subtrees (a subagent's only visibility here
|
|
3623
|
+
* is the row's child-count badge; the conversation view's subagent table
|
|
3624
|
+
* owns the per-child drill-down), cost-sorted, top-N truncated, with the
|
|
3625
|
+
* metadata index's titles and directories attached — so this component only
|
|
3626
|
+
* re-organizes presentation: the optional directory grouping (default on,
|
|
3627
|
+
* session-local, no request; grouped rows indent under their directory
|
|
3628
|
+
* head) and the identity fallback for titleless sessions (short id + time
|
|
3629
|
+
* span; the plugin never fabricates a title). Rows carry no click behavior,
|
|
3630
|
+
* matching the per-model table.
|
|
3631
|
+
*
|
|
3632
|
+
* @module token-usage/client/SessionTable
|
|
3633
|
+
*/
|
|
3634
|
+
/** The last path segment of a directory, on either separator. */
|
|
3635
|
+
function dirTailOf(cwd) {
|
|
3636
|
+
const parts = cwd.split(/[\\/]/u).filter((part) => part !== "");
|
|
3637
|
+
return parts[parts.length - 1] ?? cwd;
|
|
3638
|
+
}
|
|
3639
|
+
/** A short session-id fallback: the leading chunk is usually enough to
|
|
3640
|
+
* tell sessions apart when no title ever landed. */
|
|
3641
|
+
function shortIdOf(sessionId) {
|
|
3642
|
+
return sessionId.length > 8 ? `${sessionId.slice(0, 8)}…` : sessionId;
|
|
3643
|
+
}
|
|
3644
|
+
/** Browser-level grouping preference: localStorage, not per-component state —
|
|
3645
|
+
* a filter change unmounts this table (the section flips to its loading
|
|
3646
|
+
* branch), and the choice must survive that remount as well as reloads. */
|
|
3647
|
+
const SESSION_GROUPED_KEY = "dsh.token-usage.sessionGrouped";
|
|
3648
|
+
function readGroupedPreference() {
|
|
3649
|
+
if (typeof localStorage === "undefined") return true;
|
|
3650
|
+
try {
|
|
3651
|
+
return localStorage.getItem(SESSION_GROUPED_KEY) !== "0";
|
|
3652
|
+
} catch {
|
|
3653
|
+
return true;
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
function writeGroupedPreference(grouped) {
|
|
3657
|
+
try {
|
|
3658
|
+
if (grouped) localStorage.removeItem(SESSION_GROUPED_KEY);
|
|
3659
|
+
else localStorage.setItem(SESSION_GROUPED_KEY, "0");
|
|
3660
|
+
} catch {}
|
|
3661
|
+
}
|
|
3662
|
+
function sortValueOf(row, key) {
|
|
3663
|
+
if (key === "tokens") return totalTokens(row.totals);
|
|
3664
|
+
if (key === "cost") return row.cost;
|
|
3665
|
+
return row.lastTime;
|
|
3666
|
+
}
|
|
3667
|
+
function nextSort(current, key) {
|
|
3668
|
+
if (current?.key !== key) return {
|
|
3669
|
+
key,
|
|
3670
|
+
dir: "desc"
|
|
3671
|
+
};
|
|
3672
|
+
if (current.dir === "desc") return {
|
|
3673
|
+
key,
|
|
3674
|
+
dir: "asc"
|
|
3675
|
+
};
|
|
3676
|
+
return null;
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* Render the session table: the grouping switch above the table, optional
|
|
3680
|
+
* directory groups (rows indent under their group head), one row per
|
|
3681
|
+
* served session. The token / cost / last-active headers sort the rows
|
|
3682
|
+
* client-side within the served set (groups keep their directory order;
|
|
3683
|
+
* rows reorder inside each group). Holding Ctrl over a session title draws
|
|
3684
|
+
* a dashed underline and a click jumps to that session (the parent closes
|
|
3685
|
+
* the settings panel; the conversation view lands on the session's last
|
|
3686
|
+
* used tab) — rows the session controller does not list never invite it.
|
|
3687
|
+
* @param props - the served rows, the currency view, the session jump
|
|
3688
|
+
* seats (absent on tests / hosts without the controller), locale.
|
|
3689
|
+
*/
|
|
3690
|
+
function SessionTable({ rows, view, t, sessionListed, openSession }) {
|
|
3691
|
+
const [grouped, setGrouped] = (0, react.useState)(readGroupedPreference);
|
|
3692
|
+
const toggleGrouped = (next) => {
|
|
3693
|
+
setGrouped(next);
|
|
3694
|
+
writeGroupedPreference(next);
|
|
3695
|
+
};
|
|
3696
|
+
const [sort, setSort] = (0, react.useState)(null);
|
|
3697
|
+
const [ctrlHeld, setCtrlHeld] = (0, react.useState)(false);
|
|
3698
|
+
(0, react.useEffect)(() => {
|
|
3699
|
+
const down = (event) => {
|
|
3700
|
+
if (event.key === "Control") setCtrlHeld(true);
|
|
3701
|
+
};
|
|
3702
|
+
const up = (event) => {
|
|
3703
|
+
if (event.key === "Control") setCtrlHeld(false);
|
|
3704
|
+
};
|
|
3705
|
+
const blur = () => setCtrlHeld(false);
|
|
3706
|
+
window.addEventListener("keydown", down);
|
|
3707
|
+
window.addEventListener("keyup", up);
|
|
3708
|
+
window.addEventListener("blur", blur);
|
|
3709
|
+
return () => {
|
|
3710
|
+
window.removeEventListener("keydown", down);
|
|
3711
|
+
window.removeEventListener("keyup", up);
|
|
3712
|
+
window.removeEventListener("blur", blur);
|
|
3713
|
+
};
|
|
3714
|
+
}, []);
|
|
3715
|
+
const jumpable = (id) => ctrlHeld && sessionListed !== void 0 && openSession !== void 0 && sessionListed(id);
|
|
3716
|
+
const sorted = (0, react.useMemo)(() => {
|
|
3717
|
+
if (sort === null) return rows;
|
|
3718
|
+
const factor = sort.dir === "desc" ? -1 : 1;
|
|
3719
|
+
return [...rows].sort((left, right) => factor * (sortValueOf(left, sort.key) - sortValueOf(right, sort.key)) || (left.sessionId < right.sessionId ? -1 : 1));
|
|
3720
|
+
}, [rows, sort]);
|
|
3721
|
+
const groups = (0, react.useMemo)(() => {
|
|
3722
|
+
if (!grouped) return null;
|
|
3723
|
+
const map = /* @__PURE__ */ new Map();
|
|
3724
|
+
for (const row of sorted) {
|
|
3725
|
+
const key = row.cwd ?? "";
|
|
3726
|
+
const bucket = map.get(key) ?? [];
|
|
3727
|
+
bucket.push(row);
|
|
3728
|
+
map.set(key, bucket);
|
|
3729
|
+
}
|
|
3730
|
+
return [...map.entries()].sort((left, right) => {
|
|
3731
|
+
if (left[0] === "") return 1;
|
|
3732
|
+
if (right[0] === "") return -1;
|
|
3733
|
+
return left[0].localeCompare(right[0]);
|
|
3734
|
+
});
|
|
3735
|
+
}, [sorted, grouped]);
|
|
3736
|
+
/** One sortable header cell: the column name as the toggle, the current
|
|
3737
|
+
* direction marked and announced via aria-sort. */
|
|
3738
|
+
const sortHead = (key, label) => {
|
|
3739
|
+
const active = sort?.key === key;
|
|
3740
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3741
|
+
...active ? { "aria-sort": sort.dir === "desc" ? "descending" : "ascending" } : {},
|
|
3742
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3743
|
+
type: "button",
|
|
3744
|
+
className: SessionTable_module_css_default["sortBtn"],
|
|
3745
|
+
onClick: () => setSort((previous) => nextSort(previous, key)),
|
|
3746
|
+
children: [label, active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3747
|
+
className: SessionTable_module_css_default["sortMark"],
|
|
3748
|
+
children: sort.dir === "desc" ? "▼" : "▲"
|
|
3749
|
+
}) : null]
|
|
3750
|
+
})
|
|
3751
|
+
});
|
|
3752
|
+
};
|
|
3753
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3754
|
+
className: SessionTable_module_css_default["head"],
|
|
3755
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3756
|
+
className: SessionTable_module_css_default["segmented"],
|
|
3757
|
+
role: "group",
|
|
3758
|
+
"aria-label": t("session.group.label"),
|
|
3759
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3760
|
+
type: "button",
|
|
3761
|
+
className: grouped ? `${SessionTable_module_css_default["segBtn"]} ${SessionTable_module_css_default["segActive"]}` : SessionTable_module_css_default["segBtn"],
|
|
3762
|
+
"aria-pressed": grouped,
|
|
3763
|
+
onClick: () => toggleGrouped(true),
|
|
3764
|
+
children: t("session.group.on")
|
|
3765
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3766
|
+
type: "button",
|
|
3767
|
+
className: !grouped ? `${SessionTable_module_css_default["segBtn"]} ${SessionTable_module_css_default["segActive"]}` : SessionTable_module_css_default["segBtn"],
|
|
3768
|
+
"aria-pressed": !grouped,
|
|
3769
|
+
onClick: () => toggleGrouped(false),
|
|
3770
|
+
children: t("session.group.off")
|
|
3771
|
+
})]
|
|
3772
|
+
})
|
|
3773
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3774
|
+
className: SessionTable_module_css_default["tableWrap"],
|
|
3775
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3776
|
+
className: SessionTable_module_css_default["table"],
|
|
3777
|
+
"aria-label": t("bySession.title"),
|
|
3778
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3779
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3780
|
+
className: SessionTable_module_css_default["sessionHead"],
|
|
3781
|
+
children: t("session.titleCol")
|
|
3782
|
+
}),
|
|
3783
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3784
|
+
"aria-label": t("stat.successFail"),
|
|
3785
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
|
|
3786
|
+
}),
|
|
3787
|
+
sortHead("tokens", t("stat.totalTokens")),
|
|
3788
|
+
sortHead("cost", t("stat.cost")),
|
|
3789
|
+
sortHead("lastTime", t("session.lastActive"))
|
|
3790
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups === null ? sorted.map((row) => renderRow(row, false)) : groups.map(([cwd, groupRows]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FragmentGroup, {
|
|
3791
|
+
cwd,
|
|
3792
|
+
count: groupRows.length,
|
|
3793
|
+
t,
|
|
3794
|
+
children: groupRows.map((row) => renderRow(row, true))
|
|
3795
|
+
}, cwd === "" ? "\0" : cwd)) })]
|
|
3796
|
+
})
|
|
3797
|
+
})] });
|
|
3798
|
+
function renderRow(row, indented) {
|
|
3799
|
+
const jump = jumpable(row.sessionId);
|
|
3800
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3801
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
3802
|
+
className: indented ? `${SessionTable_module_css_default["sessionCol"]} ${SessionTable_module_css_default["sessionIndent"]}` : SessionTable_module_css_default["sessionCol"],
|
|
3803
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3804
|
+
className: SessionTable_module_css_default["sessionCell"],
|
|
3805
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3806
|
+
type: "button",
|
|
3807
|
+
className: jump ? `${SessionTable_module_css_default["sessionName"]} ${SessionTable_module_css_default["jumpable"]}` : SessionTable_module_css_default["sessionName"],
|
|
3808
|
+
title: jump ? t("session.openHint") : void 0,
|
|
3809
|
+
onClick: jump ? (event) => {
|
|
3810
|
+
event.preventDefault();
|
|
3811
|
+
openSession?.(row.sessionId);
|
|
3812
|
+
} : void 0,
|
|
3813
|
+
children: row.title !== void 0 ? row.title : `${shortIdOf(row.sessionId)} · ${dayKeyOf(new Date(row.firstTime))} – ${dayKeyOf(new Date(row.lastTime))}`
|
|
3814
|
+
}), row.childCount !== void 0 && row.childCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3815
|
+
className: SessionTable_module_css_default["badge"],
|
|
3816
|
+
"aria-label": t("view.subagents.nested", { count: String(row.childCount) }),
|
|
3817
|
+
children: t("view.subagents.nested", { count: String(row.childCount) })
|
|
3818
|
+
}) : null]
|
|
3819
|
+
}), !indented && row.cwd !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3820
|
+
className: SessionTable_module_css_default["dirTail"],
|
|
3821
|
+
children: dirTailOf(row.cwd)
|
|
3822
|
+
}) : null]
|
|
3823
|
+
}),
|
|
3824
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
|
|
3825
|
+
requests: row.totals.requests,
|
|
3826
|
+
failures: row.totals.failures ?? 0,
|
|
3827
|
+
failuresByCode: row.totals.failuresByCode,
|
|
3828
|
+
t
|
|
3829
|
+
}) }),
|
|
3830
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
|
|
3831
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatCost(row.cost, view) }),
|
|
3832
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: dayKeyOf(new Date(row.lastTime)) })
|
|
3833
|
+
] }, row.sessionId);
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
/** One directory group: a full-width head row with the directory tail, then
|
|
3837
|
+
* the group's rows (a keyed fragment keeps `<tr>`s table-legal). */
|
|
3838
|
+
function FragmentGroup({ cwd, count, t, children }) {
|
|
3839
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3840
|
+
className: SessionTable_module_css_default["groupRow"],
|
|
3841
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
3842
|
+
colSpan: 5,
|
|
3843
|
+
className: SessionTable_module_css_default["groupHead"],
|
|
3844
|
+
children: [cwd === "" ? t("session.untitledDir") : dirTailOf(cwd), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3845
|
+
className: SessionTable_module_css_default["groupCount"],
|
|
3846
|
+
children: String(count)
|
|
3847
|
+
})]
|
|
3848
|
+
})
|
|
3849
|
+
}), children] });
|
|
3850
|
+
}
|
|
3851
|
+
//#endregion
|
|
2719
3852
|
//#region src/client/trend-chart/axis.ts
|
|
2720
3853
|
/**
|
|
2721
3854
|
* Trend-chart axis helpers: the roundest step from 1/2/2.5/5 × 10ⁿ not
|
|
@@ -2753,6 +3886,46 @@ window.__ModuleLoader__.load({
|
|
|
2753
3886
|
};
|
|
2754
3887
|
}
|
|
2755
3888
|
//#endregion
|
|
3889
|
+
//#region src/client/trend-chart/path.ts
|
|
3890
|
+
/**
|
|
3891
|
+
* Per-segment gap flags: `flags[i]` is true when the next bucket starts
|
|
3892
|
+
* after this bucket's exclusive `end`. Adjacent uniform buckets have
|
|
3893
|
+
* `next.time === prev.end` and are not gaps.
|
|
3894
|
+
*/
|
|
3895
|
+
function gapAfter(points) {
|
|
3896
|
+
const flags = [];
|
|
3897
|
+
for (let index = 0; index < points.length - 1; index += 1) flags.push(points[index + 1].time > points[index].end);
|
|
3898
|
+
return flags;
|
|
3899
|
+
}
|
|
3900
|
+
/**
|
|
3901
|
+
* SVG `d` for already-scaled coordinates. Empty → `''`; one point → `M`.
|
|
3902
|
+
*
|
|
3903
|
+
* `gap` is the original polyline plus a patch: adjacent buckets stay a
|
|
3904
|
+
* straight `L`; a gap holds `hold` (`zero` = axis, `previous` = last y)
|
|
3905
|
+
* from the previous bucket's end until one bucket-width before the next
|
|
3906
|
+
* start, then slants in — so idle is not interpolated and dense hours
|
|
3907
|
+
* keep the polyline.
|
|
3908
|
+
*/
|
|
3909
|
+
function seriesPath(input) {
|
|
3910
|
+
const { xs, ys, yZero, style, hold, gaps, xEnds } = input;
|
|
3911
|
+
if (xs.length === 0) return "";
|
|
3912
|
+
const cmd = (letter, x, y) => `${letter}${x.toFixed(1)},${y.toFixed(1)}`;
|
|
3913
|
+
const parts = [cmd("M", xs[0], ys[0])];
|
|
3914
|
+
for (let index = 0; index < xs.length - 1; index += 1) {
|
|
3915
|
+
const xNext = xs[index + 1];
|
|
3916
|
+
const yNext = ys[index + 1];
|
|
3917
|
+
if (style === "gap" && gaps?.[index] === true) {
|
|
3918
|
+
const ends = xEnds ?? xs;
|
|
3919
|
+
const xEnd = ends[index];
|
|
3920
|
+
const nextWidth = Math.max(ends[index + 1] - xNext, 0);
|
|
3921
|
+
const xHold = Math.max(xEnd, xNext - nextWidth);
|
|
3922
|
+
const holdY = hold === "previous" ? ys[index] : yZero;
|
|
3923
|
+
parts.push(cmd("L", xEnd, holdY), cmd("L", xHold, holdY), cmd("L", xNext, yNext));
|
|
3924
|
+
} else parts.push(cmd("L", xNext, yNext));
|
|
3925
|
+
}
|
|
3926
|
+
return parts.join(" ");
|
|
3927
|
+
}
|
|
3928
|
+
//#endregion
|
|
2756
3929
|
//#region src/trend-bucket.ts
|
|
2757
3930
|
/**
|
|
2758
3931
|
* Bucket widths tried from fine to coarse (ms); the first whose bucket count
|
|
@@ -2853,6 +4026,7 @@ window.__ModuleLoader__.load({
|
|
|
2853
4026
|
full: `${bucketLabel(bucket.start, crossDay)}–${bucketLabel(bucket.end, crossDay)}`,
|
|
2854
4027
|
tokens: bucket.tokens,
|
|
2855
4028
|
time: bucket.start,
|
|
4029
|
+
end: bucket.end,
|
|
2856
4030
|
count: bucket.count
|
|
2857
4031
|
}))
|
|
2858
4032
|
};
|
|
@@ -2941,14 +4115,17 @@ window.__ModuleLoader__.load({
|
|
|
2941
4115
|
}
|
|
2942
4116
|
//#endregion
|
|
2943
4117
|
//#region src/client/trend-chart/scale.ts
|
|
4118
|
+
function clampX(value, leftEdge, rightEdge) {
|
|
4119
|
+
return Math.min(Math.max(value, leftEdge), rightEdge);
|
|
4120
|
+
}
|
|
2944
4121
|
/**
|
|
2945
4122
|
* Pick the right x scale for a {@link ChartSeries} and produce the
|
|
2946
4123
|
* per-point offsets in absolute viewBox coordinates. Equidistant modes
|
|
2947
4124
|
* lay points one stride apart across the `[leftEdge, rightEdge]` span;
|
|
2948
4125
|
* temporal mode uses each point's wall time against the series' own
|
|
2949
|
-
* first-to-
|
|
2950
|
-
*
|
|
2951
|
-
*
|
|
4126
|
+
* first-start to last-start span and adds `leftEdge` to the result.
|
|
4127
|
+
* A zero span (one point, or every start equal) pins to the centerline.
|
|
4128
|
+
* Temporal results include `xEnds` for the gap-path bucket width.
|
|
2952
4129
|
*
|
|
2953
4130
|
* @param series - the discriminated-union series from {@link buildChartPoints}.
|
|
2954
4131
|
* @param leftEdge - the absolute SVG x of the chart's left edge (the
|
|
@@ -2972,14 +4149,29 @@ window.__ModuleLoader__.load({
|
|
|
2972
4149
|
innerWidth
|
|
2973
4150
|
};
|
|
2974
4151
|
}
|
|
2975
|
-
const temporal = points;
|
|
4152
|
+
const temporal = series.points;
|
|
2976
4153
|
const first = temporal[0].time;
|
|
2977
|
-
const
|
|
4154
|
+
const lastStart = temporal[temporal.length - 1].time;
|
|
4155
|
+
if (temporal.length === 1 || first === lastStart) {
|
|
4156
|
+
const mid = (leftEdge + rightEdge) / 2;
|
|
4157
|
+
const xs = temporal.map(() => mid);
|
|
4158
|
+
return {
|
|
4159
|
+
xs,
|
|
4160
|
+
xEnds: [...xs],
|
|
4161
|
+
innerWidth
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
2978
4164
|
const xs = [];
|
|
2979
|
-
|
|
2980
|
-
|
|
4165
|
+
const xEnds = [];
|
|
4166
|
+
for (const point of temporal) {
|
|
4167
|
+
const x = clampX(leftEdge + scaleToSpan(first, lastStart, point.time, innerWidth), leftEdge, rightEdge);
|
|
4168
|
+
const xEnd = clampX(leftEdge + scaleToSpan(first, lastStart, point.end, innerWidth), leftEdge, rightEdge);
|
|
4169
|
+
xs.push(x);
|
|
4170
|
+
xEnds.push(Math.max(x, xEnd));
|
|
4171
|
+
}
|
|
2981
4172
|
return {
|
|
2982
4173
|
xs,
|
|
4174
|
+
xEnds,
|
|
2983
4175
|
innerWidth
|
|
2984
4176
|
};
|
|
2985
4177
|
}
|
|
@@ -3125,12 +4317,22 @@ window.__ModuleLoader__.load({
|
|
|
3125
4317
|
}));
|
|
3126
4318
|
const { top, ticks } = tickValues(Math.max(...points.map((p) => p.tokens)));
|
|
3127
4319
|
const innerHeight = 140;
|
|
3128
|
-
const { xs, innerWidth } = scaleSeries(series, LEFT, 784);
|
|
4320
|
+
const { xs, xEnds, innerWidth } = scaleSeries(series, LEFT, 784);
|
|
3129
4321
|
const radius = dotRadius(points.length);
|
|
3130
4322
|
const [active, setActive] = (0, react.useState)(null);
|
|
3131
4323
|
const activePoint = active === null ? null : points[active] ?? null;
|
|
3132
4324
|
const y = (tokens) => 152 - tokens / top * innerHeight;
|
|
3133
|
-
const path =
|
|
4325
|
+
const path = seriesPath({
|
|
4326
|
+
xs,
|
|
4327
|
+
ys: points.map((point) => y(point.tokens)),
|
|
4328
|
+
yZero: y(0),
|
|
4329
|
+
style: series.mode === "temporal" ? "gap" : "polyline",
|
|
4330
|
+
...series.mode === "temporal" ? {
|
|
4331
|
+
gaps: gapAfter(series.points),
|
|
4332
|
+
xEnds: xEnds ?? xs,
|
|
4333
|
+
hold: mode === "cumulative" ? "previous" : "zero"
|
|
4334
|
+
} : {}
|
|
4335
|
+
});
|
|
3134
4336
|
const chartAria = mode === "cumulative" ? t("chart.ariaCumulative") : series.mode === "temporal" ? t("chart.ariaRequests") : hours !== void 0 ? t("chart.ariaHour") : t("chart.aria");
|
|
3135
4337
|
const hitExtent = (index) => {
|
|
3136
4338
|
if (points.length === 1) return {
|
|
@@ -3244,7 +4446,7 @@ window.__ModuleLoader__.load({
|
|
|
3244
4446
|
}
|
|
3245
4447
|
//#endregion
|
|
3246
4448
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageSection.module.css.mjs
|
|
3247
|
-
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.
|
|
4449
|
+
const css$1 = ".RbkiSa_section{flex-direction:column;gap:16px;width:100%;display:flex}.RbkiSa_head{justify-content:space-between;align-items:center;gap:12px;display:flex}.RbkiSa_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}.RbkiSa_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}.RbkiSa_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}.RbkiSa_subtitle{color:var(--dsw-alias-label-secondary);margin:0;font-size:14px;font-weight:600}.RbkiSa_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}.RbkiSa_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}.RbkiSa_segBtn:hover:not(.RbkiSa_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}.RbkiSa_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}.RbkiSa_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.RbkiSa_tableWrap{max-height:420px;overflow:auto}.RbkiSa_table{border-collapse:collapse;font-variant-numeric:tabular-nums;width:100%;min-width:500px;font-size:12px}.RbkiSa_table th,.RbkiSa_table td{text-align:right;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap;padding:4px 6px}.RbkiSa_table th.RbkiSa_modelHead,.RbkiSa_table td.RbkiSa_modelCol{text-align:left;width:150px;max-width:150px}.RbkiSa_table th{color:var(--dsw-alias-label-secondary);z-index:1;background:var(--dsw-alias-bg-layer-2);font-weight:500;position:sticky;top:0}.RbkiSa_table td{color:var(--dsw-alias-label-primary)}.RbkiSa_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}.RbkiSa_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}.RbkiSa_button:hover{background:var(--dsw-interactive-bg-hover)}.RbkiSa_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}.RbkiSa_cards{grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px;display:grid}.RbkiSa_warning{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:6px;margin:0;padding:6px 10px;font-size:12px}.RbkiSa_modelCell{align-items:center;gap:4px;max-width:138px;display:inline-flex;position:relative}.RbkiSa_modelName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.RbkiSa_unpricedTag{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:8px;flex:none;padding:0 6px;font-size:10px;line-height:16px}.RbkiSa_pricingButton:hover{color:var(--dsw-alias-state-warn-primary);background:var(--dsw-alias-state-warn-tertiary);border-color:var(--dsw-alias-state-warn-primary)}.RbkiSa_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}.RbkiSa_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}";
|
|
3248
4450
|
const tagId$1 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
|
|
3249
4451
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
3250
4452
|
const tag = document.createElement("style");
|
|
@@ -3256,16 +4458,9 @@ window.__ModuleLoader__.load({
|
|
|
3256
4458
|
var TokenUsageSection_module_css_default = {
|
|
3257
4459
|
"button": "RbkiSa_button",
|
|
3258
4460
|
"cards": "RbkiSa_cards",
|
|
3259
|
-
"conditionCell": "RbkiSa_conditionCell",
|
|
3260
|
-
"conditionHead": "RbkiSa_conditionHead",
|
|
3261
|
-
"dialog": "RbkiSa_dialog",
|
|
3262
|
-
"dialogClose": "RbkiSa_dialogClose",
|
|
3263
|
-
"dialogHead": "RbkiSa_dialogHead",
|
|
3264
|
-
"dialogTitle": "RbkiSa_dialogTitle",
|
|
3265
4461
|
"empty": "RbkiSa_empty",
|
|
3266
4462
|
"error": "RbkiSa_error",
|
|
3267
4463
|
"filters": "RbkiSa_filters",
|
|
3268
|
-
"groupRow": "RbkiSa_groupRow",
|
|
3269
4464
|
"head": "RbkiSa_head",
|
|
3270
4465
|
"modelCell": "RbkiSa_modelCell",
|
|
3271
4466
|
"modelCol": "RbkiSa_modelCol",
|
|
@@ -3273,8 +4468,11 @@ window.__ModuleLoader__.load({
|
|
|
3273
4468
|
"modelName": "RbkiSa_modelName",
|
|
3274
4469
|
"muted": "RbkiSa_muted",
|
|
3275
4470
|
"pricingButton": "RbkiSa_pricingButton",
|
|
3276
|
-
"
|
|
4471
|
+
"pricingLink": "RbkiSa_pricingLink",
|
|
3277
4472
|
"section": "RbkiSa_section",
|
|
4473
|
+
"segActive": "RbkiSa_segActive",
|
|
4474
|
+
"segBtn": "RbkiSa_segBtn",
|
|
4475
|
+
"segmented": "RbkiSa_segmented",
|
|
3278
4476
|
"subtitle": "RbkiSa_subtitle",
|
|
3279
4477
|
"table": "RbkiSa_table",
|
|
3280
4478
|
"tableWrap": "RbkiSa_tableWrap",
|
|
@@ -3288,12 +4486,13 @@ window.__ModuleLoader__.load({
|
|
|
3288
4486
|
* Token-usage settings page (browser half): fetches the stats summary from
|
|
3289
4487
|
* the host route and renders the filter bar (inclusive day range, model
|
|
3290
4488
|
* select, 1d/7d/30d quick ranges where 1d spans today 00:00–23:59), the
|
|
3291
|
-
* total-usage strip, the daily-token trend chart, the per-model detail
|
|
3292
|
-
* table with the hit rate last
|
|
3293
|
-
*
|
|
3294
|
-
*
|
|
3295
|
-
*
|
|
3296
|
-
* the
|
|
4489
|
+
* total-usage strip, the daily-token trend chart, and the per-model detail
|
|
4490
|
+
* table with the hit rate last — all following the active filters. Each
|
|
4491
|
+
* priced model row's “定价” affordance opens that model's price dialog
|
|
4492
|
+
* (PricingDialog.tsx); the filter row's tail link opens the filter-free
|
|
4493
|
+
* pricing-overview dialog (PricingOverviewDialog.tsx). There is no refresh
|
|
4494
|
+
* button: entering the page or changing a filter refetches (the route
|
|
4495
|
+
* answers no-store); only the error state keeps a retry.
|
|
3297
4496
|
*
|
|
3298
4497
|
* @module token-usage/client/TokenUsageSection
|
|
3299
4498
|
*/
|
|
@@ -3336,157 +4535,6 @@ window.__ModuleLoader__.load({
|
|
|
3336
4535
|
const range = quickRange(days);
|
|
3337
4536
|
return filters.from === range.from && filters.to === range.to;
|
|
3338
4537
|
}
|
|
3339
|
-
/** The four base rates of one model as display text (symbol included,
|
|
3340
|
-
* converted for a USD view); a missing cache rate bills at the input rate. */
|
|
3341
|
-
function billedRates(rates, view) {
|
|
3342
|
-
return {
|
|
3343
|
-
input: formatRateWithSymbol(rates.inputPerMillion, view),
|
|
3344
|
-
output: formatRateWithSymbol(rates.outputPerMillion, view),
|
|
3345
|
-
cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
|
|
3346
|
-
cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
/** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
|
|
3350
|
-
function windowText(window) {
|
|
3351
|
-
const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
|
|
3352
|
-
return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
|
|
3353
|
-
}
|
|
3354
|
-
/** The when-it-applies text of one peak slot: its label plus its windows. */
|
|
3355
|
-
function slotCondition(slot, t) {
|
|
3356
|
-
return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
|
|
3357
|
-
}
|
|
3358
|
-
/**
|
|
3359
|
-
* The price rows of one rate node (a time rule's or the model root's): the
|
|
3360
|
-
* node's own base rates, then its peak slots, then its context tiers
|
|
3361
|
-
* (ascending), each tier followed by the peak slots hanging on that tier —
|
|
3362
|
-
* mirroring {@link resolveRate}'s node chain, where a matching tier's slots
|
|
3363
|
-
* replace the node's and peak rates replace the node's rates wholesale.
|
|
3364
|
-
*/
|
|
3365
|
-
function nodePriceRows(node, t) {
|
|
3366
|
-
const rows = [{
|
|
3367
|
-
condition: t("pricing.default"),
|
|
3368
|
-
rates: node.rates
|
|
3369
|
-
}];
|
|
3370
|
-
const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
|
|
3371
|
-
for (const tier of tiers) {
|
|
3372
|
-
const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
|
|
3373
|
-
rows.push({
|
|
3374
|
-
condition: tierCondition,
|
|
3375
|
-
rates: tier.rates
|
|
3376
|
-
});
|
|
3377
|
-
for (const slot of tier.dailySlots ?? []) rows.push({
|
|
3378
|
-
condition: `${tierCondition} · ${slotCondition(slot, t)}`,
|
|
3379
|
-
rates: slot.rates
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
for (const slot of node.slots ?? []) rows.push({
|
|
3383
|
-
condition: slotCondition(slot, t),
|
|
3384
|
-
rates: slot.rates
|
|
3385
|
-
});
|
|
3386
|
-
return rows;
|
|
3387
|
-
}
|
|
3388
|
-
/**
|
|
3389
|
-
* One model's price table: rows are billing conditions — grouped into the
|
|
3390
|
-
* model root (“常规”, omitted when it is the only group) and one group per
|
|
3391
|
-
* time rule with its date window — so tier, peak, and time-rule pricing
|
|
3392
|
-
* each show when they apply and what they bill. Shared by the pricing
|
|
3393
|
-
* dialog; the structure mirrors {@link resolveRate}'s node chain.
|
|
3394
|
-
*/
|
|
3395
|
-
function ModelPriceTable({ rules, view, t }) {
|
|
3396
|
-
const groups = [{
|
|
3397
|
-
title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
|
|
3398
|
-
rows: nodePriceRows({
|
|
3399
|
-
rates: rules.base,
|
|
3400
|
-
tiers: rules.contextTiers,
|
|
3401
|
-
slots: rules.dailySlots
|
|
3402
|
-
}, t)
|
|
3403
|
-
}, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
|
|
3404
|
-
title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
|
|
3405
|
-
rows: nodePriceRows({
|
|
3406
|
-
rates: rule.rates,
|
|
3407
|
-
tiers: rule.contextTiers,
|
|
3408
|
-
slots: rule.dailySlots
|
|
3409
|
-
}, t)
|
|
3410
|
-
}))];
|
|
3411
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3412
|
-
className: TokenUsageSection_module_css_default["tableWrap"],
|
|
3413
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3414
|
-
className: TokenUsageSection_module_css_default["table"],
|
|
3415
|
-
"aria-label": t("pricing.title"),
|
|
3416
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3417
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3418
|
-
className: TokenUsageSection_module_css_default["conditionHead"],
|
|
3419
|
-
children: t("pricing.condition")
|
|
3420
|
-
}),
|
|
3421
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
3422
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
3423
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
3424
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
|
|
3425
|
-
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3426
|
-
className: TokenUsageSection_module_css_default["groupRow"],
|
|
3427
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3428
|
-
colSpan: 5,
|
|
3429
|
-
children: group.title
|
|
3430
|
-
})
|
|
3431
|
-
}, group.title)] : [], ...group.rows.map((row, index) => {
|
|
3432
|
-
const billed = billedRates(row.rates, view);
|
|
3433
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3434
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3435
|
-
className: TokenUsageSection_module_css_default["conditionCell"],
|
|
3436
|
-
children: row.condition
|
|
3437
|
-
}),
|
|
3438
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
3439
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
3440
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
3441
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
|
|
3442
|
-
] }, `${group.title ?? ""}-${index}-${row.condition}`);
|
|
3443
|
-
})]) })]
|
|
3444
|
-
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3445
|
-
className: TokenUsageSection_module_css_default["rateNote"],
|
|
3446
|
-
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
3447
|
-
}) : null]
|
|
3448
|
-
});
|
|
3449
|
-
}
|
|
3450
|
-
/**
|
|
3451
|
-
* The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
|
|
3452
|
-
* is trapped, the backdrop dims, and the top layer renders it above the
|
|
3453
|
-
* table's scroll shell) opened by the “定价” affordance in a model row.
|
|
3454
|
-
* Mounts only while a model is selected; every close path funnels through
|
|
3455
|
-
* the dialog's `close` event, which clears the selection and unmounts it.
|
|
3456
|
-
*/
|
|
3457
|
-
function PricingDialog({ model, rules, view, onClose, t }) {
|
|
3458
|
-
const dialogRef = (0, react.useRef)(null);
|
|
3459
|
-
(0, react.useEffect)(() => {
|
|
3460
|
-
const dialog = dialogRef.current;
|
|
3461
|
-
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
3462
|
-
}, []);
|
|
3463
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
3464
|
-
ref: dialogRef,
|
|
3465
|
-
className: TokenUsageSection_module_css_default["dialog"],
|
|
3466
|
-
"aria-label": t("pricing.title"),
|
|
3467
|
-
onClose,
|
|
3468
|
-
onClick: (event) => {
|
|
3469
|
-
if (event.target === dialogRef.current) dialogRef.current?.close();
|
|
3470
|
-
},
|
|
3471
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3472
|
-
className: TokenUsageSection_module_css_default["dialogHead"],
|
|
3473
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3474
|
-
className: TokenUsageSection_module_css_default["dialogTitle"],
|
|
3475
|
-
children: model
|
|
3476
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3477
|
-
type: "button",
|
|
3478
|
-
className: TokenUsageSection_module_css_default["dialogClose"],
|
|
3479
|
-
"aria-label": t("pricing.close"),
|
|
3480
|
-
onClick: () => dialogRef.current?.close(),
|
|
3481
|
-
children: "✕"
|
|
3482
|
-
})]
|
|
3483
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
|
|
3484
|
-
rules,
|
|
3485
|
-
view,
|
|
3486
|
-
t
|
|
3487
|
-
})]
|
|
3488
|
-
});
|
|
3489
|
-
}
|
|
3490
4538
|
/** Quick-range menu entries (labels are locale-free day counts). */
|
|
3491
4539
|
const QUICK_OPTIONS = [
|
|
3492
4540
|
{
|
|
@@ -3503,8 +4551,9 @@ window.__ModuleLoader__.load({
|
|
|
3503
4551
|
}
|
|
3504
4552
|
];
|
|
3505
4553
|
/** The filter bar: quick range menu, day-range picker popover, model
|
|
3506
|
-
* menu — one row, one popover language.
|
|
3507
|
-
|
|
4554
|
+
* menu — one row, one popover language. The row's tail link is an action,
|
|
4555
|
+
* not a selector: it opens the filter-free pricing overview. */
|
|
4556
|
+
function FilterBar({ filters, models, onChange, onPricingTable, t }) {
|
|
3508
4557
|
const quickValue = QUICK_OPTIONS.find((option) => isQuickActive(Number(option.value), filters))?.value ?? (filters.from === "" && filters.to === "" ? "all" : "custom");
|
|
3509
4558
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3510
4559
|
className: TokenUsageSection_module_css_default["filters"],
|
|
@@ -3560,6 +4609,12 @@ window.__ModuleLoader__.load({
|
|
|
3560
4609
|
...filters,
|
|
3561
4610
|
model
|
|
3562
4611
|
})
|
|
4612
|
+
}),
|
|
4613
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4614
|
+
type: "button",
|
|
4615
|
+
className: TokenUsageSection_module_css_default["pricingLink"],
|
|
4616
|
+
onClick: onPricingTable,
|
|
4617
|
+
children: t("pricing.table")
|
|
3563
4618
|
})
|
|
3564
4619
|
]
|
|
3565
4620
|
});
|
|
@@ -3567,19 +4622,26 @@ window.__ModuleLoader__.load({
|
|
|
3567
4622
|
/**
|
|
3568
4623
|
* Render the Token Usage section content column. The `t` seat arrives from
|
|
3569
4624
|
* the registration's `locale:` declaration and follows the active locale.
|
|
3570
|
-
*
|
|
3571
|
-
*
|
|
4625
|
+
* The session jump seats (`sessionListed` / `openSession`) come from the
|
|
4626
|
+
* registration's `inject:` — the session table's Ctrl+click affordance
|
|
4627
|
+
* reads the controller's list and opens the target session.
|
|
4628
|
+
* @param props - the settings shell's owner share (close rides along to the
|
|
4629
|
+
* session jump: the jump closes the panel) plus the injected jump seats and
|
|
4630
|
+
* the framework-injected translate seat.
|
|
3572
4631
|
* @returns the section, one of loading / error / ready.
|
|
3573
4632
|
*/
|
|
3574
|
-
function TokenUsageSection({ t }) {
|
|
4633
|
+
function TokenUsageSection({ t, close, sessionListed, openSession }) {
|
|
3575
4634
|
const rootRef = (0, react.useRef)(null);
|
|
3576
4635
|
useColorSchemeMirror(rootRef);
|
|
3577
4636
|
const [filters, setFilters] = (0, react.useState)(() => ({
|
|
3578
4637
|
model: "",
|
|
3579
4638
|
...quickRange(1)
|
|
3580
4639
|
}));
|
|
4640
|
+
const [detailMode, setDetailMode] = (0, react.useState)("model");
|
|
3581
4641
|
const [models, setModels] = (0, react.useState)([]);
|
|
3582
4642
|
const [detailModel, setDetailModel] = (0, react.useState)(null);
|
|
4643
|
+
const [pricingTableOpen, setPricingTableOpen] = (0, react.useState)(false);
|
|
4644
|
+
const [usedSnapshot, setUsedSnapshot] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
3583
4645
|
const [retryToken, setRetryToken] = (0, react.useState)(0);
|
|
3584
4646
|
const retry = (0, react.useCallback)(() => {
|
|
3585
4647
|
setRetryToken((previous) => previous + 1);
|
|
@@ -3651,8 +4713,18 @@ window.__ModuleLoader__.load({
|
|
|
3651
4713
|
filters,
|
|
3652
4714
|
models,
|
|
3653
4715
|
onChange: setFilters,
|
|
4716
|
+
onPricingTable: () => {
|
|
4717
|
+
setUsedSnapshot(new Set(state.value.byModel.map((row) => row.model)));
|
|
4718
|
+
setPricingTableOpen(true);
|
|
4719
|
+
},
|
|
3654
4720
|
t
|
|
3655
4721
|
}),
|
|
4722
|
+
pricingTableOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingOverviewDialog, {
|
|
4723
|
+
usedModels: usedSnapshot,
|
|
4724
|
+
view,
|
|
4725
|
+
onClose: () => setPricingTableOpen(false),
|
|
4726
|
+
t
|
|
4727
|
+
}) : null,
|
|
3656
4728
|
total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3657
4729
|
className: TokenUsageSection_module_css_default["empty"],
|
|
3658
4730
|
children: t("empty")
|
|
@@ -3717,10 +4789,24 @@ window.__ModuleLoader__.load({
|
|
|
3717
4789
|
...filters.to !== "" ? { to: filters.to } : {},
|
|
3718
4790
|
...filters.from !== "" && filters.from === filters.to ? { hours: state.value.byHour } : {}
|
|
3719
4791
|
}),
|
|
3720
|
-
state.value.byModel.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
3721
|
-
className: TokenUsageSection_module_css_default["
|
|
3722
|
-
|
|
3723
|
-
|
|
4792
|
+
state.value.byModel.length > 0 || (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4793
|
+
className: TokenUsageSection_module_css_default["segmented"],
|
|
4794
|
+
role: "group",
|
|
4795
|
+
"aria-label": t("detail.switch.label"),
|
|
4796
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4797
|
+
type: "button",
|
|
4798
|
+
className: detailMode === "model" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
|
|
4799
|
+
"aria-pressed": detailMode === "model",
|
|
4800
|
+
onClick: () => setDetailMode("model"),
|
|
4801
|
+
children: t("byModel.title")
|
|
4802
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4803
|
+
type: "button",
|
|
4804
|
+
className: detailMode === "session" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
|
|
4805
|
+
"aria-pressed": detailMode === "session",
|
|
4806
|
+
onClick: () => setDetailMode("session"),
|
|
4807
|
+
children: t("bySession.title")
|
|
4808
|
+
})]
|
|
4809
|
+
}), detailMode === "model" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3724
4810
|
className: TokenUsageSection_module_css_default["tableWrap"],
|
|
3725
4811
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3726
4812
|
className: TokenUsageSection_module_css_default["table"],
|
|
@@ -3779,6 +4865,19 @@ window.__ModuleLoader__.load({
|
|
|
3779
4865
|
] }, row.model);
|
|
3780
4866
|
}) })]
|
|
3781
4867
|
})
|
|
4868
|
+
}) : (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionTable, {
|
|
4869
|
+
rows: state.value.sessionRows ?? [],
|
|
4870
|
+
view,
|
|
4871
|
+
t,
|
|
4872
|
+
...sessionListed !== void 0 && openSession !== void 0 ? {
|
|
4873
|
+
sessionListed,
|
|
4874
|
+
openSession: (id) => {
|
|
4875
|
+
if (openSession(id)) close();
|
|
4876
|
+
}
|
|
4877
|
+
} : {}
|
|
4878
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4879
|
+
className: TokenUsageSection_module_css_default["muted"],
|
|
4880
|
+
children: t("chart.empty")
|
|
3782
4881
|
})] }) : null,
|
|
3783
4882
|
detailModel !== null && state.value.pricing[detailModel] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
|
|
3784
4883
|
model: detailModel,
|
|
@@ -3793,7 +4892,7 @@ window.__ModuleLoader__.load({
|
|
|
3793
4892
|
}
|
|
3794
4893
|
//#endregion
|
|
3795
4894
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\UsageView.module.css.mjs
|
|
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}}";
|
|
4895
|
+
const css = "._0MkXVa_root{box-sizing:border-box;width:100%;padding:12px calc(var(--dsh-composer-side-clearance,16px) + 16px);padding-bottom:calc(var(--dsh-composer-height,152px) + 16px);flex-direction:column;gap:12px;max-width:1400px;height:100%;min-height:0;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}}";
|
|
3797
4896
|
const tagId = "@laoyuehanni/dsh-token-usage/UsageView.module.css";
|
|
3798
4897
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
3799
4898
|
const tag = document.createElement("style");
|
|
@@ -3852,12 +4951,21 @@ window.__ModuleLoader__.load({
|
|
|
3852
4951
|
* the whole log including history written before this plugin was installed.
|
|
3853
4952
|
* A footnote states the two scopes so the difference is not a surprise.
|
|
3854
4953
|
*
|
|
4954
|
+
* The root declares `data-conversation-composer-overlay` — the same host
|
|
4955
|
+
* opt-in Trajectory uses. ConversationRoot hides the chat-column width
|
|
4956
|
+
* handles when that attribute is present, and the view owns its own
|
|
4957
|
+
* scroller instead of sharing the transcript's constrained column.
|
|
4958
|
+
*
|
|
3855
4959
|
* @module token-usage/client/UsageView
|
|
3856
4960
|
*/
|
|
3857
4961
|
/** Refresh debounce: bursts of session-mirror updates (one request's events)
|
|
3858
4962
|
* collapse into a single fetch, so the dashboard refreshes at REQUEST
|
|
3859
4963
|
* granularity instead of per event or per turn. */
|
|
3860
4964
|
const REFRESH_DEBOUNCE_MS = 250;
|
|
4965
|
+
/** Host contract (ui-conversation ConversationRoot): views that own a
|
|
4966
|
+
* full-bleed scroller set this so the chat-column width handles hide and
|
|
4967
|
+
* the composer seat overlays instead of stealing clicks over the dashboard. */
|
|
4968
|
+
const COMPOSER_OVERLAY = { "data-conversation-composer-overlay": "" };
|
|
3861
4969
|
/** One fetch of the session-scoped summary from the host stats route,
|
|
3862
4970
|
* including the direct-child breakdown for the subagent table. */
|
|
3863
4971
|
function fetchSessionSummary(sessionIds, childGroups, signal) {
|
|
@@ -3967,6 +5075,7 @@ window.__ModuleLoader__.load({
|
|
|
3967
5075
|
if (summaryState.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3968
5076
|
ref: rootRef,
|
|
3969
5077
|
className: UsageView_module_css_default["root"],
|
|
5078
|
+
...COMPOSER_OVERLAY,
|
|
3970
5079
|
children: [header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3971
5080
|
className: UsageView_module_css_default["muted"],
|
|
3972
5081
|
children: t("loading")
|
|
@@ -3975,6 +5084,7 @@ window.__ModuleLoader__.load({
|
|
|
3975
5084
|
if (summaryState.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3976
5085
|
ref: rootRef,
|
|
3977
5086
|
className: UsageView_module_css_default["root"],
|
|
5087
|
+
...COMPOSER_OVERLAY,
|
|
3978
5088
|
children: [
|
|
3979
5089
|
header,
|
|
3980
5090
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -3995,6 +5105,7 @@ window.__ModuleLoader__.load({
|
|
|
3995
5105
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3996
5106
|
ref: rootRef,
|
|
3997
5107
|
className: UsageView_module_css_default["root"],
|
|
5108
|
+
...COMPOSER_OVERLAY,
|
|
3998
5109
|
children: [
|
|
3999
5110
|
header,
|
|
4000
5111
|
total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -4286,6 +5397,16 @@ window.__ModuleLoader__.load({
|
|
|
4286
5397
|
"stat.cacheRead": "缓",
|
|
4287
5398
|
"stat.cacheWrite": "写",
|
|
4288
5399
|
"byModel.title": "按模型",
|
|
5400
|
+
"bySession.title": "按会话",
|
|
5401
|
+
"detail.switch.label": "明细维度",
|
|
5402
|
+
"session.titleCol": "会话",
|
|
5403
|
+
"session.group.label": "目录分组",
|
|
5404
|
+
"session.group.on": "分组",
|
|
5405
|
+
"session.group.off": "列表",
|
|
5406
|
+
"session.untitledDir": "未指定目录",
|
|
5407
|
+
"session.subagentBadge": "子会话",
|
|
5408
|
+
"session.lastActive": "最近活跃",
|
|
5409
|
+
"session.openHint": "按住 Ctrl 点击打开该会话(用量页签跟随该会话上次的选择)",
|
|
4289
5410
|
"pricing.title": "模型定价",
|
|
4290
5411
|
"pricing.view": "查看 {model} 定价",
|
|
4291
5412
|
"pricing.viewShort": "定价",
|
|
@@ -4303,6 +5424,21 @@ window.__ModuleLoader__.load({
|
|
|
4303
5424
|
"pricing.exchangeRateNote": "按 1 USD = {rate} CNY 换算",
|
|
4304
5425
|
"pricing.unpriced": "未定价",
|
|
4305
5426
|
"pricing.windowSep": "、",
|
|
5427
|
+
"pricing.table": "定价表",
|
|
5428
|
+
"pricing.search": "搜索模型",
|
|
5429
|
+
"pricing.used": "已用",
|
|
5430
|
+
"pricing.overviewFailed": "模型定价获取失败",
|
|
5431
|
+
"pricing.simCost": "模拟费用",
|
|
5432
|
+
"pricing.simInput": "输入 {tokens}",
|
|
5433
|
+
"pricing.simCache": "(缓存 {pct}%)",
|
|
5434
|
+
"pricing.simOutput": "输出 {tokens}",
|
|
5435
|
+
"pricing.simBucketInput": "输入",
|
|
5436
|
+
"pricing.simBucketCacheRead": "缓存读",
|
|
5437
|
+
"pricing.simBucketOutput": "输出",
|
|
5438
|
+
"pricing.simBucketCacheWrite": "缓存写",
|
|
5439
|
+
"pricing.simCase": "案例{index}",
|
|
5440
|
+
"pricing.simUnitOf": "{bucket}({unit})",
|
|
5441
|
+
"pricing.expand": "展开定价条件",
|
|
4306
5442
|
"unpriced.warning": "{count} 个模型未定价:{models}(费用按 {zero} 计)",
|
|
4307
5443
|
"dataDir": "数据目录:{path}",
|
|
4308
5444
|
"card.title": "Token 用量",
|
|
@@ -4426,6 +5562,16 @@ window.__ModuleLoader__.load({
|
|
|
4426
5562
|
"stat.cacheRead": "Cache",
|
|
4427
5563
|
"stat.cacheWrite": "Write",
|
|
4428
5564
|
"byModel.title": "By model",
|
|
5565
|
+
"bySession.title": "By session",
|
|
5566
|
+
"detail.switch.label": "Detail dimension",
|
|
5567
|
+
"session.titleCol": "Session",
|
|
5568
|
+
"session.group.label": "Directory grouping",
|
|
5569
|
+
"session.group.on": "Grouped",
|
|
5570
|
+
"session.group.off": "List",
|
|
5571
|
+
"session.untitledDir": "No directory",
|
|
5572
|
+
"session.subagentBadge": "Subagent",
|
|
5573
|
+
"session.lastActive": "Last active",
|
|
5574
|
+
"session.openHint": "Ctrl+click to open this session (the usage tab follows its last selection)",
|
|
4429
5575
|
"pricing.title": "Model pricing",
|
|
4430
5576
|
"pricing.view": "View rates for {model}",
|
|
4431
5577
|
"pricing.viewShort": "Rates",
|
|
@@ -4443,6 +5589,21 @@ window.__ModuleLoader__.load({
|
|
|
4443
5589
|
"pricing.exchangeRateNote": "Converted at 1 USD = {rate} CNY",
|
|
4444
5590
|
"pricing.unpriced": "Unpriced",
|
|
4445
5591
|
"pricing.windowSep": ", ",
|
|
5592
|
+
"pricing.table": "Pricing",
|
|
5593
|
+
"pricing.search": "Search models",
|
|
5594
|
+
"pricing.used": "Used",
|
|
5595
|
+
"pricing.overviewFailed": "Failed to load model pricing",
|
|
5596
|
+
"pricing.simCost": "Est. cost",
|
|
5597
|
+
"pricing.simInput": "In {tokens}",
|
|
5598
|
+
"pricing.simCache": " (cache {pct}%)",
|
|
5599
|
+
"pricing.simOutput": "Out {tokens}",
|
|
5600
|
+
"pricing.simBucketInput": "Input",
|
|
5601
|
+
"pricing.simBucketCacheRead": "Cache read",
|
|
5602
|
+
"pricing.simBucketOutput": "Output",
|
|
5603
|
+
"pricing.simBucketCacheWrite": "Cache write",
|
|
5604
|
+
"pricing.simCase": "Case {index}",
|
|
5605
|
+
"pricing.simUnitOf": "{bucket} ({unit})",
|
|
5606
|
+
"pricing.expand": "Show rate conditions",
|
|
4446
5607
|
"unpriced.warning": "{count} models unpriced: {models} (cost counts as {zero})",
|
|
4447
5608
|
"dataDir": "Data directory: {path}",
|
|
4448
5609
|
"card.title": "Token Usage",
|
|
@@ -4531,15 +5692,17 @@ window.__ModuleLoader__.load({
|
|
|
4531
5692
|
*/
|
|
4532
5693
|
const TOKEN_USAGE_NS = "token-usage";
|
|
4533
5694
|
/** Required services: the slot registry, the locale dictionaries, the
|
|
4534
|
-
* settings scope,
|
|
4535
|
-
* backs the card's browse button)
|
|
5695
|
+
* settings scope, the workspace navigation service (its native directory
|
|
5696
|
+
* picker backs the card's browse button), and the session controller (the
|
|
5697
|
+
* stats page's Ctrl+click session jump reads the list and opens the target). */
|
|
4536
5698
|
const inject = [
|
|
4537
5699
|
"slots",
|
|
4538
5700
|
"locale",
|
|
4539
5701
|
"connection",
|
|
4540
5702
|
"remote",
|
|
4541
5703
|
"settingsScope",
|
|
4542
|
-
"
|
|
5704
|
+
"uiWorkspace",
|
|
5705
|
+
"sessions"
|
|
4543
5706
|
];
|
|
4544
5707
|
/**
|
|
4545
5708
|
* Register the dictionary pair, then the settings page and the plugin
|
|
@@ -4552,12 +5715,23 @@ window.__ModuleLoader__.load({
|
|
|
4552
5715
|
en
|
|
4553
5716
|
}), "token-usage: dictionaries");
|
|
4554
5717
|
const t = ctx.locale.bind(NS);
|
|
5718
|
+
const clientSessions = ctx.sessions;
|
|
5719
|
+
const sessionListed = (id) => clientSessions.list.getSnapshot().byId[id] !== void 0;
|
|
5720
|
+
const openSession = (id) => {
|
|
5721
|
+
if (!sessionListed(id)) return false;
|
|
5722
|
+
clientSessions.open(id);
|
|
5723
|
+
return true;
|
|
5724
|
+
};
|
|
4555
5725
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
4556
5726
|
name: "settings.section",
|
|
4557
5727
|
id: "token-usage",
|
|
4558
5728
|
order: 50,
|
|
4559
5729
|
label: () => t("nav.label"),
|
|
4560
|
-
locale: NS
|
|
5730
|
+
locale: NS,
|
|
5731
|
+
inject: () => ({
|
|
5732
|
+
sessionListed,
|
|
5733
|
+
openSession
|
|
5734
|
+
})
|
|
4561
5735
|
}, TokenUsageSection));
|
|
4562
5736
|
ctx.slots.inject("conversation.view", () => ctx.slots.register({
|
|
4563
5737
|
name: "conversation.view",
|
|
@@ -4597,7 +5771,7 @@ window.__ModuleLoader__.load({
|
|
|
4597
5771
|
inject: () => ({
|
|
4598
5772
|
hooks: { tokenUsageCard: store },
|
|
4599
5773
|
...form.actions(),
|
|
4600
|
-
pickDirectory: () => ctx.
|
|
5774
|
+
pickDirectory: () => ctx.uiWorkspace.pickDirectory()
|
|
4601
5775
|
})
|
|
4602
5776
|
}, TokenUsageCard));
|
|
4603
5777
|
}
|