When developing or running long-running tasks in DeepSeek Harness (DSH), such as deep reasoning or complex workflows, system sleep often interrupts processes or causes tasks to be interrupted. dsh-keep-awake is designed to solve this problem. It is a system-level plugin that prevents system sleep while any agent, subagent, or background task is running, and automatically releases resources after all tasks complete through a grace period.

Core Features

  • Real-Time Status Monitoring: Displays the current running status in the Web interface (Keeping Awake / Grace Period / Idle), the number of active agents, the number of background tasks, and the helper process PID.
  • Activity Detection: Intelligently identifies active activity, including main agents, subagents, workflow subagents, and background tasks triggered by the run_in_background command or background subagent tasks.
  • Grace Period Mechanism: After detecting that all activity has ended, a configurable grace period (default 60s, range 15s-5m) is entered before the sleep-prevention flag is automatically released.
  • Manual Keep Awake: Provides a manual toggle to force the system to stay awake regardless of current activity status.
  • Prevent Display Sleep: Optional feature. By default, it only prevents system sleep; when checked, it also prevents the display from turning off.
  • Multilingual Support: The interface language follows the DSH global language setting (zh/en), with changes taking effect immediately.

Installation and Configuration

The plugin is installed via pnpm, and the configuration file is settings.yaml under the profile directory.

  1. Navigate to the profile directory (for example, ~/.dsh/profiles/web).
  2. Add the plugin package:
    pnpm add "dsh-keep-awake@github:bearice/dsh-keep-awake"
  1. Edit package.json and add "dsh-keep-awake" to the dsh.profile.bundles field.
  2. Run pnpm install and restart the profile.

Configure parameters in settings.yaml:

keep-awake:
  enabled: true
  graceMs: 60000          # 宽限期(毫秒),默认 60s
  preventDisplaySleep: false  # 是否同时阻止屏幕关闭
  manualHold: false       # 是否手动保持唤醒

How It Works

The plugin detects activity status by combining polling every 5 seconds with immediate event rescans (agent/status, subagent/start|end, and job set changes). Once activity is detected, it starts a platform helper process through the subprocess service to set the sleep-prevention flag; the flag is released when the process exits:

  • Windows: Uses PowerShell SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED), adding ES_DISPLAY_REQUIRED when display sleep prevention is enabled.
  • macOS: Uses caffeinate -i -s.
  • Linux: Uses systemd-inhibit --what=idle --mode=block sleep 1e8.

Dependencies and Compatibility

  • Node.js: Requires Node.js >= 22.0.0.
  • Dependency Library: Requires @deepseek-ai/schemastery ^3.18.1.

Conclusion

By automatically managing the operating system power state, this plugin enables DSH to handle long-running tasks without manual intervention. The complete source code and documentation are available on GitHub.