@maricgeer/dsh-websearch 0.1.2 → 0.2.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/lib/index.d.ts CHANGED
@@ -103,10 +103,13 @@ interface TavilySettings {
103
103
  */
104
104
  filterByLanguage?: boolean;
105
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.
106
+ * Include-list semantics (S20 P2; S37 T1 upstream enum migration): the wire accepts only
107
+ * `restrict` (strict filter) or `prefer` (unstrict ranking weight). The legacy values
108
+ * `filter`/`boost` are still accepted by the input schema and normalized in resolve —
109
+ * stored settings from older versions keep loading without a migration step. Only sent
110
+ * when the unified include-domain list is non-empty. Hot.
108
111
  */
109
- includeDomainsMode?: 'filter' | 'boost';
112
+ includeDomainsMode?: 'filter' | 'boost' | 'restrict' | 'prefer';
110
113
  /**
111
114
  * Publication-date window lower bound, `YYYY-MM-DD` (S22 P3; orthogonal to `timeRange`'s relative
112
115
  * windows). `''` clears. Hot.
@@ -157,7 +160,7 @@ interface FirecrawlSettings {
157
160
  * Result category (S20 P2, official enum; `''` = clear): `developer`/`research` target docs and
158
161
  * papers for coding-agent queries. Hot.
159
162
  */
160
- categories?: 'developer' | 'research' | 'pdf' | '';
163
+ categories?: 'developer' | 'research' | 'pdf' | 'alexandria' | '';
161
164
  /** Pool selection policy; defaults to `round-robin` (ADR-0011). Hot: settings changes apply to the next search. */
162
165
  keySelection?: KeySelection;
163
166
  }
@@ -246,6 +249,64 @@ interface UnifiedSearchFanout {
246
249
  readonly includeDomains?: readonly string[];
247
250
  readonly excludeDomains?: readonly string[];
248
251
  }
252
+ /**
253
+ * DNS resilience layer mode (ADR-0022 D4): `'auto'` = lazy canary detection
254
+ * enables the layer only on reserved-range evidence (default), `'on'` =
255
+ * unconditional, `'off'` = full bypass (zero overhead, system resolution).
256
+ */
257
+ type DnsMode = 'auto' | 'on' | 'off';
258
+ /**
259
+ * Which hostnames the DNS layer resolves over DoH (ADR-0022 D5): `'members'`
260
+ * (default) = the live member baseURL host set only; `'all'` = every hostname
261
+ * routed through the patched lookup.
262
+ */
263
+ type DnsScope = 'members' | 'all';
264
+ /**
265
+ * DoH node region preset (ADR-0022 D6): `'auto'` = bootstrap probes the
266
+ * built-in pool and keeps the two fastest reachable nodes (default), `'cn'` /
267
+ * `'global'` = pinned region subsets, `'custom'` = the user-supplied
268
+ * {@link DnsSettings.nodes} list (validated non-empty).
269
+ */
270
+ type DnsPreset = 'auto' | 'cn' | 'global' | 'custom';
271
+ /** One JSON-DoH endpoint (ADR-0022 D6): `host` is the connect target (usually an IP literal), `sni` the TLS server name, so SNI and Host stay separable. */
272
+ interface DohNode {
273
+ /** Connect target — an IP literal avoids bootstrapping the resolver itself. */
274
+ host: string;
275
+ /** TLS server name for certificate validation (e.g. `dns.alidns.com`). */
276
+ sni: string;
277
+ /** Query path; absent = the node family default set by the dns transport. */
278
+ path?: string;
279
+ /** Connect port; absent = 443 (Quad9's JSON face is the documented `:5053`). */
280
+ port?: number;
281
+ }
282
+ /** DNS resilience settings (ADR-0022); every field optional and defaulted by `resolveConfig`. */
283
+ interface DnsSettings {
284
+ /** Resolver mode; defaults to `'auto'` (no evidence, no interception). Hot: on↔off applies immediately via the intercept disposer. */
285
+ mode?: DnsMode;
286
+ /** Hostname scope; defaults to `'members'`. Hot: the next resolution reads the live set. */
287
+ scope?: DnsScope;
288
+ /** Node region preset; defaults to `'auto'` (bootstrap-selected). */
289
+ preset?: DnsPreset;
290
+ /** Custom node list; required non-empty iff `preset: 'custom'` (dual-path validated). */
291
+ nodes?: DohNode[];
292
+ /** Per-node DoH query budget in ms; defaults to 350 (distinct from the TCP precheck budget). */
293
+ nodeTimeoutMs?: number;
294
+ /** Egress reachability precheck; defaults enabled, 350ms budget, 30s cache, bare TCP method. */
295
+ probe?: {
296
+ enabled?: boolean;
297
+ timeoutMs?: number;
298
+ cacheTtlS?: number;
299
+ method?: 'tcp' | 'tls-hello';
300
+ };
301
+ /** Resolution cache; positive TTLs clamp to [posMinS, posMaxS], negative answers cache negS. */
302
+ cache?: {
303
+ posMinS?: number;
304
+ posMaxS?: number;
305
+ negS?: number;
306
+ };
307
+ /** Reserved IPv4 ranges whose answers are dropped as poisoned (the side-router blackhole signature). */
308
+ poisonRanges?: string[];
309
+ }
249
310
  /** User-facing plugin configuration; every field is optional and defaulted by {@link resolveConfig}. */
