dsh-deepseek-balance-widget 1.2.4 → 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 CHANGED
@@ -2,84 +2,29 @@
2
2
 
3
3
  [English](README_EN.md) | 中文
4
4
 
5
- DeepSeek Harness(dsh)Web 侧边栏显示 DeepSeek 余额的小插件:实时展示**余额 / 今日消费 / 今日Token**,点击弹出详情(累计消费、本月消耗、API 请求次数、Tokens),每 30 秒自动刷新。
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
- ![DeepSeek 余额侧边栏展示](assets/screenshot.png)
12
-
13
- - 侧边栏常驻按钮:`余额`、`今日消费`、`今日Token` 三个数值,30 秒自动刷新
14
- - 点击弹出详情卡片:
15
- - 余额(`$`,来自 `api.deepseek.com/user/balance`)
16
- - 累计消费(全部时间,来自平台用量接口按月累加)
17
- - 今日消费 / 今日Token(平台实时接口,按 GMT+8 当日统计)
18
- - 本月消耗:本月消费、API 请求次数、Tokens
19
- - 未配置平台 Token 时,余额照常显示,用量区域显示中性提示(不展示任何人的历史快照)
20
- - 深色主题,跟随 dsh 侧边栏样式;自动适配官方皮肤与 Maid-atelier 等第三方皮肤
21
-
22
- ## 工作原理(隐私说明)
23
-
24
- ```
25
- 浏览器 (dsh web 前端) ──GET /deepseek-balance──▶ dsh 宿主端(你自己的机器)
26
-
27
- ├─ 读取本机 ~/.dsh/.credentials.yaml 的
28
- │ DEEPSEEK_API_KEY / DEEPSEEK_PLATFORM_TOKEN
29
- │ (或环境变量),绝不硬编码
30
-
31
- api.deepseek.com / platform.deepseek.com
32
-
33
- ◀── 返回「你这个账号」的余额与用量
34
- ```
35
-
36
- - 余额数据来自 DeepSeek 官方余额接口 `GET https://api.deepseek.com/user/balance`
37
- - 用量统计来自平台接口(需要 `userToken`),见下方配置说明
38
- - 请求全部由宿主端发起(服务端到服务端),浏览器端不接触任何密钥
39
-
40
- ## 环境要求
9
+ ![AI 余额侧边栏展示](assets/screenshot.png)
41
10
 
42
- - DeepSeek Harness(`dsh`)已安装并可用 `dsh web`
43
- - Node.js ≥ 18(全局 `fetch`)
44
- - pnpm(`dsh plugin` 内部转发给 pnpm)
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
- 安装成功后 dsh 会**自动把该包注册进 `dsh.profile.bundles`**,**无需手动改任何配置文件**。本包**没有构建脚本**,pnpm 不会拦截(无需在 `pnpm-workspace.yaml` 的 `allowBuilds` 里批准)。
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
- 未配置 `DEEPSEEK_PLATFORM_TOKEN` 时:余额正常显示,今日消费 / 今日Token 显示 `—`,用量区块显示配置提示。
25
+ ## 配置
75
26
 
76
- > ⚠️ `userToken` 等同于你的平台登录会话,请勿提交到 Git 或分享给他人。
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 small plugin that shows your DeepSeek balance in the DeepSeek Harness (dsh) web sidebar: live **balance / today spend / today tokens**, click to open a detail card (cumulative spend, monthly usage, request count, tokens), auto-refreshed every 30 seconds.
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
- ![DeepSeek balance sidebar](assets/screenshot.png)
12
-
13
- - Persistent sidebar widget: `余额` (balance), `今日消费` (today spend), `今日Token` (today tokens), auto-refresh every 30 s
14
- - Click for a detail card:
15
- - Balance (`$`, from `api.deepseek.com/user/balance`)
16
- - Cumulative spend (all time, summed per month from the platform usage API)
17
- - Today spend / today tokens (platform realtime API, GMT+8 day buckets)
18
- - Current-month usage: spend, API request count, tokens
19
- - When the platform token is not configured, the balance still works and the usage area shows a neutral hint (never anyone's historical snapshot)
20
- - Dark theme matching the dsh sidebar; adapts to official skins and third-party skins like Maid-atelier
21
-
22
- ## How it works (privacy)
23
-
24
- ```
25
- Browser (dsh web frontend) ──GET /deepseek-balance──▶ dsh host (your machine)
26
-
27
- ├─ reads DEEPSEEK_API_KEY / DEEPSEEK_PLATFORM_TOKEN
28
- │ from local ~/.dsh/.credentials.yaml (or env),
29
- │ never hardcoded
30
-
31
- api.deepseek.com / platform.deepseek.com
32
-
33
- ◀── returns balance & usage of YOUR account
34
- ```
35
-
36
- - Balance comes from the official endpoint `GET https://api.deepseek.com/user/balance`
37
- - Usage stats come from the platform endpoints (requires `userToken`), see configuration below
38
- - All requests are made by the host (server-to-server); the browser never touches any secret
39
-
40
- ## Requirements
9
+ ![AI balance sidebar](assets/screenshot.png)
41
10
 
42
- - DeepSeek Harness (`dsh`) with `dsh web` working
43
- - Node.js 18 (global `fetch`)
44
- - pnpm (`dsh plugin` forwards to pnpm internally)
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
- After a successful `dsh plugin` install, dsh **automatically registers the package in `dsh.profile.bundles`**, so **no manual config editing is needed**. This package has **no build script**, so pnpm does not block it (no `allowBuilds` approval needed).
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
- | Credential | Required | Purpose | How to get it |
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
- Without `DEEPSEEK_PLATFORM_TOKEN`, the balance still shows; today spend / tokens show `—` and the usage block shows a configuration hint.
25
+ ## Configuration
75
26
 
76
- > ⚠️ `userToken` is your platform login session. Never commit it to Git or share it.
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)