dsh-remote-bridge 2.6.0 → 2.7.0

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/README.en.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <img alt="Version" src="https://img.shields.io/badge/version-v2.6.0-087f8c">
12
+ <img alt="Version" src="https://img.shields.io/badge/version-v2.7.0-087f8c">
13
13
  <img alt="DSH plugin" src="https://img.shields.io/badge/DeepSeek_Harness-plugin-1f2328">
14
14
  <img alt="Platforms" src="https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-586069">
15
15
  <img alt="License" src="https://img.shields.io/badge/license-AGPL--3.0-2da44e">
@@ -102,10 +102,10 @@ dsh plugin --profile web add dsh-remote-bridge
102
102
  dsh plugin --profile web add dsh-remote-bridge --registry https://registry.npmmirror.com
103
103
 
104
104
  # 2. tarball from the GitHub release
105
- dsh plugin --profile web add https://github.com/westanke/dsh-remote-bridge/releases/download/v2.6.0/dsh-remote-bridge-v2.6.0.tgz
105
+ dsh plugin --profile web add https://github.com/westanke/dsh-remote-bridge/releases/download/v2.7.0/dsh-remote-bridge-v2.7.0.tgz
106
106
 
107
107
  # 3. tarball from the Gitee release (faster from mainland China)
108
- dsh plugin --profile web add https://gitee.com/westanke/dsh-remote-bridge/releases/download/v2.6.0/dsh-remote-bridge-v2.6.0.tgz
108
+ dsh plugin --profile web add https://gitee.com/westanke/dsh-remote-bridge/releases/download/v2.7.0/dsh-remote-bridge-v2.7.0.tgz
109
109
 
110
110
  npx @deepseek-ai/dsh web
111
111
  ```
@@ -122,7 +122,7 @@ Restart DSH after installation, then open settings — The section is titled **
122
122
  To install a downloaded release archive:
123
123
 
124
124
  ```sh
125
- dsh plugin --profile web add ./dsh-remote-bridge-v2.6.0.tgz
125
+ dsh plugin --profile web add ./dsh-remote-bridge-v2.7.0.tgz
126
126
  ```
127
127
 
128
128
  ## First connection
@@ -219,10 +219,28 @@ The following controls remain active over both HTTP and HTTPS:
219
219
  - revocable scopes and per-root grants;
220
220
  - separate rate limits for pairing, authentication failures, and normal requests;
221
221
  - audit records that omit tokens, file bodies, and chat bodies;
222
- - no automatic access to roots added after a device was paired.
222
+ - no automatic access to roots added after a device was paired;
223
+ - provider `baseURL` changes are limited to public http(s) destinations, and moving a
224
+ provider that already stores a credential to a new host also requires a fresh API key
225
+ (the kernel sends that key to the address, so this is a credential boundary, not just SSRF).
223
226
 
224
227
  Only a loopback client may add roots, change device grants, create pairing codes, configure the listener, or permanently purge trash.
225
228
 
229
+ ### Local LLM endpoints (ollama / LM Studio)
230
+
231
+ Private, loopback, link-local and CGNAT provider addresses are **rejected by default**.
232
+ To use a local model server, list it explicitly in the plugin config:
233
+
234
+ ```yaml
235
+ allowPrivateProviderHosts:
236
+ - 127.0.0.1:11434 # recommended: pin the port
237
+ - 192.168.1.5 # bare host: allows every port on that host
238
+ ```
239
+
240
+ Exact `host` or `host:port` only — CIDR is not supported. Prefer the `host:port` form:
241
+ allowing `192.168.1.5` allows every service on it, while ollama only listens on 11434.
242
+ See `docs/project/SECURITY.md` for the reasoning and the audit trail fields.
243
+
226
244
  ## Path boundary
227
245
 
228
246
  External requests use `rootId + relativePath`, never an absolute server path.
@@ -297,6 +315,16 @@ A device also needs an explicit grant for every `rootId`. Local administrators m
297
315
 
298
316
  **New scopes are picked before pairing, in Remote access**: whatever you tick is what the generated pairing code carries, and those scopes take effect once the app enters the code. For a device that is already paired, open **Devices** and use its **Permissions** button.
299
317
 
318
+ The default selection is five scopes — `chat.read`, `chat.write`, `files.read`, `files.write`, `settings.read` — and **deliberately excludes** `files.delete` and `settings.write`. You can still tick them; the default just no longer hands out destructive permissions on its own.
319
+
320
+ ### Device names and models
321
+
322
+ At pairing time the bridge has no idea who will use the token, so a new device starts with a **platform-neutral** placeholder name (`Mobile device`). The first time the device connects, the bridge works out its platform and model from the request and replaces the name with `platform · model` (for example `HarmonyOS · ICL-AL10`).
323
+
324
+ Platform detection prefers the client-declared `X-Dsh-Device: <platform>/<model>` header and falls back to the `User-Agent`. **The model is only taken from what the client reports**: neither okhttp nor ArkWeb puts a model in its default UA, and the bridge will not guess — a wrong model is worse than no model.
325
+
326
+ Open **Devices** and use **Permissions** to rename a device. **A name you set yourself is never overwritten**; an automatically generated name still updates when the device reports a new identity. Device names are for display and troubleshooting only and take no part in authorization.
327
+
300
328
  **Revoking a device deletes it from the database** rather than leaving a marker row behind. Its grants go with it, while the audit trail (who revoked which device, and when) is kept.
301
329
 
302
330
  ## Upgrade and uninstall
@@ -352,21 +380,49 @@ pnpm check
352
380
  pnpm pack
353
381
  ```
354
382
 
355
- `pnpm check` covers type-checking, documentation consistency, and tests. It currently passes **67 test files / 557 cases**, plus **8 browser-layer cases** (Playwright measuring real computed styles, including the 375px narrow-viewport contract).
383
+ `pnpm check` covers type-checking, documentation consistency, and tests. It currently passes **76 test files / 698 cases**, plus **8 browser-layer cases** (Playwright measuring real computed styles, including the 375px narrow-viewport contract).
356
384
 
357
- `npm pack` produces roughly a **0.61 MB** archive (v2.5.2 measured 635,325 bytes, SHA-256 `18d36904…c8095`): 2.2.0 dropped the standalone page and its editor dependencies and turned source maps off, down from 1.72 MB; it has since grown slightly with projection passthrough, the permission BFF, and the five-dimension hardening.
385
+ `npm pack` produces roughly a **0.64 MB** archive (v2.6.1 measured 669,434 bytes, SHA-256 `9bf0189b…2cd35`): 2.2.0 dropped the standalone page and its editor dependencies and turned source maps off, down from 1.72 MB; it has since grown slightly with projection passthrough, the permission BFF, and the five-dimension hardening.
358
386
 
359
387
  v2.5.0 was verified on DSH **0.2.1-rc.2** on real hardware: all 14/14 host services injected, the three jobs endpoints exercised, and the permission catalog returned the kernel's real three presets. The development baseline is upstream `dsh-v0.2.1-rc.2` (commit `687f282e8625c6b8d11ff58211a90524be2e4317`); see `engines.dsh` above for the supported range. CI covers Windows, Ubuntu, and macOS.
360
388
 
361
- **v2.6.0 verification status**: 70 test files / 593 cases green, plus 8 Playwright browser cases
389
+ **v2.7.0 verification status**: 76 test files / 698 cases green, plus 8 Playwright browser cases
362
390
  (including the 375px narrow-viewport contract); `typecheck`, `docs:check`, and the build all pass.
363
- All three rounds of real-hardware tunnel regressions were reproduced and verified on a
364
- React18 + Playwright click harness (one-click token issuance, the stop-tunnel escape hatch, and the
365
- locked state when re-entering settings), then confirmed by manual testing on the user's machine.
391
+ All four capabilities were exercised on an isolated DSH **0.2.1-rc.3** instance rather than inferred:
392
+ the plugin inventory returned `loaded: 14 / 16 / problems: 2`, the model catalog reported
393
+ `ctx=1048576` for `free:mimo-v2.6-flash-free`, the four `reuseBlank` semantics were each verified,
394
+ and the client bundle contains `dsh-remote-bridge-plugins` and `sidebarRightTabs`. Screenshots live
395
+ in `dsh-021cmp/shots/`. The compatibility review was itself measured: 305 packages compared by
396
+ sha256, 285 with zero code changes and 20 substantively changed, all ten hard-dependency providers
397
+ inside the zero-change set, and 4 slots retained with 0 removed.
366
398
 
367
399
  ## Project
368
400
 
369
- - Version: `v2.6.0`
401
+ - Version: `v2.7.0`
402
+ - **v2.7.0 aligns with DSH 0.2.1-rc.3 and lifts four capabilities**: (1) the model catalog now carries
403
+ `contextWindow` / `maxTokens` — the kernel's `ModelCatalogModel` only has id/name/description, so the
404
+ bridge resolves capacity through `llm.resolveModelInfo`, caching per `provider + model` for ten
405
+ minutes, never caching a failure, and never overwriting a value the kernel already supplied;
406
+ (2) the plugin inventory gains a right-sidebar form (the bridge becomes a `SidebarRightTabDefinition`
407
+ provider, so from DSH 0.2.1-rc.3 the card can be pinned; on rc.2 it still renders but has no pin or
408
+ More menu, which is the expected degradation); (3) `POST /chat/sessions` accepts an optional
409
+ `reuseBlank`, matching the 0.2.1 desktop behaviour where New Session returns to the workspace's
410
+ existing blank session, skipping blanks whose preset contradicts the request; (4) the settings page
411
+ gains a Plugins card (inventory / enable / disable / check for updates) and an "open plugin list"
412
+ button (rc.2 has no `pluginNavigation.openList`, so the bridge feature-detects instead of checking
413
+ versions).
414
+ - **v2.6.1 is the security-fix + device-identity release**: it closes a **high-severity** hole —
415
+ the three provider `baseURL` entry points (create / update / model discovery) performed no
416
+ validation at all, so a device holding `settings.write` could point the baseURL at its own server
417
+ and the kernel would request `/models` there with **that provider's real API key**, leaking the
418
+ credential outright; the persistent variant was worse, since after changing the baseURL every
419
+ subsequent chat would send the key there. There are now three gates (protocol allow-list,
420
+ private networks denied by default with an explicit `allowPrivateProviderHosts` opt-in, and a
421
+ new key required when repointing a provider that already holds a credential), and the pairing
422
+ default was narrowed from seven scopes to five (no more `settings.write` / `files.delete` by default).
423
+ It also fixes "the device name is always 'Android device'": the bridge now derives the platform and
424
+ model from the `X-Dsh-Device` header (User-Agent as fallback), renames the placeholder to
425
+ "platform · model", and offers a rename channel (a manually set name is never overwritten).
370
426
  - **v2.6.0 is the plugin-settings + IM-entry release**: it adds the per-plugin settings namespaces (`GET /api/v1/settings/namespaces`, `PATCH .../{ns}`) so the app can build the form from the kernel schema, and two entry points for "I am out and the desktop is still locked" — the host command `/tunnel` and the tool `open_tunnel_config`; plus one-tap pruning of unused devices, the audit page removed, and a guard so a failing optional registration cannot tear down the whole plugin context.
371
427
  - **v2.5.2 is a comprehensive hardening release**: it lands the five-dimension audit
372
428
  (security, features, performance, UI, button feedback) — including the unauthenticated
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <img alt="Version" src="https://img.shields.io/badge/version-v2.6.0-087f8c">
12
+ <img alt="Version" src="https://img.shields.io/badge/version-v2.7.0-087f8c">
13
13
  <img alt="DSH plugin" src="https://img.shields.io/badge/DeepSeek_Harness-plugin-1f2328">
14
14
  <img alt="Platforms" src="https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-586069">
15
15
  <img alt="License" src="https://img.shields.io/badge/license-AGPL--3.0-2da44e">
@@ -93,10 +93,10 @@ dsh plugin --profile web add dsh-remote-bridge
93
93
  dsh plugin --profile web add dsh-remote-bridge --registry https://registry.npmmirror.com
94
94
 
95
95
  # ② GitHub Release 的 tarball
96
- dsh plugin --profile web add https://github.com/westanke/dsh-remote-bridge/releases/download/v2.6.0/dsh-remote-bridge-v2.6.0.tgz
96
+ dsh plugin --profile web add https://github.com/westanke/dsh-remote-bridge/releases/download/v2.7.0/dsh-remote-bridge-v2.7.0.tgz
97
97
 
98
98
  # ③ Gitee Release 的 tarball(国内访问更快)
99
- dsh plugin --profile web add https://gitee.com/westanke/dsh-remote-bridge/releases/download/v2.6.0/dsh-remote-bridge-v2.6.0.tgz
99
+ dsh plugin --profile web add https://gitee.com/westanke/dsh-remote-bridge/releases/download/v2.7.0/dsh-remote-bridge-v2.7.0.tgz
100
100
 
101
101
  npx @deepseek-ai/dsh web
102
102
  ```
@@ -112,7 +112,7 @@ npx @deepseek-ai/dsh web
112
112
  从 GitHub Release 下载离线安装包时,可直接安装 tarball:
113
113
 
114
114
  ```sh
115
- dsh plugin --profile web add ./dsh-remote-bridge-v2.6.0.tgz
115
+ dsh plugin --profile web add ./dsh-remote-bridge-v2.7.0.tgz
116
116
  ```
117
117
 
118
118
  ## 第一次使用
@@ -251,9 +251,27 @@ DSH1:eyJ2IjoxLCJlbmRwb2ludHMiOlt7ImxhYmVsIjoi…
251
251
  - 配对、认证和普通请求分别限流。
252
252
  - 审计记录操作类型和对象,但不记录令牌、文件正文或聊天正文。
253
253
  - 新增根目录不会自动授权给已经配对的设备。
254
+ - 供应商 `baseURL` 只能指向公网 http(s) 地址;把「已经存有凭据」的供应商换到新 host
255
+ 还必须同时提供新的 API key —— 因为内核会带着那把 key 去请求这个地址,这是凭据边界,
256
+ 不只是 SSRF。
254
257
 
255
258
  只有来自回环地址的管理界面可以添加根目录、调整设备权限、生成配对码、修改监听设置和永久清理回收站。
256
259
 
260
+ ### 自建 LLM(ollama / LM Studio)
261
+
262
+ 私网、回环、链路本地与 CGNAT 的供应商地址**默认拒绝**。要用本机模型服务,在插件配置里
263
+ 显式放行:
264
+
265
+ ```yaml
266
+ allowPrivateProviderHosts:
267
+ - 127.0.0.1:11434 # 推荐:钉住端口
268
+ - 192.168.1.5 # 裸 host:放行该主机的全部端口
269
+ ```
270
+
271
+ 只接受精确 `host` 或 `host:port`,**不支持 CIDR**。推荐带端口写法:放行 `192.168.1.5`
272
+ 等于放行它上面所有服务,而 ollama 只在 11434。理由与审计字段见
273
+ [docs/project/SECURITY.md](docs/project/SECURITY.md#供应商-baseurl-的地址策略261-起sec-h11)。
274
+
257
275
  ## 文件边界
258
276
 
259
277
  外部接口只接受 `rootId + relativePath`,不会接收服务器绝对路径。路径还会经过以下检查:
@@ -328,6 +346,16 @@ Authorization: Bearer DEVICE_TOKEN
328
346
 
329
347
  **新增的权限是配对前在「远程访问」里勾选的**:勾什么,生成的配对码就带什么;APP 输入配对码后这些权限随设备一起生效。已在用的设备则到「设备」里点它的「权限」修改。
330
348
 
349
+ 默认勾选是五档 —— `chat.read`、`chat.write`、`files.read`、`files.write`、`settings.read`,**刻意不含** `files.delete` 与 `settings.write`。你仍然可以自己勾上;默认值只是不再替你做这个决定。
350
+
351
+ ### 设备名与型号
352
+
353
+ 配对那一刻桥并不知道将来是谁来用这个令牌,所以新设备先得到一个**平台无关**的占位名(`Mobile device`)。设备第一次连上来时,桥会从请求里识别平台与型号,把名字自动换成「平台 · 型号」(比如 `HarmonyOS · ICL-AL10`)。
354
+
355
+ 平台判定优先看客户端上报的 `X-Dsh-Device: <platform>/<model>` 头,没有就从 `User-Agent` 兜底。**型号只认客户端上报**:OkHttp 与 ArkWeb 的默认 UA 里都没有机型,桥不会去猜 —— 猜错的型号比没有型号更糟。
356
+
357
+ 在「设备」页点「权限」可以直接改名。**你手动改过的名字不会再被自动覆盖**;自动生成的名字在设备上报了新身份时仍会更新。设备名只用于显示与排查,不参与任何授权判断。
358
+
331
359
  **撤销一台设备会直接把它从数据库里删除**,不是打个标记留着;它的授权随之清除,但审计记录(谁在什么时候撤了谁)会保留。
332
360
 
333
361
  ## 升级与卸载
@@ -383,22 +411,42 @@ pnpm check
383
411
  pnpm pack
384
412
  ```
