Skip to main content

dsh-save-money/plugin

33Stars2Forks1Issues0Watchers

Pauses long-running tasks and model requests during user-defined time windows, achieving zero charges during peak hours for time-of-use pricing APIs like DeepSeek. Includes balance display and consumption bar charts with 10-minute granularity.

Evidence5/5methodologySourceInstallMaintenanceDSH versionSecurity scan
Machine-auditedInstall commandRepo verifieddsh-plugin topicLicenseREADMEAI wiki
Language
JavaScript
License
MIT
Branch
main
dshdsh-plugindsh-plugins

Install

cmdweb profile
$ dsh plugin --profile web add dsh-save-money

Run the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial

Install via your agent

Install the DeepSeek Harness plugin zhu168/dsh-save-money/plugin for me: review the repository at https://github.com/zhu168/dsh-save-money first, then run the install command and verify the plugin loads successfully.

Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.

One-Line Description

Automatically pause running DSH long-running tasks and all model requests within user-defined time windows, then automatically resume after the window ends—ensuring zero charges from time-of-use pricing APIs like DeepSeek during peak hours; optionally displays official account balance and an 8-hour consumption bar chart.

Core Features

  • Customizable multiple pause/resume windows, supporting overnight periods (e.g., 23:00–08:00) and day-of-week filtering
  • Auto-pause at scheduled time: Running tasks are safely "frozen" (progress preserved as-is), auto-resumed after window ends—no pause if no tasks running
  • Request-level gate: During pause, AI sends zero new requests to model services, zero billing; manual interactions always pass through
  • Per-model tier savings control: Official flash/pro, OpenCode flash/pro—4 independent toggles; unrecognized models (old names like chat/reasoner, third-party, etc.) are always exempt
  • One-time "End This Savings Session" button: Skips only the current pause window; master "enabled" toggle unaffected; next window still applies
  • Top floating banner (pending pause: light yellow / paused: light red) + session header persistent colored status text (color changes with state), 10-language UI (zh/zh-TW/en/de/fr/es/it/pt/ja/ko, auto-follows browser)
  • Optional DeepSeek official account balance display + 8-hour consumption bar chart with 10-minute granularity (external consumption distinguished by warning color)
  • Config persisted to workspace save-money.config.json, survives uninstall/reinstall/restart; auto-written to repo directory on first install to avoid polluting DSH installation directory

