BigFatFish4Wm/dsh-token-cost ↗★ 0
dsh-token-cost
Per-turn token usage, cost, session totals, and account balance for the Harness Web UI, with a workspace-local ledger. 适合需要精确统计每回合 Token 消耗、峰谷花费及账单明细的 Web/桌面用户。
같은 패키지 이름의 다른 저장소
설치
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:BigFatFish4Wm/dsh-token-cost配置
在 profile 的 cordis.patch.yml 中覆盖 token-cost 行,或在插件配置页中编辑。所有字段都有默认值。
- id: token-cost
name: 'dsh-token-cost'
config:
enabled: true
currency: CNY
currencySymbol: '¥'
pricing:
inputPerMillion: 1
outputPerMillion: 4
cacheReadPerMillion: 0.02
cacheWritePerMillion: 1
peak:
inputPerMillion: 2
outputPerMillion: 8
cacheReadPerMillion: 0.04
cacheWritePerMillion: 2
offPeak:
inputPerMillion: 1
outputPerMillion: 4
cacheReadPerMillion: 0.02
cacheWritePerMillion: 1
pricingSchedule:
enabled: true
timeZone: Asia/Shanghai
peakWindows:
- { start: '09:00', end: '12:00' }
- { start: '14:00', end: '18:00' }
weekdays: [1, 2, 3, 4, 5]
holidays: []
modelPricing:
deepseek-account/deepseek-v4-pro:
inputPerMillion: 4.5
outputPerMillion: 13.5
cacheReadPerMillion: 0.15
cacheWritePerMillion: 4.5
peak:
inputPerMillion: 9
outputPerMillion: 27
cacheReadPerMillion: 0.3
cacheWritePerMillion: 9
'openai/*':
inputPerMillion: 2.5
outputPerMillion: 10
display:
showInput: true
showOutput: true
showCache: true
showCost: true
showSessionCost: true
showBalance: true
showDetails: true
compact: false
decimals: 4
balance:
mode: auto
refreshSeconds: 60
timeoutMs: 5000
locale: zh
budgetInitial: 100
manualAmount: null
showBonus: true
storage:
enabled: true
dir: .dsh-token-cost
file: ledger.json
backfill: true
includeSubagents: true
字段说明
| 字段 | 默认 | 说明 |
|---|---|---|
enabled | true | 总开关;关闭后不注册投影、路由和账本。 |
currency | CNY | 费用与预算使用的币种;账户余额钱包保留自己的币种。 |
currencySymbol | 空 | 自定义符号;空值按币种推导(CNY/JPY ¥、USD $ 等)。 |
pricing.inputPerMillion | 1 | 空闲时段未缓存输入,每百万 tokens 单价。 |
pricing.outputPerMillion | 4 | 空闲时段输出(含推理)每百万 tokens 单价。 |
pricing.cacheReadPerMillion | 0.02 | 空闲时段缓存命中读取每百万 tokens 单价。 |
pricing.cacheWritePerMillion | 1 | 空闲时段缓存写入每百万 tokens 单价(DeepSeek 未单列写入价时按未命中输入价)。 |
pricing.peak | 见上 | 高峰时段单价表;字段同平级四项,未填字段继承 pricing 平级值。 |
pricing.offPeak | 见上 | 空闲时段单价表;字段同平级四项。 |
pricingSchedule.enabled | true | 是否按时间窗口选择 peak/offPeak。关闭后只使用 pricing 平级值。 |
pricingSchedule.timeZone | Asia/Shanghai | 高峰窗口所在 IANA 时区。 |
pricingSchedule.peakWindows | 09:00–12:00、14:00–18:00 | 高峰窗口,含起点不含终点。 |
pricingSchedule.weekdays | [1,2,3,4,5] | 可能为高峰的 ISO 星期(1=周一,7=周日)。 |
pricingSchedule.holidays | [] | YYYY-MM-DD 节假日,全日按空闲价。 |
modelPricing | {} | 按键覆盖单价。匹配顺序:provider/model → provider::model → provider/* → model → * → 默认。每项可含平级字段、peak、offPeak;未提供的子字段继承该模型的平级值。 |
display.showInput | true | 明细中显示未缓存输入。 |
display.showOutput | true | 明细中显示输出。 |
display.showCache | true | 明细中显示缓存读取/写入。 |
display.showCost | true | 收起状态显示费用。 |
display.showSessionCost | true | 收起状态显示会话累计。 |
display.showBalance | true | 收起状态显示余额。 |
display.showDetails | true | 允许展开明细。 |
display.compact | false | 使用更紧凑的间距。 |
display.decimals | 4 | 费用小数位(0–8)。 |
balance.mode | auto | auto / account / budget / manual / off。 |
balance.refreshSeconds | 60 | 账户余额缓存时间;0 表示每次请求都重新读取。前端最短 15 秒刷新。 |
balance.timeoutMs | 5000 | 单次账户余额读取超时。 |
balance.locale | zh | 传给账户 API 的语言元数据。 |
balance.budgetInitial | 空 | 预算模式初始值;auto 下作为账户不可用时的回退。 |
balance.manualAmount | 空 | 手动余额;auto 下作为最后回退。 |
balance.showBonus | true | 是否显示赠送钱包。 |
storage.enabled | true | 是否写工作区账本。 |
storage.dir | .dsh-token-cost | 工作区相对目录。 |
storage.file | ledger.json | 账本文件名(只取 basename)。 |
storage.backfill | true | 插件激活时回填当前存活会话的已完成轮次。 |
storage.includeSubagents | true | 是否把子代理会话写入账本。子代理仍会显示自己的用量条。 |
pricing.peak/pricing.offPeak是可选对象。省略整个 profile 时:若平级单价仍是默认值,peak 使用官方高峰价、offPeak 使用官方空闲价;若平级单价已自定义,则二者继承平级值。显式字段优先。这样自定义固定单价时不会意外套用 DeepSeek 高峰价。
修改
cordis.patch.yml后由 Loader 热重载;如果浏览器没有立即更新,刷新页面即可。修改客户端 UI 代码需要重启 Host 或重新加载插件。