680 lines
45 KiB
Markdown
680 lines
45 KiB
Markdown
# v0.1 宿主能力核实记录(P0 交付物)
|
||
|
||
> 本文是《[v0.1 实施方案](v0.1-实施方案.md)》§3「能力核实」的实做记录。原则:**只写读过的代码**,没有代码依据的一律标「未核实」,并写明是「需要动态验证」还是「代码里没有」。
|
||
>
|
||
> 阅读本文前请先知道一件事:**本轮核实只做到「类型层」**。没有任何一条结论来自在真实 DSH 里跑一遍(见 §0.3)。
|
||
|
||
---
|
||
|
||
## 0. 核实环境与方法
|
||
|
||
### 0.1 版本
|
||
|
||
| 项 | 值 |
|
||
| --- | --- |
|
||
| DSH 宿主包版本 | **0.2.0-rc.1**(`node_modules/@deepseek-ai/*` 全员 0.2.0-rc.1) |
|
||
| 类型定义来源 | `C:\Users\qyh15\Documents\dsh-workspaces-goups-new\dsh-workspace-groups\node_modules\@deepseek-ai\` |
|
||
| 本插件版本 | `dsh-sansheng-liubu-mode` **0.9.2**(`package.json`),面板子包 `dsh-sansheng-liubu-panel` 0.9.2 |
|
||
| 旧客户端参考 | [panel/lib/client.js](../panel/lib/client.js)(2107 行,仓库内唯一在真实宿主里跑过的客户端代码) |
|
||
| 宿主 Web GUI | `http://127.0.0.1:8457` |
|
||
| 系统 | Windows |
|
||
|
||
### 0.2 方法
|
||
|
||
1. 通读 `docs/v0.1-实施方案.md` 全文,抽出 §3 要求核实的 12 项与 §4/§6/§8 的接口需求。
|
||
2. 逐包读 `.d.ts`(签名)与 `lib/types/commands.js`、`agent.js` 等实现文件(语义),记录**文件路径 + 行号**。
|
||
3. 对照旧插件已跑通的调用点,标注哪些是「运行时已跑过」。
|
||
4. 读不到的包(如 `@deepseek-ai/dsh-client-ui-layout`)明确写「未核实」,不做推测性补全。
|
||
|
||
### 0.3 验证档位的定义(本文全篇使用)
|
||
|
||
| 档位 | 含义 |
|
||
| --- | --- |
|
||
| **类型层已核实** | 有 `.d.ts` 或实现源码为据,签名与语义可引用行号。(**允许据此写代码**) |
|
||
| **运行时已跑过** | 旧插件在真实宿主里实际调用过并通过(有代码调用点为据;本轮多数只能间接证明)。 |
|
||
| **未验证** | 分两种:**需动态验证**(类型存在,但行为/边界要靠实测确认);**代码里没有**(读遍本机宿主包找不到该能力)。 |
|
||
|
||
### 0.4 本轮**没有**做的事(重要)
|
||
|
||
- **没有**在真实宿主里做 P0 最小验证(§3 要求的「最小验证」全部待做)。
|
||
- **没有**运行任何 Host 侧 RPC,也没有在浏览器里打开插槽快照。
|
||
- 旧插件的 `panel/test/client.test.js` 本轮用仓库自带 node 跑过一遍:44 项全过(`node --test --test-isolation=none panel/test/client.test.js`)——但这是**对 mock 上下文**的单测,**不构成宿主兼容性证据**。
|
||
- 结论:**当前所有能力最多只能给到「类型层已核实」**。§12 验收矩阵里的真实宿主证据仍需按 §0.5 的核对清单去取。
|
||
|
||
### 0.5 拿到「运行时已跑过」的最小动作(P0 收尾 TODO)
|
||
|
||
| 目标 | 具体动作 |
|
||
| --- | --- |
|
||
| 槽归属 | 浏览器控制台执行 `ctx.slots.snapshot()`(`SlotRegistry.snapshot`,registry.d.ts:180),导出 `main` / `main.conversation` / `sidebar.workspaces` 三个节点的 `occupants`(谁注册、priority) |
|
||
| 会话创建幂等 | 对同一 `sessionId` 连调两次 `sessionController.create({sessionId, cwd})`,第二次应返回同一 id 且不新建;再换 cwd 调一次,应抛 `session/conflict` |
|
||
| prompt 幂等 | 同一 `requestId` 连发两次,第二次应立即 `{accepted:true}` 且日志里只有一条 `user/message` |
|
||
| cancel 真语义 | 发一条长任务 → `cancel()` → 观察 `running` 何时变 false、inbox 里排队的消息是否仍在 |
|
||
| 归档拒绝 | 会话 running 时 `archiveSession` 应抛 `workspace/session-active` |
|
||
| 断线重连 | 拔网/重启宿主,观察客户端 follow 流是否自愈、`sessionListMetadata` 是否重建 |
|
||
|
||
---
|
||
|
||
## 1. 速查总表
|
||
|
||
| # | 能力 | 档位 | 一句话结论 |
|
||
| --- | --- | --- | --- |
|
||
| 1 | 会话创建(显式 sessionId 幂等 adopt) | 类型层已核实 | 只有显式给 `sessionId` 才有幂等语义;cwd/preset 冲突抛错,不会静默合并 |
|
||
| 2 | 投递 prompt(requestId / queue / steer) | 类型层已核实 | `requestId` 幂等真实存在;`mode` 语义明确;客户端 `prompt()` 默认不带 requestId,必须自己传 |
|
||
| 3 | 取消 | 类型层已核实 | 同步返回、只对 attached agent 有效、保留 inbox;`accepted:true` ≠ 已取消 |
|
||
| 4 | 模型目录与选择 | 类型层已核实 | `modelCatalog` 有;`selectModel` **会连带改全局默认**,必须插件侧覆写 |
|
||
| 5 | 会话列表与投影 | 类型层已核实 | list 不用 resume agent;投影键名固定三个 |
|
||
| 6 | follow 事件流 | 类型层已核实 | 快照 + 无缺口事件帧;断线重连由客户端 session 层负责(细节未验证) |
|
||
| 7 | Workspace 列表与视图 | 类型层已核实 | `WorkspaceView` 有 canonical path + sessionIds;host id 不复用 |
|
||
| 8 | 项目树槽位归属 | 类型层已核实(归属)/ 未验证(实际占位) | `sidebar.workspaces` 是 single/root,由 ui-workspace 声明、workspace-groups 插件以 priority -1 shadow |
|
||
| 9 | 中央主区槽位归属 | **未核实** | `main` 槽的 SlotMap 声明在 `dsh-client-ui-layout`,本机没有该包 |
|
||
| 10 | `'conversation.content'` 工厂可复用性 | 类型层已核实 | 是 SlotFactory,可被再次实例化;但嵌套实例的 scope/绑定行为未验证 |
|
||
| 11 | slot register / registerFactory / renderFactorySlot | 类型层已核实(语义)/ 未验证(冲突抛错实测) | priority 最低者胜;同 cell 同 priority 注册**抛错**;`root` 槽禁止注册 |
|
||
| 12 | 插件 client 注入声明 | 类型层已核实 | 两种 inject 并存且含义不同:`package.json dsh.client.inject` 填包名,`exports.inject` 填服务短名 |
|
||
|
||
---
|
||
|
||
## 2. 会话与投递能力
|
||
|
||
### 2.1 会话创建(含显式 sessionId 幂等 adopt)
|
||
|
||
**签名(Host 侧)**
|
||
|
||
```ts
|
||
// node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.d.ts:93
|
||
create(request: SessionCreateRequest): Promise<SessionCreateValue>;
|
||
```
|
||
|
||
```ts
|
||
// lib/types/types.d.ts:279-289
|
||
interface SessionCreateRequest {
|
||
workspaceId?: WorkspaceId;
|
||
cwd?: string;
|
||
sessionId?: SessionId;
|
||
agentPreset?: string;
|
||
}
|
||
interface SessionCreateValue {
|
||
sessionId: SessionId;
|
||
agentPreset?: string;
|
||
}
|
||
```
|
||
|
||
**实现语义**(`lib/types/commands.js`)
|
||
|
||
| 行为 | 证据 |
|
||
| --- | --- |
|
||
| `workspaceId` 与 `cwd` 同时给 → 抛 `gateway/bad-request`("session.create accepts workspaceId or cwd, not both") | commands.js:107-110 |
|
||
| 未给 `sessionId` 时由宿主随机生成:`request.sessionId ?? brandString(\`session-${randomUUID()}\`)` | commands.js:111 |
|
||
| 给 `workspaceId` 但查不到 → 抛 `workspace/not-found` | commands.js:113-120 |
|
||
| 解析 cwd:`workspace?.path ?? request.cwd ?? defaultCwd`,并在调用前 `mkdir(cwd, {recursive:true})` | commands.js:121-124;agent.js:475 |
|
||
| **只有显式传了 `sessionId` 才做 adopt 校验**:`ensureSession(sessionId, cwd, request.sessionId !== undefined, agentPreset)` | commands.js:124 |
|
||
| adopt 校验:cwd 不同 → `ApiSessionCwdConflict` → `session/conflict`;preset 不同 → `ApiSessionPresetConflict` → `agent-preset/conflict` | agent.js:470-474 |
|
||
| adopt 命中(同 cwd 同 preset)→ 直接返回同一个 sessionId,不新建 | agent.js:454-512 |
|
||
| session 建成后 `workspace.attachSession(sessionId)`,失败抛 `session/workspace-attach-failed`——**此时 session 已创建**,调用方必须能对账 | commands.js:129-136 |
|
||
| JSDoc 原文:"Create or idempotently adopt one ordinary Session" | index.d.ts:88-93 |
|
||
|
||
**我们的用法**:`ProjectService` 用 `projectId + roleId` 生成或查出稳定 `sessionId`(形如 `session-sansheng-<projectHash>-<roleId>`),带 `cwd = workspace.path` 与 `agentPreset` 调 `create`。同一请求重放是安全的(幂等 adopt);cwd/preset 不一致时报错,由 Reconciler 处理而不是自动重建。
|
||
|
||
**档位**:**类型层已核实**。幂等仅来自「显式 sessionId + cwd/preset 一致」,`creationRequestId` **不参与** create 的幂等(`SessionCreateRequest` 里没有这个字段,types.d.ts:279-284)。
|
||
**未验证**:真实宿主上第二次同参 create 是否真的返回同 id(需动态验证)。
|
||
|
||
**客户端等价物**(`ctx.sessions`,浏览器侧)
|
||
|
||
```ts
|
||
// lib/types/client/contract/sessions.d.ts:80-84
|
||
create(opts?: { workspaceId?: WorkspaceId; cwd?: string; sessionId?: SessionId }): Promise<SessionId>;
|
||
```
|
||
|
||
```ts
|
||
// lib/types/client/contract/sessions.d.ts:54-63
|
||
class SessionCreateError extends Error {
|
||
rpcError: RemoteFailure;
|
||
requestedSessionId?: SessionId;
|
||
name = 'SessionCreateError';
|
||
}
|
||
```
|
||
|
||
`requestedSessionId` 让「创建失败但宿主可能已经建了」变成可对账状态——这正是实施方案 §6.5 要的「按 requestId 查回」的现有替代物。**档位:类型层已核实;未验证(需动态验证宿主是否真的回填该字段)**。
|
||
|
||
---
|
||
|
||
### 2.2 投递 prompt(requestId、mode queue/steer)
|
||
|
||
**签名(Host 侧)**
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:163
|
||
prompt(request: SessionPromptRequest, signal: AbortSignal): Promise<SessionPromptValue>;
|
||
```
|
||
|
||
```ts
|
||
// lib/types/types.d.ts:319-331
|
||
interface SessionPromptRequest {
|
||
requestId: SessionRequestId;
|
||
sessionId: SessionId;
|
||
mode: 'queue' | 'steer';
|
||
content: readonly PromptContentPart[];
|
||
clientTimeZone?: string;
|
||
}
|
||
type PromptContentPart =
|
||
| { type: 'text'; text: string }
|
||
| { type: 'image'; mediaType: string; data: string; name?: string }
|
||
| { type: 'file'; receiptId: string };
|
||
interface SessionPromptValue { accepted: true }
|
||
// :78-89, :329-331
|
||
```
|
||
|
||
**requestId 幂等是真的**(`lib/types/commands.js:290-352`):
|
||
|
||
- `if (hasPromptRequest(agent, request.requestId)) return { accepted: true }`(:301-302)——**重复投递直接吞掉,不报错**。
|
||
- `hasPromptRequest` 扫 `inbox.nextTurn` / `inbox.nextStep`,以及 `session.snapshotEvents()` 里 `user/message` 的 `source.rpcId`(:547-561)。这意味着**跨重启也幂等**(历史事件里留了 rpcId)。
|
||
- 空内容 → `gateway/bad-request`;`clientTimeZone` 非法 → `session/invalid-time-zone`。
|
||
- `mode === 'steer'` 走 `agent.steer(message)`,否则 `agent.followup(message)`(:327-330)。
|
||
- 其它异常统一折叠为 `session/agent-busy { reason }`(:347)——**错误码粒度很粗,不能靠它区分具体原因**。
|
||
|
||
**客户端签名(浏览器侧)**
|
||
|
||
```ts
|
||
// lib/types/client/contract/session.d.ts:82-84
|
||
prompt(content: PromptContentPart[], mode: 'queue' | 'steer', signal?: AbortSignal, requestId?: SessionRequestId)
|
||
: Promise<RemoteResult<{ accepted: true }>>;
|
||
```
|
||
|
||
注意 **`requestId` 是第 4 个可选参数**——旧插件 `panel/lib/client.js:1148-1165` 的 `deliverPrompt` 只传了前两个参数,**没有 requestId**,所以旧插件路径不具备幂等性。v0.1 必须显式传。
|
||
|
||
**`RemoteResult` 的形状**(`@deepseek-ai/dsh-typert-protocol/lib/types/types.d.ts:67-73`):
|
||
|
||
```ts
|
||
type RemoteResult<T> = { ok: true; value: T } | { ok: false; error: RemoteFailure };
|
||
```
|
||
|
||
**我们的用法**:`DispatchService` 每条派工生成一个 `requestId`(与 `dispatchId` 一一对应并落库),投递失败重试用同一个 `requestId`。`mode` 首版固定 `'queue'`;`'steer'` 只在确认宿主行为后启用。
|
||
|
||
**档位**:**类型层已核实**(Host 幂等)/**运行时已跑过**(旧插件确实用 `binding.session.prompt([...], "queue")` 成功投递,未带 requestId)。
|
||
**未验证**:客户端第 4 参数 `requestId` 是否被正确透传到 Host(需动态验证)。
|
||
|
||
**客户端补充**:`beginSubmission(input): SubmissionHandle`(session.d.ts:73)返回 `{ requestId, abandon() }`,是官方的「先登记 echo 再发」路径;`SubmissionHandle.requestId` 的类型注释明确「pass it to prompt」。
|
||
|
||
---
|
||
|
||
### 2.3 取消
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:181 (注意:同步返回,不是 Promise)
|
||
cancel(request: SessionCancelRequest): SessionCancelValue;
|
||
// lib/types/types.d.ts:353-359
|
||
interface SessionCancelRequest { sessionId: SessionId }
|
||
interface SessionCancelValue { accepted: true }
|
||
```
|
||
|
||
实现(`lib/types/commands.js:468-478`):
|
||
|
||
- **只对已 attach 的 live agent 生效**,否则抛 `session/not-found`("session ... not found (not attached)")。
|
||
- 调用 `agent.cancel({ kind: 'user' }, { keepInbox: true })`——**保留 inbox**,排队消息不会被清掉。
|
||
- JSDoc(index.d.ts:177-181):"Cancel one active Agent turn **without dropping its pending inbox** ... acknowledgement that cancellation was **requested**"。
|
||
|
||
客户端等价物:`ISession.cancel(): Promise<RemoteResult<{accepted:true}>>`(session.d.ts:108-110)。JSDoc 补一句关键语义:**"Pending queued work remains and resumes in FIFO order after the Host reaches cancellation quiescence"**——即取消后排队任务会**继续跑**。
|
||
|
||
**我们的用法**:`Attempt` 状态机保留 `cancel_requested` 与 `cancelled` 两个态(正好对应实施方案 §8);`cancel()` 返回只推进到 `cancel_requested`,终态必须靠 `follow` 事件或 `running` 投影落到 false 才能确认。
|
||
|
||
**档位**:**类型层已核实**。**未验证**:真实宿主上从 `cancel()` 到 `running=false` 的时延与事件序列(需动态验证)。
|
||
|
||
---
|
||
|
||
## 3. 模型能力
|
||
|
||
### 3.1 模型目录
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:109
|
||
modelCatalog(): Promise<ModelCatalog>;
|
||
// lib/types/types.d.ts:141-147
|
||
interface ModelCatalog {
|
||
default: ModelSelection;
|
||
routableProviders: readonly string[];
|
||
groups: readonly ModelProviderGroup[];
|
||
failures: readonly ModelCatalogFailure[];
|
||
}
|
||
interface ModelCatalogModel { // :110-127
|
||
id: string; name: string; description?: string;
|
||
reasoning?: { efforts: readonly { id: string; name: string; description?: string }[]; defaultEffort?: string };
|
||
}
|
||
interface ModelProviderGroup { id: string; name: string; models: readonly ModelCatalogModel[] } // :129-133
|
||
interface ModelCatalogFailure { id: string; name: string; message: string } // :135-139
|
||
```
|
||
|
||
**要点**:
|
||
|
||
- `reasoning.efforts` 是**每个模型自己的枚举**,`defaultEffort` 可能不存在 → 实施方案 §6「不支持旧 effort 不透传非法枚举」有直接依据。
|
||
- `failures` 是**隔离的 provider 失败**,不是整体失败——UI 应当「部分可用」而不是一有 failure 就整页报错。
|
||
- Host JSDoc:"Describe every currently routable model"(index.d.ts:105-109)。
|
||
- **客户端侧没有 `modelCatalog`**:`ISessions` / `ISession`(client/contract/*.d.ts)里搜不到该名字。旧插件只能走 `ctx.modelDirectories`(一个非本仓库的第三方服务)或 `ctx.remote.session.selectModel`。→ **v0.1 的模型目录必须从 Host 侧取**。
|
||
|
||
**档位**:**类型层已核实**(Host 签名与形状)。**未验证**:真实宿主返回的 efforts 枚举内容(需动态验证)。
|
||
|
||
### 3.2 模型选择
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:99
|
||
selectModel(request: SessionSelectModelRequest): Promise<SessionSelectModelValue>;
|
||
// lib/types/types.d.ts:91-95, :291-297
|
||
interface ModelSelection { provider: string; model: string; reasoningEffort?: string }
|
||
interface SessionSelectModelRequest extends ModelSelection { sessionId: SessionId }
|
||
interface SessionSelectModelValue { selected: ModelSelection }
|
||
```
|
||
|
||
实现(`lib/types/commands.js:145-175`):
|
||
|
||
1. 先 `resolveAgent`(**会 resume 会话**);
|
||
2. 模型不在目录里 → 抛 `session/model-unavailable { provider, model }`;
|
||
3. `llm.resolveCallConfig` 归一化(这让返回的 `selected` 可能与请求不同,例如补默认 effort);
|
||
4. `agents.selectForNextRequest(selected)`;
|
||
5. **后台** `agentDefaultModel.saveSelection(selected)` —— **会把这个选择写成全局默认**,失败只 warn。
|
||
|
||
JSDoc(index.d.ts:94-99):"Select one Session-local model after explicitly resuming the Session; **save the default in the background**"。
|
||
|
||
> **这是 v0.1 最容易踩的坑**:`selectModel` 不是「只改这个会话」,它顺带改全局默认。所以「本项目本部门固定模型」必须由插件在**每次派发前**显式 `selectModel` 覆写,并自己持久化 desired 配置;不能指望宿主记住。
|
||
|
||
相关投影:
|
||
|
||
```ts
|
||
// lib/types/types.d.ts:104-109
|
||
interface ModelSelectionProjection { lastUsed: ModelSelection | null; next: ModelSelection | null }
|
||
```
|
||
|
||
投影键名固定三个(`lib/types/types.d.ts:11-27`):`sessionListMetadata`、`imageLimits`、`modelSelection`。这正是实施方案 §6「UI 分别显示『本次运行使用』和『下次运行使用』」的现成数据源(`lastUsed` / `next`)。
|
||
|
||
**档位**:**类型层已核实**。
|
||
**运行时已跑过(间接)**:旧插件 `panel/lib/client.js:1534-1560` 走 `remote.session.selectModel({sessionId, provider, model, reasoningEffort?})` 返回 `{ok, error:{code,message}}`,说明该 RPC 在真实宿主里存在且可调。
|
||
|
||
---
|
||
|
||
## 4. 会话列表、投影与事件流
|
||
|
||
### 4.1 列表
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:80
|
||
list(_request: SessionListRequest, signal: AbortSignal): Promise<SessionListValue>;
|
||
// lib/types/types.d.ts:159-170
|
||
interface SessionSummary {
|
||
agentAvailable: boolean; sessionId: SessionId; updatedAt: number; running: boolean; blank: boolean;
|
||
parentSessionId?: SessionId; origin?: 'subagent'; cwd?: string; projections?: SessionProjectionHints;
|
||
}
|
||
```
|
||
|
||
- Host JSDoc:**"without resuming an Agent ... ordered by activity"**(index.d.ts:75-80)——列会话不会把 agent 拉起来,可放心高频调用。
|
||
- `SessionProjectionHints { kind: 'cached'|'sequenced'; asOfSeq; values }`(:51-64):**行内投影是可能过期的 partial 视图**,不能当权威值。
|
||
|
||
客户端:`SessionListState { ids; byId; phase; projectionsBySession }`(client/service.d.ts:43-52),旧插件就是读 `sessions.list.getSnapshot()` 的 `{ids, byId}`(client.js:635-760、1813)。
|
||
|
||
**档位**:**类型层已核实**+**运行时已跑过**(旧插件读列表快照驱动面板)。
|
||
|
||
### 4.2 投影
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:203
|
||
projections(request: SessionProjectionsRequest, signal: AbortSignal): Promise<SessionProjectionsValue>;
|
||
```
|
||
|
||
JSDoc:"Read all registered projections **without activating an Agent** ... **null when the Session does not exist**"(index.d.ts:198-203)。
|
||
|
||
客户端:`ISessions.refreshProjections(sessionId): Promise<void>`(sessions.d.ts:92 附近)与 `ISession.projections.faceOf(key): ObservableSnapshot<unknown>`(session.d.ts:55)。
|
||
|
||
> `faceOf(key: string)` 的参数是**裸 string**,不是联合类型——拼错键名不会有编译错误,只会拿到 `undefined` 快照。v0.1 应把这几个键名收敛成常量。
|
||
|
||
**档位**:**类型层已核实**。**未验证**:真实宿主上 cold session 的 projections 是否真返回 null vs 空对象(需动态验证)。
|
||
|
||
### 4.3 follow 事件流
|
||
|
||
```ts
|
||
// lib/types/index.d.ts:196
|
||
follow(request: SessionFollowRequest, signal: AbortSignal): AsyncIterable<SessionFollowFrame>;
|
||
// lib/types/types.d.ts:459-463, :516-527
|
||
interface SessionFollowRequest extends Pick<SessionPageRequest, 'maxMessages' | 'turnWindow'> {
|
||
address: SessionAddress; assistantStream?: true;
|
||
}
|
||
type SessionFollowFrame =
|
||
| { type: 'snapshot'; header: SessionWireHeader; cursor: number; records; hasMore: boolean;
|
||
projections: SessionProjectionBaseline; assistantStream?: ... }
|
||
| { type: 'event'; event: SessionWireEvent }
|
||
| { type: 'assistant-stream'; frame: ... };
|
||
```
|
||
|
||
Host JSDoc(index.d.ts:190-196):"complete opening snapshot followed by **gap-free durable event frames** and optional cursorless assistant-stream frames"。
|
||
|
||
- 首帧必然是 `snapshot`(带 `cursor` 与 `projections` 基线),后续是 `event`;**assistant-stream 帧是无游标的**(不可作为状态依据)。
|
||
- `SessionAddress` 支持子会话:`{kind:'subagent'; parentSessionId; childSessionId; mode:'one-shot'|'continuable'|'unknown'}`(:386-394)。v0.1 十席走**普通会话**(`{kind:'session'}`),不用 subagent 地址,这是与旧方案的关键区别。
|
||
|
||
**断线重连**(未验证的主要部分):客户端 session 层是"reconnecting"设计——
|
||
- `lib/types/client/index.d.ts:35`:"Install Client Session state and its **reconnecting** control stream";
|
||
- `sessions/manager.d.ts:258-263` `handleConnected()`:"Repair one re-established Host-event generation with queryable baselines ... Opened Session follow streams resume independently through API Gateway";
|
||
- `transport.d.ts` 有 `carrierFailed?: (error: RemoteStreamCarrierError) => void` 钩子(可重试断流)与 `failed`(终态失败)。
|
||
|
||
**档位**:**类型层已核实**(帧结构与"gap-free"承诺)。
|
||
**未验证**:断线后事件是否真的零丢失、重连窗口多长、`cursor` 从哪一层续(**需动态验证**——这是 P0 必测项之一,直接决定 `Reconciler` 要不要做全量对账)。
|
||
|
||
---
|
||
|
||
## 5. Workspace 能力
|
||
|
||
```ts
|
||
// node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/types.d.ts:13-25
|
||
interface WorkspaceView {
|
||
workspaceId: WorkspaceId;
|
||
path: string; // canonical
|
||
title: string;
|
||
sessionIds: readonly SessionId[];
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
}
|
||
// lib/types/client/model.d.ts:9-18
|
||
interface WorkspaceSnapshot {
|
||
items: readonly WorkspaceView[];
|
||
archivedSessionIds: ...; pinnedSessionIds: ...;
|
||
state: 'idle' | 'loading' | 'error';
|
||
phase: 'pending' | 'ready';
|
||
error: RemoteFailure | null;
|
||
}
|
||
```
|
||
|
||
Host 方法(`lib/types/index.d.ts`):`create(request)` :42("Create or **idempotently resolve** one Workspace over an existing directory")、`initializeDefault(signal)` :51、`rename` :57、`delete` :63("Remove one Workspace **registration** while retaining files and Sessions")、`insertBefore` :69、`insertSessionBefore` :75、`archiveSession(request)` :81、`unarchiveSession` :87、`pinSession` :93、`unpinSession` :99、`follow(signal)` :105。
|
||
|
||
客户端:`ctx.workspaces: IWorkspaces`(`lib/types/client/index.d.ts:16-20`),`list: WorkspaceSource`(`getSnapshot()` / `subscribe()`),`archiveSession(sessionId, options?: { stopActivity?: boolean })`(client/service.d.ts:80-82)。
|
||
|
||
**关键限制**:
|
||
|
||
| 限制 | 证据 |
|
||
| --- | --- |
|
||
| **有运行中工作时拒绝归档**,抛 `workspace/session-active { sessionId, activity }`,除非 `stopActivity: true` | types.d.ts:36-44;commands.js:120-127 |
|
||
| 归档**不能当 stop 用**:`stopActivity: true` 才会顺带停 | 同上 |
|
||
| workspace id **永不复用**(延迟数据不会复活已删行) | client/model.d.ts:55 |
|
||
| `delete` 只删注册,**不删文件、不删会话** | index.d.ts:63 |
|
||
|
||
**我们的用法**:`WorkspaceAdapter` 只做「读 → 投影」,**不让插件去创建/删除 workspace**(那是 workspace-groups 插件的领地,见 §6.1)。项目 `projectId` 由插件生成并绑定 `hostWorkspaceId`;宿主 workspace 的 `path` 作 canonical 键,**绝不用目录名/树行号/显示名做主键**(实施方案 §3 要求)。
|
||
|
||
**档位**:**类型层已核实**。**未验证**:归档被拒时 `activity` 数组的具体内容(需动态验证)。
|
||
|
||
---
|
||
|
||
## 6. 槽位(Slot)能力
|
||
|
||
### 6.1 项目树槽位归属:`sidebar.workspaces`
|
||
|
||
```ts
|
||
// node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/types/client/contract/slots.d.ts:57-61
|
||
'sidebar.workspaces': { kind: 'single'; scope: 'root'; owner: SidebarSectionOwnerProps };
|
||
// :54-55 JSDoc: "Declared by this package's 'sidebar' entry (declaring is claiming);
|
||
// ui-workspace registers the browser."
|
||
```
|
||
|
||
- 该槽是 **single / root**,`owner` 为 `SidebarSectionOwnerProps { wide: boolean; expandSidebar: () => void }`(:113-118)。
|
||
- ui-sidebar 声明它(声明即占用),ui-workspace 往里注册 `WorkspaceBrowser`(整个浏览区域,见 ui-workspace `contract/slots.d.ts` 头部注释 1-40 行)。
|
||
- **workspace-groups 插件(better 工作组)以 `priority: -1` shadow 官方浏览器**——旧仓库文档 `DEVELOPMENT.md`(dsh-workspace-groups)第 17 行原文:"客户端入口:向 `sidebar.workspaces` 槽注册(priority -1,shadow 官方浏览器)"。
|
||
|
||
**结论**:v0.1 左栏**不需要、也不应该**再往 `sidebar.workspaces` 注册;直接复用 workspace-groups 已占据的那棵树。若将来要改树的行内容,正确入口是它声明的子槽(`sidebar.workspaces.session.menu.item`、`sidebar.workspaces.session.row.action`、`sidebar.session.row.leading/hover`,见 ui-workspace `contract/slots.d.ts:122-191`),这些是 **list** 槽,additive、按 `order` 插队。
|
||
|
||
**档位**:归属 = **类型层已核实**;「priority -1 真的胜出」= **运行时已跑过**(workspace-groups 是在跑的插件,其 DEVELOPMENT.md 明示该策略)但**本机未实测**其 occupancy。
|
||
**未核实**:workspace-groups 当前版本的 priority 是否仍为 -1(该仓库 0.1.2 后可能改过)——需看它 `src/client/index.ts` 或 `ctx.slots.snapshot()`。
|
||
|
||
### 6.2 中央主区槽位归属:`main` / `main.conversation`
|
||
|
||
**`main.conversation`**(已核实):
|
||
|
||
```ts
|
||
// node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/types/client/contract/slots.d.ts:122-125
|
||
'main.conversation': { kind: 'single'; scope: 'session-maybe' };
|
||
// JSDoc: "Conversation shell beneath its root-scoped main-panel entry"
|
||
```
|
||
|
||
**`main`**(**未核实**):
|
||
|
||
- 该槽的 `SlotMap` 声明来自 `MainPanelId`(`@deepseek-ai/dsh-client-ui-layout/client`,被 ui-sidebar 在 `contract/slots.d.ts:14` 引用)。
|
||
- **本机没有 `@deepseek-ai/dsh-client-ui-layout` 包**(两份 `node_modules` 与全盘 `find` 均未命中)→ **无法读到 `main` 的 SlotMap 声明、kind、owner 类型**。
|
||
- 间接证据:`SidebarPanelMetadata { id: MainPanelId; order: number; label: string }`,JSDoc "List id and **matching main panel key**"(ui-sidebar slots.d.ts:101-108)→ `sidebar.panellist` 的 list `id` 就是 `main` 槽的 keyed `key`。旧插件正是这样用的(`panel/lib/client.js:2023-2027`,`key: PANEL_ID`)。
|
||
- 旧插件还依赖一个**未在类型里出现**的 `layout` 服务:`ctx.get("layout")` 回退 `ctx.layout`,再调 `selectPanel(panelId | null)`(client.js:1100-1108、1411-1415)。**这是运行时探测出来的**,没有 `.d.ts` 依据,v0.1 不应把它当公共 API。
|
||
|
||
**档位**:`main.conversation` = **类型层已核实**;`main` = **未核实(代码里没有:本机缺包)**。
|
||
**未验证**:`main` 是否 keyed、key 空间是否等于 MainPanelId、`selectPanel(null)` 回默认面板的行为(**需动态验证**)。
|
||
|
||
### 6.3 `'conversation.content'` 工厂可复用性
|
||
|
||
```ts
|
||
// ui-conversation contract/slots.d.ts:282-326
|
||
declare module '...ui-slots' {
|
||
interface SlotFactoryMap {
|
||
'conversation.content': {
|
||
scope: 'session-maybe';
|
||
props: ConversationContentInputProps;
|
||
children: {
|
||
'conversation.session': { kind: 'single'; scope: 'session' };
|
||
'conversation.composer': { kind: 'chain'; scope: 'session' };
|
||
'conversation.composer.bar': { kind: 'single'; scope: 'session-maybe' };
|
||
'conversation.input.dock': { kind: 'list'; scope: 'session' };
|
||
'conversation.hero.brand.mark': { kind: 'single'; scope: 'root' };
|
||
'conversation.hero.workspace': { kind: 'single'; scope: 'root' };
|
||
'conversation.hero.agentPreset': { kind: 'single'; scope: 'session-maybe' };
|
||
};
|
||
inject: ConversationInjected;
|
||
locale: 'conversation';
|
||
slots: { views: { scope: 'session' }; widthControls: { scope: 'root'; props: ... } };
|
||
};
|
||
}
|
||
}
|
||
// :509-513
|
||
interface ConversationContentInputProps { variant: 'main' | 'embedded'; phase: 'settling' | 'hero' | 'active'; hero: boolean }
|
||
```
|
||
|
||
JSDoc(:281):"**Reusable Conversation content instantiated by presentation hosts**"。
|
||
|
||
**含义**:这是 **SlotFactory**(不是普通 slot)——`registerFactory` 注册的是**定义**,`renderFactorySlot(name, props, options)` 实例化**occurrence**,每次 occurrence 独立(`store` 若为 factory 则每 occurrence 一份,见 ui-slots index.d.ts:505 附近注释)。
|
||
|
||
**可复用性结论**:
|
||
|
||
- ✅ **能**:任何拿到 `renderFactorySlot` 的组件都可以 `props.renderFactorySlot('conversation.content', { variant: 'embedded', phase: 'active', hero: false }, { fallback })` 渲染一份"真·原生对话"。
|
||
- ⚠️ **但**:`scope: 'session-maybe'` 说明它需要会话上下文。**在哪个 scope 下实例化、是否会自动获得 `SessionProvider`、与本项目 `sessionId` 如何对齐——本机类型只能证明这套 API 存在,不能证明"在右栏里嵌一个别的项目的会话"能工作**。→ **未验证(需动态验证)**。
|
||
- 实施方案 §4/§7 要求的「中间显示所选部门的真实会话」最稳的走法仍是:**让真会话占据 `main.conversation`**(宿主本来就这么渲染),插件只做「切换哪个 sessionId 被选中」,而不是自己再造一个 conversation。
|
||
|
||
**档位**:**类型层已核实**(声明完整可引用);**未验证**(嵌到非主区位置的可行性)。
|
||
|
||
### 6.4 slot register / registerFactory / renderFactorySlot 语义
|
||
|
||
```ts
|
||
// node_modules/@deepseek-ai/dsh-client-ui-slots/lib/types/index.d.ts
|
||
type SlotKind = 'single' | 'list' | 'keyed' | 'chain'; // :83
|
||
type SlotScope = 'root' | 'session-maybe' | 'session'; // :85
|
||
type SlotComponent<P> = (props: P) => ReactNode; // :343
|
||
```
|
||
|
||
**`register`**(两个重载,`SlotCore.register` @ :789-804;`SlotRegistry.register` 复用同一签名 @ registry.d.ts:85):
|
||
|
||
| 语义 | 证据 |
|
||
| --- | --- |
|
||
| 返回**幂等 disposer**;disposer 会**递归折叠**它声明的子槽 | :777-788 |
|
||
| 注册未声明的 slot → 抛错 | :789-804 及 load-time 校验段 |
|
||
| 同一 declarer 重复声明同一 child key → 抛错 | 同上 |
|
||
| 同一 store handle 跨不同 scope 挂载 → 抛错 | 同上 |
|
||
| keyed 缺 `key` / list 缺 `id` / chain 缺 `select` → 各自抛错 | 同上 |
|
||
| **shadowing**:同 cell(single=整槽、keyed=同 key、list=同 id)按 `priority` **升序**共存,最低者渲染;ties 保留注册顺序 | :769-776 |
|
||
| **在已占用 cell 的同 priority 再注册 → 抛错并点名 occupant** | :769-776;`KindOptions` 注释复述 "same key/id/cell + same priority throws" @ :560-584 |
|
||
| 声明了 `children` 就必须消费 `renderSlot`(或仅 chain 时 `renderSlotChain`),否则**编译期**报 `'children declared but the component consumes no renderSlot'` | `RendersCheck` :591-596 |
|
||
|
||
**`registerFactory`**:
|
||
|
||
```ts
|
||
// ui-slots index.d.ts:532-534
|
||
interface RegisterFactory {
|
||
<F>(options: RegisterFactoryOptions<F>, component: SlotComponent<FactoryComponentPropsOf<F>>): () => void;
|
||
}
|
||
// RegisterFactoryOptions @ :522-526
|
||
{ name: F; scope: FactoryDefOf<F>['scope'] } & children? & store? & inject? & locale? & slots?
|
||
```
|
||
|
||
有**类型级**碰撞检查:`FactoryCollisionCheck`(inject/input/local props 重叠 → 编译失败,:508-513)、`FactoryChildrenCheck`(子槽定义必须与 SlotMap 相符,:514-521)。
|
||
|
||
**`renderFactorySlot`**:
|
||
|
||
```ts
|
||
// ui-slots index.d.ts:395-404
|
||
type RenderFactorySlot = <F>(name: F, props: FactoryInputPropsOf<F>, options?: {
|
||
slots?: Partial<{ [N in local]: FactoryLocalComponent<F, N> }>;
|
||
fallback?: ReactNode;
|
||
}) => ReactNode;
|
||
interface PropsRenderFactories { renderFactorySlot: RenderFactorySlot }
|
||
```
|
||
|
||
"**每个 renderer 创建的组件都拿到 `renderFactorySlot`**"(原注释:Factory rendering capability supplied to **every** renderer-created Component)→ 插件组件里直接 `props.renderFactorySlot(...)` 即可,无需自己 import 任何东西。
|
||
|
||
相关但**禁止**的:`SlotRegistry.renderSlot(key, owner)` **运行时强制 `key === 'root'`**(registry.d.ts:150-158)。除 root 之外,任何槽都只能通过组件 props 的 `renderSlot` 渲染。
|
||
|
||
**`root` 槽禁止注册**——原注释(registry.d.ts:16-38)值得整段引用:
|
||
|
||
> "**DO NOT register here.** This is a single slot, so a second entry does not sit beside the frame — it shadows it, and a dynamically registered entry is assigned a lower priority than the shipped one, which makes it the winner: **the page would render your component alone, with every seat the frame declares gone.** For a surface of your own that floats over the whole app, register into `shell.overlay` instead (a list slot: additive, and click-through until your entry opts into pointer events)."
|
||
|
||
root 被 ui-layout 的 `AppFrame` 占据,AppFrame 在其内部声明 `sidebar` / `conversation` / `details` / `shell.overlay` 四个座位。
|
||
|
||
**`ctx.slots.inject(key, cb)`**(registry.d.ts:96-111)是**不依赖 apply 顺序**的正确姿势:槽已声明则同步跑 cb,否则等声明方 register 提交后跑;折叠时 dispose,再声明会重跑。旧插件全部用它(client.js:2006-2072),**这是对的,v0.1 继续用**。
|
||
|
||
**档位**:语义 = **类型层已核实**(文档注释极详细,逐条有行号)。
|
||
**运行时已跑过**:`register` + `inject` 组合(旧插件 5 处注册在真实宿主可用)。
|
||
**未验证**:priority 冲突抛错的**实测**表现(类型注释明说会抛,但没跑过);`registerFactory` 在本仓库跑过(旧插件没用到 factory)。
|
||
|
||
---
|
||
|
||
## 7. 插件客户端装载与注入
|
||
|
||
### 7.1 两种 inject,别混
|
||
|
||
| 声明位置 | 内容 | 语义 | 证据 |
|
||
| --- | --- | --- | --- |
|
||
| `package.json` → `dsh.client.inject` | **包名**(`@deepseek-ai/...`) | **informational**:只影响加载/预取顺序,**从不决定 apply 顺序** | ui-workspace `client/index.d.ts:24-31` 注释原文:"activation order ... is NOT constrained: `dsh.client.inject` edges are **informational (loading/prefetch metadata, never apply sequencing)**" |
|
||
| 客户端模块 → `exports.inject` | **cordis 服务短名**(`slots` / `sessions` / `uiWorkspace`…) | **强制**:apply 前这些服务必须就绪,缺了插件会被 **park**(不激活) | 旧插件 client.js:2073;client.js:1990 注释:"better-sidebar 是可选的,没装时不要写进 inject,否则插件会被 park" |
|
||
|
||
官方包的写法可对照(`package.json` 的 `dsh` 块):
|
||
|
||
```jsonc
|
||
// node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json
|
||
"dsh": { "client": { "inject": ["@deepseek-ai/dsh-api-remotes", "@deepseek-ai/dsh-api-session-controller", ...], "platform": "web" } }
|
||
// node_modules/@deepseek-ai/dsh-client-ui-renderer/package.json
|
||
"dsh": { "client": { "platform": "web", "immediately": true } }
|
||
// node_modules/@deepseek-ai/dsh-api-session-controller/package.json
|
||
"dsh": { "client": { "external": ["@deepseek-ai/dsh-api-gateway/client"], "inject": [...], "platform": "web" } }
|
||
```
|
||
|
||
### 7.2 仓库现状
|
||
|
||
| 文件 | 现状 | 结论 |
|
||
| --- | --- | --- |
|
||
| `C:\Users\qyh15\三省六部\package.json` | `dsh` 块只有 `manifestVersion: 1` 与 `bundle.patch`,**没有 `client`** | 根包是「模式策略层」,不带客户端 |
|
||
| [panel/package.json](../panel/package.json) | **有** `dsh.client = { platform: "web", inject: [...] }`,含 `@deepseek-ai/dsh-client-ui-model-selection` 等 6 个包名 | 客户端在 panel 子包里 |
|
||
| [panel/cordis.patch.yml](../panel/cordis.patch.yml) | `insert: [{ id: sansheng-agent-panel, name: dsh-sansheng-liubu-panel }]` | 把 panel 作为一个 bundle 插进 cordis |
|
||
| [panel/lib/client.js](../panel/lib/client.js):2073 | `exports.inject = ["slots","sessions","uiWorkspace","uiConversation","modelDirectories","remote","remote.agentPresets","remote.session","remote.subagents","remote.commands","sidebarRightTabs","sidebarRight"]` | 短名服务列表 |
|
||
|
||
### 7.3 客户端 bundle 的加载契约
|
||
|
||
```js
|
||
// panel/lib/client.js:1-6
|
||
window.__ModuleLoader__.load({
|
||
id: "dsh-sansheng-liubu-panel",
|
||
factory: (require) => { /* ... */ return module.exports },
|
||
});
|
||
```
|
||
|
||
- `require` 只对**共享模块表**里的模块生效;表外的 `@deepseek-ai/*` 必须内联。
|
||
- 共享表(官方式)见 `C:\Users\qyh15\Documents\dsh-workspaces-goups-new\dsh-workspace-groups\tsdown.config.ts:48-64`:`react`、`react/jsx-runtime`、`react-dom`、`react-dom/client`、`@deepseek-ai/cordis`、`@deepseek-ai/dsh-client-ui-slots`、`@deepseek-ai/dsh-client-ui-primitives`、`@deepseek-ai/dsh-client-store`(旧名 `dsh-client-runtime/client` 兼容)。
|
||
- 该仓库的纯净门约束(`DEVELOPMENT.md` §4.1):"任何其它 `@deepseek-ai/*` 值导入都会让构建失败"。**类型导入(`import type`)会被擦除,不受限**。
|
||
|
||
**档位**:装载契约 = **运行时已跑过**(旧插件 bundle 在真实宿主加载成功);`dsh.client.inject` 是 informational = **类型层已核实**(官方包注释原文)。
|
||
**未验证**:`immediately` 字段对自己插件的影响(代码里只有 renderer 用,**需动态验证**)。
|
||
|
||
---
|
||
|
||
## 8. 已知限制与未验证点
|
||
|
||
### 8.1 明确不能用 / 不要做
|
||
|
||
| # | 限制 | 依据 |
|
||
| --- | --- | --- |
|
||
| L1 | **`root` 槽不能注册**:会 shadow AppFrame,导致整页只剩你的组件 | registry.d.ts:16-38 原文 |
|
||
| L2 | 除 `root` 外**不能用 `slots.renderSlot(key)`** 渲染,运行时强制 `key === 'root'` | registry.d.ts:150-158 |
|
||
| L3 | **同 cell 同 priority 注册会抛错**(single/同 key/同 id 均算),并点名 occupant | ui-slots :769-776 |
|
||
| L4 | `main` 槽的声明读不到(本机无 `dsh-client-ui-layout`),**不能假设**它 keyed 或 key 空间 | §6.2 |
|
||
| L5 | `selectModel` **会改全局默认** | commands.js:145-175 |
|
||
| L6 | `cancel` **不取消排队消息**,取消后 FIFO 继续 | commands.js:468-478;session.d.ts:104-110 |
|
||
| L7 | 有活动时 `archiveSession` 拒绝(`workspace/session-active`),`stopActivity:true` 才停 | types.d.ts:36-44 |
|
||
| L8 | `delete` workspace **不删会话、不删文件** | index.d.ts:63 |
|
||
| L9 | `projections.faceOf(key)` 的 key 是裸 string,拼错不报错 | session.d.ts:55 |
|
||
| L10 | 把可选插件(如 better-sidebar)写进 `exports.inject` 会让插件被 **park** | client.js:1990 注释 |
|
||
| L11 | 客户端 `prompt()` 的 `requestId` 是第 4 个可选参数,**不传就没有幂等**(旧插件就没传) | session.d.ts:82-84;client.js:1148-1165 |
|
||
|
||
### 8.2 未验证点(分级)
|
||
|
||
| # | 项 | 类型 | 要做什么 |
|
||
| --- | --- | --- | --- |
|
||
| U1 | `main` 槽 kind/owner/keyed 语义 | **代码里没有**(缺包) | 装 `dsh-client-ui-layout` 或读其源码;运行时 `ctx.slots.snapshot('main')` |
|
||
| U2 | 三处 slot 的**实际占位者**(谁 priority 多少) | 需动态验证 | `ctx.slots.snapshot()` 导出 |
|
||
| U3 | workspace-groups 当前是否仍 priority -1 shadow `sidebar.workspaces` | 需动态验证 | 看其 `src/client/index.ts` 或快照 |
|
||
| U4 | 显式 `sessionId` 二次 create 真返回同 id | 需动态验证 | 连调两次比对 |
|
||
| U5 | 客户端 `prompt` 第 4 参 requestId 是否透传到 Host | 需动态验证 | 同 requestId 发两次看事件数 |
|
||
| U6 | `cancel()` → `running=false` 的时延与事件序列 | 需动态验证 | 长任务实测 |
|
||
| U7 | **宿主重启后客户端重建**:插槽是否重新注册、apply 是否重跑、浏览器本地状态(旧插件用 localStorage)是否还在 | 需动态验证(**v0.1 关键**) | 重启 DSH,看插件是否 park、绑定是否丢 |
|
||
| U8 | **follow 事件流断线重连**:是否零丢失、cursor 续点在哪层 | 需动态验证(**v0.1 关键**) | 断网/重启期间制造事件,重连后核对 |
|
||
| U9 | `'conversation.content'` 在非主区位置实例化是否可用 | 需动态验证 | 先做个最小 occurrence |
|
||
| U10 | `SessionCreateError.requestedSessionId` 是否真被回填 | 需动态验证 | 制造一次创建失败 |
|
||
| U11 | `modelCatalog` 的 efforts 枚举实际内容、`failures` 触发条件 | 需动态验证 | 打真实宿主 |
|
||
| U12 | 归档被拒时 `activity` 数组的成员结构 | 需动态验证 | 运行中归档一次 |
|
||
| U13 | 两窗口同会话并发投递的行为(租约/互斥) | 需动态验证(实施方案 §8 故障矩阵要求) | 两窗口同时派工 |
|
||
| U14 | `dsh.client.immediately` 对本插件的影响 | 需动态验证 | 加字段对比加载时机 |
|
||
|
||
### 8.3 与实施方案 §3 十二项的对账
|
||
|
||
| §3 项 | 本文对应 | 当前档位 |
|
||
| --- | --- | --- |
|
||
| 主页面扩展 | §6.2、§6.4 | 部分未核实(`main` 缺包) |
|
||
| 项目树 | §6.1 | 归属已核实,优先级待验证 |
|
||
| 内嵌聊天 | §6.3 | 类型层已核实,嵌入可用性未验证 |
|
||
| 独立 session | §2.1 | 类型层已核实 |
|
||
| 消息投递 | §2.2 | 类型层已核实 |
|
||
| 运行关联(hostRunId、终态、取消、重启查询) | §2.2、§2.3、§4.3 | 取消与终态语义已核实;**重启查询未核实** |
|
||
| 模型目录 | §3.1、§3.2 | 类型层已核实(Host 侧) |
|
||
| 配置/工具权限 | — | **本文未覆盖**(属 index.js 宿主策略层,需另开一节核实 `evaluateToolPolicy` 的宿主约束) |
|
||
| 材料/记忆 | — | **本文未覆盖**(未查记忆注入路径) |
|
||
| 存储(原子/事务/版本/事件恢复) | — | **本文未覆盖**(§4.1 提到 Host 用 `folded prefix`,插件侧存储方案尚未定) |
|
||
| 主题/构建 | §7.3(构建) | 构建契约已核实;主题未核实 |
|
||
|
||
---
|
||
|
||
## 9. 对 v0.1 实现的影响
|
||
|
||
1. **会话创建一律显式传 `sessionId`,别靠 `startSession` + 轮询。** `create({sessionId, cwd, agentPreset})` 天然幂等 adopt,冲突会明确报 `session/conflict` / `agent-preset/conflict`;而旧插件的 `uiWorkspace.startSession()` + `waitNew(15×200ms)`(client.js:1646-1680)是靠"轮询列表找新 id"猜归属,正是实施方案 §6.5 明令禁止的做法。`sessionId` 由 `projectId + roleId` 稳定派生,落库后永不变。
|
||
|
||
2. **调度必须放 Host 侧,浏览器只订阅。** 依据有二:`sessionController`、`workspaceController` 都是 Host 服务(`TypertRemoteService`,index.d.ts:17-19/20-23),Host 侧能直接 `create`/`prompt`/`follow`/`control`,不需要浏览器在场;而客户端离开页面时 `SessionReference.release()` 会拆掉本地 scope(sessions.d.ts:22-30)。→ `DispatchService`/`Reconciler` 写在 `index.js`(Host apply)里,插件 client 只做 `WorkbenchView`。
|
||
|
||
3. **幂等键用 `requestId`(Host 侧真幂等),不要自造去重表。** `hasPromptRequest` 会扫 inbox 与历史 `user/message` 的 `rpcId`,**跨重启**仍然生效(commands.js:301-302、547-561)。本项目只需要保证「同一个 dispatch 重试时复用同一个 requestId」。注意走客户端 `binding.session.prompt(...)` 时必须补第 4 参,否则等于没有幂等。
|
||
|
||
4. **模型配置是"每次派发前覆写",不是"设一次就记住"。** `selectModel` 会后台 `saveSelection` 改全局默认。所以:读 `modelCatalog()` 校验 desired → 每次派发前显式 `selectModel` → 用返回值 `selected` 记成 `effectiveConfigSnapshot`(可能被归一化)→ 失败就明确报错,**不静默换模型**(对应实施方案 §6 三条要求)。UI 的"本次/下次"直接用 `modelSelection` 投影的 `lastUsed` / `next`。
|
||
|
||
5. **`cancel` 只能到 `cancel_requested`;`inbox` 不会被清。** 要真停,得先 `cancel` 再把排队项逐条 `updateQueue(itemId, {kind:'remove'})`(`QueueAction`,types.d.ts:149-157);而 `updateQueue` 在 `target === 'next-turn'` 且 agent 仍 `running` 时支持 steer,否则抛 `session/steer-unavailable`(commands.js:435-436)。Attempt 状态机的 `cancel_requested → cancelled` 必须由 follow 事件确认,不能凭 `accepted:true`。
|
||
|
||
6. **左栏不要再注册 `sidebar.workspaces`。** 它是 single/root,已由 ui-workspace 声明、workspace-groups 占据。需要行内动作时只往 `sidebar.workspaces.session.menu.item` / `sidebar.workspaces.session.row.action` 这类 **list** 槽插(additive、按 order),这样不会和别人的 priority 撞(同 cell 同 priority 会抛错)。
|
||
|
||
7. **中间对话让真会话占 `main.conversation`,不要自己造 conversation。** `'conversation.content'` 是工厂、确实可复用,但 `scope: 'session-maybe'` 的绑定行为本机无法核实。最稳的是沿用旧插件的做法:`ctx.uiWorkspace.openSession(sessionId)` 让原生会话占据主区(client.js:1441-1460),插件只决定"选中哪个 session";需要额外信息就在 `conversation.session.header.actions`(list,旧插件已用 order 40)等已有座位上加,而不是覆盖整块。
|
||
|
||
8. **P0 收尾必须补 §0.5 那六项动态验证,尤其是 U7(宿主重启)与 U8(断线重连)。** 实施方案 §8 的「重启对账」「重复事件」「两窗口租约」全都依赖这两个行为;如果实测发现 follow 不能零丢失,`Reconciler` 就必须从"增量补偿"升级为"定期全量对账 + 状态机兜底",这会显著改变 §4 的分层预算。在此之前,任何"已通过"的结论都应写成"类型层已核实"。
|
||
|
||
---
|
||
|
||
## 附:本文引用的文件清单
|
||
|
||
| 简称 | 绝对路径 |
|
||
| --- | --- |
|
||
| ui-slots | `...\@deepseek-ai\dsh-client-ui-slots\lib\types\index.d.ts` |
|
||
| ui-renderer | `...\@deepseek-ai\dsh-client-ui-renderer\lib\types\client\registry.d.ts` / `client\index.d.ts` |
|
||
| ui-conversation | `...\@deepseek-ai\dsh-client-ui-conversation\lib\types\client\contract\slots.d.ts` |
|
||
| ui-sidebar | `...\@deepseek-ai\dsh-client-ui-sidebar\lib\types\client\contract\slots.d.ts` |
|
||
| ui-workspace | `...\@deepseek-ai\dsh-client-ui-workspace\lib\types\client\contract\slots.d.ts` / `navigation.d.ts` / `index.d.ts` |
|
||
| session-controller | `...\@deepseek-ai\dsh-api-session-controller\lib\types\index.d.ts` / `types.d.ts` / `commands.js` / `agent.js` / `client\contract\*.d.ts` |
|
||
| workspace-controller | `...\@deepseek-ai\dsh-api-workspace-controller\lib\types\index.d.ts` / `types.d.ts` / `client\model.d.ts` / `client\service.d.ts` |
|
||
| typert-protocol | `...\.pnpm\@deepseek-ai+dsh-typert-pro_ced96565a0ecf302a2ee4e627ca2288b\node_modules\@deepseek-ai\dsh-typert-protocol\lib\types\types.d.ts`、`remote-error.d.ts` |
|
||
|
||
其中 `...` = `C:\Users\qyh15\Documents\dsh-workspaces-goups-new\dsh-workspace-groups\node_modules\@deepseek-ai`。
|