dsh-session-superagent 0.9.110 → 0.9.112
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 +34 -0
- package/README.md +2 -2
- package/client.js +5 -2
- package/lib/index.js +22 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
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.112] - 2026-11-03 —— 错误旁边写上「多久之前」,超过一小时标「旧记录」
|
|
6
|
+
|
|
7
|
+
### 为什么
|
|
8
|
+
上一轮清掉了「暂停后旧错误永久挂着」,但**没暂停**的守也会有旧错误:
|
|
9
|
+
轮询失败后不再失败,`lastError` 还在,面板上看起来像"刚刚又失败了"。
|
|
10
|
+
|
|
11
|
+
### 改法
|
|
12
|
+
1. 所有设置 `lastError` 的地方统一走 `setEntryError()`,顺带记 `lastErrorAt`;
|
|
13
|
+
2. `/state` 暴露 `lastErrorAt`;
|
|
14
|
+
3. 面板:`(3 分钟前) 失败原因…`;超过 1 小时显示 `旧记录(2 小时前):失败原因…`。
|
|
15
|
+
|
|
16
|
+
### 测试
|
|
17
|
+
新增 1 例:3 分钟前 → 带「N 分钟前」且不标旧记录;150 分钟前 → 标「旧记录」。合计 **219 例**。
|
|
18
|
+
|
|
19
|
+
## [0.9.111] - 2026-11-03 —— 暂停后旧错误永远挂着;再给"退出码"加一道全库扫描
|
|
20
|
+
|
|
21
|
+
### 从截图那条误报想到的
|
|
22
|
+
304 误报修好之后,还有个遗留问题:**暂停的守不再轮询,旧的 `lastError` 就永远挂在面板上**
|
|
23
|
+
—— 客户看到的红点与「异常」计数,其实是几小时前的旧记录。
|
|
24
|
+
|
|
25
|
+
### 改法
|
|
26
|
+
1. 暂停 / 恢复时清掉瞬时状态:`lastError` / `deferReason` / `lastDeferred` / `consecutiveFailures` / `nextAt`;
|
|
27
|
+
2. 新增全库扫描 `scripts/audit-exit-codes.mjs`:**打印了 FAIL 却没返回非 0** 的脚本一律报出来
|
|
28
|
+
(这是本轮之前的同类"第三类装死",现在有门禁守着);
|
|
29
|
+
3. 接进 `preflight`(第 36 项「退出码一致」)。
|
|
30
|
+
|
|
31
|
+
### 验证
|
|
32
|
+
- 暂停用例:造一个 `lastError` → 面板点暂停 → 状态里 `lastError` 与 `deferReason` 都为 null;
|
|
33
|
+
- 退出码扫描:把 `audit-promises.mjs` 里两处 `process.exitCode = 1` 都换成 `void 0` →
|
|
34
|
+
`FAIL 这些脚本打印了 FAIL 却不返回失败:scripts/audit-promises.mjs`(exit=1);还原后 PASS。
|
|
35
|
+
|
|
36
|
+
### 测试
|
|
37
|
+
合计 **218 例**。
|
|
38
|
+
|
|
5
39
|
## [0.9.110] - 2026-11-02 —— 截图里的「gh: HTTP 304(没归类的错误)」是误报
|
|
6
40
|
|
|
7
41
|
### 客户看到的
|
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)
|
|
6
|
-
[](https://github.com/MYCF711/dsh-session-superagent/releases)
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-session-superagent)
|
|
8
8
|
[](https://github.com/topics/dsh-plugin)
|
|
9
9
|
|
|
@@ -122,7 +122,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
122
122
|
## 开发
|
|
123
123
|
|
|
124
124
|
```sh
|
|
125
|
-
node --test #
|
|
125
|
+
node --test # 219 项单测
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
### 工具输出:文本给人和 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.
|
|
17
|
+
const CLIENT_VERSION = '0.9.112'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -1105,8 +1105,11 @@ window.__ModuleLoader__.load({
|
|
|
1105
1105
|
gateway: { label: '立刻重试', onClick: () => act(watcher, 'poll') },
|
|
1106
1106
|
}
|
|
1107
1107
|
const fix = FIX[watcher.lastErrorKind] || null
|
|
1108
|
+
const errAge = watcher.lastErrorAt ? ageText(watcher.lastErrorAt) : ''
|
|
1109
|
+
const staleErr = watcher.lastErrorAt && (Date.now() - Date.parse(watcher.lastErrorAt)) > 3600 * 1000
|
|
1108
1110
|
return h('div', { className: 'dt-ticket-note dt-ticket-note-error' },
|
|
1109
|
-
|
|
1111
|
+
(errAge && errAge !== '—' ? (staleErr ? '旧记录(' + errAge + '前):' : '(' + errAge + '前) ') : '')
|
|
1112
|
+
+ parts.main.slice(0, 120) + (parts.main.length > 120 ? '…' : ''),
|
|
1110
1113
|
parts.hint ? h('div', { className: 'dt-hint' }, parts.hint) : null,
|
|
1111
1114
|
fix ? h('div', { className: 'dt-actions' }, h(Btn, { size: 'sm', variant: 'outline', 'aria-label': fix.label, onClick: fix.onClick }, fix.label)) : null)
|
|
1112
1115
|
})() : null,
|
package/lib/index.js
CHANGED
|
@@ -40,12 +40,17 @@ import {
|
|
|
40
40
|
|
|
41
41
|
export const name = 'dsh-session-superagent'
|
|
42
42
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
43
|
-
export const SERVER_VERSION = '0.9.
|
|
43
|
+
export const SERVER_VERSION = '0.9.112'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
47
47
|
const PROCESS_STARTED_AT = Date.now()
|
|
48
48
|
// 「未变化」那句两处要一模一样:单点改文案不会漏另一处
|
|
49
|
+
// 记错误时同时记时间:面板要能说「这是 12 分钟前的」而不是默认它刚刚发生
|
|
50
|
+
function setEntryError(entry, text) {
|
|
51
|
+
entry.lastError = text
|
|
52
|
+
entry.lastErrorAt = new Date().toISOString()
|
|
53
|
+
}
|
|
49
54
|
const UNCHANGED_TEXT = '未变化(304,不计入速率限制)'
|
|
50
55
|
// 追溯找不到任何痕迹时的那句话:两个入口(工具 / HTTP)必须一模一样
|
|
51
56
|
const noTraceText = (number, scope) => '#' + number + ' 在' + (scope || '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
|
|
@@ -881,7 +886,7 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
881
886
|
const detail = redact(res.stderr).slice(0, 240)
|
|
882
887
|
// 常见失败给一句能照着做的提示,别只丢原始 stderr
|
|
883
888
|
const classified = classifyGhError(detail)
|
|
884
|
-
entry
|
|
889
|
+
setEntryError(entry, (classified.short + classified.hint).slice(0, 300))
|
|
885
890
|
bumpFailure(entry, baseMs)
|
|
886
891
|
return
|
|
887
892
|
}
|
|
@@ -908,8 +913,8 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
908
913
|
}
|
|
909
914
|
if (parsed.etag) entry.etag = parsed.etag
|
|
910
915
|
let items
|
|
911
|
-
try { items = JSON.parse(parsed.body) } catch { entry
|
|
912
|
-
if (!Array.isArray(items)) { entry
|
|
916
|
+
try { items = JSON.parse(parsed.body) } catch { setEntryError(entry, '返回内容不是合法 JSON(可能是代理干扰)—— 已按退避自动重试;持续出现请跑 watch_doctor'); bumpFailure(entry, baseMs); return }
|
|
917
|
+
if (!Array.isArray(items)) { setEntryError(entry, '返回的数据结构不对(预期是数组)—— 已按退避自动重试;持续出现请跑 watch_doctor'); bumpFailure(entry, baseMs); return }
|
|
913
918
|
|
|
914
919
|
entry.lastError = null
|
|
915
920
|
entry.consecutiveFailures = 0
|
|
@@ -1010,7 +1015,7 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
1010
1015
|
if (!liveAgent) {
|
|
1011
1016
|
// 会话已经不在了(被删/换机器):别开隔离区,也别假装在盯。
|
|
1012
1017
|
// 必须走 bumpFailure —— 否则这条会每 intervalSec 打一次 GitHub,永不退避(第四轮审核指出)。
|
|
1013
|
-
entry
|
|
1018
|
+
setEntryError(entry, '会话已不在:请删除或重建这条主理鱼')
|
|
1014
1019
|
bumpFailure(entry, baseMs)
|
|
1015
1020
|
return
|
|
1016
1021
|
}
|
|
@@ -1094,7 +1099,7 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
1094
1099
|
entry.cursor = newestUpdatedAt(fresh)
|
|
1095
1100
|
} else {
|
|
1096
1101
|
// 保留水位,下一轮重试这次事件
|
|
1097
|
-
entry
|
|
1102
|
+
setEntryError(entry, 'wake failed: ' + String(result.reason || ''))
|
|
1098
1103
|
noteEvent(entry, 'wake-failed', entry.lastError)
|
|
1099
1104
|
// 会话正忙是暂时的:下一轮直接重试;退避反而会越拖越久
|
|
1100
1105
|
entry.deferReason = 'busy'
|
|
@@ -1158,7 +1163,7 @@ export function apply(ctx) {
|
|
|
1158
1163
|
} catch (error) {
|
|
1159
1164
|
// 未预期的异常(比如宿主上下文/服务不可用)也必须退避:
|
|
1160
1165
|
// 之前只写 lastError,于是坏掉的 watcher 会按 intervalSec 无限重试(真机踩到过)。
|
|
1161
|
-
entry
|
|
1166
|
+
setEntryError(entry, String((error && error.message) || error))
|
|
1162
1167
|
bumpFailure(entry, every)
|
|
1163
1168
|
} finally {
|
|
1164
1169
|
inFlight.delete(entry.id)
|
|
@@ -1311,7 +1316,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1311
1316
|
// 同一个仓库被别的会话也守着:客户该知道「还有谁在看」
|
|
1312
1317
|
otherSessions: allWatchers.filter((peer) => peer && peer.repo === w.repo && peer.sessionId !== w.sessionId).map((peer) => peer.sessionId),
|
|
1313
1318
|
// 分类放在服务端做一次:面板按 kind 给「下一步」按钮,不用自己解析中文
|
|
1314
|
-
lastErrorKind: w.lastError ? classifyGhError(String(w.lastError)).kind : null,
|
|
1319
|
+
lastErrorKind: w.lastError ? classifyGhError(String(w.lastError)).kind : null,
|
|
1320
|
+
lastErrorAt: w.lastErrorAt || null,
|
|
1315
1321
|
deferReason: w.deferReason ?? null,
|
|
1316
1322
|
daily: dailySummary(w.dailyWakes),
|
|
1317
1323
|
busy: busierThanUsual(dailySummary(w.dailyWakes)),
|
|
@@ -1505,6 +1511,14 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1505
1511
|
entry.nextAt = null
|
|
1506
1512
|
// 没传 enabled 就保持原值:只改间隔/标签不该把暂停的 watcher 悄悄恢复
|
|
1507
1513
|
entry.enabled = body.enabled === undefined ? (entry.enabled !== false) : body.enabled !== false
|
|
1514
|
+
// 暂停/恢复时清掉「上一次的错误」:暂停后不再轮询,旧错误会一直挂在面板上变成假异常
|
|
1515
|
+
if (body.enabled === false || body.enabled === true) {
|
|
1516
|
+
entry.lastError = null
|
|
1517
|
+
entry.deferReason = null
|
|
1518
|
+
entry.lastDeferred = null
|
|
1519
|
+
entry.consecutiveFailures = 0
|
|
1520
|
+
entry.nextAt = null
|
|
1521
|
+
}
|
|
1508
1522
|
// 只有**新建**时才做添加前体检:编辑已有守不该再打一次网络
|
|
1509
1523
|
const isNew = !created && !state.watchers[id]
|
|
1510
1524
|
let warnings = []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.112",
|
|
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",
|