@napuketto/adapter 0.18.7 → 0.18.9
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-BHS4Wz74.d.mts → index-xj5Z4aAN.d.mts} +35 -3
- package/dist/{index-BHS4Wz74.d.mts.map → index-xj5Z4aAN.d.mts.map} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/onebot11/index.d.mts +2 -2
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-DC30T-Co.mjs → onebot11-DCnfgVdx.mjs} +132 -8
- package/dist/onebot11-DCnfgVdx.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/onebot11-DC30T-Co.mjs.map +0 -1
|
@@ -763,12 +763,16 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
763
763
|
readonly protocol = "onebot11";
|
|
764
764
|
private readonly selfUin;
|
|
765
765
|
private readonly oneBotApi;
|
|
766
|
+
/** 校准日志(传输首连失败 / 重试留痕;缺省静默)。 */
|
|
767
|
+
private readonly logger;
|
|
766
768
|
/** 动作注册表(公共只读:IPC 桥等装配方枚举动作名直接挂载)。 */
|
|
767
769
|
readonly registry: ReturnType<typeof createOb11ActionRegistry>;
|
|
768
770
|
/** 收链路事件管道(订阅 / 过滤 / 翻译派发,拆出)。 */
|
|
769
771
|
private readonly pipeline;
|
|
770
772
|
private transports;
|
|
771
773
|
private heartbeatTimer;
|
|
774
|
+
/** 出向传输后台重连取消函数(stop / reload 时统一清理,issue #144)。 */
|
|
775
|
+
private outboundCancels;
|
|
772
776
|
/** IPC 桥模式标记(subscribeOnly 启动;reload 时跳过传输重建)。 */
|
|
773
777
|
private subscribedOnly;
|
|
774
778
|
constructor(opts: OneBot11AdapterOptions);
|
|
@@ -779,9 +783,17 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
779
783
|
private reloadTransports;
|
|
780
784
|
/** 启动传输:装配(HTTP/WS)+ 打开 server/client + 广播 lifecycle enable + 起心跳。 */
|
|
781
785
|
private startTransports;
|
|
786
|
+
/**
|
|
787
|
+
* 打开出向传输(issue #144)。反向 server 绑定失败仍按装配失败处理(配置/端口
|
|
788
|
+
* 问题),但正向 WS 对端未启动/不可达只 warn + 后台按 reconnect 策略重试:
|
|
789
|
+
* 已登录成功的 QQ 宿主不得因为外部 WS 服务缺席而崩溃退出。
|
|
790
|
+
*/
|
|
791
|
+
private openOutboundTransports;
|
|
792
|
+
/** 取消出向传输的后台重连(stop / reload 重建时,幂等)。 */
|
|
793
|
+
private cancelOutboundOpens;
|
|
782
794
|
/** 心跳 meta 事件(interval 毫秒,0 关闭;启动前清理残留定时器防重复)。 */
|
|
783
795
|
private startHeartbeat;
|
|
784
|
-
/** 停止:心跳 + 传输 +
|
|
796
|
+
/** 停止:心跳 + 传输 + 退订(含取消出向传输的后台重连)。 */
|
|
785
797
|
private stopAll;
|
|
786
798
|
/**
|
|
787
799
|
* 仅启动接收链路(IPC 桥模式):订阅消息通道维护 messageUnique +
|
|
@@ -794,12 +806,32 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
794
806
|
/** 请求分发(挂到 transport 的 onRequest):{ action, params, echo } → 注册表分发。 */
|
|
795
807
|
handleRequest(req: unknown, respond: (res: unknown) => void): Promise<void>;
|
|
796
808
|
}
|
|
809
|
+
/** 正向 WS client 首连失败的后台重连参数(HTTP 上报无连接,不参与)。 */
|
|
810
|
+
interface Ob11OutboundWsReconnect {
|
|
811
|
+
/** 对端地址(日志标识 + 同配置内唯一)。 */
|
|
812
|
+
url: string;
|
|
813
|
+
/** 首次重连延迟(毫秒;后续按 2 倍指数退避)。 */
|
|
814
|
+
delayMs: number;
|
|
815
|
+
/** 最大重连次数(不含首连);缺省无限。 */
|
|
816
|
+
maxAttempts?: number | undefined;
|
|
817
|
+
}
|
|
818
|
+
/** 出向传输(事件上报 / 正向 WS),`open` 由适配器统一发起。 */
|
|
819
|
+
interface Ob11OutboundTransport {
|
|
820
|
+
transport: TransportAdapter;
|
|
821
|
+
/** 正向 WS 的重连参数(首连失败后台重试);HTTP 上报为 undefined。 */
|
|
822
|
+
wsReconnect?: Ob11OutboundWsReconnect | undefined;
|
|
823
|
+
}
|
|
797
824
|
/** 传输装配结果。 */
|
|
798
825
|
interface Ob11TransportSet {
|
|
799
826
|
/** 反向 server(HTTP/WS,第三方调用入口)。 */
|
|
800
827
|
servers: TransportAdapter[];
|
|
801
828
|
/** 事件上报传输(正向 client,已注册到 broadcaster)。 */
|
|
802
829
|
transports: TransportAdapter[];
|
|
830
|
+
/**
|
|
831
|
+
* 出向传输的启动清单(issue #144):与 `transports` 同源,额外携带正向 WS
|
|
832
|
+
* 首连失败所需的后台重连参数——适配器据此容错,不因对端未启动而中断装配。
|
|
833
|
+
*/
|
|
834
|
+
outbound: Ob11OutboundTransport[];
|
|
803
835
|
/** 停止:关闭全部传输(幂等)。 */
|
|
804
836
|
close: () => Promise<void>;
|
|
805
837
|
}
|
|
@@ -816,5 +848,5 @@ interface AssembleOb11TransportsOptions {
|
|
|
816
848
|
}
|
|
817
849
|
/** 按配置装配 OB11 传输。 */
|
|
818
850
|
declare function assembleOb11Transports(opts: AssembleOb11TransportsOptions): Ob11TransportSet;
|
|
819
|
-
export {
|
|
820
|
-
//# sourceMappingURL=index-
|
|
851
|
+
export { OB11MessageInfo as $, serializeCqParts as A, canonicalToCqMessage as B, ob11ConfigSchema as C, escapeCqParam as D, encodeCqCode as E, ob11ErrorCodeMap as F, CurrentTalkative as G, cqMessageToCanonical as H, OneBotApi as I, GroupInfo as J, FriendInfo as K, OneBotApiOptions as L, Ob11ActionDeps as M, createOb11ActionRegistry as N, escapeCqText as O, AtAllRemainInfo as P, OB11Message as Q, OneBotSystemOptions as R, OB11Config as S, CqCode as T, cqMessageToSegments as U, canonicalToSegments as V, segmentsToCanonical as W, HonorMember as X, GroupMemberInfo as Y, LoginInfo as Z, OB11GroupMessageEvent as _, assembleOb11Transports as a, VersionInfo as at, OB11BaseEvent as b, OB11Event as c, OB11RequestEvent as d, OB11MessageSegment as et, OB11NoticeEvent as f, OB11Status as g, OB11MetaEvent as h, Ob11TransportSet as i, StrangerInfo as it, unescapeCqText as j, parseCqMessage as k, OB11FriendRequestEvent as l, OB11LifecycleMetaEvent as m, Ob11OutboundTransport as n, Sender as nt, NapukettoOneBot11Adapter as o, OB11HeartbeatMetaEvent as p, GroupHonorInfo as q, Ob11OutboundWsReconnect as r, Sex as rt, OneBot11AdapterOptions as s, AssembleOb11TransportsOptions as t, OB11Return as tt, OB11GroupRequestEvent as u, OB11MessageEvent as v, segmentsToCqMessage as w, OB11PostType as x, OB11PrivateMessageEvent as y, MessageUnique as z };
|
|
852
|
+
//# sourceMappingURL=index-xj5Z4aAN.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-xj5Z4aAN.d.mts","names":["MessageEventUnion","NoticeEventUnion","RequestEventUnion","MetaEventUnion","ConfigBase"],"sources":["../src/onebot11/types/index.ts","../src/onebot11/helper/data.ts","../src/onebot11/helper/message-unique.ts","../src/onebot11/api/onebot-api.ts","../src/onebot11/action/base-action.ts","../src/onebot11/action/group/query.ts","../src/onebot11/action/index.ts","../src/onebot11/helper/codec/cqcode.ts","../src/onebot11/helper/codec/segment.ts","../src/onebot11/helper/config.ts","../src/onebot11/event/base.ts","../src/onebot11/event/message.ts","../src/onebot11/event/meta.ts","../src/onebot11/event/notice.ts","../src/onebot11/event/request.ts","../src/onebot11/event/index.ts","../src/onebot11/adapter.ts","../src/onebot11/transport.ts"],"mappings":";;;;;;;;;;UAMiB,WAAW;EACxB;EACA;EACA,MAAM;EACN;EACA;;;KAIQ;EACJ;EAAc;IAAQ;;;EACtB;EAAY;IAAQ;IAAY;;;EAChC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;IAAc;;;EACrC;EAAgB;IAAQ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AEA;;EAEA,WAAW;;;UCPE;EACb;EACA;EACA;;;UAIa,oBAAoB;EACjC;EACA;;;UAIa,8BAA8B;EAC3C;EACA;;EAEA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA,QAAQ;EACR,YAAY;;;UAIC,gCAAgC;EAC7C;EACA;;EAEA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA,QAAQ;;EAER;;;KAIQ,mBAAmB,wBAAwB;;UC9CtC;EACb;EACA;GACC;;;UAIY,+BAA+B;EAC5C;EACA;EACA;;;UAIa,+BAA+B;EAC5C;EACA;;EAEA;EACA,QAAQ;;;KAIA,gBAAgB,yBAAyB;;UCvBpC;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA;EACA,MAAM;;;UAIO,kCAAkC;EAC/C;EACA;EACA;EACA;EACA;;;UAIa,qCAAqC;EAClD;EACA;EACA;EACA;EACA;EACA;;;UAIa,qCAAqC;EAClD;EACA;EACA;EACA;EACA;EACA;;;UAIa,gCAAgC;EAC7C;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIa,iCAAiC;EAC9C;EACA;EACA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA;EACA;EACA;;;UAIa,oCAAoC;EACjD;EACA;EACA;EACA;;;UAIa,iCAAiC;EAC9C;EACA;EACA;EACA;EACA;EACA;;;;;;;UAQa,oCAAoC;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIa,8BAA8B;EAC3C;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA,MAAM;;;UAIO,iCAAiC;EAC9C;EACA;EACA;EACA;;;UAIa,oCAAoC;EACjD;EACA;EACA;EACA;EACA;EACA,OAAO;;;UAIM,kCAAkC;EAC/C;EACA;EACA;EACA;EACA;;;KAIQ,kBACN,6BACA,4BACA,+BACA,+BACA,0BACA,2BACA,6BACA,8BACA,2BACA,8BACA,wBACA,6BACA,2BACA,8BACA;;UCxLW,+BAA+B;EAC5C;EACA;EACA;;EAEA;;EAEA;;;UAIa,8BAA8B;EAC3C;EACA;;EAEA;EACA;EACA;EACA;EACA;;;KAIQ,mBAAmB,yBAAyB;;KCiB5C,YAAYA,mBAAoBC,kBAAmBC,mBAAoBC;;UCjBlE,+BAA+B;;;;;EAK5C,SAASC,aAAW,cAAc,QAAQ;;EAE1C,cAAc;;EAEd,YAAY;;EAEZ,eAAe;;EAEf,gBAAgB;;EAEhB,mBAAmB;;EAEnB,SAAS;;;cAIA,iCAAiC,oBAAoB;WACrD;mBAEQ;mBACA;;mBAEA;;WAER,UAAU,kBAAkB;;mBAEpB;UACT;UACA;;UAEA;;UAEA;EAER,YAAY,MAAM;;;;;UAqCJ;;UAUA;;;;;;UA+CA;;UA0BN;;UAQA;;UAoBM;;;;;;EAkBR,iBAAiB;;EAQvB;;EAMM,cAAc,cAAc,UAAU,wBAAwB;;;UCnOvD;;EAEb;;EAEA;;EAEA;;;UAIa;EACb,WAAW;;EAEX,cAAc;;;UAID;;EAEb,SAAS;;EAET,YAAY;;;;;EAKZ,UAAU;;EAEV,aAAa;;;UAIA;;EAEb,QAAQ;;EAER,aAAa;;EAEb,gBAAgB,cAAc,UAAU;;EAExC;;;iBAiBY,uBAAuB,MAAM,gCAAgC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,6 @@
|
|
|
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-BZfGz6FA.mjs";
|
|
19
19
|
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-oinf9f75.mjs";
|
|
20
20
|
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-BlRIp4xi.mjs";
|
|
21
|
-
import {
|
|
21
|
+
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-xj5Z4aAN.mjs";
|
|
22
22
|
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-BFvhy1hU.mjs";
|
|
23
23
|
export { type ActionKernelSpec, type ActionOutcome, ActionRegistry, BaseProtocolAdapter, ConfigBase, type ConfigFormat, type ConfigOptions, type ConfigSchema, type ErrorCodeMap, type KurobotAdapterOptions, type KurobotConfig, type MilkyAdapterOptions, type MilkyConfig, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, type OB11Config, type OneBot11AdapterOptions, ProtocolConfig, type ProtocolHooks, type SatoriAdapterOptions, type SatoriConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as BaseProtocolAdapter, l as ActionRegistry, n as ProtocolConfig, r as createServerSchema, t as ConfigBase, u as runAction } from "./framework-Br7Tfx20.mjs";
|
|
2
2
|
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-DWMzq93a.mjs";
|
|
3
3
|
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-BqEP4YO-.mjs";
|
|
4
|
-
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-DCnfgVdx.mjs";
|
|
5
5
|
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-CcscgMom.mjs";
|
|
6
6
|
export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as
|
|
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 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 };
|
|
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-xj5Z4aAN.mjs";
|
|
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-DCnfgVdx.mjs";
|
|
@@ -2918,6 +2918,84 @@ function createOb11ActionRegistry(deps) {
|
|
|
2918
2918
|
for (const factory of ACTION_FACTORIES) for (const action of factory(deps.api)) registry.register(action);
|
|
2919
2919
|
return registry;
|
|
2920
2920
|
}
|
|
2921
|
+
// src/internal/infra/outbound-open.ts
|
|
2922
|
+
/**
|
|
2923
|
+
* 出向传输首连容错(issue #144)
|
|
2924
|
+
*
|
|
2925
|
+
* 背景:`network.WsClient.open()` 的契约是「首连失败即 reject,不自动重试」
|
|
2926
|
+
* (重连只覆盖已建立连接后的断线,见 `WsClient.onClose`)。协议装配层若直接
|
|
2927
|
+
* `await client.open()`,对端 WS 服务暂时未启动/不可达(ECONNREFUSED、
|
|
2928
|
+
* ENOTFOUND host.docker.internal)就会让整个 `startProtocols` 抛错 →
|
|
2929
|
+
* `self-host` exit 1,已登录成功的 QQ 宿主被一个外部服务拖死。
|
|
2930
|
+
*
|
|
2931
|
+
* 本模块在 adapter 层补足容错:首连失败只记 warn,并在后台按指数退避重试,
|
|
2932
|
+
* 不阻塞协议装配、不影响宿主运行;`stop()` 时经返回的取消函数清掉定时器。
|
|
2933
|
+
* 底层 `WsClient.open()` 失败语义保持不变(network 单测契约不动)。
|
|
2934
|
+
*
|
|
2935
|
+
* 退避从配置的 `reconnectDelayMs` 起按 2 倍递增并封顶(60s),与 supervisor
|
|
2936
|
+
* 的子进程重启退避同一思路;连接建立后的断线仍由 `WsClient` 自己的 reconnect
|
|
2937
|
+
* 策略处理,两者不重叠。
|
|
2938
|
+
*/
|
|
2939
|
+
/** 后台重连延迟上限(毫秒)。 */
|
|
2940
|
+
const MAX_RETRY_DELAY_MS = 6e4;
|
|
2941
|
+
/**
|
|
2942
|
+
* 打开出向传输(首连失败不抛出):失败后 warn + 后台退避重试。
|
|
2943
|
+
* @returns 取消函数(`stop()` / 热更新重建传输时调用,清定时器且不再重试)
|
|
2944
|
+
*/
|
|
2945
|
+
function openOutboundWithRetry(transport, opts) {
|
|
2946
|
+
let stopped = false;
|
|
2947
|
+
/** 已安排的重试次数(不含首连)。 */
|
|
2948
|
+
let attempt = 0;
|
|
2949
|
+
let timer;
|
|
2950
|
+
const baseDelayMs = Math.max(opts.delayMs, 1);
|
|
2951
|
+
const scheduleRetry = () => {
|
|
2952
|
+
if (stopped) return;
|
|
2953
|
+
if (opts.maxAttempts !== void 0 && attempt >= opts.maxAttempts) {
|
|
2954
|
+
opts.logger?.warn({
|
|
2955
|
+
label: opts.label,
|
|
2956
|
+
attempts: attempt
|
|
2957
|
+
}, "出向传输仍不可达,已达最大重连次数,停止重试(宿主继续运行)");
|
|
2958
|
+
return;
|
|
2959
|
+
}
|
|
2960
|
+
const delayMs = Math.min(baseDelayMs * 2 ** attempt, MAX_RETRY_DELAY_MS);
|
|
2961
|
+
attempt += 1;
|
|
2962
|
+
timer = setTimeout(() => {
|
|
2963
|
+
timer = void 0;
|
|
2964
|
+
tryOpen();
|
|
2965
|
+
}, delayMs);
|
|
2966
|
+
};
|
|
2967
|
+
const tryOpen = async () => {
|
|
2968
|
+
if (stopped) return;
|
|
2969
|
+
try {
|
|
2970
|
+
await transport.open();
|
|
2971
|
+
} catch (err) {
|
|
2972
|
+
if (stopped) return;
|
|
2973
|
+
opts.logger?.warn({
|
|
2974
|
+
err: errorMessage(err),
|
|
2975
|
+
label: opts.label,
|
|
2976
|
+
retry: attempt + 1
|
|
2977
|
+
}, "出向传输连接失败,后台按重连策略重试(不影响宿主运行)");
|
|
2978
|
+
scheduleRetry();
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
if (stopped) try {
|
|
2982
|
+
await transport.close();
|
|
2983
|
+
} catch (err) {
|
|
2984
|
+
opts.logger?.warn({
|
|
2985
|
+
err: errorMessage(err),
|
|
2986
|
+
label: opts.label
|
|
2987
|
+
}, "取消后关闭出向传输失败");
|
|
2988
|
+
}
|
|
2989
|
+
};
|
|
2990
|
+
tryOpen();
|
|
2991
|
+
return () => {
|
|
2992
|
+
stopped = true;
|
|
2993
|
+
if (timer !== void 0) {
|
|
2994
|
+
clearTimeout(timer);
|
|
2995
|
+
timer = void 0;
|
|
2996
|
+
}
|
|
2997
|
+
};
|
|
2998
|
+
}
|
|
2921
2999
|
// src/onebot11/api/onebot-api.ts
|
|
2922
3000
|
/**
|
|
2923
3001
|
* OneBot 11 动作统一依赖聚合。
|
|
@@ -3673,15 +3751,17 @@ function assembleOb11Transports(opts) {
|
|
|
3673
3751
|
const { config, broadcaster, handleRequest, selfUin } = opts;
|
|
3674
3752
|
const servers = [];
|
|
3675
3753
|
const transports = [];
|
|
3754
|
+
const outbound = [];
|
|
3676
3755
|
assembleHttpServers(config, handleRequest, servers);
|
|
3677
3756
|
assembleWsServers(config, handleRequest, servers);
|
|
3678
|
-
assembleHttpPosts(config, selfUin, transports);
|
|
3679
|
-
assembleWsReverses(config, selfUin, handleRequest, transports);
|
|
3757
|
+
assembleHttpPosts(config, selfUin, transports, outbound);
|
|
3758
|
+
assembleWsReverses(config, selfUin, handleRequest, transports, outbound);
|
|
3680
3759
|
for (const t of transports) broadcaster.register(t);
|
|
3681
3760
|
for (const s of servers) broadcaster.register(s);
|
|
3682
3761
|
return {
|
|
3683
3762
|
servers,
|
|
3684
3763
|
transports,
|
|
3764
|
+
outbound,
|
|
3685
3765
|
close: async () => {
|
|
3686
3766
|
await Promise.all([...servers, ...transports].map((t) => t.close()));
|
|
3687
3767
|
for (const t of [...servers, ...transports]) broadcaster.unregister(t);
|
|
@@ -3724,7 +3804,7 @@ function assembleWsServers(config, handleRequest, servers) {
|
|
|
3724
3804
|
}
|
|
3725
3805
|
}
|
|
3726
3806
|
/** 装配 HTTP 正向上报 client 列表(fire-and-forget)。 */
|
|
3727
|
-
function assembleHttpPosts(config, selfUin, transports) {
|
|
3807
|
+
function assembleHttpPosts(config, selfUin, transports, outbound) {
|
|
3728
3808
|
for (const item of config.httpPostUrls) if (item.enabled && item.url !== void 0) {
|
|
3729
3809
|
const headers = {
|
|
3730
3810
|
"x-self-id": selfUin,
|
|
@@ -3735,11 +3815,13 @@ function assembleHttpPosts(config, selfUin, transports) {
|
|
|
3735
3815
|
headers
|
|
3736
3816
|
};
|
|
3737
3817
|
if (item.timeoutMs !== void 0) options.timeoutMs = item.timeoutMs;
|
|
3738
|
-
|
|
3818
|
+
const client = new HttpClient(options);
|
|
3819
|
+
transports.push(client);
|
|
3820
|
+
outbound.push({ transport: client });
|
|
3739
3821
|
}
|
|
3740
3822
|
}
|
|
3741
3823
|
/** 装配正向 WS client 列表(双向,心跳 + 重连 + 证书选项)。 */
|
|
3742
|
-
function assembleWsReverses(config, selfUin, handleRequest, transports) {
|
|
3824
|
+
function assembleWsReverses(config, selfUin, handleRequest, transports, outbound) {
|
|
3743
3825
|
for (const item of config.wsReverseUrls) if (item.enabled && item.url !== void 0) {
|
|
3744
3826
|
const headers = {
|
|
3745
3827
|
...oneBotClientHeaders(selfUin),
|
|
@@ -3760,6 +3842,14 @@ function assembleWsReverses(config, selfUin, handleRequest, transports) {
|
|
|
3760
3842
|
const client = new WsClient(options);
|
|
3761
3843
|
client.onRequest = handleRequest;
|
|
3762
3844
|
transports.push(client);
|
|
3845
|
+
outbound.push({
|
|
3846
|
+
transport: client,
|
|
3847
|
+
wsReconnect: {
|
|
3848
|
+
url: item.url,
|
|
3849
|
+
delayMs: item.reconnectDelayMs,
|
|
3850
|
+
...item.maxReconnectAttempts !== void 0 ? { maxAttempts: item.maxReconnectAttempts } : {}
|
|
3851
|
+
}
|
|
3852
|
+
});
|
|
3763
3853
|
}
|
|
3764
3854
|
}
|
|
3765
3855
|
/** token → Authorization 头(client 上报/连接用)。 */
|
|
@@ -3773,12 +3863,16 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3773
3863
|
protocol = "onebot11";
|
|
3774
3864
|
selfUin;
|
|
3775
3865
|
oneBotApi;
|
|
3866
|
+
/** 校准日志(传输首连失败 / 重试留痕;缺省静默)。 */
|
|
3867
|
+
logger;
|
|
3776
3868
|
/** 动作注册表(公共只读:IPC 桥等装配方枚举动作名直接挂载)。 */
|
|
3777
3869
|
registry;
|
|
3778
3870
|
/** 收链路事件管道(订阅 / 过滤 / 翻译派发,拆出)。 */
|
|
3779
3871
|
pipeline;
|
|
3780
3872
|
transports = null;
|
|
3781
3873
|
heartbeatTimer = null;
|
|
3874
|
+
/** 出向传输后台重连取消函数(stop / reload 时统一清理,issue #144)。 */
|
|
3875
|
+
outboundCancels = [];
|
|
3782
3876
|
/** IPC 桥模式标记(subscribeOnly 启动;reload 时跳过传输重建)。 */
|
|
3783
3877
|
subscribedOnly = false;
|
|
3784
3878
|
constructor(opts) {
|
|
@@ -3793,6 +3887,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3793
3887
|
}
|
|
3794
3888
|
});
|
|
3795
3889
|
this.selfUin = opts.self.uin;
|
|
3890
|
+
this.logger = opts.logger;
|
|
3796
3891
|
this.oneBotApi = new OneBotApi(opts);
|
|
3797
3892
|
this.pipeline = new Ob11EventPipeline({
|
|
3798
3893
|
selfUin: this.selfUin,
|
|
@@ -3843,7 +3938,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3843
3938
|
}
|
|
3844
3939
|
});
|
|
3845
3940
|
await Promise.all(this.transports.servers.map((s) => s.open()));
|
|
3846
|
-
await
|
|
3941
|
+
await this.openOutboundTransports();
|
|
3847
3942
|
}
|
|
3848
3943
|
this.pipeline.subscribe();
|
|
3849
3944
|
this.broadcastEvent({
|
|
@@ -3855,6 +3950,34 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3855
3950
|
});
|
|
3856
3951
|
this.startHeartbeat(config.heartbeatInterval);
|
|
3857
3952
|
}
|
|
3953
|
+
/**
|
|
3954
|
+
* 打开出向传输(issue #144)。反向 server 绑定失败仍按装配失败处理(配置/端口
|
|
3955
|
+
* 问题),但正向 WS 对端未启动/不可达只 warn + 后台按 reconnect 策略重试:
|
|
3956
|
+
* 已登录成功的 QQ 宿主不得因为外部 WS 服务缺席而崩溃退出。
|
|
3957
|
+
*/
|
|
3958
|
+
async openOutboundTransports() {
|
|
3959
|
+
if (this.transports === null) return;
|
|
3960
|
+
const immediate = [];
|
|
3961
|
+
for (const item of this.transports.outbound) {
|
|
3962
|
+
const reconnect = item.wsReconnect;
|
|
3963
|
+
if (reconnect === void 0) {
|
|
3964
|
+
immediate.push(Promise.resolve(item.transport.open()));
|
|
3965
|
+
continue;
|
|
3966
|
+
}
|
|
3967
|
+
this.outboundCancels.push(openOutboundWithRetry(item.transport, {
|
|
3968
|
+
label: `onebot11 正向 WS ${reconnect.url}`,
|
|
3969
|
+
delayMs: reconnect.delayMs,
|
|
3970
|
+
...reconnect.maxAttempts !== void 0 ? { maxAttempts: reconnect.maxAttempts } : {},
|
|
3971
|
+
...this.logger !== void 0 ? { logger: this.logger } : {}
|
|
3972
|
+
}));
|
|
3973
|
+
}
|
|
3974
|
+
await Promise.all(immediate);
|
|
3975
|
+
}
|
|
3976
|
+
/** 取消出向传输的后台重连(stop / reload 重建时,幂等)。 */
|
|
3977
|
+
cancelOutboundOpens() {
|
|
3978
|
+
for (const cancel of this.outboundCancels) cancel();
|
|
3979
|
+
this.outboundCancels = [];
|
|
3980
|
+
}
|
|
3858
3981
|
/** 心跳 meta 事件(interval 毫秒,0 关闭;启动前清理残留定时器防重复)。 */
|
|
3859
3982
|
startHeartbeat(intervalMs) {
|
|
3860
3983
|
if (intervalMs <= 0) return;
|
|
@@ -3873,12 +3996,13 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3873
3996
|
});
|
|
3874
3997
|
}, intervalMs);
|
|
3875
3998
|
}
|
|
3876
|
-
/** 停止:心跳 + 传输 +
|
|
3999
|
+
/** 停止:心跳 + 传输 + 退订(含取消出向传输的后台重连)。 */
|
|
3877
4000
|
async stopAll() {
|
|
3878
4001
|
if (this.heartbeatTimer !== null) {
|
|
3879
4002
|
clearInterval(this.heartbeatTimer);
|
|
3880
4003
|
this.heartbeatTimer = null;
|
|
3881
4004
|
}
|
|
4005
|
+
this.cancelOutboundOpens();
|
|
3882
4006
|
this.pipeline.unsubscribeAll();
|
|
3883
4007
|
if (this.transports !== null) {
|
|
3884
4008
|
await this.transports.close();
|
|
@@ -3945,4 +4069,4 @@ function echoFieldOf(req) {
|
|
|
3945
4069
|
}
|
|
3946
4070
|
export { unescapeCqText as _, canonicalToCqMessage as a, cqMessageToSegments as c, segmentsToCqMessage as d, encodeCqCode as f, serializeCqParts as g, parseCqMessage as h, createOb11ActionRegistry as i, segmentsToCanonical as l, escapeCqText as m, assembleOb11Transports as n, canonicalToSegments as o, escapeCqParam as p, OneBotApi as r, cqMessageToCanonical as s, NapukettoOneBot11Adapter as t, ob11ConfigSchema as u, ob11ErrorCodeMap as v, MessageUnique as y };
|
|
3947
4071
|
|
|
3948
|
-
//# sourceMappingURL=onebot11-
|
|
4072
|
+
//# sourceMappingURL=onebot11-DCnfgVdx.mjs.map
|