dsh-deepseek-balance-widget 1.2.4 → 2.1.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.md +28 -77
- package/README_EN.md +28 -77
- package/lib/client.js +952 -89
- package/lib/index.js +602 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,84 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README_EN.md) | 中文
|
|
4
4
|
|
|
5
|
-
在
|
|
6
|
-
|
|
7
|
-
> 本插件完全运行在你自己的机器上:余额和用量由 **dsh 宿主端**用**你本机的凭据**(`~/.dsh/.credentials.yaml` 或环境变量)向 DeepSeek 官方接口实时查询。代码中**不内置任何 API Key / Token / 个人数据**,所以**每个人看到的都是自己的余额**,互不可见。
|
|
5
|
+
在 dsh Web 侧边栏显示 AI 余额的多平台插件:内置 **DeepSeek**,可添加 **MiMo(小米)** 等平台,每 30 秒自动刷新。
|
|
8
6
|
|
|
9
7
|
## 功能
|
|
10
8
|
|
|
11
|
-

|
|
41
10
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
11
|
+
- 侧边栏实时显示余额 / 今日消费 / 今日 Token,30 秒自动刷新,并随当前平台切换
|
|
12
|
+
- 弹窗顶部 **Tab** 切换平台(DeepSeek / MiMo…),侧边栏数值同步更新
|
|
13
|
+
- 弹窗右上角「**+ 添加**」:随时加入 MiMo 等其他 AI 平台
|
|
14
|
+
- 详情字段:余额、累计消费、今日消费、今日 Token、本月消耗(本月消费 / Tokens)
|
|
15
|
+
- 「**AI 帮我配置**」:凭证抓取与写入全交给智能体,无需手动翻 Cookies
|
|
16
|
+
- 弹窗底部显示版本号,有新版时一键自动更新
|
|
45
17
|
|
|
46
18
|
## 安装
|
|
47
19
|
|
|
48
|
-
|
|
20
|
+
需要:已安装 dsh(可用 `dsh web`)。
|
|
49
21
|
|
|
50
22
|
```bash
|
|
51
23
|
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
52
24
|
```
|
|
53
25
|
|
|
54
|
-
|
|
26
|
+
从 npm 拉取安装,dsh 自动注册到 `dsh.profile.bundles`,完成后**重启 `dsh web`** 即可。
|
|
55
27
|
|
|
56
|
-
|
|
28
|
+
也可以直接对 AI 说:*帮我用 npm 安装 dsh-deepseek-balance-widget 插件。*
|
|
57
29
|
|
|
58
|
-
##
|
|
30
|
+
## 配置
|
|
59
31
|
|
|
60
|
-
|
|
32
|
+
插件首次使用会自动创建 DeepSeek 条目,读取你本机的 `DEEPSEEK_API_KEY`。其他平台通过弹窗「+ 添加」加入。两种方式任选:
|
|
61
33
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
> 如果你本来就在用 DeepSeek API(dsh 里已经能跑对话),`DEEPSEEK_API_KEY` 通常已经配置好了,余额部分**开箱即用**。
|
|
34
|
+
**方式一:弹窗内添加**
|
|
35
|
+
1. 打开弹窗,点右上角「+ 添加」。
|
|
36
|
+
2. 选择平台,点「AI 帮我配置」,把提示语发给智能体。
|
|
37
|
+
3. AI 一步步引导你获取凭证,自动写入本机配置。
|
|
68
38
|
|
|
69
|
-
|
|
70
|
-
|---|---|---|---|
|
|
71
|
-
| `DEEPSEEK_API_KEY` | ✅ | 余额 | [platform.deepseek.com](https://platform.deepseek.com) → API Keys |
|
|
72
|
-
| `DEEPSEEK_PLATFORM_TOKEN` | ⭕ 可选 | 用量统计(累计/本月/今日消费、请求次数、Tokens) | 登录 [platform.deepseek.com](https://platform.deepseek.com) → 按 `F12` → `Application` → `Cookies` → 复制 `userToken` 的值 |
|
|
39
|
+
**方式二:直接对 AI 说**
|
|
73
40
|
|
|
74
|
-
|
|
41
|
+
> 帮我配置 dsh-deepseek-balance-widget。
|
|
75
42
|
|
|
76
|
-
|
|
43
|
+
AI 会接管全部:问 API Key / 引导获取平台 Cookie → 写入本机 → 提醒重启 `dsh web`。
|
|
77
44
|
|
|
78
|
-
|
|
45
|
+
| 平台 | 凭据 | 备注 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | 必填,余额 |
|
|
48
|
+
| DeepSeek 用量 | `DEEPSEEK_PLATFORM_TOKEN` | 可选,统计累计消费 / 本月 / 今日 |
|
|
49
|
+
| MiMo(小米) | 登录 Cookie | AI 引导获取 |
|
|
79
50
|
|
|
80
|
-
|
|
81
|
-
2. 左侧边栏(或底部设置栏旁)会出现余额按钮,显示 `余额 / 今日消费 / 今日Token`。
|
|
82
|
-
3. 点击按钮查看详情卡片,卡片右下角有「刷新」按钮,或等待 30 秒自动刷新。
|
|
51
|
+
凭据保存在你本机的 `~/.dsh/ai-balances.json`,不随插件分发。
|
|
83
52
|
|
|
84
53
|
## 卸载
|
|
85
54
|
|
|
@@ -87,26 +56,8 @@ DEEPSEEK_PLATFORM_TOKEN: xxxxxxxxxxxxxxxx # 可选,见下
|
|
|
87
56
|
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
57
|
```
|
|
89
58
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## 常见问题
|
|
93
|
-
|
|
94
|
-
- **侧边栏没出现按钮?** 确认 `dsh web` 已重启;不同皮肤下按钮会出现在侧边栏或底部工具栏,插件会自动寻找合适位置。
|
|
95
|
-
- **余额显示「失败」?** 检查 `DEEPSEEK_API_KEY` 是否有效、机器能否访问 `api.deepseek.com`;在弹窗的错误行能看到原因。
|
|
96
|
-
- **用量一直显示提示?** `DEEPSEEK_PLATFORM_TOKEN` 未配置或已过期(平台会话有时效,过期后重新登录复制新值)。
|
|
97
|
-
|
|
98
|
-
## 开发
|
|
99
|
-
|
|
100
|
-
- 宿主端:`lib/index.js`(cordis 插件,注册 `/deepseek-balance`、`/deepseek-usage` 两个路由)
|
|
101
|
-
- 客户端:`lib/client.js`(注入 web 前端,挂载侧边栏小组件)
|
|
102
|
-
- 修改后重新执行安装命令并重启 `dsh web` 生效(或本地调试时用 `dsh plugin --profile web add "file:<仓库路径>"`)
|
|
103
|
-
|
|
104
|
-
## 免责声明
|
|
105
|
-
|
|
106
|
-
- 本项目与 DeepSeek 官方无任何关联,非官方产品。
|
|
107
|
-
- 用量统计使用 DeepSeek 平台的内部接口,可能随平台改版而失效,属尽力而为。
|
|
108
|
-
- 请遵守 [DeepSeek 平台服务条款](https://platform.deepseek.com/terms) 与 API 使用政策。
|
|
59
|
+
或者直接对 AI 说:*帮我用 npm 卸载 dsh-deepseek-balance-widget 插件。*
|
|
109
60
|
|
|
110
61
|
## License
|
|
111
62
|
|
|
112
|
-
[MIT](LICENSE)
|
|
63
|
+
[MIT](LICENSE)
|
package/README_EN.md
CHANGED
|
@@ -2,84 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.md)
|
|
4
4
|
|
|
5
|
-
A
|
|
6
|
-
|
|
7
|
-
> This plugin runs entirely on your own machine: the dsh host resolves **your local credentials** (`~/.dsh/.credentials.yaml` or environment variables) and queries the official DeepSeek APIs server-side. No API key / token / personal data is bundled in the code, so **every user sees only their own balance**.
|
|
5
|
+
A multi-provider AI balance widget for the dsh web sidebar. **DeepSeek** is built in; add **MiMo (Xiaomi)** and others with one click. Auto-refreshes every 30 seconds.
|
|
8
6
|
|
|
9
7
|
## Features
|
|
10
8
|
|
|
11
|
-

|
|
41
10
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
11
|
+
- Sidebar shows Balance / Today spend / Today tokens, auto-refresh every 30 s; values follow the selected provider
|
|
12
|
+
- **Tabs** in the popover switch between providers (DeepSeek / MiMo…), sidebar updates with the tab
|
|
13
|
+
- **"+ Add"** button: add MiMo or any other AI provider at any time
|
|
14
|
+
- Details: balance, cumulative spend, today spend, today tokens, monthly usage (monthly spend / tokens)
|
|
15
|
+
- **"AI 帮我配置"**: credentials are handled by your AI — no digging through cookies by hand
|
|
16
|
+
- Version shown in the popover footer; one-click auto-update when a new version is available
|
|
45
17
|
|
|
46
18
|
## Install
|
|
47
19
|
|
|
48
|
-
|
|
20
|
+
Requires: dsh installed (with `dsh web` working).
|
|
49
21
|
|
|
50
22
|
```bash
|
|
51
23
|
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
52
24
|
```
|
|
53
25
|
|
|
54
|
-
|
|
26
|
+
Installed from npm and auto-registered by dsh. **Restart `dsh web`** and the balance button appears in the sidebar.
|
|
55
27
|
|
|
56
|
-
|
|
28
|
+
Or just tell your AI: *Install the dsh-deepseek-balance-widget plugin for me via npm.*
|
|
57
29
|
|
|
58
|
-
##
|
|
30
|
+
## Configuration
|
|
59
31
|
|
|
60
|
-
|
|
32
|
+
On first use the plugin creates a DeepSeek entry and reads your local `DEEPSEEK_API_KEY`. Other providers are added via "+ Add". Either:
|
|
61
33
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
> If you already use the DeepSeek API in dsh, `DEEPSEEK_API_KEY` is usually already configured and the balance part works out of the box.
|
|
34
|
+
**Option 1: Add inside the popover**
|
|
35
|
+
1. Open the popover and click "+ Add".
|
|
36
|
+
2. Pick a provider, then click "AI 帮我配置" and send the copied prompt to your AI.
|
|
37
|
+
3. Your AI walks you through getting the credentials and writes them locally.
|
|
68
38
|
|
|
69
|
-
|
|
70
|
-
|---|---|---|---|
|
|
71
|
-
| `DEEPSEEK_API_KEY` | ✅ | Balance | [platform.deepseek.com](https://platform.deepseek.com) → API Keys |
|
|
72
|
-
| `DEEPSEEK_PLATFORM_TOKEN` | ⭕ optional | Usage stats (cumulative/month/today spend, requests, tokens) | Log in to [platform.deepseek.com](https://platform.deepseek.com) → press `F12` → `Application` → `Cookies` → copy the value of `userToken` |
|
|
39
|
+
**Option 2: Just tell your AI**
|
|
73
40
|
|
|
74
|
-
|
|
41
|
+
> Configure dsh-deepseek-balance-widget for me.
|
|
75
42
|
|
|
76
|
-
|
|
43
|
+
The AI takes care of everything: asks for your API key / guides you through getting the platform cookie → writes the local config → reminds you to **restart `dsh web`**.
|
|
77
44
|
|
|
78
|
-
|
|
45
|
+
| Provider | Credential | Notes |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | Required, balance |
|
|
48
|
+
| DeepSeek usage | `DEEPSEEK_PLATFORM_TOKEN` | Optional, cumulative / monthly / today stats |
|
|
49
|
+
| MiMo (Xiaomi) | Login cookie | Guided by your AI |
|
|
79
50
|
|
|
80
|
-
|
|
81
|
-
2. A balance button appears in the left sidebar (or next to the bottom Settings row) showing `余额 / 今日消费 / 今日Token`.
|
|
82
|
-
3. Click it for the detail card; use the "刷新" (refresh) button or wait 30 s for auto-refresh.
|
|
51
|
+
Credentials are stored locally in `~/.dsh/ai-balances.json`; nothing is shipped with the plugin.
|
|
83
52
|
|
|
84
53
|
## Uninstall
|
|
85
54
|
|
|
@@ -87,26 +56,8 @@ Without `DEEPSEEK_PLATFORM_TOKEN`, the balance still shows; today spend / tokens
|
|
|
87
56
|
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
57
|
```
|
|
89
58
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
## FAQ
|
|
93
|
-
|
|
94
|
-
- **No button in the sidebar?** Make sure `dsh web` was restarted. On different skins the button appears in the sidebar or the bottom toolbar; the plugin finds a spot automatically.
|
|
95
|
-
- **Balance shows "失败" (failed)?** Check that `DEEPSEEK_API_KEY` is valid and your machine can reach `api.deepseek.com`; the error line in the popover explains why.
|
|
96
|
-
- **Usage always shows the hint?** `DEEPSEEK_PLATFORM_TOKEN` is missing or expired (platform sessions expire; log in again and copy a fresh `userToken`).
|
|
97
|
-
|
|
98
|
-
## Development
|
|
99
|
-
|
|
100
|
-
- Host half: `lib/index.js` (cordis plugin registering `/deepseek-balance` and `/deepseek-usage`)
|
|
101
|
-
- Client half: `lib/client.js` (injected into the web frontend, mounts the sidebar widget)
|
|
102
|
-
- After changes, re-run the install command and restart `dsh web` (or use `dsh plugin --profile web add "file:<repo path>"` for local iteration)
|
|
103
|
-
|
|
104
|
-
## Disclaimer
|
|
105
|
-
|
|
106
|
-
- Not affiliated with or endorsed by DeepSeek.
|
|
107
|
-
- Usage stats rely on DeepSeek platform internal endpoints that may change at any time; best effort only.
|
|
108
|
-
- Please follow the [DeepSeek Platform Terms](https://platform.deepseek.com/terms) and API usage policy.
|
|
59
|
+
Or just tell your AI: *Uninstall the dsh-deepseek-balance-widget plugin for me via npm.*
|
|
109
60
|
|
|
110
61
|
## License
|
|
111
62
|
|
|
112
|
-
[MIT](LICENSE)
|
|
63
|
+
[MIT](LICENSE)
|