@deepseek-ai/dsh-web-search-deepseek 0.2.2-rc.5 → 0.2.3-alpha.1
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 +12 -12
- package/README.md +10 -9
- package/README.zh.md +10 -9
- package/lib/index.js +95 -64
- package/lib/types/index.d.ts +7 -6
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/provider.d.ts +17 -18
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js.map +1 -1
- package/package.json +20 -23
- package/src/index.ts +60 -44
- package/src/provider.ts +84 -58
package/README.i18n.yaml
CHANGED
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
17
17
|
/deepseek-ai-dsh-web-search-deepseek/use-this-package:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: 9755de68c78e5c18
|
|
19
|
+
zh: 2b5a6300e981e270
|
|
20
20
|
/deepseek-ai-dsh-web-search-deepseek/use-this-package/when-to-choose-it:
|
|
21
21
|
en: 60c58e847abc01ab
|
|
22
22
|
zh: 730e65a38783002a
|
|
23
23
|
/deepseek-ai-dsh-web-search-deepseek/use-this-package/minimal-configuration:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
24
|
+
en: b336edf5f1a6f43f
|
|
25
|
+
zh: 215cd616bcd91874
|
|
26
26
|
/deepseek-ai-dsh-web-search-deepseek/use-this-package/authentication:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: f5af5bfdd5d26c66
|
|
28
|
+
zh: 840c9cff505a08ac
|
|
29
29
|
/deepseek-ai-dsh-web-search-deepseek/use-this-package/what-a-search-returns:
|
|
30
30
|
en: 8f852321e5c111a7
|
|
31
31
|
zh: ae43d88540e0ccde
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
en: 9842c69ad3636bb3
|
|
40
40
|
zh: 3cdc3f816cbdd0cb
|
|
41
41
|
/deepseek-ai-dsh-web-search-deepseek/understand-the-implementation/design-philosophy:
|
|
42
|
-
en:
|
|
43
|
-
zh:
|
|
42
|
+
en: e4ad49ef66f73a8e
|
|
43
|
+
zh: 13bbf09a8bc9f396
|
|
44
44
|
/deepseek-ai-dsh-web-search-deepseek/understand-the-implementation/source-map:
|
|
45
45
|
en: 6488e1c85646339f
|
|
46
46
|
zh: 2b5ca1c6b5939a8c
|
|
47
47
|
/deepseek-ai-dsh-web-search-deepseek/understand-the-implementation/request-flow:
|
|
48
|
-
en:
|
|
49
|
-
zh:
|
|
48
|
+
en: 897d7b08eeccf800
|
|
49
|
+
zh: bad9b56c7cd0cbf0
|
|
50
50
|
/deepseek-ai-dsh-web-search-deepseek/further-exploration:
|
|
51
51
|
en: 3a650478cf33d792
|
|
52
52
|
zh: ab4247c4c31f4a90
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
en: 666f5753c99783ab
|
|
70
70
|
zh: b44328e99bcc45c9
|
|
71
71
|
/deepseek-ai-dsh-web-search-deepseek/model-experience/conversation-tool-result-indirectly/what-the-model-sees:
|
|
72
|
-
en:
|
|
73
|
-
zh:
|
|
72
|
+
en: 9d61e4bbaed1e98e
|
|
73
|
+
zh: a393ba967f16da55
|
|
74
74
|
/deepseek-ai-dsh-web-search-deepseek/model-experience/conversation-tool-result-indirectly/token-effect:
|
|
75
75
|
en: 01ec43a9b616139d
|
|
76
76
|
zh: 0a5b7c28fde34bcf
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ With `dsh-web-search-deepseek`, the harness searches the web through DeepSeek's
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## Use this package
|
|
27
27
|
|
|
28
|
-
Mount the provider in a composition that already loads the web service; it registers as the `deepseek-official` search provider, so `ctx.web.search()` resolves it automatically when it is the only usable search backend, and while no search provider is configured also for a model request on the `deepseek-official` or `deepseek-account` model route ([provider selection](../web/README.md#provider-selection)) — or pin it with `searchProvider: deepseek-official`.
|
|
28
|
+
Mount the provider in a composition that already loads the web service and [`dsh-deepseek-auth`](../../account/deepseek-auth/README.md), which releases its credentials; it registers as the `deepseek-official` search provider, so `ctx.web.search()` resolves it automatically when it is the only usable search backend, and while no search provider is configured also for a model request on the `deepseek-official` or `deepseek-account` model route ([provider selection](../web/README.md#provider-selection)) — or pin it with `searchProvider: deepseek-official`.
|
|
29
29
|
|
|
30
30
|
### When to choose it
|
|
31
31
|
|
|
@@ -33,10 +33,11 @@ Choose this backend when a deployment wants DeepSeek's native server-side web se
|
|
|
33
33
|
|
|
34
34
|
### Minimal configuration
|
|
35
35
|
|
|
36
|
-
Load the web service and the provider; the key resolves from `ctx.credentials` when that service is mounted, otherwise from the process environment. The auxiliary search call has its own endpoint setting and uses the Anthropic-compatible base `https://api.deepseek.com/anthropic/v1`, with `/messages` appended. It reads `$DEEPSEEK_SEARCH_BASE_URL`, independently of the conversation adapter’s `$DEEPSEEK_BASE_URL`; the `dsh` launcher accepts both variables from the launching environment or `$DSH_HOME/.env`, never from a project `.env` ([app-boot](../../boot/app-boot/README.md)).
|
|
36
|
+
Load the web service, DeepSeek authentication, and the provider; the key resolves from `ctx.credentials` when that service is mounted, otherwise from the process environment. The auxiliary search call has its own endpoint setting and uses the Anthropic-compatible base `https://api.deepseek.com/anthropic/v1`, with `/messages` appended. It reads `$DEEPSEEK_SEARCH_BASE_URL`, independently of the conversation adapter’s `$DEEPSEEK_BASE_URL`; the `dsh` launcher accepts both variables from the launching environment or `$DSH_HOME/.env`, never from a project `.env` ([app-boot](../../boot/app-boot/README.md)).
|
|
37
37
|
|
|
38
38
|
```yaml
|
|
39
39
|
- name: '@deepseek-ai/dsh-web'
|
|
40
|
+
- name: '@deepseek-ai/dsh-deepseek-auth'
|
|
40
41
|
- name: '@deepseek-ai/dsh-web-search-deepseek'
|
|
41
42
|
config:
|
|
42
43
|
apiKeyEnv: DEEPSEEK_API_KEY
|
|
@@ -58,11 +59,11 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
|
|
|
58
59
|
<a id="authentication"></a>
|
|
59
60
|
### Authentication
|
|
60
61
|
|
|
61
|
-
A search authenticates with the DeepSeek account when the latest `request/context` event of the initiating Session names the `deepseek-account`
|
|
62
|
+
A search authenticates with the DeepSeek account when the latest `request/context` event of the initiating Session names the `deepseek-account` model route, the search endpoint has the origin of that route's base URL, and `ctx.deepseekAuth` releases the account sign-in for the search endpoint. The sign-in is asked for only at that origin, so it is never sent to the search endpoint of another deployment. The account service releases one only while signed in and only for its deployment-configured inference origin, `https://api.deepseek.com` by default. That search sends only the credential's headers, `x-dsh-auth-token`, even when an API key is configured. Every other search, including a call without an initiating Session and a search whose endpoint has another origin, sends the API key as both `x-api-key` and `Authorization: Bearer`. An HTTP 401 response to an account-authenticated search fails as `WEB_PROVIDER_ERROR` with sign-in guidance instead of endpoint guidance, and invalidates only the credential that search sent through the credential's own invalidation: a newer sign-in is preserved, and a credential-removal failure or a cancelled error-body read does not skip invalidation or replace the reported failure. An API-key 401 and every HTTP 403 leave the account signed in. An account-authenticated search in flight when the account signs out ends through the credential's `revoked` signal and fails as `WEB_PROVIDER_ERROR` with sign-in guidance.
|
|
62
63
|
|
|
63
|
-
The provider's `ready()` answers whether the search a model request would make has a credential, on any model route: the
|
|
64
|
+
The provider's `ready()` answers whether the search a model request would make has a credential, on any model route: on the `deepseek-account` route the account sign-in is configured for the search endpoint, which requires that endpoint to be under the origin of that route's base URL, or a literal `apiKey` is set or `ctx.credentials.describe` reports the `apiKeyEnv` reference configured (without that service, the process environment must carry it). It checks them in the order a search resolves them, and a route whose settings do not resolve, or a failed account-credential or credential-store read, answers false, because the search fails there instead of trying the next credential. While this provider is the selected search provider, [`dsh-tool-web`](../tool-web/README.md#search-readiness) withholds `web_search` and its prompt guidance from each request for which it answers false. Only presence is checked: a wrong key, or an endpoint that does not serve the native `web_search_20250305` server tool, counts as ready and fails each call. A call that still arrives resolves credentials when it runs.
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
`ctx.deepseekAuth` reads referenced keys through the credential reference helpers of [`dsh-credentials`](../../credentials/credentials/README.md) and applies the same whitespace normalization and format validation as model requests. A malformed referenced key fails before dispatch; readiness remains a presence-only check.
|
|
66
67
|
|
|
67
68
|
### What a search returns
|
|
68
69
|
|
|
@@ -91,7 +92,7 @@ This section explains the design decisions behind the provider; the observable b
|
|
|
91
92
|
The provider is built on two commitments:
|
|
92
93
|
|
|
93
94
|
- **Structured blocks only.** DeepSeek runs the search server-side and returns structured `web_search_tool_result` blocks; the provider parses those blocks and never scrapes URLs out of model prose. In strict mode, a response with no such block throws `WEB_PROVIDER_ERROR` instead of degrading.
|
|
94
|
-
- **Conversation credentials, resolved per search.** The provider adds no secret: a search from a Session on the account route
|
|
95
|
+
- **Conversation credentials, resolved per search.** The provider adds no secret: a search from a Session on the account route, whose deployment has the search endpoint's origin, uses the account sign-in, and every other search reuses the `DEEPSEEK_API_KEY` reference. The auxiliary request endpoint stays independent through `$DEEPSEEK_SEARCH_BASE_URL`. A mounted credentials service is authoritative; without one the key is read from the launching process environment. Resolving per call means a key stored or rotated in the Web Models page, or an account sign-in, reaches the next search without a restart.
|
|
95
96
|
|
|
96
97
|
### Source map
|
|
97
98
|
|
|
@@ -103,9 +104,9 @@ The provider is built on two commitments:
|
|
|
103
104
|
|
|
104
105
|
### Request flow
|
|
105
106
|
|
|
106
|
-
Each search captures the current Config values into provider options — endpoint, model, key reference, limits — then asks `ctx.
|
|
107
|
+
Each search captures the current Config values into provider options — endpoint, model, key reference, limits — then asks [`ctx.deepseekAuth`](../../account/deepseek-auth/README.md) for the credential of the search endpoint, the account sign-in in a conversation on the account route and otherwise the referenced key read through `ctx.credentials` (or the environment), appends the log-only session event, and dispatches the Messages request with the native `web_search` server tool. The response's `web_search_tool_result` blocks become `sources[]`, each with its item's own snippet; `cited_text` entries from text blocks are joined by URL as the snippets of items without one; results are deduplicated by URL; and the service enforces the requested source bound on the way back.
|
|
107
108
|
|
|
108
|
-
Readiness captures the same options but reads no API key value: on the account route
|
|
109
|
+
Readiness captures the same options but reads no API key value: it asks each candidate `ctx.deepseekAuth` returns for the search, in order, whether its credential is configured, in a conversation on the account route first the account sign-in for the search endpoint and then the key reference through `ctx.credentials.describe()` (or the environment). A literal key always counts as configured.
|
|
109
110
|
|
|
110
111
|
</details>
|
|
111
112
|
|
|
@@ -147,7 +148,7 @@ Independent of the conversation request cache. The auxiliary instruction and nat
|
|
|
147
148
|
|
|
148
149
|
#### What the model sees
|
|
149
150
|
|
|
150
|
-
Through `dsh-tool-web`, the conversation model sees deduplicated URLs, titles, dates, and snippets from structured search blocks; provider prose is not trusted as an answer. This provider's exact failures include the actionable missing-credential message, which also names DeepSeek Account sign-in, `DeepSeek search credential resolution failed: <error>`, and `DeepSeek search aborted`. An HTTP 401 to an account-authenticated search appends an instruction to guide the user to sign in to DeepSeek again. Other request, HTTP, native-search, and response-body failures append the resolved endpoint and the conditional configuration instruction described above. The consumer owns the error wrapper.
|
|
151
|
+
Through `dsh-tool-web`, the conversation model sees deduplicated URLs, titles, dates, and snippets from structured search blocks; provider prose is not trusted as an answer. This provider's exact failures include the actionable missing-credential message, which also names DeepSeek Account sign-in, `DeepSeek search credential resolution failed: <error>`, and `DeepSeek search aborted`. An HTTP 401 to an account-authenticated search appends an instruction to guide the user to sign in to DeepSeek again. A search the account's sign-out ended reports `The DeepSeek account signed out before this web search finished. Guide the user to sign in to DeepSeek again; the search endpoint does not need changing.` Other request, HTTP, native-search, and response-body failures append the resolved endpoint and the conditional configuration instruction described above. The consumer owns the error wrapper.
|
|
151
152
|
|
|
152
153
|
#### Token effect
|
|
153
154
|
|
package/README.zh.md
CHANGED
|
@@ -25,7 +25,7 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
在已加载 web
|
|
28
|
+
在已加载 web 服务和为它释放凭据的 [`dsh-deepseek-auth`](../../account/deepseek-auth/README.zh.md) 的组合中挂载本提供方;它以 `deepseek-official` 搜索提供方身份注册,因此当它是唯一可用的搜索后端时,`ctx.web.search()` 会自动解析到它;没有配置搜索提供方时,为 `deepseek-official` 或 `deepseek-account` 模型路由上的模型请求发起的搜索也解析到它([提供方选择](../web/README.zh.md#provider-selection))——也可以用 `searchProvider: deepseek-official` 固定。
|
|
29
29
|
|
|
30
30
|
### 何时选择
|
|
31
31
|
|
|
@@ -33,10 +33,11 @@ kind: "package-reference"
|
|
|
33
33
|
|
|
34
34
|
### 最小配置
|
|
35
35
|
|
|
36
|
-
加载 web
|
|
36
|
+
加载 web 服务、DeepSeek 鉴权服务与本提供方;密钥在已挂载 `ctx.credentials` 服务时从其解析,否则从进程环境解析。辅助搜索调用有独立的端点设置,使用 Anthropic 兼容基址 `https://api.deepseek.com/anthropic/v1`,并追加 `/messages`。它读取 `$DEEPSEEK_SEARCH_BASE_URL`,与会话适配器的 `$DEEPSEEK_BASE_URL` 相互独立;`dsh` 启动器从启动环境或 `$DSH_HOME/.env` 接受这两个变量,绝不从项目 `.env` 接受([app-boot](../../boot/app-boot/README.zh.md))。
|
|
37
37
|
|
|
38
38
|
```yaml
|
|
39
39
|
- name: '@deepseek-ai/dsh-web'
|
|
40
|
+
- name: '@deepseek-ai/dsh-deepseek-auth'
|
|
40
41
|
- name: '@deepseek-ai/dsh-web-search-deepseek'
|
|
41
42
|
config:
|
|
42
43
|
apiKeyEnv: DEEPSEEK_API_KEY
|
|
@@ -58,11 +59,11 @@ kind: "package-reference"
|
|
|
58
59
|
<a id="authentication"></a>
|
|
59
60
|
### 鉴权
|
|
60
61
|
|
|
61
|
-
当发起会话最近的 `request/context` 事件指明 `deepseek-account`
|
|
62
|
+
当发起会话最近的 `request/context` 事件指明 `deepseek-account` 模型路由,搜索端点与该路由的基础地址同源,且 `ctx.deepseekAuth` 为搜索端点释放了账号登录凭据时,搜索使用 DeepSeek 账号鉴权。只有同源时才会索取该凭据,因此它不会发往其他部署的搜索端点。账号服务仅在已登录时、且仅对部署配置的推理 origin(默认 `https://api.deepseek.com`)释放凭据。这类搜索只发送该凭据的请求头 `x-dsh-auth-token`,即使配置了 API 密钥也是如此。其余所有搜索,包括没有发起会话的调用以及端点属于其他 origin 的搜索,都把 API 密钥同时作为 `x-api-key` 与 `Authorization: Bearer` 发送。账号鉴权的搜索收到 HTTP 401 时以 `WEB_PROVIDER_ERROR` 失败,附带登录指引而非端点指引,并通过凭据自身的失效操作只作废该搜索实际发送的凭据:更新的登录不受影响,凭据删除失败或错误正文读取被取消既不会跳过作废,也不会替换所报告的失败。API 密钥请求的 401 与所有 HTTP 403 不影响账号登录状态。账号退登时仍在途的账号鉴权搜索会通过凭据的 `revoked` 信号结束,并以 `WEB_PROVIDER_ERROR` 失败,附带登录指引。
|
|
62
63
|
|
|
63
|
-
提供方的 `ready()`
|
|
64
|
+
提供方的 `ready()` 回答模型请求将发起的搜索是否有凭据,不论模型路由:在 `deepseek-account` 路由上账号登录凭据已为搜索端点配置(这要求该端点位于该路由基础地址的 origin 之下),或者设置了字面 `apiKey`,或 `ctx.credentials.describe` 报告 `apiKeyEnv` 引用已配置(没有该服务时,进程环境中必须存在该变量)。它按搜索解析凭据的顺序检查;路由设置无法解析,或读取账号凭据或凭据存储失败时回答 false,因为搜索会在那里失败,而不会尝试下一种凭据。本提供方是选中的搜索提供方时,[`dsh-tool-web`](../tool-web/README.zh.md#search-readiness) 会从它回答 false 的每个请求中撤下 `web_search` 及其提示词说明。这里只检查凭据是否存在:错误的密钥,或不提供原生 `web_search_20250305` 服务器工具的端点,都视为就绪并使每次调用失败。仍然到达的调用会在运行时解析凭据。
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
引用密钥由 `ctx.deepseekAuth` 通过 [`dsh-credentials`](../../credentials/credentials/README.zh.md) 的凭据引用函数读取,接受与模型请求相同的首尾空白规范化和格式校验。引用密钥格式错误会在发送请求前失败;就绪判断仍只检查是否存在。
|
|
66
67
|
|
|
67
68
|
### 搜索返回什么
|
|
68
69
|
|
|
@@ -91,7 +92,7 @@ kind: "package-reference"
|
|
|
91
92
|
本提供方建立在两项承诺之上:
|
|
92
93
|
|
|
93
94
|
- **只取结构化块。** DeepSeek 在服务端执行搜索并返回结构化的 `web_search_tool_result` 块;提供方解析这些块,绝不从模型文本中抓取 URL。严格模式下,没有此类块的响应会抛出 `WEB_PROVIDER_ERROR`,而非降级。
|
|
94
|
-
- **会话凭据,逐次解析。**
|
|
95
|
+
- **会话凭据,逐次解析。** 提供方不新增密钥:发起会话位于账号路由且该路由的部署与搜索端点同源时,搜索使用账号登录凭据,其余搜索复用 `DEEPSEEK_API_KEY` 引用。辅助请求端点通过 `$DEEPSEEK_SEARCH_BASE_URL` 保持独立。已挂载的凭据服务具有权威性;没有该服务时回退到启动进程的环境。按次解析意味着在 Web 的 Models 页中存储或轮换的密钥,或一次账号登录,无需重启即可用于下一次搜索。
|
|
95
96
|
|
|
96
97
|
### 源码地图
|
|
97
98
|
|
|
@@ -103,9 +104,9 @@ kind: "package-reference"
|
|
|
103
104
|
|
|
104
105
|
### 请求流程
|
|
105
106
|
|
|
106
|
-
每次搜索先把当前 Config
|
|
107
|
+
每次搜索先把当前 Config 段投影为提供方选项——端点、模型、密钥引用、上限——然后向 [`ctx.deepseekAuth`](../../account/deepseek-auth/README.zh.md) 索取搜索端点的凭据:账号路由上的会话取账号登录凭据,否则取经由 `ctx.credentials`(或环境)读取的引用密钥,追加仅用于日志的会话事件,并以原生 `web_search` 服务器工具分发 Messages 请求。响应中的 `web_search_tool_result` 块变为 `sources[]`,各带其条目自带的 snippet;文本块中的 `cited_text` 条目按 URL 关联,作为没有 snippet 的条目的 snippet;结果按 URL 去重;服务在返回路径上强制执行请求的来源上限。
|
|
107
108
|
|
|
108
|
-
就绪判断捕获相同的选项,但不读取 API
|
|
109
|
+
就绪判断捕获相同的选项,但不读取 API 密钥的值:它依次询问 `ctx.deepseekAuth` 为这次搜索返回的每个候选其凭据是否已配置,在账号路由上的会话里先是面向搜索端点的账号登录凭据,然后经由 `ctx.credentials.describe()`(或环境)询问密钥引用。字面密钥总是算作已配置。
|
|
109
110
|
|
|
110
111
|
</details>
|
|
111
112
|
|
|
@@ -147,7 +148,7 @@ kind: "package-reference"
|
|
|
147
148
|
|
|
148
149
|
#### 模型看到的内容
|
|
149
150
|
|
|
150
|
-
通过 `dsh-tool-web`,会话模型会看到结构化搜索块中去重后的 URL、标题、日期与 snippet;提供方文本不会作为答案受到信任。该提供方的具体失败消息包括带有处理指引的凭据缺失消息(其中也提到 DeepSeek 账号登录)、`DeepSeek search credential resolution failed: <error>` 和 `DeepSeek search aborted`。账号鉴权的搜索收到 HTTP 401 时,会追加引导用户重新登录 DeepSeek
|
|
151
|
+
通过 `dsh-tool-web`,会话模型会看到结构化搜索块中去重后的 URL、标题、日期与 snippet;提供方文本不会作为答案受到信任。该提供方的具体失败消息包括带有处理指引的凭据缺失消息(其中也提到 DeepSeek 账号登录)、`DeepSeek search credential resolution failed: <error>` 和 `DeepSeek search aborted`。账号鉴权的搜索收到 HTTP 401 时,会追加引导用户重新登录 DeepSeek 的指引。被账号退登结束的搜索报告 `The DeepSeek account signed out before this web search finished. Guide the user to sign in to DeepSeek again; the search endpoint does not need changing.` 其他请求、HTTP、原生搜索和响应正文失败会追加已解析端点及前述条件式配置指引。错误包装属于消费方。
|
|
151
152
|
|
|
152
153
|
#### Token 影响
|
|
153
154
|
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
3
3
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
4
|
-
import { deepSeekApiKeyConfigured, rejectDeepSeekAccountToken, resolveDeepSeekAccountToken, resolveDeepSeekApiKey } from "@deepseek-ai/dsh-llm-deepseek";
|
|
5
4
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
6
5
|
//#region lib/types/provider.js
|
|
7
6
|
/**
|
|
@@ -110,7 +109,7 @@ var DeepSeekSearchProvider = class {
|
|
|
110
109
|
}
|
|
111
110
|
available() {
|
|
112
111
|
const options = this.resolveOptions();
|
|
113
|
-
return ((options.apiKey?.length ?? 0) > 0 || options.
|
|
112
|
+
return ((options.apiKey?.length ?? 0) > 0 || options.authorize !== void 0) && dispatchable(options.baseURL) && isPositiveInteger(options.maxTokens) && isPositiveInteger(options.maxUses);
|
|
114
113
|
}
|
|
115
114
|
async search(request, signal) {
|
|
116
115
|
const options = this.resolveOptions();
|
|
@@ -141,6 +140,17 @@ var DeepSeekSearchProvider = class {
|
|
|
141
140
|
});
|
|
142
141
|
throwIfSearchAborted(signal);
|
|
143
142
|
let response;
|
|
143
|
+
const live = requestSignal(signal, auth.revoked);
|
|
144
|
+
/**
|
|
145
|
+
* The failure of an interrupted request: the caller's cancellation first, then the sign-out of the sent account.
|
|
146
|
+
* @param error - what the interrupted fetch or body read threw.
|
|
147
|
+
* @returns the failure to report, or undefined when `error` is no interruption.
|
|
148
|
+
*/
|
|
149
|
+
const interrupted = (error) => {
|
|
150
|
+
if (signal?.aborted === true) return searchAborted(signal, error);
|
|
151
|
+
if (auth.revoked?.aborted === true) return accountSignedOutError(error);
|
|
152
|
+
return isAbortError(error) ? searchAborted(signal, error) : void 0;
|
|
153
|
+
};
|
|
144
154
|
try {
|
|
145
155
|
response = await fetch(endpoint, {
|
|
146
156
|
method: "POST",
|
|
@@ -153,11 +163,10 @@ var DeepSeekSearchProvider = class {
|
|
|
153
163
|
"user-agent": USER_AGENT
|
|
154
164
|
},
|
|
155
165
|
body: JSON.stringify(body),
|
|
156
|
-
...
|
|
166
|
+
...live !== void 0 ? { signal: live } : {}
|
|
157
167
|
});
|
|
158
168
|
} catch (error) {
|
|
159
|
-
|
|
160
|
-
throw searchEndpointError(endpoint, `DeepSeek search request failed: ${String(error)}`, error);
|
|
169
|
+
throw interrupted(error) ?? searchEndpointError(endpoint, `DeepSeek search request failed: ${String(error)}`, error);
|
|
161
170
|
}
|
|
162
171
|
if (!response.ok) {
|
|
163
172
|
const status = response.status;
|
|
@@ -168,12 +177,12 @@ var DeepSeekSearchProvider = class {
|
|
|
168
177
|
const detail = typeof parsed.error === "string" ? parsed.error : parsed.error?.message ?? parsed.message;
|
|
169
178
|
if (detail !== void 0 && detail.length > 0) message += `: ${detail}`;
|
|
170
179
|
} catch (error) {
|
|
171
|
-
|
|
180
|
+
aborted = interrupted(error);
|
|
172
181
|
}
|
|
173
182
|
if (status === 401 && auth.kind === "account") {
|
|
174
183
|
try {
|
|
175
184
|
await auth.reject?.();
|
|
176
|
-
} catch (
|
|
185
|
+
} catch (_invalidationFailed) {}
|
|
177
186
|
throw aborted ?? accountRejectedError(message);
|
|
178
187
|
}
|
|
179
188
|
if (aborted !== void 0) throw aborted;
|
|
@@ -182,46 +191,30 @@ var DeepSeekSearchProvider = class {
|
|
|
182
191
|
try {
|
|
183
192
|
return mapAnthropicResponse(await response.json());
|
|
184
193
|
} catch (error) {
|
|
185
|
-
|
|
194
|
+
const stopped = interrupted(error);
|
|
195
|
+
if (stopped !== void 0) throw stopped;
|
|
186
196
|
throw searchEndpointError(endpoint, error instanceof WebError ? error.message : `DeepSeek returned an unprocessable response body: ${String(error)}`, error);
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
199
|
/**
|
|
190
|
-
* Resolve one operation's
|
|
200
|
+
* Resolve one operation's credential without retaining it on the provider.
|
|
191
201
|
* @param options - the caller's snapshot, so the credential and the endpoint it is sent to come from one section.
|
|
192
202
|
* @param endpoint - the Messages endpoint this operation dispatches to.
|
|
193
203
|
* @param signal - abort signal for the surrounding search.
|
|
194
|
-
* @returns the
|
|
204
|
+
* @returns the released credential when one resolves, otherwise the literal key in both API-key headers.
|
|
195
205
|
*/
|
|
196
206
|
async authHeaders(options, endpoint, signal) {
|
|
197
|
-
const {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
...rejectAccountToken === void 0 ? {} : { reject: () => rejectAccountToken(token) }
|
|
203
|
-
};
|
|
204
|
-
const apiKey = await this.apiKey(options, signal);
|
|
205
|
-
return {
|
|
207
|
+
const { authorize, apiKey } = options;
|
|
208
|
+
const released = authorize === void 0 ? void 0 : await resolveCredential(() => authorize(endpoint, signal), signal);
|
|
209
|
+
if (released !== void 0) return released;
|
|
210
|
+
throwIfSearchAborted(signal);
|
|
211
|
+
if (apiKey !== void 0 && apiKey.length > 0) return {
|
|
206
212
|
kind: "api-key",
|
|
207
213
|
headers: {
|
|
208
214
|
"x-api-key": apiKey,
|
|
209
215
|
"authorization": `Bearer ${apiKey}`
|
|
210
216
|
}
|
|
211
217
|
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Resolve one operation's API key without retaining it on the provider.
|
|
215
|
-
* @param options - the caller's snapshot, so the key and the endpoint it is sent to come from one section.
|
|
216
|
-
* @param signal - abort signal for the surrounding search.
|
|
217
|
-
* @returns the resolved key.
|
|
218
|
-
*/
|
|
219
|
-
async apiKey(options, signal) {
|
|
220
|
-
throwIfSearchAborted(signal);
|
|
221
|
-
if (options.apiKey !== void 0 && options.apiKey.length > 0) return options.apiKey;
|
|
222
|
-
const { resolveApiKey } = options;
|
|
223
|
-
const resolved = resolveApiKey === void 0 ? void 0 : await resolveCredential(resolveApiKey, signal);
|
|
224
|
-
if (resolved !== void 0 && resolved.length > 0) return resolved;
|
|
225
218
|
throw new WebError(`DeepSeek search has no API key for "${options.apiKeyEnv ?? "DEEPSEEK_API_KEY"}"; store it through the credentials service (the web Models page writes it), export it in the launching environment, or set a literal "apiKey" in the web-search-deepseek config; a conversation using a DeepSeek Account model searches with the account sign-in instead`, "WEB_PROVIDER_CREDENTIAL_MISSING");
|
|
226
219
|
}
|
|
227
220
|
};
|
|
@@ -242,6 +235,25 @@ async function resolveCredential(resolve, signal) {
|
|
|
242
235
|
throw new WebError(`DeepSeek search credential resolution failed: ${String(error)}`, "WEB_PROVIDER_ERROR", { cause: error });
|
|
243
236
|
}
|
|
244
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* The signal one search runs under: the caller's cancellation and the sign-out of the account credential it carries.
|
|
240
|
+
* @param signal - caller cancellation, when the caller supplies one.
|
|
241
|
+
* @param revoked - sign-out of the sent account credential, when its authorization offers one.
|
|
242
|
+
* @returns the composed signal, or undefined when neither exists.
|
|
243
|
+
*/
|
|
244
|
+
function requestSignal(signal, revoked) {
|
|
245
|
+
if (signal === void 0 || revoked === void 0) return signal ?? revoked;
|
|
246
|
+
return AbortSignal.any([signal, revoked]);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Report a search that ended because the account it authenticated with signed out. The caller did not cancel, so the
|
|
250
|
+
* failure is the provider's.
|
|
251
|
+
* @param cause - what the interrupted fetch or body read threw.
|
|
252
|
+
* @returns the provider failure with sign-in guidance.
|
|
253
|
+
*/
|
|
254
|
+
function accountSignedOutError(cause) {
|
|
255
|
+
return new WebError("The DeepSeek account signed out before this web search finished. Guide the user to sign in to DeepSeek again; the search endpoint does not need changing.", "WEB_PROVIDER_ERROR", { cause });
|
|
256
|
+
}
|
|
245
257
|
/** Replace endpoint guidance with sign-in guidance when DeepSeek rejects the account token. */
|
|
246
258
|
function accountRejectedError(message) {
|
|
247
259
|
return new WebError(`${message}\n\nDeepSeek rejected the account sign-in used for this web search. Guide the user to sign in to DeepSeek again; the search endpoint does not need changing.`, "WEB_PROVIDER_ERROR");
|
|
@@ -257,7 +269,10 @@ function searchEndpointError(endpoint, message, cause) {
|
|
|
257
269
|
*/
|
|
258
270
|
function abortable(operation, signal) {
|
|
259
271
|
if (signal === void 0) return operation;
|
|
260
|
-
if (signal.aborted)
|
|
272
|
+
if (signal.aborted) {
|
|
273
|
+
operation.catch(() => {});
|
|
274
|
+
return Promise.reject(searchAborted(signal));
|
|
275
|
+
}
|
|
261
276
|
return new Promise((resolve, reject) => {
|
|
262
277
|
const onAbort = () => {
|
|
263
278
|
reject(searchAborted(signal));
|
|
@@ -284,6 +299,12 @@ function searchAborted(signal, fallback) {
|
|
|
284
299
|
function isAbortError(error) {
|
|
285
300
|
return error instanceof DOMException && error.name === "AbortError";
|
|
286
301
|
}
|
|
302
|
+
/** True for a base URL a search can be sent to: it parses and embeds no credentials, which `fetch` refuses to send. */
|
|
303
|
+
function dispatchable(baseURL) {
|
|
304
|
+
if (!URL.canParse(baseURL)) return false;
|
|
305
|
+
const { username, password } = new URL(baseURL);
|
|
306
|
+
return username === "" && password === "";
|
|
307
|
+
}
|
|
287
308
|
/** True for DeepSeek request limits that can be sent to the Messages API. */
|
|
288
309
|
function isPositiveInteger(value) {
|
|
289
310
|
return Number.isInteger(value) && value > 0;
|
|
@@ -292,8 +313,8 @@ function isPositiveInteger(value) {
|
|
|
292
313
|
//#region lib/types/index.js
|
|
293
314
|
/** Cordis plugin name used by loader diagnostics. */
|
|
294
315
|
const name = "web-search-deepseek";
|
|
295
|
-
/** The web seam this provider registers into. */
|
|
296
|
-
const inject = ["web"];
|
|
316
|
+
/** The web seam this provider registers into, and the DeepSeek authentication its searches ask for credentials. */
|
|
317
|
+
const inject = ["web", "deepseekAuth"];
|
|
297
318
|
const Config = z.object({
|
|
298
319
|
apiKey: z.string().role("secret").volatile(),
|
|
299
320
|
apiKeyEnv: z.string().role("credential-ref").default("DEEPSEEK_API_KEY").volatile(),
|
|
@@ -308,31 +329,46 @@ const Config = z.object({
|
|
|
308
329
|
* `$DEEPSEEK_BASE_URL` and selected protocol.
|
|
309
330
|
*/
|
|
310
331
|
const SEARCH_BASE_URL_ENV = "DEEPSEEK_SEARCH_BASE_URL";
|
|
311
|
-
/** Provider route id `dsh-llm-deepseek-account` registers; `request/context` events record it per Session. */
|
|
312
|
-
const ACCOUNT_PROVIDER = "deepseek-account";
|
|
313
332
|
/** Settings namespace carrying this provider's endpoint, model, and key reference. */
|
|
314
333
|
const WEB_SEARCH_DEEPSEEK_SETTINGS_NAMESPACE = "web-search-deepseek";
|
|
315
334
|
/**
|
|
316
335
|
* Project one resolved section into the options the provider serves its next
|
|
317
336
|
* search with. Environment fallbacks stay here rather than in the provider:
|
|
318
337
|
* every value it reads is already fully defaulted.
|
|
319
|
-
* @param ctx - plugin context supplying the
|
|
338
|
+
* @param ctx - plugin context supplying the DeepSeek authentication, the Agent registry, and the environment.
|
|
320
339
|
* @param config - the currently authoritative section.
|
|
321
340
|
* @returns options for one search.
|
|
322
341
|
*/
|
|
323
342
|
function resolveOptions(ctx, config) {
|
|
324
|
-
const
|
|
343
|
+
const reference = credentialRef(config.apiKeyEnv);
|
|
325
344
|
const literalApiKey = config.apiKey !== void 0 && config.apiKey.length > 0 ? config.apiKey : void 0;
|
|
345
|
+
const baseURL = config.baseURL ?? launchEnvironmentOf(ctx).get(SEARCH_BASE_URL_ENV)?.value ?? "https://api.deepseek.com/anthropic/v1";
|
|
346
|
+
const authRequest = (route, endpoint) => {
|
|
347
|
+
const accountConversation = ctx.deepseekAuth.routeKind(route) === "account";
|
|
348
|
+
if (literalApiKey !== void 0 && !accountConversation) return void 0;
|
|
349
|
+
return {
|
|
350
|
+
consumer: name,
|
|
351
|
+
accepts: literalApiKey === void 0 ? ["account", "api-key"] : ["account"],
|
|
352
|
+
billing: accountConversation ? "auto" : "api-key",
|
|
353
|
+
route,
|
|
354
|
+
destination: { url: endpoint },
|
|
355
|
+
connections: { "api-key": {
|
|
356
|
+
baseURL,
|
|
357
|
+
reference
|
|
358
|
+
} },
|
|
359
|
+
apiKeyHeaders: ["x-api-key", "authorization"]
|
|
360
|
+
};
|
|
361
|
+
};
|
|
326
362
|
return {
|
|
327
363
|
...literalApiKey === void 0 ? {} : { apiKey: literalApiKey },
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
364
|
+
authRequest,
|
|
365
|
+
authorize: async (endpoint, signal) => {
|
|
366
|
+
const route = ctx.get("agents")?.currentInitiator()?.session.requestContext()?.provider;
|
|
367
|
+
const request = authRequest(route, endpoint);
|
|
368
|
+
return request === void 0 ? void 0 : await ctx.deepseekAuth.authorize(request, signal);
|
|
331
369
|
},
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
apiKeyEnv,
|
|
335
|
-
baseURL: config.baseURL ?? launchEnvironmentOf(ctx).get(SEARCH_BASE_URL_ENV)?.value ?? "https://api.deepseek.com/anthropic/v1",
|
|
370
|
+
apiKeyEnv: reference,
|
|
371
|
+
baseURL,
|
|
336
372
|
model: config.model,
|
|
337
373
|
apiVersion: config.apiVersion,
|
|
338
374
|
maxTokens: config.maxTokens,
|
|
@@ -344,32 +380,27 @@ function resolveOptions(ctx, config) {
|
|
|
344
380
|
}
|
|
345
381
|
/**
|
|
346
382
|
* Whether the search a model request on `route` would make has a credential, checked in the order
|
|
347
|
-
* the search resolves them: the account
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
383
|
+
* the search resolves them: on the account route the account sign-in, when the search endpoint has the
|
|
384
|
+
* origin of that route's base URL, then the API key. A route whose settings do not resolve, or a failed
|
|
385
|
+
* read, answers false, because the search fails there instead of trying the next credential. Only
|
|
386
|
+
* presence is checked: the API key's value is not read and the endpoint is not contacted, so a wrong
|
|
387
|
+
* key or an endpoint without native search still counts as configured.
|
|
388
|
+
* @param ctx - plugin context supplying the DeepSeek authentication.
|
|
352
389
|
* @param options - options the next search would use.
|
|
353
390
|
* @param route - provider route of the model request being assembled.
|
|
354
|
-
* @returns whether the account
|
|
391
|
+
* @returns whether the account sign-in or an API key is available to that search.
|
|
355
392
|
*/
|
|
356
393
|
async function searchConfigured(ctx, options, route) {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
394
|
+
const request = options.authRequest(route, `${options.baseURL}/messages`);
|
|
395
|
+
for (const candidate of request === void 0 ? [] : ctx.deepseekAuth.candidates(request)) {
|
|
396
|
+
if ("unresolved" in candidate) return false;
|
|
360
397
|
try {
|
|
361
|
-
|
|
362
|
-
} catch (
|
|
398
|
+
if (await candidate.configured()) return true;
|
|
399
|
+
} catch (_unreadableCredential) {
|
|
363
400
|
return false;
|
|
364
401
|
}
|
|
365
|
-
if (token !== void 0 && token.length > 0) return true;
|
|
366
|
-
}
|
|
367
|
-
if (options.apiKey !== void 0) return true;
|
|
368
|
-
try {
|
|
369
|
-
return await deepSeekApiKeyConfigured(ctx, options.apiKeyEnv);
|
|
370
|
-
} catch (_unreadableStore) {
|
|
371
|
-
return false;
|
|
372
402
|
}
|
|
403
|
+
return options.apiKey !== void 0;
|
|
373
404
|
}
|
|
374
405
|
/**
|
|
375
406
|
* Register the DeepSeek search provider with `ctx.web`. Its `ready()` answers whether a
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Register a DeepSeek-backed provider in `ctx.web`. It calls the Anthropic-compatible Messages API
|
|
3
|
-
* with native `web_search_20250305`.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* with native `web_search_20250305`. `ctx.deepseekAuth` releases its credential: a search initiated by
|
|
4
|
+
* a Session whose latest model request used the DeepSeek account route authenticates with the account
|
|
5
|
+
* sign-in when the search endpoint has the origin of that route's base URL and the account service
|
|
6
|
+
* allows the endpoint; every other search reuses `DEEPSEEK_API_KEY`. The provider
|
|
7
|
+
* does not reuse `DEEPSEEK_BASE_URL`; auxiliary search has its own endpoint configuration. The
|
|
8
|
+
* provider reports itself not ready for a model request whose search would have no credential.
|
|
8
9
|
* @module @deepseek-ai/dsh-web-search-deepseek
|
|
9
10
|
*/
|
|
10
11
|
import type { Volatile } from '@deepseek-ai/cordis';
|
|
@@ -14,7 +15,7 @@ export { DeepSeekSearchProvider, DEEPSEEK_DEFAULT_API_VERSION, DEEPSEEK_DEFAULT_
|
|
|
14
15
|
export type { DeepSeekSearchLlmRequest, DeepSeekSearchProviderOptions } from './provider.ts';
|
|
15
16
|
/** Cordis plugin name used by loader diagnostics. */
|
|
16
17
|
export declare const name = "web-search-deepseek";
|
|
17
|
-
/** The web seam this provider registers into. */
|
|
18
|
+
/** The web seam this provider registers into, and the DeepSeek authentication its searches ask for credentials. */
|
|
18
19
|
export declare const inject: string[];
|
|
19
20
|
/** Plugin config (all optional — `apply` fills env-var and constant defaults). */
|
|
20
21
|
export interface Config {
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAiBxC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAE5F,qDAAqD;AACrD,eAAO,MAAM,IAAI,wBAAwB,CAAA;AAEzC,mHAAmH;AACnH,eAAO,MAAM,MAAM,UAA0B,CAAA;AAI7C,kFAAkF;AAClF,MAAM,WAAW,MAAM;IACrB,kGAAkG;IAClG,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACpC,qFAAqF;IACrF,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,mEAAmE;IACnE,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACrC,oEAAoE;IACpE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACvB,kEAAkE;IAClE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5B,kFAAkF;IAClF,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,wEAAwE;IACxE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAC1B;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;aAWjB,CAAA;AAQF,sFAAsF;AACtF,eAAO,MAAM,sCAAsC,wBAAwB,CAAA;AAgG3E;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAaxD"}
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAGzE,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAGtB,qDAAqD;AACrD,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AAEzC,mHAAmH;AACnH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;AAE7C,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AAoB9C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,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OAAO,OAAO,CAAC,MAAM,KAAK,SAAS,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE;QACxC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;QACxH,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;KACtG,CAAC,CAAA;IACF,MAAM,QAAQ,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAA;IACpD,GAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC7B,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE;QACrC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,WAAW,CAAC;QACnE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC;KAC9D,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/types/provider.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { WebSearchProvider, WebSearchRequest, WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
9
9
|
import type { CredentialRef } from '@deepseek-ai/dsh-credentials';
|
|
10
|
+
import type { DeepSeekAuthorization } from '@deepseek-ai/dsh-deepseek-auth';
|
|
10
11
|
import type { AnthropicResponse, ContentBlock } from './types.ts';
|
|
11
12
|
/** Stable id this provider registers under. */
|
|
12
13
|
export declare const DEEPSEEK_PROVIDER_ID = "deepseek-official";
|
|
@@ -75,17 +76,16 @@ declare module '@deepseek-ai/dsh-session/types' {
|
|
|
75
76
|
/** Resolved provider options (the plugin's `apply` supplies credential and constant defaults). */
|
|
76
77
|
export interface DeepSeekSearchProviderOptions {
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Release the credential `ctx.deepseekAuth` binds to one search endpoint: the account sign-in in a
|
|
80
|
+
* conversation the account bills, otherwise the referenced API key. A released credential takes
|
|
81
|
+
* precedence over the literal {@link apiKey} and is sent only through its headers. An account
|
|
82
|
+
* sign-in is invalidated through `reject` after HTTP 401; a failure of that invalidation is
|
|
83
|
+
* contained, and the search reports the HTTP rejection. Its `revoked` signal ends the search when
|
|
84
|
+
* the account signs out. `undefined` selects the literal key.
|
|
81
85
|
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
rejectAccountToken?: (token: string) => Promise<void>;
|
|
85
|
-
/** Literal DeepSeek API key; when present it wins over {@link resolveApiKey}. */
|
|
86
|
+
authorize?: (endpoint: string, signal?: AbortSignal) => Promise<SearchAuth | undefined>;
|
|
87
|
+
/** Literal DeepSeek API key, sent when {@link authorize} releases no credential. */
|
|
86
88
|
apiKey?: string;
|
|
87
|
-
/** Resolve the current DeepSeek API key for one search operation. */
|
|
88
|
-
resolveApiKey?: () => Promise<string | undefined>;
|
|
89
89
|
/** Credential reference named by missing-credential diagnostics. */
|
|
90
90
|
apiKeyEnv?: CredentialRef;
|
|
91
91
|
/** Endpoint base; `/messages` is appended. */
|
|
@@ -126,6 +126,11 @@ export declare function citationSnippets(blocks: readonly ContentBlock[]): Map<s
|
|
|
126
126
|
* @throws {@link WebError} when native search produced no result block.
|
|
127
127
|
*/
|
|
128
128
|
export declare function mapAnthropicResponse(response: AnthropicResponse): WebSearchResult;
|
|
129
|
+
/**
|
|
130
|
+
* The credential one search sends, tagged by its kind: the fields the search reads of an authorization
|
|
131
|
+
* `ctx.deepseekAuth` releases. `reject` invalidates a sent account sign-in, and `revoked` ends the request at sign-out.
|
|
132
|
+
*/
|
|
133
|
+
type SearchAuth = Pick<DeepSeekAuthorization, 'kind' | 'headers' | 'reject' | 'revoked'>;
|
|
129
134
|
/**
|
|
130
135
|
* The DeepSeek-backed search provider. HTTP redirects fail as `WEB_PROVIDER_ERROR`;
|
|
131
136
|
* failures after dispatch name the endpoint and tell the model how the user can configure it.
|
|
@@ -146,19 +151,13 @@ export declare class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
146
151
|
available(): boolean;
|
|
147
152
|
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
148
153
|
/**
|
|
149
|
-
* Resolve one operation's
|
|
154
|
+
* Resolve one operation's credential without retaining it on the provider.
|
|
150
155
|
* @param options - the caller's snapshot, so the credential and the endpoint it is sent to come from one section.
|
|
151
156
|
* @param endpoint - the Messages endpoint this operation dispatches to.
|
|
152
157
|
* @param signal - abort signal for the surrounding search.
|
|
153
|
-
* @returns the
|
|
158
|
+
* @returns the released credential when one resolves, otherwise the literal key in both API-key headers.
|
|
154
159
|
*/
|
|
155
160
|
private authHeaders;
|
|
156
|
-
/**
|
|
157
|
-
* Resolve one operation's API key without retaining it on the provider.
|
|
158
|
-
* @param options - the caller's snapshot, so the key and the endpoint it is sent to come from one section.
|
|
159
|
-
* @param signal - abort signal for the surrounding search.
|
|
160
|
-
* @returns the resolved key.
|
|
161
|
-
*/
|
|
162
|
-
private apiKey;
|
|
163
161
|
}
|
|
162
|
+
export {};
|
|
164
163
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAEhB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAEhB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAE3E,OAAO,KAAK,EAEV,iBAAiB,EACjB,YAAY,EAGb,MAAM,YAAY,CAAA;AAEnB,+CAA+C;AAC/C,eAAO,MAAM,oBAAoB,sBAAsB,CAAA;AAEvD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,0CAA0C,CAAA;AAEhF,+FAA+F;AAC/F,eAAO,MAAM,sBAAsB,sBAAsB,CAAA;AAEzD,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,eAAe,CAAA;AAExD,wEAAwE;AACxE,eAAO,MAAM,2BAA2B,OAAO,CAAA;AAE/C,iEAAiE;AACjE,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAK1C;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;QAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS;YA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description": "DeepSeek-backed search provider (native web_search via the Anthropic-compatible API) for the DeepSeek Harness web capability seam (ctx.web)",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,33 +32,30 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/
|
|
36
|
-
"@deepseek-ai/dsh-
|
|
37
|
-
"@deepseek-ai/dsh-
|
|
38
|
-
"@deepseek-ai/dsh-launch-environment": "0.2.
|
|
39
|
-
"@deepseek-ai/dsh-
|
|
40
|
-
"@deepseek-ai/dsh-
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/cordis": "~4.1.0"
|
|
35
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
36
|
+
"@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
|
|
37
|
+
"@deepseek-ai/dsh-credentials": "0.2.3-alpha.1",
|
|
38
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.3-alpha.1",
|
|
39
|
+
"@deepseek-ai/dsh-session": "0.2.3-alpha.1",
|
|
40
|
+
"@deepseek-ai/dsh-web": "0.2.3-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-deepseek-auth": "0.2.3-alpha.1"
|
|
43
42
|
},
|
|
44
43
|
"dependencies": {
|
|
45
44
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
49
|
-
"@deepseek-ai/dsh-credentials": "0.2.2-rc.5",
|
|
50
|
-
"@deepseek-ai/dsh-credentials-local": "0.2.2-rc.5",
|
|
51
|
-
"@deepseek-ai/dsh-deepseek-account": "0.2.2-rc.5",
|
|
52
|
-
"@deepseek-ai/dsh-launch-environment": "0.2.2-rc.5",
|
|
53
|
-
"@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.5",
|
|
54
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
55
|
-
"@deepseek-ai/dsh-web": "0.2.2-rc.5",
|
|
56
47
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
"@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
|
|
49
|
+
"@deepseek-ai/dsh-brand": "0.2.3-alpha.1",
|
|
50
|
+
"@deepseek-ai/dsh-credentials": "0.2.3-alpha.1",
|
|
51
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.3-alpha.1",
|
|
52
|
+
"@deepseek-ai/dsh-deepseek-account": "0.2.3-alpha.1",
|
|
53
|
+
"@deepseek-ai/dsh-http-proxy": "0.2.3-alpha.1",
|
|
54
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.3-alpha.1",
|
|
55
|
+
"@deepseek-ai/dsh-llm": "0.2.3-alpha.1",
|
|
56
|
+
"@deepseek-ai/dsh-llm-deepseek-account": "0.2.3-alpha.1",
|
|
57
|
+
"@deepseek-ai/dsh-session": "0.2.3-alpha.1",
|
|
58
|
+
"@deepseek-ai/dsh-web": "0.2.3-alpha.1",
|
|
59
|
+
"@deepseek-ai/dsh-deepseek-auth": "0.2.3-alpha.1"
|
|
63
60
|
}
|
|
64
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Register a DeepSeek-backed provider in `ctx.web`. It calls the Anthropic-compatible Messages API
|
|
3
|
-
* with native `web_search_20250305`.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* with native `web_search_20250305`. `ctx.deepseekAuth` releases its credential: a search initiated by
|
|
4
|
+
* a Session whose latest model request used the DeepSeek account route authenticates with the account
|
|
5
|
+
* sign-in when the search endpoint has the origin of that route's base URL and the account service
|
|
6
|
+
* allows the endpoint; every other search reuses `DEEPSEEK_API_KEY`. The provider
|
|
7
|
+
* does not reuse `DEEPSEEK_BASE_URL`; auxiliary search has its own endpoint configuration. The
|
|
8
|
+
* provider reports itself not ready for a model request whose search would have no credential.
|
|
8
9
|
* @module @deepseek-ai/dsh-web-search-deepseek
|
|
9
10
|
*/
|
|
10
11
|
import type { Volatile } from '@deepseek-ai/cordis'
|
|
@@ -13,12 +14,8 @@ import type { Context } from '@deepseek-ai/cordis'
|
|
|
13
14
|
import z from '@deepseek-ai/schemastery'
|
|
14
15
|
import type {} from '@deepseek-ai/dsh-agent'
|
|
15
16
|
import { credentialRef } from '@deepseek-ai/dsh-credentials'
|
|
16
|
-
import type {
|
|
17
|
-
import type {} from '@deepseek-ai/dsh-deepseek-account'
|
|
17
|
+
import type { DeepSeekAuthRequest } from '@deepseek-ai/dsh-deepseek-auth'
|
|
18
18
|
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
|
|
19
|
-
import {
|
|
20
|
-
deepSeekApiKeyConfigured, rejectDeepSeekAccountToken, resolveDeepSeekAccountToken, resolveDeepSeekApiKey,
|
|
21
|
-
} from '@deepseek-ai/dsh-llm-deepseek'
|
|
22
19
|
import type {} from '@deepseek-ai/dsh-session'
|
|
23
20
|
import type {} from '@deepseek-ai/dsh-web'
|
|
24
21
|
import {
|
|
@@ -45,8 +42,8 @@ export type { DeepSeekSearchLlmRequest, DeepSeekSearchProviderOptions } from './
|
|
|
45
42
|
/** Cordis plugin name used by loader diagnostics. */
|
|
46
43
|
export const name = 'web-search-deepseek'
|
|
47
44
|
|
|
48
|
-
/** The web seam this provider registers into. */
|
|
49
|
-
export const inject = ['web']
|
|
45
|
+
/** The web seam this provider registers into, and the DeepSeek authentication its searches ask for credentials. */
|
|
46
|
+
export const inject = ['web', 'deepseekAuth']
|
|
50
47
|
|
|
51
48
|
const DEFAULT_API_KEY_ENV = 'DEEPSEEK_API_KEY'
|
|
52
49
|
|
|
@@ -87,45 +84,65 @@ export const Config = z.object({
|
|
|
87
84
|
*/
|
|
88
85
|
const SEARCH_BASE_URL_ENV = 'DEEPSEEK_SEARCH_BASE_URL'
|
|
89
86
|
|
|
90
|
-
/** Provider route id `dsh-llm-deepseek-account` registers; `request/context` events record it per Session. */
|
|
91
|
-
const ACCOUNT_PROVIDER = 'deepseek-account'
|
|
92
|
-
|
|
93
87
|
/** Settings namespace carrying this provider's endpoint, model, and key reference. */
|
|
94
88
|
export const WEB_SEARCH_DEEPSEEK_SETTINGS_NAMESPACE = 'web-search-deepseek'
|
|
95
89
|
|
|
96
|
-
/** Options for one search, with
|
|
97
|
-
type SearchOptions = DeepSeekSearchProviderOptions & {
|
|
90
|
+
/** Options for one search, with what the search asks `ctx.deepseekAuth`. */
|
|
91
|
+
type SearchOptions = DeepSeekSearchProviderOptions & {
|
|
92
|
+
/**
|
|
93
|
+
* The request a search to `endpoint` makes for a model request on `route`, or `undefined` when the literal key is
|
|
94
|
+
* the only credential it can send.
|
|
95
|
+
*/
|
|
96
|
+
readonly authRequest: (route: string | undefined, endpoint: string) => DeepSeekAuthRequest | undefined
|
|
97
|
+
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Project one resolved section into the options the provider serves its next
|
|
101
101
|
* search with. Environment fallbacks stay here rather than in the provider:
|
|
102
102
|
* every value it reads is already fully defaulted.
|
|
103
|
-
* @param ctx - plugin context supplying the
|
|
103
|
+
* @param ctx - plugin context supplying the DeepSeek authentication, the Agent registry, and the environment.
|
|
104
104
|
* @param config - the currently authoritative section.
|
|
105
105
|
* @returns options for one search.
|
|
106
106
|
*/
|
|
107
107
|
function resolveOptions(
|
|
108
108
|
ctx: Context, config: { [K in keyof Config]: ReturnType<Config[K]['get']> },
|
|
109
109
|
): SearchOptions {
|
|
110
|
-
const
|
|
110
|
+
const reference = credentialRef(config.apiKeyEnv)
|
|
111
111
|
const literalApiKey = config.apiKey !== undefined && config.apiKey.length > 0
|
|
112
112
|
? config.apiKey
|
|
113
113
|
: undefined
|
|
114
|
+
const baseURL = config.baseURL
|
|
115
|
+
?? launchEnvironmentOf(ctx).get(SEARCH_BASE_URL_ENV)?.value
|
|
116
|
+
?? DEEPSEEK_DEFAULT_BASE_URL
|
|
117
|
+
const authRequest = (route: string | undefined, endpoint: string): DeepSeekAuthRequest | undefined => {
|
|
118
|
+
// The account sign-in pays only for a conversation on the account route, and only through that route.
|
|
119
|
+
const accountConversation = ctx.deepseekAuth.routeKind(route) === 'account'
|
|
120
|
+
if (literalApiKey !== undefined && !accountConversation) return undefined
|
|
121
|
+
return {
|
|
122
|
+
consumer: name,
|
|
123
|
+
// A literal key is this provider's own credential, so beside it only the account sign-in is asked for.
|
|
124
|
+
accepts: literalApiKey === undefined ? ['account', 'api-key'] : ['account'],
|
|
125
|
+
billing: accountConversation ? 'auto' : 'api-key',
|
|
126
|
+
route,
|
|
127
|
+
destination: { url: endpoint },
|
|
128
|
+
// The referenced key is this provider's own too: it goes to the search endpoint, whatever the API-key route uses.
|
|
129
|
+
connections: { 'api-key': { baseURL, reference } },
|
|
130
|
+
// Official DeepSeek expects `x-api-key`; an Anthropic-compatible proxy may expect `Authorization: Bearer`.
|
|
131
|
+
apiKeyHeaders: ['x-api-key', 'authorization'],
|
|
132
|
+
}
|
|
133
|
+
}
|
|
114
134
|
return {
|
|
115
135
|
...literalApiKey === undefined ? {} : { apiKey: literalApiKey },
|
|
116
|
-
|
|
136
|
+
authRequest,
|
|
137
|
+
authorize: async (endpoint, signal) => {
|
|
117
138
|
// The latest request context names the route that served the model
|
|
118
139
|
// request which called this search, as account sign-out reads it.
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
return await
|
|
140
|
+
const route = ctx.get('agents')?.currentInitiator()?.session.requestContext()?.provider
|
|
141
|
+
const request = authRequest(route, endpoint)
|
|
142
|
+
return request === undefined ? undefined : await ctx.deepseekAuth.authorize(request, signal)
|
|
122
143
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
apiKeyEnv,
|
|
126
|
-
baseURL: config.baseURL
|
|
127
|
-
?? launchEnvironmentOf(ctx).get(SEARCH_BASE_URL_ENV)?.value
|
|
128
|
-
?? DEEPSEEK_DEFAULT_BASE_URL,
|
|
144
|
+
apiKeyEnv: reference,
|
|
145
|
+
baseURL,
|
|
129
146
|
model: config.model,
|
|
130
147
|
apiVersion: config.apiVersion,
|
|
131
148
|
maxTokens: config.maxTokens,
|
|
@@ -141,28 +158,27 @@ function resolveOptions(
|
|
|
141
158
|
|
|
142
159
|
/**
|
|
143
160
|
* Whether the search a model request on `route` would make has a credential, checked in the order
|
|
144
|
-
* the search resolves them: the account
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
161
|
+
* the search resolves them: on the account route the account sign-in, when the search endpoint has the
|
|
162
|
+
* origin of that route's base URL, then the API key. A route whose settings do not resolve, or a failed
|
|
163
|
+
* read, answers false, because the search fails there instead of trying the next credential. Only
|
|
164
|
+
* presence is checked: the API key's value is not read and the endpoint is not contacted, so a wrong
|
|
165
|
+
* key or an endpoint without native search still counts as configured.
|
|
166
|
+
* @param ctx - plugin context supplying the DeepSeek authentication.
|
|
149
167
|
* @param options - options the next search would use.
|
|
150
168
|
* @param route - provider route of the model request being assembled.
|
|
151
|
-
* @returns whether the account
|
|
169
|
+
* @returns whether the account sign-in or an API key is available to that search.
|
|
152
170
|
*/
|
|
153
171
|
async function searchConfigured(
|
|
154
172
|
ctx: Context, options: SearchOptions, route: string | undefined,
|
|
155
173
|
): Promise<boolean> {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
174
|
+
const request = options.authRequest(route, `${options.baseURL}/messages`)
|
|
175
|
+
for (const candidate of request === undefined ? [] : ctx.deepseekAuth.candidates(request)) {
|
|
176
|
+
// The search stops at a route whose settings do not resolve before it reads any credential.
|
|
177
|
+
if ('unresolved' in candidate) return false
|
|
178
|
+
try { if (await candidate.configured()) return true }
|
|
179
|
+
catch (_unreadableCredential) { return false /* The search fails on this read before it tries the next credential. */ }
|
|
162
180
|
}
|
|
163
|
-
|
|
164
|
-
try { return await deepSeekApiKeyConfigured(ctx, options.apiKeyEnv) }
|
|
165
|
-
catch (_unreadableStore) { return false /* A store that cannot be read supplies no key to the search either. */ }
|
|
181
|
+
return options.apiKey !== undefined
|
|
166
182
|
}
|
|
167
183
|
|
|
168
184
|
/**
|
package/src/provider.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
WebSearchSource,
|
|
15
15
|
} from '@deepseek-ai/dsh-web'
|
|
16
16
|
import type { CredentialRef } from '@deepseek-ai/dsh-credentials'
|
|
17
|
+
import type { DeepSeekAuthorization } from '@deepseek-ai/dsh-deepseek-auth'
|
|
17
18
|
import type {} from '@deepseek-ai/dsh-session'
|
|
18
19
|
import type {
|
|
19
20
|
AnthropicError,
|
|
@@ -93,17 +94,16 @@ declare module '@deepseek-ai/dsh-session/types' {
|
|
|
93
94
|
/** Resolved provider options (the plugin's `apply` supplies credential and constant defaults). */
|
|
94
95
|
export interface DeepSeekSearchProviderOptions {
|
|
95
96
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
97
|
+
* Release the credential `ctx.deepseekAuth` binds to one search endpoint: the account sign-in in a
|
|
98
|
+
* conversation the account bills, otherwise the referenced API key. A released credential takes
|
|
99
|
+
* precedence over the literal {@link apiKey} and is sent only through its headers. An account
|
|
100
|
+
* sign-in is invalidated through `reject` after HTTP 401; a failure of that invalidation is
|
|
101
|
+
* contained, and the search reports the HTTP rejection. Its `revoked` signal ends the search when
|
|
102
|
+
* the account signs out. `undefined` selects the literal key.
|
|
99
103
|
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
rejectAccountToken?: (token: string) => Promise<void>
|
|
103
|
-
/** Literal DeepSeek API key; when present it wins over {@link resolveApiKey}. */
|
|
104
|
+
authorize?: (endpoint: string, signal?: AbortSignal) => Promise<SearchAuth | undefined>
|
|
105
|
+
/** Literal DeepSeek API key, sent when {@link authorize} releases no credential. */
|
|
104
106
|
apiKey?: string
|
|
105
|
-
/** Resolve the current DeepSeek API key for one search operation. */
|
|
106
|
-
resolveApiKey?: () => Promise<string | undefined>
|
|
107
107
|
/** Credential reference named by missing-credential diagnostics. */
|
|
108
108
|
apiKeyEnv?: CredentialRef
|
|
109
109
|
/** Endpoint base; `/messages` is appended. */
|
|
@@ -187,15 +187,11 @@ export function mapAnthropicResponse(response: AnthropicResponse): WebSearchResu
|
|
|
187
187
|
return { sources, truncated: false }
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
/**
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
readonly headers: Readonly<Record<string, string>>
|
|
196
|
-
/** Request-bound invalidation, present only when an account token was sent. */
|
|
197
|
-
readonly reject?: () => Promise<void>
|
|
198
|
-
}
|
|
190
|
+
/**
|
|
191
|
+
* The credential one search sends, tagged by its kind: the fields the search reads of an authorization
|
|
192
|
+
* `ctx.deepseekAuth` releases. `reject` invalidates a sent account sign-in, and `revoked` ends the request at sign-out.
|
|
193
|
+
*/
|
|
194
|
+
type SearchAuth = Pick<DeepSeekAuthorization, 'kind' | 'headers' | 'reject' | 'revoked'>
|
|
199
195
|
|
|
200
196
|
/**
|
|
201
197
|
* The DeepSeek-backed search provider. HTTP redirects fail as `WEB_PROVIDER_ERROR`;
|
|
@@ -226,8 +222,8 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
226
222
|
|
|
227
223
|
available(): boolean {
|
|
228
224
|
const options = this.resolveOptions()
|
|
229
|
-
return ((options.apiKey?.length ?? 0) > 0 || options.
|
|
230
|
-
&&
|
|
225
|
+
return ((options.apiKey?.length ?? 0) > 0 || options.authorize !== undefined)
|
|
226
|
+
&& dispatchable(options.baseURL)
|
|
231
227
|
&& isPositiveInteger(options.maxTokens)
|
|
232
228
|
&& isPositiveInteger(options.maxUses)
|
|
233
229
|
}
|
|
@@ -257,6 +253,17 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
257
253
|
})
|
|
258
254
|
throwIfSearchAborted(signal)
|
|
259
255
|
let response: Response
|
|
256
|
+
const live = requestSignal(signal, auth.revoked)
|
|
257
|
+
/**
|
|
258
|
+
* The failure of an interrupted request: the caller's cancellation first, then the sign-out of the sent account.
|
|
259
|
+
* @param error - what the interrupted fetch or body read threw.
|
|
260
|
+
* @returns the failure to report, or undefined when `error` is no interruption.
|
|
261
|
+
*/
|
|
262
|
+
const interrupted = (error: unknown): WebError | undefined => {
|
|
263
|
+
if (signal?.aborted === true) return searchAborted(signal, error)
|
|
264
|
+
if (auth.revoked?.aborted === true) return accountSignedOutError(error)
|
|
265
|
+
return isAbortError(error) ? searchAborted(signal, error) : undefined
|
|
266
|
+
}
|
|
260
267
|
try {
|
|
261
268
|
response = await fetch(endpoint, {
|
|
262
269
|
method: 'POST',
|
|
@@ -269,11 +276,10 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
269
276
|
'user-agent': USER_AGENT,
|
|
270
277
|
},
|
|
271
278
|
body: JSON.stringify(body),
|
|
272
|
-
...
|
|
279
|
+
...live !== undefined ? { signal: live } : {},
|
|
273
280
|
})
|
|
274
281
|
} catch (error: unknown) {
|
|
275
|
-
|
|
276
|
-
throw searchEndpointError(
|
|
282
|
+
throw interrupted(error) ?? searchEndpointError(
|
|
277
283
|
endpoint,
|
|
278
284
|
`DeepSeek search request failed: ${String(error)}`,
|
|
279
285
|
error,
|
|
@@ -289,21 +295,21 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
289
295
|
const detail = typeof parsed.error === 'string' ? parsed.error : parsed.error?.message ?? parsed.message
|
|
290
296
|
if (detail !== undefined && detail.length > 0) message += `: ${detail}`
|
|
291
297
|
} catch (error: unknown) {
|
|
292
|
-
// An
|
|
298
|
+
// An interruption mid-body must surface as itself, not be swallowed
|
|
293
299
|
// into a generic HTTP-error message — cancellation is not a provider
|
|
294
300
|
// error (the seam's cancellation contract).
|
|
295
|
-
|
|
301
|
+
aborted = interrupted(error)
|
|
296
302
|
// Otherwise: the HTTP status is already captured in `message` above; a
|
|
297
303
|
// malformed/non-JSON error body (normal for gateway 5xx/429s) can only
|
|
298
304
|
// cost a richer provider message, never the real error.
|
|
299
305
|
}
|
|
300
|
-
// The account service released this
|
|
306
|
+
// The account service released this credential only for its inference
|
|
301
307
|
// origin, so the endpoint is not what the user must change.
|
|
302
308
|
if (status === 401 && auth.kind === 'account') {
|
|
303
309
|
// Invalidation can cancel this Session; finish reading the HTTP failure before it does. A cancelled read
|
|
304
|
-
// still invalidates the
|
|
310
|
+
// still invalidates the credential the status rejected.
|
|
305
311
|
try { await auth.reject?.() }
|
|
306
|
-
catch (
|
|
312
|
+
catch (_invalidationFailed) { /* The HTTP rejection stays the reported failure when the invalidation itself fails. */ }
|
|
307
313
|
throw aborted ?? accountRejectedError(message)
|
|
308
314
|
}
|
|
309
315
|
if (aborted !== undefined) throw aborted
|
|
@@ -314,7 +320,8 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
314
320
|
const payload = await response.json() as AnthropicResponse
|
|
315
321
|
return mapAnthropicResponse(payload)
|
|
316
322
|
} catch (error: unknown) {
|
|
317
|
-
|
|
323
|
+
const stopped = interrupted(error)
|
|
324
|
+
if (stopped !== undefined) throw stopped
|
|
318
325
|
const message = error instanceof WebError
|
|
319
326
|
? error.message
|
|
320
327
|
: `DeepSeek returned an unprocessable response body: ${String(error)}`
|
|
@@ -323,41 +330,24 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
/**
|
|
326
|
-
* Resolve one operation's
|
|
333
|
+
* Resolve one operation's credential without retaining it on the provider.
|
|
327
334
|
* @param options - the caller's snapshot, so the credential and the endpoint it is sent to come from one section.
|
|
328
335
|
* @param endpoint - the Messages endpoint this operation dispatches to.
|
|
329
336
|
* @param signal - abort signal for the surrounding search.
|
|
330
|
-
* @returns the
|
|
337
|
+
* @returns the released credential when one resolves, otherwise the literal key in both API-key headers.
|
|
331
338
|
*/
|
|
332
339
|
private async authHeaders(
|
|
333
340
|
options: DeepSeekSearchProviderOptions, endpoint: string, signal?: AbortSignal,
|
|
334
341
|
): Promise<SearchAuth> {
|
|
335
|
-
const {
|
|
336
|
-
const
|
|
342
|
+
const { authorize, apiKey } = options
|
|
343
|
+
const released = authorize === undefined
|
|
337
344
|
? undefined
|
|
338
|
-
: await resolveCredential(() =>
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
...rejectAccountToken === undefined ? {} : { reject: () => rejectAccountToken(token) },
|
|
342
|
-
}
|
|
343
|
-
const apiKey = await this.apiKey(options, signal)
|
|
345
|
+
: await resolveCredential(() => authorize(endpoint, signal), signal)
|
|
346
|
+
if (released !== undefined) return released
|
|
347
|
+
throwIfSearchAborted(signal)
|
|
344
348
|
// Official DeepSeek expects `x-api-key`; an Anthropic-compatible proxy
|
|
345
349
|
// may expect `Authorization: Bearer` — send both so either resolves.
|
|
346
|
-
return { kind: 'api-key', headers: { 'x-api-key': apiKey, 'authorization': `Bearer ${apiKey}` } }
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Resolve one operation's API key without retaining it on the provider.
|
|
351
|
-
* @param options - the caller's snapshot, so the key and the endpoint it is sent to come from one section.
|
|
352
|
-
* @param signal - abort signal for the surrounding search.
|
|
353
|
-
* @returns the resolved key.
|
|
354
|
-
*/
|
|
355
|
-
private async apiKey(options: DeepSeekSearchProviderOptions, signal?: AbortSignal): Promise<string> {
|
|
356
|
-
throwIfSearchAborted(signal)
|
|
357
|
-
if (options.apiKey !== undefined && options.apiKey.length > 0) return options.apiKey
|
|
358
|
-
const { resolveApiKey } = options
|
|
359
|
-
const resolved = resolveApiKey === undefined ? undefined : await resolveCredential(resolveApiKey, signal)
|
|
360
|
-
if (resolved !== undefined && resolved.length > 0) return resolved
|
|
350
|
+
if (apiKey !== undefined && apiKey.length > 0) return { kind: 'api-key', headers: { 'x-api-key': apiKey, 'authorization': `Bearer ${apiKey}` } }
|
|
361
351
|
const ref = options.apiKeyEnv ?? 'DEEPSEEK_API_KEY'
|
|
362
352
|
throw new WebError(
|
|
363
353
|
`DeepSeek search has no API key for "${ref}"; store it through the credentials service`
|
|
@@ -377,9 +367,7 @@ export class DeepSeekSearchProvider implements WebSearchProvider {
|
|
|
377
367
|
* @returns the resolved credential, or undefined when the resolver supplied none.
|
|
378
368
|
* @throws {@link WebError} `WEB_ABORTED` on cancellation, `WEB_PROVIDER_ERROR` when the resolver fails.
|
|
379
369
|
*/
|
|
380
|
-
async function resolveCredential(
|
|
381
|
-
resolve: () => Promise<string | undefined>, signal?: AbortSignal,
|
|
382
|
-
): Promise<string | undefined> {
|
|
370
|
+
async function resolveCredential<T>(resolve: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
383
371
|
throwIfSearchAborted(signal)
|
|
384
372
|
try {
|
|
385
373
|
return await abortable(resolve(), signal)
|
|
@@ -393,6 +381,32 @@ async function resolveCredential(
|
|
|
393
381
|
}
|
|
394
382
|
}
|
|
395
383
|
|
|
384
|
+
/**
|
|
385
|
+
* The signal one search runs under: the caller's cancellation and the sign-out of the account credential it carries.
|
|
386
|
+
* @param signal - caller cancellation, when the caller supplies one.
|
|
387
|
+
* @param revoked - sign-out of the sent account credential, when its authorization offers one.
|
|
388
|
+
* @returns the composed signal, or undefined when neither exists.
|
|
389
|
+
*/
|
|
390
|
+
function requestSignal(signal: AbortSignal | undefined, revoked: AbortSignal | undefined): AbortSignal | undefined {
|
|
391
|
+
if (signal === undefined || revoked === undefined) return signal ?? revoked
|
|
392
|
+
return AbortSignal.any([signal, revoked])
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Report a search that ended because the account it authenticated with signed out. The caller did not cancel, so the
|
|
397
|
+
* failure is the provider's.
|
|
398
|
+
* @param cause - what the interrupted fetch or body read threw.
|
|
399
|
+
* @returns the provider failure with sign-in guidance.
|
|
400
|
+
*/
|
|
401
|
+
function accountSignedOutError(cause: unknown): WebError {
|
|
402
|
+
return new WebError(
|
|
403
|
+
'The DeepSeek account signed out before this web search finished. Guide the user to sign in to DeepSeek again;'
|
|
404
|
+
+ ' the search endpoint does not need changing.',
|
|
405
|
+
'WEB_PROVIDER_ERROR',
|
|
406
|
+
{ cause },
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
|
|
396
410
|
/** Replace endpoint guidance with sign-in guidance when DeepSeek rejects the account token. */
|
|
397
411
|
function accountRejectedError(message: string): WebError {
|
|
398
412
|
return new WebError(
|
|
@@ -422,7 +436,12 @@ function searchEndpointError(endpoint: string, message: string, cause?: unknown)
|
|
|
422
436
|
*/
|
|
423
437
|
function abortable<T>(operation: Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
424
438
|
if (signal === undefined) return operation
|
|
425
|
-
if (signal.aborted)
|
|
439
|
+
if (signal.aborted) {
|
|
440
|
+
// The operation began before this check and can still reject: a credential read that cancels its caller, then
|
|
441
|
+
// fails on that cancellation. Observing it keeps that rejection from being unhandled.
|
|
442
|
+
void operation.catch(() => {})
|
|
443
|
+
return Promise.reject(searchAborted(signal))
|
|
444
|
+
}
|
|
426
445
|
return new Promise<T>((resolve, reject) => {
|
|
427
446
|
const onAbort = (): void => { reject(searchAborted(signal)) }
|
|
428
447
|
signal.addEventListener('abort', onAbort, { once: true })
|
|
@@ -456,6 +475,13 @@ function isAbortError(error: unknown): boolean {
|
|
|
456
475
|
return error instanceof DOMException && error.name === 'AbortError'
|
|
457
476
|
}
|
|
458
477
|
|
|
478
|
+
/** True for a base URL a search can be sent to: it parses and embeds no credentials, which `fetch` refuses to send. */
|
|
479
|
+
function dispatchable(baseURL: string): boolean {
|
|
480
|
+
if (!URL.canParse(baseURL)) return false
|
|
481
|
+
const { username, password } = new URL(baseURL)
|
|
482
|
+
return username === '' && password === ''
|
|
483
|
+
}
|
|
484
|
+
|
|
459
485
|
/** True for DeepSeek request limits that can be sent to the Messages API. */
|
|
460
486
|
function isPositiveInteger(value: number): boolean {
|
|
461
487
|
return Number.isInteger(value) && value > 0
|