Merge remote-tracking branch 'origin/master' into feat/tencent-docs-plugin

This commit is contained in:
gengruilin committed 2026-11-18 18:52:55 +08:00
commit bb41d5e1e0
480 files changed
+21041 -1717

No files matched your search

@@ -9,8 +9,8 @@
en: 31fba384d90ce7d2
zh: f8b814868f3280c3
/agent-note-session-working-directory/decision:
en: 5de5171ee52a62b4
zh: 7f78197ea38af658
en: 5ff0c24c29c916b9
zh: bfbb082623c2a86c
/agent-note-session-working-directory/alternatives-considered:
en: f0995feb9b6bcce8
zh: 97417085fd17f70f
@@ -16,11 +16,11 @@ Only Host operations change the directory: worktree creation and exit, the forge
Required user-context snapshots carry the current value; each committed change attempts to queue a notice through the ordinary Agent inbox. Cancellation or disposal may discard unadmitted notices while the directory event survives for subsequent requests. The original project is the recovery destination when the selected directory disappears. Missing recovery destinations produce an error. Write permissions remain independent.
Subagents start in the parent's current directory or a Host-chosen directory and commit that directory after inherited history. Existing processes, terminals, and persistent shells keep their process-local directory. Project instructions, skills, and completion follow the effective directory without changing Session identity, grouping, or runtime composition.
Subagents start in the parent's current directory or a Host-chosen directory and commit that directory after inherited history. Existing processes, terminals, and persistent shells keep their process-local directory. The model's file and process tools, project instructions, skills, completion, and the sandbox boundary follow the effective directory, which is the [workspace root](2026-11-03-session-workspace-root.md), without changing Session identity, grouping, or runtime composition.
Live Session skill catalogs and file completion validate through the same directory owner. These reads can commit recovery and queue its notice before discovery, keeping discovered files and subsequent operations tied to the committed Session directory. Cold skill catalogs read the recorded projection without activating an Agent.
Live Session skill catalogs and file completion validate through the same directory owner, then read the workspace root. These reads can commit recovery and queue its notice before discovery, keeping discovered files and subsequent operations tied to the committed Session directories. Cold skill catalogs read the recorded root projection without activating an Agent.
Web sidebar terminal environment lookup reads the effective directory without filesystem validation or recovery, so a missing directory does not prevent reconnecting to a retained terminal. New terminal creation validates and recovers through the directory owner before spawning; the process keeps that directory independently of later Session changes.
Web sidebar terminal environment lookup reads the workspace root without filesystem validation or recovery, so a missing directory does not prevent reconnecting to a retained terminal. New terminal creation validates and recovers through the directory owner before spawning in the workspace root; the process keeps that directory independently of later Session changes.
Playwright MCP and Chrome DevTools MCP validate the effective directory when acquiring a Session's MCP connection and use it to launch the server. Later directory changes do not restart the retained server or change its process directory.
@@ -16,11 +16,11 @@ Status: implemented
必需的用户上下文快照携带当前值;每次已提交变更都会尝试通过普通 Agent 收件箱排入通知。取消或销毁可能丢弃尚未进入请求的通知,但目录事件仍然保留,供后续请求使用。所选目录消失时恢复到原始项目。恢复目录也消失时返回错误。写权限保持独立。
子代理从父代理的当前目录或 Host 选定的目录启动,并在继承历史之后提交该目录。已有进程、终端和持久 shell 保留进程局部目录。项目指令、技能和补全跟随有效目录,不改变 Session 身份、归属或运行时组合。
子代理从父代理的当前目录或 Host 选定的目录启动,并在继承历史之后提交该目录。已有进程、终端和持久 shell 保留进程局部目录。模型的文件与进程工具、项目指令、技能、补全和沙箱边界都跟随有效目录,即[工作区根](2026-11-03-session-workspace-root.zh.md),不改变 Session 身份、归属或运行时组合。
活跃 Session 的技能目录与文件补全通过同一个目录 owner 验证目录。这些读取可在发现操作之前提交恢复并排入通知,使发现的文件与后续操作关联到已提交的 Session 目录。冷态技能目录读取已记录的投影,不激活 Agent。
活跃 Session 的技能目录与文件补全通过同一个目录 owner 验证目录,再读取工作区根。这些读取可在发现操作之前提交恢复并排入通知,使发现的文件与后续操作关联到已提交的 Session 目录。冷态技能目录读取已记录的根投影,不激活 Agent。
Web 侧栏终端的环境查询读取有效目录,不验证文件系统或执行恢复,因此目录缺失不会阻止重新连接保留的终端。新终端在创建进程前通过目录 owner 验证和恢复目录;后续 Session 目录变更不会改变该进程的目录。
Web 侧栏终端的环境查询读取工作区根,不验证文件系统或执行恢复,因此目录缺失不会阻止重新连接保留的终端。新终端在创建进程前通过目录 owner 验证和恢复目录,并在工作区根中启动;后续 Session 目录变更不会改变该进程的目录。
Playwright MCP 和 Chrome DevTools MCP 在获取 Session 的 MCP 连接时验证有效目录,并在该目录启动服务器。后续目录变更不会重启保留的服务器,也不会改变其进程目录。
@@ -15,8 +15,8 @@
en: 7f33895364a9f5cc
zh: f1c79ea15f5c151e
/agent-note-initial-draft-content-and-structured-reference-restoration/decision/classes-and-methods:
en: e57394545d9d93ff
zh: 5ab142e661750b82
en: 9039c6bf700da3cf
zh: 2808757aed8615b3
/agent-note-initial-draft-content-and-structured-reference-restoration/decision/data-flow:
en: dd57e639e9328f1d
zh: 5e16cb2e3a73597c
@@ -37,7 +37,7 @@ The existing `dsh.conversation.<sessionId>` key remains. Readers accept both leg
| `SessionInputShell.refreshLexiconSubscription()` / `DraftEditorRuntime.refreshLexiconSubscription()` | `InputHub` owns the Session-scope `inject` callback that connects the lexicon after caching the shell, reconnects when the service arrives or is replaced, and unsubscribes on disposal. Both connection and catalog updates rescan the current editor without writing old text back; `setDraft` does not establish the subscription |
| `ConversationStoreState` / `createConversationStore` | Support structured input and legacy strings in draft storage, keeping View state and the original key |
| `DefaultConversationViews` | Remove restoration and prefill effects, retaining persistence binding and unbinding. Initial saving reads the owner's current snapshot, never text captured during render |
| The existing `selectWorkspace` callback in `apply.ts` | Keep the existing cross-Workspace draft-transfer rules, passing `draftSnapshot` instead of plain text so transfer retains references |
| The cross-Workspace draft move (`moveDraft` in `apply.ts`) | Keep the existing cross-Workspace draft-transfer rules, passing `draftSnapshot` instead of plain text so transfer retains references |
There is no new draft service, storage key, general task framework, or Session creation entry point. SlotRenderer, Host Session logs, command execution, and file-discovery RPCs are unchanged. `InputActions` remains the shared input-action entry; components receive no separate content-initialization callback.
@@ -37,7 +37,7 @@ Status: implemented
| `SessionInputShell.refreshLexiconSubscription()`/`DraftEditorRuntime.refreshLexiconSubscription()` | `InputHub` 拥有 Session scope 的 `inject` 回调,在缓存输入对象后连接词典,服务到达或替换时重接,销毁时退订。连接和词典更新都会重扫当前 editor,不覆盖旧文本;`setDraft` 不负责建立订阅 |
| `ConversationStoreState`/`createConversationStore` | draft 支持兼容旧字符串的结构化输入,View 状态及原 key 保持 |
| `DefaultConversationViews` | 删除恢复/预填 effect;保留持久化回调的绑定和解绑。初始保存只能读取 owner 的当前快照,不能把 render 时的旧文字写回 |
| `apply.ts` 中现有 `selectWorkspace` 回调 | 沿用原有跨工作区携带规则,但传递 `draftSnapshot` 而不是纯文本,防止携带时再次丢失引用 |
| 跨工作区的草稿移动(`apply.ts` 中的 `moveDraft`) | 沿用原有跨工作区携带规则,但传递 `draftSnapshot` 而不是纯文本,防止携带时再次丢失引用 |
不新增草稿服务、存储 key、通用任务框架或另一套 Session 创建入口;不改 SlotRenderer、Host Session 日志、命令执行和文件发现 RPC。`InputActions` 保留统一输入操作入口,组件不单独注入另一条内容初始化回调。
@@ -9,8 +9,8 @@
en: 3f5dacf86015cebb
zh: cf0d5bceb9941554
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision:
en: 0682ebef17f6a5e7
zh: 6ea399459262eb0c
en: e243a7d535022011
zh: fd1dd8634b9603cf
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision/registered-providers-are-observable-availability-is-not:
en: 38ce796dea91fa35
zh: d312a9cd29fd5cc9
@@ -21,17 +21,17 @@
en: dca56d7ced4e5294
zh: e984a7fddac3228f
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision/defaults-and-stored-selections:
en: 5fcd3319fbceed1d
zh: 20771646b9c36fa6
en: eba9b7ca32681406
zh: 7ab74b8054bea720
/agent-note-web-provider-selection-independent-menus-over-registered-providers/decision/legacy-messages-search:
en: 2c7c84f8fa1e8745
zh: 5d0244e4f17ba12a
en: 8f3180e3dd327bfc
zh: 012b2ebe8d2f5aac
/agent-note-web-provider-selection-independent-menus-over-registered-providers/alternatives-considered:
en: 2ec7f019ec3ce309
zh: a6a5a8db1f1dd682
en: d72b359bb9ff9666
zh: 33c9a12488a81826
/agent-note-web-provider-selection-independent-menus-over-registered-providers/consequences:
en: ea4d3f05e8be197a
zh: 81faeb3edf122869
en: fe529b10fcbb2d0a
zh: ed3eabbce90ddb92
/agent-note-web-provider-selection-independent-menus-over-registered-providers/verification:
en: 0db673b16e4aeda3
zh: 3b086edecebdc5b5
en: a8f08dc7ec5845fd
zh: a491c4a93db41c3f
@@ -10,7 +10,7 @@ The web service selects search and fetch providers through two independent field
## Decision
Users choose search and fetch providers independently from the Host's registered provider lists. The shipped composition selects the Search API for search and local HTTP fetch for fetch, and the DeepSeek Search and Fetch APIs follow the conversation's DeepSeek credential.
Users choose search and fetch providers independently from the Host's registered provider lists. The shipped composition fixes no search provider, so search follows the conversation's model route, and selects local HTTP fetch for fetch; the DeepSeek Search and Fetch APIs follow the conversation's DeepSeek credential.
### Registered providers are observable; availability is not
@@ -38,18 +38,24 @@ A capability whose YAML sets a non-empty `searchBaseURL` or `searchApiKeyEnv` (`
### Defaults and stored selections
The [base composition](../../../../packages/bundle/base/cordis.patch.yml) sets `searchProvider: deepseek-search-api` and `fetchProvider: http`. Search defaults to the Search API because it returns sources without Harness starting an auxiliary model request. Fetch defaults to local HTTP fetch because it has no per-request API charge, applies Harness's own URL validation and resource limits, and reaches intranet and local addresses. The Fetch API remains one menu choice away.
The [base composition](../../../../packages/bundle/base/cordis.patch.yml) sets `fetchProvider: http` and no `searchProvider`. With no search provider configured, `dsh-web` prefers one registered, usable provider per provider route of the model request a search serves: Messages search (`deepseek-official`) on the `deepseek-official` and `deepseek-account` model routes, because DeepSeek makes no per-search charge for the server-side search tool a DeepSeek model request declares, and the Search API (`deepseek-search-api`) on every other route and outside a model request, because it returns sources without an auxiliary model request to a provider the conversation does not use. `dsh-tool-web` puts the route of the calling Session's latest model request into each search request, and `searchReady()` selects with the route of the step being prepared, so readiness and execution name the same provider. The two routes and two provider ids are constants of `dsh-web`: a deployment changes the outcome only by configuring `searchProvider`, and the settings page shows the unconfigured state as **Automatic**. Fetch defaults to local HTTP fetch because it has no per-request API charge, applies Harness's own URL validation and resource limits, and reaches intranet and local addresses. The Fetch API remains one menu choice away.
A stored selection, whether in the settings document or in a deployment's own composition, wins over the shipped default, and an upgrade does not rewrite it. A selection is never replaced at execution: when the selected provider is missing, unavailable, or fails, the operation fails with its structured error and does not fall back to another search or fetch provider. A fallback would send the query and credential to an endpoint the user did not choose and change billing without notice.
### Legacy Messages search
The DeepSeek Messages search provider remains available as **DeepSeek (legacy)**. A stored `web.searchProvider: deepseek-official` (or `DSH_WEB_SEARCH_PROVIDER=deepseek-official`) selects it, so users whose gateways serve Messages search but not `/v1/tools` can retain their working provider.
The DeepSeek Messages search provider remains available as **DeepSeek server-side search** and serves unconfigured searches on the DeepSeek model routes. A stored `web.searchProvider: deepseek-official` (or `DSH_WEB_SEARCH_PROVIDER=deepseek-official`) selects it for every route, so users whose gateways serve Messages search but not `/v1/tools` can retain their working provider.
The Messages provider owns and writes `web/deepseek-search-llm-request`. The declaration and payload retain compatibility with released Sessions; the Search and Fetch API package neither declares nor writes this auxiliary event.
## Alternatives considered
**Let each provider declare the routes it is the default for.** A `defaultFor(llmProvider)` member on `WebSearchProvider` keeps `dsh-web` free of DeepSeek ids, but it changes both DeepSeek provider packages for a rule that has one instance.
**Put the route-to-provider table in `dsh-web` configuration.** A profile patch replaces a row's whole `config`, so a stored provider selection would also store a copy of the table and stop following the shipped one, and the table is not a choice users need: fixing a provider already overrides it.
**Have the Search API provider delegate to Messages search on DeepSeek routes.** The menu would keep two entries, but the entry named DeepSeek Search API would run another provider, a user could not fix the Search API for a DeepSeek model, and one provider package would depend on the other.
**Keep one switch for both APIs.** It lets Fetch API adoption need no configuration edit, but it ties fetch billing and target access policy to the search choice, and it cannot express a provider that another plugin registers.
**Filter the lists by availability, or add availability to each entry.** A filtered list hides a provider while its credential is missing, right when the user needs to choose and configure it. Availability also depends on the request's model route and credential state, so a listed boolean could disagree with execution. The archived [observation-surface decision](../../archived/simplification/2026-07-04-drop-unconsumed-web-observation-surface.md) allows only the smallest signal a consumer reads; the menus read registration only.
@@ -76,10 +82,10 @@ The Messages provider owns and writes `web/deepseek-search-llm-request`. The dec
## Consequences
Users without a stored search selection search through the Search API: their queries go to the Search endpoint the conversation's DeepSeek credential selects, cost a Search API request each, and send up to 128 characters of the latest human prompt as `ori_question` unless `sendOriginalQuestion` is off. Deployments whose gateway has no `/v1/tools` routes get search failures until they select Messages search or set `searchBaseURL` to a base that serves them. A stored `deepseek-official` selection uses Messages search. Users without a stored fetch selection fetch through local HTTP fetch. A signed-in user without an API key has DeepSeek web search with `auto` billing in every conversation except those on the DeepSeek API-key route; the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.md) lists each affected setup.
Users without a stored search selection search through Messages search in a conversation on a DeepSeek model route: each search is one auxiliary Messages request billed as model tokens, to Messages search's own endpoint, which does not follow the model provider's base URL, so a deployment whose DeepSeek model provider points at a gateway gets search failures until it saves that gateway as the Messages Base URL or fixes the Search API ([upgrade guide](../../../../docs/upgrade-guide/v0.2.2-rc.4/web-search-deepseek-model-default/guide.md)). On every other route they search through the Search API: their queries go to the Search endpoint the conversation's DeepSeek credential selects, cost a Search API request each, and send up to 128 characters of the latest human prompt as `ori_question` unless `sendOriginalQuestion` is off. Deployments whose gateway has no `/v1/tools` routes get search failures there until they select Messages search or set `searchBaseURL` to a base that serves them. `dsh-web` names two DeepSeek model routes and two DeepSeek search providers, which a second route-specific default would have to replace with a provider-neutral rule. A stored `deepseek-official` selection uses Messages search. Users without a stored fetch selection fetch through local HTTP fetch. A signed-in user without an API key has DeepSeek web search with `auto` billing in every conversation except those on the DeepSeek API-key route; the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.md) lists each affected setup.
A plugin provider, including one written in creator mode, appears in the matching menu as soon as it registers, under its `title`. The menus can offer a provider that cannot run for the current request; the failure appears when a search or fetch runs. Each registry change costs one forwarded event and one list read in each Client that observes it.
## Verification
[web.spec.ts](../../../../packages/web/web/tests/web.spec.ts) covers list contents and order, titles, events after registration and disposal, no event for a rejected duplicate, and contained listener failures. [deepseek.spec.ts](../../../../packages/web/web-search-deepseek/tests/deepseek.spec.ts) covers the independent Messages provider, and [credential-resolution.spec.ts](../../../../packages/web/web-deepseek-api/tests/credential-resolution.spec.ts) covers, for both capabilities, the account token on the account route and its invalidation after HTTP 401, the API-key fallback without a sign-in, the route key and endpoint in official, non-DeepSeek, and Session-less conversations, the account fallback without a key outside the DeepSeek routes, account-only and API-key-only billing on every route, own fields over billing, `DEEPSEEK_API_KEY` and the official base without that route, YAML-only own fields that never send the token, independent capabilities, readiness matching each operation, and ignored removed fields; [composition.spec.ts](../../../../packages/web/web-deepseek-api/tests/composition.spec.ts) boots the real model routes through the Loader. [remote-events.host.spec.ts](../../../../packages/api/remotes/tests/remote-events.host.spec.ts) covers event forwarding, and [base.spec.ts](../../../../packages/bundle/base/tests/base.spec.ts) pins the shipped defaults. The settings page's controller and card specs and the [plugin configuration browser scenario](../../../../apps/web/tests/plugin-config.e2e.ts) cover menu contents, independent Search and Fetch selection, the billing menus of the DeepSeek APIs, and the settings each provider keeps.
[web.spec.ts](../../../../packages/web/web/tests/web.spec.ts) covers list contents and order, titles, events after registration and disposal, no event for a rejected duplicate, contained listener failures, and the per-route preference with its fallbacks; [tool-web.spec.ts](../../../../packages/web/tool-web/tests/tool-web.spec.ts) covers the route `web_search` sends, and the `web-search-legacy-endpoint-guidance` snapshot runs Messages search on a DeepSeek route with no provider configured. [deepseek.spec.ts](../../../../packages/web/web-search-deepseek/tests/deepseek.spec.ts) covers the independent Messages provider, and [credential-resolution.spec.ts](../../../../packages/web/web-deepseek-api/tests/credential-resolution.spec.ts) covers, for both capabilities, the account token on the account route and its invalidation after HTTP 401, the API-key fallback without a sign-in, the route key and endpoint in official, non-DeepSeek, and Session-less conversations, the account fallback without a key outside the DeepSeek routes, account-only and API-key-only billing on every route, own fields over billing, `DEEPSEEK_API_KEY` and the official base without that route, YAML-only own fields that never send the token, independent capabilities, readiness matching each operation, and ignored removed fields; [composition.spec.ts](../../../../packages/web/web-deepseek-api/tests/composition.spec.ts) boots the real model routes through the Loader. [remote-events.host.spec.ts](../../../../packages/api/remotes/tests/remote-events.host.spec.ts) covers event forwarding, and [base.spec.ts](../../../../packages/bundle/base/tests/base.spec.ts) pins the shipped defaults. The settings page's controller and card specs and the [plugin configuration browser scenario](../../../../apps/web/tests/plugin-config.e2e.ts) cover menu contents, independent Search and Fetch selection, the billing menus of the DeepSeek APIs, and the settings each provider keeps.
@@ -10,7 +10,7 @@ Web 服务通过 `web.searchProvider` 和 `web.fetchProvider` 两个独立字段
## 决策
用户从 Host 已注册的提供方列表中分别选择搜索和抓取提供方。内置组合将搜索设为 Search API,将抓取设为本地 HTTP 抓取;DeepSeek Search 与 Fetch API 跟随会话的 DeepSeek 凭据。
用户从 Host 已注册的提供方列表中分别选择搜索和抓取提供方。内置组合不固定搜索提供方,搜索因此跟随会话的模型路由,抓取设为本地 HTTP 抓取;DeepSeek Search 与 Fetch API 跟随会话的 DeepSeek 凭据。
### 已注册的提供方可观察,可用性不可观察
@@ -38,18 +38,24 @@ Search 与 Fetch 各有一个计费方式设置 `web-deepseek-api.searchBilling`
### 默认值与已保存的选择
[base 组合](../../../../packages/bundle/base/cordis.patch.yml)设置 `searchProvider: deepseek-search-api` 和 `fetchProvider: http`。搜索默认使用 Search API,因为它返回来源时无需 Harness 发起辅助模型请求。抓取默认使用本地 HTTP 抓取,因为它没有按次的 API 费用,执行 Harness 自身的 URL 校验和资源限制,并且可以访问内网和本地地址。Fetch API 仍可在下拉框中直接选择。
[base 组合](../../../../packages/bundle/base/cordis.patch.yml)设置 `fetchProvider: http`,不设置 `searchProvider`。没有配置搜索提供方时,`dsh-web` 按搜索所服务的模型请求的提供方路由,优先选用一个已注册且可用的提供方:在 `deepseek-official` 与 `deepseek-account` 模型路由上是 Messages 搜索(`deepseek-official`),因为 DeepSeek 不对 DeepSeek 模型请求声明的服务端搜索工具按次收费;在其他路由上以及模型请求之外是 Search API(`deepseek-search-api`),因为它返回来源时无需向会话没有使用的提供方发起辅助模型请求。`dsh-tool-web` 把发起调用的 Session 最近一次模型请求的路由写入每个搜索请求,`searchReady()` 按正在准备的步骤的路由选择,因此就绪判断与执行指向同一个提供方。这两条路由和两个提供方 id 是 `dsh-web` 中的常量:部署只能通过配置 `searchProvider` 改变结果,设置页把未配置的状态显示为**自动选择**。抓取默认使用本地 HTTP 抓取,因为它没有按次的 API 费用,执行 Harness 自身的 URL 校验和资源限制,并且可以访问内网和本地地址。Fetch API 仍可在下拉框中直接选择。
已保存的选择——无论位于设置文档还是部署自身的组合中——优先于内置默认值,升级不会改写它。执行时从不替换选择:所选提供方缺失、不可用或失败时,操作以结构化错误失败,不会回退到其他搜索或抓取提供方。回退会把查询和凭据发往用户未选择的端点,并在不提示的情况下改变计费。
### 旧版 Messages 搜索
DeepSeek Messages 搜索提供方仍以 **DeepSeek(旧版)**提供。已保存的 `web.searchProvider: deepseek-official`(或 `DSH_WEB_SEARCH_PROVIDER=deepseek-official`)会选中它,因此网关支持 Messages 搜索但不提供 `/v1/tools` 的用户可以保留可用的提供方。
DeepSeek Messages 搜索提供方仍以 **DeepSeek 服务端搜索**提供,并承担 DeepSeek 模型路由上未配置提供方的搜索。已保存的 `web.searchProvider: deepseek-official`(或 `DSH_WEB_SEARCH_PROVIDER=deepseek-official`)会在所有路由上选中它,因此网关支持 Messages 搜索但不提供 `/v1/tools` 的用户可以保留可用的提供方。
Messages 提供方负责声明并写入 `web/deepseek-search-llm-request`。声明和载荷保持与已发布会话兼容;Search 与 Fetch API 包既不声明也不写入这一辅助事件。
## 考虑过的替代方案
**让每个提供方声明自己是哪些路由的默认项。** 在 `WebSearchProvider` 上加一个 `defaultFor(llmProvider)` 成员可以让 `dsh-web` 不含 DeepSeek 的 id,但要为只有一个实例的规则修改两个 DeepSeek 提供方包。
**把路由到提供方的表放进 `dsh-web` 的配置。** profile 补丁会替换条目的整个 `config`,因此已存的提供方选择会连带存下这张表的副本,不再跟随内置的表;而这张表也不是用户需要做的选择:固定提供方已经可以覆盖它。
**让 Search API 提供方在 DeepSeek 路由上转交给 Messages 搜索。** 菜单可以保持两项,但名为 DeepSeek Search API 的条目会运行另一个提供方,用户无法为 DeepSeek 模型固定 Search API,而且一个提供方包要依赖另一个。
**保留一个同时切换两个 API 的开关。** 它让使用 Fetch API 无需修改配置,但把抓取的计费和目标访问策略绑在搜索选择上,也无法表达其他插件注册的提供方。
**按可用性过滤列表,或在每个条目中加入可用性。** 过滤后的列表恰好会在凭据缺失时隐藏提供方,而这正是用户需要选择并配置它的时候。可用性还取决于请求的模型路由和凭据状态,列表中的布尔值可能与实际执行结果不一致。已归档的[观察面决策](../../archived/simplification/2026-07-04-drop-unconsumed-web-observation-surface.md)只允许引入消费方实际读取的最小信号;下拉框只读取注册情况。
@@ -76,10 +82,10 @@ Messages 提供方负责声明并写入 `web/deepseek-search-llm-request`。声
## 影响
没有已保存搜索选择的用户通过 Search API 搜索:查询发往会话的 DeepSeek 凭据所选的 Search 端点,每次计为一次 Search API 请求,并且除非关闭 `sendOriginalQuestion`,还会把最近一条用户提示的至多 128 个字符作为 `ori_question` 发送。网关没有 `/v1/tools` 路由的部署会遇到搜索失败,直到选择 Messages 搜索,或把 `searchBaseURL` 设为提供这些路由的基础地址。已保存的 `deepseek-official` 选择使用 Messages 搜索。没有已保存抓取选择的用户通过本地 HTTP 抓取。已登录但没有 API 密钥的用户在 `auto` 计费下,除 DeepSeek API 密钥路由上的会话外,都可以使用 DeepSeek 网页搜索;[升级指南](../../../../docs/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.zh.md)列出了每种受影响的配置。
没有已保存搜索选择的用户在 DeepSeek 模型路由上的会话中通过 Messages 搜索进行搜索:每次搜索是一次按模型 token 计费的辅助 Messages 请求,发往 Messages 搜索自己的端点,该端点不跟随模型提供方的基础地址,因此 DeepSeek 模型提供方指向网关的部署会遇到搜索失败,直到把该网关保存为 Messages Base URL 或固定使用 Search API([升级指南](../../../../docs/upgrade-guide/v0.2.2-rc.4/web-search-deepseek-model-default/guide.zh.md))。在其他路由上他们通过 Search API 搜索:查询发往会话的 DeepSeek 凭据所选的 Search 端点,每次计为一次 Search API 请求,并且除非关闭 `sendOriginalQuestion`,还会把最近一条用户提示的至多 128 个字符作为 `ori_question` 发送。网关没有 `/v1/tools` 路由的部署在这些路由上会遇到搜索失败,直到选择 Messages 搜索,或把 `searchBaseURL` 设为提供这些路由的基础地址。`dsh-web` 点名了两条 DeepSeek 模型路由和两个 DeepSeek 搜索提供方,再出现一个按路由的默认值时须改为提供方无关的规则。已保存的 `deepseek-official` 选择使用 Messages 搜索。没有已保存抓取选择的用户通过本地 HTTP 抓取。已登录但没有 API 密钥的用户在 `auto` 计费下,除 DeepSeek API 密钥路由上的会话外,都可以使用 DeepSeek 网页搜索;[升级指南](../../../../docs/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.zh.md)列出了每种受影响的配置。
插件提供方(包括在创作模式下编写的提供方)一经注册,就会以其 `title` 出现在对应的下拉框中。下拉框可能提供在当前请求中无法运行的提供方;失败会在执行搜索或抓取时出现。每次注册表变更会在每个观察它的 Client 中产生一次转发事件和一次列表读取。
## 验证
[web.spec.ts](../../../../packages/web/web/tests/web.spec.ts) 覆盖列表内容与顺序、标题、注册与撤销后的事件、重复注册被拒绝时不触发事件,以及监听器失败的隔离。[deepseek.spec.ts](../../../../packages/web/web-search-deepseek/tests/deepseek.spec.ts) 覆盖独立的 Messages 提供方,[credential-resolution.spec.ts](../../../../packages/web/web-deepseek-api/tests/credential-resolution.spec.ts) 针对两个能力覆盖账号路由上的账号令牌及其在 HTTP 401 后被作废、未登录时回退到 API 密钥、官方、非 DeepSeek 和会话之外的操作使用路由密钥与端点、DeepSeek 路由之外没有密钥时回退到账号、在每个路由上只用账号或只用 API 密钥的计费、单独字段优先于计费方式、没有该路由时使用 `DEEPSEEK_API_KEY` 与官方基础地址、从不发送令牌的 YAML 单独字段、两个能力相互独立、就绪判断与每次操作一致,以及被忽略的已移除字段;[composition.spec.ts](../../../../packages/web/web-deepseek-api/tests/composition.spec.ts) 通过 Loader 启动真实的模型路由。[remote-events.host.spec.ts](../../../../packages/api/remotes/tests/remote-events.host.spec.ts) 覆盖事件转发,[base.spec.ts](../../../../packages/bundle/base/tests/base.spec.ts) 固定内置默认值。设置页的 controller 与 card 测试以及[插件配置浏览器场景](../../../../apps/web/tests/plugin-config.e2e.ts)覆盖下拉框内容、Search 与 Fetch 的分别选择、DeepSeek API 的计费方式下拉框,以及各提供方保留的设置。
[web.spec.ts](../../../../packages/web/web/tests/web.spec.ts) 覆盖列表内容与顺序、标题、注册与撤销后的事件、重复注册被拒绝时不触发事件、监听器失败的隔离,以及按路由的优先规则及其回退;[tool-web.spec.ts](../../../../packages/web/tool-web/tests/tool-web.spec.ts) 覆盖 `web_search` 发送的路由,`web-search-legacy-endpoint-guidance` 快照在未配置提供方的 DeepSeek 路由上运行 Messages 搜索。[deepseek.spec.ts](../../../../packages/web/web-search-deepseek/tests/deepseek.spec.ts) 覆盖独立的 Messages 提供方,[credential-resolution.spec.ts](../../../../packages/web/web-deepseek-api/tests/credential-resolution.spec.ts) 针对两个能力覆盖账号路由上的账号令牌及其在 HTTP 401 后被作废、未登录时回退到 API 密钥、官方、非 DeepSeek 和会话之外的操作使用路由密钥与端点、DeepSeek 路由之外没有密钥时回退到账号、在每个路由上只用账号或只用 API 密钥的计费、单独字段优先于计费方式、没有该路由时使用 `DEEPSEEK_API_KEY` 与官方基础地址、从不发送令牌的 YAML 单独字段、两个能力相互独立、就绪判断与每次操作一致,以及被忽略的已移除字段;[composition.spec.ts](../../../../packages/web/web-deepseek-api/tests/composition.spec.ts) 通过 Loader 启动真实的模型路由。[remote-events.host.spec.ts](../../../../packages/api/remotes/tests/remote-events.host.spec.ts) 覆盖事件转发,[base.spec.ts](../../../../packages/bundle/base/tests/base.spec.ts) 固定内置默认值。设置页的 controller 与 card 测试以及[插件配置浏览器场景](../../../../apps/web/tests/plugin-config.e2e.ts)覆盖下拉框内容、Search 与 Fetch 的分别选择、DeepSeek API 的计费方式下拉框,以及各提供方保留的设置。
@@ -9,14 +9,11 @@
en: 6938aa715106bb99
zh: ea1497b337712f33
/agent-note-session-workspace-root/decision:
en: b42597fdf9838587
zh: cb36853abde00754
/agent-note-session-workspace-root/deferred:
en: 8807b3829badfdcd
zh: 2ec10ce7f0dda3f4
en: 0b07db6326c2ecd6
zh: 19ba9a1adf93af1f
/agent-note-session-workspace-root/alternatives-considered:
en: 35ccc31b8b40d014
zh: 7bf3c9f45afae8ab
en: 8a4859a6f96ef49e
zh: fa7088d29ebe3dd6
/agent-note-session-workspace-root/consequences:
en: 7cef9fcd81f95833
zh: 4211d4ae53dd4974
en: a6bf8aa40464f524
zh: 61997dc31615bdbb
@@ -16,9 +16,9 @@ A Session works in one directory, and only Host operations move it. The model-fa
Worktree creation enters the checkout through `set`. The model has one tool for entering a checkout, `enter_worktree`: a name selects a worktree inside the pool of the checkout the Session works in. An existing one is entered through `ctx.worktrees.enter`, and a new one is created through `ctx.worktrees.create` when none has that name. The name cannot leave that pool, so the model still cannot choose an arbitrary directory. `ctx.worktrees.exit`, exposed as `exit_worktree`, returns the Session from the recorded worktree that contains its directory to the checkout it created or entered that worktree from. A child subagent keeps the parent's original project in its header and starts, through `set`, in the parent's directory or a Host-chosen directory.
## Deferred
Every consumer reads that directory. The model's file, search, and process tools resolve relative paths from it, and everything the user sees or that describes the project is bounded by it: the sandbox `workspace-write` boundary, the workspace file service and desktop file drag, the change recorder, the Files tree, deliverables, open-in-app actions and Session rows, new sidebar terminals, `@` file candidates, the skill catalog, project-instruction discovery, and the LSP workspace.
The sandbox write boundary, the workspace file service, desktop file drag, the change recorder, and the client file tree, deliverables, open-in-app actions, and Session rows still read `header.cwd`. Until those consumers read the Session's directory, they behave as they did before this decision, and a worktree outside the original project is writable only where the original project's boundary already allows it.
The sandbox policy reads no Git layout: it bounds a Session by its directory and adds only the directories the deployment configured or a Host plugin registered for that Session through `registerWritableRoot`. A repository's Git directory lies outside a linked worktree, so after a move into a worktree a Git command that writes it, such as `git commit`, is denied under `workspace-write` until a grant covers that directory; the original project is not writable either. Granting the Git directory of the checkout a Session works in belongs to a separate plugin that reads the Git layout and registers the directory, which this decision defers. Host maintenance of a checkout the Session does not work in keeps the original boundary: removing a worktree on archive, restoring a removed one, and reading its branch in the source repository run under a policy the worktree service and the forge panel build themselves, the Session's mode and grants with the recorded source checkout as the root. The Session's own root may be the removed directory, and a process sandbox cannot bind a missing or vanishing root.
## Alternatives considered
@@ -40,10 +40,10 @@ The sandbox write boundary, the workspace file service, desktop file drag, the c
**Two public reads.** `get` for relative paths beside `rootOf` for the workspace root kept every stored directory, and made each consumer choose between two values that are equal in every Session started from this version on. One read removes that choice.
**Keep every stored directory.** Reading every stored `working-directory/change` as the directory would let a stored model `cd`, including one to a home directory, become the write boundary once consumers follow the directory.
**Keep every stored directory.** Reading every stored `working-directory/change` as the directory would let a stored model `cd`, including one to a home directory, become the write boundary, because consumers follow the directory.
**Keep stored directories inside the original project.** A Session that entered a worktree would resume there, but the rule cannot tell a worktree from a `cd`: a stored `cd` into a subdirectory would narrow the write boundary and the file views, and a worktree outside the directory a Session was opened in would be dropped.
## Consequences
Consumers read one directory through `get`. A stored Session resumes in its original project whatever directory its `working-directory/change` events recorded, and follows Host moves from there. One that worked in a worktree returns to it through `enter_worktree`; until then its relative paths resolve in the original project. The model enters a checkout only through `enter_worktree`: a new one, or a registered one in the pool. A checkout elsewhere needs a Host operation. The ACP, SDK, and Web producers record the original project by its canonical spelling, so a Host move back to it records no change. The worktree snapshot fixture covers entering, leaving, and losing a worktree. Moving the consumers listed under Deferred is a separate change.
Consumers read one directory through `get`. A stored Session resumes in its original project whatever directory its `working-directory/change` events recorded, and follows Host moves from there. One that worked in a worktree returns to it through `enter_worktree`; until then its relative paths resolve in the original project. The model enters a checkout only through `enter_worktree`: a new one, or a registered one in the pool. A checkout elsewhere needs a Host operation. The ACP, SDK, and Web producers record the original project by its canonical spelling, so a Host move back to it records no change. A Session that works in a linked worktree, whether it entered one or was opened in one, cannot run `git commit` under `workspace-write` without a grant for the repository's Git directory; on the previous boundary a Session that entered a worktree inside its project could. An SDK `setWorkingDirectory` call and a child started in a Host-chosen directory move the `workspace-write` boundary with the directory. The worktree snapshot fixture covers entering, leaving, and losing a worktree.
@@ -16,9 +16,9 @@ Status: implemented
工作树创建通过 `set` 进入检出目录。模型只有一个进入检出的工具 `enter_worktree`:名称在 Session 所在检出的池中选中一个工作树。已有的工作树通过 `ctx.worktrees.enter` 进入,没有同名工作树时通过 `ctx.worktrees.create` 新建。名称无法离开该池,因此模型仍然不能选择任意目录。`ctx.worktrees.exit` 以 `exit_worktree` 的形式提供,它找到包含 Session 目录的已记录工作树,把 Session 送回创建或进入该工作树时所在的检出。子代理的 header 保留父级的原始项目,并通过 `set` 从父级的目录或 Host 选定的目录启动。
## Deferred
每个消费方都读取这个目录。模型的文件、搜索与进程工具从它解析相对路径,用户看到的、以及描述项目的一切都以它为界:沙箱 `workspace-write` 边界、工作区文件服务与桌面文件拖拽、变更记录器、文件树、交付物、在应用中打开操作与 Session 行、新开的侧栏终端、`@` 文件候选、技能目录、项目指令发现和 LSP 工作区。
沙箱写边界、工作区文件服务、桌面文件拖拽、变更记录器,以及客户端文件树、交付物、在应用中打开的操作和 Session 行仍然读取 `header.cwd`。在这些消费方改读 Session 的目录之前,它们的行为与本决策之前相同,位于原始项目之外的工作树只有在原始项目的边界已经允许时才可写。
沙箱策略不读取任何 Git 布局:它以 Session 的目录为界,只加入部署配置的目录,以及 Host 插件通过 `registerWritableRoot` 为该 Session 注册的目录。仓库的 Git 目录位于链接工作树之外,因此移入工作树之后,写入它的 Git 命令(例如 `git commit`)在 `workspace-write` 下会被拒绝,直到有授权覆盖该目录;原始项目也不再可写。为 Session 所在检出目录授权其 Git 目录,属于一个读取 Git 布局并注册该目录的独立插件,本决策将其延后。Host 对 Session 并不在其中工作的检出目录做维护时保留原来的边界:归档时移除 worktree、恢复被删除的 worktree、在源仓库中读取其分支,都在 worktree 服务与 forge 面板自己构造的策略下运行,即沿用 Session 的模式与授权、以记录中的源检出目录为根。Session 自身的根可能正是被删除的目录,而进程沙箱无法绑定缺失或正在消失的根。
## Alternatives considered
@@ -40,10 +40,10 @@ Status: implemented
**两个公开读取接口。** 用 `get` 读相对路径的基准、用 `rootOf` 读工作区根,可以保留每个已存储的目录,但每个消费方都要在两个值之间做选择,而这两个值在从这个版本起启动的每个 Session 中都相等。只保留一个读取接口,就不需要这种选择。
**保留每个已存储的目录。** 把每条已存储的 `working-directory/change` 都读作目录,消费方跟随目录之后,已存储的模型 `cd`(包括进入用户主目录的)会成为写边界。
**保留每个已存储的目录。** 把每条已存储的 `working-directory/change` 都读作目录,由于消费方跟随目录,已存储的模型 `cd`(包括进入用户主目录的)会成为写边界。
**保留原始项目之内的已存储目录。** 进入过工作树的 Session 会在工作树中恢复,但这条规则分不清工作树与 `cd`:已存储的进入子目录的 `cd` 会收窄写边界和文件视图,而位于 Session 打开目录之外的工作树会被丢弃。
## Consequences
消费方通过 `get` 读取一个目录。无论 `working-directory/change` 事件记录了什么目录,已存储的 Session 都在原始项目中恢复,并从那里跟随 Host 移动。曾在工作树中工作的 Session 通过 `enter_worktree` 回到工作树;在此之前,它的相对路径在原始项目中解析。模型只能通过 `enter_worktree` 进入检出:新建的检出,或池中已登记的检出。其他位置的检出需要 Host 操作。ACP、SDK 与 Web 的生产方以规范拼写记录原始项目,因此 Host 移回原始项目时不记录变更。工作树快照夹具覆盖进入、离开和失去工作树。迁移 Deferred 中列出的消费方是另一项变更。
消费方通过 `get` 读取一个目录。无论 `working-directory/change` 事件记录了什么目录,已存储的 Session 都在原始项目中恢复,并从那里跟随 Host 移动。曾在工作树中工作的 Session 通过 `enter_worktree` 回到工作树;在此之前,它的相对路径在原始项目中解析。模型只能通过 `enter_worktree` 进入检出:新建的检出,或池中已登记的检出。其他位置的检出需要 Host 操作。ACP、SDK 与 Web 的生产方以规范拼写记录原始项目,因此 Host 移回原始项目时不记录变更。在链接工作树中工作的 Session,无论是进入的还是直接在其中打开的,在没有仓库 Git 目录授权时都不能在 `workspace-write` 下运行 `git commit`;在此前的边界下,进入项目内工作树的 Session 可以。SDK 的 `setWorkingDirectory` 调用以及在 Host 选定目录启动的子代理,会让 `workspace-write` 边界随目录一起移动。工作树快照夹具覆盖进入、离开和失去工作树。
@@ -12,8 +12,8 @@
en: 5d2dc730467e4bf3
zh: 4aca28691504cd7b
/agent-note-change-request-panel-and-worktree-sessions/deferred:
en: 32ef8af85f4d2f66
zh: b82b67f94346399e
en: e76e8129691db30f
zh: fd242e67bab2633d
/agent-note-change-request-panel-and-worktree-sessions/alternatives-considered:
en: e471e16b6b6450ca
zh: 5fbc9242edc8d112
@@ -32,12 +32,7 @@ Review comments capture the file, side, range, complete hunk, and reviewed head
## Deferred
A left-navigation review page next to Plugins and Scheduled tasks, listing the user's pull requests or merge requests on the selected provider, is deferred. It attaches without changing this package's Session surfaces:
- **Provider capability** — an optional `ForgeProvider` method such as `listForViewer(host, filter, signal)` returns change request references; GitHub implements it with `gh search prs --author @me` or the GraphQL `viewer`, and the registry aggregates enabled providers.
- **Remote** — a stream like `follow` that is keyed by provider and filter instead of a Session and polls through the same `ctx.forge.watch`.
- **Client** — a `sidebar.panellist` entry with a `main` page in this package, as `ui-schedule` does, rendering `ChangeRequestCard`, which takes a change request, its snapshot, and optional actions.
- **Settings** — provider choice and hosts on the bundle's configuration page.
The left-navigation review page this section deferred is implemented as the [code review page](2026-11-11-forge-review-page.md); its lists come from an optional provider capability and its page reads change requests by URL, so this package's Session surfaces did not change.
The changes view offers no scope for one commit or for the last turn yet; both would be further `ForgeLocalScope` kinds read through `localDiff`.
@@ -32,12 +32,7 @@ Session 所在的 worktree 可能在 Session 之外被删除。每次检查都
## Deferred
在左侧导航“插件”“自动化任务”旁边新增代码审查页、列出用户在所选提供方上的 pull request 或 merge request,这项工作推迟。它的接入不需要改动本包面向 Session 的界面:
- **提供方能力**——`ForgeProvider` 增加一个可选方法,例如 `listForViewer(host, filter, signal)`,返回变更请求引用;GitHub 用 `gh search prs --author @me` 或 GraphQL `viewer` 实现,注册表汇总已启用的提供方。
- **Remote**——一条类似 `follow` 的流,以提供方与筛选条件而不是 Session 为键,通过同一个 `ctx.forge.watch` 轮询。
- **客户端**——在本包中以 `sidebar.panellist` 条目加一个 `main` 页面实现(与 `ui-schedule` 相同),渲染接收变更请求、其快照与可选操作的 `ChangeRequestCard`。
- **设置**——在套件的配置页中选择提供方与主机。
本节曾暂缓的左侧导航代码审查页已实现为[代码评审页](2026-11-11-forge-review-page.zh.md);它的列表来自可选的提供方能力,页面按 URL 读取变更请求,因此本包的会话界面没有改变。
变更视图目前还没有单个提交与上一轮的范围;两者将是经 `localDiff` 读取的更多 `ForgeLocalScope` 种类。
@@ -12,8 +12,8 @@
en: 43298ccae4f7a6d4
zh: eb7ef46b6f290c15
/agent-note-direct-deepseek-search-and-fetch-apis/decision/protocol-selection-and-deployment:
en: 90e5031d0d2fa9e4
zh: a9c0229b20555d9e
en: b07c0667e25927aa
zh: 45eda3e151040201
/agent-note-direct-deepseek-search-and-fetch-apis/decision/search-results-and-model-input:
en: ad7b3e4fbe528cf2
zh: 8ab8779bfdaaa4fa
@@ -21,14 +21,14 @@
en: 7566e400f9ab3a51
zh: 118b2e84d0030480
/agent-note-direct-deepseek-search-and-fetch-apis/decision/default-migration:
en: cb2f0910955b6730
zh: 7df057048acd7858
en: 9b1e46885451ada3
zh: 0deab76a188294dd
/agent-note-direct-deepseek-search-and-fetch-apis/decision/legacy-messages-search:
en: 0dcc97d8105fab60
zh: d80d40ae3a0c601d
/agent-note-direct-deepseek-search-and-fetch-apis/alternatives-considered:
en: e377ad3c0327300e
zh: 4b9f7f83f464e657
en: da027a3c18b4fa0a
zh: a3f0f448a0cae63f
/agent-note-direct-deepseek-search-and-fetch-apis/consequences:
en: 7ec21c5b1124e5f8
zh: af769dbdb4face9f
@@ -14,7 +14,7 @@ The [DeepSeek Search and Fetch guide](https://api-docs.deepseek.com/zh-cn/guides
### Protocol selection and deployment
The APIs register as `deepseek-search-api` and `deepseek-fetch-api`. Messages search remains separately registered as `deepseek-official`. The web service selects each provider through `web.searchProvider` and `web.fetchProvider`, which the Search and Fetch menus on the Web search and fetch page set independently; the shipped composition selects the Search API and local HTTP fetch, as the [selection decision](../architecture/2026-10-29-web-provider-selection.md) records. A saved selection takes effect on the next operation because the web service reads both selections per operation. Each operation resolves one settings snapshot, including its endpoint and credential. Both APIs read the `web-deepseek-api` namespace, and each capability resolves its own endpoint and credential.
The APIs register as `deepseek-search-api` and `deepseek-fetch-api`. Messages search remains separately registered as `deepseek-official`. The web service selects each provider through `web.searchProvider` and `web.fetchProvider`, which the Search and Fetch menus on the Web search and fetch page set independently; the shipped composition selects local HTTP fetch and no search provider, which runs the Search API outside the DeepSeek model routes, as the [selection decision](../architecture/2026-10-29-web-provider-selection.md) records. A saved selection takes effect on the next operation because the web service reads both selections per operation. Each operation resolves one settings snapshot, including its endpoint and credential. Both APIs read the `web-deepseek-api` namespace, and each capability resolves its own endpoint and credential.
Direct retrieval appends `/search` or `/fetch` to an API base. A capability without its own YAML endpoint fields uses the origin of the conversation's DeepSeek model route base URL with `/v1/tools`, which for the public deployment is the guide's `https://api.deepseek.com/v1/tools`; the [selection decision](../architecture/2026-10-29-web-provider-selection.md) owns that derivation and the credential each operation sends. The verified development base is `http://api-dev.deepseek.com:8031/api/v1/tools`; its prefix differs and is never inferred from the hostname, so such a deployment sets the complete base in `searchBaseURL` or `fetchBaseURL`. An unparseable base leaves that capability's provider unavailable.
@@ -36,7 +36,7 @@ The HTTP provider retains its own URL validation and resource limits. Selecting
### Default migration
The shipped composition selects `deepseek-search-api`; the [selection decision](../architecture/2026-10-29-web-provider-selection.md) owns that default and its no-fallback rule. API keys and account tokens both reach the public routes. Deployments behind a gateway without `/v1/tools` routes set `searchBaseURL` to a base that serves them. A stored `web.searchProvider: deepseek-official` selects Messages search, and any other stored selection keeps its provider.
The shipped composition fixes no search provider: a search runs Messages search for a model request on a DeepSeek model route and `deepseek-search-api` on every other route; the [selection decision](../architecture/2026-10-29-web-provider-selection.md) owns that default and its no-fallback rule. API keys and account tokens both reach the public routes. Deployments behind a gateway without `/v1/tools` routes set `searchBaseURL` to a base that serves them. A stored `web.searchProvider: deepseek-official` selects Messages search, and any other stored selection keeps its provider.
### Legacy Messages search
@@ -48,7 +48,7 @@ The independent `dsh-web-search-deepseek` provider sends Messages search request
**Reuse the Messages address or infer a route prefix.** The protocols and deployed prefixes differ. Separate bases preserve existing configurations and avoid sending a valid request to the wrong route.
**Require an explicit Search API base.** The Search API is the shipped search default, and an empty default would leave it unavailable until every user enters an address that the DeepSeek model route already determines. Other deployments still set their own base.
**Require an explicit Search API base.** The Search API is the shipped search default outside the DeepSeek model routes, and an empty default would leave it unavailable until every user enters an address that the DeepSeek model route already determines. Other deployments still set their own base.
**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.
@@ -14,7 +14,7 @@ Status: implemented
### 协议选择与部署
两个 API 注册为 `deepseek-search-api` 和 `deepseek-fetch-api`;Messages 搜索仍独立注册为 `deepseek-official`。Web 服务通过 `web.searchProvider` 和 `web.fetchProvider` 选择各个提供方,「网页搜索与获取」页上的 Search 和 Fetch 下拉框分别设置这两项;内置组合选择 Search API 与本地 HTTP 抓取,见[选择决策](../architecture/2026-10-29-web-provider-selection.zh.md)。已保存的选择从下一次操作起生效,因为 Web 服务在每次操作时读取两项选择。每次操作解析一份包含端点和凭据的设置快照。两个 API 读取 `web-deepseek-api` namespace,每个能力各自解析端点与凭据。
两个 API 注册为 `deepseek-search-api` 和 `deepseek-fetch-api`;Messages 搜索仍独立注册为 `deepseek-official`。Web 服务通过 `web.searchProvider` 和 `web.fetchProvider` 选择各个提供方,「网页搜索与获取」页上的 Search 和 Fetch 下拉框分别设置这两项;内置组合选择本地 HTTP 抓取,不选择搜索提供方,此时 DeepSeek 模型路由之外的搜索使用 Search API,见[选择决策](../architecture/2026-10-29-web-provider-selection.zh.md)。已保存的选择从下一次操作起生效,因为 Web 服务在每次操作时读取两项选择。每次操作解析一份包含端点和凭据的设置快照。两个 API 读取 `web-deepseek-api` namespace,每个能力各自解析端点与凭据。
直接检索在 API 基础地址后追加 `/search` 或 `/fetch`。没有在 YAML 中单独设置端点字段的能力,使用会话的 DeepSeek 模型路由基础地址的 origin 加 `/v1/tools`,公网部署即指南中的 `https://api.deepseek.com/v1/tools`;该推导及每次操作发送的凭据由[选择决策](../architecture/2026-10-29-web-provider-selection.zh.md)负责。已验证的开发地址为 `http://api-dev.deepseek.com:8031/api/v1/tools`;其前缀不同,程序不会根据主机名推断,此类部署需在 `searchBaseURL` 或 `fetchBaseURL` 中填写完整基础地址。基础地址无法解析时,该能力的提供方不可用。
@@ -36,7 +36,7 @@ HTTP 提供方继续负责自身的 URL 校验和资源限制。选择 DeepSeek
### 默认值迁移
内置组合选择 `deepseek-search-api`;[选择决策](../architecture/2026-10-29-web-provider-selection.zh.md)负责这项默认值及其不回退规则。API 密钥和账号 token 都能访问公网路由。位于没有 `/v1/tools` 路由的网关之后的部署,需把 `searchBaseURL` 设为提供这些路由的基础地址。已保存的 `web.searchProvider: deepseek-official` 会选中 Messages 搜索,其他已保存的选择保持其提供方。
内置组合不固定搜索提供方:为 DeepSeek 模型路由上的模型请求发起的搜索运行 Messages 搜索,其他路由上的搜索运行 `deepseek-search-api`;[选择决策](../architecture/2026-10-29-web-provider-selection.zh.md)负责这项默认值及其不回退规则。API 密钥和账号 token 都能访问公网路由。位于没有 `/v1/tools` 路由的网关之后的部署,需把 `searchBaseURL` 设为提供这些路由的基础地址。已保存的 `web.searchProvider: deepseek-official` 会选中 Messages 搜索,其他已保存的选择保持其提供方。
### 旧版 Messages 搜索
@@ -48,7 +48,7 @@ HTTP 提供方继续负责自身的 URL 校验和资源限制。选择 DeepSeek
**复用 Messages 地址或推断路由前缀。** 协议与部署前缀不同。分别保存基础地址可保留现有配置,避免把有效请求发往错误路由。
**要求显式填写 Search API 基础地址。** Search API 是内置的搜索默认值,空默认值会让它在每位用户填写一个 DeepSeek 模型路由已经确定的地址之前都不可用。其他部署仍可设置自己的基础地址。
**要求显式填写 Search API 基础地址。** Search API 是 DeepSeek 模型路由之外内置的搜索默认值,空默认值会让它在每位用户填写一个 DeepSeek 模型路由已经确定的地址之前都不可用。其他部署仍可设置自己的基础地址。
**把两个 API 放在 Messages 提供方内部,由提供方自己的开关切换。** Messages 提供方内的开关无法改变抓取路由,因此除非用户另外修改 `web.fetchProvider`,`web_fetch` 仍会走 HTTP;它还会把两个 API 的生命周期绑在 Messages 搜索上。独立注册让 Web 服务通过现有的提供方选择机制选择各个提供方,不会把任一 API 与 Messages 提供方绑定。
@@ -0,0 +1,19 @@
# Bilingual-pair consistency record for 2026-11-11-forge-review-page.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/feature/2026-11-11-forge-review-page.md
/agent-note-code-review-page:
en: 88e0f71d0da6eda5
zh: ff17f12fd505c772
/agent-note-code-review-page/problem:
en: ad1da0c97cfc9c2d
zh: f4420c0b004fd189
/agent-note-code-review-page/decision:
en: b0ba35d7c5818dc3
zh: 5414ec6190be0726
/agent-note-code-review-page/alternatives-considered:
en: 963b1be39a0e4bac
zh: 940b86a5e2036477
/agent-note-code-review-page/consequences:
en: c17a96adbec69d92
zh: 06b5f2c28a9ec331
@@ -0,0 +1,31 @@
# Agent Note: Code review page
Status: implemented
English | [中文](2026-11-11-forge-review-page.zh.md)
## Problem
The [forge panel](2026-10-09-forge-panel.md) shows the change requests one Session created or pushed. A reviewer also needs the change requests that ask for their review, that they created, or that involve them, read and reviewed without first finding or creating the Session that owns them, and a conversation with the Agent about one of them that does not mix into an unrelated existing conversation.
## Decision
A left-navigation Code review page in [`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.md) lists three viewer lists and shows one change request in full.
- **Lists** — an optional `ForgeProvider` capability (`viewer`, `listForViewer`, `countForViewer`) returns summaries of open change requests; GitHub answers each list with one GraphQL search, because one document with several searches times out. The Host reads the lists only while a page or count stream lasts, outside the forge's status polling, since a batch snapshot of dozens of change requests exceeds GitHub's query timeout; only the shown change request is polled through `ForgeService.watch`.
- **Reads by URL** — the page's `forgePanel/review*` methods name a change request by URL and no Session; they share the Session-bound methods' implementation and are reachable only by callers that may use the Host's code host credentials.
- **Description** — `readDescription` returns the Markdown body, labels, and signed addresses for private attachments, which the page substitutes before rendering with HTML omitted.
- **Changes** — the page draws the changes view itself, split from the right-sidebar tab, with a panel state that holds only the shown change request; plugin lenses, annotations, and slots stay with the Session tab, whose extension points name a Session.
- **Chat** — the chat tab embeds `conversation.content` for the blank Session `connectWorkspace` resolves in the Workspace named like the repository, and never offers an existing conversation. A Workspace picked in the Hero is handled by the page, as every owner of the content handles its own picks: the page connects that Workspace's blank and shows it in the chat tab, where the main Conversation opens it as the main Session. The change request is bound when the Session's first message enters its inbox, so a blank that is never used stays unbound.
- **Hosts** — the page lists every configured host together; choosing among hosts and accounts waits for a second provider that lists change requests.
## Alternatives considered
- **A Session per change request for reading** — rejected: reading the description or the diff would create Sessions nobody converses in, and bind them.
- **Reviewing in an existing conversation** — rejected by the user: the conversation's context would mix with the review.
- **Listing through the status poller** — rejected: the batch snapshot query times out at the list sizes a reviewer has.
- **Binding when the chat opens** — rejected: the blank Session is shared with New Session, so it would carry the binding into an unrelated conversation.
## Consequences
The forge registry gains a fifth optional capability family and a `rate-limited` failure code, recorded in the [upgrade guide](../../../../docs/upgrade-guide/v0.2.2-rc.4/forge-rate-limited-failure/guide.md). A Host restart before the chat's first message forgets the staged binding.
@@ -0,0 +1,31 @@
# Agent Note: 代码评审页
Status: implemented
[English](2026-11-11-forge-review-page.md) | 中文
## Problem
[forge 面板](2026-10-09-forge-panel.zh.md)显示一个会话创建或推送的变更请求。评审者还需要请自己评审的、自己创建的以及与自己有关的变更请求,不必先找到或创建拥有它们的会话就能阅读和评审;也需要就其中一个与 Agent 对话,而且这段对话不能混进无关的已有对话。
## Decision
[`dsh-experimental-client-ui-forge`](../../../../packages/experimental/client-ui-forge/README.zh.md) 在左侧导航中加入“代码评审”页,列出三个登录用户列表,并完整显示一个变更请求。
- **列表**——可选的 `ForgeProvider` 能力(`viewer`、`listForViewer`、`countForViewer`)返回未关闭变更请求的摘要;GitHub 每个列表用一次 GraphQL 搜索回答,因为在一个文档中放多个搜索会超时。Host 只在页面流或计数流存在时读取列表,不经过 forge 的状态轮询,因为几十个变更请求的批量快照会超过 GitHub 的查询时限;只有显示中的变更请求经 `ForgeService.watch` 轮询。
- **按 URL 读取**——页面的 `forgePanel/review*` 方法以 URL 而不是会话指定变更请求;它们与会话绑定的方法共用实现,只有可以使用 Host 代码托管凭据的调用方能访问。
- **描述**——`readDescription` 返回 Markdown 正文、标签以及私有附件的签名地址,页面替换这些地址后以省略 HTML 的方式渲染。
- **变更**——页面自己绘制变更视图(从右侧栏标签中拆出),面板状态只含显示中的变更请求;插件的透镜、行注释和插槽仍只在会话标签中,因为这些扩展点以会话为对象。
- **对话**——对话标签为 `connectWorkspace` 在与仓库同名的工作区中解析出的空白会话嵌入 `conversation.content`,从不提供已有对话。在 Hero 中选择工作区由页面自己处理,这与内容的每个属主处理各自的选择一致:页面连接该工作区的空白会话并在对话标签中显示它,而主 Conversation 会把它打开为主会话。该会话的首条消息进入收件箱时才绑定变更请求,因此从未使用的空白会话保持未绑定。
- **主机**——页面把所有已配置的主机合并列出;在主机与账号之间选择要等到第二个能列出变更请求的提供方。
## Alternatives considered
- **每个变更请求用一个会话来阅读**——否决:阅读描述或 diff 会创建无人对话的会话并绑定它们。
- **在已有对话中评审**——用户否决:对话上下文会与评审混在一起。
- **经状态轮询列出**——否决:在评审者常见的列表规模下,批量快照查询会超时。
- **打开对话时就绑定**——否决:空白会话与“新会话”共用,会把绑定带进无关的对话。
## Consequences
forge 注册表增加第五组可选能力和 `rate-limited` 失败码,记录在[升级指南](../../../../docs/upgrade-guide/v0.2.2-rc.4/forge-rate-limited-failure/guide.zh.md)中。在对话的首条消息之前重启 Host 会丢失暂存的绑定。
@@ -9,8 +9,8 @@
en: dc43ba84345e1405
zh: dbc03572ab7710d2
/agent-note-ship-optional-bundles-with-the-installation/decision:
en: 0f3e0daee65b6510
zh: 2e9c8000da75fb6c
en: e4ecfa61b6f71d8c
zh: a33d16e5843cf097
/agent-note-ship-optional-bundles-with-the-installation/alternatives-considered:
en: 95b48b61757f1f13
zh: e9fb2d6ea492a4bc
@@ -10,7 +10,7 @@ The Web plugin page manages only the bundles a person installed into the profile
## Decision
The launcher names in `OPTIONAL_BUNDLES` (`packages/util/official-bundles/src/bundles.ts`, beside the profile templates) the bundles the installation ships for a person to switch on. Each must be a runtime dependency of `apps/cli` that declares `dsh.bundle.patch`, and no shipped profile template selects it. The plugin manager's `listBundles` reports such a bundle as `optional`: switched off until selected, never removable, resolved from the installation like any installation-supplied bundle. The Web plugin page presents offered optional bundles in its Official group, tagged experimental when the package is experimental, ahead of the profile's own installed bundles. The [persistent-terminal bundle](../../../../packages/experimental/terminal-bundle/README.md) remains available to the Host but has no page switch, even when enabled; its existing profile selection remains intact.
The launcher names in `OPTIONAL_BUNDLES` (`packages/util/official-bundles/src/bundles.ts`, beside the profile templates) the bundles the installation ships for a person to switch on. Each must be a runtime dependency of `apps/cli` that declares `dsh.bundle.patch`, and no shipped profile template selects it. The plugin manager's `listBundles` reports such a bundle as `optional`: switched off until selected, never removable, resolved from the installation like any installation-supplied bundle. The Web plugin page presents offered optional bundles in its Official group, tagged experimental when the package is experimental, ahead of the profile's own installed bundles.
Default-product isolation keeps its rules with one declared exception: an optional bundle's dependency graph is outside the default product. The static gate skips the `dependencies` edge from `@deepseek-ai/dsh` to a listed bundle and still rejects a runtime import, a shipped composition, a preset, or a default template that names it, an experimental dependency the list does not name, and a listed name that is not a runtime dependency or not a bundle. The workspace-constraints check accepts the same `dependencies` edges and no other runtime section, and the packed-install release check skips them from the installed entry package while requiring each listed bundle to be installed.
@@ -10,7 +10,7 @@ Web 插件页只管理用户装进 profile 的组合包。像 Agent Teams 这样
## 决策
启动器在 `OPTIONAL_BUNDLES`(`packages/util/official-bundles/src/bundles.ts`,与 profile 模板并列)里点名安装随附、供用户开启的组合包。每一个都必须是 `apps/cli` 声明了 `dsh.bundle.patch` 的运行时依赖,且不被任何随附 profile 模板选中。插件管理器的 `listBundles` 把这类组合包报告为 `optional`:选中前保持关闭、永不可卸载、像其他安装提供的组合包一样从安装目录解析。Web 插件页在「官方」分组展示可供选择的可选组合包,属于实验包的带实验性标签,排在 profile 自己已安装的组合包之前。[持久终端组合包](../../../../packages/experimental/terminal-bundle/README.zh.md)仍可供 Host 使用,但即使已启用也不提供页面开关;已有的 profile 选择保持不变。
启动器在 `OPTIONAL_BUNDLES`(`packages/util/official-bundles/src/bundles.ts`,与 profile 模板并列)里点名安装随附、供用户开启的组合包。每一个都必须是 `apps/cli` 声明了 `dsh.bundle.patch` 的运行时依赖,且不被任何随附 profile 模板选中。插件管理器的 `listBundles` 把这类组合包报告为 `optional`:选中前保持关闭、永不可卸载、像其他安装提供的组合包一样从安装目录解析。Web 插件页在「官方」分组展示可供选择的可选组合包,属于实验包的带实验性标签,排在 profile 自己已安装的组合包之前。
默认产品隔离的规则保持不变,只声明一个例外:可选组合包的依赖图在默认产品之外。静态门禁跳过从 `@deepseek-ai/dsh` 到列表中组合包的 `dependencies` 边,仍然拒绝运行时 import、随附组合、preset 或默认模板对它的引用,拒绝列表没有点名的实验依赖,也拒绝不是运行时依赖或不是组合包的列表项。workspace 约束检查接受同样的 `dependencies` 边而不接受其他运行时依赖段;发布时的 packed-install 检查对已安装入口包跳过这些边,并要求列表中的每个组合包都已安装。
@@ -0,0 +1,28 @@
# Bilingual-pair consistency record for 2026-11-18-tool-reachability-and-initial-disclosure.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/proposed/architecture/2026-11-18-tool-reachability-and-initial-disclosure.md
/agent-note-tool-reachability-and-initial-disclosure:
en: 702b42d555430e20
zh: d94f3adf52d9d7cb
/agent-note-tool-reachability-and-initial-disclosure/problem:
en: 006eb992e4c0dd4d
zh: 530d13e4f832653b
/agent-note-tool-reachability-and-initial-disclosure/proposal:
en: 86ededd59a892229
zh: 1ed3ac1f5b160f9d
/agent-note-tool-reachability-and-initial-disclosure/proposal/reachability:
en: 7e8256e97b924e34
zh: be334f4469d0b5e1
/agent-note-tool-reachability-and-initial-disclosure/proposal/initial-disclosure:
en: 1c2466dff8ba70e1
zh: d0e2c35a0e74008f
/agent-note-tool-reachability-and-initial-disclosure/alternatives-considered:
en: 27bff0dbad805d7a
zh: be5b8d1746b5bc02
/agent-note-tool-reachability-and-initial-disclosure/acceptance-criteria:
en: 099ebf6f7c753286
zh: 50e29d2522d7fee9
/agent-note-tool-reachability-and-initial-disclosure/risks:
en: 9366e2866f4b2555
zh: 5d7b94bb85019f58
@@ -0,0 +1,50 @@
# Agent Note: Tool reachability and initial disclosure
Status: proposed
English | [中文](2026-11-18-tool-reachability-and-initial-disclosure.zh.md)
## Problem
Both executors disclose every reachable tool in full at every step: `tool-executor-native` through the request `tools` field, `tool-executor-ptc` through the `tools:sdk` section. No per-tool statement exists for how the model may call a tool and how much it receives before any discovery; `ToolSchema.deferLoading` names one provider mechanism instead.
## Proposal
Describe every reachable tool with two model-facing dimensions, defined by what the model receives, not by what the host or provider transmits.
### Reachability
| Value | Meaning |
|---|---|
| `native` | Callable only as a provider tool call. |
| `program` | Callable only from inside a `run_code` program. |
| `both` | Callable either way. |
Authorization is separate: a tool removed by `restrict()` or an inactive `when` condition is absent from this model; a guard denies one execution and changes neither dimension.
### Initial disclosure
| Value | What the model receives before any discovery |
|---|---|
| `none` | Nothing about this tool. |
| `name` | The tool name. |
| `summary` | A description without parameters; may be given per namespace. |
| `full` | Name, description, parameters, and for `program` reachability the return type. |
Every reachable tool is searchable; `none` only means absent from the initial disclosure.
## Alternatives considered
**A visibility axis of `invisible`, `discoverable`, `injected`, `system prompt`.** `injected` is the state a tool enters after a search hit, `system prompt` is a channel, and no name-only level exists; the axis mixed policy, state, and channel.
**A `discoverable` boolean.** Every case that seemed to need an unsearchable tool is authorization, search ranking, an alias, or a runtime builtin that is not a tool; omitting a schema is not enforcement ([packages/AGENTS.md](../../../../packages/AGENTS.md)).
## Acceptance criteria
- Each registered tool resolves to one value per dimension per step, and both executors read the same resolution.
- A `none` tool is found through `tool_search` and then called under each executor in a recorded snapshot; a `native` activation projects through [active tool headers](../../implemented/architecture/2026-09-20-dynamic-tool-updates.md).
## Risks
- Discovery adds a model round trip, and search quality depends on tool names and descriptions.
- Per-step recomputation moves tools between values and changes the declaration prefix the cache relies on.
@@ -0,0 +1,50 @@
# Agent Note: 工具可达性与初始披露
Status: proposed
[English](2026-11-18-tool-reachability-and-initial-disclosure.md) | 中文
## Problem
两个执行器在每个步骤都完整披露每个可达工具:`tool-executor-native` 通过请求的 `tools` 字段,`tool-executor-ptc` 通过 `tools:sdk` 章节。没有任何按工具的说明能表达模型可以如何调用某个工具,以及在任何发现之前它能收到多少内容;`ToolSchema.deferLoading` 只是以某一个提供方机制命名。
## Proposal
用两个面向模型的维度描述每个可达工具,两者都由模型收到的内容定义,而不是由宿主或提供方传输的内容定义。
### 可达性
| 取值 | 含义 |
|---|---|
| `native` | 只能作为提供方工具调用来调用。 |
| `program` | 只能在 `run_code` 程序内部调用。 |
| `both` | 两种方式都可调用。 |
授权是独立的:被 `restrict()` 移除或因 `when` 条件未激活而移除的工具不在此模型之内;guard 拒绝的是一次执行,不改变任何一个维度。
### 初始披露
| 取值 | 模型在任何发现之前收到的内容 |
|---|---|
| `none` | 关于该工具的任何内容都没有。 |
| `name` | 工具名称。 |
| `summary` | 不含参数的描述;可以按命名空间给出。 |
| `full` | 名称、描述、参数,以及 `program` 可达性下的返回类型。 |
每个可达工具都可被搜索;`none` 只表示不在初始披露中。
## Alternatives considered
**一个由 `invisible`、`discoverable`、`injected`、`system prompt` 构成的可见性轴。** `injected` 是工具在搜索命中后进入的状态,`system prompt` 是通道,且不存在仅名称级别;该轴混合了策略、状态和通道。
**一个 `discoverable` 布尔值。** 每个看似需要不可搜索工具的情形都是授权、搜索排序、别名或不是工具的运行时内建函数;省略 schema 不是强制手段([packages/AGENTS.md](../../../../packages/AGENTS.md))。
## Acceptance criteria
- 每个已注册工具在每个步骤为每个维度解析出一个取值,两个执行器读取同一次解析。
- 在录制快照中,一个 `none` 工具在每个执行器下都通过 `tool_search` 被找到并随后被调用;`native` 激活按[活跃工具请求头](../../implemented/architecture/2026-09-20-dynamic-tool-updates.zh.md)投影。
## Risks
- 发现增加一次模型往返,且搜索质量取决于工具名称和描述。
- 按步骤重新计算会在取值之间移动工具,并改变缓存所依赖的声明前缀。
+1
View File
@@ -32,6 +32,7 @@ mise.toml
dist-exe/
/dist/
apps/desktop/.desktop-build/
apps/desktop/.desktop-dev/
python/sdk-runtime/src/deepseek_harness_runtime/runtime/
python/**/__pycache__/
python/**/.pytest_cache/
+3 -1
View File
@@ -37,6 +37,8 @@
"@deepseek-ai/dsh-session-persistence": "workspace:*",
"@deepseek-ai/dsh-sandbox-policy": "workspace:*",
"@deepseek-ai/dsh-util-workspace-path": "workspace:*",
"@deepseek-ai/dsh-brand": "workspace:*"
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-tool-executor-native": "workspace:*",
"@deepseek-ai/dsh-api-workspace-files": "workspace:*"
}
}
+7 -11
View File
@@ -1,10 +1,8 @@
/** Resolve desktop-only file references through the active Host filesystem and Session. */
import { createHash } from 'node:crypto'
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-api-workspace-files'
import type {} from '@deepseek-ai/dsh-fs'
import type {} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-persistence'
import type {} from '@deepseek-ai/dsh-sandbox-policy'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { parseFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
@@ -17,6 +15,7 @@ export interface LocalDragResource {
/**
* Authorize an unmodified local file through the composed filesystem's actual read operations.
* Relative paths resolve from the same workspace root the workspace file service uses for the Session.
* @param ctx - booted Desktop Host.
* @param address - Session-scoped resource reference.
* @param cancellation - caller cancellation, combined with the read deadline.
@@ -25,17 +24,14 @@ export interface LocalDragResource {
export async function localDragResource(ctx: Context, address: string, cancellation?: AbortSignal): Promise<LocalDragResource | null> {
const resource = parseFileAddress(address)
if (resource?.scope !== 'session') throw new Error('File drag requires a Session resource')
const sessions = ctx.get('sessions')
const persistence = ctx.get('sessionPersistence')
const fs = ctx.get('fs')
const policy = ctx.get('sandboxPolicy')
if (fs === undefined || sessions === undefined || policy === undefined) throw new Error('File access unavailable')
const sessionId = resource.sessionId as SessionId
const header = sessions.get(sessionId)?.header ?? (await persistence?.stat(sessionId))?.header
if (header === undefined) throw new Error('File drag Session unavailable')
const workspaceFiles = ctx.get('workspaceFiles')
if (fs === undefined || workspaceFiles === undefined) throw new Error('File access unavailable')
const signal = cancellation === undefined ? AbortSignal.timeout(10_000) : AbortSignal.any([cancellation, AbortSignal.timeout(10_000)])
signal.throwIfAborted()
const cwd = header.cwd ?? policy.workspaceRoot
const scope = await workspaceFiles.scopeOf(resource.sessionId as SessionId, signal)
if (scope === undefined) throw new Error('File drag Session unavailable')
const cwd = scope.workspaceRoot
const entry = await fs.lstat(resource.path, { cwd }, signal)
if (entry?.type !== 'file') return null
const target = await fs.resolve(resource.path, { cwd, signal })
+5 -1
View File
@@ -17,9 +17,13 @@ async function fixture() {
onTestFinished(async () => { await ctx.fiber.dispose(); await rm(root, { recursive: true, force: true }) })
await ctx.plugin(LocalFileSystem, { cwd: root })
await ctx.plugin(SessionStore)
ctx.provide('sandboxPolicy', { workspaceRoot: root } as never)
const id = brandString<SessionId>('file-drag-test')
ctx.sessions.create(id, { meta: { cwd: root, origin: 'subagent' } })
// The workspace file service resolves a live Session's root; its own tests cover that resolution.
ctx.provide('workspaceFiles', {
scopeOf: (sessionId: SessionId) =>
Promise.resolve(ctx.sessions.get(sessionId) === undefined ? undefined : { sessionId, workspaceRoot: root }),
} as never)
const path = join(root, '报告.pdf')
const bytes = Buffer.from('%PDF-1.4\n原始内容\n%%EOF')
await writeFile(path, bytes)
+1
View File
@@ -11,6 +11,7 @@
{ "path": "../../packages/host/authentication-desktop" },
{ "path": "../../vendor/cordis" },
{ "path": "../../packages/core/agent" },
{ "path": "../../packages/api/workspace-files/tsconfig.host.json" },
{ "path": "../../packages/jobs/jobs" },
{ "path": "../../packages/schedule/schedule" },
{ "path": "../../packages/workspace/workspace" },
+4 -4
View File
@@ -42,8 +42,8 @@
en: 98cf848762482d48
zh: 74f9100a39ec8c2f
/deepseek-harness-desktop/develop:
en: faf7676ba18bbf2f
zh: f1d7b75ad348c548
en: 4e4b26cfaaa098ee
zh: e0a2965606020041
/deepseek-harness-desktop/develop/startup-onboarding:
en: 67dc7ef3e293236a
zh: 1b224db684a2d1d7
@@ -54,8 +54,8 @@
en: 7200a35dbed997c3
zh: 511d6961530757f1
/deepseek-harness-desktop/windows-installer-interface:
en: 3a70021830865253
zh: 0467be8b505446cb
en: eb9d30bca4134f80
zh: bf201d18ae5ba697
/deepseek-harness-desktop/updates:
en: 8b0b9efeb83727ef
zh: 5ee95de48ceab392
+2 -2
View File
@@ -199,7 +199,7 @@ The development application menu offers Reload Page (Cmd+R on macOS, Ctrl+R else
pnpm run dev:desktop
```
Development Harness state defaults to `apps/desktop/.desktop-build/development/home`, the disposable npm project lives at `apps/desktop/.desktop-build/development/project`, and Electron browser data lives at `apps/desktop/.desktop-build/development/electron-user-data`. Sessions, settings, credentials, package links, and browser data therefore stay out of the user's normal Harness home. An explicit `DSH_HOME` replaces only the development Harness home. Renderer DevTools opens automatically; Main, Renderer, and dsh Host debugging listen on ports 9229, 9222, and 9230. `DSH_DESKTOP_MAIN_INSPECT_PORT`, `DSH_DESKTOP_RENDERER_DEBUG_PORT`, and `DSH_DESKTOP_HOST_INSPECT_PORT` replace those ports, while `DSH_DESKTOP_OPEN_DEVTOOLS=0` keeps the detached Renderer tools closed.
Development Harness state defaults to `apps/desktop/.desktop-dev/home` and Electron browser data to `apps/desktop/.desktop-dev/electron-user-data`; `pnpm run clean` removes `.desktop-build` but keeps this directory. The disposable npm project lives at `apps/desktop/.desktop-build/development/project`. Sessions, settings, credentials, package links, and browser data therefore stay out of the user's normal Harness home. A launch moves each missing default directory from `.desktop-build/development`, and stops instead while a running Harness Dev still uses that browser data. An explicit `DSH_HOME` replaces only the development Harness home, and `DSH_DESKTOP_USER_DATA_DIR` replaces only the browser data. Renderer DevTools opens automatically; Main, Renderer, and dsh Host debugging listen on ports 9229, 9222, and 9230. `DSH_DESKTOP_MAIN_INSPECT_PORT`, `DSH_DESKTOP_RENDERER_DEBUG_PORT`, and `DSH_DESKTOP_HOST_INSPECT_PORT` replace those ports, while `DSH_DESKTOP_OPEN_DEVTOOLS=0` keeps the detached Renderer tools closed.
After an explicit build, `start:desktop` reconstructs the disposable project and launches the existing artifacts without building again:
@@ -261,7 +261,7 @@ During a confirmed Windows update restart, a separate process displays a draggab
The Windows installer uses native NSIS pages with light and dark palettes, system shadows, an editable installation directory, and a finish page whose launch checkbox is selected by default. Installation is restricted to the current user. Clicking Install or pressing Enter validates the current path; drive roots remain invalid after normalization, including repeated trailing separators. New destinations must be empty, and nonempty destinations must be registered installations. Running executables at the affected installation path produce a native prompt and remain running; same-named applications in other directories do not block installation. Silent updates wait up to ten seconds for the affected application to exit, then stop with exit code 2 if it is still running.
The theme follows Windows at startup; `/THEME=light`, `/THEME=dark`, and `/THEME=auto` select a palette explicitly. The window appears after its branded controls are ready. When the welcome page first appears, the installer moves above ordinary windows once and flashes its taskbar button if another window has focus; it does not remain always on top. Progress reads the pinned 7-Zip extractor’s percentage; directory promotion, registration, and cleanup retain bounded estimates. The weighted percentage does not predict remaining time. After NSIS reports success, the bar fills over 600 ms and displays 100% briefly before the finish page appears; the transition targets 750 ms. The finish page preserves the window position. Finish dismisses the installer before launching the installed executable; a launch failure restores the page for retry. Directory replacement and failure recovery follow the [installation checks](packaging/README.md#runtime-file-selection). First-launch profile preparation remains a separate Desktop operation.
The theme follows Windows at startup; `/THEME=light`, `/THEME=dark`, and `/THEME=auto` select a palette explicitly. The window appears after its branded controls are ready. When the welcome page first appears, the installer moves above ordinary windows once and flashes its taskbar button if another window has focus; it does not remain always on top. Progress reads the pinned 7-Zip extractor’s percentage; directory promotion, registration, and cleanup retain bounded estimates. The weighted percentage does not predict remaining time. After NSIS reports success, the bar fills over 600 ms and displays 100% briefly before the finish page appears; the transition targets 750 ms. Finish controls appear in the existing progress window while a title-bar drag or system menu remains active. Completion flashes the taskbar button three times if the installer is minimized or another window has focus. During installation, the Close button is disabled and dimmed without changing the cursor. On the finish page, Close exits without launching the application. Finish dismisses the installer before launching the installed executable; a launch failure restores the page for retry. Directory replacement and failure recovery follow the [installation checks](packaging/README.md#runtime-file-selection). First-launch profile preparation remains a separate Desktop operation.
Windows packaging compiles an x86 Win32/GDI+ helper with Visual C++ Build Tools and a Windows SDK; signed builds sign this helper through the configured Windows signer. The progress page keeps one opaque pixel buffer for its lifetime, draws static artwork once, and copies repainted pixels with GDI. The preparation hook leaves production dependency collection to electron-builder on every platform.
+2 -2
View File
@@ -199,7 +199,7 @@ macOS 和 Linux 从图形界面启动的程序只继承会话管理器提供的
pnpm run dev:desktop
```
开发 Harness 状态默认写入 `apps/desktop/.desktop-build/development/home`,一次性 npm 项目位于 `apps/desktop/.desktop-build/development/project`,Electron 浏览器数据则位于 `apps/desktop/.desktop-build/development/electron-user-data`。因此,会话、设置、凭据、包链接和浏览器数据都不会进入用户正常使用的 Harness home;显式 `DSH_HOME` 只会替换开发 Harness home。Renderer DevTools 默认自动打开,Main、Renderer 和 dsh Host 调试端口依次为 9229、9222 和 9230。`DSH_DESKTOP_MAIN_INSPECT_PORT`、`DSH_DESKTOP_RENDERER_DEBUG_PORT` 与 `DSH_DESKTOP_HOST_INSPECT_PORT` 可以替换这些端口,`DSH_DESKTOP_OPEN_DEVTOOLS=0` 则保持 Renderer 调试窗口关闭。
开发 Harness 状态默认写入 `apps/desktop/.desktop-dev/home`,Electron 浏览器数据默认写入 `apps/desktop/.desktop-dev/electron-user-data`;`pnpm run clean` 会删除 `.desktop-build`,但保留该目录。一次性 npm 项目位于 `apps/desktop/.desktop-build/development/project`。因此,会话、设置、凭据、包链接和浏览器数据都不会进入用户正常使用的 Harness home。启动时会把每个缺失的默认目录从 `.desktop-build/development` 移过来;若正在运行的 Harness Dev 仍在使用那里的浏览器数据,启动会停止而不迁移。显式 `DSH_HOME` 只会替换开发 Harness home,`DSH_DESKTOP_USER_DATA_DIR` 只会替换浏览器数据。Renderer DevTools 默认自动打开,Main、Renderer 和 dsh Host 调试端口依次为 9229、9222 和 9230。`DSH_DESKTOP_MAIN_INSPECT_PORT`、`DSH_DESKTOP_RENDERER_DEBUG_PORT` 与 `DSH_DESKTOP_HOST_INSPECT_PORT` 可以替换这些端口,`DSH_DESKTOP_OPEN_DEVTOOLS=0` 则保持 Renderer 调试窗口关闭。
显式构建完成后,`start:desktop` 会重新生成一次性项目,并跳过构建直接启动已有产物:
@@ -261,7 +261,7 @@ Windows 更新确认重启后,独立进程显示可拖动的状态提示,直
Windows 安装程序使用原生 NSIS 页面,提供亮暗配色、系统阴影、可编辑的安装目录,以及默认勾选立即启动的完成页。安装仅面向当前用户。点击安装或按 Enter 均校验当前路径;路径规范化后仍拒绝磁盘根目录,包括带重复末尾分隔符的写法。新安装位置必须为空,非空位置必须是已登记的安装目录。受影响安装路径中的程序运行时显示系统提示,并保持应用运行;其他目录中的同名应用不阻止安装。静默更新最多等待受影响应用退出十秒,若仍在运行则以退出码 2 结束。
主题在启动时跟随 Windows;可用 `/THEME=light`、`/THEME=dark` 和 `/THEME=auto` 显式选择配色。窗口在品牌控件准备完成后显示。欢迎页首次出现时,安装窗口会一次性移到普通窗口前方;若焦点在其他窗口,任务栏按钮会闪烁提示,但安装窗口不会始终置顶。进度读取锁定版本的 7-Zip 解压器百分比;目录替换、注册和清理仍使用有界估算。加权百分比不代表剩余时间。NSIS 报告成功后,进度条用 600 毫秒补满并短暂显示 100%,再显示完成页;切换目标时长为 750 毫秒。完成页保留窗口位置。点击完成后,安装程序先隐藏窗口,再启动已安装的可执行文件;启动失败会恢复页面以供重试。目录替换和失败恢复遵循[安装检查](packaging/README.zh.md#runtime-file-selection)。首次启动的配置档案准备仍属于独立的 Desktop 操作。
主题在启动时跟随 Windows;可用 `/THEME=light`、`/THEME=dark` 和 `/THEME=auto` 显式选择配色。窗口在品牌控件准备完成后显示。欢迎页首次出现时,安装窗口会一次性移到普通窗口前方;若焦点在其他窗口,任务栏按钮会闪烁提示,但安装窗口不会始终置顶。进度读取锁定版本的 7-Zip 解压器百分比;目录替换、注册和清理仍使用有界估算。加权百分比不代表剩余时间。NSIS 报告成功后,进度条用 600 毫秒补满并短暂显示 100%,再显示完成页;切换目标时长为 750 毫秒。完成按钮与启动复选框在原进度窗口中显示,拖动标题栏或打开系统菜单时也会更新。若安装器已最小化或焦点在其他窗口,安装完成时任务栏按钮会闪烁三次。安装中关闭按钮禁用并变灰,鼠标指针保持不变;完成页的关闭按钮退出安装器且不启动应用。点击完成后,安装程序先隐藏窗口,再启动已安装的可执行文件;启动失败会恢复页面以供重试。目录替换和失败恢复遵循[安装检查](packaging/README.zh.md#runtime-file-selection)。首次启动的配置档案准备仍属于独立的 Desktop 操作。
Windows 打包使用 Visual C++ Build Tools 和 Windows SDK 编译 x86 Win32/GDI+ 辅助库;签名构建通过已配置的 Windows 签名器对该库签名。进度页在其生命周期内保留一个不透明像素缓冲,只绘制一次静态图像,并通过 GDI 复制重绘的像素。准备钩子在所有平台上均由 electron-builder 继续负责收集生产依赖。
@@ -24,5 +24,5 @@
en: f1c19c1516a51ab6
zh: b350f7c18086d274
/desktop-recovery-and-diagnostics/collection-and-shutdown:
en: bac4a49f63d4aaf8
zh: df1ae908ee2148e1
en: 67555a4116943e85
zh: 451231cb6e28ffe9
+2
View File
@@ -67,6 +67,8 @@ The Host announces its run ID before profile loading; reported Host errors carry
Collection reads only two owned files under `userData/plugin-operations`, at most 64 KiB and 100 records; the complete appended section is limited to 64 KiB.
Only a predecessor whose handle reports the exact bigint file identity of the segment already read is deduplicated as already collected: the predecessor is skipped, so its records are not collected twice, and records appended to it after it was read are not collected. On Windows, opening a segment retries `EACCES`, `EBUSY` and `EPERM` up to four times with a 10→40 ms backoff before the segment counts as unavailable, cancellation ends those retries, and `filesRead` counts owned segments that yielded bytes.
The 500 ms collection budget reserves its final 100 ms for cooperative cancellation before requesting forced Worker termination; completion waits for its exit. Application exit, recovery exit or restart, and confirmed update installation also cancel collection and wait at most 500 ms for Worker exit. A rejected shutdown cleanup is logged without skipping the remaining cleanup waits. Shutdown prevents late basic-report saves from starting another collector. An update installation failure permits future collection again.
Worker messages interrupt collection between bounded records; an in-flight file open, stat, read or close must settle, and synchronous parsing cannot be preempted within one record. The final append uses an abort signal but can leave partial bytes. Forced termination remains the fallback when cooperative cleanup does not finish.
@@ -67,6 +67,8 @@ Host 在加载 profile 前报告运行 ID;Host 错误中的 `hostRunId` 与该
收集只读取 `userData/plugin-operations` 下归其管理的两个文件,最多读取 64 KiB 和 100 条记录;完整追加内容不超过 64 KiB。
只有前驱段的句柄给出与已读段完全相同的 bigint 文件身份时才判为已收集:该前驱段会被跳过,因此它的记录不会被重复收集,但在被读取之后追加到它的记录不会被收集。Windows 上打开文件段遇到 `EACCES`、`EBUSY`、`EPERM` 时最多重试四次,退避 10→40 ms,之后该段才计入不可用;取消会结束这些重试;`filesRead` 统计实际读到字节的所属文件段。
500 ms 收集预算中的最后 100 ms 用于协作取消,随后才请求强制终止 Worker;只有 Worker 退出后才确认收集结束。应用退出、恢复退出或重启、确认安装更新也会取消收集,并最多等待 500 ms 确认 Worker 退出。退出清理中的拒绝会被记录,但不会跳过其他清理等待。退出过程中,延迟保存完成的基本报告不会再启动收集器。更新安装失败后可再次收集。
Worker 在有界记录之间处理取消消息;已经发出的文件打开、状态读取、读取或关闭操作必须等待完成,单条记录的同步解析不能被抢占。最后的追加写入传入取消信号,但仍可能留下部分字节。协作清理未及时完成时仍需强制终止。
-75
View File
@@ -43,78 +43,3 @@ Function InstallerDrawEditFrame
System::Call 'gdiplus::GdipDeleteGraphics(p R4)'
System::Call 'gdiplus::GdipDisposeImage(p R5)'
FunctionEnd
; BS_AUTOCHECKBOX retains its native state, text, keyboard and accessibility role.
Function InstallerPaintCheckbox
Pop $R0
Pop $R1
Pop $R2
${If} $R1 != -12
Return
${EndIf}
System::Call '*$R2(p, p, i, i .R3, p .R4, i, i, i, i, p, i .R9)'
${If} $R3 != 1
Return
${EndIf}
System::Call 'gdi32::SaveDC(p R4)'
System::Alloc 16
Pop $R2
System::Call 'user32::GetClientRect(p R0, p R2)'
System::Call 'gdi32::CreateSolidBrush(i $InstallerBgColorref) p.R3'
System::Call 'user32::FillRect(p R4, p R2, p R3)'
System::Call 'gdi32::DeleteObject(p R3)'
System::Call 'kernel32::MulDiv(i 8, i $InstallerDpi, i 96) i.r2'
System::Call 'kernel32::MulDiv(i 7, i $InstallerDpi, i 96) i.r3'
System::Call 'gdi32::SetViewportOrgEx(p R4, i r2, i r3, p 0)'
System::Call 'gdiplus::GdipCreateFromHDC(p R4, *p .R5)'
System::Call 'gdiplus::GdipSetSmoothingMode(p R5, i 4)'
System::Call 'kernel32::MulDiv(i 18, i $InstallerDpi, i 96) i.R7'
StrCpy $R8 $R7
System::Call 'kernel32::MulDiv(i 6, i $InstallerDpi, i 96) i.R3'
!insertmacro InstallerRoundPath $R6 $R7 $R8 $R3
${NSD_GetState} $R0 $R8
StrCpy $R3 $InstallerBgArgb
${If} $R8 == ${BST_CHECKED}
StrCpy $R3 $InstallerPrimary
${EndIf}
System::Call 'gdiplus::GdipCreateSolidFill(i R3, *p .R1)'
System::Call 'gdiplus::GdipFillPath(p R5, p R1, p R6)'
System::Call 'gdiplus::GdipDeleteBrush(p R1)'
${If} $R8 != ${BST_CHECKED}
System::Call 'gdiplus::GdipCreatePen1(i $InstallerBorder, i 0x40000000, i 2, *p .R1)'
System::Call 'gdiplus::GdipDrawPath(p R5, p R1, p R6)'
System::Call 'gdiplus::GdipDeletePen(p R1)'
${EndIf}
System::Call 'gdiplus::GdipDeletePath(p R6)'
System::Call 'gdiplus::GdipDeleteGraphics(p R5)'
${If} $R8 == ${BST_CHECKED}
System::Call 'kernel32::MulDiv(i 2, i $InstallerDpi, i 96) i.r0'
System::Call 'gdi32::CreatePen(i 0, i r0, i $InstallerButtonText) p.R1'
System::Call 'gdi32::SelectObject(p R4, p R1) p.R3'
System::Call 'kernel32::MulDiv(i 4, i $InstallerDpi, i 96) i.r0'
System::Call 'kernel32::MulDiv(i 9, i $InstallerDpi, i 96) i.r1'
System::Call 'gdi32::MoveToEx(p R4, i r0, i r1, p 0)'
System::Call 'kernel32::MulDiv(i 8, i $InstallerDpi, i 96) i.r0'
System::Call 'kernel32::MulDiv(i 13, i $InstallerDpi, i 96) i.r1'
System::Call 'gdi32::LineTo(p R4, i r0, i r1)'
System::Call 'kernel32::MulDiv(i 14, i $InstallerDpi, i 96) i.r0'
System::Call 'kernel32::MulDiv(i 5, i $InstallerDpi, i 96) i.r1'
System::Call 'gdi32::LineTo(p R4, i r0, i r1)'
System::Call 'gdi32::SelectObject(p R4, p R3)'
System::Call 'gdi32::DeleteObject(p R1)'
${EndIf}
System::Call 'gdi32::SetViewportOrgEx(p R4, i 0, i 0, p 0)'
System::Call 'kernel32::MulDiv(i 34, i $InstallerDpi, i 96) i.r0'
System::Call '*$R2(i r0)'
System::Call 'gdi32::SetBkMode(p R4, i 1)'
System::Call 'gdi32::SetTextColor(p R4, i $InstallerTextColorref)'
System::Call 'gdi32::SelectObject(p R4, p $InstallerSmallFont)'
System::Call 'user32::DrawTextW(p R4, w "$(INSTALLER_LAUNCH)", i -1, p R2, i 0x24)'
IntOp $R9 $R9 & 16
${If} $R9 != 0
System::Call 'user32::DrawFocusRect(p R4, p R2)'
${EndIf}
System::Call 'gdi32::RestoreDC(p R4, i -1)'
System::Free $R2
${NSD_Return} 4
FunctionEnd
+20 -7
View File
@@ -54,6 +54,7 @@ Function InstallerBeforeInstall
FunctionEnd
Function InstallerProgressShow
StrCpy $InstallerPhase "installing"
; Only the stock worker executes installation; this overlay runs on the UI thread.
ShowWindow $mui.InstFilesPage 0
StrCpy $0 0
@@ -79,12 +80,24 @@ Function .onInstFailed
Quit
FunctionEnd
Function InstallerFinish
System::Call '$PLUGINSDIR\window-frame.dll::InstallerFinishProgress(p $InstallerProgressWindow) i.r0 ?c'
${If} $0 == 0
Quit
Function InstallerProgressLeave
IfAbort failed
${If} $InstallerPhase == "installing"
System::Call '$PLUGINSDIR\window-frame.dll::InstallerFinishProgress(p $InstallerProgressWindow, w "$(INSTALLER_FINISH)", w "$(INSTALLER_LAUNCH)") i.r0 ?c'
${If} $0 == 0
MessageBox MB_OK|MB_ICONSTOP "$(INSTALLER_UI_ERROR)"
SetErrorLevel 2
Quit
${EndIf}
StrCpy $InstallerPhase "success"
Abort
${EndIf}
System::Call 'user32::DestroyWindow(p $InstallerProgressWindow)'
StrCpy $InstallerPhase "success"
Call InstallerCreate
System::Call '$PLUGINSDIR\window-frame.dll::InstallerTakeFinishChoice(p $InstallerProgressWindow) i.r0 ?c'
${If} $0 < 0
Abort
${EndIf}
Call InstallerFinishLeave
Return
failed:
; NSIS owns installation failure and its exit code.
FunctionEnd
+6 -38
View File
@@ -16,7 +16,6 @@ Var InstallerChoose
Var InstallerEdit
Var InstallerEditFrame
Var InstallerBrowse
Var InstallerLaunch
Var InstallerExpanded
Var InstallerMinimizeButton
Var InstallerCloseButton
@@ -137,30 +136,6 @@ Function InstallerCreate
!insertmacro InstallerPlace $InstallerBrowse 456 434 80 34
${NSD_OnClick} $InstallerBrowse InstallerBrowsePath
${NSD_OnNotify} $InstallerBrowse InstallerPaintButton
${NSD_CreateCheckbox} 0 0 0 0 "$(INSTALLER_LAUNCH)"
Pop $InstallerLaunch
SendMessage $InstallerLaunch ${WM_SETFONT} $InstallerSmallFont 1
System::Call 'user32::GetDC(p $InstallerLaunch) p.r4'
System::Call 'gdi32::SelectObject(p r4, p $InstallerSmallFont) p.r5'
StrLen $0 "$(INSTALLER_LAUNCH)"
System::Alloc 8
Pop $6
System::Call 'gdi32::GetTextExtentPoint32W(p r4, w "$(INSTALLER_LAUNCH)", i r0, p r6)'
System::Call '*$6(i .r7)'
System::Free $6
System::Call 'gdi32::SelectObject(p r4, p r5)'
System::Call 'user32::ReleaseDC(p $InstallerLaunch, p r4)'
System::Call 'kernel32::MulDiv(i 42, i $InstallerDpi, i 96) i.r2'
IntOp $2 $2 + $7
IntOp $0 $InstallerSize - $2
IntOp $0 $0 / 2
System::Call 'kernel32::MulDiv(i 438, i $InstallerDpi, i 96) i.r1'
System::Call 'kernel32::MulDiv(i 32, i $InstallerDpi, i 96) i.r3'
System::Call 'user32::MoveWindow(p $InstallerLaunch, i r0, i r1, i r2, i r3, i 1)'
!insertmacro InstallerControlColors $InstallerLaunch
${NSD_OnNotify} $InstallerLaunch InstallerPaintCheckbox
${NSD_Check} $InstallerLaunch
${NSD_CreateButton} 0 0 0 0 "$(INSTALLER_INSTALL)"
Pop $InstallerButton
!insertmacro InstallerPlace $InstallerButton ${INSTALLER_BUTTON_X} ${INSTALLER_BUTTON_Y} ${INSTALLER_BUTTON_WIDTH} ${INSTALLER_BUTTON_HEIGHT}
@@ -188,20 +163,13 @@ Function InstallerRender
ShowWindow $InstallerEdit 0
ShowWindow $InstallerEditFrame 0
ShowWindow $InstallerBrowse 0
ShowWindow $InstallerLaunch 0
ShowWindow $InstallerStatus 0
${If} $InstallerPhase == "success"
${NSD_SetText} $InstallerButton "$(INSTALLER_FINISH)"
ShowWindow $InstallerLaunch 5
${If} $InstallerExpanded == 1
ShowWindow $InstallerEditFrame 5
ShowWindow $InstallerEdit 5
ShowWindow $InstallerBrowse 5
${Else}
${NSD_SetText} $InstallerButton "$(INSTALLER_INSTALL)"
${If} $InstallerExpanded == 1
ShowWindow $InstallerEditFrame 5
ShowWindow $InstallerEdit 5
ShowWindow $InstallerBrowse 5
${Else}
ShowWindow $InstallerChoose 5
${EndIf}
ShowWindow $InstallerChoose 5
${EndIf}
FunctionEnd
@@ -220,8 +188,8 @@ Function InstallerWelcomeLeave
${EndIf}
FunctionEnd
; The completed page requests exit with the user's launch choice in $0.
Function InstallerFinishLeave
${NSD_GetState} $InstallerLaunch $0
HideWindow
${If} $0 == ${BST_CHECKED}
StrCpy $0 ""
+183 -45
View File
@@ -140,8 +140,14 @@ struct ProgressPage {
ARGB controlHover;
ARGB controlPressed;
WCHAR captions[5][128];
HWND finish, launch, minimize, close;
bool controlsVisible = false;
int finishChoice = -1;
HFONT finishFont, launchFont;
~ProgressPage() {
if (finishFont) DeleteObject(finishFont);
if (launchFont) DeleteObject(launchFont);
delete buffer;
delete brand;
if (previousBitmap) SelectObject(bufferDc, previousBitmap);
@@ -178,13 +184,16 @@ static UINT CaptionCommand(const ProgressPage& page, LPARAM position) {
const int x = static_cast<short>(LOWORD(position));
const int y = static_cast<short>(HIWORD(position));
if (y < 0 || y >= MulDiv(48, page.dpi, 96) || x < MulDiv(504, page.dpi, 96) || x >= MulDiv(600, page.dpi, 96)) return 0;
return x >= MulDiv(548, page.dpi, 96) ? SC_CLOSE : SC_MINIMIZE;
// Installation cannot be cancelled with the progress page close button.
return x >= MulDiv(548, page.dpi, 96) ? 0 : SC_MINIMIZE;
}
static void PaintCaptionButtons(Graphics& graphics, const ProgressPage& page) {
SolidBrush background(page.dark ? Color(255, 21, 21, 23) : Color(255, 255, 255, 255));
graphics.FillRectangle(&background, 504, 0, 96, 48);
SolidBrush ink(page.dark ? Color(255, 255, 255, 255) : Color(255, 15, 17, 21));
// Disabled caption uses the same foreground with reduced opacity in both themes.
SolidBrush disabledInk(page.dark ? Color(96, 255, 255, 255) : Color(96, 15, 17, 21));
FontFamily family(L"Microsoft YaHei UI");
Font font(&family, 16, FontStyleRegular, UnitPixel);
StringFormat centered;
@@ -204,7 +213,7 @@ static void PaintCaptionButtons(Graphics& graphics, const ProgressPage& page) {
graphics.FillPath(&fill, &path);
}
graphics.DrawString(command == SC_MINIMIZE ? L"\x2212" : L"\x00d7", -1,
&font, RectF(static_cast<REAL>(x), 8, 40, 32), &centered, &ink);
&font, RectF(static_cast<REAL>(x), 8, 40, 32), &centered, command == SC_CLOSE ? &disabledInk : &ink);
}
}
@@ -213,15 +222,109 @@ static void InvalidateCaptionButtons(HWND window, const ProgressPage& page) {
InvalidateRect(window, &bounds, FALSE);
}
// NSIS ui.h: request that the stock instfiles page run its leave callback.
constexpr UINT WM_NOTIFY_OUTER_NEXT = WM_USER + 8;
static void RequestFinish(HWND window, ProgressPage& page, bool launch) {
if (!page.controlsVisible || page.finishChoice >= 0) return;
if (PostMessageW(GetParent(window), WM_NOTIFY_OUTER_NEXT, 1, 0)) page.finishChoice = launch ? 1 : 0;
}
static void RevealFinish(HWND window, ProgressPage& page) {
page.controlsVisible = true;
KillTimer(window, 1);
SetWindowTextW(window, L"");
InvalidateRect(window, nullptr, FALSE);
for (HWND child : {page.finish, page.launch, page.minimize, page.close}) ShowWindow(child, SW_SHOWNA);
HWND frame = GetParent(window);
if (GetForegroundWindow() != frame || IsIconic(frame)) {
FLASHWINFO flash = {sizeof(flash), frame, FLASHW_TRAY, 3, 0};
FlashWindowEx(&flash);
}
}
static LRESULT DrawFinishControl(const ProgressPage& page, NMCUSTOMDRAW& draw) {
if (draw.dwDrawStage != CDDS_PREPAINT) return CDRF_DODEFAULT;
const HWND control = draw.hdr.hwndFrom;
const bool primary = control == page.finish;
const bool checkbox = control == page.launch;
const bool pressed = (draw.uItemState & CDIS_SELECTED) != 0;
const bool hot = (draw.uItemState & CDIS_HOT) != 0;
const Color background = page.dark ? Color(255,21,21,23) : Color(255,255,255,255);
const Color foreground = page.dark ? Color(255,255,255,255) : Color(255,15,17,21);
const Color accent = page.dark ? Color(255,249,250,251) : Color(255,15,17,21);
const Color inverse = page.dark ? Color(255,15,17,21) : Color(255,255,255,255);
RECT rect; GetClientRect(control, &rect);
HDC dc = draw.hdc;
const int saved = SaveDC(dc);
{
Graphics graphics(dc);
graphics.ScaleTransform(page.dpi / 96.0f, page.dpi / 96.0f);
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
graphics.Clear(background);
const bool checked = checkbox && SendMessageW(control, BM_GETCHECK, 0, 0) == BST_CHECKED;
Color fill = primary ? accent : background;
if (primary && (hot || pressed)) {
fill = page.dark ? (pressed ? Color(255,212,219,233) : Color(255,233,236,242))
: (pressed ? Color(255,0,0,0) : Color(255,45,49,53));
} else if (checkbox) {
fill = checked ? accent : background;
} else if (hot || pressed) {
fill = Color(pressed ? page.controlPressed : page.controlHover);
}
const REAL x = checkbox ? 8.0f : 0.0f, y = checkbox ? 7.0f : 0.0f;
const REAL w = checkbox ? 18.0f : rect.right * 96.0f / page.dpi;
const REAL h = checkbox ? 18.0f : rect.bottom * 96.0f / page.dpi;
const REAL d = checkbox ? 6.0f : 20.0f;
GraphicsPath path;
path.AddArc(x,y,d,d,180,90); path.AddArc(x+w-d,y,d,d,270,90);
path.AddArc(x+w-d,y+h-d,d,d,0,90); path.AddArc(x,y+h-d,d,d,90,90); path.CloseFigure();
SolidBrush brush(fill); graphics.FillPath(&brush,&path);
if (checkbox && !checked) {
Pen border(page.dark ? Color(255,97,102,107) : Color(255,187,192,200)); graphics.DrawPath(&border,&path);
} else if (checked) {
Pen pen(inverse,2.0f); Point points[] = {{12,16},{16,20},{22,12}};
graphics.DrawLines(&pen,points,3);
}
}
WCHAR caption[256]; GetWindowTextW(control,caption,ARRAYSIZE(caption));
const Color text = primary ? inverse : foreground;
SetTextColor(dc,RGB(text.GetR(),text.GetG(),text.GetB())); SetBkMode(dc,TRANSPARENT);
SelectObject(dc,checkbox ? page.launchFont : page.finishFont);
if (checkbox) rect.left += MulDiv(34,page.dpi,96);
DrawTextW(dc,caption,-1,&rect,DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX | (checkbox ? DT_LEFT : DT_CENTER));
if (draw.uItemState & CDIS_FOCUS) { InflateRect(&rect,-3,-3); DrawFocusRect(dc,&rect); }
RestoreDC(dc,saved);
return CDRF_SKIPDEFAULT;
}
static LRESULT CALLBACK ProgressProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
auto* page = reinterpret_cast<ProgressPage*>(GetWindowLongPtrW(window, GWLP_USERDATA));
if (message == WM_CREATE) {
page = static_cast<ProgressPage*>(reinterpret_cast<CREATESTRUCTW*>(lparam)->lpCreateParams);
SetWindowLongPtrW(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(page));
SetTimer(window, 1, 16, nullptr);
}
if (message == WM_ERASEBKGND) return 1;
if (message == WM_TIMER) { InvalidateRect(window, nullptr, FALSE); return 0; }
if (message == WM_TIMER && page && wparam == 1) {
if (page->controlsVisible) return 0;
InvalidateRect(window, nullptr, FALSE);
if (page->progress.succeeded && GetTickCount64() - page->progress.animationStarted >= 750) {
// A covered window may not have painted its final frame on the last tick.
UpdateWindow(window);
RevealFinish(window, *page);
}
return 0;
}
if (message == WM_NOTIFY && page && reinterpret_cast<NMHDR*>(lparam)->code == NM_CUSTOMDRAW) {
return DrawFinishControl(*page, *reinterpret_cast<NMCUSTOMDRAW*>(lparam));
}
if (message == WM_COMMAND && page && page->controlsVisible && HIWORD(wparam) == BN_CLICKED) {
HWND control = reinterpret_cast<HWND>(lparam);
if (control == page->finish || control == page->close) {
RequestFinish(window, *page, control == page->finish && SendMessageW(page->launch, BM_GETCHECK, 0, 0) == BST_CHECKED);
} else if (control == page->minimize) ShowWindow(GetParent(window), SW_MINIMIZE);
return 0;
}
if (message == WM_MOUSEMOVE && page) {
TRACKMOUSEEVENT tracking{sizeof(tracking), TME_LEAVE, window, 0};
TrackMouseEvent(&tracking);
@@ -259,10 +362,7 @@ static LRESULT CALLBACK ProgressProc(HWND window, UINT message, WPARAM wparam, L
InvalidateCaptionButtons(window, *page);
const bool activate = command && GetCapture() == window && CaptionCommand(*page, lparam) == command;
if (GetCapture() == window) ReleaseCapture();
if (activate) {
if (command == SC_CLOSE) PostMessageW(GetParent(window), WM_CLOSE, 0, 0);
else ShowWindow(GetParent(window), SW_MINIMIZE);
}
if (activate) ShowWindow(GetParent(window), SW_MINIMIZE);
return 0;
}
if ((message == WM_CAPTURECHANGED || message == WM_CANCELMODE) && page) {
@@ -284,23 +384,25 @@ static LRESULT CALLBACK ProgressProc(HWND window, UINT message, WPARAM wparam, L
PaintCaptionButtons(graphics, *page);
SolidBrush background(page->dark ? Color(255, 21, 21, 23) : Color(255, 255, 255, 255));
graphics.FillRectangle(&background, 48, 480, 504, 56);
const int stage = static_cast<int>(reinterpret_cast<INT_PTR>(GetPropW(GetParent(window), L"HarnessInstaller.Stage")));
const double fraction = reinterpret_cast<UINT_PTR>(GetPropW(GetParent(window), L"HarnessInstaller.ExtractProgress")) / 100.0;
page->progress.Advance(stage, fraction, GetTickCount64());
const int percent = static_cast<int>(page->progress.value);
SolidBrush track(page->dark ? Color(255, 97, 102, 107) : Color(255, 233, 236, 242));
SolidBrush ink(page->dark ? Color(255, 255, 255, 255) : Color(255, 15, 17, 21));
FillProgress(graphics, track, 472.0f);
FillProgress(graphics, ink, 472.0f * static_cast<REAL>(page->progress.value) / 100);
FontFamily family(L"Microsoft YaHei UI");
Font font(&family, 14, FontStyleRegular, UnitPixel);
StringFormat centered;
centered.SetAlignment(StringAlignmentCenter);
centered.SetLineAlignment(StringAlignmentCenter);
WCHAR caption[160];
wsprintfW(caption, page->captions[page->progress.CaptionStage()], percent);
SetWindowTextW(window, caption);
graphics.DrawString(caption, -1, &font, RectF(48, 512, 504, 22), &centered, &ink);
if (!page->controlsVisible) {
const int stage = static_cast<int>(reinterpret_cast<INT_PTR>(GetPropW(GetParent(window), L"HarnessInstaller.Stage")));
const double fraction = reinterpret_cast<UINT_PTR>(GetPropW(GetParent(window), L"HarnessInstaller.ExtractProgress")) / 100.0;
page->progress.Advance(stage, fraction, GetTickCount64());
const int percent = static_cast<int>(page->progress.value);
SolidBrush track(page->dark ? Color(255, 97, 102, 107) : Color(255, 233, 236, 242));
SolidBrush ink(page->dark ? Color(255, 255, 255, 255) : Color(255, 15, 17, 21));
FillProgress(graphics, track, 472.0f);
FillProgress(graphics, ink, 472.0f * static_cast<REAL>(page->progress.value) / 100);
FontFamily family(L"Microsoft YaHei UI");
Font font(&family, 14, FontStyleRegular, UnitPixel);
StringFormat centered;
centered.SetAlignment(StringAlignmentCenter);
centered.SetLineAlignment(StringAlignmentCenter);
WCHAR caption[160];
wsprintfW(caption, page->captions[page->progress.CaptionStage()], percent);
SetWindowTextW(window, caption);
graphics.DrawString(caption, -1, &font, RectF(48, 512, 504, 22), &centered, &ink);
}
}
BitBlt(dc, paint.rcPaint.left, paint.rcPaint.top,
paint.rcPaint.right - paint.rcPaint.left, paint.rcPaint.bottom - paint.rcPaint.top,
@@ -372,9 +474,10 @@ extern "C" __declspec(dllexport) HWND __cdecl InstallerShowProgress(HWND parent,
}
delete page->brand;
page->brand = nullptr;
HWND window = CreateWindowExW(0, type.lpszClassName, L"", WS_CHILD,
HWND window = CreateWindowExW(WS_EX_CONTROLPARENT, type.lpszClassName, L"", WS_CHILD | WS_CLIPCHILDREN,
0, 0, MulDiv(600, dpi, 96), MulDiv(600, dpi, 96), parent, nullptr, module, page);
if (!window) { delete page; return nullptr; }
if (!SetTimer(window, 1, 16, nullptr)) { DestroyWindow(window); return nullptr; }
// Keep the stock page available until the replacement is fully constructed.
HWND stockPage = GetParent(source);
if (!SetWindowSubclass(stockPage, HiddenPageProc, 1, 0)) {
@@ -385,32 +488,65 @@ extern "C" __declspec(dllexport) HWND __cdecl InstallerShowProgress(HWND parent,
return window;
}
// NSIS has already reported success. Pump the UI for the bounded final animation,
// including a painted 100% frame, before constructing the interactive finish page.
extern "C" __declspec(dllexport) BOOL __cdecl InstallerFinishProgress(HWND window) {
// Called from the instfiles leave callback on success. Timer paints finish the
// animation while USER32 continues dispatching the current move or menu.
extern "C" __declspec(dllexport) BOOL __cdecl InstallerFinishProgress(HWND window, LPCWSTR finish, LPCWSTR launch) {
auto* page = reinterpret_cast<ProgressPage*>(GetWindowLongPtrW(window, GWLP_USERDATA));
if (!page) return FALSE;
const ULONGLONG started = GetTickCount64();
if (page->progress.succeeded) return TRUE;
const auto scaled = [&](int n) { return MulDiv(n,page->dpi,96); };
page->finishFont = CreateFontW(-scaled(16),0,0,0,FW_MEDIUM,0,0,0,DEFAULT_CHARSET,0,0,CLEARTYPE_QUALITY,0,L"Microsoft YaHei UI");
page->launchFont = CreateFontW(-scaled(14),0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,0,0,CLEARTYPE_QUALITY,0,L"Microsoft YaHei UI");
if (!page->finishFont || !page->launchFont) return FALSE;
HDC dc = GetDC(window);
if (!dc) return FALSE;
HGDIOBJ old = SelectObject(dc,page->launchFont);
SIZE size = {};
const BOOL measured = GetTextExtentPoint32W(dc,launch,lstrlenW(launch),&size);
SelectObject(dc,old); ReleaseDC(window,dc);
if (!measured) return FALSE;
const int launchWidth = std::min(scaled(600),static_cast<int>(size.cx) + scaled(42));
auto button = [&](INT_PTR id, LPCWSTR title, DWORD style, int x, int y, int w, int h, HFONT font) {
HWND child = CreateWindowW(L"BUTTON",title,WS_CHILD|WS_TABSTOP|style,x,y,w,h,window,reinterpret_cast<HMENU>(id),GetModuleHandleW(nullptr),nullptr);
if (child) SendMessageW(child,WM_SETFONT,reinterpret_cast<WPARAM>(font),FALSE);
return child;
};
page->finish = button(0x6100,finish,BS_DEFPUSHBUTTON,scaled(240),scaled(490),scaled(120),scaled(44),page->finishFont);
page->launch = button(0x6101,launch,BS_AUTOCHECKBOX,(scaled(600)-launchWidth)/2,scaled(438),launchWidth,scaled(32),page->launchFont);
page->minimize = button(0x6102,L"\x2212",BS_PUSHBUTTON,scaled(504),scaled(8),scaled(40),scaled(32),page->finishFont);
page->close = button(0x6103,L"\x00d7",BS_PUSHBUTTON,scaled(548),scaled(8),scaled(40),scaled(32),page->finishFont);
if (!page->finish || !page->launch || !page->minimize || !page->close) return FALSE;
SendMessageW(page->launch,BM_SETCHECK,BST_CHECKED,0);
SetPropW(GetParent(window), L"HarnessInstaller.Succeeded", reinterpret_cast<HANDLE>(1));
page->progress.Complete(started);
while (IsWindow(window) && GetTickCount64() - started < 750) {
MSG message;
if (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) {
if (message.message == WM_QUIT) { PostQuitMessage(static_cast<int>(message.wParam)); return FALSE; }
TranslateMessage(&message);
DispatchMessageW(&message);
} else {
MsgWaitForMultipleObjectsEx(0, nullptr, 16, QS_ALLINPUT, MWMO_INPUTAVAILABLE);
}
}
if (!IsWindow(window)) return FALSE;
InvalidateRect(window, nullptr, FALSE);
UpdateWindow(window);
page->progress.Complete(GetTickCount64());
return TRUE;
}
// Reading consumes one explicit Finish/Close action so a failed launch can retry.
extern "C" __declspec(dllexport) int __cdecl InstallerTakeFinishChoice(HWND window) {
auto* page = reinterpret_cast<ProgressPage*>(GetWindowLongPtrW(window,GWLP_USERDATA));
if (!page) return -1;
int choice = page->finishChoice;
page->finishChoice = -1;
return choice;
}
static LRESULT CALLBACK FrameProc(HWND window, UINT message, WPARAM wparam,
LPARAM lparam, UINT_PTR id, DWORD_PTR) {
if (message == WM_COMMAND && HIWORD(wparam) == BN_CLICKED) {
HWND progress = FindWindowExW(window, nullptr, L"HarnessInstallerProgress", nullptr);
auto* page = reinterpret_cast<ProgressPage*>(GetWindowLongPtrW(progress, GWLP_USERDATA));
HWND control = reinterpret_cast<HWND>(lparam);
if (page && page->controlsVisible) {
// IsDialogMessage can route Enter to the outer NSIS dialog.
if (control && GetParent(control) == progress)
return SendMessageW(progress, WM_COMMAND, wparam, lparam);
if (LOWORD(wparam) == IDOK) {
RequestFinish(progress, *page, SendMessageW(page->launch, BM_GETCHECK, 0, 0) == BST_CHECKED);
return 0;
}
}
}
if (message == WM_NCCALCSIZE && wparam) return 0;
// Activation must not repaint the standard frame over the custom client area.
if (message == WM_NCACTIVATE) return DefSubclassProc(window, message, wparam, -1);
@@ -419,7 +555,9 @@ static LRESULT CALLBACK FrameProc(HWND window, UINT message, WPARAM wparam,
// The installer has a fixed size; its page provides the drag area.
return hit >= HTLEFT && hit <= HTBOTTOMRIGHT ? HTCLIENT : hit;
}
if (message == WM_NCDESTROY) RemoveWindowSubclass(window, FrameProc, id);
if (message == WM_NCDESTROY) {
RemoveWindowSubclass(window, FrameProc, id);
}
return DefSubclassProc(window, message, wparam, lparam);
}
+2 -2
View File
@@ -10,6 +10,7 @@ import type { DesktopRelease } from '../src/release.ts'
import { developmentRuntimeDirectory, resolveDesktopBuildTarget } from './desktop-build-paths.mjs'
import { prepareDevelopmentProject } from './development-project.ts'
import { prepareDevelopmentApp } from './development-app.ts'
import { prepareDevelopmentState } from './development-state.ts'
import { preparePrimaryRuntime } from './prepare-primary-runtime.ts'
const APP_ROOT = resolve(import.meta.dirname, '..')
@@ -63,8 +64,7 @@ async function launchElectron(): Promise<void> {
const mainPort = debugPort('DSH_DESKTOP_MAIN_INSPECT_PORT', 9229)
const rendererPort = debugPort('DSH_DESKTOP_RENDERER_DEBUG_PORT', 9222)
const hostPort = debugPort('DSH_DESKTOP_HOST_INSPECT_PORT', 9230)
const home = resolve(process.env.DSH_HOME ?? join(DEVELOPMENT_ROOT, 'home'))
const userData = resolve(process.env.DSH_DESKTOP_USER_DATA_DIR ?? join(DEVELOPMENT_ROOT, 'electron-user-data'))
const { home, userData } = prepareDevelopmentState(APP_ROOT)
const environment: NodeJS.ProcessEnv = {
...process.env,
DSH_HOME: home,
+69
View File
@@ -0,0 +1,69 @@
/** Persistent Harness home and Electron browser data for unpackaged Desktop launches. */
import { existsSync, mkdirSync, readlinkSync, renameSync } from 'node:fs'
import { join, resolve } from 'node:path'
/** Development state locations selected for one launch. */
export interface DevelopmentState {
readonly home: string
readonly userData: string
}
function running(pid: number): boolean {
try {
process.kill(pid, 0)
return true
} catch (error) {
return error instanceof Error && 'code' in error && error.code === 'EPERM'
}
}
/** Chromium links `SingletonLock` to `<host>-<pid>` while a browser process owns the profile on macOS and Linux. */
function profileInUse(userData: string): boolean {
let target: string
try {
target = readlinkSync(join(userData, 'SingletonLock'))
} catch (error) {
// A missing lock or a non-link lock file means no live owner records itself this way.
if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'EINVAL')) return false
throw error
}
const pid = /-(\d+)$/.exec(target)?.[1]
return pid !== undefined && running(Number(pid))
}
/**
* Resolve development state outside `.desktop-build`, which `pnpm run clean` removes.
* A default location that does not exist yet receives the state an earlier launcher left under
* `.desktop-build/development` unless a running Harness Dev still owns that browser profile;
* explicit `DSH_HOME` and `DSH_DESKTOP_USER_DATA_DIR` are used as given.
* @param appRoot - Desktop application directory.
* @param environment - Launch environment with optional location overrides.
* @returns Harness home and Electron user-data directories.
*/
export function prepareDevelopmentState(appRoot: string, environment: NodeJS.ProcessEnv = process.env): DevelopmentState {
const legacyRoot = join(appRoot, '.desktop-build', 'development')
const select = (override: string | undefined, name: string): string => {
if (override !== undefined) return resolve(override)
const path = join(appRoot, '.desktop-dev', name)
const legacy = join(legacyRoot, name)
if (!existsSync(path) && existsSync(legacy)) {
// POSIX renames a directory that a running process still writes, which would split its state.
if (profileInUse(join(legacyRoot, 'electron-user-data'))) {
throw new Error(`desktop development: a running Harness Dev still uses ${legacyRoot}; quit it and retry`)
}
try {
mkdirSync(join(appRoot, '.desktop-dev'), { recursive: true })
renameSync(legacy, path)
} catch (error) {
const reason = error instanceof Error ? error.message : String(error)
throw new Error(`desktop development: cannot move ${legacy} to ${path}: ${reason}`, { cause: error })
}
console.log(`desktop development: moved ${legacy} to ${path}`)
}
return path
}
return {
home: select(environment.DSH_HOME, 'home'),
userData: select(environment.DSH_DESKTOP_USER_DATA_DIR, 'electron-user-data'),
}
}
+2 -1
View File
@@ -100,10 +100,11 @@ ManifestDPIAware true
!macro customPageAfterChangeDir
!define MUI_PAGE_CUSTOMFUNCTION_PRE InstallerBeforeInstall
!define MUI_PAGE_CUSTOMFUNCTION_SHOW InstallerProgressShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstallerProgressLeave
!macroend
!macro customFinishPage
Page custom InstallerFinish InstallerFinishLeave
; The final instfiles page keeps its controls until the user dismisses it.
!macroend
; Installation work publishes stage changes without disturbing the NSIS caller.
+69 -13
View File
@@ -1,9 +1,16 @@
/** Bounded, cancellable reads of Desktop-owned plugin operation history. */
import { open } from 'node:fs/promises'
import type { BigIntStats } from 'node:fs'
import { open, type FileHandle } from 'node:fs/promises'
import { join } from 'node:path'
import { setImmediate } from 'node:timers/promises'
import { setImmediate, setTimeout as wait } from 'node:timers/promises'
import { parsePluginOperationRecord, type PluginOperationRecord } from '@deepseek-ai/dsh-plugin-manager/diagnostic'
/** Windows reports these while another handle temporarily owns an otherwise readable file. */
const WINDOWS_TRANSIENT_OPEN_ERRORS: ReadonlySet<string> = new Set(['EACCES', 'EBUSY', 'EPERM'])
const WINDOWS_OPEN_RETRY_INITIAL_MS = 10
const WINDOWS_OPEN_RETRY_MAX_MS = 40
const WINDOWS_OPEN_RETRY_LIMIT = 4
/** Resource budgets for auxiliary history collection, independent of basic crash report writing. */
export interface OperationHistoryReadLimits {
readonly bytes: number
@@ -15,7 +22,7 @@ export interface OperationHistoryReadLimits {
export interface OperationHistoryReadResult {
readonly records: readonly PluginOperationRecord[]
readonly bytesRead: number
/** Distinct files from which at least one byte was read. */
/** Owned history segments from which at least one byte was read. */
readonly filesRead: number
readonly truncated: boolean
readonly invalidRecords: number
@@ -23,9 +30,53 @@ export interface OperationHistoryReadResult {
readonly cancelled: boolean
}
/**
* Exact two-name key for one file; BigInt stats keep a Windows 64-bit file ID at its
* value instead of the 53-bit Number form, where two adjacent IDs can coincide.
* @param info - Stats of the opened history segment.
* @returns Device and inode as one comparable string.
*/
function fileIdentity(info: BigIntStats): string {
return `${String(info.dev)}:${String(info.ino)}`
}
/** Whether Windows reported temporary interference with opening a history segment. */
function isTransientWindowsOpenError(error: unknown): boolean {
if (process.platform !== 'win32') return false
return WINDOWS_TRANSIENT_OPEN_ERRORS.has((error as NodeJS.ErrnoException | null)?.code ?? '')
}
/**
* Open one segment, retrying the temporary Windows sharing and permission failures a scanner
* causes on a freshly written file. One persistent failure would otherwise drop the whole
* segment from the report. A signal aborted during the bounded wait ends the retries without
* another open.
* @param filename - Absolute path of the owned segment.
* @param signal - Caller-owned collection deadline or shutdown cancellation.
* @returns The opened read handle.
*/
async function openSegment(filename: string, signal: AbortSignal): Promise<FileHandle> {
// A call keeps the post-wait check outside the catch's narrowing to the pre-wait value.
const aborted = (): boolean => signal.aborted
let delay = WINDOWS_OPEN_RETRY_INITIAL_MS
for (let retries = 0;; retries += 1) {
try {
return await open(filename, 'r')
} catch (error) {
if (!isTransientWindowsOpenError(error) || retries >= WINDOWS_OPEN_RETRY_LIMIT || aborted()) throw error
await wait(delay)
if (aborted()) throw error
delay = Math.min(delay * 2, WINDOWS_OPEN_RETRY_MAX_MS)
}
}
}
/**
* Read only the bounded tails of the two owned history files, newest segment first.
* Cancellation is observed between bounded records after yielding to Worker messages and stops subsequent I/O and parsing.
* A segment is deduplicated as already read when its handle reports the exact bigint identity of
* the segment already read; the predecessor is skipped, so its records are not collected twice and
* records appended to it after the read are not collected.
* An already-issued OS read must settle before its handle closes.
* @param directory - Desktop's operation history directory; unrelated files are never enumerated.
* @param limits - Positive byte, record-size and record-count budgets.
@@ -44,33 +95,35 @@ export async function readOperationHistory(
const cancelled = (): boolean => signal.aborted
const records: PluginOperationRecord[] = []
let bytesRead = 0
const seenFiles = new Set<string>()
let filesRead = 0
let lastReadIdentity: string | undefined
let truncated = false
let invalidRecords = 0
let unavailableFiles = 0
for (const name of ['operations.jsonl', 'operations.previous.jsonl']) {
if (cancelled()) break
try {
await using handle = await open(join(directory, name), 'r')
await using handle = await openSegment(join(directory, name), signal)
if (cancelled()) break
const fileStat = await handle.stat()
const fileStat = await handle.stat({ bigint: true })
if (cancelled()) break
if (!fileStat.isFile()) {
unavailableFiles++
continue
}
const identity = `${String(fileStat.dev)}:${String(fileStat.ino)}`
if (seenFiles.has(identity)) {
const identity = fileIdentity(fileStat)
const size = Number(fileStat.size)
if (lastReadIdentity !== undefined && identity === lastReadIdentity) {
truncated = true
continue
}
if (fileStat.size > 0 && (bytesRead >= limits.bytes || records.length >= limits.records)) {
if (size > 0 && (bytesRead >= limits.bytes || records.length >= limits.records)) {
truncated = true
break
}
const readLength = Math.min(fileStat.size, limits.bytes - bytesRead)
const readStart = fileStat.size - readLength
const readLength = Math.min(size, limits.bytes - bytesRead)
const readStart = size - readLength
const buffer = Buffer.alloc(readLength)
let readOffset = 0
while (readOffset < readLength && !cancelled()) {
@@ -79,7 +132,10 @@ export async function readOperationHistory(
if (read.bytesRead === 0) break
readOffset += read.bytesRead
}
if (readOffset > 0) seenFiles.add(identity)
if (readOffset > 0) {
filesRead++
lastReadIdentity = identity
}
if (cancelled()) break
truncated ||= readStart > 0 || readOffset < readLength
@@ -116,5 +172,5 @@ export async function readOperationHistory(
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') unavailableFiles++
}
}
return { records, bytesRead, filesRead: seenFiles.size, truncated, invalidRecords, unavailableFiles, cancelled: cancelled() }
return { records, bytesRead, filesRead, truncated, invalidRecords, unavailableFiles, cancelled: cancelled() }
}
@@ -0,0 +1,75 @@
/** Development launches keep Harness state where repository cleaning does not remove it. */
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it, onTestFinished, vi } from 'vitest'
import { prepareDevelopmentState } from '../scripts/development-state.ts'
function fixture(): string {
const root = mkdtempSync(join(tmpdir(), 'dsh-development-state-'))
onTestFinished(() => { rmSync(root, { recursive: true, force: true }) })
return root
}
it('moves state from .desktop-build into the default development state directory', () => {
vi.spyOn(console, 'log').mockImplementation(() => {})
onTestFinished(() => { vi.restoreAllMocks() })
const root = fixture()
const legacy = join(root, '.desktop-build', 'development')
mkdirSync(join(legacy, 'home'), { recursive: true })
mkdirSync(join(legacy, 'electron-user-data'))
writeFileSync(join(legacy, 'home', 'session.jsonl'), 'session')
const state = prepareDevelopmentState(root, {})
expect(state).toEqual({ home: join(root, '.desktop-dev', 'home'), userData: join(root, '.desktop-dev', 'electron-user-data') })
expect(readFileSync(join(state.home, 'session.jsonl'), 'utf8')).toBe('session')
expect(existsSync(state.userData)).toBe(true)
expect(existsSync(join(legacy, 'home'))).toBe(false)
})
it('keeps existing default state and leaves legacy state in place', () => {
const root = fixture()
mkdirSync(join(root, '.desktop-dev', 'home'), { recursive: true })
mkdirSync(join(root, '.desktop-build', 'development', 'home'), { recursive: true })
expect(prepareDevelopmentState(root, {}).home).toBe(join(root, '.desktop-dev', 'home'))
expect(existsSync(join(root, '.desktop-build', 'development', 'home'))).toBe(true)
})
it('moves only the default directory that is missing', () => {
vi.spyOn(console, 'log').mockImplementation(() => {})
onTestFinished(() => { vi.restoreAllMocks() })
const root = fixture()
const legacy = join(root, '.desktop-build', 'development')
mkdirSync(join(legacy, 'home'), { recursive: true })
mkdirSync(join(legacy, 'electron-user-data'))
const state = prepareDevelopmentState(root, { DSH_HOME: join(root, 'h') })
expect(state).toEqual({ home: join(root, 'h'), userData: join(root, '.desktop-dev', 'electron-user-data') })
expect(existsSync(state.userData)).toBe(true)
expect(existsSync(join(legacy, 'home'))).toBe(true)
})
it('uses explicit locations without moving legacy state', () => {
const root = fixture()
mkdirSync(join(root, '.desktop-build', 'development', 'home'), { recursive: true })
expect(prepareDevelopmentState(root, { DSH_HOME: join(root, 'h'), DSH_DESKTOP_USER_DATA_DIR: join(root, 'u') }))
.toEqual({ home: join(root, 'h'), userData: join(root, 'u') })
expect(existsSync(join(root, '.desktop-build', 'development', 'home'))).toBe(true)
expect(existsSync(join(root, '.desktop-dev'))).toBe(false)
})
it.skipIf(process.platform === 'win32')('does not move state that a running Harness Dev still owns', () => {
const root = fixture()
const legacy = join(root, '.desktop-build', 'development')
mkdirSync(join(legacy, 'home'), { recursive: true })
mkdirSync(join(legacy, 'electron-user-data'))
symlinkSync(`host-${String(process.pid)}`, join(legacy, 'electron-user-data', 'SingletonLock'))
expect(() => prepareDevelopmentState(root, {})).toThrow('a running Harness Dev still uses')
expect(existsSync(join(legacy, 'home'))).toBe(true)
expect(existsSync(join(root, '.desktop-dev'))).toBe(false)
})
@@ -8,6 +8,7 @@
"welcome-ready-before-first-show",
"welcome-presented-on-first-show",
"successful-install-paints-100-before-finish",
"completion-close-exits-without-launch",
"locked-directory-shows-error-and-copy-control-and-preserves-installation",
"registered-directory-with-trailing-separators",
"registered-directory-and-checked-launch",
+200 -5
View File
@@ -1,7 +1,8 @@
import { mkdtemp, mkdir, open, rename, rm, writeFile } from 'node:fs/promises'
import { appendFile, mkdtemp, mkdir, open, rename, rm, writeFile } from 'node:fs/promises'
import type { BigIntStats, StatOptions, Stats } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it, onTestFinished, vi } from 'vitest'
import { beforeEach, expect, it, onTestFinished, vi } from 'vitest'
import { readOperationHistory } from '../src/operation-history.ts'
vi.mock('node:fs/promises', async (importOriginal) => {
@@ -10,6 +11,7 @@ vi.mock('node:fs/promises', async (importOriginal) => {
})
const limits = { bytes: 64 * 1024, recordBytes: 2048, records: 100 }
beforeEach(() => { vi.mocked(open).mockClear() })
function record(id: string | number) {
return { runId: 'c254ab28-97c9-4382-95e6-2db9c66f98c8', transportDropped: 0,
operation: { id: 'c254ab28-97c9-4382-95e6-2db9c66f98c9', time: '2026-10-19T00:00:00.000Z',
@@ -25,11 +27,183 @@ async function fixture() {
it('collects recent complete records and reports malformed and incomplete entries', async () => {
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(1) + '{broken}\n' + line(2) + '{"incomplete":')
const current = line(1) + '{broken}\n' + line(2) + '{"incomplete":'
await writeFile(join(path, 'operations.jsonl'), current)
await writeFile(join(path, 'operations.previous.jsonl'), line(0))
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(2), record(1), record(0)])
expect(result).toMatchObject({ invalidRecords: 1, truncated: true, cancelled: false, unavailableFiles: 0 })
// The whole result is asserted so a missing record also names the collection facts that caused it.
expect(result).toEqual({
records: [record(2), record(1), record(0)],
bytesRead: Buffer.byteLength(current) + Buffer.byteLength(line(0)),
filesRead: 2,
truncated: true,
invalidRecords: 1,
unavailableFiles: 0,
cancelled: false,
})
})
it('does not collect a rotated predecessor twice after it was appended', async () => {
const path = await fixture()
const current = join(path, 'operations.jsonl')
const previous = join(path, 'operations.previous.jsonl')
await writeFile(current, line(1))
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const handle = await open(current, 'r')
const opener = vi.mocked(open).mockClear()
.mockImplementationOnce(async () => handle)
.mockImplementationOnce(async () => {
// The writer appends one record, then rotates: both names still denote one file.
await appendFile(current, line(2))
await rename(current, previous)
await writeFile(current, line(3))
return actualFs.open(previous, 'r')
})
try {
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(1)])
expect(result).toMatchObject({ filesRead: 1, truncated: true, unavailableFiles: 0 })
} finally {
opener.mockClear()
}
})
it('compares exact bigint identities so two nearby Numbers cannot collapse one segment', async () => {
const path = await fixture()
const current = join(path, 'operations.jsonl')
const previous = join(path, 'operations.previous.jsonl')
const currentText = line('current')
const previousText = line('old')
await writeFile(current, currentText)
await writeFile(previous, previousText)
const currentHandle = await open(current, 'r')
const previousHandle = await open(previous, 'r')
onTestFinished(async () => { await currentHandle.close(); await previousHandle.close() })
const currentStat = await currentHandle.stat({ bigint: true })
const previousStat = await previousHandle.stat({ bigint: true })
const currentNumberStat = await currentHandle.stat()
const previousNumberStat = await previousHandle.stat()
// Adjacent 64-bit file IDs: distinct as bigints, one Number after the 53-bit mantissa.
const base = 2n ** 58n + 1000n
currentStat.dev = 0n
currentStat.ino = base
previousStat.dev = 0n
previousStat.ino = base + 1n
currentNumberStat.dev = 0
currentNumberStat.ino = Number(base)
previousNumberStat.dev = 0
previousNumberStat.ino = Number(base + 1n)
expect(currentNumberStat.ino).toBe(previousNumberStat.ino)
const optionAware = (exact: BigIntStats, numeric: Stats) =>
async (options?: StatOptions): Promise<BigIntStats | Stats> => options?.bigint === true ? exact : numeric
const currentStats = vi.spyOn(currentHandle, 'stat').mockImplementation(optionAware(currentStat, currentNumberStat))
const previousStats = vi.spyOn(previousHandle, 'stat').mockImplementation(optionAware(previousStat, previousNumberStat))
const opener = vi.mocked(open).mockClear().mockResolvedValueOnce(currentHandle).mockResolvedValueOnce(previousHandle)
try {
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record('current'), record('old')])
expect(result).toMatchObject({ filesRead: 2, unavailableFiles: 0, truncated: false })
} finally {
currentStats.mockRestore()
previousStats.mockRestore()
opener.mockClear()
}
})
it('retries transient Windows sharing failures while opening a segment', async () => {
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32')
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const opener = vi.mocked(open)
onTestFinished(async () => {
platform.mockRestore()
opener.mockReset().mockImplementation(actualFs.open)
})
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(2))
await writeFile(join(path, 'operations.previous.jsonl'), line(1))
opener.mockRejectedValueOnce(Object.assign(new Error('sharing violation'), { code: 'EBUSY' }))
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(2), record(1)])
expect(result.unavailableFiles).toBe(0)
expect(opener).toHaveBeenCalledTimes(3)
})
it('counts a segment unavailable after bounded Windows open retries expire', async () => {
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32')
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const opener = vi.mocked(open)
onTestFinished(async () => {
platform.mockRestore()
opener.mockReset().mockImplementation(actualFs.open)
})
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(2))
await writeFile(join(path, 'operations.previous.jsonl'), line(1))
for (let attempt = 0; attempt <= 4; attempt++) {
opener.mockRejectedValueOnce(Object.assign(new Error('access denied'), { code: 'EPERM' }))
}
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(1)])
expect(result.unavailableFiles).toBe(1)
expect(opener).toHaveBeenCalledTimes(6)
})
it('does not retry a Windows transient code outside Windows', async () => {
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('linux')
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const opener = vi.mocked(open)
onTestFinished(async () => {
platform.mockRestore()
opener.mockReset().mockImplementation(actualFs.open)
})
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(2))
await writeFile(join(path, 'operations.previous.jsonl'), line(1))
opener.mockRejectedValueOnce(Object.assign(new Error('access denied'), { code: 'EPERM' }))
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(1)])
expect(result.unavailableFiles).toBe(1)
expect(opener).toHaveBeenCalledTimes(2)
})
it('stops Windows open retries when the collection is already cancelled', async () => {
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32')
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const opener = vi.mocked(open)
onTestFinished(async () => {
platform.mockRestore()
opener.mockReset().mockImplementation(actualFs.open)
})
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(2))
const controller = new AbortController()
opener.mockImplementationOnce(async () => {
controller.abort()
throw Object.assign(new Error('sharing violation'), { code: 'EBUSY' })
})
const result = await readOperationHistory(path, limits, controller.signal)
expect(result).toMatchObject({ records: [], cancelled: true, unavailableFiles: 1 })
expect(opener).toHaveBeenCalledTimes(1)
})
it('stops Windows open retries when cancellation lands during the retry wait', async () => {
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32')
const actualFs = await vi.importActual<typeof import('node:fs/promises')>('node:fs/promises')
const opener = vi.mocked(open)
onTestFinished(async () => {
platform.mockRestore()
opener.mockReset().mockImplementation(actualFs.open)
})
const path = await fixture()
await writeFile(join(path, 'operations.jsonl'), line(2))
const controller = new AbortController()
opener.mockImplementationOnce(async () => {
setImmediate(() => { controller.abort() })
throw Object.assign(new Error('sharing violation'), { code: 'EBUSY' })
})
const result = await readOperationHistory(path, limits, controller.signal)
expect(result).toMatchObject({ records: [], cancelled: true, unavailableFiles: 1 })
expect(opener).toHaveBeenCalledTimes(1)
})
it('reads no more than its byte budget from a two GiB file and ignores unrelated history', async () => {
@@ -159,6 +333,27 @@ it('does not collect the same open segment twice when it rotates during collecti
}
})
it('does not re-collect a rotated segment while the current path is briefly absent', async () => {
const path = await fixture()
const current = join(path, 'operations.jsonl')
await writeFile(current, line(1))
const handle = await open(current, 'r')
onTestFinished(async () => { await handle.close() })
const opener = vi.mocked(open).mockClear().mockImplementationOnce(async () => {
await rename(current, join(path, 'operations.previous.jsonl'))
return handle
})
try {
const result = await readOperationHistory(path, limits, new AbortController().signal)
expect(result.records).toEqual([record(1)])
expect(result).toMatchObject({ filesRead: 1, truncated: true })
expect(handle.fd).toBe(-1)
} finally {
opener.mockClear()
await handle.close()
}
})
it.each(['absent', 'empty', 'nonempty'])('reports omitted bytes at an exact budget: previous segment %s', async (previous) => {
const path = await fixture()
const current = line(1)
@@ -65,6 +65,8 @@ int main() {
progress.Complete(done);
double previous = progress.value;
for (std::uint64_t elapsed = 0; elapsed < 600; elapsed += 16) {
// A repeated completion notification must not restart the final animation.
if (elapsed == 320) progress.Complete(done + elapsed);
progress.Advance(4, 1, done + elapsed);
assert(progress.value >= previous && progress.value < 100);
previous = progress.value;
+109 -15
View File
@@ -11,9 +11,67 @@ extern "C" __declspec(dllimport) HRESULT __cdecl InstallerApplyFrame(HWND window
extern "C" __declspec(dllimport) HWND __cdecl InstallerShowProgress(HWND parent, HWND source,
BOOL dark, UINT dpi, DWORD controlHover, DWORD controlPressed, const WCHAR* brand, const WCHAR* preparing, const WCHAR* extracting,
const WCHAR* copying, const WCHAR* registering, const WCHAR* cleaning);
extern "C" __declspec(dllimport) BOOL __cdecl InstallerFinishProgress(HWND window);
extern "C" __declspec(dllimport) BOOL __cdecl InstallerFinishProgress(HWND window, const WCHAR* finish, const WCHAR* launch);
extern "C" __declspec(dllimport) int __cdecl InstallerTakeFinishChoice(HWND window);
struct CompletionProbe {
HWND progress;
ULONGLONG deadline;
RECT bounds;
bool requested = false;
bool completedDuringMove = false;
};
static void PollCompletion(HWND window, CompletionProbe& probe) {
const HWND finish = FindWindowExW(probe.progress, nullptr, L"Button", L"Finish");
const HWND launch = FindWindowExW(probe.progress, nullptr, L"Button", L"Launch");
if (finish && launch && IsWindowVisible(finish) && IsWindowVisible(launch)) {
GUITHREADINFO input{sizeof(input)};
RECT current;
probe.completedDuringMove = GetGUIThreadInfo(GetCurrentThreadId(), &input)
&& input.hwndMoveSize == window && GetWindowRect(window, &current)
&& EqualRect(&current, &probe.bounds) && IsWindowEnabled(finish)
&& SendMessageW(launch, BM_GETCHECK, 0, 0) == BST_CHECKED
&& GetPropW(window, L"HarnessInstaller.CompletedPercent") == reinterpret_cast<HANDLE>(100);
} else if (GetTickCount64() < probe.deadline) {
return;
}
SendMessageW(window, WM_CANCELMODE, 0, 0);
}
static bool CompleteWhileMinimized(HWND window, HWND progress) {
ShowWindow(window, SW_MINIMIZE);
const HWND foreground = GetForegroundWindow();
if (!IsIconic(window) || !InstallerFinishProgress(progress, L"Finish", L"Launch")) return false;
const ULONGLONG deadline = GetTickCount64() + 5000;
while (GetTickCount64() < deadline) {
const HWND finish = FindWindowExW(progress, nullptr, L"Button", L"Finish");
if (finish && IsWindowVisible(finish)) {
return IsIconic(window) && (foreground == window || GetForegroundWindow() != window)
&& GetPropW(window, L"HarnessInstaller.Succeeded") != nullptr;
}
MSG message;
while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) DispatchMessageW(&message);
MsgWaitForMultipleObjectsEx(0, nullptr, 16, QS_ALLINPUT, MWMO_INPUTAVAILABLE);
}
return false;
}
static LRESULT CALLBACK WindowProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) {
auto* probe = reinterpret_cast<CompletionProbe*>(GetWindowLongPtrW(window, GWLP_USERDATA));
if (probe && message == WM_ENTERSIZEMOVE) {
GetWindowRect(window, &probe->bounds);
PostMessageW(window, WM_APP, 0, 0);
}
if (probe && message == WM_APP) {
probe->requested = InstallerFinishProgress(probe->progress, L"Finish", L"Launch") != FALSE;
if (!probe->requested || !SetTimer(window, 1, 16, nullptr)) SendMessageW(window, WM_CANCELMODE, 0, 0);
return 0;
}
if (probe && message == WM_TIMER && wparam == 1) {
PollCompletion(window, *probe);
return 0;
}
if (message == WM_DESTROY) { PostQuitMessage(0); return 0; }
return DefWindowProcW(window, message, wparam, lparam);
}
@@ -68,10 +126,12 @@ int wmain(int argc, wchar_t** argv) {
HWND warmup = createProgress();
if (!warmup) { DestroyWindow(window); return 5; }
UpdateWindow(warmup);
ShowWindow(window, SW_MINIMIZE);
const bool minimizedCompletion = CompleteWhileMinimized(window, warmup);
ShowWindow(window, SW_RESTORE);
UpdateWindow(warmup);
DestroyWindow(warmup);
RemovePropW(window, L"HarnessInstaller.CompletedPercent");
RemovePropW(window, L"HarnessInstaller.Succeeded");
const DWORD initialGdi = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
HWND progress = createProgress();
if (!progress) { DestroyWindow(window); return 5; }
@@ -124,14 +184,15 @@ int wmain(int argc, wchar_t** argv) {
};
bool captionStates = true;
ShowWindow(progress, SW_HIDE);
for (int x : {504, 548}) {
{
constexpr int x = 504;
const LPARAM point = MAKELPARAM(MulDiv(x + 20, dpi, 96), MulDiv(24, dpi, 96));
captionStates = expectPixel(x, normalColor) && captionStates;
SendMessageW(progress, WM_MOUSEMOVE, 0, point);
captionStates = expectPixel(x, hoverColor) && captionStates;
SendMessageW(progress, WM_LBUTTONDOWN, MK_LBUTTON, point);
captionStates = expectPixel(x, pressedColor) && captionStates;
const int other = x == 504 ? 548 : 504;
constexpr int other = 548;
SendMessageW(progress, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(MulDiv(other + 20, dpi, 96), MulDiv(24, dpi, 96)));
captionStates = expectPixel(other, normalColor) && captionStates;
captionStates = expectPixel(x, normalColor) && captionStates;
@@ -167,12 +228,15 @@ int wmain(int argc, wchar_t** argv) {
const LPARAM closePoint = MAKELPARAM(MulDiv(568, dpi, 96), MulDiv(24, dpi, 96));
MSG closeMessage;
SendMessageW(progress, WM_LBUTTONDOWN, MK_LBUTTON, closePoint);
bool closeRelease = !PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE);
bool closeDisabled = GetCapture() != progress && expectPixel(548, normalColor)
&& !PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE);
SendMessageW(progress, WM_MOUSEMOVE, MK_LBUTTON, closePoint);
closeDisabled = closeDisabled && expectPixel(548, normalColor);
SendMessageW(progress, WM_LBUTTONUP, 0, minimizePoint);
closeRelease = closeRelease && !PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE);
closeDisabled = closeDisabled && !PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE);
SendMessageW(progress, WM_LBUTTONDOWN, MK_LBUTTON, closePoint);
SendMessageW(progress, WM_LBUTTONUP, 0, closePoint);
closeRelease = closeRelease && PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE);
closeDisabled = closeDisabled && !PeekMessageW(&closeMessage, window, WM_CLOSE, WM_CLOSE, PM_REMOVE) && GetCapture() != progress;
LARGE_INTEGER frequency, started, finished;
QueryPerformanceFrequency(&frequency);
std::vector<double> samples;
@@ -196,15 +260,45 @@ int wmain(int argc, wchar_t** argv) {
std::printf("fixture=standalone-progress dpi=%d dark=%d frames=%d screen=%dx%d foreground=%d mean_ms=%.3f p50_ms=%.3f p95_ms=%.3f max_ms=%.3f\n",
dpi, dark, frameCount, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), GetForegroundWindow() == window,
total / samples.size(), samples[samples.size() / 2], samples[samples.size() * 95 / 100], samples.back());
const bool completed = InstallerFinishProgress(progress) &&
GetPropW(window, L"HarnessInstaller.CompletedPercent") == reinterpret_cast<HANDLE>(100);
WCHAR caption[160] = {};
GetWindowTextW(progress, caption, ARRAYSIZE(caption));
const bool finalCaption = wcscmp(caption, L"Extracting 100%") == 0;
CompletionProbe probe{progress, GetTickCount64() + 5000, {}};
POINT originalCursor{};
const bool restoreCursor = GetCursorPos(&originalCursor) != FALSE;
SetWindowLongPtrW(window, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(&probe));
SendMessageW(window, WM_SYSCOMMAND, SC_MOVE, 0);
if (restoreCursor) SetCursorPos(originalCursor.x, originalCursor.y);
KillTimer(window, 1);
SetWindowLongPtrW(window, GWLP_USERDATA, 0);
const bool completed = probe.requested && probe.completedDuringMove;
bool finishActions = completed && InstallerTakeFinishChoice(progress) == -1;
bool finishInTabOrder = false, launchInTabOrder = false;
if (finishActions) {
const HWND finish = FindWindowExW(progress, nullptr, L"Button", L"Finish");
const HWND launch = FindWindowExW(progress, nullptr, L"Button", L"Launch");
const HWND close = FindWindowExW(progress, nullptr, L"Button", L"\x00d7");
const HWND first = GetNextDlgTabItem(window, nullptr, FALSE);
HWND tab = first;
for (int next = 0; tab && next < 4; ++next) {
finishInTabOrder |= tab == finish;
launchInTabOrder |= tab == launch;
tab = GetNextDlgTabItem(window, tab, FALSE);
if (tab == first) break;
}
SendMessageW(finish, BM_CLICK, 0, 0);
finishActions = InstallerTakeFinishChoice(progress) == 1 && InstallerTakeFinishChoice(progress) == -1;
SendMessageW(close, BM_CLICK, 0, 0);
finishActions = finishActions && InstallerTakeFinishChoice(progress) == 0;
SendMessageW(launch, BM_CLICK, 0, 0);
SendMessageW(window, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), 0);
finishActions = finishActions && InstallerTakeFinishChoice(progress) == 0;
}
DestroyWindow(progress);
const DWORD finalGdi = GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS);
DestroyWindow(window);
std::printf("client_frame=%d stock_preserved=%d completed=%d final_caption=%d caption_states=%d button_release=%d close_release=%d minimized=%d restored=%d gdi_before=%lu gdi_after=%lu\n",
clientFrame, failurePreservesStock, completed, finalCaption, captionStates, buttonRelease, closeRelease, minimized, restored, initialGdi, finalGdi);
return clientFrame && failurePreservesStock && completed && finalCaption && captionStates && buttonRelease && closeRelease && minimized && restored && finalGdi <= initialGdi ? 0 : 6;
std::printf("client_frame=%d stock_preserved=%d completed_during_move=%d caption_states=%d button_release=%d close_disabled=%d minimized=%d restored=%d gdi_before=%lu gdi_after=%lu\n",
clientFrame, failurePreservesStock, completed, captionStates, buttonRelease, closeDisabled, minimized, restored, initialGdi, finalGdi);
std::printf("minimized_completion=%d finish_actions=%d finish_tab=%d launch_tab=%d\n",
minimizedCompletion, finishActions, finishInTabOrder, launchInTabOrder);
return clientFrame && failurePreservesStock && completed && minimizedCompletion && finishActions
&& finishInTabOrder && launchInTabOrder && captionStates && buttonRelease && closeDisabled
&& minimized && restored && finalGdi <= initialGdi ? 0 : 6;
}
@@ -157,6 +157,14 @@ try {
$results.Add('welcome-ready-before-first-show')
$results.Add('successful-install-paints-100-before-finish')
$process = Start-Setup light
Click-Control $process $copy.INSTALLER_INSTALL
[void](Wait-Control $process $copy.INSTALLER_FINISH)
Click-Control $process ([string][char]0xD7)
if (-not $process.WaitForExit(10000) -or $process.ExitCode -ne 0) { throw 'Completion close did not exit successfully' }
if (Test-Path -LiteralPath (Join-Path $installPath 'launched.txt')) { throw 'Completion close launched the application' }
$results.Add('completion-close-exits-without-launch')
$lockedFile = [IO.File]::Open($appPath, 'Open', 'Read', 'Read')
try {
$process = Start-Setup light
@@ -0,0 +1,5 @@
- listitem:
- button "查看 持久终端": 持久终端
- text: 实验性 为智能体提供以侧栏标签页打开的终端,你可以旁观,也可以直接在其中键入来接管。进程在多次工具调用之间持续运行,因此它可以启动开发服务器或 REPL,稍后再读取输出;它也能读取你自己打开的终端。
- status
- switch "启用 持久终端"
+8
View File
@@ -1142,6 +1142,14 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
await captureStableAria(page, '[data-composer-input]', scaffold.workspaceCwd), MODE)
expect((await readPersistedEvents(scaffold, sessionId)).some(event => event.type === 'user/message'
&& event.data.content.some(block => block.type === 'text' && block.text.includes('## User Comment')))).toBe(false)
// Removing a reference card leaves its quote in the composer, and the notice's Undo puts the card back at its line.
const extra = local.locator('[data-forge-diff-file="src/extra.ts"]')
await extra.getByRole('button', { name: '评论 R1 的操作', exact: true }).click()
await page.getByRole('menuitem', { name: '移除', exact: true }).click()
await expect.poll(() => extra.locator('[data-forge-review-thread]').count()).toBe(0)
expect(await page.locator('[data-composer-input]').first().innerText()).toContain('请检查这项修改')
await page.getByRole('alert').filter({ hasText: '已移除' }).getByRole('button', { name: '撤销', exact: true }).click()
await extra.locator('[data-forge-review-thread="agent"]').getByText('请检查这项修改', { exact: true }).waitFor()
const reviewed = scaffold.whenTurnSettled()
await page.locator('[data-composer-input]').first().press('Enter')
await reviewed
+77
View File
@@ -0,0 +1,77 @@
// Web e2e scenario: connecting the Linear plugin from its page on the Plugins
// page. The section reads the MCP manager's real entry, the browser opens the
// loopback authorization server's page, the Host callback answers with its
// completion page, the connection reaches the manager, and sign-out returns the
// section to disconnected. Zero model calls.
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Browser, BrowserContext, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { startLinearOAuthFixture, type LinearOAuthFixture } from './linear-oauth-fixture.ts'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts'
const LINEAR_DIR = fileURLToPath(new URL('../../../packages/connector/linear', import.meta.url))
describe('web e2e: Linear plugin connection', () => {
let fixture: LinearOAuthFixture
let overlayDir: string
let scaffold: WebScaffold
let browser: Browser
let context: BrowserContext
let page: Page
let tripwire: ReturnType<typeof watchConsole>
beforeAll(async () => {
fixture = await startLinearOAuthFixture()
overlayDir = await mkdtemp(join(tmpdir(), 'dsh-linear-e2e-'))
const overlay = join(overlayDir, 'linear.overlay.yml')
await writeFile(overlay, `- id: linear\n config:\n url: ${fixture.origin}/mcp\n`)
scaffold = await launchWebScaffold({
extraOverlayPath: [fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)), overlay],
profile: { packages: [{ dir: LINEAR_DIR, enabled: true }] },
})
browser = await chromium.launch()
context = await browser.newContext({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE })
page = await context.newPage()
tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
}, 120_000)
afterAll(async () => {
await browser?.close()
await scaffold?.close()
await fixture?.close()
if (overlayDir !== undefined) await rm(overlayDir, { recursive: true, force: true })
})
it('connects the account from the plugin page and signs out after confirmation', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-linear-connection'))
await page.getByRole('navigation', { name: '全局面板' }).getByRole('button', { name: '插件', exact: true }).click()
const panel = page.locator('[data-plugin-panel]')
await panel.getByRole('button', { name: '查看 Linear 插件', exact: true }).click({ timeout: 20_000 })
const section = panel.locator('[data-connector-account]')
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('disconnected')
expect(await panel.locator('[data-plugin-detail]').getByText('未连接', { exact: true }).count()).toBe(2)
const opened = context.waitForEvent('page')
await section.getByRole('button', { name: '连接 Linear', exact: true }).click()
const authorization = await opened
await expect.poll(async () => await authorization.locator('body').textContent(), { timeout: 20_000 })
.toContain('已收到授权。可以关闭此页,回到 DSH 查看连接结果。')
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('connected')
await page.getByText('Linear 已连接', { exact: true }).waitFor({ timeout: 10_000 })
expect(fixture.authorizations()).toBe(1)
await authorization.close()
await section.getByRole('button', { name: '退出登录', exact: true }).click()
await page.getByRole('dialog', { name: '退出 Linear 登录?' }).getByRole('button', { name: '退出登录', exact: true }).click()
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('disconnected')
expect(tripwire.pageErrors).toEqual([])
expect(fixture.failures()).toEqual([])
})
})
+118
View File
@@ -0,0 +1,118 @@
/**
* Loopback stand-in for Linear's hosted MCP server: OAuth protected-resource
* and authorization-server metadata, dynamic client registration, an
* authorization endpoint that approves every request by redirecting straight
* back to the caller, a token endpoint, and a Streamable HTTP MCP endpoint
* that requires a bearer token this fixture issued and answers JSON-RPC with
* plain JSON. The `initialize`, `tools/list`, and `ping` answers are written
* by hand because `apps/web` carries no MCP SDK dependency; the scenario only
* needs the handshake and the tool listing to succeed.
*/
import { once } from 'node:events'
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'
/** The running fixture and what the browser and Host asked of it. */
export interface LinearOAuthFixture {
/** `http://127.0.0.1:<port>`; the MCP endpoint is `<origin>/mcp`. */
readonly origin: string
/** Authorization pages the browser opened. */
authorizations(): number
/** Errors thrown while answering requests, each answered with a 500; the scenario expects none. */
failures(): readonly unknown[]
/** Stop listening and close open connections. */
close(): Promise<void>
}
/**
* Listen on an OS-assigned loopback port.
* @returns the running fixture.
*/
export async function startLinearOAuthFixture(): Promise<LinearOAuthFixture> {
let origin = '', authorizations = 0, tokens = 0, registrations = 0
const issued = new Set<string>()
const failures: unknown[] = []
const json =(response: ServerResponse, value: unknown, status = 200): void => {
response.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify(value))
}
async function text(request: IncomingMessage): Promise<string> {
const chunks: Buffer[] = []
for await (const chunk of request) {
if (!(chunk instanceof Uint8Array)) throw new Error('Expected request bytes')
chunks.push(Buffer.from(chunk))
}
return Buffer.concat(chunks).toString()
}
async function handle(request: IncomingMessage, response: ServerResponse): Promise<void> {
const url = new URL(request.url!, origin)
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
json(response, { resource: origin + '/mcp', authorization_servers: [origin] })
} else if (url.pathname === '/.well-known/oauth-authorization-server') {
json(response, {
issuer: origin, authorization_endpoint: origin + '/authorize', token_endpoint: origin + '/token',
registration_endpoint: origin + '/register', response_types_supported: ['code'],
grant_types_supported: ['authorization_code', 'refresh_token'], code_challenge_methods_supported: ['S256'],
token_endpoint_auth_methods_supported: ['none'], authorization_response_iss_parameter_supported: true,
})
} else if (url.pathname === '/register') {
registrations++
const metadata = JSON.parse(await text(request)) as Record<string, unknown>
json(response, { ...metadata, client_id: 'linear-client-' + String(registrations), token_endpoint_auth_method: 'none' }, 201)
} else if (url.pathname === '/authorize') {
authorizations++
const callback = new URL(url.searchParams.get('redirect_uri')!)
callback.searchParams.set('code', 'linear-code-' + String(authorizations))
callback.searchParams.set('state', url.searchParams.get('state')!)
callback.searchParams.set('iss', origin)
response.writeHead(302, { location: callback.href }).end()
} else if (url.pathname === '/token') {
await text(request)
tokens++
const token = 'linear-access-' + String(tokens)
issued.add(token)
json(response, { access_token: token, refresh_token: 'linear-refresh-' + String(tokens), token_type: 'Bearer', expires_in: 3600 })
} else if (url.pathname === '/mcp') {
const token = request.headers.authorization?.replace(/^Bearer /u, '')
if (token === undefined || !issued.has(token)) {
response.writeHead(401, { 'www-authenticate': `Bearer resource_metadata="${origin}/.well-known/oauth-protected-resource/mcp"` }).end()
} else await answerMcp(request, response)
} else response.writeHead(404).end()
}
async function answerMcp(request: IncomingMessage, response: ServerResponse): Promise<void> {
if (request.method !== 'POST') { response.writeHead(405).end(); return }
const message = JSON.parse(await text(request)) as { id?: number | string; method: string; params?: { protocolVersion?: string } }
if (message.id === undefined) { response.writeHead(202).end(); return }
const reply = (result: unknown): void => { json(response, { jsonrpc: '2.0', id: message.id, result }) }
switch (message.method) {
case 'initialize':
reply({ protocolVersion: message.params?.protocolVersion, capabilities: { tools: {} }, serverInfo: { name: 'linear-fixture', version: '1.0.0' } })
break
case 'tools/list':
reply({ tools: [{ name: 'linear-search', description: 'Search the fixture workspace.', inputSchema: { type: 'object', properties: {} } }] })
break
case 'ping': reply({}); break
default: json(response, { jsonrpc: '2.0', id: message.id, error: { code: -32601, message: 'Method not found' } })
}
}
const server = createServer((request, response) => {
handle(request, response).catch((error: unknown) => {
failures.push(error)
if (!response.headersSent) response.writeHead(500).end()
})
})
server.listen(0, '127.0.0.1')
await once(server, 'listening')
const address = server.address()
if (address === null || typeof address === 'string') throw new Error('Linear OAuth fixture did not bind TCP')
origin = `http://127.0.0.1:${String(address.port)}`
return {
origin,
authorizations: () => authorizations,
failures: () => failures,
close: async () => {
await new Promise<void>((resolve, reject) => {
server.close((error) => { if (error === undefined) resolve(); else reject(error) })
server.closeAllConnections()
})
},
}
}
+76
View File
@@ -0,0 +1,76 @@
// Web e2e scenario: connecting the Notion plugin from its page on the Plugins
// page. The section reads the MCP manager's real entry, the browser opens the
// loopback authorization server's page, the Host callback answers with its
// completion page, the connection reaches the manager, and sign-out returns the
// section to disconnected. Zero model calls.
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Browser, BrowserContext, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { startNotionOAuthFixture, type NotionOAuthFixture } from './notion-oauth-fixture.ts'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts'
const NOTION_DIR = fileURLToPath(new URL('../../../packages/connector/notion', import.meta.url))
describe('web e2e: Notion plugin connection', () => {
let fixture: NotionOAuthFixture
let overlayDir: string
let scaffold: WebScaffold
let browser: Browser
let context: BrowserContext
let page: Page
let tripwire: ReturnType<typeof watchConsole>
beforeAll(async () => {
fixture = await startNotionOAuthFixture()
overlayDir = await mkdtemp(join(tmpdir(), 'dsh-notion-e2e-'))
const overlay = join(overlayDir, 'notion.overlay.yml')
await writeFile(overlay, `- id: notion\n config:\n url: ${fixture.origin}/mcp\n`)
scaffold = await launchWebScaffold({
extraOverlayPath: [fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)), overlay],
profile: { packages: [{ dir: NOTION_DIR, enabled: true }] },
})
browser = await chromium.launch()
context = await browser.newContext({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE })
page = await context.newPage()
tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
}, 120_000)
afterAll(async () => {
await browser?.close()
await scaffold?.close()
await fixture?.close()
if (overlayDir !== undefined) await rm(overlayDir, { recursive: true, force: true })
})
it('connects the account from the plugin page and signs out after confirmation', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-notion-connection'))
await page.getByRole('navigation', { name: '全局面板' }).getByRole('button', { name: '插件', exact: true }).click()
const panel = page.locator('[data-plugin-panel]')
await panel.getByRole('button', { name: '查看 Notion 插件', exact: true }).click({ timeout: 20_000 })
const section = panel.locator('[data-connector-account]')
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('disconnected')
expect(await panel.locator('[data-plugin-detail]').getByText('未连接', { exact: true }).count()).toBe(2)
const opened = context.waitForEvent('page')
await section.getByRole('button', { name: '连接 Notion', exact: true }).click()
const authorization = await opened
await expect.poll(async () => await authorization.locator('body').textContent(), { timeout: 20_000 })
.toContain('已收到授权。可以关闭此页,回到 DSH 查看连接结果。')
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('connected')
await page.getByText('Notion 已连接', { exact: true }).waitFor({ timeout: 10_000 })
expect(fixture.authorizations()).toBe(1)
await authorization.close()
await section.getByRole('button', { name: '退出登录', exact: true }).click()
await page.getByRole('dialog', { name: '退出 Notion 登录?' }).getByRole('button', { name: '退出登录', exact: true }).click()
await expect.poll(() => section.getAttribute('data-connector-account'), { timeout: 20_000 }).toBe('disconnected')
expect(tripwire.pageErrors).toEqual([])
})
})
+104
View File
@@ -0,0 +1,104 @@
/**
* Loopback stand-in for Notion's hosted MCP server: OAuth protected-resource
* and authorization-server metadata, dynamic client registration, an
* authorization endpoint that approves every request by redirecting straight
* back to the caller, a token endpoint, and a Streamable HTTP MCP endpoint
* that requires the issued bearer token and answers JSON-RPC with plain JSON.
*/
import { once } from 'node:events'
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'
/** The running fixture and what the browser and Host asked of it. */
export interface NotionOAuthFixture {
/** `http://127.0.0.1:<port>`; the MCP endpoint is `<origin>/mcp`. */
readonly origin: string
/** Authorization pages the browser opened. */
authorizations(): number
/** Stop listening and close open connections. */
close(): Promise<void>
}
/**
* Listen on an OS-assigned loopback port.
* @returns the running fixture.
*/
export async function startNotionOAuthFixture(): Promise<NotionOAuthFixture> {
let origin = '', authorizations = 0, tokens = 0, registrations = 0
const json = (response: ServerResponse, value: unknown, status = 200): void => {
response.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify(value))
}
async function text(request: IncomingMessage): Promise<string> {
const chunks: Buffer[] = []
for await (const chunk of request) {
if (!(chunk instanceof Uint8Array)) throw new Error('Expected request bytes')
chunks.push(Buffer.from(chunk))
}
return Buffer.concat(chunks).toString()
}
async function handle(request: IncomingMessage, response: ServerResponse): Promise<void> {
const url = new URL(request.url!, origin)
if (url.pathname.startsWith('/.well-known/oauth-protected-resource')) {
json(response, { resource: origin + '/mcp', authorization_servers: [origin] })
} else if (url.pathname === '/.well-known/oauth-authorization-server') {
json(response, {
issuer: origin, authorization_endpoint: origin + '/authorize', token_endpoint: origin + '/token',
registration_endpoint: origin + '/register', response_types_supported: ['code'],
grant_types_supported: ['authorization_code', 'refresh_token'], code_challenge_methods_supported: ['S256'],
token_endpoint_auth_methods_supported: ['none'], authorization_response_iss_parameter_supported: true,
})
} else if (url.pathname === '/register') {
registrations++
const metadata = JSON.parse(await text(request)) as Record<string, unknown>
json(response, { ...metadata, client_id: 'notion-client-' + String(registrations), token_endpoint_auth_method: 'none' }, 201)
} else if (url.pathname === '/authorize') {
authorizations++
const callback = new URL(url.searchParams.get('redirect_uri')!)
callback.searchParams.set('code', 'notion-code-' + String(authorizations))
callback.searchParams.set('state', url.searchParams.get('state')!)
callback.searchParams.set('iss', origin)
response.writeHead(302, { location: callback.href }).end()
} else if (url.pathname === '/token') {
await text(request)
tokens++
json(response, { access_token: 'notion-access-' + String(tokens), refresh_token: 'notion-refresh-' + String(tokens), token_type: 'Bearer', expires_in: 3600 })
} else if (url.pathname === '/mcp') {
if (request.headers.authorization === undefined) {
response.writeHead(401, { 'www-authenticate': `Bearer resource_metadata="${origin}/.well-known/oauth-protected-resource/mcp"` }).end()
} else await answerMcp(request, response)
} else response.writeHead(404).end()
}
async function answerMcp(request: IncomingMessage, response: ServerResponse): Promise<void> {
if (request.method !== 'POST') { response.writeHead(405).end(); return }
const message = JSON.parse(await text(request)) as { id?: number | string; method: string; params?: { protocolVersion?: string } }
if (message.id === undefined) { response.writeHead(202).end(); return }
const reply = (result: unknown): void => { json(response, { jsonrpc: '2.0', id: message.id, result }) }
switch (message.method) {
case 'initialize':
reply({ protocolVersion: message.params?.protocolVersion, capabilities: { tools: {} }, serverInfo: { name: 'notion-fixture', version: '1.0.0' } })
break
case 'tools/list':
reply({ tools: [{ name: 'notion-search', description: 'Search the fixture workspace.', inputSchema: { type: 'object', properties: {} } }] })
break
case 'ping': reply({}); break
default: json(response, { jsonrpc: '2.0', id: message.id, error: { code: -32601, message: 'Method not found' } })
}
}
const server = createServer((request, response) => {
handle(request, response).catch(() => { if (!response.headersSent) response.writeHead(500).end() })
})
server.listen(0, '127.0.0.1')
await once(server, 'listening')
const address = server.address()
if (address === null || typeof address === 'string') throw new Error('Notion OAuth fixture did not bind TCP')
origin = `http://127.0.0.1:${String(address.port)}`
return {
origin,
authorizations: () => authorizations,
close: async () => {
await new Promise<void>((resolve, reject) => {
server.close((error) => { if (error === undefined) resolve(); else reject(error) })
server.closeAllConnections()
})
},
}
}
+29 -8
View File
@@ -167,18 +167,33 @@ describe('web e2e: plugin configuration pages', () => {
await expect.poll(() => page.getByRole('menuitem').count()).toBe(0)
return items
}
// The shipped composition selects the DeepSeek Search API and local fetch, and the page writes nothing on mount.
expect(await searchMenu.textContent()).toBe('DeepSeek Search API')
// The shipped composition selects no search provider and local fetch, and the page writes nothing on mount.
expect(await searchMenu.textContent()).toBe('自动选择')
expect(await fetchMenu.textContent()).toBe('本机直接获取')
expect(await panel.getByRole('button', { name: '网页搜索提供方 DeepSeek Search API', exact: true }).count()).toBe(1)
expect(await panel.getByRole('button', { name: '网页搜索提供方 自动选择', exact: true }).count()).toBe(1)
expect(await panel.getByRole('button', { name: '网页获取提供方 本机直接获取', exact: true }).count()).toBe(1)
expect(await entries(searchMenu)).toEqual(['DeepSeek Search API', 'DeepSeek(旧版)'])
expect(await entries(searchMenu)).toEqual(['自动选择', 'DeepSeek Search API', 'DeepSeek 服务端搜索'])
expect(await entries(fetchMenu)).toEqual(['本机直接获取', 'DeepSeek Fetch API'])
expect(await settingsDocument()).not.toContain('searchProvider:')
// The page fixes the menu order itself; the Loader imports plugins concurrently, so the
// Host's registration order is not the YAML row order and only its membership is checked here.
const hostWeb = scaffold.ctx.get('web') as { listProviders(): Record<'search' | 'fetch', { id: string }[]> } | undefined
expect(hostWeb?.listProviders().search.map(provider => provider.id).sort()).toEqual(['deepseek-official', 'deepseek-search-api'])
// Automatic selection states which provider the Host runs for each model and shows no provider panel.
expect(await searchSection.getByText(
'跟随当前会话的模型:DeepSeek 模型使用 DeepSeek 服务端搜索,搜索不按次收费;其他模型使用 DeepSeek Search API。', { exact: true },
).count()).toBe(1)
expect(await searchSection.getByRole('link', { name: '网页搜索与获取指南', exact: true }).getAttribute('href'))
.toBe('https://api-docs.deepseek.com/zh-cn/guides/search')
expect(await searchSection.getByRole('textbox').count()).toBe(0)
expect(await save.isDisabled()).toBe(true)
// The composition names no search provider, so a selected one is stored.
await choose(searchMenu, 'DeepSeek Search API')
await save.click()
await expect.poll(() => save.isDisabled()).toBe(true)
await expect.poll(settingsDocument).toContain('searchProvider: deepseek-search-api')
expect(await panel.getByRole('button', { name: '网页搜索提供方 DeepSeek Search API', exact: true }).count()).toBe(1)
expect(await panel.getByRole('link', { name: '网页搜索与获取指南', exact: true }).getAttribute('href'))
.toBe('https://api-docs.deepseek.com/zh-cn/guides/search')
// Each section shows the description its selected provider registered with the Host, in the active language.
@@ -230,7 +245,7 @@ describe('web e2e: plugin configuration pages', () => {
await expect.poll(() => save.isDisabled()).toBe(true)
await expect.poll(settingsDocument).not.toContain('fetchProvider: deepseek-fetch-api')
await choose(searchMenu, 'DeepSeek(旧版)')
await choose(searchMenu, 'DeepSeek 服务端搜索')
const messagesEndpoint = panel.locator('#plugin-config-web-search-endpoint')
expect(await panel.getByLabel('单次请求最多搜索次数', { exact: true }).inputValue()).toBe('5')
await messagesEndpoint.fill('https://messages.test/anthropic/v1')
@@ -241,17 +256,23 @@ describe('web e2e: plugin configuration pages', () => {
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
await openPlugins()
await openPage(panel, '网页搜索与获取')
expect(await searchMenu.textContent()).toBe('DeepSeek(旧版)')
expect(await searchMenu.textContent()).toBe('DeepSeek 服务端搜索')
expect(await messagesEndpoint.inputValue()).toBe('https://messages.test/anthropic/v1')
expect(await entries(searchMenu)).toEqual(['DeepSeek Search API', 'DeepSeek(旧版)'])
expect(await entries(searchMenu)).toEqual(['自动选择', 'DeepSeek Search API', 'DeepSeek 服务端搜索'])
expect(await save.isDisabled()).toBe(true)
expect(await settingsDocument()).toContain('searchProvider: deepseek-official')
await choose(searchMenu, 'DeepSeek Search API')
await count.fill('20')
await save.click()
await expect.poll(() => save.isDisabled()).toBe(true)
await expect.poll(settingsDocument).not.toContain('searchProvider:')
await expect.poll(settingsDocument).toContain('searchProvider: deepseek-search-api')
expect(await settingsDocument()).toContain('count: 20')
// Automatic selection clears the stored provider.
await choose(searchMenu, '自动选择')
await save.click()
await expect.poll(() => save.isDisabled()).toBe(true)
await expect.poll(settingsDocument).not.toContain('searchProvider:')
expect(await searchMenu.textContent()).toBe('自动选择')
expect(await settingsDocument()).not.toMatch(/ApiKeyEnv:|searchBaseURL:|fetchBaseURL:/)
expect(tripwire.pageErrors).toEqual([])
})
+7 -2
View File
@@ -23,6 +23,7 @@ import {
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/plugin-manager', import.meta.url))
const MANAGER_EXPECTED = join(SNAPSHOT_DIR, 'manager.expected.md')
const TERMINAL_EXPECTED = join(SNAPSHOT_DIR, 'terminal.expected.md')
const LIVE_EXPECTED = join(SNAPSHOT_DIR, 'live-enabled.expected.md')
const EXPORTS_EXPECTED = join(SNAPSHOT_DIR, 'exports.expected.md')
const EXPORTS_EN_EXPECTED = join(SNAPSHOT_DIR, 'exports-en.expected.md')
@@ -849,7 +850,10 @@ describe('web e2e: plugin manager', () => {
expect(await panel.getByText(experimentalBundleDescription('inspector-profile', 'zh'), { exact: true }).count()).toBe(1)
const bundles = await scaffold.ctx.pluginManager.listBundles()
expect(bundles.some(bundle => bundle.name === '@deepseek-ai/dsh-experimental-terminal-bundle')).toBe(true)
expect(await panel.getByRole('switch', { name: '启用 持久终端', exact: true }).count()).toBe(0)
expect(await panel.getByRole('switch', { name: '启用 持久终端', exact: true }).getAttribute('aria-checked')).toBe('false')
await compareOrRefreshGolden(TERMINAL_EXPECTED, await captureStableAria(
page, '[data-plugin-group="more"] [data-plugin-package="@deepseek-ai/dsh-experimental-terminal-bundle"]', scaffold.workspaceCwd,
), MODE)
// The More list also omits LiveShare until its rows run, so the offered count is one lower than
// the eligible installed optional-bundle list.
expect(await panel.locator('[data-plugin-group="more"] [data-plugin-package="@deepseek-ai/dsh-experimental-liveshare"]').count()).toBe(0)
@@ -881,6 +885,7 @@ describe('web e2e: plugin manager', () => {
['@deepseek-ai/dsh-experimental-inspector-profile', 1],
...cuaSupported ? [['@deepseek-ai/dsh-cua-bundle', 1]] : [],
['@deepseek-ai/dsh-timeline', 1],
['@deepseek-ai/dsh-experimental-terminal-bundle', 1],
['@deepseek-ai/dsh-experimental-cot-translation-bundle', 1],
['@deepseek-ai/dsh-experimental-session-titles-bundle', 1],
['@deepseek-ai/dsh-experimental-badge-skill-bundle', 1],
@@ -1665,7 +1670,7 @@ describe('web e2e: plugin manager', () => {
it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
expect(tripwire.warnings).toEqual([])
await assertFixtureInventory(SNAPSHOT_DIR, [
'manager.expected.md', 'live-enabled.expected.md', 'missing-bundle.expected.md', 'exports.expected.md', 'exports-en.expected.md', 'icons.expected.md', 'loading.expected.md', 'refresh.expected.md',
'manager.expected.md', 'terminal.expected.md', 'live-enabled.expected.md', 'missing-bundle.expected.md', 'exports.expected.md', 'exports-en.expected.md', 'icons.expected.md', 'loading.expected.md', 'refresh.expected.md',
'ime-enter.expected.md', 'header-responsive.expected.md', 'header-natural-motion.expected.md', 'preview.expected.md',
'touch-tooltips.expected.md', 'forge-preview.expected.md', 'timeline-tracking.expected.md',
])
@@ -0,0 +1,6 @@
# The replayed conversation runs on a DeepSeek model route, where an unconfigured search selects
# legacy Messages search. This scenario exercises the DeepSeek Search API.
- id: web
config:
searchProvider: deepseek-search-api
fetchProvider: http
+2 -1
View File
@@ -247,7 +247,7 @@ describe.skipIf(process.platform === 'win32')('Web sidebar terminal', () => {
expect(tripwire.pageErrors).toEqual([])
})
it('starts in the current directory while earlier terminals and sandbox roots stay independent', async () => {
it('starts in the current directory while earlier terminals keep theirs and the sandbox root follows the directory', async () => {
onTestFailed(() => saveFailureShot(page, 'sidebar-terminal-directory'))
const agent = scaffold.ctx.agents.list()[0]!
const directories = agent.ctx.get('workingDirectory')
@@ -262,6 +262,7 @@ describe.skipIf(process.platform === 'win32')('Web sidebar terminal', () => {
if (sandbox === undefined) throw new Error('Session sandbox provider is missing')
const confine = vi.spyOn(sandbox, 'confine')
const selected = await directories.set(agent, child)
expect(sandboxPolicy.resolve({ session: agent.session })).toEqual({ ...policy, workspaceRoot: selected })
await openTerminal(page)
const firstProcess = processIdentity(0)
+5 -4
View File
@@ -1,5 +1,5 @@
// Web e2e scenario for the shipped default search provider, the DeepSeek
// Search API, with no provider selection patched. A real browser drives
// Web e2e scenario for the DeepSeek Search API, selected for a conversation
// on a DeepSeek model route. A real browser drives
// `web_search`; the model stream is replayed while the real DeepSeek provider
// calls a deterministic local Search API endpoint through the real
// credentials service.
@@ -141,7 +141,7 @@ async function startSearchServer(captured: CapturedSearchRequest[]): Promise<{ s
return { server, baseURL: `http://127.0.0.1:${address.port}` }
}
describe('web e2e: default Search API web search', () => {
describe('web e2e: Search API web search', () => {
let scaffold: WebScaffold
let browser: Browser
let page: Page
@@ -154,7 +154,8 @@ describe('web e2e: default Search API web search', () => {
const search = await startSearchServer(searchRequests)
searchServer = search.server
scaffold = await launchWebScaffold({
extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)),
extraOverlayPath: ['./pin-browse-picker.overlay.yml', './search-api-provider.overlay.yml']
.map(path => fileURLToPath(new URL(path, import.meta.url))),
compareReplaySession: true,
// Own YAML endpoint settings pin Search to the local endpoint and a dedicated key.
deepSeekWebApi: {
+4
View File
@@ -271,6 +271,10 @@
"tests/complex-history.perf.ts",
"tests/pwsh-terminal.e2e.ts",
"tests/workflow-run.e2e.ts",
"tests/linear-connection.e2e.ts",
"tests/linear-oauth-fixture.ts",
"tests/notion-connection.e2e.ts",
"tests/notion-oauth-fixture.ts",
"tests/tencent-docs-connection.e2e.ts",
"tests/tencent-docs-oauth-fixture.ts"
],
+2 -2
View File
@@ -6,5 +6,5 @@
en: 41d772192075e133
zh: 5ef3da69b4de1d8a
/capability-seams-and-core-services:
en: b8a43c17719d548b
zh: 3335f8c8fa696bae
en: e9a1a23c885fbae2
zh: 95137339b7fe8268
+17 -8
View File
@@ -62,6 +62,14 @@ flowchart LR
pkg_tool_pwsh["tool-pwsh"]
pkg_subagent["subagent"]
pkg_sdk_jsonrpc_server["sdk-jsonrpc-server"]
pkg_sandbox_policy["sandbox-policy"]
pkg_api_workspace_files["api-workspace-files"]
pkg_api_terminal_controller["api-terminal-controller"]
pkg_workspace_changes["workspace-changes"]
pkg_file_reference_local["file-reference-local"]
pkg_tool_skill["tool-skill"]
pkg_agent_instructions["agent-instructions"]
pkg_tool_lsp["tool-lsp"]
pkg_mcp_resources["mcp-resources"]
svc_mcpResources["ctx.mcpResources<br/>Scoped MCP resource access"]
pkg_mcp_client["mcp-client"]
@@ -123,11 +131,8 @@ flowchart LR
pkg_api_settings_controller["api-settings-controller"]
svc_credentialsController["ctx.credentialsController<br/>Host credential-surface Remote controller"]
svc_settingsController["ctx.settingsController<br/>Host settings-surface Remote controller"]
pkg_api_workspace_files["api-workspace-files"]
svc_workspaceFiles["ctx.workspaceFiles<br/>Host workspace file Remote service"]
pkg_workspace_changes["workspace-changes"]
svc_workspaceChanges["ctx.workspaceChanges<br/>Host per-turn changed-file summaries"]
pkg_api_terminal_controller["api-terminal-controller"]
svc_terminalController["ctx.terminalController<br/>Session interactive terminal Remote controller"]
pkg_api_workspace_controller["api-workspace-controller"]
svc_workspaceController["ctx.workspaceController<br/>Host Workspace Remote controller"]
@@ -187,7 +192,6 @@ flowchart LR
pkg_tool_session_query["tool-session-query"]
pkg_file_reference["file-reference"]
svc_fileReferences["ctx.fileReferences<br/>File reference discovery"]
pkg_file_reference_local["file-reference-local"]
svc_sessionReferenceResolver["ctx.sessionReferenceResolver<br/>Cross-session snapshot preparation"]
pkg_session_title["session-title"]
svc_sessionTitle["ctx.sessionTitle<br/>Log-backed session titles"]
@@ -201,7 +205,6 @@ flowchart LR
svc_tools["ctx.tools<br/>Scoped tool registry and executor selection"]
pkg_tool_ask_user["tool-ask-user"]
pkg_tool_cordis["tool-cordis"]
pkg_tool_skill["tool-skill"]
pkg_tool_todo["tool-todo"]
pkg_user_questions["user-questions"]
svc_userQuestions["ctx.userQuestions<br/>Human question/answer seam"]
@@ -264,7 +267,6 @@ flowchart LR
pkg_sandbox["sandbox"]
svc_sandbox["ctx.sandbox<br/>Process-sandbox seam"]
pkg_sandbox_local["sandbox-local"]
pkg_sandbox_policy["sandbox-policy"]
svc_sandboxPolicy["ctx.sandboxPolicy<br/>Sandbox policy home"]
pkg_fs_sandbox["fs-sandbox"]
pkg_user_approval["user-approval"]
@@ -331,7 +333,6 @@ flowchart LR
pkg_webhook_github["webhook-github"]
pkg_lsp["lsp"]
svc_lsp["ctx.lsp<br/>Language-server navigation seam"]
pkg_tool_lsp["tool-lsp"]
pkg_cordis_host_runner["cordis-host-runner"]
svc_dynamicCordisRunner["ctx.dynamicCordisRunner<br/>Dynamic Cordis package host runner"]
svc_cordisInspect["ctx.cordisInspect<br/>Dynamic Cordis inspect registry"]
@@ -681,11 +682,19 @@ flowchart LR
svc_webhookRuntime --> pkg_webhook_github
svc_workflowEngine --> pkg_tool_ralph
svc_workflowEngine --> pkg_tool_workflow
svc_workingDirectory --> pkg_agent_instructions
svc_workingDirectory --> pkg_api_terminal_controller
svc_workingDirectory --> pkg_api_workspace_files
svc_workingDirectory --> pkg_file_reference_local
svc_workingDirectory --> pkg_sandbox_policy
svc_workingDirectory --> pkg_sdk_jsonrpc_server
svc_workingDirectory --> pkg_subagent
svc_workingDirectory --> pkg_tool_bash
svc_workingDirectory --> pkg_tool_fs
svc_workingDirectory --> pkg_tool_lsp
svc_workingDirectory --> pkg_tool_pwsh
svc_workingDirectory --> pkg_tool_skill
svc_workingDirectory --> pkg_workspace_changes
svc_workspaceRegistry --> pkg_api_session_controller
svc_workspaceRegistry --> pkg_api_workspace_controller
svc_worktrees --> pkg_experimental_tool_worktree
@@ -713,7 +722,7 @@ flowchart LR
| `ctx.forgeSession` | `service` | [`experimental-forge-session`](../packages/experimental/forge-session) | - | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | A Session projection derives bindings from shell results and binding records and publishes their URLs without status to clients; push results trigger head-branch discovery, and Session watchers poll bound change requests through the forge registry. |
| `ctx.forgePanel` | `service` | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | - | - | Streams one panel state per followed Session: Git inspection using Session permissions, the recognized code host and its sign-in, and the bound change requests with polled status. |
| `ctx.worktrees` | `seam` | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | - | Explicit experimental creation from a pinned local commit. Existing write permissions govern checkout and shared Git metadata; the working-directory service owns the resulting Session directory. |
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server) | - | One Session projection owns the effective execution directory, which only Host operations move. The filesystem validates changes; user context reports them while original metadata and write grants stay fixed. |
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`api-workspace-files`](../packages/api/workspace-files), [`api-terminal-controller`](../packages/api/terminal-controller), [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | One Session projection owns the effective execution directory, which only Host operations move. The filesystem validates changes and user context reports them; model tools resolve paths from the directory, the sandbox boundary, file views, and discovery follow it, and original metadata stays fixed. |
| `ctx.mcpResources` | `seam` | [`mcp-resources`](../packages/mcp/mcp-resources) | [`mcp-client`](../packages/mcp/mcp-client) | [`mcp-resources`](../packages/mcp/mcp-resources) | - | Connection-owned providers serve shared resource tools in the calling agent scope. |
| `ctx.browserUse` | `seam` | [`browser-use`](../packages/browser-use/browser-use) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | - | One provider-owned name per service instance. Providers own their tools and browser resources per live Session; the shared service has no browser operation API. |
| `ctx.computerUse` | `seam` | [`computer-use`](../packages/computer-use/computer-use) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | - | One provider-owned name per service instance. Each provider also owns its model tools; the service has no common action API, runtime selection, or Session workflow lock. |
+17 -8
View File
@@ -64,6 +64,14 @@ flowchart LR
pkg_tool_pwsh["tool-pwsh"]
pkg_subagent["subagent"]
pkg_sdk_jsonrpc_server["sdk-jsonrpc-server"]
pkg_sandbox_policy["sandbox-policy"]
pkg_api_workspace_files["api-workspace-files"]
pkg_api_terminal_controller["api-terminal-controller"]
pkg_workspace_changes["workspace-changes"]
pkg_file_reference_local["file-reference-local"]
pkg_tool_skill["tool-skill"]
pkg_agent_instructions["agent-instructions"]
pkg_tool_lsp["tool-lsp"]
pkg_mcp_resources["mcp-resources"]
svc_mcpResources["ctx.mcpResources<br/>Scoped MCP resource access"]
pkg_mcp_client["mcp-client"]
@@ -125,11 +133,8 @@ flowchart LR
pkg_api_settings_controller["api-settings-controller"]
svc_credentialsController["ctx.credentialsController<br/>Host credential-surface Remote controller"]
svc_settingsController["ctx.settingsController<br/>Host settings-surface Remote controller"]
pkg_api_workspace_files["api-workspace-files"]
svc_workspaceFiles["ctx.workspaceFiles<br/>Host workspace file Remote service"]
pkg_workspace_changes["workspace-changes"]
svc_workspaceChanges["ctx.workspaceChanges<br/>Host per-turn changed-file summaries"]
pkg_api_terminal_controller["api-terminal-controller"]
svc_terminalController["ctx.terminalController<br/>Session interactive terminal Remote controller"]
pkg_api_workspace_controller["api-workspace-controller"]
svc_workspaceController["ctx.workspaceController<br/>Host Workspace Remote controller"]
@@ -189,7 +194,6 @@ flowchart LR
pkg_tool_session_query["tool-session-query"]
pkg_file_reference["file-reference"]
svc_fileReferences["ctx.fileReferences<br/>File reference discovery"]
pkg_file_reference_local["file-reference-local"]
svc_sessionReferenceResolver["ctx.sessionReferenceResolver<br/>Cross-session snapshot preparation"]
pkg_session_title["session-title"]
svc_sessionTitle["ctx.sessionTitle<br/>Log-backed session titles"]
@@ -203,7 +207,6 @@ flowchart LR
svc_tools["ctx.tools<br/>Scoped tool registry and executor selection"]
pkg_tool_ask_user["tool-ask-user"]
pkg_tool_cordis["tool-cordis"]
pkg_tool_skill["tool-skill"]
pkg_tool_todo["tool-todo"]
pkg_user_questions["user-questions"]
svc_userQuestions["ctx.userQuestions<br/>Human question/answer seam"]
@@ -266,7 +269,6 @@ flowchart LR
pkg_sandbox["sandbox"]
svc_sandbox["ctx.sandbox<br/>Process-sandbox seam"]
pkg_sandbox_local["sandbox-local"]
pkg_sandbox_policy["sandbox-policy"]
svc_sandboxPolicy["ctx.sandboxPolicy<br/>Sandbox policy home"]
pkg_fs_sandbox["fs-sandbox"]
pkg_user_approval["user-approval"]
@@ -333,7 +335,6 @@ flowchart LR
pkg_webhook_github["webhook-github"]
pkg_lsp["lsp"]
svc_lsp["ctx.lsp<br/>Language-server navigation seam"]
pkg_tool_lsp["tool-lsp"]
pkg_cordis_host_runner["cordis-host-runner"]
svc_dynamicCordisRunner["ctx.dynamicCordisRunner<br/>Dynamic Cordis package host runner"]
svc_cordisInspect["ctx.cordisInspect<br/>Dynamic Cordis inspect registry"]
@@ -683,11 +684,19 @@ flowchart LR
svc_webhookRuntime --> pkg_webhook_github
svc_workflowEngine --> pkg_tool_ralph
svc_workflowEngine --> pkg_tool_workflow
svc_workingDirectory --> pkg_agent_instructions
svc_workingDirectory --> pkg_api_terminal_controller
svc_workingDirectory --> pkg_api_workspace_files
svc_workingDirectory --> pkg_file_reference_local
svc_workingDirectory --> pkg_sandbox_policy
svc_workingDirectory --> pkg_sdk_jsonrpc_server
svc_workingDirectory --> pkg_subagent
svc_workingDirectory --> pkg_tool_bash
svc_workingDirectory --> pkg_tool_fs
svc_workingDirectory --> pkg_tool_lsp
svc_workingDirectory --> pkg_tool_pwsh
svc_workingDirectory --> pkg_tool_skill
svc_workingDirectory --> pkg_workspace_changes
svc_workspaceRegistry --> pkg_api_session_controller
svc_workspaceRegistry --> pkg_api_workspace_controller
svc_worktrees --> pkg_experimental_tool_worktree
@@ -715,7 +724,7 @@ flowchart LR
| `ctx.forgeSession` | `service` | [`experimental-forge-session`](../packages/experimental/forge-session) | - | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | Session 投影从 shell 结果与绑定记录派生绑定,并把不含状态的 URL 发布给客户端;推送结果触发按 head 分支的发现,Session 监听方通过 forge 注册表轮询已绑定的变更请求。 |
| `ctx.forgePanel` | `service` | [`experimental-client-ui-forge`](../packages/experimental/client-ui-forge) | - | - | - | 为每个被跟随的 Session 推送一份面板状态:使用 Session 权限进行的 Git 检查、识别出的代码托管平台及其登录状态,以及带轮询状态的已绑定变更请求。 |
| `ctx.worktrees` | `seam` | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-worktree`](../packages/experimental/worktree) | [`experimental-tool-worktree`](../packages/experimental/tool-worktree) | - | 显式实验组合从固定的本地提交创建工作树。检出目录与共享 Git 元数据受现有写权限约束;工作目录服务拥有创建后的 Session 目录。 |
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server) | - | 两个 Session 投影拥有有效执行目录与工作区根;Host 操作让两者一起移动。文件系统验证变更,用户上下文报告目录信息,原始元数据与写入授权保持不变。 |
| `ctx.workingDirectory` | `seam` | [`working-directory`](../packages/session/working-directory) | [`working-directory`](../packages/session/working-directory) | [`tool-fs`](../packages/fs/tool-fs), [`tool-bash`](../packages/shell/tool-bash), [`tool-pwsh`](../packages/shell/tool-pwsh), [`subagent`](../packages/subagent/subagent), [`sdk-jsonrpc-server`](../packages/sdk/server), [`sandbox-policy`](../packages/sandbox/sandbox-policy), [`api-workspace-files`](../packages/api/workspace-files), [`api-terminal-controller`](../packages/api/terminal-controller), [`workspace-changes`](../packages/deliverables/workspace-changes), [`file-reference-local`](../packages/context/file-reference-local), [`tool-skill`](../packages/skill/tool-skill), [`agent-instructions`](../packages/context/agent-instructions), [`tool-lsp`](../packages/lsp/tool-lsp) | - | 两个 Session 投影拥有有效执行目录与工作区根;Host 操作让两者一起移动。文件系统验证变更,用户上下文报告目录信息;模型工具从目录解析路径,沙箱边界、文件视图与发现跟随根,原始元数据保持不变。 |
| `ctx.mcpResources` | `seam` | [`mcp-resources`](../packages/mcp/mcp-resources) | [`mcp-client`](../packages/mcp/mcp-client) | [`mcp-resources`](../packages/mcp/mcp-resources) | - | 连接所有者提供的操作在调用 agent 的作用域内服务于共享资源工具。 |
| `ctx.browserUse` | `seam` | [`browser-use`](../packages/browser-use/browser-use) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | [`experimental-browser-use-playwright-mcp`](../packages/experimental/browser-use-playwright-mcp), [`experimental-browser-use-chrome-devtools-mcp`](../packages/experimental/browser-use-chrome-devtools-mcp), [`experimental-browser-use-stagehand-native`](../packages/experimental/browser-use-stagehand-native) | - | 每个服务实例注册一个提供方拥有的名称。提供方按实时 Session 拥有自己的工具与浏览器资源;共享服务不提供浏览器操作 API。 |
| `ctx.computerUse` | `seam` | [`computer-use`](../packages/computer-use/computer-use) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | [`experimental-computer-use-cua-driver-mcp`](../packages/experimental/computer-use-cua-driver-mcp), [`experimental-computer-use-cua-driver-native`](../packages/experimental/computer-use-cua-driver-native) | - | 每个服务实例只注册一个提供方自定的名称。各提供方也拥有自己的模型工具;服务不提供通用操作 API、运行时选择或 Session 流程锁。 |
+61 -9
View File
@@ -357,7 +357,7 @@ export interface Config {
## `@deepseek-ai/dsh-api-workspace-files`
- `inject`: `fs` · `sandboxPolicy` · `sessions` · `typert`
- `source`: [`packages/api/workspace-files/src/index.ts:74`](../packages/api/workspace-files/src/index.ts)
- `source`: [`packages/api/workspace-files/src/index.ts:100`](../packages/api/workspace-files/src/index.ts)
```ts config-catalog
/** Deployment caps on one page, one listing, or one search. */
@@ -1232,7 +1232,7 @@ export interface CotTranslationPreferences {
## `@deepseek-ai/dsh-experimental-client-ui-forge`
- `inject`: `forge` · `forgeSession` · `sessionProjections` · `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `agents`
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:530`](../packages/experimental/client-ui-forge/src/types.ts)
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:587`](../packages/experimental/client-ui-forge/src/types.ts)
```ts config-catalog
/** Host settings of the forge panel Remote. */
@@ -1287,6 +1287,14 @@ export interface Config {
maxCachedLensBytes?: number
/** Most line annotations a changes view shows in one file, across every annotation source. */
maxAnnotationsPerFile?: number
/** Milliseconds between two reads of the review page's lists while the page is open. */
reviewListIntervalMs?: number
/** Milliseconds between two reads of the review page's navigation count while it is shown. */
reviewCountIntervalMs?: number
/** Largest delay in milliseconds between two reads of the review page's lists or count after consecutive failures. */
reviewMaxBackoffMs?: number
/** Most change requests one review page list shows, capped by each provider's own limit. */
reviewPageSize?: number
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-experimental-client-ui-forge -->
@@ -1320,7 +1328,7 @@ export interface Config {
## `@deepseek-ai/dsh-experimental-forge`
- `source`: [`packages/experimental/forge/src/types.ts:638`](../packages/experimental/forge/src/types.ts)
- `source`: [`packages/experimental/forge/src/types.ts:767`](../packages/experimental/forge/src/types.ts)
```ts config-catalog
/** Poll cadence and fetch deadline for watched change requests. */
@@ -1365,6 +1373,8 @@ export interface Config {
maxCommits?: number
/** Most files whose viewed marks one read lists; GitHub lists at most 3,000 files of a pull request. */
maxViewedFiles?: number
/** Most pull requests one viewer list read returns, at most 100, the size of one GitHub search page. */
maxViewerItems?: number
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-experimental-forge-github -->
@@ -2104,6 +2114,25 @@ export interface Config {
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-jobs-local -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-linear -->
<a id="deepseek-aidsh-linear"></a>
## `@deepseek-ai/dsh-linear`
- `inject`: `mcpManager` · `systemPrompt`
- `source`: [`packages/connector/linear/src/index.ts:29`](../packages/connector/linear/src/index.ts)
```ts config-catalog
/** Linear MCP endpoint and tool loading for the managed server entry. */
export interface Config {
/** Streamable HTTP MCP endpoint; defaults to Linear's hosted server. */
url: string
/** `on-demand` (default) keeps Linear's tools hidden from each agent until it loads them; `eager` sends all of them. */
toolLoading: 'eager' | 'on-demand'
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-linear -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-llm-deepseek-account -->
<a id="deepseek-aidsh-llm-deepseek-account"></a>
@@ -2753,6 +2782,25 @@ export interface Config {
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-message-feedback -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-notion -->
<a id="deepseek-aidsh-notion"></a>
## `@deepseek-ai/dsh-notion`
- `inject`: `mcpManager` · `systemPrompt`
- `source`: [`packages/connector/notion/src/index.ts:29`](../packages/connector/notion/src/index.ts)
```ts config-catalog
/** Notion MCP endpoint and tool loading for the managed server entry. */
export interface Config {
/** Streamable HTTP MCP endpoint; defaults to Notion's hosted server. */
url: string
/** `on-demand` (default) keeps Notion's tools hidden from each agent until it loads them; `eager` sends all of them. */
toolLoading: 'eager' | 'on-demand'
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-notion -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-office-kit -->
<a id="deepseek-aidsh-office-kit"></a>
@@ -3196,7 +3244,7 @@ export interface Config {
- `inject`: `sessionProjections`
- `refs`: [`SandboxMode`](subsystems/sandbox.md)
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:95`](../packages/sandbox/sandbox-policy/src/index.ts)
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:96`](../packages/sandbox/sandbox-policy/src/index.ts)
```ts config-catalog
/**
@@ -3210,8 +3258,9 @@ export interface Config {
/** File-sandbox mode a session starts from (default: `read-only`). */
mode?: SandboxMode
/**
* Absolute fallback root for agentless calls and sessions without a cwd (default:
* `process.cwd()`). Normal agent calls use their session cwd instead.
* Absolute fallback root for agentless calls and, without the working-directory
* service, sessions without a header directory (default: `process.cwd()`).
* Normal agent calls use their session's working directory instead.
*/
workspaceRoot?: string
/**
@@ -5102,7 +5151,7 @@ export type ApprovalPolicy = 'ask' | 'never'
## `@deepseek-ai/dsh-web`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web/src/index.ts:62`](../packages/web/web/src/index.ts)
- `source`: [`packages/web/web/src/index.ts:77`](../packages/web/web/src/index.ts)
```ts config-catalog
/**
@@ -5114,7 +5163,10 @@ export type ApprovalPolicy = 'ask' | 'never'
* fields rather than introduce a hidden priority chain.
*/
export interface WebRuntimeConfig {
/** Explicit search provider id. Omitted = auto-select when exactly one usable. */
/**
* Explicit search provider id. Omitted = the usable DeepSeek provider assigned to the route of the model
* request, and otherwise auto-select when exactly one usable.
*/
readonly searchProvider: Volatile<string | undefined>
/** Explicit fetch provider id. Omitted = auto-select when exactly one usable. */
readonly fetchProvider: Volatile<string | undefined>
@@ -5333,7 +5385,7 @@ export interface Config {
## `@deepseek-ai/dsh-workspace-changes`
- `inject`: `subprocess` · `fs`
- `source`: [`packages/deliverables/workspace-changes/src/index.ts:34`](../packages/deliverables/workspace-changes/src/index.ts)
- `source`: [`packages/deliverables/workspace-changes/src/index.ts:35`](../packages/deliverables/workspace-changes/src/index.ts)
```ts config-catalog
/** Snapshot, capture, and comparison bounds. Invalid values fail plugin load. */
+61 -9
View File
@@ -359,7 +359,7 @@ export interface Config {
## `@deepseek-ai/dsh-api-workspace-files`
- `inject`: `fs` · `sandboxPolicy` · `sessions` · `typert`
- `source`: [`packages/api/workspace-files/src/index.ts:74`](../packages/api/workspace-files/src/index.ts)
- `source`: [`packages/api/workspace-files/src/index.ts:100`](../packages/api/workspace-files/src/index.ts)
```ts config-catalog
/** Deployment caps on one page, one listing, or one search. */
@@ -1234,7 +1234,7 @@ export interface CotTranslationPreferences {
## `@deepseek-ai/dsh-experimental-client-ui-forge`
- `inject`: `forge` · `forgeSession` · `sessionProjections` · `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `agents`
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:530`](../packages/experimental/client-ui-forge/src/types.ts)
- `source`: [`packages/experimental/client-ui-forge/src/types.ts:587`](../packages/experimental/client-ui-forge/src/types.ts)
```ts config-catalog
/** Host settings of the forge panel Remote. */
@@ -1289,6 +1289,14 @@ export interface Config {
maxCachedLensBytes?: number
/** Most line annotations a changes view shows in one file, across every annotation source. */
maxAnnotationsPerFile?: number
/** Milliseconds between two reads of the review page's lists while the page is open. */
reviewListIntervalMs?: number
/** Milliseconds between two reads of the review page's navigation count while it is shown. */
reviewCountIntervalMs?: number
/** Largest delay in milliseconds between two reads of the review page's lists or count after consecutive failures. */
reviewMaxBackoffMs?: number
/** Most change requests one review page list shows, capped by each provider's own limit. */
reviewPageSize?: number
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-experimental-client-ui-forge -->
@@ -1322,7 +1330,7 @@ export interface Config {
## `@deepseek-ai/dsh-experimental-forge`
- `source`: [`packages/experimental/forge/src/types.ts:638`](../packages/experimental/forge/src/types.ts)
- `source`: [`packages/experimental/forge/src/types.ts:767`](../packages/experimental/forge/src/types.ts)
```ts config-catalog
/** Poll cadence and fetch deadline for watched change requests. */
@@ -1367,6 +1375,8 @@ export interface Config {
maxCommits?: number
/** Most files whose viewed marks one read lists; GitHub lists at most 3,000 files of a pull request. */
maxViewedFiles?: number
/** Most pull requests one viewer list read returns, at most 100, the size of one GitHub search page. */
maxViewerItems?: number
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-experimental-forge-github -->
@@ -2106,6 +2116,25 @@ export interface Config {
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-jobs-local -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-linear -->
<a id="deepseek-aidsh-linear"></a>
## `@deepseek-ai/dsh-linear`
- `inject`: `mcpManager` · `systemPrompt`
- `source`: [`packages/connector/linear/src/index.ts:29`](../packages/connector/linear/src/index.ts)
```ts config-catalog
/** Linear MCP endpoint and tool loading for the managed server entry. */
export interface Config {
/** Streamable HTTP MCP endpoint; defaults to Linear's hosted server. */
url: string
/** `on-demand` (default) keeps Linear's tools hidden from each agent until it loads them; `eager` sends all of them. */
toolLoading: 'eager' | 'on-demand'
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-linear -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-llm-deepseek-account -->
<a id="deepseek-aidsh-llm-deepseek-account"></a>
@@ -2755,6 +2784,25 @@ export interface Config {
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-message-feedback -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-notion -->
<a id="deepseek-aidsh-notion"></a>
## `@deepseek-ai/dsh-notion`
- `inject`: `mcpManager` · `systemPrompt`
- `source`: [`packages/connector/notion/src/index.ts:29`](../packages/connector/notion/src/index.ts)
```ts config-catalog
/** Notion MCP endpoint and tool loading for the managed server entry. */
export interface Config {
/** Streamable HTTP MCP endpoint; defaults to Notion's hosted server. */
url: string
/** `on-demand` (default) keeps Notion's tools hidden from each agent until it loads them; `eager` sends all of them. */
toolLoading: 'eager' | 'on-demand'
}
```
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-notion -->
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-office-kit -->
<a id="deepseek-aidsh-office-kit"></a>
@@ -3198,7 +3246,7 @@ export interface Config {
- `inject`: `sessionProjections`
- `refs`: [`SandboxMode`](subsystems/sandbox.zh.md)
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:95`](../packages/sandbox/sandbox-policy/src/index.ts)
- `source`: [`packages/sandbox/sandbox-policy/src/index.ts:96`](../packages/sandbox/sandbox-policy/src/index.ts)
```ts config-catalog
/**
@@ -3212,8 +3260,9 @@ export interface Config {
/** File-sandbox mode a session starts from (default: `read-only`). */
mode?: SandboxMode
/**
* Absolute fallback root for agentless calls and sessions without a cwd (default:
* `process.cwd()`). Normal agent calls use their session cwd instead.
* Absolute fallback root for agentless calls and, without the working-directory
* service, sessions without a header directory (default: `process.cwd()`).
* Normal agent calls use their session's working directory instead.
*/
workspaceRoot?: string
/**
@@ -5104,7 +5153,7 @@ export type ApprovalPolicy = 'ask' | 'never'
## `@deepseek-ai/dsh-web`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/web/web/src/index.ts:62`](../packages/web/web/src/index.ts)
- `source`: [`packages/web/web/src/index.ts:77`](../packages/web/web/src/index.ts)
```ts config-catalog
/**
@@ -5116,7 +5165,10 @@ export type ApprovalPolicy = 'ask' | 'never'
* fields rather than introduce a hidden priority chain.
*/
export interface WebRuntimeConfig {
/** Explicit search provider id. Omitted = auto-select when exactly one usable. */
/**
* Explicit search provider id. Omitted = the usable DeepSeek provider assigned to the route of the model
* request, and otherwise auto-select when exactly one usable.
*/
readonly searchProvider: Volatile<string | undefined>
/** Explicit fetch provider id. Omitted = auto-select when exactly one usable. */
readonly fetchProvider: Volatile<string | undefined>
@@ -5335,7 +5387,7 @@ export interface Config {
## `@deepseek-ai/dsh-workspace-changes`
- `inject`: `subprocess` · `fs`
- `source`: [`packages/deliverables/workspace-changes/src/index.ts:34`](../packages/deliverables/workspace-changes/src/index.ts)
- `source`: [`packages/deliverables/workspace-changes/src/index.ts:35`](../packages/deliverables/workspace-changes/src/index.ts)
```ts config-catalog
/** Snapshot, capture, and comparison bounds. Invalid values fail plugin load. */
+3 -3
View File
@@ -47,8 +47,8 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `deepseek-account/signed-out` | `emit` | [`packages/account/deepseek-account/src/index.ts:28`](../packages/account/deepseek-account/src/index.ts) | [`deepseek-account`](../packages/account/deepseek-account) (`emit`) | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) |
| `domain/changed` | `emit` | [`packages/storage/storage-domain/src/events.ts:46`](../packages/storage/storage-domain/src/events.ts) | [`storage-domain`](../packages/storage/storage-domain) (`emit`) | `workspace-controller` |
| `feedback/committed` | `parallel` | [`packages/feedback/message-feedback/src/index.ts:58`](../packages/feedback/message-feedback/src/index.ts) | [`message-feedback`](../packages/feedback/message-feedback) (`parallel`) | [`session-telemetry-otel`](../packages/session/session-telemetry-otel) |
| `forge/providers-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:31`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `forge-session` |
| `forge/review-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:40`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge` |
| `forge/providers-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:32`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge`, `forge-session` |
| `forge/review-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:41`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge` |
| `fs/delete-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:83`](../packages/fs/fs/src/index.ts) | [`tool-fs`](../packages/fs/tool-fs) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `fs/edit-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:75`](../packages/fs/fs/src/index.ts) | `liveshare` (`waterfall`), [`tool-fs`](../packages/fs/tool-fs) (`waterfall`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `fs/observed` | `emit` | [`packages/fs/fs/src/index.ts:93`](../packages/fs/fs/src/index.ts) | `liveshare` (`emit`), [`tool-fs`](../packages/fs/tool-fs) (`emit`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`emit`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`skill-filesystem`](../packages/skill/skill-filesystem), `workspace-files` |
@@ -74,7 +74,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-telemetry`](../packages/session/session-telemetry) |
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
+3 -3
View File
@@ -49,8 +49,8 @@
| `deepseek-account/signed-out` | `emit` | [`packages/account/deepseek-account/src/index.ts:28`](../packages/account/deepseek-account/src/index.ts) | [`deepseek-account`](../packages/account/deepseek-account) (`emit`) | [`llm-deepseek-account`](../packages/llm/llm-deepseek-account) |
| `domain/changed` | `emit` | [`packages/storage/storage-domain/src/events.ts:46`](../packages/storage/storage-domain/src/events.ts) | [`storage-domain`](../packages/storage/storage-domain) (`emit`) | `workspace-controller` |
| `feedback/committed` | `parallel` | [`packages/feedback/message-feedback/src/index.ts:58`](../packages/feedback/message-feedback/src/index.ts) | [`message-feedback`](../packages/feedback/message-feedback) (`parallel`) | [`session-telemetry-otel`](../packages/session/session-telemetry-otel) |
| `forge/providers-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:31`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `forge-session` |
| `forge/review-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:40`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge` |
| `forge/providers-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:32`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge`, `forge-session` |
| `forge/review-changed` | `parallel` | [`packages/experimental/forge/src/index.ts:41`](../packages/experimental/forge/src/index.ts) | `forge` (`parallel`) | `client-ui-forge` |
| `fs/delete-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:83`](../packages/fs/fs/src/index.ts) | [`tool-fs`](../packages/fs/tool-fs) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `fs/edit-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:75`](../packages/fs/fs/src/index.ts) | `liveshare` (`waterfall`), [`tool-fs`](../packages/fs/tool-fs) (`waterfall`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `fs/observed` | `emit` | [`packages/fs/fs/src/index.ts:93`](../packages/fs/fs/src/index.ts) | `liveshare` (`emit`), [`tool-fs`](../packages/fs/tool-fs) (`emit`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`emit`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`skill-filesystem`](../packages/skill/skill-filesystem), `workspace-files` |
@@ -76,7 +76,7 @@
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`cua`](../packages/experimental/cua), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-telemetry`](../packages/session/session-telemetry) |
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
+6 -1
View File
@@ -244,6 +244,8 @@ flowchart TD
end
subgraph group_connector["packages/connector"]
pkg_cli_account["cli-account"]
pkg_linear["linear"]
pkg_notion["notion"]
pkg_tencent_docs["tencent-docs"]
pkg_upstream_skills["upstream-skills"]
end
@@ -967,6 +969,7 @@ flowchart TD
pkg_workspace_changes --> pkg_session
pkg_workspace_changes --> pkg_subprocess
pkg_workspace_changes --> pkg_tools
pkg_workspace_changes --> pkg_working_directory
pkg_creation_recommendations --> pkg_llm
pkg_creation_recommendations --> pkg_session
pkg_creation_recommendations --> pkg_skill
@@ -1719,6 +1722,8 @@ flowchart TD
| [`client-ui-workspace`](../packages/client/ui-workspace) | `client` | — |
| [`client-web`](../packages/client/web) | `client` | — |
| [`computer-use`](../packages/computer-use/computer-use) | `computer-use` | — |
| [`linear`](../packages/connector/linear) | `connector` | — |
| [`notion`](../packages/connector/notion) | `connector` | — |
| [`tencent-docs`](../packages/connector/tencent-docs) | `connector` | — |
| [`office-kit`](../packages/document/office-kit) | `document` | — |
| [`client-ui-action-cards`](../packages/experimental/client-ui-action-cards) | `experimental` | — |
@@ -1901,7 +1906,7 @@ flowchart TD
| [`agent-instructions`](../packages/context/agent-instructions) | `context` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`file-reference-local`](../packages/context/file-reference-local) | `context` | [`agent`](../packages/core/agent), [`file-reference`](../packages/context/file-reference), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`tool-present`](../packages/deliverables/tool-present) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`workspace-changes`](../packages/deliverables/workspace-changes) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools) |
| [`workspace-changes`](../packages/deliverables/workspace-changes) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`creation-recommendations`](../packages/experimental/creation-recommendations) | `experimental` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`skill`](../packages/skill/skill), [`tools`](../packages/core/tools) |
| [`cua-macos`](../packages/experimental/cua-macos) | `experimental` | [`agent`](../packages/core/agent), [`computer-use`](../packages/computer-use/computer-use), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
| [`cua-windows`](../packages/experimental/cua-windows) | `experimental` | [`agent`](../packages/core/agent), [`computer-use`](../packages/computer-use/computer-use), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
+6 -1
View File
@@ -246,6 +246,8 @@ flowchart TD
end
subgraph group_connector["packages/connector"]
pkg_cli_account["cli-account"]
pkg_linear["linear"]
pkg_notion["notion"]
pkg_tencent_docs["tencent-docs"]
pkg_upstream_skills["upstream-skills"]
end
@@ -969,6 +971,7 @@ flowchart TD
pkg_workspace_changes --> pkg_session
pkg_workspace_changes --> pkg_subprocess
pkg_workspace_changes --> pkg_tools
pkg_workspace_changes --> pkg_working_directory
pkg_creation_recommendations --> pkg_llm
pkg_creation_recommendations --> pkg_session
pkg_creation_recommendations --> pkg_skill
@@ -1721,6 +1724,8 @@ flowchart TD
| [`client-ui-workspace`](../packages/client/ui-workspace) | `client` | — |
| [`client-web`](../packages/client/web) | `client` | — |
| [`computer-use`](../packages/computer-use/computer-use) | `computer-use` | — |
| [`linear`](../packages/connector/linear) | `connector` | — |
| [`notion`](../packages/connector/notion) | `connector` | — |
| [`tencent-docs`](../packages/connector/tencent-docs) | `connector` | — |
| [`office-kit`](../packages/document/office-kit) | `document` | — |
| [`client-ui-action-cards`](../packages/experimental/client-ui-action-cards) | `experimental` | — |
@@ -1903,7 +1908,7 @@ flowchart TD
| [`agent-instructions`](../packages/context/agent-instructions) | `context` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`file-reference-local`](../packages/context/file-reference-local) | `context` | [`agent`](../packages/core/agent), [`file-reference`](../packages/context/file-reference), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`tool-present`](../packages/deliverables/tool-present) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`workspace-changes`](../packages/deliverables/workspace-changes) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools) |
| [`workspace-changes`](../packages/deliverables/workspace-changes) | `deliverables` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`session`](../packages/core/session), [`subprocess`](../packages/subprocess/subprocess), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
| [`creation-recommendations`](../packages/experimental/creation-recommendations) | `experimental` | [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`skill`](../packages/skill/skill), [`tools`](../packages/core/tools) |
| [`cua-macos`](../packages/experimental/cua-macos) | `experimental` | [`agent`](../packages/core/agent), [`computer-use`](../packages/computer-use/computer-use), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
| [`cua-windows`](../packages/experimental/cua-windows) | `experimental` | [`agent`](../packages/core/agent), [`computer-use`](../packages/computer-use/computer-use), [`subprocess`](../packages/subprocess/subprocess), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
+1 -1
View File
@@ -51,7 +51,7 @@ interface WorkspaceChangedFile {
interface WorkspaceChangesSummary {
/** The turn whose file changes this summary describes. */
turn: number
/** The Session working directory `path` values are relative to. */
/** The Session working directory `path` values are relative to, as it stood when the turn started. */
cwd: string
/** Changed files in `display` order, capped at the plugin's `maxFiles`. */
files: WorkspaceChangedFile[]
+1 -1
View File
@@ -51,7 +51,7 @@ interface WorkspaceChangedFile {
interface WorkspaceChangesSummary {
/** The turn whose file changes this summary describes. */
turn: number
/** The Session working directory `path` values are relative to. */
/** The Session working directory `path` values are relative to, as it stood when the turn started. */
cwd: string
/** Changed files in `display` order, capped at the plugin's `maxFiles`. */
files: WorkspaceChangedFile[]
+9 -3
View File
@@ -19,13 +19,19 @@
zh: 5349e9f25d08fd97
/forges/overview-and-viewed-marks:
en: fd5928603c9375b1
zh: 1a3bca55344ff385
zh: e5e32a588a18abae
/forges/viewer-lists-and-descriptions:
en: 05dba49e668fbd82
zh: 7502689f5dd46118
/forges/session-bindings:
en: 74255d6005e1c9e8
zh: 252d0d552f1e26a1
/forges/panel:
en: 0fc2e5a367d0a3ad
zh: a1028e4ecf61b70c
en: 83ad892728d13987
zh: d19b012f5898ef07
/forges/panel/review-page:
en: f576f6e104ec9546
zh: b97efdd34b3a9d1b
/forges/extension-api:
en: f35345e482e84f4f
zh: 2ecb7d9498decb31
+422 -2
View File
@@ -54,6 +54,20 @@ interface ForgeProvider {
readonly label: string
/** What this provider's hosts call a change request. */
readonly changeRequestNoun: ChangeRequestNoun
/**
* Where and which lists of the signed-in user's change requests this provider reads. A provider declares `viewer` and
* implements `listForViewer` and `countForViewer` together; omitting any declares that it reads no viewer lists.
*/
readonly viewer?: ForgeViewerCapability
/**
* Read one viewer list, most recently updated first. A query outside {@link ForgeProvider.viewer} resolves to an
* `unsupported` failure.
*/
listForViewer?(query: ForgeViewerQuery, signal: AbortSignal): Promise<ForgeViewerList | ForgeFailure>
/** Count the change requests in every list of {@link ForgeViewerCapability.filters} on one of its hosts. */
countForViewer?(host: string, signal: AbortSignal): Promise<ReadonlyMap<ForgeViewerFilter, number> | ForgeFailure>
/** Read the description and labels of a change request. Omission declares that this provider reads no descriptions. */
readDescription?(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestDescription | ForgeFailure>
/** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
/**
@@ -349,9 +363,11 @@ interface ForgeFailure {
* `not-found`: the host does not expose it; `unauthenticated`: credentials are missing or rejected;
* `too-large`: the host or the provider refuses an answer over its size limit, so reading again fails
* the same way; `stale`: the head is no longer the commit the read named, so reading again at the head of
* a later status can succeed; `unsupported`: the provider does not offer the read; `unavailable`: any other failure.
* a later status can succeed; `rate-limited`: the host refused the read under its rate limit, so reading again
* succeeds only after the limit resets; `unsupported`: the provider does not offer the read; `unavailable`: any other
* failure.
*/
readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'stale' | 'unsupported' | 'unavailable'
readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'stale' | 'rate-limited' | 'unsupported' | 'unavailable'
/** Human-readable cause. */
readonly message: string
}
@@ -750,6 +766,143 @@ interface ForgeViewedRequest {
}
```
## Viewer lists and descriptions
A provider that declares `viewer` reads three lists of open change requests that involve the signed-in user on each of its hosts: `review-requested`, `authored`, and `involved`, which never share a change request. `ctx.forge.viewerSources()` names each provider's hosts, lists, and `maxItems`; `ctx.forge.listForViewer` reads one list most recently updated first, as `ChangeRequestSummary` items without the checks, reviewers, and merge state of a snapshot; and `ctx.forge.countForViewer` reads the size of every list on one host. Neither read joins status polling: a caller polls a list itself and watches each change request it shows in full. A provider, host, or list that offers no viewer list resolves to `unsupported`, and a host that refuses under its rate limit resolves to `rate-limited`.
`ctx.forge.readDescription` reads the Markdown description and labels of a change request; raw HTML in its `body` must not render as HTML. `images` maps each image address a browser cannot load without the user's host session to an address the host issued for loading that image without one; those addresses stop loading at `imagesExpireAt`, after which a reader reads the description again. The [GitHub provider README](../../packages/experimental/forge-github/README.md#use-this-package) owns the searches and the image pairing.
```ts type-equiv
/**
* A list of open change requests that involve the signed-in user: `review-requested` asks the user or one of the user's
* teams for a review; `authored` names the user as author; `involved` names the user in any other way, as an assignee,
* a commenter, a reviewer, or a mention, and holds none of the other two lists' change requests.
*/
type ForgeViewerFilter = 'review-requested' | 'authored' | 'involved'
```
```ts type-equiv
/** Hosts a provider lists change requests on for the signed-in user, and the lists it offers there. */
interface ForgeViewerCapability {
/** Lowercase host names, each one this provider serves. */
readonly hosts: readonly string[]
/** The lists the provider reads on each of `hosts`. */
readonly filters: ReadonlySet<ForgeViewerFilter>
/** Most change requests one read returns, a positive integer. */
readonly maxItems: number
}
```
```ts type-equiv
/** A registered provider's viewer lists, as {@link ForgeViewerCapability} with the forge family that offers them. */
interface ForgeViewerSource extends ForgeViewerCapability {
/** Forge family of the provider. */
readonly forge: string
}
```
```ts type-equiv
/** One read of a list of open change requests that involve the signed-in user on one host. */
interface ForgeViewerQuery {
/** Lowercase host name from the provider's {@link ForgeViewerCapability.hosts}. */
readonly host: string
/** The list to read, from the provider's {@link ForgeViewerCapability.filters}. */
readonly filter: ForgeViewerFilter
/** One repository to read in, or null for every repository the user can read on `host`. */
readonly repository: Pick<ForgeRepository, 'owner' | 'name'> | null
/** Most change requests returned, a positive integer no greater than {@link ForgeViewerCapability.maxItems}. */
readonly limit: number
}
```
```ts type-equiv
/** The signed-in user's latest submitted review of a change request. */
interface ChangeRequestViewerReview {
/** Outcome of the review. */
readonly verdict: ReviewVerdict
/** Commit the review was on, or null when the host reports none. */
readonly reviewedSha: string | null
}
```
```ts type-equiv
/** Status of one change request as a viewer list reports it, without the checks, reviewers, and merge state of a snapshot. */
interface ChangeRequestSummary {
/** The change request. */
readonly ref: ChangeRequestRef
/** Web page of the change request. */
readonly url: string
/** Title as the author wrote it. */
readonly title: string
/** Whether the author marked the change request as a draft. */
readonly draft: boolean
/** Author, or null when the host hides the account. */
readonly author: ForgeCommentAuthor | null
/** Commit object name at the head of the change request. */
readonly headSha: string
/** Combined check outcome on the head commit. */
readonly checksRollup: ChecksRollup
/** Aggregate review outcome. */
readonly reviewDecision: ReviewDecision
/** The signed-in user's latest submitted review, or null before the first. */
readonly viewerReview: ChangeRequestViewerReview | null
/**
* The review request that asks the signed-in user, or null when none does: `team` names the team, as
* `organization/slug`, when the request asks a team the user belongs to rather than the user.
*/
readonly viewerRequest: { readonly team: string | null } | null
/** Issues the host closes once the change request merges, in host order, at most the provider's limit. */
readonly closingIssues: readonly ChangeRequestIssue[]
/** Whether the host reported more closing issues than `closingIssues` holds. */
readonly closingIssuesTruncated: boolean
/** ISO 8601 time of the host's last update to the change request. */
readonly updatedAt: string
}
```
```ts type-equiv
/** One page of a viewer list, most recently updated first. */
interface ForgeViewerList {
/** Login of the signed-in user the provider read as. */
readonly viewer: string
/** Change requests most recently updated first, at most the query's limit. */
readonly items: readonly ChangeRequestSummary[]
/** Number of change requests the host reports in the whole list; more than `items` holds when the list was cut. */
readonly total: number
}
```
```ts type-equiv
/** The description of a change request as its author wrote it. */
interface ChangeRequestDescription {
/** Markdown source; it may contain raw HTML, which readers must not render as HTML. Empty without a description. */
readonly body: string
/** Labels in host order, at most the provider's limit. */
readonly labels: readonly ChangeRequestLabel[]
/** Whether the change request has more labels than `labels` holds. */
readonly labelsTruncated: boolean
/**
* Image addresses that a browser cannot load without the user's host session, each mapped to an address the host
* issued for loading that image without one. Addresses not listed load as written.
*/
readonly images: Readonly<Record<string, string>>
/** ISO 8601 time after which the addresses in `images` stop loading, or null when there are none or the host names no time. */
readonly imagesExpireAt: string | null
/** ISO 8601 time the change request was created. */
readonly createdAt: string
}
```
```ts type-equiv
/** One label of a change request. */
interface ChangeRequestLabel {
/** Name as the host spells it. */
readonly name: string
/** Six-digit hexadecimal color without `#`, or null when the host reports none. */
readonly color: string | null
}
```
## Session bindings
`ctx.forgeSession` derives each Session's bindings from its own log by the command rules that providers register: forge-github's `gh` rule and forge-gitlab's `glab` rule bind the URLs that `gh pr create` and `glab mr create` results print and the change request that `gh pr view`, `glab mr view`, and their sibling reference commands act on, and `git push` results trigger head-branch discovery through `ctx.forge`; the panel also reports the branch its checkout tracks for the same discovery. Track, dismiss, and discovery actions are `plugin:forge-session/binding` records, which stay outside the model-visible conversation. The `forgeChangeRequests` projection's client view, which the Session summary carries, lists the bindings without their status. The [Session binding README](../../packages/experimental/forge-session/README.md#use-this-package) owns the recognition and discovery rules.
@@ -1367,6 +1520,12 @@ interface ForgeLocalChanges {
}
```
### Review page
The [code review page](../../packages/experimental/client-ui-forge/README.md#use-this-package) reads change requests by URL instead of through a Session binding. Its `forgePanel` methods (`reviewLists`, `reviewCount`, `reviewChangeRequest`, `reviewDescription`, and the `review*` reads and actions that mirror the Session-bound ones) resolve the URL with `ForgeService.changeRequestFromUrl`, fail with `forgePanel/unrecognized-url` when no provider serves it, and name no Session resource, so only callers that may use the Host's code host credentials reach them. One list hub reads the [viewer lists](#viewer-lists-and-descriptions) only while a list or count stream lasts: streams of one repository scope share one reader that reads every list of every host each `reviewListIntervalMs`, hosts in parallel and each host's lists in order, stops the round's further reads on a host that refuses the viewer or is rate-limited, and backs off after failed rounds up to `reviewMaxBackoffMs`; the count reads every `reviewCountIntervalMs`, and lists of every repository refresh it too. `reviewLists` streams `ForgeReviewFrame` values with each host's lists, the items of the latest successful read, and the failure of the latest read; `reviewCount` streams `ForgeReviewCountFrame` values; and `reviewChangeRequest` streams `ForgeReviewChangeRequest` values for the shown change request, which is polled through `ForgeService.watch` while its stream lasts.
The chat tab starts in the blank Session `connectWorkspace` resolves and records the change request with `reviewStage`; the Host keeps that choice in memory and binds the change request once the Session's next message enters its inbox, so an untouched blank stays unbound.
<a id="extension-api"></a>
## Extension API
@@ -1724,6 +1883,41 @@ async compare(ref: ChangeRequestRef, base: string, head: string, signal: AbortSi
*/
async mergeBase(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
/**
* List the viewer lists every registered provider offers; `forge/providers-changed` announces a change.
* @returns one source per provider that declares viewer lists and reads them, in registration order.
*/
viewerSources(): ForgeViewerSource[]
/**
* Read one list of open change requests that involve the signed-in user.
* @param forge - forge family of a registered provider.
* @param query - host, list, repository, and limit of the read.
* @param signal - cancellation of the read.
* @returns the list, or why the host did not provide it; `unsupported` when the provider does not offer the host or list.
* @throws when no provider serves `forge`, or with `signal.reason` when it aborts.
*/
async listForViewer(forge: string, query: ForgeViewerQuery, signal: AbortSignal): Promise<ForgeViewerList | ForgeFailure>
/**
* Count the change requests in each viewer list a provider offers on one host.
* @param forge - forge family of a registered provider.
* @param host - lowercase host name the provider lists on.
* @param signal - cancellation of the read.
* @returns the count of each list, or why the host did not provide them; `unsupported` when the provider does not list on `host`.
* @throws when no provider serves `forge`, or with `signal.reason` when it aborts.
*/
async countForViewer(forge: string, host: string, signal: AbortSignal): Promise<ReadonlyMap<ForgeViewerFilter, number> | ForgeFailure>
/**
* Read the description and labels of a change request.
* @param ref - change request served by a registered provider.
* @param signal - cancellation of the read.
* @returns the description, or why the host did not provide it; `unsupported` when the provider reads no descriptions.
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
*/
async readDescription(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestDescription | ForgeFailure>
/**
* Publish one comment or a completed review, then refresh the watched status; a publication the host took is announced
* with `forge/review-changed`.
@@ -1815,6 +2009,232 @@ Serves the forge panel. Following a Session inspects the checkout of its current
*/
@Remote({ mode: 'stream' }) async *changeRequestStates(signal: AbortSignal): AsyncIterable<ForgeChangeRequestStatesFrame>
/**
* Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
* the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
* reader, which reads every `reviewListIntervalMs` while some stream lasts and backs off after failed rounds up to
* `reviewMaxBackoffMs`; nothing is read while no stream lasts. The stream ends when `signal` aborts or the Remote stops.
* @param repository - one repository to list in, or null for every repository the user can read.
* @param signal - ends the stream.
* @returns frames, each complete.
*/
@Remote({ mode: 'stream' }) async *reviewLists( repository: { readonly owner: string; readonly name: string } | null, signal: AbortSignal, ): AsyncIterable<ForgeReviewFrame>
/**
* Stream the number of open change requests that ask the signed-in user for a review, summed over the hosts read:
* the latest count first, then each change. It is read every `reviewCountIntervalMs` while some stream lasts, and a
* list stream of every repository updates it as well. The stream ends when `signal` aborts or the Remote stops.
* @param signal - ends the stream.
* @returns frames, each complete.
*/
@Remote({ mode: 'stream' }) async *reviewCount(signal: AbortSignal): AsyncIterable<ForgeReviewCountFrame>
/**
* Read every streamed review page list and the count again at once.
* @param signal - request cancellation.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewRefresh(signal: AbortSignal): Promise<void>
/**
* Poll one change request the review page shows at once; its stream reports the result.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewPoll(url: string, signal: AbortSignal): Promise<void>
/**
* Stream one change request the review page shows in full: its latest polling result first, then each later result
* and each review change `forge/review-changed` announces for it. The change request is polled through `ctx.forge`
* while the stream lasts. Review page reads and actions name a change request by URL and need no Session binding, so
* only callers that may use the Host's code host credentials reach them.
* @param url - web URL of the change request.
* @param signal - ends the stream.
* @returns frames, each complete.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote({ mode: 'stream' }) async *reviewChangeRequest(url: string, signal: AbortSignal): AsyncIterable<ForgeReviewChangeRequest>
/**
* Read the description and labels of a change request for the review page.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @returns the description.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/description-failed` with the
* host's reason when the host does not provide it.
*/
@Remote async reviewDescription(url: string, signal: AbortSignal): Promise<ChangeRequestDescription>
/**
* Read every check of a change request the review page shows.
* @param url - web URL of the change request.
* @param headSha - head commit whose checks the page shows.
* @param signal - request cancellation.
* @returns the snapshot with every check.
* @throws as {@link ForgePanelController.changeRequestChecks} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewChecks(url: string, headSha: string, signal: AbortSignal): Promise<ChangeRequestSnapshot>
/**
* Read the review threads of a change request the review page shows, at the head of its latest status.
* @param url - web URL of the change request.
* @param headSha - head commit the page shows.
* @param fresh - whether to read from the host even when threads at this head and update time are kept.
* @param signal - request cancellation.
* @returns the threads at `headSha`.
* @throws as {@link ForgePanelController.changeRequestReview} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewThreads(url: string, headSha: string, fresh: boolean, signal: AbortSignal): Promise<ForgeReviewData>
/**
* Write to the review threads or the pending review of a change request the review page shows.
* @param url - web URL of the change request.
* @param write - the write and the head commit the user saw.
* @param signal - request cancellation.
* @returns whether the host took the write, as {@link ForgePanelController.changeRequestReviewWrite} does.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid write.
*/
@Remote async reviewThreadWrite(url: string, write: ForgeReviewWrite, signal: AbortSignal): Promise<ForgeReviewWriteResult>
/**
* Publish a line comment or a completed review on a change request the review page shows.
* @param url - web URL of the change request.
* @param request - reviewed head, ranges, plain text, and explicit review decision.
* @param signal - request cancellation.
* @returns confirmed publication or a typed failure, as {@link ForgePanelController.submitReview} does.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid review.
*/
@Remote async reviewSubmit(url: string, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
/**
* Read the changes of a change request the review page shows, or of consecutive commits of it.
* @param url - web URL of the change request.
* @param commits - consecutive commits of the change request, or null for all of it.
* @param signal - request cancellation.
* @returns the files and the commit they end at, without a local checkout count.
* @throws as {@link ForgePanelController.changeRequestDiff} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewDiff(url: string, commits: ForgeCommitRange | null, signal: AbortSignal): Promise<ForgeChangeRequestDiff>
/**
* List the commits of a change request the review page shows.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @returns the commits, or null when the provider does not read commits.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-failed` when the host does
* not list them.
*/
@Remote async reviewCommits(url: string, signal: AbortSignal): Promise<ForgeCommitList | null>
/**
* Read one file of a change request's repository at a commit for the review page.
* @param url - web URL of the change request.
* @param commit - commit object name.
* @param path - path relative to the repository root.
* @param signal - request cancellation.
* @returns the text.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-too-large` or
* `forgePanel/diff-failed` when the host does not provide the file.
*/
@Remote async reviewText(url: string, commit: string, path: string, signal: AbortSignal): Promise<string>
/**
* Read the signed-in user's viewed marks on the files of a change request the review page shows.
* @param url - web URL of the change request.
* @param headSha - head commit of the shown diff.
* @param signal - request cancellation.
* @returns the marks, or null when the provider keeps no viewed marks.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head` or
* `forgePanel/viewed-failed` as {@link ForgePanelController.changeRequestViewed} does.
*/
@Remote async reviewViewed(url: string, headSha: string, signal: AbortSignal): Promise<ForgeViewedFiles | null>
/**
* Set or clear the signed-in user's viewed mark on one file of a change request the review page shows.
* @param url - web URL of the change request.
* @param request - the file, its mark, and the head commit of the shown diff.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; the action errors of
* {@link ForgePanelController.setFileViewed}.
*/
@Remote async reviewSetViewed(url: string, request: ForgeViewedRequest, signal: AbortSignal): Promise<void>
/**
* Mark a draft change request the review page shows ready for review.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
* `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewMarkReady(url: string, signal: AbortSignal): Promise<void>
/**
* Merge a change request the review page shows while its head is still `headSha`.
* @param url - web URL of the change request.
* @param method - how the commits enter the base branch.
* @param headSha - head commit the user confirmed.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewMerge(url: string, method: MergeMethod, headSha: string, signal: AbortSignal): Promise<void>
/**
* Rerun the failed checks of a change request the review page shows.
* @param url - web URL of the change request.
* @param request - the head commit whose checks the user saw.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewRerunChecks(url: string, request: ForgeRerunRequest, signal: AbortSignal): Promise<void>
/**
* Request reviews of a change request the review page shows from more reviewers.
* @param url - web URL of the change request.
* @param reviewers - the reviewers to ask, by kind and login.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
* `forgePanel/action-unknown` with the host's reason; an error without reviewers.
*/
@Remote async reviewRequestReviews(url: string, reviewers: readonly Pick<ChangeRequestReviewer, 'kind' | 'login'>[], signal: AbortSignal): Promise<void>
/**
* List accounts a review of a change request the review page shows can be requested from.
* @param url - web URL of the change request.
* @param query - text the login or name contains; empty for the host's suggestions.
* @param signal - request cancellation.
* @returns the accounts, the host's suggestions first.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/reviewers-failed` when the host
* does not list them.
*/
@Remote async reviewReviewerCandidates(url: string, query: string, signal: AbortSignal): Promise<readonly ForgeReviewerCandidate[]>
/**
* Bring the base branch's new commits into the head branch of a change request the review page shows.
* @param url - web URL of the change request.
* @param method - merge or rebase.
* @param headSha - head commit the user confirmed.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewUpdateBranch(url: string, method: BranchUpdateMethod, headSha: string, signal: AbortSignal): Promise<void>
/**
* Remember the change request a review conversation's draft quotes, or forget it with null. When the Session's next
* message enters its inbox, the change request is bound to the Session with a `track` record before the turn starts;
* a Session that already started is bound at its next message. The choice lives in memory until then.
* @param session - the Session whose draft quotes the change request.
* @param url - web URL of the change request, or null.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewStage(session: Session, url: string | null, signal: AbortSignal): Promise<void>
/**
* Read or await the worktree service's archive cleanup of the Session's checkout.
* @param session - Session whose cleanup is visible to the caller.
+424 -2
View File
@@ -54,6 +54,20 @@ interface ForgeProvider {
readonly label: string
/** What this provider's hosts call a change request. */
readonly changeRequestNoun: ChangeRequestNoun
/**
* Where and which lists of the signed-in user's change requests this provider reads. A provider declares `viewer` and
* implements `listForViewer` and `countForViewer` together; omitting any declares that it reads no viewer lists.
*/
readonly viewer?: ForgeViewerCapability
/**
* Read one viewer list, most recently updated first. A query outside {@link ForgeProvider.viewer} resolves to an
* `unsupported` failure.
*/
listForViewer?(query: ForgeViewerQuery, signal: AbortSignal): Promise<ForgeViewerList | ForgeFailure>
/** Count the change requests in every list of {@link ForgeViewerCapability.filters} on one of its hosts. */
countForViewer?(host: string, signal: AbortSignal): Promise<ReadonlyMap<ForgeViewerFilter, number> | ForgeFailure>
/** Read the description and labels of a change request. Omission declares that this provider reads no descriptions. */
readDescription?(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestDescription | ForgeFailure>
/** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
/**
@@ -349,9 +363,11 @@ interface ForgeFailure {
* `not-found`: the host does not expose it; `unauthenticated`: credentials are missing or rejected;
* `too-large`: the host or the provider refuses an answer over its size limit, so reading again fails
* the same way; `stale`: the head is no longer the commit the read named, so reading again at the head of
* a later status can succeed; `unsupported`: the provider does not offer the read; `unavailable`: any other failure.
* a later status can succeed; `rate-limited`: the host refused the read under its rate limit, so reading again
* succeeds only after the limit resets; `unsupported`: the provider does not offer the read; `unavailable`: any other
* failure.
*/
readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'stale' | 'unsupported' | 'unavailable'
readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'stale' | 'rate-limited' | 'unsupported' | 'unavailable'
/** Human-readable cause. */
readonly message: string
}
@@ -752,6 +768,145 @@ interface ForgeViewedRequest {
}
```
<a id="viewer-lists-and-descriptions"></a>
## 登录用户的列表与描述
声明了 `viewer` 的提供方在它的每个主机上读取与登录用户有关的三类打开的变更请求:`review-requested`、`authored` 与 `involved`,三者互不重叠。`ctx.forge.viewerSources()` 列出每个提供方的主机、列表与 `maxItems`;`ctx.forge.listForViewer` 按最近更新在前读取一个列表,每项是 `ChangeRequestSummary`,不含快照的检查、评审者与合并状态;`ctx.forge.countForViewer` 读取一个主机上每个列表的总数。两者都不进入状态轮询:调用方自行轮询列表,并对完整展示的变更请求单独 watch。提供方、主机或列表不提供查看者列表时返回 `unsupported`,主机按限流拒绝时返回 `rate-limited`。
`ctx.forge.readDescription` 读取变更请求的 Markdown 描述与标签;`body` 中的原始 HTML 不得按 HTML 渲染。`images` 把浏览器在没有用户托管平台会话时无法加载的图片地址,映射为托管平台签发、无需会话即可加载该图片的地址;这些地址在 `imagesExpireAt` 之后失效,之后读者应重新读取描述。搜索与图片配对由 [GitHub 提供方 README](../../packages/experimental/forge-github/README.zh.md#use-this-package) 说明。
```ts type-equiv
/**
* A list of open change requests that involve the signed-in user: `review-requested` asks the user or one of the user's
* teams for a review; `authored` names the user as author; `involved` names the user in any other way, as an assignee,
* a commenter, a reviewer, or a mention, and holds none of the other two lists' change requests.
*/
type ForgeViewerFilter = 'review-requested' | 'authored' | 'involved'
```
```ts type-equiv
/** Hosts a provider lists change requests on for the signed-in user, and the lists it offers there. */
interface ForgeViewerCapability {
/** Lowercase host names, each one this provider serves. */
readonly hosts: readonly string[]
/** The lists the provider reads on each of `hosts`. */
readonly filters: ReadonlySet<ForgeViewerFilter>
/** Most change requests one read returns, a positive integer. */
readonly maxItems: number
}
```
```ts type-equiv
/** A registered provider's viewer lists, as {@link ForgeViewerCapability} with the forge family that offers them. */
interface ForgeViewerSource extends ForgeViewerCapability {
/** Forge family of the provider. */
readonly forge: string
}
```
```ts type-equiv
/** One read of a list of open change requests that involve the signed-in user on one host. */
interface ForgeViewerQuery {
/** Lowercase host name from the provider's {@link ForgeViewerCapability.hosts}. */
readonly host: string
/** The list to read, from the provider's {@link ForgeViewerCapability.filters}. */
readonly filter: ForgeViewerFilter
/** One repository to read in, or null for every repository the user can read on `host`. */
readonly repository: Pick<ForgeRepository, 'owner' | 'name'> | null
/** Most change requests returned, a positive integer no greater than {@link ForgeViewerCapability.maxItems}. */
readonly limit: number
}
```
```ts type-equiv
/** The signed-in user's latest submitted review of a change request. */
interface ChangeRequestViewerReview {
/** Outcome of the review. */
readonly verdict: ReviewVerdict
/** Commit the review was on, or null when the host reports none. */
readonly reviewedSha: string | null
}
```
```ts type-equiv
/** Status of one change request as a viewer list reports it, without the checks, reviewers, and merge state of a snapshot. */
interface ChangeRequestSummary {
/** The change request. */
readonly ref: ChangeRequestRef
/** Web page of the change request. */
readonly url: string
/** Title as the author wrote it. */
readonly title: string
/** Whether the author marked the change request as a draft. */
readonly draft: boolean
/** Author, or null when the host hides the account. */
readonly author: ForgeCommentAuthor | null
/** Commit object name at the head of the change request. */
readonly headSha: string
/** Combined check outcome on the head commit. */
readonly checksRollup: ChecksRollup
/** Aggregate review outcome. */
readonly reviewDecision: ReviewDecision
/** The signed-in user's latest submitted review, or null before the first. */
readonly viewerReview: ChangeRequestViewerReview | null
/**
* The review request that asks the signed-in user, or null when none does: `team` names the team, as
* `organization/slug`, when the request asks a team the user belongs to rather than the user.
*/
readonly viewerRequest: { readonly team: string | null } | null
/** Issues the host closes once the change request merges, in host order, at most the provider's limit. */
readonly closingIssues: readonly ChangeRequestIssue[]
/** Whether the host reported more closing issues than `closingIssues` holds. */
readonly closingIssuesTruncated: boolean
/** ISO 8601 time of the host's last update to the change request. */
readonly updatedAt: string
}
```
```ts type-equiv
/** One page of a viewer list, most recently updated first. */
interface ForgeViewerList {
/** Login of the signed-in user the provider read as. */
readonly viewer: string
/** Change requests most recently updated first, at most the query's limit. */
readonly items: readonly ChangeRequestSummary[]
/** Number of change requests the host reports in the whole list; more than `items` holds when the list was cut. */
readonly total: number
}
```
```ts type-equiv
/** The description of a change request as its author wrote it. */
interface ChangeRequestDescription {
/** Markdown source; it may contain raw HTML, which readers must not render as HTML. Empty without a description. */
readonly body: string
/** Labels in host order, at most the provider's limit. */
readonly labels: readonly ChangeRequestLabel[]
/** Whether the change request has more labels than `labels` holds. */
readonly labelsTruncated: boolean
/**
* Image addresses that a browser cannot load without the user's host session, each mapped to an address the host
* issued for loading that image without one. Addresses not listed load as written.
*/
readonly images: Readonly<Record<string, string>>
/** ISO 8601 time after which the addresses in `images` stop loading, or null when there are none or the host names no time. */
readonly imagesExpireAt: string | null
/** ISO 8601 time the change request was created. */
readonly createdAt: string
}
```
```ts type-equiv
/** One label of a change request. */
interface ChangeRequestLabel {
/** Name as the host spells it. */
readonly name: string
/** Six-digit hexadecimal color without `#`, or null when the host reports none. */
readonly color: string | null
}
```
## Session 绑定
`ctx.forgeSession` 按提供方注册的命令规则,从每个 Session 自己的日志派生其绑定:forge-github 的 `gh` 规则与 forge-gitlab 的 `glab` 规则绑定 `gh pr create` 与 `glab mr create` 结果输出的 URL,以及 `gh pr view`、`glab mr view` 及其同类引用命令所操作的变更请求,`git push` 的结果通过 `ctx.forge` 触发按 head 分支的发现;面板也会报告其检出所跟踪的分支,触发同样的发现。track、dismiss 与发现操作都是 `plugin:forge-session/binding` 插件记录,位于模型可见对话之外。`forgeChangeRequests` 投影的客户端视图随 Session 摘要下发,列出绑定但不含其状态。识别与发现规则见 [Session 绑定 README](../../packages/experimental/forge-session/README.zh.md#use-this-package)。
@@ -1369,6 +1524,12 @@ interface ForgeLocalChanges {
}
```
### 代码评审页
[代码评审页](../../packages/experimental/client-ui-forge/README.zh.md#use-this-package)按 URL 读取变更请求,而不经过会话绑定。它的 `forgePanel` 方法(`reviewLists`、`reviewCount`、`reviewChangeRequest`、`reviewDescription`,以及与会话绑定版本对应的各个 `review*` 读取与操作)用 `ForgeService.changeRequestFromUrl` 解析 URL,没有提供方能处理时以 `forgePanel/unrecognized-url` 失败;它们不指向任何会话资源,因此只有可以使用 Host 代码托管凭据的调用方能访问。一个列表中心只在列表流或计数流存在时读取[登录用户的列表](#viewer-lists-and-descriptions):同一仓库范围的流共用一个读取器,它每隔 `reviewListIntervalMs` 读取每个主机的每个列表,各主机并行、同一主机的列表依次读取;某主机拒绝当前用户或触发限流时,本轮不再读取它的其余列表;连续失败的轮次按 `reviewMaxBackoffMs` 为上限退避。计数每隔 `reviewCountIntervalMs` 读取一次,全部仓库范围的列表读取也会更新它。`reviewLists` 流式返回 `ForgeReviewFrame`,含每个主机的列表、最近一次成功读取的条目以及最近一次读取的失败;`reviewCount` 流式返回 `ForgeReviewCountFrame`;`reviewChangeRequest` 为显示中的变更请求流式返回 `ForgeReviewChangeRequest`,该变更请求在其流存在期间经 `ForgeService.watch` 轮询。
对话标签在 `connectWorkspace` 解析出的空白会话中开始,并用 `reviewStage` 记录该变更请求;Host 只在内存中保存这个选择,等该会话的下一条消息进入收件箱时再绑定,因此未使用的空白会话保持未绑定。
<a id="extension-api"></a>
## 扩展 API
@@ -1726,6 +1887,41 @@ async compare(ref: ChangeRequestRef, base: string, head: string, signal: AbortSi
*/
async mergeBase(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
/**
* List the viewer lists every registered provider offers; `forge/providers-changed` announces a change.
* @returns one source per provider that declares viewer lists and reads them, in registration order.
*/
viewerSources(): ForgeViewerSource[]
/**
* Read one list of open change requests that involve the signed-in user.
* @param forge - forge family of a registered provider.
* @param query - host, list, repository, and limit of the read.
* @param signal - cancellation of the read.
* @returns the list, or why the host did not provide it; `unsupported` when the provider does not offer the host or list.
* @throws when no provider serves `forge`, or with `signal.reason` when it aborts.
*/
async listForViewer(forge: string, query: ForgeViewerQuery, signal: AbortSignal): Promise<ForgeViewerList | ForgeFailure>
/**
* Count the change requests in each viewer list a provider offers on one host.
* @param forge - forge family of a registered provider.
* @param host - lowercase host name the provider lists on.
* @param signal - cancellation of the read.
* @returns the count of each list, or why the host did not provide them; `unsupported` when the provider does not list on `host`.
* @throws when no provider serves `forge`, or with `signal.reason` when it aborts.
*/
async countForViewer(forge: string, host: string, signal: AbortSignal): Promise<ReadonlyMap<ForgeViewerFilter, number> | ForgeFailure>
/**
* Read the description and labels of a change request.
* @param ref - change request served by a registered provider.
* @param signal - cancellation of the read.
* @returns the description, or why the host did not provide it; `unsupported` when the provider reads no descriptions.
* @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
*/
async readDescription(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestDescription | ForgeFailure>
/**
* Publish one comment or a completed review, then refresh the watched status; a publication the host took is announced
* with `forge/review-changed`.
@@ -1817,6 +2013,232 @@ Serves the forge panel. Following a Session inspects the checkout of its current
*/
@Remote({ mode: 'stream' }) async *changeRequestStates(signal: AbortSignal): AsyncIterable<ForgeChangeRequestStatesFrame>
/**
* Stream the review page's lists of the signed-in user's open change requests on every host a provider lists them on:
* the lists read so far first, then a frame after each read settles. Readers of one repository scope share one
* reader, which reads every `reviewListIntervalMs` while some stream lasts and backs off after failed rounds up to
* `reviewMaxBackoffMs`; nothing is read while no stream lasts. The stream ends when `signal` aborts or the Remote stops.
* @param repository - one repository to list in, or null for every repository the user can read.
* @param signal - ends the stream.
* @returns frames, each complete.
*/
@Remote({ mode: 'stream' }) async *reviewLists( repository: { readonly owner: string; readonly name: string } | null, signal: AbortSignal, ): AsyncIterable<ForgeReviewFrame>
/**
* Stream the number of open change requests that ask the signed-in user for a review, summed over the hosts read:
* the latest count first, then each change. It is read every `reviewCountIntervalMs` while some stream lasts, and a
* list stream of every repository updates it as well. The stream ends when `signal` aborts or the Remote stops.
* @param signal - ends the stream.
* @returns frames, each complete.
*/
@Remote({ mode: 'stream' }) async *reviewCount(signal: AbortSignal): AsyncIterable<ForgeReviewCountFrame>
/**
* Read every streamed review page list and the count again at once.
* @param signal - request cancellation.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewRefresh(signal: AbortSignal): Promise<void>
/**
* Poll one change request the review page shows at once; its stream reports the result.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewPoll(url: string, signal: AbortSignal): Promise<void>
/**
* Stream one change request the review page shows in full: its latest polling result first, then each later result
* and each review change `forge/review-changed` announces for it. The change request is polled through `ctx.forge`
* while the stream lasts. Review page reads and actions name a change request by URL and need no Session binding, so
* only callers that may use the Host's code host credentials reach them.
* @param url - web URL of the change request.
* @param signal - ends the stream.
* @returns frames, each complete.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote({ mode: 'stream' }) async *reviewChangeRequest(url: string, signal: AbortSignal): AsyncIterable<ForgeReviewChangeRequest>
/**
* Read the description and labels of a change request for the review page.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @returns the description.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/description-failed` with the
* host's reason when the host does not provide it.
*/
@Remote async reviewDescription(url: string, signal: AbortSignal): Promise<ChangeRequestDescription>
/**
* Read every check of a change request the review page shows.
* @param url - web URL of the change request.
* @param headSha - head commit whose checks the page shows.
* @param signal - request cancellation.
* @returns the snapshot with every check.
* @throws as {@link ForgePanelController.changeRequestChecks} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewChecks(url: string, headSha: string, signal: AbortSignal): Promise<ChangeRequestSnapshot>
/**
* Read the review threads of a change request the review page shows, at the head of its latest status.
* @param url - web URL of the change request.
* @param headSha - head commit the page shows.
* @param fresh - whether to read from the host even when threads at this head and update time are kept.
* @param signal - request cancellation.
* @returns the threads at `headSha`.
* @throws as {@link ForgePanelController.changeRequestReview} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewThreads(url: string, headSha: string, fresh: boolean, signal: AbortSignal): Promise<ForgeReviewData>
/**
* Write to the review threads or the pending review of a change request the review page shows.
* @param url - web URL of the change request.
* @param write - the write and the head commit the user saw.
* @param signal - request cancellation.
* @returns whether the host took the write, as {@link ForgePanelController.changeRequestReviewWrite} does.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid write.
*/
@Remote async reviewThreadWrite(url: string, write: ForgeReviewWrite, signal: AbortSignal): Promise<ForgeReviewWriteResult>
/**
* Publish a line comment or a completed review on a change request the review page shows.
* @param url - web URL of the change request.
* @param request - reviewed head, ranges, plain text, and explicit review decision.
* @param signal - request cancellation.
* @returns confirmed publication or a typed failure, as {@link ForgePanelController.submitReview} does.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; an error for an invalid review.
*/
@Remote async reviewSubmit(url: string, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
/**
* Read the changes of a change request the review page shows, or of consecutive commits of it.
* @param url - web URL of the change request.
* @param commits - consecutive commits of the change request, or null for all of it.
* @param signal - request cancellation.
* @returns the files and the commit they end at, without a local checkout count.
* @throws as {@link ForgePanelController.changeRequestDiff} does, with `forgePanel/unrecognized-url` in place of
* `forgePanel/not-bound`.
*/
@Remote async reviewDiff(url: string, commits: ForgeCommitRange | null, signal: AbortSignal): Promise<ForgeChangeRequestDiff>
/**
* List the commits of a change request the review page shows.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @returns the commits, or null when the provider does not read commits.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-failed` when the host does
* not list them.
*/
@Remote async reviewCommits(url: string, signal: AbortSignal): Promise<ForgeCommitList | null>
/**
* Read one file of a change request's repository at a commit for the review page.
* @param url - web URL of the change request.
* @param commit - commit object name.
* @param path - path relative to the repository root.
* @param signal - request cancellation.
* @returns the text.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/diff-too-large` or
* `forgePanel/diff-failed` when the host does not provide the file.
*/
@Remote async reviewText(url: string, commit: string, path: string, signal: AbortSignal): Promise<string>
/**
* Read the signed-in user's viewed marks on the files of a change request the review page shows.
* @param url - web URL of the change request.
* @param headSha - head commit of the shown diff.
* @param signal - request cancellation.
* @returns the marks, or null when the provider keeps no viewed marks.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head` or
* `forgePanel/viewed-failed` as {@link ForgePanelController.changeRequestViewed} does.
*/
@Remote async reviewViewed(url: string, headSha: string, signal: AbortSignal): Promise<ForgeViewedFiles | null>
/**
* Set or clear the signed-in user's viewed mark on one file of a change request the review page shows.
* @param url - web URL of the change request.
* @param request - the file, its mark, and the head commit of the shown diff.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; the action errors of
* {@link ForgePanelController.setFileViewed}.
*/
@Remote async reviewSetViewed(url: string, request: ForgeViewedRequest, signal: AbortSignal): Promise<void>
/**
* Mark a draft change request the review page shows ready for review.
* @param url - web URL of the change request.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
* `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewMarkReady(url: string, signal: AbortSignal): Promise<void>
/**
* Merge a change request the review page shows while its head is still `headSha`.
* @param url - web URL of the change request.
* @param method - how the commits enter the base branch.
* @param headSha - head commit the user confirmed.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewMerge(url: string, method: MergeMethod, headSha: string, signal: AbortSignal): Promise<void>
/**
* Rerun the failed checks of a change request the review page shows.
* @param url - web URL of the change request.
* @param request - the head commit whose checks the user saw.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewRerunChecks(url: string, request: ForgeRerunRequest, signal: AbortSignal): Promise<void>
/**
* Request reviews of a change request the review page shows from more reviewers.
* @param url - web URL of the change request.
* @param reviewers - the reviewers to ask, by kind and login.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/action-failed` or
* `forgePanel/action-unknown` with the host's reason; an error without reviewers.
*/
@Remote async reviewRequestReviews(url: string, reviewers: readonly Pick<ChangeRequestReviewer, 'kind' | 'login'>[], signal: AbortSignal): Promise<void>
/**
* List accounts a review of a change request the review page shows can be requested from.
* @param url - web URL of the change request.
* @param query - text the login or name contains; empty for the host's suggestions.
* @param signal - request cancellation.
* @returns the accounts, the host's suggestions first.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/reviewers-failed` when the host
* does not list them.
*/
@Remote async reviewReviewerCandidates(url: string, query: string, signal: AbortSignal): Promise<readonly ForgeReviewerCandidate[]>
/**
* Bring the base branch's new commits into the head branch of a change request the review page shows.
* @param url - web URL of the change request.
* @param method - merge or rebase.
* @param headSha - head commit the user confirmed.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL; `forgePanel/stale-head`,
* `forgePanel/action-failed`, or `forgePanel/action-unknown` with the host's reason.
*/
@Remote async reviewUpdateBranch(url: string, method: BranchUpdateMethod, headSha: string, signal: AbortSignal): Promise<void>
/**
* Remember the change request a review conversation's draft quotes, or forget it with null. When the Session's next
* message enters its inbox, the change request is bound to the Session with a `track` record before the turn starts;
* a Session that already started is bound at its next message. The choice lives in memory until then.
* @param session - the Session whose draft quotes the change request.
* @param url - web URL of the change request, or null.
* @param signal - request cancellation.
* @throws `forgePanel/unrecognized-url` when no provider serves the URL.
*/
@Remote // oxlint-disable-next-line typescript/require-await -- async keeps a refused or cancelled request a rejection, as Remote callers expect async reviewStage(session: Session, url: string | null, signal: AbortSignal): Promise<void>
/**
* Read or await the worktree service's archive cleanup of the Session's checkout.
* @param session - Session whose cleanup is visible to the caller.
+7 -5
View File
@@ -207,13 +207,15 @@ The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mo
/**
* Resolve the complete policy for one capability call. An approved explicit
* mode outranks the session's last `sandbox/mode` event, which outranks the
* deployment default. A session cwd is its workspace-write boundary; the
* configured root is the fallback for agentless calls and sessions without a
* cwd. Configured extra roots and this Session's active registrations are
* snapshotted together; existing operations and processes keep their policy.
* deployment default. A session's working directory is its workspace-write
* boundary, so a Host move of the Session moves the boundary; the configured
* root is the fallback for agentless calls and, without the working-directory
* service, sessions without a header directory. Configured extra roots and
* this Session's active registrations are snapshotted together; existing
* operations and processes keep their policy.
* @param request - optional session and approved mode override.
* @returns the fully resolved per-call mode and absolute workspace root.
* @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's recorded cwd is
* @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's directory is
* relative or contains a NUL byte.
*/
resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy
+7 -5
View File
@@ -207,13 +207,15 @@ The sandbox-policy service (`ctx.sandboxPolicy`). Owns the deployment default mo
/**
* Resolve the complete policy for one capability call. An approved explicit
* mode outranks the session's last `sandbox/mode` event, which outranks the
* deployment default. A session cwd is its workspace-write boundary; the
* configured root is the fallback for agentless calls and sessions without a
* cwd. Configured extra roots and this Session's active registrations are
* snapshotted together; existing operations and processes keep their policy.
* deployment default. A session's working directory is its workspace-write
* boundary, so a Host move of the Session moves the boundary; the configured
* root is the fallback for agentless calls and, without the working-directory
* service, sessions without a header directory. Configured extra roots and
* this Session's active registrations are snapshotted together; existing
* operations and processes keep their policy.
* @param request - optional session and approved mode override.
* @returns the fully resolved per-call mode and absolute workspace root.
* @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's recorded cwd is
* @throws `SandboxInvalidRootError` (`SANDBOX_INVALID_ROOT`) when the session's directory is
* relative or contains a NUL byte.
*/
resolve(request: SandboxPolicyRequest = {}): SandboxExecutionPolicy
+4 -4
View File
@@ -9,14 +9,14 @@
en: 380da3cd0aabd52b
zh: 1317c26089c3ab07
/web-access/search-request-and-result:
en: c6eee490ae914ae0
zh: d576eaeb48480c81
en: aae36206db7d881a
zh: 3db415334859f12a
/web-access/fetch-request-and-result:
en: b96bcdf42ced9eab
zh: aa927e2450238557
/web-access/provider-availability:
en: ba99c3876cb05fd9
zh: cd366d7c3279bd87
en: 359df7da69bf2945
zh: 007f24572cffe391
/web-access/fetch-network-policy:
en: 6851874be5841d90
zh: dc085bf3b82d77df
+10 -3
View File
@@ -12,7 +12,7 @@ Search and fetch share no request schema and no business logic, but they are del
## Search request and result
Each seam request carries exactly one `query`. The `dsh-tool-web` consumer accepts a required `queries` array and fans it out into separate seam requests; a one-item array performs one search. `maxResults` is a consumer-owned bound (`dsh-tool-web`'s `searchMaxResults` config, default `10`) passed through the seam and enforced on the way back — if a provider over-returns, the seam truncates `sources[]` and sets `truncated`.
Each seam request carries exactly one `query`. The `dsh-tool-web` consumer accepts a required `queries` array and fans it out into separate seam requests; a one-item array performs one search. `maxResults` is a consumer-owned bound (`dsh-tool-web`'s `searchMaxResults` config, default `10`) passed through the seam and enforced on the way back — if a provider over-returns, the seam truncates `sources[]` and sets `truncated`. `llmProvider` names the provider route of the model request a search serves; `dsh-tool-web` sets it to the route of the calling Session's latest model request.
```ts type-equiv
/**
@@ -31,6 +31,12 @@ interface WebSearchRequest {
* bound regardless.
*/
readonly maxResults?: number
/**
* Provider route id of the model request this search serves. While no search
* provider is configured, the seam selects with it, as `searchReady()` selects
* with its argument. Omitted = the search serves no model request.
*/
readonly llmProvider?: string
}
```
@@ -127,7 +133,7 @@ A provider's `available(): boolean` is a cheap LOCAL check (credential presence,
A search or fetch provider may also implement `ready(llmProvider): Promise<boolean>`, a configuration-only check that must not make network calls: it answers whether an operation made for a model request on that chat route has a credential to send. `searchReady(llmProvider?)` and `fetchReady(llmProvider?)` ask only the provider that `search()` or `fetch()` would select, treat a provider without `ready()` as ready, and answer true when selection fails, because the operation reports that failure as a `WebError`. Readiness is not a selection input; `dsh-tool-web` makes it the activation condition of `web_search` and `web_fetch`, so a model step whose route answers false neither declares nor dispatches the tool. The DeepSeek Search and Fetch API providers use the route to choose between the account token and the API key, as the [web-deepseek-api authentication](../../packages/web/web-deepseek-api/README.md#authentication) section describes.
Selection never depends on registration, config, or HMR order: a capability has an explicit provider id (config `searchProvider`/`fetchProvider`, or the matching env var feeding the same field), or auto-selects when exactly one usable provider is registered; multiple usable providers with no configured id is `WEB_PROVIDER_AMBIGUOUS`, not first-wins. Each operation reads the configured id when it runs, so a saved settings change applies to the next search or fetch without remounting `ctx.web`.
Selection never depends on registration, config, or HMR order: a capability has an explicit provider id (config `searchProvider`/`fetchProvider`, or the matching env var feeding the same field), or auto-selects when exactly one usable provider is registered; multiple usable providers with no configured id is `WEB_PROVIDER_AMBIGUOUS`, not first-wins. One fixed preference precedes that rule for search: with no configured id, a search runs `deepseek-official` (DeepSeek Messages search, which has no per-search charge) for a model request on the `deepseek-official` or `deepseek-account` route, and `deepseek-search-api` on every other route and outside a model request, whenever that provider is registered and usable. `searchReady(llmProvider)` selects the same provider as a search whose request carries that `llmProvider`. Each operation reads the configured id when it runs, so a saved settings change applies to the next search or fetch without remounting `ctx.web`.
## Fetch network policy
@@ -162,6 +168,7 @@ Selection semantics (resolved at execution time, never order-dependent):
- A configured id that is registered and `available()` → that provider.
- A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
- A configured id registered but unavailable → `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
- No search id configured, and the provider assigned to the route of the model request the search serves is usable → that provider: `deepseek-official` (Messages search) on the `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other route and outside a model request.
- No id configured, exactly one registered usable provider → that provider.
- No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
- No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -199,7 +206,7 @@ registerFetchProvider(provider: WebFetchProvider): () => void
* time with the selection rules above; throws {@link WebError} when the
* capability cannot run. The seam enforces `request.maxResults` on the result:
* if the provider over-returns, `sources[]` is truncated and `truncated` set.
* @param request - the query and optional result limit.
* @param request - the query, the optional result limit, and the route of the model request the search serves.
* @param signal - optional cancellation signal forwarded to the provider.
* @returns the provider's results, capped to `request.maxResults`.
*/
+10 -3
View File
@@ -12,7 +12,7 @@ Web 访问 seam 是一个[能力 seam](../../.agents/notes/implemented/architect
## 搜索请求与结果
每个 seam 请求只携带一个 `query`。消费方 `dsh-tool-web` 接受必填的 `queries` 数组,并把它扇出为多个独立 seam 请求;单元素数组执行一次搜索。`maxResults` 是消费方自有的上限(`dsh-tool-web` 的 `searchMaxResults` 配置,默认 `10`),通过 seam 传递并在返回时强制执行——如果提供方返回超量,seam 截断 `sources[]` 并设置 `truncated`。
每个 seam 请求只携带一个 `query`。消费方 `dsh-tool-web` 接受必填的 `queries` 数组,并把它扇出为多个独立 seam 请求;单元素数组执行一次搜索。`maxResults` 是消费方自有的上限(`dsh-tool-web` 的 `searchMaxResults` 配置,默认 `10`),通过 seam 传递并在返回时强制执行——如果提供方返回超量,seam 截断 `sources[]` 并设置 `truncated`。`llmProvider` 指明搜索所服务的模型请求的提供方路由;`dsh-tool-web` 把它设为发起调用的 Session 最近一次模型请求的路由。
```ts type-equiv
/**
@@ -31,6 +31,12 @@ interface WebSearchRequest {
* bound regardless.
*/
readonly maxResults?: number
/**
* Provider route id of the model request this search serves. While no search
* provider is configured, the seam selects with it, as `searchReady()` selects
* with its argument. Omitted = the search serves no model request.
*/
readonly llmProvider?: string
}
```
@@ -127,7 +133,7 @@ type WebFetchBody =
搜索或抓取提供方还可以实现 `ready(llmProvider): Promise<boolean>`,这是只检查配置、禁止发起网络调用的判断:它回答为该对话路由上的模型请求发起的操作是否有可发送的凭据。`searchReady(llmProvider?)` 与 `fetchReady(llmProvider?)` 只询问 `search()` 或 `fetch()` 会选中的提供方,把没有 `ready()` 的提供方视为就绪,并在选择失败时回答 true,因为对应操作会把该失败报告为 `WebError`。就绪判断不是选择输入;`dsh-tool-web` 把它作为 `web_search` 与 `web_fetch` 的激活条件,因此路由回答 false 的模型步骤既不声明也不派发该工具。DeepSeek Search 与 Fetch API 提供方依据该路由在账号令牌与 API 密钥之间选择,见 [web-deepseek-api 鉴权](../../packages/web/web-deepseek-api/README.zh.md#authentication)一节。
选择从不依赖注册顺序、配置顺序或 HMR(热模块替换)顺序:一项能力要么有显式的提供方 id(配置 `searchProvider`/`fetchProvider`,或填充同一字段的对应环境变量),要么在恰好只有一个可用提供方注册时自动选择;如果存在多个可用提供方却未配置 id,则抛出 `WEB_PROVIDER_AMBIGUOUS`,而不会选用最先注册的提供方。每次操作在执行时读取配置的 id,因此保存的设置变更无需重新挂载 `ctx.web` 即对下一次搜索或抓取生效。
选择从不依赖注册顺序、配置顺序或 HMR(热模块替换)顺序:一项能力要么有显式的提供方 id(配置 `searchProvider`/`fetchProvider`,或填充同一字段的对应环境变量),要么在恰好只有一个可用提供方注册时自动选择;如果存在多个可用提供方却未配置 id,则抛出 `WEB_PROVIDER_AMBIGUOUS`,而不会选用最先注册的提供方。搜索在这条规则之前有一条固定的优先规则:没有配置 id 时,为 `deepseek-official` 或 `deepseek-account` 路由上的模型请求发起的搜索运行 `deepseek-official`(不按次收费的 DeepSeek Messages 搜索),其他路由上以及不服务于模型请求的搜索运行 `deepseek-search-api`,前提是该提供方已注册且可用。`searchReady(llmProvider)` 选中的提供方与请求携带该 `llmProvider` 的搜索相同。每次操作在执行时读取配置的 id,因此保存的设置变更无需重新挂载 `ctx.web` 即对下一次搜索或抓取生效。
## 抓取网络策略
@@ -162,6 +168,7 @@ Selection semantics (resolved at execution time, never order-dependent):
- A configured id that is registered and `available()` → that provider.
- A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
- A configured id registered but unavailable → `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
- No search id configured, and the provider assigned to the route of the model request the search serves is usable → that provider: `deepseek-official` (Messages search) on the `deepseek-official` and `deepseek-account` routes, `deepseek-search-api` on every other route and outside a model request.
- No id configured, exactly one registered usable provider → that provider.
- No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
- No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
@@ -199,7 +206,7 @@ registerFetchProvider(provider: WebFetchProvider): () => void
* time with the selection rules above; throws {@link WebError} when the
* capability cannot run. The seam enforces `request.maxResults` on the result:
* if the provider over-returns, `sources[]` is truncated and `truncated` set.
* @param request - the query and optional result limit.
* @param request - the query, the optional result limit, and the route of the model request the search serves.
* @param signal - optional cancellation signal forwarded to the provider.
* @returns the provider's results, capped to `request.maxResults`.
*/
+2 -2
View File
@@ -6,8 +6,8 @@
en: 45832e24372ea387
zh: 7e0f31726fa1dc4e
/working-directory/directory-selection:
en: 10d9f5bed386adfe
zh: c112d1b4356166b7
en: 4cf56f80c75a2b0c
zh: 97d6813aa8636e3c
/working-directory/model-context:
en: 872112549d003dca
zh: 48bfd30fdf25c234
+1 -1
View File
@@ -10,7 +10,7 @@ A Session's active directory is owned by [`dsh-working-directory`](../../package
`get` is the one read of a Session's directory: relative paths resolve from it, and it is the workspace root for everything that follows the Session's checkout. Every change the service records is a `workspace-root/change`. A log written while the model could move the directory holds `working-directory/change` events, which have no writer now. The service ignores them: such a Session resumes in its original project, or in the directory of its last `workspace-root/change`, and the next request's context reports the directory.
Changes are local to one Session. Relative filesystem operations, newly started processes, instruction discovery, skills, and file completion use the active directory. Existing terminals and persistent shells retain their own directories. Sandbox writable roots and project membership remain anchored to the original project.
Changes are local to one Session. Relative filesystem operations, newly started processes, instruction discovery, skills, and file completion use the active directory. The sandbox `workspace-write` boundary, the Files tree and directory listings, and the change summaries follow it too. Existing terminals and persistent shells retain their own directories. Project membership remains anchored to the original project.
## Model context
+1 -1
View File
@@ -10,7 +10,7 @@ Session 的当前目录由 [`dsh-working-directory`](../../packages/session/work
`get` 是读取 Session 目录的唯一接口:相对路径从它解析,跟随 Session 检出的一切也以它为工作区根。服务记录的每次变更都是 `workspace-root/change`。写于模型还能移动目录时期的日志含有 `working-directory/change` 事件,现在没有写入方。服务忽略它们:这样的 Session 在原始项目中恢复,或在最近一条 `workspace-root/change` 的目录中恢复,下一次请求的上下文会报告该目录。
变更仅影响一个 Session。相对路径文件系统操作、新启动的进程、指令发现、技能和文件补全使用当前目录。已有终端和持久 shell 保留自己的目录。沙箱可写根目录与项目归属继续绑定原始项目。
变更仅影响一个 Session。相对路径文件系统操作、新启动的进程、指令发现、技能和文件补全使用当前目录。沙箱 `workspace-write` 边界、文件树与目录列举以及变更摘要也跟随它。已有终端和持久 shell 保留自己的目录。项目归属继续绑定原始项目。
## 模型上下文
+11
View File
@@ -453,6 +453,15 @@ Source: [`packages/api/workspace-controller/src/index.ts`](../../packages/api/wo
Host Remote file reads and workspace directory observations over the composed filesystem.
```ts cordis-catalog
/**
* Resolve the scope other Host services use to open the same `session/<id>/<path>` addresses:
* a live Session's sandbox workspace root, else a stored Session's cached directory, else its header directory.
* @param sessionId - Session identity received on the wire.
* @param signal - cancellation for the persistence read of a stored Session.
* @returns the scope, or undefined when no live or stored Session has that identity.
*/
scopeOf(sessionId: SessionId, signal?: AbortSignal): Promise<WorkspaceFileScope | undefined>
/**
* Read one page of lines from a UTF-8 file readable by the filesystem backend.
* @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.
@@ -519,6 +528,8 @@ Host Remote file reads and workspace directory observations over the composed fi
@Remote({ mode: 'stream' }) changes(workspaceFileScope: WorkspaceFileScope, path: string, signal: AbortSignal): AsyncIterable<WorkspaceFileWatchFrame>
```
Types: [SessionId](core.md)
Source: [`packages/api/workspace-files/src/index.ts`](../../packages/api/workspace-files/src/index.ts)
<a id="ctxworkspaceregistry--workspaceregistry"></a>
+11
View File
@@ -453,6 +453,15 @@ Source: [`packages/api/workspace-controller/src/index.ts`](../../packages/api/wo
Host Remote file reads and workspace directory observations over the composed filesystem.
```ts cordis-catalog
/**
* Resolve the scope other Host services use to open the same `session/<id>/<path>` addresses:
* a live Session's sandbox workspace root, else a stored Session's cached directory, else its header directory.
* @param sessionId - Session identity received on the wire.
* @param signal - cancellation for the persistence read of a stored Session.
* @returns the scope, or undefined when no live or stored Session has that identity.
*/
scopeOf(sessionId: SessionId, signal?: AbortSignal): Promise<WorkspaceFileScope | undefined>
/**
* Read one page of lines from a UTF-8 file readable by the filesystem backend.
* @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.
@@ -519,6 +528,8 @@ Host Remote file reads and workspace directory observations over the composed fi
@Remote({ mode: 'stream' }) changes(workspaceFileScope: WorkspaceFileScope, path: string, signal: AbortSignal): AsyncIterable<WorkspaceFileWatchFrame>
```
Types: [SessionId](core.zh.md)
Source: [`packages/api/workspace-files/src/index.ts`](../../packages/api/workspace-files/src/index.ts)
<a id="ctxworkspaceregistry--workspaceregistry"></a>
@@ -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.4/forge-rate-limited-failure/guide.md
/:
en: a269b2e48637b03f
zh: c9448349795ddcba
/forgefailure-code-gains-rate-limited:
en: 4f089ad68e437051
zh: d410b8ae2e2ade27
/forgefailure-code-gains-rate-limited/change:
en: 97194ff490de2bbe
zh: 49f6c69fd0dff633
/forgefailure-code-gains-rate-limited/migration:
en: b7d9cfab3582d1ca
zh: dbf6458a78bf8931
@@ -0,0 +1,20 @@
---
kind: upgrade-guide
description: "ForgeFailure.code gains rate-limited, which forge-github returns when GitHub refuses a read under its rate limit, so an exhaustive switch over the code no longer compiles."
---
# `ForgeFailure.code` gains `rate-limited`
English | [中文](guide.zh.md)
## Change
`ForgeFailure['code']` from `@deepseek-ai/dsh-experimental-forge` adds `'rate-limited'`: the host refused the read under its rate limit, and reading again succeeds only after the limit resets. [forge-github](../../../../packages/experimental/forge-github/README.md#use-this-package) now returns it for a GraphQL `RATE_LIMITED` error, HTTP 429, or a message that names a primary or secondary rate limit, which it reported as `unavailable` before. Status polls, check reads, review reads, diffs, file reads, viewer lists, and descriptions can all carry it.
A third-party plugin is affected when it switches exhaustively over `ForgeFailure['code']`, ending in `assertNever` or typing a `Record<ForgeFailure['code'], …>`, which then fails to compile, or when it treats every code other than the documented ones as impossible. A provider that never returns `rate-limited` keeps working unchanged.
## Migration
1. Search for `ForgeFailure['code']`, `failure.code`, and `assertNever(` over forge failures in your plugin, and add a `'rate-limited'` case to each exhaustive switch or record. Read it like `unavailable` when you have no rate-limit handling, or wait before reading again when you do.
2. A provider that detects its host's rate limit may return `{ code: 'rate-limited', message }` from any read that resolves to `ForgeFailure`.
3. Run your typecheck; it passes once every exhaustive switch names the new code.
@@ -0,0 +1,20 @@
---
kind: upgrade-guide
description: "ForgeFailure.code 新增 rate-limited,forge-github 在 GitHub 按限流拒绝读取时返回它,对该代码做穷尽 switch 的代码因此无法通过编译。"
---
# `ForgeFailure.code` 新增 `rate-limited`
[English](guide.md) | 中文
## 变更
`@deepseek-ai/dsh-experimental-forge` 的 `ForgeFailure['code']` 新增 `'rate-limited'`:托管平台按限流拒绝了读取,限额重置之后再读才会成功。[forge-github](../../../../packages/experimental/forge-github/README.zh.md#use-this-package) 遇到 GraphQL `RATE_LIMITED` 错误、HTTP 429,或提到主限流、次级限流的消息时返回它,此前这些情况都报告为 `unavailable`。状态轮询、检查读取、评审读取、diff、文件读取、登录用户的列表与描述读取都可能返回它。
受影响的是对 `ForgeFailure['code']` 做穷尽 switch 的第三方插件:以 `assertNever` 结尾、或声明了 `Record<ForgeFailure['code'], …>` 的代码会编译失败;把文档列出的代码之外的值都当作不可能出现的代码也会受影响。从不返回 `rate-limited` 的提供方无需修改。
## 迁移
1. 在插件中搜索 `ForgeFailure['code']`、`failure.code`,以及针对 forge 失败的 `assertNever(`,给每个穷尽的 switch 或 record 加上 `'rate-limited'`。没有限流处理时按 `unavailable` 对待;有限流处理时,等一段时间再读取。
2. 能识别主机限流的提供方,可以在任何返回 `ForgeFailure` 的读取中返回 `{ code: 'rate-limited', message }`。
3. 运行类型检查;所有穷尽的 switch 都列出新代码后即可通过。
@@ -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.4/web-search-deepseek-model-default/guide.md
/:
en: 0770389edf4d335e
zh: fdbfa622103fb642
/search-on-deepseek-models-defaults-to-legacy-messages-search:
en: 1b8b03f925f55d40
zh: ad09560d0736d4a6
/search-on-deepseek-models-defaults-to-legacy-messages-search/change:
en: 02ae47ad15769fe8
zh: 1f7b1fe3f97656da
/search-on-deepseek-models-defaults-to-legacy-messages-search/migration:
en: 5fbf8405a6a2c9dc
zh: ae8bb97ee2970f07
@@ -0,0 +1,22 @@
---
kind: upgrade-guide
description: "The shipped composition no longer fixes a search provider, so web search in a conversation on a DeepSeek model runs legacy Messages search instead of the DeepSeek Search API."
---
# Search on DeepSeek models defaults to legacy Messages search
English | [中文](guide.zh.md)
## Change
Previously, the shared base composition set `web.searchProvider` to `deepseek-search-api`, so every search was one DeepSeek Search API request. Now the base sets no `searchProvider`, and `dsh-web` selects per model provider route. A search made for a model request on the `deepseek-official` or `deepseek-account` route runs the `deepseek-official` search provider: an auxiliary Messages request to `web-search-deepseek`'s endpoint, which has no per-search charge and is billed as model tokens, and which appends a `web/deepseek-search-llm-request` event to the Session log. A search on any other route, or outside a model request, still runs `deepseek-search-api`.
The Messages search endpoint does not follow the model provider's base URL: it is `web-search-deepseek.baseURL`, else `$DEEPSEEK_SEARCH_BASE_URL`, else `https://api.deepseek.com/anthropic/v1`, and outside an account conversation it receives the key under `web-search-deepseek.apiKeyEnv` (`DEEPSEEK_API_KEY` by default). A deployment whose DeepSeek model provider points at a gateway therefore sends that key to the official endpoint and its searches fail until step 2 or 3 is applied.
The Web search provider menu on the Web search and fetch settings page gains **Automatic**, which is the selection when none is stored. A composition or profile that sets `web.searchProvider` itself, and `DSH_WEB_SEARCH_PROVIDER`, see no change. Fetch still defaults to `http`.
## Migration
1. To accept the new default, change nothing. Confirm: the Web search provider menu shows Automatic, and a search in a conversation on a DeepSeek model appends a `web/deepseek-search-llm-request` event.
2. To keep the DeepSeek Search API for every model, select DeepSeek Search API in that menu and save, or set `searchProvider: deepseek-search-api` beside `fetchProvider: http` in the `config` of the `@deepseek-ai/dsh-web` row. Confirm: the menu shows DeepSeek Search API, and a search appends no `web/deepseek-search-llm-request` event.
3. To use Messages search through a gateway, select DeepSeek server-side search in that menu and save the gateway's Anthropic-compatible base, which ends before `/messages`, as its Base URL, or set `web-search-deepseek.baseURL`; then select Automatic again if other models should keep the Search API. Confirm: a search on a DeepSeek model returns results, and its `web/deepseek-search-llm-request` event names the gateway endpoint.
@@ -0,0 +1,22 @@
---
kind: upgrade-guide
description: "交付的组合不再固定搜索提供方,因此使用 DeepSeek 模型的会话中,网页搜索改用旧版 Messages 搜索而不是 DeepSeek Search API。"
---
# DeepSeek 模型上的搜索默认使用旧版 Messages 搜索
[English](guide.md) | 中文
## 变更
过去,共享的基础组合把 `web.searchProvider` 设为 `deepseek-search-api`,因此每次搜索都是一次 DeepSeek Search API 请求。现在基础组合不设置 `searchProvider`,由 `dsh-web` 按模型提供方路由选择。为 `deepseek-official` 或 `deepseek-account` 路由上的模型请求发起的搜索使用 `deepseek-official` 搜索提供方:它向 `web-search-deepseek` 的端点发送一次辅助 Messages 请求,不按次收费,按模型 token 计费,并向会话日志追加一个 `web/deepseek-search-llm-request` 事件。其他路由上的搜索,以及不服务于模型请求的搜索,仍使用 `deepseek-search-api`。
Messages 搜索的端点不跟随模型提供方的基础地址:它是 `web-search-deepseek.baseURL`,其次是 `$DEEPSEEK_SEARCH_BASE_URL`,再次是 `https://api.deepseek.com/anthropic/v1`;在账号会话之外,它收到的是 `web-search-deepseek.apiKeyEnv`(默认 `DEEPSEEK_API_KEY`)下的密钥。因此,DeepSeek 模型提供方指向网关的部署会把该密钥发往官方端点,搜索会失败,直到执行第 2 步或第 3 步。
「网页搜索与获取」设置页的「网页搜索提供方」菜单新增**自动选择**,没有已存选择时即选中它。自行设置了 `web.searchProvider` 的组合或 profile,以及 `DSH_WEB_SEARCH_PROVIDER`,不受影响。Fetch 仍默认为 `http`。
## 迁移
1. 接受新的默认值时无需修改。确认:「网页搜索提供方」菜单显示「自动选择」,且使用 DeepSeek 模型的会话中的搜索会追加一个 `web/deepseek-search-llm-request` 事件。
2. 要让所有模型继续使用 DeepSeek Search API,在该菜单中选择 DeepSeek Search API 并保存,或在 `@deepseek-ai/dsh-web` 条目的 `config` 中把 `searchProvider: deepseek-search-api` 与 `fetchProvider: http` 一起设置。确认:菜单显示 DeepSeek Search API,且搜索不再追加 `web/deepseek-search-llm-request` 事件。
3. 要通过网关使用 Messages 搜索,在该菜单中选择 DeepSeek 服务端搜索,把网关的 Anthropic 兼容基础地址(到 `/messages` 之前为止)作为其 Base URL 保存,或设置 `web-search-deepseek.baseURL`;如果其他模型应继续使用 Search API,再重新选择「自动选择」。确认:DeepSeek 模型上的搜索返回结果,且其 `web/deepseek-search-llm-request` 事件指向网关端点。
@@ -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.4/workspace-write-boundary-follows-root/guide.md
/:
en: 8e9487f2e34d2fb5
zh: 490859f7f2bda707
/the-workspace-write-boundary-follows-the-session-s-working-directory:
en: 540195a16ff3b882
zh: bc29122de6e89f97
/the-workspace-write-boundary-follows-the-session-s-working-directory/change:
en: 6285cb3bb9343ae3
zh: 216498974cd862f9
/the-workspace-write-boundary-follows-the-session-s-working-directory/migration:
en: eadc3ff3b86b6722
zh: 8713fea1250b3578
@@ -0,0 +1,25 @@
---
kind: upgrade-guide
description: "The workspace-write boundary follows the Session's working directory instead of its original project, so a Session in a worktree can no longer write the repository's Git directory."
---
# The `workspace-write` boundary follows the Session's working directory
English | [中文](guide.zh.md)
## Change
`ctx.sandboxPolicy.resolve({ session })` returns the Session's working directory as `workspaceRoot`: the checkout the Session works in. Before, it returned the original project recorded in the Session header for the whole Session. A Session that enters a worktree through `enter_worktree` or the forge New worktree option can now write only inside that worktree; the original project is no longer writable. The boundary moves with every Host move of the Session's directory, including SDK `setWorkingDirectory` (`set_working_directory` in Python) and a child started through `ctx.subagents.start({ cwd })`; a `working-directory/change` recorded before this release does not move it.
The repository's Git directory lies outside a linked worktree. Under `workspace-write`, `git add`, `git commit`, and other commands that write it are therefore denied inside a worktree unless a grant covers that directory. Before, a worktree inside the original project shared the project's boundary, which contained `.git`. The policy reads no Git files and derives no grant.
The Files tree, directory listings and watches, deliverables and change summaries, open-in-app actions, and Session rows read the same directory. `WorkspaceChangesSummary.cwd` is the directory the turn started in, no longer the original project.
Who observes it: operators and models that commit from a worktree Session under `workspace-write`, operators who relied on a worktree Session still writing its original project, and Host plugins that read `WorkspaceChangesSummary.cwd` as the original project.
## Migration
1. To let worktree Sessions commit under `workspace-write`, add the repository's Git directory, such as `/repo/.git`, to `additionalWritableRoots` of `@deepseek-ai/dsh-sandbox-policy` in `cordis.yml`, or register it for one Session from a Host plugin with `ctx.sandboxPolicy.registerWritableRoot(session, directory)`. The grant also covers `.git/hooks` and `.git/config`; use it for trusted work only. Windows processes ignore additional writable roots, so the grant does not reach `git` there. Without an effective grant, the model requests escalation for each such command where approvals are enabled.
2. Where a task must write the original project after entering a worktree, leave with `exit_worktree()` or the forge panel's continue-in-project action, or keep the Session in the original project; the boundary follows that change. Where an SDK client moved the directory only to change where relative paths resolve, pass absolute paths or the shell's `workdir` instead.
3. In Host plugins that consume `ctx.workspaceChanges.summary`, read the original project from the Session header's `cwd`; `WorkspaceChangesSummary.cwd` is the directory listed `path` values are relative to.
4. Where `cordis.yml` sets the sandbox policy's `workspaceRoot` to bound Sessions without a header directory, set `defaultDirectory` of `@deepseek-ai/dsh-working-directory` to the same directory; that directory now bounds them.
5. Confirm: after `enter_worktree`, a write to the original project outside the worktree is denied, and, on macOS or Linux, `git commit` in the worktree succeeds once the grant of step 1 is in place.
@@ -0,0 +1,25 @@
---
kind: upgrade-guide
description: "workspace-write 边界跟随 Session 的工作目录而不是原始项目,因此 worktree 中的 Session 不再能写入仓库的 Git 目录。"
---
# `workspace-write` 边界跟随 Session 的工作目录
[English](guide.md) | 中文
## 变更
`ctx.sandboxPolicy.resolve({ session })` 返回的 `workspaceRoot` 是 Session 的工作目录,即它所在的检出目录。此前整个 Session 期间返回的都是 Session header 记录的原始项目。通过 `enter_worktree` 或 forge 的"新建工作树"选项进入 worktree 的 Session 现在只能在该 worktree 内写入;原始项目不再可写。Host 每次移动 Session 的目录,边界都随之移动,包括 SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`)以及通过 `ctx.subagents.start({ cwd })` 启动的子代理;本版本之前记录的 `working-directory/change` 不移动边界。
仓库的 Git 目录位于链接 worktree 之外。因此在 `workspace-write` 下,`git add`、`git commit` 等写入它的命令在 worktree 内会被拒绝,除非有授权覆盖该目录。此前,位于原始项目内的 worktree 共用项目的边界,其中包含 `.git`。策略不读取任何 Git 文件,也不推导授权。
文件树、目录列举与监听、交付物与变更摘要、在应用中打开操作和 Session 行读取同一个目录。`WorkspaceChangesSummary.cwd` 是该轮次开始时所在的目录,不再是原始项目。
受影响者:在 `workspace-write` 下从 worktree Session 提交的运维人员与模型、依赖 worktree Session 仍可写入原始项目的运维人员,以及把 `WorkspaceChangesSummary.cwd` 当作原始项目读取的 Host 插件。
## 迁移
1. 要让 worktree Session 在 `workspace-write` 下提交,请在 `cordis.yml` 中把仓库的 Git 目录(例如 `/repo/.git`)加入 `@deepseek-ai/dsh-sandbox-policy` 的 `additionalWritableRoots`,或在 Host 插件中用 `ctx.sandboxPolicy.registerWritableRoot(session, directory)` 为单个 Session 注册。该授权也覆盖 `.git/hooks` 与 `.git/config`,只用于可信任务。Windows 的进程忽略额外可写目录,因此该授权在 Windows 上对 `git` 不生效。没有生效的授权时,在启用审批的环境里模型会为每条这类命令请求提权。
2. 任务在进入 worktree 后仍需写入原始项目时,用 `exit_worktree()` 或 forge 面板的“在项目中继续”离开,或让 Session 留在原始项目中;边界跟随该变更。SDK 客户端若只是为了改变相对路径的解析位置而移动目录,请改传绝对路径或 shell 的 `workdir`。
3. 在消费 `ctx.workspaceChanges.summary` 的 Host 插件中,从 Session header 的 `cwd` 读取原始项目;`WorkspaceChangesSummary.cwd` 是所列 `path` 值相对的目录。
4. `cordis.yml` 若用沙箱策略的 `workspaceRoot` 限定 header 没有目录的 Session,请把 `@deepseek-ai/dsh-working-directory` 的 `defaultDirectory` 设为同一目录;现在由该目录限定这些 Session。
5. 确认:`enter_worktree` 之后,对 worktree 之外原始项目的写入被拒绝;在 macOS 或 Linux 上完成第 1 步的授权后,worktree 内的 `git commit` 成功。
+2
View File
@@ -250,6 +250,8 @@
"@deepseek-ai/dsh-llm": "workspace:*",
"@deepseek-ai/dsh-mcp-client": "workspace:*",
"@deepseek-ai/dsh-mcp-manager": "workspace:*",
"@deepseek-ai/dsh-linear": "workspace:*",
"@deepseek-ai/dsh-notion": "workspace:*",
"@deepseek-ai/dsh-tencent-docs": "workspace:*",
"@deepseek-ai/dsh-tool-session-query": "workspace:*",
"@deepseek-ai/dsh-web-fetch-http": "workspace:*",
@@ -18,8 +18,8 @@
en: 958951f6e7fdc5de
zh: 73d73a5d51b45eba
/session-controller/client-references:
en: d816da086dcda253
zh: 0f6efc1efff58efb
en: 8c9fb80b590c47ff
zh: db2902daf76e46f8
/session-controller/session-media-references:
en: 954923654eebe2dc
zh: 6bd9a7d2ea965aed
@@ -89,6 +89,8 @@ The controller composes `ArchivedSessionGate` through `ctx.plugin`: it loads onc
References keep local Session data, scoped Contexts, and history streams alive, not Host Agents. Ordinary Session retention never adds a catalog row. Retained subagents with a known direct-parent address keep a fallback row and notify list readers even before the parent catalog arrives; these rows do not join Host-list membership. Fork-title assignment sends rename directly and applies the returned title projection without retaining the child or opening its history. Final release withdraws the generation before teardown; later acquisition can create a new generation with the same id. `binding(id)` and `scope(id)` only borrow an existing generation. `retainInfo(id)` observes stable read-only source counts independently of catalog membership and performs no history I/O. Consumer source keys are declaration-merge extensible; navigation and completion acknowledgement belong to UI consumers, not this Controller. Every reference keeps the Session object and its scope. `connection`, `true` by default, also keeps the Session's own event connection and the event window it keeps current; when no reference keeps it, the Session disconnects, empties its window, and keeps local state such as pending submission echoes, and the next connected reference connects as a first open. A `connection: false` reference is ready once its binding exists. `facets` names owner-declared computations over that data, such as `conversation`. When the last facet is released while the connection remains, the Session keeps only its last Turn-aligned page visible and its event stream holds the older entries in memory, so page reads return them without a request before Host paging resumes. Owners declaration-merge `SessionRetainFacetMap`; a facet is retained only when its key is `true`, the set is fixed for the reference's lifetime, and `retainInfo(id)` reports positive per-facet counts in `retainedFacets` and the connected reference count in `connectionCount`, each absent while zero. The Controller counts facets without interpreting them or their dependencies. See [Client Session references](../../../.agents/notes/implemented/architecture/2026-09-15-client-session-references.md) for ownership and teardown rules. An unknown-mode subagent address permits history reads with direct-parent consistency validation; access is checked separately on the child Session. Successful descriptor restoration determines the displayed mode; failures remain local to the child. Control requests carry only the target id, and the Host checks continuation availability. Client snapshots retain only the subagent address; runtime admission owns continuation availability.
`@deepseek-ai/dsh-api-session-controller/client/directories` exports the import-free directory readers client plugins inline instead of importing this plugin's bundle: `selectSessionDirectory(state, sessionId)` selects a Session's directory from a list snapshot (the projected `workingDirectory`, else the row's header directory) for `useSessions` selectors, and `sessionDirectory(sessions, sessionId)` reads it at gesture time from the connected Session's projection face before the list snapshot. File views, address bases, open-in-app actions, and relative paths all use that directory.
<a id="session-media-references"></a>
## Session media references
Loaded 100 of 480 files, more files were not shown because too many files have changed in this diff. Show more