dsh-plugin-weapp-gateway 0.8.51 → 0.8.54

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/PROTOCOL.md +33 -12
  3. package/README.en.md +410 -0
  4. package/README.md +16 -0
  5. package/README.zh-CN.md +425 -0
  6. package/cordis.patch.yml +2 -0
  7. package/docs/agent-team-app-integration.md +76 -55
  8. package/docs/android-connectors-alignment.md +73 -0
  9. package/docs/dsh-0.2.2-rc.1-mobile-integration.md +269 -0
  10. package/docs/dsh-0.2.2-rc.3-compatibility-audit.md +145 -0
  11. package/docs/file-cards-mobile-integration.md +111 -0
  12. package/docs/file-changes-app-integration.md +277 -0
  13. package/docs/generated-images-mobile-integration.md +125 -0
  14. package/docs/iphone-connector-actions.md +69 -0
  15. package/docs/iphone-map-markers.md +41 -0
  16. package/docs/iphone-maps-connectors.md +56 -0
  17. package/docs/iphone-music-cards.md +28 -0
  18. package/docs/map-app-adapters.md +57 -0
  19. package/docs/phone-connectors-implementation.md +105 -0
  20. package/docs/phone-connectors.md +91 -0
  21. package/docs/readme/README.de.md +404 -0
  22. package/docs/readme/README.es.md +404 -0
  23. package/docs/readme/README.fr.md +404 -0
  24. package/docs/readme/README.ja.md +404 -0
  25. package/docs/readme/README.ko.md +404 -0
  26. package/docs/readme/README.pt-BR.md +404 -0
  27. package/lib/client.js +112 -29
  28. package/lib/cloudflare-tunnel.mjs +6 -2
  29. package/lib/cloudflared-binary.mjs +10 -24
  30. package/lib/device-tool-validation.mjs +173 -0
  31. package/lib/device-tools.mjs +119 -0
  32. package/lib/devices.js +29 -7
  33. package/lib/dsh-host-adapter.mjs +169 -36
  34. package/lib/dsh-runtime-version.mjs +22 -0
  35. package/lib/index.mjs +281 -103
  36. package/lib/logging.mjs +16 -0
  37. package/lib/message-text.mjs +51 -0
  38. package/lib/phone-request-sources.mjs +91 -0
  39. package/lib/phone-tools.mjs +248 -0
  40. package/lib/plugin-management.mjs +24 -0
  41. package/lib/schedule-management.mjs +130 -0
  42. package/lib/session-target.mjs +16 -0
  43. package/lib/tool-images.mjs +32 -0
  44. package/lib/web-restart.mjs +11 -8
  45. package/lib/workspace-changes.mjs +162 -0
  46. package/package.json +8 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # 版本记录
2
+
3
+ ## 0.12.1
4
+
5
+ 版本准备日期为 2026 年 11 月 14 日,当前状态为待发布。
6
+
7
+ ### DSH 0.2.2-rc.3 兼容性
8
+
9
+ - Host 适配基线更新至 RC.3;修复新版团队投影不含 `members` 导致的 `internal: invalid team projection`。查询、历史/会话快照、控制基线、批量和旧式投影统一兼容,保留 `enabled/tasks/failure` 与严格类型校验。
10
+ - 适配新版子代理继续对话与 `interruptByUser` 中断接口;写入前验证直接父子地址,RC.1 宿主保留旧请求路径。
11
+ - 新增 `agent-team-mode-v1`,支持根会话开启/关闭 Team 模式,写入后读取宿主投影确认结果;保留历史任务和子代理,旧 RC.1 不提供此写能力。App 按 capability 接入。
12
+ - 更新团队 App 接入指南:成员目录、enabled 空团队、ownerId/name 匹配与多层身份路径。移动协议仍为 3,Session 格式仍为 4;详细升级评估、移动端工作项及验证边界见 [RC.3 兼容性说明](docs/dsh-0.2.2-rc.3-compatibility-audit.md)。
13
+
14
+ ## 0.12.0
15
+
16
+ 版本准备日期为 2026 年 11 月 5 日。
17
+
18
+ ### 运行环境与兼容性
19
+
20
+ - Host 适配基线更新至 DSH 0.2.2-rc.1,最低 Node.js 版本提高至 24.9。
21
+ - 适配 Host 的 `changes[]` 批量投影,恢复任务、目标、轮次大纲、团队、子代理和待处理消息的实时同步。
22
+ - 适配新版图片读取参数,通过会话历史定位完整附件引用,支持用户图片、工具生图、PTC 图片及深历史读取,并保留会话范围校验。
23
+ - Session 持久格式为 V4,移动端通过新增 capability 发现对应能力。
24
+
25
+ ### 新增功能
26
+
27
+ - `message-quotes-v1` 支持有序文字与引用片段。引用按 DSH Web 的 Markdown 规则保存,实时、历史和排队消息提供紧凑预览数据,排队消息支持引用编辑。
28
+ - 普通消息的显式 `requestId` 传递至 Host,用户实时消息提供对应 ID,便于移动端关联发送确认与历史回显。
29
+ - `schedule-management-v2` 提供宿主级分页、任务详情、创建、修改、暂停、恢复、立即执行和清理已结束任务,支持既有会话、首次新建并复用会话、每次新建会话三个投递目标。
30
+ - 定时任务编辑通过 `expectedUpdatedAt` 检测并发冲突,旧移动端的列表、编辑和删除请求通过适配层转换。
31
+ - `plugin-updates-v1` 提供可更新版本查询、插件更新、更新进度、旧版本恢复结果及 Markdown 详情读取。
32
+ - 插件“通用设置”新增界面语言选项,默认跟随 DSH 并即时更新。可手动选择简体中文、English 和日本語,偏好保存在当前浏览器。DSH 其他语言使用英文显示。
33
+
34
+ ### 移动端接入
35
+
36
+ 聊天引用、宿主级任务与插件更新页面按 `hello.capabilities` 接入。字段、请求与响应示例、冲突处理、断线恢复和双平台验收用例见 [DSH 0.2.2-rc.1 移动端适配说明](docs/dsh-0.2.2-rc.1-mobile-integration.md)。
37
+
38
+ ### 验证
39
+
40
+ 网关完整回归、官方 0.2.2-rc.1 发布包的隔离契约检查以及 npm/pnpm 安装检查已通过。语言功能通过 28 项界面检查,并验证了真实 DSH LocaleRuntime 的订阅与切换。真实 Android/iOS 页面、插件更新与任务触发需完成端到端联调。
package/PROTOCOL.md CHANGED
@@ -10,6 +10,8 @@
10
10
 
11
11
  ---
12
12
 
13
+ 本次新增 `message-quotes-v1`、`schedule-management-v2` 和 `plugin-updates-v1`。完整帧示例、引用回放、任务 CAS、插件更新恢复及 App 验收见 [DSH 0.2.2-rc.1 移动端适配说明](docs/dsh-0.2.2-rc.1-mobile-integration.md)。
14
+
13
15
  ## 1. 通用约定
14
16
 
15
17
  ### 客户端 → 服务端(请求帧)
@@ -577,7 +579,7 @@ iOS 将本地图片原始文件数据编码成**标准 Base64**,不要包含 `
577
579
 
578
580
  支持的 `mediaType`:`image/png`、`image/jpeg`、`image/webp`、`image/gif`。宿主会验证 Base64、文件签名、格式、尺寸、像素数、单图大小、图片数量和总大小;声明 MIME 与真实字节不一致会拒绝整条消息,且不会产生部分附件。
579
581
 
580
- 当前 DSH 默认最多 20 张图片、单图约 3.5 MiB、单条消息图片总计 100 MiB,实际值以最近一次 `history.projections.values.imageLimits` 为准。WebSocket 单帧上限默认 144 MiB,用于容纳 100 MiB 图片经 Base64 后的 JSON 请求;反向代理也必须允许相应大小的 WebSocket 帧。
582
+ 当前 DSH 默认最多 20 张图片、单图 50 MiB、单条消息图片总计 100 MiB,实际值以最近一次 `history.projections.values.imageLimits` 为准。WebSocket 单帧上限默认 144 MiB,用于容纳 100 MiB 图片经 Base64 后的 JSON 请求;反向代理也必须允许相应大小的 WebSocket 帧。
581
583
 
582
584
  Swift 编码示例:
583
585
 
@@ -622,6 +624,13 @@ let image = [
622
624
 
623
625
  ```json
624
626
  { "kind": "session-queue", "sessionId": "session-abc", "items": [] }
627
+
628
+ 客户端也可以主动拉取当前会话队列(小程序在打开会话、发送排队消息、回到前台时使用;控制流推送丢失时靠它兜底):
629
+
630
+ → { "type": "session-queue", "sessionId": "session-abc", "requestId": "rq-1" }
631
+ ← { "kind": "session-queue", "sessionId": "session-abc", "items": [...], "requestId": "rq-1" }
632
+
633
+ 网关直接读取 Host 的 projections.values.inbox 生成 items;旧版 Host 没有该投影时返回空数组。
625
634
  ```
626
635
 
627
636
  - `session-queues.queues` 是全量快照,客户端必须整体替换所有 Session 的本地队列;快照里消失的 Session 也要清除。
@@ -673,6 +682,8 @@ let image = [
673
682
  | `session-rename` | `sessionId`, `title` | 写入用户指定的持久化 Session 名称 |
674
683
  | `history` | `sessionId`, `beforeSeq?`, `historyFormatVersion?`, `maxMessages?`, `maxBytes?`, `view?` | 历史事件页(见下) |
675
684
  | `attachment` | `sessionId`, `attachmentId` | 读取历史中属于该会话的图片字节 |
685
+ | `workspace-changes-summary` | `sessionId`, `seq`, `requestId` | 整轮文件改动清单和增删统计;需 `workspace-changes-v1` |
686
+ | `workspace-changes-diff` | `sessionId`, `seq`, `index`, `requestId` | 按清单原始下标读取带行号的 diff;需 `workspace-changes-v1` |
676
687
  | `file-list` | `sessionId`, `path?`, `requestId?` | 列出会话工作目录内的一层文件与文件夹 |
677
688
  | `file-download-open` | `sessionId`, `path`, `requestId` | 打开一个工作目录内的普通文件下载 |
678
689
  | `file-download-read` | `transferId`, `offset` | 拉取下载的下一块字节 |
@@ -815,7 +826,7 @@ iOS 用 `Data(base64Encoded:)` 解码并按 `attachment.mediaType` 渲染,建
815
826
  - 客户端必须严格使用服务端返回块的 `offset + 已解码 data 字节数` 作为下一次 `offset`;当前版本不支持断线续传。请先写入临时文件,收到 `eof: true` 后校验整文件 SHA-256,再原子重命名为最终文件。
816
827
  - 每个 `transferId` 仅归属创建它的 WebSocket 连接。连接关闭、`file-download-cancel`、空闲 2 分钟、传完最后一块或插件卸载都会关闭文件句柄;取消成功返回 `{ "kind":"file-download-cancelled", "transferId":"..." }`。
817
828
  - 默认每块为 512 KiB、同时最多 4 个下载、单个文件最多 512 MiB。部署方可用 `fileDownloadChunkBytes`、`fileDownloadMaxTransfers`、`fileDownloadMaxBytes`、`fileDownloadIdleMs` 调整;`fileDownloadsEnabled: false` 会关闭该能力,且 `hello.capabilities` 不再包含 `file-downloads`。
818
- - 绝对路径、空路径(`file-download-open`)、`..` 路径段、NUL 字符、工作目录外的符号链接、目录和其他非普通文件都会被拒绝。`file-list` 不返回符号链接,避免客户端误认为其可下载。
829
+ - `file-download-open` 接受 `file-resolve` 返回的相对或绝对路径。空路径、`..` 路径段、NUL、目录及非普通文件仍被拒绝;外部文件仅可经 Host 授权读取。`file-list` 仍拒绝绝对路径、工作区外目录和符号链接。旧版 Host 缺少 `workspaceFiles` 时保持工作区内功能,不能读取外部文件。
819
830
 
820
831
  ### 文件引用解析(`file-resolve`,`file-references-v1`)
821
832
 
@@ -1256,21 +1267,26 @@ DSH Web 的“深度求索中,用时 22 秒 ···”是客户端文案,不
1256
1267
 
1257
1268
  ---
1258
1269
 
1259
- ## 17. 定时任务(DSH 0.1.7-rc.2)
1270
+ ## 17. 定时任务(DSH 0.2.2-rc.1)
1260
1271
 
1261
- 以下请求走控制连接,网关映射到 Host `schedule` Remote namespace。Host 未启用定时任务时返回统一的 `kind: error`,`requestType` 保留原请求类型。定时任务与第 6 节的 Session `todos` 是不同的数据源。
1272
+ 以下请求走控制连接,Host 未启用定时任务时返回统一错误。`schedule-management-v2` 使用宿主级任务模型,响应为平铺字段并回显可选 `requestId`。
1262
1273
 
1263
- | 请求 type | 参数 | 成功响应 |
1274
+ | 请求 | 参数 | 响应 |
1264
1275
  |---|---|---|
1265
- | `schedule-catalog` | — | `kind: schedule-catalog`, `items`: 全宿主活动与已结束提醒,包含原 `sessionId`、`status` 和可选最近投递回执 |
1266
- | `schedule-list` | `sessionId` | `kind: schedule-list`, `sessionId`, `items`: 当前会话活动提醒 |
1267
- | `schedule-history` | `sessionId`, `id`, `limit` 1–100, `before?` | `kind: schedule-history`, `records`(从新到旧)、`retention`、`nextBefore?`;任务或游标未找到时在成功帧中返回 `code` |
1268
- | `schedule-update` | `sessionId`, `id`, 完整的 `expected`, `title?`, `prompt?`, `change?`, `requestId?` | `kind: schedule-update`, `updated`, `record`;并发冲突、已结束或未找到时返回 `updated:false` 与 `code` |
1269
- | `schedule-delete` | `sessionId`, `id`, `requestId?` | `kind: schedule-delete`, `deleted`;未找到时返回 `deleted:false` 与 `code` |
1276
+ | `schedule-catalog` | `requestId?` | `items` 全量目录 |
1277
+ | `schedule-list` | `active?`, `limit?` 1–500, `offset?`, `requestId?` | `items/shown/total/limit/offset` |
1278
+ | `schedule-view` | `id`, `requestId?` | 当前任务或 `id/code` |
1279
+ | `schedule-create` | `title/prompt/timing`, `target?`, `requestId?` | 创建后的任务 |
1280
+ | `schedule-edit` | `id/action/expectedUpdatedAt`, `patch?`, `requestId?` | 更新后的任务,或 `deleted:true`,或 `id/code` |
1281
+ | `schedule-history` | `id`, `limit` 1–100, `before?`, `requestId?` | `records/retention/nextBefore?` 等 |
1282
+ | `schedule-run` | `id`, `requestId?` | 任务或 `id/code` |
1283
+ | `schedule-delete-inactive` | `confirm:true`, `requestId?` | `deleted` 数量 |
1284
+
1285
+ `schedule-edit.action` 为 `update/delete`。修改时 `patch` 支持 `title/prompt/timing/target/active`。`expectedUpdatedAt` 必须使用读取到的 `updatedAt`,缺失时传 `null`。`schedule_conflict` 时保留草稿并重新读取,复核后再提交。
1270
1286
 
1271
- `expected` 必须是编辑前从 `schedule-list` 或 `schedule-catalog` 取得的完整任务记录,`id` 必须匹配;不要只传 id 或重建部分字段。网关会去掉目录行额外的 `sessionId`、`status`、`lastDelivery` 元数据后调用 Host。`change` 使用 Host 的 `at`、`every`、`daily`、`weekly`、`cron` 判别结构。更新与删除只对原会话绑定生效;`requestId` 若提供会原样回显。删除会同时移除该任务的投递记录,不撤回已入队的消息。
1287
+ 旧 `schedule-list(sessionId)` 继续返回该会话关联的活动任务,与宿主级分页参数互斥。旧 `schedule-update(sessionId?, id, expected, title?, prompt?, change?)` 转换为带 CAS 的编辑,`expected` 无 revision 时比对当前记录。旧 `schedule-delete(sessionId?, id, expectedUpdatedAt?)` 转换为删除。旧帧的 `sessionId` 若存在则继续限定任务关联范围。
1272
1288
 
1273
- rc.2 没有 `schedule/create` Remote 方法。新提醒由 Agent 的 `schedule_create` 工具创建;到期提醒作为 `source.kind: schedule` 的消息进入原 Session。Host 的无载荷 `schedule/changed` 被投影为移动端 `schedule-changed`;实现定时任务管理页面的客户端应在收到通知、重连或完成更新/删除后重新查询目录。当前移动端只接入协议请求、解码与变更帧识别,尚未提供管理页面。`hello.capabilities` 中的 `schedule-management` 表示网关支持这些请求,实际使用仍取决于 Host 是否启用定时任务。
1289
+ Host `schedule/changed` 转为无载荷 `schedule-changed`。重连、通知或写操作结束后刷新目录与详情。完整目标、规则、冲突、旧客户端转换和示例见 [移动端适配说明](docs/dsh-0.2.2-rc.1-mobile-integration.md)。
1274
1290
 
1275
1291
  ## 18. 插件管理(DSH 0.2.0-rc.2)
1276
1292
 
@@ -1280,6 +1296,9 @@ rc.2 没有 `schedule/create` Remote 方法。新提醒由 Agent 的 `schedule_c
1280
1296
  |---|---|---|
1281
1297
  | `plugin-catalog` | `requestId` | 同名 kind;`managementAvailable`、`bundles`(每项含 `experimental`)、`plugins`、`officialItems`、`settingsWritable` |
1282
1298
  | `plugin-registries` | `requestId` | 同名 kind;`registry`、`fallbackRegistries`、`resolved` |
1299
+ | `plugin-versions` | `requestId`, `name`, `registry?` | 同名 kind;`result` 为版本列表或业务拒绝 |
1300
+ | `plugin-detail` | `requestId`, `name`, `language` | 同名 kind;`result` 为 Markdown 详情或 none |
1301
+ | `plugin-update` | `requestId`, `name`, `version`, `registry?` | `plugin-update-result`;`result` 含最后阶段结果和可选 restore |
1283
1302
  | `plugin-inspect` | `requestId`, `spec`, `registry?` | `plugin-inspection`;`result` 为 accepted/refused 检查结果 |
1284
1303
  | `plugin-install` | `requestId`, `spec`, `enabled?`, `registry?`, `approvedBuilds?` | `plugin-install-result`;`result` 为 Host `ChangeResult` |
1285
1304
  | `plugin-install-status` / `plugin-install-cancel` | `requestId`, `installId` | 同名 kind;`result` 为安装结果/null 或取消状态 |
@@ -1292,6 +1311,8 @@ rc.2 没有 `schedule/create` Remote 方法。新提醒由 Agent 的 `schedule_c
1292
1311
 
1293
1312
  Host 的 `plugin-manager/changed` 转为 `plugins-changed`(含 `reason`),`settings/document-updated` 转为 `plugin-settings-changed`(含 `ns`、`revision`)。`plugin-manager/install-state` 和 `plugin-manager/install-log` 只发给发起安装的连接,分别转为 `plugin-install-state` 和 `plugin-install-log`;它们的 `requestId` 就是原安装请求 ID。断线后用新的请求 ID 调 `plugin-install-status`,`installId` 填原安装 ID;切勿直接重复安装。关闭/卸载网关插件自身可能先断线,再由 DSH Web/CLI 恢复。
1294
1313
 
1314
+ 新增 `plugin-updates-v1` 的更新进度、两层结果、恢复状态与断线核实,以及详情读取,见 [0.2.2-rc.1 移动端适配说明](docs/dsh-0.2.2-rc.1-mobile-integration.md)。
1315
+
1295
1316
  详细字段、官方/第三方页面分组、安装进度、配置 schema、错误处理和 DSH Mobile 验收步骤见 [插件管理对接方案](docs/dsh-0.2.0-rc.2-plugin-management-mobile-integration.md)。
1296
1317
 
1297
1318
  ---
package/README.en.md ADDED
@@ -0,0 +1,410 @@
1
+ **English** · [简体中文](README.zh-CN.md) · [日本語](docs/readme/README.ja.md) · [한국어](docs/readme/README.ko.md) · [Español](docs/readme/README.es.md) · [Français](docs/readme/README.fr.md) · [Deutsch](docs/readme/README.de.md) · [Português (Brasil)](docs/readme/README.pt-BR.md)
2
+
3
+ > Some linked protocol and integration documents are currently available only in Chinese.
4
+
5
+ <p align="center">
6
+ <img src="docs/assets/whale-girl-ios-app-promo-16x9.png" alt="Whaleness mobile client and Mobile Gateway" width="100%">
7
+ </p>
8
+
9
+ # dsh-plugin-mobile-gateway
10
+
11
+ > **v0.12.1 · pending release** — Targets DSH 0.2.2-rc.3. Fixes team projections without members and subagent continuation/interrupt compatibility; adds per-session Team mode control. Requires Node.js 24.9+. See the [changelog](CHANGELOG.md) and [RC.3 compatibility and mobile guide](docs/dsh-0.2.2-rc.3-compatibility-audit.md) (Chinese).
12
+
13
+ A third-party mobile gateway for DeepSeek Harness with device authentication. Supports sessions and live events; queued-message synchronization, editing, deletion, and Steer; bidirectional session archiving and renaming; stopping and resuming generation; task lists and the current Goal; server-driven command and skill menus; human-in-the-loop workflows; and image and file transfers. After installation, a Mobile Devices entry appears in the Harness WebUI sidebar for enabling the gateway, generating pairing QR codes, and managing trusted devices.
14
+
15
+ > RC.3 team projections and subagent controls are now supported. See the [compatibility audit and mobile follow-up](docs/dsh-0.2.2-rc.3-compatibility-audit.md) (Chinese).
16
+
17
+ > The current source targets **DSH 0.2.2-rc.3**, requires the Connection Peer interface, and uses Session format 4. Older history cursors require a fresh baseline.
18
+ >
19
+ > v0.12.0 adds ordered chat quotes, Host-wide schedules, plugin updates and details, DSH language synchronization, and compatibility for batched projections and image reads. Requires Node.js 24.9+. See the [mobile integration guide](docs/dsh-0.2.2-rc.1-mobile-integration.md).
20
+ >
21
+ > Live output now uses separate `assistant-stream` frames. Mobile clients must update subscriptions, caches, and pagination according to the [rc.2 integration guide](docs/dsh-rc2-mobile-integration.md). These changes are not yet released.
22
+ >
23
+ > v0.11.1: chunked file uploads with SHA-256 verification, progress acknowledgments, cancellation, and disconnect cleanup. Reuses official DSH attachment storage and session-scoped credentials for sending files with messages and resolving live/history file references. Clients must implement `file-upload-v1`; see the [file upload integration guide](docs/file-upload-app-integration.md).
24
+ >
25
+ > v0.11.0: Agent teams and subagent conversations, including members, shared task boards, nested subagent directories, live runtime status, independent history, view switching, continued conversations, image input, and stopping subagents. Clients must discover capabilities; see the [Agent team integration guide](docs/agent-team-app-integration.md).
26
+ >
27
+ > v0.10.4: session-list projections now retain only titles and projection cut points, avoiding timeouts when many sessions pass through public tunnels. Session metadata and full history projections remain available; existing mobile clients need no changes.
28
+ >
29
+ > v0.10.3: DSH 0.2.1-rc.2 compatibility adds Connection Peer to Remote calls and live subscriptions, fixes `Cannot read properties of undefined (reading 'signal')`, and releases the Peer when the gateway stops. The mobile protocol is unchanged.
30
+ >
31
+ > v0.10.2: forwards file-card events and safely resolves file references, reusing chunked downloads for mobile file cards and previews of file links in text. See the [file card and preview guide](docs/file-cards-mobile-integration.md).
32
+ >
33
+ > v0.10.1: integrates official voice input with model preparation/status, mobile audio transcription, cancellation, and cleanup on disconnect. Recognition uses the official speech Remote; the gateway does not bundle ASR models.
34
+ >
35
+ > v0.10.0: responsive, centered Mobile Devices window with the host's light/dark theme; consistent dropdowns and connection highlights; a separate animated pairing QR dialog; dismissible restart reminders per gateway instance; online-only trusted devices by default, expandable offline devices, mobile device names and duplicate numbering; automatic application of Tunnel mode changes and explicit saving of named Tunnel settings.
36
+ >
37
+ > v0.9.0: DSH 0.2.0-rc.2 plugin management; panel controls for Cloudflare Quick/named Tunnels using verified `cloudflared` in the plugin's private cache; LAN/public pairing guidance; gateway restart and DSH Web stop actions without opening another browser tab.
38
+ >
39
+ > v0.7.3: adjusts arrow spacing in the gateway-mode dropdown.
40
+ >
41
+ > v0.7.2: separate conversation/control connections, empty sessions, stop/resume generation, queued-message sync/edit/delete/Steer, and bidirectional session archiving and renaming.
42
+
43
+ The plugin’s General → Interface language option follows DSH by default and updates immediately. You can select 简体中文, English or 日本語 for this browser. Other DSH languages use English, and existing manual preferences are retained.
44
+
45
+ ## Protocol and DSH Compatibility Layer
46
+
47
+ Mobile clients use this project's `dsh-mobile-v1`, not DSH's internal Remote protocol. A separate Host Adapter connects to the DSH 0.2.2-rc.3 Remote Gateway. Namespaces such as Session, Workspace, Settings, Commands, Goals, Schedule, Permission Presets, and Plugin Manager, together with their strict parameters, are confined to that adapter. See the [RC2 plugin management integration plan](docs/dsh-0.2.0-rc.2-plugin-management-mobile-integration.md) for request frames and mobile UI design.
48
+
49
+ DSH 0.2.1-rc.2 requires `peer` on every Remote call. The gateway creates a local-user Peer with `ctx.connection.createPeer()` and disposes of it with the plugin. The Host Adapter injects it into regular requests, initial reads, and live subscriptions; mobile clients cannot choose the caller identity. Questions and approvals still use the gateway's Host listeners. Older gateways that omit it fail with `Cannot read properties of undefined (reading 'signal')`. After upgrading DSH, reinstall this source version and restart `dsh web`; the phone protocol needs no change.
50
+
51
+ Verify this contract against a locally installed official DSH (real Gateway/Connection, test business services, no user sessions read or written):
52
+
53
+ ```bash
54
+ DSH_INSTALL_ROOT=/absolute/path/to/@deepseek-ai/dsh node test/host-official.test.mjs
55
+ ```
56
+
57
+ Pairing authentication and `dsh-mobile-v1` / `hello.protocol = 3` are unchanged. Live tokens no longer consume persistent event `seq` values: explicitly subscribe with `assistantStream: true` to receive an atomic `session-snapshot` and separate deltas. Regular `event` frames contain only persistent events. Clients without the new subscription receive persistent messages only.
58
+
59
+ History responses include `historyFormatVersion` and `cursor`. Clear history caches and install a fresh baseline when the format changes. Pagination with `beforeSeq` or a fork with `atSeq` must also send `historyFormatVersion: 4`.
60
+ See the [rc.2 mobile integration guide](docs/dsh-rc2-mobile-integration.md) for current integration and acceptance checks, and the [Remote Gateway refactoring plan](docs/remote-gateway-refactor-plan.md) for earlier migration records.
61
+
62
+ - WebSocket: `/ws/mobile`
63
+ - LAN: `ws://<局域网 IP>:3081/ws/mobile`
64
+ - Public Linux server: `wss://<公网 IP>/ws/mobile`
65
+ - Protocol reference: [PROTOCOL.md](PROTOCOL.md)
66
+
67
+ The current source adds session mode selection: after creating an empty session, a client can query/change its Agent preset until the first conversation turn. Discover `session-agent-preset` and follow the [client integration guide](docs/session-agent-preset-app-integration.md). Client UI integration is required; this source change is not yet released.
68
+
69
+ The current source adds `turn-outline-v1`: forwards the full WebUI turn outline and live updates so clients can show turn markers and question/answer previews and paginate to a turn without loading all message bodies. Reconnecting the control channel or connecting a new device restores the outline baseline; if the Host has no outline, fall back to loaded turns. See the [turn navigation guide](docs/turn-outline-app-integration.md). Client UI integration is separate; not yet released.
70
+
71
+ The current source adds `file-upload-v1`: paired clients upload PDFs, Office files, archives, audio, and other files in chunks over the control connection. SHA-256-verified files enter official DSH attachment storage and are sent with session-scoped credentials. Supports acknowledgments, cancellation, disconnect cleanup, and live/history file references. Uses official WebUI attachment admission rules and never writes to a client-specified host path. See the [file upload guide](docs/file-upload-app-integration.md) for frames, client state machines, limits, and acceptance checks. Client UI integration is separate; not yet released.
72
+
73
+ The current source adds `agent-team-v1` and `subagent-conversations-v1`: member/shared-board queries, nested subagent directories, live team projections and member status, independent subagent history/subscriptions, continued conversations, and stop actions. The [Agent team integration guide](docs/agent-team-app-integration.md) covers target addresses, full JSON examples, board rules, switching/reconnection state machines, errors, and acceptance criteria. These are gateway capabilities; client UI integration is separate. Not yet released.
74
+
75
+ ## Multi-Gateway Phase One (Current Source)
76
+
77
+ Provides a stable `gatewayId`, configurable `gatewayName`, pairing endpoint candidates, and persistent Off / Temporary / Persistent modes. One app can pair independently with gateways on different machines; client-side multi-gateway management must implement the [integration guide](docs/multi-gateway-app-integration.md). No new npm version has been published for this source change.
78
+
79
+ Choose Persistent in Mobile Devices to continue accepting authorized devices across restarts. DSH must remain running, the host awake, and the network reachable. This does not provide automatic discovery or a network relay.
80
+
81
+ Example deployment settings (the mobile-gateway plugin's `config`):
82
+
83
+ ```yaml
84
+ gatewayMode: persistent
85
+ gatewayName: 家里电脑
86
+ requireAuth: true
87
+ endpoints:
88
+ - wss://gateway.example.com/ws/mobile
89
+ - ws://192.168.1.10:3081/ws/mobile
90
+ ```
91
+
92
+ Mode precedence: **saved UI selection > `gatewayMode` > legacy `gatewayEnabled`**. Without a saved selection, legacy `gatewayEnabled: true` means Persistent; false means Off.
93
+
94
+ - Off: disconnects mobile devices immediately and stays off after restart.
95
+ - Temporary: switches off and saves Off if no device connects successfully within 5 minutes by default. After a successful connection it stays on for that run. Restarting in Temporary mode restarts the wait. `gatewayWaitTimeoutMs` allows 30 seconds to 30 minutes.
96
+ - Persistent: no idle waiting timer. Pairing codes still expire after 5 minutes by default; file-transfer timeouts and other independent rules are unchanged.
97
+
98
+ State defaults to `<deviceFile>.gateway.json`, usually `~/.dsh/mobile-gateway-devices.json.gateway.json`, or a configured `gatewayStateFile`. It holds a random UUID v4 identity and user selections, has mode `0600`, and is atomically replaced using a temporary file in the same directory. Corruption fails startup rather than silently generating a new identity. Each running instance needs separate device registry and state files.
99
+
100
+ Keep both files when upgrading or migrating machines. For a new independent gateway clone, do not copy the original identity/state or device registry; generate a new identity and pair again. Do not delete identity files while running to reset modes. To reuse startup configuration, stop the instance, back up state, change only `mode` to `null`, retain `version` and `gatewayId`, then restart.
101
+
102
+ `gatewayName` allows up to 80 characters and defaults to the hostname. `endpoints` supplies up to 16 additional candidates, each at most 2048 characters; pairing also merges preferred, public, and listening LAN addresses and rejects totals above 16. All addresses must reach the same gateway; do not use `0.0.0.0` / `::`. They must be reachable from the phone; use WSS publicly.
103
+
104
+ See the [acceptance report](docs/multi-gateway-phase1-acceptance.md) for tests/manual steps and the [multi-gateway checklist](docs/multi-gateway-todo.md) for scope.
105
+
106
+ ## Companion Android and iOS Client
107
+
108
+ [Whaleness](https://github.com/Clarklevis1995/dsh-mobile) is the independently developed third-party native mobile client paired with this gateway. It supports Android 7.0+ and iOS / iPadOS 16.1+, sharing business logic through Kotlin Multiplatform with Jetpack Compose and SwiftUI/UIKit interfaces. Features include workspaces and sessions, live conversations, Agent teams and shared tasks, file uploads/previews, text selection, Markdown tables, local history/cache management, voice input, approvals, and server-driven command, skill, model, and permission menus. iPhone Duo and wide-screen layouts adapt to orientation and available space. System-dependent effects vary by OS and device. See the client repository for downloads, setup, and current screenshots.
109
+
110
+ > Latest iOS product screenshots: the 1.7.10 image set was captured on October 22–23, 2026; the iPhone Duo set was captured on October 26, 2026. The interface shown is Chinese. [Product screenshot sources](https://github.com/Clarklevis1995/dsh-mobile/blob/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/SOURCES.md) · [Duo screenshot sources](https://github.com/Clarklevis1995/dsh-mobile/blob/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/SOURCES.md).
111
+
112
+ ### iPhone Duo: Landscape, Portrait, and Navigation
113
+
114
+ <table>
115
+ <tr>
116
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home.webp" alt="Unfolded landscape home" width="100%"></a></td>
117
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home-alt.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-home-alt.webp" alt="Landscape home background" width="100%"></a></td>
118
+ </tr>
119
+ <tr>
120
+ <td align="center"><strong>Unfolded landscape home</strong></td>
121
+ <td align="center"><strong>Landscape home background</strong></td>
122
+ </tr>
123
+ <tr>
124
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-settings.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-settings.webp" alt="Landscape settings" width="100%"></a></td>
125
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-conversation.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-conversation.webp" alt="Landscape conversation" width="100%"></a></td>
126
+ </tr>
127
+ <tr>
128
+ <td align="center"><strong>Landscape settings</strong></td>
129
+ <td align="center"><strong>Landscape conversation</strong></td>
130
+ </tr>
131
+ <tr>
132
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-navigation.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/landscape-navigation.webp" alt="Expanded navigation sidebar" width="100%"></a></td>
133
+ <td width="50.00%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/portrait-home.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-26-duo/portrait-home.webp" alt="Unfolded portrait home" width="100%"></a></td>
134
+ </tr>
135
+ <tr>
136
+ <td align="center"><strong>Expanded navigation sidebar</strong></td>
137
+ <td align="center"><strong>Unfolded portrait home</strong></td>
138
+ </tr>
139
+ </table>
140
+
141
+ ### Teams, Attachments, and Local Storage
142
+
143
+ <table>
144
+ <tr>
145
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-members.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-members.webp" alt="Agent team members" width="100%"></a></td>
146
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-tasks.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/team-tasks.webp" alt="Shared team tasks" width="100%"></a></td>
147
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/attachment-picker.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/attachment-picker.webp" alt="File and image picker" width="100%"></a></td>
148
+ </tr>
149
+ <tr>
150
+ <td align="center"><strong>Agent team members</strong></td>
151
+ <td align="center"><strong>Shared team tasks</strong></td>
152
+ <td align="center"><strong>File and image picker</strong></td>
153
+ </tr>
154
+ <tr>
155
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/text-selection.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/text-selection.webp" alt="Dedicated text selection" width="100%"></a></td>
156
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/conversation-files.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/conversation-files.webp" alt="Files in a conversation" width="100%"></a></td>
157
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/release-notes.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/release-notes.webp" alt="Bundled release notes" width="100%"></a></td>
158
+ </tr>
159
+ <tr>
160
+ <td align="center"><strong>Dedicated text selection</strong></td>
161
+ <td align="center"><strong>Files in a conversation</strong></td>
162
+ <td align="center"><strong>Bundled release notes</strong></td>
163
+ </tr>
164
+ <tr>
165
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/storage.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/storage.webp" alt="Local storage and cache categories" width="100%"></a></td>
166
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/voice-input.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/voice-input.webp" alt="Hold-to-talk input" width="100%"></a></td>
167
+ <td width="33.33%" align="center"><a href="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/file-upload.webp"><img src="https://raw.githubusercontent.com/Clarklevis1995/dsh-mobile/1fa7aa7e2d3f50379d37fba251fb6e774416703b/Docs/images/screenshots/2026-10-23/file-upload.webp" alt="File attachment in the composer" width="100%"></a></td>
168
+ </tr>
169
+ <tr>
170
+ <td align="center"><strong>Local storage and cache categories</strong></td>
171
+ <td align="center"><strong>Hold-to-talk input</strong></td>
172
+ <td align="center"><strong>File attachment in the composer</strong></td>
173
+ </tr>
174
+ </table>
175
+
176
+ ## Install the Plugin
177
+
178
+ Prerequisites: `dsh` CLI and `pnpm` installed, with `dsh web` working. Run `pnpm --version` to ensure the current user can find `pnpm`.
179
+
180
+ For LAN use, install the plugin:
181
+
182
+ ```bash
183
+ dsh plugin --profile web add dsh-plugin-mobile-gateway@latest
184
+ ```
185
+
186
+ For public-IP access on a Linux server, use the unified initializer. It installs/updates the plugin and requests sudo once to install the system Helper:
187
+
188
+ ```bash
189
+ npx --yes dsh-plugin-mobile-gateway@latest init
190
+ ```
191
+
192
+ `init` installs the exact version of the executing npm package into the DSH profile and skips pnpm's new-release waiting period for that version only, keeping plugin and Helper versions aligned.
193
+
194
+ After installation, stop and restart WebUI:
195
+
196
+ ```bash
197
+ dsh web
198
+ ```
199
+
200
+ Open WebUI and confirm Mobile Devices appears at the bottom of the left sidebar.
201
+
202
+ ## LAN Pairing
203
+
204
+ For the DSH computer and mobile device on the same mutually reachable LAN.
205
+
206
+ 1. Open Mobile Devices in WebUI.
207
+ 2. Set Gateway Mode to Persistent, or Temporary for short pairing sessions.
208
+ 3. Leave Device Authentication enabled.
209
+ 4. Choose Direct LAN under Pairing Connection Method and verify `ws://<电脑局域网 IP>:3081/ws/mobile`. Cloudflare Tunnel can remain enabled. The adjacent help icon explains available routes for this environment and suggests scenarios without changing the selection.
210
+ 5. Enter a device name and select Generate Pairing QR Code.
211
+ 6. Open device authentication in the mobile client and scan the QR code.
212
+ 7. Pairing is complete when the trusted device shows Online in WebUI.
213
+
214
+ If a firewall blocks the connection, allow TCP `3081` only on private networks. Do not expose 3081 publicly.
215
+
216
+ ## Public-IP Pairing on Linux Servers
217
+
218
+ > [!NOTE]
219
+ > Public-IP pairing here specifically means Linux servers. The one-command setup is available since `v0.6.4` for Ubuntu/Debian with a fixed public IPv4. Node.js, `pnpm`, and the `dsh` CLI must already be installed. CentOS is not currently supported.
220
+
221
+ ### 1. Prepare Public Ports
222
+
223
+ Copy the public IPv4 from your cloud console and allow inbound TCP `80` and `443` in its security group. Do not expose the DSH WebUI port or TCP `3081` publicly.
224
+
225
+ ### 2. Initialize
226
+
227
+ First confirm the regular DSH user can run `pnpm`:
228
+
229
+ ```bash
230
+ pnpm --version
231
+ ```
232
+
233
+ Then run as that same regular user, not `root` or `sudo npx`:
234
+
235
+ ```bash
236
+ npm_config_registry=https://registry.npmjs.org \
237
+ npx --yes dsh-plugin-mobile-gateway@latest init
238
+ ```
239
+
240
+ This installs/updates the plugin and requests sudo once for Nginx, Certbot, the system Helper, and certificate renewal timers. `init` aligns the exact DSH-profile and Helper versions.
241
+
242
+ Start or restart WebUI afterward:
243
+
244
+ ```bash
245
+ dsh web
246
+ ```
247
+
248
+ ### 3. Open Remote WebUI
249
+
250
+ Prefer the built-in port forwarding in VS Code, Cursor, or similar IDEs. Alternatively, run on your own computer:
251
+
252
+ ```bash
253
+ ssh -N -L <本地端口>:127.0.0.1:<DSH 实际端口> <服务器用户名>@<服务器公网 IP>
254
+ ```
255
+
256
+ Then open in your local browser:
257
+
258
+ ```text
259
+ http://127.0.0.1:<本地端口>
260
+ ```
261
+
262
+ ### 4. Configure the Public Endpoint
263
+
264
+ Open Mobile Devices, enter the cloud console's public IPv4 in Public Access, and choose Configure Public Access or Update Public Configuration. The Helper detects the current `dsh web` port and configures Nginx, TLS certificates, and `wss://<公网 IP>/ws/mobile`.
265
+
266
+ <p align="center">
267
+ <img src="docs/assets/public-access-ui.jpg" alt="Configure public access in the Mobile Devices panel" width="960">
268
+ </p>
269
+
270
+ ### 5. Pair the Mobile Device
271
+
272
+ 1. Enable Allow Mobile Connections and leave Device Authentication enabled.
273
+ 2. Enter a device name and generate a pairing QR code.
274
+ 3. Open device authentication on the phone and scan the QR code.
275
+ 4. Pairing is complete when the device shows Online in WebUI.
276
+
277
+ QR codes are single-use and expire after 5 minutes. Generate a new one in WebUI if needed.
278
+
279
+ ## Remote Access on Windows / macOS / Linux
280
+
281
+ Home computers usually lack a fixed public IP; router port forwarding is not recommended here. The Windows/macOS/Linux panel offers account/domain-free Quick Tunnels and fixed-domain named Tunnels. On first use, the plugin downloads and verifies official Cloudflare `cloudflared` into the current user's cache. No manual system service installation is required. Linux x64 and arm64 use the official standalone binaries from the pinned [Cloudflare 2026.9.3 release](https://github.com/cloudflare/cloudflared/releases/tag/2026.9.3), verified with SHA-256. For other Linux architectures, or to use an existing installation, set `cloudflaredPath` to an executable’s absolute path. The default does not search PATH.
282
+
283
+ Start `dsh web` first. The computer must stay awake, online, and running DSH; sleep or process exit interrupts remote access.
284
+
285
+ ### Cloudflare Quick Tunnel (Temporary Access)
286
+
287
+ The default is Automatic · Prefer LAN. For remote access, change Pairing Connection Method under Mobile Devices → Connection & Pairing to Automatic · Prefer Public or Cloudflare Public. A pink setup hint appears if the public route is not ready. Under Cloudflare Tunnel choose Quick Tunnel · No Domain and enable it. First use downloads `cloudflared`; once connected, the generated `wss://<名称>.trycloudflare.com/ws/mobile` becomes the pairing address. For LAN use, select Automatic · Prefer LAN or Direct LAN; the Tunnel may stay on. Generate a QR code and scan it in the app. Switching off stops the Tunnel. Restarting DSH restores an enabled Quick mode with a **new random address**.
288
+
289
+ Quick Tunnel needs no Cloudflare account, Token, or domain, but its address may change after DSH restarts or tunnel reconnection. The app trusts only confirmed addresses: generate a new QR code and scan again after changes. **An online computer does not guarantee the old URL still works.** Cloudflare positions Quick Tunnel for testing/development, with concurrency limits and no availability guarantee. See the [Quick Tunnel documentation](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/trycloudflare/).
290
+
291
+ Update Tunnel Configuration saves the mode and named-Tunnel parameters; unchanged settings do not reconnect. Restart Tunnel interrupts mobile connections and recreates the Cloudflare tunnel without restarting DSH Web. Quick mode may obtain a new address, clearing the old QR code; scan again with the new URL. This does not upgrade `cloudflared` automatically.
292
+
293
+ ### Cloudflare Named Tunnel (Fixed Address)
294
+
295
+ 1. [Create a remotely managed Tunnel](https://developers.cloudflare.com/tunnel/get-started/) in Cloudflare, add a public hostname such as `gateway.example.com`, and set **Service URL** to `http://127.0.0.1:3082`. No Cloudflare system service or inbound router port is required.
296
+ 2. Copy the Token from Add a replica, select Named Tunnel · Fixed Domain under Mobile Devices → Cloudflare Tunnel, enter the hostname/Token, and enable it. The plugin selects Persistent mode and starts the dedicated local listener and `cloudflared`. After tunnel registration it separately checks local DNS, TLS, and the public gateway route. On success, use the supplied `wss://gateway.example.com/ws/mobile` to generate a QR code.
297
+ 3. Starting `dsh web` restores enabled Tunnels automatically. Closing Cloudflare Tunnel in the panel stops the managed `cloudflared` and dedicated listener. Manually disabling the gateway pauses the Tunnel; enabling it resumes it.
298
+
299
+ Both Cloudflare routes accept only `/ws/mobile` WebSocket. Other HTTP paths, including DSH WebUI and `/mgw`, return 404. Device credentials are always required, even if local Debug authentication is disabled. Named-Tunnel Tokens are stored in `<deviceFile>.cloudflare.json` (default `~/.dsh/mobile-gateway-devices.json.cloudflare.json`) with mode `0600` and never returned to the browser. The default private `cloudflared-bin` cache does not use system/other-app binaries. Every start verifies the cached file; only a missing/corrupt cache triggers a fixed-version download with SHA-256 checked against official assets. An external binary is used only with explicit `cloudflaredPath`. If `cloudflarePort` changes, update the named-Tunnel Service URL port too. The cached `cloudflared` is checked at every start.
300
+
301
+ #### Endpoint Checks and Status
302
+
303
+ `state: online` means only that cloudflared registered a tunnel connection, not that the public hostname, TLS, or origin route works. Status also includes `endpointHealth` (state, hint, check time, error code) and `publicReady`. The panel checks once after connecting; Check Public DNS / TLS / WebSocket retries via the management-authenticated `POST /mgw/cloudflare/check` without restarting the Tunnel.
304
+
305
+ Checks use system DNS and HTTPS WebSocket requests with strict certificate verification, no pairing/device tokens, and no redirects. Only HTTP 401 with the gateway echoing the fresh random probe marker proves the authenticated route is reachable; generic proxy/Cloudflare Access 401 responses do not count. The marker appears only in rejections without valid device credentials and grants no access. This is a local network snapshot, not proof of phone connectivity, authentication, or session sync.
306
+
307
+ Local DNS failure does not prove a public record is absent: new records may encounter cached NXDOMAIN, local DNS, VPN, or proxy issues. Check the public hostname and proxied CNAME, then retry later; do not disable TLS verification. The plugin runs remotely managed Tunnels using a Tunnel Token, which does not create DNS or hostname routes. Separately authorized cloudflared CLI/API operations can create them, but are outside this check.
308
+
309
+ ### Tailscale (For Long-Term Use)
310
+
311
+ 1. Install [Tailscale](https://tailscale.com/download) on the computer and phone and join the same Tailnet.
312
+ 2. Run in Windows PowerShell or a macOS terminal:
313
+
314
+ ```bash
315
+ tailscale serve --bg 3081
316
+ ```
317
+
318
+ 3. Run `tailscale serve status` to find `https://<设备名>.<tailnet>.ts.net`.
319
+ 4. Use `wss://<设备名>.<tailnet>.ts.net/ws/mobile` as the WebSocket Address in WebUI, then generate a QR code to pair.
320
+
321
+ Tailscale Serve allows only devices permitted by the same Tailnet's access rules and provides HTTPS automatically. Use `tailscale serve reset` to stop forwarding. See the [Tailscale Serve documentation](https://tailscale.com/docs/reference/tailscale-cli/serve).
322
+
323
+ ## Connection Options
324
+
325
+ | Scenario | Recommended Route | Mobile WebSocket Address | Additional Setup | Ports and Authentication |
326
+ |---|---|---|---|---|
327
+ | Same LAN | Plugin LAN listener | `ws://<电脑局域网 IP>:3081/ws/mobile` | No Helper/Nginx; host and phone must reach each other | Private TCP `3081` only; keep authentication on |
328
+ | Local iOS Simulator | DSH WebUI local route | `ws://127.0.0.1:<DSH WebUI 端口>/ws/mobile` | No Helper/Nginx or separate port `3081` | No external ports; disable authentication only for Debug |
329
+ | Public Linux server | Helper + Nginx + TLS | `wss://<服务器公网 IPv4>/ws/mobile` | Run `init`, then enter public IPv4 in WebUI | Allow TCP `80/443`; do not expose DSH/`3081`; authentication required |
330
+ | Windows / macOS / Linux | Cloudflare named Tunnel | `wss://<公开域名>/ws/mobile` | Route public hostname to `127.0.0.1:3082`; enter hostname/Token in panel | No router forwarding; dedicated listener requires device authentication |
331
+ | Windows / macOS / Linux | Cloudflare Quick Tunnel | `wss://<随机名称>.trycloudflare.com/ws/mobile` | Enable in panel; scan again after URL changes | No account/domain/router forwarding; device authentication required |
332
+ | Home Windows / macOS | Tailscale Serve | `wss://<Tailscale 域名>/ws/mobile` | Forward to `127.0.0.1:3081` and enter generated URL in WebUI | No router forwarding; keep authentication on |
333
+
334
+ ## Manage Linux Public Access
335
+
336
+ Check status:
337
+
338
+ ```bash
339
+ sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest status
340
+ ```
341
+
342
+ Remove public access:
343
+
344
+ ```bash
345
+ sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest remove
346
+ ```
347
+
348
+ ## Update the Plugin
349
+
350
+ Rerun initialization to update both the plugin and system Helper:
351
+
352
+ ```bash
353
+ npx --yes dsh-plugin-mobile-gateway@latest init
354
+ ```
355
+
356
+ Then stop and restart `dsh web`.
357
+
358
+ ## Uninstall
359
+
360
+ ```bash
361
+ dsh plugin --profile web remove dsh-plugin-mobile-gateway
362
+ ```
363
+
364
+ To remove the system Helper too (existing Nginx public-access configuration is retained):
365
+
366
+ ```bash
367
+ sudo env "PATH=$PATH" npx --yes dsh-plugin-mobile-gateway@latest remove-helper
368
+ ```
369
+
370
+ ## Troubleshooting
371
+
372
+ | Symptom | Action |
373
+ |---|---|
374
+ | No Mobile Devices entry | Install in the `web` profile and fully restart `dsh web` |
375
+ | Mobile client receives `503` | Enable mobile connections in WebUI |
376
+ | Mobile client receives `401` | Generate a new QR code and pair again |
377
+ | Linux public connection times out | Check cloud security groups, firewall, and TCP `80/443` |
378
+ | No Linux public address | Enter public IPv4 under Mobile Devices → Public Access and update |
379
+ | Cloudflare download fails | Check access to GitHub Releases; alternatively install cloudflared and set `cloudflaredPath` to its absolute path |
380
+ | App fails after Quick Tunnel restart | Regenerate and rescan the QR code after URL changes; use a named Tunnel for a fixed address |
381
+ | Quick Tunnel fails with existing Cloudflare configuration | Quick Tunnel cannot currently share the configuration directory containing `~/.cloudflared/config.yaml`; inspect panel errors and follow the [official guidance](https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/trycloudflare/) |
382
+ | Cloudflare connected but app unreachable | Verify the route's Service URL matches the panel's `http://127.0.0.1:<端口>`; check DNS and pairing credentials |
383
+ | Need server logs | Read `mobile-gateway.log` in the system temporary directory (Windows: `%TEMP%`; macOS: `$TMPDIR`; Linux usually `/tmp`) |
384
+
385
+ ## Source Development
386
+
387
+ ```bash
388
+ dsh plugin --profile web add file:/absolute/path/to/dsh-plugin-mobile-gateway
389
+ npm test
390
+ ```
391
+
392
+ The panel's Tools menu offers Restart Current Gateway and Stop DSH Web. Restart works only when launched through `dsh web`: it ends the current Web process and relaunches with the original arguments plus `--no-open`. The existing tab waits and refreshes; no new tab opens. The replacement process runs in the background, outside the original terminal's foreground job. Stop it through the same menu or send `SIGTERM` to the DSH process listening on the Web port. Connections briefly drop, and the Quick Tunnel URL may change. Reinstall the plugin and restart `dsh web` after source changes.
393
+
394
+
395
+ ## Official Voice Input Integration
396
+
397
+ The gateway integrates DSH 0.2.0-rc.2's official experimental voice-input plugin. Clients can list recognizers, subscribe to preparation progress, prepare models, set recognition preferences, and submit recordings for transcription. Cancellation/disconnect aborts transcription; results are not automatically sent to the Agent.
398
+
399
+ 1. Enable Voice Input (`@deepseek-ai/dsh-experimental-voice-input-bundle`) in DSH plugin management and download/prepare its model.
400
+ 2. Query `speech-catalog` through the paired control WebSocket; confirm plugin availability and model `ready`/`standby`.
401
+ 3. After a hold-to-talk recording, convert the complete audio to 16 kHz mono PCM16 WAV and upload Base64 via `speech-transcribe`.
402
+ 4. Put `speech-transcript` text in the composer, then send using the existing `message` after user confirmation.
403
+
404
+ Models run on the DSH computer; the phone needs no recognition weights. Only complete-recording transcription is currently provided; clients must implement recording controls, permissions, and conversion. See the [protocol reference](PROTOCOL.md#官方语音输入speech-input-v1) for interfaces, preparation, and errors.
405
+
406
+ Verify real WAV validation against the installed official plugin (test recognition Provider, no model download):
407
+
408
+ ```bash
409
+ DSH_INSTALL_ROOT=/absolute/path/to/@deepseek-ai/dsh node test/speech-official.test.mjs
410
+ ```
package/README.md CHANGED
@@ -6,6 +6,22 @@
6
6
 
7
7
  `dsh-plugin-weapp-gateway` · DeepSeek Harness 移动客户端连接插件
8
8
 
9
+ ### v0.8.52 · 兼容 App 下拉与方案摘要之间留出间距
10
+
11
+ - 「兼容 App(备用)」的连接方式下拉与下方「配对入口」摘要卡片之间增加间距(16px),下拉不再紧贴提示卡片。
12
+ - 摘要卡片的内边距、下方「配对入口地址」输入框与其余配对布局保持不变。
13
+ - 全量测试通过。
14
+ ### v0.8.54 · 同步上游 0.12.1 新功能
15
+
16
+ - **生图工具图片转发**(tool-result-images-v1):`tool/result`、`tool/ptc-dispatch`、`tool/code-dispatch` 与会话历史快照携带生成图片附件元数据(PNG/JPEG/WebP/GIF,按附件 ID 去重),App 可直接展示生图结果;手机经控制连接 `attachment` 请求图片。
17
+ - **DSH 0.2.2-rc.1/rc.3 协议支持**:宿主运行时版本探测、`session/control` 投影变更展平、`message-text` 文本段(textParts)、团队投影规范化(RC.3 无 members)、统一子代理控制接口(interruptByUser)。
18
+ - **排程管理 v2**(schedule-management-v2):schedule-create/edit/run/view/delete-inactive 完整模块,带严格参数校验、乐观并发(expectedUpdatedAt)与旧客户端兼容桥。
19
+ - **手机连接器**(device-tools-v1):日历/提醒/位置/照片/音乐/健康/闹钟七类原生能力。网关侧含设备权限持久化(devices 存储 v5)、`/mgw/devices/<id>/permissions` 路由、批量吊销 `POST /mgw/devices/revoke`、请求来源绑定(防伪造/串线);Agent 侧经 `dsh-plugin-weapp-gateway/phone-tools` 插件行注入 phone_* 工具(需 App 实现「连接器」页)。
20
+ - **Linux cloudflared 支持**:自动下载校验 Linux amd64/arm64 资产;原「Linux 不自动下载」的 fork 测试已被上游行为取代并移除。
21
+ - **文件改动查询**(workspace-changes):上游模块走宿主 `/api/changes.*` 只读路由;旧宿主退回原 bridge。
22
+ - **管理页可靠性**:设备列表/状态读取去重与 5 秒超时、批量删除(勾选/全选)、设备权限页。
23
+ - 可信设备行新增 `permissions` 字段;`agent-team-set-enabled` 开关;hello 能力新增 message-quotes-v1 / tool-result-images-v1 / agent-team-mode-v1 / schedule-management-v2 / plugin-updates-v1 / device-tools-v1。
24
+ - 官方集成测试(test/*-official.test.mjs)需 DSH_INSTALL_ROOT,放 `npm run test:official`;React UI 测试放 `npm run test:ui`。
9
25
  ### v0.8.51 · 配对面板细节打磨
10
26
 
11
27
  - 小程序模块去掉「鲸尾公网 · 小程序 / 中继优先,局域网兜底」说明行(上方描述文案已含同样信息)。