dsh-desktop-auto-restart: Host Restart and Session Recovery Tool

Introduction

In day-to-day development of DeepSeek Harness (DSH), modifying host-side plugins typically requires restarting the DSH application for changes to take effect. Restarting the host interrupts all currently running sessions, including the agent that initiated the restart, causing workflow disruption.

The comer2031/dsh-desktop-auto-restart plugin aims to address this pain point. It provides a mechanism that wraps “host restart” as a callable tool or sidebar action, and after the new process starts, it automatically wakes up specified sessions using a manifest mechanism, allowing the agent to continue working.

Core Features

The plugin mainly includes the following features:

  • Tool dsh_restart: Disabled by default; experimental in nature. Call parameters include reason, sessionIds (list of sessions to wake), and optional delaySeconds. If delaySeconds is not provided, it defaults to 10 seconds to allow time for receipts to be persisted; passing 0 triggers an immediate restart. For the model to call this tool, the corresponding toggle must be enabled in settings.
  • Sidebar Button: Provides an operation entry point at the bottom of the DSH interface sidebar. When the host is idle, clicking directly restarts it; when the host is busy, a red confirmation layer appears, and the restart only executes after confirmation.
  • Auto-Wake Mechanism: After restart, the plugin reads the wake-up list, attempts to wake sessions through official channels, and injects a “restart complete, please continue” notification. If wake-up fails, the list is retained for retry on the next startup.
  • Anti-Suicide Mechanism: The script prioritizes using the host’s own PID (process tree) to locate and terminate processes rather than batch-killing by process name. This avoids accidentally killing other processes with the same name in multi-instance or specific environments.

Installation and Activation

The plugin is installed via the DSH CLI:

dsh plugin --profile <profile name> add dsh-desktop-auto-restart

After installation, the DSH application must be restarted for the plugin to take effect. Configuration adjustments in the settings page do not require a restart, but enabling permission for the agent to call the tool requires restarting DSH.

Configuration Options

Plugin configuration is located in <profile>/cordis.patch.yml and can be modified through targeted patches. Core configuration items:

  • agentToolEnabled: Default false. Controls whether the dsh_restart tool is registered for model invocation. Must be set to true and DSH must be restarted to take effect.
  • wakeOnStart: Default true. Controls whether to read the manifest and perform wake-up when the plugin starts.
  • wakeDelayMs: Default 3000. How long to wait after startup before beginning wake-up, to avoid premature access when session objects aren’t available.
  • pendingTtlMs: Default 1800000 (30 minutes). Expiration time for the pending wake-up manifest.
  • scriptPath: Default ''. Custom restart script path. If empty, the plugin’s built-in script is used.
  • dryRun: Default false. When set to true, only writes the manifest without performing an actual restart; used for rehearsal.
  • installRoot: Default ''. Host installation directory. If empty, auto-detected (reads the directory containing the current process’s exe); falls back to the built-in default path only if detection fails.

Compatibility and Notes

  • Platform Limitation: Only supports the Windows platform DSH desktop client (host version ≥ 0.2.0-rc.1). The plugin refuses restart operations on non-Windows platforms.
  • Dependency Environment: Depends on PowerShell and WMI. PowerShell execution policy must allow local scripts (RemoteSigned). If the execution policy is Restricted, the script may not execute, but the tool will falsely report success.
  • Security Software: Security software such as Huorong may intercept WMI operations and log sensitive actions of WmiPrvSE.exe. This is expected behavior and should be allowed.
  • Tool Registration: The tool is not registered by default. The model can only see and call this tool after enabling agentToolEnabled in the settings page and restarting DSH.
  • Execution Results: The tool’s receipt only covers “whether the script was launched” or “whether the script refused within the first few seconds.” Script failures during execution (such as forced process kill timeout) are only recorded in log files and are not reflected in the tool’s return value.
  • Busy Detection: When the host is busy (running sessions, queued messages, background tasks, etc.), it refuses to restart. Notably, the caller’s own session is not counted in the busy determination.

Conclusion

This plugin provides a controllable automation solution for restarting the DSH host. By combining with session recovery capabilities, it minimizes business interruption after host restarts. Before use, please ensure the environment meets PowerShell and WMI runtime requirements, and pay attention to security software interception policies.

Plugin directory and source code:
* SkillHub Directory Page
* GitHub Repository

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

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

Xiaoye