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/桌面用户。

패키지
dsh-token-cost
호환성
미검증
버전
1.0.0
라이선스
MIT
최근 업데이트
2026. 10. 26.

같은 패키지 이름의 다른 저장소

설치

$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

字段说明

字段默认说明
enabledtrue总开关;关闭后不注册投影、路由和账本。
currencyCNY费用与预算使用的币种;账户余额钱包保留自己的币种。
currencySymbol空自定义符号;空值按币种推导(CNY/JPY ¥、USD $ 等)。
pricing.inputPerMillion1空闲时段未缓存输入,每百万 tokens 单价。
pricing.outputPerMillion4空闲时段输出(含推理)每百万 tokens 单价。
pricing.cacheReadPerMillion0.02空闲时段缓存命中读取每百万 tokens 单价。
pricing.cacheWritePerMillion1空闲时段缓存写入每百万 tokens 单价(DeepSeek 未单列写入价时按未命中输入价)。
pricing.peak见上高峰时段单价表;字段同平级四项,未填字段继承 pricing 平级值。
pricing.offPeak见上空闲时段单价表;字段同平级四项。
pricingSchedule.enabledtrue是否按时间窗口选择 peak/offPeak。关闭后只使用 pricing 平级值。
pricingSchedule.timeZoneAsia/Shanghai高峰窗口所在 IANA 时区。
pricingSchedule.peakWindows09: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.showInputtrue明细中显示未缓存输入。
display.showOutputtrue明细中显示输出。
display.showCachetrue明细中显示缓存读取/写入。
display.showCosttrue收起状态显示费用。
display.showSessionCosttrue收起状态显示会话累计。
display.showBalancetrue收起状态显示余额。
display.showDetailstrue允许展开明细。
display.compactfalse使用更紧凑的间距。
display.decimals4费用小数位(0–8)。
balance.modeautoauto / account / budget / manual / off。
balance.refreshSeconds60账户余额缓存时间;0 表示每次请求都重新读取。前端最短 15 秒刷新。
balance.timeoutMs5000单次账户余额读取超时。
balance.localezh传给账户 API 的语言元数据。
balance.budgetInitial空预算模式初始值;auto 下作为账户不可用时的回退。
balance.manualAmount空手动余额;auto 下作为最后回退。
balance.showBonustrue是否显示赠送钱包。
storage.enabledtrue是否写工作区账本。
storage.dir.dsh-token-cost工作区相对目录。
storage.fileledger.json账本文件名(只取 basename)。
storage.backfilltrue插件激活时回填当前存活会话的已完成轮次。
storage.includeSubagentstrue是否把子代理会话写入账本。子代理仍会显示自己的用量条。

pricing.peak / pricing.offPeak 是可选对象。省略整个 profile 时:若平级单价仍是默认值,peak 使用官方高峰价、offPeak 使用官方空闲价;若平级单价已自定义,则二者继承平级值。显式字段优先。这样自定义固定单价时不会意外套用 DeepSeek 高峰价。

修改 cordis.patch.yml 后由 Loader 热重载;如果浏览器没有立即更新,刷新页面即可。修改客户端 UI 代码需要重启 Host 或重新加载插件。