dsh-session-superagent 0.9.40 → 0.9.42
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 +50 -0
- package/README.md +1 -1
- package/client.js +1 -1
- package/lib/index.js +24 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
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.42] - 2026-11-02 —— `watch_status` 带上诊断字段,agent 能自诊
|
|
6
|
+
|
|
7
|
+
### 学到的(知识库第 90 条)
|
|
8
|
+
可观测性对 agent 同样重要:机器能查的,别让人截屏。
|
|
9
|
+
|
|
10
|
+
### 缺口
|
|
11
|
+
| 信息 | 面板 | watch_status(改前) |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| 为什么暂停(`deferReason`) | ✅ | ❌ |
|
|
14
|
+
| 叫醒后没回音几次(`silentWakes`) | ✅ | ❌ |
|
|
15
|
+
| 会话用量 / 上限 / 建议值 | ✅ | ❌ |
|
|
16
|
+
|
|
17
|
+
### 改法
|
|
18
|
+
每条守多输出 `defer=<原因码>` `silent=N`,末尾加会话汇总行:
|
|
19
|
+
```
|
|
20
|
+
session: 12/12 wakes last hour,2 条守正因上限暂停,建议把会话上限调到 24
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 一个自己挖的坑
|
|
24
|
+
用模板字符串生成代码时 `'
|
|
25
|
+
'` 被写成真实换行,`node --check` 立刻报错。
|
|
26
|
+
**用脚本生成代码,生成后要马上 `node --check`。**
|
|
27
|
+
|
|
28
|
+
### 测试
|
|
29
|
+
- 新增 1 例(三个诊断字段 + 汇总行格式)。合计 **178 例**。
|
|
30
|
+
|
|
31
|
+
## [0.9.41] - 2026-11-02 —— `watch_start` 补齐面板已有的三项参数
|
|
32
|
+
|
|
33
|
+
### 学到的(知识库第 89 条)
|
|
34
|
+
工具能做的要和面板能做的对齐,否则用户会以为其中一个是残的。
|
|
35
|
+
|
|
36
|
+
### 具体缺口
|
|
37
|
+
| 配置 | 面板 | watch_start(改前) |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| 整条会话每小时上限 | ✅ | ❌ |
|
|
40
|
+
| 隔离区保留天数 | ✅ | ❌ |
|
|
41
|
+
| 最多留几个隔离区 | ✅ | ❌ |
|
|
42
|
+
|
|
43
|
+
客户说"把隔离区最多留 3 个",agent 只能答"你去面板点一下" —— 一句话能完成的事变成了手动操作。
|
|
44
|
+
|
|
45
|
+
### 改法
|
|
46
|
+
补三个参数,**夹紧范围与面板完全一致**(1-60 / 1-30 / 1-50),描述里写清默认值。
|
|
47
|
+
|
|
48
|
+
### 一个实现细节
|
|
49
|
+
工具参数在 `tool.parameters.properties`(JSON Schema),不是 `tool.parameters[key]` ——
|
|
50
|
+
第一条断言写错路径导致"缺参数"假警报。
|
|
51
|
+
|
|
52
|
+
### 测试
|
|
53
|
+
- 新增 1 例(参数存在 + 真的写入状态 24/7/3)。合计 **177 例**。
|
|
54
|
+
|
|
5
55
|
## [0.9.40] - 2026-11-02 —— 规则对照表:同一条规则不能只在一边
|
|
6
56
|
|
|
7
57
|
### 学到的(知识库第 88 条)
|
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
|
|
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.42'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
|
|
40
40
|
export const name = 'dsh-session-superagent'
|
|
41
41
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
42
|
-
export const SERVER_VERSION = '0.9.
|
|
42
|
+
export const SERVER_VERSION = '0.9.42'
|
|
43
43
|
export const inject = ['tools', 'agents', 'webServer']
|
|
44
44
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
45
45
|
const DEFAULT_SESSION_WAKES = 12
|
|
@@ -1911,7 +1911,10 @@ export function apply(ctx) {
|
|
|
1911
1911
|
workdir: { type: 'string', description: 'Repository used for isolation worktrees (absolute path).' },
|
|
1912
1912
|
activeHours: { type: 'string', description: 'Wake only inside this window, e.g. "09:00-23:00" (supports overnight).' },
|
|
1913
1913
|
batchLimit: { type: 'number', description: 'Max items listed per wake (1-20, default 5).' },
|
|
1914
|
-
maxWakesPerHour: { type: 'number', description: 'Max wakes per hour (1-60, default 6).' },
|
|
1914
|
+
maxWakesPerHour: { type: 'number', description: 'Max wakes per hour per watcher (1-60, default 6).' },
|
|
1915
|
+
sessionMaxWakes: { type: 'number', description: 'Max wakes per hour for the whole session, summed across watchers (1-60, default 12).' },
|
|
1916
|
+
isolateKeepDays: { type: 'number', description: 'With isolated: remove isolation worktrees older than this many days (1-30, default 3).' },
|
|
1917
|
+
maxIsolated: { type: 'number', description: 'With isolated: keep at most this many worktrees, oldest removed first (1-50, default 5).' },
|
|
1915
1918
|
goal: { type: 'string', description: 'Optional per-watcher goal appended to the wake message.' },
|
|
1916
1919
|
},
|
|
1917
1920
|
async execute(args) {
|
|
@@ -1961,6 +1964,10 @@ export function apply(ctx) {
|
|
|
1961
1964
|
if (typeof args.activeHours === 'string') entry.activeHours = args.activeHours.trim() || null
|
|
1962
1965
|
if (typeof args.batchLimit === 'number') entry.batchLimit = Math.max(1, Math.min(20, Math.round(args.batchLimit)))
|
|
1963
1966
|
if (typeof args.maxWakesPerHour === 'number') entry.maxWakesPerHour = Math.max(1, Math.min(60, Math.round(args.maxWakesPerHour)))
|
|
1967
|
+
// 面板能改的三项,工具也要能改 —— 否则被问"把隔离区最多留 3 个"时 agent 无从下手
|
|
1968
|
+
if (typeof args.sessionMaxWakes === 'number') entry.sessionMaxWakes = Math.max(1, Math.min(60, Math.round(args.sessionMaxWakes)))
|
|
1969
|
+
if (typeof args.isolateKeepDays === 'number') entry.isolateKeepDays = Math.max(1, Math.min(30, Math.round(args.isolateKeepDays)))
|
|
1970
|
+
if (typeof args.maxIsolated === 'number') entry.maxIsolated = Math.max(1, Math.min(50, Math.round(args.maxIsolated)))
|
|
1964
1971
|
entry.enabled = true
|
|
1965
1972
|
state.watchers = state.watchers || {}
|
|
1966
1973
|
state.watchers[id] = entry
|
|
@@ -1984,13 +1991,17 @@ export function apply(ctx) {
|
|
|
1984
1991
|
|
|
1985
1992
|
ctx.tools.register(defineTool({
|
|
1986
1993
|
name: 'watch_status',
|
|
1987
|
-
description: 'Report active watchers with last poll, last wake and
|
|
1994
|
+
description: 'Report active watchers with last poll, last wake, last error, why a watcher is paused, and how much of the session wake budget is used. Read-only.',
|
|
1988
1995
|
parameters: {},
|
|
1989
1996
|
async execute() {
|
|
1990
1997
|
const state = readState()
|
|
1991
1998
|
const list = Object.values(state.watchers || {})
|
|
1992
1999
|
if (!list.length) return '(no watchers)'
|
|
1993
|
-
|
|
2000
|
+
const sessionId = list[0] && list[0].sessionId
|
|
2001
|
+
const sessionUsed = sessionWakesLastHour(list, sessionId)
|
|
2002
|
+
const cap = Number(list[0] && list[0].sessionMaxWakes) || DEFAULT_SESSION_WAKES
|
|
2003
|
+
const capped = countCapped(list)
|
|
2004
|
+
const body = list
|
|
1994
2005
|
.map((w) => {
|
|
1995
2006
|
const flags = []
|
|
1996
2007
|
if (w.observe === true) flags.push('observe')
|
|
@@ -1999,6 +2010,9 @@ export function apply(ctx) {
|
|
|
1999
2010
|
if (w.activeHours) flags.push('hours=' + w.activeHours)
|
|
2000
2011
|
if (w.filters && w.filters.labels && w.filters.labels.length) flags.push('labels=' + w.filters.labels.join(','))
|
|
2001
2012
|
if (w.filters && w.filters.onlyAssigned) flags.push('onlyAssigned')
|
|
2013
|
+
// 面板上有的诊断字段,工具输出也要有 —— agent 自诊时未必能看到面板
|
|
2014
|
+
if (w.deferReason) flags.push('defer=' + w.deferReason)
|
|
2015
|
+
if (Number(w.silentWakes) > 0) flags.push('silent=' + w.silentWakes)
|
|
2002
2016
|
if (w.lastDeferred) flags.push('deferred=' + JSON.stringify(String(w.lastDeferred).slice(0, 40)))
|
|
2003
2017
|
return [
|
|
2004
2018
|
w.repo, '→', w.sessionId,
|
|
@@ -2010,7 +2024,12 @@ export function apply(ctx) {
|
|
|
2010
2024
|
'| err=' + (w.lastError || '-'),
|
|
2011
2025
|
].filter(Boolean).join(' ')
|
|
2012
2026
|
})
|
|
2013
|
-
.join(
|
|
2027
|
+
.join(String.fromCharCode(10))
|
|
2028
|
+
const suggestion = suggestSessionCap({ used: sessionUsed, cap, capped })
|
|
2029
|
+
const summary = 'session: ' + sessionUsed + '/' + cap + ' wakes last hour'
|
|
2030
|
+
+ (capped > 0 ? ',' + capped + ' 条守正因上限暂停' : '')
|
|
2031
|
+
+ (suggestion ? ',建议把会话上限调到 ' + suggestion : '')
|
|
2032
|
+
return body + String.fromCharCode(10) + summary
|
|
2014
2033
|
},
|
|
2015
2034
|
}))
|
|
2016
2035
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.42",
|
|
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",
|