bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
团队成本管家:按成员/工作空间计量每次模型调用的 token 与费用(含子代理),内置 DeepSeek 2026-09 价目表与自定义价格覆盖,成员预算热更新、阈值 Webhook 告警、可选超支拦截,提供成本报表工具与 CSV 导出,并在设置页提供团队成本看板。
English | 中文
DeepSeek Harness 团队级 AI 用量与成本计量插件:按成员、按项目精确记录每一次模型调用的 token 与费用(子代理一并计入),内置成员预算、阈值告警、Webhook 通知、可选超支拦截,以及一个可以随时向 AI 查询的报表工具。
DeepSeek Harness (dsh) 正在被团队共用一台主机地使用,但生态里现存的 100+ 个用量插件几乎全是单人自用仪表盘:它们盯着自己会话的余额,回答不了团队最关心的问题——
dsh-team-cost 只做这一件事,把它做完整。
session/event,从每条 assistant/message 读取官方 TokenUsage(未命中输入 / 输出 / 缓存命中 / 缓存写入 / 推理分列)。子代理会话照常上报,全部计入。members=workspace 规则,最长前缀优先);配 dsh-login 每用户工作空间时每人只需一行规则。未匹配的会话归入可配置的默认成员。price-overrides.json 配置;未配置的模型照常计 token,费用记 0。<dataDir>/members.json 一分钟内生效,无需重启。dsh-team-cost/quota-exceeded 事件给其他插件。enforce: 'total' 超过团队日预算后拦截新模型请求;enforce: 'members' 尝试按成员拦截(尽力而为,见配置注释)。默认只监控不拦截。team_cost_report——问一句"出一下本月团队成本报表"即可按成员/模型/天分组统计,支持导出 CSV。# 从 GitHub 仓库安装
dsh plugin --profile web add https://github.com/1569126506-sudo/dsh-team-cost
# 或克隆到本地后从路径安装
git clone https://github.com/1569126506-sudo/dsh-team-cost.git
dsh plugin --profile web add ./dsh-team-cost
npm 渠道(
dsh plugin --profile web add dsh-team-cost)待账号注册开放后启用。
插件配置(cordis 设置页 / patch):
| 键 | 默认 | 说明 |
|---|---|---|
dataDir | ~/.dsh/.dsh-team-cost | 数据目录(JSONL 账本、rollups、members.json、导出文件) |
enabled | true | 总开关 |
currency | CNY | 内置价目表币种:CNY / USD |
deepseekPeakPricing | false | DeepSeek 使用峰价而非谷价 |
enforce | off | off / total / members,见上文 |
totalDailyCost | 0 | 团队日预算(enforce: total 时生效) |
alertThresholds | ["80","100"] | 告警阈值(百分比) |
alertWebhook | 空 | 告警 Webhook POST 地址 |
attributionRules | [] | 成员归因规则 "成员=工作空间路径前缀" |
defaultMember | unassigned | 未匹配会话的归属成员 |
flushIntervalSec | 15 | 聚合落盘间隔 |
成员预算示例(~/.dsh/.dsh-team-cost/members.json):
{
"members": [
{ "name": "alice", "dailyCost": 20, "monthlyCost": 400 },
{ "name": "bob", "dailyCost": 20, "dailyTokens": 50000000 }
]
}
价格覆盖示例(price-overrides.json,单位:每百万 token):
{ "kimi-k3": { "cr": 0.5, "in": 4, "out": 16 } }
对 AI 说:
用 team_cost_report 出一下本月的团队成本报表,按成员分组,并导出 CSV
或直接调用工具参数:range: today|month|all,groupBy: member|model|day,csv: "true"。
跑几轮真实会话后,校验账本完整性并把费用按内置价目重算对账:
账本是纯本地 JSONL(usage-YYYY-MM.jsonl),聚合缓存在 rollups.json。不外发任何会话内容——计量只读取 token 计数、模型名与工作目录。
设置 → 团队成本:
MIT
Team-scoped AI usage & cost metering for DeepSeek Harness. Every model call — subagents included — is metered from the official session/event firehose (assistant/message carries the step's TokenUsage), attributed to a team member via workspace-prefix rules, priced against the built-in DeepSeek 2026-09 catalog (peak/off-peak, CNY/USD) or user overrides, and appended to a local monthly JSONL ledger.
Per-member daily/monthly budgets live in <dataDir>/members.json (hot-reloaded); crossing 80%/100% thresholds fires de-duplicated alerts and an optional webhook. enforce: 'total' | 'members' can block new model requests over budget (off by default). The team_cost_report tool answers "how much did the team spend this month?" by member, model, or day, with CSV export.
No conversation content ever leaves the machine: metering reads token counts, model ids, and the session working directory only.