dsh-session-superagent 0.9.118 → 0.9.120

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,63 @@
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.120] - 2026-11-03 —— 合并唤醒消息:同一份「接下来」只印一次
6
+
7
+ ### 学到什么(出处)
8
+ Google SRE 书《Monitoring Distributed Systems》讲告警的核心原则:
9
+
10
+ > **Every page should be actionable.** … Every time the pager goes off, I should be able to react
11
+ > with a sense of urgency.
12
+
13
+ <https://sre.google/sre-book/monitoring-distributed-systems/>
14
+
15
+ 但 **actionable ≠ 把同一份指令印 N 遍** —— 合并唤醒(多条一起叫)原来每条都带一份
16
+ 「接下来:1/2/3」,三条就是同一段指令重复三次,读者只会更快跳过它。
17
+
18
+ ### 改法
19
+ `mergeWakeTexts()` 把每条消息里 `接下来:` 之后的收尾剥掉,最后**统一附一份**,
20
+ 每条自己的【完成标准】仍各自保留(内容不同,不能合并)。
21
+
22
+ ### 证据(3 条合并,实测)
23
+ | | 长度 |
24
+ |---|---|
25
+ | 改前 | 309 字符(「接下来」出现 **3** 次) |
26
+ | 改后 | 259 字符(出现 **1** 次,净省 50) |
27
+
28
+ 省下的不是大头(分隔行会补回来一点),关键是**读起来的噪音**:一份指令只出现一次。
29
+
30
+ ### 测试
31
+ 新增 1 例:3 条合并后「接下来」恰好 1 次、每条完成标准都在、净省长度 > 30。合计 **229 例**。
32
+
33
+ ### 说明
34
+ `raw.githubusercontent.com` 与 `api.github.com` 本轮仍 502,所以学习源换成了 `sre.google`(可访问)。
35
+
36
+ ## [0.9.119] - 2026-11-03 —— 凭证失效要单独报,并说清"不会自己恢复"
37
+
38
+ ### 真机现场
39
+ ```
40
+ $ gh auth status
41
+ X Failed to log in to github.com account MYCF711 (keyring)
42
+ - The token in keyring is invalid.
43
+ ```
44
+ 插件这边只会显示一条普通的失败(`gh 登录失效:跑 gh auth login`),混在网络抖动里,
45
+ 客户很容易以为"等会儿就好"。而 **401 永远不会自己好**。
46
+
47
+ ### 改法
48
+ 1. `permanentBackoffMs` 把 `auth` 也纳入 30 分钟退避 —— 每 60 秒重试一次无意义,反复 401 还可能被风控;
49
+ 2. 失败时置 `needsReauth = true`,任何一次成功(含 304/204)都清掉;
50
+ 3. `/state` 暴露 `needsReauth`;
51
+ 4. `watch_doctor` 单列一行:
52
+ `FAIL 凭证失效(N 条守):跑 gh auth login 重新登录,在此之前这些守只会一直失败 —— 它不会自己恢复`
53
+ 5. 面板顶部给红色横幅(不只是那行小字错误)。
54
+
55
+ ### 测试
56
+ 新增 3 例:`auth` 的 30 分钟退避、doctor 的"不会自己恢复"提示、面板横幅。合计 **228 例**。
57
+
58
+ ### 说明
59
+ GitHub 文档本轮不可达(`raw.githubusercontent.com` 与 `api.github.com` 均 502),
60
+ 所以这条只依据本机 `gh auth status` 的实测输出,未复核文档原文。
61
+
5
62
  ## [0.9.118] - 2026-11-03 —— 单测从 101 秒降到 1.6 秒:它们一直在等一个不可能的 gh 响应
6
63
 
7
64
  ### 现场
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.118-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.120-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
 
@@ -123,7 +123,7 @@ dsh plugin install /path/to/dsh-session-superagent
123
123
  ## 开发
124
124
 
125
125
  ```sh
126
- node --test # 225 项单测
126
+ node --test # 229 项单测
127
127
  ```
128
128
 
129
129
  ### 工具输出:文本给人和 agent,JSON 给程序
package/client.js CHANGED
@@ -14,7 +14,7 @@ window.__ModuleLoader__.load({
14
14
  const { useCallback, useEffect, useRef, useState } = React
15
15
 
16
16
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
17
- const CLIENT_VERSION = '0.9.118'
17
+ const CLIENT_VERSION = '0.9.120'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1093,6 +1093,8 @@ window.__ModuleLoader__.load({
1093
1093
  (watcher.otherSessions && watcher.otherSessions.length > 0)
1094
1094
  ? h('div', { className: 'dt-ticket-note' }, '还有 ' + watcher.otherSessions.length + ' 个会话也在守这个仓库:' + watcher.otherSessions.join('、') + '(各自独立唤醒;但 ack 标签是仓库级的 —— 任一方 ack 后两边都会跳过,想让两边各处理各的就给对方设不同标签)')
1095
1095
  : null,
1096
+ watcher.needsReauth ? h('div', { className: 'dt-banner dt-danger' },
1097
+ '凭证失效:跑 gh auth login 重新登录 —— 它不会自己恢复,在此之前这条守只会一直失败') : null,
1096
1098
  watcher.lastError ? (() => {
1097
1099
  const parts = splitErrorText(watcher.lastError)
1098
1100
  // 错误光说「为什么」不够,要能点一下就到「下一步」(服务端已给 kind)
package/lib/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
 
41
41
  export const name = 'dsh-session-superagent'
42
42
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
43
- export const SERVER_VERSION = '0.9.118'
43
+ export const SERVER_VERSION = '0.9.120'
44
44
  export const inject = ['tools', 'agents', 'webServer']
45
45
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
46
46
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -891,6 +891,7 @@ async function pollOnce(ctx, entry, baseMs) {
891
891
  // gh 把 304 当失败(非 2xx 就 exit 1):这不是错误,是「条件请求命中」
892
892
  if (/HTTP 304|304 Not Modified|not modified/i.test(String(res.stderr || '') + String(res.stdout || ''))) {
893
893
  entry.lastError = null
894
+ entry.needsReauth = false
894
895
  entry.consecutiveFailures = 0
895
896
  entry.nextAt = null
896
897
  entry.lastDeferred = UNCHANGED_TEXT
@@ -907,6 +908,7 @@ async function pollOnce(ctx, entry, baseMs) {
907
908
  entry.deferReason = 'ratelimit'
908
909
  noteEvent(entry, 'ratelimit', entry.lastDeferred)
909
910
  entry.lastError = null
911
+ entry.needsReauth = false
910
912
  return
911
913
  }
912
914
  const detail = redact(res.stderr).slice(0, 240)
@@ -915,6 +917,8 @@ async function pollOnce(ctx, entry, baseMs) {
915
917
  setEntryError(entry, (classified.short + classified.hint).slice(0, 300))
916
918
  bumpFailure(entry, baseMs)
917
919
  // 永久性错误(404 / 仓库改名)不要按普通退避重试:至少等半小时
920
+ // 凭证问题要显式标出来:它不会自己恢复,客户必须去 gh auth login
921
+ if (classified.kind === 'auth') entry.needsReauth = true
918
922
  const permanent = permanentBackoffMs(classified.kind, baseMs)
919
923
  if (permanent > 0) {
920
924
  entry.nextAt = new Date(Date.now() + permanent).toISOString()
@@ -937,11 +941,13 @@ async function pollOnce(ctx, entry, baseMs) {
937
941
  entry.deferReason = 'quota'
938
942
  + new Date(Date.now() + throttle).toISOString().slice(11, 16) + 'Z'
939
943
  entry.lastError = null
944
+ entry.needsReauth = false
940
945
  return
941
946
  }
942
947
  // 204 No Content 也是「没有新东西」:DELETE/空列表都会这样,别当 JSON 解析失败
943
948
  if (parsed.status === 204) {
944
949
  entry.lastError = null
950
+ entry.needsReauth = false
945
951
  entry.consecutiveFailures = 0
946
952
  entry.nextAt = null
947
953
  entry.lastDeferred = '没有内容(204)'
@@ -952,6 +958,7 @@ async function pollOnce(ctx, entry, baseMs) {
952
958
  if (parsed.status === 304) {
953
959
  // 没变化:不解析、不算失败、不重置退避,只记一笔
954
960
  entry.lastError = null
961
+ entry.needsReauth = false
955
962
  entry.consecutiveFailures = 0
956
963
  entry.nextAt = null
957
964
  entry.lastDeferred = UNCHANGED_TEXT
@@ -965,6 +972,7 @@ async function pollOnce(ctx, entry, baseMs) {
965
972
  if (!Array.isArray(items)) { setEntryError(entry, '返回的数据结构不对(预期是数组)—— 已按退避自动重试;持续出现请跑 watch_doctor'); bumpFailure(entry, baseMs); return }
966
973
 
967
974
  entry.lastError = null
975
+ entry.needsReauth = false
968
976
  entry.consecutiveFailures = 0
969
977
  entry.nextAt = null
970
978
  // 记住最近一条"被重新打开"的 issue:这是最该被看见的信号(之前判过不做)
@@ -1369,6 +1377,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1369
1377
  // 分类放在服务端做一次:面板按 kind 给「下一步」按钮,不用自己解析中文
1370
1378
  lastErrorKind: w.lastError ? classifyGhError(String(w.lastError)).kind : null,
1371
1379
  lastErrorAt: w.lastErrorAt || null,
1380
+ needsReauth: w.needsReauth === true,
1372
1381
  deferReason: w.deferReason ?? null,
1373
1382
  daily: dailySummary(w.dailyWakes),
1374
1383
  busy: busierThanUsual(dailySummary(w.dailyWakes)),
@@ -1958,6 +1967,14 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1958
1967
  const all = Object.values(state.watchers || {})
1959
1968
  const wanted = args.repo ? all.filter((w) => w && w.repo === String(args.repo)) : all
1960
1969
 
1970
+ // -3. 凭证失效:不会自愈,必须人去登录
1971
+ {
1972
+ const needAuth = wanted.filter((w) => w.needsReauth === true)
1973
+ if (needAuth.length > 0) {
1974
+ lines.push('FAIL 凭证失效(' + needAuth.length + ' 条守):跑 gh auth login 重新登录,'
1975
+ + '在此之前这些守只会一直失败 —— 它不会自己恢复')
1976
+ }
1977
+ }
1961
1978
  // -2. 状态来源:从备份或损坏里恢复过,客户有权知道(否则他会纳闷「我的守怎么少了一条」)
1962
1979
  if (stateSource === 'backup') {
1963
1980
  lines.push('WARN 状态文件坏过一次,已从备份恢复(原文件留在 .corrupt-* 里,可人工检查)')
package/lib/watch.js CHANGED
@@ -336,7 +336,8 @@ export function enterActiveHoursDefer(entry, waitMs, hours, at = new Date()) {
336
336
  return entry
337
337
  }
338
338
  export function permanentBackoffMs(kind, baseMs = 60000) {
339
- const PERMANENT = new Set(['notfound', 'moved'])
339
+ // auth:凭证失效不会自己好 —— 每 60 秒重试既无用,也可能被风控当成异常
340
+ const PERMANENT = new Set(['notfound', 'moved', 'auth'])
340
341
  if (!PERMANENT.has(kind)) return 0
341
342
  return Math.max(30 * 60 * 1000, Number(baseMs) || 0)
342
343
  }
@@ -662,9 +663,22 @@ export function mergeWakeTexts(parts) {
662
663
  .join(String.fromCharCode(10))
663
664
  return out
664
665
  })
666
+ // 「接下来」那一整段是每次唤醒都一样的收尾(三条动作)。合并后重复 N 遍纯噪音:
667
+ // 它就是同一份指令,客户读一遍就够。依据:SRE 的「Every page should be actionable」,
668
+ // 但 actionable 不等于把同一份指令印 N 次。
669
+ const TAIL = '接下来:'
670
+ const withTail = trimmed.filter((text) => text.includes(TAIL))
671
+ const stripped = trimmed.map((text) => {
672
+ const at = text.indexOf(TAIL)
673
+ return at < 0 ? text : text.slice(0, at).replace(/[\s]+$/, '')
674
+ })
675
+ const tailBlock = withTail.length > 1
676
+ ? withTail[0].slice(withTail[0].indexOf(TAIL))
677
+ : ''
678
+
665
679
  const head = '【主理鱼】这一小段时间内有 ' + list.length + ' 处变化,合并成一条:'
666
- const body = trimmed.map((text, i) => String.fromCharCode(10, 10) + '—— 第 ' + (i + 1) + ' 处 ——' + String.fromCharCode(10) + text).join('')
667
- return head + body
680
+ const body = stripped.map((text, i) => String.fromCharCode(10, 10) + '—— 第 ' + (i + 1) + ' 处 ——' + String.fromCharCode(10) + text).join('')
681
+ return head + body + (tailBlock ? String.fromCharCode(10, 10) + tailBlock : '')
668
682
  }
669
683
 
670
684
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.118",
3
+ "version": "0.9.120",
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",