Back to home

ArvenWang

dsh-plugin-quota

DeepSeek account quota (balance) and session token usage for the DeepSeek Harness web UI

Stars
0
Language
JavaScript
Created
Aug 16, 2026
Updated
Aug 16, 2026

Introduction

dsh-plugin-quota

DeepSeek 账户额度(余额)与 Token 用量,以独立插件形式接入 DeepSeek Harness 的 Web 界面。

Account quota (balance) and session token usage for the DeepSeek Harness web UI, as a standalone plugin.

功能 / Features

  • 账户额度 / Account quota:实时查询 DeepSeek 账户余额(总额度 / 赠送额度 / 充值额度,按币种),带可用性状态、错误提示与重试。
  • Token 用量 / Token usage:当前会话的累计消耗(未缓存输入 / 输出 / 缓存读取 / 缓存写入 / 合计)。

安装后在 设置 → 额度 分区查看(Settings → Quota)。

安装 / Install

dsh plugin --profile web add dsh-plugin-quota

安装完成后重启 dsh web(或重启桌面 App),在 设置 → 额度 中查看。

也可以直接从 GitHub 安装(等价,不经过 npm):

dsh plugin --profile web add github:ArvenWang/dsh-plugin-quota

开发期安装本地副本:dsh plugin --profile web add /path/to/dsh-plugin-quota

移除:

dsh plugin --profile web remove dsh-plugin-quota

工作原理 / How it works

  • 宿主侧(node half):在 harness 的 web server 上注册一个只读路由 GET /api/plugins/quota/balance。连接事实来自官方 DeepSeek 适配器使用的同一处配置——llm-deepseek settings 命名空间(模型页写入的 apiKeyEnv / baseURL)与凭据服务(credentials)或环境变量。凭据只在宿主进程内用于该次请求,不落盘、不经过浏览器。
  • 浏览器侧(browser half):注册一个 settings.section 分区。额度卡片同源请求上面的路由;用量卡片经框架 useSessions 钩子读取当前会话的 tokenUsage 投影值(与内置上下文计费器同一数据源)。
  • 插件通过 dsh.bundle 声明把自己作为一层组合补丁插入 profile;通过 dsh.client 声明进入 Web 浏览器 roster。

兼容性 / Compatibility

  • DeepSeek Harness >= 0.1.0-rc.5(Web profile)。
  • 需要可用的 DeepSeek API Key(DEEPSEEK_API_KEY 或经模型页配置)。未配置时分区会显示明确错误。
  • 自定义 OpenAI 兼容端点若没有 /user/balance 路由,会显示 HTTP 错误信息。

安全 / Security

路由只读、仅同源可访问(同一 loopback 页面本身已可访问整个 /api 网关,因此不引入新的信任面)。余额数据不会写入会话日志、设置或任何存储。

开发 / Development

本插件零构建:index.js(宿主侧)与 client.js(浏览器侧)均为可直接运行的 JS。

npm test   # 语法检查

许可证 / License

MIT