dsh-mobile-plugin 0.5.116 → 0.5.117

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.
@@ -16,6 +16,7 @@ description: DSH 手机版(电脑上装的「移动端插件」,手机 App
16
16
 
17
17
  ### 执行规矩(所有分类共用,从这一版起立下)
18
18
 
19
+ - 回反馈时先看详情里的 `context`:有 `submit_kind` 就按来源分流——`user`(真人手填)重点查、`scene`(失败页预填)先按 `scene` 归组复用既有口径、`ai`(对方电脑的 AI 代发)按真人现场同等对待、`diagnosis`(面板诊断自报)多为隧道未连的连带提示、`action`(动作轨迹)。版本看 `app_version` / `component_version`(电脑插件)/ `harness_version`(电脑 DSH 宿主,App 直连时缺失属正常);判断用户是否已带某修复要用这些版本对发布记录,别凭一个版本推另一个。字段缺失的是旧版本,按正文照常处理,不跳过。
19
20
  - 先看自己够不够得着,决定「执行」还是「指导」:AI 跑在用户装插件的那台电脑上、能在本机动手(curl 到局域网网关)时,自己查、自己改、自己验;我们回反馈、够不着用户局域网时,就一步一步说给用户做,不谎称自己动过手。
20
21
  - 话要短:一次只问一两个能直接答的(「路由器 IPv6 开了吗?防火墙关了吗?」)。摸不清再要后台密码:「把路由器后台密码发我,我登进去看。」密码当次用完不留存、不写进知识库、不在回复里复述。
21
22
  - 穷尽再交回:按参考里的顺序一路查到底,一处不通就换下一条路;试一下就甩给用户不算办成。
package/lib/client.js CHANGED
@@ -259,6 +259,7 @@ window.__ModuleLoader__.load({
259
259
  component_id: 'dsh-mobile-plugin',
260
260
  component_version: version || '',
261
261
  device_source: 'install',
262
+ submit_kind: 'diagnosis',
262
263
  files: { name: 'diagnosis.txt', type: 'text/plain' },
263
264
  ...(context || {}),
264
265
  }));
package/lib/impl.js CHANGED
@@ -81,6 +81,7 @@ const { installExtensions } = require('./mobile/extensions.js')
81
81
  const { installWorkspaceTools } = require('./mobile/workspace-tools.js')
82
82
  // 给模型用的反馈能力:AI 查清问题后直接提交到分发平台(见 mobile/feedback.js)。
83
83
  const { installFeedback } = require('./mobile/feedback.js')
84
+ const { readCapabilityReport } = require('./host-capabilities.cjs')
84
85
  const { activeGuard } = require('./host-guard.cjs')
85
86
  // 桌面端侧栏展开态的快照存储。桌面把这份状态只记在浏览器 localStorage 里,宿主必须
86
87
  // 有一个落盘处:客户端半边(lib/client.js)上报 → 这里 → 移动端读取。
@@ -477,7 +478,8 @@ function apply(ctx) {
477
478
  }, `${name}: workspace tool`)
