DeepSeek Harness Plugin

lizilong1993/dsh-offpeak

Stars ★ 1 Downloads (30d) 2,060 Category Usage & Billing Added 2026-10-19 npm dsh-offpeak

Pauses peak-hour requests that target official or listed models and lets everything else run, with editable peak windows, a per-model interception list and per-session free-run in the badge panel.

Install

# from npm (prebuilt)

dsh plugin --profile web add dsh-offpeak

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:lizilong1993/dsh-offpeak

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

dsh-offpeak

A DSH (DeepSeek Harness) host plugin that keeps peak-hour usage under control: it closes the session gate before a peak-hour request goes out, holds only the requests whose target is official or explicitly listed, lets everything else run, and gives a single session a time-boxed "free run" exemption.

Plugin id dsh-offpeak, settings namespace offpeak, config file config/offpeak.json.

What it does

Capability Behaviour
Configurable peak policy Peak windows, timezone, per-window weekdays and the weekend rule come from config/offpeak.json (env → $DSH_HOME/config → <cwd>/config → bundled default). A malformed file never silently disables the guard: errors are collected and reported (configFile.errors on /session-guard/settings and /diag), affected keys keep their defaults.
Turn gating On peak entry, running sessions are paused at turn level (the current turn finishes first) and released automatically off peak. Manual /pause is never touched by the automatic release.
Request-level guard agent/request is checked on every request, so sessions started after peak entry — or switched to an official route mid-session — are still caught. deferredMode: 'hold' (default) holds the request silently; 'error' raises a recognisable PEAK_DEFERRED.
Target verdict Priority: explicit officialProviders list → model name (exact match, case-insensitive) → live baseURL host → catalog default endpoint → built-in id (deepseek-official) → unknown. A request is held only when the verdict is official.
Peak interception list Tick models in the badge panel (or write officialModelPatterns): an entry is a model name matched exactly, so ticking ocg/deepseek-flash intercepts exactly that model, whatever route serves it — and nothing is intercepted until you tick something. The panel has a keyword filter, select-all / clear-select-all, refresh, hot reload, and a × undo on every intercepted entry.
Free-run Schedule one or more absolute time windows for one session; inside them the session is exempt everywhere (peak entry, request hold). Per-segment pause/resume, merged up to 8 windows, persisted — shown at the top of the same panel as the interception list.
Peak hours, editable The panel's bottom 当前高峰谷时 section is prefilled from your config: one start – end pair per window (rows can be added/removed) plus a weekend = off-peak checkbox. Saving writes config/offpeak.json and takes effect immediately, preserving every other key and each row's weekday limits.
Display timezone Pick any IANA zone (default: the policy timezone) and free-run times, peak windows and the badge tooltip are converted for display; the values in the config file stay untouched.
Badge One clickable badge in the composer: 高峰 / 高峰 · 拦截中 / 高峰 · 畅跑中 / 谷时 / 周末; red while blocking, green while allowing.
Retry Optional backend retry for transient turn failures (off by default); it always yields to the gates.

Compatibility

Item Notes
DSH host versions package.json's engines.dsh = >=0.1.5-rc.2 <0.1.6-0 || >=0.1.7-rc.1 <0.1.8-0 || >=0.2.0-rc.1 <0.2.1-0. Only the 0.1.7 line is actually verified (this plugin was developed and tested there); the other two ranges follow the same interfaces but were not exercised one by one — check dsh --profile <yours> --dump-config composes cleanly before installing.
Settings and the write path On the 0.1.7 line the client has no settingsScope, so the browser half injects only slots + locale: the settings form is auto-generated by the host from the exported Config schema, and the interception list is written through POST /session-guard/rpc {action:'setModelPatterns'}, which rewrites config/offpeak.json and reloads immediately. A custom settings card is rendered only when the host provides settingsScope.
Node engines.node >= 20 (the bundled node --test suite uses Node 22+ type-stripping imports of .ts).
Bootstrap deps @deepseek-ai/schemastery ^3.18.4 is a runtime dependency; @deepseek-ai/cordis ^4.0.1 and the @deepseek-ai/dsh-client-* packages are optional peerDependencies (missing them is not an error).
Stable surface The /session-guard/* route prefix and the in-process sessionGuard service port are deliberately kept (compatibility with existing tooling/notes): renaming the plugin does not rename them.
input-traffic The bridge global is read from window.__DSH_OFFPEAK_BRIDGE__ first, falling back to the historic window.__DSH_SESSION_GUARD_BRIDGE__; without either, the plugin ships its own fallback badge/freeze and the two do not replace each other.
Known limitations No statutory-holiday calendar; free-run interprets wall-clock input in the configured timezone; the interception list matches exact model names (no keyword/regex sweeping).

Install

Pick any of the three channels: the npm package, the GitHub repository, or a local directory / the tgz attached to a Release.

# (1) npm (recommended)
dsh plugin --profile desktop add dsh-offpeak

# (2) GitHub (first time needs an allowBuilds entry in the profile's pnpm-workspace.yaml so the package's prepare build may run)
dsh plugin --profile desktop add github:lizilong1993/dsh-offpeak

# (3) local directory / Release asset (no permissions needed)
dsh plugin --profile desktop add ./dsh-offpeak
dsh plugin --profile desktop add ./dsh-offpeak-<version>.tgz

dsh --profile desktop --dump-config     # verify the composed patch layers

Building from source (for development):

git clone https://github.com/lizilong1993/dsh-offpeak.git
cd dsh-offpeak
npm install          # or pnpm install
npm run build        # rebuild lib/client.js (the browser half)

Or point a profile at this checkout by hand — ~/.dsh/profiles/<profile>/package.json:

{ "dependencies": { "dsh-offpeak": "link:/path/to/dsh-offpeak" } }

and add dsh-offpeak to that file's dsh.profile.bundles. Then restart DSH (host code is loaded at boot) and refresh the page.

Configuration

config/offpeak.json (default layer; form values win) — keys used most:

{
  "timezone": "Asia/Shanghai",
  "peakPolicy": { "peakWindows": [{ "name": "morning", "start": "09:00", "end": "12:00", "days": ["mon","tue","wed","thu","fri"] }] },
  "weekendPolicy": { "enabled": true, "days": ["sat","sun"], "mode": "offPeak" },
  "providerGuard": true,
  "officialProviders": [],            // extra provider ids, exact match, highest priority
  "officialModelPatterns": [],        // intercepted model names (exact, case-insensitive)
  "officialBaseURLs": ["api.deepseek.com"],
  "deferredMode": "hold",             // 'hold' | 'error'
  "deferredResume": true
}

DSH_OFFPEAK_CONFIG picks an explicit config file; the state root defaults to .dsh/offpeak (DSH_OFFPEAK_STATE_DIR overrides it).

HTTP / service surface

GET /session-guard/status · /state?session= · /settings · /provider?provider=&model= · /models · /diag · POST /session-guard/rpc (stopNextTurn|resume|lockQueue|unlockQueue|state|reloadConfig|setModelPatterns|setPeakPolicy|freeRunAdd|…), plus the in-process sessionGuard service port. The GET /events SSE stream was removed together with step gating in v3.3.0.

Tests

npm test (node:test) · npm run lint · npm run build.

Acknowledgements

Licence

MIT — see LICENSE.

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.