dsh-rule-proxy: Proxy for Routing DSH Web Tools by Hostname Rules

Preface

In DeepSeek Harness (DSH), models often fetch public internet resources via web_fetch, GitHub tools, or optional plain search. If you want only specific domains to go through a company or local HTTP proxy while the rest remain direct connections—without modifying model requests, the global fetch, or the parent process proxy environment—global interception plugins (like dsh-plugin-proxy / dsh-proxy-pro) are often too heavy. dsh-rule-proxy, provided by community maintainer xiaoyi728, uses hostname rules to provide isolated transport for web tools: requests hitting a rule use your configured upstream, while unmatched requests or those where the upstream is unavailable use a separate direct connection. Neither path rewrites the network settings on the model side.

What is this

dsh-rule-proxy is a networking tool plugin within the DSH ecosystem (currently with 1 GitHub star). In one sentence: it provides isolated HTTP(S) proxy channels for DSH web tools based on hostname rules, with automatic fallback to direct connection when the upstream is unreachable. The plugin is not published to npm; source code and documentation are available at the GitHub repository, and the community directory page is at skillhub.cn/plugins/xiaoyi728/dsh-rule-proxy. DSH adopts a “Everything is a Plugin” Cordis assembly approach; directories like skillhub are independent sites with no official affiliation with DeepSeek / High-Flyer.

Differences from Global Proxy Plugins

The following points highlight the design boundaries emphasized in the README to aid selection:

  1. Rule-based routing, not global interception: It maintains independent transport via registerFetchProvider (creating a new Agent/ProxyAgent per request, public IP/DNS pinning, NAT64 checks). It does not modify the model provider, global fetch, global Undici dispatcher, or parent process proxy environment.
  2. Automatic fallback to direct connection: Requests hitting a rule prioritize the upstream; if the upstream is not configured or the connection fails, it switches to a direct connection without throwing an error to the tool. An error is only returned to the tool if the direct connection also fails.
  3. Domain matching strategy: The domain type matches by exact domain and subdomains (github.com matches api.github.com but not notgithub.com); the regex type uses RE2-WASM linear-time matching on the hostname.
  4. Memory-safe rule engine: The re2-wasm compiled instance cannot be freed (fixed 16 MiB heap), so patterns are compiled once for lifelong reuse, and configuration snapshots are compared by value to avoid OOM.
  5. One-click toggle in conversation header: A capsule button in the header of each session (Green = ON / Red = OFF) shares the same state store as the settings page.
  6. Clean uninstall: Releases only this plugin’s resources without leaving global state behind.

Licensed under MIT; requires Node >=22.19.0 and DSH >=0.2.0-rc.2 <0.3.0 (subject to package.json).

Core Features

Scope of Intercepted Requests

It only intercepts web tool requests that hit rules (web_fetch / GitHub tools / optional SearXNG plain search). These requests are sent via the upstream proxy configured in settings; requests that do not hit rules, or fallback requests when the upstream is unavailable, use the plugin’s self-contained direct transport. Model requests, global fetch, the global Undici dispatcher, and the parent process proxy environment are not modified. The plugin does not send telemetry; rules, proxy addresses, and proxyToken exist only in the profile configuration file, and proxyToken is never returned via the API.

Standard bash/git/gh, third-party SDKs, and SSH are not automatically proxied. GitHub tools do not provide private repository credentials, clone, fetch, or push.

Model-side Tools

Tool Description
rule_proxy_diagnose({url, source}) Does not access the network; returns routing and hit reason. source=model indicates it is not managed by the plugin.
github_api_get({path}) Anonymous GitHub API GET
github_git_refs({repository}) HTTPS Git reference query for public owner/repository

Settings and Troubleshooting

“Settings → Tool Rule Proxy” provides rule JSON editing and import (validation before saving/importing), and routing diagnostics (input URL to preview hits, without accessing the network). Turning off the “Tool Proxy Toggle” allows rules to still match, but web tools switch to direct connection; this differs from Cordis’s disabled (full plugin unload).

Installation and Activation

The plugin runs with the permissions of the current dsh process. Before installation, you should inspect the source code and MIT license yourself, and protect the configuration file (including proxyToken) according to your profile permissions.

dsh plugin --profile web add github:xiaoyi728/dsh-rule-proxy

In the GUI, you can paste the repository address in Plugins → Add Plugin, for example:

https://github.com/xiaoyi728/dsh-rule-proxy

