dsh-deepseek-pricing 0.0.0-stage → 0.1.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 -0
- package/README.md +94 -2
- package/client.js +1112 -0
- package/cordis.patch.yml +10 -0
- package/icon.svg +9 -0
- package/index.js +145 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +49 -4
- package/src/data.js +313 -0
- package/src/format.js +86 -0
- package/src/holidays.js +81 -0
- package/src/peak.js +141 -0
- package/src/pricing.js +241 -0
- package/src/snapshot.js +120 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-deepseek-pricing contributors
|
|
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,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-deepseek-pricing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DSH(DeepSeek Harness)插件:在输入框工具栏显示 DeepSeek API 当前是**高峰**还是**空闲**计费时段、距离下次切换还有多久,并在设置页同步官方各模型单价。
|
|
4
|
+
|
|
5
|
+
- 输入框工具栏徽章:`高峰 · 全价` / `空闲 · 半价` + 倒计时,点击展开今日时段与价格小卡片。
|
|
6
|
+
- 设置 →「DeepSeek 价格」:完整价格表(¥ / $ 可切换)、时段规则、节假日状态、数据来源、手动刷新。
|
|
7
|
+
- 可选 AI 工具 `deepseek_pricing`:让模型自己判断"现在贵不贵、要不要等到空闲时段"。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
dsh plugin --profile <profile名> add dsh-deepseek-pricing
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
或在 DSH 的 **插件(Plugins)→ 添加插件** 里输入包名 `dsh-deepseek-pricing`,装好后重启一次 DSH。
|
|
16
|
+
从源码目录安装则把包名换成该目录的绝对路径。
|
|
17
|
+
|
|
18
|
+
## 计费时段规则
|
|
19
|
+
|
|
20
|
+
来源:[DeepSeek 官方定价页](https://api-docs.deepseek.com/zh-cn/quick_start/pricing)(脚注 2)
|
|
21
|
+
|
|
22
|
+
- 高峰:**北京时间(UTC+8)周一至周五 09:00–12:00、14:00–18:00**,不含中国法定节假日。
|
|
23
|
+
- 空闲:其余全部时间,包括周末与中国法定节假日全天。
|
|
24
|
+
- 空闲价 = 高峰价的一半。
|
|
25
|
+
|
|
26
|
+
周末补班(调休上班日)不影响判定:规则本身已把周末定义为全天空闲。
|
|
27
|
+
|
|
28
|
+
## 价格与节假日数据
|
|
29
|
+
|
|
30
|
+
| 数据 | 来源 | 回退 |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| 模型价格(¥) | `https://api-docs.deepseek.com/zh-cn/quick_start/pricing.md` | 内置快照 → 上次成功值 |
|
|
33
|
+
| 模型价格($) | `https://api-docs.deepseek.com/quick_start/pricing.md` | 内置快照 → 上次成功值 |
|
|
34
|
+
| 法定节假日 | `https://timor.tech/api/holiday/year/{year}` | `holiday-cn`(GitHub)→ 内置 2026 快照 |
|
|
35
|
+
|
|
36
|
+
- 价格默认每 360 分钟自动刷新一次,也可在设置页手动刷新;抓取失败时界面会明确标注"离线快照"与数据时间。
|
|
37
|
+
- 节假日数据按当前年 + 次年的顺序获取;次年数据尚未发布时会提示"尚未发布,假期期间可能误判为高峰"。
|
|
38
|
+
- 解析采用"关键词识别 + 末尾金额"的双路匹配,并对"高峰价 = 2 × 空闲价"做校验;官方页面结构变化时宁可保留旧值,也不显示半解析结果。
|
|
39
|
+
|
|
40
|
+
## 配置
|
|
41
|
+
|
|
42
|
+
插件不导出 Config schema,配置直接写在 `cordis.patch.yml` 的行上(从源码目录、以 `link:` 方式安装时,裸 `@deepseek-ai/*` 依赖还会因为真实路径解析不到,所以保持无 schema 最稳):
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
- id: deepseek-pricing
|
|
46
|
+
name: dsh-deepseek-pricing
|
|
47
|
+
config:
|
|
48
|
+
tool: true # 是否注册 deepseek_pricing 工具(默认 false)
|
|
49
|
+
currency: CNY # 默认币种:CNY / USD(默认 CNY)
|
|
50
|
+
refreshMinutes: 360 # 价格自动刷新间隔,0 = 仅手动(默认 360)
|
|
51
|
+
holidayRefresh: true # 是否同步法定节假日(默认 true)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- `tool` 为 `true` 时,模型会多一个无参数的 `deepseek_pricing` 工具;关闭时模型侧零开销。
|
|
55
|
+
- 界面里的 ¥ / $ 切换只影响显示,保存在浏览器 localStorage。
|
|
56
|
+
|
|
57
|
+
## 实现结构
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
index.js Host 入口:两条 /api/deepseek-pricing/* 路由 + 可选工具
|
|
61
|
+
client.js 浏览器入口:工具栏徽章 + 弹出卡片 + 设置页
|
|
62
|
+
src/peak.js 纯函数:北京时间换算、高峰判定、下次切换
|
|
63
|
+
src/pricing.js 官方 Markdown 定价表解析与校验
|
|
64
|
+
src/holidays.js 节假日源 URL 与解析
|
|
65
|
+
src/data.js 缓存、抓取、回退、状态组装(可注入时钟与 fetch 测试)
|
|
66
|
+
src/snapshot.js 内置价格与 2026 节假日离线快照
|
|
67
|
+
src/format.js 工具结果的 Markdown 文本
|
|
68
|
+
test/ node 单元测试 + 手动联调脚本
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 手动检查
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
node test/peak.test.js
|
|
75
|
+
node test/pricing.test.js
|
|
76
|
+
node test/holidays.test.js
|
|
77
|
+
node test/format.test.js
|
|
78
|
+
node test/data.test.js
|
|
79
|
+
node test/live.mjs # 真实抓取官方页面与节假日源
|
|
80
|
+
node test/manual-apply.mjs # 不依赖 Cordis 跑通 apply + 工具输出
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 已知限制
|
|
84
|
+
|
|
85
|
+
- 启动顺序:Web 服务是在插件行开始激活之后才发布 `webServer` 服务的。Host 端用 `export const inject = ['webServer']` + `ctx.inject(['webServer'], …)` 等待并注册路由(与 `dsh-model-health`、`dsh-our-free-model` 同一模式),所以冷启动后路由会自动出现,不需要手动禁用/启用插件。
|
|
86
|
+
- 页面仍可能在路由注册前就发出第一次请求;客户端对失败做退避重试(1s/2s/4s…最多 30s),切回标签页也会重试,弹出卡片里还有「重试」按钮。
|
|
87
|
+
- DSH 的模型目录没有价格字段,本插件只能维护自己的价格表,不会改写模型配置。
|
|
88
|
+
- 不做会话花费估算(按请求时刻 × 用量计价),可作为二期。
|
|
89
|
+
- 官方页面改版导致解析失败时,价格停留在上次成功值或内置快照,界面会提示。
|
|
90
|
+
- 节假日以官方发布的法定节假日为准;次年安排通常要到年底才公布。
|
|
91
|
+
- 窗口弹出卡片使用固定定位;若宿主后续给输入框容器加上 `transform`/`contain` 导致裁剪,可改为 `conversation.composer.dock` 内的常驻条。
|
|
92
|
+
|
|
93
|
+
## 卸载
|
|
94
|
+
|
|
95
|
+
在「设置 → 插件」中移除 `dsh-deepseek-pricing`,或删除 `cordis.patch.yml` 中的 `deepseek-pricing` 行。
|