385
413
 
386
- `pnpm check` 覆盖类型检查、文档一致性与测试;当前 **67 个测试文件 / 557 个用例**,外加 **8 个浏览器层用例**(Playwright 实测量出的计算样式,含 375px 窄屏契约),全部通过。
414
+ `pnpm check` 覆盖类型检查、文档一致性与测试;当前 **76 个测试文件 / 698 个用例**,外加 **8 个浏览器层用例**(Playwright 实测量出的计算样式,含 375px 窄屏契约),全部通过。
387
415
 
388
- `npm pack` 的产物约 **0.61 MB**(v2.5.2 实测 635,325 字节,SHA-256 `18d36904…c8095`):2.2.0 删除独立页及其编辑器依赖、并关闭 source map 之后从 1.72 MB 降下来,之后随投影透传、权限 BFF 与五维加固小幅增长。
416
+ `npm pack` 的产物约 **0.64 MB**(v2.6.1 实测 669,434 字节,SHA-256 `9bf0189b…2cd35`):2.2.0 删除独立页及其编辑器依赖、并关闭 source map 之后从 1.72 MB 降下来,之后随投影透传、权限 BFF 与五维加固小幅增长。
389
417
 
390
418
  v2.5.0 在 DSH **0.2.1-rc.2** 上完成真机验证:14/14 宿主服务全部可注入、三个 jobs 端点实测通过、
391
419
  权限档位目录返回内核真实三档。开发基线为上游 `dsh-v0.2.1-rc.2`(commit `687f282e8625c6b8d11ff58211a90524be2e4317`),
392
420
  兼容范围见上文 `engines.dsh`。CI 覆盖 Windows、Ubuntu 和 macOS。
393
421
 
394
- **v2.6.0 的验证状态**:70 个测试文件 / 593 个用例全绿、8 个 Playwright 浏览器用例
395
- (含 375px 窄屏契约)、`typecheck`/`docs:check`/构建通过;隧道管理面三轮真机回归均用
396
- React18 + Playwright 真点击台复现并验证(一键出令牌、停止出口、重进设置页锁定态),
397
- 用户真机手工复测通过。
422
+ **v2.7.0 的验证状态**:76 个测试文件 / 698 个用例全绿、8 个 Playwright 浏览器用例
423
+ (含 375px 窄屏契约)、`typecheck`/`docs:check`/构建通过。这一版的四项能力都在
424
+ DSH **0.2.1-rc.3** 隔离实例上**实跑验过**,不是静态推断:插件清单返回
425
+ `loaded: 14 / 16 / problems: 2`、模型目录里 `free:mimo-v2.6-flash-free` 带出
426
+ `ctx=1048576`、`reuseBlank` 的四种语义逐一验过、客户端 bundle 里能找到
427
+ `dsh-remote-bridge-plugins` 与 `sidebarRightTabs`。截图存于 `dsh-021cmp/shots/`。
428
+ 兼容性核对本身也是实测:305 个包逐个 sha256 比对,285 个代码零改动、20 个有实质改动,
429
+ 10 个硬依赖服务的提供方**全部**落在零改动名单,4 个 slot 全保留、删除 0。
398
430
 
