kyya/dsh-deepseek-balance

插件Plugin 原生Native ⭐ 2 MIT

DeepSeek Harness 插件:在侧边栏实时显示 DeepSeek API 余额

项目介绍Project Overview

这是一个 DSH 插件,在 Web 侧边栏底部实时显示 DeepSeek API 账户余额。Node 侧定时拉取并缓存余额,浏览器每 30 秒轮询,点击可强制刷新;状态点用颜色区分可用、不可用、失败、加载中,悬停展示总额、赠送、充值与更新时间,API key 仅在服务端解析。适合需要随时查看余额的场景;安装或变更插件后须重启 dsh web 才生效。

This is a DSH plugin that shows the DeepSeek API account balance in real time at the bottom of the web sidebar. The Node side fetches and caches the balance periodically; the browser polls every 30 seconds, and clicking the indicator forces a refresh. Colored status dots show available, unavailable, failed, or loading states, while hover details include total, granted, topped-up balance, and update time. The API key is resolved only server-side. Restart dsh web after installing or changing the plugin.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add github:kyya/dsh-deepseek-balance

kyya/dsh-deepseek-balance 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-deepseek-balance

一个 DeepSeek Harness(dsh)插件:在 Web 侧边栏底部(设置按钮上方)实时展示 DeepSeek API 账户余额。余额数据由 Node 侧定时拉取,浏览器侧每 30s 轮询一次, 点击指示器可立即强制刷新。

  • 状态点颜色:绿 = 可用;黄 = 账户不可用;红 = 拉取失败;蓝 = 加载中。
  • 悬停显示完整明细(总额 / 赠送 / 充值 / 更新时间)。
  • API key 每次拉取时经 credentials 服务解析,永远不会下发给浏览器

安装

# 把插件装进 web profile(本地目录方式)
dsh plugin --profile web add /绝对路径/dsh-deepseek-balance

# 或从 git 安装
dsh plugin --profile web add github:kyya/dsh-deepseek-balance

然后重启 dsh webdsh plugin 只会装依赖,插件集变更要重启才生效):

dsh web

打开 http://127.0.0.1:3080,侧边栏左下角即可看到余额指示器。

配置

默认读取凭据 DEEPSEEK_API_KEY(即 ~/.dsh/.credentials.yaml 里、或 DEEPSEEK_API_KEY=… 环境变量、或「设置 → 模型」里保存的那个 key)。 在 ~/.dsh/profiles/web/cordis.patch.yml 里覆盖(覆盖整行 config,需写全字段):

- id: deepseek-balance
  config:
    refreshMs: 60000                 # 后台刷新间隔(毫秒)
    apiKeyEnv: DEEPSEEK_API_KEY      # 凭据引用名
    baseUrl: https://api.deepseek.com
    endpoint: /user/balance

工作原理

半边 文件 职责
host(Node) index.js 定时 GET <baseUrl><endpoint>(Bearer 鉴权),缓存快照;用 webServer.register 暴露 /deepseek-balance
browser client.js sidebar.footer.action 插槽注册 React 指示器;轮询 /deepseek-balance,点击带 ?refresh=1 强制刷新。

余额接口返回形如:

{ "is_available": true, "balance_infos": [{ "currency": "CNY", "total_balance": "123.45", "granted_balance": "0.00", "topped_up_balance": "123.45" }] }

卸载

dsh plugin --profile web remove dsh-deepseek-balance
上一个 Prev dsh-github-reviewer 下一个 Next dsh-artifact-preview