dsh-process-guard: Process protection plugin preventing DSH hosts and browsers from being mistakenly terminated

Preface

The DeepSeek Harness Web GUI runs within the browser client, while the underlying server is a node process. When executing tasks, agents often attempt to clean up temporary processes using shell commands (e.g., Get-Process chrome | Stop-Process -Force). This pattern of “batch killing processes by name” is prone to inadvertently terminating the DSH’s own processes, causing the GUI window to disappear, connections to drop, and sessions to be marked as interrupted. dsh-process-guard aims to intercept these dangerous command patterns, ensuring that agents can only terminate processes via explicit PIDs or controlled PassThru handles.

Core Features

This plugin functions as a DSH bundle, performing interception checks before the execution of shell tool calls.

  1. Interception of Dangerous Patterns: Refuses commands that attempt to terminate processes via image names, wildcards, process groups, or unfiltered enumeration. This prevents agents from accidentally killing the DSH server or browser using commands like taskkill /IM chrome.exe /F or killall chrome.
  2. Preservation of Safe Operations: Allows termination commands with explicitly specified PIDs (e.g., Stop-Process -Id 42), as well as calls to the .Kill() method on process objects obtained via -PassThru.
  3. System Prompt Injection: Automatically contributes a concise system prompt to inform the model of these constraints before code generation.
  4. Zero Dependencies: The plugin itself has no runtime dependencies.

Installation and Activation

Plugin installation is performed via DSH’s profile management tool.

dsh plugin --profile web add dsh-process-guard

After installation, dsh web must be restarted to apply the configuration. You can verify that the layer has been correctly stacked using the following command:

dsh --profile web --dump-config   # Look for the "# == dsh-process-guard" layer

For local development, you can also install directly from a directory or git URL without any build steps:

# Install from a local directory
dsh plugin --profile web add /path/to/dsh-process-guard

# Install from a git repository
dsh plugin --profile web add git+https://github.com/CetOeil/dsh-process-guard.git

Prerequisites: The current harness’s dsh-tools must expose the ctx.tools.guard() method. This plugin has been verified to be compatible with dsh version 0.1.5-rc.3.

Typical Usage

The plugin operates by rejecting or allowing specific command patterns.

Allowed Operations:
* Terminating directly via PID:

    Stop-Process -Id 42
  • Obtaining a process via -PassThru and terminating a process started by the agent itself:
    $p = Start-Process chrome -PassThru
    # ... other operations
    $p.Kill()

Rejected Operations:
* Batch termination by name:

    Get-Process chrome | Stop-Process -Force
  • Using wildcards or tool aliases:
    taskkill /IM chrome.exe /F
    killall chrome
    pkill -f chrome

Configuration

The plugin’s default configuration is secure and located in cordis.patch.yml. You can adjust behavior by overriding this configuration.

The default mode is deny (direct interception). To switch to an “ask” mode, add the following configuration to the profile’s cordis.patch.yml:

- id: process-guard
  name: dsh-process-guard
  config:
    mode: ask                 # 'deny' (default) or 'ask'
    announce: true            # Whether to add system prompt
    enabled: true

Description of main configuration items:

Config Item Default Value Description
mode deny deny intercepts commands directly; ask sends commands to an approval flow.
enabled true Set to false to completely disable checks.
tools common shell tool names List of shell tool names to check.
protectedImages cross-platform browsers + harness/terminal hosts List of image names that must be protected.
safeFilterAllows false By default, rejects commands allowed via CommandLine filters.

Note: tools and protectedImages replace the default lists; use additionalTools and additionalProtectedImages to append to them.

Use Cases and Notes

This plugin is suitable for Harness projects running in browser environments where agents may need to clean up temporary processes. It is particularly applicable to scenarios involving automated screenshot verification using headless Chrome or Edge.

Notes:
* The plugin runs with the permissions of the current DSH process; therefore, ensure that the Harness version supports ctx.tools.guard().
* Commands using sudo killall or wmic will also be intercepted.
* This plugin is released under the MIT License.

Summary

dsh-process-guard is a security hardening plugin for the DSH ecosystem. By performing pre-checks on commands at the shell tool level, it resolves the common pain point of session interruptions caused by agents “killing the wrong process.” Used in conjunction with dsh version 0.1.5-rc.3 and above, it significantly improves agent stability in complex environments.

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

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

Xiaoye