dsh-qq-link 1.5.3 → 1.5.4
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 +10 -0
- package/lib/host.js +23 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 1.5.4 — 2026-11-07
|
|
2
|
+
|
|
3
|
+
**宿主 0.2.2 起,QQ 空间的四个工具每 2 秒报一次 already registered,日志被刷爆**
|
|
4
|
+
|
|
5
|
+
- 🐞 issue #36:`空间工具心跳()` 注册失败时**不写 map**,于是每跳(2 秒)重试一次;
|
|
6
|
+
而 0.2.2 起同一作用域不允许重名注册,第二次就抛 `already registered` ——
|
|
7
|
+
一个中午 521 条,把宿主日志淹了。工具其实一直是挂着的,用户只看见「桥在报错」。
|
|
8
|
+
- 现在:`already registered` 不算失败,按「会话 + agent 实例」记下来,**实例换了才重挂**;
|
|
9
|
+
真的挂不上时也只记一次,不再每 2 秒刷。
|
|
10
|
+
|
|
1
11
|
## 1.5.3 — 2026-11-07
|
|
2
12
|
|
|
3
13
|
**别人发来的文件,以前一行都看不见**
|
package/lib/host.js
CHANGED
|
@@ -3120,27 +3120,40 @@ export function apply(ctx) {
|
|
|
3120
3120
|
// 宿主没给 tools 服务(或者那间会话没开)就跳过 —— 下一跳再看
|
|
3121
3121
|
if (!agent || !agent.ctx || !agent.ctx.tools || typeof agent.ctx.tools.register !== 'function') continue
|
|
3122
3122
|
const sid = 会话键((agent.session && agent.session.id) || id)
|
|
3123
|
-
|
|
3123
|
+
// ⭐ 1.5.4(issue #36):按「sid + agent 实例」记 —— 实例换了才重挂(会话重开、插件重载)。
|
|
3124
|
+
// 以前只按 sid 记,而且注册全失败时不写 map ⇒ 每 2 秒重试一次,
|
|
3125
|
+
// 0.2.2 起同一作用域不许重名注册,于是每次都抛 already registered,日志被刷爆。
|
|
3126
|
+
const 已挂 = 空间挂着.get(sid)
|
|
3127
|
+
if (已挂 && 已挂.agent === agent) continue
|
|
3124
3128
|
const 卸们 = []
|
|
3129
|
+
let 已经有过 = 0
|
|
3125
3130
|
for (const 工具 of 做空间工具()) {
|
|
3126
3131
|
try {
|
|
3127
3132
|
const off = agent.ctx.tools.register(工具)
|
|
3128
3133
|
if (typeof off === 'function') 卸们.push(off)
|
|
3129
3134
|
} catch (error) {
|
|
3130
|
-
|
|
3135
|
+
const 因 = String((error && error.message) || error)
|
|
3136
|
+
// 已经注册过 = 上一次其实挂上了(只是我们手里没留 off)—— 记下来,别再试
|
|
3137
|
+
if (/already registered/i.test(因)) { 已经有过 += 1; continue }
|
|
3138
|
+
if (!已挂 || !已挂.报过) {
|
|
3139
|
+
记账('QQ 空间的工具挂不上(' + 短id(sid) + ',' + 工具.name + '):' + 因)
|
|
3140
|
+
}
|
|
3131
3141
|
}
|
|
3132
3142
|
}
|
|
3133
|
-
if (!卸们.length)
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3143
|
+
if (!卸们.length && !已经有过) {
|
|
3144
|
+
// 一个都没成:记一笔「报过」,下一跳别再刷同样的错
|
|
3145
|
+
空间挂着.set(sid, { agent, off: null, 报过: true })
|
|
3146
|
+
continue
|
|
3147
|
+
}
|
|
3148
|
+
空间挂着.set(sid, {
|
|
3149
|
+
agent,
|
|
3150
|
+
off: () => { for (const off of 卸们) { try { off() } catch (error) {} } },
|
|
3138
3151
|
})
|
|
3139
|
-
记账('QQ 空间的工具挂上了(' + 短id(sid) + ')')
|
|
3152
|
+
记账('QQ 空间的工具挂上了(' + 短id(sid) + (卸们.length < 4 ? ',其中 ' + 已经有过 + ' 个本来就在' : '') + ')')
|
|
3140
3153
|
}
|
|
3141
|
-
for (const [sid,
|
|
3154
|
+
for (const [sid, 记] of 空间挂着) {
|
|
3142
3155
|
if ([...该挂].some((id) => 会话键(id) === sid)) continue
|
|
3143
|
-
try { off() } catch (error) {}
|
|
3156
|
+
try { if (记 && typeof 记.off === 'function') 记.off() } catch (error) {}
|
|
3144
3157
|
空间挂着.delete(sid)
|
|
3145
3158
|
记账('QQ 空间的工具卸下了(' + 短id(sid) + ')')
|
|
3146
3159
|
}
|
package/package.json
CHANGED