dsh-session-superagent 0.9.114 → 0.9.115

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,33 @@
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.115] - 2026-11-03 —— `github` 工具失败时也带「下一步」和机器可读的 kind
6
+
7
+ ### 为什么
8
+ 上一版只修了**轮询**路径(x-poll-interval / 永久错误长退避)。而 `github` 工具(任意 REST 调用)
9
+ 失败时仍然只贴原始 stderr 加一行 `[exit code: 1]`:
10
+
11
+ ```
12
+ gh: HTTP 404 Not Found
13
+ [exit code: 1]
14
+ ```
15
+
16
+ 调用它的 agent 得自己猜"是仓库名错了、还是没权限、还是登录失效"。GitHub 官方最佳实践明确要求
17
+ 「do not ignore repeated 4xx/5xx」—— 失败必须带着可执行动作回到调用方。
18
+
19
+ ### 改法
20
+ 抽出 `formatGhCall()`(`lib/gh-format.js`),`github` 工具与轮询共用同一套分类:
21
+
22
+ | 情况 | 现在返回 |
23
+ |---|---|
24
+ | 404 | `…(仓库不存在或没权限:检查 owner/name)` + `[kind: notfound]` |
25
+ | 401 | `…(gh 登录失效:跑 gh auth login…)` + `[kind: auth]` |
26
+ | 304 | `…(没有变化 —— 条件请求命中 304,这不是错误)` + `[kind: notmodified]` |
27
+ | 成功 | 只加 `[exit code: 0]`(不带 kind,保持轻量) |
28
+
29
+ ### 测试
30
+ 新增 1 例:四种情况的返回形状(含「成功时不带 kind」)。合计 **223 例**。
31
+
5
32
  ## [0.9.114] - 2026-11-03 —— 按 GitHub 官方最佳实践补两条:x-poll-interval、永久错误等更久
6
33
 
7
34
  ### 学到什么(出处)
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.114-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.115-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
 
@@ -122,7 +122,7 @@ dsh plugin install /path/to/dsh-session-superagent
122
122
  ## 开发
123
123
 
124
124
  ```sh
125
- node --test # 222 项单测
125
+ node --test # 223 项单测
126
126
  ```
127
127
 
128
128
  ### 工具输出:文本给人和 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.114'
17
+ const CLIENT_VERSION = '0.9.115'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/gh-format.js CHANGED
@@ -6,6 +6,28 @@
6
6
  //
7
7
  // 约定:本文件只做「解析 / 归类 / 措辞」,不发请求、不碰状态。
8
8
 
9
+ /**
10
+ * 把 `gh` 调用的结果整理成给 agent 看的一段文本。
11
+ *
12
+ * 为什么要单独抽出来:`github` 工具原来只贴原始 stderr + `[exit code: N]`,
13
+ * agent 拿到「gh: HTTP 404」还得自己猜该动什么。这里统一补上分类与下一步。
14
+ * 依据:GitHub 官方要求「do not ignore repeated 4xx/5xx」——
15
+ * 失败必须带着可执行的动作回到调用方。
16
+ * 出处:https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api
17
+ */
18
+ export function formatGhCall({ code, text, classify }) {
19
+ const body = String(text || '').trim() || '(empty)'
20
+ const failed = Number(code) !== 0
21
+ const why = failed ? classify(body) : null
22
+ // 304 是「没变化」,不是失败:别让调用方以为出错了
23
+ if (why && why.kind === 'notmodified') {
24
+ return body + String.fromCharCode(10) + why.hint + String.fromCharCode(10) + '[exit code: ' + code + '][kind: notmodified]'
25
+ }
26
+ if (failed) {
27
+ return body + String.fromCharCode(10) + why.hint + String.fromCharCode(10) + '[exit code: ' + code + '][kind: ' + why.kind + ']'
28
+ }
29
+ return body + String.fromCharCode(10) + '[exit code: ' + code + ']'
30
+ }
9
31
  export function classifyGhError(detail) {
10
32
  const text = String(detail || '')
11
33
  // 长 URL 压缩,避免一整条 API 地址占满面板
package/lib/index.js CHANGED
@@ -25,7 +25,7 @@ import { redact } from './redact.js'
25
25
  import { decodeBody } from './body.js'
26
26
  import {
27
27
  advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
28
- TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, permanentBackoffMs, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
28
+ TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, formatGhCall, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, permanentBackoffMs, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
29
29
  shouldRunCleanup,
30
30
  bumpDailyWakes,
31
31
  busierThanUsual,
@@ -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.114'
43
+ export const SERVER_VERSION = '0.9.115'
44
44
  export const inject = ['tools', 'agents', 'webServer']
45
45
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
46
46
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -2074,8 +2074,9 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2074
2074
  const res = await run('gh', ['api', '-X', method, args.path, '--header', 'Accept: application/vnd.github+json'], {
2075
2075
  input: write && args.body ? args.body : undefined, env: ghEnv(),
2076
2076
  })
2077
- const text = redact([res.stdout, res.stderr].filter(Boolean).join('\n').trim())
2078
- return `${text || '(empty)'}\n[exit code: ${res.code}]`
2077
+ const text = redact([res.stdout, res.stderr].filter(Boolean).join(String.fromCharCode(10)).trim())
2078
+ // 失败要带「下一步」:只贴 gh 的原始报错,调用方还得自己猜
2079
+ return formatGhCall({ code: res.code, text, classify: classifyGhError })
2079
2080
  },
2080
2081
  }))
2081
2082
 
package/lib/watch.js CHANGED
@@ -537,6 +537,7 @@ export {
537
537
  classifyGhError,
538
538
  commentSummaryLine,
539
539
  countReasons,
540
+ formatGhCall,
540
541
  jitterMs,
541
542
  linkedPrNote,
542
543
  parseCommentBatch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.114",
3
+ "version": "0.9.115",
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",