Preface

In the DeepSeek Harness (DSH) sandbox environment, directly launching browser processes is often constrained by pipe restrictions (EPERM/EINVAL), causing plugins to fail to output or communicate properly. At the same time, conventional visual verification approaches usually require invoking vision models or repeated approvals, which increases latency and cost. To address both problems, the plugin zaiwenj/dsh-cdp-browser provides an alternative: it controls a browser that has already been started locally by the user via the CDP protocol, and uses Node’s built-in fetch and WebSocket to achieve zero-subprocess automation and pixel-level checks.

Plugin Overview

zaiwenj/dsh-cdp-browser is a DeepSeek Harness plugin, positioned as a zero-spawn CDP browser automation and pixel-level visual verification tool. It drives an already running Chrome or Edge browser, does not depend on child_process, and contains no npm dependencies. Because connecting to a user-launched browser is treated as network I/O, it remains feasible under restricted modes, and the model does not need to obtain fresh human approval for every visual check.

Installation and Enablement

Installing this plugin requires Node.js version 22.0.0 or above. Run the following command in the terminal to add the plugin to the web profile:

dsh plugin --profile web add file:<path>

After installation is complete, restart the Web GUI. The cdp_* command series will appear in the toolbar.

Core Features and Tools

The plugin provides a set of commands for managing connections, page operations, and verification:

  • cdp_status: Lists the tabs/targets of the CDP browser and the browser version.
  • cdp_open: Opens or reuses a tab for the specified URL and returns the target ID.
  • cdp_eval: Executes JavaScript in the page context, supporting the awaitPromise and returnByValue parameters.
  • cdp_shot: Navigates to the specified URL and saves a PNG screenshot to an absolute path.
  • cdp_assert: Combines scripted interaction with deterministic checks (pixel/CSS/DOM/JS) and generates a pass/fail report.

Typical Usage: Pixel and Style Assertions

cdp_assert supports multiple check types. The following is an example configuration that includes a relative-coordinate pixel check, CSS property checks, and DOM text checks:

checks: [
  { type: 'pixel', x: 0.5, y: 0.96, color: '#245edb', tolerance: 16 },
  { type: 'css', selector: '#taskbar', property: 'background-color', equals: 'rgb(36, 94, 219)' },
  { type: 'css', selector: '.xp-window', property: 'border-radius', matches: '^\\d+px' },
  { type: 'dom', selector: '.xp-desk-icon', text: 'My Computer' },
  { type: 'js', expression: 'window.__XP.selfTest()', equals: { ok: true } },
]

Each item in the checks array in the configuration above supports a click parameter (for example, click: '#start-btn') or waitMs, which can be used to perform interaction or waiting before the check.

Notes: Determinism and Rendering

To ensure stable test results, note the following:

  1. Page Reload: Reload the page before each test run. Long-lived tabs accumulate state (such as modal windows and menu states), which may cause scripts to fail in subsequent runs.
  2. Synthetic Clicks: el.click() triggers real event handlers. For toggle-style controls, make sure to click only once to avoid state flips.
  3. Gradient Sampling: When performing pixel checks on gradient backgrounds, it is recommended to sample near the gradient stops rather than in blended regions; otherwise, tolerance settings may cause false failures.

Starting the Browser

Before using the plugin, manually start the browser and enable the debugging port. For example, to start Microsoft Edge:

msedge.exe --remote-debugging-port=9222 --remote-allow-origins=* --user-data-dir=<dir> <url>

After completing the steps above, DSH can communicate with the browser through the local port.

Conclusion

zaiwenj/dsh-cdp-browser resolves the compatibility problem of launching browsers via child processes in sandbox environments and provides visual verification without requiring vision models or repeated approvals. For scenarios that require high determinism and controlled access to the local browser environment, this plugin is a practical choice.