dsh-session-superagent 0.9.272 → 0.9.275

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/CHANGELOG.md CHANGED
@@ -2,6 +2,79 @@
2
2
 
3
3
  格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.9.275] - 2026-11-06 —— primary 全原生化 + 更新失败/忙碌边界
6
+
7
+ ### 全部 primary 按钮接入官方 DSH Button
8
+
9
+ 真实 Chromium 发现旧 `Btn variant=primary` 在深色下白字配浅绿底,只有 **1.045:1**。
10
+ 现在新增表单、保存凭证、保存 goal、安装更新及危险确认等 primary 在有官方 Button 时统一委托;
11
+ 其它 variant 不变,旧宿主完整回退。业务 busy/danger/disabled/aria/type/ref 均透传,未回填旧主题类。
12
+
13
+ 同一真实对比度脚本复验:**23/23,16/16 非禁用测量通过**。
14
+ 新增/保存凭证/安装更新/保存 goal:深色均 **18.0823:1**,浅色均 **18.8965:1**。
15
+ 测量脚本改为官方按钮选择器,并修正 TaskSpace 启动与 ego stdin 仓库定位。
16
+
17
+ ### 更新失败与忙碌状态
18
+
19
+ - runner 实际 settle(成功/非零/timeout/spawn_error)后才失效更新缓存并递增 generation;504 且仍 pending 时不提前清理,旧 GET 不能晚写。
20
+ - error 在 normalizeFailure 与路由出口都脱敏;405 增加 `Allow: GET, POST`。
21
+ - 安装忙碌时取消、遮罩、Escape 与右上关闭均被阻止,POST 不中断;成功/失败后恢复,成功只关闭一次。
22
+
23
+ ### 证据
24
+
25
+ ```
26
+ 更新路由 33/33;更新 UI 14/14;primary 定向 120/120
27
+ 真实 Chromium primary 对比度 → 23/23
28
+ npm test → 600/600
29
+ UI 体检 → 11/11(100 分)
30
+ ```
31
+
32
+ 未真实执行安装或重启;本版按 Git 工作流保留本地候选。
33
+
34
+ ## [0.9.274] - 2026-11-06 —— 更新链路严格审核六项修复 + 完整面板真实验收
35
+
36
+ ### 更新链路六项必须修
37
+
38
+ 1. installed=latest 且 needsReload 时,设置页显示「已安装,等待重载」,隐藏重复安装与顶部提示。
39
+ 2. 生产 CLI 超时后必须等 close 才结算/解锁;旧进程未关闭时后续更新保持 409,不重叠安装。
40
+ 3. Windows Desktop 改走 `dsh-desktop-host/lib/cli.js` + `--expose-internals` + `ELECTRON_RUN_AS_NODE=1`,不再用通用 bin.js 管理 desktop profile。
41
+ 4. 更新 POST 的 fetch rejection/404 不自动重放;显示「结果未知,先重新检查」,GET 重试保留。
42
+ 5. 统一真正 SemVer comparator:prerelease、build、大整数与 ASCII 规则;installed 决定磁盘更新,POST 后失效缓存,禁止静默降级。
43
+ 6. stdout/stderr 在注入结果与生产 collector 两条路径都先脱敏再截断,跨 16KiB 边界不留秘密前缀。
44
+
45
+ ### 真实验收
46
+
47
+ - 完整主理鱼面板:真实 client.js UMD + 安装版 React/primitives,原始 **23/23**;主线功能复跑 exit 0,CDP 截图通道问题单列 SKIP。
48
+ - 真实 CLI 探针:desktop-host `cli.js --help` exit 0,解析环境、入口 hash 与帮助首行均通过。
49
+ - live 只读对照:旧 running 比较把 latest=0.9.272 误判为有更新;新 comparator 对 installed=0.9.273 正确判为无更新。
50
+
51
+ ### 证据
52
+
53
+ ```
54
+ 更新路由 24/24;更新 UI 10/10;SemVer 合并定向 47/47
55
+ npm test → 593/593
56
+ UI 体检 → 11/11(100 分)
57
+ ```
58
+
59
+ 所有更新安装测试均为 mock;未真实 plugin add、未重启。按 Git 工作流保留本地候选,未推远端。
60
+
61
+ ## [0.9.273] - 2026-11-06 —— 更新回执与重新检查不再互相遮状态
62
+
63
+ ### 修正两个更新状态路径
64
+
65
+ - 手动「重新检查」会清掉旧安装回执,避免检测到新版本时仍显示「安装完成」。
66
+ - 安装成功后的 `GET ?refresh=1` 保留刚写入的回执,不把 installed/running/needsReload 立即抹掉。
67
+ - 顶部横幅入口从「看升级命令」改为「去更新」,与实际可安装能力一致。
68
+
69
+ ### 证据
70
+
71
+ ```
72
+ 更新 UI 定向 → 6/6(含手动清除、安装刷新保留、横幅入口)
73
+ npm test → 572/572
74
+ ```
75
+
76
+ 本版先按仓库 Git 工作流留本地验收,不把中间提交逐个推远端。
77
+
5
78
  ## [0.9.272] - 2026-11-06 —— 界面更新补上真实 DSH CLI 入口
6
79
 
7
80
  ### 修复 mock 全绿但真机 `cli_not_found`
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="assets/icon-180.png" width="88" height="88" alt="">
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.272-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.275-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](https://github.com/topics/dsh-plugin)
9
9
  [![awesome](https://img.shields.io/badge/awesome-dsh--plugin-%E2%9C%93-success.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
@@ -148,7 +148,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
148
148
  ## 开发
149
149
 
150
150
  ```sh
151
- npm test # 571 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
151
+ npm test # 600 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
152
152
  ```
153
153
 
154
154
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -208,7 +208,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
208
208
 
209
209
 
210
210
  ```bash
211
- npm test # 571 项单测(带离线开关,约 1.6 秒)
211
+ npm test # 600 项单测(带离线开关,约 1.6 秒)
212
212
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
213
213
  node scripts/preflight.mjs # 41 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
214
214
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
package/UPDATING.md CHANGED
@@ -52,6 +52,10 @@ node -e "console.log(require('<安装副本>/package.json').version)"
52
52
 
53
53
  ## 用户怎么升级
54
54
 
55
+ 优先在面板里操作:**设置 → 版本与更新 → 安装更新**。确认版本后会安装到当前 profile,并显示安装副本、运行版本和是否需要重载;不会自动重启。复制命令仍保留作手动回退。
56
+
57
+ 也可以在终端运行:
58
+
55
59
  ```bash
56
60
  dsh plugin --profile <p> update dsh-session-superagent
57
61
  ```
package/client.js CHANGED
@@ -350,7 +350,7 @@ window.__ModuleLoader__.load({
350
350
  let hostOrbit = null
351
351
  try {
352
352
  const primitives = require('@deepseek-ai/dsh-client-ui-primitives')
353
- // Button 独立探测:老宿主缺 Modal/Toast 时仍可复用官方按钮;缺 Button 则由 UpdateButton 回退 Btn。
353
+ // Button 独立探测:老宿主缺 Modal/Toast 时仍可复用官方按钮;缺 Button 时所有 primary 完整回退旧 Btn。
354
354
  hostButton = primitives.Button || null
355
355
  if (primitives && primitives.Modal && primitives.Toast && primitives.IconWarningOutlineMedium) {
356
356
  hostUi = createHostUi({ React, primitives })
@@ -379,7 +379,68 @@ window.__ModuleLoader__.load({
379
379
  }
380
380
 
381
381
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
382
- const CLIENT_VERSION = '0.9.272'
382
+ const CLIENT_VERSION = '0.9.275'
383
+ // SEMVER_COMPARATOR_SOURCE_START
384
+ // This block is duplicated verbatim in client.js because the browser UMD cannot import ESM.
385
+ // test/update-semver.test.mjs audits both copies and exercises their behavior.
386
+ const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
387
+
388
+ function parseSemver(value) {
389
+ if (typeof value !== 'string') return null
390
+ const match = SEMVER_RE.exec(value)
391
+ if (!match) return null
392
+ return {
393
+ core: [match[1], match[2], match[3]],
394
+ prerelease: match[4] === undefined ? null : match[4].split('.'),
395
+ }
396
+ }
397
+
398
+ // Numeric identifiers are compared as decimal strings: Number/BigInt would either
399
+ // lose precision or impose a fixed-width limit that SemVer itself does not have.
400
+ function compareNumericIdentifiers(left, right) {
401
+ if (left.length !== right.length) return left.length < right.length ? -1 : 1
402
+ if (left === right) return 0
403
+ return left < right ? -1 : 1
404
+ }
405
+
406
+ function comparePrerelease(left, right) {
407
+ if (left === null || right === null) {
408
+ if (left === right) return 0
409
+ return left === null ? 1 : -1
410
+ }
411
+ const length = Math.max(left.length, right.length)
412
+ for (let index = 0; index < length; index += 1) {
413
+ if (index >= left.length) return -1
414
+ if (index >= right.length) return 1
415
+ const a = left[index]
416
+ const b = right[index]
417
+ if (a === b) continue
418
+ const aNumeric = /^\d+$/.test(a)
419
+ const bNumeric = /^\d+$/.test(b)
420
+ if (aNumeric && bNumeric) return compareNumericIdentifiers(a, b)
421
+ if (aNumeric !== bNumeric) return aNumeric ? -1 : 1
422
+ return a < b ? -1 : 1
423
+ }
424
+ return 0
425
+ }
426
+
427
+ /** Return -1/0/1 by SemVer precedence, or null when either input is invalid. */
428
+ function compareSemver(left, right) {
429
+ const a = parseSemver(left)
430
+ const b = parseSemver(right)
431
+ if (!a || !b) return null
432
+ for (let index = 0; index < 3; index += 1) {
433
+ const compared = compareNumericIdentifiers(a.core[index], b.core[index])
434
+ if (compared !== 0) return compared
435
+ }
436
+ return comparePrerelease(a.prerelease, b.prerelease)
437
+ }
438
+
439
+ function isStrictSemver(value) {
440
+ return parseSemver(value) !== null
441
+ }
442
+ // SEMVER_COMPARATOR_SOURCE_END
443
+ const UPDATE_UNKNOWN_HINT = '请求结果未知,请先重新检查 installed/running,再手动确认'
383
444
  let BASE = '/session-superagent'
384
445
  /**
385
446
  * 挑「最新的那个服务端实例」。
@@ -391,10 +452,6 @@ window.__ModuleLoader__.load({
391
452
  async function discoverBase() {
392
453
  const candidates = [BASE]
393
454
  for (let i = 2; i <= 8; i += 1) candidates.push('/session-superagent/r' + i)
394
- const versionScore = (v) => {
395
- const parts = String(v || '0').split('.').map((n) => Number(n) || 0)
396
- return parts[0] * 1e6 + parts[1] * 1e3 + parts[2]
397
- }
398
455
  let best = null
399
456
  for (const base of candidates) {
400
457
  try {
@@ -403,8 +460,8 @@ window.__ModuleLoader__.load({
403
460
  const body = await res.json()
404
461
  // 只有「自报前缀 = 我请求的前缀」才说明这个实例真的在这条路径上服务
405
462
  if (!body || body.routeBase !== base) continue
406
- const score = versionScore(body.serverVersion)
407
- if (!best || score > best.score) best = { base, score }
463
+ if (!isStrictSemver(body.serverVersion)) continue
464
+ if (!best || compareSemver(body.serverVersion, best.version) === 1) best = { base, version: body.serverVersion }
408
465
  } catch {}
409
466
  }
410
467
  if (best && best.base !== BASE) {
@@ -427,17 +484,28 @@ window.__ModuleLoader__.load({
427
484
  ...(options || {}),
428
485
  headers: { 'content-type': 'application/json', accept: 'application/json', ...((options && options.headers) || {}) },
429
486
  }
487
+ // 更新可能已经开始安装;响应丢失不代表请求未执行,自动重放会重复修改安装副本。
488
+ // 特例只覆盖更新 POST:GET 与其它 mutation 的 discover/retry 行为保持原样。
489
+ const updatePost = path === '/update' && String(init.method || 'GET').toUpperCase() === 'POST'
490
+ const unknownUpdateError = (error) => {
491
+ const failure = error && (typeof error === 'object' || typeof error === 'function')
492
+ ? error
493
+ : new Error(String(error))
494
+ failure.updateResultUnknown = true
495
+ return failure
496
+ }
430
497
  let res
431
498
  try {
432
499
  res = await fetch(BASE + path, init)
433
500
  } catch (error) {
501
+ if (updatePost) throw unknownUpdateError(error)
434
502
  // 前缀失效(这一代被新实例接管并释放了):重新探一次再试,还不行就把错抛出去
435
503
  if (retried) throw error
436
504
  await discoverBase()
437
505
  return call(path, options, true)
438
506
  }
439
- // 旧前缀被释放后宿主会 404:同样重探一次
440
- if (res.status === 404 && !retried) {
507
+ // 旧前缀被释放后宿主会 404:只读请求可重探一次;更新 POST 绝不自动重放。
508
+ if (res.status === 404 && !retried && !updatePost) {
441
509
  await discoverBase()
442
510
  return call(path, options, true)
443
511
  }
@@ -452,7 +520,11 @@ window.__ModuleLoader__.load({
452
520
  const text = await res.text()
453
521
  let body = null
454
522
  try { body = text ? JSON.parse(text) : null } catch { body = { raw: text } }
455
- if (!res.ok) throw new Error((body && body.error) || ('HTTP ' + res.status))
523
+ if (!res.ok) {
524
+ const error = new Error((body && body.error) || ('HTTP ' + res.status))
525
+ if (updatePost && res.status === 404) throw unknownUpdateError(error)
526
+ throw error
527
+ }
456
528
  return body
457
529
  }
458
530
 
@@ -611,13 +683,18 @@ window.__ModuleLoader__.load({
611
683
  const cx = (...names) => names.filter(Boolean).join(' ')
612
684
 
613
685
  function Btn({ variant = 'ghost', size = 'md', icon, children, className, ...rest }) {
686
+ if (variant === 'primary' && hostButton) {
687
+ // 只转发业务 className:旧 dt-btn-primary 会覆盖宿主主题,造成深色白底浅字。
688
+ // type 默认 button,但显式 submit 等原生 props(含 ref)必须原样交给 DSH Button;key 仍由 React 管理。
689
+ return h(hostButton, { type: 'button', ...rest, variant, size, icon, className }, children)
690
+ }
614
691
  // className 必须最后合并:之前 ...rest 直接覆盖,导致 ConfirmButton 的删除按钮丢掉全部样式
615
692
  return h('button', { type: 'button', ...rest, className: cx('dt-btn', 'dt-btn-' + variant, 'dt-btn-' + size, className) },
616
693
  icon !== undefined ? h('span', { className: 'dt-btn-icon' }, icon) : null,
617
694
  children)
618
695
  }
619
696
 
620
- // 安装动作优先用 DSH Button;老宿主缺该导出时完整保留同源 Btn 的尺寸、variant 与交互。
697
+ // 保留安装动作现有调用面;其它 primary 也统一由 Btn 内的宿主分支委托,老宿主完整回退。
621
698
  const UpdateButton = hostButton || Btn
622
699
 
623
700
  function Tag({ tone = 'outline', title, children }) {
@@ -1136,9 +1213,14 @@ window.__ModuleLoader__.load({
1136
1213
  const PanelModal = hostUi ? hostUi.Modal : Modal
1137
1214
 
1138
1215
  /** 确认层与触发器分离:DSH orbit 关闭后,同一个本地 Modal 仍能由 StatusOrbit 持有。 */
1139
- function ConfirmDialog({ open, label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, onClose, modalContext = 'panel', ButtonComponent = Btn, danger = true }) {
1216
+ function ConfirmDialog({ open, label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, onClose, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false }) {
1140
1217
  const [busy, setBusy] = useState(false)
1141
1218
  const busyRef = useRef(false)
1219
+ const dismiss = () => {
1220
+ if (preventDismissOnBusy && (busy || busyRef.current)) return false
1221
+ onClose()
1222
+ return true
1223
+ }
1142
1224
  const confirm = async () => {
1143
1225
  // state 还没来得及重渲染时也可能连点;同步 ref 是第二道锁。
1144
1226
  if (busyRef.current) return false
@@ -1146,6 +1228,7 @@ window.__ModuleLoader__.load({
1146
1228
  setBusy(true)
1147
1229
  try {
1148
1230
  const done = await onConfirm()
1231
+ // 成功关闭走原回调,只执行一次,不能被 busy dismiss guard 挡住。
1149
1232
  if (done) onClose()
1150
1233
  return done
1151
1234
  } finally {
@@ -1159,10 +1242,9 @@ window.__ModuleLoader__.load({
1159
1242
  open,
1160
1243
  title,
1161
1244
  description: message || ('确定要执行「' + label + '」操作吗?'),
1162
- onClose,
1163
- children: null,
1245
+ onClose: dismiss,
1164
1246
  footer: h(React.Fragment, null,
1165
- h(ButtonComponent, { variant: 'ghost', onClick: onClose }, '取消'),
1247
+ h(ButtonComponent, { variant: 'ghost', disabled: preventDismissOnBusy && busy, onClick: dismiss }, '取消'),
1166
1248
  h(ButtonComponent, {
1167
1249
  variant: 'primary',
1168
1250
  className: cx(danger && 'dt-danger', busy && 'dt-btn-busy'),
@@ -1171,11 +1253,11 @@ window.__ModuleLoader__.load({
1171
1253
  'aria-busy': busy ? 'true' : undefined,
1172
1254
  onClick: confirm,
1173
1255
  }, confirmLabel)),
1174
- })
1256
+ }, preventDismissOnBusy && busy ? h(Hint, null, '安装进行中,完成后才能关闭') : null)
1175
1257
  }
1176
1258
 
1177
1259
  /** 官方 ConfirmButton 动线:触发按钮只开 Modal,取消不执行,确认期间 busy 防重复。 */
1178
- function ConfirmButton({ label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, variant = 'ghost', icon, size, modalContext = 'panel', ButtonComponent = Btn, danger = true }) {
1260
+ function ConfirmButton({ label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, variant = 'ghost', icon, size, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false }) {
1179
1261
  const [open, setOpen] = useState(false)
1180
1262
  const close = useCallback(() => setOpen(false), [])
1181
1263
  return h(React.Fragment, null,
@@ -1187,7 +1269,7 @@ window.__ModuleLoader__.load({
1187
1269
  'aria-haspopup': 'dialog',
1188
1270
  onClick: () => setOpen(true),
1189
1271
  }, label),
1190
- h(ConfirmDialog, { open, label, confirmLabel, title, message, onConfirm, onClose: close, modalContext, ButtonComponent, danger }))
1272
+ h(ConfirmDialog, { open, label, confirmLabel, title, message, onConfirm, onClose: close, modalContext, ButtonComponent, danger, preventDismissOnBusy }))
1191
1273
  }
1192
1274
 
1193
1275
  const watcherId = (w) => (w && w.id) || String((w && w.repo) || '') + '#' + String((w && w.sessionId) || '')
@@ -1808,6 +1890,9 @@ window.__ModuleLoader__.load({
1808
1890
  const [traceResult, setTraceResult] = useState(null)
1809
1891
  // 安装回执与版本检查分开:POST 失败不能冲掉当前版本和命令回退。
1810
1892
  const [updateResult, setUpdateResult] = useState(null)
1893
+ // POST 后 GET 仍以 runningVersion 比较 latest;已装到 latest 且等待重载时,回执优先于 hasUpdate。
1894
+ const updateAwaitingReload = Boolean(updateResult && updateResult.needsReload === true
1895
+ && update && updateResult.installedVersion === update.latest)
1811
1896
  // 去设置页时必须同时定位分区;只切 Tab 会把人留在上次看的分区(官方 settingsRoute(group) 的最小等价)。
1812
1897
  const openSettings = (section) => {
1813
1898
  setSettingsSection(section)
@@ -2744,18 +2829,22 @@ window.__ModuleLoader__.load({
2744
2829
  h(KeyValues, { rows: [
2745
2830
  ['当前版本', (update && update.current) || CLIENT_VERSION],
2746
2831
  ['npm 最新', !update ? '检测中…' : update.error ? '检测失败 · ' + update.error : (update.latest || '未知')],
2747
- ['状态', updateResult
2748
- ? (updateResult.needsReload ? '安装完成,需要重载才生效' : '安装完成')
2749
- : !update ? '…' : update.error ? '检查失败' : update.hasUpdate ? '有新版本,可以升级' : '已是最新'],
2750
- updateResult ? ['安装副本(installedVersion)', updateResult.installedVersion] : null,
2751
- updateResult ? ['运行版本(runningVersion)', updateResult.runningVersion] : null,
2752
- updateResult ? ['重载要求(needsReload)', updateResult.needsReload ? 'true · 需要重载才生效' : 'false · 当前无需重载'] : null,
2832
+ ['状态', updateResult && updateResult.resultUnknown
2833
+ ? UPDATE_UNKNOWN_HINT
2834
+ : updateAwaitingReload
2835
+ ? '已安装,等待重载'
2836
+ : updateResult
2837
+ ? (updateResult.needsReload ? '安装完成,需要重载才生效' : '安装完成')
2838
+ : !update ? '…' : update.error ? '检查失败' : update.hasUpdate ? '有新版本,可以升级' : '已是最新'],
2839
+ updateResult ? ['安装副本(installedVersion)', updateResult.resultUnknown ? '未知 · 请重新检查' : updateResult.installedVersion] : null,
2840
+ updateResult ? ['运行版本(runningVersion)', updateResult.resultUnknown ? '未知 · 请重新检查' : updateResult.runningVersion] : null,
2841
+ updateResult ? ['重载要求(needsReload)', updateResult.resultUnknown ? '未知 · 请重新检查' : updateResult.needsReload ? 'true · 需要重载才生效' : 'false · 当前无需重载'] : null,
2753
2842
  ] }),
2754
2843
  update && update.hasUpdate
2755
2844
  ? h('div', null,
2756
2845
  h('code', { className: 'dt-code' }, update.command),
2757
2846
  h('div', { className: 'dt-actions' },
2758
- h(ConfirmButton, {
2847
+ !updateAwaitingReload ? h(ConfirmButton, {
2759
2848
  label: '安装更新',
2760
2849
  confirmLabel: '确认安装',
2761
2850
  title: '安装更新',
@@ -2764,8 +2853,9 @@ window.__ModuleLoader__.load({
2764
2853
  size: 'sm',
2765
2854
  ButtonComponent: UpdateButton,
2766
2855
  danger: false,
2856
+ preventDismissOnBusy: true,
2767
2857
  onConfirm: installUpdate,
2768
- }),
2858
+ }) : null,
2769
2859
  h(Btn, {
2770
2860
  size: 'sm',
2771
2861
  // 审核 T24 W2:以前点了零反馈,writeText 的 rejection 也没人接 —— 客户不知道复制没成。
@@ -2838,7 +2928,8 @@ window.__ModuleLoader__.load({
2838
2928
  }, item.title))),
2839
2929
  h('div', { className: 'dt-settings-body' }, settingsBody))
2840
2930
 
2841
- const checkUpdate = useCallback(async (force) => {
2931
+ const checkUpdate = useCallback(async (force, preserveResult = false) => {
2932
+ if (!preserveResult) setUpdateResult(null)
2842
2933
  setChecking(true)
2843
2934
  try {
2844
2935
  const value = await call('/update' + (force ? '?refresh=1' : ''))
@@ -2877,10 +2968,22 @@ window.__ModuleLoader__.load({
2877
2968
  + ',runningVersion ' + receipt.runningVersion
2878
2969
  + (receipt.needsReload ? ',需要重载才生效' : ''), 'success')
2879
2970
  // 安装只改副本;重新检查由 GET 完成,不触发重启,也不推断 runningVersion 已变化。
2880
- await checkUpdate(true)
2971
+ await checkUpdate(true, true)
2881
2972
  return true
2882
2973
  } catch (error) {
2883
- const text = '安装更新失败:' + String((error && error.message) || error)
2974
+ const detail = String((error && error.message) || error)
2975
+ const resultUnknown = Boolean(error && error.updateResultUnknown)
2976
+ if (resultUnknown) {
2977
+ setUpdateResult({
2978
+ installedVersion: '未知',
2979
+ runningVersion: '未知',
2980
+ needsReload: null,
2981
+ resultUnknown: true,
2982
+ })
2983
+ }
2984
+ const text = resultUnknown
2985
+ ? '安装更新' + UPDATE_UNKNOWN_HINT + ':' + detail
2986
+ : '安装更新失败:' + detail
2884
2987
  setNotice({ ok: false, text })
2885
2988
  notify(text, 'error')
2886
2989
  return false
@@ -3050,11 +3153,11 @@ window.__ModuleLoader__.load({
3050
3153
  value: tab, onChange: setTab, label: '主理鱼分区',
3051
3154
  }),
3052
3155
  notice ? h('div', { className: 'dt-banner dt-danger' }, notice.text) : null,
3053
- // 有新版本时在顶部提示一次(埋在设置页里客户不会主动翻)
3054
- update && update.hasUpdate
3156
+ // 有新版本时在顶部提示一次;已装到 latest 且等待重载时完全隐藏,避免重复安装入口。
3157
+ update && update.hasUpdate && !updateAwaitingReload
3055
3158
  ? h('div', { className: 'dt-banner dt-banner-actions' },
3056
3159
  h('span', { className: 'dt-banner-label' }, '有新版本 ' + update.latest + '(当前 ' + update.current + ')'),
3057
- h('button', { className: 'dt-btn dt-btn-sm dt-btn-outline', type: 'button', onClick: () => openSettings('update') }, '看升级命令'))
3160
+ h('button', { className: 'dt-btn dt-btn-sm dt-btn-outline', type: 'button', onClick: () => openSettings('update') }, '去更新'))
3058
3161
  : null,
3059
3162
  toastView,
3060
3163
  snap.error
package/lib/index.js CHANGED
@@ -26,7 +26,8 @@ import { decodeBody, truncateUtf8 } from './body.js'
26
26
  import { quotaDeferText, isOfflineMode } from './gh-format.js'
27
27
  import { listGiteeItems, fetchGiteeLastComment, addGiteeLabel, addGiteeComment, ensureGiteeLabel, giteeWhoami, giteeRepo, mapGiteeRepoAccess, DEFAULT_ACK_LABEL_GITEE, giteeLabels, giteeHasLabel, isValidGiteeLabel, suggestGiteeLabel } from './gitee.js'
28
28
  import { migrateState, CURRENT_STATE_SCHEMA } from './state-migration.js'
29
- import { isStrictSemver, runExclusiveUpdate, spawnPluginUpdate, validateUpdateBody } from './update.js'
29
+ import { runExclusiveUpdate, spawnPluginUpdate, validateUpdateBody } from './update.js'
30
+ import { compareSemver, isStrictSemver } from './semver.js'
30
31
  import {
31
32
  effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, DEFAULT_PRIORITY, formatWatchText,
32
33
  recordPendingWake, clearPending, pendingRetry,
@@ -48,7 +49,7 @@ import {
48
49
 
49
50
  export const name = 'dsh-session-superagent'
50
51
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
51
- export const SERVER_VERSION = '0.9.272'
52
+ export const SERVER_VERSION = '0.9.275'
52
53
  export const inject = ['tools', 'agents', 'webServer']
53
54
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
54
55
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -1770,6 +1771,18 @@ const STATE_EVENTS_BUDGET = 240
1770
1771
 
1771
1772
  const UPDATE_CACHE_MS = 10 * 60 * 1000
1772
1773
  let updateCache = null
1774
+ let updateCacheGeneration = 0
1775
+ // 非零退出、spawn_error 与 timeout 同样可能已经部分改盘。包装 runner 的 Promise,
1776
+ // 只有它真正 settle 才失效缓存并递增 generation;外层 504 时若仍 pending,这里不会执行。
1777
+ // validate/profile 等尚未调用 runner 的失败自然也不会碰到这段清理。
1778
+ const runUpdateAndInvalidateCache = async (request) => {
1779
+ try {
1780
+ return await updateRunner(request)
1781
+ } finally {
1782
+ updateCacheGeneration += 1
1783
+ updateCache = null
1784
+ }
1785
+ }
1773
1786
  // 审核 T19:强制刷新(?refresh=1)没有任何节流 —— 任意网页可以反复触发它去打 npm registry。
1774
1787
  // 60 秒内最多真查一次;其余走缓存(面板上的「刷新」按钮不受影响,人点不了这么快)。
1775
1788
  let lastForcedUpdateAt = 0
@@ -1778,12 +1791,25 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1778
1791
  const mayForce = force && Date.now() - lastForcedUpdateAt >= UPDATE_FORCE_MIN_MS
1779
1792
  if (mayForce) lastForcedUpdateAt = Date.now()
1780
1793
  if (!mayForce && updateCache && Date.now() - updateCache.at < UPDATE_CACHE_MS) return updateCache.value
1794
+ const generation = updateCacheGeneration
1781
1795
  const current = SERVER_VERSION
1782
- const value = { current, latest: null, publishedAt: null, hasUpdate: false, command: '', error: null }
1796
+ const installed = readInstalledVersion()
1797
+ // 磁盘是否可更新只看 installedVersion;running/current 仅在安装版本不可用时兜底。
1798
+ const baseline = isStrictSemver(installed) ? installed : current
1799
+ const value = {
1800
+ current,
1801
+ runningVersion: current,
1802
+ installedVersion: installed,
1803
+ latest: null,
1804
+ publishedAt: null,
1805
+ hasUpdate: false,
1806
+ command: '',
1807
+ error: null,
1808
+ }
1783
1809
  // 离线开关:单测不该依赖 npm registry(一次网络抖动就会让整条门禁变红)
1784
1810
  if (process.env.DSH_SUPERAGENT_UPDATE_OFFLINE === '1') {
1785
1811
  value.command = 'dsh plugin --profile <你的 profile> add dsh-session-superagent@latest'
1786
- updateCache = { at: Date.now(), value }
1812
+ if (generation === updateCacheGeneration) updateCache = { at: Date.now(), value }
1787
1813
  return value
1788
1814
  }
1789
1815
  try {
@@ -1793,16 +1819,16 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1793
1819
  })
1794
1820
  if (!res.ok) throw new Error('HTTP ' + res.status)
1795
1821
  const body = await res.json()
1796
- value.latest = String(body.version || '')
1822
+ value.latest = typeof body.version === 'string' ? body.version : ''
1823
+ if (!isStrictSemver(value.latest)) throw new Error('npm registry 返回的 latest 不是严格 semver')
1797
1824
  const published = typeof body.dist?.tarball === 'string' ? body.dist.tarball : ''
1798
1825
  if (published) value.publishedAt = published
1799
- const score = (v) => String(v || '0').split('.').map((n) => Number(n) || 0).reduce((acc, n) => acc * 1000 + n, 0)
1800
- value.hasUpdate = score(value.latest) > score(current)
1826
+ value.hasUpdate = compareSemver(value.latest, baseline) === 1
1801
1827
  value.command = 'dsh plugin --profile <你的 profile> add dsh-session-superagent@' + (value.latest || 'latest')
1802
1828
  } catch (error) {
1803
1829
  value.error = String((error && error.message) || error).slice(0, 160)
1804
1830
  }
1805
- updateCache = { at: Date.now(), value }
1831
+ if (generation === updateCacheGeneration) updateCache = { at: Date.now(), value }
1806
1832
  return value
1807
1833
  }
1808
1834
 
@@ -2346,7 +2372,10 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2346
2372
  const value = await checkUpdate(url.searchParams.get('refresh') === '1')
2347
2373
  return json(res, 200, value)
2348
2374
  }
2349
- if (req.method !== 'POST') return json(res, 405, { error: 'method not allowed' })
2375
+ if (req.method !== 'POST') {
2376
+ res.setHeader('Allow', 'GET, POST')
2377
+ return json(res, 405, { error: 'method not allowed' })
2378
+ }
2350
2379
  if (!guardWrite(req, res)) return
2351
2380
  const body = await readBody(req, res, true)
2352
2381
  if (body === null) return // 已回 413
@@ -2374,9 +2403,20 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2374
2403
  })
2375
2404
  }
2376
2405
  version = checked.latest
2406
+ const before = versionState()
2407
+ const installedBaseline = isStrictSemver(before.installedVersion) ? before.installedVersion : SERVER_VERSION
2408
+ if (compareSemver(version, installedBaseline) === -1) {
2409
+ return json(res, 409, {
2410
+ ...before,
2411
+ ok: false,
2412
+ code: 'downgrade_requires_explicit_version',
2413
+ version,
2414
+ error: 'npm latest ' + version + ' 低于当前安装基线 ' + installedBaseline + ',本次没有静默降级;如确需降级,请显式指定 version',
2415
+ })
2416
+ }
2377
2417
  }
2378
2418
 
2379
- const result = await runExclusiveUpdate({ version, runner: updateRunner, timeoutMs: updateTimeoutMs })
2419
+ const result = await runExclusiveUpdate({ version, runner: runUpdateAndInvalidateCache, timeoutMs: updateTimeoutMs })
2380
2420
  const state = versionState()
2381
2421
  const common = {
2382
2422
  ...state,
@@ -2406,7 +2446,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2406
2446
  const error = result.error || (typeof code === 'number'
2407
2447
  ? 'DSH CLI 更新命令以非零退出码 ' + code + ' 结束,未确认安装成功'
2408
2448
  : '插件更新失败,未确认安装成功')
2409
- return json(res, status, { ...common, ok: false, code, exitCode: typeof code === 'number' ? code : null, error })
2449
+ // normalizeFailure 已脱敏一次;runner 直接 resolve 的 error 不经过它,路由出口必须再守一次。
2450
+ return json(res, status, { ...common, ok: false, code, exitCode: typeof code === 'number' ? code : null, error: redact(String(error)) })
2410
2451
  },
2411
2452
  })
2412
2453
 
package/lib/semver.js ADDED
@@ -0,0 +1,62 @@
1
+ // SEMVER_COMPARATOR_SOURCE_START
2
+ // This block is duplicated verbatim in client.js because the browser UMD cannot import ESM.
3
+ // test/update-semver.test.mjs audits both copies and exercises their behavior.
4
+ const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
5
+
6
+ function parseSemver(value) {
7
+ if (typeof value !== 'string') return null
8
+ const match = SEMVER_RE.exec(value)
9
+ if (!match) return null
10
+ return {
11
+ core: [match[1], match[2], match[3]],
12
+ prerelease: match[4] === undefined ? null : match[4].split('.'),
13
+ }
14
+ }
15
+
16
+ // Numeric identifiers are compared as decimal strings: Number/BigInt would either
17
+ // lose precision or impose a fixed-width limit that SemVer itself does not have.
18
+ function compareNumericIdentifiers(left, right) {
19
+ if (left.length !== right.length) return left.length < right.length ? -1 : 1
20
+ if (left === right) return 0
21
+ return left < right ? -1 : 1
22
+ }
23
+
24
+ function comparePrerelease(left, right) {
25
+ if (left === null || right === null) {
26
+ if (left === right) return 0
27
+ return left === null ? 1 : -1
28
+ }
29
+ const length = Math.max(left.length, right.length)
30
+ for (let index = 0; index < length; index += 1) {
31
+ if (index >= left.length) return -1
32
+ if (index >= right.length) return 1
33
+ const a = left[index]
34
+ const b = right[index]
35
+ if (a === b) continue
36
+ const aNumeric = /^\d+$/.test(a)
37
+ const bNumeric = /^\d+$/.test(b)
38
+ if (aNumeric && bNumeric) return compareNumericIdentifiers(a, b)
39
+ if (aNumeric !== bNumeric) return aNumeric ? -1 : 1
40
+ return a < b ? -1 : 1
41
+ }
42
+ return 0
43
+ }
44
+
45
+ /** Return -1/0/1 by SemVer precedence, or null when either input is invalid. */
46
+ function compareSemver(left, right) {
47
+ const a = parseSemver(left)
48
+ const b = parseSemver(right)
49
+ if (!a || !b) return null
50
+ for (let index = 0; index < 3; index += 1) {
51
+ const compared = compareNumericIdentifiers(a.core[index], b.core[index])
52
+ if (compared !== 0) return compared
53
+ }
54
+ return comparePrerelease(a.prerelease, b.prerelease)
55
+ }
56
+
57
+ function isStrictSemver(value) {
58
+ return parseSemver(value) !== null
59
+ }
60
+ // SEMVER_COMPARATOR_SOURCE_END
61
+
62
+ export { compareSemver, isStrictSemver }
package/lib/update.js CHANGED
@@ -2,12 +2,15 @@ import { spawn } from 'node:child_process'
2
2
  import { statSync } from 'node:fs'
3
3
  import { delimiter, dirname, extname, join, resolve } from 'node:path'
4
4
 
5
+ import { redact } from './redact.js'
6
+ import { isStrictSemver } from './semver.js'
7
+
8
+ export { isStrictSemver }
9
+
5
10
  export const UPDATE_PACKAGE_NAME = 'dsh-session-superagent'
6
11
  export const DEFAULT_UPDATE_TIMEOUT_MS = 120_000
7
12
  export const UPDATE_OUTPUT_LIMIT_BYTES = 16 * 1024
8
13
 
9
- // Official semver grammar: no leading "v", ranges, tags, or option-like values.
10
- const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
11
14
  const PROFILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
12
15
  const UPDATE_LOCK_KEY = Symbol.for('dsh-session-superagent.pluginUpdateInFlight')
13
16
 
@@ -17,10 +20,6 @@ function updateError(code, message) {
17
20
  return error
18
21
  }
19
22
 
20
- export function isStrictSemver(value) {
21
- return typeof value === 'string' && value.length <= 160 && SEMVER_RE.test(value)
22
- }
23
-
24
23
  /** The POST body is deliberately closed: no command, args, cwd, env, or profile overrides. */
25
24
  export function validateUpdateBody(body) {
26
25
  if (!body || typeof body !== 'object' || Array.isArray(body)) {
@@ -117,6 +116,24 @@ function standardWindowsCommand(cmdPath, fileExists) {
117
116
  }
118
117
  }
119
118
 
119
+ /** Desktop profile 的 plugin 管理在 desktop-host;通用 dsh/bin.js 会拒绝 reserved desktop。 */
120
+ function desktopWindowsCommand(jsPath, execPath, fileExists) {
121
+ if (!/DeepSeek Harness\.exe$/i.test(execPath) || !fileExists(execPath)) return null
122
+ const marker = join('app.asar', 'dsh', 'node_modules', '@deepseek-ai')
123
+ const index = jsPath.indexOf(marker)
124
+ if (index < 0) return null
125
+ const hostSuffix = join('@deepseek-ai', 'dsh-desktop-host', 'lib', 'cli.js')
126
+ const hostCli = jsPath.endsWith(hostSuffix)
127
+ ? jsPath
128
+ : join(jsPath.slice(0, index), 'app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh-desktop-host', 'lib', 'cli.js')
129
+ if (!fileExists(hostCli)) return null
130
+ return {
131
+ file: execPath,
132
+ args: ['--expose-internals', hostCli],
133
+ env: { ELECTRON_RUN_AS_NODE: '1' },
134
+ }
135
+ }
136
+
120
137
  /**
121
138
  * Resolution order is explicit and deterministic:
122
139
  * 1. DSH_CLI_PATH
@@ -144,10 +161,17 @@ export function resolveDshCommand(options = {}) {
144
161
  if (!fileExists(candidate.path)) continue
145
162
  const extension = extname(candidate.path).toLowerCase()
146
163
  if (['.js', '.mjs', '.cjs'].includes(extension)) {
164
+ if (platform === 'win32' && candidate.path.includes('app.asar')) {
165
+ const converted = desktopWindowsCommand(candidate.path, execPath, fileExists)
166
+ if (!converted) {
167
+ throw updateError('cli_unsupported', 'Windows Desktop 的 asar CLI 必须配套 dsh-desktop-host/lib/cli.js 与 DeepSeek Harness.exe;本次没有退回通用 bin.js 管理 desktop profile')
168
+ }
169
+ return { ...converted, source: candidate.source }
170
+ }
147
171
  return {
148
172
  file: execPath,
149
173
  args: [candidate.path],
150
- env: {},
174
+ env: { ELECTRON_RUN_AS_NODE: '1' },
151
175
  source: candidate.source,
152
176
  }
153
177
  }
@@ -166,19 +190,28 @@ export function resolveDshCommand(options = {}) {
166
190
  }
167
191
 
168
192
  function outputCollector(limit) {
193
+ // 多留一段用于跨 chunk 的完整 token 匹配;最终仍是先脱敏、再截断。
194
+ const captureLimit = limit + 4096
169
195
  const chunks = []
170
196
  let bytes = 0
171
197
  let truncated = false
172
198
  return {
173
199
  append(chunk) {
174
200
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk ?? ''), 'utf8')
175
- const remaining = Math.max(0, limit - bytes)
201
+ const remaining = Math.max(0, captureLimit - bytes)
176
202
  if (remaining > 0) chunks.push(buffer.subarray(0, Math.min(remaining, buffer.length)))
177
203
  bytes += Math.min(remaining, buffer.length)
178
204
  if (buffer.length > remaining) truncated = true
179
205
  },
180
206
  finish() {
181
- return { text: Buffer.concat(chunks, bytes).toString('utf8'), truncated }
207
+ const sanitized = redact(Buffer.concat(chunks, bytes).toString('utf8'))
208
+ const capped = capInjectedOutput(sanitized)
209
+ let text = capped.text
210
+ if (truncated || capped.truncated) {
211
+ // 截断点只留下已知 token 前缀时保守遮蔽;普通长文本不整段吞掉。
212
+ text = text.replace(/(?:gh[pousr]_|sk-[A-Za-z0-9_-]*|xox[baprs]-|AKIA|AIza|eyJ)[A-Za-z0-9_+/.=-]*$/i, '***')
213
+ }
214
+ return { text, truncated: truncated || capped.truncated }
182
215
  },
183
216
  }
184
217
  }
@@ -220,6 +253,7 @@ export function createSpawnRunner(options = {}) {
220
253
  const stdout = outputCollector(UPDATE_OUTPUT_LIMIT_BYTES)
221
254
  const stderr = outputCollector(UPDATE_OUTPUT_LIMIT_BYTES)
222
255
  let settled = false
256
+ let timeoutResult = null
223
257
  const finish = (result) => {
224
258
  if (settled) return
225
259
  settled = true
@@ -235,18 +269,26 @@ export function createSpawnRunner(options = {}) {
235
269
  })
236
270
  }
237
271
  const timer = setTimeout(() => {
272
+ timeoutResult = { code: 'timeout', error: 'DSH CLI 更新命令超过 ' + timeoutMs + 'ms,已终止该 CLI 子进程;未确认安装成功' }
238
273
  try { child.kill('SIGKILL') } catch {}
239
- finish({ code: 'timeout', error: 'DSH CLI 更新命令超过 ' + timeoutMs + 'ms,已终止该 CLI 子进程;未确认安装成功' })
274
+ // kill() 只表示已发送信号;必须等 close 确认进程与 stdio 都已结束。
275
+ // 若 close 永不到达,此 Promise 保持 pending,外层超时后并发锁也继续保持。
240
276
  }, timeoutMs)
241
277
 
242
278
  child.stdout?.on('data', stdout.append)
243
279
  child.stderr?.on('data', stderr.append)
244
280
  child.on('error', (error) => {
281
+ if (timeoutResult) return
245
282
  finish({ code: 'spawn_error', error: String((error && error.message) || error) })
246
283
  })
247
284
  child.on('close', (code, signal) => {
248
- if (typeof code === 'number') finish({ code })
249
- else finish({ code: 'spawn_error', error: 'DSH CLI 未给出退出码' + (signal ? '(signal=' + signal + ')' : '') })
285
+ if (timeoutResult) {
286
+ finish(timeoutResult)
287
+ } else if (typeof code === 'number') {
288
+ finish({ code })
289
+ } else {
290
+ finish({ code: 'spawn_error', error: 'DSH CLI 未给出退出码' + (signal ? '(signal=' + signal + ')' : '') })
291
+ }
250
292
  })
251
293
  })
252
294
  }
@@ -269,8 +311,9 @@ function capInjectedOutput(value) {
269
311
  }
270
312
 
271
313
  function normalizeRunnerResult(result) {
272
- const stdout = capInjectedOutput(result && result.stdout)
273
- const stderr = capInjectedOutput(result && result.stderr)
314
+ // 必须在任何截断之前脱敏:否则 16KiB 边界可能只留下半截 token,路由再脱敏也认不出来。
315
+ const stdout = capInjectedOutput(redact(result && result.stdout))
316
+ const stderr = capInjectedOutput(redact(result && result.stderr))
274
317
  return {
275
318
  ...(result || {}),
276
319
  stdout: stdout.text,
@@ -288,7 +331,8 @@ function normalizeFailure(error) {
288
331
  return {
289
332
  ok: false,
290
333
  code,
291
- error: String((error && error.message) || error || '更新失败').slice(0, 1000),
334
+ // 先脱敏再截断:错误回显也可能带凭证,截断后只剩 token 前缀就无法再识别。
335
+ error: redact(String((error && error.message) || error || '更新失败')).slice(0, 1000),
292
336
  stdout: '',
293
337
  stderr: '',
294
338
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.272",
3
+ "version": "0.9.275",
4
4
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -22,6 +22,7 @@
22
22
  "lib/gitee.js",
23
23
  "lib/state-migration.js",
24
24
  "lib/update.js",
25
+ "lib/semver.js",
25
26
  "cordis.patch.yml",
26
27
  "README.md",
27
28
  "SETUP.md",