dsh-session-superagent 0.8.51 → 0.8.52
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 +22 -0
- package/MAINTENANCE.md +1 -1
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/index.js +11 -3
- package/lib/watch.js +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
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.8.52] - 2026-11-02 —— 首轮抖动:多条守不再同一毫秒一起发车
|
|
6
|
+
|
|
7
|
+
### 学到的一条(知识库第 2 条)
|
|
8
|
+
AWS《Exponential Backoff And Jitter》:固定周期的客户端会同步成 thundering herd,加抖动摊平峰值。
|
|
9
|
+
<https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/>
|
|
10
|
+
|
|
11
|
+
我们的 `inFlight` 闸是**按 watcher**的,挡不住「N 条守在同一毫秒一起打 gh api」。
|
|
12
|
+
|
|
13
|
+
### 改了什么
|
|
14
|
+
`jitterMs(entry.id, min(5000, 间隔×10%))` 用 **id 哈希**算偏移(可复现,不是随机数),
|
|
15
|
+
只延迟**首轮**,之后按 `every` 稳定推进。
|
|
16
|
+
|
|
17
|
+
### 顺带做了三组实测(都写进知识库)
|
|
18
|
+
| 测什么 | 结果 |
|
|
19
|
+
|---|---|
|
|
20
|
+
| 单条 watcher 满载状态 | **21.8 KB**(seen 500 + history 20 + filteredLog 5),10 条 ≈ 218 KB,有上限 |
|
|
21
|
+
| `gh api` vs `gh api --include` | 稳态几乎同速(~500-650 ms)—— 0.8.51 的 `--include` 没有额外开销 |
|
|
22
|
+
| 抖动分布 | 20 条守 → 17 个不同偏移(用例里要求 >8) |
|
|
23
|
+
|
|
24
|
+
### 测试
|
|
25
|
+
- 合计 **105 例**;UI 体检 11/11。
|
|
26
|
+
|
|
5
27
|
## [0.8.51] - 2026-11-02 —— 条件请求:没变化不计入速率限制
|
|
6
28
|
|
|
7
29
|
### 学到了什么(新知识库 `docs/kb/` 的第一条)
|
package/MAINTENANCE.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## 二、当前状态(2026-11-01)
|
|
11
11
|
|
|
12
|
-
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test`
|
|
12
|
+
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 105/105 通过
|
|
13
13
|
- [x] 自回声抑制(逐条水位)
|
|
14
14
|
- [x] 仅空闲注入(避免草稿回放)
|
|
15
15
|
- [x] 唤醒失败不推进水位
|
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
|
|
|
@@ -99,7 +99,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
99
99
|
## 开发
|
|
100
100
|
|
|
101
101
|
```sh
|
|
102
|
-
node --test #
|
|
102
|
+
node --test # 105 项单测
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
版本与发布流程见 [UPDATING.md](UPDATING.md),交付门见 [CHECKLIST.md](CHECKLIST.md),接手台账见 [MAINTENANCE.md](MAINTENANCE.md)。
|
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.8.
|
|
17
|
+
const CLIENT_VERSION = '0.8.52'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -24,13 +24,13 @@ import { redact } from './redact.js'
|
|
|
24
24
|
import { decodeBody } from './body.js'
|
|
25
25
|
import {
|
|
26
26
|
advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
27
|
-
classifyGhError, filterReason, hasAckLabel, parseGhInclude, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
27
|
+
classifyGhError, filterReason, hasAckLabel, jitterMs, parseGhInclude, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
28
28
|
mergeFilters, mergePollResult, pruneSeen, pruneWakeTimes, pushHistory, recordReported, staleWorktrees, worktreePlan,
|
|
29
29
|
} from './watch.js'
|
|
30
30
|
|
|
31
31
|
export const name = 'dsh-session-superagent'
|
|
32
32
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
33
|
-
export const SERVER_VERSION = '0.8.
|
|
33
|
+
export const SERVER_VERSION = '0.8.52'
|
|
34
34
|
export const inject = ['tools', 'agents', 'webServer']
|
|
35
35
|
|
|
36
36
|
/** 仅供测试:读写状态文件(生产代码不要用)。 */
|
|
@@ -601,6 +601,8 @@ export function apply(ctx) {
|
|
|
601
601
|
const startWatcher = (entry) => {
|
|
602
602
|
if (timers.has(entry.id)) return
|
|
603
603
|
const every = Math.max(30, Number(entry.intervalSec) || 60) * 1000
|
|
604
|
+
// 首轮错峰:多条守同间隔时不要整点一起发车(之后按 every 稳定推进,不累积漂移)
|
|
605
|
+
const firstDelay = jitterMs(entry.id, Math.min(5000, every * 0.1))
|
|
604
606
|
|
|
605
607
|
const tick = async () => {
|
|
606
608
|
// A pause (or delete) can land between two ticks; never poll a watcher
|
|
@@ -627,7 +629,13 @@ export function apply(ctx) {
|
|
|
627
629
|
timers.set(entry.id, setInterval(tick, every).unref?.())
|
|
628
630
|
// DSH_SUPERAGENT_NO_POLL=1 只登记不轮询(路由层单测用,避免真去请求 GitHub)
|
|
629
631
|
if (process.env.DSH_SUPERAGENT_NO_POLL === '1') return
|
|
630
|
-
|
|
632
|
+
// 首轮按确定性抖动错峰(0~5 秒),之后按 every 稳定推进
|
|
633
|
+
if (firstDelay > 0) {
|
|
634
|
+
const boot = setTimeout(() => { tick() }, firstDelay)
|
|
635
|
+
boot.unref?.()
|
|
636
|
+
} else {
|
|
637
|
+
tick()
|
|
638
|
+
}
|
|
631
639
|
}
|
|
632
640
|
|
|
633
641
|
// Must run before the entry leaves the state file: a live tick would
|
package/lib/watch.js
CHANGED
|
@@ -445,3 +445,21 @@ export function parseGhInclude(stdout) {
|
|
|
445
445
|
}
|
|
446
446
|
return { status, etag, body }
|
|
447
447
|
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* 去同步抖动:给每个 watcher 一个**确定性的**起始偏移,避免 N 条守在同一条时间线上一起发车。
|
|
451
|
+
*
|
|
452
|
+
* 为什么不用随机数:随机数每次启动都不同,调试时对不上;用 id 的哈希则「同一条守永远同一个偏移」,
|
|
453
|
+
* 既错峰又可复现。范围固定在 [0, windowMs)。
|
|
454
|
+
*
|
|
455
|
+
* 依据:AWS Architecture Blog 的《Exponential Backoff And Jitter》——同步发车会让
|
|
456
|
+
* 下游在整点承压,加入抖动后峰值被摊平。(https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)
|
|
457
|
+
*/
|
|
458
|
+
export function jitterMs(key, windowMs) {
|
|
459
|
+
const width = Math.max(0, Math.floor(Number(windowMs) || 0))
|
|
460
|
+
if (width === 0) return 0
|
|
461
|
+
const text = String(key || '')
|
|
462
|
+
let hash = 0
|
|
463
|
+
for (let i = 0; i < text.length; i += 1) hash = (hash * 31 + text.charCodeAt(i)) % 1000003
|
|
464
|
+
return hash % width
|
|
465
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.52",
|
|
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",
|