In the DeepSeek Harness (DSH) ecosystem, the plugin architecture is central. During peak periods, API rate limiting directly causes request failures. The dsh-offpeak plugin aims to address this issue by intercepting targeted requests before they are actually sent during peak hours: only requests destined for official sources or explicitly listed models are intercepted, while all other requests proceed normally. It also supports scheduling a “free-run” exemption window for an individual session.
This is a DSH host plugin with plugin id dsh-offpeak. The author is lizilong1993. The configuration file is located at config/offpeak.json.
Core Features¶
Configurable Peak/Off-Peak Policy
Peak windows, time zone, weekday rules for each window, and weekend rules all come from config/offpeak.json (effective in order: environment variable $DSH_HOME/config, current directory config, and built-in package defaults). A malformed config file never silently disables the guard: errors are collected and surfaced, and the corresponding keys retain their default values.
Turn-Level Gating
When entering peak hours, running sessions are paused at the turn level (the current turn completes before interception). Exits from peak are automatically allowed. Automatic release does not affect manual /pause.
Request-Level Guard
agent/request passes through every request, so sessions started after peak begins and sessions that switch to official sources mid-session are also covered. hold (default) silently suspends requests; error throws a recognizable PEAK_DEFERRED.
Target Detection
Priority: explicit officialProviders → model name (exact match, case-insensitive) → live baseURL → catalog default endpoint → built-in id (deepseek-official) → unknown. Only requests detected as official are intercepted.
Peak Blocking List
Select models in the panel (or write them directly into officialModelPatterns): entries are exact model-name matches — selecting ocg/deepseek-flash blocks only that model, regardless of which route it runs on; if not selected, it is not blocked. The top of the panel provides keyword filtering, select all / deselect all, refresh, and hot reload.
Free Run
Schedule one or more absolute time windows for an individual session. While inside a window, that session is exempt from both peak entry and request hold. Supports per-window pause/resume, a maximum of 8 merged entries, and persistence. In the panel, it shares the same collapsible section as the blocking list (at the top).
Editable Peak/Off-Peak Hours
At the bottom of the panel, “Current Peak/Off-Peak Hours”: each window’s start – end is prefilled from configuration (rows can be added or removed) plus a “Weekend default off-peak” checkbox. Saving writes to config/offpeak.json and takes effect immediately (other keys and weekday restrictions for each row are preserved as-is).
Display Time Zone
A separate IANA time zone can be selected (default policy time zone): free-run times, peak/off-peak periods, and hover cards are converted and displayed accordingly; time values in the configuration file remain unchanged.
Badge
A clickable badge in the input area: Peak / Peak · Blocking / Peak · Free Run / Off-Peak / Weekend; blocking state is red, release state is green.
Automatic Retry
Optional backend retry (disabled by default), and it always yields to gating.
Compatibility¶
DSH Host Version
engines.dsh in package.json = >=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 (three ranges). Stable interface: /session-guard/* route prefix (compatible with existing tools).
Node Version
engines.node >= 20.
Relationship with input-traffic
Reads window.__DSH_OFFPEAK_BRIDGE__ first and remains compatible with the older bridge name window.__DSH_SESSION_GUARD_BRIDGE__.
Known Limitations
Statutory holidays are not recognized; free-run uses wall-clock times interpreted in the configured time zone; the peak blocking list uses exact model-name matching (no batch coverage by keywords or regular expressions).
Installation¶
Choose any of the following three channels: npm package / GitHub repository / local directory or a tgz from Releases.
# npm (recommended)
dsh plugin --profile desktop add dsh-offpeak
# GitHub
dsh plugin --profile desktop add github:lizilong1993/dsh-offpeak
# local directory / Release asset
dsh plugin --profile desktop add ./dsh-offpeak
dsh plugin --profile desktop add ./dsh-offpeak-<version>.tgz
Build from source (for development):
git clone https://github.com/lizilong1993/dsh-offpeak.git
cd dsh-offpeak
npm install
npm run build
Configuration¶
config/offpeak.json (default layer; values in the settings form take precedence). Commonly used keys:
{
"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": [], // Additional official provider ids (exact match, highest priority)
"officialModelPatterns": [], // Model names blocked during peak (exact match, case-insensitive)
"officialBaseURLs": ["api.deepseek.com"],
"deferredMode": "hold", // 'hold' | 'error'
"deferredResume": true
}
The configuration file path can be explicitly specified with DSH_OFFPEAK_CONFIG.
HTTP / Service Surface¶
GET /session-guard/status · /state?session= · /settings · /diag · POST /session-guard/rpc (actions include setModelPatterns, setPeakPolicy, freeRunAdd, reloadConfig, etc.), plus the in-process sessionGuard service endpoint.
Typical Usage¶
- Install: run
dsh plugin --profile desktop add dsh-offpeak. - Configure: edit
config/offpeak.jsonto set the time zone, peak windows, and weekend policy. - Manage: manage the blocking list and free run via the
/session-guard/settingspanel, or set model patterns and hot reload viaPOST /session-guard/rpc. - Environment variable: use
DSH_OFFPEAK_CONFIGto explicitly specify the configuration file path.