Merge pull request #8521 from deepseek-harness/refactor/deepseek-auth

refactor(deepseek-auth): authenticate DeepSeek consumers through ctx.deepseekAuth
This commit is contained in:
LegGasai authored and GitHub committed 2026-11-17 09:10:13 +00:00
commit 641c669fca
226 files changed
+3124 -1921

No files matched your search

@@ -9,8 +9,8 @@
en: 6228c81e4965b688
zh: 04b702be0cfbf195
/agent-note-credential-boundaries-whole-snapshot-requests-and-atomic-route-registration/decision:
en: 052787311a4e6edc
zh: 963eed632ea198de
en: 3ecf963f99b8e9ae
zh: 84fa0bed2316ce94
/agent-note-credential-boundaries-whole-snapshot-requests-and-atomic-route-registration/alternatives-considered:
en: 90c5883b247f7301
zh: 6d2a660d8653f805
@@ -18,7 +18,7 @@ Two request-path defects sat beside them. DeepSeek resolved connection and crede
**The stored credential has no boundary against the model, and the READMEs say so.** `0600` under a `0700` directory stops other OS users; the model's bash and filesystem tools run as that same user, and the shipped default confines nothing. What the harness does hold to is narrower and stated as exactly that: no surface hoists the document into `process.env`, and the model is never handed a resolved path to it, so reaching the value takes a deliberate read of a path it was not given. An OS-keychain provider — a store the model's processes cannot read at all — is recorded as the real answer rather than implied by a partial one.
**One request, one generation.** DeepSeek's resolved snapshot carries the credential reference beside the endpoint, and `resolveApiKey` receives that snapshot instead of re-reading configuration. A rejected generation now contributes nothing at all. pi-ai defers to provider-native discovery only for a profile naming no credential; a configured reference that misses fails with `MISSING_CREDENTIAL` naming the route and the reference. The boot-time credential probe is deleted: it could run before the credentials service mounted and reported every failure as a missing key, while the first request already gives the accurate error.
**One request, one generation.** DeepSeek's resolved snapshot carries the credential reference beside the endpoint, and the API-key route's `resolveAuth` hands that snapshot's endpoint and reference to `ctx.deepseekAuth` instead of re-reading configuration. A rejected generation now contributes nothing at all. pi-ai defers to provider-native discovery only for a profile naming no credential; a configured reference that misses fails with `MISSING_CREDENTIAL` naming the route and the reference. The boot-time credential probe is deleted: it could run before the credentials service mounted and reported every failure as a missing key, while the first request already gives the accurate error.
**Route replacement is a registry operation, not a caller sequence.** `registerAdapter` returns a handle carrying `replace(providers)`: the candidate set is validated in full first (conflicts, names, provider metadata), then swapped in one synchronous section. A refused replacement leaves the previous routes registered and serving, and the caller's facts cache only advances after the registry actually holds the new set, so reverting to a working configuration re-applies. pi-ai's registration facts are sorted by provider, so a settings document that merely reorders its keys is no longer a route change.
@@ -22,7 +22,7 @@ Status: implemented
**存下的凭据对模型没有边界,而 README 就是这么写的。**`0700` 目录下的 `0600` 挡得住其他 OS 用户;模型的 bash 与文件系统工具正是以同一用户身份运行,而已交付的默认配置不提供任何约束。harness 真正守住的边界更窄,文档也严格按这一范围表述:没有任何一个面会把该文档提升进 `process.env`,模型也从不会拿到它的解析后路径,因此要拿到这个值,需要刻意去读一条并未交给它的路径。OS 钥匙串(keychain)提供方——一个模型的进程根本读不到的存储——被记录为真正的答案,而不是靠一个残缺的方案去暗示它。
**一次请求,一代设置。**DeepSeek 解析出的快照在端点旁一并携带凭据引用,`resolveApiKey` 接收这份快照,而不再重新读取配置。被拒绝的那一代如今完全不再贡献任何东西。只有当一个 profile 完全没有点名凭据时,pi-ai 才交给提供方原生的发现流程;配置了引用却解析不到,就以 `MISSING_CREDENTIAL` 失败,并点名该路由与该引用。启动时的凭据探测被删除:它可能在凭据服务挂载之前就运行,并把每一种失败都报成密钥缺失,而第一次请求本就会给出准确的错误。
**一次请求,一代设置。**DeepSeek 解析出的快照在端点旁一并携带凭据引用,API 密钥路由的 `resolveAuth` 把这份快照的端点和引用交给 `ctx.deepseekAuth`,而不再重新读取配置。被拒绝的那一代如今完全不再贡献任何东西。只有当一个 profile 完全没有点名凭据时,pi-ai 才交给提供方原生的发现流程;配置了引用却解析不到,就以 `MISSING_CREDENTIAL` 失败,并点名该路由与该引用。启动时的凭据探测被删除:它可能在凭据服务挂载之前就运行,并把每一种失败都报成密钥缺失,而第一次请求本就会给出准确的错误。
**路由替换是注册表的操作,不是调用方的一串步骤。**`registerAdapter` 返回一个携带 `replace(providers)` 的句柄:候选集合先被完整校验(冲突、名称、提供方元数据),再在一个同步区段内完成替换。被拒绝的替换会让先前的路由保持注册并继续服务,而调用方的事实缓存只有在注册表确实持有新集合之后才会推进,因此改回可用配置时会重新生效。pi-ai 的注册事实按提供方排序,因此仅仅调换键顺序的设置文档不再算作路由变更。
@@ -9,8 +9,8 @@
en: 8d4d00e33af763b2
zh: 61977c82d66ae9bf
/agent-note-account-provider-and-active-request-cancellation/decision:
en: 6f5463ecf88c1435
zh: 7c9e46f90c8ccffb
en: 383ef40d2ec7b6f1
zh: 2e9482475015b1ff
/agent-note-account-provider-and-active-request-cancellation/alternatives-considered:
en: 7ed93136cf11074a
zh: 1ee997e271e919ad
@@ -14,7 +14,7 @@ Selecting credentials from login state changes the billing identity of an existi
Account cancellation reads each running Agent’s latest `Session.requestContext()` instead of maintaining another provider field. This logged value remains through tools and retries and follows the next bound request. Idle Agents are excluded. During a new turn’s first preparation it can still name the previous turn’s account route, so sign-out can also interrupt an API-key turn that has not bound its new request yet. A missing account credential rejects a first request without a previous context before transport.
Successful local sign-out publishes an account event. The account route plugin installs a listener, which enumerates the Agent registry and cancels matching account routes through `Agent.cancel`, preserving inboxes. It registers the same predicate with the account service as the running-task report behind sign-out confirmation. Each registered child is classified independently; existing parent-owned cancellation still applies to children whose lifetime is attached to a cancelled parent. The existing HTTP signal carries cancellation to transport. Requests this listener cannot reach end through the withdrawal signal of their credential, which the [route credential decision](2026-11-10-llm-route-credential-seam.md) owns.
Successful local sign-out publishes an account event. The account route plugin installs a listener, which enumerates the Agent registry and cancels matching account routes through `Agent.cancel`, preserving inboxes. It registers the same predicate with the account service as the running-task report behind sign-out confirmation. Each registered child is classified independently; existing parent-owned cancellation still applies to children whose lifetime is attached to a cancelled parent. The existing HTTP signal carries cancellation to transport. Requests this listener cannot reach end through the withdrawal signal of their credential, which the [DeepSeek request authentication decision](2026-11-10-deepseek-request-authentication.md) owns.
## Alternatives considered
@@ -14,7 +14,7 @@ Status: implemented
账号取消读取运行中 Agent 最近的 `Session.requestContext()`,不维护额外提供方字段。该已记录值在工具和重试阶段保留,随下一次绑定请求更新;空闲 Agent 不计入。新轮次首次准备期间,它仍可能指向上一轮的账号路由,因此退登也可能打断尚未绑定新请求的 API key 轮次。没有历史上下文的首请求若缺少账号凭据,会在传输前失败。
本地退登成功后发布账号事件。账号路由插件安装监听器,遍历 Agent 注册表,通过 `Agent.cancel` 取消匹配的账号路由并保留收件箱。它把同一判断函数注册到账号服务,作为退登确认所依据的运行中任务报告。每个已注册子代理独立分类;生命周期绑定到已取消父代理的子代理仍受现有父级取消规则约束。现有 HTTP 信号将取消传递到传输层。该监听器到达不了的请求通过其凭据的撤回信号结束,这一信号由[路由凭据决策](2026-11-10-llm-route-credential-seam.zh.md)负责。
本地退登成功后发布账号事件。账号路由插件安装监听器,遍历 Agent 注册表,通过 `Agent.cancel` 取消匹配的账号路由并保留收件箱。它把同一判断函数注册到账号服务,作为退登确认所依据的运行中任务报告。每个已注册子代理独立分类;生命周期绑定到已取消父代理的子代理仍受现有父级取消规则约束。现有 HTTP 信号将取消传递到传输层。该监听器到达不了的请求通过其凭据的撤回信号结束,这一信号由 [DeepSeek 请求鉴权决策](2026-11-10-deepseek-request-authentication.zh.md)负责。
## Alternatives considered
@@ -9,8 +9,8 @@
en: 32ba2b2b42e8deb5
zh: 6a6532561f81b8e2
/agent-note-offer-web-search-and-web-fetch-only-while-the-selected-provider-is-ready/decision:
en: 023c6db0af5f9424
zh: 7bdf40c49e381ee3
en: 9bf594047ad5c864
zh: 366263d56f8a4fbf
/agent-note-offer-web-search-and-web-fetch-only-while-the-selected-provider-is-ready/alternatives-considered:
en: 6da221f6b821ea44
zh: b15774011abed7ed
@@ -13,7 +13,7 @@ English | [中文](2026-09-27-web-search-offered-by-provider-readiness.zh.md)
Each role of the web capability seam owns one part of a per-step check:
- **Service Definition.** `WebSearchProvider` and `WebFetchProvider` have an optional `ready(llmProvider)` that answers whether an operation made for a model request on that chat route has a credential to send. It checks configuration only and makes no network calls. `ctx.web.searchReady(llmProvider?)` and `ctx.web.fetchReady(llmProvider?)` resolve the provider with the same rules as `search()` and `fetch()` and return its answer. A provider without `ready()` counts as ready, and a selection failure answers true because the operation reports that failure as a structured `WebError`.
- **Service Provider.** Each DeepSeek provider checks its credentials in the order its operation resolves them. `dsh-web-search-deepseek` checks, on a route whose `ctx.llm.providerCredential()` publishes an account credential, whether that credential is configured for its Messages endpoint, and then its literal `apiKey` or its `apiKeyEnv` reference. The Search and Fetch API providers of `dsh-web-deepseek-api` resolve the same plan as the operation ([credential resolution](2026-10-29-web-provider-selection.md)): a capability with its own YAML fields checks only the key under its `*ApiKeyEnv`; otherwise, on the account route with the account model route mounted, that route's credential configured for its `/v1/tools` base counts, and then the key of the `deepseek-official` route, or `DEEPSEEK_API_KEY` without that route. A key counts when `ctx.credentials.describe()` reports its reference configured (without that service, when the launching environment carries it); the reference helpers of `dsh-credentials` and each route's own presence check perform these checks. A failed account-token or credential-store read answers false, because the operation fails on that read instead of trying the next credential. The providers name no tool or prompt section.
- **Service Provider.** Each DeepSeek provider checks its credentials in the order its operation resolves them. `dsh-web-search-deepseek` checks, in a conversation on the account route, whether `ctx.deepseekAuth` has the account sign-in configured for its Messages endpoint, and then its literal `apiKey` or its `apiKeyEnv` reference. The Search and Fetch API providers of `dsh-web-deepseek-api` resolve the same plan as the operation ([credential resolution](2026-10-29-web-provider-selection.md)): a capability with its own YAML fields checks only the key under its `*ApiKeyEnv`; otherwise, on the account route with the account model route mounted, the account sign-in configured for the endpoint under that route's origin counts, and then the key of the `deepseek-official` route, or `DEEPSEEK_API_KEY` without that route. A key counts when `ctx.credentials.describe()` reports its reference configured (without that service, when the launching environment carries it); `ctx.deepseekAuth` performs these checks, a key's through the reference helpers of `dsh-credentials`. A failed account-token or credential-store read answers false, because the operation fails on that read instead of trying the next credential. The providers name no tool or prompt section.
- **Consumer.** `dsh-tool-web` registers `web_search` and `web_fetch` with [step activation conditions](../../../../packages/core/tools/README.md#conditional-tools) that ask `ctx.web.searchReady()` and `ctx.web.fetchReady()` about the route of the step's model selection. The agent loop resolves conditions before it assembles the step, so the declared tools, the `tool:web_search` and `tool:web_fetch` prompt sections, PTC program bindings, and dispatch all read the same admitted set.
The route decides only whether the account token is checked before the API key, which happens on the `deepseek-account` route; an API key counts on every route, so a conversation on another provider's model is offered the DeepSeek web tools whenever a DeepSeek key is configured. A Search or Fetch API capability with its own YAML fields ignores the route and is ready exactly when its own key is configured.
@@ -13,7 +13,7 @@ Status: implemented
web 能力 seam 的每个角色各负责逐步骤检查的一部分:
- **Service Definition。** `WebSearchProvider` 与 `WebFetchProvider` 有一个可选的 `ready(llmProvider)`,回答为该对话路由上的模型请求发起的操作是否有可发送的凭据。它只检查配置,不发起网络调用。`ctx.web.searchReady(llmProvider?)` 与 `ctx.web.fetchReady(llmProvider?)` 按与 `search()`、`fetch()` 相同的规则解析提供方并返回其回答。没有 `ready()` 的提供方视为就绪;选择失败时回答 true,因为对应操作会把该失败报告为结构化 `WebError`。
- **Service Provider。** 每个 DeepSeek 提供方都按其操作解析凭据的顺序检查凭据。`dsh-web-search-deepseek` 在 `ctx.llm.providerCredential()` 发布账号凭据的路由上检查该凭据是否已为其 Messages 端点配置,然后检查其字面 `apiKey` 或 `apiKeyEnv` 引用。`dsh-web-deepseek-api` 的 Search 与 Fetch API 提供方解析与操作相同的方案([凭据解析](2026-10-29-web-provider-selection.zh.md)):在 YAML 中设置了单独字段的能力只检查其 `*ApiKeyEnv` 下的密钥;否则,在账号路由上且账号模型路由已挂载时,该路由为其 `/v1/tools` 基础地址配置的凭据算数,然后是 `deepseek-official` 路由的密钥,没有该路由时为 `DEEPSEEK_API_KEY`。`ctx.credentials.describe()` 报告其引用已配置时(没有该服务时,启动环境中存在该变量),密钥即算存在;这些存在性检查由 `dsh-credentials` 的引用函数和各路由自身的存在性检查执行。读取账号 token 或凭据存储失败时回答 false,因为操作会在该次读取上失败,而不会尝试下一种凭据。提供方不点名任何工具或提示词段落。
- **Service Provider。** 每个 DeepSeek 提供方都按其操作解析凭据的顺序检查凭据。`dsh-web-search-deepseek` 在账号路由上的会话里检查 `ctx.deepseekAuth` 是否已为其 Messages 端点配置账号登录凭据,然后检查其字面 `apiKey` 或 `apiKeyEnv` 引用。`dsh-web-deepseek-api` 的 Search 与 Fetch API 提供方解析与操作相同的方案([凭据解析](2026-10-29-web-provider-selection.zh.md)):在 YAML 中设置了单独字段的能力只检查其 `*ApiKeyEnv` 下的密钥;否则,在账号路由上且账号模型路由已挂载时,为该路由 origin 之下的端点配置的账号登录凭据算数,然后是 `deepseek-official` 路由的密钥,没有该路由时为 `DEEPSEEK_API_KEY`。`ctx.credentials.describe()` 报告其引用已配置时(没有该服务时,启动环境中存在该变量),密钥即算存在;这些存在性检查由 `ctx.deepseekAuth` 执行,其中密钥的检查经由 `dsh-credentials` 的引用函数。读取账号 token 或凭据存储失败时回答 false,因为操作会在该次读取上失败,而不会尝试下一种凭据。提供方不点名任何工具或提示词段落。
- **Consumer。** `dsh-tool-web` 注册 `web_search` 与 `web_fetch` 时各带一个[步骤激活条件](../../../../packages/core/tools/README.zh.md#conditional-tools),以该步骤模型选择的路由询问 `ctx.web.searchReady()` 与 `ctx.web.fetchReady()`。agent loop 在组装该步骤之前解析各条件,因此声明的工具、`tool:web_search` 与 `tool:web_fetch` 提示词段落、PTC 程序绑定与派发都读取同一个准入集合。
路由只决定是否先检查账号 token 再检查 API 密钥,这发生在 `deepseek-account` 路由上;API 密钥在每条路由上都算数,因此只要配置了 DeepSeek 密钥,使用其他提供方模型的对话也会获得 DeepSeek Web 工具。在 YAML 中设置了单独字段的 Search 或 Fetch API 能力不看路由,恰在其自身密钥已配置时就绪。
@@ -18,8 +18,8 @@
en: 9d68ffca5c8be681
zh: 36bb661f98de0ebb
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision/credential-resolution:
en: aa5522b172d2c580
zh: 04561ffe78d69ff4
en: dca56d7ced4e5294
zh: e984a7fddac3228f
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision/defaults-and-stored-selections:
en: 5fcd3319fbceed1d
zh: 20771646b9c36fa6
@@ -30,11 +30,11 @@ The Search and Fetch APIs read one `web-deepseek-api` namespace, and each resolv
Each of Search and Fetch has a billing setting, `web-deepseek-api.searchBilling` or `fetchBilling`, which the settings page edits as a **Billing** menu under the selected API. The default, `auto`, follows the DeepSeek credential of the conversation; `account` sends only the signed-in account's token and `api-key` only the API key, without falling back to the other. The conversation's route is the `provider` of the initiating Session's latest request context, which account sign-out also reads; `ready()` uses the route of the model request being prepared, so readiness and execution resolve the same plan.
The account credential is the one `ctx.deepseekAccount` releases for the dispatch endpoint under the origin of the base URL the mounted `deepseek-account` route publishes through `ctx.llm.providerCredential()`, with `/v1/tools`; without that route, the origin `DEEPSEEK_BASE_URL` names is used. An HTTP 401 invalidates that credential. With `auto` billing on the `deepseek-account` route, the operation sends the account credential when that route is mounted and a credential is released. Every other `auto` operation, including one in an account conversation without a sign-in or a credential, sends the key the mounted `deepseek-official` route publishes, which the route resolves under its `apiKeyEnv` (its base URL includes `DEEPSEEK_BASE_URL`), to the origin of that route's base URL with `/v1/tools`; without that route, `DEEPSEEK_API_KEY` goes to `https://api.deepseek.com/v1/tools`. With `auto` billing on a route other than the two DeepSeek routes, or outside a Session, an operation without a configured key sends the account token instead, so a signed-in user without a key keeps web tools in conversations on other model providers; on the `deepseek-official` route it never sends the token, because that conversation bills the API key. Sending the API key in a signed-out account conversation keeps web tools available there. A user with only `DEEPSEEK_API_KEY`, including every headless, SDK, and ACP run, therefore searches and fetches by default, and a gateway or internal deployment set through the model provider's base URL serves web access at the same origin. A missing credential makes the capability not ready, and an operation fails with `WEB_PROVIDER_CREDENTIAL_MISSING` and guidance for its billing that names the account sign-in, the Models page and the reference, and the billing field. A mounted route whose configuration does not resolve is not treated as absent: an operation that needs that route is not ready and fails with `WEB_PROVIDER_MISCONFIGURED` before reading the credential that depends on that route, without trying later sources or sending the request, so a broken gateway setting never redirects requests to the official endpoint.
The account credential is the one `ctx.deepseekAccount` releases for the dispatch endpoint under the origin of the base URL the mounted `deepseek-account` route connects to `ctx.deepseekAuth`, with `/v1/tools`; without that route, the origin `DEEPSEEK_BASE_URL` names is used. An HTTP 401 invalidates that credential. With `auto` billing on the `deepseek-account` route, the operation sends the account credential when that route is mounted and a credential is released. Every other `auto` operation, including one in an account conversation without a sign-in or a credential, sends the key of the mounted `deepseek-official` route, read under that route's `apiKeyEnv` (its base URL includes `DEEPSEEK_BASE_URL`), to the origin of that route's base URL with `/v1/tools`; without that route, `DEEPSEEK_API_KEY` goes to `https://api.deepseek.com/v1/tools`. With `auto` billing on a route other than the two mounted DeepSeek routes, which includes either DeepSeek route id while its plugin is not mounted, or outside a Session, an operation without a configured key sends the account token instead, so a signed-in user without a key keeps web tools in conversations on other model providers; on the mounted `deepseek-official` route it never sends the token, because that conversation bills the API key. Sending the API key in a signed-out account conversation keeps web tools available there. A user with only `DEEPSEEK_API_KEY`, including every headless, SDK, and ACP run, therefore searches and fetches by default, and a gateway or internal deployment set through the model provider's base URL serves web access at the same origin. A missing credential makes the capability not ready, and an operation fails with `WEB_PROVIDER_CREDENTIAL_MISSING` and guidance for its billing that names the account sign-in, the Models page and the reference, and the billing field. A mounted route whose configuration does not resolve is not treated as absent: an operation that needs that route is not ready and fails with `WEB_PROVIDER_MISCONFIGURED` before reading the credential that depends on that route, without trying later sources or sending the request, so a broken gateway setting never redirects requests to the official endpoint.
A capability whose YAML sets a non-empty `searchBaseURL` or `searchApiKeyEnv` (`fetchBaseURL` or `fetchApiKeyEnv` for Fetch) instead, whatever its billing, always sends the key under its `*ApiKeyEnv` (`DEEPSEEK_API_KEY` when unset) to its `*BaseURL` (the official base when unset) and never the account token, so an intranet or third-party endpoint receives only the key chosen for it. Each capability has its own fields because a deployment can serve search and fetch from different gateways. These fields are YAML-only, and an empty value counts as unset. Stored values of fields outside the schema, including `baseURL`, `apiKeyEnv`, and `apiKey`, load without schema errors and have no effect.
The DeepSeek model routes publish the credential they send through `ctx.llm.providerCredential()` ([route credentials](2026-11-10-llm-route-credential-seam.md)): the API-key route its key under `apiKeyEnv`, the account route the credential `ctx.deepseekAccount` releases for a destination. Messages search and the Search and Fetch APIs read those publications instead of provider configuration, and read `DEEPSEEK_API_KEY` and own keys through the reference helpers of `dsh-credentials`, so every DeepSeek request reads the credential store the same way; a credential whose grant offers invalidation is invalidated after an HTTP 401. Shipped profiles need no per-profile credential override, because the API-key path works wherever `DEEPSEEK_API_KEY` or the DeepSeek API-key route has a key.
`ctx.deepseekAuth` orders and releases these credentials ([DeepSeek request authentication](2026-11-10-deepseek-request-authentication.md)): each DeepSeek model route connects the deployment its settings name, the API-key route with its key reference under `apiKeyEnv`, and the account sign-in is the credential `ctx.deepseekAccount` releases for a destination. Messages search and the Search and Fetch APIs ask that service instead of reading provider configuration, and it reads route keys, `DEEPSEEK_API_KEY`, and own keys through the reference helpers of `dsh-credentials`, so every DeepSeek request reads the credential store the same way; a credential whose authorization offers invalidation is invalidated after an HTTP 401. Shipped profiles need no per-profile credential override, because the API-key path works wherever `DEEPSEEK_API_KEY` or the DeepSeek API-key route has a key.
### Defaults and stored selections
@@ -30,11 +30,11 @@ Search 与 Fetch API 读取同一个 `web-deepseek-api` namespace,并各自解
Search 与 Fetch 各有一个计费方式设置 `web-deepseek-api.searchBilling` 或 `fetchBilling`,设置页在选中的 API 下方以**计费方式**下拉框编辑它。默认值 `auto` 跟随会话的 DeepSeek 凭据;`account` 只发送已登录账号的令牌,`api-key` 只发送 API 密钥,都不回退到另一种凭据。会话的路由是发起会话最近一次请求上下文的 `provider`,账号退出登录读取的也是它;`ready()` 使用正在准备的模型请求的路由,因此就绪判断与执行解析出相同的方案。
账号凭据是 `ctx.deepseekAccount` 为请求端点释放的凭据,端点位于已挂载的 `deepseek-account` 路由通过 `ctx.llm.providerCredential()` 发布的基础地址的 origin 加 `/v1/tools` 下;没有该路由时使用 `DEEPSEEK_BASE_URL` 所指的 origin。HTTP 401 会作废该凭据。`auto` 计费在 `deepseek-account` 路由上,若该路由已挂载且释放出凭据,操作发送账号凭据。其他所有 `auto` 操作,包括账号会话中没有登录或没有凭据的操作,都把已挂载的 `deepseek-official` 路由发布的密钥(由该路由按其 `apiKeyEnv` 解析,其基础地址包含 `DEEPSEEK_BASE_URL`)发往该路由基础地址的 origin 加 `/v1/tools`;没有该路由时,把 `DEEPSEEK_API_KEY` 发往 `https://api.deepseek.com/v1/tools`。`auto` 计费在两个 DeepSeek 路由之外的路由上或会话之外,没有配置密钥的操作改为发送账号令牌,因此已登录但没有密钥的用户在其他模型提供方的会话中仍可使用网页工具;在 `deepseek-official` 路由上从不发送令牌,因为该会话按 API 密钥计费。未登录的账号会话发送 API 密钥,网页工具因此在其中仍然可用。因此只有 `DEEPSEEK_API_KEY` 的用户(包括所有 headless、SDK 与 ACP 运行)默认即可搜索和抓取,通过模型提供方基础地址设置的网关或内部部署也在同一 origin 上提供 Web 访问。缺少凭据时,该能力未就绪,操作以 `WEB_PROVIDER_CREDENTIAL_MISSING` 失败,指引信息按计费方式点名账号登录、模型页面与该引用,以及计费方式字段。已挂载但配置无法解析的路由不视为不存在:需要该路由的操作未就绪,并在读取依赖该路由的凭据前以 `WEB_PROVIDER_MISCONFIGURED` 失败,不再尝试后续来源,也不发送请求,因此网关设置出错时请求不会被改发到官方端点。
账号凭据是 `ctx.deepseekAccount` 为请求端点释放的凭据,端点位于已挂载的 `deepseek-account` 路由向 `ctx.deepseekAuth` 登记的基础地址的 origin 加 `/v1/tools` 下;没有该路由时使用 `DEEPSEEK_BASE_URL` 所指的 origin。HTTP 401 会作废该凭据。`auto` 计费在 `deepseek-account` 路由上,若该路由已挂载且释放出凭据,操作发送账号凭据。其他所有 `auto` 操作,包括账号会话中没有登录或没有凭据的操作,都把已挂载的 `deepseek-official` 路由的密钥(按该路由的 `apiKeyEnv` 读取,其基础地址包含 `DEEPSEEK_BASE_URL`)发往该路由基础地址的 origin 加 `/v1/tools`;没有该路由时,把 `DEEPSEEK_API_KEY` 发往 `https://api.deepseek.com/v1/tools`。`auto` 计费在两个已挂载的 DeepSeek 路由之外的路由上(包括这两个路由 id 之一而其插件未挂载的情况)或会话之外,没有配置密钥的操作改为发送账号令牌,因此已登录但没有密钥的用户在其他模型提供方的会话中仍可使用网页工具;在已挂载的 `deepseek-official` 路由上从不发送令牌,因为该会话按 API 密钥计费。未登录的账号会话发送 API 密钥,网页工具因此在其中仍然可用。因此只有 `DEEPSEEK_API_KEY` 的用户(包括所有 headless、SDK 与 ACP 运行)默认即可搜索和抓取,通过模型提供方基础地址设置的网关或内部部署也在同一 origin 上提供 Web 访问。缺少凭据时,该能力未就绪,操作以 `WEB_PROVIDER_CREDENTIAL_MISSING` 失败,指引信息按计费方式点名账号登录、模型页面与该引用,以及计费方式字段。已挂载但配置无法解析的路由不视为不存在:需要该路由的操作未就绪,并在读取依赖该路由的凭据前以 `WEB_PROVIDER_MISCONFIGURED` 失败,不再尝试后续来源,也不发送请求,因此网关设置出错时请求不会被改发到官方端点。
在 YAML 中设置了非空 `searchBaseURL` 或 `searchApiKeyEnv`(Fetch 为 `fetchBaseURL` 或 `fetchApiKeyEnv`)的能力,则无论计费方式如何,始终把其 `*ApiKeyEnv`(未设置时为 `DEEPSEEK_API_KEY`)下的密钥发往其 `*BaseURL`(未设置时为官方基础地址),从不发送账号令牌,因此内网或第三方端点只收到为它选择的密钥。每个能力有自己的字段,因为一个部署可以由不同网关提供搜索和抓取。这些字段只能在 YAML 中设置,空值视为未设置。schema 之外字段的已保存值,包括 `baseURL`、`apiKeyEnv` 和 `apiKey`,可以加载而不产生 schema 错误,且不生效。
DeepSeek 模型路由通过 `ctx.llm.providerCredential()` 发布自己发送的凭据([路由凭据](2026-11-10-llm-route-credential-seam.zh.md)):API 密钥路由发布其 `apiKeyEnv` 下的密钥,账号路由发布 `ctx.deepseekAccount` 为目标地址释放的凭据。Messages 搜索以及 Search 与 Fetch API 读取这些发布的凭据而不读取提供方配置,并通过 `dsh-credentials` 的引用函数读取 `DEEPSEEK_API_KEY` 和单独配置的密钥,因此每个 DeepSeek 请求都以同一方式读取凭据库;授权提供失效操作的凭据会在 HTTP 401 后被作废。内置配置不需要按 profile 覆盖凭据,因为只要 `DEEPSEEK_API_KEY` 或 DeepSeek API 密钥路由有密钥,API 密钥路径就能工作。
这些凭据由 `ctx.deepseekAuth` 排序并释放([DeepSeek 请求鉴权](2026-11-10-deepseek-request-authentication.zh.md)):每条 DeepSeek 模型路由登记其设置所指的部署,API 密钥路由同时登记其 `apiKeyEnv` 下的密钥引用,账号登录凭据则是 `ctx.deepseekAccount` 为目标地址释放的凭据。Messages 搜索以及 Search 与 Fetch API 向该服务索取凭据而不读取提供方配置,该服务通过 `dsh-credentials` 的引用函数读取路由密钥、`DEEPSEEK_API_KEY` 和单独配置的密钥,因此每个 DeepSeek 请求都以同一方式读取凭据库;授权提供失效操作的凭据会在 HTTP 401 后被作废。内置配置不需要按 profile 覆盖凭据,因为只要 `DEEPSEEK_API_KEY` 或 DeepSeek API 密钥路由有密钥,API 密钥路径就能工作。
### 默认值与已保存的选择
@@ -0,0 +1,19 @@
# Bilingual-pair consistency record for 2026-11-10-deepseek-request-authentication.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write .agents/notes/implemented/architecture/2026-11-10-deepseek-request-authentication.md
/agent-note-deepseek-request-authentication-one-service-releases-the-api-key-or-the-account-sign-in-to-every-deepseek-consumer:
en: 0ede9c11789e5fd7
zh: c3e552dfe6216df0
/agent-note-deepseek-request-authentication-one-service-releases-the-api-key-or-the-account-sign-in-to-every-deepseek-consumer/problem:
en: 1470ef8f922d447a
zh: ccd66a1b897c88e2
/agent-note-deepseek-request-authentication-one-service-releases-the-api-key-or-the-account-sign-in-to-every-deepseek-consumer/decision:
en: 316f5dc600e50f33
zh: f52cacf521e94159
/agent-note-deepseek-request-authentication-one-service-releases-the-api-key-or-the-account-sign-in-to-every-deepseek-consumer/alternatives-considered:
en: 3a4f69542b4a91b2
zh: 1eb4edce81a858d6
/agent-note-deepseek-request-authentication-one-service-releases-the-api-key-or-the-account-sign-in-to-every-deepseek-consumer/consequences:
en: 88174cd0c4fca1ee
zh: ae56350b8198a0b0
@@ -0,0 +1,73 @@
# Agent Note: DeepSeek request authentication - one service releases the API key or the account sign-in to every DeepSeek consumer
Status: implemented
English | [中文](2026-11-10-deepseek-request-authentication.zh.md)
## Problem
DeepSeek APIs accept two kinds of credential, an API key and the account sign-in, and each API accepts one or both: the Messages, Files, and model-listing requests of each model route carry one kind, Search and Fetch accept both, and DeepSeek adds account authentication to its other APIs one at a time. No package owned the choice between the two kinds. `@deepseek-ai/dsh-llm-deepseek`, the protocol transport, exported helpers that read `ctx.credentials`, the launch environment, and `ctx.deepseekAccount`, so the transport depended on both credential services although it only sends the headers a route gives it. The two route plugins resolved their credentials through those helpers and threw their own missing-credential failures from inside `resolveAuth`. The Search and Fetch API providers re-derived each route's base URL and key reference from the Loader entry of the route package with that package's own config resolver, ordered the two credentials by their billing setting, and rendered the request headers; Messages search hard-coded the account route id and applied an order of its own. Both web packages therefore depended on `llm-deepseek`, on both route plugins, and on the Loader, and a consumer of another DeepSeek API would have repeated the selection, the deployment binding, the header rendering, and the invalidation. The account service, which sits below every consumer, owned Agent cancellation after sign-out and lived in the `credentials/` group beside the credential store it only uses. A change to how one route authenticates touched the transport, both web providers, and their tests.
## Decision
`@deepseek-ai/dsh-deepseek-auth`, in the `packages/account/` group, provides `ctx.deepseekAuth`. The package holds the Service Definition and the Service Provider of DeepSeek request authentication, and every plugin that calls a DeepSeek API is a Consumer. A consumer describes one request: the credential kinds its API `accepts`, the `billing` its settings choose, the model `route` of the conversation, and a `destination`, either a path under the chosen kind's deployment or one absolute URL. `candidates(request)` returns the kinds in billing order, each bound to the endpoint its credential is sent to, and reads no credential. `authorize(request, signal)` releases the first kind that has a credential as a `DeepSeekAuthorization`: the `kind`, the `endpoint`, the request `headers`, the key `reference` for diagnostics, and for the account sign-in a `reject()` for HTTP 401 and a `revoked` signal that aborts when the account signs out. An authorization carries no bare credential value: a consumer names the headers an API key is sent in through `apiKeyHeaders`, and the account service chooses the header of the sign-in.
The service owns the billing order. `api-key` and `account` billing try that kind only. `auto` follows the conversation: on the route a plugin connected for the account sign-in, the sign-in and then the API key; on the route a plugin connected for the API key, the API key; on any other route, or outside a conversation, the API key and then the sign-in. The service names no route id: each model route plugin passes the provider route it registers when it connects, and `routeKind(route)` answers the kind connected under that id. A conversation recorded on `deepseek-account` or `deepseek-official` whose plugin is not mounted is ordered as any other route. A kind outside `accepts` is never a candidate.
Each kind has one deployment at a time. A model route plugin connects its provider route and the deployment its settings name with `connect(kind, route, connection)` inside `ctx.effect()`, and the service calls `connection` for each request. Without a connection the API key is `DEEPSEEK_API_KEY` at `https://api.deepseek.com`, and the sign-in goes to the origin `DEEPSEEK_BASE_URL` names, the official API by default. A credential is released only for a destination under the origin of its kind's deployment that embeds no credentials. A request can carry its own connection of a kind in `connections`, which replaces the connected or default one: a model route passes the configuration generation it captured for one model request, and a consumer with its own endpoint and key passes those. A kind whose connection does not resolve stays among the candidates as an unresolved entry, and `authorize()` stops there with `UNRESOLVED_CONNECTION` and does not try a later kind.
The API key is read through `resolveCredentialRef` and `credentialRefConfigured` of `@deepseek-ai/dsh-credentials`, which treat a mounted credentials service as authoritative and read the launch environment only without one. `dsh-credentials` also owns `normalizeApiKey`, the Host definition of a key that an HTTP header can carry, which answers the trimmed key or the reason a key cannot be used and words no diagnostic. The service words the diagnostic of an unusable key and reports it as `DeepSeekAuthError` with code `INVALID_CREDENTIAL`, `llm-pi-ai` words its own and reports it as `LlmError`, and `@deepseek-ai/dsh-llm` holds neither a credential interface nor a key check. The account sign-in is what `ctx.deepseekAccount.resolveRequestCredential(endpoint)` releases; it is absent in a composition without the account service.
`@deepseek-ai/dsh-llm-deepseek` reads no credential. `DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` returns the request headers, an optional `revoked` signal, and an optional failure callback, or `undefined`; `missingCredential(connection, provider)` names the failure of a request without a credential, `MISSING_CREDENTIAL` by default. The transport runs each model request and its file operations under the `revoked` signal and hands the resulting failure to the provider's failure callback, which names it. The listing cache scopes by endpoint and a hash of the credential headers.
The route plugins are consumers that also connect their deployment, and both require the service. `llm-deepseek-api-key` connects, under its route id, its base URL, its `apiKeyEnv` reference, and its settings namespace as the owner that key diagnostics name; it asks for the key in `x-api-key` with `accepts: ['api-key']` and reports an unusable key as its own `INVALID_CREDENTIAL`. `llm-deepseek-account` connects its base URL under its route id, asks with `accepts: ['account']`, maps HTTP 401 to `ACCOUNT_TOKEN_INVALID` and quota failures to `ACCOUNT_QUOTA`, fails without a credential as `ACCOUNT_SIGN_IN_REQUIRED`, and owns the sign-out policy: it cancels its running Agents on `deepseek-account/signed-out` and registers a running-task report with the account service. A request in flight at sign-out ends with its authorization's `revoked` signal and fails as `ACCOUNT_SIGN_IN_REQUIRED`, and its failure callback cancels the same Agents, so a request that outlives the plugin still ends its turn with the signed-out cause.
`@deepseek-ai/dsh-deepseek-account` releases request credentials to the authentication service. `resolveRequestCredential(url)` returns the `x-dsh-auth-token` header, a `reject()` that removes the grant while it still matches and contains storage failures, and a `revoked` signal the account service aborts at each sign-out after the `deepseek-account/signed-out` listeners have returned; `registerRunningTaskReport(report)` feeds `hasRunningAccountTasks()`. The account service inspects no Agents and depends on neither `dsh-agent`, `dsh-llm`, nor the authentication service. The package lives in the `packages/account/` group under its unchanged name.
The web providers declare what their APIs accept. `web-deepseek-api` asks for candidates with `accepts: ['account', 'api-key']`, the capability's billing, the conversation's route, and the path `/v1/tools/search` or `/v1/tools/fetch`; a capability with its own `*BaseURL` or `*ApiKeyEnv` asks with `accepts: ['api-key']` and its own connection, so only that key goes to that endpoint. `web-search-deepseek` passes its search endpoint as an absolute destination and its referenced key as its own connection. In a conversation on the connected account route it asks with `auto` billing, so the sign-in comes first when the search endpoint is under the origin of the account deployment; every other search asks with `api-key` billing. A literal `apiKey` is the provider's own credential: beside it the provider asks only for the sign-in, and sends the literal key when the service releases none. `web-deepseek-api` words its missing-credential and unresolved-settings failures from the candidates. Both web consumers contain a failed `reject()` so the HTTP rejection stays the reported error, run their request under the authorization's `revoked` signal, and report a request that signal ended as `WEB_PROVIDER_ERROR` with sign-in guidance, keeping `WEB_ABORTED` for the caller's cancellation. Neither web package depends on `llm-deepseek`, the route plugins, the Loader, or the account service, and neither reads a credential through `dsh-llm`: `web-search-deepseek` does not depend on it, and `web-deepseek-api` imports only the message text helper `extractTextContent` from it.
## Alternatives considered
**Publishing each route's credential through the model service.** `LlmAdapter.providerCredential(provider)` on `dsh-llm` would answer a route's credential kind, its base URL, and a grant for one endpoint, and consumers would read `ctx.llm.providerCredential('deepseek-official')` and `providerCredential('deepseek-account')`. A lookup keyed by model route leaves every consumer to order the two credentials by billing, to render its own headers from a bare value, and to fall back by itself when a route is not mounted. An API outside the model protocol, such as the speech and document APIs under `/v1/tools/`, has no route to ask and no place to declare the kinds it accepts. The model service would carry a credential interface with one publisher, the DeepSeek adapter, and two web consumers.
**A shared library over that publication instead of a service.** The model routes authenticate through the same operation as every other consumer, and a library that reads what the routes publish cannot serve the routes themselves.
**Checking keys through `dsh-llm`, through a copy in the service, or through a validator each consumer passes.** A service shared by every DeepSeek consumer must not depend on the model service, which is one consumer's dependency. A second Host copy of the rule would be kept in step with the first and with the browser's copy by comments only. A validator parameter would make each consumer that accepts a key pass one, and the web packages would keep their `dsh-llm` dependency for it. The check lives in `dsh-credentials`, the layer that reads the key, and each caller words its own failure for the reason the check returns.
**The diagnostic text of an unusable key in `dsh-credentials`.** One function there would give the service and `llm-pi-ai` the same words. The text tells the user to set the reference on the Models page, so the package that stores credentials would name a page of its consumers. Each of the two callers words the text, and the credential store names no consumer.
**`dsh-llm` importing the key check from `dsh-credentials`.** Nothing in the model service reads a key. Its only caller of the check was `llm-pi-ai`, which already depends on `dsh-credentials`, so the model service exports no key check and gains no dependency.
**A `deepseek-api-key` package beside `deepseek-account`.** `deepseek-account` is the account product feature: browser sign-in, the stored grant, profile, balance, notifications, and the Platform session, of which releasing a request credential is a small part. The API key has no such feature. It is a named string in the generic credential store, and its DeepSeek-specific logic is the key source inside the service. A package becomes worthwhile when DeepSeek-specific key behavior appears, such as a balance per key, server-side validation, or several keys.
**Merging the two model route plugins, or their route ids.** They are two model providers with different settings and catalog sources, the `ACCOUNT_*` failure mapping, and the sign-out policy over running tasks. The route id is the durable record of how a conversation is billed: Session logs carry it, and sign-out cancellation and `auto` billing read it.
**A fixed table of the two DeepSeek route ids in the service.** `routeKind()` would answer for `deepseek-account` and `deepseek-official` whichever plugins are mounted, and a conversation recorded on the account route would try only the API key while the account route plugin is not mounted. The table would put the route ids of two consumers into the service those consumers depend on. Each route plugin passes its own id when it connects, and a route id whose plugin is not mounted is ordered as any other route.
**Route plugins that work without the service.** An optional service would leave compositions and tests that mount a route by hand unchanged, but each route would keep a credential path that bypasses the service.
**One billing order for every consumer.** Messages search outside an account conversation never tries the sign-in. Giving it the general order would change which credential existing conversations send, so the rule stays.
**A credential fingerprint in the authorization.** Consumers only send requests, so they need headers; cache scoping by credential is the adapter's own concern, which the listing cache meets by hashing the headers it sends.
**A `credentials-env` provider instead of reference helpers.** A provider that reads the environment would change which composition is authoritative for every consumer; the helpers keep the launch-environment fallback local to the consumers that need it, so such a provider remains an independent option.
**The account service's inference origin for the sign-in without a connected account route.** Routing that default through `DEEPSEEK_BASE_URL` keeps the keyless billing snapshot and every documented deployment unchanged; the account service still refuses every origin but its own.
**Moving the account package into `identity/`.** That group defines anonymous, user-independent ids; a signed-in account is the opposite, so it gets a group of its own.
**Keeping the route plugin's sign-out listener until its tasks end.** Unloading the route then waits for a running turn: disabling the plugin blocks, and every other settings write queues behind that reload, for as long as the turn runs.
**Cancelling the route's tasks when the route unloads.** A configuration reload or a plugin update would stop turns that no sign-out touched.
**Returning the sign-out policy to the account service.** The service would again inspect Agents and know route ids, the dependencies this decision removes.
**Keeping the route's listener or report registered after its plugin unloads.** A registration that outlives the plugin that made it breaks the rule that registrations are effects of their owner, and leaves code of an unloaded plugin running in another scope for as long as the task runs.
## Consequences
A consumer of another DeepSeek API declares the kinds that API accepts; it reads no credential, renders no header, and holds no fallback. When an API gains a kind, its consumer widens `accepts`. A new credential kind is a source in the service and a member of `DeepSeekAuthKind`. The transport, the model service, the web providers, and the account service do not depend on one another for credentials, and `hasRunningAccountTasks()` depends on a registered report rather than on Agents the account service can see. The `llm-deepseek` credential helpers and the route plugins' config exports do not exist; the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-rc.3/deepseek-request-auth/guide.md) lists the replacements.
Every composition that mounts a DeepSeek model route or a DeepSeek web provider mounts the service; without it those plugins wait and register nothing. The `base` and `sdk-minimal` bundles carry its row, and the SDK server mounts it with its fallback route when the composition has none. One deployment per kind means a second `connect()` of a kind throws `DUPLICATE_CONNECTION`. `auto` billing recognizes a route only while the plugin that registers it is connected: a conversation recorded on `deepseek-account` or `deepseek-official` whose plugin is not mounted, and a DeepSeek model reached through another provider plugin, are ordered as any other route, so their Search and Fetch operations send the API key and, without a key, the account sign-in. A route's configuration failure reaches consumers as an unresolved candidate: the Search and Fetch APIs report it as `WEB_PROVIDER_MISCONFIGURED`, Messages search as `WEB_PROVIDER_ERROR`, and neither tries a later credential. An unusable key reaches a web tool's result under the error name `DeepSeekAuthError`.
A sign-out ends the in-flight model, Files, Search, and Fetch requests that carry the account token, including requests no Agent turn owns, such as a model request outside a turn or an account-billed web search; the account listing request keeps its own deadline. The signal supplements the Agent cancellation of the [account sign-out decision](2026-09-17-account-provider-signout.md), which rejected a login-level signal as a duplicate of that chain: the chain reaches a request only through a mounted listener and a running Agent turn. While the account route is disabled, a task it started that still runs is not reported to the sign-out confirmation, and a sign-out ends it only through a model request in flight. A credential released by an account service that has since been replaced is not withdrawn by the replacement's sign-out; the route plugin's listener still cancels Agent turns.
@@ -0,0 +1,73 @@
# Agent Note: DeepSeek request authentication - one service releases the API key or the account sign-in to every DeepSeek consumer
Status: implemented
[English](2026-11-10-deepseek-request-authentication.md) | 中文
## 问题
DeepSeek 的 API 接受两种凭据:API 密钥和账号登录。每个 API 接受其中一种或两种:每条模型路由的 Messages、Files 和模型列表请求只带一种,Search 与 Fetch 两种都接受,DeepSeek 还在逐个为其他 API 增加账号鉴权。在两种凭据之间做选择这件事没有所有者。协议传输层 `@deepseek-ai/dsh-llm-deepseek` 导出读取 `ctx.credentials`、启动环境和 `ctx.deepseekAccount` 的辅助函数,因此尽管传输层只发送路由交给它的请求头,它仍依赖两个凭据服务。两个路由插件通过这些函数解析凭据,并在 `resolveAuth` 内部抛出各自的凭据缺失错误。Search 与 Fetch API 提供方用路由包自己的配置解析函数,从路由包的 Loader 条目重新推导每条路由的基础地址和密钥引用,按自己的计费设置排定两种凭据的顺序,并自己组装请求头;Messages 搜索则硬编码账号路由 id,并使用自己的一套顺序。因此两个 Web 包都依赖 `llm-deepseek`、两个路由插件和 Loader,而其他 DeepSeek API 的消费方还得把选择凭据、绑定部署、组装请求头和作废凭据再做一遍。位于所有消费方之下的账号服务拥有退登后的 Agent 取消逻辑,并和它仅仅使用的凭据库一起放在 `credentials/` 组。改变一条路由的鉴权方式要同时触及传输层、两个 Web 提供方及其测试。
## 决策
位于 `packages/account/` 组的 `@deepseek-ai/dsh-deepseek-auth` 提供 `ctx.deepseekAuth`。该包同时承担 DeepSeek 请求鉴权的 Service Definition 和 Service Provider,每个调用 DeepSeek API 的插件都是 Consumer。消费方描述一次请求:它的 API 接受的凭据种类 `accepts`、其设置选择的计费方式 `billing`、会话的模型路由 `route`,以及目的地 `destination`,即所选种类的部署之下的一个路径,或一个绝对 URL。`candidates(request)` 按计费顺序返回各个种类,每个种类都绑定到其凭据发往的端点,且不读取任何凭据。`authorize(request, signal)` 把第一个持有凭据的种类释放为 `DeepSeekAuthorization`:`kind`、`endpoint`、请求 `headers`、供诊断使用的密钥 `reference`,账号登录还带有用于 HTTP 401 的 `reject()` 和在账号退登时中止的 `revoked` 信号。授权不携带裸的凭据值:消费方通过 `apiKeyHeaders` 指定 API 密钥放进哪些请求头,账号登录的请求头由账号服务决定。
计费顺序由该服务拥有。`api-key` 与 `account` 计费只尝试对应的那一种。`auto` 跟随会话:在某个插件为账号登录登记的路由上先尝试账号登录、再尝试 API 密钥;在某个插件为 API 密钥登记的路由上只尝试 API 密钥;在其他路由上或不在会话中时,先尝试 API 密钥、再尝试账号登录。该服务自身不写任何路由 id:每个模型路由插件在登记时传入它注册的提供方路由,`routeKind(route)` 回答在该 id 下登记的种类。记录在 `deepseek-account` 或 `deepseek-official` 上的会话,在对应插件未挂载时按其他路由处理。不在 `accepts` 中的种类永远不会成为候选。
每个种类同一时间只有一个部署。模型路由插件在 `ctx.effect()` 内用 `connect(kind, route, connection)` 登记自己的提供方路由及其设置所指的部署,服务为每个请求调用 `connection`。没有登记时,API 密钥是发往 `https://api.deepseek.com` 的 `DEEPSEEK_API_KEY`,账号登录发往 `DEEPSEEK_BASE_URL` 所指的 origin,默认为官方 API。凭据只释放给其种类的部署 origin 之下且不内嵌凭据的目的地。请求可以在 `connections` 里携带某一种类自己的连接,它取代已登记的或默认的连接:模型路由传入它为一次模型请求捕获的那一代配置,拥有自己端点和密钥的消费方传入这两项。连接无法解析的种类作为未解析条目留在候选中,`authorize()` 在此以 `UNRESOLVED_CONNECTION` 停止,不再尝试后面的种类。
API 密钥通过 `@deepseek-ai/dsh-credentials` 的 `resolveCredentialRef` 和 `credentialRefConfigured` 读取,二者把已挂载的凭据服务视为权威,仅在没有该服务时读取启动环境。`dsh-credentials` 还拥有 `normalizeApiKey`,即 Host 端对“能放进 HTTP 请求头的密钥”的定义:它回答去掉首尾空白后的密钥,或密钥不可用的原因,不生成任何诊断文案。该服务为不可用的密钥写出诊断文案,并将其报告为代码 `INVALID_CREDENTIAL` 的 `DeepSeekAuthError`,`llm-pi-ai` 写出自己的文案并报告为 `LlmError`,`@deepseek-ai/dsh-llm` 既不带凭据接口也不带密钥检查。账号登录就是 `ctx.deepseekAccount.resolveRequestCredential(endpoint)` 释放的凭据;组合中没有账号服务时不存在这种凭据。
`@deepseek-ai/dsh-llm-deepseek` 不读取任何凭据。`DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` 返回请求头、可选的 `revoked` 信号和可选的失败回调,或 `undefined`;`missingCredential(connection, provider)` 命名没有凭据时请求的失败,默认为 `MISSING_CREDENTIAL`。传输层让每次模型请求及其文件操作受 `revoked` 信号约束,并把由此产生的失败交给提供方的失败回调命名。列表缓存以端点和凭据请求头的哈希划分作用域。
路由插件是同时登记自身部署的消费方,二者都要求该服务已挂载。`llm-deepseek-api-key` 在自己的路由 id 下登记其基础地址、`apiKeyEnv` 引用,以及作为密钥诊断所指属主的设置命名空间;它以 `accepts: ['api-key']` 索取放在 `x-api-key` 里的密钥,并把不可用的密钥报告为自己的 `INVALID_CREDENTIAL`。`llm-deepseek-account` 在自己的路由 id 下登记其基础地址,以 `accepts: ['account']` 索取凭据,把 HTTP 401 映射为 `ACCOUNT_TOKEN_INVALID`、配额失败映射为 `ACCOUNT_QUOTA`,没有凭据时以 `ACCOUNT_SIGN_IN_REQUIRED` 失败,并拥有退登策略:在 `deepseek-account/signed-out` 时取消其运行中的 Agent,并向账号服务注册运行中任务报告。退登时在途的请求随其授权的 `revoked` 信号结束,以 `ACCOUNT_SIGN_IN_REQUIRED` 失败;它的失败回调会取消同一批 Agent,因此比插件存活更久的请求仍会以退登原因结束其回合。
`@deepseek-ai/dsh-deepseek-account` 向鉴权服务释放请求凭据。`resolveRequestCredential(url)` 返回 `x-dsh-auth-token` 请求头、`reject()` 和 `revoked` 信号;`reject()` 仅在已存储的授权记录仍一致时删除它并隔离存储失败,`revoked` 由账号服务在每次退登时、`deepseek-account/signed-out` 的监听器返回之后中止。`registerRunningTaskReport(report)` 为 `hasRunningAccountTasks()` 提供答案。账号服务不检查任何 Agent,也不依赖 `dsh-agent`、`dsh-llm` 或鉴权服务。包以不变的名字位于 `packages/account/` 组。
Web 提供方声明各自的 API 接受什么。`web-deepseek-api` 以 `accepts: ['account', 'api-key']`、该能力的计费设置、会话的路由,以及路径 `/v1/tools/search` 或 `/v1/tools/fetch` 索取候选;设置了自己的 `*BaseURL` 或 `*ApiKeyEnv` 的能力以 `accepts: ['api-key']` 和自己的连接索取,因此发往该端点的只有那把密钥。`web-search-deepseek` 把搜索端点作为绝对目的地传入,把它引用的密钥作为自己的连接传入。在已登记的账号路由上的会话里,它以 `auto` 计费索取,因此当搜索端点位于账号部署的 origin 之下时先尝试账号登录;其他搜索都以 `api-key` 计费索取。字面 `apiKey` 是该提供方自己的凭据:有它时提供方只索取账号登录,服务不释放任何凭据时发送字面密钥。`web-deepseek-api` 依据候选来措辞凭据缺失和设置无法解析的失败。两个 Web 消费方都隔离失败的 `reject()` 以保证报告的是 HTTP 拒绝,都让请求受授权的 `revoked` 信号约束,并把被该信号结束的请求报告为带登录指引的 `WEB_PROVIDER_ERROR`,`WEB_ABORTED` 仍只表示调用方取消。两个 Web 包都不依赖 `llm-deepseek`、路由插件、Loader 或账号服务,也都不经 `dsh-llm` 读取凭据:`web-search-deepseek` 不依赖它,`web-deepseek-api` 只从它导入消息文本辅助函数 `extractTextContent`。
## 考虑过的替代方案
**通过模型服务发布每条路由的凭据。** `dsh-llm` 上的 `LlmAdapter.providerCredential(provider)` 回答一条路由的凭据种类、基础地址和面向某个端点的授权,消费方读取 `ctx.llm.providerCredential('deepseek-official')` 和 `providerCredential('deepseek-account')`。按模型路由查询意味着每个消费方都要自己按计费排定两种凭据的顺序、自己用裸值组装请求头,并在路由未挂载时自己回退。模型协议之外的 API,例如 `/v1/tools/` 下的语音和文档 API,既没有可以询问的路由,也没有地方声明它接受哪些种类。模型服务还要带上一个凭据接口,而它只有 DeepSeek 适配器一个发布方和两个 Web 消费方。
**在上述发布之上用公共库代替服务。** 模型路由与其他消费方通过同一个操作鉴权,而读取路由所发布内容的库无法反过来为路由本身服务。
**通过 `dsh-llm` 检查密钥、在服务里保留一份副本,或由每个消费方传入校验函数。** 所有 DeepSeek 消费方共用的服务不能依赖模型服务,后者只是其中一类消费方的依赖。Host 端的第二份规则只能靠注释与第一份以及浏览器端的那份保持一致。校验函数参数会让每个接受密钥的消费方都传一个,两个 Web 包也要为此继续依赖 `dsh-llm`。检查放在读取密钥的那一层 `dsh-credentials`,每个调用方依据检查返回的原因写出自己的失败。
**把不可用密钥的诊断文案放在 `dsh-credentials`。** 那里的一个函数能让该服务和 `llm-pi-ai` 使用同样的措辞。但文案要告诉用户在 Models 页面设置该引用,存储凭据的包就会写出其消费方的页面。两个调用方各自写出文案,凭据存储不写任何消费方的名字。
**让 `dsh-llm` 从 `dsh-credentials` 导入密钥检查。** 模型服务里没有任何代码读取密钥。该检查在其中唯一的调用方是 `llm-pi-ai`,而它已经依赖 `dsh-credentials`,因此模型服务不导出密钥检查,也不新增依赖。
**在 `deepseek-account` 旁边设一个 `deepseek-api-key` 包。** `deepseek-account` 是账号这项产品功能:浏览器登录、已存储的授权、资料、余额、通知和 Platform 会话,释放请求凭据只占其中一小部分。API 密钥没有这样的功能。它是通用凭据库里一个有名字的字符串,它的 DeepSeek 专属逻辑就是服务内部的密钥来源。等到出现 DeepSeek 专属的密钥行为,例如按密钥查余额、向服务端校验或多把密钥,才值得拆出一个包。
**合并两个模型路由插件,或合并它们的路由 id。** 它们是两个模型提供方,设置和目录来源不同,还各有 `ACCOUNT_*` 失败映射和针对运行中任务的退登策略。路由 id 是一段会话如何计费的持久记录:会话日志携带它,退登取消和 `auto` 计费读取它。
**在服务里放一张含两个 DeepSeek 路由 id 的固定表。** 无论挂载了哪些插件,`routeKind()` 都会为 `deepseek-account` 和 `deepseek-official` 作答,记录在账号路由上的会话在账号路由插件未挂载时只尝试 API 密钥。这张表会把两个消费方的路由 id 写进它们所依赖的服务。每个路由插件在登记时传入自己的 id,插件未挂载的路由 id 按其他路由处理。
**让路由插件在没有该服务时也能工作。** 把服务做成可选依赖可以让手工挂载路由的组合和测试保持不变,但每条路由都要保留一条绕过该服务的取凭据路径。
**让所有消费方使用同一套计费顺序。** Messages 搜索在账号会话之外从不尝试账号登录。让它采用通用顺序会改变现有会话发送的凭据,因此这条规则保留。
**在授权中加入凭据指纹。** 消费方只负责发送请求,因此只需要请求头;按凭据划分缓存作用域是适配器自己的事,列表缓存通过哈希它发送的请求头即可满足。
**用 `credentials-env` 提供方代替引用函数。** 读取环境的提供方会改变每个消费方眼中哪个组合具有权威性;引用函数把启动环境后备保留在需要它的消费方本地,使这样的提供方仍是独立的选项。
**没有登记账号路由时,账号登录使用账号服务的推理 origin。** 让该默认值经由 `DEEPSEEK_BASE_URL` 可保持无密钥计费快照和所有已记录部署不变;账号服务仍拒绝除自身 origin 以外的一切来源。
**把账号包并入 `identity/`。** 该组定义匿名、不识别用户的 id;已登录账号与之相反,因此单独成组。
**让路由插件的退登监听保留到其任务结束。** 这样卸载路由要等待运行中的回合:停用插件会被阻塞,其他设置写入也排在这次重载之后,直到回合结束。
**路由卸载时取消其任务。** 配置重载或插件更新会停掉与退登无关的回合。
**把退登策略放回账号服务。** 账号服务将重新检查 Agent 并认识路由 id,而这正是本决策去掉的依赖。
**插件卸载后仍保留路由的监听或报告注册。** 比注册它的插件存活更久的注册违反“注册是其所有者的 effect”这一规则,并让已卸载插件的代码在任务运行期间留在其他作用域里。
## 后果
其他 DeepSeek API 的消费方只声明该 API 接受的种类;它不读取凭据、不组装请求头,也不保留回退逻辑。某个 API 新增一种凭据时,它的消费方扩充 `accepts`。新增凭据种类意味着在服务里加一个来源,并为 `DeepSeekAuthKind` 加一个成员。传输层、模型服务、Web 提供方和账号服务在凭据上互不依赖,`hasRunningAccountTasks()` 依赖注册的报告而非账号服务可见的 Agent。`llm-deepseek` 的凭据辅助函数和路由插件的配置导出不复存在;[升级指南](../../../../docs/upgrade-guide/v0.2.2-rc.3/deepseek-request-auth/guide.zh.md)列出了替代方案。
凡是挂载 DeepSeek 模型路由或 DeepSeek Web 提供方的组合都要挂载该服务;没有它时这些插件一直等待,不注册任何东西。`base` 和 `sdk-minimal` 两个组合包带有它的条目,SDK 服务端在组合里没有它时随后备路由一起挂载它。每个种类一个部署意味着对同一种类第二次 `connect()` 会抛出 `DUPLICATE_CONNECTION`。`auto` 计费只在注册某条路由的插件已登记时才认它:记录在 `deepseek-account` 或 `deepseek-official` 上而对应插件未挂载的会话,以及经由其他提供方插件访问的 DeepSeek 模型,都按其他路由处理,因此它们的 Search 与 Fetch 操作发送 API 密钥,没有密钥时发送账号登录。路由的配置失败以未解析候选的形式到达消费方:Search 与 Fetch API 将其报告为 `WEB_PROVIDER_MISCONFIGURED`,Messages 搜索报告为 `WEB_PROVIDER_ERROR`,二者都不再尝试后面的凭据。不可用的密钥在 Web 工具的结果里以错误名 `DeepSeekAuthError` 出现。
退登会结束携带账号 token 的在途模型、Files、Search 与 Fetch 请求,包括不属于任何 Agent 回合的请求,例如回合之外的模型请求或按账号计费的 Web 搜索;账号列表请求仍只受自身期限约束。该信号是对[账号退登决策](2026-09-17-account-provider-signout.zh.md)中 Agent 取消链路的补充;那份决策以重复该链路为由否决了登录级信号,而该链路只能经由已挂载的监听和运行中的 Agent 回合到达请求。账号路由被停用期间,它此前启动且仍在运行的任务不会报告给退登确认,退登也只能通过在途的模型请求结束它。已被替换的账号服务释放的凭据不会被替换后服务的退登撤回;路由插件的监听仍会取消 Agent 回合。
@@ -1,19 +0,0 @@
# Bilingual-pair consistency record for 2026-11-10-llm-route-credential-seam.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write .agents/notes/implemented/architecture/2026-11-10-llm-route-credential-seam.md
/agent-note-route-credentials-deepseek-model-routes-publish-the-credential-consumers-reuse:
en: d11883f28d5cdd99
zh: 860795ae4d93c317
/agent-note-route-credentials-deepseek-model-routes-publish-the-credential-consumers-reuse/problem:
en: 9665e1879893fe76
zh: 9da30ad0be6fc38d
/agent-note-route-credentials-deepseek-model-routes-publish-the-credential-consumers-reuse/decision:
en: aaa2d2c7202408d4
zh: 134987da042fd07b
/agent-note-route-credentials-deepseek-model-routes-publish-the-credential-consumers-reuse/alternatives-considered:
en: d6b2de393add9887
zh: b5351f9a49387bd6
/agent-note-route-credentials-deepseek-model-routes-publish-the-credential-consumers-reuse/consequences:
en: df942606f0d31fa5
zh: cb1f21dd7f60ab7f
@@ -1,47 +0,0 @@
# Agent Note: Route credentials - DeepSeek model routes publish the credential consumers reuse
Status: implemented
English | [中文](2026-11-10-llm-route-credential-seam.zh.md)
## Problem
Several packages shared one DeepSeek credential without an owner. `@deepseek-ai/dsh-llm-deepseek`, the protocol transport, exported helpers that read `ctx.credentials`, the launch environment, and `ctx.deepseekAccount`, so the transport depended on both credential services although it only sends the headers a route gives it. The two route plugins resolved their credentials through those helpers and threw their own missing-credential failures from inside `resolveAuth`. The Search and Fetch API providers re-derived each route's base URL and key reference from the Loader entry of the route package with that package's own config resolver, and Messages search hard-coded the account route id, so both web packages depended on `llm-deepseek`, on both route plugins, and on the Loader. The account service, which sits below every consumer, owned Agent cancellation after sign-out and lived in the `credentials/` group beside the credential store it only uses. A change to how one route authenticates touched the transport, both web providers, and their tests.
## Decision
`@deepseek-ai/dsh-llm` owns the Service Definition. `LlmAdapter.providerCredential(provider)` publishes a `ProviderCredential`: the route's `kind` (merge-extensible, with `api-key` and `account` declared), its resolved `baseURL`, an optional credential `reference` for diagnostics, `configured(endpoint)` for presence checks that neither validate the credential nor contact the destination, and `resolve(endpoint, signal)` returning a `ProviderCredentialGrant` with the protocol `headers`, the bare `value` for destinations that render it differently, an optional `reject()` for HTTP 401, and an optional `revoked` signal that aborts when the owner withdraws the credential while requests carry it. `LlmRuntime.providerCredential(provider)` forwards to the owning adapter; an unregistered route answers `undefined`, and a route whose configuration does not resolve propagates the adapter's failure. The adapter reads one configuration generation per call, as it does per model request.
`@deepseek-ai/dsh-llm-deepseek` reads no credential. `DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` returns the grant or `undefined`; `missingCredential(connection, provider)` names the failure of a request without one, `MISSING_CREDENTIAL` by default; `credential` declares the published kind, reference, and presence check. The transport runs each model request and its file operations under the grant's `revoked` signal and hands the resulting failure to the provider's failure callback, which names it. The listing cache scopes by endpoint and a hash of the credential headers.
The route plugins own credentials. `llm-deepseek-api-key` reads its key through `resolveCredentialRef` and `credentialRefConfigured`, new in `@deepseek-ai/dsh-credentials`, which treat a mounted credentials service as authoritative and read the launch environment only without one; it publishes kind `api-key` with the `apiKeyEnv` reference and releases the key only for destinations under the origin of its base URL. `llm-deepseek-account` reads `ctx.deepseekAccount.resolveRequestCredential(endpoint)`, maps HTTP 401 to `ACCOUNT_TOKEN_INVALID` and quota failures to `ACCOUNT_QUOTA`, fails without a credential as `ACCOUNT_SIGN_IN_REQUIRED`, publishes kind `account`, and owns the sign-out policy: it cancels its running Agents on `deepseek-account/signed-out` and registers a running-task report with the account service. A request in flight at sign-out ends with its grant's `revoked` signal and fails as `ACCOUNT_SIGN_IN_REQUIRED`, and its failure callback cancels the same Agents, so a request that outlives the plugin still ends its turn with the signed-out cause.
`@deepseek-ai/dsh-deepseek-account` releases request credentials. `resolveRequestCredential(url)` returns the `x-dsh-auth-token` header, the bare token, a `reject()` that removes the grant while it still matches and contains storage failures, and a `revoked` signal the service aborts at each sign-out after the `deepseek-account/signed-out` listeners have returned; `registerRunningTaskReport(report)` feeds `hasRunningAccountTasks()`. The service inspects no Agents and depends on neither `dsh-agent` nor `dsh-llm`. The package lives in the `packages/account/` group under its unchanged name.
The web providers consume publications. `web-deepseek-api` builds each operation's ordered sources from `ctx.llm.providerCredential('deepseek-official')` and `providerCredential('deepseek-account')`: a route source sends an `api-key` grant's value as a bearer token and any other kind's headers unchanged, and invalidates through the grant's `reject()`. Under each route id it accepts only the kind that route publishes, `api-key` as `deepseek-official` and `account` as `deepseek-account`, so billing by route id never sends the other kind. Without the API-key route it reads `DEEPSEEK_API_KEY` through the reference helpers; without the account route it asks the account service for the origin `DEEPSEEK_BASE_URL` names. `web-search-deepseek` uses the account credential of the initiating Session's route when that route publishes kind `account` and the search endpoint has the origin of the route's base URL, and the reference helpers otherwise; it does not request an account credential published for another origin. Both web consumers contain a failed `reject()`, so the HTTP rejection stays the reported error for every credential kind. Both run their request under the grant's `revoked` signal and report a request it ended as `WEB_PROVIDER_ERROR` with sign-in guidance, keeping `WEB_ABORTED` for the caller's cancellation. Neither web package depends on `llm-deepseek`, the route plugins, or the Loader, and `web-search-deepseek` no longer depends on the account service.
## Alternatives considered
**A `deepseek-auth` package holding the credential seam.** The seam needs a Service Definition only, no Cordis service, and that one Definition role belongs beside `LlmAdapter`; a package for an interface adds a dependency without an owner of behavior.
**A credential fingerprint in the published credential.** Consumers only send requests, so they need headers and a value; cache scoping by credential is the adapter's own concern, which the listing cache meets by hashing the headers it sends.
**A `credentials-env` provider instead of reference helpers.** A provider that reads the environment would change which composition is authoritative for every consumer; the helpers keep the launch-environment fallback local to the consumers that need it, so such a provider remains an independent option.
**The account service's inference origin for the web fallback without the account route.** Routing that fallback through `DEEPSEEK_BASE_URL` keeps the keyless billing snapshot and every documented deployment unchanged; the account service still refuses every origin but its own.
**Moving the account package into `identity/`.** That group defines anonymous, user-independent ids; a signed-in account is the opposite, so it gets a group of its own.
**Keeping the route plugin's sign-out listener until its tasks end.** Unloading the route then waits for a running turn: disabling the plugin blocks, and every other settings write queues behind that reload, for as long as the turn runs.
**Cancelling the route's tasks when the route unloads.** A configuration reload or a plugin update would stop turns that no sign-out touched.
**Returning the sign-out policy to the account service.** The service would again inspect Agents and know route ids, the dependencies this decision removes.
**Keeping the route's listener or report registered after its plugin unloads.** A registration that outlives the plugin that made it breaks the rule that registrations are effects of their owner, and leaves code of an unloaded plugin running in another scope for as long as the task runs.
## Consequences
Adding a credential kind, or a consumer of a route's credential, touches one route plugin or one consumer, not the transport. The transport, the web providers, and the account service lose their cross-dependencies, and `hasRunningAccountTasks()` depends on a registered report rather than on Agents the account service can see. Consumers that construct `DeepSeekRequestAuth` supply a `value`; the removed helpers and the route plugins' config exports are gone, and the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-rc.3/llm-route-credential/guide.md) lists the replacements. A route's configuration failure reaches web consumers through `providerCredential()` as a thrown error, which they report as `WEB_PROVIDER_MISCONFIGURED`.
A sign-out ends the in-flight model, Files, Search, and Fetch requests that carry the account token, including requests no Agent turn owns, such as a model request outside a turn or an account-billed web search; the account listing request keeps its own deadline. The signal supplements the Agent cancellation of the [account sign-out decision](2026-09-17-account-provider-signout.md), which rejected a login-level signal as a duplicate of that chain: the chain reaches a request only through a mounted listener and a running Agent turn. While the account route is disabled, a task it started that still runs is not reported to the sign-out confirmation, and a sign-out ends it only through a model request in flight. A credential released by an account service that has since been replaced is not withdrawn by the replacement's sign-out; the route plugin's listener still cancels Agent turns.
@@ -1,47 +0,0 @@
# Agent Note: Route credentials - DeepSeek model routes publish the credential consumers reuse
Status: implemented
[English](2026-11-10-llm-route-credential-seam.md) | 中文
## 问题
多个包共用同一份 DeepSeek 凭据,却没有所有者。协议传输层 `@deepseek-ai/dsh-llm-deepseek` 导出读取 `ctx.credentials`、启动环境和 `ctx.deepseekAccount` 的辅助函数,因此尽管传输层只发送路由交给它的请求头,它仍依赖两个凭据服务。两个路由插件通过这些函数解析凭据,并在 `resolveAuth` 内部抛出各自的凭据缺失错误。Search 与 Fetch API 提供方用路由包自己的配置解析函数,从路由包的 Loader 条目重新推导每条路由的基础地址和密钥引用,Messages 搜索则硬编码账号路由 id,因此两个 Web 包都依赖 `llm-deepseek`、两个路由插件和 Loader。位于所有消费方之下的账号服务拥有退登后的 Agent 取消逻辑,并和它仅仅使用的凭据库一起放在 `credentials/` 组。改变一条路由的鉴权方式要同时触及传输层、两个 Web 提供方及其测试。
## 决策
`@deepseek-ai/dsh-llm` 拥有 Service Definition。`LlmAdapter.providerCredential(provider)` 发布一个 `ProviderCredential`:路由的 `kind`(可合并扩展,已声明 `api-key` 与 `account`)、解析后的 `baseURL`、用于诊断的可选凭据 `reference`、不校验凭据、不联系目的地的存在性检查 `configured(endpoint)`,以及返回 `ProviderCredentialGrant` 的 `resolve(endpoint, signal)`;授权包含协议 `headers`、供以其他方式呈现凭据的目标使用的裸 `value`、可选的 HTTP 401 `reject()`,以及可选的 `revoked` 信号;所有者在请求仍携带凭据时撤回凭据,该信号即中止。`LlmRuntime.providerCredential(provider)` 转发给拥有该路由的适配器;未注册的路由回答 `undefined`,配置无法解析的路由则传播适配器的失败。适配器每次调用读取一代配置,与每次模型请求相同。
`@deepseek-ai/dsh-llm-deepseek` 不读取任何凭据。`DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` 返回授权或 `undefined`;`missingCredential(connection, provider)` 命名没有凭据时请求的失败,默认为 `MISSING_CREDENTIAL`;`credential` 声明发布的种类、引用和存在性检查。传输层让每次模型请求及其文件操作受授权的 `revoked` 信号约束,并把由此产生的失败交给提供方的失败回调命名。列表缓存以端点和凭据请求头的哈希划分作用域。
路由插件拥有凭据。`llm-deepseek-api-key` 通过 `@deepseek-ai/dsh-credentials` 新增的 `resolveCredentialRef` 和 `credentialRefConfigured` 读取密钥,二者把已挂载的凭据服务视为权威,仅在没有该服务时读取启动环境;它发布种类 `api-key` 并附带 `apiKeyEnv` 引用,且只对其基础地址所在 origin 下的目的地释放密钥。`llm-deepseek-account` 读取 `ctx.deepseekAccount.resolveRequestCredential(endpoint)`,把 HTTP 401 映射为 `ACCOUNT_TOKEN_INVALID`、配额失败映射为 `ACCOUNT_QUOTA`,没有凭据时以 `ACCOUNT_SIGN_IN_REQUIRED` 失败,发布种类 `account`,并拥有退登策略:在 `deepseek-account/signed-out` 时取消其运行中的 Agent,并向账号服务注册运行中任务报告。退登时在途的请求随其授权的 `revoked` 信号结束,以 `ACCOUNT_SIGN_IN_REQUIRED` 失败;它的失败回调会取消同一批 Agent,因此比插件存活更久的请求仍会以退登原因结束其回合。
`@deepseek-ai/dsh-deepseek-account` 释放请求凭据。`resolveRequestCredential(url)` 返回 `x-dsh-auth-token` 请求头、裸 token、`reject()` 和 `revoked` 信号;`reject()` 仅在授权仍一致时删除它并隔离存储失败,`revoked` 由服务在每次退登时、`deepseek-account/signed-out` 的监听器返回之后中止。`registerRunningTaskReport(report)` 为 `hasRunningAccountTasks()` 提供答案。该服务不检查任何 Agent,也不依赖 `dsh-agent` 或 `dsh-llm`。包以不变的名字位于 `packages/account/` 组。
Web 提供方消费这些发布的凭据。`web-deepseek-api` 从 `ctx.llm.providerCredential('deepseek-official')` 和 `providerCredential('deepseek-account')` 构造每次操作的有序凭据来源:路由来源把 `api-key` 授权的值作为 Bearer 令牌发送,其他种类的请求头原样发送,并通过授权的 `reject()` 作废。每个路由 id 下只接受该路由发布的种类(`deepseek-official` 下为 `api-key`,`deepseek-account` 下为 `account`),因此按路由 id 计费不会发出另一种凭据。没有 API 密钥路由时,它通过引用函数读取 `DEEPSEEK_API_KEY`;没有账号路由时,它向账号服务索取发往 `DEEPSEEK_BASE_URL` 所指 origin 的凭据。`web-search-deepseek` 在发起会话的路由发布 `account` 种类且搜索端点与该路由的基础地址同源时使用其账号凭据,否则使用引用函数;为其他 origin 发布的账号凭据不会被索取。两个 Web 消费方都会隔离失败的 `reject()`,因此对任何凭据种类,报告的都是 HTTP 拒绝。二者都让请求受授权的 `revoked` 信号约束,把被它结束的请求报告为带登录指引的 `WEB_PROVIDER_ERROR`,`WEB_ABORTED` 仍只表示调用方取消。两个 Web 包都不再依赖 `llm-deepseek`、路由插件或 Loader,`web-search-deepseek` 也不再依赖账号服务。
## 考虑过的替代方案
**用一个 `deepseek-auth` 包承载凭据 seam。** 该 seam 只需要 Service Definition,不需要 Cordis 服务,而这一个 Definition 角色应与 `LlmAdapter` 放在一起;为一个接口建包只会增加一个没有行为所有者的依赖。
**在发布的凭据中加入凭据指纹。** 消费方只负责发送请求,因此只需要请求头和值;按凭据划分缓存作用域是适配器自己的事,列表缓存通过哈希它发送的请求头即可满足。
**用 `credentials-env` 提供方代替引用函数。** 读取环境的提供方会改变每个消费方眼中哪个组合具有权威性;引用函数把启动环境后备保留在需要它的消费方本地,使这样的提供方仍是独立的选项。
**没有账号路由时的 Web 后备使用账号服务的推理 origin。** 让该后备经由 `DEEPSEEK_BASE_URL` 可保持无密钥计费快照和所有已记录部署不变;账号服务仍拒绝除自身 origin 以外的一切来源。
**把账号包并入 `identity/`。** 该组定义匿名、不识别用户的 id;已登录账号与之相反,因此单独成组。
**让路由插件的退登监听保留到其任务结束。** 这样卸载路由要等待运行中的回合:停用插件会被阻塞,其他设置写入也排在这次重载之后,直到回合结束。
**路由卸载时取消其任务。** 配置重载或插件更新会停掉与退登无关的回合。
**把退登策略放回账号服务。** 账号服务将重新检查 Agent 并认识路由 id,而这正是本决策去掉的依赖。
**插件卸载后仍保留路由的监听或报告注册。** 比注册它的插件存活更久的注册违反“注册是其所有者的 effect”这一规则,并让已卸载插件的代码在任务运行期间留在其他作用域里。
## 后果
新增凭据种类或路由凭据的消费方只触及一个路由插件或一个消费方,而不是传输层。传输层、Web 提供方和账号服务之间的交叉依赖消失,`hasRunningAccountTasks()` 依赖注册的报告而非账号服务可见的 Agent。构造 `DeepSeekRequestAuth` 的消费方需提供 `value`;被移除的辅助函数和路由插件的配置导出不复存在,[升级指南](../../../../docs/upgrade-guide/v0.2.2-rc.3/llm-route-credential/guide.zh.md)列出了替代方案。路由的配置失败通过 `providerCredential()` 以抛出错误的形式到达 Web 消费方,它们将其报告为 `WEB_PROVIDER_MISCONFIGURED`。
退登会结束携带账号 token 的在途模型、Files、Search 与 Fetch 请求,包括不属于任何 Agent 回合的请求,例如回合之外的模型请求或按账号计费的 Web 搜索;账号列表请求仍只受自身期限约束。该信号是对[账号退登决策](2026-09-17-account-provider-signout.zh.md)中 Agent 取消链路的补充;那份决策以重复该链路为由否决了登录级信号,而该链路只能经由已挂载的监听和运行中的 Agent 回合到达请求。账号路由被停用期间,它此前启动且仍在运行的任务不会报告给退登确认,退登也只能通过在途的模型请求结束它。已被替换的账号服务释放的凭据不会被替换后服务的退登撤回;路由插件的监听仍会取消 Agent 回合。
@@ -27,8 +27,8 @@
en: 0dcc97d8105fab60
zh: d80d40ae3a0c601d
/agent-note-direct-deepseek-search-and-fetch-apis/alternatives-considered:
en: 021a4b08ad534b36
zh: e98e1f65e50a568b
en: e377ad3c0327300e
zh: 4b9f7f83f464e657
/agent-note-direct-deepseek-search-and-fetch-apis/consequences:
en: 7ec21c5b1124e5f8
zh: af769dbdb4face9f
@@ -52,7 +52,7 @@ The independent `dsh-web-search-deepseek` provider sends Messages search request
**Keep the APIs inside the Messages provider behind a provider-local switch.** A switch inside the Messages provider cannot change fetch routing, so `web_fetch` would stay on HTTP unless the user also edited `web.fetchProvider`; it also ties the APIs' lifecycle to Messages search. Separate registrations let the web service's existing selection choose each provider, without coupling either API to the Messages provider.
**Share one transport between Messages search and the new APIs.** A shared web transport would couple different request formats and failure mappings. Credential values instead come from the credentials the model routes publish through `ctx.llm.providerCredential()` and from the `dsh-credentials` reference helpers; Messages search and the Search/Fetch API transports remain independent.
**Share one transport between Messages search and the new APIs.** A shared web transport would couple different request formats and failure mappings. Credentials instead come from one service, `ctx.deepseekAuth`, which releases the request headers of the API key or the account sign-in; Messages search and the Search/Fetch API transports remain independent.
**Split Search and Fetch into separate packages.** The guide serves both APIs from one base with one credential; separate packages would duplicate settings that address one deployment. Independent selection does not require separate packages, because each API registers its own provider id. Each operation lives in its own module, so either API can change without the other.
@@ -52,7 +52,7 @@ HTTP 提供方继续负责自身的 URL 校验和资源限制。选择 DeepSeek
**把两个 API 放在 Messages 提供方内部,由提供方自己的开关切换。** Messages 提供方内的开关无法改变抓取路由,因此除非用户另外修改 `web.fetchProvider`,`web_fetch` 仍会走 HTTP;它还会把两个 API 的生命周期绑在 Messages 搜索上。独立注册让 Web 服务通过现有的提供方选择机制选择各个提供方,不会把任一 API 与 Messages 提供方绑定。
**让 Messages 搜索与新 API 共用一套传输层。** 共享 Web 传输层会耦合不同的请求格式和失败映射。凭据值改为来自模型路由通过 `ctx.llm.providerCredential()` 发布的凭据以及 `dsh-credentials` 的引用函数;Messages 搜索与 Search/Fetch API 传输层保持独立。
**让 Messages 搜索与新 API 共用一套传输层。** 共享 Web 传输层会耦合不同的请求格式和失败映射。凭据改为来自同一个服务 `ctx.deepseekAuth`,它释放 API 密钥或账号登录凭据的请求头;Messages 搜索与 Search/Fetch API 传输层保持独立。
**把 Search 和 Fetch 拆成两个包。** 指南从同一基础地址、以同一份凭据提供两个 API;拆成两个包会让指向同一部署的设置重复出现。分别选择不需要拆包,因为每个 API 注册自己的提供方 id。每种操作位于独立模块,任一 API 都可以单独修改。
+3
View File
@@ -56,6 +56,8 @@ flowchart LR
cfg --> plugin_dsh_base_authorization
plugin_dsh_base_deepseek_account["deepseek-account<br/>@deepseek-ai/dsh-deepseek-account"]
cfg --> plugin_dsh_base_deepseek_account
plugin_dsh_base_deepseek_auth["deepseek-auth<br/>@deepseek-ai/dsh-deepseek-auth"]
cfg --> plugin_dsh_base_deepseek_auth
plugin_dsh_base_credentials["credentials<br/>@deepseek-ai/dsh-credentials-local"]
cfg --> plugin_dsh_base_credentials
plugin_dsh_base_llm_pi_ai["llm-pi-ai<br/>@deepseek-ai/dsh-llm-pi-ai"]
@@ -234,6 +236,7 @@ flowchart LR
| `settings` | `@deepseek-ai/dsh-settings` |
| `authorization` | `@deepseek-ai/dsh-authorization` |
| `deepseek-account` | `@deepseek-ai/dsh-deepseek-account` |
| `deepseek-auth` | `@deepseek-ai/dsh-deepseek-auth` |
| `credentials` | `@deepseek-ai/dsh-credentials-local` |
| `llm-pi-ai` | `@deepseek-ai/dsh-llm-pi-ai` |
| `session-persistence-jsonl` | `@deepseek-ai/dsh-session-persistence-jsonl` |
+2 -1
View File
@@ -177,7 +177,8 @@
"@types/ws": "8.18.1",
"ajv": "^8.20.0",
"execa": "^10.0.1",
"ws": "8.21.3"
"ws": "8.21.3",
"@deepseek-ai/dsh-deepseek-auth": "workspace:*"
},
"exports": {
"./profile-boot": {
+1
View File
@@ -1263,6 +1263,7 @@ describe.skipIf(!existsSync(dshBin))('dsh BUILT bin (node lib/bin.js, no tsx)',
['deepseek-llm-api-extensions', '@deepseek-ai/dsh-deepseek-llm-api-extensions'],
['session-log-deepseek', '@deepseek-ai/dsh-session-log-deepseek'],
['plugin-package-inventory-deepseek', '@deepseek-ai/dsh-plugin-package-inventory-deepseek'],
['deepseek-auth', '@deepseek-ai/dsh-deepseek-auth'],
['llm-deepseek', '@deepseek-ai/dsh-llm-deepseek-api-key'],
['sandbox', '@deepseek-ai/dsh-sandbox-local'],
['filesystem', '@deepseek-ai/dsh-fs-local'],
@@ -9,6 +9,7 @@ import LocalSubprocessRuntime from '@deepseek-ai/dsh-subprocess-local'
import * as ToolBash from '@deepseek-ai/dsh-tool-bash'
import * as ToolTodo from '@deepseek-ai/dsh-tool-todo'
import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek-api-key'
import DeepSeekAuth from '@deepseek-ai/dsh-deepseek-auth'
import TokenMeter from '@deepseek-ai/dsh-token-meter'
import ToolResultPruner from '@deepseek-ai/dsh-compaction-tool-result-pruner'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
@@ -70,6 +71,7 @@ export async function codingHarness(workdir: string, options: CodingHarnessOptio
systemPrompt: { personaPrefix: options.personaPrefix ?? '' },
})
await ctx.plugin(AgentLoop, { agents: [] })
await ctx.plugin(DeepSeekAuth)
await ctx.plugin(LlmDeepSeek, {
...options.modelContextWindow === undefined && options.modelMaxTokens === undefined ? {} : {
models: [{
@@ -20,6 +20,7 @@ import * as BashEnvPlugin from '@deepseek-ai/dsh-shell-env'
import LocalSubprocessRuntime from '@deepseek-ai/dsh-subprocess-local'
import * as ToolBash from '@deepseek-ai/dsh-tool-bash'
import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek-api-key'
import DeepSeekAuth from '@deepseek-ai/dsh-deepseek-auth'
import NodeRuntime from '@deepseek-ai/dsh-ptc-runtime-node'
import Sandbox from '@deepseek-ai/dsh-sandbox-local'
import SandboxPolicy from '@deepseek-ai/dsh-sandbox-policy'
@@ -63,6 +64,7 @@ async function ptcModeHarness(cwd: string): Promise<Context> {
tools: { mode: 'ptc' },
})
await harness.plugin(AgentLoop, { agents: [] })
await harness.plugin(DeepSeekAuth)
await harness.plugin(LlmDeepSeek)
if (harness.get('subprocess') === undefined) await harness.plugin(LocalSubprocessRuntime)
await harness.plugin(BashEnvPlugin)
@@ -83,6 +85,7 @@ async function workspacePtcModeHarness(): Promise<Context> {
await harness.plugin(ToolFs)
await harness.plugin(AgentInstructions, { maxBytes: 65536 })
await harness.plugin(AgentLoop, { agents: [] })
await harness.plugin(DeepSeekAuth)
await harness.plugin(LlmDeepSeek, { models: [{ id: 'deepseek-v4-flash' }] })
await mountRuntime(harness)
return harness
+1 -1
View File
@@ -143,7 +143,7 @@ it.skipIf(MODE === 'record')('reuses saved native Account Flash translations acr
if (account === undefined) throw new Error('Shipped native Account service is absent')
// Only credential acquisition is nondeterministic; the Loader-owned native route and wire remain real.
const credential = {
headers: { 'x-dsh-auth-token': 'paid-browser-fixture-token' }, value: 'paid-browser-fixture-token',
headers: { 'x-dsh-auth-token': 'paid-browser-fixture-token' },
revoked: new AbortController().signal, reject: () => Promise.resolve(),
}
const auth = vi.spyOn(account, 'resolveRequestCredential').mockImplementation(async (url: string) =>
+2 -2
View File
@@ -6,5 +6,5 @@
en: 41d772192075e133
zh: 5ef3da69b4de1d8a
/capability-seams-and-core-services:
en: 9a698ae22b619a5d
zh: bd82134864167e76
en: b2a1901a1e5d3b7e
zh: b738c6da26e253eb
+16 -12
View File
@@ -94,8 +94,6 @@ flowchart LR
pkg_llm_replay["llm-replay"]
pkg_agent_loop["agent-loop"]
pkg_compaction_basic["compaction-basic"]
pkg_web_deepseek_api["web-deepseek-api"]
pkg_web_search_deepseek["web-search-deepseek"]
pkg_session_log_deepseek["session-log-deepseek"]
svc_sessionLogDeepSeek["ctx.sessionLogDeepSeek<br/>Session-log upload policy"]
pkg_deepseek_llm_api_extensions["deepseek-llm-api-extensions"]
@@ -153,10 +151,14 @@ flowchart LR
pkg_credentials["credentials"]
svc_credentials["ctx.credentials<br/>Credential seam"]
pkg_credentials_local["credentials-local"]
pkg_llm_deepseek_api_key["llm-deepseek-api-key"]
pkg_deepseek_auth["deepseek-auth"]
pkg_deepseek_account["deepseek-account"]
svc_deepseekAccount["ctx.deepseekAccount<br/>DeepSeek account"]
pkg_llm_deepseek_account["llm-deepseek-account"]
svc_deepseekAuth["ctx.deepseekAuth<br/>DeepSeek request authentication"]
pkg_llm_deepseek_api_key["llm-deepseek-api-key"]
pkg_web_deepseek_api["web-deepseek-api"]
pkg_web_search_deepseek["web-search-deepseek"]
pkg_authorization["authorization"]
svc_authorization["ctx.authorization<br/>Authorization flow registry"]
pkg_client_product_analytics["client-product-analytics"]
@@ -378,6 +380,7 @@ flowchart LR
pkg_cua --> svc_cuaAccess
pkg_cua --> svc_cuaPrograms
pkg_deepseek_account --> svc_deepseekAccount
pkg_deepseek_auth --> svc_deepseekAuth
pkg_deepseek_chat_import --> svc_deepseekChatImport
pkg_deepseek_llm_api_extensions --> svc_deepseekLlmApiExtensions
pkg_experimental_api_speech_to_text --> svc_speechController
@@ -536,14 +539,16 @@ flowchart LR
svc_connection_authentication --> pkg_client_connection
svc_cordisInspect --> pkg_tool_cordis
svc_credentials --> pkg_api_settings_controller
svc_credentials --> pkg_llm_deepseek_api_key
svc_credentials --> pkg_deepseek_auth
svc_credentials --> pkg_llm_pi_ai
svc_credentials --> pkg_web_deepseek_api
svc_credentials --> pkg_web_search_deepseek
svc_cuaAccess --> pkg_cua
svc_cuaPrograms --> pkg_cua_mcp
svc_deepseekAccount --> pkg_deepseek_auth
svc_deepseekAccount --> pkg_llm_deepseek_account
svc_deepseekAccount --> pkg_web_deepseek_api
svc_deepseekAuth --> pkg_llm_deepseek_account
svc_deepseekAuth --> pkg_llm_deepseek_api_key
svc_deepseekAuth --> pkg_web_deepseek_api
svc_deepseekAuth --> pkg_web_search_deepseek
svc_deepseekLlmApiExtensions --> pkg_llm_deepseek
svc_directoryPicker --> pkg_api_workspace_controller
svc_dynamicCordisRunner --> pkg_tool_cordis
@@ -562,8 +567,6 @@ flowchart LR
svc_jobs --> pkg_tool_terminal
svc_llm --> pkg_agent_loop
svc_llm --> pkg_compaction_basic
svc_llm --> pkg_web_deepseek_api
svc_llm --> pkg_web_search_deepseek
svc_lsp --> pkg_tool_lsp
svc_mcpResources --> pkg_mcp_resources
svc_officeKit --> pkg_client_ui_sidebar_documentpreview
@@ -708,7 +711,7 @@ flowchart LR
| `ctx.officeKit` | `core` | [`office-kit`](../packages/document/office-kit) | - | [`client-ui-sidebar-documentpreview`](../packages/client/ui-sidebar-documentpreview), [`tool-office`](../packages/document/tool-office) | - | Authorized Office bytes are rendered as PDFs or images, converted, or recalculated on the Host using the declared native target engine, or Node WASM when no native target is declared. |
| `ctx.attachments` | `seam` | [`attachment`](../packages/attachment/attachment) | [`attachment-local`](../packages/attachment/attachment-local) | [`api-session-controller`](../packages/api/session-controller), [`tool-fs`](../packages/fs/tool-fs), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-deepseek`](../packages/llm/llm-deepseek) | - | The host commits accepted images before session events; provider adapters resolve authorized durable references into provider-native content. |
| `ctx.fileUploads` | `core` | [`client-file-upload`](../packages/client/file-upload) | - | [`api-session-controller`](../packages/api/session-controller) | - | Owns streaming intake, durable storage, and staged receipt lifetime; the Session controller binds receipts to accepted submissions. |
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | Adapters register provider implementations; the loop and compaction call the provider-neutral stream service, and the DeepSeek web providers read the credential a route publishes. |
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic) | - | Adapters register provider implementations; the loop and compaction call the provider-neutral stream service. |
| `ctx.sessionLogDeepSeek` | `core` | [`session-log-deepseek`](../packages/session/session-log-deepseek) | - | - | - | Plugins register caller-owned exclusions before the canonical Session-log request contribution is prepared; unmatched requests use normal upload eligibility. |
| `ctx.deepseekLlmApiExtensions` | `seam` | [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions) | [`session-log-deepseek`](../packages/session/session-log-deepseek), [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | [`llm-deepseek`](../packages/llm/llm-deepseek) | - | Plugins prepare independent top-level fields; the official adapter merges them and commits their delivery state after HTTP acceptance. |
| `ctx.tokenMeter` | `core` | [`token-meter`](../packages/llm/token-meter) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | Owns isolated per-session replay folds; pressure consumers share immutable revisioned measurements. |
@@ -734,8 +737,9 @@ flowchart LR
| `ctx.configEditor` | `core` | [`config-editor`](../packages/boot/config-editor) | - | [`settings`](../packages/settings/settings), [`agent-default-model`](../packages/core/agent-default-model) | - | Persists profile config patches under the application file lock and HMR queue, then reconciles Loader entries. |
| `ctx.settings` | `core` | [`settings`](../packages/settings/settings) | - | [`api-settings-controller`](../packages/api/settings-controller) | - | Forms project volatile Config fields from active profile entries and delegate validated edits to config-editor. Plugins consume their own Config references. |
| `ctx.subagentModelSelection` | `core` | [`tool-subagent`](../packages/subagent/tool-subagent) | - | [`tool-subagent`](../packages/subagent/tool-subagent) | - | Owns the default-off settings namespace that Agent-scoped delegation tools sample when composing a new top-level Session. |
| `ctx.credentials` | `seam` | [`credentials`](../packages/credentials/credentials) | [`credentials-local`](../packages/credentials/credentials-local) | [`api-settings-controller`](../packages/api/settings-controller), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | Configuration carries references to secrets; providers own the values. Consumers resolve per operation, so a rotated credential reaches the very next request; the settings controller exposes value-free views and write-only storage. |
| `ctx.deepseekAccount` | `service` | [`deepseek-account`](../packages/account/deepseek-account) | - | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`web-deepseek-api`](../packages/web/web-deepseek-api) | - | The Host owns browser authorization and local credentials and releases per-request credentials to the account model route and the web providers; UI consumers receive state without tokens. |
| `ctx.credentials` | `seam` | [`credentials`](../packages/credentials/credentials) | [`credentials-local`](../packages/credentials/credentials-local) | [`api-settings-controller`](../packages/api/settings-controller), [`deepseek-auth`](../packages/account/deepseek-auth), [`llm-pi-ai`](../packages/llm/llm-pi-ai) | - | Configuration carries references to secrets; providers own the values. Consumers resolve per operation, so a rotated credential reaches the very next request; the settings controller exposes value-free views and write-only storage. |
| `ctx.deepseekAccount` | `service` | [`deepseek-account`](../packages/account/deepseek-account) | - | [`deepseek-auth`](../packages/account/deepseek-auth), [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | - | The Host owns browser authorization and local credentials and releases per-request credentials to DeepSeek request authentication; the account model route registers its running-task report, and UI consumers receive state without tokens. |
| `ctx.deepseekAuth` | `service` | [`deepseek-auth`](../packages/account/deepseek-auth) | - | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | Every DeepSeek API consumer names the credential kinds its API accepts; the service orders the API key and the account sign-in by billing, binds each to its deployment, and releases request headers. |
| `ctx.authorization` | `seam` | [`authorization`](../packages/credentials/authorization) | - | [`llm-pi-ai`](../packages/llm/llm-pi-ai) | - | Flows are registered by the plugin that knows how to obtain one credential and keyed by the record they write; the seam owns the conversation and the one-attempt-per-key lifecycle, never the protocol. |
| `ctx.productAnalytics` | `service` | [`client-product-analytics`](../packages/client/product-analytics) | - | - | - | Accepts selected Desktop events, enriches available login identity, and observes live compaction under the live Host collection policy. |
| `ctx.otel` | `service` | [`otel`](../packages/telemetry/otel) | - | [`host-product-telemetry-otel`](../packages/host/product-telemetry-otel), [`session-telemetry-otel`](../packages/session/session-telemetry-otel) | - | Product analytics and Session feedback adapters create independent reporting channels through one injected service. |
+16 -12
View File
@@ -96,8 +96,6 @@ flowchart LR
pkg_llm_replay["llm-replay"]
pkg_agent_loop["agent-loop"]
pkg_compaction_basic["compaction-basic"]
pkg_web_deepseek_api["web-deepseek-api"]
pkg_web_search_deepseek["web-search-deepseek"]
pkg_session_log_deepseek["session-log-deepseek"]
svc_sessionLogDeepSeek["ctx.sessionLogDeepSeek<br/>Session-log upload policy"]
pkg_deepseek_llm_api_extensions["deepseek-llm-api-extensions"]
@@ -155,10 +153,14 @@ flowchart LR
pkg_credentials["credentials"]
svc_credentials["ctx.credentials<br/>Credential seam"]
pkg_credentials_local["credentials-local"]
pkg_llm_deepseek_api_key["llm-deepseek-api-key"]
pkg_deepseek_auth["deepseek-auth"]
pkg_deepseek_account["deepseek-account"]
svc_deepseekAccount["ctx.deepseekAccount<br/>DeepSeek account"]
pkg_llm_deepseek_account["llm-deepseek-account"]
svc_deepseekAuth["ctx.deepseekAuth<br/>DeepSeek request authentication"]
pkg_llm_deepseek_api_key["llm-deepseek-api-key"]
pkg_web_deepseek_api["web-deepseek-api"]
pkg_web_search_deepseek["web-search-deepseek"]
pkg_authorization["authorization"]
svc_authorization["ctx.authorization<br/>Authorization flow registry"]
pkg_client_product_analytics["client-product-analytics"]
@@ -380,6 +382,7 @@ flowchart LR
pkg_cua --> svc_cuaAccess
pkg_cua --> svc_cuaPrograms
pkg_deepseek_account --> svc_deepseekAccount
pkg_deepseek_auth --> svc_deepseekAuth
pkg_deepseek_chat_import --> svc_deepseekChatImport
pkg_deepseek_llm_api_extensions --> svc_deepseekLlmApiExtensions
pkg_experimental_api_speech_to_text --> svc_speechController
@@ -538,14 +541,16 @@ flowchart LR
svc_connection_authentication --> pkg_client_connection
svc_cordisInspect --> pkg_tool_cordis
svc_credentials --> pkg_api_settings_controller
svc_credentials --> pkg_llm_deepseek_api_key
svc_credentials --> pkg_deepseek_auth
svc_credentials --> pkg_llm_pi_ai
svc_credentials --> pkg_web_deepseek_api
svc_credentials --> pkg_web_search_deepseek
svc_cuaAccess --> pkg_cua
svc_cuaPrograms --> pkg_cua_mcp
svc_deepseekAccount --> pkg_deepseek_auth
svc_deepseekAccount --> pkg_llm_deepseek_account
svc_deepseekAccount --> pkg_web_deepseek_api
svc_deepseekAuth --> pkg_llm_deepseek_account
svc_deepseekAuth --> pkg_llm_deepseek_api_key
svc_deepseekAuth --> pkg_web_deepseek_api
svc_deepseekAuth --> pkg_web_search_deepseek
svc_deepseekLlmApiExtensions --> pkg_llm_deepseek
svc_directoryPicker --> pkg_api_workspace_controller
svc_dynamicCordisRunner --> pkg_tool_cordis
@@ -564,8 +569,6 @@ flowchart LR
svc_jobs --> pkg_tool_terminal
svc_llm --> pkg_agent_loop
svc_llm --> pkg_compaction_basic
svc_llm --> pkg_web_deepseek_api
svc_llm --> pkg_web_search_deepseek
svc_lsp --> pkg_tool_lsp
svc_mcpResources --> pkg_mcp_resources
svc_officeKit --> pkg_client_ui_sidebar_documentpreview
@@ -710,7 +713,7 @@ flowchart LR
| `ctx.officeKit` | `core` | [`office-kit`](../packages/document/office-kit) | - | [`client-ui-sidebar-documentpreview`](../packages/client/ui-sidebar-documentpreview), [`tool-office`](../packages/document/tool-office) | - | 已授权的 Office 字节在宿主上使用已声明的原生目标引擎渲染为 PDF 或图片、转换或重算;未声明原生目标时使用 Node WASM。 |
| `ctx.attachments` | `seam` | [`attachment`](../packages/attachment/attachment) | [`attachment-local`](../packages/attachment/attachment-local) | [`api-session-controller`](../packages/api/session-controller), [`tool-fs`](../packages/fs/tool-fs), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-deepseek`](../packages/llm/llm-deepseek) | - | 宿主会在会话事件之前提交已接受的图片;提供方适配器将已授权的持久引用解析为提供方原生内容。 |
| `ctx.fileUploads` | `core` | [`client-file-upload`](../packages/client/file-upload) | - | [`api-session-controller`](../packages/api/session-controller) | - | 负责流式接收、持久存储和暂存回执生命周期;Session Controller 将回执绑定到已接受的提交。 |
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | 适配器注册提供方实现;agent loop(智能体循环)与压缩功能调用与提供方无关的流式服务,DeepSeek Web 提供方读取路由发布的凭据。 |
| `ctx.llm` | `seam` | [`llm`](../packages/llm/llm) | [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`llm-replay`](../packages/test-support/llm-replay) | [`agent-loop`](../packages/core/agent-loop), [`compaction-basic`](../packages/compaction/compaction-basic) | - | 适配器注册提供方实现;agent loop(智能体循环)与压缩功能调用提供方无关的流服务。 |
| `ctx.sessionLogDeepSeek` | `core` | [`session-log-deepseek`](../packages/session/session-log-deepseek) | - | - | - | 插件在准备权威 Session 日志请求贡献前注册归调用方所有的排除条件;没有条件匹配的请求应用普通上传资格判断。 |
| `ctx.deepseekLlmApiExtensions` | `seam` | [`deepseek-llm-api-extensions`](../packages/llm/deepseek-llm-api-extensions) | [`session-log-deepseek`](../packages/session/session-log-deepseek), [`plugin-package-inventory-deepseek`](../packages/llm/plugin-package-inventory-deepseek) | [`llm-deepseek`](../packages/llm/llm-deepseek) | - | 插件准备彼此独立的顶层字段;官方适配器会合并这些字段,并在 HTTP 接受后提交其交付状态。 |
| `ctx.tokenMeter` | `core` | [`token-meter`](../packages/llm/token-meter) | - | [`compaction-basic`](../packages/compaction/compaction-basic) | - | 拥有按会话隔离的回放折叠区;压力消费方共享不可变且带修订版本的测量结果。 |
@@ -736,8 +739,9 @@ flowchart LR
| `ctx.configEditor` | `core` | [`config-editor`](../packages/boot/config-editor) | - | [`settings`](../packages/settings/settings), [`agent-default-model`](../packages/core/agent-default-model) | - | Persists profile config patches under the application file lock and HMR queue, then reconciles Loader entries. |
| `ctx.settings` | `core` | [`settings`](../packages/settings/settings) | - | [`api-settings-controller`](../packages/api/settings-controller) | - | Forms project volatile Config fields from active profile entries and delegate validated edits to config-editor. Plugins consume their own Config references. |
| `ctx.subagentModelSelection` | `core` | [`tool-subagent`](../packages/subagent/tool-subagent) | - | [`tool-subagent`](../packages/subagent/tool-subagent) | - | 拥有默认关闭的设置命名空间;Agent 作用域的委派工具会在组合新顶层 Session 时读取它。 |
| `ctx.credentials` | `seam` | [`credentials`](../packages/credentials/credentials) | [`credentials-local`](../packages/credentials/credentials-local) | [`api-settings-controller`](../packages/api/settings-controller), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`llm-pi-ai`](../packages/llm/llm-pi-ai), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | 配置携带对机密信息的引用;提供方拥有实际值。消费方按操作解析,因此轮换后的凭据会在紧接着的下一次请求中生效;settings controller 提供不含实际值的视图和只写存储。 |
| `ctx.deepseekAccount` | `service` | [`deepseek-account`](../packages/account/deepseek-account) | - | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`web-deepseek-api`](../packages/web/web-deepseek-api) | - | Host 负责浏览器授权和本地凭证,并向账号模型路由和 Web 提供方释放按请求的凭据;UI 使用方只接收不含 token 的状态。 |
| `ctx.credentials` | `seam` | [`credentials`](../packages/credentials/credentials) | [`credentials-local`](../packages/credentials/credentials-local) | [`api-settings-controller`](../packages/api/settings-controller), [`deepseek-auth`](../packages/account/deepseek-auth), [`llm-pi-ai`](../packages/llm/llm-pi-ai) | - | 配置携带对机密信息的引用;提供方拥有实际值。消费方按操作解析,因此轮换后的凭据会在紧接着的下一次请求中生效;settings controller 提供不含实际值的视图和只写存储。 |
| `ctx.deepseekAccount` | `service` | [`deepseek-account`](../packages/account/deepseek-account) | - | [`deepseek-auth`](../packages/account/deepseek-auth), [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | - | Host 负责浏览器授权和本地凭证,并向 DeepSeek 请求鉴权释放按请求的凭据;账号模型路由注册其运行中任务报告,UI 使用方只接收不含 token 的状态。 |
| `ctx.deepseekAuth` | `service` | [`deepseek-auth`](../packages/account/deepseek-auth) | - | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`web-deepseek-api`](../packages/web/web-deepseek-api), [`web-search-deepseek`](../packages/web/web-search-deepseek) | - | 每个 DeepSeek API 消费方给出其 API 接受的凭据种类;服务按计费方式排定 API 密钥与账号登录的顺序,把每一种绑定到其部署,并释放请求头。 |
| `ctx.authorization` | `seam` | [`authorization`](../packages/credentials/authorization) | - | [`llm-pi-ai`](../packages/llm/llm-pi-ai) | - | flow 由知道如何取得某份凭据的插件注册,并以其写入的记录为键;seam 拥有这段对话与"每个键同时只跑一次尝试"的生命周期,而非协议本身。 |
| `ctx.productAnalytics` | `service` | [`client-product-analytics`](../packages/client/product-analytics) | - | - | - | 根据 Host 动态采集策略接收指定桌面事件、补充可用登录身份并监听实时压缩。 |
| `ctx.otel` | `service` | [`otel`](../packages/telemetry/otel) | - | [`host-product-telemetry-otel`](../packages/host/product-telemetry-otel), [`session-telemetry-otel`](../packages/session/session-telemetry-otel) | - | 产品埋点和 Session 反馈适配器通过同一个注入服务创建独立上报通道。 |
+7 -6
View File
@@ -2049,7 +2049,7 @@ export interface Config {
## `@deepseek-ai/dsh-llm-deepseek-account`
- `inject`: `llm`
- `inject`: `llm` · `deepseekAuth`
- `refs`: [`ModelListingConfig`](../packages/llm/llm-deepseek/src/index.ts) · [`ModelOverride`](../packages/llm/llm-deepseek/src/index.ts) · [`ProtocolConfig`](../packages/llm/llm-deepseek/src/index.ts) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/llm/llm-deepseek-account/src/config.ts:15`](../packages/llm/llm-deepseek-account/src/config.ts)
@@ -2067,7 +2067,7 @@ export interface Config extends Omit<ProtocolConfig, 'models'>, ModelListingConf
## `@deepseek-ai/dsh-llm-deepseek-api-key`
- `inject`: `llm`
- `inject`: `llm` · `deepseekAuth`
- `refs`: [`ModelListingConfig`](../packages/llm/llm-deepseek/src/index.ts) · [`ProtocolConfig`](../packages/llm/llm-deepseek/src/index.ts) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/llm/llm-deepseek-api-key/src/config.ts:18`](../packages/llm/llm-deepseek-api-key/src/config.ts)
@@ -5026,9 +5026,9 @@ export interface Config {
## `@deepseek-ai/dsh-web-deepseek-api`
- `inject`: `web`
- `inject`: `web` · `deepseekAuth`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web-deepseek-api/src/index.ts:57`](../packages/web/web-deepseek-api/src/index.ts)
- `source`: [`packages/web/web-deepseek-api/src/index.ts:55`](../packages/web/web-deepseek-api/src/index.ts)
```ts config-catalog
/**
@@ -5104,9 +5104,9 @@ export interface Config {
## `@deepseek-ai/dsh-web-search-deepseek`
- `inject`: `web`
- `inject`: `web` · `deepseekAuth`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web-search-deepseek/src/index.ts:53`](../packages/web/web-search-deepseek/src/index.ts)
- `source`: [`packages/web/web-search-deepseek/src/index.ts:51`](../packages/web/web-search-deepseek/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `apply` fills env-var and constant defaults). */
@@ -5309,6 +5309,7 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co
| `@deepseek-ai/dsh-cordis-client-runner` | — | [`packages/extensions/cordis-client-runner/src/index.ts`](../packages/extensions/cordis-client-runner/src/index.ts) |
| `@deepseek-ai/dsh-creation-recommendations` | `tools` · `pluginManager` · `agents` · `subagents` · `profileContext` · `skills` · `actionCards` | [`packages/experimental/creation-recommendations/src/index.ts`](../packages/experimental/creation-recommendations/src/index.ts) |
| `@deepseek-ai/dsh-cua` | — | [`packages/experimental/cua/src/index.ts`](../packages/experimental/cua/src/index.ts) |
| `@deepseek-ai/dsh-deepseek-auth` | — | [`packages/account/deepseek-auth/src/index.ts`](../packages/account/deepseek-auth/src/index.ts) |
| `@deepseek-ai/dsh-deepseek-llm-api-extensions` | — | [`packages/llm/deepseek-llm-api-extensions/src/index.ts`](../packages/llm/deepseek-llm-api-extensions/src/index.ts) |
| `@deepseek-ai/dsh-deliverable-file-references` | `systemPrompt` | [`packages/deliverables/deliverable-file-references/src/index.ts`](../packages/deliverables/deliverable-file-references/src/index.ts) |
| `@deepseek-ai/dsh-experimental-auto-review` | `approval` · `llm` · `permissionPresets` · `sessions` · `tools` · `workingDirectory` | [`packages/experimental/auto-review/src/index.ts`](../packages/experimental/auto-review/src/index.ts) |
+7 -6
View File
@@ -2051,7 +2051,7 @@ export interface Config {
## `@deepseek-ai/dsh-llm-deepseek-account`
- `inject`: `llm`
- `inject`: `llm` · `deepseekAuth`
- `refs`: [`ModelListingConfig`](../packages/llm/llm-deepseek/src/index.ts) · [`ModelOverride`](../packages/llm/llm-deepseek/src/index.ts) · [`ProtocolConfig`](../packages/llm/llm-deepseek/src/index.ts) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/llm/llm-deepseek-account/src/config.ts:15`](../packages/llm/llm-deepseek-account/src/config.ts)
@@ -2069,7 +2069,7 @@ export interface Config extends Omit<ProtocolConfig, 'models'>, ModelListingConf
## `@deepseek-ai/dsh-llm-deepseek-api-key`
- `inject`: `llm`
- `inject`: `llm` · `deepseekAuth`
- `refs`: [`ModelListingConfig`](../packages/llm/llm-deepseek/src/index.ts) · [`ProtocolConfig`](../packages/llm/llm-deepseek/src/index.ts) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/llm/llm-deepseek-api-key/src/config.ts:18`](../packages/llm/llm-deepseek-api-key/src/config.ts)
@@ -5028,9 +5028,9 @@ export interface Config {
## `@deepseek-ai/dsh-web-deepseek-api`
- `inject`: `web`
- `inject`: `web` · `deepseekAuth`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web-deepseek-api/src/index.ts:57`](../packages/web/web-deepseek-api/src/index.ts)
- `source`: [`packages/web/web-deepseek-api/src/index.ts:55`](../packages/web/web-deepseek-api/src/index.ts)
```ts config-catalog
/**
@@ -5106,9 +5106,9 @@ export interface Config {
## `@deepseek-ai/dsh-web-search-deepseek`
- `inject`: `web`
- `inject`: `web` · `deepseekAuth`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web-search-deepseek/src/index.ts:53`](../packages/web/web-search-deepseek/src/index.ts)
- `source`: [`packages/web/web-search-deepseek/src/index.ts:51`](../packages/web/web-search-deepseek/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `apply` fills env-var and constant defaults). */
@@ -5311,6 +5311,7 @@ export interface Config {
| `@deepseek-ai/dsh-cordis-client-runner` | — | [`packages/extensions/cordis-client-runner/src/index.ts`](../packages/extensions/cordis-client-runner/src/index.ts) |
| `@deepseek-ai/dsh-creation-recommendations` | `tools` · `pluginManager` · `agents` · `subagents` · `profileContext` · `skills` · `actionCards` | [`packages/experimental/creation-recommendations/src/index.ts`](../packages/experimental/creation-recommendations/src/index.ts) |
| `@deepseek-ai/dsh-cua` | — | [`packages/experimental/cua/src/index.ts`](../packages/experimental/cua/src/index.ts) |
| `@deepseek-ai/dsh-deepseek-auth` | — | [`packages/account/deepseek-auth/src/index.ts`](../packages/account/deepseek-auth/src/index.ts) |
| `@deepseek-ai/dsh-deepseek-llm-api-extensions` | — | [`packages/llm/deepseek-llm-api-extensions/src/index.ts`](../packages/llm/deepseek-llm-api-extensions/src/index.ts) |
| `@deepseek-ai/dsh-deliverable-file-references` | `systemPrompt` | [`packages/deliverables/deliverable-file-references/src/index.ts`](../packages/deliverables/deliverable-file-references/src/index.ts) |
| `@deepseek-ai/dsh-experimental-auto-review` | `approval` · `llm` · `permissionPresets` · `sessions` · `tools` · `workingDirectory` | [`packages/experimental/auto-review/src/index.ts`](../packages/experimental/auto-review/src/index.ts) |
+2 -2
View File
@@ -57,10 +57,10 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:115`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
| `hmr/change` | `emit` | [`packages/boot/hmr/src/index.ts:35`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
| `hmr/reload` | `emit` | [`packages/boot/hmr/src/index.ts:40`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:113`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:115`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
| `llm/adapters-updated` | `emit` | [`packages/llm/llm/src/types.ts:24`](../packages/llm/llm/src/types.ts) | [`llm`](../packages/llm/llm) (`events.dispatch`) | [`acp`](../packages/acp/acp), `remotes` |
| `llm/models-updated` | `emit` | [`packages/llm/llm/src/types.ts:30`](../packages/llm/llm/src/types.ts) | [`llm-deepseek`](../packages/llm/llm-deepseek) (`emit`) | `remotes` |
| `llm/stream` | `waterfall` | [`packages/llm/llm/src/index.ts:81`](../packages/llm/llm/src/index.ts) | [`llm`](../packages/llm/llm) (`waterfall`) | [`llm-replay`](../packages/test-support/llm-replay), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), [`session-title`](../packages/session/session-title), [`timeline`](../packages/experimental/timeline) |
| `llm/stream` | `waterfall` | [`packages/llm/llm/src/index.ts:78`](../packages/llm/llm/src/index.ts) | [`llm`](../packages/llm/llm) (`waterfall`) | [`llm-replay`](../packages/test-support/llm-replay), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), [`session-title`](../packages/session/session-title), [`timeline`](../packages/experimental/timeline) |
| `mcp-manager/status` | `parallel` | [`packages/mcp/mcp-manager/src/types.ts:46`](../packages/mcp/mcp-manager/src/types.ts) | [`mcp-manager`](../packages/mcp/mcp-manager) (`parallel`) | - |
| `permission-presets/catalog-changed` | `emit` | [`packages/interaction/permission-presets/src/types.ts:62`](../packages/interaction/permission-presets/src/types.ts) | [`permission-presets`](../packages/interaction/permission-presets) (`events.dispatch`) | `remotes` |
| `plugin-manager/changed` | `emit` | [`packages/boot/plugin-manager/src/types.ts:455`](../packages/boot/plugin-manager/src/types.ts) | [`plugin-manager`](../packages/boot/plugin-manager) (`emit`) | `remotes` |
+2 -2
View File
@@ -59,10 +59,10 @@
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:115`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
| `hmr/change` | `emit` | [`packages/boot/hmr/src/index.ts:35`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
| `hmr/reload` | `emit` | [`packages/boot/hmr/src/index.ts:40`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:113`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:115`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
| `llm/adapters-updated` | `emit` | [`packages/llm/llm/src/types.ts:24`](../packages/llm/llm/src/types.ts) | [`llm`](../packages/llm/llm) (`events.dispatch`) | [`acp`](../packages/acp/acp), `remotes` |
| `llm/models-updated` | `emit` | [`packages/llm/llm/src/types.ts:30`](../packages/llm/llm/src/types.ts) | [`llm-deepseek`](../packages/llm/llm-deepseek) (`emit`) | `remotes` |
| `llm/stream` | `waterfall` | [`packages/llm/llm/src/index.ts:81`](../packages/llm/llm/src/index.ts) | [`llm`](../packages/llm/llm) (`waterfall`) | [`llm-replay`](../packages/test-support/llm-replay), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), [`session-title`](../packages/session/session-title), [`timeline`](../packages/experimental/timeline) |
| `llm/stream` | `waterfall` | [`packages/llm/llm/src/index.ts:78`](../packages/llm/llm/src/index.ts) | [`llm`](../packages/llm/llm) (`waterfall`) | [`llm-replay`](../packages/test-support/llm-replay), [`session-checkpoint-policy`](../packages/session/session-checkpoint-policy), [`session-title`](../packages/session/session-title), [`timeline`](../packages/experimental/timeline) |
| `mcp-manager/status` | `parallel` | [`packages/mcp/mcp-manager/src/types.ts:46`](../packages/mcp/mcp-manager/src/types.ts) | [`mcp-manager`](../packages/mcp/mcp-manager) (`parallel`) | - |
| `permission-presets/catalog-changed` | `emit` | [`packages/interaction/permission-presets/src/types.ts:62`](../packages/interaction/permission-presets/src/types.ts) | [`permission-presets`](../packages/interaction/permission-presets) (`events.dispatch`) | `remotes` |
| `plugin-manager/changed` | `emit` | [`packages/boot/plugin-manager/src/types.ts:455`](../packages/boot/plugin-manager/src/types.ts) | [`plugin-manager`](../packages/boot/plugin-manager) (`emit`) | `remotes` |
+16 -8
View File
@@ -119,6 +119,7 @@ flowchart TD
end
subgraph group_account["packages/account"]
pkg_deepseek_account["deepseek-account"]
pkg_deepseek_auth["deepseek-auth"]
end
subgraph group_api["packages/api"]
pkg_api_gateway["api-gateway"]
@@ -666,6 +667,10 @@ flowchart TD
pkg_skill_filesystem --> pkg_fs
pkg_skill_filesystem --> pkg_home_paths
pkg_skill_filesystem --> pkg_skill
pkg_deepseek_auth --> pkg_credentials
pkg_deepseek_auth --> pkg_deepseek_account
pkg_deepseek_auth --> pkg_error
pkg_deepseek_auth --> pkg_launch_environment
pkg_api_workspace_controller --> pkg_api_gateway
pkg_api_workspace_controller --> pkg_client_connection
pkg_api_workspace_controller --> pkg_host_directory_picker
@@ -694,10 +699,12 @@ flowchart TD
pkg_pwsh_local --> pkg_timeout
pkg_llm_deepseek_account --> pkg_agent
pkg_llm_deepseek_account --> pkg_deepseek_account
pkg_llm_deepseek_account --> pkg_deepseek_auth
pkg_llm_deepseek_account --> pkg_launch_environment
pkg_llm_deepseek_account --> pkg_llm
pkg_llm_deepseek_account --> pkg_llm_deepseek
pkg_llm_deepseek_api_key --> pkg_credentials
pkg_llm_deepseek_api_key --> pkg_deepseek_auth
pkg_llm_deepseek_api_key --> pkg_launch_environment
pkg_llm_deepseek_api_key --> pkg_llm
pkg_llm_deepseek_api_key --> pkg_llm_deepseek
@@ -716,15 +723,14 @@ flowchart TD
pkg_goal --> pkg_typert_protocol
pkg_web_deepseek_api --> pkg_agent
pkg_web_deepseek_api --> pkg_credentials
pkg_web_deepseek_api --> pkg_deepseek_account
pkg_web_deepseek_api --> pkg_launch_environment
pkg_web_deepseek_api --> pkg_deepseek_auth
pkg_web_deepseek_api --> pkg_llm
pkg_web_deepseek_api --> pkg_session
pkg_web_deepseek_api --> pkg_web
pkg_web_search_deepseek --> pkg_agent
pkg_web_search_deepseek --> pkg_credentials
pkg_web_search_deepseek --> pkg_deepseek_auth
pkg_web_search_deepseek --> pkg_launch_environment
pkg_web_search_deepseek --> pkg_llm
pkg_web_search_deepseek --> pkg_session
pkg_web_search_deepseek --> pkg_web
pkg_file_reference --> pkg_agent
@@ -1574,6 +1580,7 @@ flowchart TD
pkg_sdk_jsonrpc_server --> pkg_agent
pkg_sdk_jsonrpc_server --> pkg_attachment
pkg_sdk_jsonrpc_server --> pkg_commands
pkg_sdk_jsonrpc_server --> pkg_deepseek_auth
pkg_sdk_jsonrpc_server --> pkg_goal
pkg_sdk_jsonrpc_server --> pkg_llm
pkg_sdk_jsonrpc_server --> pkg_llm_deepseek_api_key
@@ -1818,6 +1825,7 @@ flowchart TD
| [`fs-local`](../packages/fs/fs-local) | `fs` | [`fs`](../packages/fs/fs) |
| [`fs-observation-policy`](../packages/fs/fs-observation-policy) | `fs` | [`fs`](../packages/fs/fs) |
| [`skill-filesystem`](../packages/skill/skill-filesystem) | `skill` | [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`skill`](../packages/skill/skill) |
| [`deepseek-auth`](../packages/account/deepseek-auth) | `account` | [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/account/deepseek-account), [`error`](../packages/util/error), [`launch-environment`](../packages/util/launch-environment) |
| [`api-workspace-controller`](../packages/api/workspace-controller) | `api` | [`api-gateway`](../packages/api/gateway), [`client-connection`](../packages/client/connection), [`host-directory-picker`](../packages/host/directory-picker), [`session`](../packages/core/session), [`storage-domain`](../packages/storage/storage-domain), [`typert-protocol`](../packages/typert/protocol), [`workspace`](../packages/workspace/workspace) |
| [`experimental-api-speech-to-text`](../packages/experimental/api-speech-to-text) | `experimental` | [`experimental-speech-to-text`](../packages/experimental/speech-to-text), [`typert-protocol`](../packages/typert/protocol) |
| [`experimental-client-ui-cot-translation`](../packages/experimental/client-ui-cot-translation) | `experimental` | [`experimental-translator`](../packages/experimental/translator) |
@@ -1826,13 +1834,13 @@ flowchart TD
| [`lsp-stdio`](../packages/lsp/lsp-stdio) | `lsp` | [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`lsp`](../packages/lsp/lsp), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`bash-local`](../packages/shell/bash-local) | `shell` | [`shell`](../packages/shell/shell), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`pwsh-local`](../packages/shell/pwsh-local) | `shell` | [`shell`](../packages/shell/shell), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | `llm` | [`agent`](../packages/core/agent), [`deepseek-account`](../packages/account/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key) | `llm` | [`credentials`](../packages/credentials/credentials), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | `llm` | [`agent`](../packages/core/agent), [`deepseek-account`](../packages/account/deepseek-account), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key) | `llm` | [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-retry`](../packages/llm/llm-retry) | `llm` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`timeout`](../packages/util/timeout) |
| [`agent-default-model`](../packages/core/agent-default-model) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm) |
| [`goal`](../packages/goal/goal) | `goal` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`typert-protocol`](../packages/typert/protocol) |
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/account/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-search-deepseek`](../packages/web/web-search-deepseek) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-search-deepseek`](../packages/web/web-search-deepseek) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`file-reference`](../packages/context/file-reference) | `context` | [`agent`](../packages/core/agent) |
| [`harness-dev-context`](../packages/context/harness-dev-context) | `context` | [`agent`](../packages/core/agent), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) |
| [`time-context`](../packages/context/time-context) | `context` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`util-time`](../packages/util/time) |
@@ -1976,5 +1984,5 @@ flowchart TD
| [`client-test-runtime`](../packages/test-support/client-runtime) | `test-support` | [`api-gateway`](../packages/api/gateway), [`api-session-controller`](../packages/api/session-controller), [`api-workspace-controller`](../packages/api/workspace-controller), [`attachment`](../packages/attachment/attachment), [`client-connection`](../packages/client/connection), [`client-hmr`](../packages/client/hmr), [`client-modules`](../packages/client/modules), [`client-store`](../packages/client/store), [`client-ui-chat`](../packages/client/ui-chat), [`client-ui-context-menu`](../packages/client/ui-context-menu), [`client-ui-conversation`](../packages/client/ui-conversation), [`client-ui-renderer`](../packages/client/ui-renderer), [`client-ui-session`](../packages/client/ui-session), [`client-ui-session-status`](../packages/client/ui-session-status), [`client-ui-settings`](../packages/client/ui-settings), [`client-ui-slots`](../packages/client/ui-slots), [`client-web`](../packages/client/web), [`remote-mock`](../packages/test-support/remote-mock), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`typert-protocol`](../packages/typert/protocol) |
| [`subagent-dsh-sdk`](../packages/subagent/subagent-dsh-sdk) | `subagent` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`sdk-client`](../packages/sdk/client), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess) |
| [`tool-schedule`](../packages/schedule/tool-schedule) | `schedule` | [`llm`](../packages/llm/llm), [`schedule`](../packages/schedule/schedule), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) |
| [`sdk-jsonrpc-server`](../packages/sdk/server) | `sdk` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`commands`](../packages/interaction/commands), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`permission-presets`](../packages/interaction/permission-presets), [`schedule`](../packages/schedule/schedule), [`scope`](../packages/core/scope), [`sdk-protocol`](../packages/sdk/protocol), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) |
| [`sdk-jsonrpc-server`](../packages/sdk/server) | `sdk` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`commands`](../packages/interaction/commands), [`deepseek-auth`](../packages/account/deepseek-auth), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`permission-presets`](../packages/interaction/permission-presets), [`schedule`](../packages/schedule/schedule), [`scope`](../packages/core/scope), [`sdk-protocol`](../packages/sdk/protocol), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) |
<!-- END GENERATED module-graph:packages -->
+16 -8
View File
@@ -121,6 +121,7 @@ flowchart TD
end
subgraph group_account["packages/account"]
pkg_deepseek_account["deepseek-account"]
pkg_deepseek_auth["deepseek-auth"]
end
subgraph group_api["packages/api"]
pkg_api_gateway["api-gateway"]
@@ -668,6 +669,10 @@ flowchart TD
pkg_skill_filesystem --> pkg_fs
pkg_skill_filesystem --> pkg_home_paths
pkg_skill_filesystem --> pkg_skill
pkg_deepseek_auth --> pkg_credentials
pkg_deepseek_auth --> pkg_deepseek_account
pkg_deepseek_auth --> pkg_error
pkg_deepseek_auth --> pkg_launch_environment
pkg_api_workspace_controller --> pkg_api_gateway
pkg_api_workspace_controller --> pkg_client_connection
pkg_api_workspace_controller --> pkg_host_directory_picker
@@ -696,10 +701,12 @@ flowchart TD
pkg_pwsh_local --> pkg_timeout
pkg_llm_deepseek_account --> pkg_agent
pkg_llm_deepseek_account --> pkg_deepseek_account
pkg_llm_deepseek_account --> pkg_deepseek_auth
pkg_llm_deepseek_account --> pkg_launch_environment
pkg_llm_deepseek_account --> pkg_llm
pkg_llm_deepseek_account --> pkg_llm_deepseek
pkg_llm_deepseek_api_key --> pkg_credentials
pkg_llm_deepseek_api_key --> pkg_deepseek_auth
pkg_llm_deepseek_api_key --> pkg_launch_environment
pkg_llm_deepseek_api_key --> pkg_llm
pkg_llm_deepseek_api_key --> pkg_llm_deepseek
@@ -718,15 +725,14 @@ flowchart TD
pkg_goal --> pkg_typert_protocol
pkg_web_deepseek_api --> pkg_agent
pkg_web_deepseek_api --> pkg_credentials
pkg_web_deepseek_api --> pkg_deepseek_account
pkg_web_deepseek_api --> pkg_launch_environment
pkg_web_deepseek_api --> pkg_deepseek_auth
pkg_web_deepseek_api --> pkg_llm
pkg_web_deepseek_api --> pkg_session
pkg_web_deepseek_api --> pkg_web
pkg_web_search_deepseek --> pkg_agent
pkg_web_search_deepseek --> pkg_credentials
pkg_web_search_deepseek --> pkg_deepseek_auth
pkg_web_search_deepseek --> pkg_launch_environment
pkg_web_search_deepseek --> pkg_llm
pkg_web_search_deepseek --> pkg_session
pkg_web_search_deepseek --> pkg_web
pkg_file_reference --> pkg_agent
@@ -1576,6 +1582,7 @@ flowchart TD
pkg_sdk_jsonrpc_server --> pkg_agent
pkg_sdk_jsonrpc_server --> pkg_attachment
pkg_sdk_jsonrpc_server --> pkg_commands
pkg_sdk_jsonrpc_server --> pkg_deepseek_auth
pkg_sdk_jsonrpc_server --> pkg_goal
pkg_sdk_jsonrpc_server --> pkg_llm
pkg_sdk_jsonrpc_server --> pkg_llm_deepseek_api_key
@@ -1820,6 +1827,7 @@ flowchart TD
| [`fs-local`](../packages/fs/fs-local) | `fs` | [`fs`](../packages/fs/fs) |
| [`fs-observation-policy`](../packages/fs/fs-observation-policy) | `fs` | [`fs`](../packages/fs/fs) |
| [`skill-filesystem`](../packages/skill/skill-filesystem) | `skill` | [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`skill`](../packages/skill/skill) |
| [`deepseek-auth`](../packages/account/deepseek-auth) | `account` | [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/account/deepseek-account), [`error`](../packages/util/error), [`launch-environment`](../packages/util/launch-environment) |
| [`api-workspace-controller`](../packages/api/workspace-controller) | `api` | [`api-gateway`](../packages/api/gateway), [`client-connection`](../packages/client/connection), [`host-directory-picker`](../packages/host/directory-picker), [`session`](../packages/core/session), [`storage-domain`](../packages/storage/storage-domain), [`typert-protocol`](../packages/typert/protocol), [`workspace`](../packages/workspace/workspace) |
| [`experimental-api-speech-to-text`](../packages/experimental/api-speech-to-text) | `experimental` | [`experimental-speech-to-text`](../packages/experimental/speech-to-text), [`typert-protocol`](../packages/typert/protocol) |
| [`experimental-client-ui-cot-translation`](../packages/experimental/client-ui-cot-translation) | `experimental` | [`experimental-translator`](../packages/experimental/translator) |
@@ -1828,13 +1836,13 @@ flowchart TD
| [`lsp-stdio`](../packages/lsp/lsp-stdio) | `lsp` | [`error`](../packages/util/error), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`lsp`](../packages/lsp/lsp), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`bash-local`](../packages/shell/bash-local) | `shell` | [`shell`](../packages/shell/shell), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`pwsh-local`](../packages/shell/pwsh-local) | `shell` | [`shell`](../packages/shell/shell), [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
| [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | `llm` | [`agent`](../packages/core/agent), [`deepseek-account`](../packages/account/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key) | `llm` | [`credentials`](../packages/credentials/credentials), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) | `llm` | [`agent`](../packages/core/agent), [`deepseek-account`](../packages/account/deepseek-account), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key) | `llm` | [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek) |
| [`llm-retry`](../packages/llm/llm-retry) | `llm` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`timeout`](../packages/util/timeout) |
| [`agent-default-model`](../packages/core/agent-default-model) | `core` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm) |
| [`goal`](../packages/goal/goal) | `goal` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`typert-protocol`](../packages/typert/protocol) |
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/account/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-search-deepseek`](../packages/web/web-search-deepseek) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`web-search-deepseek`](../packages/web/web-search-deepseek) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-auth`](../packages/account/deepseek-auth), [`launch-environment`](../packages/util/launch-environment), [`session`](../packages/core/session), [`web`](../packages/web/web) |
| [`file-reference`](../packages/context/file-reference) | `context` | [`agent`](../packages/core/agent) |
| [`harness-dev-context`](../packages/context/harness-dev-context) | `context` | [`agent`](../packages/core/agent), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt) |
| [`time-context`](../packages/context/time-context) | `context` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`util-time`](../packages/util/time) |
@@ -1978,5 +1986,5 @@ flowchart TD
| [`client-test-runtime`](../packages/test-support/client-runtime) | `test-support` | [`api-gateway`](../packages/api/gateway), [`api-session-controller`](../packages/api/session-controller), [`api-workspace-controller`](../packages/api/workspace-controller), [`attachment`](../packages/attachment/attachment), [`client-connection`](../packages/client/connection), [`client-hmr`](../packages/client/hmr), [`client-modules`](../packages/client/modules), [`client-store`](../packages/client/store), [`client-ui-chat`](../packages/client/ui-chat), [`client-ui-context-menu`](../packages/client/ui-context-menu), [`client-ui-conversation`](../packages/client/ui-conversation), [`client-ui-renderer`](../packages/client/ui-renderer), [`client-ui-session`](../packages/client/ui-session), [`client-ui-session-status`](../packages/client/ui-session-status), [`client-ui-settings`](../packages/client/ui-settings), [`client-ui-slots`](../packages/client/ui-slots), [`client-web`](../packages/client/web), [`remote-mock`](../packages/test-support/remote-mock), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`typert-protocol`](../packages/typert/protocol) |
| [`subagent-dsh-sdk`](../packages/subagent/subagent-dsh-sdk) | `subagent` | [`agent`](../packages/core/agent), [`llm`](../packages/llm/llm), [`sdk-client`](../packages/sdk/client), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`subprocess`](../packages/subprocess/subprocess) |
| [`tool-schedule`](../packages/schedule/tool-schedule) | `schedule` | [`llm`](../packages/llm/llm), [`schedule`](../packages/schedule/schedule), [`subagent`](../packages/subagent/subagent), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools) |
| [`sdk-jsonrpc-server`](../packages/sdk/server) | `sdk` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`commands`](../packages/interaction/commands), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`permission-presets`](../packages/interaction/permission-presets), [`schedule`](../packages/schedule/schedule), [`scope`](../packages/core/scope), [`sdk-protocol`](../packages/sdk/protocol), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) |
| [`sdk-jsonrpc-server`](../packages/sdk/server) | `sdk` | [`agent`](../packages/core/agent), [`attachment`](../packages/attachment/attachment), [`commands`](../packages/interaction/commands), [`deepseek-auth`](../packages/account/deepseek-auth), [`goal`](../packages/goal/goal), [`llm`](../packages/llm/llm), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`permission-presets`](../packages/interaction/permission-presets), [`schedule`](../packages/schedule/schedule), [`scope`](../packages/core/scope), [`sdk-protocol`](../packages/sdk/protocol), [`session`](../packages/core/session), [`subagent`](../packages/subagent/subagent), [`user-approval`](../packages/interaction/user-approval), [`user-questions`](../packages/interaction/user-questions), [`working-directory`](../packages/session/working-directory) |
<!-- END GENERATED module-graph:packages -->
+22 -22
View File
@@ -558,8 +558,8 @@
en: 028791baa24a6a0a
zh: 028791baa24a6a0a
/session-persistence-event-catalog/resolved-persistence-types/in-history:
en: b952affc9dc40743
zh: dd5d0872283e3762
en: ad2f023eedbc2a7e
zh: 2124b8dedfbf8383
/session-persistence-event-catalog/resolved-persistence-types/in-progress:
en: 61de2b0c9de8c15b
zh: 61de2b0c9de8c15b
@@ -1197,8 +1197,8 @@
en: 8d2873c634bf6405
zh: 91e92b5730462cf0
/session-persistence-event-catalog/resolved-persistence-types/replayenvelope:
en: 293da0eae99bdbe8
zh: 244c9cfd281b9451
en: 34cbedee7bc95921
zh: f7deeddb8d60152a
/session-persistence-event-catalog/resolved-persistence-types/requestcontext:
en: 544039047a28b6bb
zh: c691f0bb1e23db08
@@ -1248,8 +1248,8 @@
en: 29df35a8cc984e75
zh: 321b4e8bb0ad0850
/session-persistence-event-catalog/resolved-persistence-types/streamchunk:
en: 71d48d17e3763774
zh: 8cb0f1d92afa3236
en: 747e384b3176e0cb
zh: defbff408ea7c97c
/session-persistence-event-catalog/resolved-persistence-types/subagentcatalogevent:
en: 8a56ae8e701509b3
zh: caef4f0223f65470
@@ -1317,8 +1317,8 @@
en: 49fcbb63c824347e
zh: 187486d676edfe0e
/session-persistence-event-catalog/resolved-persistence-types/toolschema:
en: d9e99600cd0c02c3
zh: 9885b7337c349b41
en: afa1e3fd9ccdd95b
zh: 7af667e3ebac25e8
/session-persistence-event-catalog/resolved-persistence-types/toolschema~2:
en: 12c14727bb7834e2
zh: b0f3c877873c36db
@@ -2013,11 +2013,11 @@
en: bb507524bcc39c53
zh: 8314898562437473
/session-persistence-event-catalog/resolved-persistence-types/type-block-end:
en: 13224de3736d2d48
zh: 6bf99a32b41f7165
en: 7513d6a33f4ad113
zh: 652201059a3de858
/session-persistence-event-catalog/resolved-persistence-types/type-block-start:
en: 598ec19ec3abf6ed
zh: 84efc0177a9fd177
en: 56230efa41e79869
zh: 9ca4b8990a28d4d9
/session-persistence-event-catalog/resolved-persistence-types/type-chunk:
en: 4b0ed1fe2caa26fb
zh: 8fffdc4f8c3deb79
@@ -2058,8 +2058,8 @@
en: 14e4b48d856bcf57
zh: 72ba176535dc7f3f
/session-persistence-event-catalog/resolved-persistence-types/type-finish:
en: e1b5a95753e1984b
zh: 3a04bd831ff9f12d
en: 30f8f49d0755dc2d
zh: d8553c9590a0e9bf
/session-persistence-event-catalog/resolved-persistence-types/type-goal-change:
en: aad2516b62d3ee83
zh: e7204c4dc4e8e408
@@ -2097,8 +2097,8 @@
en: 4bf62582902829c5
zh: c9da9d11402ee1c4
/session-persistence-event-catalog/resolved-persistence-types/type-reasoning-delta:
en: a2952ab46acfed9d
zh: b4e68befe87800dd
en: a3f08ffda3526201
zh: e599517be130ff99
/session-persistence-event-catalog/resolved-persistence-types/type-request-context:
en: f8addb1a01da9ca1
zh: 4ef11ebddd302c05
@@ -2160,8 +2160,8 @@
en: 28bab22053eabff2
zh: 54c0e424fcb99c05
/session-persistence-event-catalog/resolved-persistence-types/type-text-delta:
en: 9856f0f63d3b413c
zh: c3bae6ac9e949696
en: 5f30a603fab07135
zh: 3b7e2076351a1473
/session-persistence-event-catalog/resolved-persistence-types/type-todo-write:
en: 2fa7ba77598a95b4
zh: 50972b51d77e9155
@@ -2169,8 +2169,8 @@
en: 45ff4145d9e2c7d4
zh: 36a346ff729c4b84
/session-persistence-event-catalog/resolved-persistence-types/type-tool-call-delta:
en: 7c45dcb12f5fedb5
zh: eea8f79e052f2bf0
en: 0e907728f330a8c7
zh: d9d1400d4c468ab2
/session-persistence-event-catalog/resolved-persistence-types/type-tool-workflow-agent-end:
en: 8eb5e1eb95722bc7
zh: 8dd5980029600648
@@ -2202,8 +2202,8 @@
en: 1b045de96172be4b
zh: 8a15c6f35b576b37
/session-persistence-event-catalog/resolved-persistence-types/type-usage:
en: 2b86abaff8e6aaa8
zh: 4afeeb9af04b72f0
en: 0ce623d4c59f5a2f
zh: 2d830e6e1badb1ba
/session-persistence-event-catalog/resolved-persistence-types/type-user-message:
en: 6e4884da342f291a
zh: 454973316ff24910
+11 -11
View File
@@ -2017,7 +2017,7 @@ SHA-256: `ebb768d85ec87fb68e42fc14fd7d8535b5ac11791b14d04c6770180f0a719bf8`
SHA-256: `f311671e07bc7fa645a0b6597de9966b97147956565296ba76a36543801b66c5`
Sources: [`packages/llm/llm/src/types.ts:528`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:440`](../packages/llm/llm/src/types.ts)
`"in-history"`
@@ -4572,7 +4572,7 @@ Sources: [`packages/llm/llm/src/types.ts:75`](../packages/llm/llm/src/types.ts)
SHA-256: `0acd94fe8794574c9ae72c7855ee16d29c546096d4af760d16d1225385764555`
Sources: [`packages/llm/llm/src/types.ts:562`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:474`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -4886,7 +4886,7 @@ Sources: [`packages/skill/skill/src/index.ts:149`](../packages/skill/skill/src/i
SHA-256: `47e9095591ae36e7c39ee62553097772f2bfa16304536a72dbbc3f691f605180`
Sources: [`packages/llm/llm/src/types.ts:584`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:496`](../packages/llm/llm/src/types.ts)
One of:
@@ -5315,7 +5315,7 @@ Sources: [`packages/llm/llm/src/message.ts:172`](../packages/llm/llm/src/message
SHA-256: `66ba70f6f068da443f969a0b947a013c3addd776b9b60a0a393759c19825e9a2`
Sources: [`packages/llm/llm/src/types.ts:605`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:517`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -8336,7 +8336,7 @@ SHA-256: `1033093edd0db80ff410e00830b523405e00bb0c7684948e531ff65095799625`
SHA-256: `d4b739491689cc6bb13d07ffac1a32239875abda364c0d5edd8f74faf5e9c00d`
Sources: [`packages/llm/llm/src/types.ts:589`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:501`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -8350,7 +8350,7 @@ Sources: [`packages/llm/llm/src/types.ts:589`](../packages/llm/llm/src/types.ts)
SHA-256: `3bec87f9e6ab3da03346f49923d3c51621debc0159df68605e543c3b2a026f90`
Sources: [`packages/llm/llm/src/types.ts:585`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:497`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -8568,7 +8568,7 @@ SHA-256: `b54940ff095c17e874c5be03815f4c2145a256cf3a1d34dae4ab2f7769dfffe8`
SHA-256: `a2b49331716ba0a7078b026d145306a70eae64b7313c3e6204bd931e75ec3bb1`
Sources: [`packages/llm/llm/src/types.ts:591`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:503`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -8774,7 +8774,7 @@ Sources: [`packages/llm/llm/src/assistant-stream.ts:27`](../packages/llm/llm/src
SHA-256: `2abb711460e6238d851c30f3e4bdd87a2aa1887ee70575b3d3b7b25610673095`
Sources: [`packages/llm/llm/src/types.ts:587`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:499`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -9110,7 +9110,7 @@ Sources: [`packages/llm/llm/src/assistant-stream.ts:20`](../packages/llm/llm/src
SHA-256: `95080295115fbd83544520ba247b68a03790131f6a2eac323d388758cb542f65`
Sources: [`packages/llm/llm/src/types.ts:586`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:498`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -9158,7 +9158,7 @@ Sources: [`packages/llm/llm/src/assistant-stream.ts:34`](../packages/llm/llm/src
SHA-256: `88a610b831be6d92612a464be5c7d0b88ec24d97bd299837bf74bf7672183c9a`
Sources: [`packages/llm/llm/src/types.ts:588`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:500`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
@@ -9336,7 +9336,7 @@ SHA-256: `aa0957eca50aeb28bcd2e6930b95809926edacb550c8c340ba526ba6b861b3d8`
SHA-256: `f1a96afe7503ac1817de769cd0ba13d9b80111c7034c50106b3344ecc14cc515`
Sources: [`packages/llm/llm/src/types.ts:590`](../packages/llm/llm/src/types.ts)
Sources: [`packages/llm/llm/src/types.ts:502`](../packages/llm/llm/src/types.ts)
| Property | Presence | Type |
|---|---|---|
+11 -11
View File
@@ -2019,7 +2019,7 @@ SHA-256: `ebb768d85ec87fb68e42fc14fd7d8535b5ac11791b14d04c6770180f0a719bf8`
SHA-256: `f311671e07bc7fa645a0b6597de9966b97147956565296ba76a36543801b66c5`
来源:[`packages/llm/llm/src/types.ts:528`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:440`](../packages/llm/llm/src/types.ts)
`"in-history"`
@@ -4574,7 +4574,7 @@ SHA-256: `814d9434e1ddf9078612b3b34322f26e9363b469213335007f7e9ba7fee9464e`
SHA-256: `0acd94fe8794574c9ae72c7855ee16d29c546096d4af760d16d1225385764555`
来源:[`packages/llm/llm/src/types.ts:562`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:474`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -4888,7 +4888,7 @@ SHA-256: `672c4aa2a9b736e3d6e5da6346d2e2ed5e3573f2d0baafa18e7407c9f3fee3db`
SHA-256: `47e9095591ae36e7c39ee62553097772f2bfa16304536a72dbbc3f691f605180`
来源:[`packages/llm/llm/src/types.ts:584`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:496`](../packages/llm/llm/src/types.ts)
以下类型之一:
@@ -5317,7 +5317,7 @@ SHA-256: `4b259f7f8f0a44ad5e90b70a73553ced1df27012d126921d397ff403b6c86731`
SHA-256: `66ba70f6f068da443f969a0b947a013c3addd776b9b60a0a393759c19825e9a2`
来源:[`packages/llm/llm/src/types.ts:605`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:517`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -8338,7 +8338,7 @@ SHA-256: `1033093edd0db80ff410e00830b523405e00bb0c7684948e531ff65095799625`
SHA-256: `d4b739491689cc6bb13d07ffac1a32239875abda364c0d5edd8f74faf5e9c00d`
来源:[`packages/llm/llm/src/types.ts:589`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:501`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -8352,7 +8352,7 @@ SHA-256: `d4b739491689cc6bb13d07ffac1a32239875abda364c0d5edd8f74faf5e9c00d`
SHA-256: `3bec87f9e6ab3da03346f49923d3c51621debc0159df68605e543c3b2a026f90`
来源:[`packages/llm/llm/src/types.ts:585`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:497`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -8570,7 +8570,7 @@ SHA-256: `b54940ff095c17e874c5be03815f4c2145a256cf3a1d34dae4ab2f7769dfffe8`
SHA-256: `a2b49331716ba0a7078b026d145306a70eae64b7313c3e6204bd931e75ec3bb1`
来源:[`packages/llm/llm/src/types.ts:591`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:503`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -8776,7 +8776,7 @@ SHA-256: `71bb3254ec8f1e491ce63b762a7b5f18709de23aa4e8abcc8b886f4b6ce051dd`
SHA-256: `2abb711460e6238d851c30f3e4bdd87a2aa1887ee70575b3d3b7b25610673095`
来源:[`packages/llm/llm/src/types.ts:587`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:499`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -9112,7 +9112,7 @@ SHA-256: `e72269f931559e901e5e8fe1cfcbd0669fb795f43cc038ff39fba62f60403c33`
SHA-256: `95080295115fbd83544520ba247b68a03790131f6a2eac323d388758cb542f65`
来源:[`packages/llm/llm/src/types.ts:586`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:498`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -9160,7 +9160,7 @@ SHA-256: `3860b4757d512a2869be833acb0faf834335b1b056bf3f83df5474dce95f8fa6`
SHA-256: `88a610b831be6d92612a464be5c7d0b88ec24d97bd299837bf74bf7672183c9a`
来源:[`packages/llm/llm/src/types.ts:588`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:500`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
@@ -9338,7 +9338,7 @@ SHA-256: `aa0957eca50aeb28bcd2e6930b95809926edacb550c8c340ba526ba6b861b3d8`
SHA-256: `f1a96afe7503ac1817de769cd0ba13d9b80111c7034c50106b3344ecc14cc515`
来源:[`packages/llm/llm/src/types.ts:590`](../packages/llm/llm/src/types.ts)
来源:[`packages/llm/llm/src/types.ts:502`](../packages/llm/llm/src/types.ts)
| 属性 | 存在性 | 类型 |
|---|---|---|
+11 -11
View File
@@ -89,7 +89,7 @@
{"digest":"0a8a062bc9c3c0d97fd97742262f2ea53dd32297f834e81114870d38ac3dc6da","names":[],"sources":[]},
{"digest":"0a92c5bdfa06c2e2615b777728f3aa95f408d43b9012e7b754568311251db623","names":[],"sources":["packages/experimental/liveshare/src/host/viewer-principal.ts:29"]},
{"digest":"0aa62ab51b36c0e64b134bd03ba8725d758744180a1a447da49beaad194f219f","names":[],"sources":[]},
{"digest":"0acd94fe8794574c9ae72c7855ee16d29c546096d4af760d16d1225385764555","names":["packages/llm/llm/src/types.ts#ReplayEnvelope"],"sources":["packages/llm/llm/src/types.ts:562"]},
{"digest":"0acd94fe8794574c9ae72c7855ee16d29c546096d4af760d16d1225385764555","names":["packages/llm/llm/src/types.ts#ReplayEnvelope"],"sources":["packages/llm/llm/src/types.ts:474"]},
{"digest":"0aed9f5c80e82b6e80e92eace5b9e23cd5e58c567d37b4321cd147d51342e212","names":["packages/llm/llm/src/message.ts#UserMessage"],"sources":["packages/llm/llm/src/message.ts:161"]},
{"digest":"0af3ecfb8c60d416fc40a7cc4fb2c4851a8e46608b2b38ab9e510670c971aa1f","names":[],"sources":[]},
{"digest":"0b6d718c693fdf7f06dcccb0bcbbabe78cc63514eafc62d6b2a3899735279d6f","names":["packages/goal/goal/src/types.ts#GoalRef"],"sources":["packages/goal/goal/src/types.ts:20"]},
@@ -182,7 +182,7 @@
{"digest":"297fbd8067d7815adae02b89790ec6ff5fb7c2cb0d0eb026e1746c24ec857761","names":[],"sources":[]},
{"digest":"2aad1179f957631477b582e57cd8f538cb82618fc3fb816bde1171154235b065","names":[],"sources":[]},
{"digest":"2ab12a0e345658f9342816d773fe610f049982bcad82631f43b9205abe43e5ee","names":[],"sources":[]},
{"digest":"2abb711460e6238d851c30f3e4bdd87a2aa1887ee70575b3d3b7b25610673095","names":[],"sources":["packages/llm/llm/src/types.ts:587"]},
{"digest":"2abb711460e6238d851c30f3e4bdd87a2aa1887ee70575b3d3b7b25610673095","names":[],"sources":["packages/llm/llm/src/types.ts:499"]},
{"digest":"2aed07493b1c65b6d00de5586da1e743cf501684b9ad43a1765fb4007d4ea456","names":[],"sources":[]},
{"digest":"2c4c21f19f426a58f2dac914e34313aa43f8408972de857a486d1f086d5adb6c","names":[],"sources":[]},
{"digest":"2c64d4bc7264fd3f8bed47e96ab8a593bce05a1e4e1c436dcd244a3b7e0c2a9d","names":[],"sources":[]},
@@ -224,7 +224,7 @@
{"digest":"3bc287e765d58dc3a22672a0495a6cfd561220dd38fbaecef80aa95b96caed79","names":[],"sources":[]},
{"digest":"3bd652ebfa8726b3ce3937a4f1bd2759e02f86b3a08a20f9e41a8513656fbc5f","names":["packages/core/session/src/types.ts#OptionalSessionSeq"],"sources":["packages/core/session/src/types.ts:66"]},
{"digest":"3bdb8dc6989655b0d4ec361edafb8e2629bc263e1ea591819414fdafc1a413b3","names":[],"sources":[]},
{"digest":"3bec87f9e6ab3da03346f49923d3c51621debc0159df68605e543c3b2a026f90","names":[],"sources":["packages/llm/llm/src/types.ts:585"]},
{"digest":"3bec87f9e6ab3da03346f49923d3c51621debc0159df68605e543c3b2a026f90","names":[],"sources":["packages/llm/llm/src/types.ts:497"]},
{"digest":"3bfeb47b58606f4661904bc723da612782214c463d01e6d61cd6d6193d7374e1","names":[],"sources":[]},
{"digest":"3c2535ca0a2062f172f15344f8040755002b5ac506cf94fc4ebaa822b15feb8c","names":[],"sources":[]},
{"digest":"3cfc3a56502da1f8c6153c2c56657bab4b749056968634dd0991d325ec1c919f","names":["packages/core/tools/src/contracts.ts#ToolRestriction"],"sources":["packages/core/tools/src/contracts.ts:395"]},
@@ -249,7 +249,7 @@
{"digest":"45f2a07ea94573123b6ae14db787a40062dec3834f36d8be92c523d40ba28448","names":[],"sources":["packages/interaction/user-approval/src/types.ts:44"]},
{"digest":"477614bca595a9e7adb5a1870be446b9a8684f3ba8950259d6289f2d3b74f028","names":[],"sources":["packages/compaction/compaction-image-offload/src/projection.ts:25"]},
{"digest":"47e5d84f1a93450a78c7f3954b43990d0f629af7c034a56313e5deb63e772c1b","names":[],"sources":[]},
{"digest":"47e9095591ae36e7c39ee62553097772f2bfa16304536a72dbbc3f691f605180","names":["packages/llm/llm/src/types.ts#StreamChunk"],"sources":["packages/llm/llm/src/types.ts:584"]},
{"digest":"47e9095591ae36e7c39ee62553097772f2bfa16304536a72dbbc3f691f605180","names":["packages/llm/llm/src/types.ts#StreamChunk"],"sources":["packages/llm/llm/src/types.ts:496"]},
{"digest":"487b65c37bfedb8b72088c4107a0a90a6249701f6b26745f6d98f9b8a22b07c7","names":[],"sources":["packages/llm/llm/src/assistant-stream.ts:43"]},
{"digest":"48e5c9861f16ac07e78cb7b5ae9dabdf7bb85c58baed5a51b4ad275050ea58e3","names":[],"sources":[]},
{"digest":"48f9c19417a1abbedfa59f4667bba36b93ac2db407adf5e84cb3ba0de30942cb","names":[],"sources":[]},
@@ -326,7 +326,7 @@
{"digest":"6598cd6da253948d6b207c6374a45335804c79b576866d6215649c2d1bc85e25","names":["packages/team/agent-team/src/types.ts#TeamMemberSnapshot"],"sources":["packages/team/agent-team/src/types.ts:50"]},
{"digest":"65a8400e451e667e5b6e34df72ceb81fca8c12330330fa72083ad40279b189ad","names":["packages/llm/llm/src/message.ts#SystemPromptMessageSource"],"sources":["packages/llm/llm/src/message.ts:34"]},
{"digest":"65d583e66518c5236015e0846470fb32efcf92375ed306aef14e50a9d2cd2099","names":["packages/skill/tool-skill/src/index.ts#SkillCatalogSource"],"sources":["packages/skill/tool-skill/src/index.ts:36"]},
{"digest":"66ba70f6f068da443f969a0b947a013c3addd776b9b60a0a393759c19825e9a2","names":["packages/llm/llm/src/types.ts#ToolSchema"],"sources":["packages/llm/llm/src/types.ts:605"]},
{"digest":"66ba70f6f068da443f969a0b947a013c3addd776b9b60a0a393759c19825e9a2","names":["packages/llm/llm/src/types.ts#ToolSchema"],"sources":["packages/llm/llm/src/types.ts:517"]},
{"digest":"672c4aa2a9b736e3d6e5da6346d2e2ed5e3573f2d0baafa18e7407c9f3fee3db","names":["packages/skill/skill/src/index.ts#SkillInvocationSource"],"sources":["packages/skill/skill/src/index.ts:149"]},
{"digest":"67d5f73ceae82f5265258142ad6cf172de2c1fef93ba551b7f0454e0a93bffe0","names":["packages/llm/llm/src/call-config.ts#LlmCallConfig"],"sources":["packages/llm/llm/src/call-config.ts:30"]},
{"digest":"68141cbe3994a5ffcd064c07c75996538437fd9dbf77ce8a2927e89ec577fabe","names":[],"sources":[]},
@@ -413,7 +413,7 @@
{"digest":"871bfd6f7bb91061246768d3377f3fd58d6b8ea7c31f44c714ae7ab215650d62","names":[],"sources":[]},
{"digest":"87b1a33564b9a4d63b00988a524c12259243953aebb9c9a05127d87b27464df9","names":[],"sources":[]},
{"digest":"88841202942c7683b3b7e5ea6a796047ec326b6701ac23e58cc236d85613b9fa","names":[],"sources":[]},
{"digest":"88a610b831be6d92612a464be5c7d0b88ec24d97bd299837bf74bf7672183c9a","names":[],"sources":["packages/llm/llm/src/types.ts:588"]},
{"digest":"88a610b831be6d92612a464be5c7d0b88ec24d97bd299837bf74bf7672183c9a","names":[],"sources":["packages/llm/llm/src/types.ts:500"]},
{"digest":"8a046b52331959aa3394680d6acbe09b8a5447c6b61375f263445bfcef19b7f1","names":[],"sources":[]},
{"digest":"8a6e1ec9e8db346b0e02f027db73c07a94f067a26d40c1aef1abd09c47ce7ba0","names":[],"sources":[]},
{"digest":"8a9c990773f798eac10ca8878e6bcc531ee080bc589cac956730e462cc6a09ad","names":[],"sources":["packages/interaction/permission-presets/src/index.ts:61"]},
@@ -441,7 +441,7 @@
{"digest":"93cbbc5a7fd0b1aa1ff1b9a6bb5ec52b073f48e5a5200365c45c0cd54059e1b9","names":[],"sources":["packages/interaction/user-approval/src/types.ts:55"]},
{"digest":"93d38436347f67c9022aacbc4472e283d722bcab8eb73fc376aaf7b6a6b9fb35","names":[],"sources":[]},
{"digest":"94c56aeb1564ad735eb773d88636b40761d063efa1610f1308004d32923f5378","names":[],"sources":[]},
{"digest":"95080295115fbd83544520ba247b68a03790131f6a2eac323d388758cb542f65","names":[],"sources":["packages/llm/llm/src/types.ts:586"]},
{"digest":"95080295115fbd83544520ba247b68a03790131f6a2eac323d388758cb542f65","names":[],"sources":["packages/llm/llm/src/types.ts:498"]},
{"digest":"95a3ffccbf3c8afcf9a2f3b355f724da8e07e98dc47ee741166dde7f9ea058bd","names":[],"sources":[]},
{"digest":"95c0e88fcf0bafb2087f912ad9e2369de6ae6530cc0c4c2772c96205b57f7f60","names":[],"sources":[]},
{"digest":"9645cf93769a6dfb227bd400bd6cb9fa7bab9140f4a851e4ae92514ade6e3114","names":[],"sources":[]},
@@ -475,7 +475,7 @@
{"digest":"a15a19ef63cf5d1b711db1d249821dab0cedcd3a9ad09137b47352c93841fd20","names":[],"sources":[]},
{"digest":"a16e567c8cd2c55cf1e911aed3c200c4e1f6febb1459ff2a9e7adf159afb68cb","names":[],"sources":[]},
{"digest":"a2066bd52f61218ba15b758def2641cc6a8bd3d4a594a488ee4c65be356d7e39","names":[],"sources":[]},
{"digest":"a2b49331716ba0a7078b026d145306a70eae64b7313c3e6204bd931e75ec3bb1","names":[],"sources":["packages/llm/llm/src/types.ts:591"]},
{"digest":"a2b49331716ba0a7078b026d145306a70eae64b7313c3e6204bd931e75ec3bb1","names":[],"sources":["packages/llm/llm/src/types.ts:503"]},
{"digest":"a2be0f0cb59f0d4a06557d45847d1938aced238baa77a6da416e590b8b958553","names":[],"sources":[]},
{"digest":"a3a259a1aa5401af786ce08c4a8419681d3000d73467991b5fc563389bc4ebd2","names":[],"sources":[]},
{"digest":"a3c6f1ea38e9a61d7a9706057ba65aabe02dfe6d9dd90d4736aa62325d874531","names":[],"sources":[]},
@@ -597,7 +597,7 @@
{"digest":"d215701afb7aafbfd63205a6bbb8803aed60810bd613e2dbbc43071c38b6c568","names":[],"sources":["packages/experimental/timeline/src/reminders.ts:14"]},
{"digest":"d28765f87d6b6ab408e0b2f3e7e297791b004b806d8e302c49903ebae815feb2","names":[],"sources":[]},
{"digest":"d49164d37eab0f0f70fa787c65d887abbea869c010ccb103d717fab3519c3a41","names":[],"sources":[]},
{"digest":"d4b739491689cc6bb13d07ffac1a32239875abda364c0d5edd8f74faf5e9c00d","names":[],"sources":["packages/llm/llm/src/types.ts:589"]},
{"digest":"d4b739491689cc6bb13d07ffac1a32239875abda364c0d5edd8f74faf5e9c00d","names":[],"sources":["packages/llm/llm/src/types.ts:501"]},
{"digest":"d4c799e3d51cae1040362ba4968efc484739e14416c9c1df20c2f108b4ef2eb5","names":[],"sources":[]},
{"digest":"d4e4d575abeb4b72d616dc65c17ac0eaa943cc135609395044c38d5afcb10e31","names":[],"sources":[]},
{"digest":"d63b8b8ffad9c02fd80c43a17df4f240c1fe8118ecca9de34f9d5871838ab5b9","names":[],"sources":[]},
@@ -671,11 +671,11 @@
{"digest":"f1687f982fa3d41ef29e159feed154ecd13af4dd209acaee16038f223f2e9402","names":["packages/core/session/src/types.ts#TurnEndReason"],"sources":["packages/core/session/src/types.ts:238"]},
{"digest":"f1996af2602e6f62b5ab179ca5c4af00d8753938b74cc6ef102de09e99e74a7e","names":[],"sources":[]},
{"digest":"f19bee84bf3d20904553cdcd57465232bc1c2a194f54c4d195292ba0487223a6","names":["packages/attachment/attachment/src/types.ts#FileAttachmentRef"],"sources":["packages/attachment/attachment/src/types.ts:39"]},
{"digest":"f1a96afe7503ac1817de769cd0ba13d9b80111c7034c50106b3344ecc14cc515","names":[],"sources":["packages/llm/llm/src/types.ts:590"]},
{"digest":"f1a96afe7503ac1817de769cd0ba13d9b80111c7034c50106b3344ecc14cc515","names":[],"sources":["packages/llm/llm/src/types.ts:502"]},
{"digest":"f230c0b583e23b25ee0a61dbe4c05e95c1e2ae44b27939501eb9e03696f0c278","names":[],"sources":[]},
{"digest":"f29d63336e8266d80dd7baeab219436db86341304f6be1cd0edb36f5134c4a47","names":[],"sources":[]},
{"digest":"f2da0f27c1e6add59982c37b15e4a4912c5b33466859cce3b13d503600e24aef","names":["packages/llm/llm/src/types.ts#FileBlock"],"sources":["packages/llm/llm/src/types.ts:105"]},
{"digest":"f311671e07bc7fa645a0b6597de9966b97147956565296ba76a36543801b66c5","names":["packages/llm/llm/src/types.ts#SystemPromptUpdate"],"sources":["packages/llm/llm/src/types.ts:528"]},
{"digest":"f311671e07bc7fa645a0b6597de9966b97147956565296ba76a36543801b66c5","names":["packages/llm/llm/src/types.ts#SystemPromptUpdate"],"sources":["packages/llm/llm/src/types.ts:440"]},
{"digest":"f4a66f654996c093aae700ea4c434ff2ee3569fea9c0e5813ccf6afdccabd163","names":[],"sources":[]},
{"digest":"f5520c1d261ca86ea03735799c311a0a9ede8babb588cf0a65422576d2ee0ad1","names":[],"sources":[]},
{"digest":"f56c5b59ca0161310c338d31dd16cf14287ccd602ff4181058df178c1c286d7f","names":["packages/context/session-reference/src/types.ts#SessionReferenceSource"],"sources":["packages/context/session-reference/src/types.ts:13"]},
+2 -2
View File
@@ -6,8 +6,8 @@
en: 2302e2999588bac3
zh: 5e0ac058b50036dc
/deepseek-account/request-credentials:
en: c5fb32307f841c66
zh: 8ed40c0c99884301
en: a5d0001547d8341f
zh: 0c553f214b9ce6ea
/deepseek-account/embedded-platform-credentials:
en: 9a651d70acbe83a6
zh: 4624b0299f5fdd8e
+48 -1
View File
@@ -8,7 +8,7 @@ Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/accoun
## Request credentials
`resolveRequestCredential(url)` is Host-only. It answers `undefined` while signed out, during credential removal, and for any destination outside the configured `inferenceOrigin`; otherwise it returns an `AccountRequestCredential` whose `headers` carry the token as `x-dsh-auth-token`, whose `value` is the bare token, and whose `reject()` removes the stored grant only while it still matches that token, containing storage failures so the caller reports the destination's rejection. Its `revoked` signal aborts when the account signs out of the sign-in that token belongs to, by the user or after a rejection, once the `deepseek-account/signed-out` listeners have returned; the account model route and the DeepSeek web providers run each model, Files, Search, and Fetch request that carries the token under it, so a sign-out ends those requests even after the plugin that sent them has unloaded. The `deepseek-account` model route publishes this credential through `ctx.llm.providerCredential('deepseek-account')` ([LLM streaming](llm-streaming.md)); the DeepSeek web providers consume it there and, without that route, ask the account service directly. `reject()` runs on the account service mounted when it is called, so a reload between a request and the destination's answer still removes the grant; without a mounted service it leaves the grant for the next one to reject. A credential released by an account service that has since been replaced keeps an unaborted signal, because the replacement withdraws only the credentials it released.
`resolveRequestCredential(url)` is Host-only. It answers `undefined` while signed out, during credential removal, and for any destination outside the configured `inferenceOrigin`; otherwise it returns an `AccountRequestCredential` whose `headers` carry the token as `x-dsh-auth-token` and whose `reject()` removes the stored grant only while it still matches that token, containing storage failures so the caller reports the destination's rejection. Its `revoked` signal aborts when the account signs out of the sign-in that token belongs to, by the user or after a rejection, once the `deepseek-account/signed-out` listeners have returned; the account model route and the DeepSeek web providers run each model, Files, Search, and Fetch request that carries the token under it, so a sign-out ends those requests even after the plugin that sent them has unloaded. Consumers do not call it themselves: [`ctx.deepseekAuth`](../../packages/account/deepseek-auth/README.md) asks for the credential on behalf of the `deepseek-account` model route and the DeepSeek web providers, for a destination under the origin of that route's base URL or, without that route, of `DEEPSEEK_BASE_URL`. `reject()` runs on the account service mounted when it is called, so a reload between a request and the destination's answer still removes the grant; without a mounted service it leaves the grant for the next one to reject. A credential released by an account service that has since been replaced keeps an unaborted signal, because the replacement withdraws only the credentials it released.
Model routes that bill the account register a running-task report with `registerRunningTaskReport(report)` inside `ctx.effect()`; `hasRunningAccountTasks()` answers true while any report does, so the sign-out confirmation can warn about work the sign-out interrupts. The route plugin owns cancellation of that work after `deepseek-account/signed-out`; a request that outlives the plugin ends through its credential's `revoked` signal, and the plugin's failure callback for that request cancels the work.
@@ -167,6 +167,53 @@ watch(signal: AbortSignal, includeIdentityChanges: boolean = false): AsyncIterab
Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/account/deepseek-account/src/index.ts)
<a id="ctxdeepseekauth--deepseekauth"></a>
### `ctx.deepseekAuth` — `DeepSeekAuth`
`ctx.deepseekAuth`: the two DeepSeek credential kinds behind one request-authorization operation.
```ts cordis-catalog
/**
* Connect the deployment a model route plugin's settings name for one kind. Call it from within `ctx.effect()`.
* @param kind - the kind the plugin's route bills.
* @param route - provider route the plugin registers; {@link routeKind} answers `kind` for it while connected.
* @param connection - reads the plugin's current settings; a throw marks the kind unresolved for that operation.
* @returns the disposer removing the connection.
* @throws {DeepSeekAuthError} code `DUPLICATE_CONNECTION` when the kind is already connected.
*/
connect(kind: DeepSeekAuthKind, route: string, connection: () => DeepSeekAuthConnection): () => void
/**
* The kind that bills a conversation on one model route.
* @param route - provider route of a model request; undefined names none.
* @returns the kind connected under that route, or undefined for a route no plugin connected.
*/
routeKind(route: string | undefined): DeepSeekAuthKind | undefined
/**
* The kinds one request can authenticate with, in the order its billing tries them, each bound to its destination.
* Nothing is read from a credential store.
* @param request - the request.
* @returns candidates and unresolved kinds, first preferred; empty when the destination accepts no kind the
* billing allows or no allowed kind serves an absolute destination.
*/
candidates(request: DeepSeekAuthRequest): (DeepSeekAuthCandidate | DeepSeekAuthUnresolved)[]
/**
* Release the credential of the first candidate that has one. A later candidate is not read once an earlier one
* has a credential, fails to read, or does not resolve.
* @param request - the request.
* @param signal - cancellation for the lookups.
* @returns the authorization, or undefined when no candidate has a credential.
* @throws {DeepSeekAuthError} code `UNRESOLVED_CONNECTION` at an unresolved kind, `INVALID_CREDENTIAL` for an
* unusable API key; store failures propagate.
*/
async authorize(request: DeepSeekAuthRequest, signal?: AbortSignal): Promise<DeepSeekAuthorization | undefined>
```
Source: [`packages/account/deepseek-auth/src/index.ts`](../../packages/account/deepseek-auth/src/index.ts)
<a id="deepseek-account-events"></a>
### `deepseek-account/*` events
+48 -1
View File
@@ -8,7 +8,7 @@
## 请求凭据
`resolveRequestCredential(url)` 仅限 Host。未登录、凭据删除进行中,以及目标地址不在配置的 `inferenceOrigin` 之内时,它回答 `undefined`;否则返回一个 `AccountRequestCredential`:`headers` 以 `x-dsh-auth-token` 携带 token,`value` 是裸 token,`reject()` 仅在已存授权仍与该 token 一致时删除它,并隔离存储失败,使调用方报告的是目标地址的拒绝。其 `revoked` 信号在账号退出该 token 所属的登录时中止,无论退登由用户发起还是由拒绝触发,且在 `deepseek-account/signed-out` 的监听器返回之后;账号模型路由和 DeepSeek Web 提供方让携带该 token 的每个模型、Files、Search 与 Fetch 请求受它约束,因此即使发出请求的插件已卸载,退登仍会结束这些请求。`deepseek-account` 模型路由通过 `ctx.llm.providerCredential('deepseek-account')`([LLM 流式](llm-streaming.zh.md))发布这份凭据;DeepSeek Web 提供方在那里消费它,没有该路由时直接询问账号服务。`reject()` 在被调用时挂载的账号服务上执行,因此请求与目的地应答之间发生的重载仍会移除授权;没有挂载的服务时,授权留给下一个挂载的服务处理。已被替换的账号服务释放的凭据,其信号保持未中止,因为替换后的服务只撤回自己释放的凭据。
`resolveRequestCredential(url)` 仅限 Host。未登录、凭据删除进行中,以及目标地址不在配置的 `inferenceOrigin` 之内时,它回答 `undefined`;否则返回一个 `AccountRequestCredential`:`headers` 以 `x-dsh-auth-token` 携带 token,`reject()` 仅在已存授权仍与该 token 一致时删除它,并隔离存储失败,使调用方报告的是目标地址的拒绝。其 `revoked` 信号在账号退出该 token 所属的登录时中止,无论退登由用户发起还是由拒绝触发,且在 `deepseek-account/signed-out` 的监听器返回之后;账号模型路由和 DeepSeek Web 提供方让携带该 token 的每个模型、Files、Search 与 Fetch 请求受它约束,因此即使发出请求的插件已卸载,退登仍会结束这些请求。消费方不直接调用它:[`ctx.deepseekAuth`](../../packages/account/deepseek-auth/README.zh.md) 代 `deepseek-account` 模型路由和 DeepSeek Web 提供方索取这份凭据,目标地址位于该路由基础地址的 origin 之下;没有该路由时,位于 `DEEPSEEK_BASE_URL` 的 origin 之下。`reject()` 在被调用时挂载的账号服务上执行,因此请求与目的地应答之间发生的重载仍会移除授权;没有挂载的服务时,授权留给下一个挂载的服务处理。已被替换的账号服务释放的凭据,其信号保持未中止,因为替换后的服务只撤回自己释放的凭据。
按账号计费的模型路由在 `ctx.effect()` 内用 `registerRunningTaskReport(report)` 注册运行中任务报告;只要有报告回答 true,`hasRunningAccountTasks()` 就回答 true,使退登确认能够提醒退登将打断的工作。`deepseek-account/signed-out` 之后取消这些工作由路由插件负责;比插件存活更久的请求通过其凭据的 `revoked` 信号结束,插件为该请求提供的失败回调随后取消这些工作。
@@ -167,6 +167,53 @@ watch(signal: AbortSignal, includeIdentityChanges: boolean = false): AsyncIterab
Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/account/deepseek-account/src/index.ts)
<a id="ctxdeepseekauth--deepseekauth"></a>
### `ctx.deepseekAuth` — `DeepSeekAuth`
`ctx.deepseekAuth`: the two DeepSeek credential kinds behind one request-authorization operation.
```ts cordis-catalog
/**
* Connect the deployment a model route plugin's settings name for one kind. Call it from within `ctx.effect()`.
* @param kind - the kind the plugin's route bills.
* @param route - provider route the plugin registers; {@link routeKind} answers `kind` for it while connected.
* @param connection - reads the plugin's current settings; a throw marks the kind unresolved for that operation.
* @returns the disposer removing the connection.
* @throws {DeepSeekAuthError} code `DUPLICATE_CONNECTION` when the kind is already connected.
*/
connect(kind: DeepSeekAuthKind, route: string, connection: () => DeepSeekAuthConnection): () => void
/**
* The kind that bills a conversation on one model route.
* @param route - provider route of a model request; undefined names none.
* @returns the kind connected under that route, or undefined for a route no plugin connected.
*/
routeKind(route: string | undefined): DeepSeekAuthKind | undefined
/**
* The kinds one request can authenticate with, in the order its billing tries them, each bound to its destination.
* Nothing is read from a credential store.
* @param request - the request.
* @returns candidates and unresolved kinds, first preferred; empty when the destination accepts no kind the
* billing allows or no allowed kind serves an absolute destination.
*/
candidates(request: DeepSeekAuthRequest): (DeepSeekAuthCandidate | DeepSeekAuthUnresolved)[]
/**
* Release the credential of the first candidate that has one. A later candidate is not read once an earlier one
* has a credential, fails to read, or does not resolve.
* @param request - the request.
* @param signal - cancellation for the lookups.
* @returns the authorization, or undefined when no candidate has a credential.
* @throws {DeepSeekAuthError} code `UNRESOLVED_CONNECTION` at an unresolved kind, `INVALID_CREDENTIAL` for an
* unusable API key; store failures propagate.
*/
async authorize(request: DeepSeekAuthRequest, signal?: AbortSignal): Promise<DeepSeekAuthorization | undefined>
```
Source: [`packages/account/deepseek-auth/src/index.ts`](../../packages/account/deepseek-auth/src/index.ts)
<a id="deepseek-account-events"></a>
### `deepseek-account/*` events
+4 -4
View File
@@ -36,8 +36,8 @@
en: 58dec2259b0b1c6f
zh: fc99fe965acaabf3
/llm-streaming/the-model-request:
en: 61d4131601adbc32
zh: b83156c875d29b89
en: 834d3d8d6b5871ab
zh: 393889ec6075f622
/llm-streaming/the-model-request/the-request-envelope-llmcallconfig-and-the-logged-header:
en: b0eb4620c6953646
zh: fabf51c7245a4855
@@ -48,5 +48,5 @@
en: 8c140f9c5a799f01
zh: f66b895594247e92
/llm-streaming/service-and-provider-contracts:
en: 81b4ede66c5e906d
zh: 2ad0ddb1a32e3167
en: 8dc79d4cc82824c2
zh: 3ebabd3a117ad717
-103
View File
@@ -527,86 +527,6 @@ interface LlmNativeAuth {
}
```
A route's adapter can also publish the credential the route currently sends, so consumers that call the same deployment outside the model request path, such as the DeepSeek web providers, reuse it through `ctx.llm.providerCredential(provider)` instead of reading provider configuration or choosing header names. A grant is Host-only and is held for one operation; `kind` is merge-extensible through `LlmCredentialKindMap`, whose declared members are `api-key` and `account`. A grant whose owner can withdraw the credential while requests carry it, as an account sign-out does, has a `revoked` signal: the consumer runs each request it authenticates under that signal and reports a request the signal ended as its own failure, not as the caller's cancellation.
```ts type-equiv
/**
* One credential released for one destination. Host-only: it carries the
* secret, so it never crosses a Remote boundary and never enters a log.
*/
interface ProviderCredentialGrant {
/**
* Request headers carrying the credential as the route's own protocol
* expects it, such as `x-api-key` for an API key. Consumers speaking that
* protocol send them unchanged.
*/
readonly headers: Readonly<Record<string, string>>
/**
* The bare credential value, for destinations whose protocol renders it
* differently from {@link headers}, such as `Authorization: Bearer`.
*/
readonly value: string
/**
* Invalidate this exact credential after the destination rejected it with
* HTTP 401 so no later request resends it. Absent for kinds without
* invalidation. The owner contains storage failures: the caller reports the
* destination's rejection, never a failure of this call.
* @returns settlement after the invalidation attempt.
*/
reject?(): Promise<void>
/**
* Aborts when the owner withdraws this credential while requests carrying it
* may be in flight, as an account sign-out does. A consumer ends each request
* it authenticated with this grant and reports that end as its own failure,
* not as the caller's cancellation. Absent for kinds that are never withdrawn.
*/
readonly revoked?: AbortSignal
}
```
```ts type-equiv
/**
* The credential one registered provider route currently sends, answered by
* the route's owning adapter so that consumers read no provider configuration
* and choose no header names. `ctx.llm.providerCredential()` resolves a new value
* per call from one configuration generation; a caller keeps it for one
* operation only.
*/
interface ProviderCredential {
/** Kind of credential the route sends. */
readonly kind: LlmCredentialKind
/**
* The route's current request base URL as its configuration resolves it,
* environment fallbacks included: the destination this credential is meant
* for. Consumers derive sibling endpoints of the same deployment from it.
*/
readonly baseURL: string
/**
* Credential reference the route resolves, for diagnostics that tell the user
* where to configure the credential; absent for kinds without a stored
* reference, such as sign-in grants.
*/
readonly reference?: string
/**
* Whether {@link resolve} would release a credential for `endpoint`, checked
* without validating the credential or contacting the destination; the owner
* may read its store to answer. Store failures reject.
* @param endpoint - absolute URL the credential would be sent to.
* @returns whether a credential is configured for that destination.
*/
configured(endpoint: string): Promise<boolean>
/**
* Release the credential for `endpoint`, or `undefined` when none is
* configured or the destination may not receive it. The caller chooses the
* failure it reports for `undefined`. Store and format failures reject.
* @param endpoint - absolute URL the credential will be sent to.
* @param signal - cancellation for the lookup.
* @returns the released credential, or `undefined`.
*/
resolve(endpoint: string, signal?: AbortSignal): Promise<ProviderCredentialGrant | undefined>
}
```
A catalog entry may carry a provider-authored `badge` that selectors show beside the model name. It is display data: `resolveModelInfo` omits it, and no model request carries it.
```ts type-equiv
@@ -950,8 +870,6 @@ The [wire reference](../deepseek-llm-api-wire-extensions.md) defines the exact r
`LlmAdapter` is the provider contract: subclass, implement `stream()`, and register one adapter instance with `ctx.llm.registerAdapter(providers, adapter)`. `GenerateOptions.provider` selects the registered adapter; `GenerateOptions.model` is passed to that adapter and need not be registered at lifecycle start. Duplicate provider routes fail atomically. Optional `providerRetryPolicy()` is captured per route with normal defaults, while `providerInfo()` and asynchronous `listModels()` feed `LlmRuntime.listProviders()` / `listModels()` with detached selector metadata. That catalog is advisory rather than a request whitelist: the adapter remains authoritative and may accept unlisted model ids. One asynchronous `resolveModel()` query returns exact model identity plus optional correctness-sensitive context capacity, an adapter-configured `defaultMaxTokens`, and ordered model-owned reasoning ids with an optional deployment default; absent fields mean unavailable metadata or provider-owned behavior, not invalid catalog membership. The resolver receives optional cancellation and must settle promptly after abort. `LlmRuntime.resolveModelInfo()` validates and detaches the aggregate. At the final adapter boundary, `resolveCallConfig()` materializes the output default only when `maxTokens` is absent and validates and materializes reasoning, so direct calls cannot bypass either configured behavior; direct dispatch captures one registration before awaiting that resolution. The agent loop instead uses `prepareCall()` to keep the same registration across model resolution, durable header logging, and dispatch, retain detached context metadata from that exact lookup, and report which config fields the adapter defaulted. Adapter lookup happens at the terminal continuation of the `llm/stream` waterfall, so a listener may short-circuit the call or route a mutable one-shot request before lookup. AgentLoop observes a request attempt once the outer waterfall returns a stream handle; that limited boundary does not prove a lazy terminal adapter was constructed or began provider I/O. The `block-start` / `block-end` `index` correlation and the assembler together mean an adapter only has to emit well-formed chunks — block reassembly is not each adapter's problem. [architecture.md](../architecture.md#turn-flow) shows where `ctx.llm.stream()` and the `llm/stream` waterfall sit in one turn.
Optional `providerCredential()` publishes the credential a route currently sends, with the route's base URL, its kind, and an optional credential reference. `LlmRuntime.providerCredential(provider)` forwards to the owning adapter: an unregistered route answers `undefined`, because callers ask about routes a conversation named earlier, and a registered route whose configuration does not resolve propagates the adapter's failure. The DeepSeek web providers read it to call the deployment of the conversation's route with that route's credential, so no consumer reads another plugin's configuration or chooses its header names.
```ts type-equiv
/** One model call whose config and adapter registration were resolved together. */
interface PreparedLlmCall {
@@ -1019,16 +937,6 @@ declare abstract class LlmAdapter {
* @returns the same target used by request serialization, before provider-internal processing.
*/
imageRequestTarget(_provider: string, _model: string, image: ImageAttachmentRef): ImageRequestTarget;
/**
* Describe the credential one owned route currently sends, for consumers that
* call the same deployment outside the model request path, such as web
* providers that share a route's credential and endpoint. The default
* publishes none. Implementations answer from one configuration generation
* per call and may throw when that configuration does not resolve.
* @param _provider - a route passed to `registerAdapter()` for this instance.
* @returns the route's current credential, or `undefined` when the route publishes none.
*/
providerCredential(_provider: string): ProviderCredential | undefined;
/**
* List models this adapter can currently advertise for one owned provider.
* Core routing accepts unlisted model ids; catalog-driven entry points such
@@ -1209,17 +1117,6 @@ imageRequestPricing(provider: string, model: string): LlmImageRequestPricing | u
*/
imageRequestTarget(provider: string, model: string, image: ImageAttachmentRef): ImageRequestTarget
/**
* Resolve the credential one registered route currently sends, through its
* owning adapter. An unregistered route answers `undefined` rather than
* throwing because callers ask about routes a conversation named earlier,
* which may no longer be mounted; a registered route whose configuration
* does not resolve propagates the adapter's failure.
* @param provider - provider route whose credential is wanted.
* @returns the route's credential, or `undefined` when the route is unregistered or publishes none.
*/
providerCredential(provider: string): ProviderCredential | undefined
/**
* Resolve the exact text one durable file occurrence contributes to every
* provider request in the current execution environment.
-103
View File
@@ -533,86 +533,6 @@ interface LlmNativeAuth {
}
```
路由的适配器还可以发布该路由当前发送的凭据,使在模型请求路径之外调用同一部署的消费方(如 DeepSeek Web 提供方)通过 `ctx.llm.providerCredential(provider)` 复用它,而不读取提供方配置或自行选择请求头名称。授权仅限 Host,且只在一次操作内持有;`kind` 通过 `LlmCredentialKindMap` 可合并扩展,已声明的成员为 `api-key` 和 `account`。所有者可能在请求仍携带凭据时撤回它(例如账号退登),这类授权带有 `revoked` 信号:消费方让它鉴权的每个请求都受该信号约束,并把被该信号结束的请求报告为自身的失败,而不是调用方的取消。
```ts type-equiv
/**
* One credential released for one destination. Host-only: it carries the
* secret, so it never crosses a Remote boundary and never enters a log.
*/
interface ProviderCredentialGrant {
/**
* Request headers carrying the credential as the route's own protocol
* expects it, such as `x-api-key` for an API key. Consumers speaking that
* protocol send them unchanged.
*/
readonly headers: Readonly<Record<string, string>>
/**
* The bare credential value, for destinations whose protocol renders it
* differently from {@link headers}, such as `Authorization: Bearer`.
*/
readonly value: string
/**
* Invalidate this exact credential after the destination rejected it with
* HTTP 401 so no later request resends it. Absent for kinds without
* invalidation. The owner contains storage failures: the caller reports the
* destination's rejection, never a failure of this call.
* @returns settlement after the invalidation attempt.
*/
reject?(): Promise<void>
/**
* Aborts when the owner withdraws this credential while requests carrying it
* may be in flight, as an account sign-out does. A consumer ends each request
* it authenticated with this grant and reports that end as its own failure,
* not as the caller's cancellation. Absent for kinds that are never withdrawn.
*/
readonly revoked?: AbortSignal
}
```
```ts type-equiv
/**
* The credential one registered provider route currently sends, answered by
* the route's owning adapter so that consumers read no provider configuration
* and choose no header names. `ctx.llm.providerCredential()` resolves a new value
* per call from one configuration generation; a caller keeps it for one
* operation only.
*/
interface ProviderCredential {
/** Kind of credential the route sends. */
readonly kind: LlmCredentialKind
/**
* The route's current request base URL as its configuration resolves it,
* environment fallbacks included: the destination this credential is meant
* for. Consumers derive sibling endpoints of the same deployment from it.
*/
readonly baseURL: string
/**
* Credential reference the route resolves, for diagnostics that tell the user
* where to configure the credential; absent for kinds without a stored
* reference, such as sign-in grants.
*/
readonly reference?: string
/**
* Whether {@link resolve} would release a credential for `endpoint`, checked
* without validating the credential or contacting the destination; the owner
* may read its store to answer. Store failures reject.
* @param endpoint - absolute URL the credential would be sent to.
* @returns whether a credential is configured for that destination.
*/
configured(endpoint: string): Promise<boolean>
/**
* Release the credential for `endpoint`, or `undefined` when none is
* configured or the destination may not receive it. The caller chooses the
* failure it reports for `undefined`. Store and format failures reject.
* @param endpoint - absolute URL the credential will be sent to.
* @param signal - cancellation for the lookup.
* @returns the released credential, or `undefined`.
*/
resolve(endpoint: string, signal?: AbortSignal): Promise<ProviderCredentialGrant | undefined>
}
```
目录条目可以携带提供方编写的 `badge`,供选择器显示在模型名称旁。它只是展示数据:`resolveModelInfo` 不返回它,模型请求也不携带它。
```ts type-equiv
@@ -956,8 +876,6 @@ interface LlmCallConfigAdapterDefaults {
`LlmAdapter` 是提供方约定:创建子类、实现 `stream()`,再用 `ctx.llm.registerAdapter(providers, adapter)` 注册一个适配器实例。`GenerateOptions.provider` 选择已注册适配器;`GenerateOptions.model` 会传给该适配器,无需在生命周期启动时注册。重复提供方路由会原子失败。可选的 `providerRetryPolicy()` 会按路由捕获并填入 normal 默认值,`providerInfo()` 与异步 `listModels()` 方法则为 `LlmRuntime.listProviders()` / `listModels()` 提供分离的 selector 元数据。该目录仅供参考,不是请求白名单:适配器仍是权威,并可接受未列出的模型 id。单次异步 `resolveModel()` 查询返回确切模型身份,以及可选的对正确性敏感的上下文容量、适配器配置的 `defaultMaxTokens`、由模型持有的有序推理强度 ID 和可选的部署默认值;字段缺失表示元数据不可用或保留提供方持有的行为,而不表示目录成员关系无效。解析器会接收可选的取消信号,并且必须在信号中止后迅速完成结算。`LlmRuntime.resolveModelInfo()` 会校验聚合结果并返回分离值。在最终适配器边界,`resolveCallConfig()` 仅在 `maxTokens` 缺失时填入输出默认值,并校验和填入推理强度,因此直接调用也无法绕过任何一项已配置行为;直接分派会在等待解析前捕获一项适配器注册。agent loop 则使用 `prepareCall()`,使模型解析、请求头持久记录和分派全程使用同一项注册,保留来自同一次查询的分离上下文元数据,并报告适配器填入的配置字段。适配器查找发生在 `llm/stream` waterfall 的终端 continuation,因此 listener 可以在查找前短路调用,或路由一个可变的一次性请求。AgentLoop 在外层 waterfall 返回流句柄时观察到一次请求尝试;这个有限边界不能证明惰性终端适配器已构造完成或开始提供方 I/O。`block-start` / `block-end` 的 `index` 关联与 assembler 共同意味着适配器只需 emit 格式正确的分片——块重组不是每个适配器各自的问题。`ctx.llm.stream()` 与 `llm/stream` waterfall 在一个轮次中的位置见 [architecture.md](../architecture.zh.md#turn-flow)。
可选的 `providerCredential()` 发布路由当前发送的凭据,连同路由的基础地址、凭据种类和可选的凭据引用。`LlmRuntime.providerCredential(provider)` 转发给拥有该路由的适配器:未注册的路由回答 `undefined`,因为调用方询问的是会话早先命名的路由;已注册但配置无法解析的路由则传播适配器的失败。DeepSeek Web 提供方据此用会话路由的凭据调用同一部署,因此没有消费方需要读取其他插件的配置或自行选择请求头名称。
```ts type-equiv
/** One model call whose config and adapter registration were resolved together. */
interface PreparedLlmCall {
@@ -1025,16 +943,6 @@ declare abstract class LlmAdapter {
* @returns the same target used by request serialization, before provider-internal processing.
*/
imageRequestTarget(_provider: string, _model: string, image: ImageAttachmentRef): ImageRequestTarget;
/**
* Describe the credential one owned route currently sends, for consumers that
* call the same deployment outside the model request path, such as web
* providers that share a route's credential and endpoint. The default
* publishes none. Implementations answer from one configuration generation
* per call and may throw when that configuration does not resolve.
* @param _provider - a route passed to `registerAdapter()` for this instance.
* @returns the route's current credential, or `undefined` when the route publishes none.
*/
providerCredential(_provider: string): ProviderCredential | undefined;
/**
* List models this adapter can currently advertise for one owned provider.
* Core routing accepts unlisted model ids; catalog-driven entry points such
@@ -1215,17 +1123,6 @@ imageRequestPricing(provider: string, model: string): LlmImageRequestPricing | u
*/
imageRequestTarget(provider: string, model: string, image: ImageAttachmentRef): ImageRequestTarget
/**
* Resolve the credential one registered route currently sends, through its
* owning adapter. An unregistered route answers `undefined` rather than
* throwing because callers ask about routes a conversation named earlier,
* which may no longer be mounted; a registered route whose configuration
* does not resolve propagates the adapter's failure.
* @param provider - provider route whose credential is wanted.
* @returns the route's credential, or `undefined` when the route is unregistered or publishes none.
*/
providerCredential(provider: string): ProviderCredential | undefined
/**
* Resolve the exact text one durable file occurrence contributes to every
* provider request in the current execution environment.
@@ -0,0 +1,16 @@
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-rc.3/deepseek-request-auth/guide.md
/:
en: 56911e8190557ac2
zh: 199a530cada9ef1b
/deepseek-consumers-authenticate-through-ctx-deepseekauth:
en: 0edf2a8ee3bc6aff
zh: 3af58b98573eb8f9
/deepseek-consumers-authenticate-through-ctx-deepseekauth/change:
en: 157466403a04468e
zh: 5e361579bf85311a
/deepseek-consumers-authenticate-through-ctx-deepseekauth/migration:
en: 5080b12103295b1a
zh: f6f681e22a7c2a18
@@ -0,0 +1,34 @@
---
kind: upgrade-guide
description: "DeepSeek model routes and web providers require the new dsh-deepseek-auth plugin; the llm-deepseek credential helpers, the dsh-llm API key check, the route plugins' config exports, and account Agent inspection are removed."
---
# DeepSeek consumers authenticate through ctx.deepseekAuth
English | [中文](guide.zh.md)
## Change
`@deepseek-ai/dsh-deepseek-auth` provides `ctx.deepseekAuth`, which releases the API key or the account sign-in for one DeepSeek request. `@deepseek-ai/dsh-llm-deepseek-api-key`, `@deepseek-ai/dsh-llm-deepseek-account`, `@deepseek-ai/dsh-web-deepseek-api`, and `@deepseek-ai/dsh-web-search-deepseek` declare it as a peer dependency and start only in a composition that mounts it. The `base` and `sdk-minimal` bundles mount it.
`@deepseek-ai/dsh-llm-deepseek` no longer exports `resolveDeepSeekApiKey`, `deepSeekApiKeyConfigured`, `resolveDeepSeekAccountToken`, or `rejectDeepSeekAccountToken`. `DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` returns `DeepSeekRequestAuth | undefined`, `DeepSeekRequestAuth` gains an optional `revoked` signal, and the new `missingCredential` option names the missing-credential failure. `createModelListingCache` takes `credential(url)` returning request headers, and its `load` is optional.
`@deepseek-ai/dsh-llm` no longer exports `normalizeApiKey` and `assertUsableApiKey`. `@deepseek-ai/dsh-credentials` exports `normalizeApiKey(raw)`, `resolveCredentialRef(ctx, ref)`, and `credentialRefConfigured(ctx, ref)`.
`@deepseek-ai/dsh-llm-deepseek-api-key` no longer exports `plainOptions` and `resolveAdapterOptions`; `@deepseek-ai/dsh-llm-deepseek-account` no longer exports `plainAccountOptions` and `resolveAccountOptions`. The account route plugin cancels its running Agents after sign-out and registers a running-task report.
`@deepseek-ai/dsh-deepseek-account` adds Host-only `resolveRequestCredential(url)` and `registerRunningTaskReport(report)` and makes `resolveToken(url)` and `rejectToken(token)` private; `hasRunningAccountTasks()` answers from registered reports and no longer reads `ctx.agents`. A sign-out aborts released credentials' `revoked` signal, ending in-flight account requests: model requests outside a turn fail with `ACCOUNT_SIGN_IN_REQUIRED`, Search and Fetch with `WEB_PROVIDER_ERROR`. The package drops its `dsh-agent` and `dsh-llm` peer dependencies and moves from `packages/credentials/` to `packages/account/` under its unchanged name.
Without the account route, the Search and Fetch APIs send the account credential to the origin `DEEPSEEK_BASE_URL` names and reject a value that is not an HTTP(S) URL without embedded credentials. With `auto` billing, a `deepseek-account` or `deepseek-official` conversation whose route plugin is not mounted tries the API key, then the account credential. `DeepSeekSearchProviderOptions` replaces `resolveAccountToken`, `rejectAccountToken`, and `resolveApiKey` with `authorize(endpoint, signal)`.
## Migration
1. Add `- name: '@deepseek-ai/dsh-deepseek-auth'` to every composition that mounts one of the four plugins without the `base` or `sdk-minimal` bundle. Code that mounts them through `ctx.plugin()` mounts the package's default export first.
2. Replace the removed `llm-deepseek` helpers with `ctx.deepseekAuth.authorize({ consumer, accepts, destination })`: send the returned `headers`, call `reject()` after HTTP 401 when present, and end the request when `revoked` aborts. `candidates()` answers presence checks.
3. Replace `assertUsableApiKey` with `normalizeApiKey` from `@deepseek-ai/dsh-credentials`, and throw your own error for its `reason`.
4. In custom `DeepSeekAdapter` or `registerDeepSeekProvider` consumers, return `undefined` from `resolveAuth` when no credential exists and supply `missingCredential` for a route-specific failure. Pass credential headers, not a token, to `createModelListingCache`.
5. Replace imports of the route plugins' config exports with the plugins' own `Config`.
6. Make `deepseekAccount` stand-ins implement `resolveRequestCredential`, returning a `revoked` signal; stand-ins that supplied `ctx.agents` for `hasRunningAccountTasks()` register a report instead.
7. Update workspace references to `packages/account/deepseek-account`; the npm package name, Remote namespace, and configuration keys are unchanged.
8. Replace `resolveAccountToken`, `rejectAccountToken`, and `resolveApiKey` in `DeepSeekSearchProviderOptions` with `authorize`.
9. Type-check the callers, then send one DeepSeek model request and one web search in each changed composition.
@@ -0,0 +1,34 @@
---
kind: upgrade-guide
description: "DeepSeek 模型路由和 Web 提供方要求挂载新的 dsh-deepseek-auth 插件;移除 llm-deepseek 的凭据辅助函数、dsh-llm 的 API 密钥检查、路由插件的配置导出和账号服务对 Agent 的检查。"
---
# DeepSeek 消费方通过 ctx.deepseekAuth 鉴权
[English](guide.md) | 中文
## 变更
`@deepseek-ai/dsh-deepseek-auth` 提供 `ctx.deepseekAuth`,为一次 DeepSeek 请求释放 API 密钥或账号登录凭据。`@deepseek-ai/dsh-llm-deepseek-api-key`、`@deepseek-ai/dsh-llm-deepseek-account`、`@deepseek-ai/dsh-web-deepseek-api` 和 `@deepseek-ai/dsh-web-search-deepseek` 把它声明为对等依赖(peer dependency),并且只在挂载了它的组合中启动。`base` 与 `sdk-minimal` 两个组合包挂载它。
`@deepseek-ai/dsh-llm-deepseek` 不再导出 `resolveDeepSeekApiKey`、`deepSeekApiKeyConfigured`、`resolveDeepSeekAccountToken` 和 `rejectDeepSeekAccountToken`。`DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` 返回 `DeepSeekRequestAuth | undefined`,`DeepSeekRequestAuth` 新增可选的 `revoked` 信号,新增的 `missingCredential` 选项命名凭据缺失的失败。`createModelListingCache` 的 `credential(url)` 返回请求头,其 `load` 变为可选。
`@deepseek-ai/dsh-llm` 不再导出 `normalizeApiKey` 和 `assertUsableApiKey`。`@deepseek-ai/dsh-credentials` 导出 `normalizeApiKey(raw)`、`resolveCredentialRef(ctx, ref)` 和 `credentialRefConfigured(ctx, ref)`。
`@deepseek-ai/dsh-llm-deepseek-api-key` 不再导出 `plainOptions` 和 `resolveAdapterOptions`;`@deepseek-ai/dsh-llm-deepseek-account` 不再导出 `plainAccountOptions` 和 `resolveAccountOptions`。账号路由插件在退登后取消其运行中的 Agent,并注册运行中任务报告。
`@deepseek-ai/dsh-deepseek-account` 新增仅限 Host 的 `resolveRequestCredential(url)` 与 `registerRunningTaskReport(report)`,并将 `resolveToken(url)` 与 `rejectToken(token)` 改为私有;`hasRunningAccountTasks()` 根据注册的报告作答,不再读取 `ctx.agents`。退登会中止已释放凭据的 `revoked` 信号,从而结束在途的账号请求:回合之外的模型请求以 `ACCOUNT_SIGN_IN_REQUIRED` 失败,Search 与 Fetch 以 `WEB_PROVIDER_ERROR` 失败。该包移除 `dsh-agent` 与 `dsh-llm` 对等依赖,并以不变的名字从 `packages/credentials/` 移至 `packages/account/`。
没有账号路由时,Search 与 Fetch API 把账号凭据发往 `DEEPSEEK_BASE_URL` 所指的 origin,并拒绝不是不含内嵌凭据的 HTTP(S) URL 的值。在 `auto` 计费下,`deepseek-account` 或 `deepseek-official` 上的会话在其路由插件未挂载时先尝试 API 密钥,再尝试账号凭据。`DeepSeekSearchProviderOptions` 用 `authorize(endpoint, signal)` 替换 `resolveAccountToken`、`rejectAccountToken` 与 `resolveApiKey`。
## 迁移
1. 凡是不经 `base` 或 `sdk-minimal` 组合包而挂载上述四个插件之一的组合,都加入 `- name: '@deepseek-ai/dsh-deepseek-auth'`。用 `ctx.plugin()` 挂载它们的代码先挂载该包的默认导出。
2. 用 `ctx.deepseekAuth.authorize({ consumer, accepts, destination })` 替换被移除的 `llm-deepseek` 辅助函数:发送返回的 `headers`,存在 `reject()` 时在 HTTP 401 之后调用它,并在 `revoked` 中止时结束请求。存在性检查使用 `candidates()`。
3. 用 `@deepseek-ai/dsh-credentials` 的 `normalizeApiKey` 替换 `assertUsableApiKey`,并依据它的 `reason` 抛出自己的错误。
4. 在自定义的 `DeepSeekAdapter` 或 `registerDeepSeekProvider` 消费方中,没有凭据时让 `resolveAuth` 返回 `undefined`,并为路由专属的失败提供 `missingCredential`。向 `createModelListingCache` 传递凭据请求头而不是 token。
5. 用路由插件自身的 `Config` 替换对其配置导出的导入。
6. 让 `deepseekAccount` 替身实现 `resolveRequestCredential` 并返回 `revoked` 信号;为 `hasRunningAccountTasks()` 提供 `ctx.agents` 的替身改为注册报告。
7. 把工作区引用更新为 `packages/account/deepseek-account`;npm 包名、Remote 命名空间和配置键均不变。
8. 把 `DeepSeekSearchProviderOptions` 中的 `resolveAccountToken`、`rejectAccountToken` 与 `resolveApiKey` 替换为 `authorize`。
9. 对调用方做类型检查,然后在每个改动过的组合里各发起一次 DeepSeek 模型请求和一次 Web 搜索。
@@ -1,16 +0,0 @@
# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.2-rc.3/llm-route-credential/guide.md
/:
en: 56fc7afd90f0fcde
zh: 0b441fc159f25bcf
/deepseek-routes-publish-the-credential-web-consumers-reuse:
en: b5392bcd81f69488
zh: 68cd945f2dde46af
/deepseek-routes-publish-the-credential-web-consumers-reuse/change:
en: 7568433b72e2633b
zh: dcd4c6deb72da3a4
/deepseek-routes-publish-the-credential-web-consumers-reuse/migration:
en: 0632d7c9ffce1675
zh: a8b4d67f469eaee7
@@ -1,29 +0,0 @@
---
kind: upgrade-guide
description: "DeepSeek model routes publish their credential through ctx.llm.providerCredential(); the llm-deepseek credential helpers, the route plugins' config exports, and account Agent inspection are removed."
---
# DeepSeek routes publish the credential web consumers reuse
English | [中文](guide.zh.md)
## Change
`LlmAdapter.providerCredential(provider)` and `LlmRuntime.providerCredential(provider)` publish a route's current credential as a `ProviderCredential`: kind, resolved base URL, optional reference, a `configured(endpoint)` presence check, and `resolve(endpoint, signal)` returning a `ProviderCredentialGrant` with protocol headers, the bare value, an optional `reject()`, and an optional `revoked` withdrawal signal.
`@deepseek-ai/dsh-llm-deepseek` no longer exports `resolveDeepSeekApiKey`, `deepSeekApiKeyConfigured`, `resolveDeepSeekAccountToken`, or `rejectDeepSeekAccountToken`. `DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` returns `DeepSeekRequestAuth | undefined`, and `DeepSeekRequestAuth` requires `value` beside `headers`; the new `missingCredential` and `credential` options name the missing-credential failure and the published credential. `createModelListingCache` takes `credential(url)` returning request headers, and its `load` is optional.
`@deepseek-ai/dsh-llm-deepseek-api-key` no longer exports `plainOptions` and `resolveAdapterOptions`; `@deepseek-ai/dsh-llm-deepseek-account` no longer exports `plainAccountOptions` and `resolveAccountOptions`. The account route plugin cancels its running Agents after sign-out and registers a running-task report.
`@deepseek-ai/dsh-deepseek-account` adds Host-only `resolveRequestCredential(url)` and `registerRunningTaskReport(report)` and makes `resolveToken(url)` and `rejectToken(token)` private; `hasRunningAccountTasks()` answers from registered reports and no longer reads `ctx.agents`. A sign-out aborts released credentials' `revoked` signal, ending in-flight account requests: model requests outside a turn fail with `ACCOUNT_SIGN_IN_REQUIRED`, Search and Fetch with `WEB_PROVIDER_ERROR`. The package drops its `dsh-agent` and `dsh-llm` peer dependencies and moves from `packages/credentials/` to `packages/account/` under its unchanged name. `@deepseek-ai/dsh-credentials` adds `resolveCredentialRef(ctx, ref)` and `credentialRefConfigured(ctx, ref)`.
`@deepseek-ai/dsh-web-deepseek-api` drops its peer dependencies on `dsh-llm-deepseek`, both route plugins, and `cordis-plugin-loader`; `@deepseek-ai/dsh-web-search-deepseek` drops `dsh-llm-deepseek` and `dsh-deepseek-account` and adds `dsh-llm`. Both read route credentials through `ctx.llm.providerCredential()`, so an adapter registered under a DeepSeek route id that publishes no credential, or a credential of the other kind, counts as no route. Without the account route, the Search and Fetch APIs send the account credential to the origin `DEEPSEEK_BASE_URL` names and reject a value that is not an HTTP(S) URL without embedded credentials. `DeepSeekSearchProviderOptions` replaces `resolveAccountToken` and `rejectAccountToken` with `resolveAccountCredential(endpoint)`.
## Migration
1. Replace the removed `llm-deepseek` helpers: read keys with `resolveCredentialRef` and `credentialRefConfigured` from `@deepseek-ai/dsh-credentials` and validate them with `assertUsableApiKey`; read account credentials with `ctx.deepseekAccount.resolveRequestCredential(url)` and invalidate through the returned `reject()`. To reuse a mounted route's credential and endpoint, call `ctx.llm.providerCredential(provider)`, and run each request under the grant's `revoked` signal.
2. In custom `DeepSeekAdapter` or `registerDeepSeekProvider` consumers, return `undefined` from `resolveAuth` when no credential exists, add `value` to every `DeepSeekRequestAuth`, supply `missingCredential` for a route-specific failure, and declare `credential` to publish the route's credential. Pass credential headers, not a token, to `createModelListingCache`.
3. Replace imports of the route plugins' config exports with the plugins' own `Config`, and read a route's endpoint from its published credential instead of its resolver.
4. Make `deepseekAccount` stand-ins used by the account route or the web providers implement `resolveRequestCredential`, returning a `revoked` signal; stand-ins that supplied `ctx.agents` for `hasRunningAccountTasks()` register a report instead.
5. Update workspace references to `packages/account/deepseek-account`; the npm package name, Remote namespace, and configuration keys are unchanged.
6. Replace `resolveAccountToken` and `rejectAccountToken` in `DeepSeekSearchProviderOptions` with `resolveAccountCredential` returning a `ProviderCredentialGrant`.
@@ -1,29 +0,0 @@
---
kind: upgrade-guide
description: "DeepSeek 模型路由通过 ctx.llm.providerCredential() 发布自己的凭据;移除 llm-deepseek 的凭据辅助函数、路由插件的配置导出和账号服务对 Agent 的检查。"
---
# DeepSeek 路由发布 Web 消费方复用的凭据
[English](guide.md) | 中文
## 变更
`LlmAdapter.providerCredential(provider)` 与 `LlmRuntime.providerCredential(provider)` 把路由当前的凭据发布为 `ProviderCredential`:种类、解析后的基础地址、可选引用、`configured(endpoint)` 存在性检查,以及返回 `ProviderCredentialGrant` 的 `resolve(endpoint, signal)`,授权包含协议请求头、裸值、可选的 `reject()`,以及可选的 `revoked` 撤回信号。
`@deepseek-ai/dsh-llm-deepseek` 不再导出 `resolveDeepSeekApiKey`、`deepSeekApiKeyConfigured`、`resolveDeepSeekAccountToken` 和 `rejectDeepSeekAccountToken`。`DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` 返回 `DeepSeekRequestAuth | undefined`,且 `DeepSeekRequestAuth` 在 `headers` 之外要求 `value`;新增的 `missingCredential` 与 `credential` 选项分别命名凭据缺失的失败和发布的凭据。`createModelListingCache` 的 `credential(url)` 返回请求头,其 `load` 变为可选。
`@deepseek-ai/dsh-llm-deepseek-api-key` 不再导出 `plainOptions` 和 `resolveAdapterOptions`;`@deepseek-ai/dsh-llm-deepseek-account` 不再导出 `plainAccountOptions` 和 `resolveAccountOptions`。账号路由插件在退登后取消其运行中的 Agent,并注册运行中任务报告。
`@deepseek-ai/dsh-deepseek-account` 新增仅限 Host 的 `resolveRequestCredential(url)` 与 `registerRunningTaskReport(report)`,并将 `resolveToken(url)` 与 `rejectToken(token)` 改为私有;`hasRunningAccountTasks()` 根据注册的报告作答,不再读取 `ctx.agents`。退登会中止已释放凭据的 `revoked` 信号,从而结束在途的账号请求:回合之外的模型请求以 `ACCOUNT_SIGN_IN_REQUIRED` 失败,Search 与 Fetch 以 `WEB_PROVIDER_ERROR` 失败。该包移除 `dsh-agent` 与 `dsh-llm` peer 依赖,并以不变的名字从 `packages/credentials/` 移至 `packages/account/`。`@deepseek-ai/dsh-credentials` 新增 `resolveCredentialRef(ctx, ref)` 与 `credentialRefConfigured(ctx, ref)`。
`@deepseek-ai/dsh-web-deepseek-api` 移除对 `dsh-llm-deepseek`、两个路由插件和 `cordis-plugin-loader` 的 peer 依赖;`@deepseek-ai/dsh-web-search-deepseek` 移除 `dsh-llm-deepseek` 与 `dsh-deepseek-account`,新增 `dsh-llm`。两者都通过 `ctx.llm.providerCredential()` 读取路由凭据,因此以 DeepSeek 路由 id 注册但不发布凭据、或发布另一种凭据的适配器视为没有路由。没有账号路由时,Search 与 Fetch API 把账号凭据发往 `DEEPSEEK_BASE_URL` 所指的 origin,并拒绝不是不含内嵌凭据的 HTTP(S) URL 的值。`DeepSeekSearchProviderOptions` 用 `resolveAccountCredential(endpoint)` 替换 `resolveAccountToken` 与 `rejectAccountToken`。
## 迁移
1. 替换被移除的 `llm-deepseek` 辅助函数:用 `@deepseek-ai/dsh-credentials` 的 `resolveCredentialRef` 与 `credentialRefConfigured` 读取密钥并用 `assertUsableApiKey` 校验;用 `ctx.deepseekAccount.resolveRequestCredential(url)` 读取账号凭据并通过返回的 `reject()` 作废。要复用已挂载路由的凭据和端点,调用 `ctx.llm.providerCredential(provider)`,并让每个请求受授权的 `revoked` 信号约束。
2. 在自定义的 `DeepSeekAdapter` 或 `registerDeepSeekProvider` 消费方中,没有凭据时让 `resolveAuth` 返回 `undefined`,为每个 `DeepSeekRequestAuth` 加上 `value`,为路由专属的失败提供 `missingCredential`,并声明 `credential` 以发布路由凭据。向 `createModelListingCache` 传递凭据请求头而不是 token。
3. 用路由插件自身的 `Config` 替换对其配置导出的导入,并从路由发布的凭据而非其解析函数读取端点。
4. 让账号路由或 Web 提供方使用的 `deepseekAccount` 替身实现 `resolveRequestCredential` 并返回 `revoked` 信号;为 `hasRunningAccountTasks()` 提供 `ctx.agents` 的替身改为注册报告。
5. 把工作区引用更新为 `packages/account/deepseek-account`;npm 包名、Remote 命名空间和配置键均不变。
6. 把 `DeepSeekSearchProviderOptions` 中的 `resolveAccountToken` 与 `rejectAccountToken` 替换为返回 `ProviderCredentialGrant` 的 `resolveAccountCredential`。
+6 -6
View File
@@ -3,20 +3,20 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/account/README.md
/:
en: c603fc9f9990181e
zh: fc045770018269cd
en: 65f89da052a7067f
zh: e7d32dd098a0005e
/account-deepseek-account:
en: 15e52f323c5ffdba
zh: e32a4d077fd5ef98
/account-deepseek-account/summary:
en: b75f72f3404fcd85
zh: c24435d70528c5a4
en: 21dd20608c62012a
zh: 2d9954d43ca0e0b7
/account-deepseek-account/table-of-contents:
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/account-deepseek-account/packages:
en: 4f342c1e06b8c9e2
zh: f36f298ef3bd1be2
en: 29fa6562bc33791c
zh: 8df0763eba581702
/account-deepseek-account/related-documentation:
en: 6667d1a41ac182d1
zh: 065a196972782a34
+4 -3
View File
@@ -1,5 +1,5 @@
---
description: "Package map for the DeepSeek account family: browser sign-in, the stored account grant, and the Host-only request credentials released to the account model route and the DeepSeek web providers."
description: "Package map for the DeepSeek account family: browser sign-in, the stored account grant, and the request authentication that chooses between the account sign-in and the API key for every DeepSeek API request."
kind: "package-group"
---
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
## Summary
The `account/` group signs the user in to DeepSeek through the system browser and keeps the account grant in the local credential store that [`credentials/`](../credentials/README.md) owns. Host consumers never read the token: the `deepseek-account` model route and the DeepSeek web providers ask `ctx.deepseekAccount` for the credential of one request destination and receive its request headers, the bare value, and an invalidation for an HTTP 401. Clients receive account state through the `account` Remote namespace without credentials.
The `account/` group signs the user in to DeepSeek through the system browser and keeps the account grant in the local credential store that [`credentials/`](../credentials/README.md) owns. Host consumers never read the token: `ctx.deepseekAuth` asks `ctx.deepseekAccount` for the credential of one request destination and hands the DeepSeek model routes and web providers its request headers, an invalidation for an HTTP 401, and a signal that aborts at sign-out. The same service releases the API key for consumers the key bills. Clients receive account state through the `account` Remote namespace without credentials.
## Table of Contents
@@ -22,11 +22,12 @@ The `account/` group signs the user in to DeepSeek through the system browser an
<a id="packages"></a>
## Packages
One package provides the account feature; its README covers day-to-day use, and the subsystem reference owns the exhaustive contracts.
Two packages provide the account feature and DeepSeek request authentication; their READMEs cover day-to-day use, and the subsystem reference owns the exhaustive contracts.
| Package | Role | ctx key |
|---|---|---|
| [`deepseek-account/`](deepseek-account/README.md) | Browser sign-in, the stored grant, Platform profile, balance, and notification reads, and Host-only request credentials for allowed destinations | `ctx.deepseekAccount` |
| [`deepseek-auth/`](deepseek-auth/README.md) | Request authentication for every DeepSeek API consumer: orders the API key and the account sign-in by billing, binds each to its deployment, and releases request headers | `ctx.deepseekAuth` |
-----
+4 -3
View File
@@ -1,5 +1,5 @@
---
description: "DeepSeek 账号能力族的包映射:浏览器登录、已存账号授权,以及向账号模型路由和 DeepSeek Web 提供方释放的仅限 Host 的请求凭据。"
description: "DeepSeek 账号能力族的包映射:浏览器登录、已存账号授权,以及为每个 DeepSeek API 请求在账号登录与 API 密钥之间选择的请求鉴权。"
kind: "package-group"
---
@@ -9,7 +9,7 @@ kind: "package-group"
## 概述
`account/` 组通过系统浏览器让用户登录 DeepSeek,并把账号授权保存在 [`credentials/`](../credentials/README.zh.md) 拥有的本地凭据库中。Host 消费方从不读取 token:`deepseek-account` 模型路由和 DeepSeek Web 提供方向 `ctx.deepseekAccount` 索取某个请求目标的凭据,取得其请求头、裸值以及用于 HTTP 401 的失效操作。客户端通过不携带凭据的 `account` Remote 命名空间获得账号状态。
`account/` 组通过系统浏览器让用户登录 DeepSeek,并把账号授权保存在 [`credentials/`](../credentials/README.zh.md) 拥有的本地凭据库中。Host 消费方从不读取 token:`ctx.deepseekAuth` 向 `ctx.deepseekAccount` 索取某个请求目标的凭据,并把其请求头、用于 HTTP 401 的失效操作以及退出登录时中止的信号交给 DeepSeek 模型路由和 Web 提供方。同一个服务也为由 API 密钥计费的消费方释放密钥。客户端通过不携带凭据的 `account` Remote 命名空间获得账号状态。
## 目录
@@ -22,11 +22,12 @@ kind: "package-group"
<a id="packages"></a>
## 包
一个包提供账号功能;它的 README 覆盖日常使用,全部约定以子系统参考为准。
两个包提供账号功能和 DeepSeek 请求鉴权;它们的 README 覆盖日常使用,全部约定以子系统参考为准。
| 包 | 角色 | ctx 键 |
|---|---|---|
| [`deepseek-account/`](deepseek-account/README.zh.md) | 浏览器登录、已存授权、Platform 资料、余额与通知读取,以及面向允许目标的仅限 Host 的请求凭据 | `ctx.deepseekAccount` |
| [`deepseek-auth/`](deepseek-auth/README.zh.md) | 面向所有 DeepSeek API 消费方的请求鉴权:按计费方式排定 API 密钥与账号登录的顺序,把每一种绑定到其部署,并释放请求头 | `ctx.deepseekAuth` |
-----
@@ -6,8 +6,8 @@
en: 9dbb9bc3960a11fe
zh: ed58987926489d3e
/deepseek-ai-dsh-deepseek-account:
en: cc98cb1949c9fe0f
zh: bbb0b8fa319b9abc
en: 3943a528cd7abc81
zh: 00dfb3ac0eb520b7
/deepseek-ai-dsh-deepseek-account/summary:
en: 28bcca957bf6abf4
zh: 4a3fc8a59f2925bc
+1 -1
View File
@@ -13,7 +13,7 @@ getPlatformSession exports the stored grant only when its issuer matches platfor
`desktopPlatform` defaults to `null`, which sends `x-client-platform: web`; the Desktop profile supplies `darwin` or `win32`, becoming `desktop-mac` or `desktop-win`. The service owns all five headers, so deployment configuration cannot override them; `x-client-bundle-id` is intentionally empty, and `x-client-locale` reduces the caller's language to `zh_CN` or `en_US`. PlatformSession carries deployment headers only, and the embedding client composes the same five headers for the Platform documents and API requests it opens, only at the configured origin.
Profile and balance HTTP 401 responses or top-level response code `40003` (invalid authorization) clear the rejected local grant and emit the live `deepseek-account/session-expired` notification. Concurrent responses share one removal; responses from an invalidated credential generation cannot clear its replacement. Other HTTP failures retain the grant. `resolveRequestCredential(url)` releases the credential for one allowed destination as the request headers, the bare token, a `reject()` that removes the stored grant after an HTTP 401 while it still matches that token, containing storage failures, and a `revoked` signal; the removal runs on the account service mounted when `reject()` is called, so a reload between the request and the destination's answer still removes the grant. The account model route and the DeepSeek web providers use it instead of composing headers themselves, and end the request that carries the token when `revoked` aborts.
Profile and balance HTTP 401 responses or top-level response code `40003` (invalid authorization) clear the rejected local grant and emit the live `deepseek-account/session-expired` notification. Concurrent responses share one removal; responses from an invalidated credential generation cannot clear its replacement. Other HTTP failures retain the grant. `resolveRequestCredential(url)` releases the credential for one allowed destination as the request headers, a `reject()` that removes the stored grant after an HTTP 401 while it still matches that token, containing storage failures, and a `revoked` signal; the removal runs on the account service mounted when `reject()` is called, so a reload between the request and the destination's answer still removes the grant. [`ctx.deepseekAuth`](../deepseek-auth/README.md) calls it for the account model route and the DeepSeek web providers, which end the request that carries the token when `revoked` aborts.
## Summary
@@ -13,7 +13,7 @@ getPlatformSession 仅在已存授权的 issuer 与 platformOrigin 一致时导
`desktopPlatform` 默认为 `null`,此时携带 `x-client-platform: web`;Desktop profile 提供 `darwin` 或 `win32`,改为 `desktop-mac` 或 `desktop-win`。五个请求头均由 provider 拥有,部署配置无法覆盖;`x-client-bundle-id` 有意保持为空,`x-client-locale` 将调用方语言归约为 `zh_CN` 或 `en_US`。PlatformSession 只携带部署请求头,内嵌客户端为自行打开的 Platform 文档和 API 请求组装同样的五个请求头,且仅在配置来源发送。
资料和余额接口返回 HTTP 401 或顶层响应码 `40003`(鉴权失效)时清除被拒绝的本地凭据,并发送实时 `deepseek-account/session-expired` 通知。并发响应共用一次清除操作;已失效凭据代次的响应不能清除替换后的凭据。其他 HTTP 错误保留凭据。`resolveRequestCredential(url)` 把一个允许目标的凭据以请求头、裸 token、`reject()` 和 `revoked` 信号的形式释放;`reject()` 在 HTTP 401 后、且存储的授权仍匹配该 token 时清除它并隔离存储失败;清除在 `reject()` 被调用时挂载的账号服务上执行,因此请求与目的地应答之间发生的重载仍会清除授权。账号模型路由和 DeepSeek Web 提供方使用它,而不自行组装请求头,并在 `revoked` 中止时结束携带该 token 的请求。
资料和余额接口返回 HTTP 401 或顶层响应码 `40003`(鉴权失效)时清除被拒绝的本地凭据,并发送实时 `deepseek-account/session-expired` 通知。并发响应共用一次清除操作;已失效凭据代次的响应不能清除替换后的凭据。其他 HTTP 错误保留凭据。`resolveRequestCredential(url)` 把一个允许目标的凭据以请求头、`reject()` 和 `revoked` 信号的形式释放;`reject()` 在 HTTP 401 后、且存储的授权仍匹配该 token 时清除它并隔离存储失败;清除在 `reject()` 被调用时挂载的账号服务上执行,因此请求与目的地应答之间发生的重载仍会清除授权。[`ctx.deepseekAuth`](../deepseek-auth/README.zh.md) 代账号模型路由和 DeepSeek Web 提供方调用它,后两者在 `revoked` 中止时结束携带该 token 的请求。
## 概述
@@ -488,7 +488,6 @@ export class DeepSeekAccount extends TypertRemoteService {
const { ctx } = this
return {
headers: { [ACCOUNT_TOKEN_HEADER]: token },
value: token,
revoked,
reject: async () => {
try { await ctx.get('deepseekAccount')?.rejectToken(token) }
@@ -118,8 +118,6 @@ declare module '@deepseek-ai/cordis' {
export interface AccountRequestCredential {
/** Request headers carrying the account token. */
readonly headers: Readonly<Record<string, string>>
/** The bare token. */
readonly value: string
/**
* Remove the stored token after the destination rejected it, unless a newer
* sign-in replaced it. The removal runs on the account service mounted when
@@ -13,8 +13,8 @@ export interface AccountStubOptions {
}
/**
* An account service releasing request credentials as the real one does: the token header, the bare token, the
* sign-out signal, and an invalidation that reports no failure.
* An account service releasing request credentials as the real one does: the token header, the sign-out signal,
* and an invalidation that reports no failure.
* @param options - token policy, rejection observer, and sign-out signal.
* @returns the stand-in, typed as the service for `ctx.provide`.
*/
@@ -26,7 +26,6 @@ export function accountStub(options: AccountStubOptions): DeepSeekAccount {
if (token === undefined || token.length === 0) return undefined
return {
headers: { [ACCOUNT_TOKEN_HEADER]: token },
value: token,
revoked: signedOut,
reject: async () => {
try { await options.reject?.(token) }
@@ -369,7 +369,8 @@ it('allows real account credentials only on the exact official HTTPS origin', as
await f.ctx.credentials.modifyRecord(credentialKey('deepseek-account-platform', 'default'), () => Promise.resolve({
kind: 'grant', payload: { version: 1, issuer: 'https://platform.deepseek.com', token: 'test-account-token' },
}))
expect((await f.account.resolveRequestCredential('https://api.deepseek.com/v1'))?.value).toBe('test-account-token')
expect((await f.account.resolveRequestCredential('https://api.deepseek.com/v1'))?.headers)
.toEqual({ 'x-dsh-auth-token': 'test-account-token' })
for (const url of ['http://api.deepseek.com', 'https://api.deepseek.com.evil.test', 'https://api.deepseek.com:8443', 'https://[email protected]']) {
expect(await f.account.resolveRequestCredential(url)).toBeUndefined()
}
@@ -385,7 +386,7 @@ it('releases the request credential for an allowed destination and removes the r
const endpoint = 'http://inference.example.test:8094/v1/tools/search'
expect(await f.account.resolveRequestCredential('https://api.deepseek.com/v1/tools/search')).toBeUndefined()
const credential = await f.account.resolveRequestCredential(endpoint)
expect(credential).toMatchObject({ headers: { 'x-dsh-auth-token': 'test-account-token' }, value: 'test-account-token' })
expect(credential).toMatchObject({ headers: { 'x-dsh-auth-token': 'test-account-token' } })
await credential!.reject()
expect((await f.account.getState()).status).toBe('signed-out')
expect(await f.account.resolveRequestCredential(endpoint)).toBeUndefined()
@@ -609,7 +610,7 @@ it('releases a withdrawn credential when sign-out completes while its token is b
await f.account.signOut(clientMetadata())
release.resolve(undefined)
// The token was read before the sign-out removed it, so the credential must not authenticate a request.
expect(await pending).toMatchObject({ value: 'test-platform-grant', revoked: { aborted: true } })
expect(await pending).toMatchObject({ headers: { 'x-dsh-auth-token': 'test-platform-grant' }, revoked: { aborted: true } })
} finally { read.mockRestore() }
})
@@ -1020,7 +1021,8 @@ it('sends a development grant only to its configured inference origin', async ()
await f.wait('waiting-browser')
await fetch(f.callback(), { redirect: 'manual' })
await f.wait('succeeded')
expect((await f.account.resolveRequestCredential('http://inference.example.test:8094/api'))?.value).toBe('test-account-token')
expect((await f.account.resolveRequestCredential('http://inference.example.test:8094/api'))?.headers)
.toEqual({ 'x-dsh-auth-token': 'test-account-token' })
for (const url of ['https://api.deepseek.com', 'http://inference.example.test:8095/api',
'https://inference.example.test:8094/api', 'http://[email protected]:8094/api']) {
expect(await f.account.resolveRequestCredential(url)).toBeUndefined()
@@ -0,0 +1,58 @@
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/account/deepseek-auth/README.md
/:
en: 72aa9af5bb4b9d47
zh: 0474d8db22dbf845
/deepseek-ai-dsh-deepseek-auth:
en: 819d59b8b22bf985
zh: 3f919581e5639cca
/deepseek-ai-dsh-deepseek-auth/summary:
en: 27b451d236a03881
zh: 2eb02aed4c4ab1b3
/deepseek-ai-dsh-deepseek-auth/table-of-contents:
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-deepseek-auth/use-this-package:
en: 475c8fce4a8aa18f
zh: c5a2b3c20dc3ee53
/deepseek-ai-dsh-deepseek-auth/use-this-package/when-to-use-it:
en: 5ae5865ce8e74ca9
zh: f35aa7f2742a1e76
/deepseek-ai-dsh-deepseek-auth/use-this-package/authorizing-a-request:
en: 02b641a20536ed3e
zh: cf704140423f4091
/deepseek-ai-dsh-deepseek-auth/use-this-package/where-each-kind-s-credential-and-deployment-come-from:
en: b909920465406991
zh: babec6024f3741a0
/deepseek-ai-dsh-deepseek-auth/use-this-package/what-can-go-wrong:
en: 6b4a01982c7a435b
zh: 188c13fea190a619
/deepseek-ai-dsh-deepseek-auth/understand-the-implementation:
en: 6133f3219e92d614
zh: d4f47c8fe96bbb83
/deepseek-ai-dsh-deepseek-auth/understand-the-implementation/design-philosophy:
en: 781040be419e91c6
zh: fd7cfff0a180a6ca
/deepseek-ai-dsh-deepseek-auth/understand-the-implementation/source-map:
en: 28159a33fcde18a3
zh: 8e29411be0a9efe7
/deepseek-ai-dsh-deepseek-auth/understand-the-implementation/lifecycle:
en: 410428e4e26f97ee
zh: b0fff475dfebe3ad
/deepseek-ai-dsh-deepseek-auth/further-exploration:
en: 4d9c163447511873
zh: 39cd847064374250
/deepseek-ai-dsh-deepseek-auth/model-experience:
en: fe5289b96181fa86
zh: 186fd56ec8423081
/deepseek-ai-dsh-deepseek-auth/model-experience/kv-cache-effect:
en: 8d28a9884785f30c
zh: b1c45c04e1a543d7
/deepseek-ai-dsh-deepseek-auth/known-limitations-and-deferred-work:
en: d2fd57e36ce7b03a
zh: f105c8dbd169db9e
/deepseek-ai-dsh-deepseek-auth/known-limitations-and-deferred-work/dev-note:
en: e3eca6e1556f695c
zh: 7234e0729568e2e9
+179
View File
@@ -0,0 +1,179 @@
---
description: "DeepSeek request authentication for plugins that call a DeepSeek API: one service chooses between the API key and the account sign-in, binds the credential to its deployment, and releases the request headers."
kind: "package-reference"
---
# @deepseek-ai/dsh-deepseek-auth
English | [中文](README.zh.md)
## Summary
`dsh-deepseek-auth` authenticates requests to DeepSeek APIs through `ctx.deepseekAuth`. A consumer names the credential kinds its API accepts, the API key, the account sign-in, or both, and the billing its settings choose. The service orders the kinds, binds each to the deployment its credential belongs to, and releases the headers of the first kind that has a credential. The DeepSeek model routes, the Search and Fetch APIs, and Messages search use it. It stores nothing: keys come from the credential store or the launch environment, and the sign-in from the account service.
## Table of Contents
- [Use this package](#use-this-package)
- [Understand the implementation](#understand-the-implementation)
- [Further Exploration](#further-exploration)
- [Model Experience](#model-experience)
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
- [Dev Note](#dev-note)
-----
<a id="use-this-package"></a>
## Use this package
A plugin that calls a DeepSeek API asks this service for the credential of one request. The plugin sends the request itself and words its own failures.
### When to use it
Use it for every request a Host plugin sends to a DeepSeek deployment. Mount it in every composition that mounts a DeepSeek model route or a DeepSeek web provider; those plugins require it. It needs no configuration. It reads the credentials service and the account service when they are mounted and works without either.
### Authorizing a request
```ts
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-deepseek-auth'
declare const ctx: Context
declare const route: string | undefined // provider route of the conversation's latest model request
declare const signal: AbortSignal
const authorization = await ctx.deepseekAuth.authorize({
consumer: 'my-plugin',
accepts: ['account', 'api-key'],
billing: 'auto',
route,
destination: { path: '/v1/tools/search' },
}, signal)
if (authorization === undefined) throw new Error('no DeepSeek credential is configured')
await fetch(authorization.endpoint, { method: 'POST', headers: authorization.headers, signal })
```
`accepts` lists the kinds the destination API accepts; a kind outside it is never tried. When an API starts to accept another kind, its consumer adds that kind to `accepts`, and nothing else changes. `billing` is `api-key`, `account`, or `auto`, which follows the model route of the conversation:
| `billing` | Conversation's model route | Kinds tried, in order |
|---|---|---|
| `api-key` | any | API key |
| `account` | any | account sign-in |
| `auto` | the route connected for the account sign-in, `deepseek-account` | account sign-in, then API key |
| `auto` | the route connected for the API key, `deepseek-official` | API key |
| `auto` | any other route, or no conversation | API key, then account sign-in |
A route belongs to the first two `auto` rows only while the plugin that registers it is mounted and has connected it. A conversation recorded on `deepseek-account` or `deepseek-official` whose plugin is not mounted follows the last row.
`destination` is a path appended to the origin of the chosen kind's deployment, or one absolute `url`. A kind serves an absolute URL only when the URL is under the origin of that kind's deployment and embeds no credentials, so a key is never sent to another origin.
An authorization carries the `kind`, the `endpoint`, and the request `headers`. An API key is sent as `Authorization: Bearer` unless `apiKeyHeaders` names `x-api-key` or both; the account sign-in is sent in the header the account service chooses. `reject()`, present for the account sign-in, invalidates the credential after the destination answered HTTP 401. `revoked`, also present for the account sign-in, aborts when the account signs out: the consumer ends the request it authenticated and reports that end as its own failure, not as the caller's cancellation.
`candidates(request)` returns the same kinds in the same order without reading a credential. Each candidate answers `configured()` for readiness checks and `resolve(signal)` for the credential, and names its `endpoint` and, for an API key, its `reference` for diagnostics. `routeKind(route)` names the kind a mounted model route plugin connected under that route id, and `undefined` for every other route.
### Where each kind's credential and deployment come from
| Kind | With its model route mounted | Without it |
|---|---|---|
| API key | The key reference and base URL of the `deepseek-official` route's settings, which the Models page edits | `DEEPSEEK_API_KEY`, sent to `https://api.deepseek.com` |
| Account sign-in | The account service's credential, sent to the origin of the `deepseek-account` route's base URL | The account service's credential, sent to the origin `DEEPSEEK_BASE_URL` names, the official API by default |
A model route plugin connects the provider route it registers and its settings from within `ctx.effect()`:
```ts
import type { Context } from '@deepseek-ai/cordis'
import { credentialRef } from '@deepseek-ai/dsh-credentials'
import type {} from '@deepseek-ai/dsh-deepseek-auth'
declare const ctx: Context
declare const settings: () => { baseURL: string; apiKeyEnv: string }
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => {
const { baseURL, apiKeyEnv } = settings()
return { baseURL, reference: credentialRef(apiKeyEnv), owner: 'llm-deepseek' }
}))
```
The service calls the function for each request, so a settings change reaches the next request. While the connection exists, `auto` billing orders a conversation on that route by the connected kind. A request can carry its own connection of a kind in `connections`, which replaces the connected or default one: a model route passes the configuration generation it captured for one model request, and a consumer with its own endpoint and key passes those.
A key is read through the credentials service when one is mounted and through the launch environment otherwise, as [`dsh-credentials`](../../credentials/credentials/README.md) defines for references.
### What can go wrong
- `authorize()` returns `undefined` when no candidate has a credential. The consumer words the failure; `candidates()` supplies the kinds and the key reference to name.
- An API key that is blank or holds characters no HTTP header can carry fails with `DeepSeekAuthError` code `INVALID_CREDENTIAL`. The message names the owner and the reference to fix and never the key.
- A kind whose connection does not resolve, because the route's settings throw, a base URL does not parse, or `DEEPSEEK_BASE_URL` is no HTTP(S) URL, appears in `candidates()` as an unresolved entry. `authorize()` stops there with code `UNRESOLVED_CONNECTION` and does not try a later kind.
- A second `connect()` of one kind throws `DUPLICATE_CONNECTION`.
- Credential store failures propagate.
-----
<a id="understand-the-implementation"></a>
## Understand the implementation
<details>
<summary>Implementation internals — click to expand</summary>
This section explains the design decisions behind the service; the observable behavior is covered in [Use this package](#use-this-package).
### Design philosophy
- **Consumers declare what their API accepts; the service chooses.** DeepSeek adds account authentication to its APIs one at a time. A consumer's `accepts` list is the only place that records what one API accepts, so widening it is the whole change when an API gains a kind.
- **A credential is bound to its deployment.** Each kind has one deployment at a time, and a credential is released only for destinations under that deployment's origin.
- **The model routes are consumers.** The route plugins connect their settings and ask for authorization like every other consumer, so the transport and the model service hold no credential interface.
- **The service depends on no consumer.** It reads the credential store and the account service and names no model route: each route plugin passes its own route id when it connects, and `auto` billing compares the conversation's route with the connected ids.
### Source map
| File | Role |
|---|---|
| [`src/index.ts`](src/index.ts) | The service: connections, billing order, destination binding, the API-key and account sources, `DeepSeekAuthError` |
| [`src/types.ts`](src/types.ts) | Request, connection, candidate, and authorization types |
### Lifecycle
The service holds only the connections model route plugins registered; each disposer removes one. Nothing else is retained between requests: every `candidates()` call reads the connected settings again, and every `resolve()` reads the credential again.
</details>
-----
<a id="further-exploration"></a>
## Further Exploration
- [Account package map](../README.md) — the account service and this service.
- [DeepSeek account subsystem](../../../docs/subsystems/account.md) — the account sign-in and the request credentials this service releases.
- [Credential-reference seam](../../credentials/credentials/README.md) — how a key reference is read and checked.
- [DeepSeek request authentication](../../../.agents/notes/implemented/architecture/2026-11-10-deepseek-request-authentication.md) — the decision and its rejected alternatives.
-----
<a id="model-experience"></a>
## Model Experience
None, as the service releases request headers to Host plugins and contributes nothing to a model request's content. Its consumers word the failures a model reads.
#### KV Cache effect
No invalidation; no credential enters a request prefix.
## Known Limitations and Deferred Work
<a id="known-limitations-and-deferred-work"></a>
These limits define when this package is a poor fit or needs special care. They are current package constraints, not a task backlog.
- **One deployment per kind** — a second `deepseek-official` style route with its own key and endpoint cannot connect; a consumer that needs another key passes its own connection in the request.
- **A route counts as a DeepSeek route only while its plugin is connected** — a conversation recorded on `deepseek-account` or `deepseek-official` follows the order of other routes, API key and then account sign-in, while that plugin is not mounted, and so does a DeepSeek model reached through another provider plugin.
- **No credential validation** — `configured()` reports presence only, so a wrong key counts as configured until the destination rejects it.
<a id="dev-note"></a>
### Dev Note
<details>
<summary>Working context for maintainers — click to expand</summary>
This Dev Note is working context for maintainers: open questions and undecided directions. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above, the package code, and the linked Agent Note.
The speech and document APIs under `/v1/tools/` accept only the API key today. Their consumers declare `accepts: ['api-key']` and add `account` when the server accepts the account sign-in.
</details>
+179
View File
@@ -0,0 +1,179 @@
---
description: "面向调用 DeepSeek API 的插件的 DeepSeek 请求鉴权:一个服务在 API 密钥与账号登录之间选择,把凭据绑定到它所属的部署,并释放请求头。"
kind: "package-reference"
---
# @deepseek-ai/dsh-deepseek-auth
[English](README.md) | 中文
## 概述
`dsh-deepseek-auth` 通过 `ctx.deepseekAuth` 为发往 DeepSeek API 的请求鉴权。消费方给出其 API 接受的凭据种类(API 密钥、账号登录,或两者)以及其设置选择的计费方式。服务排定种类的顺序,把每一种绑定到其凭据所属的部署,并释放第一个持有凭据的种类的请求头。DeepSeek 模型路由、Search 与 Fetch API、Messages 搜索都使用它。它不存储任何东西:密钥来自凭据存储或启动环境,登录凭据来自账号服务。
## 目录
- [使用本包](#use-this-package)
- [理解实现](#understand-the-implementation)
- [进一步探索](#further-exploration)
- [模型体验](#model-experience)
- [已知限制与延期工作](#known-limitations-and-deferred-work)
- [开发备注](#dev-note)
-----
<a id="use-this-package"></a>
## 使用本包
调用 DeepSeek API 的插件向本服务索取一次请求的凭据。请求由插件自己发送,失败的措辞也由插件自己决定。
### 何时使用
Host 插件发往 DeepSeek 部署的每一个请求都使用它。凡是挂载了 DeepSeek 模型路由或 DeepSeek Web 提供方的组合都要挂载它,这些插件依赖它。它不需要配置。凭据服务和账号服务已挂载时它会读取它们,两者都没有时也能工作。
### 为请求鉴权
```ts
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-deepseek-auth'
declare const ctx: Context
declare const route: string | undefined // provider route of the conversation's latest model request
declare const signal: AbortSignal
const authorization = await ctx.deepseekAuth.authorize({
consumer: 'my-plugin',
accepts: ['account', 'api-key'],
billing: 'auto',
route,
destination: { path: '/v1/tools/search' },
}, signal)
if (authorization === undefined) throw new Error('no DeepSeek credential is configured')
await fetch(authorization.endpoint, { method: 'POST', headers: authorization.headers, signal })
```
`accepts` 列出目标 API 接受的种类,不在其中的种类不会被尝试。某个 API 开始接受另一种凭据时,它的消费方把该种类加入 `accepts`,其余不变。`billing` 取 `api-key`、`account` 或 `auto`,`auto` 跟随会话的模型路由:
| `billing` | 会话的模型路由 | 依次尝试的种类 |
|---|---|---|
| `api-key` | 任意 | API 密钥 |
| `account` | 任意 | 账号登录 |
| `auto` | 为账号登录登记的路由,即 `deepseek-account` | 账号登录,然后 API 密钥 |
| `auto` | 为 API 密钥登记的路由,即 `deepseek-official` | API 密钥 |
| `auto` | 其他任何路由,或不在会话中 | API 密钥,然后账号登录 |
只有注册某条路由的插件已挂载并登记了它,该路由才属于前两行 `auto`。记录在 `deepseek-account` 或 `deepseek-official` 上的会话,在对应插件未挂载时按最后一行处理。
`destination` 是拼接到所选种类部署 origin 之后的路径,或一个绝对 `url`。只有当绝对 URL 位于某种类部署的 origin 之下且不内嵌凭据时,该种类才为它服务,因此密钥不会被发往其他 origin。
一次授权携带 `kind`、`endpoint` 和请求 `headers`。API 密钥以 `Authorization: Bearer` 发送,除非 `apiKeyHeaders` 指定 `x-api-key` 或两者;账号登录凭据放在账号服务选定的请求头里。`reject()` 只在账号登录时存在,用于在目标返回 HTTP 401 后作废该凭据。`revoked` 同样只在账号登录时存在,账号退出登录时中止:消费方结束它鉴权的请求,并把这次结束报告为自身的失败,而不是调用方的取消。
`candidates(request)` 以相同顺序返回相同的种类,但不读取凭据。每个候选用 `configured()` 回答就绪检查,用 `resolve(signal)` 给出凭据,并给出 `endpoint`,API 密钥还给出供诊断使用的 `reference`。`routeKind(route)` 给出已挂载的模型路由插件在该路由 id 下登记的种类,其他路由一律为 `undefined`。
### 每种凭据及其部署的来源
| 种类 | 其模型路由已挂载 | 未挂载 |
|---|---|---|
| API 密钥 | `deepseek-official` 路由设置里的密钥引用和 base URL,即 Models 页面编辑的那份 | `DEEPSEEK_API_KEY`,发往 `https://api.deepseek.com` |
| 账号登录 | 账号服务的凭据,发往 `deepseek-account` 路由 base URL 的 origin | 账号服务的凭据,发往 `DEEPSEEK_BASE_URL` 所指的 origin,默认为官方 API |
模型路由插件在 `ctx.effect()` 内登记它注册的提供方路由和自己的设置:
```ts
import type { Context } from '@deepseek-ai/cordis'
import { credentialRef } from '@deepseek-ai/dsh-credentials'
import type {} from '@deepseek-ai/dsh-deepseek-auth'
declare const ctx: Context
declare const settings: () => { baseURL: string; apiKeyEnv: string }
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => {
const { baseURL, apiKeyEnv } = settings()
return { baseURL, reference: credentialRef(apiKeyEnv), owner: 'llm-deepseek' }
}))
```
服务对每个请求调用这个函数,所以设置的改动在下一个请求生效。连接存在期间,`auto` 计费按所登记的种类排定该路由上会话的顺序。请求可以在 `connections` 里携带某一种类自己的连接,它取代已登记的或默认的连接:模型路由传入它为一次模型请求捕获的那一代配置,拥有自己端点和密钥的消费方传入这两项。
密钥在凭据服务已挂载时经由它读取,否则经由启动环境读取,规则由 [`dsh-credentials`](../../credentials/credentials/README.zh.md) 为引用定义。
### 可能出错的地方
- 没有候选持有凭据时,`authorize()` 返回 `undefined`。失败的措辞由消费方决定;`candidates()` 提供要指出的种类和密钥引用。
- 空白的或含有 HTTP 请求头无法携带的字符的 API 密钥,以 `DeepSeekAuthError`(代码 `INVALID_CREDENTIAL`)失败。消息指出属主和要修正的引用,不包含密钥。
- 连接无法解析的种类(路由设置抛出、base URL 无法解析,或 `DEEPSEEK_BASE_URL` 不是 HTTP(S) URL)在 `candidates()` 中表现为未解析条目。`authorize()` 在此以代码 `UNRESOLVED_CONNECTION` 停止,不再尝试后面的种类。
- 对同一种类第二次 `connect()` 抛出 `DUPLICATE_CONNECTION`。
- 凭据存储的失败向上传播。
-----
<a id="understand-the-implementation"></a>
## 理解实现
<details>
<summary>实现细节——点击展开</summary>
本节解释服务背后的设计决策;可观察的行为见[使用本包](#use-this-package)。
### 设计理念
- **消费方声明其 API 接受什么,服务负责选择。** DeepSeek 逐个为它的 API 增加账号鉴权。消费方的 `accepts` 列表是记录某个 API 接受什么的唯一位置,所以 API 新增一种凭据时,扩充这个列表就是全部改动。
- **凭据绑定到它的部署。** 每个种类同一时间只有一个部署,凭据只释放给该部署 origin 之下的目标。
- **模型路由也是消费方。** 路由插件登记自己的设置,并和其他消费方一样索取授权,因此传输层和模型服务不带任何凭据接口。
- **服务不依赖任何消费方。** 它读取凭据存储和账号服务,自身不写任何模型路由的名字:每个路由插件在登记时传入自己的路由 id,`auto` 计费把会话的路由与已登记的 id 比较。
### 源码地图
| 文件 | 职责 |
|---|---|
| [`src/index.ts`](src/index.ts) | 服务本体:连接、计费顺序、目标绑定、API 密钥来源与账号来源、`DeepSeekAuthError` |
| [`src/types.ts`](src/types.ts) | 请求、连接、候选与授权的类型 |
### 生命周期
服务只保存模型路由插件登记的连接,每个 disposer 移除一个。请求之间不保留其他任何东西:每次 `candidates()` 调用都重新读取已登记的设置,每次 `resolve()` 都重新读取凭据。
</details>
-----
<a id="further-exploration"></a>
## 进一步探索
- [账号包映射](../README.zh.md)——账号服务与本服务。
- [DeepSeek 账号子系统](../../../docs/subsystems/account.zh.md)——账号登录以及本服务释放的请求凭据。
- [凭据引用 seam](../../credentials/credentials/README.zh.md)——密钥引用如何读取与检查。
- [DeepSeek 请求鉴权](../../../.agents/notes/implemented/architecture/2026-11-10-deepseek-request-authentication.zh.md)——决策及被否决的替代方案。
-----
<a id="model-experience"></a>
## 模型体验
无,因为本服务向 Host 插件释放请求头,不向模型请求的内容贡献任何东西。模型读到的失败文案由它的消费方措辞。
#### KV Cache 影响
不失效;没有凭据进入请求前缀。
## 已知限制与延期工作
<a id="known-limitations-and-deferred-work"></a>
这些限制说明本包在何时不适用或需要特别注意。它们是当前的包约束,不是任务积压。
- **每个种类一个部署**——第二条带有自己密钥和端点的 `deepseek-official` 式路由无法登记;需要另一把密钥的消费方在请求里传入自己的连接。
- **路由只在其插件已登记时才算 DeepSeek 路由**——记录在 `deepseek-account` 或 `deepseek-official` 上的会话,在对应插件未挂载时按其他路由的顺序处理(先 API 密钥,后账号登录);经由其他提供方插件访问的 DeepSeek 模型也是如此。
- **不校验凭据**——`configured()` 只报告是否存在,所以错误的密钥在目标拒绝它之前都算已配置。
<a id="dev-note"></a>
### 开发备注
<details>
<summary>维护者的工作上下文——点击展开</summary>
本开发备注是维护者的工作上下文:未决问题和尚未确定的方向。它明确不具权威性——已交付的行为、限制和已接受的理由见上文各节、包代码和链接的 Agent Note。
`/v1/tools/` 下的语音和文档 API 目前只接受 API 密钥。它们的消费方声明 `accepts: ['api-key']`,待服务端接受账号登录后再加入 `account`。
</details>
@@ -0,0 +1,6 @@
{
"meta": {
"title": "DeepSeek-Anfrageauthentifizierung",
"description": "Wählt für jede Anfrage an DeepSeek den API-Schlüssel oder die Kontoanmeldung aus und stellt die Anfrage-Header bereit."
}
}
@@ -0,0 +1,5 @@
{
"meta": {
"title": "DeepSeek request authentication"
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Autenticación de solicitudes de DeepSeek",
"description": "Elige la clave de API o el inicio de sesión de la cuenta para cada solicitud a DeepSeek y proporciona los encabezados de la solicitud."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Authentification des requêtes DeepSeek",
"description": "Choisit la clé API ou la connexion au compte pour chaque requête envoyée à DeepSeek et fournit les en-têtes de la requête."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "DeepSeek リクエスト認証",
"description": "DeepSeek へのリクエストごとに API キーまたはアカウントログインを選び、リクエストヘッダーを提供します。"
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Autenticação de solicitações DeepSeek",
"description": "Escolhe a chave de API ou o login da conta para cada solicitação ao DeepSeek e fornece os cabeçalhos da solicitação."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "Аутентификация запросов DeepSeek",
"description": "Выбирает ключ API или вход в учётную запись для каждого запроса к DeepSeek и предоставляет заголовки запроса."
}
}
@@ -0,0 +1,6 @@
{
"meta": {
"title": "DeepSeek 请求鉴权",
"description": "为发往 DeepSeek 的每个请求选择 API 密钥或账号登录,并提供请求头。"
}
}
@@ -0,0 +1,58 @@
{
"name": "@deepseek-ai/dsh-deepseek-auth",
"description": "DeepSeek request authentication (ctx.deepseekAuth): choose between the API key and the account sign-in for one DeepSeek API request and release its headers",
"version": "0.2.2-rc.3",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
"directory": "packages/account/deepseek-auth"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./types": {
"types": "./lib/types/types.d.ts",
"default": "./lib/types/types.js"
},
"./src/*": "./src/*",
"./package.json": "./package.json",
"./locale/*.json": "./locale/*.json"
},
"files": [
"locale/*.json",
"lib/index.js",
"lib/types/**/*.js",
"lib/types/**/*.d.ts",
"lib/types/**/*.d.ts.map",
"lib/**/*.js.map",
"src"
],
"license": "MIT",
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-credentials": "workspace:*",
"@deepseek-ai/dsh-deepseek-account": "workspace:*",
"@deepseek-ai/dsh-error": "workspace:*",
"@deepseek-ai/dsh-launch-environment": "workspace:*"
},
"peerDependenciesMeta": {
"@deepseek-ai/dsh-deepseek-account": {
"optional": true
}
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-credentials": "workspace:*",
"@deepseek-ai/dsh-deepseek-account": "workspace:*",
"@deepseek-ai/dsh-error": "workspace:*",
"@deepseek-ai/dsh-launch-environment": "workspace:*"
}
}
+257
View File
@@ -0,0 +1,257 @@
/**
* DeepSeek request authentication (`ctx.deepseekAuth`). DeepSeek APIs accept two kinds of credential, the API key and
* the account sign-in, and each API accepts one or both. A consumer names the kinds its API accepts and the billing
* its settings choose; this service orders the kinds, binds each to the deployment its credential belongs to, and
* releases the request headers of the first kind that has a credential. Model route plugins connect the deployment
* their settings name; without a connection the API key is `DEEPSEEK_API_KEY` at the official API and the account
* sign-in goes to the deployment `DEEPSEEK_BASE_URL` names.
*
* ```ts
* const authorization = await ctx.deepseekAuth.authorize({
* consumer: name, accepts: ['account', 'api-key'], billing: 'auto', route, destination: { path: '/v1/tools/search' },
* }, signal)
* ```
*
* @module @deepseek-ai/dsh-deepseek-auth
*/
import { Context, Service } from '@deepseek-ai/cordis'
import { credentialRef, credentialRefConfigured, normalizeApiKey, resolveCredentialRef } from '@deepseek-ai/dsh-credentials'
import type { ApiKeyRejection } from '@deepseek-ai/dsh-credentials'
import type {} from '@deepseek-ai/dsh-deepseek-account'
import { HarnessError } from '@deepseek-ai/dsh-error'
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
import type {
DeepSeekAuthCandidate, DeepSeekAuthConnection, DeepSeekAuthKind, DeepSeekAuthRequest, DeepSeekAuthUnresolved,
DeepSeekAuthorization,
} from './types.ts'
export type * from './types.ts'
declare module '@deepseek-ai/cordis' {
interface Context { deepseekAuth: DeepSeekAuth }
}
/** Base URL of the official DeepSeek API, where `DEEPSEEK_API_KEY` is sent without a connected API-key route. */
const OFFICIAL_BASE_URL = 'https://api.deepseek.com'
/** Credential reference of the official DeepSeek API key. */
const DEEPSEEK_API_KEY = credentialRef('DEEPSEEK_API_KEY')
/**
* Launch-environment variable naming the DeepSeek deployment the model routes default to. Without a connected account
* route, its origin receives the account sign-in.
*/
const DEEPSEEK_BASE_URL_ENV = 'DEEPSEEK_BASE_URL'
/** Failure codes of {@link DeepSeekAuthError}. */
export type DeepSeekAuthErrorCode =
/** A second connection of one kind; one model route plugin owns each kind's deployment. */
| 'DUPLICATE_CONNECTION'
/** The configured API key is blank or cannot travel in an HTTP header. */
| 'INVALID_CREDENTIAL'
/** The connection of the kind an operation reached does not resolve. */
| 'UNRESOLVED_CONNECTION'
/** A DeepSeek authentication failure; `message` never contains a credential. */
export class DeepSeekAuthError extends HarnessError {
declare readonly code: DeepSeekAuthErrorCode
/**
* @param message - what failed and what to change.
* @param code - the failure class.
* @param options - the underlying failure.
*/
constructor(message: string, code: DeepSeekAuthErrorCode, options?: ErrorOptions) {
super(message, code, options)
// Consumers quote this name in their own diagnostics, so it does not follow a bundler's class renaming.
this.name = 'DeepSeekAuthError'
}
}
/**
* The diagnostic for a configured API key that cannot be sent. The key never enters the text: `reference` names where to
* fix it. The Models page is named as the writer it usually is, not as the only one, because the same value can arrive
* from a hand-edited `.env` or a shell export in a composition that mounts no credentials service.
* @param reason - why the key cannot be sent.
* @param owner - settings namespace or plugin name prefixed to the text.
* @param reference - the credential reference the key was read under.
* @returns the message of the `INVALID_CREDENTIAL` failure.
*/
function unusableKey(reason: ApiKeyRejection, owner: string, reference: string): string {
const defect: Record<ApiKeyRejection, string> = {
empty: `is blank; set ${reference} to the raw key (the web Models page writes it) or export it in the launching`
+ ' environment',
illegalCharacters: `contains characters no HTTP header can carry; set ${reference} to the raw key alone (the web Models`
+ ' page writes it)',
}
return `${owner}: the API key resolved from ${reference} ${defect[reason]}`
}
/** Marks a failure of the launch-environment deployment, apart from a failure of a connected route's settings. */
class DeploymentError extends Error {
/** @param cause - why the variable's value is no deployment URL. */
constructor(cause: unknown) { super('unresolved deployment', { cause }) }
}
/** `ctx.deepseekAuth`: the two DeepSeek credential kinds behind one request-authorization operation. */
export class DeepSeekAuth extends Service {
private readonly connections = new Map<DeepSeekAuthKind, { route: string; connection: () => DeepSeekAuthConnection }>()
/** @param ctx - Host context; the credentials service and the account service are read when mounted. */
constructor(ctx: Context) {
super(ctx, 'deepseekAuth')
}
/**
* Connect the deployment a model route plugin's settings name for one kind. Call it from within `ctx.effect()`.
* @param kind - the kind the plugin's route bills.
* @param route - provider route the plugin registers; {@link routeKind} answers `kind` for it while connected.
* @param connection - reads the plugin's current settings; a throw marks the kind unresolved for that operation.
* @returns the disposer removing the connection.
* @throws {DeepSeekAuthError} code `DUPLICATE_CONNECTION` when the kind is already connected.
*/
connect(kind: DeepSeekAuthKind, route: string, connection: () => DeepSeekAuthConnection): () => void {
if (this.connections.has(kind)) {
throw new DeepSeekAuthError(`deepseek-auth: the ${kind} deployment is already connected`, 'DUPLICATE_CONNECTION')
}
this.connections.set(kind, { route, connection })
return () => { this.connections.delete(kind) }
}
/**
* The kind that bills a conversation on one model route.
* @param route - provider route of a model request; undefined names none.
* @returns the kind connected under that route, or undefined for a route no plugin connected.
*/
routeKind(route: string | undefined): DeepSeekAuthKind | undefined {
for (const [kind, connected] of this.connections) {
if (connected.route === route) return kind
}
return undefined
}
/**
* The kinds one request can authenticate with, in the order its billing tries them, each bound to its destination.
* Nothing is read from a credential store.
* @param request - the request.
* @returns candidates and unresolved kinds, first preferred; empty when the destination accepts no kind the
* billing allows or no allowed kind serves an absolute destination.
*/
candidates(request: DeepSeekAuthRequest): (DeepSeekAuthCandidate | DeepSeekAuthUnresolved)[] {
return this.order(request).filter(kind => request.accepts.includes(kind)).flatMap(kind => this.candidate(kind, request))
}
/**
* Release the credential of the first candidate that has one. A later candidate is not read once an earlier one
* has a credential, fails to read, or does not resolve.
* @param request - the request.
* @param signal - cancellation for the lookups.
* @returns the authorization, or undefined when no candidate has a credential.
* @throws {DeepSeekAuthError} code `UNRESOLVED_CONNECTION` at an unresolved kind, `INVALID_CREDENTIAL` for an
* unusable API key; store failures propagate.
*/
async authorize(request: DeepSeekAuthRequest, signal?: AbortSignal): Promise<DeepSeekAuthorization | undefined> {
for (const candidate of this.candidates(request)) {
if ('unresolved' in candidate) {
throw new DeepSeekAuthError(
`deepseek-auth: the ${candidate.kind} ${candidate.unresolved} does not resolve: ${String(candidate.error)}`,
'UNRESOLVED_CONNECTION', { cause: candidate.error },
)
}
const authorization = await candidate.resolve(signal)
if (authorization !== undefined) return authorization
}
return undefined
}
/** The kinds the billing tries, in order, before the destination's accepted kinds narrow them. */
private order(request: DeepSeekAuthRequest): DeepSeekAuthKind[] {
const billing = request.billing ?? 'auto'
if (billing !== 'auto') return [billing]
switch (this.routeKind(request.route)) {
// A conversation on the account route falls back to the API key.
case 'account': return ['account', 'api-key']
case 'api-key': return ['api-key']
// Every route no plugin connected, whatever its id, and an operation outside a conversation.
default: return ['api-key', 'account']
}
}
/** Bind one kind to the request's destination; empty when the kind does not serve an absolute destination. */
private candidate(kind: DeepSeekAuthKind, request: DeepSeekAuthRequest): (DeepSeekAuthCandidate | DeepSeekAuthUnresolved)[] {
let connection: DeepSeekAuthConnection
try { connection = request.connections?.[kind] ?? this.connections.get(kind)?.connection() ?? this.unconnected(kind) }
catch (error: unknown) {
const unresolved = error instanceof DeploymentError ? 'deployment' : 'connection'
return [{ kind, unresolved, error: error instanceof DeploymentError ? error.cause : error }]
}
let endpoint: string
try {
const deployment = new URL(connection.baseURL)
if ('path' in request.destination) endpoint = `${deployment.origin}${request.destination.path}`
else {
const destination = new URL(request.destination.url)
if (destination.origin !== deployment.origin || destination.username !== '' || destination.password !== '') return []
endpoint = request.destination.url
}
} catch (error: unknown) { return [{ kind, unresolved: 'connection', error }] }
return [kind === 'api-key' ? this.apiKey(connection, endpoint, request) : this.account(endpoint)]
}
/** The connection of a kind no model route plugin connected. */
private unconnected(kind: DeepSeekAuthKind): DeepSeekAuthConnection {
if (kind === 'api-key') return { baseURL: OFFICIAL_BASE_URL }
const configured = launchEnvironmentOf(this.ctx).get(DEEPSEEK_BASE_URL_ENV)?.value
if (configured === undefined || configured.length === 0) return { baseURL: OFFICIAL_BASE_URL }
try {
const url = new URL(configured)
if (!/^https?:$/u.test(url.protocol) || url.username.length > 0 || url.password.length > 0) {
throw new Error(`${DEEPSEEK_BASE_URL_ENV} must be an HTTP(S) URL without credentials`)
}
} catch (error: unknown) { throw new DeploymentError(error) }
return { baseURL: configured }
}
/** The API key read under the connection's reference, sent in the headers the request names. */
private apiKey(connection: DeepSeekAuthConnection, endpoint: string, request: DeepSeekAuthRequest): DeepSeekAuthCandidate {
const { ctx } = this
const reference = connection.reference ?? DEEPSEEK_API_KEY
const owner = connection.owner ?? request.consumer
return {
kind: 'api-key', endpoint, reference,
configured: () => credentialRefConfigured(ctx, reference),
resolve: async (signal) => {
signal?.throwIfAborted()
const raw = await resolveCredentialRef(ctx, reference)
if (raw === undefined) return undefined
const checked = normalizeApiKey(raw)
if (!checked.ok) throw new DeepSeekAuthError(unusableKey(checked.reason, owner, reference), 'INVALID_CREDENTIAL')
const headers: Record<string, string> = {}
for (const header of request.apiKeyHeaders ?? ['authorization']) {
headers[header] = header === 'authorization' ? `Bearer ${checked.value}` : checked.value
}
return { kind: 'api-key', endpoint, reference, headers }
},
}
}
/** The account sign-in the account service releases for the endpoint; absent without that service. */
private account(endpoint: string): DeepSeekAuthCandidate {
const { ctx } = this
return {
kind: 'account', endpoint,
configured: async () => (await ctx.get('deepseekAccount')?.resolveRequestCredential(endpoint)) !== undefined,
resolve: async (signal) => {
signal?.throwIfAborted()
const credential = await ctx.get('deepseekAccount')?.resolveRequestCredential(endpoint)
if (credential === undefined) return undefined
return {
kind: 'account', endpoint, headers: credential.headers, revoked: credential.revoked,
reject: () => credential.reject(),
}
},
}
}
}
export default DeepSeekAuth
+115
View File
@@ -0,0 +1,115 @@
/**
* Types of DeepSeek request authentication. Host-only: an authorization carries a secret, so none of these values
* crosses a Remote boundary or enters a log.
* @module @deepseek-ai/dsh-deepseek-auth/types
*/
import type { CredentialRef } from '@deepseek-ai/dsh-credentials'
/** A way to authenticate a DeepSeek API request: the API key, or the account sign-in. */
export type DeepSeekAuthKind = 'api-key' | 'account'
/** Which credential pays for an operation: one kind only, or `auto`, which follows the conversation's model route. */
export type DeepSeekAuthBilling = 'auto' | DeepSeekAuthKind
/** Request header an API key is sent in: `authorization` as `Bearer <key>`, `x-api-key` as the bare key. */
export type DeepSeekApiKeyHeader = 'authorization' | 'x-api-key'
/** The deployment the credential of one kind belongs to and, for the API key, where the key is read. */
export interface DeepSeekAuthConnection {
/** Base URL of the deployment; the credential is sent only to destinations under its origin. */
readonly baseURL: string
/** API key only: the credential reference the key is read under; `DEEPSEEK_API_KEY` when omitted. */
readonly reference?: CredentialRef
/**
* API key only: the settings namespace or package name prefixed to the diagnostic of an unusable key; the
* request's `consumer` when omitted.
*/
readonly owner?: string
}
/**
* Where one request goes: a path appended to the origin of the chosen kind's deployment, or one absolute URL, which a
* kind serves only when the URL is under the origin of that kind's deployment and embeds no credentials.
*/
export type DeepSeekAuthDestination = { readonly path: string } | { readonly url: string }
/** One DeepSeek API request that needs authentication. */
export interface DeepSeekAuthRequest {
/** Name of the requesting plugin, prefixed to the diagnostic of an unusable key whose connection names no owner. */
readonly consumer: string
/** Kinds the destination API accepts; a kind outside this list is never a candidate. */
readonly accepts: readonly DeepSeekAuthKind[]
/** Which credential pays; `auto` when omitted. */
readonly billing?: DeepSeekAuthBilling
/** Provider route of the model request this operation serves; only `auto` billing reads it. */
readonly route?: string | undefined
/** Where the request goes. */
readonly destination: DeepSeekAuthDestination
/**
* The caller's own connection of a kind, used in place of the connected or default one: the configuration
* generation a model route captured for one request, or a consumer's own endpoint and key.
*/
readonly connections?: Readonly<Partial<Record<DeepSeekAuthKind, DeepSeekAuthConnection>>>
/** Headers an API key is sent in; `authorization` when omitted. The account sign-in chooses its own header. */
readonly apiKeyHeaders?: readonly DeepSeekApiKeyHeader[]
}
/** The credential of one kind released for one request, ready to send. */
export interface DeepSeekAuthorization {
/** Kind of the credential. */
readonly kind: DeepSeekAuthKind
/** Absolute URL the request is sent to. */
readonly endpoint: string
/** Request headers carrying the credential. */
readonly headers: Readonly<Record<string, string>>
/** API key only: the reference the key was read under, for diagnostics that tell the user where to configure it. */
readonly reference?: CredentialRef
/**
* Invalidate this exact credential after the destination rejected it with HTTP 401, so no later request resends
* it. Absent for kinds without invalidation. The owner contains storage failures: the caller reports the
* destination's rejection, never a failure of this call.
* @returns settlement after the invalidation attempt.
*/
reject?(): Promise<void>
/**
* Aborts when the owner withdraws the credential while requests may carry it, as an account sign-out does. A
* consumer ends each request it authenticated with this authorization and reports that end as its own failure,
* not as the caller's cancellation. Absent for kinds that are never withdrawn.
*/
readonly revoked?: AbortSignal
}
/** One kind a request can authenticate with, in the order the billing chose. Nothing is read until asked. */
export interface DeepSeekAuthCandidate {
/** Kind of the credential. */
readonly kind: DeepSeekAuthKind
/** Absolute URL a request authenticated with this kind is sent to. */
readonly endpoint: string
/** API key only: the reference the key is read under. */
readonly reference?: CredentialRef
/**
* Whether {@link resolve} would release a credential, checked without validating it or contacting the
* destination. Store failures reject.
* @returns whether a credential of this kind is configured for the endpoint.
*/
configured(): Promise<boolean>
/**
* Release the credential, or `undefined` when none is configured. Store failures and an unusable key reject.
* @param signal - cancellation for the lookup.
* @returns the authorization, or `undefined`.
*/
resolve(signal?: AbortSignal): Promise<DeepSeekAuthorization | undefined>
}
/** A kind the billing chose whose connection does not resolve; an operation that reaches it stops there. */
export interface DeepSeekAuthUnresolved {
/** Kind of the credential. */
readonly kind: DeepSeekAuthKind
/**
* What did not resolve: the `connection` a model route plugin connected or the caller supplied, or the `deployment`
* the launch environment names for the account sign-in without a connected account route.
*/
readonly unresolved: 'connection' | 'deployment'
/** The failure. */
readonly error: unknown
}
@@ -0,0 +1,137 @@
/** Reading and releasing the credential of each kind, and choosing the first kind that has one. */
import { afterEach, describe, expect, it, vi } from 'vitest'
import { credentialRef } from '@deepseek-ai/dsh-credentials'
import { DeepSeekAuthError } from '@deepseek-ai/dsh-deepseek-auth'
import { accountStub } from '../../deepseek-account/tests/account-stub.ts'
import { candidate, disposeMounted, mount, request } from './harness.ts'
afterEach(disposeMounted)
const SEARCH = 'https://api.deepseek.com/v1/tools/search'
const key = request({ billing: 'api-key' })
const signIn = request({ billing: 'account' })
describe('the API key', () => {
it('is read under DEEPSEEK_API_KEY and sent as a bearer token by default', async () => {
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: ' sk-stored ' } })
const [entry] = ctx.deepseekAuth.candidates(key)
expect(await candidate(entry).configured()).toBe(true)
expect(await ctx.deepseekAuth.authorize(key)).toEqual({
kind: 'api-key', endpoint: SEARCH, reference: 'DEEPSEEK_API_KEY', headers: { authorization: 'Bearer sk-stored' },
})
})
it.each([
[['x-api-key'], { 'x-api-key': 'sk-stored' }],
[['x-api-key', 'authorization'], { 'x-api-key': 'sk-stored', 'authorization': 'Bearer sk-stored' }],
] as const)('is sent in the headers the request names: %j', async (apiKeyHeaders, headers) => {
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: 'sk-stored' } })
expect((await ctx.deepseekAuth.authorize({ ...key, apiKeyHeaders }))?.headers).toEqual(headers)
})
it('is read under the reference of its connection', async () => {
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: 'sk-default', ROUTE_KEY: 'sk-route' } })
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: 'https://route.deepseek.test', reference: credentialRef('ROUTE_KEY') })))
expect(await ctx.deepseekAuth.authorize(key)).toMatchObject({ reference: 'ROUTE_KEY', headers: { authorization: 'Bearer sk-route' } })
})
it('is read from the launch environment only without a credentials service', async () => {
const ambient = await mount({ environment: { DEEPSEEK_API_KEY: 'sk-ambient' } })
expect((await ambient.deepseekAuth.authorize(key))?.headers).toEqual({ authorization: 'Bearer sk-ambient' })
const authoritative = await mount({ environment: { DEEPSEEK_API_KEY: 'sk-ambient' }, stored: {} })
expect(await candidate(authoritative.deepseekAuth.candidates(key)[0]).configured()).toBe(false)
expect(await authoritative.deepseekAuth.authorize(key)).toBeUndefined()
})
it.each([
[
' ', undefined,
'web-test: the API key resolved from DEEPSEEK_API_KEY is blank; set DEEPSEEK_API_KEY to the raw key'
+ ' (the web Models page writes it) or export it in the launching environment',
],
[
'sk-你好', 'llm-deepseek',
'llm-deepseek: the API key resolved from DEEPSEEK_API_KEY contains characters no HTTP header can carry;'
+ ' set DEEPSEEK_API_KEY to the raw key alone (the web Models page writes it)',
],
])('refuses the unusable key %j, naming its owner and reference and never the key', async (value, owner, message) => {
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: value } })
const connections = { 'api-key': { baseURL: 'https://api.deepseek.com', ...owner === undefined ? {} : { owner } } }
const failure = await ctx.deepseekAuth.authorize({ ...key, connections }).catch((error: unknown) => error)
expect(failure).toBeInstanceOf(DeepSeekAuthError)
expect(failure).toMatchObject({ code: 'INVALID_CREDENTIAL', message })
})
it('starts no read for a cancelled lookup', async () => {
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: 'sk-stored' } })
const reason = new Error('cancelled')
await expect(ctx.deepseekAuth.authorize(key, AbortSignal.abort(reason))).rejects.toBe(reason)
})
})
describe('the account sign-in', () => {
it('is absent without the account service', async () => {
const ctx = await mount()
expect(await candidate(ctx.deepseekAuth.candidates(signIn)[0]).configured()).toBe(false)
expect(await ctx.deepseekAuth.authorize(signIn)).toBeUndefined()
})
it('is what the account service releases for the endpoint, with its invalidation and its sign-out signal', async () => {
const rejected = vi.fn()
const signedOut = new AbortController()
const asked: string[] = []
const account = accountStub({ token: (url) => { asked.push(url); return 'account-token' }, reject: rejected, signedOut: signedOut.signal })
const ctx = await mount({ account })
expect(await candidate(ctx.deepseekAuth.candidates(signIn)[0]).configured()).toBe(true)
const authorization = await ctx.deepseekAuth.authorize(signIn)
expect(authorization).toMatchObject({ kind: 'account', endpoint: SEARCH, headers: { 'x-dsh-auth-token': 'account-token' } })
expect(authorization?.revoked).toBe(signedOut.signal)
expect(asked).toEqual([SEARCH, SEARCH])
await authorization?.reject?.()
expect(rejected).toHaveBeenCalledExactlyOnceWith('account-token')
})
it('is absent while the account releases nothing for the endpoint, and starts no read for a cancelled lookup', async () => {
const token = vi.fn(() => undefined)
const ctx = await mount({ account: accountStub({ token }) })
expect(await ctx.deepseekAuth.authorize(signIn)).toBeUndefined()
token.mockClear()
const reason = new Error('cancelled')
await expect(ctx.deepseekAuth.authorize(signIn, AbortSignal.abort(reason))).rejects.toBe(reason)
expect(token).not.toHaveBeenCalled()
})
})
describe('authorize', () => {
it('releases the first kind that has a credential and does not read a later one', async () => {
const token = vi.fn(() => 'account-token')
const ctx = await mount({ stored: { DEEPSEEK_API_KEY: 'sk-stored' }, account: accountStub({ token }) })
expect(await ctx.deepseekAuth.authorize(request())).toMatchObject({ kind: 'api-key' })
expect(token).not.toHaveBeenCalled()
})
it('moves to the next kind when the first has no credential, and releases nothing when none has', async () => {
const withAccount = await mount({ stored: {}, account: accountStub({ token: () => 'account-token' }) })
expect(await withAccount.deepseekAuth.authorize(request())).toMatchObject({ kind: 'account' })
const empty = await mount({ stored: {} })
expect(await empty.deepseekAuth.authorize(request())).toBeUndefined()
})
it('stops at an unresolved kind without reading a later one', async () => {
const token = vi.fn(() => 'account-token')
const ctx = await mount({ account: accountStub({ token }) })
const failure = new Error('settings do not resolve')
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => { throw failure }))
const stopped = await ctx.deepseekAuth.authorize(request()).catch((error: unknown) => error)
expect(stopped).toMatchObject({ code: 'UNRESOLVED_CONNECTION', cause: failure })
expect((stopped as Error).message).toContain('the api-key connection does not resolve: Error: settings do not resolve')
expect(token).not.toHaveBeenCalled()
})
it('propagates a credential store failure', async () => {
const ctx = await mount()
const failure = new Error('store unreadable')
ctx.provide('credentials', { resolve: () => Promise.reject(failure) } as never)
await expect(ctx.deepseekAuth.authorize(key)).rejects.toBe(failure)
})
})
@@ -0,0 +1,115 @@
/** Which kinds a request can authenticate with, in which order, and where each one is sent. */
import { afterEach, describe, expect, it } from 'vitest'
import { DeepSeekAuthError } from '@deepseek-ai/dsh-deepseek-auth'
import { disposeMounted, mount, request, summary } from './harness.ts'
const OFFICIAL = 'https://api.deepseek.com/v1/tools/search'
const ROUTE = 'https://route.deepseek.test/anthropic'
const ACCOUNT = 'https://account.deepseek.test/anthropic'
afterEach(disposeMounted)
describe('billing order', () => {
it.each([
['api-key', undefined, ['api-key']],
['api-key', 'deepseek-account', ['api-key']],
['account', 'deepseek-official', ['account']],
['auto', 'deepseek-official', ['api-key']],
['auto', 'deepseek-account', ['account', 'api-key']],
['auto', 'moonshotai', ['api-key', 'account']],
['auto', undefined, ['api-key', 'account']],
[undefined, undefined, ['api-key', 'account']],
] as const)('tries %j billing on route %j as %j while both DeepSeek model routes are connected', async (billing, route, kinds) => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
ctx.effect(() => ctx.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: ACCOUNT })))
const entries = ctx.deepseekAuth.candidates(request({ ...billing === undefined ? {} : { billing }, route }))
expect(entries.map(entry => entry.kind)).toEqual(kinds)
})
it('tries the sign-in first in a conversation on the connected account route, then the API key', async () => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: ACCOUNT })))
expect(summary(ctx.deepseekAuth.candidates(request({ route: 'deepseek-account' })))).toEqual([
'account https://account.deepseek.test/v1/tools/search', `api-key ${OFFICIAL}`,
])
})
it.each(['deepseek-account', 'deepseek-official'])('orders a conversation on route %j as on any other route while no plugin connected that route', async (route) => {
const ctx = await mount()
expect(summary(ctx.deepseekAuth.candidates(request({ route })))).toEqual([`api-key ${OFFICIAL}`, `account ${OFFICIAL}`])
})
it('never offers a kind the destination does not accept', async () => {
const ctx = await mount()
expect(summary(ctx.deepseekAuth.candidates(request({ accepts: ['api-key'], destination: { path: '/v1/tools/asr' } }))))
.toEqual(['api-key https://api.deepseek.com/v1/tools/asr'])
expect(ctx.deepseekAuth.candidates(request({ accepts: ['api-key'], billing: 'account' }))).toEqual([])
})
it('names the kind a route bills by the id its plugin connected, for as long as that plugin stays mounted', async () => {
const ctx = await mount()
const kinds = () => ['gateway', 'deepseek-account', 'deepseek-official', undefined].map(route => ctx.deepseekAuth.routeKind(route))
expect(kinds()).toEqual([undefined, undefined, undefined, undefined])
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'gateway', () => ({ baseURL: ROUTE })))
const account = await ctx.plugin({ name: 'account-route', inject: ['deepseekAuth'], apply: (scope: typeof ctx) => {
scope.effect(() => scope.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: ACCOUNT })))
} })
expect(kinds()).toEqual(['api-key', 'account', undefined, undefined])
await account.dispose()
expect(kinds()).toEqual(['api-key', undefined, undefined, undefined])
})
})
describe('connections', () => {
it('sends each kind to the origin of the deployment its model route plugin connected', async () => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
ctx.effect(() => ctx.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: ACCOUNT })))
expect(summary(ctx.deepseekAuth.candidates(request()))).toEqual([
'api-key https://route.deepseek.test/v1/tools/search', 'account https://account.deepseek.test/v1/tools/search',
])
})
it('reads the connected settings for each request', async () => {
const ctx = await mount()
let baseURL = ROUTE
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL })))
baseURL = 'https://next.deepseek.test/anthropic'
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key' })))).toEqual(['api-key https://next.deepseek.test/v1/tools/search'])
})
it('removes a connection with the plugin that made it', async () => {
const ctx = await mount()
const plugin = await ctx.plugin({ name: 'route', inject: ['deepseekAuth'], apply: (scope: typeof ctx) => {
scope.effect(() => scope.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
} })
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key' })))).toEqual(['api-key https://route.deepseek.test/v1/tools/search'])
await plugin.dispose()
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key' })))).toEqual([`api-key ${OFFICIAL}`])
})
it('refuses a second connection of one kind', async () => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: ACCOUNT })))
expect(() => ctx.deepseekAuth.connect('account', 'another-account-route', () => ({ baseURL: ROUTE })))
.toThrow(expect.objectContaining({ constructor: DeepSeekAuthError, code: 'DUPLICATE_CONNECTION' }))
})
it('prefers the connection a request carries over the connected one', async () => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
const own = { 'api-key': { baseURL: 'https://own.deepseek.test/api/v1/tools' } }
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key', connections: own })))).toEqual(['api-key https://own.deepseek.test/v1/tools/search'])
})
it('marks a kind unresolved when its connected settings do not resolve or name no URL', async () => {
const ctx = await mount()
const failure = new Error('settings do not resolve')
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => { throw failure }))
ctx.effect(() => ctx.deepseekAuth.connect('account', 'deepseek-account', () => ({ baseURL: 'not a url' })))
const [key, account] = ctx.deepseekAuth.candidates(request())
expect(key).toEqual({ kind: 'api-key', unresolved: 'connection', error: failure })
expect(account).toMatchObject({ kind: 'account', unresolved: 'connection' })
})
})
@@ -0,0 +1,57 @@
/** Where a credential may be sent: absolute destinations, and the deployment of a kind no model route connected. */
import { afterEach, describe, expect, it } from 'vitest'
import { disposeMounted, mount, request, summary } from './harness.ts'
afterEach(disposeMounted)
describe('absolute destinations', () => {
const ROUTE = 'https://route.deepseek.test/anthropic'
it('offers a kind for a URL under the origin of its deployment', async () => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
const url = 'https://route.deepseek.test/anthropic/v1/models'
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key', destination: { url } })))).toEqual([`api-key ${url}`])
})
it.each([
'https://other.deepseek.test/anthropic/v1/models',
'http://route.deepseek.test/anthropic/v1/models',
'https://user:[email protected]/anthropic/v1/models',
])('offers no kind for %s, which is outside the deployment or embeds credentials', async (url) => {
const ctx = await mount()
ctx.effect(() => ctx.deepseekAuth.connect('api-key', 'deepseek-official', () => ({ baseURL: ROUTE })))
expect(ctx.deepseekAuth.candidates(request({ billing: 'api-key', destination: { url } }))).toEqual([])
})
it('marks a kind unresolved for a destination that is no URL', async () => {
const ctx = await mount()
expect(ctx.deepseekAuth.candidates(request({ billing: 'api-key', destination: { url: 'not a url' } })))
.toMatchObject([{ kind: 'api-key', unresolved: 'connection' }])
})
})
describe('the account deployment without a connected account route', () => {
it.each([[{}], [{ DEEPSEEK_BASE_URL: '' }]])('is the official API for environment %j', async (environment) => {
const ctx = await mount({ environment })
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'account' })))).toEqual(['account https://api.deepseek.com/v1/tools/search'])
})
it('is the origin DEEPSEEK_BASE_URL names', async () => {
const ctx = await mount({ environment: { DEEPSEEK_BASE_URL: 'https://gateway.deepseek.test/anthropic' } })
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'account' })))).toEqual(['account https://gateway.deepseek.test/v1/tools/search'])
})
it.each(['not a url', 'ftp://gateway.deepseek.test', 'https://user:[email protected]'])(
'is unresolved for DEEPSEEK_BASE_URL=%s, naming the deployment', async (value) => {
const ctx = await mount({ environment: { DEEPSEEK_BASE_URL: value } })
const [entry] = ctx.deepseekAuth.candidates(request({ billing: 'account' }))
expect(entry).toMatchObject({ kind: 'account', unresolved: 'deployment' })
expect(entry).toHaveProperty('error', expect.any(Error))
})
it('does not move the API key, which stays at the official API', async () => {
const ctx = await mount({ environment: { DEEPSEEK_BASE_URL: 'https://gateway.deepseek.test/anthropic' } })
expect(summary(ctx.deepseekAuth.candidates(request({ billing: 'api-key' })))).toEqual(['api-key https://api.deepseek.com/v1/tools/search'])
})
})
@@ -0,0 +1,59 @@
/** A context with the DeepSeek authentication service over stand-in credential planes. */
import { Context } from '@deepseek-ai/cordis'
import DeepSeekAuth, { type DeepSeekAuthCandidate, type DeepSeekAuthRequest, type DeepSeekAuthUnresolved } from '@deepseek-ai/dsh-deepseek-auth'
import type { DeepSeekAccount } from '@deepseek-ai/dsh-deepseek-account'
import { DSH_LAUNCH_ENVIRONMENT_KEY, createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
/** Credential planes of one test context. */
export interface Planes {
/** Launch-environment variables. */
environment?: Record<string, string>
/** Values of the mounted credentials service by reference; omitted mounts no service. */
stored?: Record<string, string>
/** Account service stand-in. */
account?: DeepSeekAccount
}
const mounted: Context[] = []
/** Dispose every context {@link mount} created. */
export async function disposeMounted(): Promise<void> {
await Promise.all(mounted.splice(0).map(ctx => ctx.fiber.dispose()))
}
/**
* Mount the service.
* @param planes - the credential planes it reads.
* @returns the context.
*/
export async function mount(planes: Planes = {}): Promise<Context> {
const ctx = new Context()
mounted.push(ctx)
ctx.provide(DSH_LAUNCH_ENVIRONMENT_KEY, createLaunchEnvironmentSnapshot([{ source: 'process', values: planes.environment ?? {} }]))
const { stored } = planes
if (stored !== undefined) {
ctx.provide('credentials', {
resolve: (ref: string) => Promise.resolve(stored[ref] === undefined ? undefined : { value: stored[ref] }),
describe: (ref: string) => Promise.resolve({ configured: (stored[ref]?.length ?? 0) > 0 }),
} as never)
}
if (planes.account !== undefined) ctx.provide('deepseekAccount', planes.account)
await ctx.plugin(DeepSeekAuth)
return ctx
}
/** A request to the Search API accepting both kinds, with overrides. */
export function request(overrides: Partial<DeepSeekAuthRequest> = {}): DeepSeekAuthRequest {
return { consumer: 'web-test', accepts: ['account', 'api-key'], destination: { path: '/v1/tools/search' }, ...overrides }
}
/** Each entry as `kind endpoint`, or `kind !unresolved` for an unresolved kind. */
export function summary(entries: readonly (DeepSeekAuthCandidate | DeepSeekAuthUnresolved)[]): string[] {
return entries.map(entry => 'unresolved' in entry ? `${entry.kind} !${entry.unresolved}` : `${entry.kind} ${entry.endpoint}`)
}
/** Narrow an entry to a candidate, failing the test for an unresolved kind. */
export function candidate(entry: DeepSeekAuthCandidate | DeepSeekAuthUnresolved | undefined): DeepSeekAuthCandidate {
if (entry === undefined || 'unresolved' in entry) throw new Error('expected a candidate')
return entry
}
@@ -0,0 +1,30 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": [
"src"
],
"references": [
{
"path": "../../../vendor/cosmokit"
},
{
"path": "../../../vendor/cordis"
},
{
"path": "../../credentials/credentials"
},
{
"path": "../deepseek-account"
},
{
"path": "../../util/error"
},
{
"path": "../../util/launch-environment"
}
]
}
+4
View File
@@ -122,6 +122,10 @@
config:
desktopPlatform: !!js "ctx.get('profileContext')?.name === 'desktop' && ['darwin', 'win32'].includes(process.platform) ? process.platform : null"
# DeepSeek model routes and web providers ask this service for the API key or the account sign-in of each request.
- id: deepseek-auth
name: '@deepseek-ai/dsh-deepseek-auth'
- id: credentials
name: '@deepseek-ai/dsh-credentials-local'
+1
View File
@@ -58,6 +58,7 @@
"@deepseek-ai/dsh-config-editor": "workspace:*",
"@deepseek-ai/dsh-credentials-local": "workspace:*",
"@deepseek-ai/dsh-deepseek-account": "workspace:*",
"@deepseek-ai/dsh-deepseek-auth": "workspace:*",
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "workspace:*",
"@deepseek-ai/dsh-fs-local": "workspace:*",
"@deepseek-ai/dsh-fs-observation-policy": "workspace:*",
@@ -23,6 +23,9 @@
- id: plugin-package-inventory-deepseek
name: '@deepseek-ai/dsh-plugin-package-inventory-deepseek'
- id: deepseek-auth
name: '@deepseek-ai/dsh-deepseek-auth'
- id: llm-deepseek
name: '@deepseek-ai/dsh-llm-deepseek-api-key'
config:
+2 -1
View File
@@ -72,7 +72,8 @@
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-working-directory": "workspace:*",
"@deepseek-ai/dsh-tool-working-directory": "workspace:*",
"@deepseek-ai/dsh-fs-local": "workspace:*"
"@deepseek-ai/dsh-fs-local": "workspace:*",
"@deepseek-ai/dsh-deepseek-auth": "workspace:*"
},
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~"
@@ -27,6 +27,7 @@ describe('dsh-sdk-minimal bundle', () => {
['deepseek-llm-api-extensions', '@deepseek-ai/dsh-deepseek-llm-api-extensions'],
['session-log-deepseek', '@deepseek-ai/dsh-session-log-deepseek'],
['plugin-package-inventory-deepseek', '@deepseek-ai/dsh-plugin-package-inventory-deepseek'],
['deepseek-auth', '@deepseek-ai/dsh-deepseek-auth'],
['llm-deepseek', '@deepseek-ai/dsh-llm-deepseek-api-key'],
['sandbox', '@deepseek-ai/dsh-sandbox-local'],
['filesystem', '@deepseek-ai/dsh-fs-local'],
@@ -36,8 +36,8 @@
en: a87afbec5e339b36
zh: 6348c81af7e650e1
/deepseek-ai-dsh-client-ui-settings-models/understand-the-implementation/validation:
en: d469e496518d44c5
zh: e71938ef7502a20c
en: 7ebb4f43b619d8dd
zh: 3cdb6dd893cb8c8e
/deepseek-ai-dsh-client-ui-settings-models/understand-the-implementation/concurrency-and-credentials:
en: 6e04c00818f014cd
zh: 2d57f8d8944e67ed
+1 -1
View File
@@ -93,7 +93,7 @@ The page never holds a full settings section: it holds only the REDACTED descrip
### Validation
A typed API key is judged on its own field: after trimming, it must be non-empty and every character must be printable ASCII (`[\x21-\x7E]`), which is exactly what an HTTP header value can carry — the twin of `normalizeApiKey` in `@deepseek-ai/dsh-llm`, mirrored here because the source-plane split forbids importing it. A value matching a pasted `NAME=value` environment line or wrapped in matching quotes is refused as the same format failure. Empty ids, duplicate ids, empty explicit names, and unreadable, non-positive, or fractional capacities fail before any write. The retry fields come from the `retryPolicy` schema the namespace publishes: each union branch is a mode, number fields become inputs whose integer step, minimum, and maximum are checked from the schema, string lists become the code picker, nested objects become folds, and fields of other types are not shown. The labels, hints, messages, and code names are copy owned by this page; an unlabelled field shows its schema key. The two rules `resolveRetryPolicy` in `@deepseek-ai/dsh-llm` enforces beyond any field bound, an initial delay at most the maximum delay and no repeated code, are mirrored for the same reason, because `llm-deepseek` only logs a warning for a live policy it refuses. The card writes the policy field by field, so an unchanged inherited field stays inherited. DeepSeek's `models` is one replace-by-value array: the editor shows inherited effective rows until the first model edit materializes the complete array in the user layer, while reset unsets that override.
A typed API key is judged on its own field: after trimming, it must be non-empty and every character must be printable ASCII (`[\x21-\x7E]`), which is exactly what an HTTP header value can carry — the twin of `normalizeApiKey` in `@deepseek-ai/dsh-credentials`, mirrored here because the source-plane split forbids importing it. A value matching a pasted `NAME=value` environment line or wrapped in matching quotes is refused as the same format failure. Empty ids, duplicate ids, empty explicit names, and unreadable, non-positive, or fractional capacities fail before any write. The retry fields come from the `retryPolicy` schema the namespace publishes: each union branch is a mode, number fields become inputs whose integer step, minimum, and maximum are checked from the schema, string lists become the code picker, nested objects become folds, and fields of other types are not shown. The labels, hints, messages, and code names are copy owned by this page; an unlabelled field shows its schema key. The two rules `resolveRetryPolicy` in `@deepseek-ai/dsh-llm` enforces beyond any field bound, an initial delay at most the maximum delay and no repeated code, are mirrored for the same reason, because `llm-deepseek` only logs a warning for a live policy it refuses. The card writes the policy field by field, so an unchanged inherited field stays inherited. DeepSeek's `models` is one replace-by-value array: the editor shows inherited effective rows until the first model edit materializes the complete array in the user layer, while reset unsets that override.
### Concurrency and credentials
@@ -93,7 +93,7 @@ Models 页面包含 **DeepSeek 账号**(`deepseek-account`,英文为 **DeepS
### 校验
键入的 API 密钥按其自身字段判定:去除首尾空白后必须非空,且每个字符都必须是可打印 ASCII(`[\x21-\x7E]`),这正是 HTTP 头值能够携带的字符集——与 `@deepseek-ai/dsh-llm` 中的 `normalizeApiKey` 互为镜像,此处复刻是因为源平面拆分禁止导入它。与粘贴的 `NAME=value` 环境行一致或包裹在匹配引号内的值,会作为同样的格式失败被拒绝。空 id、重复 id、空显式名称以及不可读、非正数或小数的容量都会在任何写入之前失败。重试字段来自命名空间发布的 `retryPolicy` schema:每个 union 分支是一种模式,数字字段成为输入框,其整数步长、最小值和最大值按 schema 检查,字符串列表成为错误码勾选列表,嵌套对象成为折叠区,其他类型的字段不显示。标签、提示、错误消息和错误码名称是本页面拥有的文案;没有标签的字段显示其 schema 键名。`@deepseek-ai/dsh-llm` 中 `resolveRetryPolicy` 在字段上限之外还强制执行两条规则:初始延迟不大于最大延迟、错误码不重复,出于同样原因在此复刻,因为 `llm-deepseek` 对它拒绝的实时策略只记录警告。卡片按字段写入策略,因此未修改的继承字段保持继承。DeepSeek 的 `models` 是一个按值整体替换的数组:编辑器先显示继承的有效行,直到第一次模型编辑把完整数组物化进用户层,重置则取消该覆盖。
键入的 API 密钥按其自身字段判定:去除首尾空白后必须非空,且每个字符都必须是可打印 ASCII(`[\x21-\x7E]`),这正是 HTTP 头值能够携带的字符集——与 `@deepseek-ai/dsh-credentials` 中的 `normalizeApiKey` 互为镜像,此处复刻是因为源平面拆分禁止导入它。与粘贴的 `NAME=value` 环境行一致或包裹在匹配引号内的值,会作为同样的格式失败被拒绝。空 id、重复 id、空显式名称以及不可读、非正数或小数的容量都会在任何写入之前失败。重试字段来自命名空间发布的 `retryPolicy` schema:每个 union 分支是一种模式,数字字段成为输入框,其整数步长、最小值和最大值按 schema 检查,字符串列表成为错误码勾选列表,嵌套对象成为折叠区,其他类型的字段不显示。标签、提示、错误消息和错误码名称是本页面拥有的文案;没有标签的字段显示其 schema 键名。`@deepseek-ai/dsh-llm` 中 `resolveRetryPolicy` 在字段上限之外还强制执行两条规则:初始延迟不大于最大延迟、错误码不重复,出于同样原因在此复刻,因为 `llm-deepseek` 对它拒绝的实时策略只记录警告。卡片按字段写入策略,因此未修改的继承字段保持继承。DeepSeek 的 `models` 是一个按值整体替换的数组:编辑器先显示继承的有效行,直到第一次模型编辑把完整数组物化进用户层,重置则取消该覆盖。
### 并发与凭据
@@ -4,7 +4,7 @@
*/
/**
* Twin of `normalizeApiKey` in `@deepseek-ai/dsh-llm`: printable ASCII, space
* Twin of `normalizeApiKey` in `@deepseek-ai/dsh-credentials`: printable ASCII, space
* excluded. Client packages reference only client packages, so the charset
* rule is mirrored here rather than imported; keep the two in step, as
* `validateDeepSeekModels` is kept in step with the host's `catalogModel`.
@@ -65,6 +65,7 @@
"@deepseek-ai/dsh-tool-fs": "workspace:*",
"@deepseek-ai/dsh-tool-testkit": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-working-directory": "workspace:*"
"@deepseek-ai/dsh-working-directory": "workspace:*",
"@deepseek-ai/dsh-deepseek-auth": "workspace:*"
}
}
@@ -9,6 +9,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session'
import type { Agent } from '@deepseek-ai/dsh-agent'
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek-api-key'
import DeepSeekAuth from '@deepseek-ai/dsh-deepseek-auth'
import * as AgentInstructions from '@deepseek-ai/dsh-agent-instructions'
import { candidateScopeKey } from '../src/render.ts'
import LocalFileSystem from '@deepseek-ai/dsh-fs-local'
@@ -47,6 +48,7 @@ async function harness(): Promise<{ ctx: Context; agent: Agent }> {
vi.stubEnv('DSH_AGENTS_HOME', join(workdir, 'absent-agents'))
await ctx.plugin(AgentInstructions, { maxBytes: 65536 })
await ctx.plugin(AgentLoop, { agents: [] })
await ctx.plugin(DeepSeekAuth)
await ctx.plugin(LlmDeepSeek, { models: [{ id: 'deepseek-v4-flash' }] })
const handle = await ctx.agents.create({
sessionId: brandString<SessionId>('workspace-context-e2e-session'),
+2 -1
View File
@@ -62,6 +62,7 @@
"@deepseek-ai/dsh-tool-executor-native": "workspace:*",
"@deepseek-ai/dsh-tool-executor-ptc": "workspace:*",
"@deepseek-ai/dsh-tool-testkit": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*"
"@deepseek-ai/dsh-tools": "workspace:*",
"@deepseek-ai/dsh-deepseek-auth": "workspace:*"
}
}
@@ -12,6 +12,7 @@ import AgentRegistry, { type Agent } from '@deepseek-ai/dsh-agent'
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import * as LlmDeepSeek from '@deepseek-ai/dsh-llm-deepseek-api-key'
import DeepSeekAuth from '@deepseek-ai/dsh-deepseek-auth'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
@@ -51,6 +52,7 @@ async function loopHarness(): Promise<Context> {
await created.plugin(NativeToolExecutor)
await created.plugin(AgentRegistry)
await created.plugin(AgentLoop, { agents: [] })
await created.plugin(DeepSeekAuth)
await created.plugin(LlmDeepSeek)
created.tools.register(defineContentToolFixture({
name: 'lookup',
@@ -24,8 +24,8 @@
en: 8f3500119608f91b
zh: 147fdb5389affbc0
/deepseek-ai-dsh-credentials/use-this-package/storing-checking-and-removing-keys:
en: 9f6cf31d0fd281ac
zh: b20ac60e6cdd7527
en: 729ea87c65c4f12b
zh: e6356492854a4487
/deepseek-ai-dsh-credentials/use-this-package/storing-updating-and-removing-records:
en: 300c3f1f13abdca4
zh: ec7a6486ac88889c
@@ -48,8 +48,8 @@
en: 1d56a35fe82e78f3
zh: 1fffc3e104c36805
/deepseek-ai-dsh-credentials/understand-the-implementation/source-map:
en: f7c85d12a7179da0
zh: 347ac9e9f89005aa
en: 74759a13b7790d41
zh: 4819aa4cac80b611
/deepseek-ai-dsh-credentials/understand-the-implementation/client-safe-types:
en: b955d1b41f0ad904
zh: 3f49a25e157d3672
+2 -1
View File
@@ -60,7 +60,7 @@ await ctx.credentials.unset(ref) // no-op when absent; an
Store a key with `set`, remove it with `unset`, check its status with `describe`, and read the current value with `resolve` when an operation needs it. `describe` reports whether the key is set, where it comes from, and whether you can write to it — it never returns the value. Providers may disclose a masked stored-value preview through the optional `masked` field; the full value stays on the Host.
Consumers that must also work in compositions without a credentials service, such as the DeepSeek model and web providers, read references through `resolveCredentialRef(ctx, ref)` and `credentialRefConfigured(ctx, ref)`: a mounted service is authoritative, including when it holds no value, and only its absence makes them read the launch environment, where an empty value is absent. Store failures propagate, and callers validate the value's format.
Consumers that must also work in compositions without a credentials service, such as DeepSeek request authentication, read references through `resolveCredentialRef(ctx, ref)` and `credentialRefConfigured(ctx, ref)`: a mounted service is authoritative, including when it holds no value, and only its absence makes them read the launch environment, where an empty value is absent. Store failures propagate. Callers validate the value's format with `normalizeApiKey(raw)`, which trims the value and rejects a blank one or one with characters no HTTP header can carry, and word their own error for the `reason` it returns; this package words no diagnostic.
### Storing, updating, and removing records
@@ -133,6 +133,7 @@ One doctrine and four consequences:
| File | Role |
|---|---|
| [`src/index.ts`](src/index.ts) | Service Definition: the `credentialRef`/`credentialKey` brands, `ResolvedCredential`/`CredentialRecordInfo`, the abstract provider over both key spaces, contained fan-out |
| [`src/api-key.ts`](src/api-key.ts) | The well-formedness check of a resolved API key and the diagnostic that names where to fix it |
| [`src/types.ts`](src/types.ts) | Client-safe type surface: the `CredentialRef` and `CredentialKey` brands, the stored-record union, the `CredentialInfo` reference view, the `credentials/reference-updated` and `credentials/record-updated` declarations |
### Client-safe types
@@ -60,7 +60,7 @@ await ctx.credentials.unset(ref) // no-op when absent; an
用 `set` 存储密钥、用 `unset` 移除、用 `describe` 检查状态、在操作需要时用 `resolve` 读取当前值。`describe` 报告密钥是否已设置、来自哪里、能否写入——它绝不返回值。提供方可通过可选的 `masked` 字段报告已保存值的脱敏预览;完整值留在 Host。
必须在没有凭据服务的组合中也能工作的消费方(如 DeepSeek 模型与 Web 提供方)通过 `resolveCredentialRef(ctx, ref)` 和 `credentialRefConfigured(ctx, ref)` 读取引用:已挂载的服务具有权威性,包括它不持有值的情况;只有服务缺席时才读取启动环境,其中空值视为不存在。存储失败向上传播,值的格式由调用方校验。
必须在没有凭据服务的组合中也能工作的消费方(如 DeepSeek 请求鉴权)通过 `resolveCredentialRef(ctx, ref)` 和 `credentialRefConfigured(ctx, ref)` 读取引用:已挂载的服务具有权威性,包括它不持有值的情况;只有服务缺席时才读取启动环境,其中空值视为不存在。存储失败向上传播。值的格式由调用方用 `normalizeApiKey(raw)` 校验:它去掉首尾空白,并拒绝空值和含有 HTTP 请求头无法携带的字符的值;调用方再依据它返回的 `reason` 写出自己的错误;本包不生成诊断文案。
### 存储、更新与移除记录
@@ -133,6 +133,7 @@ apiKeyEnv: DEEPSEEK_API_KEY
| 文件 | 职责 |
|---|---|
| [`src/index.ts`](src/index.ts) | Service Definition:`credentialRef`/`credentialKey` 品牌、`ResolvedCredential`/`CredentialRecordInfo`、覆盖两个键空间的抽象提供方、带失败隔离的扇出 |
| [`src/api-key.ts`](src/api-key.ts) | 已解析 API 密钥的格式判断,以及指出修正位置的诊断文案 |
| [`src/types.ts`](src/types.ts) | 客户端安全类型面:`CredentialRef` 与 `CredentialKey` 品牌、存储记录联合类型、`CredentialInfo` 引用视图、`credentials/reference-updated` 与 `credentials/record-updated` 事件声明 |
### 客户端安全类型
@@ -1,7 +1,8 @@
/**
* The one definition of a well-formed provider API key, shared by every
* adapter that puts one in an HTTP header.
* @module @deepseek-ai/dsh-llm/api-key
* The one definition of a well-formed API key, shared by every consumer that
* puts a resolved key in an HTTP header. A consumer words its own diagnostic
* for a key that is not.
* @module @deepseek-ai/dsh-credentials/api-key
*/
/**
@@ -16,6 +16,7 @@ import type { CredentialInfo, CredentialKey, CredentialRecord, CredentialRef } f
export type {
ApiKeyRecord, CredentialInfo, CredentialKey, CredentialRecord, CredentialRef, GrantRecord,
} from './types.ts'
export * from './api-key.ts'
const REF_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/
@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest'
import { normalizeApiKey } from '@deepseek-ai/dsh-credentials'
describe('normalizeApiKey', () => {
it('accepts a printable-ASCII key unchanged', () => {
expect(normalizeApiKey('sk-0123456789abcdef')).toEqual({ ok: true, value: 'sk-0123456789abcdef' })
})
it('trims surrounding whitespace before judging', () => {
expect(normalizeApiKey(' sk-abc\t\n')).toEqual({ ok: true, value: 'sk-abc' })
})
it.each([
['an empty string', ''],
['spaces only', ' '],
['a tab only', '\t'],
])('rejects %s as empty', (_label, raw) => {
expect(normalizeApiKey(raw)).toEqual({ ok: false, reason: 'empty' })
})
it.each([
['an emoji', 'sk-\u{1F600}abc'],
['CJK text', 'sk-你好'],
['full-width punctuation', 'sk-abc,'],
['an interior space', 'sk-abc def'],
['a C0 control character', 'sk-abc\x01'],
['a latin-1 character', 'sk-café'],
])('rejects %s as illegal characters', (_label, raw) => {
expect(normalizeApiKey(raw)).toEqual({ ok: false, reason: 'illegalCharacters' })
})
it('accepts the printable-ASCII boundary characters', () => {
expect(normalizeApiKey('!~')).toEqual({ ok: true, value: '!~' })
})
})
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff. Show more