During agent task execution, automatic computer sleep can cause task interruption, service restart errors, or session data corruption. dsh-awake is a DeepSeek Harness plugin that prevents operating system sleep during task execution and automatically restores the sleep permission after the task ends (including errors, interruptions, or cancellation).

Core Features

  • Prevent Sleep and Restore: Prevents OS sleep when a task starts and restores it after the task ends.
  • Cross-Platform Support: Supports Windows / Linux / macOS.
  • Dynamic Configuration: Supports dynamic configuration schema with hot changes taking effect from the settings page.
  • Browser Wake Lock: Enables page sleep prevention for the current browser, with state independent of the system.
  • One-Click Update/Restart: Supports plugin version updates and service restarts.
  • Automatic Migration: Automatically migrates old configurations after upgrading to v0.2.0.

Installation and Enablement

Install to a target profile (for example, web) via the command line:

dsh plugin --profile web add dsh-awake

After installation, append the - insert: section from cordis.patch.yml in the repository root to $DSH_HOME/profiles/web/cordis.patch.yml. A running DSH instance hot-watches this file, so appended configuration takes effect immediately without restarting. For local development, you can link the source directory directly:

pnpm add dsh-awake@link:...

Configuration Format

Configuration is stored in $DSH_HOME/settings.yaml and can be hot-edited through the “Sleep Prevention” section of the settings page. Starting with v0.2.0, the configuration format is as follows:

dsh-awake:
  version: 2          # 配置文件版本:2;有老配置(0.1.x)自动转换
  platform: linux     # 锚点:上次写入配置的平台
  mode: systemd       # 当前平台选中的方式(实现文件名);'off' = 关闭服务端
  config:             # 该方式的配置;字段由方式声明,多为空 {}
    why: 'dsh 任务执行中'

Platforms and Methods

The plugin automatically selects the underlying implementation based on the platform:

  • Linux: systemd (systemd-inhibit), gnome-gsettings; default is systemd.
  • macOS: caffeinate, pmset; default is caffeinate.
  • Windows: powershell (SetThreadExecutionState), powercfg; default is powershell.

Always-On Sleep Prevention

There is an “Always-On Sleep Prevention” switch at the bottom of the settings page. When enabled, the server remains active continuously regardless of whether any task is running. This state is stored in memory only and is not written to the configuration file; it becomes invalid after the host restarts. If mode is set to off, this switch cannot be enabled.

Cross-Platform Handling

If the configured platform differs from the current system, the runtime automatically uses the default method for the current platform and shows a yellow warning (without overwriting the file). The next time the configuration is saved, platform is updated to the current platform.

Using the Settings Page

In dsh web, open Settings → Sleep Prevention. The page polls the status every 5 seconds; the status line displays the connection status and the active method. The refresh button re-checks method availability.

  • Watch Status: Displays “Active” or “Disabled”.
  • Method Selection: Choose the specific implementation from the dropdown menu (such as systemd-inhibit); disabled items show the reason.
  • Dynamic Form: Displays configuration items based on the selected method (such as the prevention reason).
  • Update Notice: Shows an update card when a new version is detected, supporting one-click update and automatic restart.

Development

The plugin is built with TypeScript and Vitest. The engineering setup is aligned with dsh-win-mgr; the host outputs a single ESM file, and the client outputs a ModuleLoader shell.

pnpm install
pnpm typecheck   # tsc 双半
pnpm test        # vitest(单测 + 看门狗进程测试)
pnpm build       # host → lib/index.js;client → lib/client.js

Data Plane

All settings page data is transmitted through a single channel via POST /api/dsh-awake, using connection.fetch.register to register exact routes (awake.status / awake.refresh / awake.select / awake.alwaysOn, etc.). Starting with v0.2.1, fetch is used instead of connection.rpc.handle to avoid startup failures in DSH 0.1.5-rc caused by fiber sibling relationships.

Notes

  • Version Changes: v0.2.0 is a breaking refactor that introduced the method subsystem and dynamic schema. v0.2.1 fixed compatibility issues with DSH 0.1.5-rc.
  • Dependency Environment: Linux depends on systemd-inhibit; Windows depends on a PowerShell environment.
  • Permissions: The plugin runs with the permissions of the current dsh process. Review the source code and license before installation.