deepseek-harness
deepseek-ai
DeepSeek Harness: Everything is a Plugin.
PROJECT TOPICS
PROJECT README
DeepSeek Harness 的树外(out-of-tree)双面插件:在 右下角 显示 DeepSeek API 账户余额。
lib/index.js):读取 DEEPSEEK_API_KEY,调 GET https://api.deepseek.com/user/balance,缓存结果;一方面 ctx.emit("balance/updated", …) 推给所有客户端,另一方面注册只读的 /status-balance 拉取端点。lib/client.js):往 frame 级 shell.overlay 槽注册一个小角标;挂载时先 fetch("/status-balance") 秒出首屏,再订阅 balance/updated 实时刷新。Bearer 密钥,浏览器绝不能碰。host 半身零 import(credentialRef 运行时是恒等函数,直接用字符串 "DEEPSEEK_API_KEY")。ctx.emit("balance/updated") → dsh-host-apiproxy 转发循环 → 客户端 ctx.remote.$on,需第 1 步的 allowlist);首屏秒出走只读 HTTP 端点 /status-balance(host 用 ctx.webServer.register 注册,client 挂载时 fetch 一次)。shell.overlay 槽:dsh-client-ui-layout 把它渲染进一个 position:absolute; inset:0; z-index:20 的浮层,角标用绝对定位钉在 right:16px; bottom:16px。balance/updated 加进转发 allowlist编辑 @deepseek-ai/dsh-api-remotes/lib/index.js,在 API_REMOTE_FORWARDED_EVENTS 数组里加一行:
const API_REMOTE_FORWARDED_EVENTS = [
"agent-preset/selected",
// ...
"settings/document-updated",
"balance/updated" // ← 新增
];
该文件位于(本机):
/Users/wuhai/.nvm/versions/node/v22.19.0/lib/node_modules/@deepseek-ai/dsh/node_modules/@deepseek-ai/dsh-api-remotes/lib/index.js
注:这是对第一方包的单点改动,重装 DSH 会被覆盖;客户端
$on无运行时 allowlist 校验,所以只改这一处 host 文件即可。
dsh plugin --profile web add "file:/Users/wuhai/Desktop/untitled folder/dsh-status-balance"
(等价于在 ~/.dsh/profiles/web 里 pnpm add file:...。)
~/.dsh/profiles/web/cordis.patch.yml把 [] 替换为:
- insert:
- id: status-balance
name: 'dsh-status-balance'
单行 name 决定 host 行;包内的 dsh.client 字段同时把它登记进浏览器 roster。
dsh web # 或 dsh --profile web
打开 http://127.0.0.1:3080 刷新,右下角应出现「余额 ¥98.22」(数字按你的账户)。未配置 key 时显示「未配置 API Key」,网络失败显示「获取失败」。
node scripts/test-balance.mjs
只打印余额 JSON,不打印密钥。
改 lib/index.js 顶部的常量:
POLL_INTERVAL_MS:轮询间隔(默认 30s)API_KEY_REF:凭证引用名(默认 DEEPSEEK_API_KEY)改 lib/client.js 顶部的常量:
LOW_BALANCE_THRESHOLD:低余额提醒阈值(默认 10,单位同币种)LOW_BALANCE_CURRENCY:按哪个币种判断(默认 "CNY")当对应币种的 total_balance 低于阈值时,角标变为琥珀色并脉冲闪烁,显示「⚠ 余额不足 ¥xx」;首次跌破阈值时还会在页面顶部弹一条一次性提示。鼠标悬停角标显示「余额低于 ¥10,请及时充值」。
密钥存在 ~/.dsh/.credentials.yaml,或走 DEEPSEEK_API_KEY 环境变量(dsh-credentials-local 会继承环境)。
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。