@lyk308/dsh-token-dashboard 0.1.3 → 0.1.4
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 +69 -64
- package/README.zh.md +69 -64
- package/docs/screenshot.png +0 -0
- package/docs/screenshot2.png +0 -0
- package/lib/client.js +561 -393
- package/lib/index.js +73 -43
- package/package.json +45 -45
package/README.md
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
# dsh-token-dashboard
|
|
2
|
-
|
|
3
|
-
[](https://awesome-dsh-plugin.com)
|
|
4
|
-
|
|
5
|
-
A DeepSeek Harness plugin that puts your **real-time account balance
|
|
6
|
-
|
|
7
|
-
## Screenshots
|
|
8
|
-
|
|
9
|
-
, with force-refresh.
|
|
16
|
-
- 📊 **Token usage** — Today / This month / All-time cards, plus request count, cache hit rate, and session count.
|
|
17
|
-
- 💵 **Cost estimation** — accurate DeepSeek pricing
|
|
18
|
-
- 📈 **Usage distribution** — toggle
|
|
19
|
-
- 📉 **Daily trend** — an
|
|
20
|
-
- 🗓 **Activity heatmap** — 30 / 90 / 180
|
|
21
|
-
- 🤖 **Model breakdown** — a table of Req / Input / Cache / Output / Cost per model.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# From
|
|
32
|
-
dsh plugin --profile web add
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `lib/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
# dsh-token-dashboard
|
|
2
|
+
|
|
3
|
+
[](https://awesome-dsh-plugin.com)
|
|
4
|
+
|
|
5
|
+
A DeepSeek Harness plugin that puts your **real-time account balance**, **token usage**, and **cost estimation** on one dashboard. Local-first: reads your DSH session logs and the DeepSeek `/user/balance` API. No extra cloud account — it reuses your existing DeepSeek key.
|
|
6
|
+
|
|
7
|
+
## Screenshots
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 💰 **Account balance** — live balance from the DeepSeek official `/user/balance` API (CNY/USD aware), with force-refresh.
|
|
16
|
+
- 📊 **Token usage** — Today / This month / All-time cards, plus request count, cache hit rate, and session count.
|
|
17
|
+
- 💵 **Cost estimation** — accurate DeepSeek V4 pricing, **peak/off-peak aware**, per-model cost, and Today / This month / All-time spend.
|
|
18
|
+
- 📈 **Usage distribution** — toggle **by model** / **by workspace**, and **by token** / **by cost**. Proportional share bar (top 8 + "其他" aggregate). Percentages match the bar exactly.
|
|
19
|
+
- 📉 **Daily trend** — an interactive mini area chart (grid + axes + date labels) of daily cost or tokens, with hover tooltips per day.
|
|
20
|
+
- 🗓 **Activity heatmap** — 30 / 90 / 180-day switch; green-shade intensity maps token usage.
|
|
21
|
+
- 🤖 **Model breakdown** — a table of Req / Input / Cache / Output / Cost per model.
|
|
22
|
+
- 🗂 **Recent sessions** — per-session total / cost / model / time, sorted by most recent activity.
|
|
23
|
+
- 📅 **Global time window** — switch the whole dashboard between 近7天 / 近30天 / 近90天 / 全部 (Today / This-month stay fixed).
|
|
24
|
+
- 📤 **Export** — one-click download of the current stats as **CSV** or **JSON**.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
This is a standard DSH bundle plugin, so install it with the official CLI:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# From GitHub
|
|
32
|
+
dsh plugin --profile web add github:lyk308/dsh-token-dashboard
|
|
33
|
+
|
|
34
|
+
# From npm
|
|
35
|
+
dsh plugin --profile web add @lyk308/dsh-token-dashboard
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After installing, **refresh the web UI**. The dashboard appears under **Settings → 用量看板** (Usage Dashboard).
|
|
39
|
+
|
|
40
|
+
> Note: the plugin reads the DeepSeek API key from DSH's credentials service (`DEEPSEEK_API_KEY`). Without a valid key the balance card shows a hint; token usage still works because it comes from local session logs.
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
1. Open **Settings → 用量看板**.
|
|
45
|
+
2. In the top bar, pick a **time window** (近7天 / 30天 / 90天 / 全部).
|
|
46
|
+
3. Switch the share bar between **by model / by workspace** and **by token / by cost**.
|
|
47
|
+
4. Hover the trend chart to see a single day's value.
|
|
48
|
+
5. Use **导出 CSV / 导出 JSON** to download the current stats.
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
The plugin works out of the box. The host half resolves sensible defaults in `lib/index.js`:
|
|
53
|
+
|
|
54
|
+
- `sessionsRoot` — defaults to `$DSH_HOME/sessions`.
|
|
55
|
+
- `balanceCacheMs` — balance cache TTL (default 300000 ms = 5 min).
|
|
56
|
+
- `sweepIntervalMs` — stats refresh interval (default 60000 ms).
|
|
57
|
+
|
|
58
|
+
> Cost estimation uses DeepSeek's official V4 pricing (CNY per 1,000,000 tokens) with peak/off-peak billing: peak = Mon–Fri 09:00–12:00 & 14:00–18:00 (off-peak is half price). Prices live in the `MODEL_PRICES` map in `lib/index.js` — edit it if DeepSeek changes prices.
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
- `lib/index.js` — host half: session scanning (multi-frame zstd), token aggregation, cost estimation, per-window filtering, balance proxy.
|
|
63
|
+
- `lib/client.js` — client half: the settings.section UI, trend chart, export, share toggles.
|
|
64
|
+
|
|
65
|
+
Edit `lib/client.js` → refresh the page to see changes. Edit `lib/index.js` → restart the DSH web profile.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
[MIT](./LICENSE)
|
package/README.zh.md
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
# dsh-token-dashboard
|
|
2
|
-
|
|
3
|
-
[](https://awesome-dsh-plugin.com)
|
|
4
|
-
|
|
5
|
-
一个 DeepSeek Harness 插件,把**实时账户余额**、**Token 使用量**和**成本估算**整合在一个看板上。本地优先:读取你的 DSH 会话日志 + DeepSeek 官方 `/user/balance` 接口,无需额外云端账号(沿用你已有的 DeepSeek key)。
|
|
6
|
-
|
|
7
|
-
## 效果预览
|
|
8
|
-
|
|
9
|
-
,支持强制刷新。
|
|
16
|
-
- 📊 **Token 使用量** — 今日 / 本月 / 总计三卡,加请求数、缓存命中率、会话数。
|
|
17
|
-
- 💵 **成本估算** — 精确的 DeepSeek
|
|
18
|
-
- 📈 **用量分布** —
|
|
19
|
-
- 📉 **每日趋势** —
|
|
20
|
-
- 🗓 **活跃度热力图** — 30 / 90 / 180 天切换,绿色深浅映射 Token 用量。
|
|
21
|
-
- 🤖 **按模型明细** — 每个模型的 Req / Input / Cache / Output / Cost 表格。
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# 从
|
|
32
|
-
dsh plugin --profile web add
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- `lib/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
# dsh-token-dashboard
|
|
2
|
+
|
|
3
|
+
[](https://awesome-dsh-plugin.com)
|
|
4
|
+
|
|
5
|
+
一个 DeepSeek Harness 插件,把**实时账户余额**、**Token 使用量**和**成本估算**整合在一个看板上。本地优先:读取你的 DSH 会话日志 + DeepSeek 官方 `/user/balance` 接口,无需额外云端账号(沿用你已有的 DeepSeek key)。
|
|
6
|
+
|
|
7
|
+
## 效果预览
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## 功能
|
|
14
|
+
|
|
15
|
+
- 💰 **账户余额** — 通过 DeepSeek 官方 `/user/balance` 接口实时获取(自动识别 CNY/USD),支持强制刷新。
|
|
16
|
+
- 📊 **Token 使用量** — 今日 / 本月 / 总计三卡,加请求数、缓存命中率、会话数。
|
|
17
|
+
- 💵 **成本估算** — 精确的 DeepSeek V4 定价,**区分峰谷时段**,按模型成本,以及 今日/本月/总计 花费。
|
|
18
|
+
- 📈 **用量分布** — 可在**按模型 / 按工作区**之间切换,也支持**按 Token / 按成本**。带比例占比条(前 8 项 + 「其他」聚合),百分比与占比条完全一致。
|
|
19
|
+
- 📉 **每日趋势** — 可交互的 mini 面积图(网格 + 坐标轴 + 日期标注),展示每日成本或 Token,鼠标悬停显示单日数值。
|
|
20
|
+
- 🗓 **活跃度热力图** — 30 / 90 / 180 天切换,绿色深浅映射 Token 用量。
|
|
21
|
+
- 🤖 **按模型明细** — 每个模型的 Req / Input / Cache / Output / Cost 表格。
|
|
22
|
+
- 🗂 **最近会话** — 按活跃时间排序,展示每次会话的 token / 成本 / 模型 / 时间。
|
|
23
|
+
- 📅 **全局时间窗口** — 一键切换整个看板的统计范围:近7天 / 近30天 / 近90天 / 全部(「今日 / 本月」保持不变)。
|
|
24
|
+
- 📤 **数据导出** — 一键导出当前统计为 **CSV** 或 **JSON**。
|
|
25
|
+
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
这是一个标准 DSH bundle 插件,用官方 CLI 安装:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 从 GitHub 安装
|
|
32
|
+
dsh plugin --profile web add github:lyk308/dsh-token-dashboard
|
|
33
|
+
|
|
34
|
+
# 从 npm 安装
|
|
35
|
+
dsh plugin --profile web add @lyk308/dsh-token-dashboard
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
安装后**刷新网页**即可。看板位于 **设置 → 用量看板**。
|
|
39
|
+
|
|
40
|
+
> 说明:插件从 DSH 的凭据服务读取 DeepSeek API Key(`DEEPSEEK_API_KEY`)。没有有效 key 时余额卡片显示引导文案;Token 用量仍可正常统计(来自本地会话日志)。
|
|
41
|
+
|
|
42
|
+
## 使用方法
|
|
43
|
+
|
|
44
|
+
1. 打开 **设置 → 用量看板**。
|
|
45
|
+
2. 顶部选择**时间范围**(近7天 / 30天 / 90天 / 全部)。
|
|
46
|
+
3. 切换占比条的 **按模型 / 按工作区** 以及 **按 Token / 按成本**。
|
|
47
|
+
4. 在趋势图上**悬停**,查看某一天的数值。
|
|
48
|
+
5. 点 **导出 CSV / 导出 JSON** 下载当前统计数据。
|
|
49
|
+
|
|
50
|
+
## 配置
|
|
51
|
+
|
|
52
|
+
插件基本无需配置即可使用,host 半在 `lib/index.js` 里解析合理默认值:
|
|
53
|
+
|
|
54
|
+
- `sessionsRoot` — 默认为 `$DSH_HOME/sessions`。
|
|
55
|
+
- `balanceCacheMs` — 余额缓存时长(默认 300000 毫秒 = 5 分钟)。
|
|
56
|
+
- `sweepIntervalMs` — 统计刷新间隔(默认 60000 毫秒)。
|
|
57
|
+
|
|
58
|
+
> 成本估算使用 DeepSeek 官方 V4 定价(元/百万 tokens),按峰谷计费:高峰 = 周一至周五 09:00-12:00、14:00-18:00(空闲时段减半)。价格定义在 `lib/index.js` 的 `MODEL_PRICES`,可随 DeepSeek 调价而修改。
|
|
59
|
+
|
|
60
|
+
## 开发
|
|
61
|
+
|
|
62
|
+
- `lib/index.js` — host 半:会话扫描(多帧 zstd)、Token 聚合、成本估算、时间窗口过滤、余额代理。
|
|
63
|
+
- `lib/client.js` — client 半:settings.section 界面、趋势图、数据导出、占比切换。
|
|
64
|
+
|
|
65
|
+
改 `lib/client.js` → 刷新页面即可看到变化。改 `lib/index.js` → 重启 DSH web profile。
|
|
66
|
+
|
|
67
|
+
## 许可证
|
|
68
|
+
|
|
69
|
+
[MIT](./LICENSE)
|
package/docs/screenshot.png
CHANGED
|
Binary file
|
package/docs/screenshot2.png
CHANGED
|
Binary file
|