dsh-turn-price: Display Per-Turn CNY Cost in the DSH Web Interface

Introduction

When running long sessions with DeepSeek Harness (dsh), token usage is often scattered across multiple step events, and platform billing is reconciled post-hoc. If you want to see “approximately how much this turn cost” directly in the local interface and have historical turns recalculated after price changes, the client-side needs to combine the usage from session logs with a local price table. dsh-turn-price is a dsh client plugin released by community maintainer littlefish04. It displays the estimated amount for each completed turn on a separate line below the turn (defaulting to the RMB symbol). Clicking it expands the details.

What is this

dsh-turn-price is a standard dsh bundle (dsh.bundle.patch + dsh.client) designed for the dsh Web interface. It adds a cost information line above the action row for each completed turn, without occupying the action row that appears on hover. Amounts are calculated in real-time based on the current price table: token usage is taken from the usage of each step in the dsh session log—the plugin does not estimate character counts; if the price table is modified later, the amounts for all historical turns are immediately recalculated at the new prices.

The amount on the interface is an estimate, not a bill: it equals the token count reported by the provider multiplied by the unit price in the local price table. Actual settlement is subject to the platform.

  • Maintainer: littlefish04
  • Category: Client (Web)
  • License: MIT
  • Compatible with dsh: >=0.2.0-rc.1 <0.3.0
  • Current recommended npm version: 0.2.3

Core Features

Cost Line & Details Below Turns

Below each completed turn, a “Turn Cost” line displays the amount (e.g., ¥0.0874), an optional rule badge (e.g., “Limited Time Offer” or “Peak ×2”), and an expand arrow. Clicking the amount expands the “Turn Cost Details,” which typically include:

  • Model (provider / model); if the model changed within a turn, it notes that pricing is based on the last one in the routing table.
  • Billing Time (based on timezone offset in settings, default UTC+8).
  • Token Source description (host-folded session events or in-page fallback data).
  • Effective Price & Unit Price Basis (default per 1,000,000 tokens).
  • Category / Tokens / Unit Price / Amount breakdown table and total.

Price Table & Pricing Rules

Maintain the price table by model in Settings → Per-Turn Cost. The four billing categories are: Uncached Input, Cache Hit, Cache Write, and Output. The effective unit price is determined by the turn end time, with the following priority:

  1. Limited-time Specials (promos): Absolute time ranges; prices are self-contained within the range and do not stack with peak/off-peak coefficients.
  2. Peak/Off-peak Rules (rules): Cyclical time slots within a week; prices are multiplied by a coefficient. Supports crossing midnight.
  3. Base Price: Used when the above rules are not matched.

If multiple rules of the same type match, the one later in the list takes priority. The plugin provides recommended settings for DeepSeek official peak/off-peak standards (Base price = off-peak price, Peak/off-peak rule ×2 covers weekday peak hours) and pre-fills some models. The settings page provides a “Restore DeepSeek Official Prices” button.

Token Usage Source

The plugin performs a fault-tolerant summation of usage for each step, rather than relying solely on dsh’s built-in strict folding (strict folding might hide the entire turn if totalTokens or complete cache fields are missing). Missing fields are recorded as 0, steps missing usage are skipped, and retry steps are accumulated according to rules; if there are no samples for the entire turn, the amount is not displayed (rather than showing ¥0.0000). If the host is unavailable, the browser side can fall back to the assistant-step.usage on the page for each step to perform the same fault-tolerant summation.

0.2.x Extended Capabilities

The README marks 0.2.3 as the recommended full-feature version. In addition to per-turn costs and the price table, it includes balance, today/month/session summaries, a consumption calendar, manual bookkeeping, daily export, etc. (four cards in the settings page: Model Prices → Accounts & Balance → Consumption Records → Display Items). 0.1.1 only retains the earlier “Per-Turn Cost + Price Table” capability; do not install 0.1.0, as it will prevent dsh from starting.

Storage & Privacy

The price table is stored in the plugin’s Cordis Config, with a disk path like:

<DSH_HOME>/profiles/<profile>/cordis.patch.yml     # Entry id: turn-cost

Token and unit price calculations required for per-turn amounts are performed locally; the host-side component reads the current session event stream, does not scan other session bodies, does not read API Keys, and does not send usage data to third parties.

Installation & Enablement

The three address forms for this plugin are equivalent. You need to specify a profile when installing (desktop version commonly uses desktop, dsh web commonly uses web).

Address Form Command
npm Package Name dsh plugin --profile <profile> add dsh-turn-price
Git Repository dsh plugin --profile <profile> add github:littlefish04/dsh-turn-price
Local Directory / Tarball dsh plugin --profile <profile> add <absolute path>

You can also fill in any of the above addresses via “Add Plugin” in the Plugins page of the application sidebar.

It is recommended to pin the version to avoid installing an old version due to mirror sync delays:

dsh plugin --profile desktop add dsh-turn-price@0.2.3

Verify the latest version from the official npm source:

npm view dsh-turn-price version --registry https://registry.npmjs.org

After installation, you need to restart the profile to take effect (fully quit and reopen the desktop app, or restart dsh web). To upgrade, you must uninstall and then reinstall (dsh currently does not support automatic plugin updates; the price table is in the same profile configuration space, so it will not be lost during uninstall/reinstall):

dsh plugin --profile desktop remove dsh-turn-price
dsh plugin --profile desktop add dsh-turn-price@0.2.3

Uninstall:

dsh plugin --profile <profile> remove dsh-turn-price

Typical Usage

  1. Install dsh-turn-price@0.2.3 using the command above and restart the profile.
  2. Open Settings → Per-Turn Cost and configure base unit prices for commonly used models; if connecting to DeepSeek official peak/off-peak, you can fill in the base price and two weekday peak ×2 rules as suggested in the README, or use “Restore DeepSeek Official Prices”.
  3. Return to the session interface to view the cost line below completed turns; click the amount to check token category details and matched rules when verification is needed.
  4. If official prices or your contract prices change, modify the price in the settings page and save. Historical turn amounts will be immediately recalculated based on the new table.

Common display-related default values include: Show per-turn cost and summary line (On), Currency symbol ¥, Detail decimal places 4, Summary line decimal places 2, Timezone offset +8, Tokens per unit 1000000, Unconfigured model default “Do not show amount”.

Applicable Scenarios & Notes

Who is it for: Developers who debug agents in dsh Web for long periods, need to cross-reference token structures with local unit prices per turn, or need to make estimates using peak/off-peak or limited-time rules.

Compatibility Boundaries:

  • Requires Node >=20 and dsh >=0.2.0-rc.1 <0.3.0; if incompatible, the installer may refuse. You can use dsh plugin allow-version according to the documentation to permit specific versions.
  • Multiple models in the same turn cannot have usage split by model; pricing is based on the last distinct route in the routing table.
  • Cross-time-period turns are priced based on the turn end time.
  • Turning off the built-in “Performance Usage” compact mode does not affect this plugin’s amount display.

Before Installation: The plugin runs under dsh process permissions. Before installation, you should review the repository source code and MIT license yourself to ensure it meets your environment and compliance requirements. The community plugin directory is an independent site and has no official affiliation with DeepSeek / High-Flyer.

Links

  • SkillHub Directory Page: https://www.skillhub.cn/plugins/littlefish04/dsh-turn-price
  • GitHub Repository: https://github.com/littlefish04/dsh-turn-price
  • npm Package: dsh-turn-price

Through the steps above, you can keep “how many tokens were used per turn and how that translates to money under which rules” within the same view in your dsh session. Price changes allow for retroactive calculation on historical turns, facilitating local cost control and debugging comparison.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye