@dsh-mobile/mobile-remote 3.4.0 → 3.4.1-beta.1

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.md CHANGED
@@ -155,9 +155,9 @@ npx @deepseek-ai/dsh web
155
155
  # breakReminder: { enabled: false } # 连续工作 2 小时的休息提醒。默认:App 里有这个开关(发过 breakReminder)才提醒;true = 不看 App 也提醒,false = 这台电脑永不提醒
156
156
  ```
157
157
 
158
- ### P2P 直连(实验性,默认关闭)
158
+ ### P2P 直连(测试中)
159
159
 
160
- 手机与电脑之间可以尝试建立 WebRTC 直连(数据通道),不经中继转发流量。**实验性功能,默认关闭,也不随插件安装**(它依赖的 `werift` 体积较大,所以只是可选的 peer 依赖)。要试用:在终端运行 `dsh plugin add werift@0.27.0`(这条命令把参数原样交给 DSH 配置目录里的 pnpm,已在全新的 `DSH_HOME` 里验证:先装插件再装 werift、或先装 werift 再装插件,插件都能找到它;DSH 会提示它「不是插件、按普通依赖安装」,属正常),然后在上面的 `config` 里加 `p2p: { enabled: true }`(可选 `stun: ["stun:stun.cloudflare.com:3478"]`)并重启。没装 werift 时插件照常工作,只是不提供 P2P,`/bootstrap` 的 `features` 里也不会有 `p2p`。握手用的 offer / answer / 候选地址只经端到端加密的信令连接传输,不写日志;数据通道里会再跑一遍全新的 Noise 加密会话,只认已配对的手机。不涉及 TURN 中转:直连不成功时手机仍走原来的路径。
160
+ 手机与电脑之间可以尝试建立 WebRTC 直连(数据通道),不经中继转发流量,免费。从 3.4.1 起电脑端的 `werift` 随插件安装(约多 22 MB),`p2p.enabled` 默认打开,不用另外配置;要关掉就在上面的 `config` 里加 `p2p: { enabled: false }`(可选 `stun: ["stun:stun.cloudflare.com:3478"]`)。只有开了 P2P 的 App 才会发起直连,已发布的 App 不受影响。手机要用带中继地址的二维码配对(信令走中继房间,不需要订阅)。werift 万一加载失败,插件照常工作,只是不提供 P2P,`/bootstrap` 的 `features` 里也不会有 `p2p`。握手用的 offer / answer / 候选地址只经端到端加密的信令连接传输,不写日志;数据通道里会再跑一遍全新的 Noise 加密会话,只认已配对的手机。不涉及 TURN 中转:直连不成功时手机仍走原来的路径。
161
161
 
162
162
  ## 桌面设置页入口(客户端模块)
163
163
 
package/lib/config.js CHANGED
@@ -184,9 +184,11 @@ export const Config = z.object({
184
184
 
185
185
 
186
186
 
187
+
188
+
187
189
  p2p: z
188
190
  .object({
189
- enabled: z.boolean().default(false),
191
+ enabled: z.boolean().default(true),
190
192
  stun: z.array(z.string()).default(["stun:stun.cloudflare.com:3478"]),
191
193
  })
192
194
  .default({}),
@@ -422,7 +422,9 @@ class GuestSession {
422
422
  }
423
423
  this.mux.receive(plain);
424
424
  } catch (err) {
425
- this.kick(err instanceof MuxError ? `protocol: ${err.message}` : "bad frame");
425
+
426
+
427
+ this.kick(err instanceof MuxError ? `protocol: ${err.message}` : `bad frame: ${err?.code ?? err?.name ?? "error"}${err?.message ? ` ${err.message}` : ""}`);
426
428
  }
427
429
  }
428
430
 
@@ -448,6 +450,8 @@ class GuestSession {
448
450
 
449
451
  const result = devices.authorize(rs, this.signal || this.standby ? { ...info, otp: undefined } : info);
450
452
  if (!result) return this.kick("unauthorized device");
453
+
454
+ if (result.refused === "full") return this.kick("设备已满:已配对的手机到了上限,配对码未作废", "full");
451
455
  this.device = result.device;
452
456
  const reply = this.noise.writeMessage2(enc.encode(JSON.stringify({ v: 1, ok: true, server: serverName, device: { id: result.device.id, name: result.device.name }, newlyPaired: result.newlyPaired })));
453
457
  this.cipherOut = reply.send;
@@ -540,10 +544,14 @@ class GuestSession {
540
544
 
541
545
 
542
546
 
547
+
543
548
  kick(reason = "kicked", why = "") {
544
549
  if (this.state === "closed") return;
545
550
  this.link.o.log(`relay: 断开访客 ${this.connId.slice(0, 6)}…(${reason})`);
546
- if (this.link.control(why ? { t: "kick", c: this.connId, why } : { t: "kick", c: this.connId })) this.link.pendingKicks.add(this.connId);
551
+
552
+
553
+ const detail = this.link instanceof DirectLink ? { detail: reason } : {};
554
+ if (this.link.control(why ? { t: "kick", c: this.connId, why, ...detail } : { t: "kick", c: this.connId, ...detail })) this.link.pendingKicks?.add(this.connId);
547
555
  this.dispose(reason);
548
556
  }
549
557
  dispose(reason = "closed") {
@@ -567,6 +575,13 @@ class GuestSession {
567
575
 
568
576
 
569
577
 
578
+
579
+ export function closeReason(text) {
580
+ let s = String(text);
581
+ while (Buffer.byteLength(s, "utf8") > 120) s = s.slice(0, -1);
582
+ return s;
583
+ }
584
+
570
585
  class DirectLink {
571
586
  constructor(owner, ws, ip = "") {
572
587
  this.o = owner;
@@ -619,8 +634,8 @@ class DirectLink {
619
634
  control(obj) {
620
635
  if (this.closed) return false;
621
636
  if (obj?.t === "kick") {
622
- const code = obj.why === "busy" ? 4430 : obj.why === "replaced" ? 4409 : 4401;
623
- this.ws.close(code, obj.why || "kicked");
637
+ const code = obj.why === "busy" ? 4430 : obj.why === "replaced" ? 4409 : obj.why === "full" ? 4433 : 4401;
638
+ this.ws.close(code, closeReason(obj.why || obj.detail || "kicked"));
624
639
  return true;
625
640
  }
626
641
  if (obj?.t === "verified") return true;
@@ -144,6 +144,8 @@ export class DeviceStore {
144
144
 
145
145
 
146
146
 
147
+
148
+
147
149
  authorize(pub, info = {}) {
148
150
  const known = this.find(pub);
149
151
  if (known) {
@@ -167,8 +169,9 @@ export class DeviceStore {
167
169
  const key = hex(sha256(otp));
168
170
  const entry = this.otps.get(key);
169
171
  if (!entry) return null;
172
+
173
+ if (this.devices.length >= this.maxDevices) return { refused: "full" };
170
174
  this.otps.delete(key);
171
- if (this.devices.length >= this.maxDevices) return null;
172
175
  const device = {
173
176
  id: fingerprint(pub),
174
177
  name: cleanName(info.name ?? entry.name),
@@ -205,7 +205,7 @@ export function connectPhone({ relayUrl, room, pcPub, device, name = "Phone", ot
205
205
  phone._shutdown(e.code ?? 1006, e.reason ?? "");
206
206
  if (!opened) {
207
207
  clearTimeout(timer);
208
- reject(Object.assign(new Error(`relay closed during ${stage} (${e.code})`), { code: e.code }));
208
+ reject(Object.assign(new Error(`relay closed during ${stage} (${e.code})`), { code: e.code, reason: e.reason }));
209
209
  }
210
210
  });
211
211
  ws.addEventListener("error", () => {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-mobile/mobile-remote",
3
- "version": "3.4.0",
3
+ "version": "3.4.1-beta.1",
4
4
  "description": "DSH Mobile:把 DeepSeek Harness 变成随身控制台——手机远程发消息派活、看进度、收通知、审批决策、管理会话;配套 Flutter App(Android、iPhone / iPad)",
5
5
  "homepage": "https://dsh.claud.ing/",
6
6
  "repository": {
@@ -55,7 +55,8 @@
55
55
  "dsh": ">=0.2.1-rc.2 <0.4.0-0"
56
56
  },
57
57
  "dependencies": {
58
- "qrcode": "^1.5.4"
58
+ "qrcode": "^1.5.4",
59
+ "werift": "0.27.0"
59
60
  },
60
61
  "peerDependencies": {
61
62
  "@deepseek-ai/dsh-credentials": ">=0.2.1-rc.2 <0.4.0",
@@ -63,15 +64,11 @@
63
64
  "@deepseek-ai/dsh-sandbox-policy": ">=0.2.1-rc.2 <0.4.0",
64
65
  "@deepseek-ai/dsh-scope": ">=0.2.1-rc.2 <0.4.0",
65
66
  "@deepseek-ai/schemastery": ">=3.18.1",
66
- "dsh-codex-connect": ">=0.1.0-alpha.4.5",
67
- "werift": "0.27.0"
67
+ "dsh-codex-connect": ">=0.1.0-alpha.4.5"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "dsh-codex-connect": {
71
71
  "optional": true
72
- },
73
- "werift": {
74
- "optional": true
75
72
  }
76
73
  },
77
74
  "publishConfig": {