@dsh-agent-toolkit/token-usage 0.2.0 → 0.3.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/LICENSE +21 -21
- package/README.md +51 -30
- package/cordis.patch.yml +3 -7
- package/lib/client-module.d.ts +10 -0
- package/lib/client-module.js +24972 -0
- package/lib/client-module.js.map +1 -0
- package/lib/client.js +273 -242
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.js +157 -97
- package/lib/index.js.map +1 -1
- package/package.json +16 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EsonXie
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,30 +1,51 @@
|
|
|
1
|
-
# @dsh-agent-toolkit/token-usage
|
|
2
|
-
|
|
3
|
-
DeepSeek Harness
|
|
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
|
-
|
|
1
|
+
# @dsh-agent-toolkit/token-usage
|
|
2
|
+
|
|
3
|
+
DeepSeek Harness plugin: per-day token usage statistics — 13-week heatmap, stacked daily chart, `/token-usage` command.
|
|
4
|
+
|
|
5
|
+
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)插件:按日/按小时计量 token 用量。
|
|
6
|
+
|
|
7
|
+
- 13 周活动热力图 + 单日堆叠图(按模型/按项目/压缩单列),侧边栏底栏「Token 用量」打开
|
|
8
|
+
- `/token-usage [YYYY-MM-DD]` 命令:今日 + 近 7 日,或指定日期
|
|
9
|
+
- JSON API:`/dsh-agent-toolkit/api/usage/daily?date=`、`/dsh-agent-toolkit/api/usage/range?days=`(web 模式)
|
|
10
|
+
- 用量缺失的样本经 tokenMeter 启发式估算,估算量单列
|
|
11
|
+
|
|
12
|
+
## 截图
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
dsh plugin add @dsh-agent-toolkit/token-usage
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
包自带 `cordis.patch.yml`(bundles 层),装进 profile 后自动激活。
|
|
25
|
+
|
|
26
|
+
> **与 dsh-agent-toolkit 二选一**:`dsh-agent-toolkit` 已内置本插件全部功能(Agent 注册表/分层提示词/委派/飞书 bots + token 用量)。
|
|
27
|
+
> 两者同时安装时,后到实例会自动停用用量功能(不重复计量、不注册 `/token-usage` 命令与面板),先到者完整工作;仍建议只装其一。
|
|
28
|
+
|
|
29
|
+
## 配置
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
- id: '@dsh-agent-toolkit/token-usage'
|
|
33
|
+
config:
|
|
34
|
+
timezone: Asia/Shanghai # 默认值;按日/按小时聚合的时区
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
修改配置触发 HMR 热替换,无需重启。
|
|
38
|
+
|
|
39
|
+
## 运行前提
|
|
40
|
+
|
|
41
|
+
- 宿主注入服务:`storageDomain`、`tokenMeter`、`commands`(`webServer` 可选,headless/CLI 下 API 自动不注册)。
|
|
42
|
+
- peer dependency:`@deepseek-ai/cordis` ^4。
|
|
43
|
+
|
|
44
|
+
## 从 0.2.x 升级
|
|
45
|
+
|
|
46
|
+
0.3.0 起本包重写为 `dsh-agent-toolkit` workspace 的用量模块,存储域 `token_usage` 不变,历史数据保留。
|
|
47
|
+
0.1.x/0.2.x 已废弃(deprecated)。
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT
|
package/cordis.patch.yml
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# cordis.patch.yml 中整行覆盖(patch 是整行替换,不深度合并)。
|
|
5
|
-
- insert:
|
|
6
|
-
- id: token-usage
|
|
7
|
-
name: '@dsh-agent-toolkit/token-usage'
|
|
1
|
+
- insert:
|
|
2
|
+
- id: '@dsh-agent-toolkit/token-usage'
|
|
3
|
+
name: '@dsh-agent-toolkit/token-usage'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
//#region src/client/usage/index.d.ts
|
|
3
|
+
declare function setupUsageClient(ctx: Context): void;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/client/index.d.ts
|
|
6
|
+
declare const inject: string[];
|
|
7
|
+
declare function apply(ctx: Context): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { apply, inject, setupUsageClient };
|
|
10
|
+
//# sourceMappingURL=client-module.d.ts.map
|