dsh-cost-breakdown: DSH Session Cost Invoice and Official RMB Pricing

Introduction

When running long sessions, sub-agents, or cross-platform routing in DeepSeek Harness (DSH), token usage is often visible in the context panel. However, figuring out “how much this conversation cost,” “how much remains in the account,” or “whether we’re currently in peak or off-peak hours” usually requires manual mental math against the official pricing table. Upstream community plugins mostly price based on models.dev USD rates, and DeepSeek’s peak bucket applies a uniform fixed multiplier without distinguishing statutory holidays.

Below we introduce the community plugin dsh-cost-breakdown (maintainer liaimei). Building on the context-insight capabilities of dsh-context, it adds official CNY pricing tables (peak/off-peak + statutory holidays), a persistent cost reading below the input box, and cost summaries broken down by platform and currency. Classified as admin-security, the plugin’s source and documentation can be found on the SkillHub catalog page and GitHub repository.

What Is This

dsh-cost-breakdown is a Web-side plugin for DSH (package name dsh-cost-breakdown, current version 0.1.0, license Apache-2.0). The repository states that its src/ preserves upstream logic from dsh-context (main@209169d) verbatim, then layers its own pricing and reading capabilities on top. It has a different name from the upstream package, so theoretically both can coexist, though the README advises against enabling both simultaneously to avoid duplicated context entry points in the UI.

The problems it solves can be summarized in three points: visible balance, estimating CNY costs using official peak/off-peak and holiday rates, and reviewable consumption breakdown per session (including sub-agent-derived sessions). These are presented through multiple entry points—a reading below the input box, the right sidebar, and the left-side statistics page—with each entry point having a distinct responsibility to avoid mixing tokens and monetary amounts on the same line and causing miscalculations.

Retained Upstream Capabilities

After installation, dsh-context-style capabilities remain available, such as:

  • Context dashboard: composition, trends, browser, event list, file activity, agent network;
  • Left sidebar “Statistics” page: token and cost summaries across all sessions;
  • /context command and Ctrl/⌘ popup;
  • Per-session token cards (with sub-agent collapsing) and the upstream foundation for platform-consumption display logic.

On top of these, this plugin reworks the pricing source, some UI column layouts, and the input-area reading. See the repository’s NOTICE and FORK.md for detailed differences.

Core Features

Official CNY Pricing Table and Peak/Off-Peak

The pricing logic lives in src/shared/officialRates.ts. For models covered by the official table, it uses three buckets priced in yuan per million tokens: cache hit, miss (including cache writes), and output. Off-peak prices are half of peak prices.

Model Off-Peak (Cache Hit / Miss / Output) Peak
DeepSeek-V4.1-Flash 0.02 / 1 / 4 0.04 / 2 / 8
DeepSeek-V4-Pro 0.15 / 4.5 / 13.5 0.3 / 9 / 27

Peak/Off-Peak determination (Beijing Time): Monday–Friday 09:00–12:00 and 14:00–18:00 are peak hours; all other times are off-peak. It includes the built-in 2026 State Council statutory holiday schedule (31 days); holidays are priced at off-peak rates all day, consistent with weekends. Host configuration can override this:

holidays: ['2026-10-01', ...]   # YYYY-MM-DD, Beijing Time

If the config contains no valid dates, it safely falls back to the built-in table rather than treating it as “no holidays” (which would incorrectly apply peak pricing on holidays). Models not in the official table still go through the models.dev USD branch with fallback; peak/off-peak is resolved on the host side (isPeakAt in src/host/foldMetering.ts), and the persisted bucket carries the applicable rate at the time.

Pricing convention (important): In DSH, cacheReadTokens represents cache-hit input, inputTokens represents cache-miss input (including cache writes), and outputTokens includes thinking tokens—the three buckets are mutually exclusive. The plugin prices each bucket separately; costs are estimates, and the platform bill is authoritative. Models without configured rates are labeled “no rate configured” rather than showing ¥0.

Persistent Reading Below the Input Box

This entry point does not exist upstream. When collapsed, it shows a single line: This session’s cost · Balance · Current peak/off-peak (styled consistently with the official same-row token reading capsule). Peak/off-peak is calculated in real time, and the badge includes a countdown to the next toggle; hovering or expanding the card shows the full peak hours. Weekends and statutory holidays state directly that off-peak pricing applies all day, rather than showing a misleading countdown.

