dsh-peak-scheduler: Automatic Peak/Off-Peak Pricing Scheduling for DeepSeek

Introduction

DeepSeek Harness (DSH) is a development environment used for building agents. DeepSeek API call costs are divided into peak and off-peak prices based on time periods, with off-peak prices typically being only half of peak prices. During development, manually waiting for off-peak periods to execute tasks adds to the mental burden.

The dsh-peak-scheduler plugin solves this pain point by adding a “Peak/Off-Peak Scheduling” button to the input box toolbar. It automatically queries the current time period and allows tasks to be postponed for automatic execution during off-peak hours.

Core Features

This plugin primarily solves the following issues:

  1. Auto-Querying: Automatically determines whether the current time is peak or off-peak pricing based on official documentation rules, and fetches holiday calendars online.
  2. One-Click Scheduling: Adds a scheduling button to the input box, offering two options: “Execute Now” or “Postpone to Off-Peak”.
  3. Task Management: Postponed tasks do not run immediately; instead, a pending task is created and stored in the official schedule service.
  4. Visual Feedback: The sidebar displays the count and list of pending tasks, supporting manual start or cancellation at any time.

Installation and Activation

1. Install Plugin

Use the DSH plugin command to install. You need to specify a profile (e.g., desktop or web):

dsh plugin --profile desktop add github:yizhiyizhi0128/dsh-peak-scheduler

2. Configure Bundle

Edit ~/.dsh/profiles/desktop/package.json to add the plugin to dsh.profile.bundles. Simultaneously, the official schedule bundle must be added to the same array.

"dsh": {
  "profile": {
    "bundles": [
      "dsh-peak-scheduler",
      "@deepseek-ai/dsh-experimental-schedule-bundle"  // Must be registered here
    ]
  }
}

Note: The official schedule bundle must not be written in dependencies, otherwise it will cause pnpm install to fail. It can only be inserted by name via the bundle array.

3. Install Dependencies and Restart

Execute the installation command to make the configuration effective, then you must restart the host process. Plugin modules are loaded only at startup and will not take effect before a restart.

dsh plugin --profile desktop install

Peak/Off-Peak Rules

The plugin’s judgment criteria are derived from the official DeepSeek API documentation.

  • Peak Hours: 09:00–12:00 and 14:00–18:00 from Monday to Friday (excluding statutory holidays in China).
  • Off-Peak Hours: All other times, including weekends, statutory holidays in China, and weekends designated as compensatory working days.
  • Pricing: Off-peak price is half of the peak price.

File Structure

The plugin contains the following core files:

File Role
index.js Host side: Provides HTTP routes, calls the schedule service and session controller
lib/peak.js Pure logic for peak/off-peak determination, including test cases for boundaries, cross-day, and cross-weekend scenarios
lib/holidays.js Holiday calendar, supports online fetching, local caching, and fallback
src/client.js Browser side: Input box button, popup, sidebar task panel
cordis.patch.yml Bundle layer configuration for injecting plugin modules
test/*.mjs Contains tests for peak/off-peak determination, holiday validation, and host response assembly

Typical Usage

  1. Enter a prompt in the DSH input box.
  2. Click the “Peak/Off-Peak Scheduling” button in the input box toolbar.
  3. A popup displays the current time period, price determination, and time remaining until the next switch.
  4. Select “Postpone to Off-Peak for Automatic Execution”.
    • The plugin calculates the seconds until the next off-peak moment (at least 2 seconds).
    • Calls the official schedule service to create a one-time task.
    • The “Pending Tasks” badge on the sidebar increments.
  5. When the off-peak moment arrives, the official schedule service automatically delivers the prompt back to the original session.
  6. Alternatively, during the waiting period, click “Pending Tasks” in the sidebar to manually “Start Now”.

Dependencies

This plugin relies on the official @deepseek-ai/dsh-experimental-schedule-bundle to implement persistence storage and time-based delivery for pending tasks. Ensure this bundle is correctly installed in your profiles.

Conclusion

By reusing DSH ecosystem capabilities, this plugin encapsulates complex peak/off-peak pricing logic into a simple interactive button. All task data is stored in the official schedule service, ensuring data durability and cross-session availability.

GitHub Repository

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

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

Xiaoye