dsh-deepseek-balance-widget 1.2.3 → 1.2.5
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 +62 -112
- package/README_EN.md +25 -75
- package/lib/client.js +1080 -90
- package/lib/index.js +601 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,112 +1,62 @@
|
|
|
1
|
-
# dsh-deepseek-balance-widget
|
|
2
|
-
|
|
3
|
-
[English](README_EN.md) | 中文
|
|
4
|
-
|
|
5
|
-
在
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
DEEPSEEK_API_KEY: sk-xxxxxxxxxxxxxxxx
|
|
64
|
-
DEEPSEEK_PLATFORM_TOKEN: xxxxxxxxxxxxxxxx # 可选,见下
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
> 如果你本来就在用 DeepSeek API(dsh 里已经能跑对话),`DEEPSEEK_API_KEY` 通常已经配置好了,余额部分**开箱即用**。
|
|
68
|
-
|
|
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` 的值 |
|
|
73
|
-
|
|
74
|
-
未配置 `DEEPSEEK_PLATFORM_TOKEN` 时:余额正常显示,今日消费 / 今日Token 显示 `—`,用量区块显示配置提示。
|
|
75
|
-
|
|
76
|
-
> ⚠️ `userToken` 等同于你的平台登录会话,请勿提交到 Git 或分享给他人。
|
|
77
|
-
|
|
78
|
-
## 使用
|
|
79
|
-
|
|
80
|
-
1. 重启 `dsh web`。
|
|
81
|
-
2. 左侧边栏(或底部设置栏旁)会出现余额按钮,显示 `余额 / 今日消费 / 今日Token`。
|
|
82
|
-
3. 点击按钮查看详情卡片,卡片右下角有「刷新」按钮,或等待 30 秒自动刷新。
|
|
83
|
-
|
|
84
|
-
## 卸载
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
|
-
```
|
|
89
|
-
|
|
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
|
-
## License
|
|
111
|
-
|
|
112
|
-
[MIT](LICENSE)
|
|
1
|
+
# dsh-deepseek-balance-widget
|
|
2
|
+
|
|
3
|
+
[English](README_EN.md) | 中文
|
|
4
|
+
|
|
5
|
+
在 dsh Web 侧边栏显示 AI 余额的多平台插件:内置 **DeepSeek**,可添加 **MiMo(小米)**,每 30 秒自动刷新。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
- 侧边栏实时显示余额 / 今日消费 / 今日 Token,30 秒自动刷新,并随当前平台切换
|
|
12
|
+
- 弹窗顶部显示当前平台标题:点「**更换**」在已添加的平台间切换,点「**×**」可移除该平台
|
|
13
|
+
- 弹窗右上角「**+ 添加**」:加入 MiMo
|
|
14
|
+
- 详情字段:余额、累计消费、今日消费、今日 Token、本月消耗(本月消费 / Tokens)
|
|
15
|
+
- 「**AI 帮我配置**」:复制提示语发给智能体,AI 会一步步指导你抓取凭证并完成配置。
|
|
16
|
+
- 弹窗底部显示版本号,有新版时一键自动更新
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
需要:已安装 dsh(可用 `dsh web`)。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
从 npm 拉取安装,dsh 自动注册到 `dsh.profile.bundles`,完成后**重启 `dsh web`** 即可。
|
|
27
|
+
|
|
28
|
+
也可以直接对 AI 说:
|
|
29
|
+
|
|
30
|
+
> 帮我用 npm 安装 dsh-deepseek-balance-widget 插件。
|
|
31
|
+
|
|
32
|
+
## 配置
|
|
33
|
+
|
|
34
|
+
插件首次使用会自动创建 DeepSeek 条目,读取你本机的 `DEEPSEEK_API_KEY`。
|
|
35
|
+
|
|
36
|
+
要加入 MiMo,打开弹窗点右上角「+ 添加」,再点「AI 帮我配置」,把提示语发给智能体;也可以直接对 AI 说:
|
|
37
|
+
|
|
38
|
+
> 帮我配置 dsh-deepseek-balance-widget。
|
|
39
|
+
|
|
40
|
+
AI 会接管全部:问 API Key / 引导获取平台 Cookie → 写入本机 → 提醒重启 `dsh web`。
|
|
41
|
+
|
|
42
|
+
| 平台 | 凭据 | 备注 |
|
|
43
|
+
| ----------- | ------------------------- | ------------------- |
|
|
44
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | 必填,余额 |
|
|
45
|
+
| DeepSeek 用量 | `DEEPSEEK_PLATFORM_TOKEN` | 可选,统计累计消费 / 本月 / 今日 |
|
|
46
|
+
| MiMo(小米) | 登录 Cookie | AI 引导获取 |
|
|
47
|
+
|
|
48
|
+
凭据保存在你本机的 `~/.dsh/ai-balances.json`,不随插件分发、不上传。
|
|
49
|
+
|
|
50
|
+
## 卸载
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
或者直接对 AI 说:
|
|
57
|
+
|
|
58
|
+
> 帮我用 npm 卸载 dsh-deepseek-balance-widget 插件。
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
[MIT](LICENSE)
|
package/README_EN.md
CHANGED
|
@@ -2,84 +2,50 @@
|
|
|
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)** from the popover. 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
|
+
- Popover header shows the current provider: a "**Switch**" menu changes to another added provider, and "**×**" removes it
|
|
13
|
+
- "**+ Add**" button (top right): add **MiMo**
|
|
14
|
+
- Details: balance, cumulative spend, today spend, today tokens, monthly usage (monthly spend / tokens)
|
|
15
|
+
- "**AI 帮我配置**": one click copies a prompt; send it to your AI and it guides you through fetching credentials and writing them locally — 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:
|
|
57
29
|
|
|
58
|
-
|
|
30
|
+
> Install the dsh-deepseek-balance-widget plugin for me via npm.
|
|
59
31
|
|
|
60
|
-
|
|
32
|
+
## Configuration
|
|
61
33
|
|
|
62
|
-
|
|
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.
|
|
34
|
+
On first use the plugin creates a DeepSeek entry and reads your local `DEEPSEEK_API_KEY`.
|
|
68
35
|
|
|
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` |
|
|
36
|
+
To add MiMo, open the popover, click "+ Add", then "AI 帮我配置", and send the copied prompt to your AI. Or just tell your AI:
|
|
73
37
|
|
|
74
|
-
|
|
38
|
+
> Configure dsh-deepseek-balance-widget for me.
|
|
75
39
|
|
|
76
|
-
|
|
40
|
+
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
41
|
|
|
78
|
-
|
|
42
|
+
| Provider | Credential | Notes |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | Required, balance |
|
|
45
|
+
| DeepSeek usage | `DEEPSEEK_PLATFORM_TOKEN` | Optional, cumulative / monthly / today stats |
|
|
46
|
+
| MiMo (Xiaomi) | Login cookie | Guided by your AI |
|
|
79
47
|
|
|
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.
|
|
48
|
+
Credentials are stored locally in `~/.dsh/ai-balances.json`; nothing is shipped with the plugin and nothing is uploaded.
|
|
83
49
|
|
|
84
50
|
## Uninstall
|
|
85
51
|
|
|
@@ -87,25 +53,9 @@ Without `DEEPSEEK_PLATFORM_TOKEN`, the balance still shows; today spend / tokens
|
|
|
87
53
|
dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
88
54
|
```
|
|
89
55
|
|
|
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
|
|
56
|
+
Or just tell your AI:
|
|
105
57
|
|
|
106
|
-
|
|
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.
|
|
58
|
+
> Uninstall the dsh-deepseek-balance-widget plugin for me via npm.
|
|
109
59
|
|
|
110
60
|
## License
|
|
111
61
|
|