Preface¶
When running agents in DeepSeek Harness (DSH), model calls and tool network requests all go through the harness’s unified outbound HTTP. Gateways often have additional conventions for request headers and paths: missing one field results in a 400 error, but the logs don’t show “what was missing.” Patching each provider or SDK individually is inefficient — fixing one place misses another — and it is also not conducive to unified acceptance testing in desktop profiles.
Below is an introduction to the community plugin @leolee9086/dsh-fetch-router (maintainer: leolee9086, category: networking tool). It routes based on host + path on the DSH outbound path: it can inject or rewrite request headers, rewrite the target URL, or respond locally; and it provides a native DSH right sidebar monitoring panel for comparing rules against actual upstream behavior. The default rules in the package target the OpenCode Zen gateway’s 400 MissingSessionID (this gateway requires x-opencode-session and rejects requests that lack it).
What Is This¶
In one sentence: dsh-fetch-router is a fetch routing plugin for DSH that matches rules by hostname and path, performing header injection, URL rewriting, or local mocking before requests actually go out, while displaying hits and results one by one in the right sidebar.
- Name:
@leolee9086/dsh-fetch-router - Current version (package.json):
0.1.2 - License: MIT
- Dependencies:
@leolee9086/sac-path-router(npm package, no build scripts run on install) - Directory page: https://www.skillhub.cn/plugins/leolee9086/dsh-fetch-router
- Source code: https://github.com/leolee9086/dsh-fetch-router
The plugin intercepts and rewrites outbound requests with the permissions of the current DSH process; before installing, you should read the source code and license yourself, and only enable it in trusted profiles.
Core Features¶
Endpoint Routing (host + path)¶
The routing layer matches requests according to match conditions:
host(required, supports*.example.com)path(radix wildcard, default/**)methodsprovider,model,purpose(taken from the model call scope of the current request)
After matching, you can:
- Inject or override request headers via
headers(subject toreservedandifAbsentconstraints) - Change the dispatch target via
rewrite.url/rewrite.path/rewrite.search - Respond locally via
respond(requiresallowMock: true)
Template variables include $session, $provider, $model, $purpose, $requestId; when a value cannot be obtained, the behavior is determined by onMissing (fail or skip). Multiple rules on the same path are processed in declaration order, taking the first one that satisfies the conditions; if no endpoint rule is matched, no endpoint processing is performed, and the request goes out as normal.
Middleware Layer (Content Rewriting)¶
A layer separate from endpoint routing: before path matching, it runs rewriters registered by requestRewrite for all requests. What it modifies is the body, and it is unrelated to the host. The rewrite result is written to ctx.requestBody and used by the fetch entry point when going out.
- Explicit string bodies can be modified
Requestobjects passed by SDKs are only read, cloned, and rewritten when the media type is JSON (including+json) ortext/*- Explicit streams, FormData, URLSearchParams, and binary
Requestobjects are not processed
The two layers do not share a single gate: content rewriting concerns “operations on the body during this particular send,” which is orthogonal to endpoint attribution. Therefore, a Request is constructed for all requests (there is no longer a host early-exit), ensuring that rewriting applies to every request.
Right Sidebar Monitoring Panel¶
It registers a native right sidebar tab in the interface, with the entry at the bottom of the left sidebar (grayed out when there is no session). The panel allows viewing:
- Per request: time,
host+path, method, matched rule, modified header names, result (forward/mock/skipped/error),provider·model, upstream status code, duration - Summary: hit, passthrough, local response, and error counts; the currently active routing table; pause recording
Data interfaces (loopback only, reusing DSH Connection’s Host/Origin and signed Cookie verification):
GET {panel.path}/stats.jsonGET {panel.path}/events(SSE)POST {panel.path}/recording
By default, it does not write session logs or send session events; by default, it does not record bodies; authorization, cookie, and headers containing token / secret never display values.
Default Bundled Rules¶
The cordis.patch.yml in the package contains the example rule opencode-session-chat: for POST requests to /zen/go/v1/chat/completions on opencode.ai (where provider matches opencode-go*), it injects x-opencode-session: $session when a session exists.
Installation and Activation¶
It has been adapted to the runtime service contract of DSH 0.2.0-rc.2. Desktop deployment uses the desktop profile, not web.
Install via the GitHub address in the existing DSH plugin manager:
github:leolee9086/dsh-fetch-router#<commit-sha>
Replace <commit-sha> with a published commit to pin the installation version. Deployments with the DSH CLI can also use:
dsh plugin --profile desktop add github:leolee9086/dsh-fetch-router#<commit-sha>
dsh plugin --profile desktop remove @leolee9086/dsh-fetch-router
Go by the applied or restart-required status reported by the installer; updates that involve existing Host code require a restart to replace the Node module. Do not use local link: installation to substitute for GitHub release acceptance.
The package comes with a bundle patch (cordis.patch.yml), which is merged into profile layers by dsh plugin after installation, so there is no need to manually modify the profile’s cordis.patch.yml.
Typical Configuration¶
The default configuration is in the package’s cordis.patch.yml; to change rules, override config with the same id: fetch-router in the profile’s cordis.patch.yml.
- id: fetch-router
name: "@leolee9086/dsh-fetch-router"
config:
reserved: [user-agent] # Request headers that are never overridden by rules
ifAbsent: true # Do not override if the target header already exists
allowMock: false # Allow respond local responses (forged responses do not enter session logs)
onMissing: fail # When rule require is not satisfied: fail | skip
log: { matched: true, passthrough: false, headers: false, buffer: 200 }
panel: { enabled: true, path: '/fetch-router' }
routes:
- id: opencode-session-chat
match: { host: "opencode.ai", path: "/zen/go/v1/chat/completions", methods: [POST], provider: "opencode-go*" }
require: [session]
headers: { x-opencode-session: "$session" }
Descriptions of common configuration items:
reserved: request headers that rules must not override (e.g.,user-agent)ifAbsent: true: do not override if the target header already existsallowMock: therespondlocal response switch; forged responses enter the model context but not the session log, breaking “Model-visible ⟺ logged”, so it is only suitable for test profilesonMissing:failorskipwhen rulerequireis not satisfiedpanel.enabled/panel.path: monitoring panel switch and path prefix
Use Cases and Notes¶
Who it’s for
- Need to uniformly add request headers or change URLs for specific gateways at the DSH layer without modifying each provider implementation
- Debugging outbound behavior, wanting to see matched rules and upstream status codes in a local right panel
- Using gateways like OpenCode Zen that require session headers, wanting to quickly verify with default bundled rules
Boundaries and behavior
- If the configuration is invalid, installation is rejected, keeping the original
fetch - If a rewriter throws an error, the current request is immediately rejected, and the exception propagates to the caller
- Not covered: SDKs that connect directly via
node:http; pi-aitransport: 'websocket'routes - After dispose, it first passes through purely, then restores
globalThis.fetchbased on identity
The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer. This plugin has 0 GitHub stars (as of the data capture); please evaluate the maintenance pace and issue status yourself when choosing.
Conclusion¶
dsh-fetch-router separates “per-endpoint header injection / target rewriting / local response” and “global body rewriting” into two layers for DSH outbound HTTP, and comes with a native right sidebar monitor, making it suitable for centrally handling gateway conventions and joint debugging observation in desktop profiles.
- Directory page: https://www.skillhub.cn/plugins/leolee9086/dsh-fetch-router
- GitHub: https://github.com/leolee9086/dsh-fetch-router