sandbase-harness
sandbaseai
Local-first, self-hosted AI agent runtime and MCP bridge with sandboxed sessions, memory, credentials, audit/replay, and a local Console.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Jannchie/dsh-bill
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
Cost tracking for DSH (DeepSeek Harness). A line under each turn tells you what that turn cost; the conversation's Cost tab tells you what that session's money went on, and the global Cost panel beside Plugins does the same for the whole account.




dsh plugin --profile web add dsh-bill
Restart dsh web to pick it up.
git / pnpm / rg), tool input, attachments, system reminders, user input. The sunburst drills in.bill_stats, so the model can answer questions about spend directly, over a number of days back or one calendar day (today, yesterday, YYYY-MM-DD). agentTool: false in the plugin config leaves it unregistered, for anyone who never asks the model about spend and would rather not pay its schema on every request.Three substantive differences:
No hand-maintained price table. Every other plugin ships a built-in table of 2–4 DeepSeek models, which means no prices at all once you switch provider — and which is why they all need a "edit the price table by hand" entry point. dsh-bill pulls models.dev and OpenRouter through llm-pricing, covering 8000+ entries, so a new model is priced the day it ships.
Price is a timeline, not a number. The others compute a cost and store it (or recompute at today's price), so history goes wrong the moment a vendor changes its rates or a call crosses a peak/off-peak boundary. dsh-bill prices each call at that call's own instant, and never recomputes history.
It answers "on what". The others answer only "how much" — they consume the provider's aggregate token counts and never look at the request content. dsh-bill splits the request into classified segments at capture time and apportions cost by position in the cache prefix.
They do some things better: usage-stats reads balances and subscription quotas from 11 providers (dsh-bill only does DeepSeek), cost-meter can read OpenCode Go's subscription quota, and both surface more always-on entry points than dsh-bill does.
The sample is the cost-related plugins under the GitHub dsh-plugin topic with ★ ≥ 40, plus the four published to npm. Lower-starred plugins such as deepseek-harness-wallet were not checked individually.
| dsh-bill | cost-meter | usage-stats | dsh-cost | cost-log | dsh-usage | usage-billing | |
|---|---|---|---|---|---|---|---|
| stars / version | — | ★42 / 1.3.1 | ★40 / 0.2.0 | ★3 / 0.2.1 | ★2 / 1.0.0 | ★2 / 0.1.1 | 0.2.2 |
| price source | online catalogue | built-in table + hand-scraped docs | none | built-in table | built-in table | user-entered | built-in table |
| models covered | 8000+ entries | 4 DeepSeek | — | 4 DeepSeek | 2 DeepSeek | one at a time, by hand | DeepSeek |
| unlisted model | flagged, excluded from totals | billed at flash rate | flagged unknown | billed as v4-pro | flagged ≈ |
flagged -- |
counted as 0 |
| history never recomputed | ✓ | ✗ | — | ✗ | ✓ | ✓ | manual backfill |
| content attribution | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| forecast | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
| budget | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ |
| account balance | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
| pre-install history | ✓ | ✗ | ✓ | ✗ | ✓ | ✓ | ✓ |
| agent tool | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ |
| currencies | 166, live rates | 3, fixed rates | — | follows UI language | ¥/$ | single | ¥ only |
? and excluded from totals — nothing is estimated;priceOverrides can override or add any price (rarely needed).Every request pays for the full context again, so one tool output read into the conversation keeps being billed on every subsequent request until it slides out of the window. Attribution is computed per request and summed.
Two things matter:
Per-segment token counts are estimated from character share (providers return only a total), and the total is the real billed figure, so the parts sum exactly to what you paid.
The session log holds token counts and model routes but not the request bodies — which is why pre-install history can be backfilled as spend, but cannot be attributed retroactively. The report states what fraction is covered.
The budget, its currency, the display currency shared by every figure, and which of the five surfaces are shown are all set on the Cost page in settings, and stored in $DSH_HOME/dsh-bill/prefs.json. The two currencies are separate settings: the budget's is the promise ("¥100 a month") and does not follow the display. (Not in the harness's own settings document: its API proxy serves a fixed allowlist of namespaces to the browser, so a plugin's namespace is never readable or writable from there.)
maxRecords (the in-memory ring buffer size, default 20000), agentTool (register bill_stats, default true), backfillTimeoutMs (the total budget for the boot-time history import, default 60000) and priceOverrides are plugin config and are validated at startup — a mistyped field is reported by name rather than leaving the report quietly empty. ~/.dsh/profiles/web/cordis.patch.yml is only needed when you want to override a price:
- insert:
- id: bill
name: 'dsh-bill'
config:
priceOverrides:
'anthropic/claude-sonnet-4-6':
inputPerM: 3.0 # USD per million input tokens (uncached)
outputPerM: 15.0
cacheReadPerM: 0.3
cacheWritePerM: 3.75
$DSH_HOME/dsh-bill/records.jsonl (a 20 000-entry ring buffer; older entries are folded into a rollup);| Layer | How |
|---|---|
| Capture | hooks the llm/stream waterfall, wraps the stream to observe usage chunks, passes everything through untouched |
| Pricing | llm-pricing resolves catalogue / peak rate / override at the call's own instant |
| Attribution | the request is split into classified segments at capture time and apportioned by position in the cache prefix |
| Backfill | lists the session log once, imports sessions it never recorded with a cancellable budget, deduplicating on turn:step |
| Per turn | the billTurns session projection folds the session log host-side and pushes to the client — no polling; billLive pushes the open step's estimated output as its own small value |
| Storage | in-memory ring buffer plus append-only JSONL, folded into a rollup before eviction; preferences in their own small JSON document; atomic replace and file locking borrowed from dsh-atomic-write |
| Transport | the ctx.connection.rpc channel /dsh-bill when there is one, falling back to POST /dsh-bill/api |
| UI | conversation.view / main + sidebar.panellist / conversation.chat.turnTail / conversation.composer.dock / sidebar.footer.action / sidebar.session.row.hover / settings.section, built on the host's --dsw-* design tokens |
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: cost-attribution、cost-tracking、token-usage。