Introducing the DeepSeek Harness One-Click Restart Plugin

Introduction

DeepSeek Harness (DSH) is a local agent development framework whose core design philosophy is “everything is a plugin.” During local development and debugging, manual application restarts often interrupt the developer’s train of thought when dealing with application crashes, configuration changes, or state resets. Additionally, agents may need to actively trigger a Harness restart during runtime to apply new configurations.

The g57651/dsh-one-click-restart plugin solves this pain point through a sidebar button and an independent watchdog process.

Plugin Positioning

This plugin is maintained by user G57651 and open-sourced under the MIT license.

It provides DSH with a one-click restart capability: a visual entry point in the sidebar, backed internally by an independent watchdog process to relaunch the application. This design bypasses the limitation that Node/Electron processes cannot directly relaunch themselves.

Core Features

  1. Sidebar Button
    Injects a button at the bottom of the sidebar (above Settings). The wide sidebar displays the icon and text, while the narrow rail shows only a circular icon. The button state changes with the restart progress (spinner, bouncing dots, failure indicator).

  2. Model-Callable Tool
    Provides a tool named restart_harness. Models or agents can call this tool directly to trigger a restart, with an optional delayMs parameter for setting a delay.

  3. Token-Protected HTTP Route
    Provides GET /api/restart-harness to obtain a token and POST /api/restart-harness to trigger a restart. The token is generated by the host and used to verify the request source, preventing cross-site or unauthorized access.

Installation and Activation

Installation requires a specific version of @deepseek-ai/dsh-tools. Starting from DSH 0.2.0, peer dependencies declared by plugins are pre-checked, and version mismatches will cause installation to be rejected or the plugin to be disabled.

Install via GitHub repository (the repository includes pre-built artifacts, no local build required):

dsh plugin --profile <your-profile> add github:G57651/dsh-one-click-restart

After installation, you must restart DSH to load the plugin. After restarting, a “Restart Harness” button will appear in the bottom-left corner of the sidebar.

Typical Usage

  1. Configuration
    Override configuration items in the profile’s cordis.patch.yml:
   - id: one-click-restart
     name: "@dsh-restart/one-click-restart"
     config:
       appName: "DeepSeek Harness"
       relaunchDelayMs: 1500
  1. Agent Invocation
    The model can call the tool directly:
   {
     "name": "restart_harness",
     "arguments": {}
   }
  1. HTTP API
    Clients (browser pages) obtain a token via same-origin requests and trigger a restart:
   # Obtain token
   TOKEN=$(curl -s http://localhost:3000/api/restart-harness)
   # Trigger restart
   curl -X POST http://localhost:3000/api/restart-harness \
     -H "x-restart-token: $TOKEN"

How It Works and Caveats

How it works:
Since Node/Electron processes cannot directly relaunch themselves, the plugin uses a detached: true child process as the watchdog. This process is separated from the main process; after the main process exits, the watchdog remains alive. The watchdog is responsible for monitoring the main process state and performing the relaunch.

Different runtime surfaces use different strategies:
* macOS Desktop: Uses AppleScript’s quit event to gracefully exit the application, then relaunches via open -a after the application disappears.
* Web / Headless: Exits gracefully via ctx.appExit(0), with the watchdog responsible for relaunching.

Platform Support and Limitations:
* macOS: Tested and supports automatic relaunch.
* Windows / Linux Desktop: Behavior is unverified. The code logic follows the ctx.appExit path, but has not been tested in a real Electron environment. Desktop automation relies on macOS’s open / AppleScript, so it is inherently only automated on macOS; desktop on other systems degrades to “host exit + open relaunch.”

Compatibility:
* Requires @deepseek-ai/dsh-tools: ^0.1.7-rc.1 || ^0.2.0-rc.1.
* Supports DSH 0.1.7-rc.x and 0.2.0-rc.x.
* The repository includes pre-built lib/ directory and can be used directly via github: installation.

Troubleshooting

  • No button in sidebar: Check whether DSH was restarted, or whether the plugin entry in the profile is disabled.
  • Token expired: Clicking the button automatically discards stale tokens and fetches new ones.
  • Forbidden error: Requests must originate from a local loopback same-origin page; cross-site requests will be blocked.
  • Restart failure: Check the logs to confirm whether it is caused by an incorrect application name configuration or the host being blocked by a restore dialog.

Summary

This plugin provides DSH developers with a standardized application restart method, operable via the sidebar or integrated into agent workflows. It uses an independent process mechanism to solve the self-relaunch challenge and ensures security through a token mechanism.

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

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

Xiaoye