bowenliang123/dsh-context
bowenliang123/dsh-contextDSH 上下文洞察面板:Context 仪表盘 + /context命令 + Context 浏览器,查看 Context的分类组成、内容详情、演进趋势、压缩/注入事件、统计等一站式 Context 全生命周期管理。
会话与当日 API 费用统计、预算图框(已用%)、官方余额、历史看板,支持峰谷计价与官方价格一键同步。
English | 简体中文 · Install · Features · Screenshots · Community
Session cost tracking plugin for the DeepSeek Harness web GUI (bilingual UI)
v1.9.31 adds full settings to the plugin details page and fixes concurrent saves, CNY conversion and frozen currency totals. The future read-only settings page is prepared but remains disabled.
Host floor: DSH 0.2.0 · Adaptation target: 0.2.1-rc.2 (npm next). Expand the compatibility notes below for exact declarations, host records and troubleshooting.
Release notes: v1.9.31. Fully restart DSH after updating.
Full feature summary
Per-conversation cost · daily totals · OpenCode Go subscription quota display · budget with usage percentage · official account balance · custom provider balance · balance progress bar · history · peak/off-peak pricing hours display (peak hours UTC 01:00–04:00, 06:00–10:00; weekends and Chinese public holidays are off-peak all day, with separate labels) · pre-switch popup & system-notification alerts for peak/off-peak changes (position / lead time / alert type configurable) · one-click price sync from the official docs · Codex-style token usage heat grid · multi-vendor model pricing (built-in 170+ model-ID catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / Cline Pass / SCNet / Volcano Ark / Qwen / Xiaomi MiMo / Factory Droid) plan/API dual-track billing (subscription quota vs pay-as-you-go money separated, per-1% & full-window token/equivalent-cost estimates with daily/weekly/monthly curves) · subscription plugin compatibility (Codex / ChatGPT subscription plans) · mobile layout (dsh-pocket) · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
Compatibility, configuration and troubleshooting
Minimum supported host: DSH 0.2.0. The plugin declares the floor in engines.dsh, the host's admission gate for plugins, and no longer supports any DSH 0.1.x release; the adaptation target is the npm next release 0.2.1-rc.2. Exact ranges and how the host reads them: compatibility declaration.
Supports official Search/Fetch request fees, separately from model tokens.
Configuration and verification: OpenDesign queries, dynamic ports / LAN / WorkBuddy2API setup, and opacity fixes with performance measurements.
Desktop users: follow the Desktop installation instructions for the application's own CLI and desktop Profile.
Host records inside the declared range, and the earlier 0.1.x history, are in the compatibility record; the per-release list lives in package.json (dsh.compatibility.dshReleases).
If startup reports Ledger is busy and the cost widgets are missing, see ledger lock recovery.
Community and feedback: Join the WeChat group →. The WeChat group is open. You're welcome to join.
Feature · Location · Description OpenRouter model prices · Model picker / Settings → Cost → Prices · Hover a model for token rates and update time, or search the full catalog in Settings; automatic foreground refresh, price-change markers in the table and official model links. No API key or inference charges. Guide Cost statistics · Below the conversation input / title bar / Settings → Cost → Cost statistics · Day, week, month, all retained and custom periods; API/Plan split, trends, model/conversation rankings and per-call costs. Guide; statistics requires DSH’s asynchronous module loader Per-model cost card · Sidebar / composer dock (optional) · Disabled by default; inline Top-N, Other totals, shares and optional tokens, Today / Last 90 days, remembered expansion and a Top-1 chip. See the guide Per-conversation cost · Below the composer / session title bar · Live accumulated cost + input/cache/output tokens; the composer footer shows cache hit rate before Input (cache reads / all input, including cache writes); position configurable; Display settings can show only amounts below the composer, with the full line retained on hover Official balance · Sidebar top / Settings page (configurable) · Total / granted / topped-up balance, auto-refresh + manual refresh; optional three-segment progress bar (blue/orange/gray), whose today segment only counts official-channel spend (coding plans / custom providers excluded) Custom provider balance · Sidebar / Settings page (configurable) · Configurable HTTP balance lookup (e.g. LiteLLM); bilingual labels, currency, extract rules (dot path / number / add / subtract / divide — use divide for NewApi-style quota endpoints, see example); collapsible panel alongside Coding Plan quotas OpenCode Go quota · Sidebar / Settings / bottom-right dock (configurable) · Rolling-5h / weekly / monthly usage percent and reset times, each window toggleable independently, budget used % can show alongside; key auto-discovered (dedicated ref / official Go route apiKeyEnv / env / opencode login) or entered manually Coding plan quotas · Sidebar / Settings page (per vendor) · Multi-vendor coding-plan quota queries (Anthropic Claude Pro/Max, Z.ai / Zhipu GLM Coding Plan, MiniMax Token Plan, Kimi Code weekly + 5-hour quotas with PAYG balance fallback when no subscription key, OpenRouter credits, SiliconFlow balance, CommandCode 5h/weekly windows + monthly credits balance, Cline Pass 5-hour/weekly/monthly windows, Xiaomi MiMo Token Plan plan/compensation credit windows + period-end reset + balance via console cookie); per-vendor enable switch, key, display position and refresh interval (sidebar card in the same box style as the Go quota; the collapsed rail shows percentages), official endpoints by default, with a configurable trusted MiniMax origin; neutral hints when no credentials/subscription; SCNet Token Plan supports external console snapshots; without a valid snapshot, monthly usage is estimated from the local ledger via the official credits deduction table (no credentials needed) Subscription plugin compatibility · Settings → Cost → Codex / sidebar & quota cards · Detects installed Codex / ChatGPT subscription plugins and classifies their subscription calls as Plan quota instead of pay-as-you-go API spend; new usage is classified at record time, and a one-time dismissible prompt decides whether historical Codex billing is reclassified (idempotent). Explicit plan/API choices are never overridden. Details Codex quota display · Settings → Display → Codex / sidebar & quota strip · Reads actual quota windows from dsh-codex-subscription, the native DSH pi-ai login, @eddyskywalker/dsh-chatgpt-subscription, or dsh-codex-connect. Select auto (tries these sources in order), subscription, pi-ai, chatgpt, or connect. Native pi-ai needs no extra subscription plugin. Weekly-only accounts show no 5h bar. An explicit source uses only that source's current account; billing classification remains separate. SQLite session storage (better-session) · Host integration · Auto-detects the host session backend; with @morlay/better-session / @morlay/session-rdb (SQLite) storage, historical backfill, legacy import, history repricing, hour-bucket repair, fork cleanup and per-session cost/trajectory/call details keep working. The JSONL path is unchanged; old JSONL and RDB histories are not merged automatically. Guide OpenDesign quota · Sidebar / Settings (OpenDesign vendor) · Workspace coding-plan windows from the console API; with a Control Key, a 401/403 from the primary endpoint triggers one conservative /billing/preflight Bearer fallback, and window/wallet reads degrade independently. Troubleshooting Mobile / dsh-pocket layout · All cost UIs · On screens ≤1023px and dsh-pocket mobile layouts: single-column cards, horizontally scrolling tabs, 36px touch targets, dialogs capped at 90vh with safe-area padding and scrolling wide tables; desktop layout unchanged Quota strip · Above the input box (toggle in Display settings) · One compact chip row for budget used % / the Go main window / each enabled coding-plan usage window (short label + mini progress bar, ≥80% warn, ≥100% over, hover for reset times); click any chip to refresh its data source (budget → state, Go → Go quota, vendor → all its windows); multiple windows of one vendor merge into a single segmented chip; a first-run guide card lets you decide whether to enable it; hides itself when there is no quota data Click to refresh · Sidebar balance/quota boxes · Click the official balance / custom balance / coding-plan box (collapsed rail included) to fetch the latest data immediately; the box pulses while refreshing, failures keep the previous value and surface the reason in the hover tooltip; keyboard Enter/Space also triggers; a one-time guide card appears after the update Simple sidebar display · Settings → Cost → Display · Optional, with a one-time choice after updating. Condenses cards and caps panel height at 38% of the viewport and 320 px, while preserving amounts, quotas, refresh actions and hover details. Turn off to restore your layout. Guide Today's cost · Sidebar bottom (above the settings button) · “Today ¥x”, hover for call count and token details Budget box · Sidebar bottom (between the balance row and the settings button) · Rounded-square frame: budget, used %, progress bar, today's cost & share of budget, used/limit; ≥80% warning, ≥100% over-budget Summary cards · Settings page · Today / this month / cumulative cost and call counts External usage · Settings → Cost · Read-only snapshots from other processes on the same account; per-source tokens/calls/cost and recent days, plus DSH + external daily/monthly/all-time totals. Fresh external cost for today joins official balance reconciliation. Token usage stats · Settings page (Cost section) · All-time token totals (input/cache/output/calls) + a Codex-style 26-week daily usage heat grid that fills the settings width; hover a cell for that day's detail Token Plan usage stats · Settings page (Usage) · Per enabled coding plan (incl. Go): per-1% quota and full-window token / equivalent-cost estimates for the current windows (sample delta / live ratio), plus daily/weekly/monthly usage curves; plan-channel amounts are equivalent-only and never touch real money (issue #64) Today's sessions · Settings page · Per-session call count, input/cache/output tokens and cost History · Settings page · Per-day totals; retention days configurable (default 180) Pre-install history import · Automatic on first launch · After install/upgrade, the first launch automatically replays all host session logs to import conversations from before the plugin was installed (missing dates are rebuilt whole; existing dates only gain previously unknown sessions; idempotent and never double-counts live metering; costs priced at per-event historical rates); a manual re-run entry remains in Settings Budget settings · Settings page, top · Limit, period (today / month / cumulative / custom date range), used % Price table · Settings page · Per-model off-peak / peak prices (input/output shorthand supported; cache prices derived automatically); fully editable Peak/off-peak hours display · Settings / budget / today · Shows UTC peak hours 01:00–04:00 and 06:00–10:00 with the current tier; weekends and configured Chinese public holidays (Beijing dates) are off-peak all day, with separate labels; expanded view shows a period strip and countdown, collapsed view shows a vertical bar; independently toggleable Peak/off-peak switch popup alert · Global overlay · A full-width bracketed popup appears when the next tier switch is within the configured lead time (default 2 minutes, 1–30), with an alert-colored badge distinguishing entering peak vs off-peak; position selectable (bottom-right / screen center), alert type selectable (entering peak / entering off-peak / both), one alert per switch point; optionally sends a browser (system) notification (so you still get alerted when the page is backgrounded; requires granting notification permission); configured in the peak pricing panel in Settings, with a one-click popup preview (rendered by the real component — copy, position and notifications exactly as they will fire) Official price sync · Settings page · Fetches and parses the official pricing page, applies with one click; the official price currency is selectable (USD · English page / CNY · Chinese page) — CNY prices are booked at the display exchange rate and match the official CNY bill when displayed in CNY UI language · Settings → Display settings · Simplified Chinese / English / Follow DSH (auto); switches instantly and auto-saves Hide official balance / hide today's cost · Settings → Display settings · Two independent toggles: when on, the matching UI blocks (sidebar balance row & panels / today's cost row, budget details, overview today card) are not rendered at all; token and call-count stats stay visible — safe for screen sharing and screenshots AI price sync · prompt · DeepSeek official sync; other providers use the verified official price catalog and manual configuration Model & Plan adaptation guide · adaptation doc · Adaptation matrix for per-model billing and the Coding Plan vendors, the auto-matching mechanism and price sources (中文) Peak/off-peak alert guide · alert doc · Fully illustrated guide to the pre-switch popup and system notification: effect screenshots (EN/中文), settings reference and usage tips (中文) Token Plan usage stats guide · panel doc · Meaning of the four columns in the per-1% & full-window panel, the end-to-end delta estimation method and precision tags, the scope boundary (dsh-made calls only) and usage curves (中文) OpenRouter passthrough pricing · pricing doc · Token reference prices: offline snapshot, scoped zero-cost backfill, public-catalog refresh, custom-price preservation and failure fallback (中文) Multi-provider billing · Settings / ledger · OpenAI, Anthropic, Google Gemini, Mistral and other providers with input/output, cache and reasoning-token pricing isolated by provider + model Model-name auto-matching · Settings / ledger · Unknown model ids are matched against the price table: case/spaces/hyphens/dots and bracket annotations (e.g. (go)) are ignored — a normalized-equal or containing name hits (e.g. gpt5.6 luna(go)); router providers (opencode/zen etc.) search across all vendors; can be restricted to exact match, and unmatched models can be pinned to a specific entry in Settings Extended price catalog · Settings → Extended price catalog · Built-in reference catalog grouped by vendor and model family (expandable; vendors collapsed by default); mount entries into billing with one click — mounted third-party models live inside the catalog and stay editable; a per-model “Show directly in Cost settings” toggle chooses which models (DeepSeek included) appear directly in the price table
POST with a JSON body: in Settings → Cost → Quota, expand a custom balance entry, select POST, then fill in Request body (JSON). For example, if the endpoint expects an account and returns {"data":{"balance":12.5}}:
{"account_id":"example-account","include_credit":true}Set Extract rules (JSON) to {"remaining":"data.balance"}. Valid JSON is saved per entry and sent exactly as entered, including nested values and large integer IDs. Invalid JSON shows an error and keeps the last valid configuration; clearing the editor removes the body. GET/HEAD send no body while retaining it for a later switch back to POST. Content-Type: application/json is added automatically unless you supply a Content-Type header (any capitalization).
Existing request.body objects and raw strings remain supported. The body is ordinary saved configuration; {{VAR}} credential substitution applies only to request headers. For header authentication, use a reference such as {"Authorization":"Bearer {{MY_API_KEY}}"} and the credential input below it.
Display currency conversion: open Settings → Cost → Quota, expand a custom balance entry, and enable Convert USD balance to display currency. It defaults to off for each entry. Keep Source currency set to the endpoint's actual currency. With a USD balance of 54.3792, a CNY display rate of 7.2 and two decimal places, the balance displays as ¥391.53. Spend and API/manual limits convert together in the sidebar, settings and tooltips; progress percentages and stored balances do not change. Enter a manual limit in the source currency. The setting persists as convertToDisplayCurrency: true inside that customBalances[] entry (legacy customBalance is also supported).
The global exchange rate converts USD to the display currency. CNY/EUR source balances and Credits keep their original units; the switch is disabled for them. Alibaba Cloud balances use the currency returned by its API. No exchange-rate lookup or extra balance request is made when toggling this setting. Turning it off restores the original currency immediately.
DeepSeek CNY billing: USD prices × the display exchange rate and the official CNY table can give different amounts. Settings → Cost → Prices now explains this and provides a CNY selection button. See currency selection, sync and settlement timing.
For Qianwen / Alibaba Cloud fund accounts, use Add Qianwen / Alibaba Cloud balance to query available funds with a RAM AccessKey signature. The card uses the currency returned by the API. See the setup, permissions and balance definition.
Qwen Token Plan can use the official CLI subscription quota. Install the CLI on the DSH host and run qianwen auth login as the same OS user. Local estimates remain the default; CLI mode shows current account credits without changing the local ledger.
Local Qwen Token Plan credits include Plan calls assigned to Qwen. Existing subscription aliases such as qwen and qwen-tokenplan remain supported; custom providers can select Qwen under Model statistics → Billing class, or use an explicit vendor name and plan marker for auto detection. Explicit API calls are excluded. The pay-as-you-go qianwen provider is not assigned merely because its model ID is identical. Models outside the credits table need all three rates configured.
Xiaomi MiMo Token Plan quotas are queried with the MiMo console cookie, not an API key: log in at platform.xiaomimimo.com, press F12 → Network → find the balanceAlertConfig request and paste the full cookie request header into the MiMo card in Settings → Cost → Quotas (it must include serviceToken and userId; the DSH credential store keeps it as MIMO_COOKIE). The card shows the plan/compensation credit windows with the period-end reset (Beijing time) plus a balance row. Copy a fresh console cookie when the card reports an expired login. Token Plan inference keys (tp-* / ttp-*) are not accepted by this console adapter. Local plan statistics use the calendar month; compensation and balance are displayed without estimates because local calls cannot be attributed to those pools.
Each CLIProxyAPI source has a Gemini quota only option for its Antigravity groups. It defaults to off. Intentional filtering to no visible quota shows an empty list; malformed quota data still reports an error.
The extract rules accept four forms: a numeric constant, a dot path string, add/subtract over multiple paths, and divide scaling by a by divisor. `divide` fits NewApi and other endpoints that meter balance in integer quota (1 USD = 500000 quota — the same conversion cc-switch uses).
http:// is accepted when the host is 127.0.0.1 / localhost / [::1] (the traffic never leaves the machine), which covers local read-only routes that listen on loopback only and serve no TLS (e.g. dsh-workbuddy-connect's /plugins/dsh-workbuddy-connect/status). Every non-loopback host still requires https; plaintext is refused.With dsh-workbuddy-connect installed, its web status route already returns the aggregated credit total — no credential needs to be copied:
{
"enabled": true,
"display": "sidebar",
"refreshMinutes": 15,
"label": "WorkBuddy 积分",
"labelEn": "WorkBuddy Credits",
"unit": "CREDITS",
"request": { "url": "http://127.0.0.1:3080/plugins/dsh-workbuddy-connect/status", "method": "GET", "headers": {} },
"extract": { "remaining": "credits.total" }
}Adjust the port and response fields to the local service. This example requires the other plugin to expose that route. Cost-meter refuses redirects and continues to enforce configured credential host allowlists.
For NewApi GET /api/usage/token (response { "code": 200, "data": { "total_granted": ..., "total_used": ..., "total_available": ..., "unlimited_quota": false } }):
{
"enabled": true,
"display": "both",
"refreshMinutes": 15,
"label": "NewApi",
"labelEn": "NewApi",
"unit": "USD",
"request": {
"url": "https://your-newapi-host/api/usage/token",
"method": "GET",
"headers": { "Authorization": "Bearer {{NEWAPI_API_KEY}}" }
},
"extract": {
"remaining": { "op": "divide", "path": "data.total_available", "by": 500000 },
"maxB