@duke-dsh-plugins/dsh-remote-control 1.1.3 → 1.1.5
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 +91 -88
- package/lib/host-bridge.mjs +86 -42
- package/market/index.json +105 -0
- package/package.json +79 -75
package/README.md
CHANGED
|
@@ -1,88 +1,91 @@
|
|
|
1
|
-
# plugin —— DSH 插件(Host 侧半边)
|
|
2
|
-
|
|
3
|
-
用 HarmonyOS 手机远程控制 DeepSeek Harness 的 DSH 插件:会话遥控、审批/提问应答、推送通知。
|
|
4
|
-
|
|
5
|
-
架构与安全模型见仓库根 [README](../README.md);线协议见 [docs/PROTOCOL.md](../docs/PROTOCOL.md)(v1.0.2)。
|
|
6
|
-
|
|
7
|
-
## 安装
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
dsh plugin add <本目录> # 或 DSH 的 plugin_manager install_bundle(target 指向本目录)
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 配对(一次性)
|
|
14
|
-
|
|
15
|
-
1. 插件首次启用会在 `%DSH_HOME%/remote-control/config.json`(默认 `~/.dsh`)生成配对信息:
|
|
16
|
-
- `channel`:16 位 base32(`^[A-Z2-7]{16,64}$`)
|
|
17
|
-
- `secret`:E2E 密钥材料(**不要**发给中继或任何第三方)
|
|
18
|
-
2. 在 `config.json` 里填写 `relayUrl`(如 `ws://192.168.3.2:8787` 或 `wss://relay.example.com/`),
|
|
19
|
-
需要中继鉴权时填 `relayToken`(对应中继的 `RELAY_TOKEN`)。
|
|
20
|
-
3. 手机 App([../app](../app/))配对页输入同样的 `relayUrl / channel / secret`,连接即配对。
|
|
21
|
-
|
|
22
|
-
> 修改 `config.json` 后如插件未即时生效,用 plugin_manager 把本插件 disable→enable,
|
|
23
|
-
> 或 remove 后重新 install(link 安装指向本目录,磁盘即最新源码)。
|
|
24
|
-
|
|
25
|
-
## 扫码配对(§3.5,v1.0.3)
|
|
26
|
-
|
|
27
|
-
除手动输入外,可用会话命令 `/remote-pairing` 生成**配对二维码**(协议
|
|
28
|
-
[docs/PROTOCOL.md](../docs/PROTOCOL.md) §3.5):手机 App 配对页「扫码」直接填入
|
|
29
|
-
`relayUrl / channel / secret`,免手抄。
|
|
30
|
-
|
|
31
|
-
| 命令 | 作用 |
|
|
32
|
-
|---|---|
|
|
33
|
-
| `/remote-pairing` | 显示配对二维码(ASCII,会话窗口直接扫)+ 配对 URI(可复制兜底)+ 使用说明;同时写 `%DSH_HOME%/remote-control/pairing.svg` 并尝试用系统默认程序打开 |
|
|
34
|
-
| `/remote-pairing rotate` | 重新生成 channel+secret → 落盘 → 中继链路立即以新配对信息重连;**旧二维码/旧口述即刻失效** |
|
|
35
|
-
| `/remote-pairing hide` | 删除本机 `pairing.svg` 文件(不在屏幕上留图) |
|
|
36
|
-
|
|
37
|
-
编码细节(可由手机端实现者对照):URI 形如
|
|
38
|
-
`dshrc://pair?r=<encodeURIComponent(relayUrl)>&c=<channel>&s=<secret>[&t=<encodeURIComponent(relayToken)>]`,
|
|
39
|
-
二维码为 byte 模式、纠错级 M、版本自适应 1–10(内嵌零依赖编码器,`lib/qr.mjs`)。
|
|
40
|
-
|
|
41
|
-
> ⚠️ **安全提示(§3.5)**:二维码/URI 含 secret 明文(与口述同级信任域)——只在受信任
|
|
42
|
-
> 屏幕上展示;不需要时用 `rotate`(换 secret 作废旧码)或 `hide`(删图)清理;
|
|
43
|
-
> 插件日志对 URI 做脱敏(`s=***`/`t=***`),不落明文。
|
|
44
|
-
|
|
45
|
-
## 配置项(config.json)
|
|
46
|
-
|
|
47
|
-
| 键 | 默认 | 说明 |
|
|
48
|
-
|---|---|---|
|
|
49
|
-
| `enabled` | `true` | 总开关;false 时不连中继、不拦截任何请求 |
|
|
50
|
-
| `relayUrl` | `""` | 中继地址;空 = 空转待配对 |
|
|
51
|
-
| `relayToken` | `""` | 中继自身鉴权 token(可选) |
|
|
52
|
-
| `channel` / `secret` | 首启生成 | 配对信息 |
|
|
53
|
-
| `interceptApprovals` | `true` | 手机在线时代理审批请求 |
|
|
54
|
-
| `interceptQuestions` | `true` | 手机在线时代理用户提问 |
|
|
55
|
-
| `approvalTimeoutMs` | `120000` | 手机应答超时(钳制 10s–600s);**超时一律放行给桌面答案器** |
|
|
56
|
-
| `push.*` | 关闭 | Push Kit(`appId` / `clientId` / `clientSecret` / `channelId` / `topic` / `notifyTurnEnd`) |
|
|
57
|
-
|
|
58
|
-
## 目录
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
index.js Cordis 插件入口(KAT→配置→/remote-pairing→装配→清理)
|
|
62
|
-
lib/protocol.mjs 信封 + HKDF/AES-GCM + assertKat
|
|
63
|
-
lib/config.mjs config.json 读写(首启生成 channel/secret)
|
|
64
|
-
lib/relay-client.mjs 中继客户端(重连退避/心跳/sid:seq 去重/reload 热更换)
|
|
65
|
-
lib/host-bridge.mjs Host 服务桥接(sessionController + 事件 + 审批/提问瀑布)
|
|
66
|
-
lib/pairing.mjs 配对 URI(§3.5)+ SVG 落盘/打开/隐藏 + /remote-pairing 命令
|
|
67
|
-
lib/qr.mjs 内嵌 QR 编码器(byte/ECC-M/版本 1–10,零运行时依赖)
|
|
68
|
-
lib/push.mjs Push Kit REST 发送
|
|
69
|
-
scripts/smoke-link.mjs 链路冒烟
|
|
70
|
-
scripts/verify-qr.mjs QR 正确性自检(jsqr 独立解码 + 矩阵级 RS 自检;devDependencies)
|
|
71
|
-
scripts/verify-pairing.mjs /remote-pairing 命令逻辑自检(mock ctx;devDependencies)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## 安装(npm 分发,v1.1.3 起)
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# DSH
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
plugin_manager
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
# plugin —— DSH 插件(Host 侧半边)
|
|
2
|
+
|
|
3
|
+
用 HarmonyOS 手机远程控制 DeepSeek Harness 的 DSH 插件:会话遥控、审批/提问应答、推送通知。
|
|
4
|
+
|
|
5
|
+
架构与安全模型见仓库根 [README](../README.md);线协议见 [docs/PROTOCOL.md](../docs/PROTOCOL.md)(v1.0.2)。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
dsh plugin add <本目录> # 或 DSH 的 plugin_manager install_bundle(target 指向本目录)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 配对(一次性)
|
|
14
|
+
|
|
15
|
+
1. 插件首次启用会在 `%DSH_HOME%/remote-control/config.json`(默认 `~/.dsh`)生成配对信息:
|
|
16
|
+
- `channel`:16 位 base32(`^[A-Z2-7]{16,64}$`)
|
|
17
|
+
- `secret`:E2E 密钥材料(**不要**发给中继或任何第三方)
|
|
18
|
+
2. 在 `config.json` 里填写 `relayUrl`(如 `ws://192.168.3.2:8787` 或 `wss://relay.example.com/`),
|
|
19
|
+
需要中继鉴权时填 `relayToken`(对应中继的 `RELAY_TOKEN`)。
|
|
20
|
+
3. 手机 App([../app](../app/))配对页输入同样的 `relayUrl / channel / secret`,连接即配对。
|
|
21
|
+
|
|
22
|
+
> 修改 `config.json` 后如插件未即时生效,用 plugin_manager 把本插件 disable→enable,
|
|
23
|
+
> 或 remove 后重新 install(link 安装指向本目录,磁盘即最新源码)。
|
|
24
|
+
|
|
25
|
+
## 扫码配对(§3.5,v1.0.3)
|
|
26
|
+
|
|
27
|
+
除手动输入外,可用会话命令 `/remote-pairing` 生成**配对二维码**(协议
|
|
28
|
+
[docs/PROTOCOL.md](../docs/PROTOCOL.md) §3.5):手机 App 配对页「扫码」直接填入
|
|
29
|
+
`relayUrl / channel / secret`,免手抄。
|
|
30
|
+
|
|
31
|
+
| 命令 | 作用 |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `/remote-pairing` | 显示配对二维码(ASCII,会话窗口直接扫)+ 配对 URI(可复制兜底)+ 使用说明;同时写 `%DSH_HOME%/remote-control/pairing.svg` 并尝试用系统默认程序打开 |
|
|
34
|
+
| `/remote-pairing rotate` | 重新生成 channel+secret → 落盘 → 中继链路立即以新配对信息重连;**旧二维码/旧口述即刻失效** |
|
|
35
|
+
| `/remote-pairing hide` | 删除本机 `pairing.svg` 文件(不在屏幕上留图) |
|
|
36
|
+
|
|
37
|
+
编码细节(可由手机端实现者对照):URI 形如
|
|
38
|
+
`dshrc://pair?r=<encodeURIComponent(relayUrl)>&c=<channel>&s=<secret>[&t=<encodeURIComponent(relayToken)>]`,
|
|
39
|
+
二维码为 byte 模式、纠错级 M、版本自适应 1–10(内嵌零依赖编码器,`lib/qr.mjs`)。
|
|
40
|
+
|
|
41
|
+
> ⚠️ **安全提示(§3.5)**:二维码/URI 含 secret 明文(与口述同级信任域)——只在受信任
|
|
42
|
+
> 屏幕上展示;不需要时用 `rotate`(换 secret 作废旧码)或 `hide`(删图)清理;
|
|
43
|
+
> 插件日志对 URI 做脱敏(`s=***`/`t=***`),不落明文。
|
|
44
|
+
|
|
45
|
+
## 配置项(config.json)
|
|
46
|
+
|
|
47
|
+
| 键 | 默认 | 说明 |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `enabled` | `true` | 总开关;false 时不连中继、不拦截任何请求 |
|
|
50
|
+
| `relayUrl` | `""` | 中继地址;空 = 空转待配对 |
|
|
51
|
+
| `relayToken` | `""` | 中继自身鉴权 token(可选) |
|
|
52
|
+
| `channel` / `secret` | 首启生成 | 配对信息 |
|
|
53
|
+
| `interceptApprovals` | `true` | 手机在线时代理审批请求 |
|
|
54
|
+
| `interceptQuestions` | `true` | 手机在线时代理用户提问 |
|
|
55
|
+
| `approvalTimeoutMs` | `120000` | 手机应答超时(钳制 10s–600s);**超时一律放行给桌面答案器** |
|
|
56
|
+
| `push.*` | 关闭 | Push Kit(`appId` / `clientId` / `clientSecret` / `channelId` / `topic` / `notifyTurnEnd`) |
|
|
57
|
+
|
|
58
|
+
## 目录
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
index.js Cordis 插件入口(KAT→配置→/remote-pairing→装配→清理)
|
|
62
|
+
lib/protocol.mjs 信封 + HKDF/AES-GCM + assertKat
|
|
63
|
+
lib/config.mjs config.json 读写(首启生成 channel/secret)
|
|
64
|
+
lib/relay-client.mjs 中继客户端(重连退避/心跳/sid:seq 去重/reload 热更换)
|
|
65
|
+
lib/host-bridge.mjs Host 服务桥接(sessionController + 事件 + 审批/提问瀑布)
|
|
66
|
+
lib/pairing.mjs 配对 URI(§3.5)+ SVG 落盘/打开/隐藏 + /remote-pairing 命令
|
|
67
|
+
lib/qr.mjs 内嵌 QR 编码器(byte/ECC-M/版本 1–10,零运行时依赖)
|
|
68
|
+
lib/push.mjs Push Kit REST 发送
|
|
69
|
+
scripts/smoke-link.mjs 链路冒烟
|
|
70
|
+
scripts/verify-qr.mjs QR 正确性自检(jsqr 独立解码 + 矩阵级 RS 自检;devDependencies)
|
|
71
|
+
scripts/verify-pairing.mjs /remote-pairing 命令逻辑自检(mock ctx;devDependencies)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 安装(npm 分发,v1.1.3 起)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# DSH 插件市场(推荐):在「设置 → 插件市场」添加索引 URL 后搜「DSH Pocket」安装
|
|
78
|
+
# https://unpkg.com/@duke-dsh-plugins/dsh-remote-control-market@latest/index.json
|
|
79
|
+
#
|
|
80
|
+
# 或直接用插件管理器:会解析 peerDependencies 并做兼容性 gate
|
|
81
|
+
plugin_manager install @duke-dsh-plugins/dsh-remote-control
|
|
82
|
+
|
|
83
|
+
# 或直接 link 安装(本地开发)
|
|
84
|
+
plugin_manager install_bundle /path/to/this/repo/plugin
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
装好后到 DSH「设置 → DSH Pocket」分区填中继地址、扫码配对。中继进程会由插件
|
|
88
|
+
自动托管(`relayUrl` 指向本机时);VPS 部署请另装
|
|
89
|
+
[`@duke-dsh-plugins/dsh-remote-control-relay`](../relay/README.md)。
|
|
90
|
+
协议契约见 [`docs/PROTOCOL.md`](../docs/PROTOCOL.md)(v1.1.3:端到端加密 +
|
|
91
|
+
会话纪元抗重放 + 可选中继 TLS)。
|
package/lib/host-bridge.mjs
CHANGED
|
@@ -492,33 +492,6 @@ export function mapToolResultEvent(sessionId, event) {
|
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
/**
|
|
496
|
-
* 契约 §5.2 `system.message` 事件映射(宿主 session/event 的
|
|
497
|
-
* system/message 与 developer/message;两者共用一个 topic,用 kind 区分)。
|
|
498
|
-
* message 可能是 {content:[blocks]},也可能是字符串——两种都兜住。
|
|
499
|
-
* @returns {{sessionId:string,kind:"system"|"developer",text:string,ts:number}|null}
|
|
500
|
-
*/
|
|
501
|
-
export function mapSystemMessageEvent(sessionId, event, kind) {
|
|
502
|
-
if (!event || typeof event !== "object") return null;
|
|
503
|
-
if (event.type !== "system/message" && event.type !== "developer/message") return null;
|
|
504
|
-
const data = event.data;
|
|
505
|
-
if (!data || typeof data !== "object") return null;
|
|
506
|
-
const message = data.message !== undefined ? data.message : data;
|
|
507
|
-
let text = "";
|
|
508
|
-
if (typeof message === "string") {
|
|
509
|
-
text = message;
|
|
510
|
-
} else if (message && typeof message === "object") {
|
|
511
|
-
text = contentText(message.content);
|
|
512
|
-
}
|
|
513
|
-
if (text.trim() === "") return null;
|
|
514
|
-
return {
|
|
515
|
-
sessionId: String(sessionId ?? ""),
|
|
516
|
-
kind: kind === "developer" ? "developer" : "system",
|
|
517
|
-
text,
|
|
518
|
-
ts: eventTime(event),
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
495
|
/**
|
|
523
496
|
* 契约 §5.7 StepRecord 提取:session.history 的 page.records → steps[]。
|
|
524
497
|
*
|
|
@@ -967,10 +940,14 @@ export class HostBridge {
|
|
|
967
940
|
}
|
|
968
941
|
});
|
|
969
942
|
|
|
970
|
-
// --- v1.0.6(§5.7
|
|
943
|
+
// --- v1.0.6(§5.7)→ v1.1.4:会话事件总闸 → tool.call / tool.result ---
|
|
971
944
|
// 宿主每写入一条会话日志事件就触发(覆盖所有会话,含 subagent)。
|
|
972
945
|
// 按 session.id 寻址即可,**不过滤**子代理;不认识的事件类型直接忽略,
|
|
973
946
|
// 绝不因为形状不认识而抛错(#on 包装器已兜底)。
|
|
947
|
+
// v1.1.4:**不再桥接 system/message / developer/message**——宿主里它们是
|
|
948
|
+
// 系统提示词节点与工具注册表变更(提示词组装记录,不是对话内容),
|
|
949
|
+
// DSH 桌面端的聊天视图从不展示;手机端曾把它们当「系统消息」显示,
|
|
950
|
+
// 造成时间线里出现大段多余的系统提示文本(用户反馈)。
|
|
974
951
|
this.#on("session/event", (session, event) => {
|
|
975
952
|
const sessionId = String(session?.id ?? "");
|
|
976
953
|
if (sessionId === "") return;
|
|
@@ -985,12 +962,6 @@ export class HostBridge {
|
|
|
985
962
|
if (mapped !== null) this.#sendEvent("tool.result", mapped);
|
|
986
963
|
return;
|
|
987
964
|
}
|
|
988
|
-
if (type === "system/message" || type === "developer/message") {
|
|
989
|
-
const kind = type === "developer/message" ? "developer" : "system";
|
|
990
|
-
const mapped = mapSystemMessageEvent(sessionId, event, kind);
|
|
991
|
-
if (mapped !== null) this.#sendEvent("system.message", mapped);
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
965
|
if (type === "model/selection") {
|
|
995
966
|
// v1.0.8:会话模型/思考强度变化(桌面端或手机端 selectModel 都会追加)
|
|
996
967
|
const selection = mapModelSelection(event.data);
|
|
@@ -1189,6 +1160,36 @@ export class HostBridge {
|
|
|
1189
1160
|
return this.#service("workspaceRegistry");
|
|
1190
1161
|
}
|
|
1191
1162
|
|
|
1163
|
+
/**
|
|
1164
|
+
* v1.1.4:按 cwd 反查它是否属于某个**已注册工作区**的目录。
|
|
1165
|
+
* 命中返回该工作区的 id(供 `session.create` 传 `workspaceId` 归组),
|
|
1166
|
+
* 否则返回 null(调用方退回传 cwd,与 PC 在普通目录新建一样 = 未分组)。
|
|
1167
|
+
*
|
|
1168
|
+
* 用宿主 `workspaceRegistry.resolveByPath`:按 canonical path 匹配,
|
|
1169
|
+
* **不创建**工作区、不改写注册表;目录不存在会 reject。
|
|
1170
|
+
* 任何异常(服务缺失 / 方法不存在 / 路径解析失败)都兜底回 null——
|
|
1171
|
+
* 归组是增强,绝不能因此让 session.create 失败。
|
|
1172
|
+
* @param {string} cwd
|
|
1173
|
+
* @returns {Promise<string|null>}
|
|
1174
|
+
*/
|
|
1175
|
+
async #resolveWorkspaceByCwd(cwd) {
|
|
1176
|
+
try {
|
|
1177
|
+
const reg = this.#workspaceRegistry();
|
|
1178
|
+
if (!reg || typeof reg.resolveByPath !== "function") return null;
|
|
1179
|
+
const ws = await reg.resolveByPath(cwd);
|
|
1180
|
+
const id = typeof ws?.id === "string" && ws.id !== "" ? ws.id : null;
|
|
1181
|
+
if (id !== null) {
|
|
1182
|
+
this.#log("info", "session.create cwd matches a workspace; attaching to it", {
|
|
1183
|
+
workspaceId: id,
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
return id;
|
|
1187
|
+
} catch (e) {
|
|
1188
|
+
this.#log("warn", "resolveByPath failed; session stays ungrouped", { error: errText(e) });
|
|
1189
|
+
return null;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1192
1193
|
/** 事件监听包装:emit 监听必须永不抛出。 */
|
|
1193
1194
|
#on(name, handler) {
|
|
1194
1195
|
const wrapped = (...args) => {
|
|
@@ -1689,7 +1690,7 @@ export class HostBridge {
|
|
|
1689
1690
|
case "session.selectModel":
|
|
1690
1691
|
return await this.#rSessionSelectModel(m);
|
|
1691
1692
|
case "session.model":
|
|
1692
|
-
return this.#rSessionModel(m);
|
|
1693
|
+
return await this.#rSessionModel(m);
|
|
1693
1694
|
case "session.queue":
|
|
1694
1695
|
return this.#rSessionQueue(m);
|
|
1695
1696
|
case "session.archive":
|
|
@@ -2072,7 +2073,20 @@ export class HostBridge {
|
|
|
2072
2073
|
try {
|
|
2073
2074
|
const sc = this.#sc();
|
|
2074
2075
|
const req = {};
|
|
2075
|
-
if (typeof p.cwd === "string" && p.cwd !== "")
|
|
2076
|
+
if (typeof p.cwd === "string" && p.cwd !== "") {
|
|
2077
|
+
// v1.1.4:cwd 若命中某个**已注册工作区**的目录,改传 `workspaceId`
|
|
2078
|
+
// 让会话自动归到该工作区下面(与 PC 端「在工作区里新建」一致——
|
|
2079
|
+
// PC 走 createInWorkspace → createNamed({workspaceId}))。
|
|
2080
|
+
// 旧实现只传 cwd,宿主不会 attach 到任何工作区 → PC 上显示「未分组」。
|
|
2081
|
+
// 未命中(普通目录)保持传 cwd,与 PC 在任意目录新建一样 = 未分组。
|
|
2082
|
+
// resolveByPath 不创建工作区、不改写注册表;路径不存在会 reject → 兜底回 cwd。
|
|
2083
|
+
const ws = await this.#resolveWorkspaceByCwd(p.cwd);
|
|
2084
|
+
if (ws !== null) {
|
|
2085
|
+
req.workspaceId = ws;
|
|
2086
|
+
} else {
|
|
2087
|
+
req.cwd = p.cwd;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2076
2090
|
if (agentPreset !== "") req.agentPreset = agentPreset;
|
|
2077
2091
|
let value;
|
|
2078
2092
|
try {
|
|
@@ -2267,18 +2281,48 @@ export class HostBridge {
|
|
|
2267
2281
|
}
|
|
2268
2282
|
}
|
|
2269
2283
|
|
|
2270
|
-
/** 契约 §5.1/§5.8
|
|
2271
|
-
*
|
|
2272
|
-
*
|
|
2273
|
-
|
|
2284
|
+
/** 契约 §5.1/§5.8 session.model:查询会话当前模型/思考强度(v1.0.8 引入,
|
|
2285
|
+
* v1.1.4 数据源升级)。
|
|
2286
|
+
*
|
|
2287
|
+
* 权威数据源 = 宿主 **modelSelection 持久投影**(`sessionController.projections`
|
|
2288
|
+
* 的 `values.modelSelection`,视图形状 `{lastUsed, next}`,`next = pending ?? lastUsed`)。
|
|
2289
|
+
* 这与 DSH 桌面端 composer 显示的是**同一份**(dsh-client-ui-model-selection 的
|
|
2290
|
+
* syncInputs:`selection = projected.next ?? catalog.default`):
|
|
2291
|
+
* - `pending`:用户在会话里显式切换过、还没被请求消费的模型;
|
|
2292
|
+
* - `lastUsed`:上一个 `request/header` 实际使用的模型(旧实现完全漏掉它——
|
|
2293
|
+
* 从没显式切换过的会话在旧实现里永远回 null,手机端就总显示目录默认,
|
|
2294
|
+
* 与 PC 对不上,用户实测反馈);
|
|
2295
|
+
* - 两者都空(从未跑过也没选过的空白会话)→ null,客户端回退目录默认
|
|
2296
|
+
* (= PC 的 catalog.default 回退,天然一致)。
|
|
2297
|
+
*
|
|
2298
|
+
* 投影不可用(旧宿主没注册)/读取失败 → 退回 `model/selection` 直播事件维护的
|
|
2299
|
+
* 内存态(v1.0.8 行为);再没有 → null。**不得臆造**。 */
|
|
2300
|
+
async #rSessionModel(m) {
|
|
2274
2301
|
const p = m.payload ?? {};
|
|
2275
2302
|
const sessionId = typeof p.sessionId === "string" ? p.sessionId : "";
|
|
2276
2303
|
if (sessionId === "") {
|
|
2277
2304
|
this.#reply(m, errorOf(m, "bad-params", "sessionId required"));
|
|
2278
2305
|
return;
|
|
2279
2306
|
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2307
|
+
try {
|
|
2308
|
+
const sc = this.#sc();
|
|
2309
|
+
if (typeof sc.projections === "function") {
|
|
2310
|
+
const projections = await sc.projections({ sessionId }, this.#signal(10_000));
|
|
2311
|
+
const view = projections?.values?.modelSelection;
|
|
2312
|
+
if (view !== undefined && view !== null) {
|
|
2313
|
+
const model = mapModelSelection(view.next ?? view.lastUsed ?? null);
|
|
2314
|
+
this.#reply(m, resultOf(m, { model }));
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
} catch (e) {
|
|
2319
|
+
// 投影缺失/读取失败 → 退回直播事件内存态(不报错,静默降级)
|
|
2320
|
+
this.#log("warn", "modelSelection projection unavailable; falling back to live tracking", {
|
|
2321
|
+
sessionId,
|
|
2322
|
+
error: errText(e),
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
this.#reply(m, resultOf(m, { model: this.#modelSelections.get(sessionId) ?? null }));
|
|
2282
2326
|
}
|
|
2283
2327
|
|
|
2284
2328
|
/** 模式目录(宿主 Agent preset 目录)。服务缺失/抛错 → 空目录。 */
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"title": {
|
|
4
|
+
"en": "DSH Pocket Market",
|
|
5
|
+
"zh": "DSH Pocket 插件市场"
|
|
6
|
+
},
|
|
7
|
+
"description": {
|
|
8
|
+
"en": "Plugin index for DSH Pocket: remote-control DeepSeek Harness from a HarmonyOS phone over an end-to-end-encrypted relay.",
|
|
9
|
+
"zh": "DSH Pocket 的插件索引:通过端到端加密中继,用 HarmonyOS 手机遥控 DeepSeek Harness。"
|
|
10
|
+
},
|
|
11
|
+
"metadata": {
|
|
12
|
+
"categories": {
|
|
13
|
+
"remote-control": {
|
|
14
|
+
"title": {
|
|
15
|
+
"en": "Remote Control",
|
|
16
|
+
"zh": "远程控制"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"labels": {
|
|
21
|
+
"phone": {
|
|
22
|
+
"title": {
|
|
23
|
+
"en": "Phone",
|
|
24
|
+
"zh": "手机"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"e2e-encrypted": {
|
|
28
|
+
"title": {
|
|
29
|
+
"en": "End-to-end encrypted",
|
|
30
|
+
"zh": "端到端加密"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"sortKeys": {}
|
|
35
|
+
},
|
|
36
|
+
"plugins": [
|
|
37
|
+
{
|
|
38
|
+
"name": "@duke-dsh-plugins/dsh-remote-control",
|
|
39
|
+
"title": {
|
|
40
|
+
"en": "DSH Pocket",
|
|
41
|
+
"zh": "DSH Pocket 手机遥控"
|
|
42
|
+
},
|
|
43
|
+
"description": {
|
|
44
|
+
"en": "Control DeepSeek Harness from your phone: sessions, prompts, streamed replies, approvals, images and model switching over an E2E-encrypted relay. Fail-open by design. The relay can also be installed standalone (@duke-dsh-plugins/dsh-remote-control-relay) for VPS deployment.",
|
|
45
|
+
"zh": "在手机上遥控 DeepSeek Harness:会话、发送提示词、流式回复、审批应答、图片与模型切换,全程端到端加密。审批缺省放行(fail-open)。中继可独立安装(@duke-dsh-plugins/dsh-remote-control-relay)部署到 VPS。"
|
|
46
|
+
},
|
|
47
|
+
"icon": "https://raw.githubusercontent.com/MoonlitDropOfBlood/dsh-remote-control/main/plugin/icon.svg",
|
|
48
|
+
"author": "dukebywwh",
|
|
49
|
+
"homepage": "https://github.com/MoonlitDropOfBlood/dsh-remote-control#readme",
|
|
50
|
+
"repository": {
|
|
51
|
+
"url": "https://github.com/MoonlitDropOfBlood/dsh-remote-control",
|
|
52
|
+
"directory": "plugin"
|
|
53
|
+
},
|
|
54
|
+
"metadata": {
|
|
55
|
+
"category": "remote-control",
|
|
56
|
+
"keywords": [
|
|
57
|
+
"dsh",
|
|
58
|
+
"remote-control",
|
|
59
|
+
"harmonyos",
|
|
60
|
+
"phone",
|
|
61
|
+
"relay",
|
|
62
|
+
"e2e",
|
|
63
|
+
"approval"
|
|
64
|
+
],
|
|
65
|
+
"labels": [
|
|
66
|
+
"phone",
|
|
67
|
+
"e2e-encrypted"
|
|
68
|
+
],
|
|
69
|
+
"sortKeys": {}
|
|
70
|
+
},
|
|
71
|
+
"versions": [
|
|
72
|
+
{
|
|
73
|
+
"version": "1.1.5",
|
|
74
|
+
"publishTimestamp": 1793149102,
|
|
75
|
+
"source": {
|
|
76
|
+
"type": "npm"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"dsh": "^0.1.5-rc.3 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"version": "1.1.4",
|
|
84
|
+
"publishTimestamp": 1793036707,
|
|
85
|
+
"source": {
|
|
86
|
+
"type": "npm"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"dsh": "^0.1.5-rc.3 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"version": "1.1.3",
|
|
94
|
+
"publishTimestamp": 1793029637,
|
|
95
|
+
"source": {
|
|
96
|
+
"type": "npm"
|
|
97
|
+
},
|
|
98
|
+
"engines": {
|
|
99
|
+
"dsh": "^0.1.5-rc.3 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,75 +1,79 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@duke-dsh-plugins/dsh-remote-control",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Remote-control bridge for DeepSeek Harness: pairs a HarmonyOS phone app with the desktop Host over an end-to-end-encrypted public relay (WebSocket). Lets the phone list/create/switch sessions, send prompts, watch streamed replies, cancel turns, and answer approval and ask-user-question requests from anywhere; pushes Huawei Push Kit notifications (gracefully disabled when AGC is unconfigured) for approvals, questions, and turn completion. The pairing QR lives in the DSH settings panel (\"DSH Pocket\"). Fail-open by design: any relay timeout or fault hands the request back to the desktop answerer.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./index.js",
|
|
9
|
-
"./client": "./client.js",
|
|
10
|
-
"./typert": "./typert.host.js",
|
|
11
|
-
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
12
|
-
"./icon": "./icon.svg",
|
|
13
|
-
"./locale/*.json": "./locale/*.json",
|
|
14
|
-
"./package.json": "./package.json"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"index.js",
|
|
18
|
-
"client.js",
|
|
19
|
-
"typert.host.js",
|
|
20
|
-
"lib",
|
|
21
|
-
"vendor",
|
|
22
|
-
"cordis.patch.yml",
|
|
23
|
-
"icon.svg",
|
|
24
|
-
"locale"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"@deepseek-ai/
|
|
41
|
-
"@deepseek-ai/dsh
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"vendor:relay
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@duke-dsh-plugins/dsh-remote-control",
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"description": "Remote-control bridge for DeepSeek Harness: pairs a HarmonyOS phone app with the desktop Host over an end-to-end-encrypted public relay (WebSocket). Lets the phone list/create/switch sessions, send prompts, watch streamed replies, cancel turns, and answer approval and ask-user-question requests from anywhere; pushes Huawei Push Kit notifications (gracefully disabled when AGC is unconfigured) for approvals, questions, and turn completion. The pairing QR lives in the DSH settings panel (\"DSH Pocket\"). Fail-open by design: any relay timeout or fault hands the request back to the desktop answerer.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
10
|
+
"./typert": "./typert.host.js",
|
|
11
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
12
|
+
"./icon": "./icon.svg",
|
|
13
|
+
"./locale/*.json": "./locale/*.json",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.js",
|
|
18
|
+
"client.js",
|
|
19
|
+
"typert.host.js",
|
|
20
|
+
"lib",
|
|
21
|
+
"vendor",
|
|
22
|
+
"cordis.patch.yml",
|
|
23
|
+
"icon.svg",
|
|
24
|
+
"locale",
|
|
25
|
+
"market/index.json"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dsh": {
|
|
29
|
+
"bundle": {
|
|
30
|
+
"patch": "./cordis.patch.yml"
|
|
31
|
+
},
|
|
32
|
+
"client": {
|
|
33
|
+
"platform": "web"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"dsh": "^0.1.5-rc.3 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
41
|
+
"@deepseek-ai/dsh": "^0.1.5-rc.3 || ^0.2.0-rc.1 || ^0.2.1-rc.0",
|
|
42
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.7 || ^0.2.0-rc.1 || ^0.2.1-rc.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"@deepseek-ai/dsh": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"@deepseek-ai/cordis": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@deepseek-ai/dsh-typert-protocol": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"ws": "^8.18.1",
|
|
57
|
+
"zod": "^4.4.3"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"jsqr": "^1.4.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"vendor:relay": "node scripts/vendor-relay.mjs",
|
|
64
|
+
"vendor:relay:check": "node scripts/vendor-relay.mjs --check"
|
|
65
|
+
},
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "git+https://github.com/MoonlitDropOfBlood/dsh-remote-control.git",
|
|
69
|
+
"directory": "plugin"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/MoonlitDropOfBlood/dsh-remote-control/tree/main/plugin#readme",
|
|
72
|
+
"bugs": {
|
|
73
|
+
"url": "https://github.com/MoonlitDropOfBlood/dsh-remote-control/issues"
|
|
74
|
+
},
|
|
75
|
+
"keywords": [],
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
}
|
|
79
|
+
}
|