@deepseek-ai/dsh-web 0.2.2-rc.4 → 0.2.2-rc.5

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.i18n.yaml CHANGED
@@ -21,14 +21,14 @@
21
21
  en: 557a8a3f2dfebae4
22
22
  zh: 3c85382484e4b717
23
23
  /deepseek-ai-dsh-web/use-this-package/minimal-configuration:
24
- en: cb5267c425eef938
25
- zh: 26c3c04ee28c8c01
24
+ en: df619fcd78b5ddf3
25
+ zh: 37b2a636bc0e9811
26
26
  /deepseek-ai-dsh-web/use-this-package/searching-and-fetching:
27
- en: 713944abf68263cd
28
- zh: c428cb53b8708e99
27
+ en: b9bbc748372e1324
28
+ zh: 4255ecb86224a9a9
29
29
  /deepseek-ai-dsh-web/use-this-package/provider-selection:
30
- en: 5973c94b327aa8ae
31
- zh: cbc15a2925f70347
30
+ en: 5db9d1699d347aa5
31
+ zh: c283c6ae8655e20a
32
32
  /deepseek-ai-dsh-web/use-this-package/listing-providers:
33
33
  en: 229aed591f2194e0
34
34
  zh: d62b4b41d26be94c
@@ -36,8 +36,8 @@
36
36
  en: cf0c7f95d944be5a
37
37
  zh: 1a2b3796acec7c29
38
38
  /deepseek-ai-dsh-web/use-this-package/search-and-fetch-readiness:
39
- en: 30fec45dfb417eed
40
- zh: 253f887aeb3deeea
39
+ en: f843292cd4c207cf
40
+ zh: 18371ec971492f46
41
41
  /deepseek-ai-dsh-web/use-this-package/failures-and-recovery:
42
42
  en: d8d09ed3839f6474
43
43
  zh: 7164d902f333592a
@@ -45,8 +45,8 @@
45
45
  en: a3364d8193deb7f0
46
46
  zh: d1c4afbf25a7ae4d
47
47
  /deepseek-ai-dsh-web/understand-the-implementation/design-philosophy:
48
- en: c4d5437cfb1e2157
49
- zh: 411b1b398de73426
48
+ en: 37cecf7386caa27c
49
+ zh: 11eb1701574cfa95
50
50
  /deepseek-ai-dsh-web/understand-the-implementation/source-map:
51
51
  en: 2d8d315dba3b5f1e
52
52
  zh: dca7443453d96ba7
@@ -54,8 +54,8 @@
54
54
  en: 300340ff8465a03e
55
55
  zh: 34ab66eb6969dc94
56
56
  /deepseek-ai-dsh-web/understand-the-implementation/selection-flow:
57
- en: d5cd4851d81892e6
58
- zh: 18266b0bc8b1d1ae
57
+ en: 0472b53e93e9c7dc
58
+ zh: 63bd2d31724681e1
59
59
  /deepseek-ai-dsh-web/further-exploration:
60
60
  en: f969a627e746906d
61
61
  zh: e6ffbe79fc539cec
@@ -66,8 +66,8 @@
66
66
  en: 40294c1c31b74824
67
67
  zh: d75d48f485447a74
68
68
  /deepseek-ai-dsh-web/known-limitations-and-deferred-work:
69
- en: 12624cc86e6bc4e9
70
- zh: c86de7d9b5302601
69
+ en: 03d33ddd7673e228
70
+ zh: 9ccc0441abfbe729
71
71
  /deepseek-ai-dsh-web/known-limitations-and-deferred-work/dev-note:
72
72
  en: 7f775cc79dbce94b
73
73
  zh: 12b8f68f9e7c48ca
package/README.md CHANGED
@@ -45,7 +45,7 @@ Load the service and let a single mounted backend auto-select, or pin a provider
45
45
 
46
46
  | Field | Default | Meaning |
47
47
  |---|---|---|
48
- | `searchProvider` | (unset) | Pinned search provider id; unset auto-selects when exactly one is usable |
48
+ | `searchProvider` | (unset) | Pinned search provider id; unset prefers the usable DeepSeek provider of the [request's model route](#provider-selection), and otherwise auto-selects when exactly one is usable |
49
49
  | `fetchProvider` | (unset) | Pinned fetch provider id; unset auto-selects when exactly one is usable |
50
50
 
51
51
  The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-web) is the exhaustive source for every accepted field and its JSDoc.
