@napuketto/adapter 0.18.22 → 0.19.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/core/index.d.mts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/{framework-BbtmlUXJ.mjs → framework-CA3087JP.mjs} +35 -3
- package/dist/{index-BZfGz6FA.d.mts → index-BO1TgLTT.d.mts} +2 -2
- package/dist/{index-DrPCnj64.d.mts → index-C-pAiIuG.d.mts} +3 -4
- package/dist/{index-tljZ0fmt.d.mts → index-D93z0TYf.d.mts} +1 -2
- package/dist/{index-CKWWp8-H.d.mts → index-PWs-cVWe.d.mts} +1 -2
- package/dist/{index-oinf9f75.d.mts → index-tW3a05Du.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +5 -5
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-BUJkleqO.mjs → kurobot-8YrYipGI.mjs} +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-Dj45WP4r.mjs → milky-DTlPFEhN.mjs} +28 -49
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-CUK6blMn.mjs → onebot11-Bq0f2Tky.mjs} +9 -27
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-CDxpqL3l.mjs → satori-VkOP24Vc.mjs} +2 -3
- package/package.json +2 -2
package/dist/core/index.d.mts
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* 配置兼容:`ProtocolConfig` 是 `ConfigBase` 的历史别名(loader 动态 import
|
|
16
16
|
* 仍按该名字构造),保留导出避免运行期断链。
|
|
17
17
|
*/
|
|
18
|
-
import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, d as TokenAuthOptions, f as createTokenAuthorize, g as ActionOutcome, h as ActionKernelSpec, i as ConfigSchema, l as resolveProtocolConfig, m as ActionRegistry, n as ConfigFormat, o as createServerSchema, p as matchTokenCredential, r as ConfigOptions, s as BaseProtocolAdapter, t as ConfigBase, u as BEARER_PREFIX, v as runAction } from "../index-
|
|
18
|
+
import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, d as TokenAuthOptions, f as createTokenAuthorize, g as ActionOutcome, h as ActionKernelSpec, i as ConfigSchema, l as resolveProtocolConfig, m as ActionRegistry, n as ConfigFormat, o as createServerSchema, p as matchTokenCredential, r as ConfigOptions, s as BaseProtocolAdapter, t as ConfigBase, u as BEARER_PREFIX, v as runAction } from "../index-BO1TgLTT.mjs";
|
|
19
19
|
export { type ActionKernelSpec, type ActionOutcome, ActionRegistry, BEARER_PREFIX, BaseProtocolAdapter, ConfigBase, type ConfigFormat, type ConfigOptions, type ConfigSchema, type ErrorCodeMap, ProtocolConfig, type ProtocolHooks, type TokenAuthOptions, createServerSchema, createTokenAuthorize, matchTokenCredential, resolveProtocolConfig, runAction };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { f as ActionRegistry, c as BEARER_PREFIX, o as BaseProtocolAdapter, t as ConfigBase, n as ProtocolConfig, r as createServerSchema, l as createTokenAuthorize, u as matchTokenCredential, s as resolveProtocolConfig, p as runAction } from "../framework-CA3087JP.mjs";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigBase, ConfigBase as ConfigBase$1, ConfigBase as ProtocolConfig, isKernelError, isRecord } from "@napuketto/kernel";
|
|
2
2
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
3
3
|
import { EventBroadcaster } from "@napuketto/network";
|
|
4
|
+
import { isIP } from "node:net";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
// src/framework/action-kernel.ts
|
|
6
7
|
/**
|
|
@@ -107,8 +108,8 @@ function matchTokenCredential(ctx, token, opts) {
|
|
|
107
108
|
if (opts?.allowRawHeader === true && tokenEquals(auth, token)) return true;
|
|
108
109
|
if (opts?.allowQueryToken === true) try {
|
|
109
110
|
return tokenEquals(new URL(ctx.url, QUERY_BASE).searchParams.get("access_token"), token);
|
|
110
|
-
} catch
|
|
111
|
-
opts.onQueryParseError?.(
|
|
111
|
+
} catch {
|
|
112
|
+
opts.onQueryParseError?.();
|
|
112
113
|
return false;
|
|
113
114
|
}
|
|
114
115
|
return false;
|
|
@@ -248,6 +249,37 @@ var BaseProtocolAdapter = class {
|
|
|
248
249
|
* HTTP 反向服务器 / WS 事件服务器的实例级 schema 结构两协议一致,仅默认
|
|
249
250
|
* 端口与各协议扩展字段不同——单一工厂按默认端口生成,各协议按需调用。
|
|
250
251
|
*/
|
|
252
|
+
const PLACEHOLDER_TOKENS = /* @__PURE__ */ new Set([
|
|
253
|
+
"change-me",
|
|
254
|
+
"changeme",
|
|
255
|
+
"replace_with_random_token"
|
|
256
|
+
]);
|
|
257
|
+
const MAPPED_IPV4_LOOPBACK = /^\[::ffff:7f[\da-f]{2}:[\da-f]{1,4}\]$/;
|
|
258
|
+
/** 只信任可在校验时确认的回环 IP。主机名的最终绑定由运行环境解析。 */
|
|
259
|
+
function isLoopbackHost(host) {
|
|
260
|
+
const family = isIP(host);
|
|
261
|
+
if (family === 4) return host.startsWith("127.");
|
|
262
|
+
if (family !== 6 || host.includes("%")) return false;
|
|
263
|
+
const { hostname } = new URL(`http://[${host}]`);
|
|
264
|
+
return hostname === "[::1]" || MAPPED_IPV4_LOOPBACK.test(hostname);
|
|
265
|
+
}
|
|
266
|
+
function validateListenerToken(host, token, ctx, path) {
|
|
267
|
+
if (isLoopbackHost(host)) return;
|
|
268
|
+
const value = token?.trim().toLowerCase();
|
|
269
|
+
if (!value || PLACEHOLDER_TOKENS.has(value)) ctx.addIssue({
|
|
270
|
+
code: "custom",
|
|
271
|
+
path,
|
|
272
|
+
message: "非回环监听要求有效 token。请设置随机 token(实例可继承协议级 token),或仅供可信本机使用时改绑 127.0.0.1 / ::1。"
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/** 对启用的实例使用与装配相同的 token 覆盖规则。 */
|
|
276
|
+
function validateServerTokens(config, ctx) {
|
|
277
|
+
for (const key of ["httpServers", "wsServers"]) for (const [index, item] of config[key].entries()) if (item.enabled) validateListenerToken(item.host, item.token ?? config.token, ctx, [
|
|
278
|
+
key,
|
|
279
|
+
index,
|
|
280
|
+
"token"
|
|
281
|
+
]);
|
|
282
|
+
}
|
|
251
283
|
/**
|
|
252
284
|
* 传输实例 schema(enabled/host/port/token 骨架;HTTP 反向服务器与 WS 事件
|
|
253
285
|
* 服务器共用同一结构,OB11 / Satori 仅默认端口不同)。
|
|
@@ -261,4 +293,4 @@ function createServerSchema(defaultPort) {
|
|
|
261
293
|
token: z.string().optional()
|
|
262
294
|
});
|
|
263
295
|
}
|
|
264
|
-
export {
|
|
296
|
+
export { validateServerTokens as a, BEARER_PREFIX as c, tokenEquals as d, ActionRegistry as f, validateListenerToken as i, createTokenAuthorize as l, ProtocolConfig as n, BaseProtocolAdapter as o, runAction as p, createServerSchema as r, resolveProtocolConfig as s, ConfigBase$1 as t, matchTokenCredential as u };
|
|
@@ -56,8 +56,8 @@ interface TokenAuthOptions {
|
|
|
56
56
|
allowQueryToken?: boolean | undefined;
|
|
57
57
|
/** 是否允许裸 authorization 头直接等于 token(OB11 兼容,默认 false)。 */
|
|
58
58
|
allowRawHeader?: boolean | undefined;
|
|
59
|
-
/** 查询参数 URL
|
|
60
|
-
onQueryParseError?: ((
|
|
59
|
+
/** 查询参数 URL 解析失败通知,避免诊断路径携带请求原文。 */
|
|
60
|
+
onQueryParseError?: (() => void) | undefined;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* 请求凭据匹配(头优先,查询参数兜底)。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ErrorCodeMap, m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-
|
|
1
|
+
import { _ as ErrorCodeMap, m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BO1TgLTT.mjs";
|
|
2
2
|
import { n as AdapterLoggerLike, t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
3
3
|
import "./gray-tip-CcpfI1Og.mjs";
|
|
4
4
|
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
@@ -438,7 +438,6 @@ declare function parseCqMessage(text: string): Array<string | CqCode>;
|
|
|
438
438
|
declare function serializeCqParts(parts: Array<string | CqCode>): string;
|
|
439
439
|
/** OB11 segment 数组 → CQ 码字符串(text 段转义拼接,特殊段编码)。 */
|
|
440
440
|
declare function segmentsToCqMessage(segments: OB11MessageSegment[]): string;
|
|
441
|
-
/** OB11 配置 schema。 */
|
|
442
441
|
declare const ob11ConfigSchema: z.ZodObject<{
|
|
443
442
|
token: z.ZodOptional<z.ZodString>;
|
|
444
443
|
heartbeatInterval: z.ZodDefault<z.ZodNumber>;
|
|
@@ -810,8 +809,8 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
810
809
|
}
|
|
811
810
|
/** 正向 WS client 首连失败的后台重连参数(HTTP 上报无连接,不参与)。 */
|
|
812
811
|
interface Ob11OutboundWsReconnect {
|
|
813
|
-
/**
|
|
814
|
-
|
|
812
|
+
/** 配置项序号,用于定位日志。 */
|
|
813
|
+
index: number;
|
|
815
814
|
/** 首次重连延迟(毫秒;后续按 2 倍指数退避)。 */
|
|
816
815
|
delayMs: number;
|
|
817
816
|
/** 最大重连次数(不含首连);缺省无限。 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-
|
|
1
|
+
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BO1TgLTT.mjs";
|
|
2
2
|
import { n as AdapterLoggerLike, t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
3
3
|
import "./gray-tip-CcpfI1Og.mjs";
|
|
4
4
|
import { CanonicalElement, FriendApi, GroupApi, GroupCache, GroupNotifyApi, KernelErrorCode, MsgApi, MsgEventChannel, Peer, ProfileApi } from "@napuketto/kernel";
|
|
@@ -105,7 +105,6 @@ interface SatoriActionDeps {
|
|
|
105
105
|
type SatoriActionRegistry = ActionRegistry<SatoriActionHandler<unknown, unknown>>;
|
|
106
106
|
/** 创建 Satori 动作注册表。 */
|
|
107
107
|
declare function createSatoriActionRegistry(deps: SatoriActionDeps): SatoriActionRegistry;
|
|
108
|
-
/** Satori 配置 schema。 */
|
|
109
108
|
declare const satoriConfigSchema: z.ZodObject<{
|
|
110
109
|
token: z.ZodOptional<z.ZodString>;
|
|
111
110
|
cacheDir: z.ZodOptional<z.ZodString>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-
|
|
1
|
+
import { m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BO1TgLTT.mjs";
|
|
2
2
|
import { t as MediaCache } from "./media-cache-C_0C9eCV.mjs";
|
|
3
3
|
import { BuddyEventChannel, ChatType, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, KernelErrorCode, LoginEventChannel, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RawMessage, RecentContactApi, RecentContactEventChannel, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
4
4
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
@@ -68,7 +68,6 @@ declare class MessageSeqIndex {
|
|
|
68
68
|
/** FIFO 淘汰到容量上限内。 */
|
|
69
69
|
private evict;
|
|
70
70
|
}
|
|
71
|
-
/** Milky 配置 schema。 */
|
|
72
71
|
declare const milkyConfigSchema: z.ZodObject<{
|
|
73
72
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
74
73
|
host: z.ZodDefault<z.ZodString>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-
|
|
1
|
+
import { s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BO1TgLTT.mjs";
|
|
2
2
|
import { CanonicalElement, MsgEventChannel, Peer, RawMessage } from "@napuketto/kernel";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
/** kurobot 配置 schema。 */
|
package/dist/index.d.mts
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* 子路径导出(./core、./onebot11、./satori、./kurobot、./milky)保持不变;
|
|
16
16
|
* 本文件只追加聚合,不改变任何子路径的解析结果。
|
|
17
17
|
*/
|
|
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-
|
|
19
|
-
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-
|
|
20
|
-
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-
|
|
21
|
-
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-
|
|
22
|
-
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-
|
|
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
|
+
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-tW3a05Du.mjs";
|
|
20
|
+
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-PWs-cVWe.mjs";
|
|
21
|
+
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-C-pAiIuG.mjs";
|
|
22
|
+
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-D93z0TYf.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
|
-
import {
|
|
2
|
-
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-
|
|
3
|
-
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-
|
|
4
|
-
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-
|
|
5
|
-
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-
|
|
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
|
+
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-8YrYipGI.mjs";
|
|
3
|
+
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-DTlPFEhN.mjs";
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-Bq0f2Tky.mjs";
|
|
5
|
+
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-VkOP24Vc.mjs";
|
|
6
6
|
export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
package/dist/kurobot/index.d.mts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* kurobot 协议适配器(KuroBot MVP-3)
|
|
3
3
|
* 公共面:镜像协议 schema + 配置 schema + 连接层 + 适配器。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as wireFrameSchema, A as PROTOCOL_NAME, B as encodeFrame, C as CommandResultBody, D as HelloBody, E as HelloAckBody, F as WS_SUBPROTOCOL, G as joinFrame, H as helloAckFrame, I as bindingsUpdatedFrame, J as platformChatFrame, K as leaveFrame, L as commandFrame, M as PlatformChatBody, N as QueryResultBody, O as JoinBody, P as StatusBody, Q as statusFrame, R as commandResultFrame, S as CommandFrame, T as GameChatBody, U as helloFrame, V as gameChatFrame, W as isProtocolVersionCompatible, X as queryFrame, Y as pongFrame, Z as queryResultFrame, _ as KurobotHello, a as renderDeathText, b as BindingsUpdatedBody, c as truncateForGroup, d as KurobotConnFace, et as KurobotConfig, f as KurobotMsgApi, g as KurobotConnectionOptions, h as KurobotConnection, i as renderCommandResult, j as PROTOCOL_VERSION, k as LeaveBody, l as KurobotAdapterOptions, m as ConnectionEndedReason, n as degradeElements, nt as kurobotConfigSchema, o as renderTemplate, p as ReceiveLogFilterHolder, q as pingFrame, r as degradeMessage, s as resolveSenderName, t as MAX_GROUP_TEXT_LENGTH, tt as kurobotConfigDefaults, u as NapukettoKurobotAdapter, v as KurobotLogger, w as DeathBody, x as CommandBody, y as ServerEventMessage, z as deathFrame } from "../index-
|
|
5
|
+
import { $ as wireFrameSchema, A as PROTOCOL_NAME, B as encodeFrame, C as CommandResultBody, D as HelloBody, E as HelloAckBody, F as WS_SUBPROTOCOL, G as joinFrame, H as helloAckFrame, I as bindingsUpdatedFrame, J as platformChatFrame, K as leaveFrame, L as commandFrame, M as PlatformChatBody, N as QueryResultBody, O as JoinBody, P as StatusBody, Q as statusFrame, R as commandResultFrame, S as CommandFrame, T as GameChatBody, U as helloFrame, V as gameChatFrame, W as isProtocolVersionCompatible, X as queryFrame, Y as pongFrame, Z as queryResultFrame, _ as KurobotHello, a as renderDeathText, b as BindingsUpdatedBody, c as truncateForGroup, d as KurobotConnFace, et as KurobotConfig, f as KurobotMsgApi, g as KurobotConnectionOptions, h as KurobotConnection, i as renderCommandResult, j as PROTOCOL_VERSION, k as LeaveBody, l as KurobotAdapterOptions, m as ConnectionEndedReason, n as degradeElements, nt as kurobotConfigSchema, o as renderTemplate, p as ReceiveLogFilterHolder, q as pingFrame, r as degradeMessage, s as resolveSenderName, t as MAX_GROUP_TEXT_LENGTH, tt as kurobotConfigDefaults, u as NapukettoKurobotAdapter, v as KurobotLogger, w as DeathBody, x as CommandBody, y as ServerEventMessage, z as deathFrame } from "../index-tW3a05Du.mjs";
|
|
6
6
|
export { type BindingsUpdatedBody, type CommandBody, type CommandFrame, type CommandResultBody, type ConnectionEndedReason, type DeathBody, type GameChatBody, type HelloAckBody, type HelloBody, type JoinBody, type KurobotAdapterOptions, type KurobotConfig, type KurobotConnFace, KurobotConnection, type KurobotConnectionOptions, type KurobotHello, type KurobotLogger, type KurobotMsgApi, type LeaveBody, MAX_GROUP_TEXT_LENGTH, NapukettoKurobotAdapter, PROTOCOL_NAME, PROTOCOL_VERSION, type PlatformChatBody, type QueryResultBody, type ReceiveLogFilterHolder, type ServerEventMessage, type StatusBody, WS_SUBPROTOCOL, bindingsUpdatedFrame, commandFrame, commandResultFrame, deathFrame, degradeElements, degradeMessage, encodeFrame, gameChatFrame, helloAckFrame, helloFrame, isProtocolVersionCompatible, joinFrame, kurobotConfigDefaults, kurobotConfigSchema, leaveFrame, pingFrame, platformChatFrame, pongFrame, queryFrame, queryResultFrame, renderCommandResult, renderDeathText, renderTemplate, resolveSenderName, statusFrame, truncateForGroup, wireFrameSchema };
|
package/dist/kurobot/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-
|
|
1
|
+
export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-8YrYipGI.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as BaseProtocolAdapter, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { r as subscribeRawMessages } from "./raw-message-DU8YOhLV.mjs";
|
|
3
3
|
import { ChatType, errorMessage, getOwnProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
package/dist/milky/index.d.mts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* 对齐 ./onebot11 与 ./satori 的导出口径。装配方(loader assemble-protocols)
|
|
6
6
|
* 动态 import 本入口。
|
|
7
7
|
*/
|
|
8
|
-
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-
|
|
8
|
+
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-PWs-cVWe.mjs";
|
|
9
9
|
export { type BotOfflineData, type FriendCategoryEntity, type FriendEntity, type FriendRequestData, type FriendRequestEntity, type GetCookiesOutput, type GetImplInfoOutput, type GetLoginInfoOutput, type GroupAnnouncementEntity, type GroupDisbandData, type GroupEntity, type GroupEssenceMessage, type GroupFileEntity, type GroupFileUploadData, type GroupFolderEntity, type GroupInvitationData, type GroupInvitedJoinRequestData, type GroupJoinRequestData, type GroupMemberDecreaseData, type GroupMemberEntity, type GroupMemberIncreaseData, type GroupMessageReactionData, type GroupMuteData, type GroupNameChangeData, type GroupNotificationEntity, type GroupWholeMuteData, type IncomingForwardedMessage, type MessageRecallData, type MessageScene, type MilkyAction, type MilkyAdapterOptions, MilkyApi, type MilkyApiOptions, type MilkyConfig, type MilkyEvent, type IncomingMessage as MilkyIncomingMessage, type IncomingSegment as MilkyIncomingSegment, type MilkyLoggerLike, type OutgoingSegment as MilkyOutgoingSegment, type MilkyTransportSet, NapukettoMilkyAdapter, type OutgoingForwardedMessage, type PeerPinChangeData, type SendMessageOutput, assembleMilkyTransports, createMilkyActionRegistry, milkyConfigSchema, milkyErrorCodeMap };
|
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-DTlPFEhN.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as BEARER_PREFIX, f as ActionRegistry, i as validateListenerToken, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { a as logEventFailure, f as MediaCache, h as withMediaScope, i as hasGrayTip, m as protectMediaPath, n as findRevokeElement, o as sliceRaw, p as cacheMediaFile, r as firstUntranslatedGrayTip, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-BL1rhwZK.mjs";
|
|
3
3
|
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, o as stringOrUndefined, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage } from "./raw-message-DU8YOhLV.mjs";
|
|
4
4
|
import { a as processSysMsgBlob, c as varintAt, d as processInboundBuddyReqs, i as nodeAt, l as varintOf, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, s as textOf, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-Cn1oRaLw.mjs";
|
|
@@ -2241,14 +2241,6 @@ function createMilkyActionRegistry(opts) {
|
|
|
2241
2241
|
});
|
|
2242
2242
|
return registry;
|
|
2243
2243
|
}
|
|
2244
|
-
// src/milky/config.ts
|
|
2245
|
-
/**
|
|
2246
|
-
* Milky 协议配置(zod schema,归属本包)
|
|
2247
|
-
*
|
|
2248
|
-
* 单一 TOML 的 `[accounts.milky]` 账号段(docs/protocols/milky.md §4):
|
|
2249
|
-
* 单端口 HTTP 模型(/api + /event 同端口),`enabled` 缺省 false = 不启用。
|
|
2250
|
-
*/
|
|
2251
|
-
/** Milky 配置 schema。 */
|
|
2252
2244
|
const milkyConfigSchema = z.object({
|
|
2253
2245
|
/** 启用开关(缺省 false:账号段存在但 enabled 未开 = 装配为空转)。 */
|
|
2254
2246
|
enabled: z.boolean().default(false),
|
|
@@ -2256,7 +2248,7 @@ const milkyConfigSchema = z.object({
|
|
|
2256
2248
|
host: z.string().min(1).default("127.0.0.1"),
|
|
2257
2249
|
/** HTTP 监听端口(/api 与 /event 同端口)。 */
|
|
2258
2250
|
port: z.number().int().min(0).max(65535).default(3001),
|
|
2259
|
-
/** access_token
|
|
2251
|
+
/** access_token(仅数值回环监听可以省略)。 */
|
|
2260
2252
|
token: z.string().default(""),
|
|
2261
2253
|
/** /event 允许的连接形态(缺省两者都开)。 */
|
|
2262
2254
|
eventModes: z.array(z.enum(["sse", "ws"])).default(["sse", "ws"]),
|
|
@@ -2264,6 +2256,8 @@ const milkyConfigSchema = z.object({
|
|
|
2264
2256
|
webhooks: z.array(z.string().min(1)).default([]),
|
|
2265
2257
|
/** 发送媒体 http(s) URI 下载缓存目录(缺省不下载 = http(s) 发送媒体不可用)。 */
|
|
2266
2258
|
cacheDir: z.string().optional()
|
|
2259
|
+
}).superRefine((config, ctx) => {
|
|
2260
|
+
if (config.enabled) validateListenerToken(config.host, config.token, ctx, ["token"]);
|
|
2267
2261
|
});
|
|
2268
2262
|
// src/milky/enrichment.ts
|
|
2269
2263
|
/** Milky 收链路异步回填器。 */
|
|
@@ -3129,19 +3123,6 @@ var MilkyInboundSysMsg = class {
|
|
|
3129
3123
|
}
|
|
3130
3124
|
};
|
|
3131
3125
|
// src/milky/transport.ts
|
|
3132
|
-
/**
|
|
3133
|
-
* Milky 传输装配(单端口 HTTP:POST /api/:api + GET /event SSE + /event WS 升级
|
|
3134
|
-
* + WebHook 主动推送,docs/protocols/milky.md §4)
|
|
3135
|
-
*
|
|
3136
|
-
* - HTTP API:HttpServer onPathRequest 分发 → 动作注册表 → 规范响应信封
|
|
3137
|
-
* (200 ok / 200 failed(-400/-403/自定) / 401 鉴权 / 404 API 不存在(空 body)/
|
|
3138
|
-
* 415 Content-Type)。
|
|
3139
|
-
* - /event:onRawRequest 承接 SSE(createSseResponse,event: milky_event);
|
|
3140
|
-
* onUpgrade 承接同端口 WS 升级(网络原语 下沉 network)。
|
|
3141
|
-
* - WebHook:HttpClient(fire-and-forget POST,Authorization 头带 token)。
|
|
3142
|
-
*
|
|
3143
|
-
* 事件推送统一经 MilkyEventHub(注册到 EventBroadcaster,send → SSE/WS 客户端)。
|
|
3144
|
-
*/
|
|
3145
3126
|
/** /event 路径(规范固定)。 */
|
|
3146
3127
|
const EVENT_PATH = "/event";
|
|
3147
3128
|
/** /api/ 前缀 + 动作名(小写字母开头,小写/数字/下划线)。 */
|
|
@@ -3156,7 +3137,7 @@ var MilkyEventHub = class {
|
|
|
3156
3137
|
sseClients = /* @__PURE__ */ new Set();
|
|
3157
3138
|
sockets = /* @__PURE__ */ new Set();
|
|
3158
3139
|
/** 把 /event 的 SSE(onRawRequest)与 WS 升级(onUpgrade)挂到 HTTP server。 */
|
|
3159
|
-
attachTo(server, config) {
|
|
3140
|
+
attachTo(server, config, authorize, logger) {
|
|
3160
3141
|
server.onRawRequest = (ctx) => {
|
|
3161
3142
|
if (ctx.path !== EVENT_PATH || ctx.method !== "GET") return;
|
|
3162
3143
|
if (!config.eventModes.includes("sse")) return new Response("event mode sse disabled", { status: 404 });
|
|
@@ -3168,13 +3149,22 @@ var MilkyEventHub = class {
|
|
|
3168
3149
|
});
|
|
3169
3150
|
};
|
|
3170
3151
|
server.onUpgrade = (req, accept, reject) => {
|
|
3171
|
-
|
|
3152
|
+
const target = URL.parse(req.url, "http://localhost");
|
|
3153
|
+
if (target === null) {
|
|
3154
|
+
logger?.debug({ category: "invalid_upgrade_target" }, "milky: 升级目标解析失败");
|
|
3155
|
+
reject(400);
|
|
3156
|
+
return;
|
|
3157
|
+
}
|
|
3158
|
+
if (target.pathname !== EVENT_PATH) {
|
|
3159
|
+
reject(404);
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3172
3162
|
if (!config.eventModes.includes("ws")) {
|
|
3173
|
-
reject(404
|
|
3163
|
+
reject(404);
|
|
3174
3164
|
return;
|
|
3175
3165
|
}
|
|
3176
|
-
if (
|
|
3177
|
-
reject(401
|
|
3166
|
+
if (authorize && !authorize(req)) {
|
|
3167
|
+
reject(401);
|
|
3178
3168
|
return;
|
|
3179
3169
|
}
|
|
3180
3170
|
accept((socket) => {
|
|
@@ -3209,11 +3199,8 @@ function assembleMilkyTransports(opts) {
|
|
|
3209
3199
|
const token = config.token;
|
|
3210
3200
|
const authorize = createTokenAuthorize(token, {
|
|
3211
3201
|
allowQueryToken: true,
|
|
3212
|
-
onQueryParseError: (
|
|
3213
|
-
logger?.debug({
|
|
3214
|
-
url,
|
|
3215
|
-
error: errorMessage(err)
|
|
3216
|
-
}, "milky: 鉴权 URL 解析失败,按未授权拒绝");
|
|
3202
|
+
onQueryParseError: () => {
|
|
3203
|
+
logger?.debug({ category: "invalid_auth_target" }, "milky: 鉴权 URL 解析失败,按未授权拒绝");
|
|
3217
3204
|
}
|
|
3218
3205
|
});
|
|
3219
3206
|
const server = new HttpServer({
|
|
@@ -3221,20 +3208,20 @@ function assembleMilkyTransports(opts) {
|
|
|
3221
3208
|
port: config.port,
|
|
3222
3209
|
...authorize !== void 0 ? { authorize } : {}
|
|
3223
3210
|
});
|
|
3224
|
-
hub.attachTo(server, config);
|
|
3211
|
+
hub.attachTo(server, config, authorize, logger);
|
|
3225
3212
|
server.onPathRequest = (ctx, req, respond) => {
|
|
3226
3213
|
handleMilkyHttpRequest(ctx, req, respond, registry, logger);
|
|
3227
3214
|
};
|
|
3228
3215
|
const adapters = [server, hub];
|
|
3229
|
-
for (const url of config.webhooks) {
|
|
3216
|
+
for (const [index, url] of config.webhooks.entries()) {
|
|
3230
3217
|
const client = new HttpClient({
|
|
3231
3218
|
url,
|
|
3232
3219
|
...token !== "" ? { headers: { authorization: `${BEARER_PREFIX}${token}` } } : {},
|
|
3233
3220
|
timeoutMs: 5e3,
|
|
3234
|
-
onError: (
|
|
3221
|
+
onError: () => {
|
|
3235
3222
|
logger?.warn({
|
|
3236
|
-
|
|
3237
|
-
|
|
3223
|
+
category: "webhook_delivery_failed",
|
|
3224
|
+
index
|
|
3238
3225
|
}, "milky: webhook 推送失败");
|
|
3239
3226
|
}
|
|
3240
3227
|
});
|
|
@@ -3290,10 +3277,10 @@ function handleMilkyHttpRequest(ctx, req, respond, registry, logger) {
|
|
|
3290
3277
|
data: null,
|
|
3291
3278
|
message: result.message
|
|
3292
3279
|
});
|
|
3293
|
-
}).catch((
|
|
3280
|
+
}).catch(() => {
|
|
3294
3281
|
logger?.warn({
|
|
3295
|
-
path:
|
|
3296
|
-
|
|
3282
|
+
path: "/api/:api",
|
|
3283
|
+
category: "action_dispatch_failed"
|
|
3297
3284
|
}, "milky: 动作分发异常,已回 -500");
|
|
3298
3285
|
respond({
|
|
3299
3286
|
status: "failed",
|
|
@@ -3303,14 +3290,6 @@ function handleMilkyHttpRequest(ctx, req, respond, registry, logger) {
|
|
|
3303
3290
|
});
|
|
3304
3291
|
});
|
|
3305
3292
|
}
|
|
3306
|
-
/** URL 路径部分(无 scheme 相对 url 容错)。 */
|
|
3307
|
-
function pathnameOf(url) {
|
|
3308
|
-
try {
|
|
3309
|
-
return new URL(url, "http://localhost").pathname;
|
|
3310
|
-
} catch {
|
|
3311
|
-
return url.split("?")[0] ?? "";
|
|
3312
|
-
}
|
|
3313
|
-
}
|
|
3314
3293
|
// src/milky/adapter.ts
|
|
3315
3294
|
var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
|
|
3316
3295
|
protocol = "milky";
|
|
@@ -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-C-pAiIuG.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-Bq0f2Tky.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as validateServerTokens, c as BEARER_PREFIX, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { a as logEventFailure, c as downloadBufferToFile, d as prepareVideoElements, f as MediaCache, h as withMediaScope, i as hasGrayTip, l as ensureSilk, m as protectMediaPath, o as sliceRaw, p as cacheMediaFile, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-BL1rhwZK.mjs";
|
|
3
3
|
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as collectGroupNotifyUids } from "./raw-message-DU8YOhLV.mjs";
|
|
4
4
|
import { a as processSysMsgBlob, d as processInboundBuddyReqs, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-Cn1oRaLw.mjs";
|
|
@@ -1421,7 +1421,6 @@ const wsReverseSchema = z.object({
|
|
|
1421
1421
|
/** WS ping 间隔(毫秒)。 */
|
|
1422
1422
|
heartbeatInterval: z.number().int().default(DEFAULT_WS_HEARTBEAT_MS)
|
|
1423
1423
|
});
|
|
1424
|
-
/** OB11 配置 schema。 */
|
|
1425
1424
|
const ob11ConfigSchema = z.object({
|
|
1426
1425
|
/** 鉴权 token(全局默认,实例未指定时继承)。 */
|
|
1427
1426
|
token: z.string().optional(),
|
|
@@ -1445,7 +1444,7 @@ const ob11ConfigSchema = z.object({
|
|
|
1445
1444
|
wsServers: z.array(wsServerSchema).default([]),
|
|
1446
1445
|
/** 正向 WS client 列表。 */
|
|
1447
1446
|
wsReverseUrls: z.array(wsReverseSchema).default([])
|
|
1448
|
-
});
|
|
1447
|
+
}).superRefine(validateServerTokens);
|
|
1449
1448
|
// src/onebot11/helper/data.ts
|
|
1450
1449
|
/** canonical 元素数组 → OB11 segment 数组(无法表达的元素静默跳过)。 */
|
|
1451
1450
|
function canonicalToSegments(elements) {
|
|
@@ -2926,23 +2925,6 @@ function createOb11ActionRegistry(deps) {
|
|
|
2926
2925
|
return registry;
|
|
2927
2926
|
}
|
|
2928
2927
|
// src/internal/infra/outbound-open.ts
|
|
2929
|
-
/**
|
|
2930
|
-
* 出向传输首连容错(issue #144)
|
|
2931
|
-
*
|
|
2932
|
-
* 背景:`network.WsClient.open()` 的契约是「首连失败即 reject,不自动重试」
|
|
2933
|
-
* (重连只覆盖已建立连接后的断线,见 `WsClient.onClose`)。协议装配层若直接
|
|
2934
|
-
* `await client.open()`,对端 WS 服务暂时未启动/不可达(ECONNREFUSED、
|
|
2935
|
-
* ENOTFOUND host.docker.internal)就会让整个 `startProtocols` 抛错 →
|
|
2936
|
-
* `self-host` exit 1,已登录成功的 QQ 宿主被一个外部服务拖死。
|
|
2937
|
-
*
|
|
2938
|
-
* 本模块在 adapter 层补足容错:首连失败只记 warn,并在后台按指数退避重试,
|
|
2939
|
-
* 不阻塞协议装配、不影响宿主运行;`stop()` 时经返回的取消函数清掉定时器。
|
|
2940
|
-
* 底层 `WsClient.open()` 失败语义保持不变(network 单测契约不动)。
|
|
2941
|
-
*
|
|
2942
|
-
* 退避从配置的 `reconnectDelayMs` 起按 2 倍递增并封顶(60s),与 supervisor
|
|
2943
|
-
* 的子进程重启退避同一思路;连接建立后的断线仍由 `WsClient` 自己的 reconnect
|
|
2944
|
-
* 策略处理,两者不重叠。
|
|
2945
|
-
*/
|
|
2946
2928
|
/** 后台重连延迟上限(毫秒)。 */
|
|
2947
2929
|
const MAX_RETRY_DELAY_MS = 6e4;
|
|
2948
2930
|
/**
|
|
@@ -2975,10 +2957,10 @@ function openOutboundWithRetry(transport, opts) {
|
|
|
2975
2957
|
if (stopped) return;
|
|
2976
2958
|
try {
|
|
2977
2959
|
await transport.open();
|
|
2978
|
-
} catch
|
|
2960
|
+
} catch {
|
|
2979
2961
|
if (stopped) return;
|
|
2980
2962
|
opts.logger?.warn({
|
|
2981
|
-
|
|
2963
|
+
category: "outbound_open_failed",
|
|
2982
2964
|
label: opts.label,
|
|
2983
2965
|
retry: attempt + 1
|
|
2984
2966
|
}, "出向传输连接失败,后台按重连策略重试(不影响宿主运行)");
|
|
@@ -2987,9 +2969,9 @@ function openOutboundWithRetry(transport, opts) {
|
|
|
2987
2969
|
}
|
|
2988
2970
|
if (stopped) try {
|
|
2989
2971
|
await transport.close();
|
|
2990
|
-
} catch
|
|
2972
|
+
} catch {
|
|
2991
2973
|
opts.logger?.warn({
|
|
2992
|
-
|
|
2974
|
+
category: "outbound_close_failed",
|
|
2993
2975
|
label: opts.label
|
|
2994
2976
|
}, "取消后关闭出向传输失败");
|
|
2995
2977
|
}
|
|
@@ -3834,7 +3816,7 @@ function assembleHttpPosts(config, selfUin, transports, outbound) {
|
|
|
3834
3816
|
}
|
|
3835
3817
|
/** 装配正向 WS client 列表(双向,心跳 + 重连 + 证书选项)。 */
|
|
3836
3818
|
function assembleWsReverses(config, selfUin, handleRequest, transports, outbound) {
|
|
3837
|
-
for (const item of config.wsReverseUrls) if (item.enabled && item.url !== void 0) {
|
|
3819
|
+
for (const [index, item] of config.wsReverseUrls.entries()) if (item.enabled && item.url !== void 0) {
|
|
3838
3820
|
const headers = {
|
|
3839
3821
|
...oneBotClientHeaders(selfUin),
|
|
3840
3822
|
...authorizeHeader(item.token ?? config.token) ?? {}
|
|
@@ -3857,7 +3839,7 @@ function assembleWsReverses(config, selfUin, handleRequest, transports, outbound
|
|
|
3857
3839
|
outbound.push({
|
|
3858
3840
|
transport: client,
|
|
3859
3841
|
wsReconnect: {
|
|
3860
|
-
|
|
3842
|
+
index,
|
|
3861
3843
|
delayMs: item.reconnectDelayMs,
|
|
3862
3844
|
...item.maxReconnectAttempts !== void 0 ? { maxAttempts: item.maxReconnectAttempts } : {}
|
|
3863
3845
|
}
|
|
@@ -3978,7 +3960,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3978
3960
|
continue;
|
|
3979
3961
|
}
|
|
3980
3962
|
this.outboundCancels.push(openOutboundWithRetry(item.transport, {
|
|
3981
|
-
label: `onebot11
|
|
3963
|
+
label: `onebot11 wsReverseUrls[${reconnect.index}]`,
|
|
3982
3964
|
delayMs: reconnect.delayMs,
|
|
3983
3965
|
...reconnect.maxAttempts !== void 0 ? { maxAttempts: reconnect.maxAttempts } : {},
|
|
3984
3966
|
...this.logger !== void 0 ? { logger: this.logger } : {}
|
package/dist/satori/index.d.mts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Satori 协议适配器
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 传输装配 + 适配器。
|
|
4
4
|
*/
|
|
5
|
-
import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-
|
|
5
|
+
import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-D93z0TYf.mjs";
|
|
6
6
|
export { type Argv, type AssembleSatoriTransportsOptions, type BidiList, type Button, type CanonicalToSatoriDeps, type Channel, type ChannelType, type Direction, type Emoji, type Event, type Friend, type Guild, type GuildMember, type GuildRole, HTTP_STATUS, type IdentifyBody, type List, type Login, type LoginStatus, type Message, type MetaBody, NapukettoSatoriAdapter, type Opcode, type Order, type ReadyBody, type SatoriActionDeps, SatoriActionError, type SatoriAdapterOptions, SatoriApi, type SatoriApiOptions, type SatoriConfig, type SatoriElement, type SatoriEventContent, type SatoriEventDeps, type SatoriToCanonicalDeps, type SatoriTransportSet, type Signal, type User, assembleSatoriTransports, canonicalToSatoriElements, createSatoriActionRegistry, parseContentToCanonical, parseElements, renderElements, satoriConfigSchema, satoriHttpStatusMap, satoriToCanonicalElements, toEventSignal };
|
package/dist/satori/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-
|
|
1
|
+
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-VkOP24Vc.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as validateServerTokens, d as tokenEquals, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { a as logEventFailure, c as downloadBufferToFile, f as MediaCache, h as withMediaScope, l as ensureSilk, m as protectMediaPath, p as cacheMediaFile, t as collectGrayTipUids } from "./gray-tip-BL1rhwZK.mjs";
|
|
3
3
|
import { c as MS_TO_SEC, h as toUinString, i as toUnixSeconds, r as subscribeRawMessages } from "./raw-message-DU8YOhLV.mjs";
|
|
4
4
|
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
@@ -21,7 +21,6 @@ const DEFAULT_WS_PORT = 5501;
|
|
|
21
21
|
const httpServerSchema = createServerSchema(DEFAULT_HTTP_PORT);
|
|
22
22
|
/** WS 事件服务实例(/v1/events 信令,第三方 SDK 连入)。 */
|
|
23
23
|
const wsServerSchema = createServerSchema(DEFAULT_WS_PORT);
|
|
24
|
-
/** Satori 配置 schema。 */
|
|
25
24
|
const satoriConfigSchema = z.object({
|
|
26
25
|
/** 鉴权 token(全局默认,实例未指定时继承)。 */
|
|
27
26
|
token: z.string().optional(),
|
|
@@ -31,7 +30,7 @@ const satoriConfigSchema = z.object({
|
|
|
31
30
|
httpServers: z.array(httpServerSchema).default([]),
|
|
32
31
|
/** WS 事件服务列表。 */
|
|
33
32
|
wsServers: z.array(wsServerSchema).default([])
|
|
34
|
-
});
|
|
33
|
+
}).superRefine(validateServerTokens);
|
|
35
34
|
// src/satori/helper/error.ts
|
|
36
35
|
/** KernelErrorCode → HTTP 状态码映射表。 */
|
|
37
36
|
const satoriHttpStatusMap = {
|
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.19.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for NapukettoQQ",
|
|
7
7
|
"keywords": [
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@napuketto/kernel": "^0.16.4",
|
|
87
87
|
"@napuketto/media": "^0.2.3",
|
|
88
|
-
"@napuketto/network": "^0.
|
|
88
|
+
"@napuketto/network": "^0.5.0",
|
|
89
89
|
"zod": "^4.6.7"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|