@pinkbanana/dsh-balance 0.8.0 → 0.9.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 +16 -1
- package/README_EN.md +16 -1
- package/lib/client.js +8 -10
- package/lib/client.js.map +1 -1
- package/lib/index.js +20 -13
- package/lib/index.js.map +1 -1
- package/lib/types/billing.d.ts +3 -3
- package/lib/types/client/BalanceDock.d.ts +1 -1
- package/lib/types/client/BillingTab.d.ts +1 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/providers.d.ts +4 -0
- package/package.json +36 -26
package/README.md
CHANGED
|
@@ -24,6 +24,19 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
|
|
|
24
24
|
- 原生支持简体中文和英文,并跟随 Harness 系统语言切换
|
|
25
25
|
- 支持 Harness 已保存的 `DEEPSEEK_API_KEY`
|
|
26
26
|
|
|
27
|
+
## 兼容性
|
|
28
|
+
|
|
29
|
+
0.9.0 适配 DeepSeek Harness **0.2.0-rc.2**([上游提交 639ed01](https://github.com/deepseek-ai/deepseek-harness/commit/639ed015397290b3745d163aafe02ffee4aa3f84)),需要 Node.js **22.19+(22.x)或 24+**。本次源码不再兼容 Harness 0.1 的接口。
|
|
30
|
+
|
|
31
|
+
也可在本地构建并打包源码,再用 `dsh plugin --profile web add /absolute/path/to/package.tgz` 安装生成的 `.tgz` 文件,随后重启 Harness:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm install --frozen-lockfile
|
|
35
|
+
pnpm pack
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
消费统计通过新版只读会话句柄读取,以 `inheritedEventCount` 排除分叉继承的记录;会话页在 token 用量变化或一轮运行结束后刷新。
|
|
39
|
+
|
|
27
40
|
## 安装
|
|
28
41
|
|
|
29
42
|
```bash
|
|
@@ -33,12 +46,14 @@ dsh --profile web
|
|
|
33
46
|
|
|
34
47
|
打开 <http://127.0.0.1:3080/>,进入“设置 → 模型余额”。该入口位于“Agent 预设”下方,余额摘要也会显示在已有会话的聊天框下方。API Key 可在“设置 → 模型”中保存,或通过 `DEEPSEEK_API_KEY` 环境变量提供。
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
消费统计从已保存会话日志读取,包含当前运行会话已写入的记录,不展示 prompt 内容。可在插件配置中增加固定汇率,例如:
|
|
37
50
|
|
|
38
51
|
```yaml
|
|
39
52
|
usdToCny: 7.2
|
|
40
53
|
```
|
|
41
54
|
|
|
55
|
+
官方提供方 ID `deepseek-official` 与旧 ID `deepseek` 均受支持(大小写不敏感),共享 DeepSeek 凭据、余额及模型缓存。底部保留实际模型 ID,例如 `deepseek-flash`;价格未知的新模型仍标为“未计费”。
|
|
56
|
+
|
|
42
57
|
## StepFun 配置
|
|
43
58
|
|
|
44
59
|
在“设置 → 模型”中添加自定义提供方,Provider ID 填写 `StepFun`(`stepfun`、`STEPFUN` 等大小写写法均可),保存 API Key。Harness 默认将其保存为 `STEPFUN_API_KEY`;也可以直接设置该环境变量。在“设置 → 模型余额”选择 StepFun 即可查询。
|
package/README_EN.md
CHANGED
|
@@ -24,6 +24,19 @@ The composer readout follows the current session’s provider and model. The Set
|
|
|
24
24
|
- Native Simplified Chinese and English that follows the Harness system language
|
|
25
25
|
- Use the `DEEPSEEK_API_KEY` saved by Harness
|
|
26
26
|
|
|
27
|
+
## Compatibility
|
|
28
|
+
|
|
29
|
+
Version 0.9.0 targets DeepSeek Harness **0.2.0-rc.2** ([upstream commit 639ed01](https://github.com/deepseek-ai/deepseek-harness/commit/639ed015397290b3745d163aafe02ffee4aa3f84)). Use Node.js **22.19+ (22.x) or 24+**. Harness 0.1 APIs are no longer supported by this checkout.
|
|
30
|
+
|
|
31
|
+
To install from source, build and pack it locally, then pass the generated `.tgz` path to `dsh plugin --profile web add /absolute/path/to/package.tgz` and restart Harness:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm install --frozen-lockfile
|
|
35
|
+
pnpm pack
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Usage reads the current read-only session handles and excludes fork-inherited events using `inheritedEventCount`. The conversation tab refreshes when token usage changes or a turn finishes.
|
|
39
|
+
|
|
27
40
|
## Install
|
|
28
41
|
|
|
29
42
|
```bash
|
|
@@ -33,12 +46,14 @@ dsh --profile web
|
|
|
33
46
|
|
|
34
47
|
Open <http://127.0.0.1:3080/> and go to Settings → Model Balances. The panel sits directly below Agent presets, and the balance summary also appears below the composer in existing sessions. Save the API key in Settings → Models or provide it through the `DEEPSEEK_API_KEY` environment variable.
|
|
35
48
|
|
|
36
|
-
Usage statistics read
|
|
49
|
+
Usage statistics read persisted session logs, including writes visible from active sessions. Prompt content is never exposed. To show a fixed-rate CNY conversion, add for example:
|
|
37
50
|
|
|
38
51
|
```yaml
|
|
39
52
|
usdToCny: 7.2
|
|
40
53
|
```
|
|
41
54
|
|
|
55
|
+
Both the official provider ID `deepseek-official` and legacy `deepseek` are supported case-insensitively and share DeepSeek credentials, balance caches, and model caches. The composer retains the actual model ID, such as `deepseek-flash`; new models with unknown pricing remain unpriced.
|
|
56
|
+
|
|
42
57
|
## StepFun setup
|
|
43
58
|
|
|
44
59
|
Add a custom provider in Settings → Models with Provider ID `StepFun` (`stepfun`, `STEPFUN`, and other case variants work) and save its API key. Harness derives the credential reference `STEPFUN_API_KEY`; setting that environment variable also works. Select StepFun in Settings → Model Balances.
|
package/lib/client.js
CHANGED
|
@@ -16,17 +16,20 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
/** Browser-safe provider metadata. Credentials and wire parsers stay on the Host. */
|
|
17
17
|
const BALANCE_PROVIDERS = [{
|
|
18
18
|
id: "deepseek",
|
|
19
|
+
aliases: ["deepseek-official"],
|
|
19
20
|
name: "DeepSeek",
|
|
20
21
|
apiKeyRef: "DEEPSEEK_API_KEY",
|
|
21
22
|
baseUrl: "https://api.deepseek.com"
|
|
22
23
|
}, {
|
|
23
24
|
id: "stepfun",
|
|
25
|
+
aliases: [],
|
|
24
26
|
name: "StepFun",
|
|
25
27
|
apiKeyRef: "STEPFUN_API_KEY",
|
|
26
28
|
baseUrl: "https://api.stepfun.com/v1"
|
|
27
29
|
}];
|
|
28
30
|
function findBalanceProvider(id) {
|
|
29
|
-
|
|
31
|
+
const normalized = id.trim().toLowerCase();
|
|
32
|
+
return BALANCE_PROVIDERS.find((provider) => provider.id === normalized || provider.aliases.some((alias) => alias === normalized));
|
|
30
33
|
}
|
|
31
34
|
//#endregion
|
|
32
35
|
//#region src/pricing.ts
|
|
@@ -1100,20 +1103,15 @@ window.__ModuleLoader__.load({
|
|
|
1100
1103
|
]
|
|
1101
1104
|
});
|
|
1102
1105
|
}
|
|
1103
|
-
function BillingView({ loadUsage, sessionId, useSession, t }) {
|
|
1106
|
+
function BillingView({ loadUsage, sessionId, useSession, useProjection, t }) {
|
|
1104
1107
|
const timeZone = (0, react.useMemo)(() => Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC", []);
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
const node = snapshot.nodes[index];
|
|
1108
|
-
if (node?.kind === "assistant") return `${node.seq}:${node.time}`;
|
|
1109
|
-
}
|
|
1110
|
-
return "empty";
|
|
1111
|
-
});
|
|
1108
|
+
const running = useSession((snapshot) => snapshot.running);
|
|
1109
|
+
const tokenUsage = useProjection("tokenUsage");
|
|
1112
1110
|
const { result, loading, refresh } = useUsageResult(loadUsage, (0, react.useMemo)(() => ({
|
|
1113
1111
|
scope: "session",
|
|
1114
1112
|
sessionId,
|
|
1115
1113
|
timeZone
|
|
1116
|
-
}), [sessionId, timeZone]), `${sessionId}:${
|
|
1114
|
+
}), [sessionId, timeZone]), `${sessionId}:${running}:${JSON.stringify(tokenUsage)}`);
|
|
1117
1115
|
const sessionResult = result?.ok === true && result.scope === "session" ? result : void 0;
|
|
1118
1116
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1119
1117
|
className: "dsh-billing-view",
|