Introduction¶
In the DSH ecosystem, when integrating multiple vendors such as DeepSeek, GLM, OpenCode Go, and Volcengine simultaneously, manually checking balances and quotas is cumbersome. The api-monitor plugin provides a resident monitoring panel with an entry at the bottom of the sidebar. Clicking it opens a floating window that aggregates the balance, quota, and token usage and cost of the current conversation tree.
The plugin is maintained by jcleener and open-sourced under the MIT license.
Core Features¶
Multi-vendor polling
The plugin host process is responsible for periodically polling 5 data sources: DeepSeek balance, GLM Coding Plan quota, OpenCode Go usage, Volcengine Coding Plan (GetCodingPlanUsage), and Volcengine Agent Plan (GetAFPUsage).
Sidebar and floating window
The bottom of the sidebar provides a vertical “API Usage” summary entry, with one line per vendor and a status dot. Opening the floating window displays detailed data.
Conversation tree usage aggregation
The plugin collects token usage from the root conversation and its subagent conversations (subagents.listDescendants), bucketing by source (provider/model). Concrete cost is calculated only for DeepSeek conversations.
Peak/off-peak time-based pricing
Based on the time field in assistant/message events, it identifies peak and off-peak periods (Beijing Time Monday to Friday 9:00-12:00 and 14:00-18:00 are peak) and displays usage and amount separately.
Automatic official price scraping
The plugin includes a regular expression parser for the official DeepSeek pricing page (6-hour TTL). If parsing fails, it retains the built-in rate card.
Zero third-party dependencies
The host side uses only Node.js built-in capabilities (fetch / crypto.subtle) and @deepseek-ai/schemastery; Volcengine signing uses a manually implemented SigV4.
Installation and Activation¶
The plugin does not provide an automatic installation script and must be manually placed in DSH’s profile directory.
- Place the plugin package into
profile/node_modules. - Add a mount line to
profile/cordis.patch.yml:
- insert:
- id: api-monitor
name: api-monitor
- Restart the DSH instance to activate the plugin.
- (Optional) If you need to use Volcengine features, configure
volcesAccessKeyIdandvolcesSecretAccessKeyin the settings.
Configuration¶
The plugin registers its configuration through the host settings namespace. The fields are as follows:
| Field | Type | Default | Description |
|---|---|---|---|
volcesAccessKeyId |
string | '' |
Volcengine AccessKey ID |
volcesSecretAccessKey |
string | '' |
Volcengine SecretKey |
volcesTier |
string | 'auto' |
Plan tier. Only retained and displayed, not used in requests |
pollIntervalSeconds |
number | 60 |
Polling interval in seconds. Only takes effect when applied; changes require a restart |
warnPercent |
number | 70 |
Warning threshold (turns yellow when remaining quota ≤ 100 − this value) |
dangerPercent |
number | 90 |
Danger threshold (turns red when remaining quota ≤ 100 − this value) |
balanceWarn |
number | 10 |
Marked red when balance is below this value (CNY) |
priceTable |
dict(any) | {} |
Unit price override table, supports {peak,offPeak} form |
showCacheHitRate |
boolean | true |
Whether to display the cache hit rate row |
showResetTime |
boolean | false |
The client code does not read this field |
entryVisibility |
object | all true | Controls whether each vendor is displayed in the sidebar entry |
The floating window UI allows direct modification of Volcengine AK/SK, plan tier, and the visibility status of each section. priceTable, pollIntervalSeconds, thresholds, and showCacheHitRate must be modified directly in the settings.
Typical Usage¶
Force data refresh
In the browser console or via API call:
POST /api-monitor/refresh
This forces a refresh of official prices and immediately triggers one polling cycle.
View conversation snapshot
View aggregated data for the current conversation via API:
GET /api-monitor/snapshot?root=<会话ID>
Configure Volcengine
To monitor Volcengine Coding or Agent Plan, you must provide the AccessKey in the settings and write it via the “key configuration” item in the floating window.
Notes¶
Dependency on internal class names
The client CSS is directly bound to DSH internal class names (e.g., .hHd-Xa_*). Changes to shell layer class names may cause the vertical layout to fail, but do not affect functionality.
Client and host polling differences
The actual polling interval on the browser side is 8000ms, while the floating window UI text displays the host pollIntervalSeconds value (default 60s).
Qwen section behavior
The qwen section is visible in the sidebar entry, but the host has no corresponding polling logic. Its data comes from conversation bucket aggregation, and its quota line is hard-coded in the client as “API query unavailable” and provides an external console link.
Conversation attribution
Only events with source.provider are placed into source buckets. Events lacking routing information are counted only toward the total and are not distinguished by source; therefore, “the sum of the individual sources ≤ total” is expected behavior.
Version and dependency declarations
package.json declares three client dependencies (such as @deepseek-ai/dsh-client-locale), but lib/client.js actually only require("react"). The panel copy is hard-coded in Chinese, with no internationalization support.