bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
DSH 费用统计面板:从 session 事件采集每次请求用量,按内置 16 家厂商 136 个模型的价格目录实时计费,在输入框旁展示当前模型、账户余额、本会话/今日/本月消费与月度预算横条。中英双语。
本插件由原
dsh-custom-cost-meter(计费统计面板)与dsh-spend(开销统计)合并而来:服务端计费 + 输入框旁实时展示,单插件单脚本安装,中英双语。
DeepSeek Harness 会话费用统计插件(服务端计费 + 输入框旁实时展示,中英双语)。
alertThreshold 变色,默认 ≥80% 转橙、≥100% 转红)balanceCacheTtl)lib/pricing.js 134 条 + prices.override.json 2 条):DeepSeek、豆包/火山方舟、OpenAI、Anthropic、Gemini、通义千问、腾讯混元、Kimi、MiniMax、智谱 GLM、硅基流动、xAI、Mistral、Meta Llama、Cohere、OpenRouterdsh plugin --profile web add dsh-token-ledger-pro
装完重启 DSH Web,浏览器 Ctrl+F5 强刷即可。包已发布到 npm(dsh-token-ledger-pro),预构建安装不需要 allowBuilds 授权。
install-dsh-token-ledger-pro.ps1(自动清理旧版本、复制插件、接线DSH profile、建立链接、迁移历史数据)dsh-token-ledger-pro 文件夹复制到目标电脑任意位置install-dsh-token-ledger-pro.ps1首次安装后打开 ~/.dsh/profiles/web/cordis.patch.yml,在 dsh-token-ledger-pro 的 balance 块中填入对应厂商的密钥即可查询余额,所有配置与DSH版本完全兼容。
在 profile 的 cordis.patch.yml(或 settings)里给 dsh-token-ledger-pro 加 config.balance。按当前选中模型的厂商自动选择对应余额配置;未配置时显示「--」。
- id: dsh-token-ledger-pro
config:
monthlyBudget: 100
unknownModel: estimate
balance:
deepseek:
type: deepseek # 官方余额 API(api.deepseek.com/user/balance)
apiKey: "sk-你的DeepSeek密钥"
currency: "CNY"
openai:
type: openai # OpenAI 订阅余额
apiKey: "sk-你的OpenAI密钥"
currency: "USD"
anthropic:
type: anthropic
apiKey: "sk-ant-xxx" # 需在组织设置里补 organization_id
endpoint: "https://api.anthropic.com/v1/organizations/<你的组织ID>/usage"
currency: "USD"
moonshot:
type: moonshot # Kimi 余额
apiKey: "sk-xxx"
currency: "CNY"
zhipu:
type: zhipu # 智谱余额
apiKey: "xxx.xxx"
currency: "CNY"
# 腾讯混元:按腾讯云账户计费,用费用中心 DescribeAccountBalance(TC3 签名)
hunyuan:
type: tencent # 腾讯云签名接口 billing.tencentcloudapi.com
secretId: "AKID你的腾讯云SecretId"
secretKey: "你的腾讯云SecretKey"
region: "ap-guangzhou" # 可留空,余额接口不依赖地域
currency: "CNY"
# 阿里千问(百炼):按阿里云账户计费,用 BSS QueryAccountBalance(RPC 签名)
qwen:
type: aliyun # 阿里云签名接口 business.aliyuncs.com
accessKeyId: "LTAI你的阿里云AccessKeyId"
accessKeySecret: "你的阿里云AccessKeySecret"
region: "cn-hangzhou" # 可留空
currency: "CNY"
balanceCacheTtl: 60 # 缓存秒数,默认 60(1 分钟)
⚠️ 密钥以明文存在本地配置文件中,注意不要泄露;若不想配置官方密钥,可用下方自定义端点。
- id: dsh-token-ledger-pro
config:
balance:
myproxy: # 与模型 provider 名一致
type: custom
endpoint: "https://你的中转站/api/balance"
headers:
Authorization: "Bearer sk-xxx"
valuePath: "data.balance" # JSONPath,从响应 JSON 提取数值
currency: "CNY"
endpoint 覆盖默认地址valuePath 支持点号路径:data.balance、balance、data.amount…火山方舟/豆包(Volcano Ark)需要 AK/SK 签名,暂未内置;可用 type: custom 指向你自己的签名网关。
lib/prices.override.json(与服务端 index.js 同级目录),结构:{
"deepseek": {
"default": { "input": 2, "output": 8, "cacheRead": 0.5, "cacheWrite": 2 },
"models": { "deepseek-chat": { "input": 2, "output": 8 } }
}
}
config.priceSyncUrl 指向同构 JSON。GET /dsh-token-ledger-pro/summary?session=<sessionId> — 会话/今日/本月/预算/当前模型计价状态GET /dsh-token-ledger-pro/balance?provider=<provider> — 账户余额({value, currency, updatedAt, error})GET /dsh-token-ledger-pro/prices — 价格目录GET /dsh-token-ledger-pro/config / POST /dsh-token-ledger-pro/config — 读取/修改预算与未知模型策略GET /dsh-token-ledger-pro/history?limit=50 — 最近明细 + 14 日曲线~/.dsh/profiles/<profile>/data/dsh-token-ledger-pro.json
prices.override.json 补精确价