dsh-qq-link 1.5.5 → 1.5.6

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
@@ -1,3 +1,16 @@
1
+ ## 1.5.6 — 2026-11-11
2
+
3
+ **回复门槛 / QQ 空间那五个工具:会话建出来就当场挂,不再等轮询那一跳**
4
+
5
+ - 🐞 这两批工具是「按会话挂」的(只有绑了 QQ 的那几间屋才有),以前只在收消息那一跳
6
+ (默认 2 秒一次)里顺带挂。重启之后第一句要是比那一跳快,那一轮的工具表就少几条 ——
7
+ 前缀跟着变,**整段历史按未缓存重算一次**(实测 34.6 万 token)。
8
+ - 现在接 `agent/created` / `agent/disposed`:会话一建好就挂、销毁就摘,没有空档;
9
+ 轮询那一跳照旧留着当兜底。
10
+ - 🐞 回复门槛以前只看「这个会话挂过没有」—— 会话重开、插件重载换了 agent 实例之后就不重挂,
11
+ 那间屋的门槛工具从此永久没了。现在按「会话 + 实例」记,实例变了就重挂。
12
+ - 🐞 空间工具换实例时只挂新的、不摘旧的,会留两份。现在先摘再挂。
13
+
1
14
  ## 1.5.5 — 2026-11-10
2
15
 
3
16
  **QQ 空间「看单条说说」会把整轮对话弄崩:tid 被声明成了整数**
package/lib/host.js CHANGED
@@ -2564,7 +2564,7 @@ export function apply(ctx) {
2564
2564
  // 「工具调用 · Error: tool call aborted」+ 宿主开始「重试模型请求 (1/5)」,看着像坏了。
2565
2565
  // 现在改成**不停轮、只把这轮的出站掐掉**:工具返回一句「这轮不接」,并在这一轮结束时跳过发送。
2566
2566
  const 静默轮 = new Set() // 会话键
2567
- const 闸门挂着 = new Map() // sid -> disposer(DSH 的 tools.register 返回的就是一个收尾函数)
2567
+ const 闸门挂着 = new Map() // sid -> { agent, off }
2568
2568
  const QqWalake窗口 = 10 * 60 * 1000
2569
2569
 
2570
2570
  // ── 群聊的节奏(1.0.9:**只要两个数**)──
@@ -2799,20 +2799,27 @@ export function apply(ctx) {
2799
2799
  const agent = 找agent(id)
2800
2800
  if (!agent) continue
2801
2801
  const sid = 会话键((agent.session && agent.session.id) || id)
2802
- if (闸门挂着.has(sid)) continue
2802
+ const 已 = 闸门挂着.get(sid)
2803
+ // ⭐ 1.5.6:按「sid + agent 实例」记。以前只看 sid 在不在,
2804
+ // 会话重开 / 插件重载换了实例就不重挂 —— 那间屋的门槛工具从此永久没了。
2805
+ if (已 && 已.agent === agent) continue
2806
+ if (已) {
2807
+ try { if (typeof 已.off === 'function') 已.off() } catch (error) {}
2808
+ 闸门挂着.delete(sid)
2809
+ }
2803
2810
  try {
2804
2811
  const off = agent.ctx.tools.register(做闸门工具(agent, sid))
2805
- 闸门挂着.set(sid, off)
2812
+ 闸门挂着.set(sid, { agent, off })
2806
2813
  记账('回复门槛已挂上(' + 短id(sid) + ')')
2807
2814
  } catch (error) {
2808
2815
  记账('回复门槛挂不上(' + 短id(sid) + '):' + String((error && error.message) || error))
2809
2816
  }
2810
2817
  }
2811
2818
  // 卸
2812
- for (const [sid, off] of 闸门挂着) {
2819
+ for (const [sid, 记] of 闸门挂着) {
2813
2820
  const 还要 = [...该挂].some((id) => 会话键(id) === sid)
2814
2821
  if (还要) continue
2815
- try { if (typeof off === 'function') off() } catch (error) {}
2822
+ try { if (记 && typeof 记.off === 'function') 记.off() } catch (error) {}
2816
2823
  闸门挂着.delete(sid)
2817
2824
  记账('回复门槛已卸下(' + 短id(sid) + ')')
2818
2825
  }
@@ -3129,6 +3136,11 @@ export function apply(ctx) {
3129
3136
  // 0.2.2 起同一作用域不许重名注册,于是每次都抛 already registered,日志被刷爆。
3130
3137
  const 已挂 = 空间挂着.get(sid)
3131
3138
  if (已挂 && 已挂.agent === agent) continue
3139
+ // 实例换了:先把上一批摘干净再挂新的,别留两份
3140
+ if (已挂 && typeof 已挂.off === 'function') {
3141
+ try { 已挂.off() } catch (error) {}
3142
+ }
3143
+ 空间挂着.delete(sid)
3132
3144
  const 卸们 = []
3133
3145
  let 已经有过 = 0
3134
3146
  for (const 工具 of 做空间工具()) {
@@ -3860,6 +3872,23 @@ export function apply(ctx) {
3860
3872
  }
3861
3873
  }, 'qq-bridge: 轮询收 QQ 消息')
3862
3874
 
3875
+ // ⭐ 1.5.6:会话一建出来就当场挂,不等下一跳轮询。
3876
+ // 以前这两批工具只在「收消息那一跳」里顺带挂(默认 2 秒一次)。重启之后,
3877
+ // 第一句要是来得比那一跳快,那一轮的工具表就少几条 —— 前缀跟着变,
3878
+ // 整段历史按未缓存重算一次。DSH 有 agent/created,建好就通知,用它就没有空档。
3879
+ for (const 事件 of ['agent/created', 'agent/disposed']) {
3880
+ try {
3881
+ ctx.on(事件, () => {
3882
+ try {
3883
+ 闸门心跳()
3884
+ 空间工具心跳()
3885
+ } catch (error) {}
3886
+ })
3887
+ } catch (error) {
3888
+ 记账('挂不上 ' + 事件 + '(不影响对话):' + String((error && error.message) || error))
3889
+ }
3890
+ }
3891
+
3863
3892
  // ⭐ 1.5.0:空间的两件定时活,共用一个 60 秒的 setInterval(定时说说 + 定时看一圈)。
3864
3893
  // ⚠ 整跳都在 空间定时一跳 里各自 try/catch —— 抛一次错不能让后面的跳停掉。
3865
3894
  // 宿主没给 setTimeout / setInterval 就安静跳过(跟上面 ctx.interval 不在一处,别混)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-qq-link",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "通到 QQ:DSH 里的 AI 伙伴和 QQ 双向互通 —— 它说完话自动发到 QQ,你在 QQ 里说的话自动转进 DSH。走 OneBot 11 HTTP(SnowLuma / NapCat 都行)。",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {