DSH Desktop: AnySearch Provider and 402 Key Rotation

Preface

In the official DeepSeek Harness (DSH) desktop, web_search and web_fetch require a reliable internet-connected backend. If you use the AnySearch HTTP API, a single key may trigger an HTTP 402 due to quota limits or billing issues, causing the entire search to fail directly; furthermore, if local DNS caches a stale node, fetch failed may occur, rendering search unavailable. The community plugin sousuo (repository yueyexiayu/dsh-sousuo) targets the official desktop, adapting AnySearch into a DSH search/fetch Provider and rotating through multiple local keys for retry when encountering a 402. Below is an introduction to what it is, what it does, and how to install and enable it.

What is this

sousuo is released by maintainer yueyexiayu and categorized as a Networking Tool in the SkillHub directory. The current version is 0.1.6 (see repository package.json). In one sentence: it is a DSH desktop search provider — the backend remains AnySearch’s web_search / web_fetch HTTP API; the plugin handles Provider adaptation, immediately switches to the next local API key and retries the same request upon encountering an HTTP 402 (a single request rotates through keys at most once before failing), and ensures system prompts related to answering after search are enforced. It does not rotate keys for 401 / 403 / 429.

The project description emphasizes: currently deeply adapted for personal use; intended for reference and inspiration, do not copy directly; targets the official desktop, do not write keys into patches, READMEs, Git, or conversations.

Core Features

Division of Labor: AnySearch and Official tool-web

  • web_search / web_fetch are still registered and controlled by the official tool-web; the plugin only provides the AnySearch provider and will not re-enable a disabled web_fetch.
  • The security statement for native search is rendered by the official tool-web; the provider does not disguise the statement as content / answer.
  • Normal zero results return No results found.; clear prompts are provided when sources are empty after trimming; request failures and cancellations still throw official WEB_PROVIDER_ERROR / WEB_ABORTED, rather than returning an empty success.

HTTP 402 and Multi-Key Rotation

  • Keys are stored locally at $DSH_HOME/plugins/sousuo/keys (default $DSH_HOME is ~/.dsh), one per line, with # indicating comments; state.json records the current index and is also excluded from Git.
  • Each request captures an independent current-first candidate slot snapshot, iterating through keys at most one full round. Under concurrency, keys are neither skipped nor duplicated due to switching.
  • 402 triggers a switch to the next key and retry; 401 / 403 / 429 do not rotate, and Retry-After is preserved.

Connection and DNS

  • If the API connection fails with TypeError: fetch failed, it first retries once using system DNS; if it still fails and the target does not require an environment proxy, it attempts a direct connection using an IPv4 resolved via public DNS/DoH (SNI remains the request hostname). This mitigates situations where locally cached stale GTM nodes cause the entire search to fail.
  • When HTTP_PROXY / HTTPS_PROXY / ALL_PROXY are configured, the system proxy path is preserved, and credentials are not sent bypassing the proxy; NO_PROXY only enables direct connections for commonly used rules that can be safely confirmed.

Advanced Tools (Disabled by Default)

By default, anysearch_capabilities / anysearch_search / anysearch_batch_search are not exposed to the model. This avoids scenarios where some high-reasoning models perform capability discovery first, then “search again” in their thinking and stop, making the interface appear as if the internet connection stopped automatically. Standard queries can simply use web_search, as the backend is already sousuo. If vertical tags are needed, set advancedTools: true for this plugin in the desktop patch.

Other Behaviors (Explained in README)

  • Connection, body reading, and DNS fallback share a 55-second timeout limit for the current HTTP request; 502 / 503 / 504 will trigger retries and release the old response.
  • API response JSON is limited to 5,000,000 bytes before parsing; search retains a maximum of 50 sources, with length limits on titles, snippets, URLs, etc.
  • The local 55-second deadline maps to the official WEB_FETCH_TIMEOUT; oversized responses map to WEB_FETCH_TOO_LARGE; cancellation maps to WEB_ABORTED.

Installation and Activation

The installation steps come from the repository README and are not CLI installations like dsh plugin add github:.... The README states that this solution directly manages declared file: dependencies without running additional CLI plugin installations, and does not add sousuo to dsh.profile.bundles again (the user patch handles activation to avoid duplicate registration).

1. Copy the plugin to the plugins directory

Copy this repository to $DSH_HOME/plugins/sousuo.

2. Declare file dependency in the desktop profile

Add the following to the dependencies in $DSH_HOME/profiles/desktop/package.json:

"sousuo": "file:../../plugins/sousuo"

Keep other dependencies and dsh.profile.bundles. Use the pnpm included with the current DSH to run in this profile:

pnpm install --ignore-scripts

And keep the generated pnpm-lock.yaml. Keep the profile’s pnpm-workspace.yaml with nodeLinker: hoisted and autoInstallPeers: false.

The package declares @deepseek-ai/dsh-web / @deepseek-ai/schemastery etc. as peers provided by the Host, without installing a separate set of official DSH runtimes.

3. Write cordis.patch.yml

Write the following to $DSH_HOME/profiles/desktop/cordis.patch.yml:

- insert:
    - id: sousuo
      name: ./node_modules/sousuo/lib/index.js
      config:
        baseURL: https://api.anysearch.com
        # advancedTools: true   # Optional: re-expose anysearch_* vertical search tools

- id: web
  config:
    searchProvider: sousuo
    fetchProvider: sousuo

Note: - id: web will replace the entire web config block. After completion, fully quit DeepSeek Harness (macOS: ⌘Q) before reopening.

4. Configure the local Key file

cp keys.example keys
chmod 600 keys

Use an editor to write real keys into keys; do not paste them into chats or Git. C0/C1 control characters are rejected before trimming, and errors report only the line number.

Typical Usage

Once enabled, simply call web_search and web_fetch in conversations just like using the official internet features. When both searchProvider and fetchProvider point to sousuo, traffic is forwarded through this plugin to AnySearch (default baseURL: https://api.anysearch.com).

If advancedTools: true has been enabled in the patch, the model can also use the anysearch_* series of vertical search and batch search tools; when disabled by default, no change in usage is needed, and standard retrieval still goes through web_search.

Use Cases and Notes

Who it is for: Individuals or developers in self-built environments who are already using AnySearch in the official DSH desktop, wish to use multiple keys to mitigate 402 errors, and require DNS/proxy strategies consistent with official error semantics.

Permissions and Security: The plugin runs with the permissions of the current DSH process; before installation, you should read the source code and license yourself (the repository packaging whitelist includes LICENSE) to confirm that keys remain only in the local keys file and runtime state, and do not enter Git or conversations.

Ecosystem Notes: The DSH philosophy is “Everything is a plugin”; the SkillHub directory page is a community site and has no official affiliation with DeepSeek / High-Flyer.

Development Sync: After modifying plugin source code, the README requires incrementing package.json and lib/version.js, removing and re-adding the file: dependency in the desktop profile using the bundled pnpm, performing a frozen-lockfile install, then fully quitting the Host before reopening for actual testing. A standard install / update may retain old hard links and cannot guarantee complete sync with the source code.

Conclusion

sousuo connects AnySearch to the DSH official desktop’s web_search / web_fetch, uses local key rotation to handle 402s, and implements DNS and proxy remedies at the connection layer; it hides advanced anysearch tools by default to reduce “false stops” caused by model misuse. For details and development test commands, refer to the repository README.

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

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

Xiaoye