dsh-mobile-plugin 0.5.65 → 0.5.66
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/lib/client.js +457 -86
- package/lib/frpc/runner.cjs +12 -6
- package/lib/mobile/host-bridge/session-model.js +7 -2
- package/lib/panel/index.html +11 -11
- package/lib/routes/control-plane.js +6 -0
- package/package.json +1 -1
package/lib/frpc/runner.cjs
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* 所以每次启动前都把配置里的 `localPort` 改成当前实际端口,再写盘、再起 frpc。
|
|
12
12
|
*
|
|
13
13
|
* 进程退出/起不来一律记进 `error`,不抛给调用方;`status()` 回一份可渲染的事实。frpc 自己会
|
|
14
|
-
* 对 frps
|
|
14
|
+
* 对 frps 重试,进程不会因为连不上服务器就退出,所以这里不做进程级自动重启。退出原因取自
|
|
15
|
+
* 两路输出的尾部(frpc 把致命原因写在 stdout),且等 `close` 收全流再拼,别让人只看到退出码。
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
const fs = require('node:fs');
|
|
@@ -181,14 +182,19 @@ function createFrpcRunner(options = {}) {
|
|
|
181
182
|
remoteAddress = '';
|
|
182
183
|
startedAt = Date.now();
|
|
183
184
|
let tail = '';
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
// 两路输出都要收:frpc 把致命原因(token 错、配置解析失败、端口占用、登录失败退出)
|
|
186
|
+
// 写在 stdout 上,只收 stderr 时用户只会看到「frpc 已退出(code=1)」这么一句。
|
|
187
|
+
for (const stream of [proc.stdout, proc.stderr]) {
|
|
188
|
+
if (!stream || typeof stream.on !== 'function') continue;
|
|
189
|
+
if (typeof stream.setEncoding === 'function') stream.setEncoding('utf8');
|
|
190
|
+
stream.on('data', (chunk) => { tail = (tail + String(chunk)).slice(-1500); });
|
|
187
191
|
}
|
|
188
192
|
if (typeof proc.on === 'function') {
|
|
189
193
|
proc.on('error', (err) => { error = `frpc 进程出错:${err && err.message ? err.message : err}`; });
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
// 用 close 而不是 exit:exit 触发时 stdio 里可能还有没读完的输出,太早拼文案会把
|
|
195
|
+
// 刚写出来的原因丢掉;close 保证流都关了、tail 收全。
|
|
196
|
+
proc.on('close', (code, signal) => {
|
|
197
|
+
if (!child || child !== proc) return;
|
|
192
198
|
child = null;
|
|
193
199
|
remoteAddress = '';
|
|
194
200
|
const lastLine = tail.trim() ? tail.trim().split('\n').pop() : '';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** 手机模型选择等待宿主服务就绪,只写当前会话;缺能力时区分「宿主太老」与「这条会话没有可切模型」。 */
|
|
2
2
|
'use strict';
|
|
3
3
|
const { ok, fail, unsupported } = require('./transport.js');
|
|
4
4
|
|
|
@@ -21,7 +21,12 @@ async function selectSessionModel(ctx, payload) {
|
|
|
21
21
|
const resolved = await controller.resolveAgent(payload.sessionId);
|
|
22
22
|
if (resolved.error) return fail(resolved.error);
|
|
23
23
|
const agent = resolved.agent;
|
|
24
|
-
|
|
24
|
+
// 会话恢复出来了,但这类会话本身没有可切换的模型(特殊会话/子代理):问题在会话,不在版本。
|
|
25
|
+
if (!agent || !agent.model) {
|
|
26
|
+
return fail({ code: 'host-unsupported', message: '这条会话当前没有可切换的模型' });
|
|
27
|
+
}
|
|
28
|
+
// 会话有模型对象却没有 select:是宿主 Agent.model 能力缺失,确实要更新宿主。
|
|
29
|
+
if (typeof agent.model.select !== 'function') {
|
|
25
30
|
return unsupported('仅切换当前会话模型的能力');
|
|
26
31
|
}
|
|
27
32
|
const selected = { provider: payload.provider, model: payload.model,
|