dsh-mobile-plugin 0.5.115 → 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 : '';