dsh-session-superagent 0.9.122 → 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 CHANGED
@@ -2,6 +2,30 @@
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
+
5
29
  ## [0.9.122] - 2026-11-03 —— 面板上写出「第几次失败 + 下次什么时候重试」
6
30
 
7
31
  ### 学到什么(出处)
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.122-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.123-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 # 232 项单测
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.122'
17
+ const CLIENT_VERSION = '0.9.123'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1100,7 +1100,12 @@ window.__ModuleLoader__.load({
1100
1100
  const wait = Math.max(0, Date.now() - Date.parse(watcher.nextAt))
1101
1101
  const left = Date.parse(watcher.nextAt) - Date.now()
1102
1102
  const mins = Math.max(0, Math.round((left > 0 ? left : wait) / 60000))
1103
- const slow = fails >= 6 ? '(已放慢到 2 小时档)' : ''
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 + '档)' : ''
1104
1109
  return h('div', { className: 'dt-hint' },
1105
1110
  '已连续失败 ' + fails + ' 次 · ' + (left > 0 ? '下次重试约 ' + mins + ' 分钟后' : '等待重试') + slow)
1106
1111
  })(),
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.122'
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 ? 2 * 60 * 60 * 1000 : 30 * 60 * 1000
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.122",
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",