Introduction¶
DeepSeek Harness (DSH) adopts a plugin-based architecture. When developing agents on the Web, it is often necessary to generate images directly or track the cost of multi-turn conversations. dsh-toolkit is a DSH Web Bundle that integrates an image generation panel and a Token usage statistics panel. Once installed via the plugin Manager, it can be used directly in the sidebar.
Component Overview¶
This Bundle contains two independent components:
- image-gen (Sidebar Panel Order 49): Provides image generation tools and a panel. Supports text-to-image, image-to-image, and editing. Calls OpenAI-compatible interfaces and manages the image library and prompts.
- token-usage (Sidebar Panel Order 50): Tracks Token consumption and costs for all sessions (including subagents), featuring an activity heatmap for the past year.
The two components can be enabled independently; they have different panel keys and different route prefixes.
Installation & Activation¶
Prerequisites¶
- DSH version 0.1.7 or higher.
- Runtime environment must be DSH Web (
client.platform: web).
Installation¶
Declare the dependency in the profile’s package.json and then load it using plugin_manager:
- Declare the dependency in the profile’s
package.json:
// ~/.dsh/profiles/<profile>/package.json
{
"dependencies": {
"dsh-toolkit": "^0.2.0"
}
}
- Execute the installation command:
plugin_manager install_bundle dsh-toolkit
Alternatively, restart DSH to trigger automatic loading.
Local Development & Debugging¶
For local debugging, you can use a local link in package.json:
"dependencies": {
"dsh-toolkit": "link:/absolute/path/to/dsh-toolkit"
}
Note:
remove_bundlewill also remove the declaration from the profile’spackage.json. You must manually add it back before reinstalling.
Core Features¶
Image Generation¶
1. Tool Invocation¶
Call the generate_image tool within the Agent code.
Function Signature:
generate_image(prompt, size, count, image)
Parameter Description:
| Parameter | Description | Default Value |
|---|---|---|
prompt |
Required. Detailed prompt (subject, style, scene, etc.). | - |
size |
Output pixel dimensions: 1024x1024, 1536x1024, 1024x1536, etc. |
1024x1024 |
count |
Number of images to generate, 1–4. | 1 |
image |
Optional array of reference images (for image-to-image/editing), max 9 images. Supports local paths, URLs, or data URLs. | - |
Return Value:
Returns ok, model, count, size, imageUrls (valid for approx. 24 hours), imageUrl (first image), and files (local disk paths). Includes partial status upon partial failure.
2. Sidebar Panel Operations¶
- Open the sidebar “Image Generation” → “Settings”.
- Click ”+ Add Model”, and fill in the API URL, Model ID (click “Fetch Available Models” to detect), and API Key.
- Click “Add to Catalog”, and select it in the “Default Model” dropdown.
- In the “Text to Image” or “Image to Image” area, enter a prompt or upload a reference image, and click generate.
Token Usage & Cost¶
This component aggregates Token consumption and costs for all DSH sessions (including subagents). Data is sourced from the session event stream without requiring additional instrumentation.
Panel Features¶
- Data Overview: Displays total actual Tokens consumed, total requests, and total cost at the top. The time range can be switched between
Today,7 Days,30 Days,90 Days,All, or Custom. Cost currency can be switched between$ USD/¥ CNY. Main data polls every 15 seconds and supports manual refresh. - Metric Cards: Displays New Input, Output, Cache Creation, Cache Hits, Reasoning, and Cache Hit Rate (with a progress bar).
- Activity: A heatmap of the past year by day, colored according to the number of requests per day.
- Model Distribution: Displays Model / Requests / Input / Output / Cache Read / Cache Write / Total / Cost / Percentage.
- Usage Trends: A dual-Y-axis line chart (Tokens on left, Cost on right), with lines drawn independently for each metric.
- Request Viewer: Aggregated by session, supports filtering by
All Sources/Main Session/Sub Session, and searching by Title / ID / Path. Clicking a row expands to show details of individual requests. - Pricing Details: Allows adding, editing, or deleting price lists, syncing with models.dev, and setting exchange rates.
Configuration & Environment Variables¶
Plugin runtime data is collected under $DSH_HOME/dsh-toolkit/ by default (locally defaults to ~/.dsh/dsh-toolkit/).
Key Environment Variables:
| Environment Variable | Function | Default Value |
|---|---|---|
DSH_TOOLKIT_DATA |
Redirects the entire data directory (absolute path, supports ~ expansion). |
$DSH_HOME/dsh-toolkit |
IMAGE_GEN_DIR |
Unified directory for saving generated images. | $DSH_HOME/dsh-toolkit/images |
IMAGE_GEN_CONFIG |
Model catalog configuration file. | $DSH_HOME/dsh-toolkit/config.json |
IMAGE_GEN_LIBRARY |
Prompt library file. | $DSH_HOME/dsh-toolkit/library.json |
IMAGE_GEN_USAGE |
Image generation billing record file. | $DSH_HOME/dsh-toolkit/usage.jsonl |
CUSTOM_API_KEY |
Default key source. | — |
TOKEN_USAGE_PRICING |
Custom pricing file for Token usage. | $DSH_HOME/dsh-toolkit/token-usage/pricing.json |
MODELS_DEV_API_URL |
Sync source for models.dev. | https://models.dev/api.json |
TOKEN_USAGE_DIAG |
Set to 1 to write token-usage diagnostic logs. |
Disabled |
DSH_HOME |
Location of DSH Home. | ~/.dsh |
Data Persistence¶
Plugin runtime data is collected under $DSH_HOME/dsh-toolkit/ by default:
$DSH_HOME/dsh-toolkit/images/: Unified directory for generated images.$DSH_HOME/dsh-toolkit/favorites/: Favorite images (at the same level asimages/).$DSH_HOME/dsh-toolkit/config.json: Model catalog configuration.$DSH_HOME/dsh-toolkit/library.json: Prompt library.$DSH_HOME/dsh-toolkit/usage.jsonl: Image generation billing records.$DSH_HOME/dsh-toolkit/token-usage/pricing.json: User pricing + models.dev sync results.
Notes¶
- The plugin is not bound to any specific service provider; the model catalog must be added manually.
- The plugin is licensed under MIT.
- Data is persisted in the
$DSH_HOME/dsh-toolkit/directory; please ensure this directory has read and write permissions.