DeepSeek Harness Plugin: dsh-plugin-cdp

The plugin mechanism of DeepSeek Harness (DSH) allows developers to extend runner capabilities through specific interfaces. dsh-plugin-cdp is a plugin based on the Chrome DevTools Protocol (CDP), designed to address issues encountered when using browser extensions for automation, such as tab clearing, borrowed user tabs becoming invalid, and untrustworthy success popups. By driving a controlled Chrome instance, it provides an automation solution with zero runtime dependencies (built on Node ≥ 22’s built-in modules).

Core Capabilities

The plugin primarily provides the following four core capabilities:

  1. CDP-Driven Controlled Instance: Does not rely on browser extensions; communicates directly with Chrome via the CDP protocol to avoid being counteracted by target websites.
  2. Popup Collection Rules: The plugin itself carries no preset rules. On first use, it collects information through DSH’s built-in ask_user_question popup, including job direction, work location, salary floor, application platforms, browser selection, and exclusion rules. Collected answers are persisted to disk and not asked again.
  3. Plain Text Visualization: Provides Unicode character-art based visualization reports including salary distribution, location bar charts, platform share, and application timelines. Does not depend on external chart libraries; Chinese characters are calculated as double-width to prevent table misalignment.
  4. Zero-Downtime Hot Swap: When rules change, adopts a “start new process first, then retire old process” strategy. The old and new processes share an append-only state record during the overlap period, ensuring uninterrupted tasks.

Tool List

The plugin provides 15 tools to support automation workflows:

Tool Name Purpose
cdp_status View controlled Chrome’s status, port, and tab information
cdp_navigate Navigate to a specified URL and wait for load completion
cdp_eval Execute JS code in the tab context and return JSON
cdp_read Read the current tab’s URL, title, or visible text
cdp_screenshot Capture a screenshot of the current tab and save to a local file
cdp_new_tab / cdp_use_tab Create a new tab or switch to a specified tab
cdp_apply_verified Verified operation: Wait for the detail panel to stabilize, verify salary consistency, and prevent misclicks
cdp_prefs Read or write browser preferences (including rule questionnaire)
cdp_browser_info Report the actual browser used and whether the executable exists
cdp_jobs_report Generate a text visualization report of jobs/salary/locations
cdp_jobs_data Retrieve raw JSON data
cdp_runner_status View runner status, including a hint for “rules changed but not yet effective”
cdp_runner_reload Sync rules and execute hot swap
cdp_runner_stop Stop the runner

Installation & Configuration

Run the following command in the project directory to install the plugin:

npm i dsh-plugin-cdp

After installation, you need to reference the plugin in DSH’s plugin configuration:

- id: cdp
  name: "dsh-plugin-cdp"
  config:
    port: 9222

Configuration Fields

In the YAML configuration, the following fields are required or commonly used:

  • chromePath: Path to the Chrome executable; auto-detected if left blank.
  • userDataDir: A separate user directory used by the controlled instance. Note: Since the everyday browser profile is not reused, you need to log in to target sites separately within this directory.
  • windowSize: Browser window size, formatted as width,height.
  • defaultTimeoutMs: Timeout for a single CDP command.
  • loadEventMs: Maximum duration to wait for page load events.
  • settleMs: Extra stabilization wait time after navigation.
  • prefsPath: Disk path for preferences (including the rule questionnaire).
  • stateDir: Runner state directory.

Running & Hot Swap Flow

In the repository directory, use the following commands for self-check and testing:

node run-all-tests.mjs
node --test lib/jobs.test.mjs
node --test lib/report.test.mjs

Hot Swap Mechanism

The plugin supports updating rules without interrupting service. The flow is as follows:

  1. Change Rules: Modify rule configuration, triggering a fingerprint change.
  2. Start New Process: Launch a new-generation runner process, coexisting with the old process.
  3. Heartbeat Verification: Wait for the new-generation process to output a heartbeat signal, proving it is running normally.
  4. Retire: The old process exits, and the new generation takes over.

If the new-generation process does not output a heartbeat within the readiness window, the system will retain the old process and continue running, without terminating the task.

Notes

  1. Strict Output Field Validation: Return values must correspond one-to-one with output.schema, with additionalProperties: false. Even one extra field will be rejected by the host.
  2. Runner Default Heartbeat Mode: When no command is configured, the runner does not perform actual operations, only maintaining the heartbeat. This is to verify the connectivity of the link.
  3. State Storage Method: Hot swap relies on append-only state storage. If the state were rewritten in full, the two processes would overwrite each other during the overlap period, causing lost updates.
  4. Result Verification: A “success” dialog popping up on the page does not mean the operation has been recorded. Always manually verify on the target site’s records page.

Summary

dsh-plugin-cdp is suitable for scenarios requiring high-control browser automation via the CDP protocol within the DSH environment. Through its enforced verifiable operation flow and zero-dependency design, it provides developers with a stable automation channel. For complete documentation and source code, refer to the GitHub repository.

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

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

Xiaoye