dsh-session-superagent 0.9.125 → 0.9.126

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 CHANGED
@@ -2,6 +2,32 @@
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.126] - 2026-11-03 —— 断路器下沉到 `run()`:一处生效,所有调用点都覆盖
6
+
7
+ ### 为什么
8
+ 0.9.125 只给 `github` / `repo_here` 两个工具加了短路。但**真正会发请求的地方有七八处**
9
+ (轮询、`watch_ack` 打标签、仓库体检、评论查询…),漏掉任何一处,"明知凭证坏了还去调"就还在。
10
+
11
+ 上一轮刚立下的规矩(`policy-numbers-have-one-home.md`)同样适用:**政策只该有一处**。
12
+
13
+ ### 改法
14
+ 把断路器移进 `run()` —— 所有 `gh` 调用的唯一出口:
15
+
16
+ ```js
17
+ if (file === 'gh' && !argv.includes('--version') && argv[1] !== 'auth') {
18
+ if (isAuthBroken(authStatusCache.text) && fresh) {
19
+ resolve({ code: 1, stdout: '', stderr: '凭证已失效,本次没有发起请求:跑 gh auth login 重新登录后再试' })
20
+ }
21
+ }
22
+ ```
23
+
24
+ - `gh auth status` 与 `--version` **豁免**(否则无法自检、也永远解不开);
25
+ - 顺序放在**离线模式之前**,让"凭证坏了"的语义在测试里也一致;
26
+ - 工具层那两处重复短路随之删除,死常量 `AUTH_BROKEN_REPLY` 一并清掉。
27
+
28
+ ### 测试
29
+ 新增 1 例:凭证失效时 `watch_ack`(要打标签的内部调用)也走短路。合计 **236 例**。
30
+
5
31
  ## [0.9.125] - 2026-11-03 —— 凭证坏了就别再发请求:断路器式短路
6
32
 
7
33
  ### 学到什么(出处)
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: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.125-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.126-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](https://github.com/topics/dsh-plugin)
9
9
 
@@ -123,7 +123,7 @@ dsh plugin install /path/to/dsh-session-superagent
123
123
  ## 开发
124
124
 
125
125
  ```sh
126
- node --test # 235 项单测
126
+ node --test # 236 项单测
127
127
  ```
128
128
 
129
129
  ### 工具输出:文本给人和 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.125'
17
+ const CLIENT_VERSION = '0.9.126'
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.125'
43
+ export const SERVER_VERSION = '0.9.126'
44
44
  export const inject = ['tools', 'agents', 'webServer']
45
45
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
46
46
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -51,8 +51,6 @@ function setEntryError(entry, text) {
51
51
  entry.lastError = text
52
52
  entry.lastErrorAt = new Date().toISOString()
53
53
  }
54
- // 凭证失效时两个工具必须给一模一样的话:写两遍迟早会漂
55
- const AUTH_BROKEN_REPLY = '[error: 凭证已失效,本次没有发起请求] 跑 gh auth login 重新登录后再试'
56
54
  const UNCHANGED_TEXT = '未变化(304,不计入速率限制)'
57
55
  // 追溯找不到任何痕迹时的那句话:两个入口(工具 / HTTP)必须一模一样
58
56
  const noTraceText = (number, scope) => '#' + number + ' 在' + (scope || '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
@@ -504,6 +502,14 @@ function offlineGhReply(args) {
504
502
  function run(file, args, options = {}) {
505
503
  const { input, cwd, env, timeoutMs = 60000 } = options
506
504
  return new Promise((resolve) => {
505
+ // 统一断路器:已知凭证失效时,除了`gh auth status`/`--version`,一律不发起调用。
506
+ // 放在 run() 里而不是各个调用点:政策只该有一处(见 KB policy-numbers-have-one-home.md)。
507
+ if (file === 'gh' && !(args || []).includes('--version') && !((args || [])[1] === 'auth')) {
508
+ if (isAuthBroken(authStatusCache.text) && Date.now() - authStatusCache.at < 10 * 60 * 1000) {
509
+ resolve({ code: 1, stdout: '', stderr: '凭证已失效,本次没有发起请求:跑 gh auth login 重新登录后再试' })
510
+ return
511
+ }
512
+ }
507
513
  if (file === 'gh' && process.env.DSH_SUPERAGENT_OFFLINE === '1') {
508
514
  resolve({ code: 0, stdout: offlineGhReply(args), stderr: '' })
509
515
  return
@@ -2140,10 +2146,6 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2140
2146
  if (write && args.confirm !== true) {
2141
2147
  return `[error: ${method} requires confirm: true — this plugin never writes to GitHub without an explicit flag]`
2142
2148
  }
2143
- // 已知凭证失效时不再 spawn:Fowler 的断路器就是「不发起这次受保护的调用」
2144
- if (isAuthBroken(authStatusCache.text) && Date.now() - authStatusCache.at < 10 * 60 * 1000) {
2145
- return AUTH_BROKEN_REPLY
2146
- }
2147
2149
  const res = await run('gh', ['api', '-X', method, args.path, '--header', 'Accept: application/vnd.github+json'], {
2148
2150
  input: write && args.body ? args.body : undefined, env: ghEnv(),
2149
2151
  })
@@ -2158,10 +2160,6 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2158
2160
  description: 'Report the GitHub repository of the current working directory (owner/name, default branch, visibility). Read-only.',
2159
2161
  parameters: {},
2160
2162
  async execute() {
2161
- // 已知凭证失效时不再 spawn:Fowler 的断路器就是「不发起这次受保护的调用」
2162
- if (isAuthBroken(authStatusCache.text) && Date.now() - authStatusCache.at < 10 * 60 * 1000) {
2163
- return AUTH_BROKEN_REPLY
2164
- }
2165
2163
  const res = await run('gh', ['repo', 'view', '--json', 'nameWithOwner,defaultBranchRef,visibility,url'], { cwd: process.cwd(), env: ghEnv() })
2166
2164
  const text = redact([res.stdout, res.stderr].filter(Boolean).join(String.fromCharCode(10)).trim())
2167
2165
  // 与 github 工具同一套:失败带分类与下一步,而不是只贴原始 stderr
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.125",
3
+ "version": "0.9.126",
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",