@sligqoer/dsh-usage-stats 0.2.0 → 0.2.2
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/CHANGELOG.md +89 -1
- package/NOTICE +39 -0
- package/README.en.md +187 -0
- package/README.md +93 -263
- package/lib/bridge.js +33 -0
- package/lib/client.js +2321 -1579
- package/lib/index.js +173 -197
- package/lib/lm-fingerprint-engine.js +166 -0
- package/lib/lm-fingerprint-source.js +134 -0
- package/lib/lm-fingerprint-worker.js +31 -0
- package/lib/{model-test-history.js → model-detection-history.js} +23 -30
- package/lib/model-detection.js +255 -0
- package/lib/quota-controls.js +64 -23
- package/lib/supplemental-usage.js +77 -0
- package/lib/usage-preferences.js +51 -0
- package/locale/en.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +28 -25
- package/screenshots/controls.png +0 -0
- package/screenshots/detection.png +0 -0
- package/screenshots/quotas.png +0 -0
- package/screenshots/usage.png +0 -0
- package/third_party/brand-icons/CHANNEL-ICONS-LICENSE +21 -0
- package/third_party/brand-icons/LICENSE +59 -0
- package/third_party/brand-icons/NOTICE.txt +5 -0
- package/third_party/brand-icons/REACT-ICONS-LICENSE +104 -0
- package/third_party/brand-icons/channel-icons/LICENSE +21 -0
- package/third_party/brand-icons/channel-icons/UPSTREAM.json +6 -0
- package/third_party/brand-icons/lobe-icons/LICENSE +21 -0
- package/third_party/brand-icons/lobe-icons/UPSTREAM.json +16 -0
- package/third_party/brand-icons/react-icons/LICENSE +13 -0
- package/third_party/brand-icons/react-icons/UPSTREAM.json +6 -0
- package/third_party/lm-fingerprint/LICENSE +21 -0
- package/third_party/lm-fingerprint/UPSTREAM.json +32 -0
- package/third_party/lm-fingerprint/core/challenge-browser.mjs +210 -0
- package/third_party/lm-fingerprint/core/detector-codec.mjs +20 -0
- package/third_party/lm-fingerprint/core/fingerprint-core.mjs +121 -0
- package/third_party/lm-fingerprint/core/positional.mjs +64 -0
- package/third_party/lm-fingerprint/core/shared-detector.mjs +132 -0
- package/third_party/lm-fingerprint/data/shared_detector.bin +0 -0
- package/third_party/lm-fingerprint/data/unified_bank.json +826820 -0
- package/README.zh-CN.md +0 -357
- package/lib/fingerprints/KBF-LICENSE.txt +0 -201
- package/lib/fingerprints/NOTICE.txt +0 -6
- package/lib/fingerprints/kbf-202609.json +0 -1
- package/lib/model-capabilities.js +0 -41
- package/lib/model-fingerprints.js +0 -146
- package/lib/model-match.js +0 -407
- package/screenshots/match.png +0 -0
- package/screenshots/token-speed.png +0 -0
package/README.zh-CN.md
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="screenshots/icon.svg" alt="dsh-usage-stats" width="80" height="80">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">dsh-usage-stats</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<strong>在 DSH 里,看清 Token 用量、账户余额与订阅配额。</strong><br>
|
|
9
|
-
为 <a href="https://github.com/deepseek-ai/deepseek-harness">DeepSeek Harness 桌面端</a>打造的本地用量面板。
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
<p align="center">
|
|
13
|
-
<a href="#安装"><img src="https://img.shields.io/badge/DSH-Desktop-2563eb?style=flat-square" alt="DSH 桌面端"></a>
|
|
14
|
-
<a href="https://github.com/Jockjrop/dsh-usage-stats/releases/latest"><img src="https://img.shields.io/github/v/release/Jockjrop/dsh-usage-stats?style=flat-square&color=64748b" alt="最新发行版"></a>
|
|
15
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-22c55e?style=flat-square" alt="Apache 2.0 许可"></a>
|
|
16
|
-
</p>
|
|
17
|
-
|
|
18
|
-
<p align="center">
|
|
19
|
-
<a href="README.md">English</a> · 简体中文<br>
|
|
20
|
-
<a href="https://github.com/Jockjrop/dsh-usage-stats/releases/latest">下载</a> ·
|
|
21
|
-
<a href="#功能">功能</a> ·
|
|
22
|
-
<a href="#安装">安装</a> ·
|
|
23
|
-
<a href="#使用">使用</a> ·
|
|
24
|
-
<a href="#常见问题">常见问题</a> ·
|
|
25
|
-
<a href="CHANGELOG.md">更新日志</a> ·
|
|
26
|
-
<a href="https://github.com/Jockjrop/dsh-usage-stats/issues">反馈问题</a>
|
|
27
|
-
</p>
|
|
28
|
-
|
|
29
|
-
<p align="center">
|
|
30
|
-
<a href="screenshots/usage.png"><img src="screenshots/usage.png" alt="用量面板:概览指标、今日图表与使用量热力图" width="800"></a>
|
|
31
|
-
</p>
|
|
32
|
-
|
|
33
|
-
<p align="center"><sub>从今天用了多少,到长期使用趋势,一眼看清。展示截图的版本与数值已替换为本次发布的模拟数据。</sub></p>
|
|
34
|
-
|
|
35
|
-
<table align="center">
|
|
36
|
-
<thead>
|
|
37
|
-
<tr><th align="center">配额</th><th align="center">控制</th></tr>
|
|
38
|
-
</thead>
|
|
39
|
-
<tbody>
|
|
40
|
-
<tr>
|
|
41
|
-
<td align="center"><a href="screenshots/quotas.png"><img src="screenshots/quotas.png" alt="供应商余额与 WorkBuddy 积分" width="400"></a></td>
|
|
42
|
-
<td align="center"><a href="screenshots/controls.png"><img src="screenshots/controls.png" alt="自动查询设置与自定义配额查询" width="400"></a></td>
|
|
43
|
-
</tr>
|
|
44
|
-
<tr>
|
|
45
|
-
<td align="center">集中查看供应商余额与 WorkBuddy 积分。</td>
|
|
46
|
-
<td align="center">设置自动刷新间隔和自定义配额查询。</td>
|
|
47
|
-
</tr>
|
|
48
|
-
</tbody>
|
|
49
|
-
</table>
|
|
50
|
-
|
|
51
|
-
<table align="center">
|
|
52
|
-
<thead>
|
|
53
|
-
<tr><th align="center">token输出速度</th><th align="center">模型匹配</th></tr>
|
|
54
|
-
</thead>
|
|
55
|
-
<tbody>
|
|
56
|
-
<tr>
|
|
57
|
-
<td align="center"><a href="screenshots/token-speed.png"><img src="screenshots/token-speed.png" alt="按 TPS 排序的模型列表与平均 TTFT" width="400"></a></td>
|
|
58
|
-
<td align="center"><a href="screenshots/match.png"><img src="screenshots/match.png" alt="参考接近度、检测结论与折叠详情" width="400"></a></td>
|
|
59
|
-
</tr>
|
|
60
|
-
<tr>
|
|
61
|
-
<td align="center">比较不同供应商的输出速度和首 Token 等待时间。</td>
|
|
62
|
-
<td align="center">直接查看分数、结论与已计入统计的检测用量。</td>
|
|
63
|
-
</tr>
|
|
64
|
-
</tbody>
|
|
65
|
-
</table>
|
|
66
|
-
|
|
67
|
-
## 功能
|
|
68
|
-
|
|
69
|
-
| 页面 | 你可以做什么 |
|
|
70
|
-
| --- | --- |
|
|
71
|
-
| **用量** | 查看今日与累计 Token、使用天数、小时调用次数、每日/每周热力图、模型明细与 token输出速度。 |
|
|
72
|
-
| **配额** | 集中查看已配置平台的余额、订阅额度窗口,以及 WorkBuddy/WorkBuddy AI 积分。 |
|
|
73
|
-
| **匹配** | 在控制页开启「检测模型匹配」后显示(默认关闭),分析当前会话的请求设置与响应声明模型,按需运行可取消的独立测试。 |
|
|
74
|
-
| **控制** | 调整查询间隔、设置自定义配额接口、切换模型明细、检测模型匹配、token输出速度和高级模型选择器。 |
|
|
75
|
-
|
|
76
|
-
- **看清使用趋势**:趋势图切换 7/30 天,热力图按日/周查看历史,按供应商、模型查看用量。
|
|
77
|
-
- **汇总账户配额**:使用内置读取器,也能为自定义供应商映射 JSON 响应。
|
|
78
|
-
- **按需刷新**:手动获取或开启定时查询;自动查询默认关闭。
|
|
79
|
-
- **查看概览指标**:展开后显示缓存命中率、历史单日 Token 峰值、最长已完成单轮任务、当前连续天数、历史最长连续使用天数和最近 7 天调用最多的一个模型。同名模型跨供应商合并;任务耗时要求完整起止记录,排除消息之间的空闲时间;今日尚未使用时连续记录延续至昨日,完整空闲一天后归零。已删除会话的历史汇总继续保留。
|
|
80
|
-
- **比较输出速度**:默认显示「token输出速度」,按供应商+模型的 TPS 排名;沿用 DSH TPS,以累计输出 Token 除以首个非空输出到响应完成的累计时间,单位为 tok/s。TTFT 列显示完成调用从开始到首个非空 Token 的平均耗时,单位为秒,缺少记录时显示「—」。无有效解码时间的样本不参与排名,可在控制页关闭显示。
|
|
81
|
-
- **保留刷新结果**:配额失败时保留上次成功的数据和时间并提示原因;卡片刷新只查询对应供应商,查询草稿跨标签页保留。
|
|
82
|
-
- **更快选择模型**:可开启模型与推理强度面板,拖动滑条调整;关闭后恢复官方选择器。
|
|
83
|
-
- **融入桌面界面**:适配浅色/深色主题,图表自适应宽度,标签页固定,供应商选择支持键盘。
|
|
84
|
-
- **跟随应用语言**:支持中文、英语和日语,随 DSH 所选语言即时切换;用户自定义名称与配额标签保持原样。
|
|
85
|
-
|
|
86
|
-
## 安装
|
|
87
|
-
|
|
88
|
-
**推荐通过 DSH 桌面端安装 [npm 包 `@sligqoer/dsh-usage-stats`](https://www.npmjs.com/package/@sligqoer/dsh-usage-stats)。** 已包含预构建模块,无需克隆仓库或在本机构建;通过包名安装后可使用插件页的「检查更新」。
|
|
89
|
-
|
|
90
|
-
### 1. 打开插件安装入口
|
|
91
|
-
|
|
92
|
-
在 DSH 桌面端主界面的侧栏进入 **插件 → 添加插件**。
|
|
93
|
-
|
|
94
|
-
### 2. 填入完整 npm 包名
|
|
95
|
-
|
|
96
|
-
```text
|
|
97
|
-
@sligqoer/dsh-usage-stats
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
将包名粘贴到 **包名或地址**,点击 **安装**。请保留完整的 `@sligqoer/` 前缀。
|
|
101
|
-
|
|
102
|
-
### 3. 启用并打开面板
|
|
103
|
-
|
|
104
|
-
点击 **立即启用**,进入 **设置 → 用量统计**。如果插件管理器提示需要重启,按提示重启 DSH。
|
|
105
|
-
|
|
106
|
-
用量页会读取本地 DSH 会话。进入 **配额**,点击对应卡片的刷新按钮,即可查询账户数据。
|
|
107
|
-
|
|
108
|
-
<details>
|
|
109
|
-
<summary>安装指定版本或已下载的压缩包</summary>
|
|
110
|
-
|
|
111
|
-
要安装指定版本 `0.2.0`,在同一安装入口填入:
|
|
112
|
-
|
|
113
|
-
```text
|
|
114
|
-
@sligqoer/dsh-usage-stats@0.2.0
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
也可以手动安装 [Release 压缩包](https://github.com/Jockjrop/dsh-usage-stats/releases/latest),在安装入口填入以下地址,或下载 `.tgz` 与 `SHA256SUMS` 后填写压缩包的本地绝对路径。安装前无需解压。
|
|
118
|
-
|
|
119
|
-
```text
|
|
120
|
-
https://github.com/Jockjrop/dsh-usage-stats/releases/latest/download/dsh-usage-stats.tgz
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
```powershell
|
|
124
|
-
Get-FileHash ./sligqoer-dsh-usage-stats-0.2.0.tgz -Algorithm SHA256
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
</details>
|
|
128
|
-
|
|
129
|
-
<details>
|
|
130
|
-
<summary>从源码安装/手动链接开发目录</summary>
|
|
131
|
-
|
|
132
|
-
开发时准备 Git、Node.js 和 pnpm,再构建仓库。以下步骤已在 Windows + Node.js 24 环境验证:
|
|
133
|
-
|
|
134
|
-
```sh
|
|
135
|
-
git clone https://github.com/Jockjrop/dsh-usage-stats.git
|
|
136
|
-
cd dsh-usage-stats
|
|
137
|
-
npm ci
|
|
138
|
-
npm run build
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
请将克隆目录保存在固定位置,DSH 会链接到该目录。
|
|
142
|
-
|
|
143
|
-
在 **插件 → 添加插件** 填入克隆目录的绝对路径,安装后点击 **立即启用**。如果选择手动链接,完全退出 DSH 桌面端,备份其 profile 的 `package.json`,然后在**刚克隆的目录内,用 PowerShell** 运行:
|
|
144
|
-
|
|
145
|
-
```powershell
|
|
146
|
-
$pluginDir = (Get-Location).Path.Replace('\', '/')
|
|
147
|
-
$dshDataDir = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $env:USERPROFILE '.dsh' }
|
|
148
|
-
$profileDir = Join-Path $dshDataDir 'profiles/desktop'
|
|
149
|
-
pnpm --dir $profileDir add "link:$pluginDir"
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
打开 `$profileDir/package.json`,在其已有的 `dsh.profile.bundles` 数组末尾加入 `"@sligqoer/dsh-usage-stats"`,保留其他 bundle 条目。
|
|
153
|
-
|
|
154
|
-
DSH 桌面端自行管理 desktop profile,不能使用 `dsh plugin --profile desktop`。手动链接完成后,启动应用并进入 **设置 → 用量统计**。
|
|
155
|
-
|
|
156
|
-
</details>
|
|
157
|
-
|
|
158
|
-
<details>
|
|
159
|
-
<summary>更新与卸载</summary>
|
|
160
|
-
|
|
161
|
-
**从旧版迁移:** 在「插件」页面卸载旧的 `dsh-usage-stats`,再填入 `@sligqoer/dsh-usage-stats` 安装并启用。包名切换仅需做一次;插件继续使用原有的数据目录、配额接口和设置标识。
|
|
162
|
-
|
|
163
|
-
**npm 安装:** 使用插件页的「检查更新」,按提示更新并重启。当前更新检查器只处理直接通过 npm 包名安装的插件。GitHub 地址、压缩包地址、本地路径或 `link:` 安装需要手动升级;这些来源显示「已是最新版本」也不代表没有新发布。
|
|
164
|
-
|
|
165
|
-
**Release 安装:** 从「插件」页面卸载后,使用上面的 Release 地址重新安装并启用新版。彻底卸载时,使用同一页面的卸载操作。
|
|
166
|
-
|
|
167
|
-
**源码安装:** 完全退出 DSH 桌面端,在克隆目录执行以下命令,再启动应用:
|
|
168
|
-
|
|
169
|
-
```sh
|
|
170
|
-
git pull --ff-only
|
|
171
|
-
npm ci
|
|
172
|
-
npm run build
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
**手动链接卸载:** 退出桌面端,从 desktop profile 中仅移除 `@sligqoer/dsh-usage-stats` 依赖和 bundle 条目,在该 profile 运行 `pnpm install`,然后重启。
|
|
176
|
-
|
|
177
|
-
</details>
|
|
178
|
-
|
|
179
|
-
## 使用
|
|
180
|
-
|
|
181
|
-
**用量**用于查看总量与趋势。悬停图表或热力图格子可以查看明细;切换历史筛选时,概览卡片仍按今日/完整历史口径显示。
|
|
182
|
-
|
|
183
|
-
**配额**展示平台接口返回的数据。已配置但尚未查询的余额可能显示 **未查询**;卡片是否可用取决于凭据和账户权限。
|
|
184
|
-
|
|
185
|
-
**匹配**读取当前会话的供应商、模型与推理强度。已有响应的名称声明仅作辅助提示,读取日志和参考列表不调用模型。开启控制页「检测模型匹配」后才能看到此页,默认关闭。
|
|
186
|
-
|
|
187
|
-
**行为指纹检测**对照 [KBF](https://github.com/Ooo0ption/KBF) 的知识边界回答模式,包含稳定的错误回答。插件附带 28 份公开参考、10,327 个探针,记录参考通道、日期、原始文件 SHA-256 与来源。公开参考可能来自第三方部署;例如 DeepSeek V4.1 Flash 的参考来自 Novita。没有对应参考的模型可导入 KBF JSON,或选择可信供应商建立本地参考。自建参考从候选池筛选三轮稳定回答,再单独自测校准;这属于自建行为基线,尚未复现论文完整的对比模型筛选实验。
|
|
188
|
-
|
|
189
|
-
自测误差的 Clopper–Pearson 99% 上界作为噪声基线,使用单侧二项检验(p < 0.05)判断差异。至少需要 64 个有效回答、目标与参考均达到 80% 覆盖率;参考噪声上界超过 30% 时要求重新校准。结果为「发现显著差异」「未发现显著差异」或「样本不足或测试未完成」。p 值不表示模型为真的概率。版本、推理设置、提示词或部署变化也可能产生差异;未发现显著差异仅描述本次测试。公开参考使用温度 0、关闭推理,宿主不支持关闭时需自建相同推理参数的参考。
|
|
190
|
-
|
|
191
|
-
完成的行为检测显示 0–100 的「参考接近度」:一致回答数 ÷ 有效回答数 × 100。分数表示回答一致率,不表示模型为真的概率;取消、中断或证据不足时显示「无法评分」。已有结果自动计算分数,无需重新测试。参数、验证过程、统计检验和通道表现收进默认折叠的「检测详情」。
|
|
192
|
-
|
|
193
|
-
**能力测试**运行 16 项可复用随机种子的代码推演、路径推理、上下文检索与约束优化。自建参考保存有效的能力成绩,后续在相同推理强度下用成对单侧检验检查下降。没有能力参考时仅显示当前成绩,不据此识别模型或量化级别。TPS 与 TTFT 单列表示测试通道表现。
|
|
194
|
-
|
|
195
|
-
先点击 **查看测试预算**,核对实际参数、最多请求次数、输入估算、输出上限与已上报 Token 预算,再点击 **开始检测(会消耗 Token)**。预算五分钟有效且仅可使用一次。测试可取消、每次超时 60 秒;达到已上报预算时停止后续请求。推理、未上报用量与供应商重试按通道规则计费,因此已上报预算不等同于绝对账单上限。测试不使用会话正文、不改写当前会话,已上报用量逐次计入用量统计;失败或取消的消耗也保留。基线原子保存到 `storages/usage-stats-model-baselines.json`,最多 20 份;检测用量及最近 10 次结果保存到 `storages/usage-stats-model-tests.json`。结果卡片在表单上方显示「未发现明显异常」「疑似不匹配」「疑似能力下降」或「无法判定」及具体原因,宿主重启中断的测试保持无法判定。切换或删除原会话后仍可查看「上次检测结果」,其结论仅对应卡片列出的模型和参数。
|
|
196
|
-
|
|
197
|
-
**控制**管理显示与刷新方式:
|
|
198
|
-
|
|
199
|
-
| 设置 | 默认值 |
|
|
200
|
-
| --- | --- |
|
|
201
|
-
| 自动获取配额 | 关闭 |
|
|
202
|
-
| 查询间隔 | 1 小时;也可选 10 分钟、5 小时、每天 |
|
|
203
|
-
| 模型明细与分布 | 开启 |
|
|
204
|
-
| 检测模型匹配 | 关闭 |
|
|
205
|
-
| token输出速度 | 开启 |
|
|
206
|
-
| 高级模型选择器 | 关闭 |
|
|
207
|
-
|
|
208
|
-
开启自动查询前需要确认可能产生的查询成本。关闭设置页后,宿主仍按间隔执行;平时打开配额页只读取缓存。
|
|
209
|
-
|
|
210
|
-
<details>
|
|
211
|
-
<summary><strong>支持的平台与凭据</strong></summary>
|
|
212
|
-
|
|
213
|
-
内置读取器覆盖 Claude、DeepSeek、StepFun、Codex、GitHub Copilot、OpenRouter、Moonshot 国内/国际、Kimi Coding、MiniMax 国内/国际、Z.AI、智谱 GLM Coding、阿里云 Token Plan 国内版、xAI 和 OpenCode Go。
|
|
214
|
-
|
|
215
|
-
供应商需要已在 DSH 中配置。支持 OAuth 的读取器使用已有且未过期的登录,本插件不会刷新或改写登录信息。
|
|
216
|
-
|
|
217
|
-
| 可选读取器 | 宿主凭据引用 |
|
|
218
|
-
| --- | --- |
|
|
219
|
-
| OpenRouter 账户总余额 | `OPENROUTER_MANAGEMENT_API_KEY` |
|
|
220
|
-
| xAI 预付余额 | `XAI_MANAGEMENT_API_KEY`、`XAI_TEAM_ID` |
|
|
221
|
-
| 阿里云 Token Plan 国内版 | `ALIBABA_CLOUD_ACCESS_KEY_ID`、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`;临时凭据可加 `ALIBABA_CLOUD_SECURITY_TOKEN` |
|
|
222
|
-
|
|
223
|
-
OpenCode Go 只使用其自身在 DSH 中配置的凭据。Zen 没有内置钱包余额读取器,可使用自定义查询;阿里云国际版 Token Plan 暂未接入。
|
|
224
|
-
|
|
225
|
-
WorkBuddy 与 WorkBuddy AI 依赖可选的 `dsh-workbuddy-connect` 适配器,两套积分分别缓存、分别刷新。
|
|
226
|
-
|
|
227
|
-
</details>
|
|
228
|
-
|
|
229
|
-
<details>
|
|
230
|
-
<summary><strong>配置自定义配额查询</strong></summary>
|
|
231
|
-
|
|
232
|
-
1. 进入 **控制 → 配额查询**,选择已有供应商。
|
|
233
|
-
2. 填写查询 URL 和响应字段映射。
|
|
234
|
-
3. 点击 **测试**,检查解析出的结果。
|
|
235
|
-
4. 确认查询后,在 **配额** 页面查看。
|
|
236
|
-
|
|
237
|
-
假设接口返回 `{ "data": { "balance": 12.34 } }`:
|
|
238
|
-
|
|
239
|
-
```json
|
|
240
|
-
{
|
|
241
|
-
"url": "https://api.example.com/balance",
|
|
242
|
-
"method": "GET",
|
|
243
|
-
"auth": "provider",
|
|
244
|
-
"headers": { "accept": "application/json" },
|
|
245
|
-
"response": {
|
|
246
|
-
"metrics": [
|
|
247
|
-
{
|
|
248
|
-
"label": "账户可用余额",
|
|
249
|
-
"kind": "amount",
|
|
250
|
-
"remaining": "data.balance",
|
|
251
|
-
"currency": "CNY"
|
|
252
|
-
}
|
|
253
|
-
]
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
将示例 URL 替换为供应商的真实接口。`auth: "provider"` 使用其已有的 DSH 凭据,认证查询地址需与配置地址或官方配额地址同源。
|
|
259
|
-
|
|
260
|
-
模板支持 GET/POST、JSON body、余额/窗口指标,以及 `data.items[0].balance` 等字段路径。窗口支持百分比或 `total` 搭配 `remaining`/`used`,`response.rows` 指定数组;无需认证时使用 `auth: "none"`。
|
|
261
|
-
|
|
262
|
-
修改模板后需要重新测试,成功结果有效期为 15 分钟。确认后的自定义查询覆盖该供应商的内置读取器,移除后恢复。
|
|
263
|
-
|
|
264
|
-
</details>
|
|
265
|
-
|
|
266
|
-
## 隐私
|
|
267
|
-
|
|
268
|
-
用量统计在本机完成。插件保存统计数、模型标识、用量时间、显式会话标题和工作目录,以及每个会话最多 30 条模型证据摘要;不保存对话正文、私有 replay blocks 或凭据。凭据只在宿主读取,不返回渲染进程。独立测试持久化已上报用量及最近 10 组结果,不保存问题或生成原文。
|
|
269
|
-
|
|
270
|
-
测试查询与刷新会访问对应平台的配额服务。插件不含分析上报或遥测接口。
|
|
271
|
-
|
|
272
|
-
<details>
|
|
273
|
-
<summary>本地存储与请求保护</summary>
|
|
274
|
-
|
|
275
|
-
本地文件位于 `<DSH_HOME>/storages/`;未设置 `DSH_HOME` 时使用当前用户的 `.dsh/storages/`:
|
|
276
|
-
|
|
277
|
-
| 文件 | 内容 |
|
|
278
|
-
| --- | --- |
|
|
279
|
-
| `usage-stats-corpus.json` | 按会话保存的用量贡献 |
|
|
280
|
-
| `usage-stats-controls.json` | 控制设置、自定义模板与配额快照 |
|
|
281
|
-
| `usage-stats-model-baselines.json` | 私人行为与能力参考 |
|
|
282
|
-
| `usage-stats-model-tests.json` | 已上报检测用量与最近 10 次结果 |
|
|
283
|
-
|
|
284
|
-
这些是私人的本地数据,与凭据、环境文件、数据库、日志、备份和预览一起排除在 Git 之外。
|
|
285
|
-
|
|
286
|
-
接口检查回环地址、Host、Origin 与跨站请求,使用 `Cache-Control: no-store`,隐藏未知宿主异常的原始详情。同一用户权限下的其他进程可以访问本地数据。
|
|
287
|
-
|
|
288
|
-
自定义查询拒绝模板中的认证请求头和常见凭据字段;使用供应商认证时要求对应来源,不跟随重定向,超时 8 秒,响应上限 1 MB。WorkBuddy 适配器只保留配额展示字段。
|
|
289
|
-
|
|
290
|
-
</details>
|
|
291
|
-
|
|
292
|
-
## 常见问题
|
|
293
|
-
|
|
294
|
-
**支持 DSH Web 吗?**
|
|
295
|
-
|
|
296
|
-
当前版本只在 desktop profile 和 Electron 主窗口加载。
|
|
297
|
-
|
|
298
|
-
**为什么配额卡片不显示或无法获取?**
|
|
299
|
-
|
|
300
|
-
先确认供应商已配置、凭据可用且账户支持配额接口。普通模型 API Key 可能没有账单查询权限。
|
|
301
|
-
|
|
302
|
-
**Token 总数就是账单金额吗?**
|
|
303
|
-
|
|
304
|
-
不是。总数为输入、输出、缓存读取和缓存写入 Token 之和,账户余额来自平台接口。
|
|
305
|
-
|
|
306
|
-
**会修改 DSH 的文件吗?**
|
|
307
|
-
|
|
308
|
-
插件注册外部 bundle。高级模型选择器开启时接管界面槽位,关闭后恢复官方选择器,不修改 DSH 源码。
|
|
309
|
-
|
|
310
|
-
## 参与贡献
|
|
311
|
-
|
|
312
|
-
欢迎提交问题和改进。报告问题时,请附上 DSH 版本、插件版本、复现步骤,以及已处理私人账户信息的截图。
|
|
313
|
-
|
|
314
|
-
<details>
|
|
315
|
-
<summary><strong>开发与本地接口</strong></summary>
|
|
316
|
-
|
|
317
|
-
只编辑 `src/` 中的模块源码。`npm run build` 同步到 `lib/` 和根目录兼容副本,并从 `package.json` 注入界面模块的包名和顶部版本号,包入口加载 `lib/`。
|
|
318
|
-
|
|
319
|
-
```sh
|
|
320
|
-
npm run build
|
|
321
|
-
npm test
|
|
322
|
-
node scripts/render-heatmap-check.mjs
|
|
323
|
-
node scripts/check-heat-tip-placement.mjs
|
|
324
|
-
npm run preview:heatmap
|
|
325
|
-
npm pack --dry-run
|
|
326
|
-
npm run release
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
测试使用模拟数据与临时 DSH 目录,无需真实凭据或付费调用。可设置 `DSH_THEME_CLIENT` 验证已安装主题,默认使用随仓库提供的变量契约。模拟预览生成已忽略的 `preview-heatmap.html`。
|
|
330
|
-
|
|
331
|
-
`npm run release` 构建插件,将 `sligqoer-dsh-usage-stats-<版本号>.tgz`、`dsh-usage-stats.tgz` 别名与 `SHA256SUMS` 写入已忽略的 `release/`,并在临时 profile 验证安装。发行说明包含 [CHANGELOG.md](CHANGELOG.md) 中对应版本的更新内容。
|
|
332
|
-
|
|
333
|
-
推送与 `package.json` 版本一致的 `v<版本号>` 标签后,GitHub Actions 会运行测试,使用 npm 可信发布将验证过的压缩包发布为公开包,再将同一文件发布到 GitHub Release。可信发布绑定 `Jockjrop/dsh-usage-stats` 仓库的 `release.yml` 工作流,无需在仓库保存 npm 令牌。`npm run publish:release` 发布已构建的压缩包;已有版本仅在完整性与本地压缩包一致时跳过,内容不同则终止。
|
|
334
|
-
|
|
335
|
-
接口统一使用 `/api/dsh-usage-stats/` 前缀:
|
|
336
|
-
|
|
337
|
-
| 路由 | 方法 | 作用 |
|
|
338
|
-
| --- | --- | --- |
|
|
339
|
-
| `stats` | GET | 用量;`days`、`tz`、`model`、`fresh=1` |
|
|
340
|
-
| `provider-quotas` | GET | 配额缓存;`fresh=1` 刷新 |
|
|
341
|
-
| `workbuddy`、`workbuddy-ai` | GET | 适配器缓存;支持 `fresh=1` |
|
|
342
|
-
| `controls` | GET/POST | 读取/修改设置,写入要求 JSON |
|
|
343
|
-
| `quota-providers` | GET | 已有供应商与无凭据模板 |
|
|
344
|
-
| `quota-test` | POST | 测试模板并返回限时确认 ID |
|
|
345
|
-
| `model-match` | GET | 已有响应提示与当前/上次检测结果 |
|
|
346
|
-
| `model-test` | POST | 查看预算、开始或取消检测 |
|
|
347
|
-
| `model-baselines` | GET/POST | 列出、导入、导出或移除行为参考 |
|
|
348
|
-
|
|
349
|
-
语料库每 30 秒刷新;接口最多等待 1500 ms,可能返回 `stale: true`/`partial: true`。SQLite 指纹要求 `node:sqlite`,否则回退为重读会话。时区变化时按已存事件重新分桶,逐小时保存的旧历史在半小时时区边界上可能存在近似。
|
|
350
|
-
|
|
351
|
-
`platform: "web"` 是 DSH 桌面端使用的渲染通信格式;两端入口仍要求 desktop profile 与渲染进程的原生桥接。
|
|
352
|
-
|
|
353
|
-
</details>
|
|
354
|
-
|
|
355
|
-
## 许可
|
|
356
|
-
|
|
357
|
-
[Apache-2.0](LICENSE)。
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
-
Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2026 The KBF Authors
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
KBF reference probes, domain definitions and prompt format
|
|
2
|
-
Copyright 2026 The KBF Authors. Apache License 2.0.
|
|
3
|
-
Source: https://github.com/Ooo0ption/KBF
|
|
4
|
-
Pinned revision: 68aefbbab879469152aaac9fd988a86c30ee4739
|
|
5
|
-
The reference files were reduced to the fields needed by this plugin.
|
|
6
|
-
Reference provenance is recorded per model; third-party references are not official attestations.
|