Rainronin/dsh-balance-monitor ↗★ 2

@rainronin/dsh-balance-monitor

实时监测 DeepSeek API 余额与单会话费用 适合需要实时监控 API 余额、估算单次会话费用并掌握峰谷计价状态的用户。

套件
@rainronin/dsh-balance-monitor
相容性
待驗證
Harness 依賴範圍
^0.1.2-alpha.1
Cordis 依賴範圍
^4.0.1
版本
0.3.0
授權
MIT
最近更新
2026年8月31日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Rainronin/dsh-balance-monitor

Usage

In-session query — just ask the agent:

查一下 DeepSeek 余额 / check my DeepSeek balance

Sidebar badge — at the sidebar footer next to Settings: 刷新 force-refreshes past the cache; polling follows the host-configured interval (30s by default); the collapsed (rail) state shows a single status lamp (green = 连接正常, amber = degraded). The badge follows the dsh native theme. When a conversation is selected, the badge also shows 本会话 ¥xx.xx — the estimated cumulative cost of that conversation, calculated from official DeepSeek V4 peak/off-peak pricing; switching conversations switches the cost automatically.

Configuration

KeyDefaultMeaning
apiKeyEnvDEEPSEEK_API_KEYCredential reference (env var name); change for a different account
cacheTtlMs30000Cache lifetime in ms
pollIntervalMs30000Background polling interval in ms
injectEveryTurnfalseWhether to inject the balance into context every turn (opt-in; the badge and ds_balance tool are on by default)
requestTimeoutMs5000Official-API request timeout in ms

Override in the profile's cordis.patch.yml:

- id: balance-monitor
  config:
    cacheTtlMs: 10000
    pollIntervalMs: 10000

使用

会话内查询——直接让 agent 查:

帮我查一下 DeepSeek 余额

侧边栏徽章——侧边栏底部(Settings 旁):刷新 按钮穿透缓存立即刷新; 轮询间隔跟随 host 配置(默认 30s);折叠态(rail)显示单色状态灯(绿 = 连接正常, 琥珀 = 异常)。徽章跟随 dsh 原生主题。选中某个会话时,徽章还会显示 本会话 ¥xx.xx—— 按 DeepSeek 官方 V4 峰谷价格估算的当前会话累计费用;切换会话时会自动跟随当前会话。

配置

键默认值说明
apiKeyEnvDEEPSEEK_API_KEY凭证引用名(环境变量名),多账号时改这里
cacheTtlMs30000缓存有效期(毫秒)
pollIntervalMs30000后台轮询间隔(毫秒)
injectEveryTurnfalse是否每轮注入余额到模型上下文(默认关闭,按需开启)
requestTimeoutMs5000官方接口请求超时(毫秒)

覆盖示例(profile 的 cordis.patch.yml):

- id: balance-monitor
  config:
    cacheTtlMs: 10000
    pollIntervalMs: 10000