dsh-session-superagent 0.9.259 → 0.9.260
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 +25 -0
- package/README.md +3 -3
- package/client.js +1 -1
- package/lib/index.js +54 -51
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
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.260] - 2026-11-05 —— T40 入口对等收尾:同一件事,不再两套行为
|
|
6
|
+
|
|
7
|
+
### 工具新建也会做「添加前体检」
|
|
8
|
+
|
|
9
|
+
`watch_start` 新建时与 HTTP 一样调用 `precheckRepo()`:仓库不存在、只读、归档等问题在创建时就警告,
|
|
10
|
+
并把 `repoAccess` 写进状态。只警告、不阻止创建;编辑已有守不重复打网络。
|
|
11
|
+
|
|
12
|
+
文本回执追加 `WARN <repo>:…`;JSON 在确有警告时增加 `warnings: string[]`,正常创建形状不变。
|
|
13
|
+
|
|
14
|
+
### 隔离目录默认值两条路一致
|
|
15
|
+
|
|
16
|
+
`isolated: true` 且未给 `workdir` 时,工具与 HTTP 都明确兜底 `process.cwd()`,
|
|
17
|
+
不再出现「面板创建不告警、工具创建被 doctor 警告」。
|
|
18
|
+
|
|
19
|
+
### 工具与面板追溯共用一套模板
|
|
20
|
+
|
|
21
|
+
`formatTraceText()` 统一缩进、标点、冷却吸收与「最近一次唤醒」省略规则;
|
|
22
|
+
独立验收还抓出无痕迹分支 HTTP 少一个前导空格,也已对齐。
|
|
23
|
+
|
|
24
|
+
### 证据
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm test → 423/423(新增 3 条独立验收:Gitee 假 fetch 真体检、隔离 cwd、正常/异常/无痕迹逐字一致)
|
|
28
|
+
```
|
|
29
|
+
|
|
5
30
|
## [0.9.259] - 2026-11-05 —— 工具不再只能「暂停」,优先级也不再只有面板能调
|
|
6
31
|
|
|
7
32
|
### ① `watch_stop` 可以真正删除,但默认行为不变
|
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
|
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
146
146
|
## 开发
|
|
147
147
|
|
|
148
148
|
```sh
|
|
149
|
-
npm test #
|
|
149
|
+
npm test # 423 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
### 工具输出:文本给人和 agent,JSON 给程序
|
|
@@ -206,7 +206,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
|
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
```bash
|
|
209
|
-
npm test #
|
|
209
|
+
npm test # 423 项单测(带离线开关,约 1.6 秒)
|
|
210
210
|
node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
|
|
211
211
|
node scripts/preflight.mjs # 41 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
|
|
212
212
|
node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
|
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.260'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
|
|
47
47
|
export const name = 'dsh-session-superagent'
|
|
48
48
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
49
|
-
export const SERVER_VERSION = '0.9.
|
|
49
|
+
export const SERVER_VERSION = '0.9.260'
|
|
50
50
|
export const inject = ['tools', 'agents', 'webServer']
|
|
51
51
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
52
52
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -63,6 +63,27 @@ const UNCHANGED_TEXT_GITEE = '未变化(Gitee 无 ETag:这一轮是真空读
|
|
|
63
63
|
// 追溯找不到任何痕迹时的那句话:两个入口(工具 / HTTP)必须一模一样
|
|
64
64
|
const noTraceText = (number, scope) => '#' + number + ' 在' + (scope || '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
|
|
65
65
|
|
|
66
|
+
/** 工具与面板共用同一份追溯文本,别再各写一套缩进、标点和省略规则。 */
|
|
67
|
+
const formatTraceText = (traces) => {
|
|
68
|
+
const lines = []
|
|
69
|
+
for (const trace of traces || []) {
|
|
70
|
+
lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
|
|
71
|
+
// 例外优先:一切正常时一行说完,只有「被过滤/被吸收/唤醒失败」才展开细节。
|
|
72
|
+
const quiet = trace.filtered.length === 0 && (trace.absorbed || []).length === 0
|
|
73
|
+
&& trace.wakes.length > 0 && trace.wakes.every((item) => item.ok)
|
|
74
|
+
if (!quiet) {
|
|
75
|
+
if (trace.seen) lines.push(' 水位 seen:' + trace.seen)
|
|
76
|
+
if (trace.reported) lines.push(' 上次上报:' + trace.reported)
|
|
77
|
+
for (const item of trace.filtered) lines.push(' 被过滤(' + (item.reason || '未知') + '):' + item.at)
|
|
78
|
+
for (const item of trace.absorbed || []) lines.push(' 被冷却期吸收:' + item.at)
|
|
79
|
+
for (const item of trace.wakes) lines.push(' 唤醒尝试:' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
|
|
80
|
+
} else if (trace.wakes.length > 0) {
|
|
81
|
+
lines.push(' 最近一次唤醒:' + trace.wakes[trace.wakes.length - 1].at + '(成功)')
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return lines.join(String.fromCharCode(10))
|
|
85
|
+
}
|
|
86
|
+
|
|
66
87
|
const DEFAULT_SESSION_WAKES = 12
|
|
67
88
|
/** 单次唤醒最多铺开几条(面板的占位符要显示这个真值,不能写死)。 */
|
|
68
89
|
const DEFAULT_BATCH_LIMIT = 5
|
|
@@ -2211,21 +2232,11 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2211
2232
|
const number = url.searchParams.get('number') || ''
|
|
2212
2233
|
const state = readState()
|
|
2213
2234
|
const list = Object.values(state.watchers || {}).filter((entry) => !repo || entry.repo === repo)
|
|
2214
|
-
const
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
if (!touched) continue
|
|
2220
|
-
lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
|
|
2221
|
-
if (trace.seen) lines.push('水位 ' + trace.seen)
|
|
2222
|
-
if (trace.reported) lines.push('上次上报 ' + trace.reported)
|
|
2223
|
-
for (const item of trace.filtered) lines.push('被过滤(' + (item.reason || '未知') + ')' + item.at)
|
|
2224
|
-
for (const item of trace.wakes) lines.push('唤醒尝试 ' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
|
|
2225
|
-
}
|
|
2226
|
-
const text = lines.length > 0
|
|
2227
|
-
? lines.join(String.fromCharCode(10))
|
|
2228
|
-
: noTraceText(number, repo || '所有守')
|
|
2235
|
+
const traces = list.map((entry) => itemTrace(entry, number)).filter((trace) => trace
|
|
2236
|
+
&& Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length))
|
|
2237
|
+
const text = traces.length > 0
|
|
2238
|
+
? formatTraceText(traces)
|
|
2239
|
+
: noTraceText(number, repo ? ' ' + repo : '所有守')
|
|
2229
2240
|
json(res, 200, { ok: true, text })
|
|
2230
2241
|
},
|
|
2231
2242
|
})
|
|
@@ -2511,41 +2522,15 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2511
2522
|
return toolError(args, why)
|
|
2512
2523
|
}
|
|
2513
2524
|
const number = rawNumber
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2516
|
-
const trace = itemTrace(entry, number)
|
|
2517
|
-
if (!trace) continue
|
|
2518
|
-
const touched = Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length)
|
|
2519
|
-
if (!touched) continue
|
|
2520
|
-
lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
|
|
2521
|
-
// 例外优先:一切正常时一行说完,只有「被过滤/被吸收/唤醒失败」才展开细节
|
|
2522
|
-
const quiet = trace.filtered.length === 0 && (trace.absorbed || []).length === 0
|
|
2523
|
-
&& trace.wakes.length > 0 && trace.wakes.every((item) => item.ok)
|
|
2524
|
-
if (!quiet) {
|
|
2525
|
-
if (trace.seen) lines.push(' 水位 seen:' + trace.seen)
|
|
2526
|
-
if (trace.reported) lines.push(' 上次上报:' + trace.reported)
|
|
2527
|
-
for (const item of trace.filtered) lines.push(' 被过滤(' + item.reason + '):' + item.at)
|
|
2528
|
-
for (const item of trace.absorbed || []) lines.push(' 被冷却期吸收:' + item.at)
|
|
2529
|
-
for (const item of trace.wakes) lines.push(' 唤醒尝试:' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
|
|
2530
|
-
} else if (trace.wakes.length > 0) {
|
|
2531
|
-
lines.push(' 最近一次唤醒:' + trace.wakes[trace.wakes.length - 1].at + '(成功)')
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2525
|
+
const traces = list.map((entry) => itemTrace(entry, number)).filter((trace) => trace
|
|
2526
|
+
&& Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length))
|
|
2534
2527
|
if (args && args.format === 'json') {
|
|
2535
|
-
|
|
2536
|
-
for (const entry of list) {
|
|
2537
|
-
const trace = itemTrace(entry, number)
|
|
2538
|
-
if (!trace) continue
|
|
2539
|
-
const touched = Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length)
|
|
2540
|
-
if (!touched) continue
|
|
2541
|
-
results.push(trace)
|
|
2542
|
-
}
|
|
2543
|
-
return JSON.stringify({ schemaVersion: 1, number: String(number), results }, null, 2)
|
|
2528
|
+
return JSON.stringify({ schemaVersion: 1, number: String(number), results: traces }, null, 2)
|
|
2544
2529
|
}
|
|
2545
|
-
if (
|
|
2530
|
+
if (traces.length === 0) {
|
|
2546
2531
|
return noTraceText(number, wanted ? ' ' + wanted : '所有守')
|
|
2547
2532
|
}
|
|
2548
|
-
return
|
|
2533
|
+
return formatTraceText(traces)
|
|
2549
2534
|
},
|
|
2550
2535
|
}))
|
|
2551
2536
|
|
|
@@ -2842,7 +2827,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2842
2827
|
}
|
|
2843
2828
|
if (parsedSpecs.length === 0) return toolError(args, '至少给一个仓库(owner/name)')
|
|
2844
2829
|
const repoList = parsedSpecs.map(({ item, spec }) => ({ repo: spec.repo, provider: spec.provider, label: item }))
|
|
2845
|
-
const applyOne = ({ repo, provider }) => {
|
|
2830
|
+
const applyOne = async ({ repo, provider }) => {
|
|
2846
2831
|
const id = (provider === 'gitee' ? 'gitee:' : '') + `${repo}#${sessionId}`
|
|
2847
2832
|
const state = readState()
|
|
2848
2833
|
const existing = state.watchers && state.watchers[id]
|
|
@@ -2873,6 +2858,9 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2873
2858
|
if (typeof args.goal === 'string') entry.goal = args.goal.slice(0, 500)
|
|
2874
2859
|
if (typeof args.observe === 'boolean') entry.observe = args.observe
|
|
2875
2860
|
if (typeof args.isolated === 'boolean') entry.isolated = args.isolated
|
|
2861
|
+
// 与 HTTP 创建路径同口径:隔离开着但没给目录,就明确兜底到宿主 cwd。
|
|
2862
|
+
// 否则面板创建不告警、工具创建却被 doctor 警告,同一个配置两种结果。
|
|
2863
|
+
if (entry.isolated && !entry.workdir) entry.workdir = process.cwd()
|
|
2876
2864
|
if (typeof args.workdir === 'string' && args.workdir.trim()) {
|
|
2877
2865
|
const workdir = args.workdir.trim()
|
|
2878
2866
|
if (!isAbsolute(workdir)) return toolError(args, 'workdir must be an absolute path')
|
|
@@ -2919,6 +2907,14 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2919
2907
|
return '一条会话最多同时挂 ' + MAX_WATCHERS_PER_SESSION + ' 条在跑的守(现在 ' + mine.length + ' 条)—— 先 watch_stop 停掉不用的,或把多个仓库合成一条规则'
|
|
2920
2908
|
}
|
|
2921
2909
|
}
|
|
2910
|
+
// 与 HTTP 创建路径同口径:**新建**才做添加前体检,编辑不重复打网络。
|
|
2911
|
+
// 只警告不阻止:仓库不存在/只读/归档要在创建时就说,而不是等下一次轮询。
|
|
2912
|
+
let warnings = []
|
|
2913
|
+
if (!existing) {
|
|
2914
|
+
const pre = await precheckRepo(repo, provider)
|
|
2915
|
+
warnings = pre.warnings || []
|
|
2916
|
+
if (pre.access) entry.repoAccess = pre.access
|
|
2917
|
+
}
|
|
2922
2918
|
state.watchers[id] = entry
|
|
2923
2919
|
// 显式 start 同 repo/session 表示要重建;只解除这个 id 的墓碑,不影响其他已删守。
|
|
2924
2920
|
writeState(state, { revive: [id] })
|
|
@@ -2936,7 +2932,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2936
2932
|
if (entry.batchLimit) flags.push('batch=' + entry.batchLimit)
|
|
2937
2933
|
if (entry.maxWakesPerHour) flags.push('perHour=' + entry.maxWakesPerHour)
|
|
2938
2934
|
if (entry.goal) flags.push('goal=' + JSON.stringify(entry.goal.slice(0, 40)))
|
|
2939
|
-
return { entry, existing, flags, id, repo }
|
|
2935
|
+
return { entry, existing, flags, id, repo, warnings }
|
|
2940
2936
|
|
|
2941
2937
|
}
|
|
2942
2938
|
// 批量要整批校验:19 条时一次加 2 条,不能只加进去第一条
|
|
@@ -2954,22 +2950,29 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2954
2950
|
}
|
|
2955
2951
|
const applied = []
|
|
2956
2952
|
for (const item of repoList) {
|
|
2957
|
-
const result = applyOne(item)
|
|
2953
|
+
const result = await applyOne(item)
|
|
2958
2954
|
// 单条校验失败(比如相对路径的 workdir)要原地返回,不能继续加后面的
|
|
2959
2955
|
if (typeof result === 'string') return result
|
|
2960
2956
|
applied.push(result)
|
|
2961
2957
|
}
|
|
2958
|
+
// 与 HTTP 创建回执同形状:warnings 是字符串数组;仓库归属在 repos[] 与文本行里表达。
|
|
2959
|
+
const warnings = applied.flatMap((item) => item.warnings || [])
|
|
2962
2960
|
if (args && args.format === 'json') {
|
|
2963
2961
|
const first = applied[0]
|
|
2964
2962
|
const base = JSON.parse(JSON.stringify({ schemaVersion: 1, ok: true, repo: first.repo, sessionId, id: first.id, intervalSec: first.entry.intervalSec,
|
|
2965
2963
|
flags: first.flags, filters: first.entry.filters || {}, updated: Boolean(first.existing), observe: first.entry.observe === true,
|
|
2966
2964
|
isolated: first.entry.isolated === true, activeHours: first.entry.activeHours || null }))
|
|
2967
|
-
base.repos = applied.map((item) => ({ repo: item.repo, id: item.id, updated: Boolean(item.existing) }))
|
|
2965
|
+
base.repos = applied.map((item) => ({ repo: item.repo, id: item.id, updated: Boolean(item.existing), ...(item.warnings.length ? { warnings: item.warnings } : {}) }))
|
|
2966
|
+
// 只在确有警告时增加字段,保持正常创建的 JSON 形状不变。
|
|
2967
|
+
if (warnings.length) base.warnings = warnings
|
|
2968
2968
|
return JSON.stringify(base, null, 2)
|
|
2969
2969
|
}
|
|
2970
2970
|
const lines = applied.map((item) => `watching ${item.repo} → session ${sessionId} every ${item.entry.intervalSec}s`
|
|
2971
2971
|
+ (item.flags.length ? ' [' + item.flags.join(' ') + ']' : '')
|
|
2972
2972
|
+ (item.existing ? ' (updated existing watcher)' : ''))
|
|
2973
|
+
for (const item of applied) {
|
|
2974
|
+
for (const warning of item.warnings || []) lines.push('WARN ' + item.repo + ':' + warning)
|
|
2975
|
+
}
|
|
2973
2976
|
return lines.join(String.fromCharCode(10))
|
|
2974
2977
|
},
|
|
2975
2978
|
}))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.260",
|
|
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",
|