@laoyuehanni/dsh-token-usage 0.4.13 → 0.4.15
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 +17 -9
- package/README.zh.md +17 -9
- package/lib/aux-request.d.ts +4 -0
- package/lib/aux-request.d.ts.map +1 -1
- package/lib/aux-request.js +1 -0
- package/lib/aux-request.js.map +1 -1
- package/lib/client/CostPill.d.ts +3 -4
- package/lib/client/CostPill.d.ts.map +1 -1
- package/lib/client/CostPill.js +5 -7
- package/lib/client/CostPill.js.map +1 -1
- package/lib/client/DashboardCards.d.ts +18 -10
- package/lib/client/DashboardCards.d.ts.map +1 -1
- package/lib/client/DashboardCards.js +14 -8
- package/lib/client/DashboardCards.js.map +1 -1
- package/lib/client/RequestPool.d.ts.map +1 -1
- package/lib/client/RequestPool.js +42 -18
- package/lib/client/RequestPool.js.map +1 -1
- package/lib/client/TokenUsageSection.d.ts.map +1 -1
- package/lib/client/TokenUsageSection.js +25 -14
- package/lib/client/TokenUsageSection.js.map +1 -1
- package/lib/client/UsageRows.d.ts +19 -11
- package/lib/client/UsageRows.d.ts.map +1 -1
- package/lib/client/UsageRows.js +59 -16
- package/lib/client/UsageRows.js.map +1 -1
- package/lib/client/cost-inflate-motion.d.ts +0 -4
- package/lib/client/cost-inflate-motion.d.ts.map +1 -1
- package/lib/client/cost-inflate-motion.js +0 -19
- package/lib/client/cost-inflate-motion.js.map +1 -1
- package/lib/client/cost-inflate.d.ts +4 -6
- package/lib/client/cost-inflate.d.ts.map +1 -1
- package/lib/client/cost-inflate.js +3 -5
- package/lib/client/cost-inflate.js.map +1 -1
- package/lib/client/format.d.ts +5 -0
- package/lib/client/format.d.ts.map +1 -1
- package/lib/client/format.js +5 -0
- package/lib/client/format.js.map +1 -1
- package/lib/client/locales.d.ts +10 -0
- package/lib/client/locales.d.ts.map +1 -1
- package/lib/client/locales.js +20 -0
- package/lib/client/locales.js.map +1 -1
- package/lib/client/use-cost-inflate.d.ts +5 -15
- package/lib/client/use-cost-inflate.d.ts.map +1 -1
- package/lib/client/use-cost-inflate.js +11 -51
- package/lib/client/use-cost-inflate.js.map +1 -1
- package/lib/client.js +288 -225
- package/lib/client.js.map +1 -1
- package/lib/compaction-attribution.d.ts +72 -0
- package/lib/compaction-attribution.d.ts.map +1 -0
- package/lib/compaction-attribution.js +82 -0
- package/lib/compaction-attribution.js.map +1 -0
- package/lib/field-completion.d.ts +46 -0
- package/lib/field-completion.d.ts.map +1 -0
- package/lib/field-completion.js +71 -0
- package/lib/field-completion.js.map +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +145 -15
- package/lib/index.js.map +1 -1
- package/lib/migrate.d.ts +2 -1
- package/lib/migrate.d.ts.map +1 -1
- package/lib/migrate.js +13 -1
- package/lib/migrate.js.map +1 -1
- package/lib/provider-label.d.ts +20 -0
- package/lib/provider-label.d.ts.map +1 -0
- package/lib/provider-label.js +21 -0
- package/lib/provider-label.js.map +1 -0
- package/lib/provider-names.d.ts +60 -0
- package/lib/provider-names.d.ts.map +1 -0
- package/lib/provider-names.js +156 -0
- package/lib/provider-names.js.map +1 -0
- package/lib/rollup.d.ts +10 -4
- package/lib/rollup.d.ts.map +1 -1
- package/lib/rollup.js +21 -4
- package/lib/rollup.js.map +1 -1
- package/lib/session-request-details.d.ts.map +1 -1
- package/lib/session-request-details.js +2 -0
- package/lib/session-request-details.js.map +1 -1
- package/lib/stats-route.d.ts +4 -0
- package/lib/stats-route.d.ts.map +1 -1
- package/lib/stats-route.js +14 -1
- package/lib/stats-route.js.map +1 -1
- package/lib/stats.d.ts.map +1 -1
- package/lib/stats.js +86 -19
- package/lib/stats.js.map +1 -1
- package/lib/sync-state.d.ts +43 -0
- package/lib/sync-state.d.ts.map +1 -1
- package/lib/sync-state.js +106 -0
- package/lib/sync-state.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +26 -5
- package/lib/sync.js.map +1 -1
- package/lib/usage-log.d.ts +31 -0
- package/lib/usage-log.d.ts.map +1 -1
- package/lib/usage-log.js +172 -8
- package/lib/usage-log.js.map +1 -1
- package/lib/usage-record.d.ts +33 -8
- package/lib/usage-record.d.ts.map +1 -1
- package/lib/usage-record.js +79 -12
- package/lib/usage-record.js.map +1 -1
- package/lib/wire.d.ts +53 -1
- package/lib/wire.d.ts.map +1 -1
- package/lib/wire.js.map +1 -1
- package/package.json +1 -1
- package/lib/client/CostDeltaFlyLabel.d.ts +0 -8
- package/lib/client/CostDeltaFlyLabel.d.ts.map +0 -1
- package/lib/client/CostDeltaFlyLabel.js +0 -24
- package/lib/client/CostDeltaFlyLabel.js.map +0 -1
package/lib/client.js
CHANGED
|
@@ -547,6 +547,20 @@ window.__ModuleLoader__.load({
|
|
|
547
547
|
}
|
|
548
548
|
return points;
|
|
549
549
|
}
|
|
550
|
+
// src/provider-label.ts
|
|
551
|
+
/**
|
|
552
|
+
* Label for a route key. The name registry wins; a missing or empty entry
|
|
553
|
+
* falls back to the key itself, so a route the registry never saw still
|
|
554
|
+
* displays. A route without a name is not an error — the registry is a
|
|
555
|
+
* convenience, the route key is the identity.
|
|
556
|
+
* @param id - the route key.
|
|
557
|
+
* @param names - the name registry, when the caller has one.
|
|
558
|
+
* @returns the display name, or the route key itself.
|
|
559
|
+
*/
|
|
560
|
+
function providerLabel(id, names) {
|
|
561
|
+
const name = names?.[id];
|
|
562
|
+
return name !== void 0 && name !== "" ? name : id;
|
|
563
|
+
}
|
|
550
564
|
// src/client/format.ts
|
|
551
565
|
/** Known `LlmFailure.code`s that have a `fail.*` locale label. An unknown
|
|
552
566
|
* future code is not in this map and the tooltip renders it verbatim. */
|
|
@@ -1939,88 +1953,6 @@ window.__ModuleLoader__.load({
|
|
|
1939
1953
|
easing: "cubic-bezier(0.25, 0.85, 0.35, 1)"
|
|
1940
1954
|
});
|
|
1941
1955
|
}
|
|
1942
|
-
/** +Δ label fall (`deltaFall`). Caller must position the element (absolute,
|
|
1943
|
-
* below the pill — the dock sits under the composer, so the label falls
|
|
1944
|
-
* away from the message scrollport rather than climbing into it). */
|
|
1945
|
-
function runDeltaFly(el, v) {
|
|
1946
|
-
if (!motionAllowed() || !waapiAvailable(el)) return null;
|
|
1947
|
-
return el.animate([
|
|
1948
|
-
{
|
|
1949
|
-
opacity: 0,
|
|
1950
|
-
transform: "translate(-50%, 20%)"
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
opacity: 1,
|
|
1954
|
-
transform: "translate(-50%, 20%)",
|
|
1955
|
-
offset: .15
|
|
1956
|
-
},
|
|
1957
|
-
{
|
|
1958
|
-
opacity: 0,
|
|
1959
|
-
transform: `translate(calc(-50% + ${v.flyX}), calc(100% + ${v.flyY}))`
|
|
1960
|
-
}
|
|
1961
|
-
], {
|
|
1962
|
-
duration: v.inflateMs,
|
|
1963
|
-
easing: "cubic-bezier(0.22, 0.55, 0.25, 1)",
|
|
1964
|
-
fill: "both"
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/CostPill.module.css.mjs
|
|
1968
|
-
const css$15 = ".T_i-_W_root{min-width:0;display:inline-flex;position:relative}.T_i-_W_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.T_i-_W_glyph{flex:none;width:14px;height:14px}button.T_i-_W_pill{cursor:pointer}button.T_i-_W_pill:hover,button.T_i-_W_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.T_i-_W_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.T_i-_W_deltaLayer{pointer-events:none;z-index:3;position:absolute;inset:0;overflow:visible}.T_i-_W_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);margin-top:2px;font-size:11px;font-weight:600;position:absolute;top:100%;left:50%}@media (prefers-reduced-motion:reduce){.T_i-_W_deltaFly{display:none}}.T_i-_W_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.T_i-_W_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.T_i-_W_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.T_i-_W_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.T_i-_W_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.T_i-_W_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.T_i-_W_dot{color:var(--dsw-alias-separator-primary)}.T_i-_W_rows{flex-direction:column;margin-top:8px;display:flex}.T_i-_W_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.T_i-_W_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.T_i-_W_rowValue{color:var(--dsw-alias-label-primary)}.T_i-_W_rowSub .T_i-_W_rowValue{color:var(--dsw-alias-label-secondary)}.T_i-_W_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.T_i-_W_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.T_i-_W_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.T_i-_W_unpriced .T_i-_W_rowLabel,.T_i-_W_unpriced .T_i-_W_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.T_i-_W_pending{color:var(--dsw-alias-label-tertiary)}";
|
|
1969
|
-
const tagId$15 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
|
|
1970
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$15) + "]") === null) {
|
|
1971
|
-
const tag = document.createElement("style");
|
|
1972
|
-
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
1973
|
-
tag.dataset.pluginCss = tagId$15;
|
|
1974
|
-
tag.textContent = css$15;
|
|
1975
|
-
document.head.appendChild(tag);
|
|
1976
|
-
}
|
|
1977
|
-
var CostPill_module_css_default = {
|
|
1978
|
-
"cost": "T_i-_W_cost",
|
|
1979
|
-
"deltaFly": "T_i-_W_deltaFly",
|
|
1980
|
-
"deltaLayer": "T_i-_W_deltaLayer",
|
|
1981
|
-
"dot": "T_i-_W_dot",
|
|
1982
|
-
"glyph": "T_i-_W_glyph",
|
|
1983
|
-
"groupLabel": "T_i-_W_groupLabel",
|
|
1984
|
-
"panel": "T_i-_W_panel",
|
|
1985
|
-
"panelHead": "T_i-_W_panelHead",
|
|
1986
|
-
"panelTitle": "T_i-_W_panelTitle",
|
|
1987
|
-
"panelTotal": "T_i-_W_panelTotal",
|
|
1988
|
-
"pending": "T_i-_W_pending",
|
|
1989
|
-
"pill": "T_i-_W_pill",
|
|
1990
|
-
"requests": "T_i-_W_requests",
|
|
1991
|
-
"root": "T_i-_W_root",
|
|
1992
|
-
"row": "T_i-_W_row",
|
|
1993
|
-
"rowLabel": "T_i-_W_rowLabel",
|
|
1994
|
-
"rowSub": "T_i-_W_rowSub",
|
|
1995
|
-
"rowValue": "T_i-_W_rowValue",
|
|
1996
|
-
"rows": "T_i-_W_rows",
|
|
1997
|
-
"scopeTag": "T_i-_W_scopeTag",
|
|
1998
|
-
"tok": "T_i-_W_tok",
|
|
1999
|
-
"unpriced": "T_i-_W_unpriced",
|
|
2000
|
-
"usageLine": "T_i-_W_usageLine"
|
|
2001
|
-
};
|
|
2002
|
-
// src/client/CostDeltaFlyLabel.tsx
|
|
2003
|
-
/** One +Δ fly label; animation starts on mount via WAAPI. */
|
|
2004
|
-
function CostDeltaFlyLabel({ text, vars }) {
|
|
2005
|
-
const ref = (0, react.useRef)(null);
|
|
2006
|
-
(0, react.useLayoutEffect)(() => {
|
|
2007
|
-
const el = ref.current;
|
|
2008
|
-
if (el === null) return;
|
|
2009
|
-
const anim = runDeltaFly(el, vars);
|
|
2010
|
-
if (anim === null) {
|
|
2011
|
-
el.style.visibility = "hidden";
|
|
2012
|
-
return;
|
|
2013
|
-
}
|
|
2014
|
-
return () => {
|
|
2015
|
-
anim.cancel();
|
|
2016
|
-
};
|
|
2017
|
-
}, [vars]);
|
|
2018
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2019
|
-
ref,
|
|
2020
|
-
className: CostPill_module_css_default["deltaFly"],
|
|
2021
|
-
children: text
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
1956
|
// src/client/cost-inflate.ts
|
|
2025
1957
|
const MISS_RATE_CAP = .55;
|
|
2026
1958
|
const OUT_CAP = 32e3;
|
|
@@ -2056,16 +1988,15 @@ window.__ModuleLoader__.load({
|
|
|
2056
1988
|
return {
|
|
2057
1989
|
inflateMs: Math.round(lerp(1e3, 1800, I)),
|
|
2058
1990
|
popScale: lerp(1.08, 1.32, I).toFixed(3),
|
|
2059
|
-
warnMix: `${Math.round(lerp(0, 55, I))}
|
|
2060
|
-
flyY: `${lerp(22, 38, I).toFixed(1)}px`,
|
|
2061
|
-
flyX: `${((Math.random() - .5) * 10).toFixed(1)}px`
|
|
1991
|
+
warnMix: `${Math.round(lerp(0, 55, I))}%`
|
|
2062
1992
|
};
|
|
2063
1993
|
}
|
|
2064
1994
|
// src/client/use-cost-inflate.ts
|
|
2065
1995
|
/**
|
|
2066
1996
|
* Request-driven cost-figure inflate animation for the composer-dock usage
|
|
2067
|
-
* pill: detects new usage from summary deltas and drives WAAPI motion on
|
|
2068
|
-
* the cost figure
|
|
1997
|
+
* pill: detects new usage from summary deltas and drives the WAAPI motion on
|
|
1998
|
+
* the cost figure (a scale + colour pop whose amplitude follows the step's
|
|
1999
|
+
* token intensity).
|
|
2069
2000
|
*
|
|
2070
2001
|
* @module token-usage/client/use-cost-inflate
|
|
2071
2002
|
*/
|
|
@@ -2077,44 +2008,23 @@ window.__ModuleLoader__.load({
|
|
|
2077
2008
|
return totalTokens$1(delta) > 0;
|
|
2078
2009
|
}
|
|
2079
2010
|
/**
|
|
2080
|
-
* Hook the pill uses to play costPop
|
|
2011
|
+
* Hook the pill uses to play the costPop on each new request.
|
|
2081
2012
|
* @param scopeKey - changes reset the diff baseline.
|
|
2082
2013
|
* @param costRef - the live cost figure span (WAAPI target).
|
|
2083
2014
|
*/
|
|
2084
2015
|
function useCostInflate(scopeKey, costRef) {
|
|
2085
2016
|
const prevRef = (0, react.useRef)(null);
|
|
2086
|
-
const flyIdRef = (0, react.useRef)(0);
|
|
2087
|
-
const timersRef = (0, react.useRef)([]);
|
|
2088
|
-
const flyCountRef = (0, react.useRef)(0);
|
|
2089
2017
|
const popAnimRef = (0, react.useRef)(null);
|
|
2090
|
-
const [flies, setFlies] = (0, react.useState)([]);
|
|
2091
|
-
const [flyOverflow, setFlyOverflow] = (0, react.useState)(false);
|
|
2092
|
-
const clearTimers = (0, react.useCallback)(() => {
|
|
2093
|
-
for (const id of timersRef.current) window.clearTimeout(id);
|
|
2094
|
-
timersRef.current = [];
|
|
2095
|
-
}, []);
|
|
2096
|
-
const schedule = (0, react.useCallback)((fn, ms) => {
|
|
2097
|
-
const id = window.setTimeout(fn, ms);
|
|
2098
|
-
timersRef.current.push(id);
|
|
2099
|
-
}, []);
|
|
2100
2018
|
const reset = (0, react.useCallback)(() => {
|
|
2101
|
-
clearTimers();
|
|
2102
2019
|
popAnimRef.current?.cancel();
|
|
2103
2020
|
popAnimRef.current = null;
|
|
2104
2021
|
prevRef.current = null;
|
|
2105
|
-
|
|
2106
|
-
flyCountRef.current = 0;
|
|
2107
|
-
setFlies([]);
|
|
2108
|
-
setFlyOverflow(false);
|
|
2109
|
-
}, [clearTimers]);
|
|
2022
|
+
}, []);
|
|
2110
2023
|
(0, react.useEffect)(() => {
|
|
2111
2024
|
reset();
|
|
2112
2025
|
}, [scopeKey, reset]);
|
|
2113
2026
|
(0, react.useEffect)(() => () => {
|
|
2114
|
-
|
|
2115
|
-
}, [clearTimers]);
|
|
2116
|
-
const maybeClearOverflow = (0, react.useCallback)(() => {
|
|
2117
|
-
if (flyCountRef.current <= 0) setFlyOverflow(false);
|
|
2027
|
+
popAnimRef.current?.cancel();
|
|
2118
2028
|
}, []);
|
|
2119
2029
|
const playCostPop = (0, react.useCallback)((v) => {
|
|
2120
2030
|
const el = costRef.current;
|
|
@@ -2123,8 +2033,6 @@ window.__ModuleLoader__.load({
|
|
|
2123
2033
|
popAnimRef.current = runCostPop(el, v);
|
|
2124
2034
|
}, [costRef]);
|
|
2125
2035
|
return {
|
|
2126
|
-
flies,
|
|
2127
|
-
flyOverflow,
|
|
2128
2036
|
onSummary: (0, react.useCallback)((summary) => {
|
|
2129
2037
|
if (!costsAvailable(summary.costState)) {
|
|
2130
2038
|
reset();
|
|
@@ -2140,36 +2048,46 @@ window.__ModuleLoader__.load({
|
|
|
2140
2048
|
if (!hasUsageChurn(prev, summary)) return;
|
|
2141
2049
|
if (!motionAllowed()) return;
|
|
2142
2050
|
const v = animVars(computeIntensityFromDelta(deltaTotals(prev.totals, summary.total)));
|
|
2143
|
-
setFlyOverflow(true);
|
|
2144
2051
|
window.requestAnimationFrame(() => {
|
|
2145
2052
|
playCostPop(v);
|
|
2146
2053
|
});
|
|
2147
|
-
|
|
2148
|
-
if (wireDeltaCost > MIN_WIRE_DELTA_COST) {
|
|
2149
|
-
const view = currencyViewOf(summary);
|
|
2150
|
-
const text = `+${(wireDeltaCost / view.rate).toFixed(2)}${view.symbol}`;
|
|
2151
|
-
const id = ++flyIdRef.current;
|
|
2152
|
-
flyCountRef.current += 1;
|
|
2153
|
-
setFlies((current) => [...current, {
|
|
2154
|
-
id,
|
|
2155
|
-
text,
|
|
2156
|
-
vars: v
|
|
2157
|
-
}]);
|
|
2158
|
-
schedule(() => {
|
|
2159
|
-
flyCountRef.current -= 1;
|
|
2160
|
-
setFlies((current) => current.filter((fly) => fly.id !== id));
|
|
2161
|
-
maybeClearOverflow();
|
|
2162
|
-
}, v.inflateMs + 40);
|
|
2163
|
-
} else schedule(maybeClearOverflow, v.inflateMs + 40);
|
|
2164
|
-
}, [
|
|
2165
|
-
maybeClearOverflow,
|
|
2166
|
-
playCostPop,
|
|
2167
|
-
schedule,
|
|
2168
|
-
reset
|
|
2169
|
-
]),
|
|
2054
|
+
}, [playCostPop, reset]),
|
|
2170
2055
|
reset
|
|
2171
2056
|
};
|
|
2172
2057
|
}
|
|
2058
|
+
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/CostPill.module.css.mjs
|
|
2059
|
+
const css$15 = ".T_i-_W_root{min-width:0;display:inline-flex;position:relative}.T_i-_W_pill{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;padding:1px 8px;display:inline-flex}.T_i-_W_glyph{flex:none;width:14px;height:14px}button.T_i-_W_pill{cursor:pointer}button.T_i-_W_pill:hover,button.T_i-_W_pill[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.T_i-_W_cost{transform-origin:50%;z-index:2;display:inline-flex;position:relative}.T_i-_W_panel{background:var(--dsw-specific-menu);width:300px;backdrop-filter:var(--dsw-menu-backdrop-filter);border:1px solid var(--dsw-alias-border-inverted);box-shadow:var(--dsw-shadow-lv3);z-index:30;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);color:var(--dsw-alias-label-primary);border-radius:12px;padding:12px 14px;position:absolute;bottom:calc(100% + 8px)}.T_i-_W_panelHead{border-bottom:1px solid var(--dsw-alias-border-l1);justify-content:space-between;align-items:baseline;padding-bottom:8px;display:flex}.T_i-_W_panelTitle{align-items:center;gap:6px;font-weight:600;display:inline-flex}.T_i-_W_scopeTag{color:var(--dsw-alias-label-secondary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:1px 5px;font-size:10px;font-weight:400}.T_i-_W_panelTotal{font-variant-numeric:tabular-nums;font-size:14px;font-weight:600}.T_i-_W_usageLine{font-variant-numeric:tabular-nums;align-items:center;gap:6px;margin-top:8px;display:flex}.T_i-_W_dot{color:var(--dsw-alias-separator-primary)}.T_i-_W_rows{flex-direction:column;margin-top:8px;display:flex}.T_i-_W_row{font-variant-numeric:tabular-nums;justify-content:space-between;padding:4px 0;display:flex}.T_i-_W_rowLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;display:inline-flex}.T_i-_W_rowValue{color:var(--dsw-alias-label-primary)}.T_i-_W_rowSub .T_i-_W_rowValue{color:var(--dsw-alias-label-secondary)}.T_i-_W_tok{color:var(--dsw-alias-label-tertiary);margin-left:6px;font-size:11px}.T_i-_W_groupLabel{color:var(--dsw-alias-label-tertiary);letter-spacing:.06em;margin-top:10px;font-size:10px}.T_i-_W_requests{color:var(--dsw-alias-label-tertiary);font-size:11px}.T_i-_W_unpriced .T_i-_W_rowLabel,.T_i-_W_unpriced .T_i-_W_rowValue{color:var(--dsw-alias-label-tertiary);font-style:italic}.T_i-_W_pending{color:var(--dsw-alias-label-tertiary)}";
|
|
2060
|
+
const tagId$15 = "@laoyuehanni/dsh-token-usage/CostPill.module.css";
|
|
2061
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$15) + "]") === null) {
|
|
2062
|
+
const tag = document.createElement("style");
|
|
2063
|
+
tag.dataset.plugin = "@laoyuehanni/dsh-token-usage";
|
|
2064
|
+
tag.dataset.pluginCss = tagId$15;
|
|
2065
|
+
tag.textContent = css$15;
|
|
2066
|
+
document.head.appendChild(tag);
|
|
2067
|
+
}
|
|
2068
|
+
var CostPill_module_css_default = {
|
|
2069
|
+
"cost": "T_i-_W_cost",
|
|
2070
|
+
"dot": "T_i-_W_dot",
|
|
2071
|
+
"glyph": "T_i-_W_glyph",
|
|
2072
|
+
"groupLabel": "T_i-_W_groupLabel",
|
|
2073
|
+
"panel": "T_i-_W_panel",
|
|
2074
|
+
"panelHead": "T_i-_W_panelHead",
|
|
2075
|
+
"panelTitle": "T_i-_W_panelTitle",
|
|
2076
|
+
"panelTotal": "T_i-_W_panelTotal",
|
|
2077
|
+
"pending": "T_i-_W_pending",
|
|
2078
|
+
"pill": "T_i-_W_pill",
|
|
2079
|
+
"requests": "T_i-_W_requests",
|
|
2080
|
+
"root": "T_i-_W_root",
|
|
2081
|
+
"row": "T_i-_W_row",
|
|
2082
|
+
"rowLabel": "T_i-_W_rowLabel",
|
|
2083
|
+
"rowSub": "T_i-_W_rowSub",
|
|
2084
|
+
"rowValue": "T_i-_W_rowValue",
|
|
2085
|
+
"rows": "T_i-_W_rows",
|
|
2086
|
+
"scopeTag": "T_i-_W_scopeTag",
|
|
2087
|
+
"tok": "T_i-_W_tok",
|
|
2088
|
+
"unpriced": "T_i-_W_unpriced",
|
|
2089
|
+
"usageLine": "T_i-_W_usageLine"
|
|
2090
|
+
};
|
|
2173
2091
|
// src/client/CostPill.tsx
|
|
2174
2092
|
/**
|
|
2175
2093
|
* Composer-dock usage pill (browser half): a cost trigger registered into
|
|
@@ -2194,10 +2112,9 @@ window.__ModuleLoader__.load({
|
|
|
2194
2112
|
* cadence, inherited whole): `sessionStats` projection churn plus mirror
|
|
2195
2113
|
* `updatedAt` is debounced 250 ms into one fetch, a failed FIRST fetch
|
|
2196
2114
|
* retries itself on a 3 s cadence, and later failures keep the prior
|
|
2197
|
-
* figures. When
|
|
2198
|
-
*
|
|
2199
|
-
*
|
|
2200
|
-
* Reduced-motion users get silent figure updates.
|
|
2115
|
+
* figures. When usage grows on a new request the figure plays `costPop` —
|
|
2116
|
+
* a scale + colour pop whose amplitude follows that step's token
|
|
2117
|
+
* intensity. Reduced-motion users get silent figure updates.
|
|
2201
2118
|
*
|
|
2202
2119
|
* Visibility contract: a session with no recorded requests renders
|
|
2203
2120
|
* nothing; a transient fetch miss keeps the previous render.
|
|
@@ -2259,7 +2176,7 @@ window.__ModuleLoader__.load({
|
|
|
2259
2176
|
liveSessionStats: useProjection("sessionStats")
|
|
2260
2177
|
});
|
|
2261
2178
|
const debouncedKey = useDebouncedValue(`${scopeIds.join("\n")}\n\t${freshnessKey}`, REFRESH_DEBOUNCE_MS$1);
|
|
2262
|
-
const {
|
|
2179
|
+
const { onSummary } = useCostInflate(scopeIds.join("\n"), costRef);
|
|
2263
2180
|
const [treeRes, retryTree] = useAsyncResource((signal) => {
|
|
2264
2181
|
const [idsPart] = debouncedKey.split("\n ");
|
|
2265
2182
|
return fetchSummary$1((idsPart ?? "").split("\n").filter((id) => id !== ""), "chip", signal);
|
|
@@ -2367,41 +2284,30 @@ window.__ModuleLoader__.load({
|
|
|
2367
2284
|
onClick: () => {
|
|
2368
2285
|
setOpen(!open);
|
|
2369
2286
|
},
|
|
2370
|
-
children: [
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
children: costText
|
|
2395
|
-
}),
|
|
2396
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2397
|
-
className: CostPill_module_css_default.deltaLayer,
|
|
2398
|
-
"aria-hidden": "true",
|
|
2399
|
-
children: flies.map((fly) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostDeltaFlyLabel, {
|
|
2400
|
-
text: fly.text,
|
|
2401
|
-
vars: fly.vars
|
|
2402
|
-
}, fly.id))
|
|
2403
|
-
})
|
|
2404
|
-
]
|
|
2287
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
2288
|
+
className: CostPill_module_css_default.glyph,
|
|
2289
|
+
viewBox: "0 0 14 14",
|
|
2290
|
+
width: "14",
|
|
2291
|
+
height: "14",
|
|
2292
|
+
"aria-hidden": true,
|
|
2293
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
2294
|
+
cx: "7",
|
|
2295
|
+
cy: "7",
|
|
2296
|
+
r: "5.5",
|
|
2297
|
+
fill: "none",
|
|
2298
|
+
stroke: "currentColor",
|
|
2299
|
+
strokeWidth: "1.2"
|
|
2300
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
2301
|
+
d: "M4.8 4.5 L7 7.2 L9.2 4.5 M7 7.2 V10 M5.2 8 H8.8 M5.2 9.4 H8.8",
|
|
2302
|
+
fill: "none",
|
|
2303
|
+
stroke: "currentColor",
|
|
2304
|
+
strokeWidth: "1.2"
|
|
2305
|
+
})]
|
|
2306
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2307
|
+
ref: costRef,
|
|
2308
|
+
className: CostPill_module_css_default.cost,
|
|
2309
|
+
children: costText
|
|
2310
|
+
})]
|
|
2405
2311
|
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2406
2312
|
className: CostPill_module_css_default.panel,
|
|
2407
2313
|
role: "dialog",
|
|
@@ -4165,7 +4071,7 @@ window.__ModuleLoader__.load({
|
|
|
4165
4071
|
});
|
|
4166
4072
|
}
|
|
4167
4073
|
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/UsageRows.module.css.mjs
|
|
4168
|
-
const css$10 = ".qYVDeG_rows{flex-direction:column;min-height:120px;max-height:400px;padding-right:2px;display:flex;overflow-y:auto;container-type:inline-size}.qYVDeG_rows::-webkit-scrollbar{width:8px}.qYVDeG_rows::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.qYVDeG_rows.qYVDeG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.qYVDeG_rows::-webkit-scrollbar-track{background:0 0}.qYVDeG_row{border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:12px;padding:4px 0;display:flex}.qYVDeG_row:last-child{border-bottom:none}.qYVDeG_rowName{width:138px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;flex:none;font-size:12px;font-weight:400;overflow:hidden}.qYVDeG_nameLine{align-items:baseline;gap:4px;width:100%;min-width:0;display:flex}.qYVDeG_nameGrow{flex:1;width:auto}.qYVDeG_nameText{text-overflow:ellipsis;white-space:nowrap;min-width:0;font:inherit;color:inherit;text-align:left;background:0 0;border:none;border-bottom:1.5px dashed #0000;padding:0;font-size:12px;overflow:hidden}.qYVDeG_jumpable{cursor:pointer;border-bottom-color:var(--dsw-alias-label-secondary);color:var(--dsw-alias-label-primary);text-decoration:none}.qYVDeG_jumpable:hover{border-bottom-color:var(--dsw-alias-label-primary)}.qYVDeG_badge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:10px}.qYVDeG_track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:2px;flex:1;min-width:0;height:3px;overflow:hidden}.qYVDeG_fill{background:color-mix(in srgb, var(--dsw-alias-label-primary) 55%, transparent);border-radius:2px;height:100%;display:block}.qYVDeG_rowNums{text-align:right;width:118px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.qYVDeG_rowCost{text-align:right;font-variant-numeric:tabular-nums;width:64px;color:var(--dsw-alias-label-primary);flex:none;font-size:12px;font-weight:600}.qYVDeG_srow .qYVDeG_rowCost{width:auto}.qYVDeG_perfToggle{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;align-items:center;gap:5px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500;display:inline-flex}.qYVDeG_perfToggle:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_perfToggle:focus-visible{outline:2px solid var(--dsw-alias-border-l1);outline-offset:1px}.qYVDeG_perfGauge{font-size:11px;line-height:1}.qYVDeG_perfOn{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);border-color:#0000;font-weight:600}.qYVDeG_perfNums{text-align:right;width:260px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;font-size:12px}.qYVDeG_perfNums b{color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_perfDim,.qYVDeG_perfDim b{color:var(--dsw-alias-label-tertiary);font-weight:400}.qYVDeG_srow{cursor:default;display:block}.qYVDeG_srow .qYVDeG_rowName{flex:1;width:auto}.qYVDeG_rowTop{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.qYVDeG_rowSub{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:11px;overflow:hidden}.qYVDeG_empty{color:var(--dsw-alias-label-tertiary);text-align:center;padding:16px 0;font-size:12px}.qYVDeG_segmented{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.qYVDeG_segBtn{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500}.qYVDeG_segBtn:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_controlCompact .qYVDeG_segBtn{padding:2px 7px;font-size:10px}.qYVDeG_controlCompact{border-radius:6px;padding:1px}.qYVDeG_perfCompact{border-radius:6px;padding:3px 7px;font-size:10px}@container (width<=440px){.qYVDeG_row:not(.qYVDeG_srow){grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_row:not(.qYVDeG_srow)>.qYVDeG_rowName{grid-column:1/-1;width:auto}.qYVDeG_track{display:none}.qYVDeG_rowNums{text-align:left;width:auto}.qYVDeG_perfNums{text-align:left;white-space:normal;overflow-wrap:anywhere;grid-column:1/-1;width:auto}.qYVDeG_rowTop{grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_rowTop>.qYVDeG_rowName{grid-column:1/-1}}";
|
|
4074
|
+
const css$10 = ".qYVDeG_rows{flex-direction:column;min-height:120px;max-height:400px;padding-right:2px;display:flex;overflow-y:auto;container-type:inline-size}.qYVDeG_rows::-webkit-scrollbar{width:8px}.qYVDeG_rows::-webkit-scrollbar-thumb{background:0 0;border-radius:4px}.qYVDeG_rows.qYVDeG_scrolling::-webkit-scrollbar-thumb{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}.qYVDeG_rows::-webkit-scrollbar-track{background:0 0}.qYVDeG_row{border-bottom:1px solid var(--dsw-alias-border-l1);align-items:center;gap:12px;padding:4px 0;display:flex}.qYVDeG_row:last-child{border-bottom:none}.qYVDeG_rowName{width:138px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;flex:none;font-size:12px;font-weight:400;overflow:hidden}.qYVDeG_nameLine{align-items:baseline;gap:4px;width:100%;min-width:0;display:flex}.qYVDeG_nameGrow{flex:1;width:auto}.qYVDeG_nameDim{color:var(--dsw-alias-label-secondary)}.qYVDeG_hintWrap{min-width:0;display:inline-flex}.qYVDeG_hintWrap [role=tooltip]{white-space:pre-wrap;overflow-wrap:anywhere;width:max-content;min-width:0;max-width:min(360px,100vw - 24px);font-size:12px;font-weight:400;line-height:1.4}.qYVDeG_nameHint{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);white-space:nowrap;cursor:help;border-radius:4px;flex:none;align-items:center;padding:2px 5px;font-size:10px;line-height:1;display:inline-flex}.qYVDeG_nameText{text-overflow:ellipsis;white-space:nowrap;min-width:0;font:inherit;color:inherit;text-align:left;background:0 0;border:none;border-bottom:1.5px dashed #0000;padding:0;font-size:12px;overflow:hidden}.qYVDeG_jumpable{cursor:pointer;border-bottom-color:var(--dsw-alias-label-secondary);color:var(--dsw-alias-label-primary);text-decoration:none}.qYVDeG_jumpable:hover{border-bottom-color:var(--dsw-alias-label-primary)}.qYVDeG_badge{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:10px}.qYVDeG_track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:2px;flex:1;min-width:0;height:3px;overflow:hidden}.qYVDeG_fill{background:color-mix(in srgb, var(--dsw-alias-label-primary) 55%, transparent);border-radius:2px;height:100%;display:block}.qYVDeG_rowNums{text-align:right;width:118px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.qYVDeG_rowCost{text-align:right;font-variant-numeric:tabular-nums;width:64px;color:var(--dsw-alias-label-primary);flex:none;font-size:12px;font-weight:600}.qYVDeG_srow .qYVDeG_rowCost{width:auto}.qYVDeG_perfToggle{border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border-radius:8px;align-items:center;gap:5px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500;display:inline-flex}.qYVDeG_perfToggle:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_perfToggle:focus-visible{outline:2px solid var(--dsw-alias-border-l1);outline-offset:1px}.qYVDeG_perfGauge{font-size:11px;line-height:1}.qYVDeG_perfOn{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);border-color:#0000;font-weight:600}.qYVDeG_perfNums{text-align:right;width:260px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;font-size:12px}.qYVDeG_perfNums b{color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_perfDim,.qYVDeG_perfDim b{color:var(--dsw-alias-label-tertiary);font-weight:400}.qYVDeG_srow{cursor:default;display:block}.qYVDeG_srow .qYVDeG_rowName{flex:1;width:auto}.qYVDeG_rowTop{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.qYVDeG_rowSub{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:11px;overflow:hidden}.qYVDeG_empty{color:var(--dsw-alias-label-tertiary);text-align:center;padding:16px 0;font-size:12px}.qYVDeG_segmented{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;align-items:stretch;gap:2px;padding:2px;display:inline-flex}.qYVDeG_segBtn{color:var(--dsw-alias-label-secondary);cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;padding:3px 10px;font-family:inherit;font-size:12px;font-weight:500}.qYVDeG_segBtn:hover{color:var(--dsw-alias-label-primary)}.qYVDeG_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 10%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}.qYVDeG_controlCompact .qYVDeG_segBtn{padding:2px 7px;font-size:10px}.qYVDeG_controlCompact{border-radius:6px;padding:1px}.qYVDeG_perfCompact{border-radius:6px;padding:3px 7px;font-size:10px}@container (width<=440px){.qYVDeG_row:not(.qYVDeG_srow){grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_row:not(.qYVDeG_srow)>.qYVDeG_rowName{grid-column:1/-1;width:auto}.qYVDeG_track{display:none}.qYVDeG_rowNums{text-align:left;width:auto}.qYVDeG_perfNums{text-align:left;white-space:normal;overflow-wrap:anywhere;grid-column:1/-1;width:auto}.qYVDeG_rowTop{grid-template-columns:minmax(0,1fr) auto;gap:6px 10px;display:grid}.qYVDeG_rowTop>.qYVDeG_rowName{grid-column:1/-1}}";
|
|
4169
4075
|
const tagId$10 = "@laoyuehanni/dsh-token-usage/UsageRows.module.css";
|
|
4170
4076
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$10) + "]") === null) {
|
|
4171
4077
|
const tag = document.createElement("style");
|
|
@@ -4179,8 +4085,11 @@ window.__ModuleLoader__.load({
|
|
|
4179
4085
|
"controlCompact": "qYVDeG_controlCompact",
|
|
4180
4086
|
"empty": "qYVDeG_empty",
|
|
4181
4087
|
"fill": "qYVDeG_fill",
|
|
4088
|
+
"hintWrap": "qYVDeG_hintWrap",
|
|
4182
4089
|
"jumpable": "qYVDeG_jumpable",
|
|
4090
|
+
"nameDim": "qYVDeG_nameDim",
|
|
4183
4091
|
"nameGrow": "qYVDeG_nameGrow",
|
|
4092
|
+
"nameHint": "qYVDeG_nameHint",
|
|
4184
4093
|
"nameLine": "qYVDeG_nameLine",
|
|
4185
4094
|
"nameText": "qYVDeG_nameText",
|
|
4186
4095
|
"perfCompact": "qYVDeG_perfCompact",
|
|
@@ -4398,14 +4307,16 @@ window.__ModuleLoader__.load({
|
|
|
4398
4307
|
}
|
|
4399
4308
|
// src/client/UsageRows.tsx
|
|
4400
4309
|
/**
|
|
4401
|
-
* The dashboards' flat row lists (browser half): one component,
|
|
4402
|
-
* shapes — `project` (directory-tail folds), `model` (the priced rows)
|
|
4403
|
-
* `session` (two-line rows)
|
|
4404
|
-
*
|
|
4405
|
-
*
|
|
4406
|
-
*
|
|
4407
|
-
*
|
|
4408
|
-
*
|
|
4310
|
+
* The dashboards' flat row lists (browser half): one component, four
|
|
4311
|
+
* shapes — `project` (directory-tail folds), `model` (the priced rows),
|
|
4312
|
+
* `session` (two-line rows) and `provider` (the per-route rows with the
|
|
4313
|
+
* unattributed remainder sunk to the bottom). All four read the same
|
|
4314
|
+
* single-line grammar of the v3 demo: name | relative bar (projects /
|
|
4315
|
+
* models / providers only) | total tokens · cache share | cost; sessions
|
|
4316
|
+
* swap the bar for a second identity line (directory · activity) under the
|
|
4317
|
+
* same figures cells, all four lists rendering one figures style everywhere
|
|
4318
|
+
* (no hover affordance — a former four-bucket popup read as clutter and
|
|
4319
|
+
* went).
|
|
4409
4320
|
*
|
|
4410
4321
|
* The relative bar scales to
|
|
4411
4322
|
* the active sort's own measure — tokens while sorted by tokens, billed cost
|
|
@@ -4497,6 +4408,20 @@ window.__ModuleLoader__.load({
|
|
|
4497
4408
|
function shortIdOf(sessionId) {
|
|
4498
4409
|
return sessionId.length > 8 ? `${sessionId.slice(0, 8)}…` : sessionId;
|
|
4499
4410
|
}
|
|
4411
|
+
/** The unattributed row's hover tooltip: an intro line, then the known
|
|
4412
|
+
* reasons a record can carry no route key as a numbered list, each line
|
|
4413
|
+
* indented by two spaces (the bubble renders `pre`, so the indent shows).
|
|
4414
|
+
* The list is the full closed set — deleted logs, pre-field history, and
|
|
4415
|
+
* bypass calls the host never gives a route key — so the reader sees this
|
|
4416
|
+
* row is expected, not a bug. */
|
|
4417
|
+
function unattributedTooltip(t) {
|
|
4418
|
+
const causes = [
|
|
4419
|
+
t("byProvider.cause.deletedLog"),
|
|
4420
|
+
t("byProvider.cause.preField"),
|
|
4421
|
+
t("byProvider.cause.bypass")
|
|
4422
|
+
];
|
|
4423
|
+
return [t("byProvider.cause.intro"), ...causes.map((cause, index) => ` ${index + 1}. ${cause}`)].join("\n");
|
|
4424
|
+
}
|
|
4500
4425
|
/** Relative last-active label (「3 小时前」): minutes inside the first hour,
|
|
4501
4426
|
* hours inside the first day, days beyond. */
|
|
4502
4427
|
function relativeTimeOf(time, t) {
|
|
@@ -4510,7 +4435,7 @@ window.__ModuleLoader__.load({
|
|
|
4510
4435
|
* Render one flat row list. The list is the height-capped scroll container
|
|
4511
4436
|
* (scrollbar appears while scrolling, fades 800ms after it stops).
|
|
4512
4437
|
*/
|
|
4513
|
-
function UsageRows({ kind, projectRows, modelRows, sessionRows, sort, perfView, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName }) {
|
|
4438
|
+
function UsageRows({ kind, projectRows, modelRows, sessionRows, providerRows, providerNames, sort, perfView, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName }) {
|
|
4514
4439
|
const ctrlHeld = useCtrlHeld();
|
|
4515
4440
|
const scrollRef = (0, react.useRef)(null);
|
|
4516
4441
|
const scrollTimer = (0, react.useRef)(void 0);
|
|
@@ -4528,7 +4453,7 @@ window.__ModuleLoader__.load({
|
|
|
4528
4453
|
const perfMode = perfView === true && kind === "model";
|
|
4529
4454
|
const active = sort ?? (kind === "session" ? "cost" : "tokens");
|
|
4530
4455
|
const rows = (0, react.useMemo)(() => {
|
|
4531
|
-
const base = kind === "project" ? projectRows : kind === "model" ? modelRows : sessionRows;
|
|
4456
|
+
const base = kind === "project" ? projectRows : kind === "model" ? modelRows : kind === "session" ? sessionRows : providerRows;
|
|
4532
4457
|
if (base === void 0) return [];
|
|
4533
4458
|
if (kind === "session") {
|
|
4534
4459
|
if (active === "cost") return base;
|
|
@@ -4538,6 +4463,10 @@ window.__ModuleLoader__.load({
|
|
|
4538
4463
|
if (active === "tokens") return base;
|
|
4539
4464
|
return [...base].sort((left, right) => right.cost - left.cost || (left.name < right.name ? -1 : 1));
|
|
4540
4465
|
}
|
|
4466
|
+
if (kind === "provider") {
|
|
4467
|
+
const unattributedLast = (row) => row.provider === "" ? 1 : 0;
|
|
4468
|
+
return [...base].sort((left, right) => unattributedLast(left) - unattributedLast(right) || (active === "cost" ? right.cost - left.cost : totalTokens$1(right.totals) - totalTokens$1(left.totals)) || (left.provider < right.provider ? -1 : 1));
|
|
4469
|
+
}
|
|
4541
4470
|
const models = [...base];
|
|
4542
4471
|
if (perfMode) {
|
|
4543
4472
|
const ranked = (row) => row.perf !== void 0 && row.perf.samples >= 5;
|
|
@@ -4555,10 +4484,11 @@ window.__ModuleLoader__.load({
|
|
|
4555
4484
|
projectRows,
|
|
4556
4485
|
modelRows,
|
|
4557
4486
|
sessionRows,
|
|
4487
|
+
providerRows,
|
|
4558
4488
|
active,
|
|
4559
4489
|
perfMode
|
|
4560
4490
|
]);
|
|
4561
|
-
const barValueOf = (row) => perfMode ? "perf" in row && row.perf !== void 0 && row.perf.samples >= 5 ? row.perf.tokensPerSec : 0 : active === "cost" ? row.cost : totalTokens$1(row.totals);
|
|
4491
|
+
const barValueOf = (row) => perfMode ? "perf" in row && row.perf !== void 0 && row.perf.samples >= 5 ? row.perf.tokensPerSec : 0 : kind === "provider" && row.provider === "" ? 0 : active === "cost" ? row.cost : totalTokens$1(row.totals);
|
|
4562
4492
|
const barMax = (0, react.useMemo)(() => {
|
|
4563
4493
|
let max = 0;
|
|
4564
4494
|
for (const row of rows) {
|
|
@@ -4628,7 +4558,7 @@ window.__ModuleLoader__.load({
|
|
|
4628
4558
|
]
|
|
4629
4559
|
});
|
|
4630
4560
|
};
|
|
4631
|
-
const ariaLabel = kind === "project" ? t("byProject.title") : kind === "model" ? t("byModel.title") : t("bySession.title");
|
|
4561
|
+
const ariaLabel = kind === "project" ? t("byProject.title") : kind === "model" ? t("byModel.title") : kind === "session" ? t("bySession.title") : t("byProvider.title");
|
|
4632
4562
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4633
4563
|
className: UsageRows_module_css_default["rows"],
|
|
4634
4564
|
ref: scrollRef,
|
|
@@ -4725,6 +4655,56 @@ window.__ModuleLoader__.load({
|
|
|
4725
4655
|
]
|
|
4726
4656
|
}, model.model);
|
|
4727
4657
|
}
|
|
4658
|
+
if (kind === "provider") {
|
|
4659
|
+
const provider = row;
|
|
4660
|
+
const unattributed = provider.provider === "";
|
|
4661
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4662
|
+
className: UsageRows_module_css_default["row"],
|
|
4663
|
+
role: "listitem",
|
|
4664
|
+
children: [
|
|
4665
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4666
|
+
className: unattributed ? `${UsageRows_module_css_default["rowName"]} ${UsageRows_module_css_default["nameDim"]}` : UsageRows_module_css_default["rowName"],
|
|
4667
|
+
title: unattributed ? void 0 : provider.provider,
|
|
4668
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4669
|
+
className: UsageRows_module_css_default["nameLine"],
|
|
4670
|
+
children: unattributed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4671
|
+
className: UsageRows_module_css_default["hintWrap"],
|
|
4672
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
4673
|
+
label: unattributedTooltip(t),
|
|
4674
|
+
side: "bottom",
|
|
4675
|
+
delayMs: 100,
|
|
4676
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4677
|
+
className: UsageRows_module_css_default["nameText"],
|
|
4678
|
+
"aria-label": t("byProvider.unattributed"),
|
|
4679
|
+
tabIndex: 0,
|
|
4680
|
+
children: [t("byProvider.unattributed"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4681
|
+
className: UsageRows_module_css_default["nameHint"],
|
|
4682
|
+
"aria-hidden": true,
|
|
4683
|
+
children: "?"
|
|
4684
|
+
})]
|
|
4685
|
+
})
|
|
4686
|
+
})
|
|
4687
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4688
|
+
className: UsageRows_module_css_default["nameText"],
|
|
4689
|
+
children: providerLabel(provider.provider, providerNames)
|
|
4690
|
+
})
|
|
4691
|
+
})
|
|
4692
|
+
}),
|
|
4693
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4694
|
+
className: UsageRows_module_css_default["track"],
|
|
4695
|
+
children: barMax > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4696
|
+
className: UsageRows_module_css_default["fill"],
|
|
4697
|
+
style: { width: `${barValueOf(provider) / barMax * 100}%` }
|
|
4698
|
+
}) : null
|
|
4699
|
+
}),
|
|
4700
|
+
numsCell(provider.totals),
|
|
4701
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4702
|
+
className: UsageRows_module_css_default["rowCost"],
|
|
4703
|
+
children: costText(provider.cost)
|
|
4704
|
+
})
|
|
4705
|
+
]
|
|
4706
|
+
}, unattributed ? "\0" : provider.provider);
|
|
4707
|
+
}
|
|
4728
4708
|
const session = row;
|
|
4729
4709
|
const jump = ctrlHeld && sessionListed !== void 0 && onSessionOpen !== void 0 && sessionListed(session.sessionId);
|
|
4730
4710
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4793,9 +4773,9 @@ window.__ModuleLoader__.load({
|
|
|
4793
4773
|
"panelTitle": "dNNuRW_panelTitle"
|
|
4794
4774
|
};
|
|
4795
4775
|
// src/client/DashboardCards.tsx
|
|
4796
|
-
/** The
|
|
4797
|
-
* token size and billed cost; sessions add last activity. The
|
|
4798
|
-
* performance view is a separate head toggle, not a sort pick. */
|
|
4776
|
+
/** The cards' fixed sort options: projects, models and providers pick
|
|
4777
|
+
* between token size and billed cost; sessions add last activity. The
|
|
4778
|
+
* models' performance view is a separate head toggle, not a sort pick. */
|
|
4799
4779
|
const SORT_PROJECT = ["tokens", "cost"];
|
|
4800
4780
|
const SORT_SESSION = [
|
|
4801
4781
|
"tokens",
|
|
@@ -4803,12 +4783,14 @@ window.__ModuleLoader__.load({
|
|
|
4803
4783
|
"recent"
|
|
4804
4784
|
];
|
|
4805
4785
|
const SORT_MODEL = ["tokens", "cost"];
|
|
4786
|
+
const SORT_PROVIDER = ["tokens", "cost"];
|
|
4806
4787
|
/**
|
|
4807
|
-
* Render the
|
|
4808
|
-
*
|
|
4809
|
-
* and scroll inside the cards.
|
|
4788
|
+
* Render the dashboard: projects | sessions on the first row, models |
|
|
4789
|
+
* providers on the second, runtime overhead on the last. The lists cap
|
|
4790
|
+
* their own height and scroll inside the cards.
|
|
4810
4791
|
*/
|
|
4811
|
-
function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, sessionSort, onSessionSortChange, aux, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
|
|
4792
|
+
function DashboardCards({ projectRows, modelRows, sessionRows, projectSort, onProjectSortChange, modelSort, onModelSortChange, modelPerfView, onModelPerfToggle, providerRows, providerNames, providerSort, onProviderSortChange, sessionSort, onSessionSortChange, aux, pricing, costState, view, t, sessionListed, onSessionOpen, onToggleModel, onModelName, overheadCardRef, overheadFlash }) {
|
|
4793
|
+
const namedProviderCount = providerRows.filter((row) => row.provider !== "").length;
|
|
4812
4794
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4813
4795
|
className: DashboardCards_module_css_default["grid2"],
|
|
4814
4796
|
children: [
|
|
@@ -4910,6 +4892,33 @@ window.__ModuleLoader__.load({
|
|
|
4910
4892
|
onModelName
|
|
4911
4893
|
})]
|
|
4912
4894
|
}),
|
|
4895
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4896
|
+
className: DashboardCards_module_css_default["panel"],
|
|
4897
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4898
|
+
className: DashboardCards_module_css_default["panelHead"],
|
|
4899
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4900
|
+
className: DashboardCards_module_css_default["panelTitle"],
|
|
4901
|
+
children: [t("board.providers"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4902
|
+
className: DashboardCards_module_css_default["panelCount"],
|
|
4903
|
+
children: providerSort === "cost" ? t("board.byCost", { count: namedProviderCount.toLocaleString() }) : t("board.byTokens", { count: namedProviderCount.toLocaleString() })
|
|
4904
|
+
})]
|
|
4905
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowSortControl, {
|
|
4906
|
+
value: providerSort,
|
|
4907
|
+
options: SORT_PROVIDER,
|
|
4908
|
+
onChange: onProviderSortChange,
|
|
4909
|
+
ariaLabel: t("board.providers"),
|
|
4910
|
+
t
|
|
4911
|
+
})]
|
|
4912
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageRows, {
|
|
4913
|
+
kind: "provider",
|
|
4914
|
+
providerRows,
|
|
4915
|
+
providerNames,
|
|
4916
|
+
sort: providerSort,
|
|
4917
|
+
costState,
|
|
4918
|
+
view,
|
|
4919
|
+
t
|
|
4920
|
+
})]
|
|
4921
|
+
}),
|
|
4913
4922
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4914
4923
|
ref: overheadCardRef,
|
|
4915
4924
|
className: overheadFlash ? `${DashboardCards_module_css_default["panel"]} ${DashboardCards_module_css_default["flash"]}` : DashboardCards_module_css_default["panel"],
|
|
@@ -6718,7 +6727,7 @@ window.__ModuleLoader__.load({
|
|
|
6718
6727
|
});
|
|
6719
6728
|
}
|
|
6720
6729
|
// \0dsh-css:/home/runner/work/dsh-token-usage/dsh-token-usage/src/client/TokenUsageSection.module.css.mjs
|
|
6721
|
-
const css$2 = "._1fNFvW_section{flex-direction:column;gap:16px;width:100%;min-width:0;display:flex;container-type:inline-size}._1fNFvW_pageVariant ._1fNFvW_title{font-size:20px;font-weight:500;line-height:28px}._1fNFvW_head{justify-content:space-between;align-items:center;gap:12px;display:flex}._1fNFvW_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}._1fNFvW_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._1fNFvW_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._1fNFvW_sortRow{justify-content:flex-end;align-items:center;gap:6px;margin-left:auto;display:flex}._1fNFvW_sortHidden{visibility:hidden}._1fNFvW_detailPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0}._1fNFvW_detailToolbar{border-bottom:1px solid var(--dsw-alias-border-l1);flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 12px;padding:10px 12px;display:flex}._1fNFvW_detailBody{min-width:0;padding:2px 12px 6px}._1fNFvW_segmented{align-items:stretch;gap:2px;padding:0;display:inline-flex}._1fNFvW_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 8px;font-size:11px;font-weight:500}._1fNFvW_segBtn:hover:not(._1fNFvW_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._1fNFvW_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._1fNFvW_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._1fNFvW_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}._1fNFvW_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}._1fNFvW_button:hover{background:var(--dsw-interactive-bg-hover)}._1fNFvW_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}._1fNFvW_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}._1fNFvW_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}@container (width<=480px){._1fNFvW_filters{flex-wrap:wrap}}";
|
|
6730
|
+
const css$2 = "._1fNFvW_section{flex-direction:column;gap:16px;width:100%;min-width:0;display:flex;container-type:inline-size}._1fNFvW_pageVariant ._1fNFvW_title{font-size:20px;font-weight:500;line-height:28px}._1fNFvW_head{justify-content:space-between;align-items:center;gap:12px;display:flex}._1fNFvW_title{color:var(--dsw-alias-label-primary);margin:0;font-size:16px;font-weight:600}._1fNFvW_muted{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px}._1fNFvW_error{color:var(--dsw-alias-state-error-primary);margin:0;font-size:13px}._1fNFvW_sortRow{justify-content:flex-end;align-items:center;gap:6px;margin-left:auto;display:flex}._1fNFvW_sortHidden{visibility:hidden}._1fNFvW_detailPanel{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-fill-container,transparent);border-radius:9px;min-width:0}._1fNFvW_detailToolbar{border-bottom:1px solid var(--dsw-alias-border-l1);flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 12px;padding:10px 12px;display:flex}._1fNFvW_detailBody{min-width:0;padding:2px 12px 6px}._1fNFvW_segmented{flex-wrap:wrap;align-items:stretch;gap:2px;padding:0;display:inline-flex}._1fNFvW_segBtn{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));cursor:pointer;background:0 0;border:none;border-radius:6px;padding:4px 8px;font-size:11px;font-weight:500}._1fNFvW_segBtn:hover:not(._1fNFvW_segActive){color:var(--dsw-alias-label-secondary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}._1fNFvW_segBtn:focus-visible{outline:2px solid var(--dsw-alias-border-l2);outline-offset:1px}._1fNFvW_segActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 16%, transparent);color:var(--dsw-alias-label-primary);font-weight:600}._1fNFvW_empty{color:var(--dsw-alias-label-secondary);margin:0;font-size:13px}._1fNFvW_button{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);cursor:pointer;border-radius:6px;padding:4px 12px;font-size:13px;line-height:20px}._1fNFvW_button:hover{background:var(--dsw-interactive-bg-hover)}._1fNFvW_filters{flex-wrap:nowrap;align-items:center;gap:8px;display:flex}._1fNFvW_pricingLink{color:var(--dsw-alias-link-primary,var(--dsw-alias-label-primary));cursor:pointer;white-space:nowrap;background:0 0;border:none;border-radius:6px;flex:none;margin-left:auto;padding:4px 8px;font-size:13px;line-height:20px}._1fNFvW_pricingLink:hover{background:var(--dsw-interactive-bg-hover)}@container (width<=480px){._1fNFvW_filters{flex-wrap:wrap}}";
|
|
6722
6731
|
const tagId$2 = "@laoyuehanni/dsh-token-usage/TokenUsageSection.module.css";
|
|
6723
6732
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
6724
6733
|
const tag = document.createElement("style");
|
|
@@ -6763,15 +6772,28 @@ window.__ModuleLoader__.load({
|
|
|
6763
6772
|
*
|
|
6764
6773
|
* @module token-usage/client/TokenUsageSection
|
|
6765
6774
|
*/
|
|
6766
|
-
/** The
|
|
6767
|
-
* token size and billed cost; sessions add last activity. */
|
|
6775
|
+
/** The detail tabs' fixed sort options: projects, models and providers pick
|
|
6776
|
+
* between token size and billed cost; sessions add last activity. */
|
|
6768
6777
|
const PROJECT_SORT = ["tokens", "cost"];
|
|
6769
6778
|
const MODEL_SORT = ["tokens", "cost"];
|
|
6779
|
+
const PROVIDER_SORT = ["tokens", "cost"];
|
|
6770
6780
|
const SESSION_SORT = [
|
|
6771
6781
|
"tokens",
|
|
6772
6782
|
"cost",
|
|
6773
6783
|
"recent"
|
|
6774
6784
|
];
|
|
6785
|
+
/** The detail switch's tab labels, one per mode. */
|
|
6786
|
+
const DETAIL_MODES = [
|
|
6787
|
+
"project",
|
|
6788
|
+
"model",
|
|
6789
|
+
"session",
|
|
6790
|
+
"provider",
|
|
6791
|
+
"aux"
|
|
6792
|
+
];
|
|
6793
|
+
/** One detail mode's label key. */
|
|
6794
|
+
function detailLabelOf(mode) {
|
|
6795
|
+
return mode === "project" ? "byProject.title" : mode === "model" ? "byModel.title" : mode === "session" ? "bySession.title" : mode === "provider" ? "byProvider.title" : "aux.tab";
|
|
6796
|
+
}
|
|
6775
6797
|
/** Fetch the summary for one query string; the caller owns the failure
|
|
6776
6798
|
* presentation. The AbortSignal wires into the request so a filter change
|
|
6777
6799
|
* cancels the in-flight fetch instead of letting its response overwrite
|
|
@@ -6944,6 +6966,7 @@ window.__ModuleLoader__.load({
|
|
|
6944
6966
|
const [projectSort, setProjectSort] = (0, react.useState)("tokens");
|
|
6945
6967
|
const [modelSort, setModelSort] = (0, react.useState)("tokens");
|
|
6946
6968
|
const [modelPerfView, setModelPerfView] = (0, react.useState)(false);
|
|
6969
|
+
const [providerSort, setProviderSort] = (0, react.useState)("tokens");
|
|
6947
6970
|
const [sessionSort, setSessionSort] = (0, react.useState)("cost");
|
|
6948
6971
|
const handleToggleModel = (0, react.useCallback)((model) => {
|
|
6949
6972
|
setFilters((previous) => ({
|
|
@@ -7118,6 +7141,10 @@ window.__ModuleLoader__.load({
|
|
|
7118
7141
|
onModelSortChange: setModelSort,
|
|
7119
7142
|
modelPerfView,
|
|
7120
7143
|
onModelPerfToggle: setModelPerfView,
|
|
7144
|
+
providerRows: state.value.byProvider ?? [],
|
|
7145
|
+
providerNames: state.value.providerNames,
|
|
7146
|
+
providerSort,
|
|
7147
|
+
onProviderSortChange: setProviderSort,
|
|
7121
7148
|
sessionSort,
|
|
7122
7149
|
onSessionSortChange: setSessionSort,
|
|
7123
7150
|
aux: state.value.aux,
|
|
@@ -7141,17 +7168,12 @@ window.__ModuleLoader__.load({
|
|
|
7141
7168
|
className: TokenUsageSection_module_css_default["segmented"],
|
|
7142
7169
|
role: "group",
|
|
7143
7170
|
"aria-label": t("detail.switch.label"),
|
|
7144
|
-
children:
|
|
7145
|
-
"project",
|
|
7146
|
-
"model",
|
|
7147
|
-
"session",
|
|
7148
|
-
"aux"
|
|
7149
|
-
].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7171
|
+
children: DETAIL_MODES.map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7150
7172
|
type: "button",
|
|
7151
7173
|
className: detailMode === mode ? `${TokenUsageSection_module_css_default["segBtn"]} ${TokenUsageSection_module_css_default["segActive"]}` : TokenUsageSection_module_css_default["segBtn"],
|
|
7152
7174
|
"aria-pressed": detailMode === mode,
|
|
7153
7175
|
onClick: () => setDetailMode(mode),
|
|
7154
|
-
children: t(mode
|
|
7176
|
+
children: t(detailLabelOf(mode))
|
|
7155
7177
|
}, mode))
|
|
7156
7178
|
}), detailMode !== "aux" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7157
7179
|
className: TokenUsageSection_module_css_default["sortRow"],
|
|
@@ -7159,10 +7181,10 @@ window.__ModuleLoader__.load({
|
|
|
7159
7181
|
className: detailMode === "model" && modelPerfView ? TokenUsageSection_module_css_default["sortHidden"] : void 0,
|
|
7160
7182
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowSortControl, {
|
|
7161
7183
|
compact: true,
|
|
7162
|
-
value: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : sessionSort,
|
|
7163
|
-
options: detailMode === "project" ? PROJECT_SORT : detailMode === "model" ? MODEL_SORT : SESSION_SORT,
|
|
7164
|
-
onChange: detailMode === "project" ? setProjectSort : detailMode === "model" ? setModelSort : setSessionSort,
|
|
7165
|
-
ariaLabel: t(detailMode
|
|
7184
|
+
value: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : detailMode === "provider" ? providerSort : sessionSort,
|
|
7185
|
+
options: detailMode === "project" ? PROJECT_SORT : detailMode === "model" ? MODEL_SORT : detailMode === "provider" ? PROVIDER_SORT : SESSION_SORT,
|
|
7186
|
+
onChange: detailMode === "project" ? setProjectSort : detailMode === "model" ? setModelSort : detailMode === "provider" ? setProviderSort : setSessionSort,
|
|
7187
|
+
ariaLabel: t(detailLabelOf(detailMode)),
|
|
7166
7188
|
t
|
|
7167
7189
|
})
|
|
7168
7190
|
}), detailMode === "model" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PerfToggle, {
|
|
@@ -7184,7 +7206,9 @@ window.__ModuleLoader__.load({
|
|
|
7184
7206
|
projectRows,
|
|
7185
7207
|
modelRows: state.value.byModel,
|
|
7186
7208
|
sessionRows: state.value.sessionRows ?? [],
|
|
7187
|
-
|
|
7209
|
+
providerRows: state.value.byProvider ?? [],
|
|
7210
|
+
providerNames: state.value.providerNames,
|
|
7211
|
+
sort: detailMode === "project" ? projectSort : detailMode === "model" ? modelSort : detailMode === "provider" ? providerSort : sessionSort,
|
|
7188
7212
|
perfView: detailMode === "model" && modelPerfView,
|
|
7189
7213
|
pricing: state.value.pricing,
|
|
7190
7214
|
costState: state.value.costState,
|
|
@@ -7376,22 +7400,39 @@ window.__ModuleLoader__.load({
|
|
|
7376
7400
|
}
|
|
7377
7401
|
/** The hit cell's tooltip: the low-hit explanation (with the raw-precision
|
|
7378
7402
|
* note when rounding would hide a sub-threshold rate) or the exclusion
|
|
7379
|
-
* reason. Unknown figures explain their unknown instead of going silent.
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7403
|
+
* reason. Unknown figures explain their unknown instead of going silent.
|
|
7404
|
+
* The compaction attribution (when the row carries one) rides the same
|
|
7405
|
+
* tooltip as its closing section — real-world feedback dropped the standalone
|
|
7406
|
+
* badge as redundant next to the 缓存过低 marker, and the causal chain reads
|
|
7407
|
+
* exactly where the rate is questioned. The wording says the prefix WAS
|
|
7408
|
+
* rewritten and cache behaviour MAY be affected — never that compaction
|
|
7409
|
+
* caused a cache loss, because a high-hit row can carry the same attribution
|
|
7410
|
+
* (the miss severity depends on the earliest rewritten position, which the
|
|
7411
|
+
* plugin cannot see). */
|
|
7412
|
+
function hitTooltipOf(cache, t, attribution) {
|
|
7413
|
+
const lines = [];
|
|
7414
|
+
if (cache.rate === void 0) {
|
|
7415
|
+
if (cache.reason !== void 0) lines.push(t(`pool.excluded.${cache.reason}`));
|
|
7416
|
+
} else {
|
|
7417
|
+
const display = formatRequestRate(cache.rate);
|
|
7418
|
+
if (cache.band === "loss") {
|
|
7419
|
+
lines.push(t("pool.cache.tooltip", { rate: display }));
|
|
7420
|
+
if (Number.parseFloat(display) >= 50) lines.push(t("pool.cache.roundedDown", { rate: formatRequestRateExact(cache.rate) }));
|
|
7421
|
+
} else if (cache.reason !== void 0) lines.push(t(`pool.excluded.${cache.reason}`));
|
|
7387
7422
|
}
|
|
7388
|
-
if (
|
|
7389
|
-
|
|
7423
|
+
if (attribution !== void 0) {
|
|
7424
|
+
lines.push(t("pool.attribution.prefix"));
|
|
7425
|
+
for (const item of attribution) lines.push(item.kind === "prune" ? t("pool.attribution.prune", {
|
|
7426
|
+
count: String(item.count),
|
|
7427
|
+
tokens: formatTokens(item.shadowedTokenCount)
|
|
7428
|
+
}) : t("pool.attribution.summary", { tokens: formatTokens(item.shadowedTokenCount) }));
|
|
7429
|
+
}
|
|
7430
|
+
return lines.join("\n");
|
|
7390
7431
|
}
|
|
7391
7432
|
/** The hit cell keeps request precision, shared numeric colours, and its explanation. */
|
|
7392
|
-
function HitCell({ cache, t }) {
|
|
7433
|
+
function HitCell({ cache, attribution, t }) {
|
|
7393
7434
|
const text = formatRequestRate(cache.rate);
|
|
7394
|
-
const tooltip = hitTooltipOf(cache, t);
|
|
7435
|
+
const tooltip = hitTooltipOf(cache, t, attribution);
|
|
7395
7436
|
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7396
7437
|
className: hitClassOf(cache),
|
|
7397
7438
|
children: text
|
|
@@ -7443,7 +7484,7 @@ window.__ModuleLoader__.load({
|
|
|
7443
7484
|
children: kindLabel
|
|
7444
7485
|
}),
|
|
7445
7486
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
7446
|
-
label: hitTooltipOf(cache, t),
|
|
7487
|
+
label: hitTooltipOf(cache, t, detail.compactionAttribution),
|
|
7447
7488
|
side: "top",
|
|
7448
7489
|
delayMs: 100,
|
|
7449
7490
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
@@ -7623,6 +7664,7 @@ window.__ModuleLoader__.load({
|
|
|
7623
7664
|
"data-label": t("pool.col.hit"),
|
|
7624
7665
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitCell, {
|
|
7625
7666
|
cache: detail.cache,
|
|
7667
|
+
attribution: detail.compactionAttribution,
|
|
7626
7668
|
t
|
|
7627
7669
|
})
|
|
7628
7670
|
}),
|
|
@@ -7751,6 +7793,7 @@ window.__ModuleLoader__.load({
|
|
|
7751
7793
|
className: UsageView_module_css_default["metricValue"],
|
|
7752
7794
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HitCell, {
|
|
7753
7795
|
cache: latest.cache,
|
|
7796
|
+
attribution: latest.compactionAttribution,
|
|
7754
7797
|
t
|
|
7755
7798
|
})
|
|
7756
7799
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -8573,6 +8616,12 @@ window.__ModuleLoader__.load({
|
|
|
8573
8616
|
"perf.lowSamples": "样本不足",
|
|
8574
8617
|
"perf.requestCount": "{count} 次",
|
|
8575
8618
|
"byModel.title": "按模型",
|
|
8619
|
+
"byProvider.title": "按供应商",
|
|
8620
|
+
"byProvider.unattributed": "缺失供应商",
|
|
8621
|
+
"byProvider.cause.intro": "可能是:",
|
|
8622
|
+
"byProvider.cause.deletedLog": "会话日志已删除的历史会话",
|
|
8623
|
+
"byProvider.cause.preField": "路由键字段加入前的旧会话",
|
|
8624
|
+
"byProvider.cause.bypass": "不带路由键的运行开销",
|
|
8576
8625
|
"bySession.title": "按会话",
|
|
8577
8626
|
"byProject.title": "按项目",
|
|
8578
8627
|
"aux.tab": "运行开销",
|
|
@@ -8591,6 +8640,7 @@ window.__ModuleLoader__.load({
|
|
|
8591
8640
|
"board.projects": "项目",
|
|
8592
8641
|
"board.sessions": "会话",
|
|
8593
8642
|
"board.models": "模型",
|
|
8643
|
+
"board.providers": "供应商",
|
|
8594
8644
|
"board.byTokens": "{count} 个 · 按总 token",
|
|
8595
8645
|
"board.byCost": "{count} 个 · 按费用",
|
|
8596
8646
|
"board.bySpeed": "{count} 个 · 按输出速度",
|
|
@@ -8735,6 +8785,9 @@ window.__ModuleLoader__.load({
|
|
|
8735
8785
|
"pool.kind.session-title": "标题",
|
|
8736
8786
|
"pool.kind.translation": "翻译",
|
|
8737
8787
|
"pool.kind.other": "辅助",
|
|
8788
|
+
"pool.attribution.prefix": "此请求发出前,宿主的压缩操作改写了上下文前缀,缓存表现可能受影响:",
|
|
8789
|
+
"pool.attribution.prune": "工具结果剪枝改写了请求前缀({count} 条,剪除消息的影子 token 合计 {tokens})",
|
|
8790
|
+
"pool.attribution.summary": "LLM 摘要替换了会话历史(影子 token {tokens})",
|
|
8738
8791
|
"pool.state.waiting": "等待首 token",
|
|
8739
8792
|
"pool.state.streaming": "生成中",
|
|
8740
8793
|
"pool.state.completed": "已完成",
|
|
@@ -8929,6 +8982,12 @@ window.__ModuleLoader__.load({
|
|
|
8929
8982
|
"perf.lowSamples": "Low samples",
|
|
8930
8983
|
"perf.requestCount": "{count} reqs",
|
|
8931
8984
|
"byModel.title": "By model",
|
|
8985
|
+
"byProvider.title": "By provider",
|
|
8986
|
+
"byProvider.unattributed": "Missing provider",
|
|
8987
|
+
"byProvider.cause.intro": "Could be:",
|
|
8988
|
+
"byProvider.cause.deletedLog": "History sessions whose logs were deleted",
|
|
8989
|
+
"byProvider.cause.preField": "Sessions older than the route-key field",
|
|
8990
|
+
"byProvider.cause.bypass": "Bypass calls that carry no route key",
|
|
8932
8991
|
"bySession.title": "By session",
|
|
8933
8992
|
"byProject.title": "By project",
|
|
8934
8993
|
"aux.tab": "Runtime overhead",
|
|
@@ -8947,6 +9006,7 @@ window.__ModuleLoader__.load({
|
|
|
8947
9006
|
"board.projects": "Projects",
|
|
8948
9007
|
"board.sessions": "Sessions",
|
|
8949
9008
|
"board.models": "Models",
|
|
9009
|
+
"board.providers": "Providers",
|
|
8950
9010
|
"board.byTokens": "{count} · by tokens",
|
|
8951
9011
|
"board.byCost": "{count} · by cost",
|
|
8952
9012
|
"board.bySpeed": "{count} · by speed",
|
|
@@ -9091,6 +9151,9 @@ window.__ModuleLoader__.load({
|
|
|
9091
9151
|
"pool.kind.session-title": "Title",
|
|
9092
9152
|
"pool.kind.translation": "Translation",
|
|
9093
9153
|
"pool.kind.other": "Auxiliary",
|
|
9154
|
+
"pool.attribution.prefix": "Before this request, host compaction rewrote the context prefix; cache behaviour may be affected:",
|
|
9155
|
+
"pool.attribution.prune": "Tool-result pruning rewrote the request prefix ({count} event(s), shadow tokens of pruned messages {tokens})",
|
|
9156
|
+
"pool.attribution.summary": "An LLM summary replaced the conversation history (shadow tokens {tokens})",
|
|
9094
9157
|
"pool.state.waiting": "Waiting for first token",
|
|
9095
9158
|
"pool.state.streaming": "Generating",
|
|
9096
9159
|
"pool.state.completed": "Completed",
|