Clicking expands a detail card containing the same Token Stats and Cost Stats cards as the statistics page, plus the current period’s official price table; the overlay portals to document.body to avoid being clipped by the input area’s overflow.

Balance sources are tried in order: ① DSH account login (deepseekAccount, desktop login suffices, no API key required); ② API-key providers. The reading displays cached values first, then corrects on a 60-second cycle.

Each Entry Point Answers One Thing

Entry Point Question It Answers
Left sidebar “Statistics” page Token and cost summary for all sessions
In-session “Context” tab Context and tokens only, no monetary amounts on the page
Right sidebar “Session Summary” panel This session’s token summary + consumption by platform
Reading below the input box Consumption and balance for the currently used platform

Platform consumption summary (statsPlatforms.tsx): a single session may span multiple platforms, with one card per platform, each in its own currency (DeepSeek ¥, third-party $, points for points-based platforms), never summed together; within each card are per-model consumption and call counts. All three cost estimates share estimateSessionCostByBucket from client/cost.ts, reducing reading drift.

Derived Sessions and Data Sources

Sub-agent / fork sessions truncate the inherited prefix at session/end-seed { inherited: true }, counting only calls that actually occurred in this session to avoid double billing (upstream behavior, preserved in this repository).

Data Source
Balance Host host/balance.ts requests api.deepseek.com/user/balance (plugin does not touch tokens)
Usage usage from assistant/message in session logs, folded by the host into (provider, model, time-slot) buckets
Prices Official CNY table; others from models.dev
Time slots Beijing peak/off-peak rules + holiday table

Installation and Activation

The plugin targets the web profile and ships with compiled artifacts in lib/, so no local build is needed when installing from GitHub. package.json declares Node engine ^22.19.0 || >=24.0.0 and marks compatibility with DSH 0.1.7-rc.2 and 0.2.0-rc.2.

Install first, then restart DSH (the host half does not hot-reload):

dsh plugin --profile web add github:liaimei/dsh-cost-breakdown

After installation, a persistent cost reading should appear below the input box. To check whether the host loaded the new code, use a request with the session cookie: POST /api/dsh-cost-breakdown/skills should return 200; a 404 means restart DSH. The README warns: be cautious with dsh plugin list when troubleshooting, as it triggers reconcile and may alter the lock; for read-only status checks, view ~/.dsh/profiles/<profile>/package.json and node_modules/.

For local development, you can use a link install (replace the path with your checkout directory):

dsh plugin --profile web add "dsh-cost-breakdown@link:/path/to/dsh-cost-breakdown"

Typical Usage

  1. Check how much the current session cost and the balance: the reading below the session input box; click to open the overlay for details—Token/Cost cards and the price table.
  2. View the full account’s historical summary: open the left sidebar “Statistics” page and check the Token section and Cost section separately; DeepSeek official usage sessions show peak/off-peak breakdowns in the Cost section (for the currently active platform only).
  3. Context only, no money: stay on the “Context” tab or use /context; monetary amounts appear in the Cost section of the right sidebar “Session Summary.”
  4. Custom holidays: set the holidays array in host config; malformed or entirely invalid dates fall back to the built-in 2026 table.

Use Cases and Caveats

Who it’s for: developers who long-term use DeepSeek official or mixed routing in the DSH Web client, need to estimate session costs using official CNY peak/off-peak rates, and want a persistent view of balance and peak/off-peak status next to the composer.

Important to know:

  • The plugin runs with the current DSH process’s privileges; before installing, read the source code and LICENSE to confirm it meets your security and compliance requirements.
  • High feature overlap with dsh-context; enabling both easily creates duplicate entry points.
  • The community catalog SkillHub has no official affiliation with DeepSeek or Hithink RoyalFlush; the DSH ecosystem follows an independent community distribution model of “everything is a plugin.”
  • Costs are estimates based on log usage and price tables; actual charges are subject to the platform bill.

Conclusion

dsh-cost-breakdown preserves dsh-context’s context visualization and brings DeepSeek’s official CNY peak/off-peak pricing, holidays, per-platform per-currency billing, and a persistent reading next to the composer into a single data pipeline. If you need to directly check “how much this session cost, how much remains, and whether it’s currently peak or off-peak” inside the Harness, install it from the catalog page or GitHub using the commands above, restart, and verify below the input box.

  • Catalog page: https://www.skillhub.cn/plugins/liaimei/dsh-cost-breakdown
  • GitHub: https://github.com/liaimei/dsh-cost-breakdown
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye