dsh-deepseek-balance-widget 2.3.6 → 2.3.8
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 +26 -13
- package/README_EN.md +23 -10
- package/lib/client.js +48 -2
- package/lib/index.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,24 +12,25 @@
|
|
|
12
12
|
- 弹窗顶部显示当前平台标题:点「**更换**」在已添加的平台间切换,点「**×**」可移除该平台
|
|
13
13
|
- 弹窗右上角「**+ 添加**」:加入 MiMo
|
|
14
14
|
- 详情字段:余额、累计消费、今日消费、今日 Token、本月消耗(本月消费 / Tokens)
|
|
15
|
-
- 「**AI 帮我配置**」:复制提示语发给智能体,AI
|
|
15
|
+
- 「**AI 帮我配置**」:复制提示语发给智能体,AI 会一步步指导你抓取凭证并完成配置
|
|
16
16
|
- 弹窗底部显示版本号,有新版时一键自动更新
|
|
17
|
+
- 支持中 / EN 界面切换
|
|
17
18
|
|
|
18
19
|
## 安装
|
|
19
20
|
|
|
20
21
|
需要:已安装 dsh(可用 `dsh web`)。
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget@
|
|
24
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
从 npm 拉取安装,dsh 自动注册到 `dsh.profile.bundles`,完成后**重启 `dsh web`** 即可。
|
|
27
28
|
|
|
28
|
-
>
|
|
29
|
+
> **务必写死版本号 `@2.3.6`**(当前最新稳定版)。不要用 `@latest`——它会被本地 pnpm/npm 缓存或镜像源解析成旧版本,导致装到老版(实测在某些电脑上 `@latest` 会装成 2.3.3)。如果未来发布了更高版本,把这里的版本号换成最新的即可。
|
|
29
30
|
|
|
30
31
|
也可以直接对 AI 说:
|
|
31
32
|
|
|
32
|
-
> 帮我用 npm 安装 dsh-deepseek-balance-widget
|
|
33
|
+
> 帮我用 npm 安装 dsh-deepseek-balance-widget 插件,执行 `dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6`。
|
|
33
34
|
|
|
34
35
|
## 配置
|
|
35
36
|
|
|
@@ -41,11 +42,11 @@ dsh plugin --profile web add dsh-deepseek-balance-widget@latest
|
|
|
41
42
|
|
|
42
43
|
AI 会接管全部:问 API Key / 引导获取平台 Cookie → 写入本机 → 提醒重启 `dsh web`。
|
|
43
44
|
|
|
44
|
-
| 平台
|
|
45
|
-
|
|
|
46
|
-
| DeepSeek
|
|
45
|
+
| 平台 | 凭据 | 备注 |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | 必填,余额 |
|
|
47
48
|
| DeepSeek 用量 | `DEEPSEEK_PLATFORM_TOKEN` | 可选,统计累计消费 / 本月 / 今日 |
|
|
48
|
-
| MiMo(小米)
|
|
49
|
+
| MiMo(小米) | 登录 Cookie | AI 引导获取 |
|
|
49
50
|
|
|
50
51
|
凭据保存在你本机的 `~/.dsh/ai-balances.json`,不随插件分发、不上传。
|
|
51
52
|
|
|
@@ -64,23 +65,23 @@ AI 会接管全部:问 API Key / 引导获取平台 Cookie → 写入本机
|
|
|
64
65
|
### 方式二:命令行强制更新(最稳妥,适合卡住或装不上的情况)
|
|
65
66
|
|
|
66
67
|
```bash
|
|
67
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget@
|
|
68
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
**写死版本号 `@2.3.6`** 可绕过本地缓存 / 镜像源不同步 / `latest` 解析成旧版的问题,一步到位。装完**彻底重启 `dsh web`**。
|
|
71
72
|
|
|
72
73
|
### 方式三:手动更新(命令行更新失败时兜底)
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
76
|
cd ~/.dsh/profiles/web
|
|
76
|
-
npm install dsh-deepseek-balance-widget@
|
|
77
|
+
npm install dsh-deepseek-balance-widget@2.3.6 # 若目录内有 pnpm-lock.yaml 则用 pnpm add
|
|
77
78
|
# 验证磁盘上确实变了
|
|
78
79
|
cat node_modules/dsh-deepseek-balance-widget/package.json | grep '"version"'
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
确认输出 `2.3.6` 后,**彻底重启 `dsh web`** 即可。
|
|
82
83
|
|
|
83
|
-
>
|
|
84
|
+
> 如果你的环境里弹窗/命令行的更新一直失败(提示版本没变),通常是 Agent 主机(如 WorkBuddy)通过 `NODE_OPTIONS` 注入了文件删除拦截导致 pnpm/npm 更新中断。此时在**普通终端**(不通过 Agent 运行)里执行上面的命令即可成功;或先执行 `set NODE_OPTIONS=`(PowerShell)再重试。
|
|
84
85
|
|
|
85
86
|
## 卸载
|
|
86
87
|
|
|
@@ -92,6 +93,18 @@ dsh plugin --profile web rm dsh-deepseek-balance-widget
|
|
|
92
93
|
|
|
93
94
|
> 帮我用 npm 卸载 dsh-deepseek-balance-widget 插件。
|
|
94
95
|
|
|
96
|
+
## 联系
|
|
97
|
+
|
|
98
|
+
有问题或建议,欢迎联系:
|
|
99
|
+
|
|
100
|
+
- 邮箱:crazy_l118@icloud.com
|
|
101
|
+
|
|
102
|
+
## 赞助
|
|
103
|
+
|
|
104
|
+
如果这个插件对你有帮助,可以给我的晚餐加一根火腿肠 🍗
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
95
108
|
## License
|
|
96
109
|
|
|
97
110
|
[MIT](LICENSE)
|
package/README_EN.md
CHANGED
|
@@ -12,24 +12,25 @@ A multi-provider AI balance widget for the dsh web sidebar. **DeepSeek** is buil
|
|
|
12
12
|
- Popover header shows the current provider: a "**Switch**" menu changes to another added provider, and "**×**" removes it
|
|
13
13
|
- "**+ Add**" button (top right): add **MiMo**
|
|
14
14
|
- Details: balance, cumulative spend, today spend, today tokens, monthly usage (monthly spend / tokens)
|
|
15
|
-
- "**AI 帮我配置**":
|
|
15
|
+
- "**AI 帮我配置**": copy a prompt, send it to your AI, and it walks you through fetching the credentials — no digging through cookies by hand
|
|
16
16
|
- Version shown in the popover footer; one-click auto-update when a new version is available
|
|
17
|
+
- UI language toggle: 中文 / EN
|
|
17
18
|
|
|
18
19
|
## Install
|
|
19
20
|
|
|
20
21
|
Requires: dsh installed (with `dsh web` working).
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget@
|
|
24
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
Installed from npm and auto-registered by dsh. **Restart `dsh web`** and the balance button appears in the sidebar.
|
|
27
28
|
|
|
28
|
-
>
|
|
29
|
+
> **Always pin the version `@2.3.6`** (the current latest stable). Do not use `@latest` — local pnpm/npm cache or a mirror registry can resolve it to an outdated release (observed: `@latest` installed 2.3.3 on another machine). When a newer version is released, bump the number here.
|
|
29
30
|
|
|
30
31
|
Or just tell your AI:
|
|
31
32
|
|
|
32
|
-
> Install the dsh-deepseek-balance-widget plugin for me via npm.
|
|
33
|
+
> Install the dsh-deepseek-balance-widget plugin for me via npm: run `dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6`.
|
|
33
34
|
|
|
34
35
|
## Configuration
|
|
35
36
|
|
|
@@ -42,7 +43,7 @@ To add MiMo, open the popover, click "+ Add", then "AI 帮我配置", and send t
|
|
|
42
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`**.
|
|
43
44
|
|
|
44
45
|
| Provider | Credential | Notes |
|
|
45
|
-
|
|
46
|
+
| --- | --- | --- |
|
|
46
47
|
| DeepSeek | `DEEPSEEK_API_KEY` | Required, balance |
|
|
47
48
|
| DeepSeek usage | `DEEPSEEK_PLATFORM_TOKEN` | Optional, cumulative / monthly / today stats |
|
|
48
49
|
| MiMo (Xiaomi) | Login cookie | Guided by your AI |
|
|
@@ -64,23 +65,23 @@ Upgrade to the latest stable release on npm regardless of which older version yo
|
|
|
64
65
|
### Method 2: Force update from the command line (most reliable if stuck)
|
|
65
66
|
|
|
66
67
|
```bash
|
|
67
|
-
dsh plugin --profile web add dsh-deepseek-balance-widget@
|
|
68
|
+
dsh plugin --profile web add dsh-deepseek-balance-widget@2.3.6
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
**Pinning `@2.3.6`** bypasses local cache / mirror desync / a stale `latest` resolution in one step. Then **fully restart `dsh web`**.
|
|
71
72
|
|
|
72
73
|
### Method 3: Manual update (fallback when the command-line update fails)
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
76
|
cd ~/.dsh/profiles/web
|
|
76
|
-
npm install dsh-deepseek-balance-widget@
|
|
77
|
+
npm install dsh-deepseek-balance-widget@2.3.6 # use `pnpm add` if a pnpm-lock.yaml exists in this dir
|
|
77
78
|
# verify the on-disk version actually changed
|
|
78
79
|
cat node_modules/dsh-deepseek-balance-widget/package.json | grep '"version"'
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
Once it prints
|
|
82
|
+
Once it prints `2.3.6`, **fully restart `dsh web`**.
|
|
82
83
|
|
|
83
|
-
>
|
|
84
|
+
> If the popover / command-line update keeps failing (version never changes), an agent host (e.g. WorkBuddy) is likely injecting a file-deletion guard via `NODE_OPTIONS`, which makes pnpm/npm abort during updates. Run the command in a **plain terminal** (not through the agent), or unset `NODE_OPTIONS` first (PowerShell: `set NODE_OPTIONS=`) and retry.
|
|
84
85
|
|
|
85
86
|
## Uninstall
|
|
86
87
|
|
|
@@ -92,6 +93,18 @@ Or just tell your AI:
|
|
|
92
93
|
|
|
93
94
|
> Uninstall the dsh-deepseek-balance-widget plugin for me via npm.
|
|
94
95
|
|
|
96
|
+
## Contact
|
|
97
|
+
|
|
98
|
+
Questions or suggestions? Feel free to reach out:
|
|
99
|
+
|
|
100
|
+
- Email: crazy_l118@icloud.com
|
|
101
|
+
|
|
102
|
+
## Sponsor
|
|
103
|
+
|
|
104
|
+
If this plugin helped you, consider buying me a ham sausage for dinner 🍗
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
95
108
|
## License
|
|
96
109
|
|
|
97
110
|
[MIT](LICENSE)
|
package/lib/client.js
CHANGED
|
@@ -110,6 +110,7 @@ window.__ModuleLoader__.load({
|
|
|
110
110
|
pasteCookieHint: "请粘贴 Cookie 或 cURL,AI 会自动提取",
|
|
111
111
|
copied: "已复制",
|
|
112
112
|
copyFailed: "复制失败",
|
|
113
|
+
copyError: "复制错误信息",
|
|
113
114
|
refresh: "刷新",
|
|
114
115
|
peakPeriod: "繁忙时段",
|
|
115
116
|
offPeakPeriod: "空闲时段"
|
|
@@ -195,6 +196,7 @@ window.__ModuleLoader__.load({
|
|
|
195
196
|
pasteCookieHint: "Paste a Cookie or cURL; the AI will extract it",
|
|
196
197
|
copied: "Copied",
|
|
197
198
|
copyFailed: "Copy failed",
|
|
199
|
+
copyError: "Copy error",
|
|
198
200
|
refresh: "Refresh",
|
|
199
201
|
peakPeriod: "Peak",
|
|
200
202
|
offPeakPeriod: "Off-peak"
|
|
@@ -420,7 +422,12 @@ window.__ModuleLoader__.load({
|
|
|
420
422
|
".dshBalanceWizardLink:hover{color:#79b8ff}",
|
|
421
423
|
".dshBalanceCookiePreview{font-size:11px;color:#7b8494;background:rgba(255,255,255,.05);border-radius:6px;padding:6px 8px;word-break:break-all}",
|
|
422
424
|
".dshBalanceCookiePreview code{color:#e6e9ef;font-size:10px}",
|
|
423
|
-
".dshBalanceCookiePreview[data-found=false]{display:none}"
|
|
425
|
+
".dshBalanceCookiePreview[data-found=false]{display:none}",
|
|
426
|
+
".dshBalanceUpdateErr{margin-top:10px;border:1px solid rgba(248,81,73,.25);border-radius:8px;background:rgba(248,81,73,.08);padding:8px 10px}",
|
|
427
|
+
".dshBalanceUpdateErrHead{display:flex;justify-content:space-between;align-items:center;font-size:12px;font-weight:600;color:#f85149;margin-bottom:6px}",
|
|
428
|
+
".dshBalanceUpdateErrClose{appearance:none;background:transparent;border:0;color:#9aa4b2;font-size:18px;line-height:1;cursor:pointer;padding:0 2px}",
|
|
429
|
+
".dshBalanceUpdateErrClose:hover{color:#f85149}",
|
|
430
|
+
".dshBalanceUpdateErrBody{max-height:120px;overflow:auto;background:#0f1216;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:6px 8px;margin:0 0 8px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:10px;line-height:1.4;color:#c9d1d9;white-space:pre-wrap;word-break:break-all}"
|
|
424
431
|
].join("");
|
|
425
432
|
const tag = document.createElement("style");
|
|
426
433
|
tag.dataset.plugin = "dsh-deepseek-balance-widget";
|
|
@@ -565,6 +572,8 @@ window.__ModuleLoader__.load({
|
|
|
565
572
|
} else {
|
|
566
573
|
btn.textContent = t("updateFailed");
|
|
567
574
|
btn.title = String(result.error || t("updateFailed")) + (result.output ? "\n" + result.output.slice(-200) : "");
|
|
575
|
+
updateErrorDetail = { error: result.error || t("updateFailed"), output: result.output || "" };
|
|
576
|
+
renderPopover();
|
|
568
577
|
setTimeout(() => { btn.textContent = originalText; btn.disabled = false; btn.title = ""; }, 3000);
|
|
569
578
|
}
|
|
570
579
|
}
|
|
@@ -835,6 +844,24 @@ window.__ModuleLoader__.load({
|
|
|
835
844
|
if (updateBtn !== null) {
|
|
836
845
|
updateBtn.addEventListener("click", () => handleUpdateClick(updateBtn));
|
|
837
846
|
}
|
|
847
|
+
const updateErrClose = popRef.querySelector("[data-update-err-close]");
|
|
848
|
+
if (updateErrClose !== null) {
|
|
849
|
+
updateErrClose.addEventListener("click", () => { updateErrorDetail = null; renderPopover(); });
|
|
850
|
+
}
|
|
851
|
+
const updateErrCopy = popRef.querySelector("[data-update-err-copy]");
|
|
852
|
+
if (updateErrCopy !== null) {
|
|
853
|
+
updateErrCopy.addEventListener("click", () => {
|
|
854
|
+
if (!updateErrorDetail) return;
|
|
855
|
+
const text = String(updateErrorDetail.error || "") + "\n" + String(updateErrorDetail.output || "");
|
|
856
|
+
navigator.clipboard?.writeText(text).then(() => {
|
|
857
|
+
updateErrCopy.textContent = t("copied");
|
|
858
|
+
setTimeout(() => updateErrCopy.textContent = t("copyError"), 1500);
|
|
859
|
+
}).catch(() => {
|
|
860
|
+
updateErrCopy.textContent = t("copyFailed");
|
|
861
|
+
setTimeout(() => updateErrCopy.textContent = t("copyError"), 1500);
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
}
|
|
838
865
|
const addBtn = popRef.querySelector("[data-add]");
|
|
839
866
|
if (addBtn !== null) addBtn.addEventListener("click", () => { addFormState = { kind: "mimo", label: "", key: "", cookie: "" }; showAddForm = true; renderPopover(); });
|
|
840
867
|
const cancelBtn = popRef.querySelector("[data-cancel]");
|
|
@@ -1221,11 +1248,28 @@ window.__ModuleLoader__.load({
|
|
|
1221
1248
|
}
|
|
1222
1249
|
const updated = lastUpdated ? lastUpdated.toLocaleTimeString() : "—";
|
|
1223
1250
|
const versionHtml = versionHtmlOf(lastVersion);
|
|
1251
|
+
const errorPanel = updateErrorDetail ? updateErrorHtml(updateErrorDetail) : "";
|
|
1224
1252
|
return header + syncHint + body +
|
|
1225
1253
|
'<div class="dshBalanceFoot">' + versionHtml +
|
|
1226
1254
|
'<span style="display:flex;align-items:center;gap:8px">' +
|
|
1227
1255
|
'<button class="dshBalanceBtn" type="button" data-refresh>' + t("refresh") + "</button>" +
|
|
1228
|
-
'<span>' + t("updatedAt") + updated + "</span></span></div>";
|
|
1256
|
+
'<span>' + t("updatedAt") + updated + "</span></span></div>" + errorPanel;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/** Render the update-failure detail panel shown below the footer. */
|
|
1260
|
+
function updateErrorHtml(detail) {
|
|
1261
|
+
const summary = String(detail.error || t("updateFailed"));
|
|
1262
|
+
const text = (detail.output || "").trim();
|
|
1263
|
+
const snippet = text.slice(-500) || summary;
|
|
1264
|
+
const escaped = snippet.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1265
|
+
return '<div class="dshBalanceUpdateErr">' +
|
|
1266
|
+
'<div class="dshBalanceUpdateErrHead">' +
|
|
1267
|
+
'<span>' + t("updateFailed") + "</span>" +
|
|
1268
|
+
'<button class="dshBalanceUpdateErrClose" type="button" data-update-err-close aria-label="close">×</button>' +
|
|
1269
|
+
"</div>" +
|
|
1270
|
+
'<pre class="dshBalanceUpdateErrBody" title="' + t("updateFailed") + '">' + escaped + "</pre>" +
|
|
1271
|
+
'<button class="dshBalanceBtn" type="button" data-update-err-copy>' + t("copyError") + "</button>" +
|
|
1272
|
+
"</div>";
|
|
1229
1273
|
}
|
|
1230
1274
|
|
|
1231
1275
|
/** Build the npm version snippet shown in the footer (always a clickable button). */
|
|
@@ -1452,6 +1496,8 @@ window.__ModuleLoader__.load({
|
|
|
1452
1496
|
let timer = null;
|
|
1453
1497
|
let versionTimer = null;
|
|
1454
1498
|
let updateSuccessUntil = 0;
|
|
1499
|
+
/** When the last update attempt failed, hold {error, output} so the user can inspect it. */
|
|
1500
|
+
let updateErrorDetail = null;
|
|
1455
1501
|
|
|
1456
1502
|
/** One refresh cycle: fetch balance + usage + providers, update entry and popover. */
|
|
1457
1503
|
async function refresh(manual) {
|
package/lib/index.js
CHANGED
|
@@ -601,12 +601,22 @@ function cleanEnv() {
|
|
|
601
601
|
const env = { ...process.env };
|
|
602
602
|
const no = env.NODE_OPTIONS || "";
|
|
603
603
|
if (/genie-safe-delete/i.test(no)) {
|
|
604
|
+
// Strip the WorkBuddy safe-delete shim entirely. The shim monkey-patches
|
|
605
|
+
// fs.unlink/rm to route through a trash channel which is disabled inside
|
|
606
|
+
// the desktop sandbox, causing pnpm/npm to fail-closed whenever they delete
|
|
607
|
+
// temporary files during an install. Removing the --require prevents the
|
|
608
|
+
// child Node process from loading it at all.
|
|
604
609
|
env.NODE_OPTIONS = no
|
|
605
610
|
.replace(/\s*--require="[^"]*genie-safe-delete[^"]*"/gi, "")
|
|
606
611
|
.replace(/\s*--require=[^\s"]*genie-safe-delete[^\s"]*/gi, "")
|
|
607
612
|
.trim();
|
|
608
613
|
if (!env.NODE_OPTIONS) delete env.NODE_OPTIONS;
|
|
609
614
|
}
|
|
615
|
+
// Also delete any remaining WorkBuddy/shim variables that can re-enable
|
|
616
|
+
// safe-delete behavior in spawned package managers.
|
|
617
|
+
delete env.WORKBUDDY_SAFE_DELETE;
|
|
618
|
+
delete env.GENIE_SAFE_DELETE;
|
|
619
|
+
delete env.SAFE_DELETE_ENABLED;
|
|
610
620
|
env.NPM_CONFIG_FUND = "false";
|
|
611
621
|
env.NPM_CONFIG_AUDIT = "false";
|
|
612
622
|
return env;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deepseek-balance-widget",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-provider AI balance widget for the dsh web sidebar: a live, auto-refreshing balance pill plus a detail popover listing DeepSeek and any added providers (MiMo etc.). Keys are stored per-machine in ~/.dsh/ai-balances.json and resolved from the local credential seam, never hardcoded.",
|
|
6
6
|
"keywords": [
|