478
479
  ctx.effect(() => {
479
480
  // 反馈工具:设备身份从凭据库取(手机每条请求都上报,宿主写回记录),提交到分发平台。
480
- try { installFeedback(ctx, { credentials, instanceId: () => state.instanceId }) } catch (error) {
481
+ // hostVersion 从同进程的宿主版本台账取(host.js 启动时写入),作为 Harness 版本上报。
482
+ try { installFeedback(ctx, { credentials, instanceId: () => state.instanceId, hostVersion: () => readCapabilityReport()?.runtimeVersion || '' }) } catch (error) {
481
483
  if (!String(error).includes('without inject')) throw error
482
484
  }
483
485
  return undefined
@@ -112,6 +112,31 @@ function diagnosisTextOf({ deviceSource, deviceId, submissionId }) {
112
112
  ].join('\n');
113
113
  }
114
114
 
115
+ /**
116
+ * context 里那一组结构化字段收窄成短 ASCII,别把正文 / 用户内容带进来。
117
+ * 与 App 侧 feedbackContext 同一口径,排查侧据此一眼分清「谁报的、什么场景、什么版本」。
118
+ */
119
+ function feedbackContextFacts(opts) {
120
+ const o = opts && typeof opts === 'object' ? opts : {};
121
+ const safe = (value, max = 64) => {
122
+ if (typeof value !== 'string') return undefined;
123
+ const text = value.replace(/[^A-Za-z0-9._:+@-]/g, '').slice(0, max);
124
+ return text || undefined;
125
+ };
126
+ const kind = o.submitKind;
127
+ const facts = {};
128
+ if (kind === 'ai' || kind === 'diagnosis' || kind === 'user') facts.submit_kind = kind;
129
+ const scene = safe(o.scene);
130
+ if (scene) facts.scene = scene;
131
+ const harness = safe(o.harnessVersion);
132
+ if (harness) facts.harness_version = harness;
133
+ const app = safe(o.appVersion);
134
+ if (app) facts.app_version = app;
135
+ const build = safe(o.buildNumber);
136
+ if (build) facts.build_number = build;
137
+ return facts;
138
+ }
139
+
115
140
  /**
116
141
  * 拼提交给分发平台的表单。字段名与 App 的反馈页逐字对齐(`app/src/services/feedback.ts`
117
142
  * 的 `feedbackForm`),另加插件侧的新字段:`source` / `product_slug` / `component_*` /
@@ -152,6 +177,7 @@ function buildFeedbackForm(device, content, threadKey, options = {}) {
152
177
  component_version: componentVersion,
153
178
  device_source: deviceSource,
154
179
  files: opts.diagnosis ? { name: ATTACHMENT_NAME, type: 'text/plain' } : null,
180
+ ...feedbackContextFacts(opts),
155
181
  ...(opts.context && typeof opts.context === 'object' ? opts.context : {}),
156
182
  };
157
183
  form.append('context', JSON.stringify(context));
@@ -211,12 +237,20 @@ async function submitFeedback(deps, content, threadKey, deviceId, options = {})
211
237
  const submissionId = String(opts.submissionId || submissionIdFor(content, threadKey));
212
238
  const deviceSource = device ? 'paired' : (localId ? 'install' : 'local');
213
239
  const diagnosis = String(opts.diagnosis || diagnosisTextOf({ deviceSource, deviceId: device ? device.deviceId : localId, submissionId }));
240
+ // 宿主 Harness 版本由装配层注入(同进程的 host-capabilities 台账);读不到就留空,不伪造。
241
+ const hostVersion = deps && typeof deps.hostVersion === 'function'
242
+ ? String(deps.hostVersion() || '') : '';
214
243
  const form = buildFeedbackForm(device, content, threadKey, {
215
244
  localDeviceId: localId,
216
245
  submissionId,
217
246
  diagnosis,
218
247
  componentVersion: opts.componentVersion,
219
248
  context: opts.context,
249
+ submitKind: opts.submitKind || 'ai',
250
+ scene: opts.scene,
251
+ harnessVersion: hostVersion,
252
+ appVersion: device ? device.appVersion : undefined,
253
+ buildNumber: device ? device.buildNumber : undefined,
220
254
  });
221
255
  const thread = await postMultipart(form);
222
256
  const key = typeof thread.thread_key === 'string' ? thread.thread_key : '';
@@ -1,3 +1,4 @@
1
+ // 2026-11-25:running 认守护进程而非早退出的启动进程;连上后可由接线层定时体检判活。
1
2
  // 2026-11-25:复用隧道前比对 local_port,旧端口隧道不再静默复用。
2
3
  // ZeroNews 客户端运行器:ensure→login→start→建隧道→读域名,进程生命周期与状态。
3
4
  'use strict';
@@ -166,11 +167,17 @@ function createZeroNewsRunner(options = {}) {
166
167
  let phase = 'off'; // off | installing | login | starting | connecting | connected | error
167
168
  let retryable = true;
168
169
  let generation = 0;
170
+ /**
171
+ * 真正的守护进程在不在跑。`start` 命令后台化自己后会退出,它不是客户端句柄;
172
+ * 连上之后的存活只能认 CLI status 报的 running,不能认那个早退出的启动进程。
173
+ */
174
+ let daemonRunning = false;
175
+ let aliveCheckPromise = null;
169
176
 
170
177
  function status() {
171
178
  return {
172
179
  available: Boolean(binary) || phase !== 'off',
173
- running: Boolean(child) || attached,
180
+ running: Boolean(child) || attached || (phase === 'connected' && daemonRunning),
174
181
  phase,
175
182
  url: phase === 'connected' ? url : '',
176
183
  error,
@@ -404,6 +411,8 @@ function createZeroNewsRunner(options = {}) {
404
411
  if (gen !== generation) return status();
405
412
  if (!url) throw new Error('客户端已连上,但还没拿到隧道公网地址,请稍后刷新');
406
413
  phase = 'connected';
414
+ // 隧道地址是从守护进程的本地 API 读到的:能读到就说明它活着,running 认这一格。
415
+ daemonRunning = true;
407
416
  } catch (err) {
408
417
  if (gen !== generation) return status();
409
418
  // 「还没登录」不是错误,是缺一步:停在 login 阶段,交给面板去打开确认页。
@@ -431,18 +440,43 @@ function createZeroNewsRunner(options = {}) {
431
440
  return startPromise;
432
441
  }
433
442
 
443
+ /**
444
+ * 连上之后定时问一次 CLI:守护进程是不是还在跑。launcher 早退出,手里没有它的退出事件,
445
+ * 只能靠这里发现「状态说连着、进程其实没了」,再交接线层安排自愈重连。
446
+ * CLI 读不到(命令报错)时当「不知道」,不动状态——别因为一次抖动把还能用的线路抖掉。
447
+ */
448
+ async function checkAlive() {
449
+ if (phase !== 'connected' || aliveCheckPromise) return status();
450
+ const gen = generation;
451
+ aliveCheckPromise = (async () => {
452
+ const st = await cliStatus();
453
+ if (gen !== generation || phase !== 'connected' || !st) return;
454
+ daemonRunning = st.running === true;
455
+ if (daemonRunning) return;
456
+ attached = false;
457
+ url = '';
458
+ phase = 'error';
459
+ error = 'ZeroNews 客户端意外退出';
460
+ retryable = true;
461
+ if (onUnexpectedExit) { try { onUnexpectedExit(error); } catch { /* 回调失败不影响状态 */ } }
462
+ })();
463
+ try { await aliveCheckPromise; } finally { aliveCheckPromise = null; }
464
+ return status();
465
+ }
466
+
434
467
  function stop() {
435
468
  generation += 1;
436
469
  if (child && typeof child.kill === 'function') { try { child.kill(); } catch {} }
437
470
  child = null;
438
471
  attached = false;
472
+ daemonRunning = false;
439
473
  url = '';
440
474
  error = '';
441
475
  phase = 'off';
442
476
  return status();
443
477
  }
444
478
 
445
- return { start, stop, status, pickEndpoint, endpointUrl };
479
+ return { start, stop, status, checkAlive, pickEndpoint, endpointUrl };
446
480
  }
447
481
 
448
482
  module.exports = { DEFAULT_BASE, LOGIN_TIMEOUT_MS, START_TIMEOUT_MS, endpointUrl, pickEndpoint, createZeroNewsRunner };
@@ -1,3 +1,4 @@
1
+ // 2026-11-25:连上后定时体检守护进程,发现进程没了自动走自愈重连。
1
2
  // 2026-11-24:首次接入先开代理商邀请链接埋归属 cookie,让新注册用户无感归到代理商名下。
2
3
  // ZeroNews 线路挂载:把运行器接进装配层,隧道地址写回独立字段,随 effect 启停。
3
4
  // 第一次接入的登录:`zeronews login` 要一直活着轮询设备授权码,浏览器确认后才把 token 落盘,
@@ -158,6 +159,22 @@ function mountZeroNews(options) {
158
159
  if (retryTimer && typeof retryTimer.unref === 'function') retryTimer.unref();
159
160
  };
160
161
 
162
+ // `start` 命令一后台化就退出,没有退出事件能告诉接线层守护进程后来挂了。连着的时候
163
+ // 定时问一次 CLI:运行器把状态打回 error 并回调,就走上面同一条自愈重连。
164
+ const healthCheckMs = Number(options.healthCheckMs) > 0 ? Number(options.healthCheckMs) : 15_000;
165
+ let healthTimer = null;
166
+ const clearHealth = () => { if (healthTimer) { clearTimeout(healthTimer); healthTimer = null; } };
167
+ const startHealth = () => {
168
+ if (healthTimer || typeof runner.checkAlive !== 'function') return;
169
+ healthTimer = setTimeout(() => {
170
+ healthTimer = null;
171
+ if (!isConfigured()) return;
172
+ void runner.checkAlive().catch(() => {});
173
+ startHealth();
174
+ }, healthCheckMs);
175
+ if (healthTimer && typeof healthTimer.unref === 'function') healthTimer.unref();
176
+ };
177
+
161
178
  /** 身份看过没有:runner 这一进程见过的,或者落盘记录里做过都算。 */
162
179
  const statusOf = () => {
163
180
  const current = runner.status();
@@ -238,6 +255,7 @@ function mountZeroNews(options) {
238
255
 
239
256
  const stop = async () => {
240
257
  clearRetry();
258
+ clearHealth();
241
259
  retryMs = retryBaseMs;
242
260
  killLogin();
243
261
  const result = runner.stop();
@@ -257,6 +275,7 @@ function mountZeroNews(options) {
257
275
  */
258
276
  const purge = async () => {
259
277
  clearRetry();
278
+ clearHealth();
260
279
  retryMs = retryBaseMs;
261
280
  killLogin();
262
281
  const stopped = runner.stop();
@@ -279,8 +298,13 @@ function mountZeroNews(options) {
279
298
  // 所以清空之后不会自动再拉起。连不上让状态停在错误上,不阻塞启动。
280
299
  const s = getState();
281
300
  const configured = s.zeroNewsEnabled === true || (typeof s.zeroNewsUrl === 'string' && s.zeroNewsUrl.trim() !== '');
282
- if (configured) { void start().catch(() => {}); }
283
- return () => { clearRetry(); killLogin(); runner.stop(); };
301
+ if (configured) {
302
+ startHealth();
303
+ void start().catch(() => {});
304
+ } else {
305
+ clearHealth();
306
+ }
307
+ return () => { clearRetry(); clearHealth(); killLogin(); runner.stop(); };
284
308
  }, `${name}: zeronews runner`));
285
309
  return facade;
286
310
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-plugin",
3
- "version": "0.5.116",
3
+ "version": "0.5.117",
4
4
  "description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.png",
@@ -117,22 +117,23 @@
117
117
  "yaml": "2.9.1"
118
118
  },
119
119
  "dshMobileReleaseNotes": {
120
- "version": "0.5.116",
120
+ "version": "0.5.117",
121
121
  "kinds": [
122
+ "fix",
122
123
  "feature"
123
124
  ],
124
125
  "notes": {
125
- "zh-Hans": "- 首次接入引导页新增「跳过配置」:不想接服务商的用户可以直接进入控制台,自己配好网络后再回来扫码。",
126
- "zh-Hant": "- 首次接入引導頁新增「跳過設定」:不想接服務商的使用者可以直接進入控制台,自己配好網路後再回來掃碼。",
127
- "en": "- Added a Skip setup option to the first-time guide. If you don't want a service provider, you can go straight to the console and scan the QR code after setting up your own network.",
128
- "ja": "- 初回セットアップ画面に「設定をスキップ」を追加しました。プロバイダーを利用したくない場合は、コンソールに直接入り、自分でネットワークを設定してから QR コードをスキャンできます。",
129
- "ko": "- 첫 연결 안내 화면에 «설정 건너뛰기»를 추가했습니다. 서비스 제공자를 원하지 않으면 콘솔로 바로 들어가 직접 네트워크를 설정한 뒤 QR 코드를 스캔할 수 있습니다.",
130
- "de": "- Der Ersteinrichtungsseite wurde «Einrichtung überspringen» hinzugefügt. Ohne Dienstanbieter geht es direkt in die Konsole; nach der eigenen Netzwerkeinrichtung kann der QR-Code gescannt werden.",
131
- "es": "- Se añadió «Omitir la configuración» a la guía inicial. Si no quieres usar un proveedor, entra directamente en la consola y escanea el código QR después de configurar tu red.",
132
- "fr": "- Ajout de « Passer la configuration » dans le guide de première connexion. Sans fournisseur, vous pouvez entrer directement dans la console et scanner le code QR après avoir configuré votre réseau.",
133
- "pt": "- Adicionado «Pular a configuração» ao guia de primeira conexão. Sem um provedor, você pode entrar direto no console e escanear o código QR após configurar sua rede.",
134
- "ru": "- В экран первичной настройки добавлена команда «Пропустить настройку». Без провайдера можно сразу открыть консоль и отсканировать QR-код после настройки своей сети.",
135
- "tr": "- İlk kurulum ekranına «Kurulumu atla» eklendi. Bir sağlayıcı kullanmak istemiyorsanız doğrudan konsola girebilir, kendi ağınızı kurduktan sonra QR kodunu tarayabilirsiniz."
126
+ "zh-Hans": "- 修复零讯线路的问题:客户端意外退出后不再一直显示「已连接」,会定期检查客户端状态,掉线后自动恢复。\n- 从引导页或失败页提交问题时,会自动带上问题来源、场景和版本信息,反馈更容易被定位。",
127
+ "zh-Hant": "- 修復零訊線路的問題:用戶端意外結束後不再一直顯示「已連線」,會定期檢查用戶端狀態,掉線後自動恢復。\n- 從引導頁或失敗頁提交問題時,會自動帶上問題來源、場景與版本資訊,讓回報更容易被定位。",
128
+ "en": "- Fixed an issue where the ZeroNews route kept showing \"Connected\" after the client exited unexpectedly and never reconnected. The client is now checked periodically and the route is restored automatically after a drop.\n- Feedback sent from the guide or an error page now includes its source, scenario and version details, making reports easier to trace.",
129
+ "ja": "- クライアントが予期せず終了しても ZeroNews 回線が「接続済み」のまま自動再接続しない問題を修正しました。定期的にクライアントの状態を確認し、切断後は自動で復旧します。\n- ガイド画面やエラー画面から問題を送信すると、発生元・場面・バージョン情報が自動で付き、報告を追いやすくなりました。",
130
+ "ko": "- 클라이언트가 예기치 않게 종료된 뒤에도 ZeroNews 회선이 '연결됨'으로만 표시되고 자동 재연결되지 않던 문제를 수정했습니다. 이제 클라이언트 상태를 주기적으로 확인하고, 연결이 끊기면 자동으로 복구합니다.\n- 안내 화면이나 오류 화면에서 문제를 제출할 때 출처, 상황, 버전 정보가 함께 전송되어 보고 내용을 더 쉽게 추적할 수 있습니다.",
131
+ "de": "- Behoben: Die ZeroNews-Verbindung zeigte nach einem unerwarteten Client-Absturz weiterhin „Verbunden\" und stellte die Verbindung nicht wieder her. Der Client wird jetzt regelmäßig geprüft und nach einem Abbruch automatisch wiederhergestellt.\n- Feedback aus dem Einrichtungs- oder Fehlerbildschirm enthält jetzt automatisch Quelle, Szene und Versionsangaben, sodass Meldungen leichter nachvollziehbar sind.",
132
+ "es": "- Se corrigió un problema por el cual la línea ZeroNews seguía mostrando «Conectado» después de que el cliente saliera de forma inesperada y nunca se reconectaba. Ahora se comprueba periódicamente el cliente y la línea se restaura automáticamente tras una caída.\n- Los informes enviados desde la guía o una pantalla de error incluyen automáticamente el origen, la situación y la versión, lo que facilita su seguimiento.",
133
+ "fr": "- Correction d'un problème où la ligne ZeroNews affichait toujours « Connecté » après la fermeture inattendue du client et ne se reconnectait jamais. Le client est désormais vérifié régulièrement et la ligne est restaurée automatiquement après une coupure.\n- Les signalements envoyés depuis le guide ou un écran d'erreur incluent désormais automatiquement la source, le contexte et la version, ce qui facilite leur suivi.",
134
+ "pt": "- Corrigido um problema em que a linha ZeroNews continuava mostrando \"Conectado\" depois que o cliente saía inesperadamente e nunca se reconectava. Agora o cliente é verificado periodicamente e a linha é restaurada automaticamente após uma queda.\n- Os relatórios enviados pelo guia ou por uma tela de erro agora incluem automaticamente a origem, o cenário e a versão, facilitando o acompanhamento.",
135
+ "ru": "- Исправлена проблема, при которой линия ZeroNews продолжала показывать «Подключено» после непредвиденного завершения клиента и не восстанавливала соединение. Теперь состояние клиента проверяется периодически, и после обрыва линия восстанавливается автоматически.\n- Отзывы, отправленные из руководства или экрана ошибки, теперь автоматически содержат источник, сценарий и версию, что упрощает их отслеживание.",
136
+ "tr": "- İstemci beklenmedik şekilde kapandıktan sonra ZeroNews hattının \"Bağlı\" görünmeye devam edip hiç yeniden bağlanmaması sorunu düzeltildi. Artık istemci düzenli olarak kontrol ediliyor ve kopma sonrası hat otomatik olarak geri yükleniyor.\n- Kılavuz veya hata ekranından gönderilen geri bildirimler artık kaynak, senaryo ve sürüm bilgilerini otomatik olarak içeriyor; böylece takip kolaylaşıyor."
136
137
  }
137
138
  }
138
139
  }