chore(dsh): adapt to DSH 0.2.3-alpha.2 and drop pre-0.2.3 compatibility

Raise the whole baseline to the alpha line and stop carrying code that only
exists for older hosts (no runtime compatibility layer, per AGENTS §4):

- peers/engines: 14 DSH peers and engines.dsh -> 0.2.3-alpha.2, Cordis ->
  4.2.0-alpha.1, group/include 1.2.0-alpha.1, schemastery 3.20.0-alpha.1;
  dev pins and CI/e2e/install scripts move with them; plugin version
  0.34.0-alpha.0.
- admission: DSH 0.2.3 deleted `requestRejection`, so only the injected
  `connection.authentication` provider can call `admit`; the legacy branch
  and the direct-admit fallback are gone and the fence fails loudly.
- directory events: the projection authority is `workspace-root/change`;
  the side-chat cwd stamp emits it and the worktree scan no longer reads
  the retired `working-directory/change`.
- llm types: `@deepseek-ai/dsh-llm` no longer exports `./brand`, so
  MessageId comes from `./types`.
- client anchors: only `[data-slot="main.conversation"]`; the alpha.1
  `conversation` key is retired. `webServer.getOrigin` is called directly.

Gates: peers check, typecheck, lint, test (366 files / 4615 passed),
build, check:consumer-types.
This commit is contained in:
Menghuan1918 committed 2026-11-25 01:03:57 +08:00
1 parent d7e525471e
commit 795beabe22
39 files changed
+973 -973

No files matched your search

