
dongsheng123132/dsh-cost
30Last commit Aug 14, 2026
dsh-cost DSH plugin
dsh-cost is a DSH plugin that computes session cost from durable session logs. It attributes each usage record to the active provider/model route, applies a user-owned price book, and keeps missing usage and missing prices explicit. It provides two tools (dsh_cost_report and dsh_cost_check) and a bundled stdio MCP server for cost queries.
How to install the dsh-cost DSH plugin
dsh plugin --profile <name> add github:dongsheng123132/dsh-costThis source command needs manual review. Copying does not run it.
dsh-cost DSH plugin data source
dsh-cost DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-cost DSH plugin can do
- Computes session cost from durable assistant/message.usage records in DSH logs
- Attributes each usage record to the active provider/model route
- Applies a user-owned price book (prices.json) with per-million-token pricing for input, output, cache-read, and cache-write buckets
- Provides two plugin tools: dsh_cost_report (cost report with breakdown, evidence completeness, budget status, and tokenMeter pressure) and dsh_cost_check (fail-open/fail-closed budget decision)
- Bundles a stdio MCP server exposing cost_report and cost_check endpoints with bounded, sanitized input
- Supports offline ledger mode via dsh-cost --events session-events.json --prices prices.json --budget --fail-closed
- Preserves tools and tokenMeter injection through the real Cordis Loader (namespace plugin with no default export)
Where the dsh-cost DSH plugin fits
- Track token costs across multiple provider/model routes in a DSH session
- Set and enforce budget limits with fail-open or fail-closed policies
- Generate cost reports with route breakdown and evidence completeness statistics
- Use the MCP server for cost queries from external tools without exposing message bodies or credentials
- Run offline cost audits on session event files exported from DSH
Who the dsh-cost DSH plugin is for
- DSH users who need to monitor and control token spending across providers
- Developers who want to attribute costs per project or client using a custom price book
dsh-cost DSH plugin limitations
- 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' while any missing or unpriced calls exist
- No vendor prices are baked in; users must supply their own prices.json file
- Requires Node.js 22+ (as indicated by the badge)
- MCP server rejects prompts, message bodies, credentials, and other extra fields; only accepts bounded, sanitized usage rows
dsh-cost DSH plugin: from the repository README
Quoted from the dongsheng123132/dsh-cost README, the upstream source of the dsh-cost DSH plugin. Copyright remains with the original authors.
Evidence-first token cost ledger and budget checks for [DeepSeek Harness](https://github.com/deepseek-ai/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 ```bash 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
Read the full READMERepository license: MIT
dsh-cost DSH plugin questions
How do I install dsh-cost?
Run `dsh plugin --profile <name> add github:dongsheng123132/dsh-cost` in your DSH environment. This will download and mount the plugin. After installation, you can use the tools `dsh_cost_report` and `dsh_cost_check` within your DSH session.
How do I configure the price book?
Copy the `prices.example.json` file from the plugin repository, replace the zero placeholders with the actual per-million-token prices from your provider contract. Then pass the absolute path of this file as plugin config via `priceBookFile: C:/absolute/path/prices.json`. You can also set a default budget with `defaultBudget: 5` (in your chosen currency unit).
Can I use dsh-cost offline without a running DSH session?
Yes, you can run the offline ledger mode: `dsh-cost --events session-events.json --prices prices.json --budget 5 --fail-closed`. The events file can be a raw array or an object with an `events` array. Exit code 2 indicates over budget or unknown when `--fail-closed` is active.
What does the MCP server do?
The bundled stdio MCP server exposes the same cost computation as `cost_report` and `cost_check` tools, but only accepts bounded, sanitized usage rows (provider, model, token buckets, or an explicit missingUsage marker). It rejects prompts, message bodies, credentials, and other extra fields, making it safe to use from external tools without exposing sensitive data.
What happens if some provider calls have no usage records or the price book is missing entries?
Calls without provider usage are listed as `missingUsageCalls`. Routes absent from the price book are listed as `unpricedCalls`. The budget check will return 'unknown' instead of 'within' if any missing or unpriced calls exist, even if known costs are under budget. This ensures partial evidence never becomes a reassuring fake total.