@@ -62,8 +62,9 @@ const result = await ctx.web.search({ query: 'deepseek harness', maxResults: 8 }
62
62
  const page = await ctx.web.fetch({ url: 'https://example.com' })
63
63
  ```
64
64
 
65
- Both calls accept an optional `AbortSignal` that is forwarded to the provider for cancellation. The normalized request and result shapes are the contract callers build on; the vocabulary section of the [web subsystem](../../../docs/subsystems/web.md) reference describes them exhaustively.
65
+ A search made for a model request also carries that request's provider route as `llmProvider`, which [provider selection](#provider-selection) reads. Both calls accept an optional `AbortSignal` that is forwarded to the provider for cancellation. The normalized request and result shapes are the contract callers build on; the vocabulary section of the [web subsystem](../../../docs/subsystems/web.md) reference describes them exhaustively.
66
66
 
67
+ <a id="provider-selection"></a>
67
68
  ### Provider selection
68
69
 
69
70
  Each call resolves its provider at execution time, and registration or load order never matters. A configured provider id wins when it is registered and usable; without a configured id, the service runs the single usable provider or fails clearly:
@@ -73,11 +74,12 @@ Each call resolves its provider at execution time, and registration or load orde
73
74
  | configured id registered and usable | runs that provider |
74
75
  | configured id not registered | `WEB_PROVIDER_CONFIGURED_MISSING` |
75
76
  | configured id registered but unavailable | `WEB_PROVIDER_CONFIGURED_UNAVAILABLE` |
77
+ | no search id, the provider preferred for the request's `llmProvider` is registered and usable | runs that provider |
76
78
  | no id, exactly one registered usable provider | runs it |
77
79
  | no id, no usable provider | `WEB_PROVIDER_UNAVAILABLE` |
78
80
  | no id, multiple usable providers | `WEB_PROVIDER_AMBIGUOUS` |
79
81
 
80
- The shipped `deepseek-official` and `deepseek-search-api` search ids select legacy Messages search and the direct Search API respectively.
82
+ The shipped `deepseek-official` and `deepseek-search-api` search ids select legacy Messages search and the direct Search API respectively. While no search provider is configured, a search prefers `deepseek-official` for a model request on the `deepseek-official` or `deepseek-account` model route, because DeepSeek makes no per-search charge for Messages search, and `deepseek-search-api` for a request on any other route and for a search that serves no model request. The preference is fixed in this package and applies only while the preferred provider is registered and usable, so a composition without these providers selects as the table states. The [base composition](../../bundle/base/cordis.patch.yml) mounts both and configures no search provider. A configured `searchProvider`, or `$DSH_WEB_SEARCH_PROVIDER`, applies to every route.
81
83
 
82
84
  A provider's availability is a cheap local check — for example whether its API key is present — and never makes network calls, so selection stays fast and deterministic.
83
85
 
@@ -111,7 +113,7 @@ A search or fetch backend outside the shipped composition is a plugin package th
111
113
  <a id="search-readiness"></a>
112
114
  ### Search and fetch readiness
113
115
 
114
- `searchReady(llmProvider?)` and `fetchReady(llmProvider?)` ask the provider that `search()` or `fetch()` would select whether an operation made for a model request on that chat route has a credential to send; [`dsh-tool-web`](../tool-web/README.md#search-readiness) uses the answers to decide whether each model step admits `web_search` and `web_fetch`. A provider answers through its optional `ready(llmProvider)`, a configuration-only check that must not make network calls; a provider without it counts as ready. When selection fails, the readiness method answers true, because the operation reports that failure as a structured `WebError`. Readiness never changes which provider is selected.
116
+ `searchReady(llmProvider?)` and `fetchReady(llmProvider?)` ask the provider that `search()` or `fetch()` would select, for a search the one selected for a request with that `llmProvider`, whether an operation made for a model request on that chat route has a credential to send; [`dsh-tool-web`](../tool-web/README.md#search-readiness) uses the answers to decide whether each model step admits `web_search` and `web_fetch`. A provider answers through its optional `ready(llmProvider)`, a configuration-only check that must not make network calls; a provider without it counts as ready. When selection fails, the readiness method answers true, because the operation reports that failure as a structured `WebError`. Readiness never changes which provider is selected.
115
117
 
116
118
  ```text
117
119
  // false only when the selected provider cannot authenticate this route's operations:
@@ -138,7 +140,7 @@ This section explains the design decisions behind the service; the observable be
138
140
  The package is built on one deliberate separation:
139
141
 
140
142
  - **One seam, two independent operations.** Search and fetch share no request schema and no business logic, but they share one service so provider selection, cancellation, errors, and product configuration have a single owner. The parallel `Search`/`Fetch` method pairs are intentional.
141
- - **Selection is never order-dependent.** A capability either pins a provider id or auto-selects when exactly one usable provider is registered; `search()`/`fetch()` resolve the provider at execution time.
143
+ - **Selection is never order-dependent.** A capability either pins a provider id or auto-selects when exactly one usable provider is registered, and an unpinned search prefers the DeepSeek provider of the request's model route; `search()`/`fetch()` resolve the provider at execution time.
142
144
  - **The service owns the result bound.** `maxResults` is enforced by the seam after the provider returns, so an over-returning provider can never leak more sources than the caller asked for.
143
145
 
144
146
  ### Source map
@@ -154,7 +156,7 @@ The request and result types define the normalized vocabulary callers build on
154
156
 
155
157
  ### Selection flow
156
158
 
157
- At call time the service resolves the provider — configured id first, then the unique usable provider — and throws the matching `WebError` when no clear winner exists. A search result then passes through `capSources`, which truncates `sources[]` to `maxResults` and flags `truncated`. `searchReady()` and `fetchReady()` resolve the same provider as the matching operation, answer true when resolution throws, and otherwise return the provider's `ready()` answer, or true when it has none. Registration is effect-based: providers register with the calling fiber and unregister when it disposes, and a duplicate id within a capability kind is rejected at registration.
159
+ At call time the service resolves the provider — configured id first, then for a search the usable provider preferred for the request's route, then the unique usable provider — and throws the matching `WebError` when no clear winner exists. A search result then passes through `capSources`, which truncates `sources[]` to `maxResults` and flags `truncated`. `searchReady()` and `fetchReady()` resolve the same provider as the matching operation, answer true when resolution throws, and otherwise return the provider's `ready()` answer, or true when it has none. Registration is effect-based: providers register with the calling fiber and unregister when it disposes, and a duplicate id within a capability kind is rejected at registration.
158
160
 
159
161
  </details>
160
162
 
@@ -192,8 +194,9 @@ No direct invalidation; the named consumer owns any request-prefix changes.
192
194
  These limits define when the service is incomplete on its own. They are current package constraints.
193
195
 
194
196
  - **No availability observation** — `listProviders()` and `web/providers-changed` report which providers are registered, not whether they are usable; there is no capability-status query, and `searchReady()` and `fetchReady()` report only the selected provider's credential readiness and answer true when selection fails. Availability is observable only by running a search or fetch and routing the thrown code, and the no-provider failure is the generic `WEB_PROVIDER_UNAVAILABLE` with no per-provider reason enumeration ([Agent Note](../../../.agents/notes/archived/simplification/2026-07-04-drop-unconsumed-web-observation-surface.md)).
195
- - **Search requests carry only `query` and `maxResults`** — provider-neutral controls (recency, domain filters, regional hints, search depth) are deferred until the backends can honor them ([seam Agent Note](../../../.agents/notes/implemented/architecture/2026-06-24-web-capability-seam.md)).
197
+ - **Search requests carry only `query`, `maxResults`, and `llmProvider`** — provider-neutral controls (recency, domain filters, regional hints, search depth) are deferred until the backends can honor them ([seam Agent Note](../../../.agents/notes/implemented/architecture/2026-06-24-web-capability-seam.md)).
196
198
  - **`WebFetchBody` has no `pdf` arm** — text-extractable PDF support is named deferred work; the closed union makes adding it a compile-enforced change across the web packages.
199
+ - **The per-route search preference is fixed** — the two DeepSeek model routes and the two DeepSeek search provider ids are constants of this package, so a deployment changes the outcome only by configuring `searchProvider`, and a provider-neutral rule is deferred until a second pair of routes and providers needs one.
197
200
  - **Provider-backed page extraction is out of scope of `fetch()`** — a Firecrawl/Tavily-style `web_extract` capability is deferred rather than widening the fetch operation.
198
201
 
199
202
  <a id="dev-note"></a>
package/README.zh.md CHANGED
@@ -45,7 +45,7 @@ kind: "package-reference"
45
45
 
46
46
  | 字段 | 默认值 | 含义 |
47
47
  |---|---|---|
48
- | `searchProvider` | (未设置) | 固定的搜索提供方 id;未设置时仅在恰好一个可用时自动选择 |
48
+ | `searchProvider` | (未设置) | 固定的搜索提供方 id;未设置时优先使用[请求的模型路由](#provider-selection)对应的可用 DeepSeek 提供方,否则仅在恰好一个可用时自动选择 |
49
49
  | `fetchProvider` | (未设置) | 固定的抓取提供方 id;未设置时仅在恰好一个可用时自动选择 |
50
50
 
51
51
  生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-web)是每个受支持字段及其 JSDoc 的穷尽式真源。
@@ -62,8 +62,9 @@ const result = await ctx.web.search({ query: 'deepseek harness', maxResults: 8 }
62
62
  const page = await ctx.web.fetch({ url: 'https://example.com' })
63
63
  ```
64
64
 
65
- 两个调用都接受可选的 `AbortSignal`,用于把取消转发给提供方。规范化的请求与结果形状是调用方赖以构建的约定;[web 子系统](../../../docs/subsystems/web.zh.md) 参考中的词汇章节对其有穷尽式描述。
65
+ 为模型请求发起的搜索还会在 `llmProvider` 中携带该请求的提供方路由,供[提供方选择](#provider-selection)读取。两个调用都接受可选的 `AbortSignal`,用于把取消转发给提供方。规范化的请求与结果形状是调用方赖以构建的约定;[web 子系统](../../../docs/subsystems/web.zh.md) 参考中的词汇章节对其有穷尽式描述。
66
66
 
67
+ <a id="provider-selection"></a>
67
68
  ### 提供方选择
68
69
 
69
70
  每次调用都在执行时解析提供方,注册或加载顺序从不影响结果。已配置的提供方 id 在已注册且可用时优先;没有配置 id 时,服务运行唯一可用的提供方,或在情况不明时明确失败:
@@ -73,11 +74,12 @@ const page = await ctx.web.fetch({ url: 'https://example.com' })
73
74
  | 已配置 id 已注册且可用 | 运行该提供方 |
74
75
  | 已配置 id 未注册 | `WEB_PROVIDER_CONFIGURED_MISSING` |
75
76
  | 已配置 id 已注册但不可用 | `WEB_PROVIDER_CONFIGURED_UNAVAILABLE` |
77
+ | 无搜索 id,请求的 `llmProvider` 所优先的提供方已注册且可用 | 运行该提供方 |
76
78
  | 无 id,恰好一个已注册的可用提供方 | 运行它 |
77
79
  | 无 id,没有可用提供方 | `WEB_PROVIDER_UNAVAILABLE` |
78
80
  | 无 id,多个可用提供方 | `WEB_PROVIDER_AMBIGUOUS` |
79
81
 
80
- 随附的 `deepseek-official` 与 `deepseek-search-api` 搜索 id 分别选择旧版 Messages 搜索与直接 Search API。
82
+ 随附的 `deepseek-official` 与 `deepseek-search-api` 搜索 id 分别选择旧版 Messages 搜索与直接 Search API。没有配置搜索提供方时,为 `deepseek-official` 或 `deepseek-account` 模型路由上的模型请求发起的搜索优先使用 `deepseek-official`,因为 DeepSeek 不对 Messages 搜索按次收费;其他路由上的请求以及不服务于任何模型请求的搜索优先使用 `deepseek-search-api`。这一优先规则固定在本包中,仅在被优先的提供方已注册且可用时生效,因此没有这些提供方的组合按上表选择。[base 组合](../../bundle/base/cordis.patch.yml)挂载这两个提供方且不配置搜索提供方。已配置的 `searchProvider` 或 `$DSH_WEB_SEARCH_PROVIDER` 对所有路由生效。
81
83
 
82
84
  提供方的可用性是一项廉价的局部检查——例如其 API 密钥是否存在——并且从不发起网络调用,因此选择保持快速且确定。
83
85
 
@@ -111,7 +113,7 @@ ctx.remote.$on('web/providers-changed', () => { /* re-read the lists */ })
111
113
  <a id="search-readiness"></a>
112
114
  ### 搜索与抓取就绪
113
115
 
114
- `searchReady(llmProvider?)` 与 `fetchReady(llmProvider?)` 询问 `search()` 或 `fetch()` 会选中的提供方:为该对话路由上的模型请求发起的操作是否有可发送的凭据;[`dsh-tool-web`](../tool-web/README.zh.md#search-readiness) 据此决定每个模型步骤是否准入 `web_search` 与 `web_fetch`。提供方通过可选的 `ready(llmProvider)` 回答,它是只检查配置的判断,禁止发起网络调用;未实现它的提供方视为就绪。选择失败时就绪方法回答 true,因为对应操作会把该失败报告为结构化 `WebError`。就绪判断从不改变选中哪个提供方。
116
+ `searchReady(llmProvider?)` 与 `fetchReady(llmProvider?)` 询问 `search()` 或 `fetch()` 会选中的提供方(搜索为携带该 `llmProvider` 的请求所选中的提供方):为该对话路由上的模型请求发起的操作是否有可发送的凭据;[`dsh-tool-web`](../tool-web/README.zh.md#search-readiness) 据此决定每个模型步骤是否准入 `web_search` 与 `web_fetch`。提供方通过可选的 `ready(llmProvider)` 回答,它是只检查配置的判断,禁止发起网络调用;未实现它的提供方视为就绪。选择失败时就绪方法回答 true,因为对应操作会把该失败报告为结构化 `WebError`。就绪判断从不改变选中哪个提供方。
115
117
 
116
118
  ```text
117
119
  // false only when the selected provider cannot authenticate this route's operations:
@@ -138,7 +140,7 @@ const fetchOffered = await ctx.web.fetchReady('deepseek-official')
138
140
  本包建立在一个刻意的分离之上:
139
141
 
140
142
  - **一个 seam,两个独立操作。** 搜索与抓取没有共享请求 schema 或业务逻辑,但它们共用一个服务,使提供方选择、取消、错误与产品配置只有一个归属方。并行的 `Search`/`Fetch` 方法对是有意为之。
141
- - **选择绝不依赖顺序。** 能力要么固定提供方 id,要么在恰好注册一个可用提供方时自动选择;`search()`/`fetch()` 在执行时解析提供方。
143
+ - **选择绝不依赖顺序。** 能力要么固定提供方 id,要么在恰好注册一个可用提供方时自动选择,未固定的搜索优先使用请求的模型路由对应的 DeepSeek 提供方;`search()`/`fetch()` 在执行时解析提供方。
142
144
  - **服务拥有结果上限。** `maxResults` 由 seam 在提供方返回后强制执行,因此超量返回的提供方绝不可能泄漏超出调用方要求的来源。
143
145
 
144
146
  ### 源码地图
@@ -154,7 +156,7 @@ const fetchOffered = await ctx.web.fetchReady('deepseek-official')
154
156
 
155
157
  ### 选择流程
156
158
 
157
- 执行时,服务先按配置 id、再按唯一可用提供方解析提供方,没有明确赢家时抛出对应的 `WebError`。搜索结果随后经过 `capSources`:把 `sources[]` 截断到 `maxResults` 并标记 `truncated`。`searchReady()` 与 `fetchReady()` 解析与对应操作相同的提供方,解析抛错时回答 true,否则返回该提供方 `ready()` 的回答,提供方没有 `ready()` 时回答 true。注册基于 effect:提供方随调用 fiber 注册,fiber 释放时注销;同一能力类型下重复的 id 会在注册时被拒绝。
159
+ 执行时,服务先按配置 id、搜索再按请求路由所优先的可用提供方、最后按唯一可用提供方解析提供方,没有明确赢家时抛出对应的 `WebError`。搜索结果随后经过 `capSources`:把 `sources[]` 截断到 `maxResults` 并标记 `truncated`。`searchReady()` 与 `fetchReady()` 解析与对应操作相同的提供方,解析抛错时回答 true,否则返回该提供方 `ready()` 的回答,提供方没有 `ready()` 时回答 true。注册基于 effect:提供方随调用 fiber 注册,fiber 释放时注销;同一能力类型下重复的 id 会在注册时被拒绝。
158
160
 
159
161
  </details>
160
162
 
@@ -192,8 +194,9 @@ const fetchOffered = await ctx.web.fetchReady('deepseek-official')
192
194
  这些限制说明本服务单独使用时在哪些方面不完整。它们是当前包约束。
193
195
 
194
196
  - **没有可用性观测**:`listProviders()` 与 `web/providers-changed` 只报告哪些提供方已注册,不报告它们是否可用;没有能力状态查询,`searchReady()` 与 `fetchReady()` 只报告选中提供方的凭据就绪状态,选择失败时回答 true。可用性只能通过执行搜索或抓取并按抛出的 code 路由来观测,无提供方失败是通用的 `WEB_PROVIDER_UNAVAILABLE`,不枚举逐提供方原因(见 [Agent Note](../../../.agents/notes/archived/simplification/2026-07-04-drop-unconsumed-web-observation-surface.md))。
195
- - **搜索请求只携带 `query` 与 `maxResults`**:提供方无关的控制项(新近程度、域名过滤条件、区域提示、搜索深度)暂缓至后端都能诚实支持时(见 [seam Agent Note](../../../.agents/notes/implemented/architecture/2026-06-24-web-capability-seam.zh.md))。
197
+ - **搜索请求只携带 `query`、`maxResults` 与 `llmProvider`**:提供方无关的控制项(新近程度、域名过滤条件、区域提示、搜索深度)暂缓至后端都能诚实支持时(见 [seam Agent Note](../../../.agents/notes/implemented/architecture/2026-06-24-web-capability-seam.zh.md))。
196
198
  - **`WebFetchBody` 没有 `pdf` 分支**:可提取文本的 PDF 支持属于明确的延期工作;封闭联合会使新增该分支成为跨 web 包、由编译强制执行的变更。
199
+ - **按路由的搜索优先规则是固定的**:两条 DeepSeek 模型路由与两个 DeepSeek 搜索提供方 id 是本包中的常量,因此部署只能通过配置 `searchProvider` 改变结果;提供方无关的规则延期至出现第二组路由与提供方时。
197
200
  - **提供方支持的页面提取不属于 `fetch()` 范围**:Firecrawl/Tavily 风格的 `web_extract` 能力延期,而不会扩展抓取操作。
198
201
 
199
202
  <a id="dev-note"></a>
package/lib/index.js CHANGED
@@ -22,8 +22,9 @@ var WebError = class extends HarnessError {};
22
22
  /**
23
23
  * Service Definition for the web access capability seam (`ctx.web`): registries and provider-selecting execution for search and
24
24
  * fetch. Duplicate ids are rejected. At execution time, a configured provider must exist and
25
- * be usable; without one, exactly one usable provider is required, so selection never depends
26
- * on registration order.
25
+ * be usable; without one, exactly one usable provider is required, except that a search prefers the
26
+ * usable DeepSeek provider assigned to the route of the model request it serves, so selection never
27
+ * depends on registration order.
27
28
  * @module @deepseek-ai/dsh-web
28
29
  */
29
30
  var __runInitializers = function(thisArg, initializers, value) {
@@ -64,6 +65,15 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
64
65
  if (target) Object.defineProperty(target, contextIn.name, descriptor);
65
66
  done = true;
66
67
  };
68
+ /** Provider routes of the DeepSeek API-key and account models. */
69
+ const DEEPSEEK_MODEL_ROUTES = new Set(["deepseek-official", "deepseek-account"]);
70
+ /**
71
+ * Search provider preferred for a model request on a DeepSeek model route while none is configured: DeepSeek
72
+ * Messages search, which DeepSeek serves without a per-search charge.
73
+ */
74
+ const DEEPSEEK_ROUTE_SEARCH_PROVIDER = "deepseek-official";
75
+ /** Search provider preferred on every other route and outside a model request while none is configured. */
76
+ const OTHER_ROUTE_SEARCH_PROVIDER = "deepseek-search-api";
67
77
  /**
68
78
  * The web access service. Registered as `ctx.web` (one instance per context)
69
79
  * and exposed to Clients as the `web` Remote namespace (`listProviders`).
@@ -73,6 +83,10 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
73
83
  * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
74
84
  * - A configured id registered but unavailable →
75
85
  * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
86
+ * - No search id configured, and the provider assigned to the route of the model request
87
+ * the search serves is usable → that provider: `deepseek-official` (Messages search) on the
88
+ * `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other
89
+ * route and outside a model request.
76
90
  * - No id configured, exactly one registered usable provider → that provider.
77
91
  * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
78
92
  * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -191,12 +205,12 @@ let WebRuntime = (() => {
191
205
  * time with the selection rules above; throws {@link WebError} when the
192
206
  * capability cannot run. The seam enforces `request.maxResults` on the result:
193
207
  * if the provider over-returns, `sources[]` is truncated and `truncated` set.
194
- * @param request - the query and optional result limit.
208
+ * @param request - the query, the optional result limit, and the route of the model request the search serves.
195
209
  * @param signal - optional cancellation signal forwarded to the provider.
196
210
  * @returns the provider's results, capped to `request.maxResults`.
197
211
  */
198
212
  async search(request, signal) {
199
- return capSources(await this.selectSearchProvider().search(request, signal), request.maxResults);
213
+ return capSources(await this.selectSearchProvider(request.llmProvider).search(request, signal), request.maxResults);
200
214
  }
201
215
  /**
202
216
  * Whether the provider `search()` would select can authenticate a search made for a
@@ -207,13 +221,19 @@ let WebRuntime = (() => {
207
221
  * @returns false only when the selected provider reports that it cannot authenticate.
208
222
  */
209
223
  async searchReady(llmProvider) {
210
- return await selectedProviderReady(() => this.selectSearchProvider(), llmProvider);
224
+ return await selectedProviderReady(() => this.selectSearchProvider(llmProvider), llmProvider);
211
225
  }
212
- /** Select the search provider with the rules above, throwing the matching {@link WebError}. */
213
- selectSearchProvider() {
226
+ /**
227
+ * Select the search provider with the rules above, throwing the matching {@link WebError}.
228
+ * @param llmProvider - provider route id of the model request the search serves, when known.
229
+ * @returns the provider the search runs through.
230
+ */
231
+ selectSearchProvider(llmProvider) {
214
232
  const configuredId = this.config.searchProvider.get() ?? this.searchProviderEnv;
233
+ const preferredId = llmProvider !== void 0 && DEEPSEEK_MODEL_ROUTES.has(llmProvider) ? DEEPSEEK_ROUTE_SEARCH_PROVIDER : OTHER_ROUTE_SEARCH_PROVIDER;
215
234
  return resolveProvider({
216
235
  providers: this.searchProviders,
236
+ preferredId,
217
237
  ...configuredId !== void 0 ? { configuredId } : {}
218
238
  });
219
239
  }
@@ -283,6 +303,8 @@ function resolveProvider(selection) {
283
303
  return provider;
284
304
  }
285
305
  const usable = [...providers.values()].filter((provider) => provider.available());
306
+ const preferred = usable.find((provider) => provider.id === selection.preferredId);
307
+ if (preferred !== void 0) return preferred;
286
308
  const [single] = usable;
287
309
  if (single === void 0) throw new WebError("no usable web provider is registered", "WEB_PROVIDER_UNAVAILABLE");
288
310
  if (usable.length > 1) throw new WebError(`multiple usable web providers are registered (${usable.map((provider) => provider.id).join(", ")}); configure one explicitly`, "WEB_PROVIDER_AMBIGUOUS");
@@ -37,7 +37,7 @@ const $remote = createTypertRemoteInfo({
37
37
  description: 'detached `{ id, title, description }` entries per capability, in registration order.',
38
38
  jsonSchemaError: 'typert tool schema: selected dictionaries require string keys and unconstrained JSON values',
39
39
  },
40
- sourceLocation: {"file":"packages/web/web/src/index.ts","line":152,"column":3},
40
+ sourceLocation: {"file":"packages/web/web/src/index.ts","line":174,"column":3},
41
41
  },
42
42
  },
43
43
  }, z)
