@goodandready/dsh-cost-meter
v0.8.8
Published
DeepSeek Harness plugin: a session cost chip in the conversation header - live token usage by bucket, peak/off-peak tariff, and a countdown to the next tariff switch.
Maintainers
Readme
📦 @goodandready/dsh-cost-meter
⚡ 概述与核心痛点
在使用智能体与大语言模型编程时,模型推理、长上下文以及缓存读写会产生大量 Token 消耗。如果缺乏实时的财务监控,开发者容易错过官方 50% 闲时折扣窗口,或因死循环导致账单超出预算。
@goodandready/dsh-cost-meter 在 DeepSeek Harness 会话顶部工具栏(conversation.session.header.utilities)无缝嵌入高精度花费微件芯片:
● ≈ ¥0.85 0:17 ← 会话顶部实时花费芯片与换价倒计时点击芯片可展开交互式详情面板:按每 1M Token 展示峰谷两档费率表格(高亮显示当前激活档位)、UTC 优惠时间段状态以及各模型在当前会话中的累计消费明细。
🏛️ 架构设计
graph TD
subgraph StreamTelemetry ["DSH 流式遥测运行时"]
Req["LLM 请求 / 报头<br/>(provider, model)"]
StreamHook["增量流式分片 Hook"]
Proj["costByModel 会话投影<br/>(半小时 UTC 时隙)"]
end
subgraph PricingCatalog ["费率解析引擎"]
Manual["自定义费率配置<br/>(settings.yaml: prices)"]
DeepSeekTier["DeepSeek 官方费率<br/>(高峰 / 闲时 50% 折扣)"]
OpenRouterTier["OpenRouter 公开目录<br/>(每日自动缓存)"]
end
subgraph UI ["用户交互界面"]
Chip["顶部花费芯片<br/>(实时计费 + 换价倒计时)"]
Modal["消费明细抽屉面板<br/>(1M 单价表, UTC 时段, 模型清单)"]
Settings["设置卡片<br/>(币种符号, 汇率, 时区)"]
end
Req --> Proj
StreamHook --> Proj
Proj --> Chip
PricingCatalog --> Proj
Manual --> PricingCatalog
DeepSeekTier --> PricingCatalog
OpenRouterTier --> PricingCatalog
Chip --> Modal✨ 核心特性
- 增量流式实时计算:在模型打字生成过程中毫秒级更新 Prompt、Completion 和 Cache 费用,无轮询无卡顿。
- 两级阶梯电价引擎:支持 DeepSeek 官方高峰时段(UTC 01:00–04:00 与 06:00–10:00)及闲时 50% 优惠折扣自动匹配。
- UTC 半小时时隙不可变性:历史消费严格锁定在消耗发生时刻的时隙费率,切换费率不溯及既往。
- 服务商智能路由:精准区分直连 DeepSeek 服务商与 OpenRouter 等代理网关。
- 多币种与本地化:支持自定义货币符号(
¥,$,€,₽)、汇率换算与显示时区。
📦 快速安装
dsh plugin --profile web add @goodandready/dsh-cost-meter重启 DeepSeek Harness 实例并刷新浏览器页面。
⚙️ 配置项说明 (settings.yaml)
dsh-cost-meter:
currency: "¥"
usdRate: 7.2
displayTimeZone: "Asia/Shanghai"
useOpenRouter: true
prices: {}
modelMap: {}配置参数列表
| 参数项 | 类型 | 默认值 | 说明 |
|:---|:---|:---|:---|
| currency | string | "¥" | 显示的货币符号或代码 |
| usdRate | number | 7.2 | 美元到目标货币的换算汇率 |
| displayTimeZone | string | "Asia/Shanghai" | 界面中优惠时间段显示的参考时区 |
| useOpenRouter | boolean | true | 是否加载 OpenRouter 价格表作为备用 |
| prices | object | {} | 自定义每 1M Token 的费率覆盖 |
| modelMap | object | {} | 模型别名映射表 |
🧪 自动化测试
运行单元测试套件:
npm test📄 许可证
MIT © GooDAnDReaDY
