@napuketto/adapter 0.24.5 → 0.25.0
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-Beq1S5ad.d.mts → index-k9tVdOyb.d.mts} +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-DbT3wxVC.mjs → milky-DqdxZQV2.mjs} +46 -22
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-DnDRoiMk.mjs → onebot11-zpsm4o9D.mjs} +40 -15
- package/package.json +3 -3
|
@@ -870,6 +870,7 @@ interface AssembleOb11TransportsOptions {
|
|
|
870
870
|
handleRequest: (req: unknown, respond: (res: unknown) => void) => void;
|
|
871
871
|
/** 机器人自身 uin(koishi 等第三方按 X-Self-ID 识别连接归属)。 */
|
|
872
872
|
selfUin: string;
|
|
873
|
+
logger?: Pick<AdapterLoggerLike, "warn"> | undefined;
|
|
873
874
|
}
|
|
874
875
|
/** 按配置装配 OB11 传输。 */
|
|
875
876
|
declare function assembleOb11Transports(opts: AssembleOb11TransportsOptions): Ob11TransportSet;
|
package/dist/index.d.mts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, g as ActionOutcome, h as ActionKernelSpec, i as ConfigSchema, m as ActionRegistry, n as ConfigFormat, o as createServerSchema, r as ConfigOptions, s as BaseProtocolAdapter, t as ConfigBase, v as runAction } from "./index-BO1TgLTT.mjs";
|
|
19
19
|
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-tW3a05Du.mjs";
|
|
20
20
|
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-CWUA38Aw.mjs";
|
|
21
|
-
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-
|
|
21
|
+
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-k9tVdOyb.mjs";
|
|
22
22
|
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-DNuLYcSP.mjs";
|
|
23
23
|
import { z } from "zod";
|
|
24
24
|
declare const protocolMediaSchema: z.ZodObject<{
|
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-DqdxZQV2.mjs";
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-zpsm4o9D.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-DqdxZQV2.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({
|
|
@@ -3176,20 +3202,18 @@ function assembleMilkyTransports(opts) {
|
|
|
3176
3202
|
handleMilkyHttpRequest(ctx, req, respond, registry, logger);
|
|
3177
3203
|
};
|
|
3178
3204
|
const adapters = [server, hub];
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
adapters.push(client);
|
|
3192
|
-
}
|
|
3205
|
+
const webhooks = config.webhooks.map((url, index) => new HttpClient({
|
|
3206
|
+
url,
|
|
3207
|
+
...token !== "" ? { headers: { authorization: `${BEARER_PREFIX}${token}` } } : {},
|
|
3208
|
+
timeoutMs: 5e3,
|
|
3209
|
+
onError: () => {
|
|
3210
|
+
logger?.warn({
|
|
3211
|
+
category: "webhook_delivery_failed",
|
|
3212
|
+
index
|
|
3213
|
+
}, "milky: webhook 推送失败");
|
|
3214
|
+
}
|
|
3215
|
+
}));
|
|
3216
|
+
adapters.push(...webhooks);
|
|
3193
3217
|
for (const adapter of adapters) broadcaster.register(adapter);
|
|
3194
3218
|
let closing;
|
|
3195
3219
|
return {
|
|
@@ -3198,7 +3222,7 @@ function assembleMilkyTransports(opts) {
|
|
|
3198
3222
|
closing ??= (async () => {
|
|
3199
3223
|
for (const adapter of adapters) broadcaster.unregister(adapter);
|
|
3200
3224
|
try {
|
|
3201
|
-
await hub.close();
|
|
3225
|
+
await Promise.all([hub.close(), ...webhooks.map((client) => client.close())]);
|
|
3202
3226
|
} finally {
|
|
3203
3227
|
await server.close();
|
|
3204
3228
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as OB11MessageInfo, A as serializeCqParts, B as canonicalToCqMessage, C as ob11ConfigSchema, D as escapeCqParam, E as encodeCqCode, F as ob11ErrorCodeMap, G as CurrentTalkative, H as cqMessageToCanonical, I as OneBotApi, J as GroupInfo, K as FriendInfo, L as OneBotApiOptions, M as Ob11ActionDeps, N as createOb11ActionRegistry, O as escapeCqText, P as AtAllRemainInfo, Q as OB11Message, R as OneBotSystemOptions, S as OB11Config, T as CqCode, U as cqMessageToSegments, V as canonicalToSegments, W as segmentsToCanonical, X as HonorMember, Y as GroupMemberInfo, Z as LoginInfo, _ as OB11GroupMessageEvent, a as assembleOb11Transports, at as VersionInfo, b as OB11BaseEvent, c as OB11Event, d as OB11RequestEvent, et as OB11MessageSegment, f as OB11NoticeEvent, g as OB11Status, h as OB11MetaEvent, i as Ob11TransportSet, it as StrangerInfo, j as unescapeCqText, k as parseCqMessage, l as OB11FriendRequestEvent, m as OB11LifecycleMetaEvent, n as Ob11OutboundTransport, nt as Sender, o as NapukettoOneBot11Adapter, p as OB11HeartbeatMetaEvent, q as GroupHonorInfo, r as Ob11OutboundWsReconnect, rt as Sex, s as OneBot11AdapterOptions, t as AssembleOb11TransportsOptions, tt as OB11Return, u as OB11GroupRequestEvent, v as OB11MessageEvent, w as segmentsToCqMessage, x as OB11PostType, y as OB11PrivateMessageEvent, z as MessageUnique } from "../index-
|
|
5
|
+
import { $ as OB11MessageInfo, A as serializeCqParts, B as canonicalToCqMessage, C as ob11ConfigSchema, D as escapeCqParam, E as encodeCqCode, F as ob11ErrorCodeMap, G as CurrentTalkative, H as cqMessageToCanonical, I as OneBotApi, J as GroupInfo, K as FriendInfo, L as OneBotApiOptions, M as Ob11ActionDeps, N as createOb11ActionRegistry, O as escapeCqText, P as AtAllRemainInfo, Q as OB11Message, R as OneBotSystemOptions, S as OB11Config, T as CqCode, U as cqMessageToSegments, V as canonicalToSegments, W as segmentsToCanonical, X as HonorMember, Y as GroupMemberInfo, Z as LoginInfo, _ as OB11GroupMessageEvent, a as assembleOb11Transports, at as VersionInfo, b as OB11BaseEvent, c as OB11Event, d as OB11RequestEvent, et as OB11MessageSegment, f as OB11NoticeEvent, g as OB11Status, h as OB11MetaEvent, i as Ob11TransportSet, it as StrangerInfo, j as unescapeCqText, k as parseCqMessage, l as OB11FriendRequestEvent, m as OB11LifecycleMetaEvent, n as Ob11OutboundTransport, nt as Sender, o as NapukettoOneBot11Adapter, p as OB11HeartbeatMetaEvent, q as GroupHonorInfo, r as Ob11OutboundWsReconnect, rt as Sex, s as OneBot11AdapterOptions, t as AssembleOb11TransportsOptions, tt as OB11Return, u as OB11GroupRequestEvent, v as OB11MessageEvent, w as segmentsToCqMessage, x as OB11PostType, y as OB11PrivateMessageEvent, z as MessageUnique } from "../index-k9tVdOyb.mjs";
|
|
6
6
|
export { type AssembleOb11TransportsOptions, type AtAllRemainInfo, type CqCode, type CurrentTalkative, type FriendInfo, type GroupHonorInfo, type GroupInfo, type GroupMemberInfo, type HonorMember, type LoginInfo, MessageUnique, NapukettoOneBot11Adapter, type OB11BaseEvent, type OB11Config, type OB11Event, type OB11FriendRequestEvent, type OB11GroupMessageEvent, type OB11GroupRequestEvent, type OB11HeartbeatMetaEvent, type OB11LifecycleMetaEvent, type OB11Message, type OB11MessageEvent, type OB11MessageInfo, type OB11MessageSegment, type OB11MetaEvent, type OB11NoticeEvent, type OB11PostType, type OB11PrivateMessageEvent, type OB11RequestEvent, type OB11Return, type OB11Status, type Ob11ActionDeps, type Ob11OutboundTransport, type Ob11OutboundWsReconnect, type Ob11TransportSet, type OneBot11AdapterOptions, OneBotApi, type OneBotApiOptions, type OneBotSystemOptions, type Sender, type Sex, type StrangerInfo, type VersionInfo, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
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-zpsm4o9D.mjs";
|
|
@@ -1357,7 +1357,7 @@ const httpPostSchema = z.object({
|
|
|
1357
1357
|
url: z.string().optional(),
|
|
1358
1358
|
/** 实例级 token,覆盖全局 token(缺省继承全局)。 */
|
|
1359
1359
|
token: z.string().optional(),
|
|
1360
|
-
/**
|
|
1360
|
+
/** 上报超时(毫秒,含排队),缺省 5 秒。 */
|
|
1361
1361
|
timeoutMs: z.number().int().optional()
|
|
1362
1362
|
});
|
|
1363
1363
|
/** 反向 WS server 实例(第三方 WS 连入,带 WS ping 间隔扩展字段)。 */
|
|
@@ -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
|
}
|
|
@@ -3747,7 +3764,7 @@ function assembleOb11Transports(opts) {
|
|
|
3747
3764
|
const outbound = [];
|
|
3748
3765
|
assembleHttpServers(config, handleRequest, servers);
|
|
3749
3766
|
assembleWsServers(config, handleRequest, servers);
|
|
3750
|
-
assembleHttpPosts(
|
|
3767
|
+
assembleHttpPosts(opts, transports, outbound);
|
|
3751
3768
|
assembleWsReverses(config, selfUin, handleRequest, transports, outbound);
|
|
3752
3769
|
for (const t of transports) broadcaster.register(t);
|
|
3753
3770
|
for (const s of servers) broadcaster.register(s);
|
|
@@ -3756,8 +3773,9 @@ function assembleOb11Transports(opts) {
|
|
|
3756
3773
|
transports,
|
|
3757
3774
|
outbound,
|
|
3758
3775
|
close: async () => {
|
|
3759
|
-
|
|
3760
|
-
for (const t of
|
|
3776
|
+
const adapters = [...servers, ...transports];
|
|
3777
|
+
for (const t of adapters) broadcaster.unregister(t);
|
|
3778
|
+
await Promise.all(adapters.map((t) => t.close()));
|
|
3761
3779
|
}
|
|
3762
3780
|
};
|
|
3763
3781
|
}
|
|
@@ -3797,15 +3815,21 @@ function assembleWsServers(config, handleRequest, servers) {
|
|
|
3797
3815
|
}
|
|
3798
3816
|
}
|
|
3799
3817
|
/** 装配 HTTP 正向上报 client 列表(fire-and-forget)。 */
|
|
3800
|
-
function assembleHttpPosts(config, selfUin, transports, outbound) {
|
|
3801
|
-
for (const item of config.httpPostUrls) if (item.enabled && item.url !== void 0) {
|
|
3818
|
+
function assembleHttpPosts({ config, selfUin, logger }, transports, outbound) {
|
|
3819
|
+
for (const [index, item] of config.httpPostUrls.entries()) if (item.enabled && item.url !== void 0) {
|
|
3802
3820
|
const headers = {
|
|
3803
3821
|
"x-self-id": selfUin,
|
|
3804
3822
|
...authorizeHeader(item.token ?? config.token) ?? {}
|
|
3805
3823
|
};
|
|
3806
3824
|
const options = {
|
|
3807
3825
|
url: item.url,
|
|
3808
|
-
headers
|
|
3826
|
+
headers,
|
|
3827
|
+
onError: () => {
|
|
3828
|
+
logger?.warn({
|
|
3829
|
+
category: "webhook_delivery_failed",
|
|
3830
|
+
index
|
|
3831
|
+
}, "onebot11: webhook 推送失败");
|
|
3832
|
+
}
|
|
3809
3833
|
};
|
|
3810
3834
|
if (item.timeoutMs !== void 0) options.timeoutMs = item.timeoutMs;
|
|
3811
3835
|
const client = new HttpClient(options);
|
|
@@ -3916,6 +3940,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3916
3940
|
config,
|
|
3917
3941
|
broadcaster,
|
|
3918
3942
|
selfUin: this.selfUin,
|
|
3943
|
+
logger: this.logger,
|
|
3919
3944
|
handleRequest: (req, respond) => {
|
|
3920
3945
|
this.handleRequest(req, respond).catch((err) => {
|
|
3921
3946
|
let message = String(err);
|
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.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for Napuketto",
|
|
7
7
|
"keywords": [
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"dev": "tsdown --watch"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@napuketto/kernel": "^0.19.
|
|
85
|
+
"@napuketto/kernel": "^0.19.7",
|
|
86
86
|
"@napuketto/media": "^0.4.1",
|
|
87
|
-
"@napuketto/network": "^0.
|
|
87
|
+
"@napuketto/network": "^0.6.0",
|
|
88
88
|
"zod": "^4.6.7"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|