Back to home@kenny2077

dsh-web-search-zai

Web search for the DeepSeek Harness, powered by Z.ai (GLM)

Stars
1
Language
TypeScript
Created
Aug 28, 2026
Updated
Aug 28, 2026
GitHub repo

Introduction

dsh-web-search-zai

Web search for the DeepSeek Harness, powered by Z.ai (GLM).

CI npm version License: MIT

English | 中文

What is it

dsh-web-search-zai is a community plugin for the DeepSeek Harness that plugs a ZAI (Zhipu/GLM)-backed search provider into the harness's ctx.web capability seam. One dsh plugin add and your harness searches the web through ZAI's standalone Web Search API — no editing of base bundles, no restart to change settings.

Why

  • One key for chat and search. The same ZAI_API_KEY that authorizes the GLM chat model authorizes this search. If you have an active Coding Plan or token balance, you're already set up.
  • Runtime-configurable. Endpoint, engine, and recency window are plain settings — a committed change takes effect on the very next search, no restart.
  • Fits the seam, not around it. The provider registers into ctx.web exactly like the built-in DeepSeek provider, so dsh-tool-web and everything above the seam work unchanged.
  • No invented fields. Only what the API actually returns gets mapped — if ZAI doesn't send a publication date, you won't get a fabricated one.

How it works

dsh ──▶ ctx.web ──▶ web-search-zai ──▶ POST {baseURL}/web_search
                        │                    ZAI (Zhipu/GLM)
                        ◀──────────────────── search_result[]
                        │
                        └──▶ normalized WebSearchResult (sources + truncated)

ZAI returns a flat search_result[] with no generated answer, so each entry maps to a source and content is omitted:

ZAI fieldSeam fieldNotes
linkurlEntry dropped if missing
titletitleOmitted when empty
contentsnippetEntry dropped if blank
publishedAtNot returned by the API; omitted rather than invented

Failures surface as standard WebError codes: WEB_PROVIDER_ERROR (HTTP/network/bad body), WEB_ABORTED (cancellation), and WEB_PROVIDER_CREDENTIAL_MISSING (no key). Through dsh-tool-web, these reach the model under the consumer's usual error wrapper.

Quick start

You'll need the DeepSeek Harness installed (dsh CLI available) and a ZAI API key.

  1. Get a key at z.ai (international) or open.bigmodel.cn (China), then store it so it never lands in a config file — via the harness web UI (Models page), a ZAI_API_KEY entry in $DSH_HOME/.credentials.yaml, or the launching environment.

    A Token Rhythm (chat gateway) key does not work here — only a native ZAI key.

  2. Install the plugin:

    dsh plugin add dsh-web-search-zai        # from npm
    dsh plugin add github:kenny2077/dsh-web-search-zai   # from git (prebuilt, no build step)
    

    The cordis.patch.yml overlay registers the provider and switches the active searchProvider from deepseek-official to zai in one step. To go back: dsh plugin remove dsh-web-search-zai.

  3. Search. Ask your harness something current and watch the web_search tool return ZAI results.

Configuration

All fields are runtime-configurable via the Settings GUI (web-search-zai namespace); changes apply on the next search.

KeyDefaultMeaning
apiKey(from credentials store)Literal ZAI API key. Prefer apiKeyEnv so no secret enters config files.
apiKeyEnvZAI_API_KEYCredential reference resolved for each search.
baseURLhttps://api.z.ai/api/paas/v4Endpoint base; /web_search is appended.
searchEnginesearch-primesearch-prime for api.z.ai; search_pro (underscore) for open.bigmodel.cn.
searchRecency(unset)Recency filter: day, week, month, or year.

Known limitations

  • Results without a link or snippet are dropped, so you may get fewer sources than requested.
  • Very short queries can return zero results (e.g. "SP Tarkov mods installation" → 0; add the word "guide" → 10). That's the upstream backend, not the plugin.
  • No publishedAt — the API doesn't reliably return one.
  • The engine name differs per endpoint (search-prime vs search_pro); it's a config field, not auto-derived.
  • Only a DOMException named AbortError maps to WEB_ABORTED; aborts carrying custom reasons surface as WEB_PROVIDER_ERROR.
  • The chat-side web_search tool-injection variant is deferred; this provider uses the standalone API only.

Development

pnpm install     # all dependencies (including DSH seam packages) come from npm
pnpm typecheck   # tsc --noEmit
pnpm build       # emits lib/*.js + lib/types/*.d.ts
pnpm test        # unit suite (34 tests)

The live-API smoke test self-skips without a key:

ZAI_API_KEY=<key> pnpm exec vitest run tests/zai.e2e.ts

See CONTRIBUTING.md for guidelines.

License

MIT