250
311
  interface Config {
251
312
  /** 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. */
@@ -317,6 +378,8 @@ interface Config {
317
378
  exa?: ExaSettings;
318
379
  /** Anysearch member settings (ADR-0009). */
319
380
  anysearch?: AnysearchSettings;
381
+ /** DNS resilience settings (ADR-0022). */
382
+ dns?: DnsSettings;
320
383
  }
321
384
  /**
322
385
  * A volatile handle as the host hands it to `apply` on 0.1.7+ (upstream
@@ -367,7 +430,7 @@ interface TavilyMemberConfig extends Required<Pick<TavilySettings, 'enabled' | '
367
430
  /** Hard language filter; absent = not sent (S20 P2). */
368
431
  filterByLanguage?: boolean;
369
432
  /** Include-list semantics; absent = not sent (S20 P2). */
370
- includeDomainsMode?: 'filter' | 'boost';
433
+ includeDomainsMode?: 'restrict' | 'prefer';
371
434
  /** Publication-date window lower bound (`YYYY-MM-DD`); absent = not sent (S22 P3). */
372
435
  startDate?: string;
373
436
  /** Publication-date window upper bound; absent = not sent (S22 P3). */
@@ -389,7 +452,7 @@ interface FirecrawlMemberConfig extends Required<Pick<FirecrawlSettings, 'enable
389
452
  /** Result sources; `''` normalizes away at resolve (S20 P2). */
390
453
  sources?: 'news' | 'web+news' | '';
391
454
  /** Result category; `''` normalizes away at resolve (S20 P2). */
392
- categories?: 'developer' | 'research' | 'pdf' | '';
455
+ categories?: 'developer' | 'research' | 'pdf' | 'alexandria' | '';
393
456
  /** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
394
457
  keySelection?: KeySelection;
395
458
  }
@@ -426,12 +489,42 @@ interface AnysearchMemberConfig extends Required<Pick<AnysearchSettings, 'enable
426
489
  /** Pool selection policy; resolveConfig defaults to 'round-robin' (ADR-0011). */
427
490
  keySelection?: KeySelection;
428
491
  }
