@duke-dsh-plugins/dsh-token-stats 1.5.1 → 1.5.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 +1 -1
- package/client.js +22 -6
- package/index.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ dsh plugin --profile web add https://github.com/MoonlitDropOfBlood/dsh-token-sta
|
|
|
65
65
|
- 切换模型时自动切换 provider;每 60s 自动刷新,**点击读数立即强制刷新**;
|
|
66
66
|
- 未配置对应 API Key 或拉取失败时显示 `⚠`(悬停查看原因);当前 provider 不在支持列表时不占位。
|
|
67
67
|
|
|
68
|
-
> **MiMo(小米)配置**:MiMo 的用量走 dashboard admin API(非公开 endpoint),纯 API Key(Bearer)实测会被 401 拒绝,可靠凭证是浏览器登录 Cookie。打开 platform.xiaomimimo.com → 订阅管理,F12 → Network 任一 `/api/v1/tokenPlan/*` 请求 → 复制完整 `Cookie` 请求头值,粘到 DSH 凭据的 `XIAOMI_MIMO_COOKIE`(或把 API Key 配到 `XIAOMI_MIMO_API_KEY`,插件会先 Bearer 后 Cookie
|
|
68
|
+
> **MiMo(小米)配置**:MiMo 的用量走 dashboard admin API(非公开 endpoint),纯 API Key(Bearer)实测会被 401 拒绝,可靠凭证是浏览器登录 Cookie。打开 platform.xiaomimimo.com → 订阅管理,F12 → Network 任一 `/api/v1/tokenPlan/*` 请求 → 复制完整 `Cookie` 请求头值,粘到 DSH 凭据的 `XIAOMI_MIMO_COOKIE`(或把 API Key 配到 `XIAOMI_MIMO_API_KEY`,插件会先 Bearer 后 Cookie 自动重试)。按 route 派生命名的凭据(设置页自动生成,如 `XIAOMI_TOKEN_PLAN_CN_API_KEY`)同样识别;composer 读数按 route id 匹配(`xiaomi-mimo` / `xiaomimimo` / `xiaomi-token-plan-cn` / 名字含 xiaomi 或 mimo 均可)。
|
|
69
69
|
|
|
70
70
|
## 工作原理
|
|
71
71
|
|
package/client.js
CHANGED
|
@@ -140,9 +140,12 @@ window.__ModuleLoader__.load({
|
|
|
140
140
|
// client assembly mounts only the five official namespaces, so a plugin
|
|
141
141
|
// must mount its own. Mirrors the invocation in typert.host.js (id,
|
|
142
142
|
// service/namespace/method). zod is not requirable in the browser module
|
|
143
|
-
// loader, so codecs use passthrough schemas
|
|
144
|
-
//
|
|
143
|
+
// loader, so codecs use passthrough schemas. 0.1.7's client-side typert
|
|
144
|
+
// remote store REJECTS strict codecs without a create() factory (same
|
|
145
|
+
// contract as typert-loader — v1.5.1 shipped without these and every
|
|
146
|
+
// $mount failed with "has no create() factory", dead Remote namespace).
|
|
145
147
|
const passthrough = () => ({ parse: (v) => v });
|
|
148
|
+
const createPassthrough = () => passthrough();
|
|
146
149
|
const CLIENT_REMOTE = {
|
|
147
150
|
package: "dsh-token-stats",
|
|
148
151
|
descriptors: [
|
|
@@ -157,6 +160,7 @@ window.__ModuleLoader__.load({
|
|
|
157
160
|
mode: "strict",
|
|
158
161
|
typeSymbol: "dsh-token-stats#TokenStatsResult",
|
|
159
162
|
schema: passthrough(),
|
|
163
|
+
create: createPassthrough,
|
|
160
164
|
},
|
|
161
165
|
},
|
|
162
166
|
{
|
|
@@ -170,19 +174,20 @@ window.__ModuleLoader__.load({
|
|
|
170
174
|
name: "provider",
|
|
171
175
|
wire: "provider",
|
|
172
176
|
source: "json",
|
|
173
|
-
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getQuota:provider", schema: passthrough() },
|
|
177
|
+
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getQuota:provider", schema: passthrough(), create: createPassthrough },
|
|
174
178
|
},
|
|
175
179
|
{
|
|
176
180
|
name: "force",
|
|
177
181
|
wire: "force",
|
|
178
182
|
source: "json",
|
|
179
|
-
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getQuota:force", schema: passthrough() },
|
|
183
|
+
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getQuota:force", schema: passthrough(), create: createPassthrough },
|
|
180
184
|
},
|
|
181
185
|
],
|
|
182
186
|
result: {
|
|
183
187
|
mode: "strict",
|
|
184
188
|
typeSymbol: "dsh-token-stats#TokenStatsQuotaResult",
|
|
185
189
|
schema: passthrough(),
|
|
190
|
+
create: createPassthrough,
|
|
186
191
|
},
|
|
187
192
|
},
|
|
188
193
|
{
|
|
@@ -196,13 +201,14 @@ window.__ModuleLoader__.load({
|
|
|
196
201
|
name: "force",
|
|
197
202
|
wire: "force",
|
|
198
203
|
source: "json",
|
|
199
|
-
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getAllQuotas:force", schema: passthrough() },
|
|
204
|
+
codec: { mode: "strict", typeSymbol: "dsh-token-stats#tokenStats/getAllQuotas:force", schema: passthrough(), create: createPassthrough },
|
|
200
205
|
},
|
|
201
206
|
],
|
|
202
207
|
result: {
|
|
203
208
|
mode: "strict",
|
|
204
209
|
typeSymbol: "dsh-token-stats#TokenStatsAllQuotasResult",
|
|
205
210
|
schema: passthrough(),
|
|
211
|
+
create: createPassthrough,
|
|
206
212
|
},
|
|
207
213
|
},
|
|
208
214
|
],
|
|
@@ -640,8 +646,18 @@ window.__ModuleLoader__.load({
|
|
|
640
646
|
// Xiaomi MiMo:route id 由用户添加 provider 时命名,覆盖常见拼法。
|
|
641
647
|
"xiaomi-mimo": "mimo",
|
|
642
648
|
"xiaomimimo": "mimo",
|
|
649
|
+
"xiaomi-token-plan-cn": "mimo",
|
|
643
650
|
"mimo": "mimo",
|
|
644
651
|
};
|
|
652
|
+
/** route id → 内部 key:精确查表未命中时对 mimo 做包含回退(route id 用户自由命名,如 xiaomi-token-plan-cn)。 */
|
|
653
|
+
function providerKeyForRoute(route) {
|
|
654
|
+
if (!route) return null;
|
|
655
|
+
const exact = PROVIDER_ALIASES[route];
|
|
656
|
+
if (exact !== undefined) return exact;
|
|
657
|
+
const lower = String(route).toLowerCase();
|
|
658
|
+
if (lower.includes("mimo") || lower.includes("xiaomi")) return "mimo";
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
645
661
|
const QUOTA_PROVIDER_ORDER = ["minimax", "deepseek", "kimi", "openrouter", "zhipu", "mimo"];
|
|
646
662
|
|
|
647
663
|
function quotaProviderLabel(p) {
|
|
@@ -779,7 +795,7 @@ window.__ModuleLoader__.load({
|
|
|
779
795
|
try {
|
|
780
796
|
const snap = directory.store.getSnapshot();
|
|
781
797
|
const route = snap && snap.current && snap.current.provider;
|
|
782
|
-
setProvider(route
|
|
798
|
+
setProvider(providerKeyForRoute(route));
|
|
783
799
|
} catch (e) {
|
|
784
800
|
setProvider(null);
|
|
785
801
|
}
|
package/index.js
CHANGED
|
@@ -146,10 +146,14 @@ const QUOTA_PROVIDERS = {
|
|
|
146
146
|
// Bearer 实测 401(session 守护),可靠路径是登录 Cookie;单个凭证值先
|
|
147
147
|
// Bearer 后 Cookie 自动重试(对齐 Musage xiaomi.rs 的 BearerThenCookie)。
|
|
148
148
|
// 在 DSH 凭据里把浏览器 DevTools 复制的完整 Cookie 或 API Key 配到
|
|
149
|
-
// XIAOMI_MIMO_API_KEY / XIAOMI_MIMO_COOKIE(或 MIMO_*)任一 ref
|
|
149
|
+
// XIAOMI_MIMO_API_KEY / XIAOMI_MIMO_COOKIE(或 MIMO_*)任一 ref;route 派生
|
|
150
|
+
// 名(设置页按 route 生成的 XIAOMI_TOKEN_PLAN_CN_API_KEY/_COOKIE,与
|
|
151
|
+
// 其他 provider 的 MINIMAX_CN_* 同规则)同样识别。
|
|
150
152
|
mimo: {
|
|
151
|
-
refs: ["XIAOMI_MIMO_API_KEY", "XIAOMI_MIMO_COOKIE", "MIMO_API_KEY", "MIMO_COOKIE"],
|
|
153
|
+
refs: ["XIAOMI_TOKEN_PLAN_CN_API_KEY", "XIAOMI_TOKEN_PLAN_CN_COOKIE", "XIAOMI_MIMO_API_KEY", "XIAOMI_MIMO_COOKIE", "MIMO_API_KEY", "MIMO_COOKIE"],
|
|
152
154
|
urls: {
|
|
155
|
+
XIAOMI_TOKEN_PLAN_CN_API_KEY: "https://platform.xiaomimimo.com/api/v1/tokenPlan/usage",
|
|
156
|
+
XIAOMI_TOKEN_PLAN_CN_COOKIE: "https://platform.xiaomimimo.com/api/v1/tokenPlan/usage",
|
|
153
157
|
XIAOMI_MIMO_API_KEY: "https://platform.xiaomimimo.com/api/v1/tokenPlan/usage",
|
|
154
158
|
XIAOMI_MIMO_COOKIE: "https://platform.xiaomimimo.com/api/v1/tokenPlan/usage",
|
|
155
159
|
MIMO_API_KEY: "https://platform.xiaomimimo.com/api/v1/tokenPlan/usage",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duke-dsh-plugins/dsh-token-stats",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Token usage statistics for DeepSeek Harness (7/30-day per-model charts + yearly heatmap) plus an inline coding-plan balance/quota readout in the composer (minimax/deepseek/kimi/openrouter/zhipu).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|