🎁 福利专区全网大模型免费应用 + 新用户福利 + 注册活动入口,低成本玩转 AI

用量成本计 lhh666-6/dsh-usage-cost

DeepSeek Harness
lhh666-672 天前有提交已提供中文文档扫描:含敏感能力

实时查看会话 token 用量与花费,数据只存本地

27.4/100
综合分
0
GitHub 星标
—
npm 周下载
—/5
用户评分

数据截至 2026/9/18 · 周下载取自 npm 全网(含 CI / 镜像),非本站安装数;综合分由星标、活跃度与兼容性检查合成。

安装命令 · 需先装 dsh CLI 引擎
dsh plugin --profile web add lhh666-6/dsh-usage-cost
该包不可直接 npm 安装,改从 GitHub 源安装(明细见下方安装检查)

状态速览

判定依据:实装验证 · 静态安装检查 · 自动扫描 · 仓库维护状态
信任档位:已验证
是什么
dsh 原生插件 · ui
装得上吗
本站已真实安装成功
非静态推断
L4 · 真实安装等级说明 →
安全吗
本站尚未对该插件做风险分级
暂未覆盖,不等同于无风险
还在维护吗
更新放缓:最近一次提交在 72 天前
档位由哪些信号合成

本站实装验证(真实安装 L4 覆盖全站;L5 为运行时冒烟或实机截图,覆盖范围小于 L4) · 验证所用 dsh 版本 · 静态安装检查 · 风险分级 · 仓库维护状态。 下方各区块是它的证据明细。

验证判据与等级说明 →
社区实装还没有人打卡 · 装过的第一个就是你
安全扫描自动 · 静态分析源码
v2.7.0
🔵 扫描:含敏感能力尚无人工评估
展开查看扫描说明与证据 ↓

静态扫描发现插件具备触达本地系统的能力:执行外部命令、读写/删除本地文件、读取剪贴板或密钥类环境变量(至少其一)。这是能力清单,不是危险判定——具体能力项与证据见下方,安装前请自行判断是否需要。

