dsh-session-superagent 0.9.91 → 0.9.93
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 +39 -0
- package/README.md +2 -2
- package/client.js +4 -1
- package/lib/index.js +21 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
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.93] - 2026-11-02 —— 同一仓库被多个会话守着时,面板说说清"还有谁"
|
|
6
|
+
|
|
7
|
+
### 为什么
|
|
8
|
+
两个会话守同一个仓库时,面板上每条守看起来都像"独占"的 ——
|
|
9
|
+
客户不知道**还有人在看同一个仓库**,也不知道两者会不会互相抢唤醒。
|
|
10
|
+
|
|
11
|
+
### 改法
|
|
12
|
+
- `/state` 每条守增加 `otherSessions: string[]`(同仓库、不同会话的 id);
|
|
13
|
+
- 面板行内显示:`还有 1 个会话也在守这个仓库:session-2(各自独立唤醒,互不影响)`;
|
|
14
|
+
- 独占时不显示这一行。
|
|
15
|
+
|
|
16
|
+
### 过程中三次修正
|
|
17
|
+
1. 先把字段加进了 `statusView` 的清单 → **稳定性用例立刻红**:那个契约是"工具输出"的,
|
|
18
|
+
而这个字段只在 `/state` 里 —— 清单撤回,契约边界才是对的;
|
|
19
|
+
2. 面板先加在「判定」页,但用例发现那一页在没有事件时不渲染 ticket → 改到总览行;
|
|
20
|
+
3. 我插的「另有 N 个会话在守」和已有的完整句子**重复** → 删掉我插的那行,只留一处实现。
|
|
21
|
+
|
|
22
|
+
### 测试
|
|
23
|
+
- 新增 2 例:面板显示(含独占时不显示)、`/state` 双向可见(我方看到对方、对方看到我方)。合计 **206 例**。
|
|
24
|
+
|
|
25
|
+
## [0.9.92] - 2026-11-02 —— 一条会话最多 20 条守(批量请求整批校验)
|
|
26
|
+
|
|
27
|
+
### 为什么
|
|
28
|
+
之前没有上限:客户可以给一条会话挂 200 条守 —— 每条每 60 秒轮询,
|
|
29
|
+
`/state` 再压缩也挡不住真实的请求量与上下文压力。
|
|
30
|
+
|
|
31
|
+
### 改法
|
|
32
|
+
- `MAX_WATCHERS_PER_SESSION = 20`;
|
|
33
|
+
- 第 21 条被拒绝:`一条会话最多挂 20 条守(现在 20 条)—— 先 watch_stop 停掉不用的,或把多个仓库合成一条规则`;
|
|
34
|
+
- **批量请求整批校验**:19 条时一次加 2 条 → 整批拒绝并说明"这次要新增 2 条",不会只写进去第一条;
|
|
35
|
+
- 更新已有守不受上限影响。
|
|
36
|
+
|
|
37
|
+
### 过程中两次自我修正
|
|
38
|
+
1. 第一版只在"单条写入前"检查 → 批量时会出现**部分写入**;补了整批预校验;
|
|
39
|
+
2. 补丁把 `const applied = []` 和 `for` 挤到一行 → `SyntaxError`,`node --check` 当场拦下。
|
|
40
|
+
|
|
41
|
+
### 测试
|
|
42
|
+
- 新增 1 例:20 条为止、第 21 条被拦、19+2 整批拒绝且不写入、更新已有守不受影响。合计 **204 例**。
|
|
43
|
+
|
|
5
44
|
## [0.9.91] - 2026-11-02 —— 「最近 5 次唤醒」其实早就有,只是名字看不出来
|
|
6
45
|
|
|
7
46
|
### 先确认(结果和预期相反)
|
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
|
|
|
@@ -121,7 +121,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
121
121
|
## 开发
|
|
122
122
|
|
|
123
123
|
```sh
|
|
124
|
-
node --test #
|
|
124
|
+
node --test # 206 项单测
|
|
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.
|
|
17
|
+
const CLIENT_VERSION = '0.9.93'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -1082,6 +1082,9 @@ window.__ModuleLoader__.load({
|
|
|
1082
1082
|
watcher.note ? '目标: ' + String(watcher.note).slice(0, 40) : '',
|
|
1083
1083
|
].filter(Boolean).join(' · ')),
|
|
1084
1084
|
watcher.lastDeferred ? h('div', { className: 'dt-ticket-note' }, watcher.lastDeferred) : null,
|
|
1085
|
+
(watcher.otherSessions && watcher.otherSessions.length > 0)
|
|
1086
|
+
? h('div', { className: 'dt-ticket-note' }, '还有 ' + watcher.otherSessions.length + ' 个会话也在守这个仓库:' + watcher.otherSessions.join('、') + '(各自独立唤醒,互不影响)')
|
|
1087
|
+
: null,
|
|
1085
1088
|
watcher.lastError ? (() => {
|
|
1086
1089
|
const parts = splitErrorText(watcher.lastError)
|
|
1087
1090
|
return h('div', { className: 'dt-ticket-note dt-ticket-note-error' },
|
package/lib/index.js
CHANGED
|
@@ -40,10 +40,12 @@ 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.93'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
const DEFAULT_SESSION_WAKES = 12
|
|
47
|
+
// 一条会话最多挂多少守:再多轮询压力与上下文都会失控(20 条 × 每 60 秒已很密)
|
|
48
|
+
const MAX_WATCHERS_PER_SESSION = 20
|
|
47
49
|
/** 隔离区回收的最小间隔:没有超额时不必每次唤醒都跑 git。 */
|
|
48
50
|
const CLEANUP_INTERVAL_MS = 10 * 60 * 1000
|
|
49
51
|
|
|
@@ -1284,6 +1286,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1284
1286
|
maxIsolated: w.maxIsolated ?? 5,
|
|
1285
1287
|
history: (w.history ?? []).slice(-5),
|
|
1286
1288
|
events: (w.events ?? []).slice(-perWatcherEvents),
|
|
1289
|
+
// 同一个仓库被别的会话也守着:客户该知道「还有谁在看」
|
|
1290
|
+
otherSessions: allWatchers.filter((peer) => peer && peer.repo === w.repo && peer.sessionId !== w.sessionId).map((peer) => peer.sessionId),
|
|
1287
1291
|
deferReason: w.deferReason ?? null,
|
|
1288
1292
|
daily: dailySummary(w.dailyWakes),
|
|
1289
1293
|
busy: busierThanUsual(dailySummary(w.dailyWakes)),
|
|
@@ -2075,6 +2079,12 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2075
2079
|
if (typeof args.maxIsolated === 'number') entry.maxIsolated = Math.max(1, Math.min(50, Math.round(args.maxIsolated)))
|
|
2076
2080
|
entry.enabled = true
|
|
2077
2081
|
state.watchers = state.watchers || {}
|
|
2082
|
+
if (!existing) {
|
|
2083
|
+
const mine = Object.values(state.watchers).filter((w) => w && w.sessionId === sessionId)
|
|
2084
|
+
if (mine.length >= MAX_WATCHERS_PER_SESSION) {
|
|
2085
|
+
return '一条会话最多挂 ' + MAX_WATCHERS_PER_SESSION + ' 条守(现在 ' + mine.length + ' 条)—— 先 watch_stop 停掉不用的,或把多个仓库合成一条规则'
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2078
2088
|
state.watchers[id] = entry
|
|
2079
2089
|
writeState(state)
|
|
2080
2090
|
stopWatcher(id)
|
|
@@ -2090,6 +2100,16 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2090
2100
|
if (entry.goal) flags.push('goal=' + JSON.stringify(entry.goal.slice(0, 40)))
|
|
2091
2101
|
return { entry, existing, flags, id, repo }
|
|
2092
2102
|
|
|
2103
|
+
}
|
|
2104
|
+
// 批量要整批校验:19 条时一次加 2 条,不能只加进去第一条
|
|
2105
|
+
{
|
|
2106
|
+
const snapshot = readState()
|
|
2107
|
+
const mine = Object.values(snapshot.watchers || {}).filter((w) => w && w.sessionId === sessionId)
|
|
2108
|
+
const incoming = repoList.filter((name) => !(snapshot.watchers || {})[name + '#' + sessionId])
|
|
2109
|
+
const room = MAX_WATCHERS_PER_SESSION - mine.length
|
|
2110
|
+
if (incoming.length > room) {
|
|
2111
|
+
return '一条会话最多挂 ' + MAX_WATCHERS_PER_SESSION + ' 条守(现在 ' + mine.length + ' 条,这次要新增 ' + incoming.length + ' 条)—— 先 watch_stop 停掉不用的,或把多个仓库合成一条规则'
|
|
2112
|
+
}
|
|
2093
2113
|
}
|
|
2094
2114
|
const applied = []
|
|
2095
2115
|
for (const name of repoList) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.93",
|
|
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",
|