dsh-session-superagent 0.9.87 → 0.9.89
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 +47 -0
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/index.js +37 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
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.89] - 2026-11-02 —— watch_start 一次加多个仓库(客户三仓库不用点三次)
|
|
6
|
+
|
|
7
|
+
### 为什么
|
|
8
|
+
`watch_start` 一次只收一个 `repo`,三个仓库要点三次、三个工具调用 —— 而它们的
|
|
9
|
+
间隔/过滤/限流通常完全一样。
|
|
10
|
+
|
|
11
|
+
### 改法
|
|
12
|
+
`repo` 支持 `a/b, c/d e/f`(逗号、空格、换行都认):
|
|
13
|
+
- 文本:每个仓库一行 `watching a/b → session s1 every 60s`;
|
|
14
|
+
- JSON:保留原字段(兼容),新增 `repos: [{repo,id,updated}]`;
|
|
15
|
+
- **有一个写错就整体拒绝**(`仓库要写成 owner/name,这些不对:…`),不会只加一半。
|
|
16
|
+
|
|
17
|
+
### 过程中踩到的坑
|
|
18
|
+
第一版把 `applyOne()` 包在原逻辑外面,但**原逻辑里还留着旧的 `format=json` 提前 return** ——
|
|
19
|
+
于是多仓库时只返回第一个仓库的 JSON。删掉那段之后才对。
|
|
20
|
+
|
|
21
|
+
### 测试
|
|
22
|
+
- 新增 1 例:三个仓库三行、守数=3;JSON 带 `repos`;一个写错时整体拒绝且不写入。
|
|
23
|
+
- `contract-stability.json` 登记 `repos: stable`(用例先红一次)。合计 **201 例**。
|
|
24
|
+
|
|
25
|
+
## [0.9.88] - 2026-11-02 —— 先量 /state 体积:100 条守 347 KB,加事件预算后 143 KB
|
|
26
|
+
|
|
27
|
+
### 先量(`scripts/measure-state.mjs`)
|
|
28
|
+
按 `/state` 的真实形状(比 `statusView` 多 `filteredLog`/`history`/`events`)建模:
|
|
29
|
+
|
|
30
|
+
| 守数量 | 修改前 | 修改后 |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| 1 | 3.7 KB | 2.1 KB |
|
|
33
|
+
| 5 | 17.5 KB | 9.6 KB |
|
|
34
|
+
| 20 | 69.6 KB | **37.8 KB** |
|
|
35
|
+
| 50 | 173.7 KB | 82.8 KB |
|
|
36
|
+
| 100 | **347.3 KB** | 143.0 KB |
|
|
37
|
+
|
|
38
|
+
**每守 3.5 KB → 1.4 KB**,`events`(每守 20 条)是主因。
|
|
39
|
+
|
|
40
|
+
### 改法
|
|
41
|
+
- `events` 每守上限 6 条,且**全局预算 240 条**:`perWatcher = max(1, min(6, 240/N))`;
|
|
42
|
+
守越多,每守分到的越少(100 条守时每人 2 条)。
|
|
43
|
+
|
|
44
|
+
### 判据怎么定的
|
|
45
|
+
判据按**现实上限**:面板是会话级的,一个会话挂 20 条守已经很极端 → 上限 **50 KB @ 20 条守**。
|
|
46
|
+
100 条守不是目标,所以不为了它把字段砍到没法用。**这条判据写进脚本注释里,不是拍脑袋。**
|
|
47
|
+
|
|
48
|
+
### 测试
|
|
49
|
+
- 新增 1 例:40 条守 × 20 事件 → 返回每守 ≤ 6 条、总数 ≤ 240。合计 **200 例**。
|
|
50
|
+
- 踩到的坑:用例第一版用共享的 `call()`,打到了**别的实例**的路由表(返回 7 条守)→ 改用本实例路由。
|
|
51
|
+
|
|
5
52
|
## [0.9.87] - 2026-11-02 —— 「需要关注」按严重程度排序(会丢消息的排最前)
|
|
6
53
|
|
|
7
54
|
### 为什么
|
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 # 201 项单测
|
|
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.89'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
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.89'
|
|
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)),
|
|
@@ -2013,6 +2020,12 @@ export function apply(ctx) {
|
|
|
2013
2020
|
try { repo = JSON.parse(res.stdout).nameWithOwner } catch { return `[error: cannot infer repo]\n${redact(res.stderr)}` }
|
|
2014
2021
|
}
|
|
2015
2022
|
|
|
2023
|
+
// 一次可以加多个仓库:客户三个仓库不用点三次(逗号/空格/换行都认)
|
|
2024
|
+
const repoList = String(repo).split(/[,\s]+/).map((item) => item.trim()).filter(Boolean)
|
|
2025
|
+
const bad = repoList.filter((item) => !/^[^/\s]+\/[^/\s]+$/.test(item))
|
|
2026
|
+
if (bad.length > 0) return '[error: 仓库要写成 owner/name,这些不对:' + bad.join(', ') + ']'
|
|
2027
|
+
if (repoList.length === 0) return '[error: 至少给一个仓库(owner/name)]'
|
|
2028
|
+
const applyOne = (repo) => {
|
|
2016
2029
|
const id = `${repo}#${sessionId}`
|
|
2017
2030
|
const state = readState()
|
|
2018
2031
|
const existing = state.watchers && state.watchers[id]
|
|
@@ -2067,14 +2080,28 @@ export function apply(ctx) {
|
|
|
2067
2080
|
if (entry.batchLimit) flags.push('batch=' + entry.batchLimit)
|
|
2068
2081
|
if (entry.maxWakesPerHour) flags.push('perHour=' + entry.maxWakesPerHour)
|
|
2069
2082
|
if (entry.goal) flags.push('goal=' + JSON.stringify(entry.goal.slice(0, 40)))
|
|
2083
|
+
return { entry, existing, flags, id, repo }
|
|
2084
|
+
|
|
2085
|
+
}
|
|
2086
|
+
const applied = []
|
|
2087
|
+
for (const name of repoList) {
|
|
2088
|
+
const result = applyOne(name)
|
|
2089
|
+
// 单条校验失败(比如相对路径的 workdir)要原地返回,不能继续加后面的
|
|
2090
|
+
if (typeof result === 'string') return result
|
|
2091
|
+
applied.push(result)
|
|
2092
|
+
}
|
|
2070
2093
|
if (args && args.format === 'json') {
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2094
|
+
const first = applied[0]
|
|
2095
|
+
const base = JSON.parse(JSON.stringify({ schemaVersion: 1, ok: true, repo: first.repo, sessionId, id: first.id, intervalSec: first.entry.intervalSec,
|
|
2096
|
+
flags: first.flags, filters: first.entry.filters || {}, updated: Boolean(first.existing), observe: first.entry.observe === true,
|
|
2097
|
+
isolated: first.entry.isolated === true, activeHours: first.entry.activeHours || null }))
|
|
2098
|
+
base.repos = applied.map((item) => ({ repo: item.repo, id: item.id, updated: Boolean(item.existing) }))
|
|
2099
|
+
return JSON.stringify(base, null, 2)
|
|
2074
2100
|
}
|
|
2075
|
-
|
|
2076
|
-
(flags.length ? ' [' + flags.join(' ') + ']' : '')
|
|
2077
|
-
(existing ? ' (updated existing watcher)' : '')
|
|
2101
|
+
const lines = applied.map((item) => `watching ${item.repo} → session ${sessionId} every ${item.entry.intervalSec}s`
|
|
2102
|
+
+ (item.flags.length ? ' [' + item.flags.join(' ') + ']' : '')
|
|
2103
|
+
+ (item.existing ? ' (updated existing watcher)' : ''))
|
|
2104
|
+
return lines.join(String.fromCharCode(10))
|
|
2078
2105
|
},
|
|
2079
2106
|
}))
|
|
2080
2107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.89",
|
|
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",
|