dsh-token-dash 2.3.0 → 2.4.0
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.en.md +11 -8
- package/README.md +11 -8
- package/client.js +302 -76
- package/index.js +30 -8
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +4 -3
- package/src/adapters.js +568 -561
- package/src/core.js +919 -887
- package/src/diagnostics.js +160 -108
- package/src/quota-sources.js +228 -224
- package/src/version.js +44 -37
package/README.en.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<p align="center">
|
|
24
24
|
<img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
|
|
25
25
|
<img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
|
|
26
|
-
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.
|
|
26
|
+
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.3_tested-4c8bf5" alt="DSH tested" />
|
|
27
27
|
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
|
|
28
28
|
<a href="https://awesome-dsh-plugin.com/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
|
|
29
29
|
</p>
|
|
@@ -41,13 +41,14 @@ Only the official endpoints listed below are called. Any other provider is still
|
|
|
41
41
|
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`, optional `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`; falls back to `GET api.moonshot.cn/v1/users/me/balance` | Subscription / API usage | 5h + weekly/monthly windows; falls back to balance |
|
|
42
42
|
| OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API usage | Credits (USD) |
|
|
43
43
|
| Qwen | `DASHSCOPE_API_KEY` (CNY) / `DASHSCOPE_INTL_API_KEY` (USD) | No balance endpoint | API usage | Local usage only; balance unsupported |
|
|
44
|
-
| OpenCode Go | `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`, falls back to `GET opencode.ai/api/v1/usage` | Subscription | 5h / weekly / monthly windows (USD) |
|
|
44
|
+
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`, falls back to `GET opencode.ai/api/v1/usage` | Subscription | 5h / weekly / monthly windows (USD) |
|
|
45
45
|
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits` (with `orgId`) | Subscription | 5h + weekly windows, credits (CNY) |
|
|
46
46
|
| Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`; `GET ollama.com/api/usage?range=30d` | API usage | Plan + purchased credits (USD), plan usage, cycle, 30-day channel usage |
|
|
47
47
|
| Any other provider (self-hosted, relay, local Ollama) | None | No endpoint | API usage | Priced by model name only; unpriced rows can be backfilled |
|
|
48
48
|
|
|
49
49
|
- Save keys under the names above in DSH's credential settings; the plugin reads them through the host `credentials` service, not environment variables or local login files.
|
|
50
50
|
- Ollama is added through DSH's custom OpenAI-compatible provider: the route id must be `ollama` (the key reference is derived as `<ROUTE>_API_KEY` → `OLLAMA_API_KEY`). Any other id will not resolve the key and the balance card will not appear.
|
|
51
|
+
- OpenCode Go reads `OPENCODE_API_KEY`, the same name pi-ai uses for its routes, so configuring the LLM route is enough; `OPENCODE_GO_API_KEY` remains accepted. The `<ROUTE>_API_KEY` derivation applies to custom providers only — built-in providers get their names from the pi-ai catalog.
|
|
51
52
|
- Keys are detected automatically; GLM / Kimi / OpenCode Go / Command Code can be re-detected from the dashboard footer.
|
|
52
53
|
- Subscription models count toward Tokens but not cost; billing mode is pinned per key instead of following quota flakiness.
|
|
53
54
|
- Balance, quota and usage are separate; a balance failure never resets today's Token ledger to zero.
|
|
@@ -57,7 +58,7 @@ Only the official endpoints listed below are called. Any other provider is still
|
|
|
57
58
|
|
|
58
59
|
Screenshots use mock data so the full layout is visible at once.
|
|
59
60
|
|
|
60
|
-
**P1 · Composer footer-right Pill**: API usage / subscription variants; click to open, click outside, `×` or `Esc` to close.
|
|
61
|
+
**P1 · Composer footer-right Pill**: API usage / subscription variants; click to open, click outside, `×` or `Esc` to close. The API variant shows one line of budget ring + today's spend + real balance; the subscription variant shows a ring per window. Colour only signals alerts — a healthy state stays neutral.
|
|
61
62
|
|
|
62
63
|
<p align="center">
|
|
63
64
|
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/pill-api.png" alt="API usage pill" />
|
|
@@ -84,21 +85,23 @@ Screenshots use mock data so the full layout is visible at once.
|
|
|
84
85
|
- Subscription windows use three slots: first left, second center, third right; two windows occupy the first two slots.
|
|
85
86
|
- Model column is capped at 150; Tokens / requests / hit rate are right-aligned.
|
|
86
87
|
|
|
87
|
-
**P3 · Full dashboard**: cards for 8 providers, a four-cell summary (
|
|
88
|
+
**P3 · Full dashboard**: cards for 8 providers, a four-cell summary (real tokens / cost / cache hit rate / requests), a metric-switchable trend chart (including the dual-currency, dual-axis cost view), a model breakdown with subscription estimates, and a settings capsule; the page owns its scrollbar at the window edge.
|
|
88
89
|
|
|
89
90
|
<p align="center">
|
|
90
91
|
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/en/settings.png" alt="Full dashboard" />
|
|
91
92
|
</p>
|
|
92
93
|
|
|
93
|
-
- API usage card: budget input, planned balance, real balance, month-to-date spend; subscription card: one ring per window with remaining percentage and countdown.
|
|
94
|
-
-
|
|
94
|
+
- API usage card: budget input, planned balance, real balance, month-to-date spend; subscription card: one ring per window with remaining percentage and countdown, plus an estimated monthly value when available; cards no longer carry a status line.
|
|
95
|
+
- Trend chart: the vertical axis takes its own column outside the plot, with three ticks that follow the selected metric; three grid lines line up with those ticks; the hit-rate axis is pinned to 100% at the top, and a single 0% day cannot drag its floor back to zero. With **two currencies** the cost metric switches to a **dual-axis, two-bar** layout — CNY on the left axis, USD on the right, each scaled to its own maximum, with a colour legend in the header.
|
|
96
|
+
- Total cost tile: includes subscription estimates alongside actual billing, captioned “{n} currencies · incl. estimates”.
|
|
97
|
+
- Breakdown: its own section heading, then model / Tokens / input / cache / output / requests / hit rate / cost; everything except the model column is right-aligned. Cost is always marked `≈` as a local estimate, and subscription rows show what those tokens would cost at API rates (or “not priced”, or `—` when no estimate exists).
|
|
95
98
|
- Settings capsule: refresh interval + account-balance toggle; logs, export/import, price table and version below.
|
|
96
99
|
- The settings section has an external "Settings and data" title above the capsule; the capsule itself keeps the refresh interval, logs/data controls and version row.
|
|
97
100
|
- Spacing uses only 4 / 8 / 12 / 16 / 24 / 32; P2 and P3 share the same tokens.
|
|
98
101
|
|
|
99
102
|
## Install
|
|
100
103
|
|
|
101
|
-
Requires DSH `0.2.1` or newer; tested on **DSH 0.2.2-rc.
|
|
104
|
+
Requires DSH `0.2.1` or newer; tested on **DSH 0.2.2-rc.3**. DSH 0.2.2 itself requires Node **24.9+**.
|
|
102
105
|
|
|
103
106
|
```bash
|
|
104
107
|
# Option 1: install from npm (recommended)
|
|
@@ -117,7 +120,7 @@ Update: run `update` with the same name, or use the update button on the right o
|
|
|
117
120
|
|
|
118
121
|
## Compatibility & limitations
|
|
119
122
|
|
|
120
|
-
- DSH `0.2.1+`; verified on `0.2.2-rc.
|
|
123
|
+
- DSH `0.2.1+`; verified on `0.2.2-rc.3`. DSH 0.2.2 is a pre-release and itself requires Node 24.9.
|
|
121
124
|
- The UI currently ships Chinese / English only. Other DSH languages (Japanese, German, Russian, etc.) fall back to English.
|
|
122
125
|
- After a DSH upgrade the plugin may disappear from the profile; reinstall the same tarball — the ledger is not deleted.
|
|
123
126
|
- Qwen tracks usage only; its balance endpoint is unsupported. Other balances/quotas follow what each API returns.
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<p align="center">
|
|
24
24
|
<img src="https://img.shields.io/github/v/tag/spartawhy117/dsh-token-dash?label=version&sort=semver" alt="version" />
|
|
25
25
|
<img src="https://img.shields.io/npm/dt/dsh-token-dash?logo=npm&label=npm%20downloads" alt="npm downloads" />
|
|
26
|
-
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.
|
|
26
|
+
<img src="https://img.shields.io/badge/DSH-0.2.2--rc.3_tested-4c8bf5" alt="DSH tested" />
|
|
27
27
|
<img src="https://img.shields.io/github/license/spartawhy117/dsh-token-dash" alt="license" />
|
|
28
28
|
<a href="https://awesome-dsh-plugin.com/zh/p/spartawhy117/dsh-token-dash"><img src="https://img.shields.io/badge/awesome--dsh--plugin-listed-6ea8ff" alt="awesome-dsh-plugin" /></a>
|
|
29
29
|
</p>
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
| Kimi Coding | `KIMI_API_KEY` / `KIMI_CODING_API_KEY`,可选 `MOONSHOT_API_KEY` | `GET api.kimi.com/coding/v1/usages`;回落 `GET api.moonshot.cn/v1/users/me/balance` | 订阅 / API 用量 | 5h + 周/月窗口;订阅查询失败可回落余额 |
|
|
42
42
|
| OpenRouter | `OPENROUTER_API_KEY` | `GET openrouter.ai/api/v1/credits` | API 用量 | Credits(USD) |
|
|
43
43
|
| Qwen | `DASHSCOPE_API_KEY`(CNY)/ `DASHSCOPE_INTL_API_KEY`(USD) | 不请求余额接口 | API 用量 | 仅本地用量;余额不支持 |
|
|
44
|
-
| OpenCode Go | `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`,回落 `GET opencode.ai/api/v1/usage` | 订阅 | 5h / 周 / 月窗口(USD) |
|
|
44
|
+
| OpenCode Go | `OPENCODE_API_KEY` / `OPENCODE_GO_API_KEY` | `GET opencode.ai/zen/go/v1/usage`,回落 `GET opencode.ai/api/v1/usage` | 订阅 | 5h / 周 / 月窗口(USD) |
|
|
45
45
|
| Command Code | `COMMAND_CODE_API_KEY` + `COMMAND_CODE_ORG_ID` | `GET api.commandcode.ai/alpha/billing/credits`(带 `orgId`) | 订阅 | 5h + 周窗口、Credits(CNY) |
|
|
46
46
|
| Ollama Cloud | `OLLAMA_API_KEY` | `GET ollama.com/api/balance`;`GET ollama.com/api/usage?range=30d` | API 用量 | 套餐剩余 + 购买余额(USD)、套餐已用、周期、渠道 30 天用量 |
|
|
47
47
|
| 其他任意 provider(自建、中转、Ollama 本地) | 无需凭据 | 不请求任何接口 | API 用量 | 只按模型名计价;未定价可补算 |
|
|
48
48
|
|
|
49
49
|
- 在 DSH 的凭据设置中按上表名称保存 Key;插件只通过宿主 `credentials` 读取,不读环境变量或本机登录文件。
|
|
50
50
|
- Ollama 在 DSH 里需要用「自定义 OpenAI 兼容供应商」接入:route id 必须填 `ollama`(凭据按 `<ROUTE>_API_KEY` 派生成 `OLLAMA_API_KEY`),自定义名填别的会取不到 Key,余额卡也不会出现。
|
|
51
|
+
- OpenCode Go 的 `OPENCODE_API_KEY` 与 pi-ai 路由配置同名,配好 LLM 路由后无需再填第二份;旧名 `OPENCODE_GO_API_KEY` 仍兼容。`<ROUTE>_API_KEY` 派生只适用于自定义供应商,内置供应商的凭据名由 pi-ai 目录决定。
|
|
51
52
|
- 填 Key 后自动探测;GLM / Kimi / OpenCode Go / Command Code 可在「全量看板」底部重新检测订阅。
|
|
52
53
|
- 订阅模型计入 Tokens,但不计费用;计费形态按 Key 固化,不随配额接口抖动。
|
|
53
54
|
- 余额、配额、用量分开展示;余额失败不会把当天的 Token 记账清零。
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
以下截图使用假数据演示,便于一次看到完整效果。
|
|
59
60
|
|
|
60
|
-
**P1 · 输入框底栏右侧 Pill**:API 用量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。
|
|
61
|
+
**P1 · 输入框底栏右侧 Pill**:API 用量 / 订阅两种形态,点击展开浮层,点击外部、`×` 或 `Esc` 收起。API 态一行显示「预算环 + 今日花费 + 真实余额」,订阅态显示各窗口的用量环;颜色只表达告警,正常时保持中性色。
|
|
61
62
|
|
|
62
63
|
<p align="center">
|
|
63
64
|
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/pill-api.png" alt="API 用量 Pill" />
|
|
@@ -84,20 +85,22 @@
|
|
|
84
85
|
- 订阅窗口固定三槽位:第 1 窗左、第 2 窗中、第 3 窗右;只有两窗时占前两个槽位。
|
|
85
86
|
- 模型列上限 150,Tokens / 请求 / 命中右对齐;长模型名用省略号,悬浮可看全名。
|
|
86
87
|
|
|
87
|
-
**P3 · 整页看板**:8
|
|
88
|
+
**P3 · 整页看板**:8 家供应商卡片、四格摘要带(真实 Tokens / 总费用 / 缓存命中率 / 总请求数)、可切指标的趋势图(含双币种双轴成本柱)、模型明细区块(含订阅估算价)、底部设置胶囊;页面自己滚动,滚动条贴窗口右缘。
|
|
88
89
|
|
|
89
90
|
<p align="center">
|
|
90
91
|
<img src="https://raw.githubusercontent.com/spartawhy117/dsh-token-dash/main/docs/pic/settings.png" alt="整页看板" />
|
|
91
92
|
</p>
|
|
92
93
|
|
|
93
|
-
- API 用量卡:预算输入、计划余额、真实余额、本月已花;订阅卡:每个窗口一个环 + 剩余百分比 +
|
|
94
|
-
-
|
|
94
|
+
- API 用量卡:预算输入、计划余额、真实余额、本月已花;订阅卡:每个窗口一个环 + 剩余百分比 + 倒计时;有估算数据时订阅卡底部显示「本月估算」,卡片不再附带状态行。
|
|
95
|
+
- 趋势图:纵坐标独立占左侧一列(在绘图区之外),三档刻度随指标切换;上 / 中 / 下三条网格线与刻度对齐;命中率轴顶档固定 100%,单个 0% 日不会把下限拉回 0。切到「费用」且出现两种币种时改为**双轴双柱**:人民币走左轴、美元走右轴,各自按自身最大值缩放,标题行给色块图例。
|
|
96
|
+
- 四格总费用:与实际计费同列,**含订阅估算**,副行标注「{n} 个币种 · 含估算」。
|
|
97
|
+
- 明细表:独立「模型明细」区块,模型 / Tokens / 输入 / 缓存 / 输出 / 请求 / 命中 / 费用;除模型列外全部右对齐。费用一律以 `≈` 标注为本地估算,订阅行给出「若按 API 计」的估算金额(无价显示「未定价」,无估算数据显示 `—`)。
|
|
95
98
|
- 设置区:胶囊外是「设置与数据管理」区块标题;胶囊内第一行刷新间隔 + 账户余额开关,下面是日志、导出导入、价格表与版本。
|
|
96
99
|
- 间距只使用 4 / 8 / 12 / 16 / 24 / 32 六档,P2 / P3 同一套 token。
|
|
97
100
|
|
|
98
101
|
## 安装
|
|
99
102
|
|
|
100
|
-
需要 DSH `0.2.1` 或更新版本;已在 **DSH 0.2.2-rc.
|
|
103
|
+
需要 DSH `0.2.1` 或更新版本;已在 **DSH 0.2.2-rc.3** 上验证。DSH 0.2.2 自身要求 Node **24.9+**。
|
|
101
104
|
|
|
102
105
|
```bash
|
|
103
106
|
# 方式一:npm 安装(推荐)
|
|
@@ -116,7 +119,7 @@ dsh plugin --profile desktop add /path/to/dsh-token-dash-x.y.z.tgz
|
|
|
116
119
|
|
|
117
120
|
## 兼容与限制
|
|
118
121
|
|
|
119
|
-
- DSH `0.2.1+`;已在 `0.2.2-rc.
|
|
122
|
+
- DSH `0.2.1+`;已在 `0.2.2-rc.3` 上验证。DSH 0.2.2 是预发布版,且自身要求 Node 24.9。
|
|
120
123
|
- 界面语言当前仅中文 / English;选择日语、德语、俄语等其他 DSH 语言时,插件文案显示英文回退。
|
|
121
124
|
- 升级 DSH 后插件可能从 profile 消失,重装同一个 tarball 即可,账本不会被删。
|
|
122
125
|
- Qwen 只统计用量,余额接口不支持;其余供应商的余额/配额以接口实际返回为准。
|