Introduction¶
When developing agents in a DSH (DeepSeek Harness) environment, managing API call costs and quotas is a key part of day-to-day operations. Manually refreshing web pages or checking CLI output is inefficient and can easily miss important status changes. This plugin fetches official API data on the DSH Host side and provides a visual widget on the browser side, solving the problem of real-time monitoring and usage control.
Plugin Overview¶
This is a DSH client plugin maintained by XingPeng-Pixel. It runs on the DSH Host side, fetches data by making same-origin calls to the /alpha/* interfaces of Command Code, and exposes the status to the frontend. The plugin does not involve transmission of any plain-text API Key; all sensitive operations are completed on the Host side.
Core Features¶
- Real-time usage snapshot: Fetches data from interfaces such as
/alpha/whoamiand/alpha/usage/summary, supporting balance monitoring for the 5-hour and weekly rolling windows. - Multi-account support: Supports configuring multiple accounts, with the Host side fetching independently and isolating errors.
- Visual presentation: Provides a sidebar widget (auto-adapting width) and a settings-page dashboard (ring chart and progress bars), with colors changing according to usage rate.
- Zero key exposure: API Keys are parsed on the Host side (supporting environment variables, CLI credentials, etc.), while the browser side only consumes data via same-origin HTTP JSON interfaces.
- Interactive interfaces: Provides same-origin JSON query interfaces and the chat slash command
/commandcode-usage, supporting real-time push of consumption per conversation turn.
Installation and Enablement¶
The plugin has been published to npm and can be installed with one click using the official DSH plugin command:
dsh plugin --profile web add dsh-commandcode-usage-monitor
After installation, configure the API Key in the CMDAI Monitoring section of the DSH settings page or via environment variables.
Typical Usage¶
- Configure the environment variable:
export COMMANDCODE_API_KEY=user_xxx
You can also enter it in the DSH settings page.
- Verify the interfaces:
After installing the plugin, the Host starts a same-origin HTTP service. You can verify it with curl:
curl http://127.0.0.1:3099/commandcode-usage/status.json
curl http://127.0.0.1:3099/commandcode-usage/turn-cost.json
curl http://127.0.0.1:3099/commandcode-usage/health
- Use the slash command:
Enter/commandcode-usagein the chat window to view the current usage dashboard.
Applicable Scenarios and Notes¶
- Applicable scenarios: DSH developers who need to fine-manage Command Code quotas and costs.
- Security notes: The plugin runs with DSH process permissions, and the browser side never accesses plain-text API Keys.
- Current limitations:
- The
amountfield inturn-cost.jsonis currentlynull(no built-in price list). - The configuration items
storagePathandactiveAccountare reserved fields and do not yet affect runtime behavior. - The plugin depends on the official
/alpha/*interfaces; it must be updated synchronously if upstream interfaces change.
- The
Conclusion¶
By decoupling Host-side fetching from browser-side presentation, this plugin provides a secure and real-time usage monitoring solution. For developers who need to strictly control Token consumption or manage multiple accounts, this is a practical helper tool.