Skip to main content
P

dsh-budget

perrylink/dsh-budget

Cost governance for DeepSeek Harness: aggregated token/cost metering per model, session and day, session/daily/monthly budget caps with threshold alerts (desktop notification + webhook) and alert/block/degrade over-limit policies, built-in carbon footprin

Install

dsh plugin --profile web add github:perrylink/dsh-budget

README

💰 dsh-budget

Cost governance for DeepSeek Harness: budgets, carbon, and latency in one panel.

Know what every session costs — before it costs you.

License DSH plugin Node CI Version npm version npm downloads

English · 简体中文 · Español · Português · हिन्दी


Compatibility

SurfaceStatus
HarnessDeepSeek Harness 0.1.0-rc.6
Node^22.19.0 || >=24.0.0
SurfacesHost + Web client (Settings budget tab); /budget command

What you get

dsh-budget turns the session event stream into a four-in-one cost governance loop:

  • Aggregated metering — tokens (uncached input / output / cache read / cache write), estimated USD cost, and carbon footprint per model, session, and day, priced through a built-in USD-per-1M table merged with your config.prices.
  • Budget governance — session/daily/monthly caps; a warn-ratio threshold alert (webhook POST + desktop-notification flag) and three over-limit policies: alert (notify only), block (short-circuit new model requests until the user lifts the block), degrade (block with corrective guidance naming the cheaper model from your degradation map).
  • Carbon & latency — token→carbon bridge (tokens × kWh/token × PUE × regional grid intensity, ported from AI-Carbon-Footprint-Calculator) and per-model latency percentiles.
  • Surfaces — the Settings budget tab (usage bars, model breakdown, alerts, cap editors, unblock buttons) and the /budget command (/budget, /budget models, /budget unblock <scope>).

Quick start

# 1. install the bundle into your profile
dsh plugin --profile web add "github:PerryLink/dsh-budget#main"

# or from npm (published releases)
dsh plugin --profile web add dsh-budget

# 2. restart and verify the row
dsh --profile web --dump-config | grep -A2 'id: budget'

Then ask the agent: /budget — and watch the Settings tab fill in.

Install & uninstall

  • git channel (latest main): dsh plugin --profile web add "github:PerryLink/dsh-budget#main" — the prepare script builds with production dependencies only.
  • npm channel (published releases): dsh plugin --profile web add dsh-budget.
  • tarball channel: pnpm pack in this repo, then dsh plugin --profile web add ./dsh-budget-<version>.tgz.
  • uninstall: dsh plugin --profile web remove dsh-budget.

