dsh-session-superagent 0.9.121 → 0.9.123
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 +51 -0
- package/README.md +2 -2
- package/client.js +17 -1
- package/lib/index.js +3 -2
- package/lib/watch.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
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.123] - 2026-11-03 —— 「已放慢到 2 小时档」不该是写死的文案
|
|
6
|
+
|
|
7
|
+
### 学到什么(出处)
|
|
8
|
+
Kubernetes Job 的做法:重试策略写在 `spec`(`backoffLimit`、退避上限),**状态由控制器按它算出来再写进 `status`**:
|
|
9
|
+
|
|
10
|
+
> The `.spec.backoffLimit` is set by default to 6 … The number of retries is calculated in two ways …
|
|
11
|
+
|
|
12
|
+
<https://kubernetes.io/docs/concepts/workloads/controllers/job/>
|
|
13
|
+
|
|
14
|
+
政策只有一处定义,派生的数字另算 —— 而不是在 UI 里再抄一份。
|
|
15
|
+
|
|
16
|
+
### 现场
|
|
17
|
+
0.9.122 的面板写着「已放慢到 **2 小时**档」,而这个 2 小时是 `nextDelayMs` 里的字面量。
|
|
18
|
+
一旦有人把上限改成 90 分钟(或把预算从 6 改掉),**这句话立刻变成谎话,而且没有任何门禁会红**。
|
|
19
|
+
|
|
20
|
+
### 改法
|
|
21
|
+
1. `lib/watch.js` 导出 `RETRY_SLOW_CAP_MINUTES = 120`,`nextDelayMs` 用它算上限;
|
|
22
|
+
2. `/state` 顶层新增 `retryPolicy: { budgetAttempts, slowCapMinutes }`(一次请求,逐守可用);
|
|
23
|
+
3. 面板的档位文案由这三个数字算出来(≥60 分钟显示小时,否则显示分钟)。
|
|
24
|
+
|
|
25
|
+
### 测试
|
|
26
|
+
新增 1 例:默认 → 「2 小时档」;改成 90 分钟 → 「1.5 小时档」;预算调到 20 → 8 次失败**不该**说"已放慢"。
|
|
27
|
+
合计 **233 例**。
|
|
28
|
+
|
|
29
|
+
## [0.9.122] - 2026-11-03 —— 面板上写出「第几次失败 + 下次什么时候重试」
|
|
30
|
+
|
|
31
|
+
### 学到什么(出处)
|
|
32
|
+
Kubernetes Job 的重试策略把这些数字**暴露在 status 里**给人和工具看:
|
|
33
|
+
|
|
34
|
+
> The `.spec.backoffLimit` is set by default to **6**. Failed Pods … are recreated by the Job controller with
|
|
35
|
+
> an **exponential back-off delay (10s, 20s, 40s …) capped at ten minutes**.
|
|
36
|
+
|
|
37
|
+
<https://kubernetes.io/docs/concepts/workloads/controllers/job/>
|
|
38
|
+
|
|
39
|
+
两个要点:① 默认重试上限就是 **6**(和 0.9.121 的 `RETRY_BUDGET_ATTEMPTS` 一致,属于巧合但方向对);
|
|
40
|
+
② **重试进度是可读的状态**,不是藏在日志里的行为。
|
|
41
|
+
|
|
42
|
+
### 改法
|
|
43
|
+
面板每条守在有失败时多一行:
|
|
44
|
+
```
|
|
45
|
+
已连续失败 7 次 · 下次重试约 90 分钟后(已放慢到 2 小时档)
|
|
46
|
+
```
|
|
47
|
+
数据全部来自 `/state` 已有的 `consecutiveFailures` / `nextAt`,没有新增字段、没有额外请求。
|
|
48
|
+
|
|
49
|
+
### 为什么要写
|
|
50
|
+
0.9.121 让失败后的间隔放慢到 2 小时,**如果面板不写出来,客户只会看到"它不动了"** ——
|
|
51
|
+
把"我们主动放慢"误读成"它坏了"。
|
|
52
|
+
|
|
53
|
+
### 测试
|
|
54
|
+
新增 1 例:失败 7 次 + 90 分钟后重试 → 面板出现次数、时间、以及「2 小时档」。合计 **232 例**。
|
|
55
|
+
|
|
5
56
|
## [0.9.121] - 2026-11-03 —— 重试要花预算:连续失败 6 次后放慢到 2 小时一次
|
|
6
57
|
|
|
7
58
|
### 学到什么(出处)
|
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
|
|
|
@@ -123,7 +123,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
123
123
|
## 开发
|
|
124
124
|
|
|
125
125
|
```sh
|
|
126
|
-
node --test #
|
|
126
|
+
node --test # 233 项单测
|
|
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.
|
|
17
|
+
const CLIENT_VERSION = '0.9.123'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -1093,6 +1093,22 @@ 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
|
+
(() => {
|
|
1097
|
+
const fails = Number(watcher.consecutiveFailures) || 0
|
|
1098
|
+
if (fails < 1 || !watcher.nextAt) return null
|
|
1099
|
+
// 让「为什么很久没动」写在面板上:K8s 的 Job 也是把 backoff 状态暴露在 status 里
|
|
1100
|
+
const wait = Math.max(0, Date.now() - Date.parse(watcher.nextAt))
|
|
1101
|
+
const left = Date.parse(watcher.nextAt) - Date.now()
|
|
1102
|
+
const mins = Math.max(0, Math.round((left > 0 ? left : wait) / 60000))
|
|
1103
|
+
// 档位文案从后端给的 retryPolicy 算:写死「2 小时」会在有人改常量后变成谎话
|
|
1104
|
+
const policy = (body && body.retryPolicy) || {}
|
|
1105
|
+
const budget = Number(policy.budgetAttempts) || 6
|
|
1106
|
+
const capMin = Number(policy.slowCapMinutes) || 120
|
|
1107
|
+
const capText = capMin >= 60 ? (capMin / 60) + ' 小时' : capMin + ' 分钟'
|
|
1108
|
+
const slow = fails >= budget ? '(已放慢到 ' + capText + '档)' : ''
|
|
1109
|
+
return h('div', { className: 'dt-hint' },
|
|
1110
|
+
'已连续失败 ' + fails + ' 次 · ' + (left > 0 ? '下次重试约 ' + mins + ' 分钟后' : '等待重试') + slow)
|
|
1111
|
+
})(),
|
|
1096
1112
|
watcher.needsReauth ? h('div', { className: 'dt-banner dt-danger' },
|
|
1097
1113
|
'凭证失效:跑 gh auth login 重新登录 —— 它不会自己恢复,在此之前这条守只会一直失败') : null,
|
|
1098
1114
|
watcher.lastError ? (() => {
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { redact } from './redact.js'
|
|
|
25
25
|
import { decodeBody } from './body.js'
|
|
26
26
|
import {
|
|
27
27
|
advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
28
|
-
TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, formatGhCall, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, enterActiveHoursDefer, permanentBackoffMs, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
28
|
+
TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, formatGhCall, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, enterActiveHoursDefer, permanentBackoffMs, RETRY_BUDGET_ATTEMPTS, RETRY_SLOW_CAP_MINUTES, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
29
29
|
shouldRunCleanup,
|
|
30
30
|
bumpDailyWakes,
|
|
31
31
|
busierThanUsual,
|
|
@@ -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.
|
|
43
|
+
export const SERVER_VERSION = '0.9.123'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -1410,6 +1410,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1410
1410
|
tokenScopes: scopesCache.value || null,
|
|
1411
1411
|
isolation: isolationReport(Object.values(state.watchers || {})),
|
|
1412
1412
|
sessionTitle: sessionTitle(focusSession),
|
|
1413
|
+
retryPolicy: { budgetAttempts: RETRY_BUDGET_ATTEMPTS, slowCapMinutes: RETRY_SLOW_CAP_MINUTES },
|
|
1413
1414
|
watchers: watchers.map((w) => ({ ...w, goal: goalView(ctx, w.sessionId) })),
|
|
1414
1415
|
}
|
|
1415
1416
|
// ETag/304:面板每 5 秒拉一次 /state,没变化时没必要重传整份 JSON ——
|
package/lib/watch.js
CHANGED
|
@@ -350,13 +350,15 @@ export function permanentBackoffMs(kind, baseMs = 60000) {
|
|
|
350
350
|
* 出处:https://sre.google/sre-book/handling-overload/
|
|
351
351
|
*/
|
|
352
352
|
export const RETRY_BUDGET_ATTEMPTS = 6
|
|
353
|
+
// 预算外的等待上限(分钟):面板上的「已放慢到 X 小时档」从这里算,不再写死文案
|
|
354
|
+
export const RETRY_SLOW_CAP_MINUTES = 120
|
|
353
355
|
export function nextDelayMs(entry, baseMs) {
|
|
354
356
|
const failures = Number((entry && entry.consecutiveFailures) || 0)
|
|
355
357
|
if (failures <= 0) return baseMs
|
|
356
358
|
const overBudget = failures >= RETRY_BUDGET_ATTEMPTS
|
|
357
359
|
// 预算内:最多 60 倍(默认 60s 间隔 → 1 小时);超出预算:最多 120 倍(→ 2 小时)
|
|
358
360
|
const factor = Math.min(2 ** failures, overBudget ? 120 : 60)
|
|
359
|
-
const cap = overBudget ?
|
|
361
|
+
const cap = overBudget ? RETRY_SLOW_CAP_MINUTES * 60 * 1000 : 30 * 60 * 1000
|
|
360
362
|
return Math.min(Math.max(baseMs * factor, baseMs), cap)
|
|
361
363
|
}
|
|
362
364
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.123",
|
|
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",
|