dsh-mobile-plugin 0.5.113 → 0.5.115
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/cloudflared/runner.cjs +25 -6
- package/lib/impl.js +18 -10
- package/lib/mobile/feedback-watch.cjs +33 -91
- package/lib/mobile/feedback.js +8 -8
- package/lib/panel/index.html +15 -15
- package/lib/relay/connection-check.js +39 -1
- package/lib/relay/lan-network.cjs +8 -22
- package/lib/relay/lan-port-policy.cjs +3 -1
- package/lib/relay/preview.js +29 -10
- package/lib/relay/status.js +2 -2
- package/lib/routes/control-plane.js +48 -2
- package/lib/zeronews/runner.cjs +53 -9
- package/package.json +13 -14
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Cloudflare 快速隧道的进程起停、banner 地址解析、连没连上边缘、崩溃退避重连与用户开关标记。
|
|
2
2
|
// 内置保底隧道默认开:标记文件记的是「用户显式关掉」,没有这个文件就算开着。
|
|
3
|
+
// 进程消失以 exit 为准(stdio 管道被占时 close 可能不来),exit/close 共用幂等清理;spawn error 也清 child 并撤回地址。
|
|
3
4
|
'use strict';
|
|
4
5
|
|
|
5
6
|
/** 本机 cloudflared 快速隧道的进程生命周期管理。 */
|
|
@@ -270,10 +271,16 @@ function createCloudflaredRunner(options = {}) {
|
|
|
270
271
|
stream.on('data', consume);
|
|
271
272
|
}
|
|
272
273
|
if (typeof proc.on === 'function') {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
/** 进程没了的最终原因;close 到得晚、输出更全,用它覆盖 exit 时那句粗略的原因。 */
|
|
275
|
+
const setGoneError = (code, signal) => {
|
|
276
|
+
const lastLine = tail.trim() ? tail.trim().split('\n').pop() : '';
|
|
277
|
+
error = `cloudflared 已退出(code=${code}${signal ? `, ${signal}` : ''})${lastLine ? `:${lastLine}` : ''}`;
|
|
278
|
+
};
|
|
279
|
+
let gone = false;
|
|
280
|
+
/** exit 和 close 共用的幂等清理:谁先到谁做一次,管道被占住时 close 不来就靠 exit 兜底。 */
|
|
281
|
+
const onGone = (code, signal) => {
|
|
282
|
+
if (gone) return;
|
|
283
|
+
gone = true;
|
|
277
284
|
clearConnectTimer();
|
|
278
285
|
child = null;
|
|
279
286
|
runningLocalPort = 0;
|
|
@@ -282,9 +289,21 @@ function createCloudflaredRunner(options = {}) {
|
|
|
282
289
|
lineBuf = '';
|
|
283
290
|
// 进程没了,之前上报的地址一定连不上,先撤掉;重连成功会带着新地址再报一次。
|
|
284
291
|
withdrawAddress();
|
|
285
|
-
|
|
286
|
-
error = `cloudflared 已退出(code=${code}${signal ? `, ${signal}` : ''})${lastLine ? `:${lastLine}` : ''}`;
|
|
292
|
+
setGoneError(code, signal);
|
|
287
293
|
scheduleRestart();
|
|
294
|
+
};
|
|
295
|
+
proc.on('error', (err) => {
|
|
296
|
+
if (child !== proc || gone) return;
|
|
297
|
+
error = describeSpawnFailure(err, binary);
|
|
298
|
+
// spawn 失败时 child 还挂着,不清掉 launch() 里的 if(child) return 会永久卡死。
|
|
299
|
+
child = null;
|
|
300
|
+
withdrawAddress();
|
|
301
|
+
scheduleRestart();
|
|
302
|
+
});
|
|
303
|
+
proc.on('exit', (code, signal) => { if (child === proc) onGone(code, signal); });
|
|
304
|
+
proc.on('close', (code, signal) => {
|
|
305
|
+
if (child === proc) onGone(code, signal);
|
|
306
|
+
else if (gone) setGoneError(code, signal);
|
|
288
307
|
});
|
|
289
308
|
}
|
|
290
309
|
})();
|
package/lib/impl.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// 热重载跨代:隧道助手/点对点的父地址取值器改为挂载时缓存,回滚或半装载后不再现读失效 ctx.webServer。
|
|
2
|
+
// 本次改动:网页版预览的宿主绑定地址随 ctx.webServer.host 传入,老宿主缺省时维持环回行为。
|
|
1
3
|
// 兼容服务挂不上时按本代装载失败处理,交给外壳重试,不再静默当成功。
|
|
2
4
|
// Cloudflare 兜底隧道:本地装配 cloudflared runner,把快速隧道地址写进独立字段 cloudflareUrl(作为新线路 kind:'cf' 上报,不再写直连格)。
|
|
3
5
|
// 身份变更同时迁移三类连接登记,主动重连独立于普通配置同步。
|
|
@@ -320,29 +322,33 @@ function apply(ctx) {
|
|
|
320
322
|
// 隧道状态取值器在下面 sidecar 装配完成后才拿到,这里先放占位,装配完换成权威那个。
|
|
321
323
|
let relayConnectedOf = () => false
|
|
322
324
|
// 总控上报客户端在 sidecar 装配之后创建(`advertisedLanPort` 依赖 sidecar),见下方。
|
|
325
|
+
// 父进程地址(宿主 web 的端口 / 绑定地址)在这一代挂载时取一次缓存住。下面交给稳定外壳的
|
|
326
|
+
// 隧道助手 / 点对点 provider 取值器会被外壳**跨代**持有并回调:换代回滚或半装载失败时,交出
|
|
327
|
+
// 这些闭包的那一代 ctx 已 inactive,现读 `ctx.webServer` 会抛 "cannot get required service
|
|
328
|
+
// webServer in inactive context",经 tunnel-forwarder 的 forwardRequest 放大成 Host 致命异常
|
|
329
|
+
// (GitHub issue #42)。宿主 web 端口 / 绑定地址在进程生命周期内固定,缓存值与现读一致。
|
|
330
|
+
const webPortForSidecar = ctx.webServer.port
|
|
331
|
+
const webHostForSidecar = ctx.webServer.host
|
|
323
332
|
let tailcatHost = null
|
|
324
333
|
try { tailcatHost = typeof ctx.get === 'function' ? ctx.get('dshMobileTransportTailcat') || null : null } catch { tailcatHost = null }
|
|
325
334
|
// 直连隧道:优先用稳定外壳持有的那份(换代不重建入口/助手,直连不断);外壳不在时本地挂载兜底。
|
|
326
|
-
const tailcatProviders = { getState: () => state, saveState: s => core.saveState(s), lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () =>
|
|
335
|
+
const tailcatProviders = { getState: () => state, saveState: s => core.saveState(s), lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => webPortForSidecar, webHost: () => webHostForSidecar, hostName: () => state.name }
|
|
327
336
|
const tailcat = tailcatHost && typeof tailcatHost.ensure === 'function'
|
|
328
337
|
? tailcatHost.ensure({ providers: tailcatProviders, mount: mountTailcat, fingerprint: tailcatFingerprint() })
|
|
329
|
-
: mountTailcat({ mount, warn, state, saveState: core.saveState, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () =>
|
|
338
|
+
: mountTailcat({ mount, warn, state, saveState: core.saveState, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => webPortForSidecar, webHost: () => webHostForSidecar, hostName: () => state.name, ctx, name })
|
|
330
339
|
let p2pHost = null
|
|
331
340
|
try { p2pHost = typeof ctx.get === 'function' ? ctx.get('dshMobileTransportP2P') || null : null } catch { p2pHost = null }
|
|
332
341
|
// 点对点隧道:优先用稳定外壳持有的那份(换代不重建助手/落点,直连不断);外壳不在时本地挂载兜底。
|
|
333
|
-
const p2pProviders = { getState: () => state, saveState: s => core.saveState(s), localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () =>
|
|
342
|
+
const p2pProviders = { getState: () => state, saveState: s => core.saveState(s), localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => webPortForSidecar, webHost: () => webHostForSidecar }
|
|
334
343
|
const p2p = p2pHost && typeof p2pHost.ensure === 'function'
|
|
335
344
|
? p2pHost.ensure({ providers: p2pProviders, mount: mountP2P, fingerprint: p2pFingerprint() })
|
|
336
|
-
: mountP2P({ mount, warn, state, saveState: core.saveState, localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () =>
|
|
345
|
+
: mountP2P({ mount, warn, state, saveState: core.saveState, localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => webPortForSidecar, webHost: () => webHostForSidecar, ctx, name })
|
|
337
346
|
|
|
338
347
|
// sidecar 子进程的全部生命周期:起停、配置下发、自重启、健康轮询。
|
|
339
348
|
// **传输进程归稳定外壳**:优先取外壳持有的那份(换代时它不重启,隧道跨代存活);外壳不在
|
|
340
349
|
// (实现被单独挂载 / 测试)时退回本地创建,行为与从前一致。配置由这一代组装后交给它。
|
|
341
|
-
//
|
|
342
|
-
//
|
|
343
|
-
// in inactive context",导致重启与配置下发全失败(隧道、frpc、P2P 都起不来)。
|
|
344
|
-
const webPortForSidecar = ctx.webServer.port
|
|
345
|
-
const webHostForSidecar = ctx.webServer.host
|
|
350
|
+
// 下发配置的闭包同样会被外壳持有的 sidecar 跨代调用,沿用上面挂载时缓存的父端口 / 绑定地址,
|
|
351
|
+
// 免得本代 ctx 已 inactive 时现读 ctx.webServer 抛错,把重启与配置下发全打挂(隧道、frpc、P2P)。
|
|
346
352
|
const buildSidecarConfig = (lanPort) => ({ enabled: state.enabled, relayUrl: state.relayUrl, relayUrls: core.relayAddressesOf(state).relayUrls, instanceId: state.instanceId, previousInstanceId: state.previousInstanceId || '', pairingCode: state.pairingCode, pairingTicket: state.pairingTicket || '', pairingTier: permissions.isKnownTier(state.pairingTier) ? state.pairingTier : permissions.DEFAULT_TIER, name: state.name, upstreamPort: webPortForSidecar, upstreamHost: webHostForSidecar, lanPort, lanPortLockReason: portLock(), lanEnabled: effectiveLanEnabled(), lanSecret: state.lanSecret, registerSecret: state.registerSecret })
|
|
347
353
|
let hostedSidecar = null
|
|
348
354
|
try { hostedSidecar = typeof ctx.get === 'function' ? ctx.get('dshMobileSidecarHost') || null : null } catch { hostedSidecar = null }
|
|
@@ -663,7 +669,8 @@ function apply(ctx) {
|
|
|
663
669
|
// 「把桌面端 GUI 搬进手机」这件事。
|
|
664
670
|
//
|
|
665
671
|
// `ownWebPort` 是同一条边界上的唯一例外:用户显式要求手机能打开网页版(2026-11-03),
|
|
666
|
-
// 所以 `mode=webapp`
|
|
672
|
+
// 所以 `mode=webapp` 那一档只放行这一个端口(目标主机还得是环回或宿主绑定地址)。同样用取值器。
|
|
673
|
+
// `ownWebHost` 跟随宿主实际绑定地址:网页版管道必须拨它,否则宿主绑在局域网地址上时手机侧两发拨空。
|
|
667
674
|
const preview = createPreviewService({
|
|
668
675
|
authorized: (req) => {
|
|
669
676
|
const outcome = authOutcome(req)
|
|
@@ -678,6 +685,7 @@ function apply(ctx) {
|
|
|
678
685
|
return ports
|
|
679
686
|
},
|
|
680
687
|
ownWebPort: () => ctx.webServer.port,
|
|
688
|
+
ownWebHost: () => ctx.webServer.host,
|
|
681
689
|
permission: permissions.createUpgradePermission({ credentials, instanceId: state.instanceId, presentedCredential }),
|
|
682
690
|
onLog: (message) => ctx.logger?.info?.(`${name}: %s`, message),
|
|
683
691
|
})
|
|
@@ -1,106 +1,48 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 用途:轮询平台现有反馈读取端点,等线程里出现第一条新官方回复;超时给改用 read 的提示。
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const FEEDBACK_EVENTS_PATH = '/api/sdk/feedback/events';
|
|
6
|
-
const DEFAULT_TIMEOUT_MS = 5 * 60_000;
|
|
4
|
+
const { readFeedback } = require('./feedback-read.cjs');
|
|
7
5
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** 只认 id 大于水位、作者是官方的 reply;其余帧都不算回复。 */
|
|
14
|
-
function staffReplyOf(event, data, afterMessageId) {
|
|
15
|
-
if (event !== 'reply' || !data) return null;
|
|
16
|
-
let payload = null;
|
|
17
|
-
try { payload = JSON.parse(data); } catch { return null; }
|
|
18
|
-
if (!payload || typeof payload.id !== 'number' || payload.id <= afterMessageId || payload.author !== 'staff') return null;
|
|
19
|
-
return {
|
|
20
|
-
id: payload.id,
|
|
21
|
-
author: 'staff',
|
|
22
|
-
content: typeof payload.content === 'string' ? payload.content : '',
|
|
23
|
-
created_at: typeof payload.created_at === 'string' ? payload.created_at : '',
|
|
24
|
-
};
|
|
25
|
-
}
|
|
6
|
+
/** 两秒一问、最多两分钟;不是长连接,到点就停,不无限等。 */
|
|
7
|
+
const DEFAULT_INTERVAL_MS = 2_000;
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 2 * 60_000;
|
|
9
|
+
const TIMEOUT_MESSAGE = '暂时没收到回复,请用 read 查看';
|
|
26
10
|
|
|
27
11
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
12
|
+
* 轮询现有 /api/sdk/feedback(与 read 同一端点)等第一条官方回复。
|
|
13
|
+
* 只读公开反馈,不读凭据、不碰会话内容。
|
|
14
|
+
*
|
|
15
|
+
* 选项:afterMessageId(已见过的最大 id,默认 0)、intervalMs(默认 2 秒)、
|
|
16
|
+
* timeoutMs(默认 2 分钟)。平台没有公开事件流可用,所以每轮沿用 read 的线程视图,
|
|
17
|
+
* 取第一条 author 为 staff 且 id 大于水位的消息;提交后立刻到达的回复也在第一轮被看到。
|
|
18
|
+
* 到点仍无回复返回 { timedOut: true, message };HTTP 与网络错误照状态抛出。
|
|
33
19
|
*/
|
|
34
20
|
async function watchFeedback(threadKey, options = {}) {
|
|
35
21
|
const key = typeof threadKey === 'string' ? threadKey.trim() : '';
|
|
36
|
-
if (!key) throw
|
|
22
|
+
if (!key) throw Object.assign(new Error('watch 需要 threadKey'), { status: 400 });
|
|
37
23
|
const opts = options && typeof options === 'object' ? options : {};
|
|
38
24
|
const afterMessageId = Number.isFinite(opts.afterMessageId) ? opts.afterMessageId : 0;
|
|
39
25
|
const timeoutMs = Number.isFinite(opts.timeoutMs) && opts.timeoutMs > 0 ? opts.timeoutMs : DEFAULT_TIMEOUT_MS;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} catch { /* 非 JSON 错误体按状态码报 */ }
|
|
56
|
-
}
|
|
57
|
-
throw feedbackError(message || `反馈订阅失败(HTTP ${response.status})`, response.status);
|
|
58
|
-
}
|
|
59
|
-
if (!response.body || typeof response.body.getReader !== 'function') {
|
|
60
|
-
throw feedbackError('反馈订阅没有返回事件流', 502);
|
|
61
|
-
}
|
|
62
|
-
reader = response.body.getReader();
|
|
63
|
-
const decoder = new TextDecoder();
|
|
64
|
-
let buffer = '';
|
|
65
|
-
let event = '';
|
|
66
|
-
let data = '';
|
|
67
|
-
for (;;) {
|
|
68
|
-
const { done, value } = await reader.read();
|
|
69
|
-
if (done) break;
|
|
70
|
-
buffer += decoder.decode(value, { stream: true });
|
|
71
|
-
let index;
|
|
72
|
-
while ((index = buffer.indexOf('\n')) >= 0) {
|
|
73
|
-
let line = buffer.slice(0, index);
|
|
74
|
-
buffer = buffer.slice(index + 1);
|
|
75
|
-
if (line.endsWith('\r')) line = line.slice(0, -1);
|
|
76
|
-
if (line === '') {
|
|
77
|
-
const reply = staffReplyOf(event, data, afterMessageId);
|
|
78
|
-
if (reply) return reply;
|
|
79
|
-
event = '';
|
|
80
|
-
data = '';
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (line.startsWith(':')) continue; // 心跳注释
|
|
84
|
-
const colon = line.indexOf(':');
|
|
85
|
-
const field = colon === -1 ? line : line.slice(0, colon);
|
|
86
|
-
let valueText = colon === -1 ? '' : line.slice(colon + 1);
|
|
87
|
-
if (valueText.startsWith(' ')) valueText = valueText.slice(1);
|
|
88
|
-
if (field === 'event') event = valueText;
|
|
89
|
-
else if (field === 'data') data = data ? `${data}\n${valueText}` : valueText;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const pending = staffReplyOf(event, data, afterMessageId);
|
|
93
|
-
if (pending) return pending;
|
|
94
|
-
return { timedOut: true };
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if (error && (error.name === 'AbortError' || controller.signal.aborted)) return { timedOut: true };
|
|
97
|
-
throw error;
|
|
98
|
-
} finally {
|
|
99
|
-
clearTimeout(timer);
|
|
100
|
-
if (reader) {
|
|
101
|
-
try { await reader.cancel(); } catch { /* 流已被服务端收掉 */ }
|
|
26
|
+
const intervalMs = Number.isFinite(opts.intervalMs) && opts.intervalMs > 0 ? opts.intervalMs : DEFAULT_INTERVAL_MS;
|
|
27
|
+
const deadline = Date.now() + timeoutMs;
|
|
28
|
+
|
|
29
|
+
for (;;) {
|
|
30
|
+
const thread = await readFeedback(key);
|
|
31
|
+
const messages = Array.isArray(thread?.messages) ? thread.messages : [];
|
|
32
|
+
const reply = messages.find((message) => message && message.author === 'staff'
|
|
33
|
+
&& typeof message.id === 'number' && message.id > afterMessageId);
|
|
34
|
+
if (reply) {
|
|
35
|
+
return {
|
|
36
|
+
id: reply.id,
|
|
37
|
+
author: 'staff',
|
|
38
|
+
content: reply.content,
|
|
39
|
+
created_at: reply.created_at,
|
|
40
|
+
};
|
|
102
41
|
}
|
|
42
|
+
const remaining = deadline - Date.now();
|
|
43
|
+
if (remaining <= 0) return { timedOut: true, message: TIMEOUT_MESSAGE };
|
|
44
|
+
await new Promise(resolve => setTimeout(resolve, Math.min(intervalMs, remaining)));
|
|
103
45
|
}
|
|
104
46
|
}
|
|
105
47
|
|
|
106
|
-
module.exports = { watchFeedback };
|
|
48
|
+
module.exports = { DEFAULT_INTERVAL_MS, DEFAULT_TIMEOUT_MS, TIMEOUT_MESSAGE, watchFeedback };
|
package/lib/mobile/feedback.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 用途:插件反馈统一提交、读取与轮询等回复口;工具和本机面板按线程查看官方回复、继续跟进。
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - **分发平台**:公开反馈接口(`/api/sdk/feedback`)。明确指定设备号时带上那台手机的
|
|
11
11
|
* 身份;没指定时用这台电脑上的插件安装身份;没配手机时依然能交,受影响手机那几格留空。
|
|
12
12
|
* 诊断文本作为 text/plain 附件一起发。线程 key 当场回显,可在本机面板或工具里读取
|
|
13
|
-
* 官方回复,再带同一个 key 继续补充;submit 后也可以用 watch
|
|
14
|
-
*
|
|
13
|
+
* 官方回复,再带同一个 key 继续补充;submit 后也可以用 watch 每两秒轮询现有反馈端点等官方回复,
|
|
14
|
+
* 最多两分钟,超时提示改用 read。线程历史由提交端保留,不写进 App 的反馈列表。
|
|
15
15
|
* - **GitHub**:插件代码本身的 bug 可以直接提 PR。这条路依赖用户自己登录 GitHub,
|
|
16
16
|
* 插件无法代提,所以只把仓库与前提写进说明,由 AI 自己判断走不走。
|
|
17
17
|
*
|
|
@@ -68,7 +68,7 @@ function feedbackChannels() {
|
|
|
68
68
|
{
|
|
69
69
|
kind: 'distribution',
|
|
70
70
|
name: 'APP 分发系统反馈',
|
|
71
|
-
description: '提交到分发平台的公开反馈接口(与 App 里的反馈页同一个)。没配手机也能提交:指定设备号才带那台手机的身份,否则用这台电脑的插件安装身份;诊断文本作 text/plain 附件。提交后给出可复制的线程 key
|
|
71
|
+
description: '提交到分发平台的公开反馈接口(与 App 里的反馈页同一个)。没配手机也能提交:指定设备号才带那台手机的身份,否则用这台电脑的插件安装身份;诊断文本作 text/plain 附件。提交后给出可复制的线程 key,可在本机面板或工具用 watch 定时轮询现有反馈端点等第一条官方回复(每两秒一次,最多两分钟,超时提示改用 read);需要看历史再 read,用 submit 带 threadKey 继续补充;不会写进 App 的反馈列表。',
|
|
72
72
|
endpoint: `${PLATFORM_ORIGIN}${FEEDBACK_PATH}`,
|
|
73
73
|
requiresLogin: false,
|
|
74
74
|
},
|
|
@@ -242,7 +242,7 @@ function registerFeedbackTool(ctx, deps) {
|
|
|
242
242
|
ctx.tools.register(defineTool({
|
|
243
243
|
name: 'dsh_feedback',
|
|
244
244
|
description: 'Report a real problem with this mobile plugin or the AI-HUB app. '
|
|
245
|
-
+ 'Feedback routes: (1) the APP distribution platform — `submit` sends the content to it. You do NOT need to find the root cause: describe what you observed, what you already checked, and what is still uncertain. No paired phone is required either; without an explicitly chosen device the plugin submits under its local installation identity, with a text/plain diagnostics attachment and a thread key you can show to the user. After `submit`, call `watch` with the returned threadKey
|
|
245
|
+
+ 'Feedback routes: (1) the APP distribution platform — `submit` sends the content to it. You do NOT need to find the root cause: describe what you observed, what you already checked, and what is still uncertain. No paired phone is required either; without an explicitly chosen device the plugin submits under its local installation identity, with a text/plain diagnostics attachment and a thread key you can show to the user. After `submit`, call `watch` with the returned threadKey: it checks the existing feedback endpoint every two seconds for the first official reply, for at most two minutes, then stops with a hint to use `read`. It is polling, not a live stream. Use `read` with the thread key only when you need to review the conversation history, and `submit` with the same threadKey to follow up. The local feedback dialog can show these threads; they are not written into the in-app feedback list. '
|
|
246
246
|
+ '(2) GitHub — code-level bugs can go to https://github.com/WNLUO/dsh-mobile-plugin as a pull request or issue, but that needs the user to be logged into GitHub and is not submitted by this tool. '
|
|
247
247
|
+ 'Use `channels` to list both routes.',
|
|
248
248
|
parameters: {
|
|
@@ -250,7 +250,7 @@ function registerFeedbackTool(ctx, deps) {
|
|
|
250
250
|
type: 'string',
|
|
251
251
|
required: true,
|
|
252
252
|
enum: ['channels', 'read', 'submit', 'watch'],
|
|
253
|
-
description: 'channels: list the feedback routes. read: view a thread and replies. submit: open a feedback thread or follow up using threadKey. watch: after submit,
|
|
253
|
+
description: 'channels: list the feedback routes. read: view a thread and replies. submit: open a feedback thread or follow up using threadKey. watch: after submit, poll the existing read endpoint for the first official staff reply on that threadKey (every two seconds, up to two minutes, then a hint to use read).',
|
|
254
254
|
},
|
|
255
255
|
content: {
|
|
256
256
|
type: 'string',
|
|
@@ -315,7 +315,7 @@ function registerFeedbackTool(ctx, deps) {
|
|
|
315
315
|
case 'watch': {
|
|
316
316
|
const reply = await watchFeedback(args.threadKey, { afterMessageId: args.afterMessageId });
|
|
317
317
|
return reply && reply.timedOut
|
|
318
|
-
? { action: 'watch', threadKey: args.threadKey, timedOut: true }
|
|
318
|
+
? { action: 'watch', threadKey: args.threadKey, timedOut: true, message: reply.message }
|
|
319
319
|
: { action: 'watch', threadKey: args.threadKey, reply };
|
|
320
320
|
}
|
|
321
321
|
default:
|
|
@@ -338,7 +338,7 @@ function renderSummary(value) {
|
|
|
338
338
|
case 'watch':
|
|
339
339
|
return value.reply
|
|
340
340
|
? `反馈 ${value.threadKey} 收到官方回复(${value.reply.created_at}):${value.reply.content}`
|
|
341
|
-
: `反馈 ${value.threadKey}
|
|
341
|
+
: `反馈 ${value.threadKey} ${value.message || '暂时没收到回复,请用 read 查看。'}`;
|
|
342
342
|
default:
|
|
343
343
|
return '完成。';
|
|
344
344
|
}
|