读写/删除本地文件读取剪贴板或密钥环境变量发起外部网络请求
查看扫描证据(共 12 处,展示前 12 条)
  • 读取本地文件
    lib/index.js:659
    const parsed = parseDocument(await readFile(this.filePath, "utf8"));
  • 写入本地文件
    lib/index.js:758
    await mkdir(dirname(this.filePath), { recursive: true });
  • 写入本地文件
    lib/index.js:759
    await writeFile(this.filePath, JSON.stringify(this.state), "utf8");
  • 发起网络请求
    lib/index.js:820
    const response = await fetch(BALANCE_ENDPOINT, {
  • 读取密钥环境变量
    lib/index.js:946
    const envKey = process.env.DEEPSEEK_API_KEY;
  • 读取本地文件
    lib/index.js:949
    const text = await readFile(dshHomePath(".credentials.yaml"), "utf8");
  • 读取本地文件
    src/aggregates.ts:132
    const raw = await readFile(this.filePath, 'utf8')
  • 写入本地文件
    src/aggregates.ts:244
    await mkdir(dirname(this.filePath), { recursive: true })
  • 写入本地文件
    src/aggregates.ts:245
    await writeFile(this.filePath, JSON.stringify(this.state), 'utf8')
  • 发起网络请求
    src/balance.ts:50
    const response = await fetch(BALANCE_ENDPOINT, {
  • 读取密钥环境变量
    src/index.ts:114
    const envKey = process.env.DEEPSEEK_API_KEY
  • 读取本地文件
    src/index.ts:117
    const text = await readFile(dshHomePath('.credentials.yaml'), 'utf8')
扫描于 2026/11/3(0 天前) · 范围 入口闭包 + 发布文件清单 · 来源 GitHub 仓库

静态扫描只反映源码中出现的调用,不构成安全背书;人工评估与自动扫描相互独立、互不覆盖。

依赖的 DSH / Cordis 模块
@deepseek-ai/cordis@deepseek-ai/dsh-client-runtime@deepseek-ai/dsh-client-ui-conversation@deepseek-ai/dsh-client-ui-slots@deepseek-ai/dsh-home-paths@deepseek-ai/dsh-llm@deepseek-ai/dsh-session@deepseek-ai/dsh-session-projection@deepseek-ai/dsh-settings@deepseek-ai/schemastery
给这个插件打分还没有人投票↓
用户评分
还没有人投票,来当第一个

功能亮点

  • 实时查看token用量
  • 计量会话费用
  • 数据仅本地存储

DSH 的实时 DeepSeek token 用量与费用计量器:状态栏胶囊加详情面板,仅本地持久化。

README

由 DeepSeek 最新模型翻译生成
dsh-usage-cost GitHub: https://github.com/lhh666-6/dsh-usage-cost npm: dsh-usage-cost 实时显示 DeepSeek 会话 token 用量与成本的 DSH 插件(状态栏小胶囊 + 详情面板)。全部数据本地计算、本地持久化,不上传任何内容。 功能 - 常驻胶囊:注册到会话标题栏右侧 conversation.session.header.utilities,显示模型名、输入/输出 token、本次会话成本;流式输出期间数字实时滚动,估算值带 ~ 标记。 - 详情面板:点击胶囊展开,显示输入/输出 token、缓存命中/未命中 token、总 token、本次成本、耗时、tokens/s、今日/本月累计成本、数据状态(估算中/已校准/未完成)。 - 实时估算 + 权威校准:流式期间用本地 tokenizer(gpt-tokenizer)估算,按「每 50 个 chunk 或每 100ms」节流;请求结束用 DeepSeek 返回的 usage(prompt_tokens/completion_tokens/prompt_cache_hit_tokens/prompt_cache_miss_tokens)校准。
展开完整文档(README 剩余 1 节)
dsh-usage-cost

GitHub: https://github.com/lhh666-6/dsh-usage-cost

npm: dsh-usage-cost

实时显示 DeepSeek 会话 token 用量与成本的 DSH 插件(状态栏小胶囊 + 详情面板)。全部数据本地计算、本地持久化,不上传任何内容。

功能

- 常驻胶囊:注册到会话标题栏右侧 conversation.session.header.utilities,显示模型名、输入/输出 token、本次会话成本;流式输出期间数字实时滚动,估算值带 ~ 标记。
- 详情面板:点击胶囊展开,显示输入/输出 token、缓存命中/未命中 token、总 token、本次成本、耗时、tokens/s、今日/本月累计成本、数据状态(估算中/已校准/未完成)。
- 实时估算 + 权威校准:流式期间用本地 tokenizer(gpt-tokenizer)估算,按「每 50 个 chunk 或每 100ms」节流;请求结束用 DeepSeek 返回的 usage(prompt_tokens/completion_tokens/prompt_cache_hit_tokens/prompt_cache_miss_tokens)校准。
- 成本计算:cost = cache_hit/1e6 * cacheHit + cache_miss/1e6 * cacheMiss + completion/1e6 * output(人民币/百万 token)。价格表可配置,模型名模糊匹配(deepseek-chat-2025-xxx → deepseek-chat);缺失价格只显示 token,成本显示「未配置价格」。
- 持久化:本次会话数据走 session projection(由 session-projection-cache 落盘);今日/本月/按模型累计写入 $DSH_HOME/usage-cost/aggregates.json,重启不丢。
- 边界:流式中断/报错保留估算并标记「未完成」,不覆盖历史准确数据;切换会话由投影按会话隔离,不串数据;多币种暂不做汇率,默认人民币。

架构

这是一个双面 DSH 插件包(与 dsh-plugin-desktop 同一套插件系统,无需改动主程序):

- Host 面(lib/index.js):注册 usageCost session projection(纯 fold,框架自动做实时推送 + 落盘 + 重放),监听 session/event 累计今日/本月/按模型数据,注册 usage-cost settings 段用于价格配置。
- Client 面(lib/client.js):dsh.client manifest + exports["./client"],注册状态栏胶囊;组件通过标准 useProjection('usageCost') 读实时值。

目录

dsh-usage-cost/
├── package.json # dsh.bundle.patch + dsh.client manifest + exports
├── cordis.yml # Host 行声明(insert usage-cost) ├── tsconfig.json # Host 面类型检查 ├── tsconfig.client.json # Client 面类型检查 ├── tsdown.config.ts # 打包 lib/index.js + lib/client.js └── src/ ├── index.ts # Host 插件入口 ├── types.ts # 纯类型 + SessionProjectionMap 声明合并 ├── pricing.ts # 价格表、模糊匹配、成本公式 ├── estimator.ts # gpt-tokenizer 封装 ├── projection.ts # usageCost session projection 单元 ├── aggregates.ts # 今日/本月/模型累计 + JSON 持久化 └── client/ ├── index.ts # Client 插件入口 ├── UsageCapsule.tsx └── format.ts

构建

npm install
npm run build # tsdown 打包 + tsc 声明
npm run typecheck # 仅类型检查

安装到 DSH Desktop / DSH

插件通过官方 dsh plugin 语义安装(Desktop 内等价于 desktopPnpm.runPlugin):

npm 安装(推荐,预构建)
dsh plugin --profile desktop add dsh-usage-cost
dsh plugin --profile web add dsh-usage-cost

或直接从 GitHub 安装
dsh plugin --profile desktop add github:lhh666-6/dsh-usage-cost
dsh plugin --profile web add github:lhh666-6/dsh-usage-cost

安装后重启(或切换一次 profile),发起对话时状态栏即出现用量胶囊。

价格配置

默认价格(人民币 / 百万 token):

| 模型 | 缓存命中 | 缓存未命中 | 输出 |
| deepseek-chat | ¥0.5 | ¥2 | ¥8 |
| deepseek-reasoner | ¥1 | ¥4 | ¥16 |

可在 $DSH_HOME/settings.yaml 的 usage-cost 段覆盖(或通过 DSH 设置页的插件配置):

usage-cost:
models:
- id: deepseek-chat
cacheHit: 0.5
cacheMiss: 2
output: 8
- id: deepseek-reasoner
cacheHit: 1
cacheMiss: 4
output: 16yaml
chunkInterval: 50
timeIntervalMs: 100

官方价格会变动,请以 DeepSeek 最新价格为准更新此表。

模型体验

无。本插件只观察会话事件与 provider usage,不注入任何模型可见指令、工具或请求字段。
预览分享卡片长什么样 ↓lhh666-6/dsh-usage-cost
分享 · DeepSeek Harness Hub
lhh666-6/dsh-usage-cost

实时查看会话 token 用量与花费,数据只存本地

这是你的仓库?认领条目

回到顶部