dsh-web-search-ddg
aooyoo
Zero-token DuckDuckGo search provider for the DeepSeek Harness (DSH) web seam — local headless browser, no API key, no m…
PROJECT TOPICS
PROJECT README
English | 中文
DeepSeek Harness(DSH)插件:展示 DeepSeek 账户余额、当前会话预估消耗、历史对话明细(每个对话的 token 与金额),并根据历史会话的平均消耗,估算各模型剩余对话次数。
GET /user/balance 接口,展示总余额 / 充值余额 / 赠送余额(CNY 或 USD)。剩余次数 = ⌊余额 ÷ 单次会话平均消耗⌋,同时展示会话数、平均消耗、累计消耗与 token 明细。conversation.composer.dock,order 10):当前会话预估消耗、当前余额、预估还能对话几轮,随对话每 4 秒自动刷新。settings.section):余额卡片 + 对话明细表 + 各模型剩余对话次数。插件必须能被 Cordis Loader 从 profile 目录按名称解析。默认 Windows 路径:
$DSH_HOME):C:\Users\<you>\.dshC:\Users\<you>\.dsh\profiles\desktop\$DSH_HOME\profiles\desktop\node_modules(pnpm 管理)+ 扁平回退 $DSH_HOME\profiles\node_modulesdsh plugin add 一键安装本包声明了 dsh.bundle.patch(即 cordis.patch.yml),dsh plugin add 会 pnpm add
并把它自动追加进 profile 的 dsh.profile.bundles,从而完成「安装 + 组合」两步:
dsh plugin --profile desktop add dsh-usage-dashboard
然后重启 DSH Desktop。可用 dsh --profile desktop --dump-config 确认 usage-dashboard 条目已生效。
把本包安装进 profile 的 node_modules:
cd "$DSH_HOME/profiles/desktop"
pnpm add <本包路径或包名>
编辑 $DSH_HOME\profiles\desktop\cordis.patch.yml,在顶层插入一行(不要编辑 desktop 根目录的 cordis.yml,它每次启动都会被重写为 []):
- insert:
- id: usage-dashboard
name: dsh-usage-dashboard
config:
currency: CNY
pricing:
- effective: 2026-07-24T00:00:00Z
models:
- model: deepseek-v4-flash
inputPerM: 1
cacheReadPerM: 0.02
outputPerM: 2
- model: deepseek-v4-pro
inputPerM: 3
cacheReadPerM: 0.025
outputPerM: 6
- effective: 2026-08-16T16:00:00Z
models:
- model: deepseek-v4-flash
inputPerM: 1.5
cacheReadPerM: 0.05
outputPerM: 4.5
peak:
inputPerM: 3
cacheReadPerM: 0.1
outputPerM: 9
offPeak:
inputPerM: 1.5
cacheReadPerM: 0.05
outputPerM: 4.5
- model: deepseek-v4-pro
inputPerM: 4.5
cacheReadPerM: 0.15
outputPerM: 13.5
peak:
inputPerM: 9
cacheReadPerM: 0.3
outputPerM: 27
offPeak:
inputPerM: 4.5
cacheReadPerM: 0.15
outputPerM: 13.5
重启 DSH Desktop。
| 键 | 类型 | 默认 | 说明 |
|---|---|---|---|
apiKeyEnv |
credential-ref | DEEPSEEK_API_KEY |
API Key 凭证引用名 |
baseURL |
string | https://api.deepseek.com |
DeepSeek API 根地址 |
currency |
CNY | USD |
CNY |
计价与余额展示货币(必须与 pricing 单位一致) |
balanceCacheMs |
number | 60000 |
余额缓存时长(毫秒) |
pricing |
array | 见下 | 价目历史(era 列表),每个 era 有生效时刻与各模型单价 |
pricing 为价目历史(按生效时间排序,成本按每个模型调用的事件发生时刻取当时生效的价目计算):
pricing:
- effective: 2026-07-24T00:00:00Z # era 生效时刻(ISO 8601 UTC)
models:
- model: deepseek-v4-flash
inputPerM: 1 # 平段价:输入(缓存未命中)
cacheReadPerM: 0.02 # 平段价:输入(缓存命中)
outputPerM: 2 # 平段价:输出
- effective: 2026-08-16T16:00:00Z # 官方 8.17 峰谷定价(北京 8/17 生效)
models:
- model: deepseek-v4-flash
inputPerM: 1.5
cacheReadPerM: 0.05
outputPerM: 4.5
peak: # 高峰时段单价(与 offPeak 同时存在才生效)
inputPerM: 3
cacheReadPerM: 0.1
outputPerM: 9
offPeak: # 谷段单价
inputPerM: 1.5
cacheReadPerM: 0.05
outputPerM: 4.5
model: "*" 条目(若有),否则按 0 计。effective 更新的 era 即可——旧会话自动按历史价核算,新会话按新价核算。effective/models)会被当作单个 era 处理。| 生效时间 | 模型 | 时段 | 输入(未命中) | 输入(命中) | 输出 |
|---|---|---|---|---|---|
| 2026-07-24(V4 上线) | deepseek-v4-flash |
平段 | ¥1 | ¥0.02 | ¥2 |
| 2026-07-24 | deepseek-v4-pro |
平段 | ¥3 | ¥0.025 | ¥6 |
| 2026-08-16T16:00Z(北京 8/17 起) | deepseek-v4-flash |
高峰 | ¥3 | ¥0.10 | ¥9 |
| 2026-08-16T16:00Z | deepseek-v4-flash |
谷段 | ¥1.5 | ¥0.05 | ¥4.5 |
| 2026-08-16T16:00Z | deepseek-v4-pro |
高峰 | ¥9 | ¥0.30 | ¥27 |
| 2026-08-16T16:00Z | deepseek-v4-pro |
谷段 | ¥4.5 | ¥0.15 | ¥13.5 |
高峰时段:UTC 01:00–04:00 与 06:00–10:00(北京时间 09:00–12:00 与 14:00–18:00);其余为谷段(价格为高峰一半)。
来源:https://api-docs.deepseek.com/zh-cn/quick_start/pricing/(英文:https://api-docs.deepseek.com/quick_start/pricing/)。注意:默认价是内置的、不会自动跟随官方后续调价——官方再次调整价格后,需追加一个新 era(或等插件发布新默认值),插件本身不会自动抓取官方页面。
assistant/message 事件的 provider usage 字段
(inputTokens = 缓存未命中输入、cacheReadTokens = 缓存命中输入、outputTokens = 输出,
与 DeepSeek 的 prompt_cache_miss_tokens / prompt_cache_hit_tokens / completion_tokens 一一对应)。(turn, step) 的多次 assistant/message(llm/retry 重试)只保留最后一次,
与 token-meter 的口径一致。cost = (inputTokens×inputPerM + cacheReadTokens×cacheReadPerM + outputTokens×outputPerM) / 1e6。ctx.sessionQuery(合并内存中的 live 会话与持久化的冷会话);
无该服务时退化为仅统计当前已加载进内存的会话。持久化会话的用量按会话 id 一次性缓存,
重启后自动重建。conversations 按会话创建时间倒序,仅包含有实际 token 消耗的会话(自动跳过空会话);其中除当前会话外的第一条即「最近一次对话」。⌊余额 ÷ 该模型单次会话平均消耗⌋;该模型无历史或平均消耗为 0 时显示 —。⌊余额 ÷(当前会话累计消耗 ÷ 当前会话轮数)⌋;当前会话尚无输出轮次时显示 —。total_balance 等为字符串,本插件在展示与计算时转成数字。lib/index.js):Cordis 插件 { name, inject, apply, Config }。核心是一个
TypertRemoteService 子类 UsageDashboardGateway,暴露 balance() 与 overview(sessionId?)
两个 SRC Remote 端点。SRC(source)模式由 dsh-api-gateway 的 TypertGatewayService 在运行时
从 @Remote 标记推导参数与端点,无需 Typert 编译器生成的 strict 描述符——因此本插件用
installRemote() 手动展开装饰器(plain-JS 环境无装饰器语法)。lib/client.js):window.__ModuleLoader__.load({ id, factory }) 形态,
通过 ctx.slots.inject(...) 在 settings.section 与 sidebar.footer.action 两个槽位注册
React 组件;数据经 ctx.connection.rpc.call('/api', 'usageDashboard/<method>', { args }) 获取。dsh-session-query 服务(DSH 默认组合已包含)。CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。