wycto/dsh-token-usage 预览 preview

wycto/dsh-token-usage

Plugin插件 Native原生 ⭐ 4 MIT Usage & Cost用量与计费Data & Analysis数据与分析

基于DSH的Token用量统计,DSH的Token用量统计功能

Project Overview项目介绍

This is a native DSH plugin built specifically for tracking and analyzing LLM token usage and API costs within DeepSeek Harness. It can be installed via the DSH CLI by running dsh plugin add @wycto/dsh-token-usage, followed by a restart of DSH to activate the plugin. Once installed, a blue “Token Usage” button will appear at the bottom of the DSH sidebar, clicking it opens the full-screen statistics panel that displays all extracted call data from DSH’s local session logs. The plugin does not modify or intercept any API calls, it only reads existing local session logs to pull accurate token and cost data for analysis and export.

The panel supports a wide range of useful filtering options, including second-granularity time range queries, filtering by session ID, provider, model, call status, and reasoning effort level. All 15 columns in the detailed call table can be sorted by clicking the table header, and the default sort order is newest first, descending by timestamp. It shows cost in both USD and CNY, with CNY pricing based on official DeepSeek rates that are automatically pulled from their website daily, you can also manually override pricing or the USD-CNY exchange rate in your DSH settings file. It supports full CSV export of all filtered data matching your current search criteria. This tool is ideal for independent developers and teams that need to track monthly API spending and audit LLM usage patterns.

The plugin is released under the open-source MIT license, and it follows strict security practices to protect user API credentials. It never stores or displays plaintext API keys, only masks them for display, and all usage data is stored locally on your machine, never sent to any third-party external server. Estimated costs are based on current official model pricing, and unknown models use a default fallback price that you can manually override in your DSH configuration file at any time. There are a few small known limitations: failed calls without a complete assistant response will not have token data recorded, and when using an OCX gateway, usage fields may be missing leading to 0 token count display.

这是专为 DeepSeek Harness 开发的原生插件,用于记录和统计 DSH 中所有 LLM API 调用的 Token 用量与消耗成本。它不侵入模型调用链路,仅读取 DSH 本地会话日志提取信息,提供了全屏统计面板,支持秒级时间范围查询、多维度筛选、会话 ID 筛选、排序、调用详情查看、分组统计以及 CSV 导出功能。

安装后重启 DSH 即可使用,侧边栏底部会出现蓝色的“Token 用量”入口按钮,点击即可打开统计面板。面板默认展示所有历史调用记录,筛选条件会自动暂存在浏览器本地存储中,下次打开可恢复上次设置的筛选条件,也可点击一键重置清空所有筛选条件。它支持美元人民币双币显示金额,内置 DeepSeek 模型峰谷定价规则,可自动同步官网最新价格,用户可按需求筛选导出对应数据,方便进行成本对账和用量分析。

该插件采用 MIT 许可开源,安全上不会存储明文 API 密钥,仅展示掩码处理后的密钥信息。价格为估算值,内置常见模型单价表,未知模型使用默认兜底单价,用户也可在配置文件中手动覆盖定价和汇率。已知失败调用无 Token 记录,OCX 网关场景下可能缺失用量数据显示为 0。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

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

CLI Install命令行安装

dsh plugin --profile web add @wycto/dsh-token-usage

把 wycto/dsh-token-usage 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-token-usage — DSH Token 用量记录与统计插件

记录 DeepSeek Harness 中所有 LLM API 调用(模型请求),提供单窗口全屏统计面板。 支持秒级时间范围查询、多维度筛选、会话 ID 筛选、排序、状态码与调用详情、分组统计表与 CSV 导出。

界面截图

Token 用量统计面板

Token 用量统计面板:汇总卡片、多维度筛选、状态码与调用明细

侧边栏入口

侧边栏底部"Token 用量"入口按钮

功能特性

  • 醒目入口:侧边栏底部蓝色渐变大按钮 "Token 用量",一键打开全屏面板。
  • 秒级时间查询:起止 datetime-local(精确到秒)过滤调用记录。
  • 默认不限制时间:打开面板默认时间不选、显示全部记录(不再默认"当天");筛选条件自动暂存(localStorage),下次打开恢复上次条件;点【重置】清空全部条件回到显示全部。
  • 提供商/模型下拉去重合并:选项 = 现有配置(settings.yaml 的 llm-pi-ai.providers)∪ 历史记录,无记录时仍可选现有提供商,已删除的提供商/模型因有记录仍可选中。
  • 多维度筛选:会话 ID / 模型提供商 / 模型 / 状态 / 推理强度 下拉筛选。
  • 排序:明细表全部 15 列点击表头可排序(时间/会话ID/提供商/模型/输入/缓存/命中%/输出/推理/总额/金额/金额(¥)/强度/状态/耗时),升降序切换。默认按时间倒序(最新在前)。
  • 金额双币显示:明细表与统计表金额均为 USD + 人民币两列;定价表以官方人民币刊例为基准(支持 DeepSeek-V4 峰谷两档),人民币按汇率换算(默认 7.2,可用 settings.yaml 的 token-usage.usdCnyRate 覆盖),CSV 导出含 costCny 列。
  • 会话 ID:明细表显示会话 ID(缩略),点击任意会话 ID 即按该会话筛选。
  • 状态码 + 详情:状态列显示 HTTP 状态码(200 成功 / 400 / 401 / 429 / 500 等,来自 turn/end 错误),状态下方【查看详情】弹窗展示完整信息(含会话 ID、错误信息、错误码、各 Token 桶、金额、耗时、Turn/Step 等)。
  • 统计表:按 provider / model / status / effort 分组汇总(调用数、各 Token、命中率、金额、耗时)。
  • CSV 导出:按当前筛选导出全字段明细。

数据来源

插件不侵入模型调用链路,只读取 DSH 会话日志(session/event 事件 + 历史扫描), 从以下会话事件中提取每次模型调用的完整信息:

字段 来源 说明
时间 事件 time Unix epoch ms,秒级精确
模型提供商 request/header.config.provider 路由名(如 ocx)
模型 request/header.config.model 模型 id
apikey 配置 apiKeyEnv 仅存掩码(安全,见下)
输入 Token assistant/message.usage.inputTokens 未命中缓存输入
输出 Token usage.outputTokens 含推理 token
缓存命中量 usage.cacheReadTokens
缓存写入量 usage.cacheWriteTokens
推理 Token usage.reasoningTokens
缓存命中率 计算 cacheRead/(input+cacheRead)
消耗金额 内置定价表估算(人民币/1M) 含 DeepSeek-V4 峰谷两档、可配置覆盖
推理强度 config.reasoningEffort
状态 turn/end.reason.kind completed/error/aborted/...
状态码 turn/end.reason.error.status 真实 HTTP 码(如 400/401/429),无则映射 200/403/499/500
错误信息/码 turn/end.reason.error.message/code 详情弹窗展示
会话 ID 事件所属 session id 可点击筛选、详情展示
耗时 step/start → assistant/message llmMs

安装

方式一:npm 包(推荐,已发布)

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-agent-compact 下一个 Next MathModelingAgent →