dsh-session-superagent 0.9.86 → 0.9.88
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 +52 -0
- package/README.md +2 -2
- package/client.js +11 -9
- package/lib/index.js +11 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,58 @@
|
|
|
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.88] - 2026-11-02 —— 先量 /state 体积:100 条守 347 KB,加事件预算后 143 KB
|
|
6
|
+
|
|
7
|
+
### 先量(`scripts/measure-state.mjs`)
|
|
8
|
+
按 `/state` 的真实形状(比 `statusView` 多 `filteredLog`/`history`/`events`)建模:
|
|
9
|
+
|
|
10
|
+
| 守数量 | 修改前 | 修改后 |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| 1 | 3.7 KB | 2.1 KB |
|
|
13
|
+
| 5 | 17.5 KB | 9.6 KB |
|
|
14
|
+
| 20 | 69.6 KB | **37.8 KB** |
|
|
15
|
+
| 50 | 173.7 KB | 82.8 KB |
|
|
16
|
+
| 100 | **347.3 KB** | 143.0 KB |
|
|
17
|
+
|
|
18
|
+
**每守 3.5 KB → 1.4 KB**,`events`(每守 20 条)是主因。
|
|
19
|
+
|
|
20
|
+
### 改法
|
|
21
|
+
- `events` 每守上限 6 条,且**全局预算 240 条**:`perWatcher = max(1, min(6, 240/N))`;
|
|
22
|
+
守越多,每守分到的越少(100 条守时每人 2 条)。
|
|
23
|
+
|
|
24
|
+
### 判据怎么定的
|
|
25
|
+
判据按**现实上限**:面板是会话级的,一个会话挂 20 条守已经很极端 → 上限 **50 KB @ 20 条守**。
|
|
26
|
+
100 条守不是目标,所以不为了它把字段砍到没法用。**这条判据写进脚本注释里,不是拍脑袋。**
|
|
27
|
+
|
|
28
|
+
### 测试
|
|
29
|
+
- 新增 1 例:40 条守 × 20 事件 → 返回每守 ≤ 6 条、总数 ≤ 240。合计 **200 例**。
|
|
30
|
+
- 踩到的坑:用例第一版用共享的 `call()`,打到了**别的实例**的路由表(返回 7 条守)→ 改用本实例路由。
|
|
31
|
+
|
|
32
|
+
## [0.9.87] - 2026-11-02 —— 「需要关注」按严重程度排序(会丢消息的排最前)
|
|
33
|
+
|
|
34
|
+
### 为什么
|
|
35
|
+
原来按**发现顺序**往数组里塞:`仓库已归档` 这种静态提示可能压在一堆真问题上面。
|
|
36
|
+
排在最前的应该是最急的:**正在丢消息的**。
|
|
37
|
+
|
|
38
|
+
### 改法
|
|
39
|
+
给每类问题一个权重,排序时按 `rank` 升序、同权重按文本:
|
|
40
|
+
| rank | 类型 |
|
|
41
|
+
|---|---|
|
|
42
|
+
| 0 | gh 不可用(所有轮询都会失败) |
|
|
43
|
+
| 1 | 轮询失败 |
|
|
44
|
+
| 2 | 叫醒后没回音 |
|
|
45
|
+
| 3 | 仓库结构(归档/关 Issues/fork) |
|
|
46
|
+
| 4 | 只有读权限 |
|
|
47
|
+
| 5 | 条目被重新打开 |
|
|
48
|
+
| 6 | 暂停唤醒 |
|
|
49
|
+
| 7 | 未配置 token(提示性) |
|
|
50
|
+
|
|
51
|
+
顺带修掉一个**重复推送**:`structure` 那条被 push 了两次(列表里会出现两条一模一样)。
|
|
52
|
+
|
|
53
|
+
### 测试
|
|
54
|
+
- 新增 1 例:四类提示都要出现,且「轮询失败」排在「已归档」「只有读权限」之前。
|
|
55
|
+
- 验证方式:把排序语句替换成 `void 0` → 用例立刻变红;恢复后全绿。合计 **199 例**。
|
|
56
|
+
|
|
5
57
|
## [0.9.86] - 2026-11-02 —— watch_status 文本:正常的守不堆字段,异常的才说原因
|
|
6
58
|
|
|
7
59
|
### 为什么
|
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 # 200 项单测
|
|
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.88'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -1145,38 +1145,39 @@ window.__ModuleLoader__.load({
|
|
|
1145
1145
|
if (deferFilter && watcher.deferReason !== deferFilter) continue
|
|
1146
1146
|
// 仓库结构问题(关闭 Issues / 是 fork)比轮询失败更早该说:它注定收不到条目
|
|
1147
1147
|
const structure = repoStructureNote(watcher.repoAccess)
|
|
1148
|
-
if (structure) problems.push({ key: 's-' + watcher.repo, text: structure })
|
|
1148
|
+
if (structure) problems.push({ key: 's-' + watcher.repo, text: structure, rank: 3, kind: 'structure' })
|
|
1149
1149
|
// 只读:以前只在行内显示一个徽章,客户在「需要关注」里看不到,也不知道回写会 403
|
|
1150
1150
|
const readOnly = accessNoteForPanel(watcher.repoAccess, watcher.repo)
|
|
1151
|
-
if (readOnly) problems.push({ key: 'ro-' + watcher.repo, text: readOnly })
|
|
1151
|
+
if (readOnly) problems.push({ key: 'ro-' + watcher.repo, text: readOnly, rank: 4, kind: 'readonly' })
|
|
1152
1152
|
// 叫醒了但没回音:守在工作、消息也进去了,但会话没动手(规则缺失或被忽略)
|
|
1153
1153
|
if (Number(watcher.silentWakes) >= 2) {
|
|
1154
1154
|
problems.push({
|
|
1155
1155
|
key: 'silent-' + watcher.repo,
|
|
1156
|
+
rank: 2, kind: 'silent',
|
|
1156
1157
|
text: watcher.repo + ' 连续 ' + watcher.silentWakes + ' 次被叫醒后没有动作(没看到 watch_ack 标签)—— 会话可能没按规则处理',
|
|
1157
1158
|
action: { label: '看建议规则', onClick: () => setGlossary('rules:' + watcher.repo) },
|
|
1158
1159
|
})
|
|
1159
1160
|
}
|
|
1160
1161
|
// 被反复重开的条目:说明"之前判过不做"可能有问题,值得人看一眼
|
|
1161
1162
|
if (watcher.lastReopened) {
|
|
1162
|
-
problems.push({ key: 'r-' + watcher.repo, text: watcher.repo + ' #' + watcher.lastReopened + ' 被重新打开过 —— 之前判"不做"可能不对' })
|
|
1163
|
+
problems.push({ key: 'r-' + watcher.repo, text: watcher.repo + ' #' + watcher.lastReopened + ' 被重新打开过 —— 之前判"不做"可能不对', rank: 5, kind: 'reopened' })
|
|
1163
1164
|
}
|
|
1164
|
-
if (structure) problems.push({ key: 's-' + watcher.repo, text: structure })
|
|
1165
1165
|
if (watcher.lastError) {
|
|
1166
1166
|
// 同样拆开:现象截断、建议保留(这里原来是整串塞进「需要关注」)
|
|
1167
1167
|
const parts = splitErrorText(watcher.lastError)
|
|
1168
1168
|
problems.push({
|
|
1169
1169
|
key: 'e-' + watcher.repo,
|
|
1170
|
+
rank: 1, kind: 'error',
|
|
1170
1171
|
text: watcher.repo + ' 轮询失败:' + parts.main.slice(0, 120) + (parts.main.length > 120 ? '…' : '') + ' ' + parts.hint,
|
|
1171
1172
|
})
|
|
1172
1173
|
}
|
|
1173
|
-
else if (watcher.lastDeferred) problems.push({ key: 'd-' + watcher.repo, text: watcher.repo + ' 暂停唤醒:' + watcher.lastDeferred })
|
|
1174
|
+
else if (watcher.lastDeferred) problems.push({ key: 'd-' + watcher.repo, text: watcher.repo + ' 暂停唤醒:' + watcher.lastDeferred, rank: 6, kind: 'deferred' })
|
|
1174
1175
|
}
|
|
1175
1176
|
if (body.gh && body.gh.ok === false && credentials.token === 'none') {
|
|
1176
|
-
problems.push({ key: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 → 来源」填一个 token。' })
|
|
1177
|
+
problems.push({ key: 'gh', rank: 0, kind: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 → 来源」填一个 token。' })
|
|
1177
1178
|
}
|
|
1178
1179
|
if (watchers.length > 0 && credentials.token === 'none') {
|
|
1179
|
-
problems.push({ key: 'cred', text: '未配置 token,正在复用已登录的 gh CLI(可用 panel 填 token 换成独立凭据)' })
|
|
1180
|
+
problems.push({ key: 'cred', rank: 7, kind: 'cred', text: '未配置 token,正在复用已登录的 gh CLI(可用 panel 填 token 换成独立凭据)' })
|
|
1180
1181
|
}
|
|
1181
1182
|
|
|
1182
1183
|
const needle = search.trim().toLowerCase()
|
|
@@ -1203,7 +1204,8 @@ window.__ModuleLoader__.load({
|
|
|
1203
1204
|
'#' + entry.number + ' ' + (entry.title || '') + ' — ' + entry.reason)),
|
|
1204
1205
|
}))
|
|
1205
1206
|
: null,
|
|
1206
|
-
|
|
1207
|
+
// 排序:会丢消息的(失败/没回音)排前面;静态提示(仓库归档、只读)排后面
|
|
1208
|
+
(() => { problems.sort((a, b) => ((a.rank ?? 9) - (b.rank ?? 9)) || String(a.text).localeCompare(String(b.text))); return problems.length > 0 })()
|
|
1207
1209
|
? h(Section, { key: 'problems', title: '需要关注', count: problems.length },
|
|
1208
1210
|
h('ul', { className: 'dt-plain-list' }, problems.map((item) => h('li', { key: item.key, className: 'dt-danger' }, item.text))))
|
|
1209
1211
|
: null,
|
package/lib/index.js
CHANGED
|
@@ -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.88'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
const DEFAULT_SESSION_WAKES = 12
|
|
@@ -1161,7 +1161,11 @@ export function apply(ctx) {
|
|
|
1161
1161
|
* 不触发安装 —— 装/升级要改 profile,必须由人执行且升级后要重载宿主。
|
|
1162
1162
|
* 10 分钟内存缓存,避免面板每次刷新都打 registry。
|
|
1163
1163
|
*/
|
|
1164
|
-
|
|
1164
|
+
// /state 的体积预算:每守最多 6 条事件、全局最多 240 条(约 100 KB 内)
|
|
1165
|
+
const STATE_EVENTS_PER_WATCHER = 6
|
|
1166
|
+
const STATE_EVENTS_BUDGET = 240
|
|
1167
|
+
|
|
1168
|
+
const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
1165
1169
|
let updateCache = null
|
|
1166
1170
|
const checkUpdate = async (force) => {
|
|
1167
1171
|
if (!force && updateCache && Date.now() - updateCache.at < UPDATE_CACHE_MS) return updateCache.value
|
|
@@ -1236,7 +1240,10 @@ export function apply(ctx) {
|
|
|
1236
1240
|
// 顺带刷新一次 token scopes(缓存 5 分钟;失败不影响 /state)
|
|
1237
1241
|
tokenScopes().catch(() => {})
|
|
1238
1242
|
const gh = await ghHealth()
|
|
1239
|
-
const
|
|
1243
|
+
const allWatchers = Object.values(state.watchers || {})
|
|
1244
|
+
// 全局预算:守越多,每守分到的事件条数越少(100 条守时每人 2 条,总量 ≤ 240)
|
|
1245
|
+
const perWatcherEvents = Math.max(1, Math.min(STATE_EVENTS_PER_WATCHER, Math.floor(STATE_EVENTS_BUDGET / Math.max(1, allWatchers.length))))
|
|
1246
|
+
const watchers = allWatchers.map((w) => ({
|
|
1240
1247
|
id: w.id || (w.repo + '#' + w.sessionId),
|
|
1241
1248
|
repo: w.repo,
|
|
1242
1249
|
sessionId: w.sessionId,
|
|
@@ -1268,7 +1275,7 @@ export function apply(ctx) {
|
|
|
1268
1275
|
isolateKeepDays: w.isolateKeepDays ?? 3,
|
|
1269
1276
|
maxIsolated: w.maxIsolated ?? 5,
|
|
1270
1277
|
history: (w.history ?? []).slice(-5),
|
|
1271
|
-
events: (w.events ?? []).slice(-
|
|
1278
|
+
events: (w.events ?? []).slice(-perWatcherEvents),
|
|
1272
1279
|
deferReason: w.deferReason ?? null,
|
|
1273
1280
|
daily: dailySummary(w.dailyWakes),
|
|
1274
1281
|
busy: busierThanUsual(dailySummary(w.dailyWakes)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.88",
|
|
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",
|