dsh-querit 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -46
- package/cordis.patch.yml +6 -0
- package/lib/card.js +264 -240
- package/lib/client.d.ts +105 -6
- package/lib/client.js +198 -41
- package/lib/index.d.ts +70 -59
- package/lib/index.js +150 -123
- package/lib/provider.d.ts +51 -17
- package/lib/provider.js +160 -90
- package/lib/sanitize.d.ts +2 -0
- package/lib/sanitize.js +4 -0
- package/package.json +29 -30
- package/lib/invariant.d.ts +0 -18
- package/lib/invariant.js +0 -20
package/README.md
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
# dsh-querit
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-querit)
|
|
3
4
|
[](./LICENSE)
|
|
4
5
|
|
|
5
6
|
Querit-backed search and fetch providers for the DeepSeek Harness [web capability seam](https://www.npmjs.com/package/@deepseek-ai/dsh-web) (`ctx.web`). It is the DeepSeek Harness counterpart of [`pi-querit`](https://www.npmjs.com/package/pi-querit): the model-facing `web_search` and `web_fetch` tools keep working unchanged, and this package swaps their backend to [Querit](https://www.querit.ai) — live web search and clean page content through `POST https://api.querit.ai/v1/search` and `/v1/contents`.
|
|
6
7
|
|
|
7
8
|
Sign up on [Querit.ai](https://www.querit.ai) to get an API key with **1,000 free API calls per month** — no credit card required.
|
|
8
9
|
|
|
9
|
-
Since
|
|
10
|
+
Since v2.0.0 the package targets **dsh 0.2.2-rc.5 and later 0.2.x hosts** on Node.js 24.9 or newer. The host checks the package's `engines.dsh` range at install and startup, and refuses a host outside it. On dsh 0.1.x hosts install `dsh-querit@1.1.2` instead.
|
|
10
11
|
|
|
11
12
|
## Quick start
|
|
12
13
|
|
|
13
|
-
1. Install the package (see **Install and update** below).
|
|
14
|
-
2.
|
|
15
|
-
- `
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
3. Restart the profile to load the plugin row and its settings card.
|
|
14
|
+
1. Install the package (see **Install and update** below). It ships as a *profile bundle*: `dsh plugin add` wires the provider row and the seam routing automatically — no `cordis.patch.yml` edits needed.
|
|
15
|
+
2. Give it a Querit API key. Either:
|
|
16
|
+
- open **Settings → Plugins → Installed → `dsh-querit` → the `web-search-querit` row → Configure** and enter the key, or
|
|
17
|
+
- add `QUERIT_API_KEY` to the credentials store, or
|
|
18
|
+
- set `apiKey` on the `web-search-querit` row.
|
|
19
|
+
3. Search. Both model-facing web tools now run through Querit.
|
|
20
20
|
|
|
21
|
-
If the plugin loads without any resolvable key, the host log prints a one-time warning
|
|
22
|
-
|
|
23
|
-
Since v1.0.4 the package also ships a browser half with a settings card: **Settings → Plugins → Plugin configuration** lists a "Querit web search" card that edits the `web-search-querit` namespace (credential reference, result count, time range, languages, countries, domain lists, content excerpts, fetch format) and can write the API key straight into the credentials domain. Its writes go through the same settings transport as `$DSH_HOME/settings.yaml` (see **Config**). Since v1.0.6 the card chrome (background, padding, font size, chevron toggle, button styles) matches the official plugin cards shipped by `@deepseek-ai/dsh-client-ui-settings-plugins`, so the entry sits flush with "Terminal", "Agent loop", and the DeepSeek "Web search" row. All colors and borders are sourced from the theme's alias tokens (`--dsw-alias-bg-layer-3`, `--dsw-alias-label-primary`, etc.), so the card follows the active light or dark palette without any package-local override.
|
|
24
|
-
|
|
25
|
-
This is an **implementation** package: it registers one search provider and one fetch provider into `ctx.web`. Per operation, it resolves the API key from the launching environment first, then the optional `ctx.credentials` seam, then literal config. It registers no model-facing tool itself: since dsh 0.1.2 the base composition and agent presets register both `web_search` and `web_fetch` through their `tool-web` rows, and both tools execute through `ctx.web` — so once the seam selects Querit, both tools are Querit-backed. (`fetch: true` opts into registering `web_fetch` via [`@deepseek-ai/dsh-tool-web`](https://www.npmjs.com/package/@deepseek-ai/dsh-tool-web)'s `applyWebFetchTool` for compositions that provide no `tool-web` row.) Both providers share the stable id `web-search-querit`, mirroring the native `web-search-deepseek` naming.
|
|
21
|
+
If the plugin loads without any resolvable key, the host log prints a one-time warning. Until a key exists the providers report themselves not ready, so the host withholds `web_search` and `web_fetch` for that step instead of failing the call. A search that is attempted anyway fails with a `WEB_PROVIDER_CREDENTIAL_MISSING` error that spells out the same options.
|
|
26
22
|
|
|
27
23
|
## Install and update
|
|
28
24
|
|
|
@@ -34,13 +30,13 @@ dsh plugin --profile web add dsh-querit
|
|
|
34
30
|
|
|
35
31
|
(`dsh plugin` forwards to pnpm in the profile directory; replace `web` with your profile name.)
|
|
36
32
|
|
|
37
|
-
Installing also reconciles the profile's bundle list: because `dsh-querit` declares `dsh.bundle`, it automatically joins `dsh.profile.bundles` and its shipped patch layer registers the provider row, routes the seam, and disables the DeepSeek search row (the entries shown in **Wire it up**). After the install completes, restart the profile and the plugin is live. `dsh plugin remove dsh-querit` drops the whole layer, so everything the bundle did — including the DeepSeek disable — reverts to the base behavior automatically.
|
|
33
|
+
Installing also reconciles the profile's bundle list: because `dsh-querit` declares `dsh.bundle`, it automatically joins `dsh.profile.bundles` and its shipped patch layer registers the provider row, routes the seam, and disables the DeepSeek search row (the entries shown in **Wire it up**). After the install completes, restart the profile and the plugin is live. `dsh plugin remove dsh-querit` drops the whole layer, so everything the bundle did — including the DeepSeek disable — reverts to the base behavior automatically.
|
|
38
34
|
|
|
39
35
|
### Update
|
|
40
36
|
|
|
41
37
|
```bash
|
|
42
38
|
dsh plugin --profile web outdated # what's new?
|
|
43
|
-
dsh plugin --profile web update dsh-querit
|
|
39
|
+
dsh plugin --profile web update dsh-querit # update within the declared range
|
|
44
40
|
```
|
|
45
41
|
|
|
46
42
|
pnpm 11+ ignores releases younger than its minimum-release-age window, so a version published minutes ago may not show up in `outdated`/`update` yet. Install it immediately with an explicit version:
|
|
@@ -60,10 +56,10 @@ Only when pnpm is unavailable: unpack the tarball into `<profile>/node_modules/d
|
|
|
60
56
|
|
|
61
57
|
## Wire it up
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
The package ships as a profile bundle whose patch layer applies all of this automatically. For reference, the entries it applies (kept in the package as `cordis.patch.yml`) are:
|
|
64
60
|
|
|
65
61
|
```yaml
|
|
66
|
-
# Add the provider row
|
|
62
|
+
# Add the provider row.
|
|
67
63
|
- insert:
|
|
68
64
|
- id: web-search-querit
|
|
69
65
|
name: 'dsh-querit'
|
|
@@ -82,9 +78,11 @@ Since v1.0.3 the package ships as a profile bundle whose patch layer applies all
|
|
|
82
78
|
disabled: true
|
|
83
79
|
```
|
|
84
80
|
|
|
85
|
-
That is the whole wiring: `web_search`
|
|
81
|
+
That is the whole wiring: `web_search` and `web_fetch` both route through `ctx.web`, which now selects Querit. A patch **replaces** the targeted row's whole `config`, so the `web` entry above restates both keys. The bundle layer applies after the base and app bundles, so its `web` override wins unless your profile's own `cordis.patch.yml` or a `--patch` overlay comes later and restates the row — that is also how you switch back to DeepSeek search (`searchProvider: deepseek-official`), re-enable the DeepSeek row (`disabled: false`), or pin custom defaults. Restart the profile to load the row.
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
The row id `web-search-querit` doubles as the entry's settings namespace and as the key of its configuration page (`dsh-querit#web-search-querit`). Renaming the row in a later layer detaches that page: the providers keep working, but the row can then only be configured through the profile's own patch.
|
|
84
|
+
|
|
85
|
+
Keep the DeepSeek provider row disabled unless you explicitly need it: the bundle ships `disabled: true` on `web-search-deepseek`, so only Querit is mounted.
|
|
88
86
|
|
|
89
87
|
If a preset ever registers `web_fetch` itself (its `tool-web` row with `fetch: true`), set `fetch: false` on this row so only one registration exists per scope.
|
|
90
88
|
|
|
@@ -92,24 +90,30 @@ If a preset ever registers `web_fetch` itself (its `tool-web` row with `fetch: t
|
|
|
92
90
|
|
|
93
91
|
| Key | Default | Meaning |
|
|
94
92
|
|---|---|---|
|
|
95
|
-
| `apiKey` | omitted | Literal Querit API key. Prefer
|
|
96
|
-
| `apiKeyEnv` | `QUERIT_API_KEY` | Credential reference
|
|
93
|
+
| `apiKey` | omitted | Literal Querit API key. Prefer the settings page or the credentials store so no secret enters composition files. When set, it wins over every other source. |
|
|
94
|
+
| `apiKeyEnv` | `QUERIT_API_KEY` | Credential reference the providers resolve per operation. |
|
|
97
95
|
| `baseURL` | `https://api.querit.ai` | Querit API base; `/v1/search` and `/v1/contents` are appended. Falls back to `$QUERIT_BASE_URL` from any environment layer. An unparseable value makes both providers unavailable. |
|
|
98
|
-
| `timeoutMs` | `70000` |
|
|
99
|
-
| `count` |
|
|
96
|
+
| `timeoutMs` | `70000` | Deadline for one operation in ms (minimum 1000), retries and backoff waits included. |
|
|
97
|
+
| `count` | Querit's server default | Result count used when the seam passes no `maxResults` bound (1–100). Leave unset to let Querit choose. The `dsh-tool-web` layer always bounds searches, so this mainly serves direct seam callers. |
|
|
100
98
|
| `timeRange` | none | Relative (`d7`, `w2`, `m3`, `y1`, or any `dN`/`wN`/`mN`/`yN`) or `YYYY-MM-DDtoYYYY-MM-DD` date range. |
|
|
101
99
|
| `countries` | none | Country bias. Valid values: `argentina`, `australia`, `brazil`, `canada`, `colombia`, `france`, `germany`, `india`, `indonesia`, `japan`, `mexico`, `nigeria`, `philippines`, `south korea`, `spain`, `united kingdom`, `united states`. |
|
|
102
|
-
| `languages` | none | Language filter. Valid values: `english`, `japanese`, `korean`, `german`, `french`, `spanish`, `portuguese`. |
|
|
100
|
+
| `languages` | none | Language filter. Valid values: `english`, `japanese`, `korean`, `german`, `french`, `spanish`, `portuguese`, `russian`. |
|
|
103
101
|
| `includeDomains` | none | **Whitelist** hostnames; only these domains return results. |
|
|
104
102
|
| `excludeDomains` | none | **Blacklist** hostnames; these domains never return results. |
|
|
105
|
-
| `includeContent` | `false` | Request
|
|
106
|
-
| `
|
|
103
|
+
| `includeContent` | `false` | Request body text (`needContent`). Querit bills each page returned. |
|
|
104
|
+
| `contentMaxChars` | full body text | With `includeContent`, cap the body text per result in Unicode code points (1–1000000). |
|
|
105
|
+
| `highlights` | `false` | Request the passages of each page that match the query. Usually the better answer to "the snippet is too short", and cheaper to read than whole pages. |
|
|
106
|
+
| `needMarkdown` | `false` | Enterprise plans only: return the snippet and body as Markdown. Querit ignores it on other plans. |
|
|
107
|
+
| `rank` | default ranking | `relevance` or `freshness`: a nudge on top of Querit's default ranking, not a sort. Dropped automatically for `vertical: code`, which rejects it. |
|
|
108
|
+
| `vertical` | none | Route every search to a vertical data source: `code` or `finance`. A mismatched vertical loses results, so set it only on a profile that asks nothing but code or finance questions. |
|
|
109
|
+
| `resourceTags` | none | Code vertical only: `qa`, `github`, or both. Omit to search the whole vertical. |
|
|
110
|
+
| `chunksPerDoc` | omitted | **Deprecated by Querit.** Sent only when set; switch to `highlights`. |
|
|
107
111
|
| `fetchFormat` | `markdown` | Format requested from `/v1/contents` for fetch calls: `markdown`, `text`, or `html`. HTML bodies are labeled `kind: 'html'` so `dsh-tool-web` converts them to markdown. |
|
|
108
112
|
| `fetchCrawlTimeout` | `10` | Per-page crawl timeout in seconds (1–60). |
|
|
109
113
|
| `fetchMaxChars` | `8000` | Cap applied to one fetched page's decoded body, in chars; a cut body sets `truncated`. |
|
|
110
|
-
| `fetch` | `false` | Opt in to registering the model-facing `web_fetch` tool (reused from `@deepseek-ai/dsh-tool-web`).
|
|
111
|
-
| `fetchTimeoutMs` | `30000` | Cooperative tool-call timeout budget (ms) attached to `web_fetch`. |
|
|
112
|
-
| `fetchMaxOutputChars` | `200000` | Cap on one `web_fetch` rendered output, in chars. |
|
|
114
|
+
| `fetch` | `false` | Opt in to registering the model-facing `web_fetch` tool (reused from `@deepseek-ai/dsh-tool-web`). The base and agent-preset `tool-web` rows register `web_fetch` themselves and route through the seam, so leave off unless no other row provides the tool. Read when the entry starts. |
|
|
115
|
+
| `fetchTimeoutMs` | `30000` | Cooperative tool-call timeout budget (ms) attached to `web_fetch`. Read when the entry starts. |
|
|
116
|
+
| `fetchMaxOutputChars` | `200000` | Cap on one `web_fetch` rendered output, in chars. Read when the entry starts. |
|
|
113
117
|
|
|
114
118
|
```yaml
|
|
115
119
|
- id: web-search-querit
|
|
@@ -122,30 +126,38 @@ If a preset ever registers `web_fetch` itself (its `tool-web` row with `fetch: t
|
|
|
122
126
|
excludeDomains: [pinterest.com, facebook.com, instagram.com, tiktok.com]
|
|
123
127
|
```
|
|
124
128
|
|
|
125
|
-
|
|
129
|
+
Unknown values in `countries`, `languages`, `rank`, `vertical`, and `resourceTags`, malformed hostnames, and an invalid `timeRange` are ignored rather than failing the row.
|
|
126
130
|
|
|
127
|
-
There are
|
|
131
|
+
There are two configuration surfaces:
|
|
128
132
|
|
|
129
|
-
1. **The
|
|
130
|
-
2. **The composition patch** (`cordis.patch.yml` above)
|
|
131
|
-
3. **The settings document** — `$DSH_HOME/settings.yaml`, the same directory as `.credentials.yaml`. A `web-search-querit:` section there overrides the row config and **hot-reloads** (the settings provider watches the file; verified live — no restart needed). The settings card writes this same document through the settings service:
|
|
133
|
+
1. **The row's configuration page**: **Settings → Plugins → Installed → `dsh-querit` → the `web-search-querit` row → Configure**. Edits the entry's config form and can write the API key into the credentials domain. Saves apply to the next operation — no restart needed.
|
|
134
|
+
2. **The composition patch** (`cordis.patch.yml` above). Needs a restart.
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
```
|
|
136
|
+
Values saved on the page are the user layer over the row config, which is the layer over the schema default. Every field is a live handle: the providers read it as it stands when an operation starts, so the seam's provider selection never flickers when a default changes. `apiKey` carries `role('secret')`, so it never rides a settings describe response.
|
|
137
|
+
|
|
138
|
+
### Where the API key comes from
|
|
139
|
+
|
|
140
|
+
Per operation, in priority order:
|
|
139
141
|
|
|
140
|
-
|
|
142
|
+
1. `apiKey` on the row, when set.
|
|
143
|
+
2. The credentials store entry named by `apiKeyEnv` (this is what the configuration page writes). An installed credentials service is authoritative, including absence, as it is for the host's own providers.
|
|
144
|
+
3. Only where no credentials service runs (a headless profile, for instance): the launching environment's `apiKeyEnv`.
|
|
145
|
+
|
|
146
|
+
Before v2.0.0 the launching environment came first. A deployment that exported `QUERIT_API_KEY` *and* stored a different key in the credentials store now uses the stored one, matching the host's own rule.
|
|
141
147
|
|
|
142
148
|
## Mapping
|
|
143
149
|
|
|
144
|
-
Search results become citeable sources: `url` ← `url`, `title` ← `title`, `snippet` ← `snippet`
|
|
150
|
+
Search results become citeable sources: `url` ← `url`, `title` ← `title`, `snippet` ← `snippet` (one line, for display), `summary` ← highlights, then body text when either was requested (for the model to read; `dsh-tool-web` caps it), `publishedAt` ← `page_age`. No provider-generated answer text is trusted as `content`, so `content` is omitted. Results are deduplicated by URL and normalized to HTTP(S). The seam enforces the request's `maxResults` bound, so the provider sets `truncated: false` and asks Querit for the same count as a cost optimization.
|
|
145
151
|
|
|
146
152
|
Fetch maps a successful `/v1/contents` crawl to `statusCode 200` with a `text` body (`markdown`/`text` formats) or an `html` body (`html` format). A failed crawl is a `WEB_PROVIDER_ERROR`: Querit proxies the retrieval, so no real HTTP status exists to report.
|
|
147
153
|
|
|
148
|
-
Failures use the seam's `WebError` taxonomy: `WEB_ABORTED` for cancellation, `WEB_PROVIDER_ERROR` for API/HTTP/parse failures, and `WEB_PROVIDER_CREDENTIAL_MISSING` for a missing key. API keys are redacted from every error surface, responses are size-limited (2 MiB search, 10 MiB contents), and retrieved text is stripped of terminal escape/control sequences and bidi controls before the model sees it.
|
|
154
|
+
Failures use the seam's `WebError` taxonomy: `WEB_ABORTED` for cancellation, `WEB_PROVIDER_ERROR` for API/HTTP/parse failures, and `WEB_PROVIDER_CREDENTIAL_MISSING` for a missing key. API keys are redacted from every error surface, responses are size-limited (2 MiB search, 10 MiB contents), and retrieved text is stripped of terminal escape/control sequences and bidi controls before the model sees it. HTTP 429, 500, and 503 are retried with bounded exponential backoff and honor `Retry-After`; 400, 401, 403, and 404 are never retried. Failure messages end with the request's `search_id`, which Querit support asks for.
|
|
155
|
+
|
|
156
|
+
Every completed operation writes one log line with the same `search_id`, the server time, and the request's cost as Querit reports it (`cost=n/a` when Querit sent none):
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
web-search-querit: search search_id=9007199254740993123 took=0.42 cost=USD 0.000123
|
|
160
|
+
```
|
|
149
161
|
|
|
150
162
|
## Safety
|
|
151
163
|
|
|
@@ -153,18 +165,22 @@ Treat every search result and retrieved page as untrusted external data. The mod
|
|
|
153
165
|
|
|
154
166
|
## Development
|
|
155
167
|
|
|
168
|
+
Requires Node.js 24.9 or newer, the version the host requires.
|
|
169
|
+
|
|
156
170
|
```bash
|
|
157
171
|
npm install
|
|
158
172
|
npm run check # typecheck src + tests
|
|
159
|
-
npm test # vitest: host providers + settings form model +
|
|
173
|
+
npm test # vitest: host providers + settings form model + page render smoke tests
|
|
160
174
|
npm run build # tsc -> lib/ plus the browser bundle -> lib/card.js
|
|
161
175
|
```
|
|
162
176
|
|
|
163
|
-
The
|
|
177
|
+
The configuration page's form logic lives in `src/form-model.js` (unit-tested); `scripts/build-client.mjs` inlines it into the loader-wrapped browser bundle `src/card.js` and writes `lib/card.js`. The bundle deliberately does not overwrite `lib/client.js`, which tsc produces from `src/client.ts` (the host-side HTTP client) — that collision breaks the host imports. `tests/card-render.test.mjs` renders the built page with `react-dom/server` and asserts its controls; run `npm run build` before `npm test`. To exercise the page in the browser, restart the profile and open **Settings → Plugins → `dsh-querit`**.
|
|
178
|
+
|
|
179
|
+
`lib/` is committed: the compiled package is what the profile loader executes, and committing it lets users install from GitHub Release tarballs without a build toolchain. Rebuild with `npm run build` and commit the result on release.
|
|
164
180
|
|
|
165
181
|
## Packaging notes
|
|
166
182
|
|
|
167
|
-
The `peerDependencies` are declared **optional**: the harness provides them at runtime
|
|
183
|
+
The `peerDependencies` are declared **optional**: the harness provides them at runtime, not through the profile's own pnpm graph — so `dsh plugin add` finishes without installing peers. `engines.dsh` (`>=0.2.2-rc.5 <0.3.0`) is what the host reads to decide compatibility; the `@deepseek-ai/dsh-*` peer ranges repeat it for tools that still look at peers. pnpm compares prerelease versions against a plain range without its `includePrerelease` flag, so installing on a prerelease host can print an unmet-peer warning that the host itself does not act on.
|
|
168
184
|
|
|
169
185
|
## License
|
|
170
186
|
|
package/cordis.patch.yml
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
#
|
|
7
7
|
# A patch replaces the targeted row's whole `config`, so the `web` row below
|
|
8
8
|
# restates every key it owns (search + fetch selection).
|
|
9
|
+
#
|
|
10
|
+
# The row id `web-search-querit` doubles as the entry's settings namespace and
|
|
11
|
+
# as the key of its configuration page on the Plugins screen
|
|
12
|
+
# (`dsh-querit#web-search-querit`). Renaming the row in a later layer detaches
|
|
13
|
+
# that page: the providers keep working, but the row can only be configured
|
|
14
|
+
# through the profile's own patch.
|
|
9
15
|
|
|
10
16
|
- insert:
|
|
11
17
|
- id: web-search-querit
|