399
431
  ## 项目信息
400
432
 
401
- - 当前版本:`v2.6.0`
433
+ - 当前版本:`v2.7.0`
434
+ - **v2.7.0 是对齐 DSH 0.2.1-rc.3 的能力提升版**:四项 —— ①模型目录补上 `contextWindow` / `maxTokens`
435
+ (内核的 `ModelCatalogModel` 只有 id/name/description,容量得另走 `llm.resolveModelInfo`,桥按
436
+ `provider + model` 缓存 10 分钟、失败不缓存、内核自己给了就不覆盖);②插件清单多了右侧栏形态
437
+ (成为 `SidebarRightTabDefinition` 提供方,DSH 0.2.1-rc.3 起该卡片可被 pin;rc.2 上正常显示但
438
+ 没有 pin 与 More 菜单,属预期降级);③`POST /chat/sessions` 新增可选 `reuseBlank`,对齐 0.2.1
439
+ 桌面端「新会话回到那个工作区已有的空白会话」的语义,并跳过 preset 与请求不符的空白;
440
+ ④设置页新增「插件」卡片(清单 / 启停 / 检查更新)与「打开插件列表」按钮(rc.2 无
441
+ `pluginNavigation.openList`,故做特性检测而非版本判断)。
442
+ - **v2.6.1 是安全修复 + 设备身份版**:修掉一个**高危**问题 —— 供应商 `baseURL` 的三个入口
443
+ (新建 / 修改 / 探测模型)此前不做任何校验,持有 `settings.write` 的设备可以把 baseURL
444
+ 指向自己的服务器,内核会带着**该供应商的真实 API key** 去请求 `/models`,等于凭据直接外泄;
445
+ 持久化变体更糟:改完 baseURL 之后正常聊天都会把 key 发过去。现在三道闸门(协议白名单、
446
+ 私网默认拒绝 + `allowPrivateProviderHosts` 显式放行、换 host 且已有凭据时必须同时给新 key),
447
+ 配对默认权限也从七档收到五档(不再默认给 `settings.write` 与 `files.delete`)。
448
+ 另修「设备名永远是『Android 设备』」:桥现在从 `X-Dsh-Device` 头(UA 兜底)识别平台与型号,
449
+ 自动把占位名换成「平台 · 型号」,并新增改名通道(手动改过的名字永不被自动覆盖)。
402
450
  - **v2.6.0 是通用设置面 + IM 入口版**:新增「按插件划分的设置命名空间」两个端点(手机端照 schema 自建表单,新装插件无需改 App),以及「人已出门、电脑还锁着」时用 IM 一句话开隧道并收回配对配置的双入口(宿主命令 `/tunnel` + 工具 `open_tunnel_config`);另加一键清理 N 天未使用设备、移除审计页,并把「激活期降级保护」补上(apply 尾部抛错不再拆掉整条插件上下文)。
403
451
  - **v2.5.2 是全量完善版**:落地五维审计(安全/功能/性能/界面/按钮反馈)——含高危的
404
452
  `debug/host-services` 免鉴权信息泄露修复、限流双桶、广播背压、弱 ETag、审计保留策略等,
@@ -1,7 +1,7 @@
1
1
  asyncapi: 3.0.0
2
2
  info:
3
3
  title: DeepSeek Harness Mobile Events
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  description: |
6
6
  Live file and authorized DSH chat events. Reconnect clients must refresh
7
7
  REST state; unbounded replay is not provided.
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: DeepSeek Harness Mobile API
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  description: Versioned file and chat BFF for mobile and third-party DSH clients. HTTP and HTTPS are both supported.
6
6
  servers:
7
7
  - url: http://127.0.0.1:3090/api/v1
