dsh-session-superagent 0.9.45 → 0.9.46
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 +20 -0
- package/README.md +3 -2
- package/client.js +1 -1
- package/lib/index.js +25 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.46] - 2026-11-02 —— 写工具也给 JSON:成功与否不再靠读中文
|
|
6
|
+
|
|
7
|
+
### 学到的(延续知识库第 91 条)
|
|
8
|
+
只读工具有了 `format=json`,但**写工具**仍返回自然语言:
|
|
9
|
+
`acked o/r #12 with label …` / `stopped o/r#s` —— agent 判断成功与否只能读中文,改一次措辞就误判。
|
|
10
|
+
|
|
11
|
+
### 改法
|
|
12
|
+
`watch_start` / `watch_stop` / `watch_ack` 补上 `format: 'json'`:
|
|
13
|
+
| 场景 | JSON |
|
|
14
|
+
|---|---|
|
|
15
|
+
| start 成功 | `{ schemaVersion, ok: true, repo, id, intervalSec, flags, updated }` |
|
|
16
|
+
| stop 成功 | `{ schemaVersion, ok: true, id }` |
|
|
17
|
+
| ack 成功 | `{ schemaVersion, ok: true, repo, label, acked, at }` |
|
|
18
|
+
| 失败 | `{ schemaVersion, ok: false, error }` |
|
|
19
|
+
|
|
20
|
+
文本形态**保持不变**(老调用方不受影响),顺序是"先判断 json,再拼文本"。
|
|
21
|
+
|
|
22
|
+
### 测试
|
|
23
|
+
- 新增 1 例(start 新建/更新、stop 成功/不存在、默认仍返回文本)。合计 **182 例**。
|
|
24
|
+
|
|
5
25
|
## [0.9.45] - 2026-11-02 —— README 写着 136 项单测,实际 181(现在会自动报错)
|
|
6
26
|
|
|
7
27
|
### 学到的(知识库第 92 条)
|
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 # 182 项单测
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
### 工具输出:文本给人和 agent,JSON 给程序
|
|
@@ -133,6 +133,7 @@ node --test # 181 项单测
|
|
|
133
133
|
| `watch_status` | 每条守一行 + 会话用量行 | `{ schemaVersion, session, watchers[] }` |
|
|
134
134
|
| `watch_doctor` | `OK/WARN/FAIL` 检查清单 | `{ schemaVersion, checks[{status,text}] }` |
|
|
135
135
|
| `watch_trace` | 单条条目的追溯文字 | `{ schemaVersion, number, results[] }`(错误时 `{ schemaVersion, error }`) |
|
|
136
|
+
| `watch_start` / `watch_stop` / `watch_ack` | 一句话结果 | `{ schemaVersion, ok, … }` —— 成功/失败都靠 `ok` 判断,不用读中文 |
|
|
136
137
|
|
|
137
138
|
`schemaVersion` 现在是 `1`;**字段语义一变就会加这个数**,程序可以据此决定要不要重新解析。
|
|
138
139
|
|
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.46'
|
|
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.46'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
const DEFAULT_SESSION_WAKES = 12
|
|
@@ -1702,6 +1702,7 @@ export function apply(ctx) {
|
|
|
1702
1702
|
number: { type: 'number', description: 'issue or PR number' },
|
|
1703
1703
|
numbers: { type: 'string', description: '逗号分隔的多个编号,如 "12,13,14"(与 number 二选一)' },
|
|
1704
1704
|
label: { type: 'string', description: 'ack label, default 主理鱼:已处理' },
|
|
1705
|
+
format: { type: 'string', description: "'text' (default) or 'json'." },
|
|
1705
1706
|
},
|
|
1706
1707
|
async execute(args) {
|
|
1707
1708
|
const numbers = String(args.numbers || args.number || '')
|
|
@@ -1728,7 +1729,11 @@ export function apply(ctx) {
|
|
|
1728
1729
|
}
|
|
1729
1730
|
results.push(number)
|
|
1730
1731
|
}
|
|
1731
|
-
if (failed)
|
|
1732
|
+
if (failed) {
|
|
1733
|
+
return (args && args.format === 'json')
|
|
1734
|
+
? JSON.stringify({ schemaVersion: 1, ok: false, repo: entry.repo, acked: results, failed: { number: failed.number, text: failed.text } })
|
|
1735
|
+
: `[error: #${failed.number} gh exited ${failed.code}] ${failed.text}`
|
|
1736
|
+
}
|
|
1732
1737
|
const latest = readState()
|
|
1733
1738
|
const live = latest.watchers && latest.watchers[entry.id]
|
|
1734
1739
|
const nowIso = new Date().toISOString()
|
|
@@ -1739,6 +1744,9 @@ export function apply(ctx) {
|
|
|
1739
1744
|
live.lastAcked = { numbers: results, label, at: nowIso }
|
|
1740
1745
|
writeState(latest)
|
|
1741
1746
|
}
|
|
1747
|
+
if (args && args.format === 'json') {
|
|
1748
|
+
return JSON.stringify({ schemaVersion: 1, ok: true, repo: entry.repo, label, acked: results, at: nowIso })
|
|
1749
|
+
}
|
|
1742
1750
|
return `acked ${entry.repo} #${results.join(' #')} with label "${label}"`
|
|
1743
1751
|
},
|
|
1744
1752
|
}))
|
|
@@ -1943,6 +1951,7 @@ export function apply(ctx) {
|
|
|
1943
1951
|
isolated: { type: 'boolean', description: 'Run each wake in a throwaway git worktree.' },
|
|
1944
1952
|
workdir: { type: 'string', description: 'Repository used for isolation worktrees (absolute path).' },
|
|
1945
1953
|
activeHours: { type: 'string', description: 'Wake only inside this window, e.g. "09:00-23:00" (supports overnight).' },
|
|
1954
|
+
format: { type: 'string', description: "'text' (default) or 'json'." },
|
|
1946
1955
|
batchLimit: { type: 'number', description: 'Max items listed per wake (1-20, default 5).' },
|
|
1947
1956
|
maxWakesPerHour: { type: 'number', description: 'Max wakes per hour per watcher (1-60, default 6).' },
|
|
1948
1957
|
sessionMaxWakes: { type: 'number', description: 'Max wakes per hour for the whole session, summed across watchers (1-60, default 12).' },
|
|
@@ -2016,6 +2025,11 @@ export function apply(ctx) {
|
|
|
2016
2025
|
if (entry.batchLimit) flags.push('batch=' + entry.batchLimit)
|
|
2017
2026
|
if (entry.maxWakesPerHour) flags.push('perHour=' + entry.maxWakesPerHour)
|
|
2018
2027
|
if (entry.goal) flags.push('goal=' + JSON.stringify(entry.goal.slice(0, 40)))
|
|
2028
|
+
if (args && args.format === 'json') {
|
|
2029
|
+
return JSON.stringify({ schemaVersion: 1, ok: true, repo, sessionId, id, intervalSec: entry.intervalSec,
|
|
2030
|
+
flags, filters: entry.filters || {}, updated: Boolean(existing), observe: entry.observe === true,
|
|
2031
|
+
isolated: entry.isolated === true, activeHours: entry.activeHours || null }, null, 2)
|
|
2032
|
+
}
|
|
2019
2033
|
return `watching ${repo} → session ${sessionId} every ${entry.intervalSec}s` +
|
|
2020
2034
|
(flags.length ? ' [' + flags.join(' ') + ']' : '') +
|
|
2021
2035
|
(existing ? ' (updated existing watcher)' : '')
|
|
@@ -2064,18 +2078,25 @@ export function apply(ctx) {
|
|
|
2064
2078
|
ctx.tools.register(defineTool({
|
|
2065
2079
|
name: 'watch_stop',
|
|
2066
2080
|
description: 'Stop watching a repository for the current session.',
|
|
2067
|
-
parameters: {
|
|
2081
|
+
parameters: {
|
|
2082
|
+
repo: { type: 'string', required: true, description: 'owner/name' },
|
|
2083
|
+
format: { type: 'string', description: "'text' (default) or 'json'." },
|
|
2084
|
+
},
|
|
2068
2085
|
async execute(args) {
|
|
2069
2086
|
const toolAgents = agentsService(ctx)
|
|
2070
2087
|
const agent = toolAgents && typeof toolAgents.currentInitiator === 'function' ? toolAgents.currentInitiator() : undefined
|
|
2071
2088
|
const sessionId = agent && agent.id
|
|
2072
2089
|
const id = `${args.repo}#${sessionId}`
|
|
2073
2090
|
const state = readState()
|
|
2074
|
-
if (!state.watchers || !state.watchers[id])
|
|
2091
|
+
if (!state.watchers || !state.watchers[id]) {
|
|
2092
|
+
const message = 'no watcher for ' + id
|
|
2093
|
+
return (args && args.format === 'json') ? JSON.stringify({ schemaVersion: 1, ok: false, id, error: message }) : '(' + message + ')'
|
|
2094
|
+
}
|
|
2075
2095
|
state.watchers[id].enabled = false
|
|
2076
2096
|
writeState(state)
|
|
2077
2097
|
const timer = timers.get(id)
|
|
2078
2098
|
if (timer) { clearInterval(timer); timers.delete(id) }
|
|
2099
|
+
if (args && args.format === 'json') return JSON.stringify({ schemaVersion: 1, ok: true, id, repo: args.repo })
|
|
2079
2100
|
return `stopped ${id}`
|
|
2080
2101
|
},
|
|
2081
2102
|
}))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.46",
|
|
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",
|