@maricgeer/dsh-websearch 0.1.2
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/LICENSE +21 -0
- package/README.en.md +159 -0
- package/README.md +158 -0
- package/cordis.patch.yml +9 -0
- package/lib/client.js +8307 -0
- package/lib/index.d.ts +905 -0
- package/lib/index.js +2470 -0
- package/package.json +141 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
import { CredentialProvider, CredentialRef } from "@deepseek-ai/dsh-credentials";
|
|
2
|
+
import { WebFetchProvider, WebFetchRequest, WebFetchResult, WebSearchProvider, WebSearchRequest, WebSearchResult } from "@deepseek-ai/dsh-web";
|
|
3
|
+
import z from "@deepseek-ai/schemastery";
|
|
4
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
5
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
6
|
+
//#region src/config.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The DeepSeek member id — the paid fallback candidate (ADR-0014). It is not
|
|
9
|
+
* orderable and joins the chain only when designated AND eligible (see the
|
|
10
|
+
* participation guard in src/index.ts: at most one ready tool member).
|
|
11
|
+
*/
|
|
12
|
+
declare const DEEPSEEK_FALLBACK_MEMBER_ID = "dshws-deepseek";
|
|
13
|
+
/**
|
|
14
|
+
* The designated fallback role (ADR-0014): `'auto'` (default — the last
|
|
15
|
+
* position of the chain order IS the fallback), one of the five tool member
|
|
16
|
+
* ids (pinned tail, stripped from the normal rotation), or the paid DeepSeek
|
|
17
|
+
* floor (participation is runtime-guarded, never static).
|
|
18
|
+
*/
|
|
19
|
+
type FallbackMember = 'auto' | 'dshws-tavily' | 'dshws-exa' | 'dshws-firecrawl' | 'dshws-anysearch' | typeof DEEPSEEK_FALLBACK_MEMBER_ID;
|
|
20
|
+
/**
|
|
21
|
+
* Legacy fallbackMember value naming the REMOVED `dshws-perplexity` member
|
|
22
|
+
* (S19, ADR-0017): kept in the input schema so stored sections still load;
|
|
23
|
+
* `resolveConfig` normalizes it to `'auto'` (degrading to the chain-order tail,
|
|
24
|
+
* the same intent the dead member held as a designated tool fallback).
|
|
25
|
+
*/
|
|
26
|
+
type LegacyFallbackMember = 'dshws-perplexity';
|
|
27
|
+
/**
|
|
28
|
+
* Legacy pre-0.2 fallback field values (ADR-0014): kept in the input schema so
|
|
29
|
+
* stored sections from older versions still load; `resolveConfig` normalizes
|
|
30
|
+
* them into {@link FallbackMember} ('deepseek' names the paid floor, the rest
|
|
31
|
+
* — including the deleted free floor — mean 'auto'). The GUI never writes it.
|
|
32
|
+
*/
|
|
33
|
+
type LegacyFallbackProvider = 'deepseek' | 'none' | 'auto' | 'fetch';
|
|
34
|
+
/**
|
|
35
|
+
* Effective built-in search order (ADR-0014): the orderable five only — the
|
|
36
|
+
* chain's last ready member is the fallback; no member is appended by default.
|
|
37
|
+
*/
|
|
38
|
+
declare const BUILT_IN_MEMBER_ORDER: readonly string[];
|
|
39
|
+
/** Per-member timeout budget applied when the config omits one (ADR-0002). */
|
|
40
|
+
declare const DEFAULT_PER_MEMBER_TIMEOUT_MS = 30000;
|
|
41
|
+
/** How one member picks a key from its pool each search (ADR-0008). */
|
|
42
|
+
type KeySelection = 'order' | 'round-robin' | 'random';
|
|
43
|
+
/** DeepSeek member settings (`dshws-deepseek`). */
|
|
44
|
+
interface DeepSeekSettings {
|
|
45
|
+
/**
|
|
46
|
+
* Client-facing switch, `false` unless set. Since ADR-0014 this flag no
|
|
47
|
+
* longer governs chain membership — the fallback role is named solely by
|
|
48
|
+
* `fallbackMember` — it only feeds the settings-page snapshot.
|
|
49
|
+
*/
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
/** Credential-ref env name resolved through the credentials service. Defaults to `DEEPSEEK_API_KEY`. */
|
|
52
|
+
apiKeyEnv?: string;
|
|
53
|
+
/** API endpoint base; provider default applies when omitted (S04). Hot: a settings change applies to the next search (S17 D1). */
|
|
54
|
+
baseURL?: string;
|
|
55
|
+
/** Chat model powering the web_search server tool; provider default applies when omitted (S04). Hot: a settings change applies to the next search (S17 D1). */
|
|
56
|
+
model?: string;
|
|
57
|
+
/** Response token cap; provider default applies when omitted (S04). Hot: a settings change applies to the next search (S17 D1). */
|
|
58
|
+
maxTokens?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Server-tool search budget per request (S14c, host parity — the host
|
|
61
|
+
* `web-search-deepseek` knob of the same name/semantic/default). Hot (S17 D1).
|
|
62
|
+
*/
|
|
63
|
+
maxUses?: number;
|
|
64
|
+
/** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
|
|
65
|
+
keySelection?: KeySelection;
|
|
66
|
+
}
|
|
67
|
+
/** Tavily member settings (`dshws-tavily`). */
|
|
68
|
+
interface TavilySettings {
|
|
69
|
+
/** Defaults to `true`. Hot: settings changes apply to the next search. */
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
/** Defaults to `TAVILY_API_KEY`. Hot: a settings change applies to the next search (S17 D1; keys are configured through the credentials service, not this field). */
|
|
72
|
+
apiKeyEnv?: string;
|
|
73
|
+
/** API endpoint base; provider default applies when omitted (S04). Hot: a settings change applies to the next search (S17 D1). */
|
|
74
|
+
baseURL?: string;
|
|
75
|
+
/** Default result count; provider default applies when omitted (S04). Hot: a settings change applies to the next search (S17 D1). */
|
|
76
|
+
maxResults?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Search category (S17 P1, official 3-value enum): `general` (default — omitted = not sent),
|
|
79
|
+
* `news` (carries `published_date`), `finance`. Hot.
|
|
80
|
+
*/
|
|
81
|
+
topic?: 'general' | 'news' | 'finance' | '';
|
|
82
|
+
/** Publication-recency filter (S17 P1, official enum; omitted = not sent). Hot. */
|
|
83
|
+
timeRange?: 'day' | 'week' | 'month' | 'year' | '';
|
|
84
|
+
/**
|
|
85
|
+
* Search depth tier (S17 P1, official 4-value enum; omitted = `basic` API default). `advanced`
|
|
86
|
+
* costs 2 credits per search, the rest 1. Hot.
|
|
87
|
+
*/
|
|
88
|
+
searchDepth?: 'basic' | 'advanced' | 'fast' | 'ultra-fast' | '';
|
|
89
|
+
/**
|
|
90
|
+
* Generated-answer tier (S17 P1; the boolean form evolved into the `basic`/`advanced` enum).
|
|
91
|
+
* Defaults to `'basic'` — the answer is free per the official docs and becomes the result's
|
|
92
|
+
* `content` (D4). Hot.
|
|
93
|
+
*/
|
|
94
|
+
includeAnswer?: 'basic' | 'advanced';
|
|
95
|
+
/**
|
|
96
|
+
* Content chunks per source (S20 P2, 1-3; omitted = API default 3). Suppressed at the wire when
|
|
97
|
+
* `searchDepth` is `ultra-fast` (that depth ignores the parameter). Hot.
|
|
98
|
+
*/
|
|
99
|
+
chunksPerSource?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Hard language filter (S20 P2; default false = language stays a ranking boost). Only sent when
|
|
102
|
+
* the unified `searchLanguage` is set — the API 400s on the bare flag (official constraint). Hot.
|
|
103
|
+
*/
|
|
104
|
+
filterByLanguage?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Include-list semantics (S20 P2): `filter` (default) or `boost` (weight, still searches the whole
|
|
107
|
+
* web). Only sent when the unified include-domain list is non-empty. Hot.
|
|
108
|
+
*/
|
|
109
|
+
includeDomainsMode?: 'filter' | 'boost';
|
|
110
|
+
/**
|
|
111
|
+
* Publication-date window lower bound, `YYYY-MM-DD` (S22 P3; orthogonal to `timeRange`'s relative
|
|
112
|
+
* windows). `''` clears. Hot.
|
|
113
|
+
*/
|
|
114
|
+
startDate?: string;
|
|
115
|
+
/** Publication-date window upper bound, `YYYY-MM-DD` (S22 P3). `''` clears. Hot. */
|
|
116
|
+
endDate?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Only return results containing the exact quoted phrase(s) of the query, bypassing synonym
|
|
119
|
+
* expansion (S22 P3; a pure result filter, no credit note in the official spec). Hot.
|
|
120
|
+
*/
|
|
121
|
+
exactMatch?: boolean;
|
|
122
|
+
/** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
|
|
123
|
+
keySelection?: KeySelection;
|
|
124
|
+
}
|
|
125
|
+
/** Firecrawl member settings (`dshws-firecrawl`). */
|
|
126
|
+
interface FirecrawlSettings {
|
|
127
|
+
/** Defaults to `true`. Hot: settings changes apply to the next search. */
|
|
128
|
+
enabled?: boolean;
|
|
129
|
+
/** Defaults to `FIRECRAWL_API_KEY`. Hot: a settings change applies to the next search (S17 D1; keys are configured through the credentials service, not this field). */
|
|
130
|
+
apiKeyEnv?: string;
|
|
131
|
+
/** API endpoint base; provider default applies when omitted (S05a). Hot: a settings change applies to the next search (S17 D1). */
|
|
132
|
+
baseURL?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Time-based search filter (S17 P1 presets; S22 P3 widened to official combos: `qdr:*`
|
|
135
|
+
* presets, `sbd:1` date sort, `cdr:1,cd_min:MM/DD/YYYY,cd_max:MM/DD/YYYY` custom range,
|
|
136
|
+
* comma-combinable). Validated on both write paths; omitted = no filter. Hot.
|
|
137
|
+
*/
|
|
138
|
+
tbs?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Free-text geo location for search results (S17 P1, e.g. `San Francisco,California,United
|
|
141
|
+
* States`; city-level granularity — finer than the global country entry; omitted = not sent).
|
|
142
|
+
* The official docs recommend setting it together with a country. Hot.
|
|
143
|
+
*/
|
|
144
|
+
location?: string;
|
|
145
|
+
/**
|
|
146
|
+
* SafeSearch filter (S22 P3, official boolean): `true` filters explicit content from `web`
|
|
147
|
+
* source results; omitted = not sent (the API default, no filtering). Hot.
|
|
148
|
+
*/
|
|
149
|
+
safe?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Result sources (S20 P2; `''` = clear, omitted = not sent, API default web-only): `news` adds
|
|
152
|
+
* the native time-sorted news feed (the only bundled member with one), `web+news` requests both —
|
|
153
|
+
* `limit` applies PER SOURCE there (up to 2× results). Hot.
|
|
154
|
+
*/
|
|
155
|
+
sources?: 'news' | 'web+news' | '';
|
|
156
|
+
/**
|
|
157
|
+
* Result category (S20 P2, official enum; `''` = clear): `developer`/`research` target docs and
|
|
158
|
+
* papers for coding-agent queries. Hot.
|
|
159
|
+
*/
|
|
160
|
+
categories?: 'developer' | 'research' | 'pdf' | '';
|
|
161
|
+
/** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
|
|
162
|
+
keySelection?: KeySelection;
|
|
163
|
+
}
|
|
164
|
+
/** Exa member settings (`dshws-exa`). */
|
|
165
|
+
interface ExaSettings {
|
|
166
|
+
/** Defaults to `true`. Hot: settings changes apply to the next search. */
|
|
167
|
+
enabled?: boolean;
|
|
168
|
+
/** Defaults to `EXA_API_KEY`. Hot: a settings change applies to the next search (S17 D1; keys are configured through the credentials service, not this field). */
|
|
169
|
+
apiKeyEnv?: string;
|
|
170
|
+
/** API endpoint base; provider default applies when omitted (S05a). Hot: a settings change applies to the next search (S17 D1). */
|
|
171
|
+
baseURL?: string;
|
|
172
|
+
/** Default result count; provider default applies when omitted (S05a). Hot: a settings change applies to the next search (S17 D1). */
|
|
173
|
+
numResults?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Search type (S17 P1): the current official 6-value enum — `keyword`/`neural` were removed
|
|
176
|
+
* upstream. Defaults to `'auto'` (the provider constant). Hot.
|
|
177
|
+
*/
|
|
178
|
+
type?: 'instant' | 'fast' | 'auto' | 'deep-lite' | 'deep' | 'deep-reasoning';
|
|
179
|
+
/**
|
|
180
|
+
* Text fallback (S17 P1, D4 default `true`): also request `contents.text` so a result without
|
|
181
|
+
* highlights keeps a full-text excerpt as its snippet instead of being dropped. Hot.
|
|
182
|
+
*/
|
|
183
|
+
textFallback?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Publication-date floor (S17 P1): only results published after this date. Stored as
|
|
186
|
+
* `YYYY-MM-DD` (the GUI date input) or a full ISO date-time; the provider normalizes date-only
|
|
187
|
+
* values to the date-time form the API expects. Hot.
|
|
188
|
+
*/
|
|
189
|
+
startPublishedDate?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Vertical category (S20 P2, official 6-value enum; `''` = clear). `company`/`people` disable the
|
|
192
|
+
* date floor and exclude-domain fan-out at the wire (official 400 combos). Hot.
|
|
193
|
+
*/
|
|
194
|
+
category?: 'company' | 'publication' | 'news' | 'personal site' | 'financial report' | 'people' | '';
|
|
195
|
+
/**
|
|
196
|
+
* Content cache freshness (S20 P2, -1..720 hours; omitted = not sent). The current official name —
|
|
197
|
+
* the old `livecrawl`/`crawlingOptions` are deprecated. Hot.
|
|
198
|
+
*/
|
|
199
|
+
maxAgeHours?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Publication-date ceiling (S22 P3, symmetric to `startPublishedDate`); date-only stored,
|
|
202
|
+
* normalized to date-time at the provider. `''` clears. Hot.
|
|
203
|
+
*/
|
|
204
|
+
endPublishedDate?: string;
|
|
205
|
+
/**
|
|
206
|
+
* `contents.text` verbosity (S22 P3, official enum). `standard`/`full` enlarge the returned
|
|
207
|
+
* text (more downstream tokens — billing-relevant, ⓘ-noted in the GUI); absent = API default
|
|
208
|
+
* `compact`, identical to the previous wire. Hot.
|
|
209
|
+
*/
|
|
210
|
+
textVerbosity?: 'compact' | 'standard' | 'full' | '';
|
|
211
|
+
/**
|
|
212
|
+
* `contents.text` section filter, comma-separated from the official closed set
|
|
213
|
+
* (header/navigation/banner/sidebar/footer/metadata/body; S22 P3). Requires `maxAgeHours: 0`
|
|
214
|
+
* (fresh crawl) — enforced on both write paths. Hot.
|
|
215
|
+
*/
|
|
216
|
+
includeSections?: string;
|
|
217
|
+
/** `contents.text` section exclusion filter; same closed set and freshness requirement as {@link includeSections}. Hot. */
|
|
218
|
+
excludeSections?: string;
|
|
219
|
+
/** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
|
|
220
|
+
keySelection?: KeySelection;
|
|
221
|
+
}
|
|
222
|
+
/** Anysearch member settings (`dshws-anysearch`, ADR-0009). */
|
|
223
|
+
interface AnysearchSettings {
|
|
224
|
+
/** Defaults to `true`. Hot: settings changes apply to the next search. */
|
|
225
|
+
enabled?: boolean;
|
|
226
|
+
/** Defaults to `ANYSEARCH_API_KEY`. Hot: a settings change applies to the next search (S17 D1; keys are configured through the credentials service, not this field). */
|
|
227
|
+
apiKeyEnv?: string;
|
|
228
|
+
/** API endpoint base; provider default applies when omitted. Hot: a settings change applies to the next search (S17 D1). */
|
|
229
|
+
baseURL?: string;
|
|
230
|
+
/** Regional zone passed through to the request body; omitted = not sent. Hot (S17 D1). */
|
|
231
|
+
zone?: 'cn' | 'intl';
|
|
232
|
+
/** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
|
|
233
|
+
keySelection?: KeySelection;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The unified fan-out context (S17 P1 ADR-0015 geo entry + S20 P1 ADR-0018
|
|
237
|
+
* domain entry): single write points fanned out to each member's native wire
|
|
238
|
+
* parameters. Country is an ISO 3166-1 alpha-2 code, language an ISO 639-1
|
|
239
|
+
* code; both normalize (country uppercase, language lowercase) and blank means
|
|
240
|
+
* "not sent". The domain lists arrive pre-split (resolveConfig owns the
|
|
241
|
+
* comma-string parsing and the include-vs-exclude exclusivity rule).
|
|
242
|
+
*/
|
|
243
|
+
interface UnifiedSearchFanout {
|
|
244
|
+
readonly country?: string;
|
|
245
|
+
readonly language?: string;
|
|
246
|
+
readonly includeDomains?: readonly string[];
|
|
247
|
+
readonly excludeDomains?: readonly string[];
|
|
248
|
+
}
|
|
249
|
+
/** User-facing plugin configuration; every field is optional and defaulted by {@link resolveConfig}. */
|
|
250
|
+
interface Config {
|
|
251
|
+
/** Search priority chain by member id. Empty = {@link BUILT_IN_MEMBER_ORDER}. Unknown ids are skipped at call time. Hot: settings changes apply to the next search. */
|
|
252
|
+
searchChain?: string[];
|
|
253
|
+
/** Fetch priority chain by member id. Empty = {@link BUILT_IN_MEMBER_ORDER}. Hot: settings changes apply to the next search. */
|
|
254
|
+
fetchChain?: string[];
|
|
255
|
+
/** Timeout budget per chain member per call, in milliseconds. Defaults to {@link DEFAULT_PER_MEMBER_TIMEOUT_MS}. Hot: settings changes apply to the next search. */
|
|
256
|
+
perMemberTimeoutMs?: number;
|
|
257
|
+
/**
|
|
258
|
+
* The designated fallback (ADR-0014): `'auto'` (default — chain-order last
|
|
259
|
+
* position), a tool member id (pinned tail), or `'dshws-deepseek'` (paid
|
|
260
|
+
* floor; joins only when at most one tool member is ready and its key is
|
|
261
|
+
* configured). Hot: settings changes apply to the next search.
|
|
262
|
+
*/
|
|
263
|
+
fallbackMember?: FallbackMember | LegacyFallbackMember;
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated Legacy pre-0.2 alias (ADR-0014), read-only: normalized into
|
|
266
|
+
* {@link fallbackMember} at resolve time; the GUI never writes it. Kept in
|
|
267
|
+
* the schema so stored sections from older versions still load.
|
|
268
|
+
*/
|
|
269
|
+
fallbackProvider?: LegacyFallbackProvider;
|
|
270
|
+
/**
|
|
271
|
+
* Append the chain trace (draws with key tails, rotation, degradation,
|
|
272
|
+
* served-by) to `<dshHome>/logs/dsh-websearch.log` (S14z). Default true;
|
|
273
|
+
* best-effort — a failing append disables the sink, never the chain.
|
|
274
|
+
*/
|
|
275
|
+
chainLogFile?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Universal web_fetch takeover (S15c): true = the web_fetch tool is
|
|
278
|
+
* hidden from every agent's tool list and prompt via the official
|
|
279
|
+
* `tools.restrict()` API (zero errors, zero guidance); false = web_fetch
|
|
280
|
+
* is visible and functional. Default true.
|
|
281
|
+
* Hot: applies to the next agent created after the settings commit.
|
|
282
|
+
*/
|
|
283
|
+
fetchTakeover?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Unified search region (S17 P1, ADR-0015): an ISO 3166-1 alpha-2 code (e.g. `CN`) fanned
|
|
286
|
+
* out to the members whose native APIs accept a region — Exa `userLocation` and Firecrawl
|
|
287
|
+
* `country` (Tavily is excluded in v1:
|
|
288
|
+
* its `country` expects country-name strings; ISO-code compatibility is unverified). Blank =
|
|
289
|
+
* not sent. Hot: the next search.
|
|
290
|
+
*/
|
|
291
|
+
searchCountry?: string;
|
|
292
|
+
/**
|
|
293
|
+
* Unified search language (S17 P1, ADR-0015): an ISO 639-1 code (e.g. `zh`) fanned out to
|
|
294
|
+
* the members with a search-level language parameter — Tavily `language`. Blank = not sent. Hot: the next search.
|
|
295
|
+
*/
|
|
296
|
+
searchLanguage?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Unified include-domain allowlist (S20 P1, ADR-0018): comma-separated domains fanned out to
|
|
299
|
+
* Tavily/Exa/Firecrawl (with each member's format guards). Mutually exclusive with
|
|
300
|
+
* {@link searchExcludeDomains} — a state setting both fails loud (settings path: validate hook
|
|
301
|
+
* rejects before persist; cordis.yml path: load error). Blank = not sent. Hot: the next search.
|
|
302
|
+
*/
|
|
303
|
+
searchIncludeDomains?: string;
|
|
304
|
+
/**
|
|
305
|
+
* Unified exclude-domain blocklist (S20 P1, ADR-0018): comma-separated domains fanned out to
|
|
306
|
+
* Tavily/Exa/Firecrawl. Mutually exclusive with {@link searchIncludeDomains}. Blank = not sent.
|
|
307
|
+
* Hot: the next search.
|
|
308
|
+
*/
|
|
309
|
+
searchExcludeDomains?: string;
|
|
310
|
+
/** DeepSeek member settings. */
|
|
311
|
+
deepseek?: DeepSeekSettings;
|
|
312
|
+
/** Tavily member settings. */
|
|
313
|
+
tavily?: TavilySettings;
|
|
314
|
+
/** Firecrawl member settings. */
|
|
315
|
+
firecrawl?: FirecrawlSettings;
|
|
316
|
+
/** Exa member settings. */
|
|
317
|
+
exa?: ExaSettings;
|
|
318
|
+
/** Anysearch member settings (ADR-0009). */
|
|
319
|
+
anysearch?: AnysearchSettings;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* A volatile handle as the host hands it to `apply` on 0.1.7+ (upstream
|
|
323
|
+
* `Volatile<T>`): reading through `get()` evaluates the field against the
|
|
324
|
+
* live configuration. Structural — no compile-time cordis-version tie.
|
|
325
|
+
*/
|
|
326
|
+
interface VolatileHandle<T> {
|
|
327
|
+
get(): T;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The configuration shape `apply` receives at runtime. On 0.1.7+ hosts every
|
|
331
|
+
* volatile-marked field (the whole schema, S32/ADR-0021) arrives as a handle;
|
|
332
|
+
* on 0.1.5/0.1.6 hosts the same fields arrive as plain values, so every
|
|
333
|
+
* consumer normalizes through {@link materializeConfig} before resolving.
|
|
334
|
+
*/
|
|
335
|
+
type ConfigRuntime = { [K in keyof Config]?: Config[K] | VolatileHandle<Config[K]>; };
|
|
336
|
+
/**
|
|
337
|
+
* Validation schema the cordis loader applies to the `dsh-websearch` config
|
|
338
|
+
* section — every editable field volatile-marked (S32, ADR-0021): 0.1.7+
|
|
339
|
+
* hosts register the namespace as a live settings form from these marks and
|
|
340
|
+
* resolve the fields into `Volatile` handles.
|
|
341
|
+
*/
|
|
342
|
+
declare const Config: z;
|
|
343
|
+
/** Fully defaulted settings for one member. */
|
|
344
|
+
interface DeepSeekMemberConfig extends Required<Pick<DeepSeekSettings, 'enabled' | 'apiKeyEnv'>> {
|
|
345
|
+
baseURL?: string;
|
|
346
|
+
model?: string;
|
|
347
|
+
maxTokens?: number;
|
|
348
|
+
/** Server-tool search budget per request (S14c, host parity). */
|
|
349
|
+
maxUses?: number;
|
|
350
|
+
/** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
|
|
351
|
+
keySelection?: KeySelection;
|
|
352
|
+
}
|
|
353
|
+
/** Fully defaulted settings for one member. */
|
|
354
|
+
interface TavilyMemberConfig extends Required<Pick<TavilySettings, 'enabled' | 'apiKeyEnv'>> {
|
|
355
|
+
baseURL?: string;
|
|
356
|
+
maxResults?: number;
|
|
357
|
+
/** Search category; absent = not sent (S17 P1). */
|
|
358
|
+
topic?: 'general' | 'news' | 'finance';
|
|
359
|
+
/** Publication-recency filter; absent = not sent (S17 P1). */
|
|
360
|
+
timeRange?: 'day' | 'week' | 'month' | 'year';
|
|
361
|
+
/** Search depth tier; absent = API default `basic` (S17 P1). */
|
|
362
|
+
searchDepth?: 'basic' | 'advanced' | 'fast' | 'ultra-fast';
|
|
363
|
+
/** Generated-answer tier; resolveConfig defaults `'basic'` (S17 P1, D4). */
|
|
364
|
+
includeAnswer?: 'basic' | 'advanced';
|
|
365
|
+
/** Content chunks per source; absent = not sent (S20 P2). */
|
|
366
|
+
chunksPerSource?: number;
|
|
367
|
+
/** Hard language filter; absent = not sent (S20 P2). */
|
|
368
|
+
filterByLanguage?: boolean;
|
|
369
|
+
/** Include-list semantics; absent = not sent (S20 P2). */
|
|
370
|
+
includeDomainsMode?: 'filter' | 'boost';
|
|
371
|
+
/** Publication-date window lower bound (`YYYY-MM-DD`); absent = not sent (S22 P3). */
|
|
372
|
+
startDate?: string;
|
|
373
|
+
/** Publication-date window upper bound; absent = not sent (S22 P3). */
|
|
374
|
+
endDate?: string;
|
|
375
|
+
/** Exact quoted-phrase filter; absent = not sent (S22 P3). */
|
|
376
|
+
exactMatch?: boolean;
|
|
377
|
+
/** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
|
|
378
|
+
keySelection?: KeySelection;
|
|
379
|
+
}
|
|
380
|
+
/** Fully defaulted settings for one member. */
|
|
381
|
+
interface FirecrawlMemberConfig extends Required<Pick<FirecrawlSettings, 'enabled' | 'apiKeyEnv'>> {
|
|
382
|
+
baseURL?: string;
|
|
383
|
+
/** Time-based search filter (presets + official combos, validated upstream); absent = not sent (S17/S22 P3). */
|
|
384
|
+
tbs?: string;
|
|
385
|
+
/** SafeSearch filter; absent = not sent (S22 P3). */
|
|
386
|
+
safe?: boolean;
|
|
387
|
+
/** Free-text geo location; absent = not sent (S17 P1). */
|
|
388
|
+
location?: string;
|
|
389
|
+
/** Result sources; `''` normalizes away at resolve (S20 P2). */
|
|
390
|
+
sources?: 'news' | 'web+news' | '';
|
|
391
|
+
/** Result category; `''` normalizes away at resolve (S20 P2). */
|
|
392
|
+
categories?: 'developer' | 'research' | 'pdf' | '';
|
|
393
|
+
/** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
|
|
394
|
+
keySelection?: KeySelection;
|
|
395
|
+
}
|
|
396
|
+
/** Fully defaulted settings for one member. */
|
|
397
|
+
interface ExaMemberConfig extends Required<Pick<ExaSettings, 'enabled' | 'apiKeyEnv'>> {
|
|
398
|
+
baseURL?: string;
|
|
399
|
+
numResults?: number;
|
|
400
|
+
/** Search type; absent = provider default `'auto'` (S17 P1). */
|
|
401
|
+
type?: 'instant' | 'fast' | 'auto' | 'deep-lite' | 'deep' | 'deep-reasoning';
|
|
402
|
+
/** Text fallback; resolveConfig defaults `true` (S17 P1, D4). */
|
|
403
|
+
textFallback?: boolean;
|
|
404
|
+
/** Publication-date floor; absent = not sent (S17 P1). */
|
|
405
|
+
startPublishedDate?: string;
|
|
406
|
+
/** Vertical category; `''` normalizes away at resolve (S20 P2). */
|
|
407
|
+
category?: 'company' | 'publication' | 'news' | 'personal site' | 'financial report' | 'people' | '';
|
|
408
|
+
/** Content cache freshness; absent = not sent (S20 P2). */
|
|
409
|
+
maxAgeHours?: number;
|
|
410
|
+
/** Publication-date ceiling; absent = not sent (S22 P3). */
|
|
411
|
+
endPublishedDate?: string;
|
|
412
|
+
/** `contents.text` verbosity; absent = not sent = API default compact (S22 P3). */
|
|
413
|
+
textVerbosity?: 'compact' | 'standard' | 'full';
|
|
414
|
+
/** `contents.text` include-section filter; absent = not sent (S22 P3). */
|
|
415
|
+
includeSections?: string;
|
|
416
|
+
/** `contents.text` exclude-section filter; absent = not sent (S22 P3). */
|
|
417
|
+
excludeSections?: string;
|
|
418
|
+
/** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
|
|
419
|
+
keySelection?: KeySelection;
|
|
420
|
+
}
|
|
421
|
+
/** Fully defaulted settings for one member. */
|
|
422
|
+
interface AnysearchMemberConfig extends Required<Pick<AnysearchSettings, 'enabled' | 'apiKeyEnv'>> {
|
|
423
|
+
baseURL?: string;
|
|
424
|
+
/** Regional zone passed to the request body; absent = not sent. */
|
|
425
|
+
zone?: 'cn' | 'intl';
|
|
426
|
+
/** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
|
|
427
|
+
keySelection?: KeySelection;
|
|
428
|
+
}
|
|
429
|
+
/** Fully defaulted plugin configuration; the chain providers consume this, not the raw `Config`. */
|
|
430
|
+
interface ResolvedWebSearchConfig {
|
|
431
|
+
/** Canonical designated fallback (legacy `fallbackProvider` normalized away; ADR-0014). */
|
|
432
|
+
readonly fallbackMember: FallbackMember;
|
|
433
|
+
/** Universal web_fetch takeover toggle, resolved default true (S15a). */
|
|
434
|
+
readonly fetchTakeover: boolean;
|
|
435
|
+
/** Unified search region (ISO 3166-1 alpha-2, uppercase); absent = not sent (S17 P1, ADR-0015). */
|
|
436
|
+
readonly searchCountry?: string;
|
|
437
|
+
/** Unified search language (ISO 639-1, lowercase); absent = not sent (S17 P1, ADR-0015). */
|
|
438
|
+
readonly searchLanguage?: string;
|
|
439
|
+
/** Unified include-domain allowlist, pre-split; empty = not sent (S20 P1, ADR-0018). */
|
|
440
|
+
readonly searchIncludeDomains: readonly string[];
|
|
441
|
+
/** Unified exclude-domain blocklist, pre-split; empty = not sent (S20 P1, ADR-0018). */
|
|
442
|
+
readonly searchExcludeDomains: readonly string[];
|
|
443
|
+
/** Search priority chain; never empty after resolution. */
|
|
444
|
+
readonly searchChain: readonly string[];
|
|
445
|
+
/** Fetch priority chain; never empty after resolution. */
|
|
446
|
+
readonly fetchChain: readonly string[];
|
|
447
|
+
/** Timeout budget per member per call, in milliseconds. */
|
|
448
|
+
readonly perMemberTimeoutMs: number;
|
|
449
|
+
readonly deepseek: DeepSeekMemberConfig;
|
|
450
|
+
readonly tavily: TavilyMemberConfig;
|
|
451
|
+
readonly firecrawl: FirecrawlMemberConfig;
|
|
452
|
+
readonly exa: ExaMemberConfig;
|
|
453
|
+
readonly anysearch: AnysearchMemberConfig;
|
|
454
|
+
}
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/providers/exa.d.ts
|
|
457
|
+
/** Stable id this member registers under (chain + direct pin, `dshws-` prefixed). */
|
|
458
|
+
declare const EXA_MEMBER_ID = "dshws-exa";
|
|
459
|
+
/** Exa search type (S17 P1): the current official 6-value enum — `keyword`/`neural` were removed upstream. */
|
|
460
|
+
type ExaSearchType = 'instant' | 'fast' | 'auto' | 'deep-lite' | 'deep' | 'deep-reasoning';
|
|
461
|
+
/** Fully-resolved runtime options for the member; defaults applied by {@link resolveExaMemberOptions}. */
|
|
462
|
+
interface ExaMemberOptions {
|
|
463
|
+
/** Credential-ref env name, for missing-credential diagnostics. */
|
|
464
|
+
readonly apiKeyRef: string;
|
|
465
|
+
/** Resolve the current API key per operation (credentials service-backed). */
|
|
466
|
+
readonly resolveApiKey: () => Promise<string | undefined>;
|
|
467
|
+
/** Endpoint base; `/search` is appended. */
|
|
468
|
+
readonly baseURL: string;
|
|
469
|
+
/** Default result count when a request carries no `maxResults`. */
|
|
470
|
+
readonly numResults?: number;
|
|
471
|
+
/** Search type; resolved default `'auto'` (S17 P1). */
|
|
472
|
+
readonly type: ExaSearchType;
|
|
473
|
+
/** Text fallback; resolved default `true` — `contents.text` rides along (S17 P1, D4). */
|
|
474
|
+
readonly textFallback: boolean;
|
|
475
|
+
/** Publication-date floor, normalized to date-time; absent = not sent (S17 P1). */
|
|
476
|
+
readonly startPublishedDate?: string;
|
|
477
|
+
/** Unified search region (ISO 3166-1 alpha-2) as Exa's `userLocation`; absent = not sent (S17 P1, ADR-0015). */
|
|
478
|
+
readonly userLocation?: string;
|
|
479
|
+
/** Unified include-domain allowlist (≤1200, hostname/path-prefix/wildcard); empty = not sent (S20 P1, ADR-0018). */
|
|
480
|
+
readonly includeDomains?: readonly string[];
|
|
481
|
+
/** Unified exclude-domain blocklist; empty = not sent (S20 P1, ADR-0018). */
|
|
482
|
+
readonly excludeDomains?: readonly string[];
|
|
483
|
+
/** Vertical category; absent = not sent (S20 P2). */
|
|
484
|
+
readonly category?: 'company' | 'publication' | 'news' | 'personal site' | 'financial report' | 'people';
|
|
485
|
+
/** Content cache freshness; absent = not sent (S20 P2). */
|
|
486
|
+
readonly maxAgeHours?: number;
|
|
487
|
+
/** Publication-date ceiling, normalized to date-time; absent = not sent (S22 P3). */
|
|
488
|
+
readonly endPublishedDate?: string;
|
|
489
|
+
/** `contents.text` verbosity; absent = not sent = API default compact (S22 P3). */
|
|
490
|
+
readonly textVerbosity?: 'compact' | 'standard' | 'full';
|
|
491
|
+
/** `contents.text` include-section filter; absent = not sent (S22 P3). */
|
|
492
|
+
readonly includeSections?: readonly string[];
|
|
493
|
+
/** `contents.text` exclude-section filter; absent = not sent (S22 P3). */
|
|
494
|
+
readonly excludeSections?: readonly string[];
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Explicit defaulting at the owning boundary (explicit > implicit): the base
|
|
498
|
+
* URL default lands here, config passthrough stays untouched.
|
|
499
|
+
*/
|
|
500
|
+
declare function resolveExaMemberOptions(config: ExaMemberConfig, resolveApiKey: () => Promise<string | undefined>, fanout?: UnifiedSearchFanout): ExaMemberOptions;
|
|
501
|
+
/** The Exa-backed chain member; redirects fail as a request failure. */
|
|
502
|
+
declare class ExaSearchProvider implements WebSearchProvider {
|
|
503
|
+
#private;
|
|
504
|
+
private readonly options;
|
|
505
|
+
readonly id = "dshws-exa";
|
|
506
|
+
constructor(options: ExaMemberOptions);
|
|
507
|
+
/** Cheap local config check (no network, no key dimension — the gate owns that). */
|
|
508
|
+
available(): boolean;
|
|
509
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
510
|
+
}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/providers/tavily.d.ts
|
|
513
|
+
/** Stable id this member registers under (chain + direct pin, `dshws-` prefixed). */
|
|
514
|
+
declare const TAVILY_MEMBER_ID = "dshws-tavily";
|
|
515
|
+
/** Fully-resolved runtime options for the member; defaults applied by {@link resolveTavilyMemberOptions}. */
|
|
516
|
+
interface TavilyMemberOptions {
|
|
517
|
+
/** Credential-ref env name, for missing-credential diagnostics. */
|
|
518
|
+
readonly apiKeyRef: string;
|
|
519
|
+
/** Resolve the current API key per operation (credentials service-backed). */
|
|
520
|
+
readonly resolveApiKey: () => Promise<string | undefined>;
|
|
521
|
+
/** Endpoint base; `/search` is appended. */
|
|
522
|
+
readonly baseURL: string;
|
|
523
|
+
/** Default result count when a request carries no `maxResults`. */
|
|
524
|
+
readonly maxResults?: number;
|
|
525
|
+
/** Search category; absent = not sent (S17 P1). */
|
|
526
|
+
readonly topic?: 'general' | 'news' | 'finance';
|
|
527
|
+
/** Publication-recency filter; absent = not sent (S17 P1). */
|
|
528
|
+
readonly timeRange?: 'day' | 'week' | 'month' | 'year';
|
|
529
|
+
/** Search depth tier; absent = API default `basic` (S17 P1). */
|
|
530
|
+
readonly searchDepth?: 'basic' | 'advanced' | 'fast' | 'ultra-fast';
|
|
531
|
+
/** Generated-answer tier; resolved default `'basic'` (S17 P1, D4). */
|
|
532
|
+
readonly includeAnswer: 'basic' | 'advanced';
|
|
533
|
+
/** Unified search language (ISO 639-1); absent = not sent (S17 P1, ADR-0015). */
|
|
534
|
+
readonly language?: string;
|
|
535
|
+
/** Unified include-domain allowlist; wildcard entries skip the whole domain fan-out for this member (S20 P1, ADR-0018 — Tavily has no wildcard support). */
|
|
536
|
+
readonly includeDomains?: readonly string[];
|
|
537
|
+
/** Wildcard guard flag: set when any unified domain entry contains `*` (S20 stage-5 F-1). */
|
|
538
|
+
readonly domainsHaveWildcard?: boolean;
|
|
539
|
+
/** Unified exclude-domain blocklist; empty = not sent (S20 P1, ADR-0018). */
|
|
540
|
+
readonly excludeDomains?: readonly string[];
|
|
541
|
+
/** Content chunks per source; absent = not sent (S20 P2). */
|
|
542
|
+
readonly chunksPerSource?: number;
|
|
543
|
+
/** Hard language filter; only sent when `language` is set (S20 P2, official 400 constraint). */
|
|
544
|
+
readonly filterByLanguage?: boolean;
|
|
545
|
+
/** Include-list semantics; only sent with a non-empty include list (S20 P2). */
|
|
546
|
+
readonly includeDomainsMode?: 'filter' | 'boost';
|
|
547
|
+
/** Publication-date window lower bound (`YYYY-MM-DD`); absent = not sent (S22 P3). */
|
|
548
|
+
readonly startDate?: string;
|
|
549
|
+
/** Publication-date window upper bound; absent = not sent (S22 P3). */
|
|
550
|
+
readonly endDate?: string;
|
|
551
|
+
/** Exact quoted-phrase filter; absent = not sent (S22 P3). */
|
|
552
|
+
readonly exactMatch?: boolean;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Explicit defaulting at the owning boundary (explicit > implicit): the base
|
|
556
|
+
* URL default lands here, config passthrough stays untouched. The geo entry
|
|
557
|
+
* contributes only the language — Tavily's `country` expects country-name
|
|
558
|
+
* strings (ISO-code compatibility unverified), so v1 does not fan the region
|
|
559
|
+
* out here (ADR-0015).
|
|
560
|
+
*/
|
|
561
|
+
declare function resolveTavilyMemberOptions(config: TavilyMemberConfig, resolveApiKey: () => Promise<string | undefined>, fanout?: UnifiedSearchFanout): TavilyMemberOptions;
|
|
562
|
+
/**
|
|
563
|
+
* The Tavily-backed chain member on both capability faces: search (`/search`)
|
|
564
|
+
* and fetch (`/extract`, S21 — markdown by request, single URL per the seam's
|
|
565
|
+
* one-URL contract). Redirects fail as a request failure.
|
|
566
|
+
*/
|
|
567
|
+
declare class TavilySearchProvider implements WebSearchProvider, WebFetchProvider {
|
|
568
|
+
#private;
|
|
569
|
+
private readonly options;
|
|
570
|
+
readonly id = "dshws-tavily";
|
|
571
|
+
constructor(options: TavilyMemberOptions);
|
|
572
|
+
/** Cheap local config check (no network, no key dimension — the gate owns that). */
|
|
573
|
+
available(): boolean;
|
|
574
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
575
|
+
/**
|
|
576
|
+
* The extract face (S21): one URL in, markdown out. Billing is per success
|
|
577
|
+
* (1 credit / 5 URLs basic); the chain's per-member budget governs — no
|
|
578
|
+
* extra timeout field is sent (the API default 10s sits well inside it).
|
|
579
|
+
*/
|
|
580
|
+
fetch(request: WebFetchRequest, signal?: AbortSignal): Promise<WebFetchResult>;
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/providers/firecrawl.d.ts
|
|
584
|
+
/** Stable id this member registers under (search + fetch, `dshws-` prefixed). */
|
|
585
|
+
declare const FIRECRAWL_MEMBER_ID = "dshws-firecrawl";
|
|
586
|
+
/** Fully-resolved runtime options for the member; defaults applied by {@link resolveFirecrawlMemberOptions}. */
|
|
587
|
+
interface FirecrawlMemberOptions {
|
|
588
|
+
/** Credential-ref env name, for missing-credential diagnostics. */
|
|
589
|
+
readonly apiKeyRef: string;
|
|
590
|
+
/** Resolve the current API key per operation (credentials service-backed). */
|
|
591
|
+
readonly resolveApiKey: () => Promise<string | undefined>;
|
|
592
|
+
/** Endpoint base; `/v2/search` and `/v2/scrape` are appended. */
|
|
593
|
+
readonly baseURL: string;
|
|
594
|
+
/** Time-based search filter; absent = not sent (S17 P1). */
|
|
595
|
+
/** Time-based search filter (presets + official combos); absent = not sent (S17/S22 P3). */
|
|
596
|
+
readonly tbs?: string;
|
|
597
|
+
/** SafeSearch filter; absent = not sent (S22 P3). */
|
|
598
|
+
readonly safe?: boolean;
|
|
599
|
+
/** Free-text geo location; absent = not sent (S17 P1). */
|
|
600
|
+
readonly location?: string;
|
|
601
|
+
/** Unified search region (ISO 3166-1 alpha-2); absent = not sent (S17 P1, ADR-0015 — the fix for the API's US default). */
|
|
602
|
+
readonly country?: string;
|
|
603
|
+
/** Unified include-domain allowlist, hostname-normalized; wildcards skip the fan-out (S20 P1, ADR-0018). */
|
|
604
|
+
readonly includeDomains?: readonly string[];
|
|
605
|
+
/** Unified exclude-domain blocklist, hostname-normalized; wildcards skip the fan-out (S20 P1, ADR-0018). */
|
|
606
|
+
readonly excludeDomains?: readonly string[];
|
|
607
|
+
/** Result sources; absent = not sent (web-only API default) (S20 P2). */
|
|
608
|
+
readonly sources?: 'news' | 'web+news';
|
|
609
|
+
/** Result category; absent = not sent (S20 P2). */
|
|
610
|
+
readonly categories?: 'developer' | 'research' | 'pdf';
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Explicit defaulting at the owning boundary (explicit > implicit): the base
|
|
614
|
+
* URL default lands here, config passthrough stays untouched.
|
|
615
|
+
*/
|
|
616
|
+
declare function resolveFirecrawlMemberOptions(config: FirecrawlMemberConfig, resolveApiKey: () => Promise<string | undefined>, fanout?: UnifiedSearchFanout): FirecrawlMemberOptions;
|
|
617
|
+
/**
|
|
618
|
+
* The Firecrawl-backed chain member on both capability faces: one class, one
|
|
619
|
+
* credential, one gate — registered with the search AND fetch registries.
|
|
620
|
+
*/
|
|
621
|
+
declare class FirecrawlProvider implements WebSearchProvider, WebFetchProvider {
|
|
622
|
+
#private;
|
|
623
|
+
private readonly options;
|
|
624
|
+
readonly id = "dshws-firecrawl";
|
|
625
|
+
constructor(options: FirecrawlMemberOptions);
|
|
626
|
+
/** Cheap local config check (no network, no key dimension — the gate owns that). */
|
|
627
|
+
available(): boolean;
|
|
628
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
629
|
+
fetch(request: WebFetchRequest, signal?: AbortSignal): Promise<WebFetchResult>;
|
|
630
|
+
}
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/providers/deepseek.d.ts
|
|
633
|
+
/** Stable id this member registers under (chain + direct pin, `dshws-` prefixed). */
|
|
634
|
+
declare const DEEPSEEK_MEMBER_ID = "dshws-deepseek";
|
|
635
|
+
/** Fully-resolved runtime options for the member; defaults applied by {@link resolveDeepSeekMemberOptions}. */
|
|
636
|
+
interface DeepSeekMemberOptions {
|
|
637
|
+
/** Credential-ref env name, for missing-credential diagnostics. */
|
|
638
|
+
readonly apiKeyRef: string;
|
|
639
|
+
/** Resolve the current API key per operation (credentials service-backed). */
|
|
640
|
+
readonly resolveApiKey: () => Promise<string | undefined>;
|
|
641
|
+
/** Endpoint base; `/messages` is appended. */
|
|
642
|
+
readonly baseURL: string;
|
|
643
|
+
/** Anthropic-format model name. */
|
|
644
|
+
readonly model: string;
|
|
645
|
+
/** Upper bound on generated tokens. */
|
|
646
|
+
readonly maxTokens: number;
|
|
647
|
+
/** Server-tool search budget per request (S14c, host parity; was the `DEEPSEEK_MAX_USES` constant). */
|
|
648
|
+
readonly maxUses: number;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Explicit defaulting at the owning boundary (explicit > implicit): omitted
|
|
652
|
+
* config fields become the provider constants here, not via schema injection.
|
|
653
|
+
*/
|
|
654
|
+
declare function resolveDeepSeekMemberOptions(config: DeepSeekMemberConfig, resolveApiKey: () => Promise<string | undefined>): DeepSeekMemberOptions;
|
|
655
|
+
/** The DeepSeek-backed chain member; redirects fail as a request failure. */
|
|
656
|
+
declare class DeepSeekSearchProvider implements WebSearchProvider {
|
|
657
|
+
#private;
|
|
658
|
+
private readonly options;
|
|
659
|
+
readonly id = "dshws-deepseek";
|
|
660
|
+
constructor(options: DeepSeekMemberOptions);
|
|
661
|
+
/** Cheap local config check (no network, no key dimension — the gate owns that). */
|
|
662
|
+
available(): boolean;
|
|
663
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/providers/anysearch.d.ts
|
|
667
|
+
/** Stable id this member registers under (chain + direct pin, `dshws-` prefixed). */
|
|
668
|
+
declare const ANYSEARCH_MEMBER_ID = "dshws-anysearch";
|
|
669
|
+
/** Fully-resolved runtime options for the member; defaults applied by {@link resolveAnysearchMemberOptions}. */
|
|
670
|
+
interface AnysearchMemberOptions {
|
|
671
|
+
/** Credential-ref env name, for missing-credential diagnostics. */
|
|
672
|
+
readonly apiKeyRef: string;
|
|
673
|
+
/** Resolve the current API key per operation (credentials service-backed). */
|
|
674
|
+
readonly resolveApiKey: () => Promise<string | undefined>;
|
|
675
|
+
/** Endpoint base; `/v1/search` is appended. */
|
|
676
|
+
readonly baseURL: string;
|
|
677
|
+
/** Regional zone; sent in the request body only when configured. */
|
|
678
|
+
readonly zone?: 'cn' | 'intl';
|
|
679
|
+
/** Result-language preference in BCP-47 form, mapped from the unified entry; absent = not sent (S22 P3). */
|
|
680
|
+
readonly language?: string;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Explicit defaulting at the owning boundary (explicit > implicit): the base
|
|
684
|
+
* URL default lands here, config passthrough stays untouched.
|
|
685
|
+
*/
|
|
686
|
+
declare function resolveAnysearchMemberOptions(config: AnysearchMemberConfig, resolveApiKey: () => Promise<string | undefined>, fanout?: UnifiedSearchFanout): AnysearchMemberOptions;
|
|
687
|
+
/** The Anysearch-backed chain member on both capability faces (search + extract, S21). */
|
|
688
|
+
declare class AnysearchSearchProvider implements WebSearchProvider, WebFetchProvider {
|
|
689
|
+
#private;
|
|
690
|
+
private readonly options;
|
|
691
|
+
readonly id = "dshws-anysearch";
|
|
692
|
+
constructor(options: AnysearchMemberOptions);
|
|
693
|
+
/** Cheap local config check (no network, no key dimension — the gate owns that). */
|
|
694
|
+
available(): boolean;
|
|
695
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
696
|
+
/** Resolve one operation's key without retaining it; a missing key is a loud member error. */
|
|
697
|
+
/**
|
|
698
|
+
* The extract face (S21, probe-backed): `POST /v1/extract` with a single
|
|
699
|
+
* `{url}` body — the probe rejected the array form. Envelope `code !== 0`
|
|
700
|
+
* rides the established business-error path (chain degradation).
|
|
701
|
+
*/
|
|
702
|
+
fetch(request: WebFetchRequest, signal?: AbortSignal): Promise<WebFetchResult>;
|
|
703
|
+
}
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/errors.d.ts
|
|
706
|
+
/**
|
|
707
|
+
* Error vocabulary for dsh-websearch. Every error carries a stable string
|
|
708
|
+
* code prefixed `DSHWS_` so tool output and host logs stay machine-routable
|
|
709
|
+
* (AGENTS.md 插件开发规范). Chain-level codes are final here; member-level
|
|
710
|
+
* namespaces are claimed now and each provider adds its concrete codes when
|
|
711
|
+
* it lands (S04/S05a).
|
|
712
|
+
*
|
|
713
|
+
* @module dsh-websearch/errors
|
|
714
|
+
*/
|
|
715
|
+
/** Chain-level codes owned by the chain meta providers (`src/chain/`). */
|
|
716
|
+
declare const CHAIN_ERROR_CODES: {
|
|
717
|
+
/** Every member on the chain was tried and failed. Terminal, fail-loud. */
|
|
718
|
+
readonly exhausted: "DSHWS_CHAIN_EXHAUSTED";
|
|
719
|
+
/** No member on the chain passed the selection-level gates (unregistered, disabled, missing credentials, `available() === false`). */
|
|
720
|
+
readonly noMemberConfigured: "DSHWS_NO_MEMBER_CONFIGURED";
|
|
721
|
+
/** Log code recorded when a member exceeds its `perMemberTimeoutMs` budget and the chain degrades to the next member. */
|
|
722
|
+
readonly memberTimeout: "DSHWS_MEMBER_TIMEOUT";
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Member-level code families. Every landed provider family carries its five
|
|
726
|
+
* concrete codes (S05a: five families landed as objects; the S14e fetch-search
|
|
727
|
+
* family was removed with its member in ADR-0014).
|
|
728
|
+
*/
|
|
729
|
+
declare const MEMBER_ERROR_CODES: {
|
|
730
|
+
readonly deepseek: {
|
|
731
|
+
readonly credentialMissing: "DSHWS_DEEPSEEK_CREDENTIAL_MISSING";
|
|
732
|
+
readonly requestFailed: "DSHWS_DEEPSEEK_REQUEST_FAILED";
|
|
733
|
+
readonly httpError: "DSHWS_DEEPSEEK_HTTP_ERROR";
|
|
734
|
+
readonly badResponse: "DSHWS_DEEPSEEK_BAD_RESPONSE";
|
|
735
|
+
readonly aborted: "DSHWS_DEEPSEEK_ABORTED";
|
|
736
|
+
};
|
|
737
|
+
readonly tavily: {
|
|
738
|
+
readonly credentialMissing: "DSHWS_TAVILY_CREDENTIAL_MISSING";
|
|
739
|
+
readonly requestFailed: "DSHWS_TAVILY_REQUEST_FAILED";
|
|
740
|
+
readonly httpError: "DSHWS_TAVILY_HTTP_ERROR";
|
|
741
|
+
readonly badResponse: "DSHWS_TAVILY_BAD_RESPONSE";
|
|
742
|
+
readonly aborted: "DSHWS_TAVILY_ABORTED";
|
|
743
|
+
};
|
|
744
|
+
readonly firecrawl: {
|
|
745
|
+
readonly credentialMissing: "DSHWS_FIRECRAWL_CREDENTIAL_MISSING";
|
|
746
|
+
readonly requestFailed: "DSHWS_FIRECRAWL_REQUEST_FAILED";
|
|
747
|
+
readonly httpError: "DSHWS_FIRECRAWL_HTTP_ERROR";
|
|
748
|
+
readonly badResponse: "DSHWS_FIRECRAWL_BAD_RESPONSE";
|
|
749
|
+
readonly aborted: "DSHWS_FIRECRAWL_ABORTED";
|
|
750
|
+
};
|
|
751
|
+
readonly exa: {
|
|
752
|
+
readonly credentialMissing: "DSHWS_EXA_CREDENTIAL_MISSING";
|
|
753
|
+
readonly requestFailed: "DSHWS_EXA_REQUEST_FAILED";
|
|
754
|
+
readonly httpError: "DSHWS_EXA_HTTP_ERROR";
|
|
755
|
+
readonly badResponse: "DSHWS_EXA_BAD_RESPONSE";
|
|
756
|
+
readonly aborted: "DSHWS_EXA_ABORTED";
|
|
757
|
+
};
|
|
758
|
+
readonly anysearch: {
|
|
759
|
+
readonly credentialMissing: "DSHWS_ANYSEARCH_CREDENTIAL_MISSING";
|
|
760
|
+
readonly requestFailed: "DSHWS_ANYSEARCH_REQUEST_FAILED";
|
|
761
|
+
readonly httpError: "DSHWS_ANYSEARCH_HTTP_ERROR";
|
|
762
|
+
readonly badResponse: "DSHWS_ANYSEARCH_BAD_RESPONSE";
|
|
763
|
+
readonly aborted: "DSHWS_ANYSEARCH_ABORTED";
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
/** Domain error with a machine-routable string code and the standard `cause` slot. */
|
|
767
|
+
declare class DshwsError extends Error {
|
|
768
|
+
/** Stable `DSHWS_*` code; consumers must tolerate member-specific codes. */
|
|
769
|
+
readonly code: string;
|
|
770
|
+
/** HTTP status of the failing response, when the failure came from one; drives the request-level vs credential-level redraw split (S14y). */
|
|
771
|
+
readonly httpStatus?: number;
|
|
772
|
+
constructor(code: string, message: string, options?: {
|
|
773
|
+
cause?: unknown;
|
|
774
|
+
httpStatus?: number;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/credentials.d.ts
|
|
779
|
+
/**
|
|
780
|
+
* Port wiring the gate into the cordis event bus (`apply` passes
|
|
781
|
+
* `ctx.on('credentials/reference-updated', …)`). The returned disposer is
|
|
782
|
+
* owned by the caller's disposal scope — cordis binds `ctx.on` to the
|
|
783
|
+
* calling fiber, so plugin unload unsubscribes the gate.
|
|
784
|
+
*/
|
|
785
|
+
type CredentialEventSubscribe = (handler: (ref: CredentialRef) => void) => () => void;
|
|
786
|
+
/** Constructor ports for the gate; all host access goes through them. */
|
|
787
|
+
interface CredentialGatePorts {
|
|
788
|
+
/** The injected credentials service (`ctx.credentials`). */
|
|
789
|
+
readonly credentials: CredentialProvider;
|
|
790
|
+
/** Event subscription port; the gate fans one handler out over watched refs. */
|
|
791
|
+
readonly subscribe: CredentialEventSubscribe;
|
|
792
|
+
/** Observability sink for describe failures; omit for a silent gate (tests). */
|
|
793
|
+
readonly log?: (message: string) => void;
|
|
794
|
+
}
|
|
795
|
+
declare class CredentialGate {
|
|
796
|
+
#private;
|
|
797
|
+
constructor(ports: CredentialGatePorts);
|
|
798
|
+
/**
|
|
799
|
+
* Validate the configured references (a name outside the credential
|
|
800
|
+
* grammar throws here — misconfiguration fails loud at load), then describe
|
|
801
|
+
* each and cache the result. Resolves once the initial cache is filled.
|
|
802
|
+
*/
|
|
803
|
+
prime(refNames: readonly string[]): Promise<void>;
|
|
804
|
+
/** Whether the ref currently describes as configured; unknown refs are not ready. */
|
|
805
|
+
isReady(refName: string): boolean;
|
|
806
|
+
}
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/key-counts.d.ts
|
|
809
|
+
/** Constructor ports for the count Remote; all host access goes through them. */
|
|
810
|
+
interface KeyCountsPorts {
|
|
811
|
+
/** The refs currently owned by the five members, read live per call. */
|
|
812
|
+
readonly allowedRefs: () => ReadonlySet<string>;
|
|
813
|
+
/** Per-call value resolution (the credentials service; never cached). */
|
|
814
|
+
readonly resolve: (ref: string) => Promise<string | undefined>;
|
|
815
|
+
}
|
|
816
|
+
/** Wire namespace of this plugin's Remote (`remote.dshws-websearch` client-side). */
|
|
817
|
+
declare const KEY_COUNTS_NAMESPACE = "dshws-websearch";
|
|
818
|
+
/**
|
|
819
|
+
* Host service exposing the per-ref key counts to the settings page. The
|
|
820
|
+
* gateway discovers it through its `typertRemote` binding (source-mode
|
|
821
|
+
* discovery), so no assembly change is needed on the host side.
|
|
822
|
+
*
|
|
823
|
+
* The gateway invokes Remote methods with the context's traceable proxy as
|
|
824
|
+
* the receiver, so the method body reads only public members — no `#private`
|
|
825
|
+
* state (private-field access through that proxy throws).
|
|
826
|
+
*/
|
|
827
|
+
declare class DshWsKeyCountsRemote extends TypertRemoteService {
|
|
828
|
+
readonly ports: KeyCountsPorts;
|
|
829
|
+
/** @param ctx - owning Cordis Context (the plugin's fiber owns disposal). */
|
|
830
|
+
constructor(ctx: Context, ports: KeyCountsPorts);
|
|
831
|
+
/**
|
|
832
|
+
* Count the configured keys for several references. Counts only — the
|
|
833
|
+
* stored value stays in the host process.
|
|
834
|
+
* @param refs - reference names; a name outside the member whitelist answers 0.
|
|
835
|
+
* @returns one count per requested name, keyed by that name.
|
|
836
|
+
*/
|
|
837
|
+
describeKeyCounts(refs: string[]): Promise<Record<string, number>>;
|
|
838
|
+
}
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region src/settings.d.ts
|
|
841
|
+
/** The plugin's settings namespace (lowercase kebab, seam grammar). */
|
|
842
|
+
declare const SETTINGS_NAMESPACE = "dsh-websearch";
|
|
843
|
+
/**
|
|
844
|
+
* One hot state holder. `setSource` swaps the authoritative source and
|
|
845
|
+
* recomputes (the service's attach/detach hook); `refresh` recomputes from
|
|
846
|
+
* the current source (the committed-change hook, whose source thunk re-reads
|
|
847
|
+
* the section). Every recompute runs `resolveConfig`, so settings-sourced
|
|
848
|
+
* sections get the same explicit defaulting as cordis.yml config.
|
|
849
|
+
*/
|
|
850
|
+
declare class LiveResolvedConfig {
|
|
851
|
+
#private;
|
|
852
|
+
constructor(config: Config);
|
|
853
|
+
/** The currently authoritative resolved state (chain getters read per call). */
|
|
854
|
+
current(): ResolvedWebSearchConfig;
|
|
855
|
+
/** Swap the authoritative source and recompute — the `setSource` hook. */
|
|
856
|
+
setSource(source: () => Config): void;
|
|
857
|
+
/**
|
|
858
|
+
* Adopt read-time evaluation — the 0.1.7+ volatile hook: the source thunk
|
|
859
|
+
* unwraps live handles on every call, so `current()` stays fresh without
|
|
860
|
+
* commit events.
|
|
861
|
+
*/
|
|
862
|
+
setVolatileSource(source: () => Config): void;
|
|
863
|
+
/** Recompute from the current source — the `onChange` hook. */
|
|
864
|
+
refresh(): void;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Post-commit hook: runs after `live.refresh()` inside the settings onChange,
|
|
868
|
+
* with the refreshed config in effect. The credential gate re-primes its
|
|
869
|
+
* watched set here — prime is additive-idempotent, so a pool ref added by the
|
|
870
|
+
* commit starts being observed (key-first-then-pool ordering included; the
|
|
871
|
+
* reference-updated event cannot cover a ref that was unwatched at store
|
|
872
|
+
* time).
|
|
873
|
+
*/
|
|
874
|
+
interface SettingsCommitHooks {
|
|
875
|
+
readonly onCommitted?: () => void;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Attach the plugin's settings section on the host's settings model
|
|
879
|
+
* (ADR-0021 dual path):
|
|
880
|
+
*
|
|
881
|
+
* - 0.1.5/0.1.6 — the service exposes `installSection`; the hooks hand the
|
|
882
|
+
* live config the authoritative source and recompute on every committed
|
|
883
|
+
* change, and the custom validators (ADR-0018 domain exclusivity, Firecrawl
|
|
884
|
+
* tbs, Exa section filter) reject invalid writes before persist.
|
|
885
|
+
* - 0.1.7+ — no `installSection`; the volatile-marked Config registers the
|
|
886
|
+
* namespace as a live form by itself. The live config adopts read-time
|
|
887
|
+
* evaluation (handles unwrap the live configuration per read), and the
|
|
888
|
+
* commit-side hook rides `settings/document-updated` for this namespace —
|
|
889
|
+
* schema-level validation is the host's, so the plugin's custom validators
|
|
890
|
+
* degrade to resolve-time loud failures on this path.
|
|
891
|
+
*
|
|
892
|
+
* Without a settings service at all, a no-op: the entry config stays
|
|
893
|
+
* authoritative and the plugin must not fail to load. Disposal is bound to
|
|
894
|
+
* the calling fiber by the surrounding effects.
|
|
895
|
+
*/
|
|
896
|
+
declare function attachSettingsSection(ctx: Context, entry: ConfigRuntime, live: LiveResolvedConfig, commitHooks?: SettingsCommitHooks): void;
|
|
897
|
+
//#endregion
|
|
898
|
+
//#region src/index.d.ts
|
|
899
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
900
|
+
declare const name = "dsh-websearch";
|
|
901
|
+
/** The seams this plugin binds to: provider registration, per-operation credential resolution, hot settings. */
|
|
902
|
+
declare const inject: string[];
|
|
903
|
+
declare function apply(ctx: Context, config: ConfigRuntime): void;
|
|
904
|
+
//#endregion
|
|
905
|
+
export { ANYSEARCH_MEMBER_ID, type AnysearchMemberOptions, AnysearchSearchProvider, type AnysearchSettings, BUILT_IN_MEMBER_ORDER, CHAIN_ERROR_CODES, Config, CredentialGate, DEEPSEEK_MEMBER_ID, DEFAULT_PER_MEMBER_TIMEOUT_MS, type DeepSeekMemberOptions, DeepSeekSearchProvider, type DeepSeekSettings, DshWsKeyCountsRemote, DshwsError, EXA_MEMBER_ID, type ExaMemberOptions, ExaSearchProvider, type ExaSearchType, type ExaSettings, FIRECRAWL_MEMBER_ID, type FirecrawlMemberOptions, FirecrawlProvider, type FirecrawlSettings, KEY_COUNTS_NAMESPACE, LiveResolvedConfig, MEMBER_ERROR_CODES, type ResolvedWebSearchConfig, SETTINGS_NAMESPACE, TAVILY_MEMBER_ID, type TavilyMemberOptions, TavilySearchProvider, type TavilySettings, type UnifiedSearchFanout, apply, attachSettingsSection, inject, name, resolveAnysearchMemberOptions, resolveDeepSeekMemberOptions, resolveExaMemberOptions, resolveFirecrawlMemberOptions, resolveTavilyMemberOptions };
|