@@ -24,7 +24,7 @@ paths:
24
24
  properties:
25
25
  ok: { type: boolean, const: true }
26
26
  version: { type: string, const: v1 }
27
- pluginVersion: { type: string, const: 2.6.0 }
27
+ pluginVersion: { type: string, const: 2.7.0 }
28
28
  /debug/host-services:
29
29
  get:
30
30
  operationId: hostServices
@@ -506,7 +506,16 @@ paths:
506
506
  '403': { $ref: '#/components/responses/Error' }
507
507
  post:
508
508
  operationId: createCustomProvider
509
- description: Creates a fully custom llm-pi-ai provider using the protocols reported by ProviderSettings.customProvider.
509
+ description: |
510
+ Creates a fully custom llm-pi-ai provider using the protocols reported by
511
+ ProviderSettings.customProvider.
512
+
513
+ `baseURL` must be an absolute http(s) URL. Private, loopback, link-local and
514
+ CGNAT destinations are rejected with `403 PROVIDER_BASE_URL_FORBIDDEN` unless the
515
+ deployment lists the host in `allowPrivateProviderHosts` (exact `host` or
516
+ `host:port`, no CIDR). The kernel sends the provider's stored API key to this
517
+ address, so the check is what keeps a paired device from redirecting credentials.
518
+ See SECURITY.md ("供应商 baseURL 的地址策略").
510
519
  requestBody:
511
520
  required: true
512
521
  content:
@@ -519,6 +528,7 @@ paths:
519
528
  application/json:
520
529
  schema: { $ref: '#/components/schemas/ProviderSettings' }
521
530
  '400': { $ref: '#/components/responses/Error' }
531
+ '403': { $ref: '#/components/responses/Error' }
522
532
  '409': { $ref: '#/components/responses/Error' }
523
533
  /settings/plugins:
524
534
  get:
@@ -649,7 +659,15 @@ paths:
649
659
  schema: { type: string }
650
660
  patch:
651
661
  operationId: updateProvider
652
- description: Updates provider settings and optionally writes an API key to the DSH credential store.
662
+ description: |
663
+ Updates provider settings and optionally writes an API key to the DSH credential store.
664
+
665
+ `baseURL` goes through the same address policy as creation. In addition, moving a
666
+ provider that already holds a credential to a different host requires supplying a
667
+ new `apiKey` in the same patch (`403 PROVIDER_BASE_URL_REPOINT_FORBIDDEN`) —
668
+ otherwise a paired device could point a live key at its own public domain, which
669
+ the private-address rule cannot catch. Changing models, the display name, or the
670
+ path within the same host is unaffected.
653
671
  requestBody:
654
672
  required: true
655
673
  content:
@@ -675,6 +693,11 @@ paths:
675
693
  /settings/providers/{providerId}/discover:
676
694
  post:
677
695
  operationId: discoverProviderModels
696
+ description: |
697
+ Fetches `GET {baseURL}/models` through the kernel, carrying the provider's stored
698
+ credential. `baseURL` here is a temporary override that is NOT persisted, so a
699
+ rejected address never reaches the config — but it does reach the network unless
700
+ the address policy allows it. Same rules as creation.
678
701
  parameters:
679
702
  - name: providerId
680
703
  in: path
@@ -702,6 +725,8 @@ paths:
702
725
  models:
703
726
  type: array
704
727
  items: { $ref: '#/components/schemas/ProviderModel' }
728
+ '400': { $ref: '#/components/responses/Error' }
729
+ '403': { $ref: '#/components/responses/Error' }
705
730
  /chat/sessions:
706
731
  get:
707
732
  operationId: listChatSessions
@@ -747,6 +772,16 @@ paths:
747
772
  path: { $ref: '#/components/schemas/WirePath' }
748
773
  sessionId: { type: string }
749
774
  agentPreset: { type: string }
