@laoyuehanni/dsh-token-usage 0.4.1 → 0.4.3
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 +4 -12
- package/README.zh.md +4 -12
- 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/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/TokenUsageCard.d.ts.map +1 -1
- package/lib/client/TokenUsageCard.js +4 -1
- package/lib/client/TokenUsageCard.js.map +1 -1
- package/lib/client/TokenUsageSection.d.ts +17 -9
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +67 -127
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/format.d.ts.map +1 -1
- package/lib/client/format.js +12 -4
- package/lib/client/format.js.map +1 -1
- package/lib/client/index.d.ts +3 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +23 -3
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +35 -2
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +70 -4
- package/lib/client/locales.js.map +1 -1
- package/lib/client.js +1438 -317
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +59 -20
- 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 +63 -21
- package/lib/pricing.d.ts.map +1 -1
- package/lib/pricing.js +82 -53
- 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 +93 -12
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts +57 -11
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +239 -26
- 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 +122 -15
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +142 -20
- package/lib/sync.js.map +1 -1
- package/lib/usage-log.d.ts +35 -0
- package/lib/usage-log.d.ts.map +1 -1
- package/lib/usage-log.js +111 -0
- package/lib/usage-log.js.map +1 -1
- package/lib/wire.d.ts +117 -11
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js +4 -1
- package/lib/wire.js.map +1 -1
- package/package.json +1 -1
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("&");
|
|
@@ -50,7 +53,7 @@ window.__ModuleLoader__.load({
|
|
|
50
53
|
/**
|
|
51
54
|
* The full-sync endpoint path: the card's manual "scan again" affordance.
|
|
52
55
|
* `POST` starts one full scan over every session log (the same scan the
|
|
53
|
-
* one-shot startup sync ran on first install — list +
|
|
56
|
+
* one-shot startup sync ran on first install — list + read + dedupe), and
|
|
54
57
|
* `GET` returns the live progress. The scan is fire-and-forget on the host
|
|
55
58
|
* side, so the card polls while it runs.
|
|
56
59
|
*/
|
|
@@ -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 = {
|
|
@@ -1053,14 +1056,22 @@ window.__ModuleLoader__.load({
|
|
|
1053
1056
|
/** Known `LlmFailure.code`s that have a `fail.*` locale label. An unknown
|
|
1054
1057
|
* future code is not in this map and the tooltip renders it verbatim. */
|
|
1055
1058
|
const FAILURE_CODE_LABEL_KEYS = {
|
|
1059
|
+
ABORTED: "fail.ABORTED",
|
|
1060
|
+
AUTH: "fail.AUTH",
|
|
1061
|
+
CONTEXT_WINDOW_EXCEEDED: "fail.CONTEXT_WINDOW_EXCEEDED",
|
|
1062
|
+
EMPTY_RESPONSE: "fail.EMPTY_RESPONSE",
|
|
1063
|
+
FILES_API: "fail.FILES_API",
|
|
1064
|
+
INVALID_CREDENTIAL: "fail.INVALID_CREDENTIAL",
|
|
1065
|
+
INVALID_REQUEST: "fail.INVALID_REQUEST",
|
|
1066
|
+
MALFORMED_RESPONSE: "fail.MALFORMED_RESPONSE",
|
|
1067
|
+
MISSING_CREDENTIAL: "fail.MISSING_CREDENTIAL",
|
|
1068
|
+
QUOTA: "fail.QUOTA",
|
|
1056
1069
|
RATE_LIMIT: "fail.RATE_LIMIT",
|
|
1070
|
+
REQUEST_EXTENSION: "fail.REQUEST_EXTENSION",
|
|
1057
1071
|
SERVER: "fail.SERVER",
|
|
1072
|
+
STREAM_CLOSED: "fail.STREAM_CLOSED",
|
|
1058
1073
|
TIMEOUT: "fail.TIMEOUT",
|
|
1059
1074
|
TRANSPORT: "fail.TRANSPORT",
|
|
1060
|
-
EMPTY_RESPONSE: "fail.EMPTY_RESPONSE",
|
|
1061
|
-
QUOTA: "fail.QUOTA",
|
|
1062
|
-
CONTEXT_WINDOW_EXCEEDED: "fail.CONTEXT_WINDOW_EXCEEDED",
|
|
1063
|
-
INVALID_CREDENTIAL: "fail.INVALID_CREDENTIAL",
|
|
1064
1075
|
UNKNOWN: "fail.UNKNOWN"
|
|
1065
1076
|
};
|
|
1066
1077
|
/** One decimal below 10, integer otherwise, trailing `.0` stripped. */
|
|
@@ -1227,13 +1238,13 @@ window.__ModuleLoader__.load({
|
|
|
1227
1238
|
}
|
|
1228
1239
|
//#endregion
|
|
1229
1240
|
//#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$
|
|
1241
|
+
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)}";
|
|
1242
|
+
const tagId$11 = "@laoyuehanni/dsh-token-usage/hit-rate-band.module.css";
|
|
1243
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$11) + "]") === null) {
|
|
1233
1244
|
const tag = document.createElement("style");
|
|
1234
1245
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1235
|
-
tag.dataset.pluginCss = tagId$
|
|
1236
|
-
tag.textContent = css$
|
|
1246
|
+
tag.dataset.pluginCss = tagId$11;
|
|
1247
|
+
tag.textContent = css$11;
|
|
1237
1248
|
document.head.appendChild(tag);
|
|
1238
1249
|
}
|
|
1239
1250
|
var hit_rate_band_module_css_default = {
|
|
@@ -1453,13 +1464,13 @@ window.__ModuleLoader__.load({
|
|
|
1453
1464
|
}
|
|
1454
1465
|
//#endregion
|
|
1455
1466
|
//#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$
|
|
1467
|
+
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}}";
|
|
1468
|
+
const tagId$10 = "@laoyuehanni/dsh-token-usage/SessionStatsChip.module.css";
|
|
1469
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
|
|
1459
1470
|
const tag = document.createElement("style");
|
|
1460
1471
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1461
|
-
tag.dataset.pluginCss = tagId$
|
|
1462
|
-
tag.textContent = css$
|
|
1472
|
+
tag.dataset.pluginCss = tagId$10;
|
|
1473
|
+
tag.textContent = css$10;
|
|
1463
1474
|
document.head.appendChild(tag);
|
|
1464
1475
|
}
|
|
1465
1476
|
var SessionStatsChip_module_css_default = {
|
|
@@ -1795,13 +1806,13 @@ window.__ModuleLoader__.load({
|
|
|
1795
1806
|
}
|
|
1796
1807
|
//#endregion
|
|
1797
1808
|
//#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$
|
|
1809
|
+
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}";
|
|
1810
|
+
const tagId$9 = "@laoyuehanni/dsh-token-usage/TokenUsageCard.module.css";
|
|
1811
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$9) + "]") === null) {
|
|
1801
1812
|
const tag = document.createElement("style");
|
|
1802
1813
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1803
|
-
tag.dataset.pluginCss = tagId$
|
|
1804
|
-
tag.textContent = css$
|
|
1814
|
+
tag.dataset.pluginCss = tagId$9;
|
|
1815
|
+
tag.textContent = css$9;
|
|
1805
1816
|
document.head.appendChild(tag);
|
|
1806
1817
|
}
|
|
1807
1818
|
var TokenUsageCard_module_css_default = {
|
|
@@ -1910,6 +1921,7 @@ window.__ModuleLoader__.load({
|
|
|
1910
1921
|
total: body.total,
|
|
1911
1922
|
added: body.added,
|
|
1912
1923
|
skipped: body.skipped,
|
|
1924
|
+
removed: typeof body.removed === "number" ? body.removed : 0,
|
|
1913
1925
|
failedSessions: typeof body.failedSessions === "number" ? body.failedSessions : 0
|
|
1914
1926
|
};
|
|
1915
1927
|
return null;
|
|
@@ -1956,6 +1968,7 @@ window.__ModuleLoader__.load({
|
|
|
1956
1968
|
total: 0,
|
|
1957
1969
|
added: 0,
|
|
1958
1970
|
skipped: 0,
|
|
1971
|
+
removed: 0,
|
|
1959
1972
|
failedSessions: 0
|
|
1960
1973
|
});
|
|
1961
1974
|
return;
|
|
@@ -2113,7 +2126,8 @@ window.__ModuleLoader__.load({
|
|
|
2113
2126
|
processed: String(fullSync.processed),
|
|
2114
2127
|
total: String(fullSync.total),
|
|
2115
2128
|
added: String(fullSync.added),
|
|
2116
|
-
skipped: String(fullSync.skipped)
|
|
2129
|
+
skipped: String(fullSync.skipped),
|
|
2130
|
+
removed: String(fullSync.removed)
|
|
2117
2131
|
}), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
|
|
2118
2132
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2119
2133
|
className: TokenUsageCard_module_css_default.fullSyncBar,
|
|
@@ -2128,7 +2142,8 @@ window.__ModuleLoader__.load({
|
|
|
2128
2142
|
role: "status",
|
|
2129
2143
|
children: [t("card.fullSync.done", {
|
|
2130
2144
|
added: String(fullSync.added),
|
|
2131
|
-
skipped: String(fullSync.skipped)
|
|
2145
|
+
skipped: String(fullSync.skipped),
|
|
2146
|
+
removed: String(fullSync.removed)
|
|
2132
2147
|
}), fullSync.failedSessions > 0 ? t("card.fullSync.failuresNote", { count: String(fullSync.failedSessions) }) : ""]
|
|
2133
2148
|
}) : null,
|
|
2134
2149
|
fullSync.status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -2168,13 +2183,13 @@ window.__ModuleLoader__.load({
|
|
|
2168
2183
|
}
|
|
2169
2184
|
//#endregion
|
|
2170
2185
|
//#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$
|
|
2186
|
+
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)}";
|
|
2187
|
+
const tagId$8 = "@laoyuehanni/dsh-token-usage/DateRangePicker.module.css";
|
|
2188
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$8) + "]") === null) {
|
|
2174
2189
|
const tag = document.createElement("style");
|
|
2175
2190
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2176
|
-
tag.dataset.pluginCss = tagId$
|
|
2177
|
-
tag.textContent = css$
|
|
2191
|
+
tag.dataset.pluginCss = tagId$8;
|
|
2192
|
+
tag.textContent = css$8;
|
|
2178
2193
|
document.head.appendChild(tag);
|
|
2179
2194
|
}
|
|
2180
2195
|
var DateRangePicker_module_css_default = {
|
|
@@ -2398,13 +2413,13 @@ window.__ModuleLoader__.load({
|
|
|
2398
2413
|
}
|
|
2399
2414
|
//#endregion
|
|
2400
2415
|
//#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$
|
|
2416
|
+
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}";
|
|
2417
|
+
const tagId$7 = "@laoyuehanni/dsh-token-usage/MenuSelect.module.css";
|
|
2418
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$7) + "]") === null) {
|
|
2404
2419
|
const tag = document.createElement("style");
|
|
2405
2420
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2406
|
-
tag.dataset.pluginCss = tagId$
|
|
2407
|
-
tag.textContent = css$
|
|
2421
|
+
tag.dataset.pluginCss = tagId$7;
|
|
2422
|
+
tag.textContent = css$7;
|
|
2408
2423
|
document.head.appendChild(tag);
|
|
2409
2424
|
}
|
|
2410
2425
|
var MenuSelect_module_css_default = {
|
|
@@ -2572,113 +2587,977 @@ window.__ModuleLoader__.load({
|
|
|
2572
2587
|
});
|
|
2573
2588
|
}
|
|
2574
2589
|
//#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$
|
|
2590
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingDialog.module.css.mjs
|
|
2591
|
+
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)}";
|
|
2592
|
+
const tagId$6 = "@laoyuehanni/dsh-token-usage/PricingDialog.module.css";
|
|
2593
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$6) + "]") === null) {
|
|
2579
2594
|
const tag = document.createElement("style");
|
|
2580
2595
|
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2581
|
-
tag.dataset.pluginCss = tagId$
|
|
2582
|
-
tag.textContent = css$
|
|
2596
|
+
tag.dataset.pluginCss = tagId$6;
|
|
2597
|
+
tag.textContent = css$6;
|
|
2583
2598
|
document.head.appendChild(tag);
|
|
2584
2599
|
}
|
|
2585
|
-
var
|
|
2586
|
-
"
|
|
2587
|
-
"
|
|
2588
|
-
"
|
|
2589
|
-
"
|
|
2590
|
-
"
|
|
2591
|
-
"
|
|
2592
|
-
"
|
|
2593
|
-
"
|
|
2594
|
-
"
|
|
2595
|
-
"
|
|
2596
|
-
"splitSep": "F2LbNW_splitSep"
|
|
2600
|
+
var PricingDialog_module_css_default = {
|
|
2601
|
+
"conditionCell": "gh1SLa_conditionCell",
|
|
2602
|
+
"conditionHead": "gh1SLa_conditionHead",
|
|
2603
|
+
"dialog": "gh1SLa_dialog",
|
|
2604
|
+
"dialogClose": "gh1SLa_dialogClose",
|
|
2605
|
+
"dialogHead": "gh1SLa_dialogHead",
|
|
2606
|
+
"dialogTitle": "gh1SLa_dialogTitle",
|
|
2607
|
+
"groupRow": "gh1SLa_groupRow",
|
|
2608
|
+
"rateNote": "gh1SLa_rateNote",
|
|
2609
|
+
"table": "gh1SLa_table",
|
|
2610
|
+
"tableWrap": "gh1SLa_tableWrap"
|
|
2597
2611
|
};
|
|
2598
2612
|
//#endregion
|
|
2599
|
-
//#region src/client/
|
|
2613
|
+
//#region src/client/PricingDialog.tsx
|
|
2600
2614
|
/**
|
|
2601
|
-
*
|
|
2602
|
-
*
|
|
2615
|
+
* The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
|
|
2616
|
+
* is trapped, the backdrop dims, and the top layer renders it above the
|
|
2617
|
+
* table's scroll shell) holding that model's full price table — billing
|
|
2618
|
+
* conditions (default / context tiers / peak slots / time rules) × the four
|
|
2619
|
+
* per-million rates, converted for a USD view. Shared by the settings
|
|
2620
|
+
* page's per-model “定价” affordance and the pricing-overview dialog's
|
|
2621
|
+
* drill-in rows; a native showModal naturally stacks a second instance
|
|
2622
|
+
* above the overview.
|
|
2623
|
+
*
|
|
2624
|
+
* @module token-usage/client/PricingDialog
|
|
2603
2625
|
*/
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2626
|
+
/** The four base rates of one model as display text (symbol included,
|
|
2627
|
+
* converted for a USD view); a missing cache rate bills at the input rate. */
|
|
2628
|
+
function billedRates(rates, view) {
|
|
2629
|
+
return {
|
|
2630
|
+
input: formatRateWithSymbol(rates.inputPerMillion, view),
|
|
2631
|
+
output: formatRateWithSymbol(rates.outputPerMillion, view),
|
|
2632
|
+
cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
|
|
2633
|
+
cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
/** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
|
|
2637
|
+
function windowText(window) {
|
|
2638
|
+
const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
|
|
2639
|
+
return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
|
|
2640
|
+
}
|
|
2641
|
+
/** The when-it-applies text of one peak slot: its label plus its windows. */
|
|
2642
|
+
function slotCondition(slot, t) {
|
|
2643
|
+
return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* The price rows of one rate node (a time rule's or the model root's): the
|
|
2647
|
+
* node's own base rates, then its peak slots, then its context tiers
|
|
2648
|
+
* (ascending), each tier followed by the peak slots hanging on that tier —
|
|
2649
|
+
* mirroring {@link resolveRate}'s node chain, where a matching tier's slots
|
|
2650
|
+
* replace the node's and peak rates replace the node's rates wholesale.
|
|
2651
|
+
*/
|
|
2652
|
+
function nodePriceRows(node, t) {
|
|
2653
|
+
const rows = [{
|
|
2654
|
+
condition: t("pricing.default"),
|
|
2655
|
+
rates: node.rates
|
|
2656
|
+
}];
|
|
2657
|
+
const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
|
|
2658
|
+
for (const tier of tiers) {
|
|
2659
|
+
const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
|
|
2660
|
+
rows.push({
|
|
2661
|
+
condition: tierCondition,
|
|
2662
|
+
rates: tier.rates
|
|
2663
|
+
});
|
|
2664
|
+
for (const slot of tier.dailySlots ?? []) rows.push({
|
|
2665
|
+
condition: `${tierCondition} · ${slotCondition(slot, t)}`,
|
|
2666
|
+
rates: slot.rates
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
for (const slot of node.slots ?? []) rows.push({
|
|
2670
|
+
condition: slotCondition(slot, t),
|
|
2671
|
+
rates: slot.rates
|
|
2614
2672
|
});
|
|
2673
|
+
return rows;
|
|
2615
2674
|
}
|
|
2616
2675
|
/**
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2619
|
-
*
|
|
2676
|
+
* One model's price table: rows are billing conditions — grouped into the
|
|
2677
|
+
* model root (“常规”, omitted when it is the only group) and one group per
|
|
2678
|
+
* time rule with its date window — so tier, peak, and time-rule pricing
|
|
2679
|
+
* each show when they apply and what they bill. The structure mirrors
|
|
2680
|
+
* {@link resolveRate}'s node chain.
|
|
2620
2681
|
*/
|
|
2621
|
-
function
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2682
|
+
function ModelPriceTable({ rules, view, t }) {
|
|
2683
|
+
const groups = [{
|
|
2684
|
+
title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
|
|
2685
|
+
rows: nodePriceRows({
|
|
2686
|
+
rates: rules.base,
|
|
2687
|
+
tiers: rules.contextTiers,
|
|
2688
|
+
slots: rules.dailySlots
|
|
2689
|
+
}, t)
|
|
2690
|
+
}, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
|
|
2691
|
+
title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
|
|
2692
|
+
rows: nodePriceRows({
|
|
2693
|
+
rates: rule.rates,
|
|
2694
|
+
tiers: rule.contextTiers,
|
|
2695
|
+
slots: rule.dailySlots
|
|
2696
|
+
}, t)
|
|
2697
|
+
}))];
|
|
2698
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2699
|
+
className: PricingDialog_module_css_default["tableWrap"],
|
|
2700
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
2701
|
+
className: PricingDialog_module_css_default["table"],
|
|
2702
|
+
"aria-label": t("pricing.title"),
|
|
2703
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2704
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
2705
|
+
className: PricingDialog_module_css_default["conditionHead"],
|
|
2706
|
+
children: t("pricing.condition")
|
|
2707
|
+
}),
|
|
2708
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
2709
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
2710
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
2711
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
|
|
2712
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
2713
|
+
className: PricingDialog_module_css_default["groupRow"],
|
|
2714
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2715
|
+
colSpan: 5,
|
|
2716
|
+
children: group.title
|
|
2717
|
+
})
|
|
2718
|
+
}, group.title)] : [], ...group.rows.map((row, index) => {
|
|
2719
|
+
const billed = billedRates(row.rates, view);
|
|
2720
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
2721
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
2722
|
+
className: PricingDialog_module_css_default["conditionCell"],
|
|
2723
|
+
children: row.condition
|
|
2724
|
+
}),
|
|
2725
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
2726
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
2727
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
2728
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
|
|
2729
|
+
] }, `${group.title ?? ""}-${index}-${row.condition}`);
|
|
2730
|
+
})]) })]
|
|
2731
|
+
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2732
|
+
className: PricingDialog_module_css_default["rateNote"],
|
|
2733
|
+
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
2734
|
+
}) : null]
|
|
2635
2735
|
});
|
|
2636
2736
|
}
|
|
2637
2737
|
/**
|
|
2638
|
-
* The
|
|
2639
|
-
*
|
|
2738
|
+
* The pricing dialog of one model. Mounts only while a model is selected;
|
|
2739
|
+
* every close path funnels through the dialog's `close` event, which clears
|
|
2740
|
+
* the selection and unmounts it.
|
|
2640
2741
|
*/
|
|
2641
|
-
function
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2742
|
+
function PricingDialog({ model, rules, view, onClose, t }) {
|
|
2743
|
+
const dialogRef = (0, react.useRef)(null);
|
|
2744
|
+
const backdropPress = (0, react.useRef)(false);
|
|
2745
|
+
(0, react.useEffect)(() => {
|
|
2746
|
+
const dialog = dialogRef.current;
|
|
2747
|
+
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
2748
|
+
}, []);
|
|
2749
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
2750
|
+
ref: dialogRef,
|
|
2751
|
+
className: PricingDialog_module_css_default["dialog"],
|
|
2752
|
+
"aria-label": t("pricing.title"),
|
|
2753
|
+
onClose,
|
|
2754
|
+
onMouseDown: (event) => {
|
|
2755
|
+
backdropPress.current = event.target === dialogRef.current;
|
|
2756
|
+
},
|
|
2757
|
+
onClick: (event) => {
|
|
2758
|
+
if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
|
|
2759
|
+
},
|
|
2760
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2761
|
+
className: PricingDialog_module_css_default["dialogHead"],
|
|
2762
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2763
|
+
className: PricingDialog_module_css_default["dialogTitle"],
|
|
2764
|
+
children: model
|
|
2765
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2766
|
+
type: "button",
|
|
2767
|
+
className: PricingDialog_module_css_default["dialogClose"],
|
|
2768
|
+
"aria-label": t("pricing.close"),
|
|
2769
|
+
onClick: () => dialogRef.current?.close(),
|
|
2770
|
+
children: "✕"
|
|
2771
|
+
})]
|
|
2772
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
|
|
2773
|
+
rules,
|
|
2774
|
+
view,
|
|
2650
2775
|
t
|
|
2651
|
-
})]
|
|
2776
|
+
})]
|
|
2652
2777
|
});
|
|
2653
2778
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2665
|
-
className: StatCard_module_css_default["splitSep"],
|
|
2666
|
-
"aria-hidden": true,
|
|
2667
|
-
children: "/"
|
|
2668
|
-
}),
|
|
2669
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2670
|
-
className: StatCard_module_css_default["splitFailHead"],
|
|
2671
|
-
children: t("stat.fail")
|
|
2672
|
-
})
|
|
2673
|
-
]
|
|
2674
|
-
});
|
|
2779
|
+
//#endregion
|
|
2780
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\PricingOverviewDialog.module.css.mjs
|
|
2781
|
+
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}";
|
|
2782
|
+
const tagId$5 = "@laoyuehanni/dsh-token-usage/PricingOverviewDialog.module.css";
|
|
2783
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$5) + "]") === null) {
|
|
2784
|
+
const tag = document.createElement("style");
|
|
2785
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2786
|
+
tag.dataset.pluginCss = tagId$5;
|
|
2787
|
+
tag.textContent = css$5;
|
|
2788
|
+
document.head.appendChild(tag);
|
|
2675
2789
|
}
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2790
|
+
var PricingOverviewDialog_module_css_default = {
|
|
2791
|
+
"arrowGap": "bVRC-q_arrowGap",
|
|
2792
|
+
"bucket": "bVRC-q_bucket",
|
|
2793
|
+
"bucketInput": "bVRC-q_bucketInput",
|
|
2794
|
+
"bucketLabel": "bVRC-q_bucketLabel",
|
|
2795
|
+
"buckets": "bVRC-q_buckets",
|
|
2796
|
+
"cellInner": "bVRC-q_cellInner",
|
|
2797
|
+
"expandArrow": "bVRC-q_expandArrow",
|
|
2798
|
+
"expansionRow": "bVRC-q_expansionRow",
|
|
2799
|
+
"failRow": "bVRC-q_failRow",
|
|
2800
|
+
"modelCell": "bVRC-q_modelCell",
|
|
2801
|
+
"modelHead": "bVRC-q_modelHead",
|
|
2802
|
+
"modelName": "bVRC-q_modelName",
|
|
2803
|
+
"modelRow": "bVRC-q_modelRow",
|
|
2804
|
+
"note": "bVRC-q_note",
|
|
2805
|
+
"overview": "bVRC-q_overview",
|
|
2806
|
+
"retryButton": "bVRC-q_retryButton",
|
|
2807
|
+
"scenario": "bVRC-q_scenario",
|
|
2808
|
+
"scenarios": "bVRC-q_scenarios",
|
|
2809
|
+
"search": "bVRC-q_search",
|
|
2810
|
+
"sortArrow": "bVRC-q_sortArrow",
|
|
2811
|
+
"sortArrowIdle": "bVRC-q_sortArrowIdle",
|
|
2812
|
+
"sortHead": "bVRC-q_sortHead",
|
|
2813
|
+
"specialLabel": "bVRC-q_specialLabel",
|
|
2814
|
+
"specialRate": "bVRC-q_specialRate",
|
|
2815
|
+
"specialRow": "bVRC-q_specialRow",
|
|
2816
|
+
"specialRows": "bVRC-q_specialRows",
|
|
2817
|
+
"table": "bVRC-q_table",
|
|
2818
|
+
"tableWrap": "bVRC-q_tableWrap",
|
|
2819
|
+
"unit": "bVRC-q_unit",
|
|
2820
|
+
"unitGroup": "bVRC-q_unitGroup",
|
|
2821
|
+
"usedTag": "bVRC-q_usedTag"
|
|
2822
|
+
};
|
|
2823
|
+
//#endregion
|
|
2824
|
+
//#region src/client/PricingOverviewDialog.tsx
|
|
2825
|
+
/**
|
|
2826
|
+
* The pricing-overview dialog of the settings page: the full cloud-mirror
|
|
2827
|
+
* model list served by the filter-free `/token-usage/pricing` route — one
|
|
2828
|
+
* flat row per model, sorted by the feed's upstream `family` field (zero
|
|
2829
|
+
* client-side mapping) then by modelId, each row's four base rates in the
|
|
2830
|
+
* page's display currency. Families drive order and search only — there is
|
|
2831
|
+
* no grouping UI, every row is directly visible. Rows the page's filters
|
|
2832
|
+
* have used carry a “已用” tag; clicking a row opens that model's full
|
|
2833
|
+
* price table as a second native dialog stacked above.
|
|
2834
|
+
*
|
|
2835
|
+
* Above the table, four token-bucket inputs drive a simulated-cost column:
|
|
2836
|
+
* what the buckets would bill at each model's base rates. Each bucket is
|
|
2837
|
+
* an amount under a picked K/M/B unit — switching converts the amount, the
|
|
2838
|
+
* token count stands still. Preset case buttons (「案例1」, hover-titled
|
|
2839
|
+
* with the workload picture) refill the buckets compact in one click; the
|
|
2840
|
+
* first case is prefilled on open, and the pressed highlight tracks exact
|
|
2841
|
+
* token matches, so a manual edit un-presses. The column sorts by a
|
|
2842
|
+
* three-state header cycle (family order → cost desc → cost asc → family);
|
|
2843
|
+
* the header's glyph never disappears: a dim ⇅ in the default family
|
|
2844
|
+
* order, then ▾ desc and ▴ asc.
|
|
2845
|
+
*
|
|
2846
|
+
* Aliases never render — they stay a search dimension only (a hit on an
|
|
2847
|
+
* alias surfaces the model, whose id then reads as the result).
|
|
2848
|
+
*
|
|
2849
|
+
* @module token-usage/client/PricingOverviewDialog
|
|
2850
|
+
*/
|
|
2851
|
+
/** The family a model row without a feed `family` lands in; the feed
|
|
2852
|
+
* itself already uses this value for uncategorized rows. */
|
|
2853
|
+
const OTHER_FAMILY = "other";
|
|
2854
|
+
/** The family of one row (absent → `other`): the sort key's first half
|
|
2855
|
+
* and one of the search dimensions. */
|
|
2856
|
+
function familyOf(model) {
|
|
2857
|
+
return model.family ?? OTHER_FAMILY;
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* Sort models by family (alphabetical, absent → `other`), then by modelId —
|
|
2861
|
+
* the feed's own classification drives the browsing order so same-family
|
|
2862
|
+
* models stay adjacent, with zero client-side mapping.
|
|
2863
|
+
*/
|
|
2864
|
+
function sortPricingModels(models) {
|
|
2865
|
+
return [...models].sort((a, b) => {
|
|
2866
|
+
const familyA = familyOf(a);
|
|
2867
|
+
const familyB = familyOf(b);
|
|
2868
|
+
if (familyA !== familyB) return familyA < familyB ? -1 : 1;
|
|
2869
|
+
return a.modelId < b.modelId ? -1 : a.modelId > b.modelId ? 1 : 0;
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Whether one model row matches the search: a case-insensitive substring
|
|
2874
|
+
* hit on the modelId, any alias, or the family. An empty query
|
|
2875
|
+
* matches everything.
|
|
2876
|
+
*/
|
|
2877
|
+
function matchesPricingSearch(model, query) {
|
|
2878
|
+
if (query === "") return true;
|
|
2879
|
+
const needle = query.toLowerCase();
|
|
2880
|
+
if (model.modelId.toLowerCase().includes(needle)) return true;
|
|
2881
|
+
if (familyOf(model).toLowerCase().includes(needle)) return true;
|
|
2882
|
+
return model.aliases.some((alias) => alias.toLowerCase().includes(needle));
|
|
2883
|
+
}
|
|
2884
|
+
/** The preset cases the buttons fill the inputs with (maintainer-curated
|
|
2885
|
+
* classic workloads). The first prefills the inputs on open. */
|
|
2886
|
+
const SIM_SCENARIOS = [
|
|
2887
|
+
{
|
|
2888
|
+
inputTokens: 2e6,
|
|
2889
|
+
cacheReadTokens: 98e6,
|
|
2890
|
+
outputTokens: 457e3,
|
|
2891
|
+
cacheWriteTokens: 0
|
|
2892
|
+
},
|
|
2893
|
+
{
|
|
2894
|
+
inputTokens: 5e6,
|
|
2895
|
+
cacheReadTokens: 95e6,
|
|
2896
|
+
outputTokens: 6e5,
|
|
2897
|
+
cacheWriteTokens: 0
|
|
2898
|
+
},
|
|
2899
|
+
{
|
|
2900
|
+
inputTokens: 1e8,
|
|
2901
|
+
cacheReadTokens: 0,
|
|
2902
|
+
outputTokens: 1e8,
|
|
2903
|
+
cacheWriteTokens: 0
|
|
2904
|
+
}
|
|
2905
|
+
];
|
|
2906
|
+
/** The units a bucket's amount can carry. */
|
|
2907
|
+
const BUCKET_UNITS = [
|
|
2908
|
+
"K",
|
|
2909
|
+
"M",
|
|
2910
|
+
"B"
|
|
2911
|
+
];
|
|
2912
|
+
const UNIT_MULT = {
|
|
2913
|
+
K: 1e3,
|
|
2914
|
+
M: 1e6,
|
|
2915
|
+
B: 1e9
|
|
2916
|
+
};
|
|
2917
|
+
/** The whole-token count a bucket stands for: amount × unit, float fuzz
|
|
2918
|
+
* rounded off; empty, negative, or non-numeric amounts read as zero. */
|
|
2919
|
+
function tokensOf(bucket) {
|
|
2920
|
+
const parsed = Number(bucket.amount);
|
|
2921
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 0;
|
|
2922
|
+
return Math.round(parsed * UNIT_MULT[bucket.unit]);
|
|
2923
|
+
}
|
|
2924
|
+
/** The amount string for the same tokens under a new unit — converting so
|
|
2925
|
+
* the token count stands still (98M reads 98000K). Trims float fuzz to
|
|
2926
|
+
* six decimals so 0.457M ↔ 457K round-trips cleanly. */
|
|
2927
|
+
function convertBucketAmount(bucket, unit) {
|
|
2928
|
+
const parsed = Number(bucket.amount);
|
|
2929
|
+
if (!Number.isFinite(parsed)) return "";
|
|
2930
|
+
const converted = parsed * UNIT_MULT[bucket.unit] / UNIT_MULT[unit];
|
|
2931
|
+
return String(Math.round(converted * 1e6) / 1e6);
|
|
2932
|
+
}
|
|
2933
|
+
/** The compact refill shape of one token count: a short amount under the
|
|
2934
|
+
* fitting unit (98M, 457K), K as the floor for the sub-1K tail. */
|
|
2935
|
+
function compactBucket(tokens) {
|
|
2936
|
+
if (tokens >= UNIT_MULT.B) return {
|
|
2937
|
+
amount: String(tokens / UNIT_MULT.B),
|
|
2938
|
+
unit: "B"
|
|
2939
|
+
};
|
|
2940
|
+
if (tokens >= UNIT_MULT.M) return {
|
|
2941
|
+
amount: String(tokens / UNIT_MULT.M),
|
|
2942
|
+
unit: "M"
|
|
2943
|
+
};
|
|
2944
|
+
return {
|
|
2945
|
+
amount: String(tokens / UNIT_MULT.K),
|
|
2946
|
+
unit: "K"
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
/** The refill shape of a whole case: every bucket compact. */
|
|
2950
|
+
function bucketsOfCase(scenario) {
|
|
2951
|
+
return {
|
|
2952
|
+
inputTokens: compactBucket(scenario.inputTokens),
|
|
2953
|
+
cacheReadTokens: compactBucket(scenario.cacheReadTokens),
|
|
2954
|
+
outputTokens: compactBucket(scenario.outputTokens),
|
|
2955
|
+
cacheWriteTokens: compactBucket(scenario.cacheWriteTokens)
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
/**
|
|
2959
|
+
* The simulated cost (¥) of one scenario under a model's base rates —
|
|
2960
|
+
* the same arithmetic as the host half's `costOf` (a missing cache rate
|
|
2961
|
+
* bills at the input rate), re-implemented here because pricing.ts lives
|
|
2962
|
+
* on the node side of the bundle boundary.
|
|
2963
|
+
*/
|
|
2964
|
+
function simCostOf(scenario, rates) {
|
|
2965
|
+
const M = 1e6;
|
|
2966
|
+
const cacheRead = rates.cacheReadPerMillion ?? rates.inputPerMillion;
|
|
2967
|
+
const cacheWrite = rates.cacheWritePerMillion ?? rates.inputPerMillion;
|
|
2968
|
+
return (scenario.inputTokens * rates.inputPerMillion + scenario.outputTokens * rates.outputPerMillion + scenario.cacheReadTokens * cacheRead + scenario.cacheWriteTokens * cacheWrite) / M;
|
|
2969
|
+
}
|
|
2970
|
+
/** The largest tier whose threshold the context clears. */
|
|
2971
|
+
function hitTier(tiers, ctxTokens) {
|
|
2972
|
+
let hit;
|
|
2973
|
+
for (const tier of tiers) if (ctxTokens >= tier.threshold && (hit === void 0 || tier.threshold > hit.threshold)) hit = tier;
|
|
2974
|
+
return hit;
|
|
2975
|
+
}
|
|
2976
|
+
function hitNodeOf(rules, ctxTokens, nowMs) {
|
|
2977
|
+
const nowSec = Math.floor(nowMs / 1e3);
|
|
2978
|
+
const rule = rules.timeRules.find((candidate) => candidate.startTime <= nowSec && nowSec <= candidate.endTime);
|
|
2979
|
+
if (rule !== void 0) return {
|
|
2980
|
+
baseRates: rule.rates,
|
|
2981
|
+
slots: rule.dailySlots ?? [],
|
|
2982
|
+
tier: hitTier(rule.contextTiers ?? [], ctxTokens)
|
|
2983
|
+
};
|
|
2984
|
+
return {
|
|
2985
|
+
baseRates: rules.base,
|
|
2986
|
+
slots: rules.dailySlots,
|
|
2987
|
+
tier: hitTier(rules.contextTiers, ctxTokens)
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
/** The workload picture of one case — the input line (input-side total
|
|
2991
|
+
* with its cache-hit share) and the output line — joined into the case
|
|
2992
|
+
* button's hover title. */
|
|
2993
|
+
function scenarioLabel(scenario, t) {
|
|
2994
|
+
const total = scenario.inputTokens + scenario.cacheReadTokens;
|
|
2995
|
+
const pct = Math.round(scenario.cacheReadTokens / total * 100);
|
|
2996
|
+
return {
|
|
2997
|
+
inputLine: `${t("pricing.simInput", { tokens: formatTokens(total) })}${t("pricing.simCache", { pct: String(pct) })}`,
|
|
2998
|
+
outputLine: t("pricing.simOutput", { tokens: formatTokens(scenario.outputTokens) })
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
/** One bucket's K/M/B unit segment. Switching converts the amount so the
|
|
3002
|
+
* token count stands still. */
|
|
3003
|
+
function UnitPicker({ t, bucket, unit, onPick }) {
|
|
3004
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3005
|
+
className: PricingOverviewDialog_module_css_default["unitGroup"],
|
|
3006
|
+
children: BUCKET_UNITS.map((candidate) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3007
|
+
type: "button",
|
|
3008
|
+
className: PricingOverviewDialog_module_css_default["unit"],
|
|
3009
|
+
"aria-pressed": candidate === unit,
|
|
3010
|
+
"aria-label": t("pricing.simUnitOf", {
|
|
3011
|
+
bucket,
|
|
3012
|
+
unit: candidate
|
|
3013
|
+
}),
|
|
3014
|
+
onClick: () => {
|
|
3015
|
+
if (candidate !== unit) onPick(candidate);
|
|
3016
|
+
},
|
|
3017
|
+
children: candidate
|
|
3018
|
+
}, candidate))
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Fetch the pricing overview from the local route — deliberately without
|
|
3023
|
+
* any query parameters: the overview is not a filtered view, so changing
|
|
3024
|
+
* the page's filters never changes what this dialog shows. An empty model
|
|
3025
|
+
* list (a first startup whose sync has not landed a mirror yet) reads as
|
|
3026
|
+
* the same failure the fetch error does: nothing to show, retry offered.
|
|
3027
|
+
*/
|
|
3028
|
+
function fetchPricingOverview(signal) {
|
|
3029
|
+
return fetch(PRICING_PATH, { signal }).then((response) => {
|
|
3030
|
+
if (!response.ok) throw new Error(`HTTP ${String(response.status)}`);
|
|
3031
|
+
return response.json();
|
|
3032
|
+
}).then((value) => {
|
|
3033
|
+
if (typeof value !== "object" || value === null || !Array.isArray(value.models)) throw new Error("unexpected pricing response");
|
|
3034
|
+
if (value.models.length === 0) throw new Error("pricing mirror is empty");
|
|
3035
|
+
return value;
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* The pricing-overview dialog. `usedModels` is the open-time snapshot of
|
|
3040
|
+
* the page's filtered model selection (the modal's backdrop covers the
|
|
3041
|
+
* filter row, so it cannot change while the dialog is open); `view` is the
|
|
3042
|
+
* page's display currency. Mounts only while open; every close path
|
|
3043
|
+
* funnels through the dialog's `close` event, which unmounts it.
|
|
3044
|
+
*/
|
|
3045
|
+
function PricingOverviewDialog({ usedModels, view, onClose, t }) {
|
|
3046
|
+
const dialogRef = (0, react.useRef)(null);
|
|
3047
|
+
const backdropPress = (0, react.useRef)(false);
|
|
3048
|
+
(0, react.useEffect)(() => {
|
|
3049
|
+
const dialog = dialogRef.current;
|
|
3050
|
+
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
3051
|
+
}, []);
|
|
3052
|
+
const [state, retry] = useAsyncResource(fetchPricingOverview, [], { retryToken: 0 });
|
|
3053
|
+
const [search, setSearch] = (0, react.useState)("");
|
|
3054
|
+
const [buckets, setBuckets] = (0, react.useState)(() => bucketsOfCase(SIM_SCENARIOS[0]));
|
|
3055
|
+
const [sortMode, setSortMode] = (0, react.useState)("family");
|
|
3056
|
+
const [detail, setDetail] = (0, react.useState)(null);
|
|
3057
|
+
const [nowMs] = (0, react.useState)(() => Date.now());
|
|
3058
|
+
const [expandedId, setExpandedId] = (0, react.useState)(null);
|
|
3059
|
+
const sorted = (0, react.useMemo)(() => sortPricingModels(state.status === "ready" ? state.value.models : []), [state]);
|
|
3060
|
+
const scenario = (0, react.useMemo)(() => ({
|
|
3061
|
+
inputTokens: tokensOf(buckets.inputTokens),
|
|
3062
|
+
cacheReadTokens: tokensOf(buckets.cacheReadTokens),
|
|
3063
|
+
outputTokens: tokensOf(buckets.outputTokens),
|
|
3064
|
+
cacheWriteTokens: tokensOf(buckets.cacheWriteTokens)
|
|
3065
|
+
}), [buckets]);
|
|
3066
|
+
const ctxTokens = scenario.inputTokens + scenario.cacheReadTokens;
|
|
3067
|
+
const pressedCase = SIM_SCENARIOS.find((candidate) => candidate.inputTokens === scenario.inputTokens && candidate.cacheReadTokens === scenario.cacheReadTokens && candidate.outputTokens === scenario.outputTokens && candidate.cacheWriteTokens === scenario.cacheWriteTokens);
|
|
3068
|
+
const query = search.trim();
|
|
3069
|
+
const rows = (0, react.useMemo)(() => {
|
|
3070
|
+
const withCost = sorted.map((model) => {
|
|
3071
|
+
const node = hitNodeOf(model.rules, ctxTokens, nowMs);
|
|
3072
|
+
return {
|
|
3073
|
+
model,
|
|
3074
|
+
node,
|
|
3075
|
+
cost: simCostOf(scenario, node.baseRates),
|
|
3076
|
+
specials: [...node.tier !== void 0 ? [{
|
|
3077
|
+
kind: "tier",
|
|
3078
|
+
tier: node.tier,
|
|
3079
|
+
slot: void 0,
|
|
3080
|
+
cost: simCostOf(scenario, node.tier.rates)
|
|
3081
|
+
}] : [], ...node.slots.map((slot) => ({
|
|
3082
|
+
kind: "slot",
|
|
3083
|
+
tier: void 0,
|
|
3084
|
+
slot,
|
|
3085
|
+
cost: simCostOf(scenario, slot.rates)
|
|
3086
|
+
}))]
|
|
3087
|
+
};
|
|
3088
|
+
}).filter(({ model }) => query === "" || matchesPricingSearch(model, query));
|
|
3089
|
+
if (sortMode === "family") return withCost;
|
|
3090
|
+
return [...withCost].sort((a, b) => sortMode === "cost-desc" ? b.cost - a.cost : a.cost - b.cost);
|
|
3091
|
+
}, [
|
|
3092
|
+
sorted,
|
|
3093
|
+
scenario,
|
|
3094
|
+
query,
|
|
3095
|
+
sortMode,
|
|
3096
|
+
ctxTokens,
|
|
3097
|
+
nowMs
|
|
3098
|
+
]);
|
|
3099
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
3100
|
+
ref: dialogRef,
|
|
3101
|
+
className: `${PricingDialog_module_css_default["dialog"]} ${PricingOverviewDialog_module_css_default["overview"]}`,
|
|
3102
|
+
"aria-label": t("pricing.table"),
|
|
3103
|
+
onClose: (event) => {
|
|
3104
|
+
if (event.target === dialogRef.current) onClose();
|
|
3105
|
+
},
|
|
3106
|
+
onMouseDown: (event) => {
|
|
3107
|
+
backdropPress.current = event.target === dialogRef.current;
|
|
3108
|
+
},
|
|
3109
|
+
onClick: (event) => {
|
|
3110
|
+
if (event.target === dialogRef.current && backdropPress.current) dialogRef.current?.close();
|
|
3111
|
+
},
|
|
3112
|
+
children: [
|
|
3113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3114
|
+
className: PricingDialog_module_css_default["dialogHead"],
|
|
3115
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3116
|
+
className: PricingDialog_module_css_default["dialogTitle"],
|
|
3117
|
+
children: t("pricing.table")
|
|
3118
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3119
|
+
type: "button",
|
|
3120
|
+
className: PricingDialog_module_css_default["dialogClose"],
|
|
3121
|
+
"aria-label": t("pricing.close"),
|
|
3122
|
+
onClick: () => dialogRef.current?.close(),
|
|
3123
|
+
children: "✕"
|
|
3124
|
+
})]
|
|
3125
|
+
}),
|
|
3126
|
+
state.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3127
|
+
className: PricingOverviewDialog_module_css_default["note"],
|
|
3128
|
+
children: t("loading")
|
|
3129
|
+
}) : null,
|
|
3130
|
+
state.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3131
|
+
className: PricingOverviewDialog_module_css_default["failRow"],
|
|
3132
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3133
|
+
className: PricingOverviewDialog_module_css_default["note"],
|
|
3134
|
+
children: t("pricing.overviewFailed")
|
|
3135
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3136
|
+
type: "button",
|
|
3137
|
+
className: PricingOverviewDialog_module_css_default["retryButton"],
|
|
3138
|
+
onClick: retry,
|
|
3139
|
+
children: t("retry")
|
|
3140
|
+
})]
|
|
3141
|
+
}) : null,
|
|
3142
|
+
state.status === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3144
|
+
type: "search",
|
|
3145
|
+
className: PricingOverviewDialog_module_css_default["search"],
|
|
3146
|
+
placeholder: t("pricing.search"),
|
|
3147
|
+
"aria-label": t("pricing.search"),
|
|
3148
|
+
value: search,
|
|
3149
|
+
onChange: (event) => setSearch(event.target.value)
|
|
3150
|
+
}),
|
|
3151
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3152
|
+
className: PricingOverviewDialog_module_css_default["buckets"],
|
|
3153
|
+
children: [
|
|
3154
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3155
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3156
|
+
children: [
|
|
3157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3158
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3159
|
+
children: t("pricing.simBucketInput")
|
|
3160
|
+
}),
|
|
3161
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3162
|
+
type: "number",
|
|
3163
|
+
min: 0,
|
|
3164
|
+
step: "any",
|
|
3165
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3166
|
+
"aria-label": t("pricing.simBucketInput"),
|
|
3167
|
+
value: buckets.inputTokens.amount,
|
|
3168
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3169
|
+
...previous,
|
|
3170
|
+
inputTokens: {
|
|
3171
|
+
...previous.inputTokens,
|
|
3172
|
+
amount: event.target.value
|
|
3173
|
+
}
|
|
3174
|
+
}))
|
|
3175
|
+
}),
|
|
3176
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3177
|
+
t,
|
|
3178
|
+
bucket: t("pricing.simBucketInput"),
|
|
3179
|
+
unit: buckets.inputTokens.unit,
|
|
3180
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3181
|
+
...previous,
|
|
3182
|
+
inputTokens: {
|
|
3183
|
+
amount: convertBucketAmount(previous.inputTokens, unit),
|
|
3184
|
+
unit
|
|
3185
|
+
}
|
|
3186
|
+
}))
|
|
3187
|
+
})
|
|
3188
|
+
]
|
|
3189
|
+
}),
|
|
3190
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3191
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3192
|
+
children: [
|
|
3193
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3194
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3195
|
+
children: t("pricing.simBucketCacheRead")
|
|
3196
|
+
}),
|
|
3197
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3198
|
+
type: "number",
|
|
3199
|
+
min: 0,
|
|
3200
|
+
step: "any",
|
|
3201
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3202
|
+
"aria-label": t("pricing.simBucketCacheRead"),
|
|
3203
|
+
value: buckets.cacheReadTokens.amount,
|
|
3204
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3205
|
+
...previous,
|
|
3206
|
+
cacheReadTokens: {
|
|
3207
|
+
...previous.cacheReadTokens,
|
|
3208
|
+
amount: event.target.value
|
|
3209
|
+
}
|
|
3210
|
+
}))
|
|
3211
|
+
}),
|
|
3212
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3213
|
+
t,
|
|
3214
|
+
bucket: t("pricing.simBucketCacheRead"),
|
|
3215
|
+
unit: buckets.cacheReadTokens.unit,
|
|
3216
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3217
|
+
...previous,
|
|
3218
|
+
cacheReadTokens: {
|
|
3219
|
+
amount: convertBucketAmount(previous.cacheReadTokens, unit),
|
|
3220
|
+
unit
|
|
3221
|
+
}
|
|
3222
|
+
}))
|
|
3223
|
+
})
|
|
3224
|
+
]
|
|
3225
|
+
}),
|
|
3226
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3227
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3228
|
+
children: [
|
|
3229
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3230
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3231
|
+
children: t("pricing.simBucketOutput")
|
|
3232
|
+
}),
|
|
3233
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3234
|
+
type: "number",
|
|
3235
|
+
min: 0,
|
|
3236
|
+
step: "any",
|
|
3237
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3238
|
+
"aria-label": t("pricing.simBucketOutput"),
|
|
3239
|
+
value: buckets.outputTokens.amount,
|
|
3240
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3241
|
+
...previous,
|
|
3242
|
+
outputTokens: {
|
|
3243
|
+
...previous.outputTokens,
|
|
3244
|
+
amount: event.target.value
|
|
3245
|
+
}
|
|
3246
|
+
}))
|
|
3247
|
+
}),
|
|
3248
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3249
|
+
t,
|
|
3250
|
+
bucket: t("pricing.simBucketOutput"),
|
|
3251
|
+
unit: buckets.outputTokens.unit,
|
|
3252
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3253
|
+
...previous,
|
|
3254
|
+
outputTokens: {
|
|
3255
|
+
amount: convertBucketAmount(previous.outputTokens, unit),
|
|
3256
|
+
unit
|
|
3257
|
+
}
|
|
3258
|
+
}))
|
|
3259
|
+
})
|
|
3260
|
+
]
|
|
3261
|
+
}),
|
|
3262
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3263
|
+
className: PricingOverviewDialog_module_css_default["bucket"],
|
|
3264
|
+
children: [
|
|
3265
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3266
|
+
className: PricingOverviewDialog_module_css_default["bucketLabel"],
|
|
3267
|
+
children: t("pricing.simBucketCacheWrite")
|
|
3268
|
+
}),
|
|
3269
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3270
|
+
type: "number",
|
|
3271
|
+
min: 0,
|
|
3272
|
+
step: "any",
|
|
3273
|
+
className: PricingOverviewDialog_module_css_default["bucketInput"],
|
|
3274
|
+
"aria-label": t("pricing.simBucketCacheWrite"),
|
|
3275
|
+
value: buckets.cacheWriteTokens.amount,
|
|
3276
|
+
onChange: (event) => setBuckets((previous) => ({
|
|
3277
|
+
...previous,
|
|
3278
|
+
cacheWriteTokens: {
|
|
3279
|
+
...previous.cacheWriteTokens,
|
|
3280
|
+
amount: event.target.value
|
|
3281
|
+
}
|
|
3282
|
+
}))
|
|
3283
|
+
}),
|
|
3284
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnitPicker, {
|
|
3285
|
+
t,
|
|
3286
|
+
bucket: t("pricing.simBucketCacheWrite"),
|
|
3287
|
+
unit: buckets.cacheWriteTokens.unit,
|
|
3288
|
+
onPick: (unit) => setBuckets((previous) => ({
|
|
3289
|
+
...previous,
|
|
3290
|
+
cacheWriteTokens: {
|
|
3291
|
+
amount: convertBucketAmount(previous.cacheWriteTokens, unit),
|
|
3292
|
+
unit
|
|
3293
|
+
}
|
|
3294
|
+
}))
|
|
3295
|
+
})
|
|
3296
|
+
]
|
|
3297
|
+
})
|
|
3298
|
+
]
|
|
3299
|
+
}),
|
|
3300
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3301
|
+
className: PricingOverviewDialog_module_css_default["scenarios"],
|
|
3302
|
+
children: SIM_SCENARIOS.map((candidate, index) => {
|
|
3303
|
+
const label = scenarioLabel(candidate, t);
|
|
3304
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3305
|
+
type: "button",
|
|
3306
|
+
className: PricingOverviewDialog_module_css_default["scenario"],
|
|
3307
|
+
"aria-pressed": pressedCase === candidate,
|
|
3308
|
+
title: `${label.inputLine} ${label.outputLine}`,
|
|
3309
|
+
onClick: () => {
|
|
3310
|
+
setBuckets(bucketsOfCase(candidate));
|
|
3311
|
+
},
|
|
3312
|
+
children: t("pricing.simCase", { index: String(index + 1) })
|
|
3313
|
+
}, index);
|
|
3314
|
+
})
|
|
3315
|
+
}),
|
|
3316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3317
|
+
className: PricingOverviewDialog_module_css_default["tableWrap"],
|
|
3318
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3319
|
+
className: PricingOverviewDialog_module_css_default["table"],
|
|
3320
|
+
"aria-label": t("pricing.table"),
|
|
3321
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3322
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3323
|
+
className: PricingOverviewDialog_module_css_default["modelHead"],
|
|
3324
|
+
children: t("filter.model")
|
|
3325
|
+
}),
|
|
3326
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
3327
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
3328
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
3329
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] }),
|
|
3330
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3331
|
+
type: "button",
|
|
3332
|
+
className: PricingOverviewDialog_module_css_default["sortHead"],
|
|
3333
|
+
onClick: () => {
|
|
3334
|
+
setSortMode((previous) => previous === "family" ? "cost-desc" : previous === "cost-desc" ? "cost-asc" : "family");
|
|
3335
|
+
},
|
|
3336
|
+
children: [t("pricing.simCost"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3337
|
+
className: sortMode === "family" ? `${PricingOverviewDialog_module_css_default["sortArrow"]} ${PricingOverviewDialog_module_css_default["sortArrowIdle"]}` : PricingOverviewDialog_module_css_default["sortArrow"],
|
|
3338
|
+
"aria-hidden": true,
|
|
3339
|
+
children: sortMode === "family" ? " ⇅" : sortMode === "cost-desc" ? " ▾" : " ▴"
|
|
3340
|
+
})]
|
|
3341
|
+
}) })
|
|
3342
|
+
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: rows.map(({ model, node, cost, specials }) => {
|
|
3343
|
+
const billed = billedRates(node.baseRates, view);
|
|
3344
|
+
const expanded = expandedId === model.modelId;
|
|
3345
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
3346
|
+
className: PricingOverviewDialog_module_css_default["modelRow"],
|
|
3347
|
+
role: "button",
|
|
3348
|
+
tabIndex: 0,
|
|
3349
|
+
"aria-label": t("pricing.view", { model: model.modelId }),
|
|
3350
|
+
onClick: () => setDetail(model),
|
|
3351
|
+
onKeyDown: (event) => {
|
|
3352
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
3353
|
+
event.preventDefault();
|
|
3354
|
+
setDetail(model);
|
|
3355
|
+
}
|
|
3356
|
+
},
|
|
3357
|
+
children: [
|
|
3358
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3359
|
+
className: PricingOverviewDialog_module_css_default["modelCell"],
|
|
3360
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3361
|
+
className: PricingOverviewDialog_module_css_default["cellInner"],
|
|
3362
|
+
children: [
|
|
3363
|
+
specials.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3364
|
+
type: "button",
|
|
3365
|
+
className: PricingOverviewDialog_module_css_default["expandArrow"],
|
|
3366
|
+
"aria-expanded": expanded,
|
|
3367
|
+
"aria-label": t("pricing.expand"),
|
|
3368
|
+
onClick: (event) => {
|
|
3369
|
+
event.stopPropagation();
|
|
3370
|
+
setExpandedId((previous) => previous === model.modelId ? null : model.modelId);
|
|
3371
|
+
},
|
|
3372
|
+
children: expanded ? "▾" : "▸"
|
|
3373
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3374
|
+
className: PricingOverviewDialog_module_css_default["arrowGap"],
|
|
3375
|
+
"aria-hidden": true
|
|
3376
|
+
}),
|
|
3377
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3378
|
+
className: PricingOverviewDialog_module_css_default["modelName"],
|
|
3379
|
+
children: model.modelId
|
|
3380
|
+
}),
|
|
3381
|
+
usedModels.has(model.modelId) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3382
|
+
className: PricingOverviewDialog_module_css_default["usedTag"],
|
|
3383
|
+
children: t("pricing.used")
|
|
3384
|
+
}) : null
|
|
3385
|
+
]
|
|
3386
|
+
})
|
|
3387
|
+
}),
|
|
3388
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
3389
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
3390
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
3391
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite }),
|
|
3392
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatCost(cost, view) })
|
|
3393
|
+
]
|
|
3394
|
+
}), expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3395
|
+
className: PricingOverviewDialog_module_css_default["expansionRow"],
|
|
3396
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3397
|
+
colSpan: 6,
|
|
3398
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3399
|
+
className: PricingOverviewDialog_module_css_default["specialRows"],
|
|
3400
|
+
children: specials.map((special, index) => {
|
|
3401
|
+
const specialBilled = billedRates(special.tier?.rates ?? special.slot.rates, view);
|
|
3402
|
+
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"))}`;
|
|
3403
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3404
|
+
className: PricingOverviewDialog_module_css_default["specialRow"],
|
|
3405
|
+
children: [
|
|
3406
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3407
|
+
className: PricingOverviewDialog_module_css_default["specialLabel"],
|
|
3408
|
+
children: label
|
|
3409
|
+
}),
|
|
3410
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3411
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3412
|
+
children: specialBilled.input
|
|
3413
|
+
}),
|
|
3414
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3415
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3416
|
+
children: specialBilled.output
|
|
3417
|
+
}),
|
|
3418
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3419
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3420
|
+
children: specialBilled.cacheRead
|
|
3421
|
+
}),
|
|
3422
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3423
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3424
|
+
children: specialBilled.cacheWrite
|
|
3425
|
+
}),
|
|
3426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3427
|
+
className: PricingOverviewDialog_module_css_default["specialRate"],
|
|
3428
|
+
children: formatCost(special.cost, view)
|
|
3429
|
+
})
|
|
3430
|
+
]
|
|
3431
|
+
}, index);
|
|
3432
|
+
})
|
|
3433
|
+
})
|
|
3434
|
+
})
|
|
3435
|
+
}) : null] }, model.modelId);
|
|
3436
|
+
}) })]
|
|
3437
|
+
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3438
|
+
className: PricingDialog_module_css_default["rateNote"],
|
|
3439
|
+
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
3440
|
+
}) : null]
|
|
3441
|
+
})
|
|
3442
|
+
] }) : null,
|
|
3443
|
+
detail !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
|
|
3444
|
+
model: detail.modelId,
|
|
3445
|
+
rules: detail.rules,
|
|
3446
|
+
view,
|
|
3447
|
+
onClose: () => setDetail(null),
|
|
3448
|
+
t
|
|
3449
|
+
}) : null
|
|
3450
|
+
]
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
//#endregion
|
|
3454
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\StatCard.module.css.mjs
|
|
3455
|
+
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}";
|
|
3456
|
+
const tagId$4 = "@laoyuehanni/dsh-token-usage/StatCard.module.css";
|
|
3457
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$4) + "]") === null) {
|
|
3458
|
+
const tag = document.createElement("style");
|
|
3459
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
3460
|
+
tag.dataset.pluginCss = tagId$4;
|
|
3461
|
+
tag.textContent = css$4;
|
|
3462
|
+
document.head.appendChild(tag);
|
|
3463
|
+
}
|
|
3464
|
+
var StatCard_module_css_default = {
|
|
3465
|
+
"card": "F2LbNW_card",
|
|
3466
|
+
"cardLabel": "F2LbNW_cardLabel",
|
|
3467
|
+
"cardValue": "F2LbNW_cardValue",
|
|
3468
|
+
"cardValueMain": "F2LbNW_cardValueMain",
|
|
3469
|
+
"pill": "F2LbNW_pill",
|
|
3470
|
+
"pillWrap": "F2LbNW_pillWrap",
|
|
3471
|
+
"split": "F2LbNW_split",
|
|
3472
|
+
"splitFail": "F2LbNW_splitFail",
|
|
3473
|
+
"splitFailHead": "F2LbNW_splitFailHead",
|
|
3474
|
+
"splitOk": "F2LbNW_splitOk",
|
|
3475
|
+
"splitSep": "F2LbNW_splitSep"
|
|
3476
|
+
};
|
|
3477
|
+
//#endregion
|
|
3478
|
+
//#region src/client/StatCard.tsx
|
|
3479
|
+
/**
|
|
3480
|
+
* Render one stat card. The value uses the standard label-primary color.
|
|
3481
|
+
* The label clamps to one line and ellipsizes if the column is squeezed.
|
|
3482
|
+
*/
|
|
3483
|
+
function StatCard({ label, value }) {
|
|
3484
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3485
|
+
className: StatCard_module_css_default["card"],
|
|
3486
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3487
|
+
className: StatCard_module_css_default["cardLabel"],
|
|
3488
|
+
children: label
|
|
3489
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3490
|
+
className: StatCard_module_css_default["cardValue"],
|
|
3491
|
+
children: value
|
|
3492
|
+
})]
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Compact "失败 n" chip for the requests **card** only. Hovering or focusing
|
|
3497
|
+
* it lists `限流 ×count` per class. Zero failures render nothing. Per-model
|
|
3498
|
+
* tables do not use this — they print `A/B` via {@link RequestsCell}.
|
|
3499
|
+
*/
|
|
3500
|
+
function FailurePill({ failures, failuresByCode, t }) {
|
|
3501
|
+
if (failures === 0) return null;
|
|
3502
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3503
|
+
className: StatCard_module_css_default["pillWrap"],
|
|
3504
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
3505
|
+
label: failuresTooltip(failuresByCode, t),
|
|
3506
|
+
side: "bottom",
|
|
3507
|
+
delayMs: 200,
|
|
3508
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3509
|
+
className: StatCard_module_css_default["pill"],
|
|
3510
|
+
tabIndex: 0,
|
|
3511
|
+
children: t("stat.failuresPill", { count: failures.toLocaleString() })
|
|
3512
|
+
})
|
|
3513
|
+
})
|
|
3514
|
+
});
|
|
3515
|
+
}
|
|
3516
|
+
/**
|
|
3517
|
+
* The requests tile both dashboards share: hero figure is the successful
|
|
3518
|
+
* count; a compact pill to its right carries the failure count.
|
|
3519
|
+
*/
|
|
3520
|
+
function RequestsStatCard({ requests, failures, failuresByCode, t }) {
|
|
3521
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatCard, {
|
|
3522
|
+
label: t("stat.requests"),
|
|
3523
|
+
value: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3524
|
+
className: StatCard_module_css_default["cardValueMain"],
|
|
3525
|
+
children: requests.toLocaleString()
|
|
3526
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailurePill, {
|
|
3527
|
+
failures,
|
|
3528
|
+
failuresByCode,
|
|
3529
|
+
t
|
|
3530
|
+
})] })
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
/** Column header for the per-model success/fail split: same 3-track
|
|
3534
|
+
* grid as {@link RequestsCell} so the slash sits on the column midline. */
|
|
3535
|
+
function RequestsSplitHead({ t }) {
|
|
3536
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3537
|
+
className: StatCard_module_css_default["split"],
|
|
3538
|
+
children: [
|
|
3539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3540
|
+
className: StatCard_module_css_default["splitOk"],
|
|
3541
|
+
children: t("stat.ok")
|
|
3542
|
+
}),
|
|
3543
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3544
|
+
className: StatCard_module_css_default["splitSep"],
|
|
3545
|
+
"aria-hidden": true,
|
|
3546
|
+
children: "/"
|
|
3547
|
+
}),
|
|
3548
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3549
|
+
className: StatCard_module_css_default["splitFailHead"],
|
|
3550
|
+
children: t("stat.fail")
|
|
3551
|
+
})
|
|
3552
|
+
]
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
/** One table cell: successful count, and when failures > 0 a slash on
|
|
3556
|
+
* the column midline plus the failure count in the error color.
|
|
3557
|
+
* Zero failures print only A (same left track, so the figure still
|
|
3558
|
+
* lines up with rows that have a B). Hovering B lists the per-code
|
|
3559
|
+
* breakdown. */
|
|
3560
|
+
function RequestsCell({ requests, failures, failuresByCode, t }) {
|
|
2682
3561
|
const ok = requests.toLocaleString();
|
|
2683
3562
|
const okFigure = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2684
3563
|
className: StatCard_module_css_default["splitOk"],
|
|
@@ -2716,6 +3595,272 @@ window.__ModuleLoader__.load({
|
|
|
2716
3595
|
});
|
|
2717
3596
|
}
|
|
2718
3597
|
//#endregion
|
|
3598
|
+
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\SessionTable.module.css.mjs
|
|
3599
|
+
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}";
|
|
3600
|
+
const tagId$3 = "@laoyuehanni/dsh-token-usage/SessionTable.module.css";
|
|
3601
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$3) + "]") === null) {
|
|
3602
|
+
const tag = document.createElement("style");
|
|
3603
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
3604
|
+
tag.dataset.pluginCss = tagId$3;
|
|
3605
|
+
tag.textContent = css$3;
|
|
3606
|
+
document.head.appendChild(tag);
|
|
3607
|
+
}
|
|
3608
|
+
var SessionTable_module_css_default = {
|
|
3609
|
+
"badge": "DW1kVq_badge",
|
|
3610
|
+
"dirTail": "DW1kVq_dirTail",
|
|
3611
|
+
"groupCount": "DW1kVq_groupCount",
|
|
3612
|
+
"groupHead": "DW1kVq_groupHead",
|
|
3613
|
+
"groupRow": "DW1kVq_groupRow",
|
|
3614
|
+
"head": "DW1kVq_head",
|
|
3615
|
+
"jumpable": "DW1kVq_jumpable",
|
|
3616
|
+
"segActive": "DW1kVq_segActive",
|
|
3617
|
+
"segBtn": "DW1kVq_segBtn",
|
|
3618
|
+
"segmented": "DW1kVq_segmented",
|
|
3619
|
+
"sessionCell": "DW1kVq_sessionCell",
|
|
3620
|
+
"sessionCol": "DW1kVq_sessionCol",
|
|
3621
|
+
"sessionHead": "DW1kVq_sessionHead",
|
|
3622
|
+
"sessionIndent": "DW1kVq_sessionIndent",
|
|
3623
|
+
"sessionName": "DW1kVq_sessionName",
|
|
3624
|
+
"sortBtn": "DW1kVq_sortBtn",
|
|
3625
|
+
"sortMark": "DW1kVq_sortMark",
|
|
3626
|
+
"table": "DW1kVq_table",
|
|
3627
|
+
"tableWrap": "DW1kVq_tableWrap"
|
|
3628
|
+
};
|
|
3629
|
+
//#endregion
|
|
3630
|
+
//#region src/client/SessionTable.tsx
|
|
3631
|
+
/**
|
|
3632
|
+
* The settings page's per-session detail table (browser half): the "by
|
|
3633
|
+
* session" mode of the detail-table block. Rows arrive FINAL from the host
|
|
3634
|
+
* route — folded over subagent subtrees (a subagent's only visibility here
|
|
3635
|
+
* is the row's child-count badge; the conversation view's subagent table
|
|
3636
|
+
* owns the per-child drill-down), cost-sorted, top-N truncated, with the
|
|
3637
|
+
* metadata index's titles and directories attached — so this component only
|
|
3638
|
+
* re-organizes presentation: the optional directory grouping (default on,
|
|
3639
|
+
* session-local, no request; grouped rows indent under their directory
|
|
3640
|
+
* head) and the identity fallback for titleless sessions (short id + time
|
|
3641
|
+
* span; the plugin never fabricates a title). Rows carry no click behavior,
|
|
3642
|
+
* matching the per-model table.
|
|
3643
|
+
*
|
|
3644
|
+
* @module token-usage/client/SessionTable
|
|
3645
|
+
*/
|
|
3646
|
+
/** The last path segment of a directory, on either separator. */
|
|
3647
|
+
function dirTailOf(cwd) {
|
|
3648
|
+
const parts = cwd.split(/[\\/]/u).filter((part) => part !== "");
|
|
3649
|
+
return parts[parts.length - 1] ?? cwd;
|
|
3650
|
+
}
|
|
3651
|
+
/** A short session-id fallback: the leading chunk is usually enough to
|
|
3652
|
+
* tell sessions apart when no title ever landed. */
|
|
3653
|
+
function shortIdOf(sessionId) {
|
|
3654
|
+
return sessionId.length > 8 ? `${sessionId.slice(0, 8)}…` : sessionId;
|
|
3655
|
+
}
|
|
3656
|
+
/** Browser-level grouping preference: localStorage, not per-component state —
|
|
3657
|
+
* a filter change unmounts this table (the section flips to its loading
|
|
3658
|
+
* branch), and the choice must survive that remount as well as reloads. */
|
|
3659
|
+
const SESSION_GROUPED_KEY = "dsh.token-usage.sessionGrouped";
|
|
3660
|
+
function readGroupedPreference() {
|
|
3661
|
+
if (typeof localStorage === "undefined") return true;
|
|
3662
|
+
try {
|
|
3663
|
+
return localStorage.getItem(SESSION_GROUPED_KEY) !== "0";
|
|
3664
|
+
} catch {
|
|
3665
|
+
return true;
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
function writeGroupedPreference(grouped) {
|
|
3669
|
+
try {
|
|
3670
|
+
if (grouped) localStorage.removeItem(SESSION_GROUPED_KEY);
|
|
3671
|
+
else localStorage.setItem(SESSION_GROUPED_KEY, "0");
|
|
3672
|
+
} catch {}
|
|
3673
|
+
}
|
|
3674
|
+
function sortValueOf(row, key) {
|
|
3675
|
+
if (key === "tokens") return totalTokens(row.totals);
|
|
3676
|
+
if (key === "cost") return row.cost;
|
|
3677
|
+
return row.lastTime;
|
|
3678
|
+
}
|
|
3679
|
+
function nextSort(current, key) {
|
|
3680
|
+
if (current?.key !== key) return {
|
|
3681
|
+
key,
|
|
3682
|
+
dir: "desc"
|
|
3683
|
+
};
|
|
3684
|
+
if (current.dir === "desc") return {
|
|
3685
|
+
key,
|
|
3686
|
+
dir: "asc"
|
|
3687
|
+
};
|
|
3688
|
+
return null;
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Render the session table: the grouping switch above the table, optional
|
|
3692
|
+
* directory groups (rows indent under their group head), one row per
|
|
3693
|
+
* served session. The token / cost / last-active headers sort the rows
|
|
3694
|
+
* client-side within the served set (groups keep their directory order;
|
|
3695
|
+
* rows reorder inside each group). Holding Ctrl over a session title draws
|
|
3696
|
+
* a dashed underline and a click jumps to that session (the parent closes
|
|
3697
|
+
* the settings panel; the conversation view lands on the session's last
|
|
3698
|
+
* used tab) — rows the session controller does not list never invite it.
|
|
3699
|
+
* @param props - the served rows, the currency view, the session jump
|
|
3700
|
+
* seats (absent on tests / hosts without the controller), locale.
|
|
3701
|
+
*/
|
|
3702
|
+
function SessionTable({ rows, view, t, sessionListed, openSession }) {
|
|
3703
|
+
const [grouped, setGrouped] = (0, react.useState)(readGroupedPreference);
|
|
3704
|
+
const toggleGrouped = (next) => {
|
|
3705
|
+
setGrouped(next);
|
|
3706
|
+
writeGroupedPreference(next);
|
|
3707
|
+
};
|
|
3708
|
+
const [sort, setSort] = (0, react.useState)(null);
|
|
3709
|
+
const [ctrlHeld, setCtrlHeld] = (0, react.useState)(false);
|
|
3710
|
+
(0, react.useEffect)(() => {
|
|
3711
|
+
const down = (event) => {
|
|
3712
|
+
if (event.key === "Control") setCtrlHeld(true);
|
|
3713
|
+
};
|
|
3714
|
+
const up = (event) => {
|
|
3715
|
+
if (event.key === "Control") setCtrlHeld(false);
|
|
3716
|
+
};
|
|
3717
|
+
const blur = () => setCtrlHeld(false);
|
|
3718
|
+
window.addEventListener("keydown", down);
|
|
3719
|
+
window.addEventListener("keyup", up);
|
|
3720
|
+
window.addEventListener("blur", blur);
|
|
3721
|
+
return () => {
|
|
3722
|
+
window.removeEventListener("keydown", down);
|
|
3723
|
+
window.removeEventListener("keyup", up);
|
|
3724
|
+
window.removeEventListener("blur", blur);
|
|
3725
|
+
};
|
|
3726
|
+
}, []);
|
|
3727
|
+
const jumpable = (id) => ctrlHeld && sessionListed !== void 0 && openSession !== void 0 && sessionListed(id);
|
|
3728
|
+
const sorted = (0, react.useMemo)(() => {
|
|
3729
|
+
if (sort === null) return rows;
|
|
3730
|
+
const factor = sort.dir === "desc" ? -1 : 1;
|
|
3731
|
+
return [...rows].sort((left, right) => factor * (sortValueOf(left, sort.key) - sortValueOf(right, sort.key)) || (left.sessionId < right.sessionId ? -1 : 1));
|
|
3732
|
+
}, [rows, sort]);
|
|
3733
|
+
const groups = (0, react.useMemo)(() => {
|
|
3734
|
+
if (!grouped) return null;
|
|
3735
|
+
const map = /* @__PURE__ */ new Map();
|
|
3736
|
+
for (const row of sorted) {
|
|
3737
|
+
const key = row.cwd ?? "";
|
|
3738
|
+
const bucket = map.get(key) ?? [];
|
|
3739
|
+
bucket.push(row);
|
|
3740
|
+
map.set(key, bucket);
|
|
3741
|
+
}
|
|
3742
|
+
return [...map.entries()].sort((left, right) => {
|
|
3743
|
+
if (left[0] === "") return 1;
|
|
3744
|
+
if (right[0] === "") return -1;
|
|
3745
|
+
return left[0].localeCompare(right[0]);
|
|
3746
|
+
});
|
|
3747
|
+
}, [sorted, grouped]);
|
|
3748
|
+
/** One sortable header cell: the column name as the toggle, the current
|
|
3749
|
+
* direction marked and announced via aria-sort. */
|
|
3750
|
+
const sortHead = (key, label) => {
|
|
3751
|
+
const active = sort?.key === key;
|
|
3752
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3753
|
+
...active ? { "aria-sort": sort.dir === "desc" ? "descending" : "ascending" } : {},
|
|
3754
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3755
|
+
type: "button",
|
|
3756
|
+
className: SessionTable_module_css_default["sortBtn"],
|
|
3757
|
+
onClick: () => setSort((previous) => nextSort(previous, key)),
|
|
3758
|
+
children: [label, active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3759
|
+
className: SessionTable_module_css_default["sortMark"],
|
|
3760
|
+
children: sort.dir === "desc" ? "▼" : "▲"
|
|
3761
|
+
}) : null]
|
|
3762
|
+
})
|
|
3763
|
+
});
|
|
3764
|
+
};
|
|
3765
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3766
|
+
className: SessionTable_module_css_default["head"],
|
|
3767
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3768
|
+
className: SessionTable_module_css_default["segmented"],
|
|
3769
|
+
role: "group",
|
|
3770
|
+
"aria-label": t("session.group.label"),
|
|
3771
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3772
|
+
type: "button",
|
|
3773
|
+
className: grouped ? `${SessionTable_module_css_default["segBtn"]} ${SessionTable_module_css_default["segActive"]}` : SessionTable_module_css_default["segBtn"],
|
|
3774
|
+
"aria-pressed": grouped,
|
|
3775
|
+
onClick: () => toggleGrouped(true),
|
|
3776
|
+
children: t("session.group.on")
|
|
3777
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3778
|
+
type: "button",
|
|
3779
|
+
className: !grouped ? `${SessionTable_module_css_default["segBtn"]} ${SessionTable_module_css_default["segActive"]}` : SessionTable_module_css_default["segBtn"],
|
|
3780
|
+
"aria-pressed": !grouped,
|
|
3781
|
+
onClick: () => toggleGrouped(false),
|
|
3782
|
+
children: t("session.group.off")
|
|
3783
|
+
})]
|
|
3784
|
+
})
|
|
3785
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3786
|
+
className: SessionTable_module_css_default["tableWrap"],
|
|
3787
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3788
|
+
className: SessionTable_module_css_default["table"],
|
|
3789
|
+
"aria-label": t("bySession.title"),
|
|
3790
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3791
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3792
|
+
className: SessionTable_module_css_default["sessionHead"],
|
|
3793
|
+
children: t("session.titleCol")
|
|
3794
|
+
}),
|
|
3795
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3796
|
+
"aria-label": t("stat.successFail"),
|
|
3797
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsSplitHead, { t })
|
|
3798
|
+
}),
|
|
3799
|
+
sortHead("tokens", t("stat.totalTokens")),
|
|
3800
|
+
sortHead("cost", t("stat.cost")),
|
|
3801
|
+
sortHead("lastTime", t("session.lastActive"))
|
|
3802
|
+
] }) }), /* @__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, {
|
|
3803
|
+
cwd,
|
|
3804
|
+
count: groupRows.length,
|
|
3805
|
+
t,
|
|
3806
|
+
children: groupRows.map((row) => renderRow(row, true))
|
|
3807
|
+
}, cwd === "" ? "\0" : cwd)) })]
|
|
3808
|
+
})
|
|
3809
|
+
})] });
|
|
3810
|
+
function renderRow(row, indented) {
|
|
3811
|
+
const jump = jumpable(row.sessionId);
|
|
3812
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3813
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
3814
|
+
className: indented ? `${SessionTable_module_css_default["sessionCol"]} ${SessionTable_module_css_default["sessionIndent"]}` : SessionTable_module_css_default["sessionCol"],
|
|
3815
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3816
|
+
className: SessionTable_module_css_default["sessionCell"],
|
|
3817
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3818
|
+
type: "button",
|
|
3819
|
+
className: jump ? `${SessionTable_module_css_default["sessionName"]} ${SessionTable_module_css_default["jumpable"]}` : SessionTable_module_css_default["sessionName"],
|
|
3820
|
+
title: jump ? t("session.openHint") : void 0,
|
|
3821
|
+
onClick: jump ? (event) => {
|
|
3822
|
+
event.preventDefault();
|
|
3823
|
+
openSession?.(row.sessionId);
|
|
3824
|
+
} : void 0,
|
|
3825
|
+
children: row.title !== void 0 ? row.title : `${shortIdOf(row.sessionId)} · ${dayKeyOf(new Date(row.firstTime))} – ${dayKeyOf(new Date(row.lastTime))}`
|
|
3826
|
+
}), row.childCount !== void 0 && row.childCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3827
|
+
className: SessionTable_module_css_default["badge"],
|
|
3828
|
+
"aria-label": t("view.subagents.nested", { count: String(row.childCount) }),
|
|
3829
|
+
children: t("view.subagents.nested", { count: String(row.childCount) })
|
|
3830
|
+
}) : null]
|
|
3831
|
+
}), !indented && row.cwd !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3832
|
+
className: SessionTable_module_css_default["dirTail"],
|
|
3833
|
+
children: dirTailOf(row.cwd)
|
|
3834
|
+
}) : null]
|
|
3835
|
+
}),
|
|
3836
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
|
|
3837
|
+
requests: row.totals.requests,
|
|
3838
|
+
failures: row.totals.failures ?? 0,
|
|
3839
|
+
failuresByCode: row.totals.failuresByCode,
|
|
3840
|
+
t
|
|
3841
|
+
}) }),
|
|
3842
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatTokens(totalTokens(row.totals)) }),
|
|
3843
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: formatCost(row.cost, view) }),
|
|
3844
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: dayKeyOf(new Date(row.lastTime)) })
|
|
3845
|
+
] }, row.sessionId);
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
/** One directory group: a full-width head row with the directory tail, then
|
|
3849
|
+
* the group's rows (a keyed fragment keeps `<tr>`s table-legal). */
|
|
3850
|
+
function FragmentGroup({ cwd, count, t, children }) {
|
|
3851
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3852
|
+
className: SessionTable_module_css_default["groupRow"],
|
|
3853
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("td", {
|
|
3854
|
+
colSpan: 5,
|
|
3855
|
+
className: SessionTable_module_css_default["groupHead"],
|
|
3856
|
+
children: [cwd === "" ? t("session.untitledDir") : dirTailOf(cwd), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3857
|
+
className: SessionTable_module_css_default["groupCount"],
|
|
3858
|
+
children: String(count)
|
|
3859
|
+
})]
|
|
3860
|
+
})
|
|
3861
|
+
}), children] });
|
|
3862
|
+
}
|
|
3863
|
+
//#endregion
|
|
2719
3864
|
//#region src/client/trend-chart/axis.ts
|
|
2720
3865
|
/**
|
|
2721
3866
|
* Trend-chart axis helpers: the roundest step from 1/2/2.5/5 × 10ⁿ not
|
|
@@ -3313,7 +4458,7 @@ window.__ModuleLoader__.load({
|
|
|
3313
4458
|
}
|
|
3314
4459
|
//#endregion
|
|
3315
4460
|
//#region \0dsh-css:D:\Code\dsh-token-usage\src\client\TokenUsageSection.module.css.mjs
|
|
3316
|
-
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}.
|
|
4461
|
+
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}button.RbkiSa_modelName{max-width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;margin:0;padding:0}button.RbkiSa_modelName:hover{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary))}.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_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)}";
|
|
3317
4462
|
const tagId$1 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
|
|
3318
4463
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
3319
4464
|
const tag = document.createElement("style");
|
|
@@ -3325,25 +4470,20 @@ window.__ModuleLoader__.load({
|
|
|
3325
4470
|
var TokenUsageSection_module_css_default = {
|
|
3326
4471
|
"button": "RbkiSa_button",
|
|
3327
4472
|
"cards": "RbkiSa_cards",
|
|
3328
|
-
"conditionCell": "RbkiSa_conditionCell",
|
|
3329
|
-
"conditionHead": "RbkiSa_conditionHead",
|
|
3330
|
-
"dialog": "RbkiSa_dialog",
|
|
3331
|
-
"dialogClose": "RbkiSa_dialogClose",
|
|
3332
|
-
"dialogHead": "RbkiSa_dialogHead",
|
|
3333
|
-
"dialogTitle": "RbkiSa_dialogTitle",
|
|
3334
4473
|
"empty": "RbkiSa_empty",
|
|
3335
4474
|
"error": "RbkiSa_error",
|
|
3336
4475
|
"filters": "RbkiSa_filters",
|
|
3337
|
-
"groupRow": "RbkiSa_groupRow",
|
|
3338
4476
|
"head": "RbkiSa_head",
|
|
3339
4477
|
"modelCell": "RbkiSa_modelCell",
|
|
3340
4478
|
"modelCol": "RbkiSa_modelCol",
|
|
3341
4479
|
"modelHead": "RbkiSa_modelHead",
|
|
3342
4480
|
"modelName": "RbkiSa_modelName",
|
|
3343
4481
|
"muted": "RbkiSa_muted",
|
|
3344
|
-
"
|
|
3345
|
-
"rateNote": "RbkiSa_rateNote",
|
|
4482
|
+
"pricingLink": "RbkiSa_pricingLink",
|
|
3346
4483
|
"section": "RbkiSa_section",
|
|
4484
|
+
"segActive": "RbkiSa_segActive",
|
|
4485
|
+
"segBtn": "RbkiSa_segBtn",
|
|
4486
|
+
"segmented": "RbkiSa_segmented",
|
|
3347
4487
|
"subtitle": "RbkiSa_subtitle",
|
|
3348
4488
|
"table": "RbkiSa_table",
|
|
3349
4489
|
"tableWrap": "RbkiSa_tableWrap",
|
|
@@ -3357,12 +4497,14 @@ window.__ModuleLoader__.load({
|
|
|
3357
4497
|
* Token-usage settings page (browser half): fetches the stats summary from
|
|
3358
4498
|
* the host route and renders the filter bar (inclusive day range, model
|
|
3359
4499
|
* select, 1d/7d/30d quick ranges where 1d spans today 00:00–23:59), the
|
|
3360
|
-
* total-usage strip, the daily-token trend chart, the per-model detail
|
|
3361
|
-
* table with the hit rate last
|
|
3362
|
-
*
|
|
3363
|
-
*
|
|
3364
|
-
*
|
|
3365
|
-
*
|
|
4500
|
+
* total-usage strip, the daily-token trend chart, and the per-model detail
|
|
4501
|
+
* table with the hit rate last — all following the active filters. A
|
|
4502
|
+
* priced model name is the row's price affordance (one click opens
|
|
4503
|
+
* PricingDialog.tsx); unpriced rows keep the in-cell tag. The filter
|
|
4504
|
+
* row's tail link opens the filter-free pricing-overview dialog
|
|
4505
|
+
* (PricingOverviewDialog.tsx). There is no refresh
|
|
4506
|
+
* button: entering the page or changing a filter refetches (the route
|
|
4507
|
+
* answers no-store); only the error state keeps a retry.
|
|
3366
4508
|
*
|
|
3367
4509
|
* @module token-usage/client/TokenUsageSection
|
|
3368
4510
|
*/
|
|
@@ -3405,157 +4547,6 @@ window.__ModuleLoader__.load({
|
|
|
3405
4547
|
const range = quickRange(days);
|
|
3406
4548
|
return filters.from === range.from && filters.to === range.to;
|
|
3407
4549
|
}
|
|
3408
|
-
/** The four base rates of one model as display text (symbol included,
|
|
3409
|
-
* converted for a USD view); a missing cache rate bills at the input rate. */
|
|
3410
|
-
function billedRates(rates, view) {
|
|
3411
|
-
return {
|
|
3412
|
-
input: formatRateWithSymbol(rates.inputPerMillion, view),
|
|
3413
|
-
output: formatRateWithSymbol(rates.outputPerMillion, view),
|
|
3414
|
-
cacheRead: formatRateWithSymbol(rates.cacheReadPerMillion ?? rates.inputPerMillion, view),
|
|
3415
|
-
cacheWrite: formatRateWithSymbol(rates.cacheWritePerMillion ?? rates.inputPerMillion, view)
|
|
3416
|
-
};
|
|
3417
|
-
}
|
|
3418
|
-
/** `HH:MM-HH:MM` of one peak window (half-open, local minutes). */
|
|
3419
|
-
function windowText(window) {
|
|
3420
|
-
const clock = (minute) => `${String(Math.floor(minute / 60)).padStart(2, "0")}:${String(minute % 60).padStart(2, "0")}`;
|
|
3421
|
-
return `${clock(window.startMinute)}-${clock(window.endMinute)}`;
|
|
3422
|
-
}
|
|
3423
|
-
/** The when-it-applies text of one peak slot: its label plus its windows. */
|
|
3424
|
-
function slotCondition(slot, t) {
|
|
3425
|
-
return `${slot.label ?? t("pricing.peak")} ${slot.windows.map(windowText).join(t("pricing.windowSep"))}`;
|
|
3426
|
-
}
|
|
3427
|
-
/**
|
|
3428
|
-
* The price rows of one rate node (a time rule's or the model root's): the
|
|
3429
|
-
* node's own base rates, then its peak slots, then its context tiers
|
|
3430
|
-
* (ascending), each tier followed by the peak slots hanging on that tier —
|
|
3431
|
-
* mirroring {@link resolveRate}'s node chain, where a matching tier's slots
|
|
3432
|
-
* replace the node's and peak rates replace the node's rates wholesale.
|
|
3433
|
-
*/
|
|
3434
|
-
function nodePriceRows(node, t) {
|
|
3435
|
-
const rows = [{
|
|
3436
|
-
condition: t("pricing.default"),
|
|
3437
|
-
rates: node.rates
|
|
3438
|
-
}];
|
|
3439
|
-
const tiers = [...node.tiers ?? []].sort((a, b) => a.threshold - b.threshold);
|
|
3440
|
-
for (const tier of tiers) {
|
|
3441
|
-
const tierCondition = t("pricing.tier", { threshold: formatTokens(tier.threshold) });
|
|
3442
|
-
rows.push({
|
|
3443
|
-
condition: tierCondition,
|
|
3444
|
-
rates: tier.rates
|
|
3445
|
-
});
|
|
3446
|
-
for (const slot of tier.dailySlots ?? []) rows.push({
|
|
3447
|
-
condition: `${tierCondition} · ${slotCondition(slot, t)}`,
|
|
3448
|
-
rates: slot.rates
|
|
3449
|
-
});
|
|
3450
|
-
}
|
|
3451
|
-
for (const slot of node.slots ?? []) rows.push({
|
|
3452
|
-
condition: slotCondition(slot, t),
|
|
3453
|
-
rates: slot.rates
|
|
3454
|
-
});
|
|
3455
|
-
return rows;
|
|
3456
|
-
}
|
|
3457
|
-
/**
|
|
3458
|
-
* One model's price table: rows are billing conditions — grouped into the
|
|
3459
|
-
* model root (“常规”, omitted when it is the only group) and one group per
|
|
3460
|
-
* time rule with its date window — so tier, peak, and time-rule pricing
|
|
3461
|
-
* each show when they apply and what they bill. Shared by the pricing
|
|
3462
|
-
* dialog; the structure mirrors {@link resolveRate}'s node chain.
|
|
3463
|
-
*/
|
|
3464
|
-
function ModelPriceTable({ rules, view, t }) {
|
|
3465
|
-
const groups = [{
|
|
3466
|
-
title: rules.timeRules.length > 0 ? t("pricing.regular") : null,
|
|
3467
|
-
rows: nodePriceRows({
|
|
3468
|
-
rates: rules.base,
|
|
3469
|
-
tiers: rules.contextTiers,
|
|
3470
|
-
slots: rules.dailySlots
|
|
3471
|
-
}, t)
|
|
3472
|
-
}, ...[...rules.timeRules].sort((a, b) => b.endTime - a.endTime).map((rule) => ({
|
|
3473
|
-
title: `${rule.label !== void 0 ? `${rule.label} ` : ""}${rule.startTime > 0 ? `${dayKeyOf(/* @__PURE__ */ new Date(rule.startTime * 1e3))} ~ ` : "~ "}${dayKeyOf(/* @__PURE__ */ new Date(rule.endTime * 1e3))}`,
|
|
3474
|
-
rows: nodePriceRows({
|
|
3475
|
-
rates: rule.rates,
|
|
3476
|
-
tiers: rule.contextTiers,
|
|
3477
|
-
slots: rule.dailySlots
|
|
3478
|
-
}, t)
|
|
3479
|
-
}))];
|
|
3480
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3481
|
-
className: TokenUsageSection_module_css_default["tableWrap"],
|
|
3482
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3483
|
-
className: TokenUsageSection_module_css_default["table"],
|
|
3484
|
-
"aria-label": t("pricing.title"),
|
|
3485
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3486
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3487
|
-
className: TokenUsageSection_module_css_default["conditionHead"],
|
|
3488
|
-
children: t("pricing.condition")
|
|
3489
|
-
}),
|
|
3490
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.input"), t("pricing.perMillion")] }),
|
|
3491
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.output"), t("pricing.perMillion")] }),
|
|
3492
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheRead"), t("pricing.perMillion")] }),
|
|
3493
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("th", { children: [t("pricing.cacheWrite"), t("pricing.perMillion")] })
|
|
3494
|
-
] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: groups.flatMap((group) => [...group.title !== null ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3495
|
-
className: TokenUsageSection_module_css_default["groupRow"],
|
|
3496
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3497
|
-
colSpan: 5,
|
|
3498
|
-
children: group.title
|
|
3499
|
-
})
|
|
3500
|
-
}, group.title)] : [], ...group.rows.map((row, index) => {
|
|
3501
|
-
const billed = billedRates(row.rates, view);
|
|
3502
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3503
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3504
|
-
className: TokenUsageSection_module_css_default["conditionCell"],
|
|
3505
|
-
children: row.condition
|
|
3506
|
-
}),
|
|
3507
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.input }),
|
|
3508
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.output }),
|
|
3509
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheRead }),
|
|
3510
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: billed.cacheWrite })
|
|
3511
|
-
] }, `${group.title ?? ""}-${index}-${row.condition}`);
|
|
3512
|
-
})]) })]
|
|
3513
|
-
}), view.symbol === "$" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3514
|
-
className: TokenUsageSection_module_css_default["rateNote"],
|
|
3515
|
-
children: t("pricing.exchangeRateNote", { rate: formatRate(view.rate) })
|
|
3516
|
-
}) : null]
|
|
3517
|
-
});
|
|
3518
|
-
}
|
|
3519
|
-
/**
|
|
3520
|
-
* The pricing dialog of one model: a native `<dialog>` (Esc closes, focus
|
|
3521
|
-
* is trapped, the backdrop dims, and the top layer renders it above the
|
|
3522
|
-
* table's scroll shell) opened by the “定价” affordance in a model row.
|
|
3523
|
-
* Mounts only while a model is selected; every close path funnels through
|
|
3524
|
-
* the dialog's `close` event, which clears the selection and unmounts it.
|
|
3525
|
-
*/
|
|
3526
|
-
function PricingDialog({ model, rules, view, onClose, t }) {
|
|
3527
|
-
const dialogRef = (0, react.useRef)(null);
|
|
3528
|
-
(0, react.useEffect)(() => {
|
|
3529
|
-
const dialog = dialogRef.current;
|
|
3530
|
-
if (dialog !== null && !dialog.open) dialog.showModal();
|
|
3531
|
-
}, []);
|
|
3532
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dialog", {
|
|
3533
|
-
ref: dialogRef,
|
|
3534
|
-
className: TokenUsageSection_module_css_default["dialog"],
|
|
3535
|
-
"aria-label": t("pricing.title"),
|
|
3536
|
-
onClose,
|
|
3537
|
-
onClick: (event) => {
|
|
3538
|
-
if (event.target === dialogRef.current) dialogRef.current?.close();
|
|
3539
|
-
},
|
|
3540
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3541
|
-
className: TokenUsageSection_module_css_default["dialogHead"],
|
|
3542
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3543
|
-
className: TokenUsageSection_module_css_default["dialogTitle"],
|
|
3544
|
-
children: model
|
|
3545
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3546
|
-
type: "button",
|
|
3547
|
-
className: TokenUsageSection_module_css_default["dialogClose"],
|
|
3548
|
-
"aria-label": t("pricing.close"),
|
|
3549
|
-
onClick: () => dialogRef.current?.close(),
|
|
3550
|
-
children: "✕"
|
|
3551
|
-
})]
|
|
3552
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPriceTable, {
|
|
3553
|
-
rules,
|
|
3554
|
-
view,
|
|
3555
|
-
t
|
|
3556
|
-
})]
|
|
3557
|
-
});
|
|
3558
|
-
}
|
|
3559
4550
|
/** Quick-range menu entries (labels are locale-free day counts). */
|
|
3560
4551
|
const QUICK_OPTIONS = [
|
|
3561
4552
|
{
|
|
@@ -3572,8 +4563,9 @@ window.__ModuleLoader__.load({
|
|
|
3572
4563
|
}
|
|
3573
4564
|
];
|
|
3574
4565
|
/** The filter bar: quick range menu, day-range picker popover, model
|
|
3575
|
-
* menu — one row, one popover language.
|
|
3576
|
-
|
|
4566
|
+
* menu — one row, one popover language. The row's tail link is an action,
|
|
4567
|
+
* not a selector: it opens the filter-free pricing overview. */
|
|
4568
|
+
function FilterBar({ filters, models, onChange, onPricingTable, t }) {
|
|
3577
4569
|
const quickValue = QUICK_OPTIONS.find((option) => isQuickActive(Number(option.value), filters))?.value ?? (filters.from === "" && filters.to === "" ? "all" : "custom");
|
|
3578
4570
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3579
4571
|
className: TokenUsageSection_module_css_default["filters"],
|
|
@@ -3629,6 +4621,12 @@ window.__ModuleLoader__.load({
|
|
|
3629
4621
|
...filters,
|
|
3630
4622
|
model
|
|
3631
4623
|
})
|
|
4624
|
+
}),
|
|
4625
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4626
|
+
type: "button",
|
|
4627
|
+
className: TokenUsageSection_module_css_default["pricingLink"],
|
|
4628
|
+
onClick: onPricingTable,
|
|
4629
|
+
children: t("pricing.table")
|
|
3632
4630
|
})
|
|
3633
4631
|
]
|
|
3634
4632
|
});
|
|
@@ -3636,19 +4634,26 @@ window.__ModuleLoader__.load({
|
|
|
3636
4634
|
/**
|
|
3637
4635
|
* Render the Token Usage section content column. The `t` seat arrives from
|
|
3638
4636
|
* the registration's `locale:` declaration and follows the active locale.
|
|
3639
|
-
*
|
|
3640
|
-
*
|
|
4637
|
+
* The session jump seats (`sessionListed` / `openSession`) come from the
|
|
4638
|
+
* registration's `inject:` — the session table's Ctrl+click affordance
|
|
4639
|
+
* reads the controller's list and opens the target session.
|
|
4640
|
+
* @param props - the settings shell's owner share (close rides along to the
|
|
4641
|
+
* session jump: the jump closes the panel) plus the injected jump seats and
|
|
4642
|
+
* the framework-injected translate seat.
|
|
3641
4643
|
* @returns the section, one of loading / error / ready.
|
|
3642
4644
|
*/
|
|
3643
|
-
function TokenUsageSection({ t }) {
|
|
4645
|
+
function TokenUsageSection({ t, close, sessionListed, openSession }) {
|
|
3644
4646
|
const rootRef = (0, react.useRef)(null);
|
|
3645
4647
|
useColorSchemeMirror(rootRef);
|
|
3646
4648
|
const [filters, setFilters] = (0, react.useState)(() => ({
|
|
3647
4649
|
model: "",
|
|
3648
4650
|
...quickRange(1)
|
|
3649
4651
|
}));
|
|
4652
|
+
const [detailMode, setDetailMode] = (0, react.useState)("model");
|
|
3650
4653
|
const [models, setModels] = (0, react.useState)([]);
|
|
3651
4654
|
const [detailModel, setDetailModel] = (0, react.useState)(null);
|
|
4655
|
+
const [pricingTableOpen, setPricingTableOpen] = (0, react.useState)(false);
|
|
4656
|
+
const [usedSnapshot, setUsedSnapshot] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
3652
4657
|
const [retryToken, setRetryToken] = (0, react.useState)(0);
|
|
3653
4658
|
const retry = (0, react.useCallback)(() => {
|
|
3654
4659
|
setRetryToken((previous) => previous + 1);
|
|
@@ -3720,8 +4725,18 @@ window.__ModuleLoader__.load({
|
|
|
3720
4725
|
filters,
|
|
3721
4726
|
models,
|
|
3722
4727
|
onChange: setFilters,
|
|
4728
|
+
onPricingTable: () => {
|
|
4729
|
+
setUsedSnapshot(new Set(state.value.byModel.map((row) => row.model)));
|
|
4730
|
+
setPricingTableOpen(true);
|
|
4731
|
+
},
|
|
3723
4732
|
t
|
|
3724
4733
|
}),
|
|
4734
|
+
pricingTableOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingOverviewDialog, {
|
|
4735
|
+
usedModels: usedSnapshot,
|
|
4736
|
+
view,
|
|
4737
|
+
onClose: () => setPricingTableOpen(false),
|
|
4738
|
+
t
|
|
4739
|
+
}) : null,
|
|
3725
4740
|
total.requests === 0 && (total.failures ?? 0) === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3726
4741
|
className: TokenUsageSection_module_css_default["empty"],
|
|
3727
4742
|
children: t("empty")
|
|
@@ -3786,10 +4801,24 @@ window.__ModuleLoader__.load({
|
|
|
3786
4801
|
...filters.to !== "" ? { to: filters.to } : {},
|
|
3787
4802
|
...filters.from !== "" && filters.from === filters.to ? { hours: state.value.byHour } : {}
|
|
3788
4803
|
}),
|
|
3789
|
-
state.value.byModel.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
3790
|
-
className: TokenUsageSection_module_css_default["
|
|
3791
|
-
|
|
3792
|
-
|
|
4804
|
+
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", {
|
|
4805
|
+
className: TokenUsageSection_module_css_default["segmented"],
|
|
4806
|
+
role: "group",
|
|
4807
|
+
"aria-label": t("detail.switch.label"),
|
|
4808
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4809
|
+
type: "button",
|
|
4810
|
+
className: detailMode === "model" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
|
|
4811
|
+
"aria-pressed": detailMode === "model",
|
|
4812
|
+
onClick: () => setDetailMode("model"),
|
|
4813
|
+
children: t("byModel.title")
|
|
4814
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4815
|
+
type: "button",
|
|
4816
|
+
className: detailMode === "session" ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
|
|
4817
|
+
"aria-pressed": detailMode === "session",
|
|
4818
|
+
onClick: () => setDetailMode("session"),
|
|
4819
|
+
children: t("bySession.title")
|
|
4820
|
+
})]
|
|
4821
|
+
}), detailMode === "model" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3793
4822
|
className: TokenUsageSection_module_css_default["tableWrap"],
|
|
3794
4823
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3795
4824
|
className: TokenUsageSection_module_css_default["table"],
|
|
@@ -3815,21 +4844,21 @@ window.__ModuleLoader__.load({
|
|
|
3815
4844
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3816
4845
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3817
4846
|
className: TokenUsageSection_module_css_default["modelCol"],
|
|
3818
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4847
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3819
4848
|
className: TokenUsageSection_module_css_default["modelCell"],
|
|
3820
|
-
children:
|
|
3821
|
-
className: TokenUsageSection_module_css_default["modelName"],
|
|
3822
|
-
children: row.model
|
|
3823
|
-
}), rules !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4849
|
+
children: rules !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3824
4850
|
type: "button",
|
|
3825
|
-
className: TokenUsageSection_module_css_default["
|
|
4851
|
+
className: TokenUsageSection_module_css_default["modelName"],
|
|
3826
4852
|
"aria-label": t("pricing.view", { model: row.model }),
|
|
3827
4853
|
onClick: () => setDetailModel(row.model),
|
|
3828
|
-
children:
|
|
3829
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4854
|
+
children: row.model
|
|
4855
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4856
|
+
className: TokenUsageSection_module_css_default["modelName"],
|
|
4857
|
+
children: row.model
|
|
4858
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3830
4859
|
className: TokenUsageSection_module_css_default["unpricedTag"],
|
|
3831
4860
|
children: t("pricing.unpriced")
|
|
3832
|
-
})]
|
|
4861
|
+
})] })
|
|
3833
4862
|
})
|
|
3834
4863
|
}),
|
|
3835
4864
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestsCell, {
|
|
@@ -3848,6 +4877,19 @@ window.__ModuleLoader__.load({
|
|
|
3848
4877
|
] }, row.model);
|
|
3849
4878
|
}) })]
|
|
3850
4879
|
})
|
|
4880
|
+
}) : (state.value.sessionRows?.length ?? 0) > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionTable, {
|
|
4881
|
+
rows: state.value.sessionRows ?? [],
|
|
4882
|
+
view,
|
|
4883
|
+
t,
|
|
4884
|
+
...sessionListed !== void 0 && openSession !== void 0 ? {
|
|
4885
|
+
sessionListed,
|
|
4886
|
+
openSession: (id) => {
|
|
4887
|
+
if (openSession(id)) close();
|
|
4888
|
+
}
|
|
4889
|
+
} : {}
|
|
4890
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4891
|
+
className: TokenUsageSection_module_css_default["muted"],
|
|
4892
|
+
children: t("chart.empty")
|
|
3851
4893
|
})] }) : null,
|
|
3852
4894
|
detailModel !== null && state.value.pricing[detailModel] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingDialog, {
|
|
3853
4895
|
model: detailModel,
|
|
@@ -4358,6 +5400,14 @@ window.__ModuleLoader__.load({
|
|
|
4358
5400
|
"fail.QUOTA": "配额耗尽",
|
|
4359
5401
|
"fail.CONTEXT_WINDOW_EXCEEDED": "上下文超限",
|
|
4360
5402
|
"fail.INVALID_CREDENTIAL": "凭证无效",
|
|
5403
|
+
"fail.AUTH": "鉴权失败",
|
|
5404
|
+
"fail.INVALID_REQUEST": "请求无效",
|
|
5405
|
+
"fail.MISSING_CREDENTIAL": "缺少凭证",
|
|
5406
|
+
"fail.ABORTED": "已中止",
|
|
5407
|
+
"fail.REQUEST_EXTENSION": "请求扩展失败",
|
|
5408
|
+
"fail.FILES_API": "文件接口异常",
|
|
5409
|
+
"fail.STREAM_CLOSED": "流中断",
|
|
5410
|
+
"fail.MALFORMED_RESPONSE": "响应异常",
|
|
4361
5411
|
"fail.UNKNOWN": "未知错误",
|
|
4362
5412
|
"stat.totalTokens": "总 token",
|
|
4363
5413
|
"stat.hitRate": "命中率",
|
|
@@ -4367,6 +5417,16 @@ window.__ModuleLoader__.load({
|
|
|
4367
5417
|
"stat.cacheRead": "缓",
|
|
4368
5418
|
"stat.cacheWrite": "写",
|
|
4369
5419
|
"byModel.title": "按模型",
|
|
5420
|
+
"bySession.title": "按会话",
|
|
5421
|
+
"detail.switch.label": "明细维度",
|
|
5422
|
+
"session.titleCol": "会话",
|
|
5423
|
+
"session.group.label": "目录分组",
|
|
5424
|
+
"session.group.on": "分组",
|
|
5425
|
+
"session.group.off": "列表",
|
|
5426
|
+
"session.untitledDir": "未指定目录",
|
|
5427
|
+
"session.subagentBadge": "子会话",
|
|
5428
|
+
"session.lastActive": "最近活跃",
|
|
5429
|
+
"session.openHint": "按住 Ctrl 点击打开该会话(用量页签跟随该会话上次的选择)",
|
|
4370
5430
|
"pricing.title": "模型定价",
|
|
4371
5431
|
"pricing.view": "查看 {model} 定价",
|
|
4372
5432
|
"pricing.viewShort": "定价",
|
|
@@ -4384,6 +5444,21 @@ window.__ModuleLoader__.load({
|
|
|
4384
5444
|
"pricing.exchangeRateNote": "按 1 USD = {rate} CNY 换算",
|
|
4385
5445
|
"pricing.unpriced": "未定价",
|
|
4386
5446
|
"pricing.windowSep": "、",
|
|
5447
|
+
"pricing.table": "定价表",
|
|
5448
|
+
"pricing.search": "搜索模型",
|
|
5449
|
+
"pricing.used": "已用",
|
|
5450
|
+
"pricing.overviewFailed": "模型定价获取失败",
|
|
5451
|
+
"pricing.simCost": "模拟费用",
|
|
5452
|
+
"pricing.simInput": "输入 {tokens}",
|
|
5453
|
+
"pricing.simCache": "(缓存 {pct}%)",
|
|
5454
|
+
"pricing.simOutput": "输出 {tokens}",
|
|
5455
|
+
"pricing.simBucketInput": "输入",
|
|
5456
|
+
"pricing.simBucketCacheRead": "缓存读",
|
|
5457
|
+
"pricing.simBucketOutput": "输出",
|
|
5458
|
+
"pricing.simBucketCacheWrite": "缓存写",
|
|
5459
|
+
"pricing.simCase": "案例{index}",
|
|
5460
|
+
"pricing.simUnitOf": "{bucket}({unit})",
|
|
5461
|
+
"pricing.expand": "展开定价条件",
|
|
4387
5462
|
"unpriced.warning": "{count} 个模型未定价:{models}(费用按 {zero} 计)",
|
|
4388
5463
|
"dataDir": "数据目录:{path}",
|
|
4389
5464
|
"card.title": "Token 用量",
|
|
@@ -4413,9 +5488,9 @@ window.__ModuleLoader__.load({
|
|
|
4413
5488
|
"card.fullSync.hint": "手动扫一遍所有 session 日志,把可能漏掉的历史请求补进来(已记录的会跳过)。",
|
|
4414
5489
|
"card.fullSync.button": "开始扫描",
|
|
4415
5490
|
"card.fullSync.running": "扫描中…",
|
|
4416
|
-
"card.fullSync.progress": "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条",
|
|
5491
|
+
"card.fullSync.progress": "已处理 {processed}/{total} 个 session,新增 {added} 条,跳过 {skipped} 条,删除 {removed} 条",
|
|
4417
5492
|
"card.fullSync.failuresNote": ",无法读取 {count} 个 session 已跳过",
|
|
4418
|
-
"card.fullSync.done": "扫描完成:新增 {added} 条,跳过 {skipped} 条",
|
|
5493
|
+
"card.fullSync.done": "扫描完成:新增 {added} 条,跳过 {skipped} 条,删除 {removed} 条",
|
|
4419
5494
|
"card.fullSync.failed": "扫描失败:{error}",
|
|
4420
5495
|
"loadFailed": "统计加载失败:{message}",
|
|
4421
5496
|
"empty": "暂无数据。可调整筛选条件;模型请求成功后会自动写入,安装前已发生的历史记录会在首次启动时自动补齐。",
|
|
@@ -4498,6 +5573,14 @@ window.__ModuleLoader__.load({
|
|
|
4498
5573
|
"fail.QUOTA": "Quota exceeded",
|
|
4499
5574
|
"fail.CONTEXT_WINDOW_EXCEEDED": "Context exceeded",
|
|
4500
5575
|
"fail.INVALID_CREDENTIAL": "Invalid credential",
|
|
5576
|
+
"fail.AUTH": "Auth failed",
|
|
5577
|
+
"fail.INVALID_REQUEST": "Invalid request",
|
|
5578
|
+
"fail.MISSING_CREDENTIAL": "Missing credential",
|
|
5579
|
+
"fail.ABORTED": "Aborted",
|
|
5580
|
+
"fail.REQUEST_EXTENSION": "Request extension failed",
|
|
5581
|
+
"fail.FILES_API": "Files API error",
|
|
5582
|
+
"fail.STREAM_CLOSED": "Stream closed",
|
|
5583
|
+
"fail.MALFORMED_RESPONSE": "Malformed response",
|
|
4501
5584
|
"fail.UNKNOWN": "Unknown error",
|
|
4502
5585
|
"stat.totalTokens": "Total",
|
|
4503
5586
|
"stat.hitRate": "Hit %",
|
|
@@ -4507,6 +5590,16 @@ window.__ModuleLoader__.load({
|
|
|
4507
5590
|
"stat.cacheRead": "Cache",
|
|
4508
5591
|
"stat.cacheWrite": "Write",
|
|
4509
5592
|
"byModel.title": "By model",
|
|
5593
|
+
"bySession.title": "By session",
|
|
5594
|
+
"detail.switch.label": "Detail dimension",
|
|
5595
|
+
"session.titleCol": "Session",
|
|
5596
|
+
"session.group.label": "Directory grouping",
|
|
5597
|
+
"session.group.on": "Grouped",
|
|
5598
|
+
"session.group.off": "List",
|
|
5599
|
+
"session.untitledDir": "No directory",
|
|
5600
|
+
"session.subagentBadge": "Subagent",
|
|
5601
|
+
"session.lastActive": "Last active",
|
|
5602
|
+
"session.openHint": "Ctrl+click to open this session (the usage tab follows its last selection)",
|
|
4510
5603
|
"pricing.title": "Model pricing",
|
|
4511
5604
|
"pricing.view": "View rates for {model}",
|
|
4512
5605
|
"pricing.viewShort": "Rates",
|
|
@@ -4524,6 +5617,21 @@ window.__ModuleLoader__.load({
|
|
|
4524
5617
|
"pricing.exchangeRateNote": "Converted at 1 USD = {rate} CNY",
|
|
4525
5618
|
"pricing.unpriced": "Unpriced",
|
|
4526
5619
|
"pricing.windowSep": ", ",
|
|
5620
|
+
"pricing.table": "Pricing",
|
|
5621
|
+
"pricing.search": "Search models",
|
|
5622
|
+
"pricing.used": "Used",
|
|
5623
|
+
"pricing.overviewFailed": "Failed to load model pricing",
|
|
5624
|
+
"pricing.simCost": "Est. cost",
|
|
5625
|
+
"pricing.simInput": "In {tokens}",
|
|
5626
|
+
"pricing.simCache": " (cache {pct}%)",
|
|
5627
|
+
"pricing.simOutput": "Out {tokens}",
|
|
5628
|
+
"pricing.simBucketInput": "Input",
|
|
5629
|
+
"pricing.simBucketCacheRead": "Cache read",
|
|
5630
|
+
"pricing.simBucketOutput": "Output",
|
|
5631
|
+
"pricing.simBucketCacheWrite": "Cache write",
|
|
5632
|
+
"pricing.simCase": "Case {index}",
|
|
5633
|
+
"pricing.simUnitOf": "{bucket} ({unit})",
|
|
5634
|
+
"pricing.expand": "Show rate conditions",
|
|
4527
5635
|
"unpriced.warning": "{count} models unpriced: {models} (cost counts as {zero})",
|
|
4528
5636
|
"dataDir": "Data directory: {path}",
|
|
4529
5637
|
"card.title": "Token Usage",
|
|
@@ -4553,9 +5661,9 @@ window.__ModuleLoader__.load({
|
|
|
4553
5661
|
"card.fullSync.hint": "Walk every session log once and fold any historical requests the log does not yet hold (rows already recorded are skipped).",
|
|
4554
5662
|
"card.fullSync.button": "Start scan",
|
|
4555
5663
|
"card.fullSync.running": "Scanning…",
|
|
4556
|
-
"card.fullSync.progress": "Processed {processed}/{total} sessions, added {added}, skipped {skipped}",
|
|
5664
|
+
"card.fullSync.progress": "Processed {processed}/{total} sessions, added {added}, skipped {skipped}, removed {removed}",
|
|
4557
5665
|
"card.fullSync.failuresNote": ", {count} unreadable sessions skipped",
|
|
4558
|
-
"card.fullSync.done": "Scan complete: added {added}, skipped {skipped}",
|
|
5666
|
+
"card.fullSync.done": "Scan complete: added {added}, skipped {skipped}, removed {removed}",
|
|
4559
5667
|
"card.fullSync.failed": "Scan failed: {error}",
|
|
4560
5668
|
"loadFailed": "Failed to load stats: {message}",
|
|
4561
5669
|
"empty": "No data yet. Adjust the filters; requests are written automatically after each successful model call, and pre-install history is backfilled automatically on the first startup.",
|
|
@@ -4612,15 +5720,17 @@ window.__ModuleLoader__.load({
|
|
|
4612
5720
|
*/
|
|
4613
5721
|
const TOKEN_USAGE_NS = "token-usage";
|
|
4614
5722
|
/** Required services: the slot registry, the locale dictionaries, the
|
|
4615
|
-
* settings scope,
|
|
4616
|
-
*
|
|
5723
|
+
* settings scope, the workspace navigation service (its native directory
|
|
5724
|
+
* picker backs the card's browse button), and the session controller (the
|
|
5725
|
+
* stats page's Ctrl+click session jump reads the list and opens the target). */
|
|
4617
5726
|
const inject = [
|
|
4618
5727
|
"slots",
|
|
4619
5728
|
"locale",
|
|
4620
5729
|
"connection",
|
|
4621
5730
|
"remote",
|
|
4622
5731
|
"settingsScope",
|
|
4623
|
-
"uiWorkspace"
|
|
5732
|
+
"uiWorkspace",
|
|
5733
|
+
"sessions"
|
|
4624
5734
|
];
|
|
4625
5735
|
/**
|
|
4626
5736
|
* Register the dictionary pair, then the settings page and the plugin
|
|
@@ -4633,12 +5743,23 @@ window.__ModuleLoader__.load({
|
|
|
4633
5743
|
en
|
|
4634
5744
|
}), "token-usage: dictionaries");
|
|
4635
5745
|
const t = ctx.locale.bind(NS);
|
|
5746
|
+
const clientSessions = ctx.sessions;
|
|
5747
|
+
const sessionListed = (id) => clientSessions.list.getSnapshot().byId[id] !== void 0;
|
|
5748
|
+
const openSession = (id) => {
|
|
5749
|
+
if (!sessionListed(id)) return false;
|
|
5750
|
+
clientSessions.open(id);
|
|
5751
|
+
return true;
|
|
5752
|
+
};
|
|
4636
5753
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
4637
5754
|
name: "settings.section",
|
|
4638
5755
|
id: "token-usage",
|
|
4639
5756
|
order: 50,
|
|
4640
5757
|
label: () => t("nav.label"),
|
|
4641
|
-
locale: NS
|
|
5758
|
+
locale: NS,
|
|
5759
|
+
inject: () => ({
|
|
5760
|
+
sessionListed,
|
|
5761
|
+
openSession
|
|
5762
|
+
})
|
|
4642
5763
|
}, TokenUsageSection));
|
|
4643
5764
|
ctx.slots.inject("conversation.view", () => ctx.slots.register({
|
|
4644
5765
|
name: "conversation.view",
|