前言¶
DSH 的理念是「一切皆插件」,社區插件可以擴展 dsh web surface 的頁面能力。對於同時配置多個 provider 的智能體開發者來說,餘額、用量窗口分散在不同 provider 接口中,頁面裏缺少一個統一查看的位置,同時也不宜讓 API key 直接進入瀏覽器。
dsh-quota-panel 針對這個問題:它在 dsh web surface 右下角注入一個狀態組件,並在服務端代理 provider 的 quota / balance 請求。
這是什麼¶
dsh-quota-panel 由 brittanistrehlowll-oss 維護,採用 MIT 許可。它是一個 zero-dependency host plugin,面向 dsh web surface:爲每個配置的 provider 註冊一條服務端代理路由 /api/quota/<id>,並在頁面右下角注入一個 Harness-native 狀態組件。
該組件有兩種形態:
- 摺疊 capsule:默認顯示狀態點和數值,適合快速查看。
- 展開 card:顯示完整 provider 狀態信息。
核心能力¶
dsh-quota-panel 提供以下已覈實能力:
- 爲每個配置的 provider 註冊服務端代理路由
/api/quota/<id>。 - API key 通過 credentials seam 在服務端解析,不進入瀏覽器。
- 瀏覽器只訪問
/api/quota/<id>,由服務端繼續請求 provider。 - 在頁面右下角注入 Harness-native 狀態組件,包含 collapsed capsule 和 expanded card。
- 支持
deepseek-balance和opencode-usage兩類格式。 - 使用 battery-colored status dots 和 values,依據餘額或用量閾值顯示狀態。
- 自動刷新;頁面隱藏時暫停刷新。
- 手動刷新按鈕在刷新期間會旋轉,並忽略重入點擊。
- 跟隨 Harness design tokens,適配 light/dark theme。
安裝與啓用¶
先使用插件安裝命令把 dsh-quota-panel 添加到 web profile:
dsh plugin --profile web add "github:brittanistrehlowll-oss/dsh-quota-panel"
該包聲明瞭 dsh.bundle.patch,因此 dsh plugin add 會把它作爲 profile layer 自動激活。
如果 dsh web 正在運行,重啓它。bundle layers 在啓動時生效。
典型配置¶
在 profile 的 cordis.patch.yml 中,將 provider 配置放在 providers 下。下面是一個示例,同時配置 DeepSeek balance 和 OpenCode Go usage:
- id: quota-panel
config:
refreshMs: 30000
providers:
- id: deepseek
label: DeepSeek
credential: DEEPSEEK_API_KEY
endpoint: https://api.deepseek.com/user/balance
format: deepseek-balance
balanceTiers: {10, 20, 50}
- id: opencode-go
label: OpenCode Go
credential: OPENCODE_GO_API_KEY
endpoint: https://opencode.ai/zen/go/v1/usage
format: opencode-usage
示例中的 refreshMs: 30000 是覆蓋默認值。資料給出的默認值如下:
refreshMs:60000balanceTiers:{10, 20, 50}windowLabels:{滾, 周, 月}warnPercent:70errorPercent:90
常用配置項包括:
id:對應路由/api/quota/<id>。label:卡片上顯示的 provider 名稱。credential:credential reference。endpoint:provider 的 quota / balance / usage 地址。format:行渲染器,支持deepseek-balance和opencode-usage。balanceTiers:餘額閾值。windowLabels:usage 窗口標籤。warnPercent/errorPercent:usage 閾值。refreshMs:自動刷新間隔。
安全與使用注意¶
使用這個插件時,需要關注以下幾點:
- 插件以當前
dsh進程權限運行。安裝前建議檢查源碼、依賴範圍和 MIT 許可證。 - API key 在服務端通過
ctx.credentials解析,只用於服務端到 provider 的請求。 - 瀏覽器只與
/api/quota/<id>通信,不直接持有或發送 provider API key。 - 注入卡片使用
createElement/textContent構建 DOM;API response values 不經過innerHTML。 - 401、timeout、credential missing 等技術錯誤會放進
titlehover 文本,而不是直接顯示在卡片主體中。
結尾¶
dsh-quota-panel 的價值在於把 provider 的 quota / balance / usage 狀態放進 dsh web surface,同時讓 API key 留在服務端。它適合需要同時查看多個 provider 餘額或用量狀態,並且希望頁面刷新邏輯跟隨 Harness 主題的場景。
- GitHub:
https://github.com/brittanistrehlowll-oss/dsh-quota-panel - 插件目錄線索:
https://www.skillhub.cn/plugins/brittanistrehlowll-oss/dsh-quota-panel(來自插件線索,未出現在已抓取資料中)
社區目錄是獨立站點,與 DeepSeek / 幻方無官方從屬關係。