dsh-session-superagent 0.8.33 → 0.8.35
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 +1 -1
- package/client.js +25 -5
- package/lib/index.js +2 -2
- 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.8.35] - 2026-11-02 —— 面板在跟哪一代,能查了
|
|
6
|
+
|
|
7
|
+
排查热重载问题时一直卡在一个观测盲点:面板每 5 秒轮询 `/state`,但**轮询不落任何痕迹**,
|
|
8
|
+
所以「客户端有没有跟着换到新前缀(`/rN`)」只能靠猜。
|
|
9
|
+
|
|
10
|
+
### 新增
|
|
11
|
+
- 客户端探测到前缀并**发生切换**时,写一条 `client-base` 探针(服务端 `CLIENT_NOTE_KEYS` 放行该键)。
|
|
12
|
+
- 于是 `watchers.json → client['note:client-base']` 能直接回答「这个浏览器现在跟的是哪一代」。
|
|
13
|
+
|
|
14
|
+
### 测试
|
|
15
|
+
- 合计 **94 例**(探针属于运行时行为,靠真机确认)。
|
|
16
|
+
|
|
17
|
+
## [0.8.34] - 2026-11-02 —— 前缀失效后自动重探,面板不会卡死
|
|
18
|
+
|
|
19
|
+
真机时间线:客户端 22:42 加载(当时活着的是 `/r2`),22:45 服务端换到 `/r3` 并**释放了 `/r2`** ——
|
|
20
|
+
于是面板手里的前缀失效,后续请求全部打空,除非手动刷新页面。
|
|
21
|
+
|
|
22
|
+
### 改法
|
|
23
|
+
`call()` 遇到「请求抛错」或「404」时,**重新探一次前缀再试一遍**(只重试一次,避免打转)。
|
|
24
|
+
|
|
25
|
+
这样每一代被接管后,面板自己就跟到新一代,不需要刷新页面。
|
|
26
|
+
|
|
27
|
+
### 测试
|
|
28
|
+
- 合计 **94 例**(该分支靠真机验证,单测的假 fetch 不会产生 404)。
|
|
29
|
+
|
|
5
30
|
## [0.8.33] - 2026-11-02 —— 客户端按版本挑「最新的那个服务端实例」
|
|
6
31
|
|
|
7
32
|
### 背景
|
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.8.
|
|
17
|
+
const CLIENT_VERSION = '0.8.35'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -42,17 +42,37 @@ window.__ModuleLoader__.load({
|
|
|
42
42
|
if (!best || score > best.score) best = { base, score }
|
|
43
43
|
} catch {}
|
|
44
44
|
}
|
|
45
|
-
if (best
|
|
45
|
+
if (best && best.base !== BASE) {
|
|
46
|
+
BASE = best.base
|
|
47
|
+
// 记一笔:排查「面板到底在跟哪一代」时用得上(不像轮询那样完全不落痕迹)
|
|
48
|
+
try { note('client-base', BASE) } catch {}
|
|
49
|
+
} else if (best) {
|
|
50
|
+
BASE = best.base
|
|
51
|
+
}
|
|
46
52
|
return BASE
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
const POLL_MS = 5000
|
|
50
56
|
|
|
51
|
-
async function call(path, options) {
|
|
52
|
-
const
|
|
57
|
+
async function call(path, options, retried) {
|
|
58
|
+
const init = {
|
|
53
59
|
...(options || {}),
|
|
54
60
|
headers: { 'content-type': 'application/json', accept: 'application/json', ...((options && options.headers) || {}) },
|
|
55
|
-
}
|
|
61
|
+
}
|
|
62
|
+
let res
|
|
63
|
+
try {
|
|
64
|
+
res = await fetch(BASE + path, init)
|
|
65
|
+
} catch (error) {
|
|
66
|
+
// 前缀失效(这一代被新实例接管并释放了):重新探一次再试,还不行就把错抛出去
|
|
67
|
+
if (retried) throw error
|
|
68
|
+
await discoverBase()
|
|
69
|
+
return call(path, options, true)
|
|
70
|
+
}
|
|
71
|
+
// 旧前缀被释放后宿主会 404:同样重探一次
|
|
72
|
+
if (res.status === 404 && !retried) {
|
|
73
|
+
await discoverBase()
|
|
74
|
+
return call(path, options, true)
|
|
75
|
+
}
|
|
56
76
|
const text = await res.text()
|
|
57
77
|
let body = null
|
|
58
78
|
try { body = text ? JSON.parse(text) : null } catch { body = { raw: text } }
|
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.35'
|
|
34
34
|
export const inject = ['tools', 'agents', 'webServer']
|
|
35
35
|
|
|
36
36
|
const STATE_DIR = process.env.DSH_SUPERAGENT_STATE
|
|
@@ -40,7 +40,7 @@ const SECRETS_FILE = join(STATE_DIR, 'secrets.json')
|
|
|
40
40
|
const STATE_FILE = join(STATE_DIR, 'watchers.json')
|
|
41
41
|
const TRIGGER_FILE = join(STATE_DIR, 'trigger.json')
|
|
42
42
|
// 客户端探针只认这几个键(别的键一律丢弃,防止被任意网页写盘)
|
|
43
|
-
const CLIENT_NOTE_KEYS = new Set(['client-version', 'apply', 'desk-registered', 'desk-fail', 'orbit-registered', 'orbit-fail', 'orbit-mount', 'badge-registered', 'badge-mount', 'badge-state', 'error'])
|
|
43
|
+
const CLIENT_NOTE_KEYS = new Set(['client-version', 'client-base', 'apply', 'desk-registered', 'desk-fail', 'orbit-registered', 'orbit-fail', 'orbit-mount', 'badge-registered', 'badge-mount', 'badge-state', 'error'])
|
|
44
44
|
const DEFAULT_COOLDOWN_MS = 180_000
|
|
45
45
|
|
|
46
46
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.35",
|
|
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",
|