dsh-usage-dashboard: Mounting usage reports on DSH Web

Preface

When using DSH to run agents, token consumption and costs are often scattered across logs or standalone scripts. While dsh-usage-stats can aggregate usage into an HTML report, the report file itself does not automatically appear on the same site as the daily DSH GUI. Setting up a separate static file server or copying links adds an extra layer of entry points, and authentication must be handled manually.

Here we introduce dsh-usage-dashboard: a DSH host plugin that mounts the HTML generated by dsh-usage-stats to the host web server at /usage. It reuses the host’s login session for authentication. The package is pure ESM with zero dependencies and does not modify other projects.

What is this

The plugin does exactly one thing: register an HTTP route within the DSH host process to return a local HTML report file based on a configured path. If not logged in or if the Host/Origin check fails, it utilizes the host’s existing requestRejection, avoiding the introduction of an independent token system.

Why a plugin instead of modifying the stats project

Report data and generation logic remain the domain of dsh-usage-stats. The DSH host already provides two capabilities required to mount routes and reuse browser sessions:

Purpose Interface
Mount your own HTTP route ctx.webServer.register({ kind, path, handler })
Reuse host login state for auth ctx.connection.requestRejection(req) → 401 / 403 / undefined

Documentation states that requestRejection applies Connection’s Host/Origin checks and browser authentication to “another web route.” A browser capable of opening the DSH GUI can usually open /usage under the same origin (session cookies are Path=/; SameSite=Strict).

Core Features

  1. Route Mounting: Default path is /usage, configurable (must be valid: start with /, not root, no trailing slash, no query strings/fragments; invalid values throw errors during loading).
  2. Authentication: Authenticates before reading the file to prevent unauthorized requests from becoming probes for “file existence.”
  3. Static HTML Service: Supports GET/HEAD; normal responses are 200, text/html, with Cache-Control: no-store and X-Content-Type-Options: nosniff.
  4. On-disk Reading: Reads the report file on every request; simply refresh the page after regenerating HTML in the stats side, no need to restart dsh web.
  5. Profile Integration: Includes dsh.bundle.patch in the package. After dsh plugin installation, it automatically reconciles dsh.profile.bundles, so manual profile editing is generally unnecessary.

Response behavior summary:

Scenario Response
Unauthenticated 401
Host/Origin check failed 403
Method not GET/HEAD 405, Allow: GET, HEAD
Report file not found 404 (Response body does not echo configured path)
Normal 200, HTML

Installation and Activation

This plugin is in a standalone repository and should be installed under the web profile. You must restart dsh web after installation for it to take effect.

Install from GitHub (following main):

dsh plugin --profile web add github:SJTUMalPan/dsh-usage-dashboard

Lock commit for reproducible installation:

dsh plugin --profile web add "git+https://github.com/SJTUMalPan/dsh-usage-dashboard#<sha>"

Local development (run in the repository root directory; creates a symlink, changes take effect immediately):

dsh plugin --profile web add "link:$PWD"

Uninstall:

dsh plugin --profile web remove dsh-usage-dashboard

The route is automatically unregistered via the ctx.effect disposer when the plugin is uninstalled.

Typical Usage

1. Generate Report

Reports are generated by dsh-usage-stats, for example:

node dsh-usage.mjs --format html --out <some-path>/usage-dashboard.html

Fill the output path into the plugin’s reportPath config. If omitted, it defaults to report/usage-dashboard.html inside the package; placing the generated file there allows for zero-configuration usage.

Example for refreshing data (in the stats project directory):

cd /path/to/dsh-usage-stats
node dsh-usage.mjs --format html --out usage-dashboard.html

2. Configuration (Optional)

In the config of the corresponding plugin item in cordis.patch.yml, both items are optional:

- insert:
    - id: usage-dashboard
      name: dsh-usage-dashboard
      config:
        path: /usage        # Mount path, default /usage
        reportPath: /abs/path/to/report.html
        # Defaults to <package-root>/report/usage-dashboard.html

reportPath can be an absolute path or relative to the package root.

3. Access

Log in to the DSH Web GUI in your browser first, then open:

http://<your-dsh-web-address>/usage

Returns 401 if not logged in; 403 if Host/Origin check fails. No need to use separate tokens.

Scenarios and Notes

Suitable for: Internal viewing where you are already using the DSH Web GUI and want usage reports on the same site with the same login state; report update frequency is low, and the “stats generate HTML + browser refresh” workflow is acceptable.

Boundaries and Risks (Stated in README):

  • Page availability depends on dsh web; /usage is unavailable when DSH is not running. If an entry point independent of the DSH process is needed, you should run your own service rather than mounting it to the host.
  • No independent TLS; the transmission boundary is consistent with the host web (if the host web does not use TLS, the report is the same).
  • Reports may contain internal information such as project names, session IDs, and costs; do not change the mount path to a host route that bypasses authentication.

Before Installation: This plugin runs inside the DSH host process with the same permissions as the current dsh process. You should read the repository source code and the MIT license before installation to ensure the paths and report contents comply with your security policies. The DeepSeek Harness community plugin directory (such as the entry on SkillHub) is an independent ecosystem site and has no official affiliation with DeepSeek or High-Flyer.

Conclusion

dsh-usage-dashboard connects the HTML reports from dsh-usage-stats to the host’s /usage, reusing the GUI login state with zero dependencies and no modification to other projects. Once the plugin is installed, the report file is configured or placed, and dsh web is restarted, usage can be viewed in the same-origin browser.

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

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

Xiaoye