yushuosun/dsh-cost-governor0

dsh-cost-governor

Cost governance & budget enforcement for DeepSeek Harness: multi-provider pricing, per-model cost accounting, budget quotas with soft/hard thresholds, and cross-session trends.

包名
dsh-cost-governor
版本
0.1.0
许可证
MIT
最近更新
2026年8月22日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:yushuosun/dsh-cost-governor

3. restart dsh — the dashboard appears under Settings → Usage & Cost


## Configuration

| key | default | description |
|---|---|---|
| `currency` | `USD` | display currency |
| `budget.period` | `monthly` | `daily` \| `weekly` \| `monthly` \| `unlimited` |
| `budget.budgetUsd` | `20` | period cap |
| `budget.warnRatio` | `0.8` | soft-warn at 80% |
| `budget.hardRatio` | `1.0` | ceiling at 100% |
| `budget.hardAction` | `notify-only` | ceiling behavior |
| `notifyWebhook` | — | optional webhook URL |
| `priceCatalog` | built-in | per-model overrides (USD / 1M tokens) |

## Architecture

client dashboard / HUD ▲ session/projection frames + settings scope host UsageCost service ── BudgetGovernor · CostLedger · Notifier ▲ ctx.sessionProjections.register(costUsage) costUsage projection (pure fold: raw per-model token buckets) ▲ reuses core token buckets (request/context → model attribution) dsh-token-meter · dsh-llm (TokenUsage)


The `costUsage` projection stores **raw token buckets only** — never currency — so it is replay-safe and a price-table edit re-prices history without refolding the log.

## Development

```bash
pnpm install
pnpm build          # tsc (see PUBLISHING.md for the full DSH toolchain notes)

Open preview/dashboard.html for a zero-build visual preview of the dashboard.

Limitations

  • Only final assistant/message usage is billed; input spend of a request that fails before assembling a message is not captured (a provider still charges it). This matches the harness's own usage-carrier semantics and is a documented edge, not a miscount.
  • block-new-requests / steer-to-cheaper-model are exposed as a governance gate (BudgetGovernor.gate) and emitted events; wiring them into the LLM waterfall is the one integration point to verify against the official DSH plugin docs at first build.
  • Prices in the built-in catalog are community placeholders — verify against each provider before trusting absolute dollar figures.

License

MIT

Configuration

keydefaultdescription
currencyUSDdisplay currency
budget.periodmonthlydaily | weekly | monthly | unlimited
budget.budgetUsd20period cap
budget.warnRatio0.8soft-warn at 80%
budget.hardRatio1.0ceiling at 100%
budget.hardActionnotify-onlyceiling behavior
notifyWebhookoptional webhook URL
priceCatalogbuilt-inper-model overrides (USD / 1M tokens)