dsh-mobile-plugin 0.5.148 → 0.5.150
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/config/agent-presets/standard/skills/dsh-mobile-kb/references/frp.md +1 -1
- package/extension-registry/index.json +65 -0
- package/lib/cloudflared/runner.cjs +9 -0
- package/lib/cloudflared/wiring.cjs +1 -1
- package/lib/mobile/events.js +26 -1
- package/lib/mobile/voice/providers/cn/xfyun.js +20 -14
- package/lib/panel/index.html +13 -13
- package/lib/relay/firewall-probe.js +6 -1
- package/lib/routes/mobile-api.js +17 -1
- package/package.json +15 -14
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
## 选哪一档
|
|
15
15
|
|
|
16
16
|
- **有域名 + 证书:走 https 隧道(优先)。** frps 在公网 443 用证书终结 TLS,frpc 用 `type=https` + `customDomains` 把电脑的 `51887` 映射到域名。手机填 `https://域名` 到直连地址栏。这一档手机侧是 https,凭据不会被链路上的人看到。
|
|
17
|
-
- **只有公网 IP、没域名证书:走裸 TCP 兜底。** frpc 用 `type=tcp` 把 `51887` 映射到公网某个端口。手机填 `http://公网IP:端口`。代价要当面说清:公网这段是明文,配对令牌和请求头里的凭据会被看到;请求正文本身还有一层端到端加密,裸的是元数据和凭据这一层。iOS
|
|
17
|
+
- **只有公网 IP、没域名证书:走裸 TCP 兜底。** frpc 用 `type=tcp` 把 `51887` 映射到公网某个端口。手机填 `http://公网IP:端口`。代价要当面说清:公网这段是明文,配对令牌和请求头里的凭据会被看到;请求正文本身还有一层端到端加密,裸的是元数据和凭据这一层。iOS 上公网明文 `http`(IP 和域名都一样)会被系统明文限制挡住;手机 App 虽有转到本机入口再用底层连接送出的绕行设计,现场仍出现过填 `http://公网IP:端口` 不通、换 https 立刻通的情况,所以**不要把 IP:端口当成 iOS 上一定可用的兜底**。没有域名证书时优先试 TCP 直连栏(`主机:端口`,底层裸 TCP),或给 frp 套一层 TLS 反代;想让凭据在公网上加密,仍要回到 https 那档。
|
|
18
18
|
|
|
19
19
|
**关键一点别搞错**:手机侧的加密靠 frps 在公网口终结 TLS(https 那档),不是 frp 隧道内部那条 `transport.tls`——后者只保护 frpc↔frps 那一段。想要手机侧加密就必须让手机连的是 https 地址。
|
|
20
20
|
|
|
@@ -82,6 +82,71 @@
|
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "dsh-nearby",
|
|
88
|
+
"url": "https://github.com/Azhu9701/dsh-nearby",
|
|
89
|
+
"repository": {
|
|
90
|
+
"url": "https://github.com/Azhu9701/dsh-nearby"
|
|
91
|
+
},
|
|
92
|
+
"owner": "Azhu9701",
|
|
93
|
+
"title": {
|
|
94
|
+
"zh-Hans": "邻座 NextSeat",
|
|
95
|
+
"zh-Hant": "鄰座 NextSeat",
|
|
96
|
+
"en": "NextSeat",
|
|
97
|
+
"ja": "NextSeat",
|
|
98
|
+
"ko": "NextSeat",
|
|
99
|
+
"de": "NextSeat",
|
|
100
|
+
"es": "NextSeat",
|
|
101
|
+
"fr": "NextSeat",
|
|
102
|
+
"pt": "NextSeat",
|
|
103
|
+
"ru": "NextSeat",
|
|
104
|
+
"tr": "NextSeat"
|
|
105
|
+
},
|
|
106
|
+
"description": {
|
|
107
|
+
"zh-Hans": "从手机管理已配对电脑上的临时分享房间,发送文件、提示词和本地插件包。",
|
|
108
|
+
"zh-Hant": "從手機管理已配對電腦上的臨時分享房間,傳送檔案、提示詞和本機外掛套件。",
|
|
109
|
+
"en": "Manage temporary sharing rooms on your paired computer from your phone and send files, prompts, and local plugin packages.",
|
|
110
|
+
"ja": "スマートフォンからペアリング済みのパソコンの一時共有ルームを管理し、ファイル、プロンプト、ローカルプラグインのパッケージを送信できます。",
|
|
111
|
+
"ko": "휴대폰에서 페어링된 컴퓨터의 임시 공유 방을 관리하고 파일, 프롬프트, 로컬 플러그인 패키지를 보냅니다.",
|
|
112
|
+
"de": "Verwalte temporäre Freigaberäume auf deinem gekoppelten Computer vom Handy aus und sende Dateien, Prompts und lokale Plugin-Pakete.",
|
|
113
|
+
"es": "Gestiona desde el móvil salas temporales para compartir en tu ordenador emparejado y envía archivos, prompts y paquetes de complementos locales.",
|
|
114
|
+
"fr": "Gérez depuis votre téléphone les salons de partage temporaires sur votre ordinateur associé et envoyez des fichiers, des prompts et des paquets d’extensions locales.",
|
|
115
|
+
"pt": "Gerencie pelo celular salas temporárias de compartilhamento no computador pareado e envie arquivos, prompts e pacotes de plugins locais.",
|
|
116
|
+
"ru": "Управляйте с телефона временными комнатами обмена на сопряжённом компьютере и отправляйте файлы, запросы и пакеты локальных плагинов.",
|
|
117
|
+
"tr": "Telefonunuzdan eşleştirilmiş bilgisayarınızdaki geçici paylaşım odalarını yönetin ve dosya, istem ve yerel eklenti paketleri gönderin."
|
|
118
|
+
},
|
|
119
|
+
"npm": "dsh-nearby",
|
|
120
|
+
"category": "tools",
|
|
121
|
+
"stars": 0,
|
|
122
|
+
"downloads": null,
|
|
123
|
+
"icon": "https://raw.githubusercontent.com/Azhu9701/dsh-nearby/main/assets/icon-180.png",
|
|
124
|
+
"screenshots": [],
|
|
125
|
+
"capabilities": [
|
|
126
|
+
"host.data",
|
|
127
|
+
"file.pick",
|
|
128
|
+
"file.save"
|
|
129
|
+
],
|
|
130
|
+
"added": "2026-11-30",
|
|
131
|
+
"version": "0.8.0",
|
|
132
|
+
"purpose": null,
|
|
133
|
+
"ageRating": null,
|
|
134
|
+
"publicUrl": null,
|
|
135
|
+
"extensions": [
|
|
136
|
+
{
|
|
137
|
+
"slug": "dsh-nearby.nextseat",
|
|
138
|
+
"name": "邻座 NextSeat",
|
|
139
|
+
"purpose": "从手机管理已配对电脑上的邻座分享房间,分享文件、提示词和本地插件包。",
|
|
140
|
+
"sourceUrl": "https://github.com/Azhu9701/dsh-nearby",
|
|
141
|
+
"publicUrl": "https://ai-hub.wnluo.com/extensions/dsh-nearby.nextseat/",
|
|
142
|
+
"ageRating": null,
|
|
143
|
+
"capabilities": [
|
|
144
|
+
"host.data",
|
|
145
|
+
"file.pick",
|
|
146
|
+
"file.save"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
85
150
|
}
|
|
86
151
|
]
|
|
87
152
|
}
|
|
@@ -104,6 +104,8 @@ function createCloudflaredRunner(options = {}) {
|
|
|
104
104
|
let binary = '';
|
|
105
105
|
let error = '';
|
|
106
106
|
let startedAt = 0;
|
|
107
|
+
/** 这一轮「开始连」的时刻(毫秒);连上 / 掉线重连 / 停用都会重置。手机的连接超时靠它算。 */
|
|
108
|
+
let connectingSince = 0;
|
|
107
109
|
let url = '';
|
|
108
110
|
/** 边缘那条连接真的建立了没有。banner 地址出来不等于有它——`running` 只认这一格。 */
|
|
109
111
|
let registered = false;
|
|
@@ -166,6 +168,8 @@ function createCloudflaredRunner(options = {}) {
|
|
|
166
168
|
starting: Boolean(child) ? !registered : Boolean(starting),
|
|
167
169
|
retrying: retryTimer !== null,
|
|
168
170
|
waitingForPort,
|
|
171
|
+
/** 这一轮从开始连到现在过了多久(毫秒);已连上或没在连时为 0。手机据此判连接超时。 */
|
|
172
|
+
connectingForMs: registered ? 0 : (connectingSince > 0 ? Math.max(0, Date.now() - connectingSince) : 0),
|
|
169
173
|
enabled: !exists(paths.disabled),
|
|
170
174
|
};
|
|
171
175
|
}
|
|
@@ -189,6 +193,7 @@ function createCloudflaredRunner(options = {}) {
|
|
|
189
193
|
if (starting) { await starting; return status(); }
|
|
190
194
|
const token = ++generation;
|
|
191
195
|
const run = (async () => {
|
|
196
|
+
connectingSince = Date.now();
|
|
192
197
|
requestedLocalPort = localPort();
|
|
193
198
|
waitingForPort = requestedLocalPort === 0;
|
|
194
199
|
if (waitingForPort) { error = ''; return; }
|
|
@@ -245,6 +250,7 @@ function createCloudflaredRunner(options = {}) {
|
|
|
245
250
|
};
|
|
246
251
|
// 从「还没连上」重新计时:起进程时一次,掉线后再计一次。超时只写原因、不杀进程(它自己重试)。
|
|
247
252
|
const armConnectTimer = () => {
|
|
253
|
+
connectingSince = Date.now();
|
|
248
254
|
clearConnectTimer();
|
|
249
255
|
connectTimer = setConnectTimer(() => {
|
|
250
256
|
connectTimer = null;
|
|
@@ -269,6 +275,7 @@ function createCloudflaredRunner(options = {}) {
|
|
|
269
275
|
if (CONNECTED_RE.test(line)) {
|
|
270
276
|
registered = true;
|
|
271
277
|
error = '';
|
|
278
|
+
connectingSince = 0;
|
|
272
279
|
clearConnectTimer();
|
|
273
280
|
publish();
|
|
274
281
|
} else if (DISCONNECTED_RE.test(line) && registered) {
|
|
@@ -299,6 +306,7 @@ function createCloudflaredRunner(options = {}) {
|
|
|
299
306
|
runningLocalPort = 0;
|
|
300
307
|
url = '';
|
|
301
308
|
registered = false;
|
|
309
|
+
connectingSince = 0;
|
|
302
310
|
lineBuf = '';
|
|
303
311
|
// 进程没了,之前上报的地址一定连不上,先撤掉;重连成功会带着新地址再报一次。
|
|
304
312
|
withdrawAddress();
|
|
@@ -349,6 +357,7 @@ function createCloudflaredRunner(options = {}) {
|
|
|
349
357
|
url = '';
|
|
350
358
|
error = '';
|
|
351
359
|
registered = false;
|
|
360
|
+
connectingSince = 0;
|
|
352
361
|
lineBuf = '';
|
|
353
362
|
// 主动停用 / 卸载:地址必死,撤掉,别让总控还拿着它发给手机。
|
|
354
363
|
withdrawAddress();
|
|
@@ -66,7 +66,7 @@ function mountCloudflare(options) {
|
|
|
66
66
|
runner = host && host.runner ? host.runner : createCloudflaredRunner({ portOf, ipVersionPolicy: () => state.ipVersionPolicy });
|
|
67
67
|
} catch (error) {
|
|
68
68
|
warn('Cloudflare 隧道运行器创建失败:%s', error && error.message ? error.message : error);
|
|
69
|
-
const degraded = () => ({ available: false, running: false, pid: null, url: '', error: `Cloudflare 隧道初始化失败:${error && error.message ? error.message : error}`, startedAt: 0, starting: false, retrying: false, waitingForPort: false, enabled: false });
|
|
69
|
+
const degraded = () => ({ available: false, running: false, pid: null, url: '', error: `Cloudflare 隧道初始化失败:${error && error.message ? error.message : error}`, startedAt: 0, starting: false, retrying: false, waitingForPort: false, connectingForMs: 0, enabled: false });
|
|
70
70
|
return { start: async () => degraded(), stop: async () => degraded(), status: degraded, syncLocalPort: async () => degraded(), reconcile: async () => degraded() };
|
|
71
71
|
}
|
|
72
72
|
|
package/lib/mobile/events.js
CHANGED
|
@@ -26,6 +26,8 @@ const { writeSse: sharedWriteSse, stableEventId: sharedEventId, waitForDrain } =
|
|
|
26
26
|
const DEDUP_WINDOW = 2048;
|
|
27
27
|
/** 心跳帧间隔。App 用它判定「这条流真的还活着」,必须与 app 侧的 SIGNAL_HEARTBEAT_MS 一致。 */
|
|
28
28
|
const HEARTBEAT_MS = 15_000;
|
|
29
|
+
/** 线路现场「变了才推」的巡检间隔:比对归一化快照,值真的变了才发一帧。 */
|
|
30
|
+
const ROUTE_STATE_POLL_MS = 2_000;
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* 诊断日志。失败路径一条都不许静默:手机把兜底轮询降成 3 分钟,宿主日志里却查不到这条流是
|
|
@@ -138,7 +140,7 @@ function listRelevantPayload(rawPayload) {
|
|
|
138
140
|
* Device-wide compatibility stream. The mux frame remains intact in `payload`;
|
|
139
141
|
* the envelope only provides a stable event identity for future clients.
|
|
140
142
|
*/
|
|
141
|
-
async function handleDeviceStream(ctx, req, res) {
|
|
143
|
+
async function handleDeviceStream(ctx, req, res, extra = {}) {
|
|
142
144
|
// 协议 v2:与 /session/stream 一样逐帧封装,头必须在 writeHead 之前声明。
|
|
143
145
|
const sealFrame = createFrameSealer(req);
|
|
144
146
|
try {
|
|
@@ -267,6 +269,28 @@ async function handleDeviceStream(ctx, req, res) {
|
|
|
267
269
|
// 定时器不该拖住进程退出(同 lib/sidecar-facade-worker.cjs 的 shutdown)。测试里的
|
|
268
270
|
// setInterval 桩没有 unref,先判类型。
|
|
269
271
|
if (keepAlive && typeof keepAlive.unref === 'function') keepAlive.unref();
|
|
272
|
+
// 变化即推:电脑自己握着的线路现场(中转地址 / P2P / Cloudflare / 第三方线路清单)变了,
|
|
273
|
+
// 就在这条已经挂着的流上发一帧 device/route-state,手机收到立刻补拉一次状态,不必等 30 秒心跳。
|
|
274
|
+
// 快照只取**稳定字段**(去掉每拍都在涨的 connectingForMs、candidates 明细等),否则会变成每拍都推。
|
|
275
|
+
const getRouteState = extra && typeof extra.getRouteState === 'function' ? extra.getRouteState : null;
|
|
276
|
+
let lastRouteJson = null;
|
|
277
|
+
const routeTimer = getRouteState ? setInterval(() => {
|
|
278
|
+
if (ac.signal.aborted) return;
|
|
279
|
+
let snapshot; let json;
|
|
280
|
+
try { snapshot = getRouteState(); json = JSON.stringify(snapshot); } catch { return; }
|
|
281
|
+
if (json === lastRouteJson) return;
|
|
282
|
+
lastRouteJson = json;
|
|
283
|
+
if (!writeFrame({ type: 'device/route-state', state: snapshot, at: Date.now() })) ac.abort();
|
|
284
|
+
}, ROUTE_STATE_POLL_MS) : null;
|
|
285
|
+
if (routeTimer && typeof routeTimer.unref === 'function') routeTimer.unref();
|
|
286
|
+
// 连上先补一帧当前现场,手机据此对齐(与本条流其它补发同口径)。
|
|
287
|
+
if (getRouteState) {
|
|
288
|
+
try {
|
|
289
|
+
const snapshot = getRouteState();
|
|
290
|
+
lastRouteJson = JSON.stringify(snapshot);
|
|
291
|
+
if (!writeFrame({ type: 'device/route-state', state: snapshot, at: Date.now() })) ac.abort();
|
|
292
|
+
} catch { /* 取不到就不补 */ }
|
|
293
|
+
}
|
|
270
294
|
const seenEventIds = new Set();
|
|
271
295
|
const seenEventOrder = [];
|
|
272
296
|
// 「客户端走了」与「循环正常结束」必须分开:前者不该再写日志说流被关,后者要留痕,
|
|
@@ -328,6 +352,7 @@ async function handleDeviceStream(ctx, req, res) {
|
|
|
328
352
|
logDeviceStream('mux loop threw', error);
|
|
329
353
|
}
|
|
330
354
|
clearInterval(keepAlive);
|
|
355
|
+
if (routeTimer) clearInterval(routeTimer);
|
|
331
356
|
unsubscribeSignal();
|
|
332
357
|
unsubscribeActivity();
|
|
333
358
|
releaseSignal();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 讯飞实时语音转写(RTASR
|
|
1
|
+
// 讯飞实时语音转写(RTASR 标准版)适配器:WebSocket + appid/ts(秒)/signa 签名,二进制 PCM 帧上送。
|
|
2
2
|
// 签名在插件侧完成(Base64(HmacSHA1(MD5(appid+ts), apiKey))),手机和面板都拿不到 apiKey。
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -6,6 +6,7 @@ const crypto = require('node:crypto');
|
|
|
6
6
|
const WebSocket = require('ws');
|
|
7
7
|
|
|
8
8
|
const DEFAULT_ENDPOINT = 'wss://rtasr.xfyun.cn/v1/ws';
|
|
9
|
+
const END_MARKER = Buffer.from('{"end": true}');
|
|
9
10
|
const CONNECT_TIMEOUT_MS = 10_000;
|
|
10
11
|
const IDLE_TIMEOUT_MS = 15_000;
|
|
11
12
|
const FINISH_TIMEOUT_MS = 10_000;
|
|
@@ -53,21 +54,26 @@ function configReady(config) {
|
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// 官方逐句结构:cn.st.rt[].ws[].cw[].w,rt 是一句、ws 是一字。
|
|
58
|
+
function sentenceText(rt) {
|
|
59
|
+
const words = rt && Array.isArray(rt.ws) ? rt.ws : [];
|
|
60
|
+
return words.map((ws) => (ws && Array.isArray(ws.cw)
|
|
61
|
+
? ws.cw.map((cw) => (cw && typeof cw.w === 'string' ? cw.w : '')).join('')
|
|
62
|
+
: '')).join('');
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
//
|
|
65
|
+
// 讯飞 RTASR 标准版结果:data 是 JSON 字符串,解析后取 cn.st.rt[];st.type=0 为定稿、1 为中间结果。
|
|
62
66
|
function readResultPayload(raw) {
|
|
63
67
|
let data = raw;
|
|
64
68
|
if (typeof raw === 'string') {
|
|
65
69
|
try { data = JSON.parse(raw); } catch { return null; }
|
|
66
70
|
}
|
|
67
71
|
if (!data || typeof data !== 'object') return null;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const st = data.cn && data.cn.st;
|
|
73
|
+
if (!st || typeof st !== 'object') return null;
|
|
74
|
+
const rt = Array.isArray(st.rt) ? st.rt : [];
|
|
75
|
+
const text = rt.map(sentenceText).join('');
|
|
76
|
+
return { text, definite: st.type === '0' || st.type === 0 };
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
module.exports = {
|
|
@@ -114,7 +120,7 @@ module.exports = {
|
|
|
114
120
|
const langKey = String(h.lang || 'zh').toLowerCase();
|
|
115
121
|
const lang = LANG_MAP[langKey] || LANG_MAP.zh;
|
|
116
122
|
|
|
117
|
-
const ts = String(Date.now());
|
|
123
|
+
const ts = String(Math.floor(Date.now() / 1000));
|
|
118
124
|
const params = new URLSearchParams({
|
|
119
125
|
appid: appId,
|
|
120
126
|
ts,
|
|
@@ -185,13 +191,13 @@ module.exports = {
|
|
|
185
191
|
idleTimer = setTimeout(() => fail(voiceError('voice-timeout', '讯飞长时间没有返回结果')), IDLE_TIMEOUT_MS);
|
|
186
192
|
}
|
|
187
193
|
|
|
188
|
-
function
|
|
194
|
+
function sendBinary(payload) {
|
|
189
195
|
if (!socket || socket.readyState !== WebSocket.OPEN) return;
|
|
190
|
-
socket.send(
|
|
196
|
+
socket.send(payload);
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
function sendAudio(pcm) {
|
|
194
|
-
|
|
200
|
+
sendBinary(pcm);
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
function onAbort() {
|
|
@@ -240,7 +246,7 @@ module.exports = {
|
|
|
240
246
|
clearTimeout(connectTimer);
|
|
241
247
|
for (const pcm of pendingAudio) sendAudio(pcm);
|
|
242
248
|
pendingAudio.length = 0;
|
|
243
|
-
if (finishRequested)
|
|
249
|
+
if (finishRequested) sendBinary(END_MARKER);
|
|
244
250
|
armIdle();
|
|
245
251
|
});
|
|
246
252
|
|
|
@@ -274,7 +280,7 @@ module.exports = {
|
|
|
274
280
|
if (settled || finishRequested) return;
|
|
275
281
|
finishRequested = true;
|
|
276
282
|
if (!opened) return;
|
|
277
|
-
|
|
283
|
+
sendBinary(END_MARKER);
|
|
278
284
|
clearTimeout(idleTimer);
|
|
279
285
|
finishTimer = setTimeout(() => succeed(), FINISH_TIMEOUT_MS);
|
|
280
286
|
},
|