dsh-deepseek-balance-widget 1.2.3 → 2.0.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 +9 -84
- package/README_EN.md +9 -84
- package/lib/client.js +650 -49
- package/lib/index.js +568 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,84 +2,29 @@
|
|
|
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 等平台,实时展示**余额 / 今日消费 / 今日 Token**,每 30 秒自动刷新。
|
|
8
6
|
|
|
9
7
|
## 功能
|
|
10
8
|
|
|
11
|
-

|
|
41
10
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
11
|
+
- 侧边栏显示余额 / 今日消费 / 今日 Token,30 秒自动刷新
|
|
12
|
+
- 点击弹出详情:累计消费、本月消耗、Tokens
|
|
13
|
+
- 多平台 Tab 切换(DeepSeek / MiMo…),可「+ 添加」新平台
|
|
45
14
|
|
|
46
15
|
## 安装
|
|
47
16
|
|
|
48
|
-
插件已发布到 npm,包名 **`dsh-deepseek-balance-widget`**。一条命令安装:
|
|
49
|
-
|
|
50
17
|
```bash
|
|
51
18
|
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
52
19
|
```
|
|
53
20
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
完成后**重启 `dsh web`**,侧边栏出现余额按钮即可。
|
|
57
|
-
|
|
58
|
-
## 配置凭据(关键一步)
|
|
59
|
-
|
|
60
|
-
编辑 `~/.dsh/.credentials.yaml`:
|
|
61
|
-
|
|
62
|
-
```yaml
|
|
63
|
-
DEEPSEEK_API_KEY: sk-xxxxxxxxxxxxxxxx
|
|
64
|
-
DEEPSEEK_PLATFORM_TOKEN: xxxxxxxxxxxxxxxx # 可选,见下
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
> 如果你本来就在用 DeepSeek API(dsh 里已经能跑对话),`DEEPSEEK_API_KEY` 通常已经配置好了,余额部分**开箱即用**。
|
|
21
|
+
从 npm 拉取安装,dsh 自动注册,**重启 `dsh web`** 后侧边栏出现余额按钮。
|
|
68
22
|
|
|
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` 的值 |
|
|
23
|
+
也可以直接对 AI 说:*帮我用 npm 安装 dsh-deepseek-balance-widget 插件。*
|
|
73
24
|
|
|
74
|
-
|
|
25
|
+
## 配置
|
|
75
26
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## 使用
|
|
79
|
-
|
|
80
|
-
1. 重启 `dsh web`。
|
|
81
|
-
2. 左侧边栏(或底部设置栏旁)会出现余额按钮,显示 `余额 / 今日消费 / 今日Token`。
|
|
82
|
-
3. 点击按钮查看详情卡片,卡片右下角有「刷新」按钮,或等待 30 秒自动刷新。
|
|
27
|
+
打开弹窗 →「+ 添加」→ 选平台 →「AI 帮我配置」→ 把提示语发给智能体,AI 会引导你完成配置并写入本机。
|
|
83
28
|
|
|
84
29
|
## 卸载
|
|
85
30
|
|
|
@@ -87,26 +32,6 @@ DEEPSEEK_PLATFORM_TOKEN: xxxxxxxxxxxxxxxx # 可选,见下
|
|
|
87
32
|
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
33
|
```
|
|
89
34
|
|
|
90
|
-
dsh 会自动从 `dsh.profile.bundles` 移除该层;若还残留(旧版 dsh),手动删除 `~/.dsh/profiles/web/package.json` 中 `dependencies` 与 `dsh.profile.bundles` 里的同名条目。
|
|
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 使用政策。
|
|
109
|
-
|
|
110
35
|
## License
|
|
111
36
|
|
|
112
37
|
[MIT](LICENSE)
|
package/README_EN.md
CHANGED
|
@@ -2,84 +2,29 @@
|
|
|
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 plugin that shows AI balances in the dsh web sidebar: DeepSeek built in, add MiMo and more, with live **balance / today spend / today tokens**, auto-refreshed every 30 s.
|
|
8
6
|
|
|
9
7
|
## Features
|
|
10
8
|
|
|
11
|
-

|
|
41
10
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
11
|
+
- Sidebar widget: Balance / Today spend / Today tokens, auto-refresh every 30 s
|
|
12
|
+
- Click for details: cumulative spend, monthly usage, tokens
|
|
13
|
+
- Multi-provider tabs (DeepSeek / MiMo…), "+ Add" to add new providers
|
|
45
14
|
|
|
46
15
|
## Install
|
|
47
16
|
|
|
48
|
-
The plugin is published to npm as **`dsh-deepseek-balance-widget`**. Install with a single command:
|
|
49
|
-
|
|
50
17
|
```bash
|
|
51
18
|
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
52
19
|
```
|
|
53
20
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Then **restart `dsh web`** — the balance button appears in the sidebar.
|
|
57
|
-
|
|
58
|
-
## Configure credentials (important)
|
|
59
|
-
|
|
60
|
-
Edit `~/.dsh/.credentials.yaml`:
|
|
61
|
-
|
|
62
|
-
```yaml
|
|
63
|
-
DEEPSEEK_API_KEY: sk-xxxxxxxxxxxxxxxx
|
|
64
|
-
DEEPSEEK_PLATFORM_TOKEN: xxxxxxxxxxxxxxxx # optional, see below
|
|
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.
|
|
21
|
+
Installed from npm and auto-registered by dsh. **Restart `dsh web`** and the balance button appears in the sidebar.
|
|
68
22
|
|
|
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` |
|
|
23
|
+
Or just tell your AI: *Install the dsh-deepseek-balance-widget plugin for me via npm.*
|
|
73
24
|
|
|
74
|
-
|
|
25
|
+
## Configuration
|
|
75
26
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## Usage
|
|
79
|
-
|
|
80
|
-
1. Restart `dsh web`.
|
|
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.
|
|
27
|
+
Open the popover → "+ Add" → pick a provider → "AI 帮我配置" → send the copied prompt to your AI; it will guide you through the setup and write the config locally.
|
|
83
28
|
|
|
84
29
|
## Uninstall
|
|
85
30
|
|
|
@@ -87,26 +32,6 @@ Without `DEEPSEEK_PLATFORM_TOKEN`, the balance still shows; today spend / tokens
|
|
|
87
32
|
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
33
|
```
|
|
89
34
|
|
|
90
|
-
dsh removes the layer from `dsh.profile.bundles` automatically; if anything remains (older dsh), delete the `dsh-deepseek-balance-widget` entries from `dependencies` and `dsh.profile.bundles` in `~/.dsh/profiles/web/package.json`.
|
|
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.
|
|
109
|
-
|
|
110
35
|
## License
|
|
111
36
|
|
|
112
37
|
[MIT](LICENSE)
|