dsh-session-superagent 0.9.207 → 0.9.208
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 +40 -0
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/gh-format.js +19 -0
- package/lib/index.js +8 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
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.208] - 2026-11-05 —— 覆盖审计顺手挖出一个真 bug:`deferReason` 被拼成 `quota09:30Z`
|
|
6
|
+
|
|
7
|
+
### ① 真 bug:额度文案拼接错位
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
entry.deferReason = 'quota'
|
|
11
|
+
+ new Date(Date.now() + throttle).toISOString().slice(11, 16) + 'Z' // → 'quota09:30Z'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`deferReason` 是**机器可读的稳定原因**(面板按它查 `DEFER_LABELS`、打标签、筛选),掺进时间就永远查不到,
|
|
15
|
+
**面板「按暂停原因筛选」永远是空列表**。
|
|
16
|
+
|
|
17
|
+
改法不是就地改字符串,而是把文案抽成**纯函数** `quotaDeferText()` 并加单测钉住:
|
|
18
|
+
`reason` 必须**恰好**是已知的稳定值、不许含 `:`;时间只能出现在人读的那句话里。
|
|
19
|
+
T20 是把 bug 跑出来的(`actual: 'quota00:01Z'`),现在这条用例进套件了。
|
|
20
|
+
|
|
21
|
+
### ② 清掉一处空三元
|
|
22
|
+
|
|
23
|
+
`bumpFailure(entry, diag && diag.kind === 'auth' ? baseMs : baseMs)` —— 两个分支同一个值。
|
|
24
|
+
写它的人本来想区分什么,但没写出来;删掉,行为不变。
|
|
25
|
+
|
|
26
|
+
### ③ 补两条覆盖(T20 报的「必须补」里最便宜的两条)
|
|
27
|
+
|
|
28
|
+
- **凭证写入校验**:`sshKeyPath` / `ghConfigDir` 必须绝对路径 —— 以前只有**一个 grep 源码**的测试在守
|
|
29
|
+
(源码里有那句字符串就绿),现在真打 HTTP 看 400。
|
|
30
|
+
- **凭证清空仍然合法**(三个字段都传空串)。
|
|
31
|
+
|
|
32
|
+
### ④ 覆盖审计本身的方法论(记录)
|
|
33
|
+
|
|
34
|
+
官方 `--experimental-test-coverage` 对 `lib/index.js` **不可信**:5 个测试文件、33 处用
|
|
35
|
+
`import('../lib/index.js?xxx=…')` 重复加载同一模块,报告器只保留其中一个实例 ——
|
|
36
|
+
同一条命令连跑两次给 24.14% 和 11.03%,只跑单个文件反而报 28.03%(统计上不可能)。
|
|
37
|
+
真实值是 **59.17% 行 / 67.9% 函数**(V8 原始区间合并)。洞集中在「必须真起进程 / 真等定时器 / 真写盘」那一层。
|
|
38
|
+
|
|
39
|
+
### 证据
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
node --test → 360/360(新增:额度文案回归、凭证校验两条)
|
|
43
|
+
```
|
|
44
|
+
|
|
5
45
|
## [0.9.207] - 2026-11-05 —— 路由安全审计剩下的「值得改」:无上限、无形状、无节流
|
|
6
46
|
|
|
7
47
|
### ① 守数量没有任何上限(HTTP 路径)
|
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
|
|
|
@@ -144,7 +144,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
144
144
|
## 开发
|
|
145
145
|
|
|
146
146
|
```sh
|
|
147
|
-
node --test #
|
|
147
|
+
node --test # 360 项单测
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### 工具输出:文本给人和 agent,JSON 给程序
|
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.208'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/gh-format.js
CHANGED
|
@@ -577,3 +577,22 @@ export function linkedPrNote(linked) {
|
|
|
577
577
|
return '已有 PR #' + first.number + (stateText || draftText || blocked ? '(' + stateText + draftText + blocked + ')' : '')
|
|
578
578
|
+ (list.length > 1 ? ' 等 ' + list.length + ' 个' : '')
|
|
579
579
|
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* 额度推迟的文案(审核 T20 的回归点)。
|
|
583
|
+
*
|
|
584
|
+
* 以前这段是内联拼的,拼错过一次:
|
|
585
|
+
* `deferReason = 'quota' + new Date(...).toISOString().slice(11, 16) + 'Z'` → `quota09:30Z`
|
|
586
|
+
* `deferReason` 是**机器可读的稳定原因**(面板按它筛选、打标签),掺进时间就永远查不到。
|
|
587
|
+
* 抽成纯函数 + 单测钉住:reason 必须**恰好**是下面这些之一,时间只能出现在人读的那句话里。
|
|
588
|
+
*/
|
|
589
|
+
export const DEFER_REASONS = ['ratelimit', 'quota', 'truncated', 'busy', 'window', 'observe', 'backoff']
|
|
590
|
+
|
|
591
|
+
export function quotaDeferText(remaining, resumeInMs, now = Date.now()) {
|
|
592
|
+
const at = new Date(now + Math.max(0, Number(resumeInMs) || 0))
|
|
593
|
+
const hhmm = at.toISOString().slice(11, 16)
|
|
594
|
+
return {
|
|
595
|
+
reason: 'quota',
|
|
596
|
+
text: '额度紧张(剩余 ' + String(remaining) + '),已推迟到 ' + hhmm + ' UTC',
|
|
597
|
+
}
|
|
598
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { zstdDecompressSync } from 'node:zlib'
|
|
|
23
23
|
|
|
24
24
|
import { redact } from './redact.js'
|
|
25
25
|
import { decodeBody, truncateUtf8 } from './body.js'
|
|
26
|
+
import { quotaDeferText } from './gh-format.js'
|
|
26
27
|
import { listGiteeItems, fetchGiteeLastComment, addGiteeLabel, ensureGiteeLabel, giteeWhoami, giteeRepo, mapGiteeRepoAccess, DEFAULT_ACK_LABEL_GITEE, giteeLabels, giteeHasLabel, isValidGiteeLabel, suggestGiteeLabel } from './gitee.js'
|
|
27
28
|
import {
|
|
28
29
|
advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
@@ -42,7 +43,7 @@ import {
|
|
|
42
43
|
|
|
43
44
|
export const name = 'dsh-session-superagent'
|
|
44
45
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
45
|
-
export const SERVER_VERSION = '0.9.
|
|
46
|
+
export const SERVER_VERSION = '0.9.208'
|
|
46
47
|
export const inject = ['tools', 'agents', 'webServer']
|
|
47
48
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
48
49
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -1181,9 +1182,11 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
1181
1182
|
const throttle = throttleDelayMs({ remaining: parsed.remaining, resetAt: parsed.resetAt })
|
|
1182
1183
|
if (throttle > 0) {
|
|
1183
1184
|
entry.nextAt = new Date(Date.now() + throttle).toISOString()
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1185
|
+
// 审核 T20:以前 deferReason 被拼成 'quota09:30Z' —— 面板按 reason 筛选永远空。
|
|
1186
|
+
// 文案抽成纯函数(quotaDeferText)并有单测钉住:reason 只有稳定原因,时间只在人读的那句里。
|
|
1187
|
+
const quotaText = quotaDeferText(parsed.remaining, throttle)
|
|
1188
|
+
entry.lastDeferred = quotaText.text
|
|
1189
|
+
entry.deferReason = quotaText.reason
|
|
1187
1190
|
entry.lastError = null
|
|
1188
1191
|
entry.needsReauth = false
|
|
1189
1192
|
return
|
|
@@ -1238,7 +1241,7 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
|
|
|
1238
1241
|
// 兜底不再默认「可能是代理干扰」:那会把客户往网络上游带。
|
|
1239
1242
|
// 现在只有确诊是网关页才说代理;其余情况指向 watch_doctor 与本仓库 issue。
|
|
1240
1243
|
setEntryError(entry, (diag ? diag.hint : '(返回内容不是合法 JSON:先跑 watch_doctor;确认不是凭证问题就带上这段提 issue)') + ' —— 已按退避自动重试')
|
|
1241
|
-
bumpFailure(entry,
|
|
1244
|
+
bumpFailure(entry, baseMs)
|
|
1242
1245
|
if (diag && diag.kind === 'auth') {
|
|
1243
1246
|
const wait = permanentBackoffMs('auth', baseMs)
|
|
1244
1247
|
if (wait > 0) entry.nextAt = new Date(Date.now() + wait).toISOString()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.208",
|
|
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",
|