DeepSeek Harness 插件

dsh-cost

Evidence-first token cost ledger and budget checks for DeepSeek Harness(英文原文)

跳到安装方式

来源信息

GitHub 仓库
dongsheng123132/dsh-cost
最近更新
2026年8月14日
分类
用量与账单
GitHub stars
3
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/dongsheng123132/dsh-cost
插件名:dsh-cost
作者:dongsheng123132

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-cost

![CI](https://github.com/dongsheng123132/dsh-cost/actions/workflows/check.yml) ![MIT license](LICENSE) ![Node.js 22+](package.json) ![Awesome DSH Plugins](https://github.com/dongsheng123132/awesome-dsh-plugins#2origin-plugin-lab)

Evidence-first token cost ledger and budget checks for DeepSeek Harness.

dsh-cost folds the durable DSH session log. It attributes each committed assistant/message.usage record to the active request/header provider/model route, then applies a user-owned price book. Missing usage and missing prices remain explicit: partial evidence never becomes a reassuring fake total.

Install

dsh plugin --profile <name> add github:dongsheng123132/dsh-cost

The bundle mounts two tools:

  • dsh_cost_report — durable session cost, route breakdown, evidence completeness, optional budget status, and the current ctx.tokenMeter pressure snapshot.
  • dsh_cost_check — explicit fail-open/fail-closed budget decision. It does not claim to intercept future calls automatically.

The same evidence core is available through the bundled stdio MCP server as cost_report and cost_check. MCP accepts only bounded, sanitized usage rows (provider, model, disjoint token buckets, or an explicit missingUsage marker); it rejects prompts, message bodies, credentials and other extra fields. The formal Codex plugin manifest lives at .codex-plugin/plugin.json.

The DSH entry is a namespace plugin (name / inject / apply) with no default export. This preserves both tools and tokenMeter injection through the real Cordis Loader. Structural and plugin smokes fail if a default export is reintroduced.

Price book

Copy prices.example.json, replace the zero placeholders with prices from your own current provider contract, and pass its path as plugin config:

- id: dsh-cost
  name: dsh-cost
  config:
    priceBookFile: C:/absolute/path/prices.json
    defaultBudget: 5

Prices are per million tokens. Input, output, cache-read and cache-write buckets are disjoint. reasoningTokens is informational inside output usage and is not added again.

No vendor prices are baked in: prices change, account discounts differ, and a stale number is worse than an explicit unpriced route.

Offline ledger

dsh-cost --events session-events.json --prices prices.json --budget 5 --fail-closed

Exit code 2 means over budget, or unknown when --fail-closed is active. The events file may be a raw array or an object with an events array.

Evidence boundary

  • Cost is computed only from durable assistant/message.usage records.
  • Calls without provider usage stay missingUsageCalls.
  • Routes absent from the price book stay unpricedCalls.
  • A below-budget answer is unknown, not within, while either count is non-zero.
  • Current context pressure comes from DSH's own ctx.tokenMeter; it is not confused with lifetime spend.

Verify

npm test
npm run check
npm run smoke:plugin
npm run smoke:mcp

For a built DSH checkout and an isolated Web profile containing this bundle, run DSH_CHECKOUT=/path/to/dsh DSH_HOME=/path/to/isolated-home npm run smoke:web-loader. The smoke starts the real stock Web profile with a bounded, credential-free environment and requires an actual readiness URL. npm run smoke:dsh additionally enumerates and calls both tools through the real DSH ToolRuntime when DSH_CHECKOUT is set.

MIT