Introduction

When developing or debugging with the DeepSeek Harness (DSH) Web interface, visually inspecting the Token consumption and cumulative cost of each interaction helps control costs. The arthur20150522/dsh-token-usage-cost plugin provides a purely UI-based display, does not enter the model context, and does not affect session or token statistics.

Feature Overview

This plugin provides the following capabilities in the DSH Web interface:

  1. Per-round cost chip: After each round (question → answer + tool calls) ends, the cost of that round, input/output token counts, and model short name are always visible in the copy/feedback toolbar. It supports color coding by model, with details available on hover.
  2. Session cumulative line: Displays the cumulative cost and token counts for the entire session below the status line above the input bar. When switching models, it displays “Multi-model”.
  3. Automatic price table retrieval: Concurrently fetches prices from authoritative sources such as the LiteLLM community table, OpenRouter, and models.dev, automatically recognizes their formats and merges them into a table, with disk cache support on the host side.
  4. One-click reconciliation synchronization: Click the ⚙ at the end of the session cumulative line to enter the configuration page. Use the ⟳ sync button to fetch all price sources and enumerate the configured models; after automatic matching, it writes the result back to the modelMap configuration.
  5. Multi-dimensional cost configuration: Supports configuring costs by model, currency and exchange-rate conversion, peak/off-peak and time-slot pricing, and historical model attribution.
  6. REST API: Provides endpoints for configuration read/write, price queries, forced refresh, and reconciliation.

Installation and Activation

Install via the official CLI:

dsh plugin --profile web add github:arthur20150522/dsh-token-usage-cost
# 然后重启 dsh web

The package includes dsh.bundle and cordis.patch.yml, which are automatically mounted, so there is no need to manually modify the profile patch file.

Usage

  1. View per-round cost: After each interaction ends, observe the chip in the copy/feedback toolbar. The display format is Round · Cost · ↑Input ↓Output · Model short name.
  2. Edit configuration: Click the ⚙ at the end of the session cumulative line to open the built-in mini editor. You can modify the currency/exchange rate, peak/off-peak time-slot rules, model mappings, or manually override prices.
  3. Reconciliation synchronization: In the configuration page, click the ⟳ sync button. The plugin fetches price sources and matches the currently configured models, automatically writes matched mappings back to the configuration, and lists unmatched entries.

Notes

  • Zero build chain: The plugin requires no build. The source code consists of lib/index.js (host, ESM) and lib/client.js (client, factory CJS classic script). Modifying host code requires a restart, while modifying client code only requires refreshing the page.
  • Data source: Cost calculation preferentially reads the usage, message.source, and event time of each assistant/message entry in the full DSH session.history.
  • License: MIT License.

Development and Maintenance

This plugin follows a zero-dependency principle. The main files are located in the lib/ directory. Developers can directly run tests in a local Node ≥ 18 environment (node test\run-tests.mjs).