Technical Implementation

  • Language: TypeScript (source), built as ESM JavaScript (scripts/build.js inlines src/*.ts into single files plugin/index.js and plugin/client.js)
  • Key dependencies: @deepseek-ai/dsh-client-ui-primitives (runtime detection, falls back to self-rendered buttons if missing); DSH built-in services (timer/slots/agents/goals/fs/sandboxPolicy/webServer/tools/credentials/settings/subprocess); no third-party runtime dependencies
  • Architecture pattern: Dual-half host plugin (Host + Client), same source → official bundle three install forms (--patch overlay / tgz bundle / link+HMR)
    • Host half (src/host.ts): Intercepts all model calls at request level via ctx.on('llm/stream', ...) (gate), freezes/resumes long-running tasks via ctx.get('goals') + ctx.get('agents'), ctx.timer.interval drives state machine every 30 seconds (NORMAL → WARN → PAUSED), dynamic submodules src/config.ts / src/state.ts / src/host-goals.ts / src/balance-host.ts / src/gate.ts / src/host-tools.ts / src/host-http.ts inlined at build time
    • Client half (src/client.ts): Injects conversation.session.header.utilities slot (unique persistent entry: colored status text) + settings.section slot ("Save Money" plugin section in system settings) + shell.overlay (floating banner); i18n from src/i18n/*.ts (10 language dicts inlined at build time)
    • Mount declaration: plugin/package.json#dsh.bundle.patch (cordis overlay) + plugin/cordis.patch.yml (inserts plugin line id: save-money)
  • Entry files: Host entry src/host.ts (exports { inject: ['timer'], apply(ctx) {...} }, build output plugin/index.js); Client entry src/client.ts (build output plugin/client.js); build scripts scripts/build.js (TS → JS) + scripts/make-plugin.js (generates official bundle); quick-try overlay cordis.patch.yml

Use Cases

When using DeepSeek and other time-of-use pricing model services in DSH, and wanting zero billing during peak hours (Beijing time 09:00–12:00, 14:00–18:00): this plugin freezes tasks, closes the gate, and stops sending requests at scheduled times; auto-resumes after window ends with conversation and task progress preserved. Also applicable to any "don't want the machine working during certain time periods" scenario (custom electricity prices, custom bandwidth off-peak). Also wants to see recent 8-hour consumption granularity per 10 minutes from official account for bill reconciliation and consumption attribution across devices.

Prerequisites & Compatibility

DependencyMin VersionNotes
DeepSeek Harness (DSH)Not declaredPlugin doesn't explicitly declare DSH min version in manifest; uses standard ctx.on('llm/stream') + ctx.timer + ctx.get(...) injection mode, requires DSH official plugin form support (typically 0.1.0-rc.6 and above)
Node.jsNot declaredNeither package.json nor plugin/package.json in repo declares engines.node; the only engines field in package-lock.json comes from typescript dev dependency (>=14.17)
PlatformCross-platformNo native modules introduced; config persistence via DSH fs service (compatible with Node node:fs), balance history via ~/.dsh/
Native modulesNoneNo dependencies on node-pty / node:sqlite or other native bindings

Installation

dsh plugin --profile web add github:zhu168/dsh-save-money/plugin

Configuration Options

All config can be visually edited in DSH Settings → Save Money Plugin or via the session header "Save Money · 🟢" status text popup; the following fields can also be programmatically modified via AI tool save_money_configure (excerpted from src/config.ts:26-58, src/host-tools.ts:31-66, with instant validation and auto-persistence):

ConfigTypeDescriptionDefault
enabledbooleanMaster toggle: auto-pause at scheduled times when checked, immediate resume all windows when uncheckedfalse
timezonestring (IANA timezone)Timezone for time windows; auto-detected on first browser launch, falls back to Beijing timeAsia/Shanghai
warnMinutesnumberMinutes before next window to enter "pending pause" WARN state and show light yellow banner5
windowsarrayPause/resume window list, each item { pauseAt, resumeAt, days?, timezone? } (HH:mm strings, days is 1-7 array representing Monday–Sunday)[]
reconcileOnStartbooleanIf targets are still paused on startup, auto-resume (to avoid permanent freeze after restart)true
langenumUI language: auto (follows browser) / zh / zh-TW / en / de / fr / es / it / pt / ja / koauto
showBalancebooleanShow DeepSeek official account balance next to session header status text (only shows after official API calls)false
modelApply.official-flashbooleanWhether to pause official DeepSeek flash model inside pause window (checked = pause for savings)true
modelApply.official-probooleanWhether to pause official DeepSeek pro model inside pause windowtrue
modelApply.opencode-flashbooleanWhether to pause OpenCode Go/Zen flash model inside pause windowfalse
modelApply.opencode-probooleanWhether to pause OpenCode Go/Zen pro model inside pause windowfalse

FAQ

Q: What's the difference between this plugin and DSH's built-in "budget/cost" feature?

A: The official cost tool is passive accounting with "overspend alerts"; this plugin actively closes the gate—no requests sent to models at scheduled times, zero charges, and freezes running tasks until window ends before resuming.

Q: I don't see "Save Money" status text on the page after installation. What should I do?

A: Must fully restart DSH (Ctrl+C to stop, then start) and force-refresh the browser (Ctrl+Shift+R)—the UI mounts at startup. Builds before v1.2.5 had "toggle won't check / settings won't work" issues; please upgrade to the latest version.

Q: Is it a bug that AI doesn't reply during pause?

A: Not a bug—it's intended behavior. The design for pause windows is "no requests, no charges"; running tasks are frozen, conversation context preserved; auto-resumes all after window ends, or click "End This Savings Session" to resume immediately.

Q: Where is the config file saved? Will it be lost after uninstall?

A: Config auto-saves to workspace save-money.config.json (already .gitignored). Location auto-resolves via 6-level fallback: pointer file ~/.dsh/save-money-config-path.json > current session workspace > session workspace named dsh-save-money > DSH startup directory > sibling dsh-save-money directory of startup directory > sandboxPolicy.workspaceRoot. Uninstall/reinstall won't touch it; delete the file to restore defaults.

Q: Will "End This Savings Session" turn off the master toggle?

A: No. This button is a one-time in-memory operation, ending only this specific triggered pause window; the next window (today or later) still applies, the persisted "enabled" toggle stays unchanged. To disable all window savings, manually uncheck "Enabled".

Q: Does balance display only support DeepSeek official?

A: Yes. Balance and consumption stats only show when the most recent model request ran on official DeepSeek; other vendors' keys (SiliconFlow, relay, etc.) won't show balance. Balance history is saved by API key fingerprint to ~/.dsh/dsh-save-money-balance.json; changing keys automatically retires old history.

Q: Will "One-Click DeepSeek Time-of-Use Strategy" auto-enable?

A: No. One-click strategy only appends peak windows to config (deduplicated, Beijing time 08:58–12:02, 13:58–18:02—2 min early/late margin), the "Enabled" toggle requires user to check—your call.

Q: How to uninstall?

A: dsh plugin --profile web remove dsh-save-money, then restart DSH. Config file save-money.config.json and balance history ~/.dsh/dsh-save-money-balance.json won't be deleted—manually delete them for complete cleanup.

Ease of Use

Beginner—one command install + restart DSH + click session header status text to open popup and check "Enabled" to use; advanced usage involves adjusting time windows, model tier toggles, and timezone as needed.

Known Issues & Limitations

  • After install/upgrade must fully restart dsh web (Ctrl+C to stop, then start) and force-refresh browser (Ctrl+Shift+R) to see UI; page refresh alone won't reload server-side plugin (README.zh.md:298-306)
  • Balance and consumption stats only support DeepSeek official API—other vendors' keys (SiliconFlow, relay, etc.) won't show balance or bar chart (src/balance-host.ts:88-130)
  • AI not responding during pause windows is intended behavior, but may mislead users into thinking "AI is stuck"; use banner and status text color changes to determine whether current state is NORMAL/WARN/PAUSED
  • Any unrecognized models (old names like chat/reasoner, other third-party, etc.) are always exempt from pause—if you intentionally use old names, they pass through the gate (src/host-tools.ts:33 / README.zh.md:28)
  • Config auto-saves to workspace, but if current directory is DSH installation directory on first install, plugin writes to repo directory first and records via ~/.dsh/save-money-config-path.json pointer to avoid polluting DSH installation directory (src/config.ts:118-185)
  • Builds before v1.2.2 had harness is not defined error, before v1.2.4 had incomplete UI loading, before v1.2.5 had "toggle won't check" issue—must upgrade to latest version (README.zh.md:298-306)
  • Plugin doesn't explicitly declare DSH and Node.js min version requirements in manifest; after upgrading DSH major version, recommend verifying compatibility first

Read the usage guide →

Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.

Listing badge

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](https://deepseek-plugin.org/plugins/zhu168/dsh-save-money/plugin)

Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.

← Back to plugin directory