If pnpm reports ERR_PNPM_IGNORED_BUILDS for this package (esbuild's harmless platform-binary validation), add allowBuilds: { esbuild: true } to your pnpm-workspace.yaml — the dsh CLI prints the exact snippet.

Configuration

All tunables are Schemastery Config fields (changeable from cordis.yml). cordis.patch.yml documents each key inline.

KeyDefaultMeaning
prices{}Per-model USD prices per 1M tokens, merged over the built-in table
defaultPrice{input: 1.0, output: 3.0}Fallback for models absent from both tables
budgets.session / daily / monthly10 / 50 / 500Budget caps in USD per scope; omit for unlimited
warnRatio0.8Alert once usage reaches this fraction of a cap (0..1)
overLimitalertalert / block / degrade after a cap is crossed
degradation{}Model id → cheaper model id of the same provider
webhookUrl(none)Optional webhook URL for threshold alerts (POST JSON)
webhookTimeoutMs5000Webhook request timeout
alertsEnabledtrueMaster switch for threshold alerts
alertCooldownMs3600000Minimum ms between two alerts of the same scope
desktopNotificationsfalseBrowser desktop notifications while the tab is open
refreshIntervalMs5000Settings tab polling interval
carbon.enabled / region / pue / energyKwhPerTokentrue / global / 1.58 / 0.000007Carbon bridge (regions: global, us, eu, china, india, uk, france, iceland)
latency.enabled / windowSizetrue / 200Per-model latency percentiles and their window
currency{code: USD, rate: 1.0, decimals: 2}Display currency (costs are computed in USD)
outputLanguageen/budget output language: en / zh
historyDays30Per-day usage history kept in the panel snapshot

Tools & surfaces

SurfaceKindNotes
/budgetCommandPer-scope overview (usage, ratio, carbon, blocked state)
/budget modelsCommandPer-model breakdown with latency percentiles
/budget unblock <scope>CommandLift a blocked scope (session / daily / monthly)
Settings → Plugins → BudgetSettings tabUsage bars, model breakdown, alerts, cap editors, unblock buttons
budget/status, budget/setSettings, budget/unblockTypert RemoteThe client channel (the tab consumes these)

Permissions & data

  • Permissions: network:outbound (the optional alert webhook only), session:append (audit events), native-code:none.
  • Data: everything displayed comes from the session event stream; the only host-side network call is the configured webhook, whose URL is validated at load and credential-stripped before any log. No prompts or payloads ever leave the host.
  • Session log: budget/alert and budget/block are log-only audit events carrying scope names and USD amounts (microtask-deferred past the session-append reentrancy guard).

Security boundaries

  • No fabrication: a budget block yields a corrective error finish on the llm/stream waterfall — the plugin never invents model output.
  • No request rewriting: loop-built requests are frozen; degrade therefore names the target model in the corrective message instead of swapping the request.
  • Fail loud: invalid prices, URLs, ratios, regions, and bounds fail the mount.
  • Honest scope: runtime edits from the panel are session-scoped; a reload restores the cordis.yml values.

Known limitations

  • Aggregation is process-local: usage resets when the harness restarts (per-day/per-month buckets rebuild from the current session log view).
  • block/degrade rely on the llm/stream waterfall; harness builds without that seam cannot block requests (alerts still work).
  • Built-in prices drift; override entries via config.prices.

Development

pnpm install        # node ^22.19 || >=24
pnpm run typecheck  # tsc: src + tests against the local harness checkout
pnpm run typecheck:ci  # tsc against the published 0.1.0-rc.6 types (no paths)
pnpm test           # vitest: 45 tests
pnpm run build      # tsc declarations + tsdown bundles (lib/)
pnpm run verify:self-contained  # dependency specs resolve from the registry
pnpm run verify:artifacts       # built ESM face + typert manifest + client bundle
pnpm pack           # the published tarball

Topics

dsh, dsh-plugin, deepseek-harness, deepseek, cordis, budget, cost-tracking, carbon-footprint, latency-benchmark, token-usage

Contributors

  • @PerryLink — creator and maintainer: aggregation, budget governance, carbon and latency ports, the Settings tab, and the five-language docs.

This project is one of the 29 DeepSeek Harness plugins maintained by PerryLink. If this one helps you, the others likely will too:

PluginOne-liner
dsh-auto-reviewSecond-model auto-review on the approval chain, fail-closed by default
dsh-background-agentsDurable background child agents with a Web UI sidebar, messaging and interrupt
dsh-budgetCost governance for DeepSeek Harness: budgets, carbon, and latency in one panel.
dsh-checkpoint-rewindClaude Code /rewind-equivalent: snapshots, session forks, one-shot restore
dsh-claude-moveMigrate Claude Code sessions, memory, skills and CLAUDE.md into DSH
dsh-clickCross-platform native desktop control for DeepSeek Harness — Windows first.
dsh-composer-historyTerminal-style input history for the web composer: arrows, Ctrl+R search
dsh-defendPrompt-injection, jailbreak, and secret-leak defense for DeepSeek Harness.
dsh-doublecheckEngineering-discipline guard: requirements grill, test gates, adversary review
dsh-drawUnified static-image generation routing for DeepSeek Harness.
dsh-fastRead-only performance diagnostics for DeepSeek Harness.
dsh-githubGitHub PR/issues integration for DSH, every write gated by approval
dsh-libraryLocal document knowledge base for DeepSeek Harness.
dsh-local-aiLocal-model (Ollama) integration for DeepSeek Harness.
dsh-lsp-actionsLSP diagnostics, formatting, completion, code actions and rename over language servers
dsh-maskPII masking middleware for DeepSeek Harness — anonymize personal data before it reaches the model, restore it at the display layer.
dsh-mcp-panelRead-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors
dsh-mementoApproval-gated cross-session memory: ctx.memory seam + SQLite + memory tool
dsh-observeOpenTelemetry and Langfuse observability exporter for DeepSeek Harness.
dsh-output-stylesClaude Code outputStyles-equivalent runtime style switching
dsh-permission-rulesClaude Code-style declarative allow/deny/ask permission rules with audit
dsh-plugin-guidePlugin-development knowledge base as an on-demand agent skill
dsh-scoreMulti-dimensional quality scoring for DeepSeek Harness plugins.
dsh-session-pinPin sessions in the Web sidebar with durable ordering
dsh-session-syncCross-device session sync for DeepSeek Harness — a dedicated git mirror of your session store.
dsh-skill-pack-securitySecurity-audit skill pack: secret scan, dependency and supply-chain review
dsh-talkVoice-first session loop for DeepSeek Harness: talk to it, hear it answer.
dsh-test-driveIsolated install-and-smoke test drives for DeepSeek Harness plugins.
dsh-translateVendor parameter translation and deterministic JSON repair for DeepSeek Harness.

License

Apache License 2.0 © 2026 dsh-budget contributors

Related plugins