← Back to home@Dogtiti

dsh-plugin-usage-panel

Provider usage panel for DeepSeek Harness: shows the remaining share of each quota window (GLM Coding Plan today) as a chip beside the model selector, with a detail popover.

Stars
0
Language
JavaScript
Created
Oct 23, 2026
Updated
Oct 26, 2026

Introduction

dsh-plugin-usage-panel

给 DeepSeek Harness 加一个供应商套餐用量面板:在模型选择器右侧显示一枚小图标,悬停(或点击)展开当前套餐的窗口明细。

已接入两家:

套餐面板列
GLM Coding Plan(智谱 / Z.ai)5 小时 · 每周 · 工具调用
OpenCode Zen(Go)滚动窗口 · 每周 · 每月
  • 按会话实际使用的供应商显示:面板问 Host「这个会话在跑哪家」,Host 从会话自己的 model/selection 事件读 provider id,所以 newapi 之类的网关不会误显示
  • 平时不发任何请求:只有悬停/点击时才查一次(?refresh=1 绕过缓存),移开即关闭
  • API key 只在 Host 进程内使用,不下发到浏览器;上游结果按 refreshSeconds 缓存

安装

dsh plugin install dsh-plugin-usage-panel

或在 Plugins 页安装后重启。

配置

键默认说明
sourceautoauto / glm / opencode;auto 按当前 provider 判断
apiKeyEnvZAI_CODING_CN_API_KEY智谱 key 的凭据名
baseUrlhttps://api.z.ai智谱接口域名;BigModel 用 https://open.bigmodel.cn
opencodeApiKeyEnvOPENCODE_GO_API_KEYOpenCode key 的凭据名
opencodeBaseUrlhttps://opencode.ai/zen/go/v1OpenCode 接口域名
refreshSeconds20缓存时间(下限 10 秒)

两个 key 都只在 Host 进程内使用,不会下发到浏览器。只配一家也能用,另一家会显示「未配置 API Key」。

数据来源

与各家客户端自己用的接口一致:

# GLM Coding Plan
GET <base>/api/monitor/usage/quota/limit
authorization: <api key>

# OpenCode Zen (Go)
GET <opencodeBaseUrl>/usage
authorization: Bearer <api key>

OpenCode 返回的是三个窗口的使用百分比:

{"usage":{"rolling":{"percent":1,"resetsAt":"..."},"weekly":{"percent":0,...},"monthly":{"percent":0,...}}}

位置与可见性

  • 挂在 conversation.input.activity:输入框工具行里、模型选择器右侧紧邻。 (布局没有"模型左侧"的插槽:conversation.input.left 是最左边那一簇,而模型选择器本身是 single 槽,不能被扩展。)

  • 渲染前先问 Host 一次 ?probe=1(纯本地、不打上游),Host 用会话的 model/selection 事件得出 provider: 判断顺序:

    1. 模型控件上的 data-provider-id(选择器自己渲染的属性,就是用户眼前那个)→ 最优先
    2. 会话的 model/selection 事件(会话记录过选择时)
    3. 都没有 → 隐藏图标

    为什么不能只看模型名:deepseek-v4.1-flash 这类模型同时挂在多个供应商下,名字分不出归属。 为什么不能退到「profile 默认模型」:新会话在第一次选择被记录前没有事件,而默认模型未必是用户刚切换的那个——之前就因此把 GLM 会话显示成了 OpenCode。

显示内容

  • 触发图标:一个柱状小图标,不显示数字
  • 弹层:套餐徽标(GLM Coding Plan / OpenCode Go)+ 各窗口一列(名称、剩余百分比、重置日期、进度条)
  • 底部:本次读数时间

接口字段对照

面板GLMOpenCode
5 小时 / 滚动TOKENS_LIMIT + unit: 3usage.rolling.percent
每周TOKENS_LIMIT + unit: 6usage.weekly.percent
每月—usage.monthly.percent
工具调用TIME_LIMIT(usage 总额、currentValue 已用)—
套餐data.level—

两家返回的都是已用百分比,面板统一按 剩余 = 100 - 已用 显示。

相关插件

插件说明
dsh-plugin-composer-predict预测下一条指令并显示为占位文字,Tab 采纳
dsh-plugin-composer-history输入框中按 ↑ / ↓ 回填历史消息
dsh-plugin-subagent-bridge让 Codex 通过本机 MCP 把 DSH 当 subagent 用(spawn / wait / followup),反向也能把任务派给 Codex
dsh-plugin-usage-panel(本仓库)在模型选择器旁显示供应商套餐额度余量(GLM Coding Plan / OpenCode Go),点开是明细浮层
dsh-plugin-provider-icons在模型名旁显示供应商品牌 logo(24 个厂商,支持前缀匹配)