@linxin666/dsh-usage 0.4.5 → 0.4.6
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/lib/client.js +42 -22
- package/lib/client.js.map +1 -1
- package/lib/types/client/voucher.d.ts +27 -9
- package/package.json +2 -2
- package/src/client/UsageSectionCard.tsx +10 -10
- package/src/client/locales.ts +4 -4
- package/src/client/voucher.ts +33 -11
package/lib/client.js
CHANGED
|
@@ -107,8 +107,8 @@ window.__ModuleLoader__.load({
|
|
|
107
107
|
"usage.config.pollIntervalSec": "轮询间隔(秒)",
|
|
108
108
|
"usage.config.saveFailed": "保存失败:设置未被接受。",
|
|
109
109
|
"usage.bank.title": "鲸元券",
|
|
110
|
-
"usage.bank.hint": "官方 API 每消耗 100 万 tokens 铸造 1 鲸元;保存或分享这张票券。",
|
|
111
|
-
"usage.bank.noUsage": "暂无 DeepSeek
|
|
110
|
+
"usage.bank.hint": "DeepSeek 官方 API 与 MiMo 每消耗 100 万 tokens 铸造 1 鲸元;保存或分享这张票券。",
|
|
111
|
+
"usage.bank.noUsage": "暂无 DeepSeek 官方 / MiMo 用量数据(统计自插件启用起)",
|
|
112
112
|
"usage.bank.minted": "累计铸造 {minted} 鲸元({tokens} tokens)",
|
|
113
113
|
"usage.bank.spend.observed": "官方余额实测花费 ¥{cost}(自 {since} 起)",
|
|
114
114
|
"usage.bank.spend.estimated": "消费估算:约 ¥{cost}",
|
|
@@ -173,8 +173,8 @@ window.__ModuleLoader__.load({
|
|
|
173
173
|
"usage.config.pollIntervalSec": "Poll interval (seconds)",
|
|
174
174
|
"usage.config.saveFailed": "Save failed: the deployment did not accept the setting.",
|
|
175
175
|
"usage.bank.title": "Whale-yuan voucher",
|
|
176
|
-
"usage.bank.hint": "Every 1,000,000 tokens spent on the official API mint one whale yuan; save or share the note.",
|
|
177
|
-
"usage.bank.noUsage": "No official
|
|
176
|
+
"usage.bank.hint": "Every 1,000,000 tokens spent on the DeepSeek official API or on MiMo mint one whale yuan; save or share the note.",
|
|
177
|
+
"usage.bank.noUsage": "No DeepSeek official or MiMo usage yet (counting starts when the plugin is enabled)",
|
|
178
178
|
"usage.bank.minted": "Minted {minted} whale yuan ({tokens} tokens)",
|
|
179
179
|
"usage.bank.spend.observed": "Spent ¥{cost} observed on the official balance (watching since {since})",
|
|
180
180
|
"usage.bank.spend.estimated": "Estimated spend: about ¥{cost}",
|
|
@@ -1067,8 +1067,8 @@ window.__ModuleLoader__.load({
|
|
|
1067
1067
|
//#endregion
|
|
1068
1068
|
//#region src/client/voucher.ts
|
|
1069
1069
|
/**
|
|
1070
|
-
* The Whale-yuan voucher (鲸元券): the
|
|
1071
|
-
*
|
|
1070
|
+
* The Whale-yuan voucher (鲸元券): the mint family's retained ledger totals
|
|
1071
|
+
* stamped onto the banknote artwork as a denomination, ready
|
|
1072
1072
|
* to save or share. The canvas copy is deliberately locale-neutral (digits,
|
|
1073
1073
|
* latin captions, ISO dates) so the exported image needs no dictionary;
|
|
1074
1074
|
* everything user-facing around it lives in the section's locales. The pure
|
|
@@ -1090,21 +1090,41 @@ window.__ModuleLoader__.load({
|
|
|
1090
1090
|
return `${date.getFullYear()}-${month}-${day}`;
|
|
1091
1091
|
}
|
|
1092
1092
|
/**
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1093
|
+
* Provider route ids minted beside the DeepSeek official family: the MiMo
|
|
1094
|
+
* gateway, which a profile may run as its default route and which the ledger
|
|
1095
|
+
* records under its own route id. The bank counts the tokens a profile spends,
|
|
1096
|
+
* not only the ones DeepSeek bills. Route ids rather than adapter families
|
|
1097
|
+
* because minting is an accounting decision that must never widen the
|
|
1098
|
+
* credential or probing paths — the same split `isDeepSeekProviderRoute()`
|
|
1099
|
+
* keeps against `adapterFor()` (issue #1772). An empty list mints exactly the
|
|
1100
|
+
* official family, which is how a profile that never runs MiMo behaves.
|
|
1097
1101
|
*/
|
|
1098
|
-
|
|
1102
|
+
const EXTRA_MINT_ROUTE_IDS = ["mimo"];
|
|
1103
|
+
/** Whether one provider route's ledger rows mint whale yuan. */
|
|
1104
|
+
function mintsWhaleYuan(provider) {
|
|
1105
|
+
return isDeepSeekProviderRoute(provider) || EXTRA_MINT_ROUTE_IDS.includes(provider);
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Sum the mint family's rows out of a usage window: the whole DeepSeek
|
|
1109
|
+
* official family (the `deepseek` catalog alias, the live `deepseek-official`
|
|
1110
|
+
* route and the signed-in `deepseek-account` route all fold into one voucher)
|
|
1111
|
+
* plus {@link EXTRA_MINT_ROUTE_IDS}. Undefined when the window is absent
|
|
1112
|
+
* (older host) or the family has no usage — a zero-token note mints nothing.
|
|
1113
|
+
*
|
|
1114
|
+
* Only the priced family contributes `cost`: MiMo ships no price book, so it
|
|
1115
|
+
* mints tokens and calls while the spend line keeps reporting the official
|
|
1116
|
+
* family's fold-time estimate (and the observed-balance watch above it).
|
|
1117
|
+
*/
|
|
1118
|
+
function voucherData(window) {
|
|
1099
1119
|
if (window === void 0) return void 0;
|
|
1100
1120
|
let tokens = 0;
|
|
1101
1121
|
let calls = 0;
|
|
1102
1122
|
let cost = 0;
|
|
1103
1123
|
for (const row of window.providers) {
|
|
1104
|
-
if (!
|
|
1124
|
+
if (!mintsWhaleYuan(row.provider)) continue;
|
|
1105
1125
|
tokens += totalTokens(row.totals);
|
|
1106
1126
|
calls += row.totals.calls;
|
|
1107
|
-
cost += row.totals.cost;
|
|
1127
|
+
if (isDeepSeekProviderRoute(row.provider)) cost += row.totals.cost;
|
|
1108
1128
|
}
|
|
1109
1129
|
if (tokens <= 0) return void 0;
|
|
1110
1130
|
return {
|
|
@@ -1791,18 +1811,18 @@ window.__ModuleLoader__.load({
|
|
|
1791
1811
|
return totals.inputTokens + totals.cacheReadTokens + totals.cacheWriteTokens + totals.outputTokens;
|
|
1792
1812
|
}
|
|
1793
1813
|
/**
|
|
1794
|
-
* The Token 银行 card: the
|
|
1795
|
-
* minted onto the whale-yuan note at 1,000,000 tokens
|
|
1796
|
-
* window is the whole retained ledger by default (the
|
|
1797
|
-
* falling back to the 30-day trend when an older host serves
|
|
1798
|
-
* single day the user picked; the spend line prefers the
|
|
1799
|
-
* watch (whole window only) and falls back to the fold-time
|
|
1800
|
-
*
|
|
1801
|
-
* down.
|
|
1814
|
+
* The Token 银行 card: the mint family's (DeepSeek official + MiMo)
|
|
1815
|
+
* retained-ledger usage minted onto the whale-yuan note at 1,000,000 tokens
|
|
1816
|
+
* per whale yuan. The window is the whole retained ledger by default (the
|
|
1817
|
+
* host's aggregate, falling back to the 30-day trend when an older host serves
|
|
1818
|
+
* no `all`) or the single day the user picked; the spend line prefers the
|
|
1819
|
+
* official balance watch (whole window only) and falls back to the fold-time
|
|
1820
|
+
* estimate, which only the priced family feeds; the artwork draw failure
|
|
1821
|
+
* degrades to an error line and never takes the section down.
|
|
1802
1822
|
*/
|
|
1803
1823
|
function VoucherCard(props) {
|
|
1804
1824
|
const { window: ledger, observedSpend, loading, error } = props;
|
|
1805
|
-
const data =
|
|
1825
|
+
const data = voucherData(ledger);
|
|
1806
1826
|
const canvasRef = (0, react.useRef)(null);
|
|
1807
1827
|
const [drawError, setDrawError] = (0, react.useState)(void 0);
|
|
1808
1828
|
(0, react.useEffect)(() => {
|