summmmerz/dsh-spend-guard ↗★ 0

dsh-spend-guard

Rolling-window spend fuse for DeepSeek Harness: warns at 1 CNY and cancels the running turn at 2 CNY spent within the last 10 minutes. 适合需要严格控制API预算、防止智能体死循环导致高额扣费的用户。

Package
dsh-spend-guard
Compatibility
Unverified
Version
0.1.1
License
MIT
Last updated
Oct 5, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:summmmerz/dsh-spend-guard

配置

默认值可通过 profile 的 cordis.patch.yml 覆盖:

- id: dsh-spend-guard
  config:
    windowMs: 600000        # 滚动窗口(ms),默认 10 分钟
    warnYuan: 1             # 窗口内达到该金额(元) → 提醒
    stopYuan: 2             # 窗口内达到该金额(元) → 结束当前回合
    pollMs: 10000           # 账本轮询间隔(ms)
    field: cost             # cost(含订阅折算) | apiCost(纯 API 口径)
    exchangeRate: null      # 汇率覆盖;null = 用账本的 config.exchangeRate
    warnCooldownMs: 60000   # 两条提醒之间的最小间隔(ms)
    stopCooldownMs: 60000   # 两次熔断之间的最小间隔(ms);0 = 超限就一直熔断
    cancelScope: all        # all=结束所有在跑的 agent(含子代理) | root=只结束主会话
    toast: true             # 是否发 Windows 通知
    debug: false            # 每次轮询打印窗口金额
    ledgerPath: ""          # 账本路径;留空=自动定位

禁用整行:

- id: dsh-spend-guard
  disabled: true