492
+ /** Fully defaulted DNS resilience settings consumed by the dns layer (ADR-0022). */
493
+ interface ResolvedDnsConfig {
494
+ /** Resolver mode; default `'auto'` (canary evidence required before any interception). */
495
+ readonly mode: DnsMode;
496
+ /** Hostname scope; default `'members'` (live member host set only). */
497
+ readonly scope: DnsScope;
498
+ /** Node region preset; default `'auto'`. */
499
+ readonly preset: DnsPreset;
500
+ /** Per-node DoH query budget; default 350ms. */
501
+ readonly nodeTimeoutMs: number;
502
+ /** Custom nodes, copied; empty unless `preset: 'custom'` supplies a validated list. */
503
+ readonly nodes: readonly DohNode[];
504
+ /** Egress precheck; defaults `{ enabled: true, timeoutMs: 350, cacheTtlS: 30, method: 'tcp' }`. */
505
+ readonly probe: {
506
+ readonly enabled: boolean;
507
+ readonly timeoutMs: number;
508
+ readonly cacheTtlS: number;
509
+ readonly method: 'tcp' | 'tls-hello';
510
+ };
511
+ /** Resolution cache; defaults `{ posMinS: 30, posMaxS: 300, negS: 10 }`. */
512
+ readonly cache: {
513
+ readonly posMinS: number;
514
+ readonly posMaxS: number;
515
+ readonly negS: number;
516
+ };
517
+ /** Reserved ranges dropped as poisoned; defaults {@link DEFAULT_DNS_POISON_RANGES}. */
518
+ readonly poisonRanges: readonly string[];
519
+ }
429
520
  /** Fully defaulted plugin configuration; the chain providers consume this, not the raw `Config`. */
430
521
  interface ResolvedWebSearchConfig {
431
522
  /** Canonical designated fallback (legacy `fallbackProvider` normalized away; ADR-0014). */
432
523
  readonly fallbackMember: FallbackMember;
433
524
  /** Universal web_fetch takeover toggle, resolved default true (S15a). */
434
525
  readonly fetchTakeover: boolean;
526
+ /** DNS resilience settings (ADR-0022). */
527
+ readonly dns: ResolvedDnsConfig;
435
528
  /** Unified search region (ISO 3166-1 alpha-2, uppercase); absent = not sent (S17 P1, ADR-0015). */
436
529
  readonly searchCountry?: string;
437
530
  /** Unified search language (ISO 639-1, lowercase); absent = not sent (S17 P1, ADR-0015). */
@@ -543,7 +636,7 @@ interface TavilyMemberOptions {
543
636
  /** Hard language filter; only sent when `language` is set (S20 P2, official 400 constraint). */
544
637
  readonly filterByLanguage?: boolean;
545
638
  /** Include-list semantics; only sent with a non-empty include list (S20 P2). */
546
- readonly includeDomainsMode?: 'filter' | 'boost';
639
+ readonly includeDomainsMode?: 'restrict' | 'prefer';
547
640
  /** Publication-date window lower bound (`YYYY-MM-DD`); absent = not sent (S22 P3). */
548
641
  readonly startDate?: string;
549
642
  /** Publication-date window upper bound; absent = not sent (S22 P3). */
@@ -607,7 +700,8 @@ interface FirecrawlMemberOptions {
607
700
  /** Result sources; absent = not sent (web-only API default) (S20 P2). */
608
701
  readonly sources?: 'news' | 'web+news';
609
702
  /** Result category; absent = not sent (S20 P2). */
610
- readonly categories?: 'developer' | 'research' | 'pdf';
703
+ /** `research` migrates to `alexandria` on 2026-11-16 (upstream announcement). */
704
+ readonly categories?: 'developer' | 'research' | 'pdf' | 'alexandria';
611
705
  }
612
706
  /**
613
707
  * Explicit defaulting at the owning boundary (explicit > implicit): the base
@@ -684,7 +778,6 @@ interface AnysearchMemberOptions {
684
778
  * URL default lands here, config passthrough stays untouched.
685
779
  */
686
780
  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
781
  declare class AnysearchSearchProvider implements WebSearchProvider, WebFetchProvider {
689
782
  #private;
690
783
  private readonly options;
@@ -902,4 +995,4 @@ declare const name = "dsh-websearch";
902
995
  declare const inject: string[];
903
996
  declare function apply(ctx: Context, config: ConfigRuntime): void;
904
997
  //#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 };
998
+ 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, type DnsMode, type DnsPreset, type DnsScope, type DnsSettings, type DohNode, 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 ResolvedDnsConfig, type ResolvedWebSearchConfig, SETTINGS_NAMESPACE, TAVILY_MEMBER_ID, type TavilyMemberOptions, TavilySearchProvider, type TavilySettings, type UnifiedSearchFanout, apply, attachSettingsSection, inject, name, resolveAnysearchMemberOptions, resolveDeepSeekMemberOptions, resolveExaMemberOptions, resolveFirecrawlMemberOptions, resolveTavilyMemberOptions };