dsh-webui-perf
awa-123-cw
DeepSeek Harness WebUI 性能优化开关插件:长代码流式渲染/历史加载/高亮缓存优化,设置面板一键开关(with official-package patches)
YZz-S/dsh-token-cost-meter
Community plugins for DeepSeek Harness (DSH) Web GUI: session token cost meter with official dynamic pricing, DeepSeek & Volcengine billing balance, and update checker. Plain JavaScript, no build required.
PROJECT TOPICS
PROJECT README
DeepSeek Harness (DSH) plugin that shows the current session's cumulative token consumption and estimated cost (CNY) in real time in the stats line below the input box, with prices fetched dynamically from the official DeepSeek pricing page.
DeepSeek Harness(DSH)插件:在 Web GUI 输入框下方的统计行中实时显示当前会话累计 token 消耗与估算费用(人民币),价格从 DeepSeek 官方价格页动态获取。
Supports two forms: an installable dsh.bundle package (recommended, persists across DSH restarts) and the dynamic cordis_define usage (temporary run).
中文 · ← Back to DeepSeekHarnessPlugins
A new stats line appears below the input box (right of the built-in stats line):
Cost ¥0.13 · 43.2K tokens
Hovering shows the breakdown: pricing model, input (cache-miss / cache-hit buckets), output, pricing mode (current / peak-hour / off-peak-hour), price source and fetch time.
tokenUsage (provider-reported cumulative usage: cache-miss input / cache-hit input / output — same source as DSH's built-in stats line)≈ and noting the reason in the hover tooltipprovenance → requestConfig → Host agents.options.model; if all fail, displays a price range computed per model| File | Description |
|---|---|
index.js |
Installed Host half: fetches/parses the official pricing page; /api/token-cost-meter/* routes (pricing / model) |
lib/client.js |
Installed Client half: UI below the input box, cost calculation |
cordis.patch.yml |
Bundle patch: inserts this plugin's row into the DSH composition |
host.js |
Dynamic Host half (cordis_define code.host), functionally equivalent to the installed form |
client.js |
Dynamic Client half (code.client) |
README.md / SECURITY.md / CHANGELOG.md / LICENSE |
Docs & license |
This repo is also an installable dsh plugin package (package.json declares dsh.bundle + dsh.client):
dsh plugin --profile web add github:YZz-S/dsh-token-cost-meter
After installation, restart DSH and the cost stats line below the input box takes effect automatically. The dynamic usage (cordis_define loading host.js / client.js) is kept; pick either one.
cordis_define, submitting host.js full text as code.host and client.js full text as code.client;cordis_run the returned pluginId / packageId;A dynamic plugin lives as long as the current DSH process: after a DSH restart you must define + run it again.
That's the "Installation (dsh.bundle)" section above — after dsh plugin add it loads automatically at DSH startup.
┌────────────────────────── Client (browser) ──────────────────────────┐
│ conversation.composer.dock (stats line below input box) │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ CostLine component │ │
│ │ · useProjection('tokenUsage') ← session cumulative real usage │ │
│ │ · GET /api/token-cost-meter/pricing ← official prices (TTL 6h + │ │
│ │ snapshot fallback) │ │
│ │ · GET /api/token-cost-meter/model ← session model (Host side) │ │
│ │ cost = miss input × miss price + cache-hit × hit price + │ │
│ │ output × output price │ │
│ └──────────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
│ fetch (same-origin HTTP)
┌──────────────────────── Host (DSH Node process) ──────────────────────┐
│ webServer routes: pricing (native fetch → parse both price tables) │
│ model (agents.get(sessionId).options.model) │
└───────────────────────────────────────────────────────────────────────┘
Cost (CNY) = cache-miss input × miss price + cache-hit input × hit price + output × output price
fetch (Node ≥ 18)host.js): the price-fetching command is PowerShell syntax and works out of the box on Windows; on Linux/macOS replace NODE_FETCH in host.js with the corresponding shell syntaxThe DSH dynamic plugin sandbox disables fetch / require, and the Web deployment by default does not mount the fetch provider of ctx.web (anti-SSRF); also, the Windows sandbox executor corrupts curl/PowerShell schannel TLS credentials. The dynamic form therefore calls node.exe via ctx.shell (OpenSSL TLS, unaffected by schannel) to fetch the single hard-coded official URL — the command string concatenates no external input, leaving no command-injection surface. The installed form uses the host process's native fetch and is not subject to this restriction.
English · ← 返回 DeepSeekHarnessPlugins
DeepSeek Harness(DSH)插件:在 Web GUI 输入框下方的统计行中实时显示当前会话累计 token 消耗与估算费用(人民币),价格从 DeepSeek 官方价格页动态获取。
支持两种形态:可安装的 dsh.bundle 包(推荐,随 DSH 启动常驻)与动态 cordis_define 用法(临时运行)。
输入框下方(自带 stats 行右侧)新增一行读数:
费用 ¥0.13 · 43.2K tokens
鼠标悬停显示明细:计价模型、输入(缓存未命中/命中分桶)、输出、计价模式(现行价 / 高峰时段价 / 空闲时段价)、价格来源与抓取时间。
tokenUsage(服务商上报的累计用量:未命中输入 / 缓存命中 / 输出,与 DSH 自带统计行同源)≈ 并在悬停提示中标注原因provenance → requestConfig → Host agents.options.model;全部失败时显示按各模型分别计算的价格区间| 文件 | 说明 |
|---|---|
index.js |
安装版 Host 半边:抓取/解析官方价格页,/api/token-cost-meter/* 路由(pricing / model) |
lib/client.js |
安装版 Client 半边:输入框下方 UI、费用计算 |
cordis.patch.yml |
bundle 补丁:向 DSH 组合插入本插件行 |
host.js |
动态版 Host 半边(cordis_define 的 code.host),与安装版功能等价 |
client.js |
动态版 Client 半边(code.client) |
README.md / SECURITY.md / CHANGELOG.md / LICENSE |
文档与许可 |
本仓库同时是可安装的 dsh 插件包(package.json 声明 dsh.bundle + dsh.client):
dsh plugin --profile web add github:YZz-S/dsh-token-cost-meter
安装后重启 DSH,输入框下方的费用读数自动生效。
动态用法(cordis_define 加载 host.js / client.js)仍保留,两种方式二选一。
cordis_define,将 host.js 全文作为 code.host、client.js 全文作为 code.client 提交;cordis_run 运行返回的 pluginId / packageId;动态插件的生命周期与当前 DSH 进程相同:重启 DSH 后需重新 define + run。
即上方「安装(dsh.bundle)」一节,dsh plugin add 后随 DSH 启动自动加载。
┌─────────────────────────── Client(浏览器) ───────────────────────────┐
│ conversation.composer.dock(输入框下方统计行) │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ CostLine 组件 │ │
│ │ · useProjection('tokenUsage') ← 会话累计真实用量(实时更新) │ │
│ │ · GET /api/token-cost-meter/pricing ← 官方价格(TTL 6h + 快照兜底)│ │
│ │ · GET /api/token-cost-meter/model ← 会话模型(Host 侧来源) │ │
│ │ 费用 = 未命中输入×未命中价 + 缓存命中×命中价 + 输出×输出价 │ │
│ └───────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
│ fetch(同源 HTTP)
┌───────────────────────── Host(DSH Node 进程) ─────────────────────────┐
│ webServer 路由: pricing(原生 fetch 抓官方页 → 解析两套价表) │
│ model(agents.get(sessionId).options.model) │
└─────────────────────────────────────────────────────────────────────────┘
费用(人民币)= 缓存未命中输入 × 未命中价 + 缓存命中 × 命中价 + 输出 × 输出价
fetch(Node ≥ 18)host.js)的价格抓取命令为 PowerShell 语法,Windows 开箱即用;Linux/macOS 需替换 host.js 中 NODE_FETCH 为对应 shell 语法DSH 动态插件沙盒禁用了 fetch / require,且 Web 部署默认不挂载 ctx.web 的 fetch provider(防 SSRF);同时 Windows 沙盒执行器会破坏 curl / PowerShell 的 schannel TLS 凭据。因此动态版经 ctx.shell 调用 node.exe(OpenSSL TLS,不受 schannel 影响)抓取唯一的硬编码官方 URL,命令字符串无任何外部输入拼接,无命令注入面。安装版宿主进程自带原生 fetch,不受此限制。
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。