+2 -2
View File
@@ -171,14 +171,14 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Pin the exact 0.2.2-rc.2 host CLI; never use a dist-tag.
# Pin the exact 0.2.3-alpha.2 host CLI; never use a dist-tag.
# Keep peer resolution ON: do not add --legacy-peer-deps; it skips boot peers.
# The lanes speak the slash-only RPC dialect (tests/e2e/host-protocol.ts).
# NODE_OPTIONS below preserves the heap budget needed for prerelease peer resolution.
- name: Install dsh CLI (pinned)
env:
NODE_OPTIONS: --max-old-space-size=4096
run: npm install -g @deepseek-ai/dsh@0.2.2-rc.3
run: npm install -g @deepseek-ai/dsh@0.2.3-alpha.2
# lib/ is gitignored; the tarball is produced from this build.
- name: Build and pack the npm tarball
+2
View File
@@ -4,6 +4,8 @@
### 未发布
- 🧪 **DSH 0.2.3-alpha.2(alpha 线)适配**:14 条 DSH peer 与 `engines.dsh` 同批抬到 `0.2.3-alpha.2`,Cordis 依赖线同步到 `4.2.0-alpha.1`。宿主删除了 `@deepseek-ai/dsh-llm` 的 `./brand` 子路径,类型改从 `./types` 引入;目录投影的权威事件从 `working-directory/change` 换成 `workspace-root/change`,侧边对话的 cwd 边界戳记与工作树跟随随之调整;同时删除了所有旧宿主兼容分支(准入 `requestRejection` 回退、旧目录事件、旧 `data-slot` 锚点、`getOrigin` 探测)——这一版只服务 0.2.3-alpha.2+,更早宿主固定 v0.33.0。
- 🎛️ **紧凑划选菜单**:操作菜单与译文面板分开定宽;改写悬停时向有空间的一侧展开二级浮层,也支持点击与键盘进入。窄屏仍保持侧弹,必要时覆盖部分主菜单。翻译结果的「返回 / 复制」改为并排底栏,长译文单独滚动。
- 🧭 **开始页更直观**:「线索收集(beta)」用一行说明其用途——本地文件、飞书与 GitHub 的上下文信息中心;「侧边对话」移除 beta 标识。默认位置交换侧边对话与新建终端,用户已保存的自定义顺序不变。
+2
View File
@@ -6,6 +6,8 @@
### Unreleased
- 🧪 **DSH 0.2.3-alpha.2 (alpha line)**: the 14 DSH peers and `engines.dsh` move to `0.2.3-alpha.2`, with the Cordis line at `4.2.0-alpha.1`. The host removed `@deepseek-ai/dsh-llm`'s `./brand` subpath, so the type now comes from `./types`, and the projection authority moved from `working-directory/change` to `workspace-root/change` — side-chat cwd stamps and worktree following moved with it. Every older-host compatibility branch is gone too (the `requestRejection` admission fallback, the legacy directory event, the old `data-slot` anchor and the `getOrigin` probe): this build serves 0.2.3-alpha.2+ only, and older hosts stay on v0.33.0.
- 🎛️ **Compact selection menus**: action menus use a smaller width than translation results. Rewrite opens a lateral flyout on hover, click or keyboard, flipping sides to fit; narrow screens keep the flyout with partial parent overlap. Translation results place Back and Copy together in a bottom bar, with long text scrolling separately.
- 🧭 **Clearer start-page entries**: Clues is now marked beta and described as a context hub for local files, Feishu and GitHub; Side Chat drops its beta marker. Side Chat and New terminal exchange their default positions without changing saved custom ordering.
+6 -5
View File
@@ -7,7 +7,7 @@
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml/badge.svg" /></a>
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/omdsh-dev/DSH-better-sidebar" /></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="Supported DSH versions: 0.2.2-rc.3+" src="https://img.shields.io/badge/DSH-0.2.2--rc.3%2B-4d6bfe" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="Supported DSH versions: 0.2.3-alpha.2+" src="https://img.shields.io/badge/DSH-0.2.3--alpha.2%2B-4d6bfe" /></a>
</div>
<div align="center">
@@ -44,15 +44,16 @@ With the `dsh-context` plugin installed, three places offer a one-click jump int
dsh plugin --profile web add dsh-better-sidebar@latest
```
Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R). Requires DSH **0.2.2-rc.3+**.
Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R). Requires DSH **0.2.3-alpha.2+**.
> **Compatibility warning — match the plugin to the host line.** As of 2026-11-24, DSH's npm `latest` and `next` are both **0.2.2-rc.5**. **v0.33.0 requires DSH 0.2.2-rc.3+**; hosts on **0.2.2-rc.2** must pin `dsh-better-sidebar@0.32.1`, and hosts on **0.2.2-rc.1** must pin `dsh-better-sidebar@0.32.0`. Hosts on the 0.2.1 line (**0.2.1-rc.1 ~ rc.5**) must pin `dsh-better-sidebar@0.28.2` — v0.29.0 was never published to npm. DSH 0.2.1-alpha.5 users must pin `dsh-better-sidebar@0.28.0-alpha.0`, and hosts still on **0.2.0-rc.2** must pin `dsh-better-sidebar@0.26.1`. A 0.x caret never spans a minor version, so one plugin build cannot serve two host lines. The marketplace installer picks the plugin's `latest` regardless of host version, so an old host gets a version-rejection error — upgrade the host or pin the version explicitly. The two packages' `latest` tags are independent.
> **Compatibility warning — match the plugin to the host line.** As of 2026-11-24, DSH's npm `latest` and `next` are both **0.2.2-rc.5**. **v0.34.0-alpha.0 requires DSH 0.2.3-alpha.2+** (alpha line), while the stable **v0.33.0** needs DSH 0.2.2-rc.3+; hosts on **0.2.2-rc.2** must pin `dsh-better-sidebar@0.32.1`, and hosts on **0.2.2-rc.1** must pin `dsh-better-sidebar@0.32.0`. Hosts on the 0.2.1 line (**0.2.1-rc.1 ~ rc.5**) must pin `dsh-better-sidebar@0.28.2` — v0.29.0 was never published to npm. DSH 0.2.1-alpha.5 users must pin `dsh-better-sidebar@0.28.0-alpha.0`, and hosts still on **0.2.0-rc.2** must pin `dsh-better-sidebar@0.26.1`. A 0.x caret never spans a minor version, so one plugin build cannot serve two host lines. The marketplace installer picks the plugin's `latest` regardless of host version, so an old host gets a version-rejection error — upgrade the host or pin the version explicitly. The two packages' `latest` tags are independent.
<details>
<summary><b>Pick the plugin version for your DSH version</b></summary>
| Your DSH version | Install command |
| --- | --- |
| **0.2.3-alpha.2+** | `dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0` |
| **0.2.2-rc.3+** | `dsh plugin --profile web add dsh-better-sidebar@0.33.0` |
| **0.2.2-rc.2** | `dsh plugin --profile web add dsh-better-sidebar@0.32.1` |
| **0.2.2-rc.1** | `dsh plugin --profile web add dsh-better-sidebar@0.32.0` |
@@ -75,7 +76,7 @@ Always pin **exact versions** for older releases (`latest` moves forward with ea
```text
Install the dsh-better-sidebar plugin (a sidebar workbench for DSH):
1. Confirm DSH is 0.2.2-rc.3 or newer, then run dsh plugin --profile web add dsh-better-sidebar@0.33.0
1. Confirm DSH is 0.2.3-alpha.2 (alpha line) or newer, then run dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0
2. Remind me to hard-refresh the browser (Cmd/Ctrl+Shift+R) afterwards
If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-better-sidebar README first.
```
@@ -98,7 +99,7 @@ If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-bett
| **Two sidebars** on the page | Double mounting. Remove the legacy manual mount line (`- insert: ... better-sidebar ...`) from `~/.dsh/profiles/web/cordis.patch.yml`; aggregate packages mounting this package under a different id are auto-yielded, no action needed. |
| Settings values gone after upgrade | Since DSH 0.1.7, preferences live on this plugin's mount row in the profile (default entry id `better-sidebar`). The plugin migrates your old `settings.yaml` values once on first start and never overwrites newer values. |
| Terminal unavailable | Terminals are provided by **DSH itself** (this plugin ships no PTY) — see DSH docs; "host provides no terminal capability" in the bottom terminal means this deployment has no terminal controller mounted. |
| `dsh: command not found` | Install DSH first; or use `npx -y --package @deepseek-ai/dsh@0.2.2-rc.3 dsh plugin --profile web add dsh-better-sidebar@0.33.0`. |
| `dsh: command not found` | Install DSH first; or use `npx -y --package @deepseek-ai/dsh@0.2.3-alpha.2 dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0`. |
</details>
+6 -5
View File
@@ -7,7 +7,7 @@
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml/badge.svg" /></a>
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/omdsh-dev/DSH-better-sidebar" /></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="支持的 DSH 版本:0.2.2-rc.3+" src="https://img.shields.io/badge/DSH-0.2.2--rc.3%2B-4d6bfe" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="支持的 DSH 版本:0.2.3-alpha.2+" src="https://img.shields.io/badge/DSH-0.2.3--alpha.2%2B-4d6bfe" /></a>
</div>
<div align="center">
@@ -44,15 +44,16 @@
dsh plugin --profile web add dsh-better-sidebar@latest
```
装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可。要求 DSH **0.2.2-rc.3+**。
装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可。要求 DSH **0.2.3-alpha.2+**。
> **兼容性警告:插件版本必须与宿主线匹配。** 截至 2026-11-24,DSH 的 npm `latest` 与 `next` 都是 **0.2.2-rc.5**。**v0.33.0 要求 DSH 0.2.2-rc.3+**;仍在 **0.2.2-rc.2** 的宿主必须固定 `dsh-better-sidebar@0.32.1`,**0.2.2-rc.1** 的宿主固定 `dsh-better-sidebar@0.32.0`。仍停在 0.2.1 线(**0.2.1-rc.1 ~ rc.5**)的宿主必须固定 `dsh-better-sidebar@0.28.2`——v0.29.0 从未发布到 npm。DSH 0.2.1-alpha.5 用户固定 `dsh-better-sidebar@0.28.0-alpha.0`,**0.2.0-rc.2** 宿主固定 `dsh-better-sidebar@0.26.1`。0.x 的 caret 不跨 minor,因此一个构建无法同时服务两条宿主线。市场安装器按插件的 `latest` 安装、不按宿主版本选版本,旧宿主会收到版本拒绝错误——请升级宿主或显式固定版本。两个包的 `latest` 标签不是同一支持线。
> **兼容性警告:插件版本必须与宿主线匹配。** 截至 2026-11-24,DSH 的 npm `latest` 与 `next` 都是 **0.2.2-rc.5**。**v0.34.0-alpha.0 要求 DSH 0.2.3-alpha.2+**(alpha 线),稳定线 **v0.33.0** 仍要求 DSH 0.2.2-rc.3+;仍在 **0.2.2-rc.2** 的宿主必须固定 `dsh-better-sidebar@0.32.1`,**0.2.2-rc.1** 的宿主固定 `dsh-better-sidebar@0.32.0`。仍停在 0.2.1 线(**0.2.1-rc.1 ~ rc.5**)的宿主必须固定 `dsh-better-sidebar@0.28.2`——v0.29.0 从未发布到 npm。DSH 0.2.1-alpha.5 用户固定 `dsh-better-sidebar@0.28.0-alpha.0`,**0.2.0-rc.2** 宿主固定 `dsh-better-sidebar@0.26.1`。0.x 的 caret 不跨 minor,因此一个构建无法同时服务两条宿主线。市场安装器按插件的 `latest` 安装、不按宿主版本选版本,旧宿主会收到版本拒绝错误——请升级宿主或显式固定版本。两个包的 `latest` 标签不是同一支持线。
<details>
<summary><b>按 DSH 版本选插件版本</b></summary>
| 你的 DSH 版本 | 安装命令 |
| --- | --- |
| **0.2.3-alpha.2+** | `dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0` |
| **0.2.2-rc.3+** | `dsh plugin --profile web add dsh-better-sidebar@0.33.0` |
| **0.2.2-rc.2** | `dsh plugin --profile web add dsh-better-sidebar@0.32.1` |
| **0.2.2-rc.1** | `dsh plugin --profile web add dsh-better-sidebar@0.32.0` |
@@ -75,7 +76,7 @@ dsh plugin --profile web add dsh-better-sidebar@latest
```text
帮我安装 dsh-better-sidebar 插件(DSH 侧边栏工作台),步骤:
1. 先确认 DSH 为 0.2.2-rc.3 或更新版本,再执行 dsh plugin --profile web add dsh-better-sidebar@0.33.0
1. 先确认 DSH 为 0.2.3-alpha.2(alpha 线)或更新版本,再执行 dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0
2. 完成后提醒我硬刷新浏览器(Cmd/Ctrl+Shift+R)
遇到报错先查 https://github.com/omdsh-dev/DSH-better-sidebar README 的常见问题表。
```
@@ -98,7 +99,7 @@ dsh plugin --profile web add dsh-better-sidebar@latest
| 页面出现**两个侧边栏** | 双挂载。删掉 `~/.dsh/profiles/web/cordis.patch.yml` 里旧的手动挂载行(`- insert: ... better-sidebar ...`);聚合包以不同 id 挂载本包时会自动退让,无需处理。 |
| 升级后设置页的值去哪了 | DSH 0.1.7 起偏好写在 profile 里本插件的挂载行上(默认 entry id `better-sidebar`),插件首次启动会把旧 `settings.yaml` 里的配置一次性回迁,不会覆盖新设的值。 |
| 终端无法使用 | 终端由 **DSH 自身**提供(本插件不自带 PTY),请查 DSH 侧文档;底部终端显示「宿主未提供终端能力」= 这个部署没挂终端控制器。 |
| 提示 `dsh: command not found` | 先安装 DSH;或用 `npx -y --package @deepseek-ai/dsh@0.2.2-rc.3 dsh plugin --profile web add dsh-better-sidebar@0.33.0`。 |
| 提示 `dsh: command not found` | 先安装 DSH;或用 `npx -y --package @deepseek-ai/dsh@0.2.3-alpha.2 dsh plugin --profile web add dsh-better-sidebar@0.34.0-alpha.0`。 |
</details>
+29 -9
View File
@@ -7,11 +7,11 @@
| 项 | 值 |
| --- | --- |
| 基线宿主 | **DSH 0.2.2-rc.2**(v0.32.1 起;v0.33.0 起安装下限抬到 rc.3,见 `engines.dsh`) |
| DSH peer 数量 | **14 条** `@deepseek-ai/dsh-*`,下限全部 `^0.2.2-rc.2` |
| devDependencies | 每条 DSH 包精确钉 `0.2.2-rc.2`(**30 条**:0.2.2-rc.2 新增的传递 peer `@deepseek-ai/dsh-error` 已提升进 devDependencies) |
| 伴随依赖 | Cordis peer `^4.1.0` / dev `4.1.0`、group `~1.1.0`、schemastery `~3.19.0` 解析、include `1.1.0` |
| `engines.dsh` | **`>=0.2.2-rc.3 <0.3.0`**(package.json 与 `dsh.plugin.json` 同值;字段存在时宿主只按它判定,peer 不再参与) |
| 基线宿主 | **DSH 0.2.3-alpha.2**(v0.34.0-alpha.0 起;安装下限与 peer 同批抬到 alpha 线) |
| DSH peer 数量 | **14 条** `@deepseek-ai/dsh-*`,下限全部 `^0.2.3-alpha.2` |
| devDependencies | 每条 DSH 包精确钉 `0.2.3-alpha.2`(**30 条**:传递 peer `@deepseek-ai/dsh-error` 在 0.2.2 线已提升进 devDependencies) |
| 伴随依赖 | Cordis peer `^4.2.0-alpha.1` / dev `4.2.0-alpha.1`、group `~1.2.0-alpha.1`、schemastery `~3.20.0-alpha.1` 解析、include `1.2.0-alpha.1` |
| `engines.dsh` | **`>=0.2.3-alpha.2 <0.3.0`**(package.json 与 `dsh.plugin.json` 同值;字段存在时宿主只按它判定,peer 不再参与) |
| 守护测试 | tests/market-manifest.spec.ts(peer 形状)+ tests/dsh-baseline.spec.ts(CI / 脚本 / 文档同版) |
14 条 peer 里包含 `dsh-client-ui-input-trigger`(划选引用 chip 的 `ctx.inputTriggers` 服务);新增 peer 必须同批更新 AGENTS、本文件、指南与 README 的计数。
@@ -20,7 +20,8 @@
| 用户的 DSH | 应安装的插件 |
| --- | --- |
| **0.2.2-rc.3+** | **v0.33.0**(当前线) |
| **0.2.3-alpha.2+** | **v0.34.0-alpha.0**(alpha 线,进行中) |
| **0.2.2-rc.3+** | **v0.33.0**(稳定线) |
| 0.2.2-rc.2 | **v0.32.1** |
| 0.2.2-rc.1 | **v0.32.0** |
| 0.2.1-rc.1 ~ 0.2.1-rc.5 | **v0.28.2** |
@@ -29,7 +30,7 @@
| 0.2.0-rc.1 | v0.24.1 |
| 0.1.7-rc.1 ~ 0.1.7 | v0.22.1 |
自 v0.33.0 起 `package.json#engines.dsh` 为 `>=0.2.2-rc.3 <0.3.0`,安装下限随之抬到 rc.3;v0.32.1 仍接受 rc.2。
自 v0.34.0-alpha.0 起 `package.json#engines.dsh` 为 `>=0.2.3-alpha.2 <0.3.0`,装在下限之下的宿主请继续用 v0.33.0;v0.32.1 仍接受 0.2.2-rc.2。
## 3. 为什么「一个构建只服务一条宿主线」
@@ -54,7 +55,7 @@
## 5. 仍然生效的删除契约(alpha.5 起)
- 不再依赖 `dsh-invariants`、`ctx.invariants` 或上游 `/invariant` 子路径;不发布 invariant companion。
- HTTP/WS 准入优先调用 `ctx.connection.requestRejection(req)`,**只有 `undefined` 放行**;DSH 0.2.2-rc.3 起该方法 deprecated、0.2.3 已删除,缺席时改调 `admit(req)` 并读同一个 `rejection` 字段。0.2.3 的 `admit` 把凭据校验委托给嵌套服务 `connection.authentication`,cordis 只允许**显式注入**该服务的调用方读取它,所以这一段放在 `ctx.inject(['connection.authentication'])` 子 fiber 里执行;rc.2–rc.5 没有该服务,子 fiber 不激活,旧宿主行为不变。两者都没有则直接抛错;不恢复 `webRuntime`,不自建信任例外。
- HTTP/WS 准入只调 `ctx.connection.admit(req)`,读返回对象上的 `rejection` 字段。`admit` 把凭据校验委托给嵌套服务 `connection.authentication`,cordis 只允许**显式注入**该服务的调用方读取它,所以这一段放在 `ctx.inject(['connection.authentication'])` 子 fiber 里执行;服务缺席时准入直接抛错(v0.34.0-alpha.0 起删除 `requestRejection` 回退)。不恢复 `webRuntime`,不自建信任例外。
## 6. 0.2.1 → 0.2.2 的代码级差异(v0.30.0)
@@ -79,7 +80,26 @@
- 验证结果(2026-11-16):临时 worktree 把 devDependencies 的 30 条 DSH 包升到 `0.2.2-rc.3`(不提交)后,`typecheck` / `build` / `check:consumer-types` 通过;全量单测 302/303 文件、3,517 例通过——唯一失败是 `tests/dsh-baseline.spec.ts` 仍断言 dev 钉版为 rc.2(临时升版导致,属于验证环境而非代码);rc.3 宿主真实挂载 26 通过 / 6 跳过。rc.2 宿主同样 26 通过 / 6 跳过。
- 结论:当前构建服务 **0.2.2-rc.2 与 rc.3 两条 RC**;dev 钉版与 CI 仍保持 rc.2 基线;安装下限由 `engines.dsh` 裁决为 rc.3 起(见 §1)。
## 9. 适配记录索引
## 9. 0.2.2-rc.5 → 0.2.3-alpha.2(v0.34.0-alpha.0)
| 变化 | 影响 | 处理 |
| --- | --- | --- |
| `@deepseek-ai/dsh-llm` 的 `exports` 删除 `./brand` 子路径(文件仍在 `lib/types/brand.d.ts`,`./types` 与根入口重新导出) | `src/sidechat-routes.ts` 的 `MessageId` 类型解析回退到旧副本,报两处 `[BRAND]` 不匹配 | 改从 `@deepseek-ai/dsh-llm/types` 引入 |
| Cordis 抬到 `4.2.0-alpha.1`(宿主 peer `~4.2.0-alpha.1`);`cordis-plugin-group` / `include` 抬到 `1.2.0-alpha.1`;`schemastery` 解析到 `~3.20.0-alpha.1` | dev 依赖树 | dev 钉 4.2.0-alpha.1 / group ~1.2.0-alpha.1 / include 1.2.0-alpha.1;schemastery peer 抬到 `>=3.20.0-alpha.1 <4` |
| 宿主包集合:移除 `dsh-client-ui-settings-plugin-inventory` / `-settings-plugins`;`dsh-experimental-cua-macos` 改名 `dsh-cua-macos`;新增 session-panel / session-status / connector-account / timeline | 本插件未引用被移除的包 | 无需改动 |
| 删除 `rankByName`、`ApiKeyCheck` / `assertUsableApiKey`、`SettingsPluginsTabOwnerProps` | 本插件 0 引用 | 无需改动 |
| 会话格式版本仍是 4、`SUBAGENT_DESCRIPTOR_VERSION` 仍是 3 | — | 不变 |
同一批删除的旧宿主兼容路径(不写运行时兼容层,旧宿主固定旧插件版本):
- `src/index.ts` 的 `requestRejection` 分支与直连 `admit` 回退——只剩注入 provider 一条路,服务缺席即抛 `TypeError`;
- `src/active-worktree.ts` 的 `working-directory/change` 旧目录事件——只认 `workspace-root/change`;
- `src/client/center-column.ts` 的 `[data-slot="conversation"]` 旧锚点——只认 `[data-slot="main.conversation"]`;
- `src/clues/context/injection.ts` 对 `webServer.getOrigin` 的存在性探测——直接调用。
验证(2026-11-24):`pnpm peers check` / `typecheck` / `lint` / `test` 全绿——真实破损只有 `dsh-llm/brand` 一处。
## 10. 适配记录索引
- [0.2.2-rc.2](plans/2026-11-12-dsh-0.2.2-rc.2-adaptation.md)
- [0.2.2-rc.1](plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md)
+2 -2
View File
@@ -2,9 +2,9 @@
> 从 `AGENTS.md` §3 移出的深度参考(原 §3.4 第 1–13 条与 0.1.5–0.1.7 历史线中仍然生效的部分)。
> **编号保持不变**:代码、测试与文档里写的「AGENTS.md §3.4 第 N 条」就是本文第 N 条。
> 历史版本已不在支持线内(当前基线 DSH 0.2.2-rc.2,见 [docs/dsh-version-adaptation.md](dsh-version-adaptation.md));逐条适配过程见 [docs/plans/](plans/) 与 [CHANGELOG.md](../CHANGELOG.md)。
> 历史版本已不在支持线内(当前基线 DSH 0.2.3-alpha.2,见 [docs/dsh-version-adaptation.md](dsh-version-adaptation.md));逐条适配过程见 [docs/plans/](plans/) 与 [CHANGELOG.md](../CHANGELOG.md)。
当前适配约束:HTTP/WS 均由宿主 Connection 的准入方法裁决 Host/Origin 与浏览器认证——`requestRejection(req)` 存在时用它(只有 `undefined` 放行),rc.3 之后它被删除、只剩 `admit(req)`,则读 `admit` 返回对象上的同一个 `rejection` 字段。0.2.3 的 `admit` 需要一个由调用方显式注入的嵌套服务 `connection.authentication`(rc.2–rc.5 没有它),因此 `admit` 在 `ctx.inject(['connection.authentication'])` 子 fiber 内调用;不读取已删除的 `webRuntime`,也不自建信任表。alpha.5 同时移除了 `@deepseek-ai/dsh-invariants`、`ctx.invariants` 和上游 `/invariant` 子路径;本插件不再发布 invariant companion。
当前适配约束:HTTP/WS 均由宿主 Connection 的 `admit(req)` 裁决 Host/Origin 与浏览器认证,读返回对象上的 `rejection` 字段。`admit` 把凭据校验委托给嵌套服务 `connection.authentication`,cordis 只允许显式注入该服务的调用方读取它,因此准入在 `ctx.inject(['connection.authentication'])` 子 fiber 内执行;这是唯一路径——0.2.3 删除了 `requestRejection`,本构建不再保留旧宿主回退,也不读取已删除的 `webRuntime`、不自建信任表。alpha.5 同时移除了 `@deepseek-ai/dsh-invariants`、`ctx.invariants` 和上游 `/invariant` 子路径;本插件不再发布 invariant companion。
**本次 0.2.2-rc.1 → rc.2 有真实契约变化**:`ui-primitives` 的 `Menu` 用 `anchorRef` / `anchorPoint` 取代 `getAnchorRect`,portal 菜单改为 CSS Anchor Positioning,子菜单改为 portal 到 `document.body` 并按空间选 side / single-page;`@deepseek-ai/dsh-agent-team`(base composition)取代实验包,`TeamService` 的 `tryMembership` 换成 `isEnabled`;所有宿主包把 Cordis peer 收紧到 `~4.1.0`,并新增 `@deepseek-ai/dsh-error` 传递 peer。上一轮 0.2.1 → 0.2.2 的 `AgentModel` / PTC / sprite 变化见 [0.2.2-rc.1 适配记录](plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md)。逐项证据见 [0.2.2-rc.2 适配记录](plans/2026-11-12-dsh-0.2.2-rc.2-adaptation.md)。
+2 -2
View File
@@ -1,10 +1,10 @@
{
"id": "dsh-external/dsh-better-sidebar",
"version": "0.33.0",
"version": "0.34.0-alpha.0",
"main": "./lib/index.js",
"description": "更好用的右侧边栏——文件树、编辑器、文件变动、任务和侧边对话都收在这一栏里,每个会话互不干扰。侧边栏配置在左下角「设置 → 侧边卡片」中。暴露服务供其他插件注册侧边栏页面与文件预览器",
"engines": {
"dsh": ">=0.2.2-rc.3 <0.3.0"
"dsh": ">=0.2.3-alpha.2 <0.3.0"
},
"contributes": {
"tools": [],
+51 -51
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-better-sidebar",
"version": "0.33.0",
"version": "0.34.0-alpha.0",
"description": "Better Sidebar for DSH — file tree, editor, changes, tasks and side chat in one column, separate for every conversation. Configure it in Settings → Side card (bottom-left). Also exposes a service other plugins use to register sidebar tabs and file viewers.",
"type": "module",
"repository": {
@@ -39,7 +39,7 @@
"./locale/*.json": "./locale/*.json"
},
"engines": {
"dsh": ">=0.2.2-rc.3 <0.3.0",
"dsh": ">=0.2.3-alpha.2 <0.3.0",
"node": ">=20"
},
"packageManager": "pnpm@11.8.0",
@@ -100,22 +100,22 @@
},
"license": "MIT",
"peerDependencies": {
"@deepseek-ai/cordis": "^4.1.0",
"@deepseek-ai/schemastery": ">=3.18.5 <4",
"@deepseek-ai/dsh-agent": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
"@deepseek-ai/dsh-llm": "^0.2.2-rc.2",
"@deepseek-ai/dsh-session": "^0.2.2-rc.2",
"@deepseek-ai/dsh-settings": "^0.2.2-rc.2",
"@deepseek-ai/dsh-subagent": "^0.2.2-rc.2",
"@deepseek-ai/dsh-tools": "^0.2.2-rc.2",
"@deepseek-ai/cordis": "^4.2.0-alpha.1",
"@deepseek-ai/schemastery": ">=3.20.0-alpha.1 <4",
"@deepseek-ai/dsh-agent": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-llm": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-session": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-settings": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-subagent": "^0.2.3-alpha.2",
"@deepseek-ai/dsh-tools": "^0.2.3-alpha.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
@@ -151,39 +151,39 @@
"@codemirror/state": "^6.7.1",
"@codemirror/view": "^6.43.8",
"@cordisjs/plugin-loader": "^1.0.0-rc.5",
"@deepseek-ai/cordis": "4.1.0",
"@deepseek-ai/cordis-plugin-group": "~1.1.0",
"@deepseek-ai/cordis-plugin-include": "1.1.0",
"@deepseek-ai/dsh-agent": "0.2.2-rc.2",
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
"@deepseek-ai/dsh-attachment": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-store": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-input-trigger": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.2",
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.2",
"@deepseek-ai/dsh-error": "0.2.2-rc.2",
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.2",
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
"@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.2",
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
"@deepseek-ai/dsh-scope": "0.2.2-rc.2",
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.2",
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
"@deepseek-ai/dsh-settings": "0.2.2-rc.2",
"@deepseek-ai/dsh-subagent": "0.2.2-rc.2",
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
"@deepseek-ai/dsh-util-code-language": "0.2.2-rc.2",
"@deepseek-ai/dsh-util-time": "0.2.2-rc.2",
"@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.2",
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.2",
"@deepseek-ai/cordis": "4.2.0-alpha.1",
"@deepseek-ai/cordis-plugin-group": "~1.2.0-alpha.1",
"@deepseek-ai/cordis-plugin-include": "1.2.0-alpha.1",
"@deepseek-ai/dsh-agent": "0.2.3-alpha.2",
"@deepseek-ai/dsh-agent-loop": "0.2.3-alpha.2",
"@deepseek-ai/dsh-attachment": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-locale": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-store": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-conversation": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-input-trigger": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.3-alpha.2",
"@deepseek-ai/dsh-client-ui-slots": "0.2.3-alpha.2",
"@deepseek-ai/dsh-error": "0.2.3-alpha.2",
"@deepseek-ai/dsh-host-webserver": "0.2.3-alpha.2",
"@deepseek-ai/dsh-llm": "0.2.3-alpha.2",
"@deepseek-ai/dsh-ptc-runtime": "0.2.3-alpha.2",
"@deepseek-ai/dsh-sandbox": "0.2.3-alpha.2",
"@deepseek-ai/dsh-sandbox-policy": "0.2.3-alpha.2",
"@deepseek-ai/dsh-scope": "0.2.3-alpha.2",
"@deepseek-ai/dsh-session": "0.2.3-alpha.2",
"@deepseek-ai/dsh-session-persistence": "0.2.3-alpha.2",
"@deepseek-ai/dsh-session-projection": "0.2.3-alpha.2",
"@deepseek-ai/dsh-settings": "0.2.3-alpha.2",
"@deepseek-ai/dsh-subagent": "0.2.3-alpha.2",
"@deepseek-ai/dsh-system-prompt": "0.2.3-alpha.2",
"@deepseek-ai/dsh-tools": "0.2.3-alpha.2",
"@deepseek-ai/dsh-user-approval": "0.2.3-alpha.2",
"@deepseek-ai/dsh-util-code-language": "0.2.3-alpha.2",
"@deepseek-ai/dsh-util-time": "0.2.3-alpha.2",
"@deepseek-ai/dsh-util-workspace-path": "0.2.3-alpha.2",
"@deepseek-ai/dsh-working-directory": "0.2.3-alpha.2",
"@eslint/js": "^10.0.1",
"@formkit/auto-animate": "^0.10.0",
"@lezer/highlight": "^1.2.3",
+673 -678
View File
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -59,7 +59,7 @@ const effects = []
const routes = []
const registry = { get: id => (id === 'ws-1' ? { path: workspace } : undefined) }
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register(route) {
routes.push(route)
@@ -75,7 +75,8 @@ const ctx = {
const cleanup = fn()
if (typeof cleanup === 'function') effects.push(cleanup)
},
inject() {
inject(deps, callback) {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } })
return () => {}
},
on() {
+2 -2
View File
@@ -44,7 +44,7 @@ e2e_require_cmd() {
# 回退的 npx 版本是显式钉死的:不钉就会解析 npm 的 dist-tag,可能静默挂到
# 插件不支持的宿主上。**必须写精确版本,不能写 `@next`/`@alpha` 等 dist-tag**。
# 该版本必须与 package.json 的 DSH peer 基线同步。
DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@0.2.2-rc.3}"
DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@0.2.3-alpha.2}"
e2e_resolve_dsh_cmd() {
local explicit="${DSH_CMD}"
if ! command -v "$DSH_CMD" >/dev/null 2>&1; then
@@ -66,7 +66,7 @@ e2e_resolve_dsh_cmd() {
# 己在挂什么),只告警。
e2e_check_dsh_version() {
local explicit="$1" actual expected
expected="${DSH_EXPECT_VERSION:-0.2.2-rc.3}"
expected="${DSH_EXPECT_VERSION:-0.2.3-alpha.2}"
# `dsh --version` 冷启动要走 npx,给足预算;拿不到版本就只告警。
actual="$($DSH_CMD --version 2>/dev/null | tr -d '[:space:]' | head -c 64 || true)"
case "$actual" in
+2 -2
View File
@@ -28,7 +28,7 @@
# 环境变量(均可省略):
# DSH_HOME 默认 %USERPROFILE%\.dsh
# REGISTRY 默认 https://registry.npmjs.org
# DSH_CMD 默认优先 PATH 上的 dsh,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.2-rc.3
# DSH_CMD 默认优先 PATH 上的 dsh,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.3-alpha.2
#
# 说明:
# - pnpm 11 的 minimumReleaseAge 会拒绝发布 <24h 的新版本。脚本会预写
@@ -174,7 +174,7 @@ Ensure-WorkspaceSettings
if ($CLI -eq 'dsh') {
$cliArgs = @('plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
} else {
$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@0.2.2-rc.3', 'dsh', 'plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@0.2.3-alpha.2', 'dsh', 'plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
}
Say "执行 $CLI plugin --profile $Profile add $PKG@$SPEC ..."
$addOut = & $CLI @cliArgs 2>&1
+2 -2
View File
@@ -24,7 +24,7 @@
# 环境(均可省略,脚本会自动探测):
# DSH_HOME 默认 ~/.dsh(Windows Git Bash 下回退 $USERPROFILE/.dsh)
# REGISTRY 默认 https://registry.npmjs.org(发布源;装依赖仍走 pnpm 配置)
# DSH_CMD 默认优先用 PATH 上的 `dsh`,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.2-rc.3
# DSH_CMD 默认优先用 PATH 上的 `dsh`,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.3-alpha.2
#
# 说明:
# - pnpm 11 的 minimumReleaseAge 会拒绝发布 <24h 的新版本。脚本会预写
@@ -140,7 +140,7 @@ dsh_cli() {
if command -v "$DSH_CMD" >/dev/null 2>&1; then
printf '%s' "$DSH_CMD"
elif command -v npx >/dev/null 2>&1; then
printf 'npx -y --package @deepseek-ai/dsh@0.2.2-rc.3 dsh'
printf 'npx -y --package @deepseek-ai/dsh@0.2.3-alpha.2 dsh'
else
die "未找到 dsh 或 npx。请先安装 DSH(并确保 Node/npm 可用),或用 DSH_CMD 指定 dsh 路径。"
fi
+3 -3
View File
@@ -22,7 +22,7 @@
* (#952). Outside the workspace any linked worktree is adopted, which is PR
* #802's cross-repository case. The highest-scoring adoptable worktree of the
* newest event that has one wins, but only evidence after the last committed
* working-directory/change is eligible. With no such evidence the session cwd
* workspace-root/change is eligible. With no such evidence the session cwd
* itself is kept, a session living in a subdirectory of its repository
* included: the repository top level is never a root on its own.
*
@@ -150,7 +150,7 @@ function directoryEpochOf(ctx: Context, sessionId: string): number | undefined {
let epoch = previous?.epoch ?? -1
for (let index = end - 1; index >= start; index -= 1) {
const event = session.eventAt(index)
if (event?.type !== 'working-directory/change') continue
if (event?.type !== 'workspace-root/change') continue
epoch = event.seq
break
}
@@ -442,7 +442,7 @@ async function activeRootFromEvents(events: readonly SidebarSessionEvent[], base
const event = events[index]
// An explicit directory transition is the authority boundary. Older tool
// paths belong to the previous execution context and must not override it.
if (event?.type === 'working-directory/change') break
if (event?.type === 'workspace-root/change') break
if (event === undefined || event.type !== 'tool/call') continue
const weights = new Map<string, ActivePathEntry>()
collectActivePaths(event.data, weights, false)
+5 -10
View File
@@ -1,15 +1,10 @@
/**
* Anchor selectors for the DSH AppFrame conversation slot host, newest first:
*
* - DSH 0.1.5-alpha.2 replaced the root `conversation` slot with a root-scoped
* keyed `main` slot, so the conversation renders under `main.conversation`
* (ConversationPanel -> `renderSlot('main.conversation')`);
* - alpha.1 and earlier spell the same host `conversation`.
*
* Both keys are accepted deliberately so one build spans the alpha.1 → alpha.2
* boundary; only one exists in any given host.
* Anchor selector for the DSH AppFrame conversation slot host: the conversation
* renders under the root-scoped keyed `main` slot (ConversationPanel ->
* `renderSlot('main.conversation')`), which the slot host marks with
* `data-slot="main.conversation"`.
*/
const CENTER_COLUMN_SELECTOR = '#root [data-slot="main.conversation"], #root [data-slot="conversation"]'
const CENTER_COLUMN_SELECTOR = '#root [data-slot="main.conversation"]'
/** Match Sidebar's existing last-resort retry cadence (issue #248). */
export const CENTER_COLUMN_REVALIDATE_MS = 1500
+1 -1
View File
@@ -1072,7 +1072,7 @@ export function matchUrlTarget(tabs: readonly TabDescriptor[], url: URL): TabDes
* The plugin version this service instance reports. Keep in lockstep with
* `package.json`'s version — `tests/service.spec.ts` asserts the pair.
*/
export const SIDEBAR_SERVICE_VERSION = '0.33.0'
export const SIDEBAR_SERVICE_VERSION = '0.34.0-alpha.0'
/**
* Monotonic capability list consumers use to gate new API usage (features
+2 -3
View File
@@ -69,9 +69,8 @@ export function useCenterColumn(
useEffect(() => {
let disposed = false
let observer: ResizeObserver | undefined
// Locate the AppFrame's center column. DSH 0.1.x wraps slot hosts in
// [data-slot] containers: the conversation slot host (key
// `main.conversation` on 0.1.5-alpha.2+, `conversation` on alpha.1)
// Locate the AppFrame's center column. The host wraps slot hosts in
// [data-slot] containers: the conversation slot host (`main.conversation`)
// sits inside the center column behind transparent `display: contents`
// slot hosts, so the resolver walks up to the first ancestor that
// renders a box — no hashed-class or positional dependency
+12 -14
View File
@@ -690,29 +690,27 @@ export function installClueInjection(
* `getOrigin()` is the host's own public composition fact.
*/
const readerOriginOf = (): string | undefined => {
let webServer: { readonly port?: unknown; getOrigin?(): string } | undefined
let webServer: { readonly port?: unknown; getOrigin(): string } | undefined
try {
const value = injectionCtx.get?.('webServer')
if (value !== null && typeof value === 'object') {
webServer = value as { readonly port?: unknown; getOrigin?(): string }
webServer = value as { readonly port?: unknown; getOrigin(): string }
}
} catch {
webServer = undefined
}
if (webServer === undefined) return undefined
if (typeof webServer.getOrigin === 'function') {
try {
const origin = webServer.getOrigin()
if (typeof origin === 'string' && origin !== '') {
const trimmed = origin.replace(/\/+$/u, '')
// The route admits loopback peers only. Never emit a command aimed
// at a non-loopback bind address (it would be refused by design).
const hostname = new URL(trimmed).hostname
if (hostname === 'localhost' || isLoopbackAddress(hostname)) return trimmed
}
} catch {
// Throws before the listener is bound; fall back to the port if known.
try {
const origin = webServer.getOrigin()
if (typeof origin === 'string' && origin !== '') {
const trimmed = origin.replace(/\/+$/u, '')
// The route admits loopback peers only. Never emit a command aimed
// at a non-loopback bind address (it would be refused by design).
const hostname = new URL(trimmed).hostname
if (hostname === 'localhost' || isLoopbackAddress(hostname)) return trimmed
}
} catch {
// Throws before the listener is bound; fall back to the port if known.
}
const port = webServer.port
return typeof port === 'number' && Number.isSafeInteger(port) && port > 0
+4 -6
View File
@@ -139,12 +139,10 @@ export interface SidebarSessionStore {
* Host request admission plus the client transport recovery face.
*/
export interface SidebarConnectionService {
/** Public Host/Origin and authentication policy (DSH 0.2.0-rc.2+). Deprecated
* after 0.2.2-rc.3 and removed on DSH master — `admit` is the replacement. */
requestRejection?(request: { headers: Record<string, string | string[] | undefined> }): 401 | 403 | undefined
/** Host admission (DSH 0.2.2-rc.3+, the method `requestRejection` delegated to).
* Returns an object carrying `rejection` when the request is refused. */
admit?(request: { headers: Record<string, string | string[] | undefined> }): unknown
/** Host admission (DSH 0.2.3+): verifies Host/Origin and browser credentials
* through the injected `connection.authentication` verifier and returns an
* object carrying `rejection` when the request is refused. */
admit(request: { headers: Record<string, string | string[] | undefined> }): unknown
state: {
getSnapshot(): 'connected' | 'disconnected' | 'connecting' | undefined
subscribe(listener: () => void): () => void
+11 -21
View File
@@ -1261,34 +1261,24 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
const resolved = resolveSidebarConfig(config)
// Connection owns both deployment trust and authentication; never infer or
// bypass its policy from invocation flags or a copied trust list.
// DSH 0.2.2-rc.3 deprecated `requestRejection` and DSH 0.2.3 removed it, leaving
// `admit` (the method the old wrapper delegated to) as the only admission call.
// From 0.2.3 `admit` also delegates the credential check to the verifier
// registered under the NESTED `connection.authentication` service, and cordis
// refuses that read unless the caller declares the dependency. Hosts at
// rc.2–rc.5 have no such service (their `admit` verifies in place), so the
// dependency lives in a child fiber: where the service never appears the
// callback never runs and admission keeps using the host's own method. Never
// rebuild a trust list here: when no admission path is available the request
// fails loudly.
// DSH 0.2.3 deleted `requestRejection`; `admit` is the only admission call and
// it verifies credentials with the verifier registered under the NESTED
// `connection.authentication` service. Cordis refuses that read unless the
// caller declares the dependency, so admission lives in the injected child
// fiber — the only path this build supports. Never rebuild a trust list here:
// without the provider the request fails loudly.
/** `admit` refuses by carrying `rejection`; nothing else counts as a refusal. */
const admitted = (verdict: unknown): boolean =>
!(verdict !== null && typeof verdict === 'object' && 'rejection' in verdict)
let admitThroughProvider: ((req: SidebarHttpRequest) => boolean) | undefined
let admit: ((req: SidebarHttpRequest) => boolean) | undefined
ctx.inject(['connection.authentication'], (providerCtx) => {
const connection = (providerCtx as Context).connection
const admit = connection.admit
if (typeof admit !== 'function') return
admitThroughProvider = (req) => admitted(admit.call(connection, req))
const call = connection.admit
admit = (req) => admitted(call.call(connection, req))
})
const fence = (req: SidebarHttpRequest): boolean => {
const connection = ctx.connection
const requestRejection = connection.requestRejection
if (typeof requestRejection === 'function') return requestRejection.call(connection, req) === undefined
if (admitThroughProvider !== undefined) return admitThroughProvider(req)
const admit = connection.admit
if (typeof admit === 'function') return admitted(admit.call(connection, req))
throw new TypeError('connection exposes neither requestRejection nor admit')
if (admit !== undefined) return admit(req)
throw new TypeError('connection admission requires the injected authentication provider')
}
// The clue stack's context injection reads the live Side card preferences
// (source switches). The settings face is filled by the `ctx.inject` below,
+6 -4
View File
@@ -25,7 +25,7 @@ import type { ImageAttachmentRef, StoredImageAttachment } from '@deepseek-ai/dsh
import { parseSidechatPrompt, sidechatAdmissionError, sidechatAttachments, sidechatImageLimits } from './sidechat-image-admission.ts'
import { randomUUID } from 'node:crypto'
import { createUserMessage, ReasoningEffortId, type ContentBlock, type UserMessage } from '@deepseek-ai/dsh-llm'
import type { MessageId } from '@deepseek-ai/dsh-llm/brand'
import type { MessageId } from '@deepseek-ai/dsh-llm/types'
import {
installModelSelection,
type Agent,
@@ -769,12 +769,14 @@ export function buildSidechatApi(
})
// A truncated inheritance can end before the parent's last directory
// change. Header cwd alone cannot win: the host projection replays seed
// working-directory/change events over it. Stamp the committed directory
// workspace-root/change events over it. Stamp the committed directory
// (the parent's LIVE cwd) at the seed boundary, using the host-owned event
// rather than refolding its history or asking set() to enqueue a
// synthetic user notice.
// synthetic user notice. DSH 0.2.3-alpha.2 moved the projection authority
// from `working-directory/change` (model-era log) to `workspace-root/change`
// (host-committed move); only the latter is applied by the unit now.
const directorySeed: SeedEvent[] = workingDirectory === undefined ? [] : [{
type: 'working-directory/change',
type: 'workspace-root/change',
seq: inheritance.seed.length,
time: Date.now(),
data: { cwd: stampCwd },
+5 -2
View File
@@ -178,7 +178,7 @@ function mountHost(): { api: SidebarWebRoute; download: SidebarWebRoute } {
const routes: SidebarWebRoute[] = []
const cleanups: Array<() => void | Promise<void>> = []
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (route: SidebarWebUpgradeRoute) => { void route; return () => {} },
@@ -189,7 +189,10 @@ function mountHost(): { api: SidebarWebRoute; download: SidebarWebRoute } {
const cleanup = fn()
if (typeof cleanup === 'function') cleanups.push(cleanup)
},
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+6 -11
View File
@@ -20,7 +20,7 @@ interface Fixture {
function connectedColumn(doc = document.implementation.createHTMLDocument()): Fixture {
const col = doc.createElement('div')
const slot = doc.createElement('div')
slot.dataset.slot = 'conversation'
slot.dataset.slot = 'main.conversation'
col.append(slot)
doc.body.append(col)
return { doc, col, slot }
@@ -30,14 +30,14 @@ function connectedColumn(doc = document.implementation.createHTMLDocument()): Fi
// contents-skip walk needs a live defaultView.getComputedStyle (inline
// `display: contents` on the wrapper). Build:
// #root > col > wrapper[display: contents] > host[data-slot="main.conversation"].
function alphaColumn(hostSlot: string): { col: HTMLDivElement; host: HTMLDivElement } {
function alphaColumn(): { col: HTMLDivElement; host: HTMLDivElement } {
const root = document.createElement('div')
root.id = 'root'
const col = document.createElement('div')
const wrapper = document.createElement('div')
wrapper.style.display = 'contents'
const host = document.createElement('div')
host.dataset.slot = hostSlot
host.dataset.slot = 'main.conversation'
wrapper.append(host)
col.append(wrapper)
root.append(col)
@@ -50,14 +50,9 @@ function alphaColumn(hostSlot: string): { col: HTMLDivElement; host: HTMLDivElem
afterEach(() => {
for (const root of document.body.querySelectorAll('div#root')) root.remove()
})
describe('center-column anchor keys (DSH 0.1.5-alpha.2)', () => {
describe('center-column anchor key (main.conversation)', () => {
it('skips display:contents slot hosts above a main.conversation host', () => {
const { col } = alphaColumn('main.conversation')
expect(resolveCenterColumn(null, { now: () => 0 })).toBe(col)
})
it('still resolves the alpha.1 conversation key through the default selector', () => {
const { col } = alphaColumn('conversation')
const { col } = alphaColumn()
expect(resolveCenterColumn(null, { now: () => 0 })).toBe(col)
})
})
@@ -191,7 +186,7 @@ function CenterColumnProbe(): ReactElement {
/** 把上面的 alpha.2 fixture(#root > col > wrapper[contents] > host)建好。 */
function renderTrackedColumn(): { unmount: () => void; col: HTMLDivElement; root: HTMLElement } {
const { col } = alphaColumn('main.conversation')
const { col } = alphaColumn()
const root = document.getElementById('root')
if (root === null) throw new Error('missing element: #root fixture')
const view = renderRoot(createElement(CenterColumnProbe))
+5 -2
View File
@@ -280,12 +280,15 @@ describe('/sidebar/api clue dispatcher fallback', () => {
const routes: SidebarWebRoute[] = []
const registry = { get: (id: string) => (id === 'ws-1' ? { path: workspace } : undefined) }
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: { register: (route: SidebarWebRoute) => { routes.push(route); return () => {} }, registerUpgrade: () => () => {} },
sessions: { get: () => undefined },
tools: { register: () => () => {} },
effect: (fn: () => void | (() => void)) => { const cleanup = fn(); if (typeof cleanup === 'function') effects.push(cleanup) },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: (key: string) => (key === 'betterSidebarClues' ? provided.get(key) : key === 'workspaceRegistry' ? registry : undefined),
provide: (name: string, value: unknown) => { provided.set(name, value) },
+2 -2
View File
@@ -5,11 +5,11 @@
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const baseline = '0.2.2-rc.2'
const baseline = '0.2.3-alpha.2'
/** The host runtime the mount lane and the standalone installers pin. It follows
* `package.json#engines.dsh`, which is stricter than the peer floor: the plugin
* installs on this line or newer, so every place that actually runs it moves. */
const hostBaseline = '0.2.2-rc.3'
const hostBaseline = '0.2.3-alpha.2'
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
const bash = readFileSync(new URL('../scripts/install.sh', import.meta.url), 'utf8')
const powershell = readFileSync(new URL('../scripts/install.ps1', import.meta.url), 'utf8')
+6 -3
View File
@@ -26,7 +26,7 @@ import type { SidebarWebRoute } from '../src/context-types.ts'
import { removeTree } from './temp-tree.ts'
interface FakeContext {
connection: { requestRejection: () => undefined }
connection: { admit: () => ({ peer: null }) }
webServer: {
register: (route: SidebarWebRoute) => () => void
registerUpgrade: () => () => void
@@ -67,12 +67,15 @@ function workspace(name: string): string {
async function serve(workspace: string): Promise<{ origin: string; routes: SidebarWebRoute[] }> {
const routes: SidebarWebRoute[] = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: { register: (route) => { routes.push(route); return () => {} }, registerUpgrade: () => () => {} },
sessions: { get: () => ({ header: { cwd: workspace } }) },
tools: { register: () => () => {} },
effect: (fn) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+4 -1
View File
@@ -240,8 +240,11 @@ describe('FileTree multi-selection', () => {
expect(rows[rows.length - 1]!.compareDocumentPosition(bar) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
// The only trailing siblings are the menu's portal anchor and the hidden
// file input, so the bar IS the last piece of tree content.
// The host's menu portal anchor trails the tree with an implementation-
// specific class name (0.2.3 changed its shape), so identify "content" by
// text instead of host class names: the anchor renders no text.
const content = [...body.children].filter(child =>
child.tagName !== 'INPUT' && !(child as HTMLElement).className.includes('_root_'))
child.tagName !== 'INPUT' && (child.textContent ?? '').trim() !== '')
expect(content[content.length - 1]).toBe(bar)
// jsdom has no layout: the sheet is the evidence for the docking mechanic.
const sheet = readFileSync('src/client/sidebar.module.css', 'utf8')
+6 -3
View File
@@ -143,7 +143,7 @@ describe('createWorkspaceFile', () => {
* editor reads.
*/
interface FakeContext {
connection: { requestRejection: () => undefined }
connection: { admit: () => ({ peer: null }) }
webServer: {
register: (route: SidebarWebRoute) => () => void
registerUpgrade: () => () => void
@@ -160,12 +160,15 @@ interface FakeContext {
function mountApi(workspace: string): SidebarWebRoute {
const routes: SidebarWebRoute[] = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: { register: (route) => { routes.push(route); return () => {} }, registerUpgrade: () => () => {} },
sessions: { get: () => ({ header: { cwd: workspace } }) },
tools: { register: () => () => {} },
effect: (fn) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+6 -3
View File
@@ -26,7 +26,7 @@ import type { SidebarWebRoute } from '../src/context-types.ts'
import { removeTree } from './temp-tree.ts'
interface FakeContext {
connection: { requestRejection: () => undefined }
connection: { admit: () => ({ peer: null }) }
webServer: {
register: (route: SidebarWebRoute) => () => void
registerUpgrade: () => () => void
@@ -56,12 +56,15 @@ function workspaceWith(name: string, contents: Buffer | string): string {
function mountApi(workspace: string): SidebarWebRoute {
const routes: SidebarWebRoute[] = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: { register: (route) => { routes.push(route); return () => {} }, registerUpgrade: () => () => {} },
sessions: { get: () => ({ header: { cwd: workspace } }) },
tools: { register: () => () => {} },
effect: (fn) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+5 -2
View File
@@ -9,7 +9,7 @@ import type { SidebarWebRoute } from '../src/context-types.ts'
function mountApi(cwd: string): SidebarWebRoute {
const routes: SidebarWebRoute[] = []
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webRuntime: { trustedHosts: [] },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
@@ -18,7 +18,10 @@ function mountApi(cwd: string): SidebarWebRoute {
sessions: { get: () => ({ header: { cwd }, snapshotEvents: () => [] }) },
tools: { register: () => () => {} },
effect: (fn: () => unknown) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+6 -3
View File
@@ -32,7 +32,7 @@ import type { SidebarWebRoute } from '../src/context-types.ts'
import { removeTree } from './temp-tree.ts'
interface FakeContext {
connection: { requestRejection: () => undefined }
connection: { admit: () => ({ peer: null }) }
webServer: {
register: (route: SidebarWebRoute) => () => void
registerUpgrade: () => () => void
@@ -56,12 +56,15 @@ interface Mounted {
function mountApi(workspace: string): Mounted {
const routes: SidebarWebRoute[] = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: { register: (route) => { routes.push(route); return () => {} }, registerUpgrade: () => () => {} },
sessions: { get: () => ({ header: { cwd: workspace } }) },
tools: { register: () => () => {} },
effect: (fn) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+5 -2
View File
@@ -92,7 +92,7 @@ function makeRemoteFixture(): RemoteFixture {
function mount(): { route: SidebarWebRoute } {
const routes: SidebarWebRoute[] = []
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (_route: SidebarWebUpgradeRoute) => () => {},
@@ -101,7 +101,10 @@ function mount(): { route: SidebarWebRoute } {
tools: { register: () => () => {} },
// The vendored cordis runs registration effects immediately.
effect: (fn: () => void | (() => void)) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
+2 -1
View File
@@ -208,7 +208,7 @@ function mount(setup: {
},
logger: { info: () => {}, warn: () => {} },
profileContext: undefined,
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (_route: SidebarWebUpgradeRoute) => () => {},
@@ -219,6 +219,7 @@ function mount(setup: {
effect: (fn: () => void | (() => void)) => { fn() },
inject: (deps: readonly string[], cb: (sctx: unknown) => void) => {
if (deps.includes('settings')) cb({ settings })
if (deps.includes('connection.authentication')) cb({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
+1 -1
View File
@@ -162,7 +162,7 @@ describe('DSH community-market manifest compatibility', () => {
const dshPeers = Object.keys(peers).filter(name => name === '@deepseek-ai/dsh' || name.startsWith('@deepseek-ai/dsh-'))
expect(dshPeers.length).toBeGreaterThan(10)
for (const name of dshPeers) {
expect(peers[name], name).toMatch(/^\^0\.2\.2-rc\.2$/)
expect(peers[name], name).toMatch(/^\^0\.2\.3-alpha\.2$/)
}
})
})
+5 -5
View File
@@ -152,7 +152,7 @@ describe('sidechat.start', () => {
// (packages/workspace/workspace/src/entity.ts:136), so a live cwd that had
// `cd`-ed elsewhere must not become meta.cwd: it made the fork fail with
// session/workspace-attach-failed. The live cwd still reaches the child
// through the seeded working-directory/change stamp.
// through the seeded workspace-root/change stamp.
expect(services.create.mock.calls[0]![0]).toMatchObject({ meta: { cwd: '/p' } })
expect(get).toHaveBeenCalledOnce()
})
@@ -194,10 +194,10 @@ describe('sidechat.start', () => {
const parent = agent('parent', {
header: { cwd: original },
events: [
ev('working-directory/change', 0, { cwd: previous }),
ev('workspace-root/change', 0, { cwd: previous }),
ev('turn/start', 1, { turn: 1 }),
ev('step/start', 2, { turn: 1, step: 1 }),
ev('working-directory/change', 3, { cwd: current }),
ev('workspace-root/change', 3, { cwd: current }),
ev('tool/call', 4, { turn: 1, step: 1, callId: 'pending', name: 'bash', arguments: '{}' }),
],
})
@@ -239,7 +239,7 @@ describe('sidechat.start', () => {
// Control proves that merely changing meta.cwd is insufficient: the
// dangling-call cut dropped current but retained previous in the seed.
const unstamped = buildSidechatInheritance(parent.session.snapshotEvents() as never).seed
expect(unstamped.map(event => event.type)).toEqual(['working-directory/change'])
expect(unstamped.map(event => event.type)).toEqual(['workspace-root/change'])
expect(unstamped.reduce((cwd, event) => projection.apply(cwd, event as SessionEvent), projection.init({ cwd: current }))).toBe(previous)
const child = Session.create(options.sessionId, options.seed, {
...options.meta, id: options.sessionId, version: SESSION_FORMAT_VERSION, createdAt: Date.now(), isSeeded: true,
@@ -250,7 +250,7 @@ describe('sidechat.start', () => {
expect(options.seed.every((event, index) => event.seq === index)).toBe(true)
expect(child.ownEvents()[0]?.type).toBe('session/end-seed')
expect(workingDirectory.get(child)).toBe(current)
expect(options.seed.at(-2)).toMatchObject({ type: 'working-directory/change', data: { cwd: current } })
expect(options.seed.at(-2)).toMatchObject({ type: 'workspace-root/change', data: { cwd: current } })
})
it('creates a seeded subagent-origin child and admits the boundary + question', async () => {
+5 -5
View File
@@ -1,7 +1,7 @@
/**
* The thread's ATTACH cwd must be the parent session's HEADER cwd — the
* workspace path the Host attaches sessions to — while the seeded
* `working-directory/change` stamp keeps the parent's LIVE cwd (where the tools
* `workspace-root/change` stamp keeps the parent's LIVE cwd (where the tools
* actually run).
*
* Why this spec exists (field failure, Host source verified): the Host's
@@ -19,7 +19,7 @@
* ============================ CONTRACT ============================
* 1. `meta.cwd` comes from the PARENT SESSION HEADER (`parent.session.header.cwd`)
* ONLY. The live working directory must never win while a header cwd exists.
* 2. The live cwd still drives the `working-directory/change` boundary stamp
* 2. The live cwd still drives the `workspace-root/change` boundary stamp
* appended to the seed (the last such event before the descriptor), so the
* thread keeps running tools in the directory the reader is standing in.
* 3. FALLBACKS. A parent with no header cwd (an old/partial session) uses the
@@ -69,7 +69,7 @@ type AgentLike = ReturnType<typeof agent>
/** A parent conversation with one completed turn, logged from an older cwd. */
function storedTurn(): unknown[] {
return [
{ type: 'working-directory/change', seq: 0, time: 0, data: { cwd: '/older-execution' } },
{ type: 'workspace-root/change', seq: 0, time: 0, data: { cwd: '/older-execution' } },
{
type: 'user/message',
seq: 1,
@@ -114,9 +114,9 @@ function createdOptions(create: ReturnType<typeof servicesFor>['create']): Creat
return options as CreateOptions
}
/** The last `working-directory/change` event in the seed (the boundary stamp). */
/** The last `workspace-root/change` event in the seed (the boundary stamp). */
function lastStamp(options: CreateOptions): string | undefined {
const changes = (options.seed ?? []).filter(event => event.type === 'working-directory/change')
const changes = (options.seed ?? []).filter(event => event.type === 'workspace-root/change')
const cwd = changes.at(-1)?.data?.cwd
return typeof cwd === 'string' ? cwd : undefined
}
+32 -15
View File
@@ -61,7 +61,7 @@ const canCreateSymlink = (() => {
})()
interface FakeContext {
connection: { requestRejection: () => undefined }
connection: { admit: () => ({ peer: null }) }
webServer: {
register: (route: SidebarWebRoute) => () => void
registerUpgrade: (route: SidebarWebUpgradeRoute) => () => void
@@ -116,7 +116,7 @@ describe('host plugin smoke', () => {
const upgrades: SidebarWebUpgradeRoute[] = []
const effects: Array<() => void | (() => void)> = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route) => { routes.push(route); return () => {} },
registerUpgrade: (route) => { upgrades.push(route); return () => {} },
@@ -131,7 +131,10 @@ describe('host plugin smoke', () => {
},
// No settings service in the smoke context: the registration callback
// never runs (cordis' service-less inject behaves the same).
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
// No jobs/agents services: the jobs routes degrade to a 503.
get: () => undefined,
@@ -177,7 +180,7 @@ describe('host plugin smoke', () => {
const upgrades: SidebarWebUpgradeRoute[] = []
const effects: Array<() => void | (() => void)> = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: () => () => {},
registerUpgrade: (route) => { upgrades.push(route); return () => {} },
@@ -188,7 +191,10 @@ describe('host plugin smoke', () => {
const cleanup = fn()
if (typeof cleanup === 'function') effects.push(cleanup)
},
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
@@ -227,7 +233,7 @@ describe('host plugin smoke', () => {
const routes: SidebarWebRoute[] = []
const effects: Array<() => void | (() => void)> = []
const ctx: FakeContext = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route) => { routes.push(route); return () => {} },
registerUpgrade: () => () => {},
@@ -238,7 +244,10 @@ describe('host plugin smoke', () => {
const cleanup = fn()
if (typeof cleanup === 'function') effects.push(cleanup)
},
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: () => undefined,
}
@@ -537,7 +546,7 @@ describe('session cwd resolution over the API route', () => {
const routes: SidebarWebRoute[] = []
lastMountedRoutes = routes
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (route: SidebarWebUpgradeRoute) => { void route; return () => {} },
@@ -547,7 +556,10 @@ describe('session cwd resolution over the API route', () => {
// The vendored cordis runs registration effects immediately.
effect: (fn: () => void | (() => void)) => { fn() },
// No settings service: the namespace registration never runs.
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
// The session/agent event feeds: nothing emits in these tests.
on: () => () => {},
// No jobs/agents services in the smoke context: the routes degrade.
@@ -788,7 +800,7 @@ describe('session cwd resolution over the API route', () => {
workingDirectory: { get: () => current },
})
expect(await invoke(route, 'session.cwd', { sessionId: 'wd-linked' })).toMatchObject({ ok: true, value: { cwd: linked } })
events.push({ type: 'working-directory/change', seq: 1, time: 1, data: { cwd: main } })
events.push({ type: 'workspace-root/change', seq: 1, time: 1, data: { cwd: main } })
current = main
expect(await invoke(route, 'session.cwd', { sessionId: 'wd-linked' })).toMatchObject({ ok: true, value: { cwd: main } })
expect(await invoke(route, 'git.status', { sessionId: 'wd-linked', cwd: linked })).toMatchObject({ ok: true, value: { branch: 'main' } })
@@ -807,7 +819,7 @@ describe('session cwd resolution over the API route', () => {
sameBaseEvents.push({ type: 'turn/start', seq: 1, time: 1, data: { cwd: main } })
expect(await invoke(sameBaseRoute, 'session.cwd', payload)).toMatchObject({ ok: true, value: { cwd: linked } })
expect(snapshotEvents).toHaveBeenCalledTimes(1)
sameBaseEvents.push({ type: 'working-directory/change', seq: 2, time: 2, data: { cwd: main } })
sameBaseEvents.push({ type: 'workspace-root/change', seq: 2, time: 2, data: { cwd: main } })
expect(await invoke(sameBaseRoute, 'session.cwd', payload)).toMatchObject({ ok: true, value: { cwd: main } })
expect(await invoke(sameBaseRoute, 'session.cwd', payload)).toMatchObject({ ok: true, value: { cwd: main } })
expect(snapshotEvents).toHaveBeenCalledTimes(2)
@@ -1685,7 +1697,7 @@ describe('sidechat prompt large-body admission', () => {
isAttachmentError: () => false,
}
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: () => () => {},
@@ -1693,7 +1705,10 @@ describe('sidechat prompt large-body admission', () => {
sessions: { get: () => undefined },
tools: { register: () => () => {} },
effect: (fn: () => void | (() => void)) => { fn() },
inject: () => () => {},
inject: (deps: readonly string[], callback: (sctx: never) => void) => {
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
get: (key: string) => key === 'agents' ? { get: () => agent } : key === 'attachments' ? attachments : undefined,
logger: { info: () => {}, warn: () => {}, debug: () => {}, error: () => {} },
@@ -1889,7 +1904,7 @@ const mountWithSettings = (settings?: unknown, home?: string): SidebarWebRoute =
const routes: SidebarWebRoute[] = []
lastMountedRoutes = routes
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (route: SidebarWebUpgradeRoute) => { void route; return () => {} },
@@ -1899,6 +1914,7 @@ const mountWithSettings = (settings?: unknown, home?: string): SidebarWebRoute =
effect: (fn: () => void | (() => void)) => { fn() },
inject: (deps: string[], callback: (sctx: { settings: unknown }) => void) => {
if (deps.includes('settings') && settings !== undefined) callback({ settings })
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
// The session/agent event feeds: nothing emits in these tests.
@@ -2137,7 +2153,7 @@ describe('agent sidebar-open tool gating', () => {
configure: () => () => {},
}
const ctx = {
connection: { requestRejection: () => undefined },
connection: { admit: () => ({ peer: null }) },
webServer: {
register: (route: SidebarWebRoute) => { routes.push(route); return () => {} },
registerUpgrade: (route: SidebarWebUpgradeRoute) => { void route; return () => {} },
@@ -2155,6 +2171,7 @@ describe('agent sidebar-open tool gating', () => {
effect: (fn: () => void | (() => void)) => { fn() },
inject: (deps: readonly string[], callback: (sctx: { settings: unknown }) => void) => {
if (deps.includes('settings')) callback({ settings })
if (deps.includes('connection.authentication')) callback({ connection: { admit: () => ({ peer: null }) } } as never)
return () => {}
},
on: () => () => {},
+44 -88
View File
@@ -1,12 +1,26 @@
/** The sidebar must use native Connection admission, never a reconstructed trust list. */
/** The sidebar must use native Connection admission, never a reconstructed trust list.
*
* DSH 0.2.3 deleted `requestRejection`: `admit` is the only admission call and it
* verifies credentials through the NESTED `connection.authentication` service,
* which cordis only exposes to the caller that injected the dependency. The
* plugin therefore admits from its injected child fiber and has no second path:
* without the provider every fenced request fails loudly.
*/
import { describe, expect, it, vi } from 'vitest'
import { apply } from '../src/index.ts'
import type { SidebarHttpRequest, SidebarWebRoute, SidebarWebUpgradeRoute } from '../src/context-types.ts'
/** No retired webRuntime service: rc.2 and newer both expose Connection admission. */
function mount(initialRejection: 401 | 403 | undefined = undefined) {
/** Mount the plugin with a 0.2.3 host: bare `admit` on the plugin context that
* rejects the nested read, plus the injected provider connection the plugin's
* child fiber declares. */
function mount(initialRejection: 401 | 403 | undefined = undefined, activateProvider = true) {
let rejection = initialRejection
const connection = { requestRejection: vi.fn((_request: SidebarHttpRequest) => rejection) }
const providerAdmit = vi.fn((_request: SidebarHttpRequest) =>
rejection === undefined ? { peer: {} } : { rejection })
const providerConnection = { admit: providerAdmit }
const connection = {
admit: () => { throw new Error('cannot get property "connection.authentication" without inject') },
}
const routes: SidebarWebRoute[] = []
const upgrades: SidebarWebUpgradeRoute[] = []
const effects: Array<() => void> = []
@@ -33,17 +47,18 @@ function mount(initialRejection: 401 | 403 | undefined = undefined) {
on: () => () => {},
get: () => undefined,
} as never)
if (activateProvider) {
for (const injection of injections) {
if (injection.deps.includes('connection.authentication')) injection.activate({ connection: providerConnection })
}
}
return {
connection,
providerAdmit,
providerConnection,
routes,
upgrades,
setRejection: (next: 401 | 403 | undefined) => { rejection = next },
/** Fire the child fiber that waits for `connection.authentication` (0.2.3+). */
activateProvider: (providerConnection: unknown = connection) => {
for (const injection of injections) {
if (injection.deps.includes('connection.authentication')) injection.activate({ connection: providerConnection })
}
},
cleanup: () => { for (const cleanup of effects) cleanup() },
}
}
@@ -80,13 +95,13 @@ describe('native Connection admission', () => {
const { req } = request('/sidebar/api/session.cwd', {
host: 'example.com',
origin: 'https://example.com',
cookie: 'native-authenticated-session',
cookie: 'test-cookie',
})
const { res, out } = response()
await mounted.routes.find(route => route.path === '/sidebar/api')!.handler(req, res)
expect(out.status).toBe(200)
expect(mounted.connection.requestRejection).toHaveBeenCalledExactlyOnceWith(req)
expect(mounted.connection.requestRejection.mock.contexts[0]).toBe(mounted.connection)
expect(mounted.providerAdmit).toHaveBeenCalledExactlyOnceWith(req)
expect(mounted.providerAdmit.mock.contexts[0]).toBe(mounted.providerConnection)
} finally {
mounted.cleanup()
}
@@ -115,7 +130,7 @@ describe('native Connection admission', () => {
await route.handler(input.req, res)
expect(out.status, route.path).toBe(403)
expect(input.reads(), route.path).toBe(0)
expect(mounted.connection.requestRejection).toHaveBeenLastCalledWith(input.req)
expect(mounted.providerAdmit).toHaveBeenLastCalledWith(input.req)
}
// Both exact routes reject a non-loopback peer before reading a body.
for (const path of agentPaths) {
@@ -124,7 +139,7 @@ describe('native Connection admission', () => {
await mounted.routes.find(route => route.path === path)!.handler(input.req, res)
expect(out.status).toBe(403)
expect(input.reads()).toBe(0)
expect(mounted.connection.requestRejection).not.toHaveBeenCalledWith(input.req)
expect(mounted.providerAdmit).not.toHaveBeenCalledWith(input.req)
}
for (const route of mounted.upgrades) {
const input = request(route.path)
@@ -132,102 +147,43 @@ describe('native Connection admission', () => {
await route.handler(input.req, socket, new Uint8Array())
expect(socket.destroy, route.path).toHaveBeenCalledOnce()
expect(input.reads(), route.path).toBe(0)
expect(mounted.connection.requestRejection).toHaveBeenLastCalledWith(input.req)
expect(mounted.providerAdmit).toHaveBeenLastCalledWith(input.req)
}
// One admission check per FENCED HTTP route and per WebSocket upgrade.
expect(mounted.connection.requestRejection).toHaveBeenCalledTimes(mounted.routes.length + mounted.upgrades.length - agentPaths.length)
expect(mounted.providerAdmit).toHaveBeenCalledTimes(mounted.routes.length + mounted.upgrades.length - agentPaths.length)
} finally {
mounted.cleanup()
}
})
it.each([null, false, 0, ''])('does not treat an unexpected falsy verdict (%s) as admission', async (verdict) => {
const mounted = mount()
it('does not admit through the bare connection when the authentication provider never activates', async () => {
const mounted = mount(undefined, false)
try {
mounted.connection.requestRejection.mockReturnValue(verdict as never)
for (const route of mounted.routes) {
if (['/sidebar/agent/clues/read', '/sidebar/agent/clues/commit'].includes(route.path)) continue
const input = request(route.path)
const { res, out } = response()
await route.handler(input.req, res)
expect(out.status, route.path).toBe(403)
expect(input.reads(), route.path).toBe(0)
}
// The loopback route ignores the login verdict entirely; without a real
// peer socket its own gate still refuses it.
for (const path of ['/sidebar/agent/clues/read', '/sidebar/agent/clues/commit']) {
const input = request(path)
const { res, out } = response()
await mounted.routes.find(route => route.path === path)!.handler(input.req, res)
expect(out.status).toBe(403)
expect(input.reads()).toBe(0)
}
for (const route of mounted.upgrades) {
const input = request(route.path)
const socket = { destroy: vi.fn() }
await route.handler(input.req, socket, new Uint8Array())
expect(socket.destroy, route.path).toHaveBeenCalledOnce()
expect(input.reads(), route.path).toBe(0)
}
} finally {
mounted.cleanup()
}
})
it('has no old-host fallback when native admission is missing', async () => {
const mounted = mount()
try {
Reflect.deleteProperty(mounted.connection, 'requestRejection')
const input = request('/sidebar/api/session.cwd')
const { res, out } = response()
await expect(mounted.routes.find(route => route.path === '/sidebar/api')!.handler(input.req, res)).rejects.toThrow(TypeError)
await expect(mounted.routes.find(route => route.path === '/sidebar/api')!.handler(input.req, res))
.rejects.toThrow(TypeError)
expect(out.status).toBe(0)
expect(input.reads()).toBe(0)
// The bare context `admit` throws when it reads the uninjected service;
// reaching it would surface that error instead of the fence's TypeError.
expect(() => (mounted.connection.admit as () => unknown)()).toThrow(/without inject/)
} finally {
mounted.cleanup()
}
})
it('falls back to native admit once requestRejection is gone', async () => {
it('admits through the injected authentication provider', async () => {
const mounted = mount()
try {
let rejection: 401 | 403 | undefined
const admit = vi.fn(() => (rejection === undefined ? {} : { rejection }))
Reflect.deleteProperty(mounted.connection, 'requestRejection')
Object.assign(mounted.connection as unknown as Record<string, unknown>, { admit })
const route = mounted.routes.find(candidate => candidate.path === '/sidebar/api')!
for (const [verdict, expected] of [[undefined, 200], [401, 403], [403, 403]] as const) {
rejection = verdict
mounted.setRejection(verdict)
const { res, out } = response()
await route.handler(request('/sidebar/api/session.cwd').req, res)
expect(out.status).toBe(expected)
}
expect(admit).toHaveBeenCalledTimes(3)
} finally {
mounted.cleanup()
}
})
it('admits through the injected authentication provider when admit reads the nested service', async () => {
const mounted = mount()
try {
let rejection: 401 | 403 | undefined
const providerAdmit = vi.fn(() => (rejection === undefined ? { peer: {} } : { rejection }))
// 0.2.3 host: the plugin's own context exposes `admit`, but cordis refuses the
// nested `connection.authentication` read unless the provider fiber declared it.
Reflect.deleteProperty(mounted.connection, 'requestRejection')
Object.assign(mounted.connection as unknown as Record<string, unknown>, {
admit: () => { throw new Error('cannot get property "connection.authentication" without inject') },
})
mounted.activateProvider({ admit: providerAdmit })
const route = mounted.routes.find(candidate => candidate.path === '/sidebar/api')!
for (const [verdict, expected] of [[undefined, 200], [401, 403], [403, 403]] as const) {
rejection = verdict
const { res, out } = response()
await route.handler(request('/sidebar/api/session.cwd').req, res)
expect(out.status).toBe(expected)
}
expect(providerAdmit).toHaveBeenCalledTimes(3)
expect(mounted.providerAdmit).toHaveBeenCalledTimes(3)
} finally {
mounted.cleanup()
}
@@ -249,7 +205,7 @@ describe('native Connection admission', () => {
const { res, out } = response()
await mounted.routes.find(route => route.path === '/sidebar/file')!.handler(req, res)
expect(out.status).toBe(403)
expect(mounted.connection.requestRejection).toHaveBeenLastCalledWith(req)
expect(mounted.providerAdmit).toHaveBeenLastCalledWith(req)
expect(req.headers).toBe(headers)
}
} finally {
@@ -268,7 +224,7 @@ describe('native Connection admission', () => {
await route.handler(req, res)
expect(out.status).toBe(expected)
}
expect(mounted.connection.requestRejection).toHaveBeenCalledTimes(4)
expect(mounted.providerAdmit).toHaveBeenCalledTimes(4)
} finally {
mounted.cleanup()
}