@marktrue/dsh-mobile-remote 3.3.1-alpha.2 → 3.3.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## v3.3.1-alpha.3(build 66,issues #106/#153/#166/#168/#170/#171)— 插件管理与设置查看器
4
+
5
+ > 插件 `3.3.1-alpha.3` / App `3.3.1+66` / 载体 `3.3.1-alpha.3-app`。
6
+
7
+ ### 新功能
8
+
9
+ - **#153 主页面插件管理**:手机端插件页对齐 DSH Web 主页面。一页三 Tab「内置 / 实验性 / 自定义」,每 Tab 内分「已安装 / 可安装」;本地搜索(只作用当前 Tab);`HIDDEN_BUNDLES`(8 个无插件页的 bundle)默认折叠,提供「显示隐藏项」开关。
10
+ - **一键检查全部更新**:App 侧有界并发 3,只查 `canUpdate` 的行;Git 来源标 `skipped` 不发请求;失败逐项带 `errorCode`;可中断,已完成结果保留;**不自动安装**、不创建宿主 op。
11
+ - **安装源选择 + 手动 http(s) URL**:只读展示宿主 `registries()`(首选 / 备选 / pnpm 解析);手动 URL 仅本次生效、不写 Host 配置;只接受 http(s),拒凭据 / 片段 / 查询 / 控制字符;失败明确归因,**不静默换源**(响应带 `requestedRegistry` / `answeredRegistry` / `attempts`)。
12
+ - 宿主 `/plugin-inventory` 每行新增 `official` / `optional` / `availability` / `installed` / `category` / `hidden`;根级新增 `classification`。分类谓词与静态表在**插件宿主侧**,App 只渲染不重算。
13
+ - **#106 DSH 设置只读查看器**:设置 →「通用」→「电脑端设置(只读)」。查看当前宿主 DSH 设置的名称、值、来源与默认值。
14
+ - **固定白名单 fail-closed**:14 项 / 5 namespace 在宿主侧冻结;白名单外一律不返回;App 不保存副本、不拼路径、不补默认值。
15
+ - **嵌套 secret 全链剔除**:任意祖先/后代路径含 `role('secret')` 即整棵子树移除;`value` / `base` / `user` **三层都脱敏**,不能从"默认值"旁路泄露;secret 只显示「已设置 / 未设置」。
16
+ - 路径与凭据擦除:绝对路径、`baseURL` 的 userinfo、token / API key、连接串不进响应。
17
+ - 搜索只匹配标题 / 命名空间 / 键路径,**不搜值**。
18
+ - **#171 编辑电脑也支持扫码**:编辑档案时可直接扫码替换地址与口令,不必退出再走「添加」。文案按态区分(添加「扫码添加」/ 编辑「扫码替换」);**档案名不被覆盖**;当前输入非空时先确认;扫码填入仍走既有表单校验。
19
+
20
+ ### 修复
21
+
22
+ - **#170 图片预览对扩展名与内容不符的 PNG/JPEG 返回 415**(alpha.2 真机发现的缺陷):宿主要求「扩展名推定类型 === magic 嗅探类型」,而 `.png` 里装 JPEG 极常见(截图工具、浏览器另存、下载重命名、IM 转存)。现已改为按内容判定 —— magic 嗅探确认是受支持图片即放行,`content-type` 恒用嗅探值。**安全边界不降**:扩展名仍在白名单内、嗅探不出类型仍拒、大小/像素/consent/O_NOFOLLOW 全部不变。
23
+ - **#168 首页 Drawer「连接」补齐图标**:「连接」是唯一没有图标的一级入口。现改为复用统一的一级入口结构(图标 20dp、12dp 间距、minHeight 44、无选中底色),并补 Semantics 按钮语义。
24
+
25
+ ### 兼容性变更(需留意)
26
+
27
+ - **#166 DSH peer 上界放宽到 `0.2.3`**:DSH 已进入 0.2.3 系列。**代价明确** —— 原「`0.2.3` 必须被拒」的保护随之移除,日后 0.2.3 若引入破坏性变更,peer 范围不再拦截,只能靠 canary 与运行时能力探测(ADR 0017)暴露。`0.3.0` 边界仍由测试守住。
28
+ - **不声明 `engines.node`**:DSH 0.2.3 要求 Node 24.22.3,插件不声明门槛,版本过低时由宿主启动报错。
29
+
30
+ ### 文档
31
+
32
+ - **#164 / #169 仓库布局决策**:ADR 0039 入 develop —— 不做 `apps/` + `packages/` 大重构;`tools/` 按性质分目录(不按新旧);一次性证据(设计稿、盘点)放 GitLab issue,长期决策放仓库。盘点文档按此决策**不入库**,内容保留在 #164 评论。
33
+
34
+ ### 已接受 / 已知未验证
35
+
36
+ - **#153 无真机验证**:三 Tab、320/深色/1.5x/2.0x、安装流程均为 widget 级断言。**实验性静态表固定为 DSH 0.2.2**,升级 DSH 后需同步更新(`classification.matched` 会暴露漂移)。
37
+ - **#106 无真机验证**:白名单首版只覆盖 5 个内置 namespace(实测 `describe()` 先经 `volatileForm()` 过滤,只有 volatile 字段可达)。通配展开上限 50 项,超过即整段 fail-closed。
38
+ - **#157 图片预览**:EXIF Orientation 仍未处理(`Image.memory` 不按 EXIF 自动旋转,竖拍 JPEG 真机可能横向);超大图二次确认未做;大 GIF 内存峰值未实测。
39
+ - **私网 registry 扩大请求面**(#153):允许 localhost/私网是内网 Verdaccio 的合法用例,风险已写入 `docs/04-security.md`,未加私网黑名单。
40
+ - 3.3.1 各功能真机验收:**#157 待本轮验证(#170 修复后)**;#155/#163/#154/#158/#159/#162 已于 alpha.2 真机验收通过。
41
+
42
+
3
43
  ## v3.3.1-alpha.2(build 65,issues #151/#154/#155/#157/#158/#159/#162/#163)— 3.3.1 功能候选
4
44
 
5
45
  > 插件 `3.3.1-alpha.2` / App `3.3.1+65` / 载体 `3.3.1-alpha.2-app`。
@@ -8,7 +48,7 @@
8
48
 
9
49
  - **#157 会话文件图片预览**:文件列表识别 PNG/JPEG/WebP/GIF(图片行改用图片图标),点按进全屏查看器;共享查看器壳 `widgets/image_viewer_shell.dart` 同时服务于附件图库与会话文件(图库侧净删约 130 行重复),`InteractiveViewer` 0.5–4x + 双击、加载/失败/不支持状态面板、底部元信息条;大图按视口物理宽×2 降采样(封顶 4096);图片字节只走 `/workspace-image`(sessionId + cwd 相对路径),复用既有会话作用域校验/realpath/O_NOFOLLOW/magic 嗅探/8MiB·8192px·40MP 限制;SVG/HEIC/AVIF 显式提示不支持;新增 ETag/304 条件请求与按 profile/session/path 的 LRU 缓存;下载复用 #138。能力位双门控 `files.imagePreview` + `files.sessionRelative`,旧宿主回退文本预览。
10
50
  - **#158 输入区上下文三 Tab 抽屉**:上下文圆环/百分比可点开底部抽屉,三 Tab「上下文构成 / Token 用量 / 会话统计」;三个分项(system/tools/messages)各自独立水平条,明确不堆叠成 pressure 总条;无 breakdown 时只显示 pressure + 「当前电脑端未提供构成」,不伪造分项;不展示 prompt 正文与工具 schema。
11
- - **#155 设置页 5 Tab**:设置页按分组拆 Tab,降低单页长度。
51
+ - **#155 设置页分组 Tab**:设置页按任务分组拆 Tab,降低单页长度。最终为 **4 Tab:对话 / 外观 / 通知 / 通用** —— #155 最初交付 5 Tab(含「连接」),随后 #163 按「移动语义」把连接管理从设置页移除、只留 Drawer「连接」,故「连接」Tab 不再存在。
12
52
  - **#163 连接入口移至 Drawer**:连接入口从首页收进 Drawer,统一添加/编辑表单并补主机名称。
13
53
  - **#159 Git tags 三 Tab + 定位**:Git 分支列表增加 tags 与三 Tab,支持点击定位到分支图;tag 意图不打断分页,stale 不弹失败。
14
54
 
@@ -46,7 +86,7 @@
46
86
  ### 未包含/后续 alpha
47
87
 
48
88
  - #151 提问卡缺失 debug 取证
49
- - #155 设置页 5 Tab
89
+ - #155 设置页分组 Tab(已在 alpha.2 交付,最终 4 Tab)
50
90
  - #159 Git tags
51
91
  - #158 上下文抽屉
52
92
  - #157 图片预览
package/docs/03-api.md CHANGED
@@ -1595,15 +1595,28 @@ POST 请求体:`{"sessionId","repositoryId","tips":[...],"limit"?,"snapshotId"
1595
1595
  "degraded": false,
1596
1596
  "reason": "",
1597
1597
  "host": { "id": "<宿主稳定身份>", "pluginVersion": "3.3.0", "restartSupported": false },
1598
+ "classification": {
1599
+ "tableVersion": "2026.11", "targetDsh": "0.2.2", "dshVersion": "0.2.2-rc.5",
1600
+ "matched": true, "source": "static-table"
1601
+ },
1598
1602
  "plugins": [{
1599
1603
  "id": "@scope/pkg", "name": "@scope/pkg", "title": { "zh": "显示名", "en": "Display" },
1600
1604
  "description": null, "packageName": "@scope/pkg", "version": "1.2.3",
1601
1605
  "source": { "kind": "builtin|local|git|registry|entry|unknown", "label": "内置|本地|Git|配置渠道|配置条目|未知" },
1606
+ "official": true, "optional": false, "availability": "installation|profile|missing",
1607
+ "installed": true, "hidden": false,
1608
+ "category": { "kind": "builtin|experimental|custom|unclassified", "label": "内置|实验性|自定义|已安装(未分类)", "reason": "" },
1602
1609
  "enabled": true, "current": true, "independent": false,
1603
1610
  "health": { "state": "ok|starting|disabled|failed|unknown", "reasonCode": "runtime-starting|runtime-unknown|runtime-start-failed|…" },
1604
1611
  "compatibility": { "ok": null, "state": "ok|incompatible|unknown", "requirements": "engines.dsh: >=0.3.0" },
1605
1612
  "updateAvailable": null,
1606
1613
  "management": { "readOnly": true }
1614
+ }],
1615
+ "installable": [{
1616
+ "id": "@scope/new", "name": "@scope/new", "packageName": "@scope/new", "version": "0.7.0",
1617
+ "source": { "kind": "registry", "label": "配置渠道" },
1618
+ "category": { "kind": "experimental", "label": "实验性", "reason": "" }, "hidden": false,
1619
+ "installed": false
1607
1620
  }]
1608
1621
  }
1609
1622
  ```
@@ -1617,16 +1630,42 @@ POST 请求体:`{"sessionId","repositoryId","tips":[...],"limit"?,"snapshotId"
1617
1630
  - **`host.restartSupported`(bool,始终下发;issue #156)**:当前宿主形态是否允许手机触发重启(`restartFormOf() !== "unsupported"`)。仅作为能力位,供 App 在 `restartRequired` 时决定是否显示「重启电脑端」;实际重启仍走 `POST /plugin-inventory/restart`(#147,需显式 confirm)。旧宿主缺字段时 App 按 `false` 处理。
1618
1631
  - `updateAvailable` 固定 `null`:更新候选检查属于 #146/#147,本端点不触网检查 registry。
1619
1632
 
1633
+ #### 6.25.1 插件三分类与隐藏项(v3.3.1,issue #153)
1634
+
1635
+ 分类**事实由宿主下发**,App 只渲染、不重算:分类谓词与 `EXPERIMENTAL_BUNDLES` 静态表都在插件宿主侧(`lib/experimental-bundles.js`),因为 App 拿不到当前 DSH 版本。
1636
+
1637
+ - 每个行(`plugins[]` 与 `installable[]`)新增**顶层**字段 `official`/`optional`(`boolean|null`,取宿主 `BundleInfo` 同名字段)、`availability`(`installation|profile|missing|null`)、`installed`(`boolean|null`)、`hidden`(`boolean`)、`category`(`{kind,label,reason}`)。**不得塞进 `source`**:`source` 是既有契约(App 与测试都按形状断言)。
1638
+ - 分类谓词(互斥,一行只落一个 kind;优先级自上而下):
1639
+ | kind | 判据 |
1640
+ |---|---|
1641
+ | `unclassified` | `official`/`optional` 任一为 `null` → `reason:"host-facts-missing"`;或 `independent:true` → `reason:"independent-entry"` |
1642
+ | `experimental` | 包名命中宿主的 `EXPERIMENTAL_BUNDLES` 静态表(**即使随安装附带也算实验性**) |
1643
+ | `builtin` | `availability === "installation"` |
1644
+ | `custom` | 其余已安装 profile bundle |
1645
+ - **降级写死**:`official === null || optional === null` → `unclassified` + `host-facts-missing`;独立配置条目 → `unclassified` + `independent-entry`。**不得按包名前缀 / `optional` / 名称猜分类**。
1646
+ - `hidden`:没有插件页的 bundle(内置模板、常驻终端、独立 worktree 工具,共 8 项)标 `hidden:true`。App 默认不展示,提供「显示隐藏项」开关;**过滤只发生在客户端展示层,不改变 `complete`/`supported` 语义,也不从清单里删行**。
1647
+ - 根级 `classification`:`{tableVersion,targetDsh,dshVersion,matched,source:"static-table"}`。`dshVersion` 取宿主 `profileContext.installAnchor` 指向的 `package.json` version,读不到为 `""`(fail-closed);`matched` 只比较 core 版本(忽略 prerelease/build)。`matched === false` 时 App 显示「分类表与当前 DSH 版本不匹配」提示,但**仍按分类展示**(不改判、不挪 Tab)。
1648
+ - 旧宿主缺 `category` 字段 → App 退回单列表「已安装(未分类)」并提示,不伪造三 Tab。
1649
+
1620
1650
  ### 6.26 插件安装/升级(v3.3,issue #146)
1621
1651
 
1622
- 只使用宿主**已配置渠道**:App 不传任意 registry/Git/路径;安装候选与升级目标均来自宿主 `listBundles()/listVersions()`。宿主 `installBundle/updateBundle` 负责事务与失败回滚;本插件只做参数校验、同插件互斥、进度投影与结果归一,不自行改 profile。
1652
+ 只使用宿主**已配置渠道**:App 不传任意 Git/路径;安装候选与升级目标均来自宿主 `listBundles()/listVersions()`。宿主 `installBundle/updateBundle` 负责事务与失败回滚;本插件只做参数校验、同插件互斥、进度投影与结果归一,不自行改 profile。
1623
1653
 
1624
- - `GET /m/api/plugin-inventory/versions?name=<name>`:检查已安装 registry bundle 的更新。返回 `{status:"listed",installedVersion,versions:[{version,prerelease,deprecated,bundle,incompatible:{requirements}}],omitted}` 或 `{status:"refused",problem,reason}`;Git/内置/不可升级 → 409(稳定码 `git-update-desktop-required`/`plugin-not-updatable`)。
1625
- - `POST /m/api/plugin-inventory/install` `{name}`:仅接受宿主清单里带 `installTarget` 的候选;spec 由宿主决定,`expected` 固定目标版本。返回 `{ok,operation}`。
1626
- - `POST /m/api/plugin-inventory/update` `{name,version}`:仅接受 `update:"registry"` 的已安装 bundle;App 不能传 `spec`。返回 `{ok,operation}`。
1627
- - `GET /m/api/plugin-inventory/op?opId=`:轮询操作快照:`status(running|succeeded|failed|cancelled)`、`steps[{key,state}]`、`version/fromVersion`、`restartRequired`、`rolledBack`、`rollbackFailed`、`unchanged`、`outcomeUnknown`、`cancelled`、`errorCode`。
1654
+ - `GET /m/api/plugin-inventory/versions?name=<name>&registry=<url>`:检查已安装 registry bundle 的更新。返回 `{status:"listed",installedVersion,versions:[{version,prerelease,deprecated,bundle,incompatible:{requirements}}],omitted,requestedRegistry,answeredRegistry,attempts:[{registry,problem}]}` 或 `{status:"refused",problem,reason,requestedRegistry,answeredRegistry,attempts}`;Git/内置/不可升级 → 409(稳定码 `git-update-desktop-required`/`plugin-not-updatable`)。
1655
+ - `POST /m/api/plugin-inventory/install` `{name, registry?}`:仅接受宿主清单里带 `installTarget` 的候选;spec 由宿主决定,`expected` 固定目标版本。返回 `{ok,operation}`。
1656
+ - `POST /m/api/plugin-inventory/update` `{name,version, registry?}`:仅接受 `update:"registry"` 的已安装 bundle;App 不能传 `spec`。返回 `{ok,operation}`。
1657
+ - `GET /m/api/plugin-inventory/op?opId=`:轮询操作快照:`status(running|succeeded|failed|cancelled)`、`steps[{key,state}]`、`version/fromVersion`、`restartRequired`、`rolledBack`、`rollbackFailed`、`unchanged`、`outcomeUnknown`、`cancelled`、`errorCode`,以及 issue #153 的源归因 `registries:[url]`、`attempt:{index,total}|null`、`answeredRegistry:url|null`(卸载/启停恒为空/null)。
1628
1658
  - `POST /m/api/plugin-inventory/op/cancel` `{opId}`:委托宿主 `cancelInstall`;返回 `{cancel:"cancelled|too-late|not-running",operation}`。
1629
1659
 
1660
+ #### 6.26.1 安装源(registry)选择(v3.3.1,issue #153)
1661
+
1662
+ - `GET /m/api/plugin-inventory/registries`(只读,GET/HEAD):返回 `{ok,supported,complete,reason,writable:false,registries:[{id,kind,url,display,role}]}`。`kind ∈ registry|pnpm`,`role ∈ primary|fallback|resolved`。旧宿主无 `pluginManager.registries()` 或其抛错 → **HTTP 200** + `supported:false`、`reason:"host-registry-unavailable"`、`registries:[]`(不是 404/500)。非 GET/HEAD → 405。`writable` 恒 `false`:App 不能增删电脑端 registry。
1663
+ - **凭据安全**:带 `username`/`password`/`query`/`fragment` 的条目**整条丢弃**(不做脱敏回显);被丢弃时 `complete:false` + `reason:"registry-entries-dropped"`。`display` 只给 host+pathname。
1664
+ - `registry` 参数(`versions` 的 query、`install`/`update` 的 body 字段)只影响**本次**解析用的源,**不持久化**(不写 profile `package.json`/`pnpm-lock.yaml`/`.npmrc`,不写插件状态目录)。安装 spec 仍由宿主 `installTarget` 决定 —— 手动 URL **不能安装任意包**。
1665
+ - 校验器(`validateRegistryUrl`,三处共用):失败一律 `400 registry-invalid`,`detail` 只给类别(`not-string|empty|too-long|control-char|whitespace|unparsable|unsupported-protocol|missing-host|has-credentials|has-fragment|has-query`),**不回显原文**。规范化:pathname 末尾补 `/`,输出 `href`(与宿主 `normalizeRegistry` 幂等)。
1666
+ - 允许 localhost/私网(内网 Verdaccio/Nexus 是合法用例),不加私网黑名单;风险记录见 `docs/04-security.md`。
1667
+ - 不静默换源:`versions` 与操作快照都带 `requestedRegistry`/`answeredRegistry`/`attempts`;失败时 `answeredRegistry` 为 `null`(不能声称某个源答了)。
1668
+
1630
1669
  口径:
1631
1670
  - 安装失败/取消:宿主恢复 profile,`rolledBack:true`;异常逃逸 → `outcomeUnknown:true`(不断言回滚成功)。
1632
1671
  - 升级失败:宿主返回 `restore` 时 `rolledBack/rollbackFailed` 如实投影;未进入安装即失败 → `unchanged:true`;成功且 `application:"restart-required"` → `restartRequired:true`(只提示,重启由 #147)。
@@ -91,6 +91,17 @@
91
91
 
92
92
  已知/接受边界:hardlink 与 bind-mount 的同用户场景不在本端点威胁模型内;8 MiB/8192px/40MP 上限;HEAD 仍完整读取以生成强 ETag。通用文件下载 `/files` 已按 #16 收紧;上传与目录选择器的边界见上节,三者不可混用。
93
93
 
94
+ ### 插件安装源选择(`/m/api/plugin-inventory/registries` 与 `registry` 参数,issue #153)
95
+
96
+ 手机端「安装源选择」**只改变本次解析用的 registry**,不是新的安装通道:
97
+
98
+ - **只读**:`GET /m/api/plugin-inventory/registries` 投影宿主 `pluginManager.registries()`(首选源、回退源、pnpm 自身解析出的源),`writable` 恒 `false`;App 不能新增/删除/改写电脑端 registry,不写 profile `package.json`、`pnpm-lock.yaml`、`.npmrc` 或插件状态目录。
99
+ - **凭据安全(P0)**:出网前统一剥离 `username`/`password`/`search`/`hash`;**带凭据的条目整条丢弃**,不做“只去密码”的脱敏回显——回显保留用户名/主机关系,下游容易误当成可复用源。响应只给 `display`(host + pathname),日志不使用原始 URL。
100
+ - **手动 URL 校验**:只接受 `http(s)`;拒绝非字符串/空/超 2048 字节、控制字符与空白、`new URL` 失败(裸路径、`file:`/`data:`/`git+ssh:`/`ftp:` 等非 http(s))、带 userinfo、带 query、带 fragment、hostname 为空。失败一律 `400 registry-invalid`,`detail` **只给类别**、不回显原文(原文可能含凭据)。通过后与宿主 `normalizeRegistry` 幂等:pathname 末尾补 `/`。
101
+ - **允许 localhost 与私网**:内网 Verdaccio/Nexus 是合法用例,因此**不加私网/回环黑名单**。代价是已认证用户可以让宿主向指定 http(s) 主机发 registry 查询/安装请求;这与他本就能在电脑端配置 registry 等价,但**扩大了从手机发起的内网请求面**(可被用作端口/服务存在性探测:错误码与耗时能区分“无服务”“非 registry”)。缓解:端点需要移动端口令;安装 spec 仍由宿主 `installTarget` 决定,手动 URL **不能安装任意包**;不持久化,不会长期改变后续行为。
102
+ - **不静默换源**:`versions` 返回 `requestedRegistry`/`answeredRegistry`/`attempts[{registry,problem}]`,安装/升级操作快照带 `registries`/`attempt{index,total}`/`answeredRegistry`。失败时 `answeredRegistry` 留空——不能声称“某个源答了”。
103
+ - **旧宿主降级**:无 `registries()`/抛错 → HTTP 200 + `supported:false`(不是 404/500),App 只显示「当前电脑端不提供安装源信息」,仍可在宿主默认源安装。
104
+
94
105
  ### 持久化与投递
95
106
 
96
107
  - 插件**持久化仅限最小移动端状态**(`~/.dsh/mobile-remote/`:通知已读 id、会话最近活跃时间),不含会话内容;口令只存在于 profile 配置。
@@ -27,7 +27,11 @@
27
27
  | Flutter 构建环境 | Flutter 3.35+(Dart SDK ^3.13) |
28
28
  | 插件自更新通道(v3.5) | 按**能力**分两条通道,不按宿主版本号门禁:宿主提供 `pluginManager.updateBundle` 且本插件可被它更新 → **`host-manager`**(进程内热更新,**不重启宿主**;HMR 可用时立即生效,否则装完需重启);否则退回传统通道(改依赖 → pnpm install → 重启 → 健康确认),再不行给人工指引。`0.2.2` 之前的宿主没有该服务,自动走传统通道,行为与旧版一致 |
29
29
 
30
- **声明式兼容范围(`peerDependencies`)**:`@deepseek-ai/dsh-{credentials,llm,sandbox-policy,scope}` 声明 `>=0.1.0-rc.6 <=0.2.2 || >=0.2.0-0 <0.2.0 || >=0.2.1-0 <0.2.1 || >=0.2.2-0 <0.2.2`。稳定版上限为 `0.2.2`;三个显式预发布分支分别纳入已发布的 `0.2.0-rc.*`、`0.2.1-rc.*`、`0.2.2-alpha/rc.*` 系列(npm 默认 semver 语义不会把裸 `<=0.2.2` 认作覆盖预发布版本)。`0.2.3+` 与 `0.3.0+` 会被判为不兼容。
30
+ **声明式兼容范围(`peerDependencies`)**:`@deepseek-ai/dsh-{credentials,llm,sandbox-policy,scope}` 声明 `>=0.1.0-rc.6 <=0.2.3 || >=0.2.0-0 <0.2.0 || >=0.2.1-0 <0.2.1 || >=0.2.2-0 <0.2.2 || >=0.2.3-0 <0.2.3`。稳定版上限为 `0.2.3`;四个显式预发布分支分别纳入已发布的 `0.2.0-rc.*`、`0.2.1-rc.*`、`0.2.2-alpha/rc.*`、`0.2.3-alpha/rc.*` 系列(npm 默认 semver 语义不会把裸 `<=0.2.3` 认作覆盖预发布版本)。`0.3.0+` 会被判为不兼容。
31
+
32
+ > **上界放宽记录(issue #166,2026-11-23)**:原上界为 `<=0.2.2`,且 `test/host-compat-022.test.mjs` 显式断言 `0.2.3` 必须被拒("must cap the stable line at 0.2.2")。用户裁决按方案 B 放宽到 `0.2.3`,该保护随之移除 —— **代价明确**:日后 `0.2.3` 若引入破坏性变更,peer 范围不再拦截,只能靠 canary 与运行时能力探测(ADR 0017)暴露。`0.3.0` 边界仍由测试守住。
33
+
34
+ > **Node 门槛**:DSH `0.2.3` 把 Node 要求提高到 `24.22.3`,而本插件**不声明 `engines`**(用户裁决)。因此版本过低时不会在 `npm install` 阶段被拦,而是在宿主启动时由 DSH 自己报错。
31
35
 
32
36
  注意两条判定通道语义不同:宿主 `@deepseek-ai/dsh-app-boot` 的 `evaluatePluginCompatibility()` 用 `semver.satisfies(runtimeVersion, range, { includePrerelease: true })`(运行时放行预发布);npm / pnpm 安装期的 peer 解析用默认语义,所以预发布宿主必须在范围里显式出现。上界**只用于声明可安装边界**,功能路径仍按能力探测(ADR 0017),不按版本号做功能门禁。
33
37
 
@@ -149,6 +149,8 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
149
149
  { path: "/git/repository", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
150
150
  { path: "/git/worktree", methods: "GET/HEAD", capability: null, why: NO_CAPABILITY_NEEDED },
151
151
  { path: "/goal", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
152
+ // issue #106 引入:DSH 设置只读查看器(固定白名单投影;老宿主 200 + supported:false)。
153
+ { path: "/host-settings", methods: "GET/HEAD", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
152
154
  { path: "/history", methods: "GET", capability: "eventTimeline" },
153
155
  { path: "/jobs", methods: "GET", capability: null, why: NO_CAPABILITY_NEEDED },
154
156
  { path: "/jobs/kill", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
@@ -159,6 +161,8 @@ export const REGISTERED_ENDPOINTS = Object.freeze([
159
161
  { path: "/notifications/delete", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
160
162
  { path: "/notifications/read", methods: "GET/POST", capability: null, why: NO_CAPABILITY_NEEDED },
161
163
  { path: "/plugin-inventory", methods: "GET/HEAD", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
164
+ // issue #153 引入:只读安装源投影(GET/HEAD;老宿主返回 200 + supported:false)。
165
+ { path: "/plugin-inventory/registries", methods: "GET/HEAD", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
162
166
  // issue #143 引入;补齐登记避免端点登记门禁红(方法与源码 requireGet 一致)。
163
167
  { path: "/team/tasks", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
164
168
  { path: "/plugin-inventory/versions", methods: "GET", capability: null, auth: "required", why: NO_CAPABILITY_NEEDED },
@@ -0,0 +1,121 @@
1
+ // issue #153:插件三分类(内置 / 实验性 / 自定义)的**静态权威表**。
2
+ //
3
+ // 为什么这张表在插件宿主侧、而不是 App 里:
4
+ // - DSH 的“实验性”不是 `BundleInfo` 字段,而是 `@deepseek-ai/dsh-official-bundles`
5
+ // 按 DSH 版本发布的静态名单(EXPERIMENTAL_BUNDLES);App 拿不到 DSH 版本事实,
6
+ // 只有宿主能读到当前运行版本;
7
+ // - 分类谓词与表必须同侧,否则全仓会出现两份互相漂移的分类实现。
8
+ //
9
+ // 明确禁止:
10
+ // - 运行时 `import("@deepseek-ai/dsh-official-bundles")` 当权威——不同宿主版本的导出
11
+ // 形状不保证稳定,且“宿主自己判自己”无法暴露表漂移;
12
+ // - 按包名前缀(`experimental-`)、`optional` 或名称猜实验性。
13
+ // 表版本必须随 DSH 升级评审更新;漂移由根级 `classification.matched` 暴露,不静默改判。
14
+ //
15
+ // 表内容取自 `@deepseek-ai/dsh-official-bundles@0.2.2-rc.5` 的 EXPERIMENTAL_BUNDLES /
16
+ // HIDDEN_BUNDLES(2026-11 实测),保持不变,不做增删。
17
+
18
+ /** 表版本:随 DSH 版本评审更新;App 与发版说明引用此值。 */
19
+ export const EXPERIMENTAL_TABLE_VERSION = "2026.11";
20
+
21
+ /** 该表对齐的 DSH core 版本(去掉 prerelease/build 后比较)。 */
22
+ export const EXPERIMENTAL_TARGET_DSH = "0.2.2";
23
+
24
+ /** 命中即归「实验性」的官方 bundle 名单(与 DSH 0.2.2 的 EXPERIMENTAL_BUNDLES 一致)。 */
25
+ export const EXPERIMENTAL_BUNDLES = Object.freeze(new Set([
26
+ "@deepseek-ai/dsh-personalized-recommendations",
27
+ "@deepseek-ai/dsh-cua-bundle",
28
+ "@deepseek-ai/dsh-experimental-voice-input-bundle",
29
+ "@deepseek-ai/dsh-experimental-auto-review",
30
+ "@deepseek-ai/dsh-experimental-inspector-profile",
31
+ "@deepseek-ai/dsh-experimental-forge-bundle",
32
+ "@deepseek-ai/dsh-experimental-tool-worktree",
33
+ "@deepseek-ai/dsh-experimental-cot-translation-bundle",
34
+ "@deepseek-ai/dsh-experimental-session-search",
35
+ "@deepseek-ai/dsh-experimental-session-titles-bundle",
36
+ "@deepseek-ai/dsh-experimental-badge-skill-bundle",
37
+ "@deepseek-ai/dsh-experimental-ralph-bundle",
38
+ "@deepseek-ai/dsh-experimental-plugin-market-bundle",
39
+ "@deepseek-ai/dsh-experimental-liveshare",
40
+ "@deepseek-ai/dsh-deepseek-chat-import",
41
+ ]));
42
+
43
+ /**
44
+ * 没有插件页的 bundle(内置模板、常驻终端、独立 worktree 工具):
45
+ * 手机端主列表默认不展示,提供「显示隐藏项」开关。
46
+ */
47
+ export const HIDDEN_BUNDLES = Object.freeze(new Set([
48
+ "@deepseek-ai/dsh-base",
49
+ "@deepseek-ai/dsh-web-app",
50
+ "@deepseek-ai/dsh-headless",
51
+ "@deepseek-ai/dsh-sdk-app",
52
+ "@deepseek-ai/dsh-acp-app",
53
+ "@deepseek-ai/dsh-sdk-minimal",
54
+ "@deepseek-ai/dsh-experimental-terminal-bundle",
55
+ "@deepseek-ai/dsh-experimental-tool-worktree",
56
+ ]));
57
+
58
+ /** 分类 kind → 中文 label(English 由 App 本地化,label 只作兜底)。 */
59
+ const CATEGORY_LABELS = Object.freeze({
60
+ experimental: "实验性",
61
+ builtin: "内置",
62
+ custom: "自定义",
63
+ unclassified: "已安装(未分类)",
64
+ });
65
+
66
+ const CATEGORY = (kind, reason = "") => ({ kind, label: CATEGORY_LABELS[kind], reason });
67
+
68
+ /** 宿主是否把某个包名标为隐藏(无插件页的 bundle)。 */
69
+ export function isHiddenBundle(name) {
70
+ return typeof name === "string" && HIDDEN_BUNDLES.has(name);
71
+ }
72
+
73
+ /**
74
+ * 去掉 prerelease/build 后的 `major.minor.patch`;非字符串/非法 → ""。
75
+ * DSH 运行版本形如 `0.2.2-rc.5`,表目标是 `0.2.2`:同一 core 即视为匹配。
76
+ */
77
+ export function dshCoreVersion(version) {
78
+ if (typeof version !== "string") return "";
79
+ const core = version.trim().split(/[-+]/, 1)[0];
80
+ return /^\d+\.\d+\.\d+$/.test(core) ? core : "";
81
+ }
82
+
83
+ /** 当前 DSH 版本是否与静态表对齐(版本未知 → false,fail-closed)。 */
84
+ export function experimentalTableMatches(dshVersion) {
85
+ const core = dshCoreVersion(dshVersion);
86
+ return core !== "" && core === EXPERIMENTAL_TARGET_DSH;
87
+ }
88
+
89
+ /**
90
+ * 分类谓词(用户已裁决 = 方案 B)。
91
+ *
92
+ * 优先级:**事实缺失/独立条目先降级**(写死,不猜),再 experimental → builtin → custom。
93
+ * - `official`/`optional` 任一为 null(旧宿主没给这两个字段)→ unclassified/host-facts-missing;
94
+ * - `independent:true`(配置条目,不是 bundle)→ unclassified/independent-entry;
95
+ * - 命中 EXPERIMENTAL_BUNDLES → experimental(实验性包即使随安装附带也算实验性);
96
+ * - `availability === "installation"` → builtin;
97
+ * - 其余已安装 profile bundle → custom。
98
+ *
99
+ * @param {{ name?: unknown, official?: unknown, optional?: unknown, availability?: unknown, installed?: unknown, independent?: unknown }} bundle
100
+ * @returns {{ kind: "experimental"|"builtin"|"custom"|"unclassified", label: string, reason: string }}
101
+ */
102
+ export function classifyPluginBundle(bundle) {
103
+ if (bundle?.independent === true) return CATEGORY("unclassified", "independent-entry");
104
+ if (typeof bundle?.official !== "boolean" || typeof bundle?.optional !== "boolean") {
105
+ return CATEGORY("unclassified", "host-facts-missing");
106
+ }
107
+ const name = typeof bundle?.name === "string" ? bundle.name : "";
108
+ if (EXPERIMENTAL_BUNDLES.has(name)) return CATEGORY("experimental");
109
+ if (bundle?.availability === "installation") return CATEGORY("builtin");
110
+ return CATEGORY("custom");
111
+ }
112
+
113
+ /** `availability` 只接受契约里的四个值,其余(含缺失)→ null。 */
114
+ export function normalizeAvailability(value) {
115
+ return value === "installation" || value === "profile" || value === "missing" ? value : null;
116
+ }
117
+
118
+ /** `installed` 只接受布尔事实,缺失 → null。 */
119
+ export function normalizeInstalled(value) {
120
+ return typeof value === "boolean" ? value : null;
121
+ }
@@ -0,0 +1,207 @@
1
+ // issue #106:手机端「电脑端设置(只读)」的**固定白名单**。
2
+ //
3
+ // 安全契约(不可妥协):
4
+ // - 白名单只在宿主侧冻结;App **不保存副本、不拼路径、不接受运行时扩展**。
5
+ // - 投影只走这里列出的 `namespace + field path`;**没列出的项一律不返回**,
6
+ // 响应里没有的项在 UI 上就是不可见(不补默认、不猜 schema、不显示原始 JSON)。
7
+ // - 这里只放**无凭据、无文件系统路径、无会话正文**的配置字段。
8
+ //
9
+ // ## 冻结依据(2026-11-23,DSH 0.2.2-rc.5 `settings.describe()` 实测口径)
10
+ //
11
+ // 1. **只有 volatile 字段可达**:`dsh-settings` 的 `describe()` 先用 `volatileForm()`
12
+ // 过滤 schema,再用 `projectForm()` 投影值;非 volatile 字段既不进 `schema`,
13
+ // 也不进 `value`/`base`/`user`。因此白名单**只能**选 volatile 节点下的字段,
14
+ // 否则永远是"可见 0 项"(等于白列)。例:`agent-preset-registry.default` 与
15
+ // `permission.presets.*` 都**不是** volatile,故不列;列 `selectedDefault` / `defaultPreset`。
16
+ // 2. **secret 只以槽位出现**:`role('secret')`(密文本身)与 `role('credential-ref')`
17
+ // (凭据引用名,常内嵌账号 id)一律只作为 `kind:"secret"` 的「已设置/未设置」出现,
18
+ // 或干脆不列。`llm-pi-ai.providers.*.apiKeyEnv` 即属后者:引用名无展示价值,不列。
19
+ // 3. **一律不列**(宿主也不会替我们剥):
20
+ // - `headers` / `requestHeaders` / `accountRequestHeaders`(值可能是令牌);
21
+ // - `baseURL` / `proxyUrl` / `platformOrigin` / `inferenceOrigin`(可能内嵌 userinfo
22
+ // 或暴露主机拓扑);
23
+ // - `cwd` / `path` / `updateDir` / `documentPath` 等一切文件系统路径;
24
+ // - 自由文本(`description`、prompt 类)与会话正文、工具参数/结果。
25
+ // 4. **不按第三方插件猜**:只列 DSH 内置插件自带 schema 中语义稳定的字段;插件自由
26
+ // `object`/`dict`(形状会随版本漂移、无法逐字段断言脱敏)整段不列。
27
+ //
28
+ // ## 更新方式
29
+ // 改本文件后必跑 `node --test test/host-settings*.test.mjs`(含嵌套 secret / 默认值旁路 /
30
+ // 凭据 / 路径负例)。`HOST_SETTINGS_WHITELIST_VERSION` 只在**字段语义变化**时递增,
31
+ // 供诊断与后续契约迁移(App 不据此推断字段是否存在)。
32
+ //
33
+ // 路径里的 `*` 只表示「dict 的键 / 数组元素」,由宿主按实际值展开成具体键,
34
+ // 展开数量有上限(`lib/host-settings.js` 的 `MAX_WILDCARD_ITEMS`);超限即 fail-closed。
35
+
36
+ /** 白名单契约版本(字段语义变化时递增)。 */
37
+ export const HOST_SETTINGS_WHITELIST_VERSION = 1;
38
+
39
+ /**
40
+ * 视觉分组(只分组,不新增可展示 key)。顺序即 UI 顺序。
41
+ *
42
+ * 按 /tmp/3.3.1-ui-design.md §2.3 的四组收敛掉「连接与宿主」:主机名/DSH 版本/运行模式
43
+ * **不是设置项**,由响应顶部的 `host` 段(及 App 本地连接档案名)承载,不进 `namespaces`,
44
+ * 避免把"宿主事实"混进"设置字段"里造成来源/默认值语义不清。
45
+ */
46
+ export const HOST_SETTINGS_GROUPS = Object.freeze([
47
+ Object.freeze({ id: "model-routing", title: "模型与路由", titleEn: "Model & routing" }),
48
+ Object.freeze({ id: "permissions", title: "权限与审批", titleEn: "Permissions & approval" }),
49
+ Object.freeze({ id: "session-agent", title: "会话与代理", titleEn: "Sessions & agents" }),
50
+ ]);
51
+
52
+ /**
53
+ * 固定白名单。每条 = 一个 namespace 下的一个 field path(`path` 中的 `*` 为 dict 键)。
54
+ * `title` / `titleEn` 是该行的固定标题(宿主算好,App 不再猜 schema 标题)。
55
+ */
56
+ export const HOST_SETTINGS_WHITELIST = Object.freeze([
57
+ // ── 模型与路由 ────────────────────────────────────────────────
58
+ // agent-default-model:三者都 `.volatile()`,是纯标识串,不含密钥
59
+ // (密钥在各自 llm-* 命名空间,已从白名单排除)。
60
+ Object.freeze({
61
+ ns: "agent-default-model",
62
+ group: "model-routing",
63
+ namespaceTitle: "默认模型",
64
+ namespaceTitleEn: "Default model",
65
+ path: Object.freeze(["provider"]),
66
+ title: "默认提供商",
67
+ titleEn: "Default provider",
68
+ }),
69
+ Object.freeze({
70
+ ns: "agent-default-model",
71
+ group: "model-routing",
72
+ namespaceTitle: "默认模型",
73
+ namespaceTitleEn: "Default model",
74
+ path: Object.freeze(["model"]),
75
+ title: "默认模型",
76
+ titleEn: "Default model",
77
+ }),
78
+ Object.freeze({
79
+ ns: "agent-default-model",
80
+ group: "model-routing",
81
+ namespaceTitle: "默认模型",
82
+ namespaceTitleEn: "Default model",
83
+ path: Object.freeze(["reasoningEffort"]),
84
+ title: "推理强度",
85
+ titleEn: "Reasoning effort",
86
+ }),
87
+ // llm-pi-ai:`providers` 整棵子树是 volatile dict,可按 route 展开。
88
+ // 只取显示名与默认上下文窗口;`apiKeyEnv`(credential-ref)、`baseURL`、`headers`、
89
+ // `models` / `modelOverrides`(含端点与自由形状)**都不列**。
90
+ Object.freeze({
91
+ ns: "llm-pi-ai",
92
+ group: "model-routing",
93
+ namespaceTitle: "提供商路由",
94
+ namespaceTitleEn: "Provider routes",
95
+ path: Object.freeze(["providers", "*", "displayName"]),
96
+ title: "提供商名称",
97
+ titleEn: "Provider name",
98
+ }),
99
+ Object.freeze({
100
+ ns: "llm-pi-ai",
101
+ group: "model-routing",
102
+ namespaceTitle: "提供商路由",
103
+ namespaceTitleEn: "Provider routes",
104
+ path: Object.freeze(["providers", "*", "defaultContextWindow"]),
105
+ title: "上下文窗口",
106
+ titleEn: "Context window",
107
+ }),
108
+ // web-search-deepseek:联网搜索的模型与配额。`apiKey` 是 `role('secret')`,
109
+ // 只作为 secret 槽位(已设置/未设置),永不带值/长度/前缀。
110
+ // `baseURL` / `apiKeyEnv` / `apiVersion` 不列。
111
+ Object.freeze({
112
+ ns: "web-search-deepseek",
113
+ group: "model-routing",
114
+ namespaceTitle: "联网搜索",
115
+ namespaceTitleEn: "Web search",
116
+ path: Object.freeze(["model"]),
117
+ title: "搜索模型",
118
+ titleEn: "Search model",
119
+ }),
120
+ Object.freeze({
121
+ ns: "web-search-deepseek",
122
+ group: "model-routing",
123
+ namespaceTitle: "联网搜索",
124
+ namespaceTitleEn: "Web search",
125
+ path: Object.freeze(["maxUses"]),
126
+ title: "单次最多搜索次数",
127
+ titleEn: "Max searches per request",
128
+ }),
129
+ Object.freeze({
130
+ ns: "web-search-deepseek",
131
+ group: "model-routing",
132
+ namespaceTitle: "联网搜索",
133
+ namespaceTitleEn: "Web search",
134
+ path: Object.freeze(["maxTokens"]),
135
+ title: "回复 token 上限",
136
+ titleEn: "Max reply tokens",
137
+ }),
138
+ Object.freeze({
139
+ ns: "web-search-deepseek",
140
+ group: "model-routing",
141
+ namespaceTitle: "联网搜索",
142
+ namespaceTitleEn: "Web search",
143
+ path: Object.freeze(["apiKey"]),
144
+ title: "API 密钥",
145
+ titleEn: "API key",
146
+ }),
147
+
148
+ // ── 权限与审批 ────────────────────────────────────────────────
149
+ // permission:`defaultPreset` 是唯一的 volatile 字段。`presets` 表**不是** volatile,
150
+ // describe() 里根本不存在,故不列(不制造"永远 0 项"的假字段)。
151
+ Object.freeze({
152
+ ns: "permission",
153
+ group: "permissions",
154
+ namespaceTitle: "权限预设",
155
+ namespaceTitleEn: "Permission presets",
156
+ path: Object.freeze(["defaultPreset"]),
157
+ title: "默认权限预设",
158
+ titleEn: "Default permission preset",
159
+ }),
160
+
161
+ // ── 会话与代理 ────────────────────────────────────────────────
162
+ // agent-preset-registry:`default` 非 volatile(describe 不可见),只有
163
+ // `selectedDefault` 可见;如实只列后者,标题也按"当前选中"而非"默认",
164
+ // 不让 UI 把运行态覆盖误标成默认值。
165
+ Object.freeze({
166
+ ns: "agent-preset-registry",
167
+ group: "session-agent",
168
+ namespaceTitle: "Agent 预设",
169
+ namespaceTitleEn: "Agent presets",
170
+ path: Object.freeze(["selectedDefault"]),
171
+ title: "当前选中的预设",
172
+ titleEn: "Selected preset",
173
+ }),
174
+ // subagent:子代理深度与并发上限,两个数字字段,无路径/正文。
175
+ Object.freeze({
176
+ ns: "subagent",
177
+ group: "session-agent",
178
+ namespaceTitle: "子代理",
179
+ namespaceTitleEn: "Subagents",
180
+ path: Object.freeze(["maxDepth"]),
181
+ title: "最大层级",
182
+ titleEn: "Max depth",
183
+ }),
184
+ Object.freeze({
185
+ ns: "subagent",
186
+ group: "session-agent",
187
+ namespaceTitle: "子代理",
188
+ namespaceTitleEn: "Subagents",
189
+ path: Object.freeze(["maxActiveSubagents"]),
190
+ title: "最大并发子代理",
191
+ titleEn: "Max active subagents",
192
+ }),
193
+ // agent-loop:并发工具上限。`agents[]` 含 `cwd`(绝对路径)与 resumeSessionId,
194
+ // **整段不列**,只列这一个数字。
195
+ Object.freeze({
196
+ ns: "agent-loop",
197
+ group: "session-agent",
198
+ namespaceTitle: "Agent 循环",
199
+ namespaceTitleEn: "Agent loop",
200
+ path: Object.freeze(["maxParallelToolCalls"]),
201
+ title: "最大并行工具调用",
202
+ titleEn: "Max parallel tool calls",
203
+ }),
204
+ ]);
205
+
206
+ /** 白名单是否为空(fail-closed 判据之一)。 */
207
+ export const hostSettingsWhitelistIsEmpty = () => HOST_SETTINGS_WHITELIST.length === 0;