@napuketto/adapter 0.24.5 → 0.24.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/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { f as ActionRegistry, n as ProtocolConfig, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, t as ConfigBase } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-xqbvEUYA.mjs";
|
|
3
|
-
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-
|
|
4
|
-
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-
|
|
3
|
+
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-DmlPzIeg.mjs";
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-Bq9Qd9ys.mjs";
|
|
5
5
|
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-Cmu2QGGz.mjs";
|
|
6
6
|
export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
package/dist/milky/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-
|
|
1
|
+
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-DmlPzIeg.mjs";
|
|
@@ -2297,6 +2297,7 @@ var MilkyEventPipeline = class {
|
|
|
2297
2297
|
if (this.unsubscribes.length > 0) return;
|
|
2298
2298
|
this.deps.request.markStartup();
|
|
2299
2299
|
const { msgChannel, groupChannel, buddyChannel, recentContactChannel, loginChannel } = this.deps;
|
|
2300
|
+
this.deps.essence.start(groupChannel);
|
|
2300
2301
|
this.unsubscribes.push(subscribeRawMessages(msgChannel, (msg) => this.deps.message.handle(msg).catch((err) => {
|
|
2301
2302
|
this.logFailure("message_receive", err);
|
|
2302
2303
|
}), { logger: this.deps.logger }), msgChannel.on("Msg/onRecvSysMsg", (a) => this.deps.sysMsg.handleRawArg(a)), msgChannel.on("Msg/onRecvOfflineFileMsg", (m) => this.deps.fileNotice.fileMessages(m)), msgChannel.on("Msg/onFileMsgCome", (m) => this.deps.fileNotice.fileMessages(m)));
|
|
@@ -2320,6 +2321,7 @@ var MilkyEventPipeline = class {
|
|
|
2320
2321
|
}
|
|
2321
2322
|
/** 退订(幂等)。 */
|
|
2322
2323
|
unsubscribeAll() {
|
|
2324
|
+
this.deps.essence.stop();
|
|
2323
2325
|
for (const off of this.unsubscribes) off();
|
|
2324
2326
|
this.unsubscribes = [];
|
|
2325
2327
|
}
|
|
@@ -2424,6 +2426,9 @@ var RecentKeyCache = class {
|
|
|
2424
2426
|
this.entries.set(key, now + this.ttlMs);
|
|
2425
2427
|
return true;
|
|
2426
2428
|
}
|
|
2429
|
+
deleteMatching(predicate) {
|
|
2430
|
+
for (const key of this.entries.keys()) if (predicate(key)) this.entries.delete(key);
|
|
2431
|
+
}
|
|
2427
2432
|
/** 惰性清理过期键(每次 claim 顺带执行,量级小无需定时器)。 */
|
|
2428
2433
|
prune(now) {
|
|
2429
2434
|
for (const [key, expiry] of this.entries) if (expiry <= now) this.entries.delete(key);
|
|
@@ -2438,15 +2443,30 @@ var MilkyInboundEssence = class {
|
|
|
2438
2443
|
constructor(deps) {
|
|
2439
2444
|
this.deps = deps;
|
|
2440
2445
|
this.essenceSync = new EssenceListSync({
|
|
2446
|
+
allowsGroup: (groupCode) => deps.api.groupCache?.allowsGroupEvents?.(groupCode) !== false,
|
|
2441
2447
|
fetchList: (groupCode) => deps.api.webApi.getEssenceMsgList(groupCode),
|
|
2442
|
-
onAdded: (groupCode, added) => this.broadcastAdded(groupCode, added),
|
|
2443
|
-
onRemoved: (groupCode, removed) => this.broadcastRemoved(groupCode, removed),
|
|
2448
|
+
onAdded: (groupCode, added, signal) => this.broadcastAdded(groupCode, added, signal),
|
|
2449
|
+
onRemoved: (groupCode, removed, _prev, signal) => this.broadcastRemoved(groupCode, removed, signal),
|
|
2450
|
+
onMembershipChange: (allows) => {
|
|
2451
|
+
this.essenceKeys.deleteMatching((key) => !allows(key.split(":", 1)[0] ?? ""));
|
|
2452
|
+
},
|
|
2453
|
+
onNotifyError: (groupCode, err) => deps.logger?.warn({
|
|
2454
|
+
group: groupCode,
|
|
2455
|
+
err: String(err)
|
|
2456
|
+
}, "精华事件广播失败"),
|
|
2457
|
+
onQueueFull: (groupCode) => deps.logger?.debug({ group: groupCode }, "精华同步队列已满,下次事件时重试"),
|
|
2444
2458
|
onFetchError: (g, err) => deps.logger?.warn({
|
|
2445
2459
|
group: g,
|
|
2446
2460
|
err: String(err)
|
|
2447
2461
|
}, "milky: 精华列表拉取失败(diff 跳过)")
|
|
2448
2462
|
});
|
|
2449
2463
|
}
|
|
2464
|
+
start(channel) {
|
|
2465
|
+
this.essenceSync.start(channel, this.deps.api.groupApi);
|
|
2466
|
+
}
|
|
2467
|
+
stop() {
|
|
2468
|
+
this.essenceSync.stop();
|
|
2469
|
+
}
|
|
2450
2470
|
/** sysmsg 732:1 快路径去重守卫:非精华恒 true;精华 claim 失败(diff 已抢发)→ false。 */
|
|
2451
2471
|
claimFastPath(ruleKind, data) {
|
|
2452
2472
|
if (ruleKind !== "group_essence_message_change") return true;
|
|
@@ -2454,7 +2474,7 @@ var MilkyInboundEssence = class {
|
|
|
2454
2474
|
const groupId = data["group_id"];
|
|
2455
2475
|
const seq = data["message_seq"];
|
|
2456
2476
|
if (typeof groupId !== "number" || typeof seq !== "number") return true;
|
|
2457
|
-
return this.claimChange(groupId, seq, true);
|
|
2477
|
+
return this.essenceSync.accepts(String(groupId)) && this.claimChange(groupId, seq, true);
|
|
2458
2478
|
}
|
|
2459
2479
|
/** 精华列表变更:拉全量列表 diff(remove 路径 + operator 回填;串行防乱序)。 */
|
|
2460
2480
|
change(arg) {
|
|
@@ -2466,13 +2486,19 @@ var MilkyInboundEssence = class {
|
|
|
2466
2486
|
this.essenceSync.enqueue(groupCode);
|
|
2467
2487
|
}
|
|
2468
2488
|
/** diff 广播:add(operator = add_digest_uin,快路径已发则跳过)→ remove(operator 省略)。 */
|
|
2469
|
-
broadcastAdded(groupCode, added) {
|
|
2489
|
+
broadcastAdded(groupCode, added, signal) {
|
|
2470
2490
|
const now = Math.floor(Date.now() / 1e3);
|
|
2471
|
-
for (const item of added)
|
|
2491
|
+
for (const item of added) {
|
|
2492
|
+
if (signal?.aborted === true) return;
|
|
2493
|
+
if (this.claimChange(groupCode, item.messageSeq, true)) this.broadcastChange(groupCode, item.messageSeq, true, numericUin(item.operatorUin), now);
|
|
2494
|
+
}
|
|
2472
2495
|
}
|
|
2473
|
-
broadcastRemoved(groupCode, removed) {
|
|
2496
|
+
broadcastRemoved(groupCode, removed, signal) {
|
|
2474
2497
|
const now = Math.floor(Date.now() / 1e3);
|
|
2475
|
-
for (const seq of removed)
|
|
2498
|
+
for (const seq of removed) {
|
|
2499
|
+
if (signal?.aborted === true) return;
|
|
2500
|
+
if (this.claimChange(groupCode, seq, false)) this.broadcastChange(groupCode, seq, false, null, now);
|
|
2501
|
+
}
|
|
2476
2502
|
}
|
|
2477
2503
|
broadcastChange(groupCode, seq, isSet, operatorId, time) {
|
|
2478
2504
|
this.deps.broadcast({
|
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-
|
|
1
|
+
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-Bq9Qd9ys.mjs";
|
|
@@ -3188,18 +3188,20 @@ var Ob11Enrichment = class {
|
|
|
3188
3188
|
* resolveMsgIdBySeq fallback 层)→ MessageUnique.alloc 幂等分配(可被 get_msg
|
|
3189
3189
|
* 反查的正确空间,对照 recall 的 msgSeq 错位)。未命中返回 null(跳过事件)。
|
|
3190
3190
|
*/
|
|
3191
|
-
async resolveEssenceMsgId(groupCode, seq) {
|
|
3191
|
+
async resolveEssenceMsgId(groupCode, seq, signal) {
|
|
3192
3192
|
const peer = {
|
|
3193
3193
|
chatType: ChatType.GROUP,
|
|
3194
3194
|
peerUid: groupCode
|
|
3195
3195
|
};
|
|
3196
|
-
const
|
|
3196
|
+
const msgs = await this.api.msgApi.fetchMessages(peer, { count: 60 }).catch((err) => {
|
|
3197
3197
|
this.calibLogger?.debug({
|
|
3198
3198
|
group: groupCode,
|
|
3199
3199
|
error: errorMessage(err)
|
|
3200
3200
|
}, "ob11: 精华反查近段历史拉取失败");
|
|
3201
3201
|
return [];
|
|
3202
|
-
})
|
|
3202
|
+
});
|
|
3203
|
+
if (signal?.aborted === true) return null;
|
|
3204
|
+
const hit = msgs.find((m) => Number(m.msgSeq) === seq);
|
|
3203
3205
|
if (hit === void 0) {
|
|
3204
3206
|
this.calibLogger?.warn({
|
|
3205
3207
|
group: groupCode,
|
|
@@ -3218,20 +3220,32 @@ var Ob11InboundEssence = class {
|
|
|
3218
3220
|
constructor(deps) {
|
|
3219
3221
|
this.deps = deps;
|
|
3220
3222
|
this.essenceSync = new EssenceListSync({
|
|
3223
|
+
allowsGroup: (groupCode) => deps.api.groupCache?.allowsGroupEvents?.(groupCode) !== false,
|
|
3221
3224
|
fetchList: (groupCode) => deps.api.webApi.getEssenceMsgList(groupCode),
|
|
3222
|
-
onAdded: (groupCode, added) => this.broadcastDiff(groupCode, added, "add"),
|
|
3223
|
-
onRemoved: (groupCode, removed, prev) => this.broadcastDiff(groupCode, removed.map((seq) => ({
|
|
3225
|
+
onAdded: (groupCode, added, signal) => this.broadcastDiff(groupCode, added, "add", signal),
|
|
3226
|
+
onRemoved: (groupCode, removed, prev, signal) => this.broadcastDiff(groupCode, removed.map((seq) => ({
|
|
3224
3227
|
messageSeq: seq,
|
|
3225
3228
|
senderUin: prev.get(seq)?.senderUin ?? null,
|
|
3226
3229
|
operatorUin: null,
|
|
3227
3230
|
addDigestTime: null
|
|
3228
|
-
})), "delete"),
|
|
3231
|
+
})), "delete", signal),
|
|
3232
|
+
onNotifyError: (groupCode, err) => deps.logger?.warn({
|
|
3233
|
+
group: groupCode,
|
|
3234
|
+
err: String(err)
|
|
3235
|
+
}, "精华事件广播失败"),
|
|
3236
|
+
onQueueFull: (groupCode) => deps.logger?.debug({ group: groupCode }, "精华同步队列已满,下次事件时重试"),
|
|
3229
3237
|
onFetchError: (g, err) => deps.logger?.warn({
|
|
3230
3238
|
group: g,
|
|
3231
3239
|
err: String(err)
|
|
3232
3240
|
}, "ob11: 精华列表拉取失败(diff 跳过)")
|
|
3233
3241
|
});
|
|
3234
3242
|
}
|
|
3243
|
+
start(channel) {
|
|
3244
|
+
this.essenceSync.start(channel, this.deps.api.groupApi);
|
|
3245
|
+
}
|
|
3246
|
+
stop() {
|
|
3247
|
+
this.essenceSync.stop();
|
|
3248
|
+
}
|
|
3235
3249
|
/** sysmsg 732:1 加速触发器:抽取群号踢入串行链(抽取失败 → false 落校准路径)。 */
|
|
3236
3250
|
triggerFromSysMsg(tree) {
|
|
3237
3251
|
const hit = extractEssenceSetSysMsg(tree);
|
|
@@ -3249,7 +3263,7 @@ var Ob11InboundEssence = class {
|
|
|
3249
3263
|
this.essenceSync.enqueue(groupCode);
|
|
3250
3264
|
}
|
|
3251
3265
|
/** diff 逐条广播(add/delete 共用):sender 必填 → message_id 反查 → notice 装配。 */
|
|
3252
|
-
async broadcastDiff(groupCode, items, subType) {
|
|
3266
|
+
async broadcastDiff(groupCode, items, subType, signal) {
|
|
3253
3267
|
const { enrich, broadcast, selfUin } = this.deps;
|
|
3254
3268
|
for (const item of items) {
|
|
3255
3269
|
const senderId = numericUin(item.senderUin);
|
|
@@ -3261,7 +3275,8 @@ var Ob11InboundEssence = class {
|
|
|
3261
3275
|
}, `ob11: 精华${detail}(跳过事件)`);
|
|
3262
3276
|
continue;
|
|
3263
3277
|
}
|
|
3264
|
-
const messageId = await enrich.resolveEssenceMsgId(groupCode, item.messageSeq);
|
|
3278
|
+
const messageId = await enrich.resolveEssenceMsgId(groupCode, item.messageSeq, signal);
|
|
3279
|
+
if (signal?.aborted === true) return;
|
|
3265
3280
|
if (messageId === null) continue;
|
|
3266
3281
|
const operatorId = numericUin(item.operatorUin);
|
|
3267
3282
|
broadcast({
|
|
@@ -3698,6 +3713,7 @@ var Ob11EventPipeline = class {
|
|
|
3698
3713
|
if (this.unsubscribes.length > 0) return;
|
|
3699
3714
|
this.request.markStartup();
|
|
3700
3715
|
const { msgChannel, groupChannel, friendChannel, buddyCacheEvents } = this.deps;
|
|
3716
|
+
this.essence.start(groupChannel);
|
|
3701
3717
|
this.unsubscribes.push(subscribeRawMessages(msgChannel, (msg) => this.message.handleRawMessage(msg), { logger: this.deps.logger }), msgChannel.on("Msg/onRecvOfflineFileMsg", (a) => this.fileNotice.offlineFile(a)), msgChannel.on("Msg/onRecvSysMsg", (a) => this.sysMsg.handleRawArg(a)), msgChannel.on("Msg/onRecvOnlineFileMsg", (a) => this.fileNotice.onlineFile(a)));
|
|
3702
3718
|
if (groupChannel !== void 0) this.unsubscribes.push(groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
|
|
3703
3719
|
this.request.groupNotifies(doubt, notifies).catch((err) => logEventFailure(this.deps.logger, "ob11: group request 翻译失败(整批丢弃)", err));
|
|
@@ -3709,6 +3725,7 @@ var Ob11EventPipeline = class {
|
|
|
3709
3725
|
if (buddyCacheEvents !== void 0) this.unsubscribes.push(buddyCacheEvents.on("BuddyCache/onBuddyAdded", (e) => this.fileNotice.friendAdd(e)));
|
|
3710
3726
|
}
|
|
3711
3727
|
unsubscribeAll() {
|
|
3728
|
+
this.essence.stop();
|
|
3712
3729
|
for (const off of this.unsubscribes) off();
|
|
3713
3730
|
this.unsubscribes = [];
|
|
3714
3731
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@napuketto/adapter",
|
|
4
|
-
"version": "0.24.
|
|
4
|
+
"version": "0.24.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for Napuketto",
|
|
7
7
|
"keywords": [
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"dev": "tsdown --watch"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@napuketto/kernel": "^0.19.
|
|
85
|
+
"@napuketto/kernel": "^0.19.6",
|
|
86
86
|
"@napuketto/media": "^0.4.1",
|
|
87
87
|
"@napuketto/network": "^0.5.1",
|
|
88
88
|
"zod": "^4.6.7"
|