Preface¶
When running agents in DeepSeek Harness (DSH), if the upstream returns a 401 or 403, the client categorizes the error as AUTH and displays a unified “API Key Invalid” message in the UI. True causes such as token expiration, session invalidation, or the need to re-probe directories are masked by this single message. Developers are left guessing which provider failed and must manually renew credentials.
dsh-api-heal is a community plugin that monitors authentication failures, calls the respective renewal endpoints for each provider, and instructs the agent loop to resend the request in-place. In most cases, the user will not see the error. Below is an introduction to its positioning, capabilities, and installation methods.
What is this¶
- Name: dsh-api-heal (npm package name matches the directory name)
- Maintainer: YSwo-fei
- Category: admin-security (SkillHub Directory)
- Version: 0.1.0 (MIT)
- Repository: https://github.com/YSwo-fei/dsh-api-heal
The plugin does not modify the DSH core, nor does it change the “API Key Invalid” text. Instead, it attempts to repair the credential chain before the error reaches the UI and exposes read-only status routes and manual tools for the model or operations staff to call.
Core Features¶
Automatic Self-Healing¶
Monitors agent/request-error. If a failure resembles an authentication issue, it renews or re-fetches credentials for the corresponding provider locally and returns { kind: "retry" }, allowing the agent loop to resend the same request in-place.
Automatic behavior can be disabled via cordis.patch.yml in the profile (autoHeal: false); manual tools remain available in this mode.
Manual Tool heal_api¶
Can be actively invoked by models or scripts. Optional parameter provider: qoder, workbuddy-ai, our-free-model; if not passed, all three are processed sequentially.
Status Route¶
Read-only: GET /plugins/dsh-api-heal/status. The route is registered when the DSH process starts; accessing it before a restart will result in a 404.
Self-Healing Actions for the Three Providers¶
| provider | Self-Healing Action |
|---|---|
qoder |
GET /plugins/dsh-qoder-connect/status to obtain probeKey → POST /plugins/dsh-qoder-connect/probe with body {"action":"refresh"} (triggers renewal and refreshes model catalog) |
workbuddy-ai |
GET /plugins/dsh-workbuddy-connect/ai/status to obtain probeKey → POST .../ai/probe {"action":"refresh"} (re-decrypts desktop credentials and re-pulls catalog; CN variant skips directly if signed-out) |
our-free-model |
POST /api/our-free-model/refresh, requires connection authentication cookie |
our-free-model’s /api/our-free-model/* is mounted behind a connection admission fence; a raw POST will return 401. The plugin reads the signing key from client-connection/browser-session in .credentials.yaml and self-signs a session cookie using the same algorithm as dsh-client-connection (HMAC-SHA256 + base64url, payload {version:1, authority, issuedAt, expiresAt}), requiring no browser or logged-in Web session.
Installation and Activation¶
The official README targets Windows: On local PowerShell 5.1 with execution policy RemoteSigned, it is not recommended to directly use the unsigned install.ps1; install.cmd should be used instead:
E:\DSH CODE\dsh-api-heal\install.cmd
The script backs up the profile’s package.json, copies the plugin to .dsh/plugins/dsh-api-heal under the data directory, writes it into dependencies as a file: reference, adds it to dsh.profile.bundles, runs pnpm install, and performs a post-install self-check. Paths depend on your local clone or extraction location; the example above is from the README.
After installation, fully restart DSH (quit the tray as well). Verify with:
GET http://127.0.0.1:19387/plugins/dsh-api-heal/status
Rollback:
E:\DSH CODE\dsh-api-heal\install.cmd -Uninstall
The plugin runs with the current DSH process permissions. Please read the repository source code and the MIT license before installation to ensure compliance with your security policy. Node engine requirement: ^22.19.0 || >=24.0.0 (see package.json).
Configuration¶
Plugin configuration can be overridden in the profile’s cordis.patch.yml:
| Key | Default | Description |
|---|---|---|
enabled |
true |
Master switch |
autoHeal |
true |
If disabled, only manual heal_api remains |
cooldownMs |
60000 |
Minimum interval between two automatic self-healings (debounce) |
requestTimeoutMs |
30000 |
Timeout for a single upstream call |
webBaseUrl |
"" |
If empty, sequentially uses webServer.port/host → $DSH_WEB_URL → http://127.0.0.1:19387 |
registerRoutes |
true |
Whether to register status routes |
Example snippet:
- id: api-heal
name: dsh-api-heal
config:
cooldownMs: 15000
autoHeal: true
Typical Usage and Verification¶
Probe the three entry points without installing the plugin¶
Set DSH_HOME and DSH’s bundled node.exe, then run in the plugin directory:
cd /d "E:\DSH CODE\dsh-api-heal"
set DSH_HOME=E:\dsh-data\.dsh
set NODE=D:\DSH\resources\runtime\primary-runtime\dependencies\node\bin\node.exe
%NODE% probe.mjs
On success, the output will look like: a line for each of qoder / workbuddy-ai / our-free-model showing [OK] and timing details.
Full test after plugin installation¶
%NODE% selftest.mjs
%NODE% smoke.mjs
%NODE% loadtest.mjs
loadtest.mjs requires extracting real dependencies from app.asar (the stage_deps.mjs step in the README, only needed once).
If authentication failures still occur at runtime, let the agent call heal_api, or specify a provider to fix only one.
Use Cases and Boundaries¶
Suitable for: Environments where DSH agents are kept running long-term, relying on one or more of qoder / workbuddy-ai / our-free-model, and occasionally encountering credential expiration that causes the UI to uniformly report “API Key Invalid”.
Boundaries (Key points from the original README):
- Can only save requests that “fail after the stream has been established”. If an error is thrown during the connection phase (
started === false), theagent/request-errorlistener will not run; manualheal_apior resending the message is required. probeKeychanges with every process restart. The plugin fetches it dynamically viaGET .../statusevery time; it is not hardcoded.- Automatic self-healing has a default 60-second cooldown, preventing the upstream from being flooded with requests due to the same error in a short period.
- The
our-free-modelcookie is signed with the local.credentials.yamlkey, used only on 127.0.0.1, and is not persisted to disk or sent externally.
The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent of DeepSeek / High-Flyer. This article introduces a community-maintained admin-security plugin, not an official app store entry.
Conclusion¶
dsh-api-heal decomposes authentication failures swallowed by the UI back into executable renewal steps for the three providers and automatically retries within the agent loop, reducing the troubleshooting cost caused by misinterpreting “API Key Invalid”. Directory and Source Code: