dsh-session-superagent 0.9.95 → 0.9.96

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,22 @@
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.96] - 2026-11-02 —— 刚重启 ≠ 定时器丢了
6
+
7
+ ### 为什么
8
+ 上一版加的停滞检查(`age > max(3×interval, 5min)`)有一个假警报:
9
+ **宿主重启后**,`lastPoll` 天然是几小时前的,doctor 立刻报「定时器可能丢了」——
10
+ 而客户只是刚重启。**假故障比没检查更糟**,客户会开始不信这个自检。
11
+
12
+ ### 改法
13
+ - 记录 `PROCESS_STARTED_AT`,写进 `state.server.startedAt`;
14
+ - 停滞判断加一个前提:**进程 uptime 也超过停滞周期**才报故障;
15
+ - 否则给一条如实说明:`上次轮询是 120 分钟前,但进程才启动 1 分钟 —— 刚重启,等下一轮即可`。
16
+
17
+ ### 测试
18
+ - 更新 1 例(原「定时器丢了」用例补上"进程已跑 4 小时"的前提);
19
+ - 新增 1 例:刚重启 → 出现「刚重启」、不出现「定时器可能丢了」;进程跑够 3 小时 → 才报故障。合计 **207 例**。
20
+
5
21
  ## [0.9.95] - 2026-11-02 —— 长跑体积实测:20 条守跑 30 天 204 KB → 165 KB
6
22
 
7
23
  ### 怎么量的
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.95-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.96-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
 
@@ -121,7 +121,7 @@ dsh plugin install /path/to/dsh-session-superagent
121
121
  ## 开发
122
122
 
123
123
  ```sh
124
- node --test # 206 项单测
124
+ node --test # 207 项单测
125
125
  ```
126
126
 
127
127
  ### 工具输出:文本给人和 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.95'
17
+ const CLIENT_VERSION = '0.9.96'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -40,9 +40,11 @@ import {
40
40
 
41
41
  export const name = 'dsh-session-superagent'
42
42
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
43
- export const SERVER_VERSION = '0.9.95'
43
+ export const SERVER_VERSION = '0.9.96'
44
44
  export const inject = ['tools', 'agents', 'webServer']
45
45
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
46
+ // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
47
+ const PROCESS_STARTED_AT = Date.now()
46
48
  const DEFAULT_SESSION_WAKES = 12
47
49
  // 一条会话最多挂多少守:再多轮询压力与上下文都会失控(20 条 × 每 60 秒已很密)
48
50
  const MAX_WATCHERS_PER_SESSION = 20
@@ -1659,11 +1661,11 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1659
1661
  }
1660
1662
  }
1661
1663
  const state = readState()
1662
- state.server = { at: new Date().toISOString(), routes: routes.length, failed: failedRoutes, base: activeBase }
1664
+ state.server = { at: new Date().toISOString(), routes: routes.length, failed: failedRoutes, base: activeBase, startedAt: new Date(PROCESS_STARTED_AT).toISOString() }
1663
1665
  writeState(state)
1664
1666
  } catch (error) {
1665
1667
  const state = readState()
1666
- state.server = { at: new Date().toISOString(), routes: routes.length, failed: failedRoutes, error: String((error && error.message) || error).slice(0, 300) }
1668
+ state.server = { at: new Date().toISOString(), routes: routes.length, failed: failedRoutes, error: String((error && error.message) || error).slice(0, 300), startedAt: new Date(PROCESS_STARTED_AT).toISOString() }
1667
1669
  writeState(state)
1668
1670
  }
1669
1671
  const teardown = () => {
@@ -1943,8 +1945,12 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1943
1945
  const intervalMs = (Number(entry.intervalSec) || 60) * 1000
1944
1946
  const staleMs = Math.max(intervalMs * 3, 5 * 60 * 1000)
1945
1947
  const age = Date.now() - Date.parse(entry.lastPoll)
1946
- if (Number.isFinite(age) && age > staleMs) {
1948
+ const uptimeMs = state.server && state.server.startedAt ? Date.now() - Date.parse(state.server.startedAt) : Infinity
1949
+ // 刚重启时 uptime 还不够一个停滞周期:陈旧只是「还没轮到」,不是故障
1950
+ if (Number.isFinite(age) && age > staleMs && uptimeMs > staleMs) {
1947
1951
  lines.push(`WARN ${entry.repo} 已经 ${Math.round(age / 60000)} 分钟没轮询过(预期每 ${Math.round(intervalMs / 1000)} 秒)—— 定时器可能丢了`)
1952
+ } else if (Number.isFinite(age) && age > staleMs) {
1953
+ lines.push(`INFO ${entry.repo} 上次轮询是 ${Math.round(age / 60000)} 分钟前,但进程才启动 ${Math.round(uptimeMs / 60000)} 分钟 —— 刚重启,等下一轮即可`)
1948
1954
  }
1949
1955
  }
1950
1956
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.95",
3
+ "version": "0.9.96",
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",