@plusl/usage-cost
v0.1.0
Published
Cost estimation for dsh usage figures: a /cost command and a Web cost card with per-model CNY pricing, over the official usage projections
Downloads
144
Readme
@plusl/usage-cost
/cost 命令与 Web 费用卡片:基于官方 usage 投影(tokenUsage / contextPressure)
与可配置的按模型单价表(CNY / 百万 token),估算当前会话的计费成本。官方
/usage 回答"用了多少",/cost 回答"大概花了多少钱"。
安装
# npm(推荐)
dsh plugin --profile web add @plusl/usage-cost
# tarball
dsh plugin --profile web add ./plusl-usage-cost-<version>.tgz
# git(仓库自带预构建 lib/ 产物,无需 allowBuilds 构建脚本)
dsh plugin --profile web add github:<owner>/dsh-plus依赖 dsh ≥ 0.1.0-rc.6(官方 /usage 全家桶所在版本)。在任何挂载 dsh-base
的 profile 上可用;无 Web 表面时浏览器半边不激活,命令文本仍是全部表现。
行与 id
| id | 包 | 说明 |
|---|---|---|
| usage-cost | @plusl/usage-cost | 双面行:host 半边注册 /cost 命令;browser 半边(dsh.client)注册 keyed conversation.chat.commandview 的 cost 渲染器 |
配置
prices:按模型 id 索引的单价行(CNY / 1M token):
- id: usage-cost
config:
prices:
default: # 无精确匹配模型的回退
uncachedInputCny: 2
cacheReadCny: 0.2
cacheWriteCny: 8
outputCny: 8
deepseek-chat: { ... } # 精确模型 id 覆盖- 精确模型 id 优先;未命中用
default行并在输出里注明。 - 默认值即 DeepSeek 官方牌价(deepseek-chat:2 / 0.2 / 8 输入,8 输出)。
- 覆盖本行时须重述完整
config(patch 层按行整体替换)。
依赖的官方能力
ctx.commands(dsh-commands):命令注册面ctx.sessionProjections(dsh-session-projection)+tokenUsage/contextPressure(dsh-token-meter)- Web:
conversation.chat.commandviewkeyed slot(ui-conversation)与 locale 注册面
构建
pnpm --filter @plusl/usage-cost build # lib/index.js + lib/client.js + lib/types估算值仅供参考;实际账单以提供方计费为准。
