Back to home

AlexShang1992

dsh-offpeak

Off-peak cost autopilot for DeepSeek Harness: peak/off-peak pricing pill, defer queue, and savings ledger. · DeepSeek Harness 错峰省钱助手

Stars
0
Language
TypeScript
Created
Aug 15, 2026
Updated
Aug 15, 2026

Introduction

dsh-offpeak

Off-peak cost autopilot for DeepSeek Harness — peak/off-peak pricing awareness, a defer queue, and a savings ledger for the DSH web GUI.

English | 简体中文

License CI Release npm Downloads

Screenshots

Live pricing pill — the current window, multiplier, countdown, and effective prices; hover for the full readout:

Peak hours (×2)Off-peak hours (×1)
Peak status pillOff-peak status pill

Settings → Plugins → Off-peak — pricing preferences, the defer queue, and the savings ledger with a 7-day chart:

Off-peak settings panel

Screenshots are rendered from the plugin's real stylesheet (see scripts/generate-preview.mjs) and can never drift from the shipped UI.

Why

DeepSeek API usage is priced in two daily windows, defined in UTC:

WindowUTC hoursPrice
Peak08:30 – 16:30peakMultiplier × base (official default )
Off-peak16:30 – 08:30base (1×)

That is a 50% saving on every non-urgent token — plus lower peak-hour congestion. dsh-offpeak makes the window visible, lets you (and your agent) defer expensive work into off-peak, and keeps an honest ledger of the savings you estimated by doing so.

⚠️ Prices change. Default prices and the multiplier follow the official DeepSeek pricing page at the time of writing; every figure is user-editable in Settings and should be kept current.

Features

  • Live pricing pill (composer dock) — current window, ×multiplier, countdown to the next switch, effective prices, today's savings; hover for the full readout.
  • Model toolsoffpeak_status, offpeak_estimate, offpeak_defer, offpeak_queue let the agent itself reason about timing and queue work.
  • Slash commands/offpeak for a status summary, /defer <task> to queue a task.
  • Defer queue — durable, JSON-backed, atomic writes, corrupt-file quarantine; manage it from Settings or via tools.
  • Savings ledger — append-only JSONL record of estimates and deferrals, with today/total stats and a 7-day chart in Settings.
  • Fully configurable — prices, multiplier, display currency (USD/CNY), display timezone, all live-applied.
  • Bilingual (English / 简体中文), theme-aware UI on the harness's own --dsw-alias-* tokens.

Installation

Requires a DeepSeek Harness web profile (Node.js ≥ 22.19):

dsh plugin --profile web add dsh-offpeak

Or from a Git repository:

dsh plugin --profile web add "github:AlexShang1992/dsh-offpeak"

Restart dsh --profile web after installing. The plugin shows up under Settings → Plugins → Off-peak; the pill appears under the composer.

Data lives in $DSH_HOME/offpeak/ (~/.dsh/offpeak/ by default): queue.json + ledger.jsonl. Uninstall cleanly by removing the plugin — your queue and ledger files are kept.

Usage

For humans

  • /offpeak — one-shot status summary in the conversation.
  • /defer <task description> — add a task to the queue (e.g. /defer run the full regression suite).
  • Hover the pill to see prices and savings; open Settings → Off-peak for the full panel.

For the agent

The tools are registered automatically; the model will call them when relevant:

ToolPurpose
offpeak_statusCurrent window, multiplier, countdown, prices, savings, queue counts
offpeak_estimateCost of a request now vs off-peak (records a ledger row)
offpeak_deferEnqueue a task with optional token estimates
offpeak_queueList, cancel, or prune the queue

Settings reference

SettingDefaultMeaning
EnabledtrueShow the pill and power the queue/ledger
CurrencyUSDDisplay currency (USD or CNY; uses the USD→CNY rate)
Input / cache-hit / output price0.28 / 0.028 / 0.42Base (off-peak) prices, USD per 1M tokens
Peak multiplier2Price factor during peak hours
Display timezone480 (UTC+8)UTC offset in minutes, used only to display switch times
Record window switchestrueAppend a status row when the window changes

Development

pnpm install          # install dependencies
pnpm run check        # typecheck + test + lint + build (CI-equivalent)
pnpm run test:watch   # iterate on tests

Structure:

src/
  pricing.ts     pure pricing engine (window math, cost estimates) — host & browser
  contract.ts    wire contract: settings/queue/ledger types, zod codecs, Typert invocations
  store.ts       durable queue + ledger (atomic writes, corruption quarantine)
  runtime.ts     OffpeakRuntime — the `offpeak` Typert Remote service
  tools.ts       model tools (offpeak_status/estimate/defer/queue)
  commands.ts    slash commands (/offpeak, /defer)
  index.ts       host plugin entry
  client/        browser half: status pill, settings section, zh/en locales, styles
tests/           unit tests (pricing boundaries, store durability)

Build artifacts: lib/index.js (host ESM), lib/client.js (browser bundle served at /plugins/dsh-offpeak/client.js), lib/types/ (declarations).

Architecture

  • One source of truth: the pricing engine in src/pricing.ts is pure and dependency-free; the same code runs in the host and is bundled into the browser, so every surface agrees by construction.
  • Strict wire contract: host and client share zod codecs and Typert invocation descriptors (src/contract.ts); every Remote call is validated on the wire.
  • Live settings: the offpeak settings namespace applies changes without a restart (applies: 'live'); tools, commands, and the UI read the same resolved value.
  • Fail-closed storage: corrupt files are quarantined (never crash, never silently return garbage); writes are atomic (tmp + rename).

Roadmap

  • Off-peak scheduling: auto-run queued tasks in fresh headless sessions at window switch
  • Peak/off-peak-aware model routing (expensive models only during off-peak)
  • Budget caps + over-budget alerts
  • Weekly savings report
  • One-click sync of official prices

Security

Installing a plugin runs third-party code with your permissions. This plugin writes only under $DSH_HOME/offpeak/ and reads nothing outside it; no network calls are made. See SECURITY.md for reporting guidelines.

License

MIT © dsh-offpeak contributors. Not affiliated with DeepSeek.