775
+ reuseBlank:
776
+ type: boolean
777
+ default: true
778
+ description: |
779
+ Only consulted when `sessionId` is absent. When true (the default) the
780
+ bridge first looks for an existing **blank** session at the requested
781
+ location and reuses it, mirroring the DSH 0.2.1 desktop "New Session"
782
+ behaviour; when false it always mints a fresh session. A blank whose
783
+ recorded `agentPreset` contradicts a requested one is skipped rather
784
+ than reused. Clients that omit this field get the desktop semantics.
750
785
  clientRequestId: { type: string, maxLength: 200 }
751
786
  responses:
752
787
  '201': { description: DSH session created or idempotently returned. }
@@ -1412,6 +1447,28 @@ components:
1412
1447
  rootIds:
1413
1448
  type: array
1414
1449
  items: { type: string }
1450
+ platform:
1451
+ type: string
1452
+ description: >-
1453
+ Platform the device reported, or the one inferred from its
1454
+ User-Agent when it reported nothing. Absent for devices that never
1455
+ connected since the bridge started collecting it. Informational
1456
+ only — it is client-declared and never takes part in authorization.
1457
+ enum: [android, harmonyos, ios, ipados, web, windows, macos, linux]
1458
+ model:
1459
+ type: string
1460
+ description: >-
1461
+ Model the device reported. Often absent: neither okhttp nor ArkWeb
1462
+ puts a model in its default User-Agent, and the bridge deliberately
1463
+ does not guess — a wrong model is worse than no model.
1464
+ nameSource:
1465
+ type: string
1466
+ description: >-
1467
+ Where `name` came from. `default` (pairing placeholder) and
1468
+ `detected` (auto-generated from the reported identity) may still be
1469
+ replaced when the device reports a different identity; `declared`
1470
+ means a human set it and it is never overwritten automatically.
1471
+ enum: [default, detected, declared]
1415
1472
  FileEntry:
1416
1473
  type: object
1417
1474
  required: [name, path, kind, size, modifiedAt, writable]
@@ -46,6 +46,12 @@ data class DeviceView(
46
46
  val name: String,
47
47
  val scopes: List<String>,
48
48
  val rootIds: List<String>,
49
+ /** 平台:`android` / `harmonyos` / `ios` / …。老桥与从未连过的设备没有这个字段。 */
50
+ val platform: String? = null,
51
+ /** 型号。桥刻意不猜(okhttp/ArkWeb 默认 UA 里没有机型),所以多数时候是 null。 */
52
+ val model: String? = null,
53
+ /** `name` 的来源:`default` / `detected` / `declared`。null 等价于 `declared`。 */
54
+ val nameSource: String? = null,
49
55
  )
50
56
 
51
57
  @Serializable
@@ -482,14 +488,21 @@ class DshWorkspaceClient(
482
488
  ).models
483
489
  }
484
490
 
491
+ /**
492
+ * 在工作区里新建会话。
493
+ *
494
+ * [reuseBlank] 省略时由桥按桌面语义处理(复用该位置已有的空白会话);传 `false`
495
+ * 可强制新建一个全新会话。老客户端不传这个参数,行为与之前一致。
496
+ */
485
497
  fun createSessionInWorkspace(
486
498
  workspaceId: String,
487
499
  clientRequestId: String,
488
500
  agentPreset: String? = null,
501
+ reuseBlank: Boolean? = null,
489
502
  ): JsonElement {
490
503
  val body = json.encodeToString(
491
504
  WorkspaceSessionRequest.serializer(),
492
- WorkspaceSessionRequest(workspaceId, agentPreset, clientRequestId),
505
+ WorkspaceSessionRequest(workspaceId, agentPreset, clientRequestId, reuseBlank),
493
506
  )
494
507
  return executeJsonElement("chat/sessions", "POST", body)
495
508
  }
@@ -800,6 +813,7 @@ class EventSubscription internal constructor(
800
813
  val workspaceId: String,
801
814
  val agentPreset: String? = null,
802
815
  val clientRequestId: String,
816
+ val reuseBlank: Boolean? = null,
803
817
  )
804
818
  @Serializable private data class SendMessageRequest(val text: String, val mode: String, val clientRequestId: String)
805
819
  @Serializable private data class ErrorEnvelope(val error: ApiErrorBody)