Equivalent forms include github:xiaoyi728/dsh-rule-proxy, https://github.com/xiaoyi728/dsh-rule-proxy.git, etc. This plugin has no prepare / build scripts, so source installation will not trigger pnpm’s allowBuilds build authorization. add dsh-rule-proxy (npm name) is currently unavailable.

For local development, you can fill in the absolute path of the repository when adding the plugin.

Hooking up web’s fetchProvider

After installation, you need to point the web service’s fetchProvider to rule-proxy. The native DSH profile uses cordis.patch.yml, so you should merge the following patch into the profile’s existing patch array (do not overwrite other entries):

- insert:
    - id: rule-proxy
      name: dsh-rule-proxy
- id: rule-proxy
  config:
    enabled: true
    proxyUrl: http://127.0.0.1:7890
- id: web
  config:
    fetchProvider: rule-proxy

Here, web must be replaced with the entry id of the actual WebRuntime for that profile; proxyUrl should be modified according to your upstream. The profile must already have the web service; using standard tools also requires enabling the native tool-web. Restart dsh web after installation.

To enable plain search, set searchProvider: rule-proxy-searxng in @deepseek-ai/dsh-web and configure the optional field searxEndpoint.

Typical Usage

Session Header Toggle

“● Proxy ON/OFF” on the right side of the conversation header: a green dot indicates the tool proxy is active, a red dot indicates it is off; click the dot to toggle the master switch, hover to see the number of active rules and upstream address.

Upstream and Authentication

The “Upstream HTTP(S) Proxy” must be an origin (no path, query string, or embedded credentials); SOCKS is not supported yet. For authentication, configure the full Proxy-Authorization value in the secret field proxyToken; this field is never returned by the API.

Rule Examples

Rules are a JSON array, each item containing include, type, title, pattern, active. Only include/regex or include/domain are supported:

[
  { "include": "include", "type": "domain", "title": "GitHub domain", "pattern": "github.com", "active": true },
  { "include": "include", "type": "regex", "title": "OpenAI hosts", "pattern": "(^|\\.)openai\\.com$", "active": true }
]

Rules only match normalized hostnames (lowercase, trailing dot removed). Maximum 256 items, pattern max 512 characters; the host uses RE2, which does not support backreferences or lookaheads, and the settings page will reject illegal constructions. Default rules are provided in the packaged rules.json.

Local Routing Diagnostic CLI

When not starting the GUI, you can use the packaged script to verify routing:

npm run diagnose -- https://github.com web-fetch rules.json
npm run diagnose -- https://api.openai.com model rules.json

Configuration Field Summary

Configuration is persisted by the Cordis profile and exposed via the settings page and schema:

Field Default Description
enabled true Master switch; when false, rules still match but web tools switch to direct connection.
proxyUrl '' Upstream HTTP(S) proxy origin; if empty or connection fails, automatically direct connects.
proxyToken '' Secret: full Proxy-Authorization value.
rules rules.json in package Routing rule array.
searxEndpoint '' Optional SearXNG plain search endpoint.
maxResponseBytes 5000000 Maximum response bytes.
maxBodyChars 100000 Maximum characters for body to text conversion.
timeoutMs 30000 Request timeout.
maxRedirects 5 Maximum redirects (same-origin limited).

If both http and rule-proxy providers are retained, you must explicitly select fetchProvider in the web configuration, otherwise the web service will report a provider ambiguity.

Use Cases and Notes

Suitable for: When you need model web tools to access specific domains (like GitHub, specified API hosts) via a fixed HTTP proxy, while other tool traffic goes direct; when you want automatic fallback on occasional upstream failures rather than throwing errors directly to the tool; when you need to verify hostname hits offline in the settings page or via rule_proxy_diagnose.

Not suitable for or limitations: Diagnostics do not verify DNS, upstream authentication, or TLS; logs do not output request bodies or credentials. Full Git clone/fetch/push is not yet implemented. Rule matching and tool transport isolation do not equal control over the internal network of model services or remote search services. The README notes that public network HTTPS upstreams and real GitHub workflows require acceptance testing in an isolated profile with a self-provided upstream; local unit tests use fake targets and cannot be used to assume production environments are connected.

When uninstalling, first change the web’s fetchProvider back to http and searchProvider back to its original value, then remove the rule-proxy plugin entry.

Conclusion

dsh-rule-proxy converges “web tools via proxy” into hostname rules and an independent transport layer, decoupled from global network rewriting, and falls back to direct connection when the upstream is unavailable. To install or read design details, open the Community Directory Page and GitHub Repository; for pitfalls and design decisions, see docs/LESSONS.md in the repository, and for test descriptions, see TEST_REPORT.md.

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

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

Xiaoye