@@ -51,10 +51,10 @@ export const TYPERT = {
51
51
  model: {
52
52
  "services": [
53
53
  {
54
- "description": "The web access service. Registered as `ctx.web` (one instance per context) and exposed to Clients as the `web` Remote namespace (`listProviders`). Selection semantics (resolved at execution time, never order-dependent): - A configured id that is registered and `available()` → that provider. - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`. - A configured id registered but unavailable → `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`. - No id configured, exactly one registered usable provider → that provider. - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`. - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.",
54
+ "description": "The web access service. Registered as `ctx.web` (one instance per context) and exposed to Clients as the `web` Remote namespace (`listProviders`). Selection semantics (resolved at execution time, never order-dependent): - A configured id that is registered and `available()` → that provider. - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`. - A configured id registered but unavailable → `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`. - No search id configured, and the provider assigned to the route of the model request the search serves is usable → that provider: `deepseek-official` (Messages search) on the `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other route and outside a model request. - No id configured, exactly one registered usable provider → that provider. - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`. - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.",
55
55
  "summary": "The web access service.",
56
56
  "tags": [],
57
- "jsDoc": "/**\n * The web access service. Registered as `ctx.web` (one instance per context)\n * and exposed to Clients as the `web` Remote namespace (`listProviders`).\n *\n * Selection semantics (resolved at execution time, never order-dependent):\n * - A configured id that is registered and `available()` → that provider.\n * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.\n * - A configured id registered but unavailable →\n * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.\n * - No id configured, exactly one registered usable provider → that provider.\n * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.\n * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.\n */",
57
+ "jsDoc": "/**\n * The web access service. Registered as `ctx.web` (one instance per context)\n * and exposed to Clients as the `web` Remote namespace (`listProviders`).\n *\n * Selection semantics (resolved at execution time, never order-dependent):\n * - A configured id that is registered and `available()` → that provider.\n * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.\n * - A configured id registered but unavailable →\n * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.\n * - No search id configured, and the provider assigned to the route of the model request\n * the search serves is usable → that provider: `deepseek-official` (Messages search) on the\n * `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other\n * route and outside a model request.\n * - No id configured, exactly one registered usable provider → that provider.\n * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.\n * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.\n */",
58
58
  "key": "web",
59
59
  "exportName": "WebRuntime",
60
60
  "members": [
@@ -84,7 +84,7 @@ export const TYPERT = {
84
84
  "name": "search",
85
85
  "signature": "async search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>",
86
86
  "summary": "Run one search through the selected provider.",
87
- "jsDoc": "/**\n * Run one search through the selected provider. Resolves the provider at call\n * time with the selection rules above; throws {@link WebError} when the\n * capability cannot run. The seam enforces `request.maxResults` on the result:\n * if the provider over-returns, `sources[]` is truncated and `truncated` set.\n * @param request - the query and optional result limit.\n * @param signal - optional cancellation signal forwarded to the provider.\n * @returns the provider's results, capped to `request.maxResults`.\n */"
87
+ "jsDoc": "/**\n * Run one search through the selected provider. Resolves the provider at call\n * time with the selection rules above; throws {@link WebError} when the\n * capability cannot run. The seam enforces `request.maxResults` on the result:\n * if the provider over-returns, `sources[]` is truncated and `truncated` set.\n * @param request - the query, the optional result limit, and the route of the model request the search serves.\n * @param signal - optional cancellation signal forwarded to the provider.\n * @returns the provider's results, capped to `request.maxResults`.\n */"
88
88
  },
89
89
  {
90
90
  "kind": "method",
@@ -143,7 +143,7 @@ export const TYPERT = {
143
143
  },
144
144
  {
145
145
  "name": "WebSearchRequest",
146
- "declaration": "export interface WebSearchRequest {\n readonly query: string;\n readonly maxResults?: number;\n}"
146
+ "declaration": "export interface WebSearchRequest {\n readonly query: string;\n readonly maxResults?: number;\n readonly llmProvider?: string;\n}"
147
147
  },
148
148
  {
149
149
  "name": "WebSearchResult",
@@ -1 +1 @@
1
- {"version":3,"file":"typert.remote-client.d.ts","names":["listProviders"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;IAuJEA,a;;;IAAAA,mB","ignoreList":[]}
1
+ {"version":3,"file":"typert.remote-client.d.ts","names":["listProviders"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;IA6KEA,a;;;IAAAA,mB","ignoreList":[]}
@@ -37,7 +37,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
37
37
  description: 'detached `{ id, title, description }` entries per capability, in registration order.',
38
38
  jsonSchemaError: 'typert tool schema: selected dictionaries require string keys and unconstrained JSON values',
39
39
  },
40
- sourceLocation: {"file":"packages/web/web/src/index.ts","line":152,"column":3},
40
+ sourceLocation: {"file":"packages/web/web/src/index.ts","line":174,"column":3},
41
41
  },
42
42
  },
43
43
  }, z)
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Service Definition for the web access capability seam (`ctx.web`): registries and provider-selecting execution for search and
3
3
  * fetch. Duplicate ids are rejected. At execution time, a configured provider must exist and
4
- * be usable; without one, exactly one usable provider is required, so selection never depends
5
- * on registration order.
4
+ * be usable; without one, exactly one usable provider is required, except that a search prefers the
5
+ * usable DeepSeek provider assigned to the route of the model request it serves, so selection never
6
+ * depends on registration order.
6
7
  * @module @deepseek-ai/dsh-web
7
8
  */
8
9
  import { Context, type Volatile } from '@deepseek-ai/cordis';
@@ -25,7 +26,10 @@ declare module '@deepseek-ai/cordis' {
25
26
  * fields rather than introduce a hidden priority chain.
26
27
  */
27
28
  export interface WebRuntimeConfig {
28
- /** Explicit search provider id. Omitted = auto-select when exactly one usable. */
29
+ /**
30
+ * Explicit search provider id. Omitted = the usable DeepSeek provider assigned to the route of the model
31
+ * request, and otherwise auto-select when exactly one usable.
32
+ */
29
33
  readonly searchProvider: Volatile<string | undefined>;
30
34
  /** Explicit fetch provider id. Omitted = auto-select when exactly one usable. */
31
35
  readonly fetchProvider: Volatile<string | undefined>;
@@ -39,6 +43,10 @@ export interface WebRuntimeConfig {
39
43
  * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
40
44
  * - A configured id registered but unavailable →
41
45
  * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
46
+ * - No search id configured, and the provider assigned to the route of the model request
47
+ * the search serves is usable → that provider: `deepseek-official` (Messages search) on the
48
+ * `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other
49
+ * route and outside a model request.
42
50
  * - No id configured, exactly one registered usable provider → that provider.
43
51
  * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
44
52
  * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -95,7 +103,7 @@ export declare class WebRuntime extends TypertRemoteService {
95
103
  * time with the selection rules above; throws {@link WebError} when the
96
104
  * capability cannot run. The seam enforces `request.maxResults` on the result:
97
105
  * if the provider over-returns, `sources[]` is truncated and `truncated` set.
98
- * @param request - the query and optional result limit.
106
+ * @param request - the query, the optional result limit, and the route of the model request the search serves.
99
107
  * @param signal - optional cancellation signal forwarded to the provider.
100
108
  * @returns the provider's results, capped to `request.maxResults`.
101
109
  */
@@ -109,7 +117,11 @@ export declare class WebRuntime extends TypertRemoteService {
109
117
  * @returns false only when the selected provider reports that it cannot authenticate.
110
118
  */
111
119
  searchReady(llmProvider?: string): Promise<boolean>;
112
- /** Select the search provider with the rules above, throwing the matching {@link WebError}. */
120
+ /**
121
+ * Select the search provider with the rules above, throwing the matching {@link WebError}.
122
+ * @param llmProvider - provider route id of the model request the search serves, when known.
123
+ * @returns the provider the search runs through.
124
+ */
113
125
  private selectSearchProvider;
114
126
  /**
115
127
  * Retrieve one URL through the selected provider. Resolves the provider at
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GA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AAO,CAAC,eAAe,CAAC;IAKvF;;;;;;;OAOG;IACG,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzD;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAY5B;;;;;;;OAOG;IACG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC;IAIpF;;;;;;;OAOG;IACG,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIxD,8FAA8F;IAC9F,OAAO,CAAC,mBAAmB;CAO5B;AAgED,eAAe,UAAU,CAAA"}
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Service Definition for the web access capability seam (`ctx.web`): registries and provider-selecting execution for search and
3
3
  * fetch. Duplicate ids are rejected. At execution time, a configured provider must exist and
4
- * be usable; without one, exactly one usable provider is required, so selection never depends
5
- * on registration order.
4
+ * be usable; without one, exactly one usable provider is required, except that a search prefers the
5
+ * usable DeepSeek provider assigned to the route of the model request it serves, so selection never
6
+ * depends on registration order.
6
7
  * @module @deepseek-ai/dsh-web
7
8
  */
8
9
  var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
@@ -43,6 +44,15 @@ import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
43
44
  import z from '@deepseek-ai/schemastery';
44
45
  import { WebError } from "./types.js";
45
46
  export { WebError, } from "./types.js";
47
+ /** Provider routes of the DeepSeek API-key and account models. */
48
+ const DEEPSEEK_MODEL_ROUTES = new Set(['deepseek-official', 'deepseek-account']);
49
+ /**
50
+ * Search provider preferred for a model request on a DeepSeek model route while none is configured: DeepSeek
51
+ * Messages search, which DeepSeek serves without a per-search charge.
52
+ */
53
+ const DEEPSEEK_ROUTE_SEARCH_PROVIDER = 'deepseek-official';
54
+ /** Search provider preferred on every other route and outside a model request while none is configured. */
55
+ const OTHER_ROUTE_SEARCH_PROVIDER = 'deepseek-search-api';
46
56
  /**
47
57
  * The web access service. Registered as `ctx.web` (one instance per context)
48
58
  * and exposed to Clients as the `web` Remote namespace (`listProviders`).
@@ -52,6 +62,10 @@ export { WebError, } from "./types.js";
52
62
  * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
53
63
  * - A configured id registered but unavailable →
54
64
  * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
65
+ * - No search id configured, and the provider assigned to the route of the model request
66
+ * the search serves is usable → that provider: `deepseek-official` (Messages search) on the
67
+ * `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other
68
+ * route and outside a model request.
55
69
  * - No id configured, exactly one registered usable provider → that provider.
56
70
  * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
57
71
  * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -158,12 +172,12 @@ let WebRuntime = (() => {
158
172
  * time with the selection rules above; throws {@link WebError} when the
159
173
  * capability cannot run. The seam enforces `request.maxResults` on the result:
160
174
  * if the provider over-returns, `sources[]` is truncated and `truncated` set.
161
- * @param request - the query and optional result limit.
175
+ * @param request - the query, the optional result limit, and the route of the model request the search serves.
162
176
  * @param signal - optional cancellation signal forwarded to the provider.
163
177
  * @returns the provider's results, capped to `request.maxResults`.
164
178
  */
165
179
  async search(request, signal) {
166
- const result = await this.selectSearchProvider().search(request, signal);
180
+ const result = await this.selectSearchProvider(request.llmProvider).search(request, signal);
167
181
  return capSources(result, request.maxResults);
168
182
  }
169
183
  /**
@@ -175,13 +189,21 @@ let WebRuntime = (() => {
175
189
  * @returns false only when the selected provider reports that it cannot authenticate.
176
190
  */
177
191
  async searchReady(llmProvider) {
178
- return await selectedProviderReady(() => this.selectSearchProvider(), llmProvider);
192
+ return await selectedProviderReady(() => this.selectSearchProvider(llmProvider), llmProvider);
179
193
  }
180
- /** Select the search provider with the rules above, throwing the matching {@link WebError}. */
181
- selectSearchProvider() {
194
+ /**
195
+ * Select the search provider with the rules above, throwing the matching {@link WebError}.
196
+ * @param llmProvider - provider route id of the model request the search serves, when known.
197
+ * @returns the provider the search runs through.
198
+ */
199
+ selectSearchProvider(llmProvider) {
182
200
  const configuredId = this.config.searchProvider.get() ?? this.searchProviderEnv;
201
+ const preferredId = llmProvider !== undefined && DEEPSEEK_MODEL_ROUTES.has(llmProvider)
202
+ ? DEEPSEEK_ROUTE_SEARCH_PROVIDER
203
+ : OTHER_ROUTE_SEARCH_PROVIDER;
183
204
  return resolveProvider({
184
205
  providers: this.searchProviders,
206
+ preferredId,
185
207
  ...configuredId !== undefined ? { configuredId } : {},
186
208
  });
187
209
  }
@@ -257,6 +279,9 @@ function resolveProvider(selection) {
257
279
  return provider;
258
280
  }
259
281
  const usable = [...providers.values()].filter(provider => provider.available());
282
+ const preferred = usable.find(provider => provider.id === selection.preferredId);
283
+ if (preferred !== undefined)
284
+ return preferred;
260
285
  const [single] = usable;
261
286
  if (single === undefined) {
262
287
  throw new WebError('no usable web provider is registered', 'WEB_PROVIDER_UNAVAILABLE');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC9E,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAWxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EACL,QAAQ,GACT,MAAM,YAAY,CAAA;AA2CnB;;;;;;;;;;;;GAYG;IACU,UAAU;sBAAS,mBAAmB;;;iBAAtC,UAAW,SAAQ,WAAmB;;;yCAqEhD,MAAM;YACP,0LAAA,aAAa,6DAKZ;;;QA3D0C,MAAM,GAhBtC,mDAAU;QACrB;;;;WAIG;QACH,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YACvB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
@@ -35,6 +35,12 @@ export interface WebSearchRequest {
35
35
  * bound regardless.
36
36
  */
37
37
  readonly maxResults?: number;
38
+ /**
39
+ * Provider route id of the model request this search serves. While no search
40
+ * provider is configured, the seam selects with it, as `searchReady()` selects
41
+ * with its argument. Omitted = the search serves no model request.
42
+ */
43
+ readonly llmProvider?: string;
38
44
  }
39
45
  /**
40
46
  * Normalized search outcome. `content` is optional provider-generated answer
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAEtE,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,MAAM;QACd;;;;;;;WAOG;QACH,uBAAuB,IAAI,IAAI,CAAA;KAChC;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IAC5C,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAA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AAA;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,iFAAiF;IACjF,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAA;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;IAC3C,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAA;CAC3C;AAED;;;;;;;GAOG;AACH,qBAAa,QAAS,SAAQ,YAAY;CAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AA0LnD;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;CAAG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAgMnD;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;CAAG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-web",
3
3
  "description": "Abstract web access capability seam (ctx.web) for the DeepSeek Harness — search/fetch provider registry, registration-order-independent selection, request/result vocabulary, and the WebError taxonomy",
4
- "version": "0.2.2-rc.4",
4
+ "version": "0.2.2-rc.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -50,16 +50,16 @@
50
50
  ],
51
51
  "license": "MIT",
52
52
  "peerDependencies": {
53
- "@deepseek-ai/dsh-llm": "0.2.2-rc.4",
53
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
54
54
  "@deepseek-ai/cordis": "~4.1.0"
55
55
  },
56
56
  "dependencies": {
57
- "@deepseek-ai/dsh-package-manifest": "0.2.2-rc.4",
57
+ "@deepseek-ai/dsh-package-manifest": "0.2.2-rc.5",
58
58
  "@deepseek-ai/schemastery": "~3.19.0",
59
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.4"
59
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5"
60
60
  },
61
61
  "devDependencies": {
62
- "@deepseek-ai/dsh-llm": "0.2.2-rc.4",
62
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
63
63
  "@deepseek-ai/cordis": "~4.1.0"
64
64
  }
65
65
  }
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Service Definition for the web access capability seam (`ctx.web`): registries and provider-selecting execution for search and
3
3
  * fetch. Duplicate ids are rejected. At execution time, a configured provider must exist and
4
- * be usable; without one, exactly one usable provider is required, so selection never depends
5
- * on registration order.
4
+ * be usable; without one, exactly one usable provider is required, except that a search prefers the
5
+ * usable DeepSeek provider assigned to the route of the model request it serves, so selection never
6
+ * depends on registration order.
6
7
  * @module @deepseek-ai/dsh-web
7
8
  */
8
9
 
@@ -49,8 +50,22 @@ interface Selection<P> {
49
50
  readonly configuredId?: string
50
51
  /** Providers registered for this capability kind. */
51
52
  readonly providers: ReadonlyMap<string, P>
53
+ /** The provider that wins among the usable ones while none is configured, if it is usable. */
54
+ readonly preferredId?: string
52
55
  }
53
56
 
57
+ /** Provider routes of the DeepSeek API-key and account models. */
58
+ const DEEPSEEK_MODEL_ROUTES: ReadonlySet<string> = new Set(['deepseek-official', 'deepseek-account'])
59
+
60
+ /**
61
+ * Search provider preferred for a model request on a DeepSeek model route while none is configured: DeepSeek
62
+ * Messages search, which DeepSeek serves without a per-search charge.
63
+ */
64
+ const DEEPSEEK_ROUTE_SEARCH_PROVIDER = 'deepseek-official'
65
+
66
+ /** Search provider preferred on every other route and outside a model request while none is configured. */
67
+ const OTHER_ROUTE_SEARCH_PROVIDER = 'deepseek-search-api'
68
+
54
69
  /**
55
70
  * Config for the web seam. `searchProvider` / `fetchProvider` pin which provider
56
71
  * wins for each capability; both are optional (a single registered usable
@@ -60,7 +75,10 @@ interface Selection<P> {
60
75
  * fields rather than introduce a hidden priority chain.
61
76
  */
62
77
  export interface WebRuntimeConfig {
63
- /** Explicit search provider id. Omitted = auto-select when exactly one usable. */
78
+ /**
79
+ * Explicit search provider id. Omitted = the usable DeepSeek provider assigned to the route of the model
80
+ * request, and otherwise auto-select when exactly one usable.
81
+ */
64
82
  readonly searchProvider: Volatile<string | undefined>
65
83
  /** Explicit fetch provider id. Omitted = auto-select when exactly one usable. */
66
84
  readonly fetchProvider: Volatile<string | undefined>
@@ -75,6 +93,10 @@ export interface WebRuntimeConfig {
75
93
  * - A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
76
94
  * - A configured id registered but unavailable →
77
95
  * `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
96
+ * - No search id configured, and the provider assigned to the route of the model request
97
+ * the search serves is usable → that provider: `deepseek-official` (Messages search) on the
98
+ * `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other
99
+ * route and outside a model request.
78
100
  * - No id configured, exactly one registered usable provider → that provider.
79
101
  * - No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
80
102
  * - No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -178,12 +200,12 @@ export class WebRuntime extends TypertRemoteService {
178
200
  * time with the selection rules above; throws {@link WebError} when the
179
201
  * capability cannot run. The seam enforces `request.maxResults` on the result:
180
202
  * if the provider over-returns, `sources[]` is truncated and `truncated` set.
181
- * @param request - the query and optional result limit.
203
+ * @param request - the query, the optional result limit, and the route of the model request the search serves.
182
204
  * @param signal - optional cancellation signal forwarded to the provider.
183
205
  * @returns the provider's results, capped to `request.maxResults`.
184
206
  */
185
207
  async search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult> {
186
- const result = await this.selectSearchProvider().search(request, signal)
208
+ const result = await this.selectSearchProvider(request.llmProvider).search(request, signal)
187
209
  return capSources(result, request.maxResults)
188
210
  }
189
211
 
@@ -196,14 +218,22 @@ export class WebRuntime extends TypertRemoteService {
196
218
  * @returns false only when the selected provider reports that it cannot authenticate.
197
219
  */
198
220
  async searchReady(llmProvider?: string): Promise<boolean> {
199
- return await selectedProviderReady(() => this.selectSearchProvider(), llmProvider)
221
+ return await selectedProviderReady(() => this.selectSearchProvider(llmProvider), llmProvider)
200
222
  }
201
223
 
202
- /** Select the search provider with the rules above, throwing the matching {@link WebError}. */
203
- private selectSearchProvider(): WebSearchProvider {
224
+ /**
225
+ * Select the search provider with the rules above, throwing the matching {@link WebError}.
226
+ * @param llmProvider - provider route id of the model request the search serves, when known.
227
+ * @returns the provider the search runs through.
228
+ */
229
+ private selectSearchProvider(llmProvider: string | undefined): WebSearchProvider {
204
230
  const configuredId = this.config.searchProvider.get() ?? this.searchProviderEnv
231
+ const preferredId = llmProvider !== undefined && DEEPSEEK_MODEL_ROUTES.has(llmProvider)
232
+ ? DEEPSEEK_ROUTE_SEARCH_PROVIDER
233
+ : OTHER_ROUTE_SEARCH_PROVIDER
205
234
  return resolveProvider({
206
235
  providers: this.searchProviders,
236
+ preferredId,
207
237
  ...configuredId !== undefined ? { configuredId } : {},
208
238
  })
209
239
  }
@@ -285,6 +315,8 @@ function resolveProvider<P extends ResolvableProvider>(selection: Selection<P>):
285
315
  return provider
286
316
  }
287
317
  const usable = [...providers.values()].filter(provider => provider.available())
318
+ const preferred = usable.find(provider => provider.id === selection.preferredId)
319
+ if (preferred !== undefined) return preferred
288
320
  const [single] = usable
289
321
  if (single === undefined) {
290
322
  throw new WebError('no usable web provider is registered', 'WEB_PROVIDER_UNAVAILABLE')
package/src/types.ts CHANGED
@@ -38,6 +38,12 @@ export interface WebSearchRequest {
38
38
  * bound regardless.
39
39
  */
40
40
  readonly maxResults?: number
41
+ /**
42
+ * Provider route id of the model request this search serves. While no search
43
+ * provider is configured, the seam selects with it, as `searchReady()` selects
44
+ * with its argument. Omitted = the search serves no model request.
45
+ */
46
+ readonly llmProvider?: string
41
47
  }
42
48
 
43
49
  /**