dsh-session-superagent 0.8.37 → 0.8.39
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 +46 -4
- package/MAINTENANCE.md +1 -1
- package/README.md +31 -2
- package/client.js +47 -1
- package/lib/index.js +44 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +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.8.
|
|
5
|
+
## [0.8.39] - 2026-11-02 —— 有新版本时,面板顶上直接告诉你
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
0.8.38 把版本检查放进了「设置」页 —— 但客户不会主动翻设置页,等于没做。
|
|
8
|
+
这一版把结果提到**面板顶部**:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
[ 有新版本 0.9.0(当前 0.8.38) [看升级命令] ]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
点「看升级命令」跳到设置页,命令可以直接复制。没有新版本时不显示,不打扰。
|
|
15
|
+
|
|
16
|
+
### 测试
|
|
17
|
+
- 新增用例:有新版时必须出现横幅且写明版本号;无新版时不得出现。合计 **99 例**。
|
|
18
|
+
|
|
19
|
+
## [0.8.38] - 2026-11-02 —— 面板里就能看到「有没有新版本」
|
|
20
|
+
|
|
21
|
+
### 为什么
|
|
22
|
+
客户在自己电脑上用发布版。我这边修完、发到 npm,**客户不升级就一直跑旧版** ——
|
|
23
|
+
而他并不会主动去 `npm view`。所以「有没有新版本、该跑什么命令」应该长在面板里。
|
|
24
|
+
|
|
25
|
+
### 做法(只读,不替你安装)
|
|
26
|
+
新增 `GET /session-superagent/update`:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{ "current": "0.8.38", "latest": "0.8.38", "hasUpdate": false,
|
|
30
|
+
"command": "dsh plugin --profile <你的 profile> add dsh-session-superagent@0.8.38" }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- 问 `registry.npmjs.org/<pkg>/latest`,5 秒超时,**内存缓存 10 分钟**(`?refresh=1` 强制刷新);
|
|
34
|
+
- 面板「设置 → 版本与更新」显示:当前版本 / npm 最新 / 状态,有新版本时给出命令 + 复制按钮;
|
|
35
|
+
- **不自动安装**:装要改 profile,而且装完必须重载宿主才生效 —— 这一步交给客户自己决定,面板里写明了。
|
|
36
|
+
|
|
37
|
+
### 顺带
|
|
38
|
+
- 路由面 6 → 7 条,测试与 preflight 里的断言同步更新;
|
|
39
|
+
- 客户端 hook 顺序变了(多两个 state),测试里的 `deskQueue` 同步补槽位。
|
|
40
|
+
|
|
41
|
+
### 测试
|
|
42
|
+
- 合计 **98 例**。
|
|
43
|
+
|
|
44
|
+
## [0.8.37] - 2026-11-02 —— 状态文件不再丢 watcher
|
|
45
|
+
|
|
46
|
+
### 真机现象(本机复现)
|
|
47
|
+
用 HTTP 建的一条 watcher,几秒后从状态文件里消失,只剩另一条 —— 同一天出现两次。
|
|
48
|
+
|
|
49
|
+
> 更正:早先我把一张**客户**截图(`Betsy20/magpie-Jet-Hub`)也算作案例,这是错的。
|
|
50
|
+
> 那是别人 PC 上跑我们插件的实例,本机的状态文件里当然没有它的条目;
|
|
51
|
+
> 这条修复的依据只是本机那次复现。
|
|
10
52
|
|
|
11
53
|
### 根因
|
|
12
54
|
`writeState()` 是**整份覆盖**。当两个写入者手里的快照不同(宿主热重载时新旧实例交替、
|
package/MAINTENANCE.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## 二、当前状态(2026-11-01)
|
|
11
11
|
|
|
12
|
-
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test`
|
|
12
|
+
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 99/99 通过
|
|
13
13
|
- [x] 自回声抑制(逐条水位)
|
|
14
14
|
- [x] 仅空闲注入(避免草稿回放)
|
|
15
15
|
- [x] 唤醒失败不推进水位
|
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
|
|
|
@@ -99,11 +99,40 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
99
99
|
## 开发
|
|
100
100
|
|
|
101
101
|
```sh
|
|
102
|
-
node --test #
|
|
102
|
+
node --test # 99 项单测
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
版本与发布流程见 [UPDATING.md](UPDATING.md),交付门见 [CHECKLIST.md](CHECKLIST.md),接手台账见 [MAINTENANCE.md](MAINTENANCE.md)。
|
|
106
106
|
|
|
107
|
+
## 客户(Customer)
|
|
108
|
+
|
|
109
|
+
> **本文档里的「客户」= 在**其它电脑**上使用本插件的使用者**(不是本机的会话,也不是本仓库的贡献者)。
|
|
110
|
+
|
|
111
|
+
客户和本机的差别,决定了排查要看哪里:
|
|
112
|
+
|
|
113
|
+
| | 本机(开发者) | 客户 |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| 插件来源 | `file:` 硬链接到本仓库 | npm / 市场安装的发布版 |
|
|
116
|
+
| 状态文件 | `<DSH_HOME>/state/session-superagent/watchers.json` | 同路径,但在客户自己的 `~/.dsh/` 下 |
|
|
117
|
+
| 我能不能直接查 | 能 | **不能** —— 只能让客户贴信息 |
|
|
118
|
+
|
|
119
|
+
所以客户报问题时要这三样,缺一件就只能猜:
|
|
120
|
+
|
|
121
|
+
1. **版本**:面板「设置」页,或状态文件里 `client['note:client-version'].detail`;
|
|
122
|
+
2. **挂载状态**:状态文件里的 `server` 字段(`routes` / `failed` / `base`),或让客户跑一次 `watch_doctor`;
|
|
123
|
+
3. **出错那行的原文**:0.8.36 起 gh 失败会被分类成人话(网络抖动 / 凭证失效 / 限流 / 仓库不存在 / 没装 gh)。
|
|
124
|
+
|
|
125
|
+
**客户升级**:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
dsh plugin --profile <profile> add dsh-session-superagent@latest
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
(客户机器上 `npm i` 不会生效 —— 必须装进 profile,见上面的「安装」。)
|
|
132
|
+
|
|
133
|
+
**本机复现不了客户的问题**:`EOF` / 超时 / 代理这类错误取决于客户的网络,本机能访问同一个仓库不代表客户能。
|
|
134
|
+
遇到这种情况,先按上面的三样收集信息,再判断是环境还是代码。
|
|
135
|
+
|
|
107
136
|
## 故障排查(都是真实踩过的)
|
|
108
137
|
|
|
109
138
|
| 症状 | 原因 | 处理 |
|
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.8.
|
|
17
|
+
const CLIENT_VERSION = '0.8.39'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -693,6 +693,9 @@ window.__ModuleLoader__.load({
|
|
|
693
693
|
const [draft, setDraft] = useState({})
|
|
694
694
|
const [search, setSearch] = useState('')
|
|
695
695
|
const [glossary, setGlossary] = useState(false)
|
|
696
|
+
// 版本检查结果(只读):面板里直接告诉客户「有没有新版本、该跑什么命令」
|
|
697
|
+
const [update, setUpdate] = useState(null)
|
|
698
|
+
const [checking, setChecking] = useState(false)
|
|
696
699
|
|
|
697
700
|
const load = useCallback(async () => {
|
|
698
701
|
try {
|
|
@@ -975,6 +978,21 @@ window.__ModuleLoader__.load({
|
|
|
975
978
|
field('Token', h(Input, { type: 'password', value: token, placeholder: 'ghp_… / github_pat_…(留空不改)', onChange: (e) => setToken(e.target.value) })),
|
|
976
979
|
h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveCredentials }, '保存凭证')),
|
|
977
980
|
h(Hint, null, '不填也能用:插件直接复用已登录的 gh CLI。')),
|
|
981
|
+
h(Section, { key: 'update', title: '版本与更新' },
|
|
982
|
+
h(KeyValues, { rows: [
|
|
983
|
+
['当前版本', (update && update.current) || CLIENT_VERSION],
|
|
984
|
+
['npm 最新', !update ? '检测中…' : update.error ? '检测失败 · ' + update.error : (update.latest || '未知')],
|
|
985
|
+
['状态', !update ? '…' : update.hasUpdate ? '有新版本,可以升级' : '已是最新'],
|
|
986
|
+
] }),
|
|
987
|
+
update && update.hasUpdate
|
|
988
|
+
? h('div', null,
|
|
989
|
+
h('code', { className: 'dt-code' }, update.command),
|
|
990
|
+
h('div', { className: 'dt-actions' },
|
|
991
|
+
h(Btn, { size: 'sm', onClick: () => { try { navigator.clipboard.writeText(update.command) } catch {} } }, '复制命令')))
|
|
992
|
+
: null,
|
|
993
|
+
h('div', { className: 'dt-actions' },
|
|
994
|
+
h(Btn, { size: 'sm', variant: 'ghost', onClick: () => checkUpdate(true), disabled: checking }, checking ? '检查中…' : '重新检查')),
|
|
995
|
+
h(Hint, null, '升级要改 profile,装完需要重载一次宿主才会用上新版本 —— 所以这里只给命令,不替你执行。')),
|
|
978
996
|
h(Section, { key: 'goal', title: '会话 goal' },
|
|
979
997
|
h('textarea', {
|
|
980
998
|
className: 'dt-textarea', rows: 3, value: goalDraft,
|
|
@@ -984,6 +1002,28 @@ window.__ModuleLoader__.load({
|
|
|
984
1002
|
h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveGoal, disabled: !sessionId }, '保存 goal'))),
|
|
985
1003
|
]
|
|
986
1004
|
|
|
1005
|
+
const checkUpdate = useCallback(async (force) => {
|
|
1006
|
+
setChecking(true)
|
|
1007
|
+
try {
|
|
1008
|
+
const value = await call('/update' + (force ? '?refresh=1' : ''))
|
|
1009
|
+
setUpdate(value)
|
|
1010
|
+
} catch (error) {
|
|
1011
|
+
setUpdate({ current: CLIENT_VERSION, latest: null, hasUpdate: false, error: String(error && error.message || error) })
|
|
1012
|
+
} finally {
|
|
1013
|
+
setChecking(false)
|
|
1014
|
+
}
|
|
1015
|
+
}, [])
|
|
1016
|
+
|
|
1017
|
+
useEffect(() => {
|
|
1018
|
+
let alive = true
|
|
1019
|
+
try {
|
|
1020
|
+
Promise.resolve(call('/update'))
|
|
1021
|
+
.then((value) => { if (alive) setUpdate(value) })
|
|
1022
|
+
.catch(() => {})
|
|
1023
|
+
} catch { /* 宿主早期渲染时 fetch 可能还不存在,忽略即可 */ }
|
|
1024
|
+
return () => { alive = false }
|
|
1025
|
+
}, [])
|
|
1026
|
+
|
|
987
1027
|
function field(label, control) {
|
|
988
1028
|
return h('label', { className: 'dt-field', key: label }, h('span', { className: 'dt-field-head' }, label), control)
|
|
989
1029
|
}
|
|
@@ -1011,6 +1051,12 @@ window.__ModuleLoader__.load({
|
|
|
1011
1051
|
value: tab, onChange: setTab, label: '主理鱼分区',
|
|
1012
1052
|
}),
|
|
1013
1053
|
notice ? h('div', { className: 'dt-banner dt-danger' }, notice.text) : null,
|
|
1054
|
+
// 有新版本时在顶部提示一次(埋在设置页里客户不会主动翻)
|
|
1055
|
+
update && update.hasUpdate
|
|
1056
|
+
? h('div', { className: 'dt-banner dt-banner-actions' },
|
|
1057
|
+
h('span', { className: 'dt-banner-label' }, '有新版本 ' + update.latest + '(当前 ' + update.current + ')'),
|
|
1058
|
+
h('a', { className: 'dt-btn dt-btn-sm dt-btn-outline', href: '#', onClick: (e) => { e.preventDefault(); setTab('settings') } }, '看升级命令'))
|
|
1059
|
+
: null,
|
|
1014
1060
|
toastView,
|
|
1015
1061
|
snap.error ? h('div', { className: 'dt-banner dt-danger' }, '读取失败:' + snap.error) : null,
|
|
1016
1062
|
snap.loading && !snap.body ? h(Hint, null, '正在读取…') : null,
|
package/lib/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
|
|
31
31
|
export const name = 'dsh-session-superagent'
|
|
32
32
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
33
|
-
export const SERVER_VERSION = '0.8.
|
|
33
|
+
export const SERVER_VERSION = '0.8.39'
|
|
34
34
|
export const inject = ['tools', 'agents', 'webServer']
|
|
35
35
|
|
|
36
36
|
/** 仅供测试:读写状态文件(生产代码不要用)。 */
|
|
@@ -627,6 +627,37 @@ export function apply(ctx) {
|
|
|
627
627
|
return true
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
/**
|
|
631
|
+
* 版本检查(只读):问 npm registry 最新版是多少,和本实例版本比。
|
|
632
|
+
* 不触发安装 —— 装/升级要改 profile,必须由人执行且升级后要重载宿主。
|
|
633
|
+
* 10 分钟内存缓存,避免面板每次刷新都打 registry。
|
|
634
|
+
*/
|
|
635
|
+
const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
636
|
+
let updateCache = null
|
|
637
|
+
const checkUpdate = async (force) => {
|
|
638
|
+
if (!force && updateCache && Date.now() - updateCache.at < UPDATE_CACHE_MS) return updateCache.value
|
|
639
|
+
const current = SERVER_VERSION
|
|
640
|
+
const value = { current, latest: null, publishedAt: null, hasUpdate: false, command: '', error: null }
|
|
641
|
+
try {
|
|
642
|
+
const res = await fetch('https://registry.npmjs.org/' + encodeURIComponent('dsh-session-superagent') + '/latest', {
|
|
643
|
+
signal: AbortSignal.timeout(5000),
|
|
644
|
+
headers: { accept: 'application/json' },
|
|
645
|
+
})
|
|
646
|
+
if (!res.ok) throw new Error('HTTP ' + res.status)
|
|
647
|
+
const body = await res.json()
|
|
648
|
+
value.latest = String(body.version || '')
|
|
649
|
+
const published = typeof body.dist?.tarball === 'string' ? body.dist.tarball : ''
|
|
650
|
+
if (published) value.publishedAt = published
|
|
651
|
+
const score = (v) => String(v || '0').split('.').map((n) => Number(n) || 0).reduce((acc, n) => acc * 1000 + n, 0)
|
|
652
|
+
value.hasUpdate = score(value.latest) > score(current)
|
|
653
|
+
value.command = 'dsh plugin --profile <你的 profile> add dsh-session-superagent@' + (value.latest || 'latest')
|
|
654
|
+
} catch (error) {
|
|
655
|
+
value.error = String((error && error.message) || error).slice(0, 160)
|
|
656
|
+
}
|
|
657
|
+
updateCache = { at: Date.now(), value }
|
|
658
|
+
return value
|
|
659
|
+
}
|
|
660
|
+
|
|
630
661
|
// Read-only status endpoints for the web panel. `httpServer` is looked up
|
|
631
662
|
// through ctx.inject: the service may load after this plugin, and ctx.get()
|
|
632
663
|
// does not wait for it.
|
|
@@ -875,6 +906,18 @@ export function apply(ctx) {
|
|
|
875
906
|
},
|
|
876
907
|
})
|
|
877
908
|
|
|
909
|
+
// 版本检查(只读;面板「设置」页那一行「有新版本」靠它)
|
|
910
|
+
addRoute({
|
|
911
|
+
kind: 'exact',
|
|
912
|
+
path: '/session-superagent/update',
|
|
913
|
+
handler: async (req, res) => {
|
|
914
|
+
if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
|
|
915
|
+
const url = new URL(String(req.url || '/'), 'http://127.0.0.1')
|
|
916
|
+
const value = await checkUpdate(url.searchParams.get('refresh') === '1')
|
|
917
|
+
json(res, 200, value)
|
|
918
|
+
},
|
|
919
|
+
})
|
|
920
|
+
|
|
878
921
|
// Set / edit / clear the session's REAL goal through ctx.goals — the same
|
|
879
922
|
// service the /goal command drives, so the panel and the conversation are
|
|
880
923
|
// one source of truth (polling reads it back).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
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",
|