dsh-session-superagent 0.9.30 → 0.9.31

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,23 @@
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.31] - 2026-11-02 —— 面板也能追溯了(`/trace` 路由,路由面 8 → 9)
6
+
7
+ ### 做了什么
8
+ - 新增 `GET /session-superagent/trace?repo=&number=`:返回结论 + 水位 + 上次上报 + 过滤原因 + 唤醒历史;
9
+ - 面板「判定」页新增「追溯一条」:在右上角搜索框输入编号(如 `42`),点「追溯 #42」把结论显示在提示区。
10
+
11
+ ### 为什么走服务端而不是在客户端再算一遍
12
+ 客户端本地算需要 `seen` / `lastReported` —— 那是**大字段**,而既有用例明确要求
13
+ `/state` 不回传服务端自己用的字段(面板每 5 秒拉一次,省的是真流量)。
14
+ 所以走 `/trace`,按需请求、只回传结论。**同时避免了第三份重复实现**(服务端有 `itemTrace`,客户端不需要再有)。
15
+
16
+ ### 连带改动
17
+ 路由面从 8 条变 9 条:相关用例(跨实例接管 / 撞车重放 / 卸载 / 路由清单)与 preflight 的期望值一并更新。
18
+
19
+ ### 测试
20
+ - 新增 1 例(未输入时给提示、输入编号后出现追溯按钮、单守时说明在哪个仓库查)。合计 **170 例**。
21
+
5
22
  ## [0.9.30] - 2026-11-02 —— 单条追溯:`watch_trace` 工具 + `trace-item` 脚本
6
23
 
7
24
  ### 学到的(知识库第 78 条)
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.30-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.31-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
 
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.30'
17
+ const CLIENT_VERSION = '0.9.31'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1228,6 +1228,31 @@ window.__ModuleLoader__.load({
1228
1228
  count: watchers.reduce((n, w) => n + (w.history || []).length, 0),
1229
1229
  action: h(InfoTip, { text: '每轮判定都会记一条:唤醒、仅观察,或跳过及其原因。只存最近若干条。' }),
1230
1230
  },
1231
+ (() => {
1232
+ const needle = search.trim()
1233
+ const asNumber = /^#?[0-9]+$/.test(needle) ? needle.replace('#', '') : ''
1234
+ if (!asNumber) {
1235
+ return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(如 42),这里就能查它经历了什么' },
1236
+ h(Hint, null, '追溯会告诉你:它被过滤了、已经唤醒过、还是根本没轮到。'))
1237
+ }
1238
+ const onlyRepo = watchers.length === 1 ? watchers[0].repo : ''
1239
+ return h(Section, { key: 'trace', title: '追溯一条' },
1240
+ h('div', { className: 'dt-row-meta' },
1241
+ h('button', {
1242
+ className: 'dt-textlink',
1243
+ type: 'button',
1244
+ onClick: async () => {
1245
+ try {
1246
+ const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
1247
+ const payload = await call(query)
1248
+ notify(String((payload && payload.text) || '没有结果').split(String.fromCharCode(10)).join(' · '), 'info')
1249
+ } catch (error) {
1250
+ notify('追溯失败:' + String((error && error.message) || error), 'error')
1251
+ }
1252
+ },
1253
+ }, '追溯 #' + asNumber),
1254
+ h('span', { className: 'dt-row-meta' }, onlyRepo ? '(在 ' + onlyRepo + ' 里查)' : '(在所有守里查)')))
1255
+ })(),
1231
1256
  (() => {
1232
1257
  const counts = new Map()
1233
1258
  for (const w of watchers) if (w.deferReason) counts.set(w.deferReason, (counts.get(w.deferReason) || 0) + 1)
package/lib/index.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
 
36
36
  export const name = 'dsh-session-superagent'
37
37
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
38
- export const SERVER_VERSION = '0.9.30'
38
+ export const SERVER_VERSION = '0.9.31'
39
39
  export const inject = ['tools', 'agents', 'webServer']
40
40
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
41
41
  const DEFAULT_SESSION_WAKES = 12
@@ -1526,6 +1526,36 @@ export function apply(ctx) {
1526
1526
  },
1527
1527
  })
1528
1528
 
1529
+ // 单条追溯:面板点「追溯」时来问。只回传结论与明细,不回传 seen/lastReported 这类大字段。
1530
+ addRoute({
1531
+ kind: 'exact',
1532
+ path: '/session-superagent/trace',
1533
+ handler: async (req, res) => {
1534
+ if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
1535
+ const url = new URL(String(req.url || '/'), 'http://127.0.0.1')
1536
+ const repo = url.searchParams.get('repo') || ''
1537
+ const number = url.searchParams.get('number') || ''
1538
+ const state = readState()
1539
+ const list = Object.values(state.watchers || {}).filter((entry) => !repo || entry.repo === repo)
1540
+ const lines = []
1541
+ for (const entry of list) {
1542
+ const trace = itemTrace(entry, number)
1543
+ if (!trace) continue
1544
+ const touched = Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length)
1545
+ if (!touched) continue
1546
+ lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
1547
+ if (trace.seen) lines.push('水位 ' + trace.seen)
1548
+ if (trace.reported) lines.push('上次上报 ' + trace.reported)
1549
+ for (const item of trace.filtered) lines.push('被过滤(' + (item.reason || '未知') + ')' + item.at)
1550
+ for (const item of trace.wakes) lines.push('唤醒尝试 ' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
1551
+ }
1552
+ const text = lines.length > 0
1553
+ ? lines.join(String.fromCharCode(10))
1554
+ : '#' + number + ' 在' + (repo || '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
1555
+ json(res, 200, { ok: true, text })
1556
+ },
1557
+ })
1558
+
1529
1559
  // 版本检查(只读;面板「设置」页那一行「有新版本」靠它)
1530
1560
  addRoute({
1531
1561
  kind: 'exact',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.30",
3
+ "version": "0.9.31",
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",