@napuketto/adapter 0.15.4 → 0.16.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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/core/index.d.mts +8 -3
  3. package/dist/core/index.mjs +1 -1
  4. package/dist/core-Byoso-c3.mjs +108 -0
  5. package/dist/core-Byoso-c3.mjs.map +1 -0
  6. package/dist/{core-DOyFBFOW.mjs → essence-CYb60NC6.mjs} +164 -260
  7. package/dist/essence-CYb60NC6.mjs.map +1 -0
  8. package/dist/{gray-tip-C0pnbB__.mjs → gray-tip-C7lAbfOf.mjs} +10 -10
  9. package/dist/gray-tip-C7lAbfOf.mjs.map +1 -0
  10. package/dist/index-RMEWjNfV.d.mts +91 -0
  11. package/dist/index-RMEWjNfV.d.mts.map +1 -0
  12. package/dist/kurobot/index.d.mts +6 -6
  13. package/dist/kurobot/index.d.mts.map +1 -1
  14. package/dist/kurobot/index.mjs +10 -10
  15. package/dist/kurobot/index.mjs.map +1 -1
  16. package/dist/media-DMMn74TC.mjs +126 -0
  17. package/dist/media-DMMn74TC.mjs.map +1 -0
  18. package/dist/milky/index.d.mts +19 -22
  19. package/dist/milky/index.d.mts.map +1 -1
  20. package/dist/milky/index.mjs +1240 -1357
  21. package/dist/milky/index.mjs.map +1 -1
  22. package/dist/onebot11/index.d.mts +45 -21
  23. package/dist/onebot11/index.d.mts.map +1 -1
  24. package/dist/onebot11/index.mjs +1221 -1865
  25. package/dist/onebot11/index.mjs.map +1 -1
  26. package/dist/{raw-message-D2vA27kj.mjs → raw-message-DE3sdJg8.mjs} +18 -4
  27. package/dist/raw-message-DE3sdJg8.mjs.map +1 -0
  28. package/dist/satori/index.d.mts +24 -37
  29. package/dist/satori/index.d.mts.map +1 -1
  30. package/dist/satori/index.mjs +396 -564
  31. package/dist/satori/index.mjs.map +1 -1
  32. package/package.json +1 -1
  33. package/dist/core-DOyFBFOW.mjs.map +0 -1
  34. package/dist/gray-tip-C0pnbB__.mjs.map +0 -1
  35. package/dist/index-BbHwULNm.d.mts +0 -269
  36. package/dist/index-BbHwULNm.d.mts.map +0 -1
  37. package/dist/log-DYEB3Eto.mjs +0 -176
  38. package/dist/log-DYEB3Eto.mjs.map +0 -1
  39. package/dist/lookup-Dw0W04Ng.mjs +0 -22
  40. package/dist/lookup-Dw0W04Ng.mjs.map +0 -1
  41. package/dist/raw-message-D2vA27kj.mjs.map +0 -1
  42. package/dist/transport-schema-BEzr06W3.mjs +0 -29
  43. package/dist/transport-schema-BEzr06W3.mjs.map +0 -1
@@ -1,17 +1,16 @@
1
- import { C as runAction, S as ActionRegistry, _ as ensureSilk, b as BaseProtocolAdapter } from "../core-DOyFBFOW.mjs";
2
- import { t as findFirstMatch } from "../lookup-Dw0W04Ng.mjs";
3
- import { t as forEachRawMessage } from "../raw-message-D2vA27kj.mjs";
4
- import { l as toUinString, t as collectGrayTipUids } from "../gray-tip-C0pnbB__.mjs";
5
- import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-BEzr06W3.mjs";
1
+ import { i as runAction, n as BaseProtocolAdapter, r as ActionRegistry } from "../core-Byoso-c3.mjs";
2
+ import { r as createServerSchema, t as ensureSilk } from "../media-DMMn74TC.mjs";
3
+ import { t as forEachRawMessage } from "../raw-message-DE3sdJg8.mjs";
4
+ import { l as toUinString, t as collectGrayTipUids } from "../gray-tip-C7lAbfOf.mjs";
6
5
  import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, kernelError, toCanonicalElements } from "@napuketto/kernel";
7
- import { mkdir, writeFile } from "node:fs/promises";
6
+ import { z } from "zod";
8
7
  import { join } from "node:path";
9
8
  import { transcodeVideo } from "@napuketto/media";
10
- import { z } from "zod";
9
+ import { mkdir, writeFile } from "node:fs/promises";
11
10
  import { HttpServer, WsServer } from "@napuketto/network";
12
11
  // src/satori/helper/config.ts
13
12
  /**
14
- * Satori 协议配置(zod schema,归属本包,ADR-012)
13
+ * Satori 协议配置(zod schema,归属本包)
15
14
  * 协议配置 schema 在各自协议包,kernel 只提供 ConfigBase 基类。
16
15
  */
17
16
  /** HTTP RPC 服务器默认端口(satori.chat 惯例 5500 区间,取 5500)。 */
@@ -19,9 +18,9 @@ const DEFAULT_HTTP_PORT = 5500;
19
18
  /** WS 事件服务默认端口(satori.chat 惯例 5500 区间,取 5501)。 */
20
19
  const DEFAULT_WS_PORT = 5501;
21
20
  /** HTTP RPC 服务器实例(POST /v1/{resource}.{method})。 */
22
- const httpServerSchema = createHttpServerSchema(DEFAULT_HTTP_PORT);
21
+ const httpServerSchema = createServerSchema(DEFAULT_HTTP_PORT);
23
22
  /** WS 事件服务实例(/v1/events 信令,第三方 SDK 连入)。 */
24
- const wsServerSchema = createWsServerSchema(DEFAULT_WS_PORT);
23
+ const wsServerSchema = createServerSchema(DEFAULT_WS_PORT);
25
24
  /** Satori 配置 schema。 */
26
25
  const satoriConfigSchema = z.object({
27
26
  /** 鉴权 token(全局默认,实例未指定时继承)。 */
@@ -208,7 +207,7 @@ async function canonicalToSatoriElements(elements, deps = {}) {
208
207
  }
209
208
  // src/satori/helper/element/parse-tag.ts
210
209
  /**
211
- * Satori 标签读取(元素名 / 属性解析,从 element.ts 拆分,2026-08-08 FTA 优化)
210
+ * Satori 标签读取(元素名 / 属性解析,从 element.ts 拆分,FTA 优化)
212
211
  *
213
212
  * - decodeEntity/decodeEntities:命名/十进制/十六进制实体解码(属性值用)
214
213
  * - readTagName:读取元素名(小写字母/数字/连字符,以字母开头)
@@ -581,312 +580,228 @@ var SatoriActionError = class extends Error {
581
580
  };
582
581
  /** 校验失败默认状态码。 */
583
582
  const INVALID_PARAM_STATUS = 400;
584
- /**
585
- * Satori 动作基类:校验 + 执行 + 错误映射。
586
- * 成功返回资源对象(或数组/分页列表),失败抛 SatoriActionError。
587
- */
588
- var BaseSatoriAction = class {
589
- /** 校验并执行(HTTP/WS 共用)。 */
590
- async run(payload) {
591
- const outcome = await runAction({
592
- schema: this.schema,
593
- handle: (parsed) => this._handle(parsed),
594
- errorCodeMap: satoriHttpStatusMap,
595
- invalidRetcode: INVALID_PARAM_STATUS,
596
- passthrough: (err) => err instanceof SatoriActionError
597
- }, payload);
598
- if (!outcome.ok) throw new SatoriActionError(outcome.retcode, outcome.message);
599
- return outcome.data;
600
- }
601
- };
583
+ /** 声明式动作工厂:闭包依赖 + 统一校验与错误映射。 */
584
+ function defineSatoriAction(spec) {
585
+ return {
586
+ name: spec.name,
587
+ schema: spec.schema,
588
+ run: async (payload) => {
589
+ const outcome = await runAction({
590
+ schema: spec.schema,
591
+ handle: spec.handle,
592
+ errorCodeMap: satoriHttpStatusMap,
593
+ invalidRetcode: INVALID_PARAM_STATUS,
594
+ passthrough: (err) => err instanceof SatoriActionError
595
+ }, payload);
596
+ if (!outcome.ok) throw new SatoriActionError(outcome.retcode, outcome.message);
597
+ return outcome.data;
598
+ }
599
+ };
600
+ }
602
601
  // src/satori/action/channel.ts
603
602
  /**
604
603
  * Satori 频道动作:channel.get / channel.list
605
604
  * (channel.create / update / delete / mute:QQ 不支持 → 501,见 registry)
606
605
  */
607
- /** channel.get 参数。 */
608
- const channelGetSchema = z.object({ channel_id: z.string() });
609
- /** 获取频道(群聊 = 群号频道;私聊 = uin 频道)。 */
610
- var ChannelGetAction = class extends BaseSatoriAction {
611
- name = "channel.get";
612
- schema = channelGetSchema;
613
- deps;
614
- constructor(deps) {
615
- super();
616
- this.deps = deps;
617
- }
618
- async _handle(payload) {
619
- const { channel_id: channelId } = payload;
620
- const isGroup = (await this.deps.resolvePeer(channelId)).chatType === 2;
621
- this.deps.setChannelType(channelId, isGroup);
622
- if (isGroup) return toChannelById(channelId, true, (await this.deps.groupCache?.getGroupDetail(channelId))?.groupName);
623
- return toChannelById(channelId, false);
624
- }
625
- };
626
- /** channel.list 参数。 */
627
- const channelListSchema = z.object({
628
- guild_id: z.string(),
629
- next: z.string().optional()
630
- });
631
- /** 获取群组频道列表(QQ:群组与群聊频道重合 → 单元素列表)。 */
632
- var ChannelListAction = class extends BaseSatoriAction {
633
- name = "channel.list";
634
- schema = channelListSchema;
635
- deps;
636
- constructor(deps) {
637
- super();
638
- this.deps = deps;
639
- }
640
- async _handle(payload) {
641
- const { guild_id: guildId } = payload;
642
- const name = (await this.deps.groupCache?.getGroupDetail(guildId))?.groupName;
643
- return { data: [toChannelById(guildId, true, name)] };
644
- }
645
- };
606
+ /** 频道动作工厂(channel.get / channel.list)。 */
607
+ function createChannelActions(deps) {
608
+ return [defineSatoriAction({
609
+ name: "channel.get",
610
+ schema: z.object({ channel_id: z.string() }),
611
+ handle: async (payload) => {
612
+ const { channel_id: channelId } = payload;
613
+ const isGroup = (await deps.resolvePeer(channelId)).chatType === 2;
614
+ deps.setChannelType(channelId, isGroup);
615
+ if (isGroup) return toChannelById(channelId, true, (await deps.groupCache?.getGroupDetail(channelId))?.groupName);
616
+ return toChannelById(channelId, false);
617
+ }
618
+ }), defineSatoriAction({
619
+ name: "channel.list",
620
+ schema: z.object({
621
+ guild_id: z.string(),
622
+ next: z.string().optional()
623
+ }),
624
+ handle: async (payload) => {
625
+ const { guild_id: guildId } = payload;
626
+ const name = (await deps.groupCache?.getGroupDetail(guildId))?.groupName;
627
+ return { data: [toChannelById(guildId, true, name)] };
628
+ }
629
+ })];
630
+ }
646
631
  // src/satori/action/friend.ts
647
- /** friend.list 参数。 */
648
- const friendListSchema = z.object({ next: z.string().optional() });
649
- /** 获取好友列表。 */
650
- var FriendListAction = class extends BaseSatoriAction {
651
- name = "friend.list";
652
- schema = friendListSchema;
653
- deps;
654
- constructor(deps) {
655
- super();
656
- this.deps = deps;
657
- }
658
- async _handle(_payload) {
659
- return { data: (await this.deps.friendApi.getFriendList()).map((f) => {
660
- const out = { user: toUser(f.uin, f.nickname) };
661
- if (f.remark !== "" && f.remark !== f.nickname) out.nick = f.remark;
662
- return out;
663
- }) };
664
- }
665
- };
666
- /** friend.delete 参数。 */
667
- const friendDeleteSchema = z.object({ user_id: z.string() });
668
- /** 删除好友。 */
669
- var FriendDeleteAction = class extends BaseSatoriAction {
670
- name = "friend.delete";
671
- schema = friendDeleteSchema;
672
- deps;
673
- constructor(deps) {
674
- super();
675
- this.deps = deps;
676
- }
677
- async _handle(payload) {
678
- const { user_id: userId } = payload;
679
- const uid = (await this.deps.uinToUid([userId])).get(userId) ?? userId;
680
- await this.deps.friendApi.deleteFriend(uid);
681
- }
682
- };
683
- /** friend.approve 参数(处理好友申请)。 */
684
- const friendApproveSchema = z.object({
685
- message_id: z.string(),
686
- approve: z.boolean(),
687
- comment: z.string().optional()
688
- });
689
- /** 处理好友申请(message_id = 申请方 uin)。 */
690
- var FriendApproveAction = class extends BaseSatoriAction {
691
- name = "friend.approve";
692
- schema = friendApproveSchema;
693
- deps;
694
- constructor(deps) {
695
- super();
696
- this.deps = deps;
697
- }
698
- async _handle(payload) {
699
- const { message_id: messageId, approve } = payload;
700
- const notify = await findBuddyReq(this.deps, messageId);
701
- await this.deps.friendApi.handleFriendRequest(notify, approve);
702
- }
703
- };
704
- /** 按 message_id(申请方 uin)查找好友申请(骨架走 core findFirstMatch)。 */
632
+ /** 好友动作工厂(friend.list / friend.delete / friend.approve)。 */
633
+ function createFriendActions(deps) {
634
+ return [
635
+ defineSatoriAction({
636
+ name: "friend.list",
637
+ schema: z.object({ next: z.string().optional() }),
638
+ handle: async () => {
639
+ return { data: (await deps.friendApi.getFriendList()).map((f) => {
640
+ const out = { user: toUser(f.uin, f.nickname) };
641
+ if (f.remark !== "" && f.remark !== f.nickname) out.nick = f.remark;
642
+ return out;
643
+ }) };
644
+ }
645
+ }),
646
+ defineSatoriAction({
647
+ name: "friend.delete",
648
+ schema: z.object({ user_id: z.string() }),
649
+ handle: async (payload) => {
650
+ const { user_id: userId } = payload;
651
+ const uid = (await deps.uinToUid([userId])).get(userId) ?? userId;
652
+ await deps.friendApi.deleteFriend(uid);
653
+ }
654
+ }),
655
+ defineSatoriAction({
656
+ name: "friend.approve",
657
+ schema: z.object({
658
+ message_id: z.string(),
659
+ approve: z.boolean(),
660
+ comment: z.string().optional()
661
+ }),
662
+ handle: async (payload) => {
663
+ const { message_id: messageId, approve } = payload;
664
+ const notify = await findBuddyReq(deps, messageId);
665
+ await deps.friendApi.handleFriendRequest(notify, approve);
666
+ }
667
+ })
668
+ ];
669
+ }
670
+ /** 按 message_id(申请方 uin)查找好友申请。 */
705
671
  async function findBuddyReq(deps, messageId) {
706
672
  const reqs = await deps.friendApi.getBuddyReqList();
707
673
  if (reqs.length === 0) throw new Error("好友申请不存在");
708
674
  const uinMap = await deps.uidToUin(reqs.map((r) => r.friendUid));
709
- const found = await findFirstMatch([async () => reqs], (req) => uinMap.get(req.friendUid) === messageId);
675
+ const found = reqs.find((req) => uinMap.get(req.friendUid) === messageId);
710
676
  if (found === void 0) throw new Error("好友申请不存在");
711
677
  return found;
712
678
  }
713
679
  // src/satori/action/guild.ts
714
680
  /** 成员列表默认条数。 */
715
681
  const DEFAULT_MEMBER_LIMIT = 100;
716
- /** guild.get 参数。 */
717
- const guildGetSchema = z.object({ guild_id: z.string() });
718
- /** 获取群组。 */
719
- var GuildGetAction = class extends BaseSatoriAction {
720
- name = "guild.get";
721
- schema = guildGetSchema;
722
- deps;
723
- constructor(deps) {
724
- super();
725
- this.deps = deps;
726
- }
727
- async _handle(payload) {
728
- const { guild_id: guildId } = payload;
729
- const detail = await this.deps.groupApi.getGroupInfo(guildId);
730
- return toGuild(detail.groupCode, detail.groupName);
731
- }
732
- };
733
- /** guild.list 参数。 */
734
- const guildListSchema = z.object({ next: z.string().optional() });
735
- /** 获取群组列表。 */
736
- var GuildListAction = class extends BaseSatoriAction {
737
- name = "guild.list";
738
- schema = guildListSchema;
739
- deps;
740
- constructor(deps) {
741
- super();
742
- this.deps = deps;
743
- }
744
- async _handle(_payload) {
745
- return { data: (this.deps.groupCache === void 0 ? await this.deps.groupApi.getGroupList(true) : await this.deps.groupCache.listGroupsRefreshed()).map((g) => toGuild(g.groupCode, g.groupName)) };
746
- }
747
- };
748
- /** guild.approve 参数(处理入群邀请)。 */
749
- const guildApproveSchema = z.object({
682
+ /** guild.approve / guild.member.approve 共入参(处理群邀请与加群申请)。 */
683
+ const groupApproveSchema = z.object({
750
684
  message_id: z.string(),
751
685
  approve: z.boolean(),
752
686
  comment: z.string().optional()
753
687
  });
754
- /** 群请求 approve 基类(guild.approve / guild.member.approve 共用实现)。 */
755
- var GroupRequestApproveBase = class extends BaseSatoriAction {
756
- schema = guildApproveSchema;
757
- deps;
758
- constructor(deps) {
759
- super();
760
- this.deps = deps;
761
- }
762
- async _handle(payload) {
763
- const { message_id: messageId, approve, comment } = payload;
764
- const notify = await findGroupNotify(this.deps, messageId);
765
- const operateType = approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE;
766
- await this.deps.groupNotifyApi.handleGroupRequest(false, notify, operateType, comment ?? "");
767
- }
768
- };
769
- /** 处理群邀请(message_id = 群通知 seq)。 */
770
- var GuildApproveAction = class extends GroupRequestApproveBase {
771
- name = "guild.approve";
772
- };
773
- /** guild.member.get 参数。 */
774
- const guildMemberGetSchema = z.object({
775
- guild_id: z.string(),
776
- user_id: z.string()
777
- });
778
- /** 获取群成员。 */
779
- var GuildMemberGetAction = class extends BaseSatoriAction {
780
- name = "guild.member.get";
781
- schema = guildMemberGetSchema;
782
- deps;
783
- constructor(deps) {
784
- super();
785
- this.deps = deps;
786
- }
787
- async _handle(payload) {
788
- const { guild_id: guildId, user_id: userId } = payload;
789
- const uid = (await this.deps.uinToUid([userId])).get(userId) ?? userId;
790
- const member = await this.deps.groupCache?.getMember(guildId, uid);
791
- if (member !== void 0) return toGuildMember(member, userId);
792
- const found = (await this.deps.groupApi.getGroupMemberInfo(guildId, [uid])).find((m) => m.uid === uid);
793
- if (found === void 0) throw new Error("群成员不存在");
794
- return toGuildMember(found, userId);
795
- }
796
- };
797
- /** guild.member.list 参数。 */
798
- const guildMemberListSchema = z.object({
799
- guild_id: z.string(),
800
- next: z.string().optional()
801
- });
802
- /** 获取群成员列表。 */
803
- var GuildMemberListAction = class extends BaseSatoriAction {
804
- name = "guild.member.list";
805
- schema = guildMemberListSchema;
806
- deps;
807
- constructor(deps) {
808
- super();
809
- this.deps = deps;
810
- }
811
- async _handle(payload) {
812
- const { guild_id: guildId } = payload;
813
- let members;
814
- const cached = await this.deps.groupCache?.getMembers(guildId);
815
- if (cached !== void 0 && cached.length > 0) members = cached;
816
- else members = await this.deps.groupApi.getGroupMemberList(guildId, true);
817
- const limited = members.slice(0, DEFAULT_MEMBER_LIMIT);
818
- const uids = limited.map((m) => m.uid);
819
- const uinMap = await this.deps.uidToUin(uids);
820
- const out = { data: limited.map((m) => toGuildMember(m, uinMap.get(m.uid) ?? m.uin)) };
821
- if (members.length > DEFAULT_MEMBER_LIMIT) out.next = String(DEFAULT_MEMBER_LIMIT);
822
- return out;
823
- }
824
- };
825
- /** guild.member.kick 参数。 */
826
- const guildMemberKickSchema = z.object({
827
- guild_id: z.string(),
828
- user_id: z.string(),
829
- /** 是否永久踢出(无法再次加入)。 */
830
- permanent: z.boolean().optional()
831
- });
832
- /** 踢出群成员。 */
833
- var GuildMemberKickAction = class extends BaseSatoriAction {
834
- name = "guild.member.kick";
835
- schema = guildMemberKickSchema;
836
- deps;
837
- constructor(deps) {
838
- super();
839
- this.deps = deps;
840
- }
841
- async _handle(payload) {
842
- const { guild_id: guildId, user_id: userId, permanent } = payload;
843
- const uid = (await this.deps.uinToUid([userId])).get(userId) ?? userId;
844
- await this.deps.groupApi.kickMember(guildId, [uid], permanent === true);
845
- }
846
- };
688
+ /** 群组动作工厂(guild.get / list / approve + member 五动作)。 */
689
+ function createGuildActions(deps) {
690
+ return [
691
+ defineSatoriAction({
692
+ name: "guild.get",
693
+ schema: z.object({ guild_id: z.string() }),
694
+ handle: async (payload) => {
695
+ const { guild_id: guildId } = payload;
696
+ const detail = await deps.groupApi.getGroupInfo(guildId);
697
+ return toGuild(detail.groupCode, detail.groupName);
698
+ }
699
+ }),
700
+ defineSatoriAction({
701
+ name: "guild.list",
702
+ schema: z.object({ next: z.string().optional() }),
703
+ handle: async () => {
704
+ return { data: (deps.groupCache === void 0 ? await deps.groupApi.getGroupList(true) : await deps.groupCache.listGroupsRefreshed()).map((g) => toGuild(g.groupCode, g.groupName)) };
705
+ }
706
+ }),
707
+ defineSatoriAction({
708
+ name: "guild.approve",
709
+ schema: groupApproveSchema,
710
+ handle: async (payload) => {
711
+ const { message_id: messageId, approve, comment } = payload;
712
+ await respondGroupRequest(deps, messageId, approve, comment);
713
+ }
714
+ }),
715
+ defineSatoriAction({
716
+ name: "guild.member.get",
717
+ schema: z.object({
718
+ guild_id: z.string(),
719
+ user_id: z.string()
720
+ }),
721
+ handle: async (payload) => {
722
+ const { guild_id: guildId, user_id: userId } = payload;
723
+ const uid = (await deps.uinToUid([userId])).get(userId) ?? userId;
724
+ const member = await deps.groupCache?.getMember(guildId, uid);
725
+ if (member !== void 0) return toGuildMember(member, userId);
726
+ const found = (await deps.groupApi.getGroupMemberInfo(guildId, [uid])).find((m) => m.uid === uid);
727
+ if (found === void 0) throw new Error("群成员不存在");
728
+ return toGuildMember(found, userId);
729
+ }
730
+ }),
731
+ defineSatoriAction({
732
+ name: "guild.member.list",
733
+ schema: z.object({
734
+ guild_id: z.string(),
735
+ next: z.string().optional()
736
+ }),
737
+ handle: async (payload) => {
738
+ const { guild_id: guildId } = payload;
739
+ let members;
740
+ const cached = await deps.groupCache?.getMembers(guildId);
741
+ if (cached !== void 0 && cached.length > 0) members = cached;
742
+ else members = await deps.groupApi.getGroupMemberList(guildId, true);
743
+ const limited = members.slice(0, DEFAULT_MEMBER_LIMIT);
744
+ const uids = limited.map((m) => m.uid);
745
+ const uinMap = await deps.uidToUin(uids);
746
+ const out = { data: limited.map((m) => toGuildMember(m, uinMap.get(m.uid) ?? m.uin)) };
747
+ if (members.length > DEFAULT_MEMBER_LIMIT) out.next = String(DEFAULT_MEMBER_LIMIT);
748
+ return out;
749
+ }
750
+ }),
751
+ defineSatoriAction({
752
+ name: "guild.member.kick",
753
+ schema: z.object({
754
+ guild_id: z.string(),
755
+ user_id: z.string(),
756
+ /** 是否永久踢出(无法再次加入)。 */
757
+ permanent: z.boolean().optional()
758
+ }),
759
+ handle: async (payload) => {
760
+ const { guild_id: guildId, user_id: userId, permanent } = payload;
761
+ const uid = (await deps.uinToUid([userId])).get(userId) ?? userId;
762
+ await deps.groupApi.kickMember(guildId, [uid], permanent === true);
763
+ }
764
+ }),
765
+ defineSatoriAction({
766
+ name: "guild.member.mute",
767
+ schema: z.object({
768
+ guild_id: z.string(),
769
+ user_id: z.string(),
770
+ /** 禁言时长(毫秒,Satori 规范);0 解除禁言。 */
771
+ duration: z.number()
772
+ }),
773
+ handle: async (payload) => {
774
+ const { guild_id: guildId, user_id: userId, duration } = payload;
775
+ const uid = (await deps.uinToUid([userId])).get(userId) ?? userId;
776
+ await deps.groupApi.setMemberShutUp(guildId, [{
777
+ uid,
778
+ duration: msToSeconds(duration)
779
+ }]);
780
+ }
781
+ }),
782
+ defineSatoriAction({
783
+ name: "guild.member.approve",
784
+ schema: groupApproveSchema,
785
+ handle: async (payload) => {
786
+ const { message_id: messageId, approve, comment } = payload;
787
+ await respondGroupRequest(deps, messageId, approve, comment);
788
+ }
789
+ })
790
+ ];
791
+ }
792
+ /** 处理群请求(guild.approve / guild.member.approve 共用实现)。 */
793
+ async function respondGroupRequest(deps, messageId, approve, comment) {
794
+ const notify = await findGroupNotify(deps, messageId);
795
+ const operateType = approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE;
796
+ await deps.groupNotifyApi.handleGroupRequest(false, notify, operateType, comment ?? "");
797
+ }
847
798
  /** 毫秒 → 秒(QQ setMemberShutUp 单位;向下取整,0 解除禁言)。 */
848
799
  function msToSeconds(ms) {
849
800
  return Math.max(0, Math.floor(ms / 1e3));
850
801
  }
851
- /** guild.member.mute 参数。 */
852
- const guildMemberMuteSchema = z.object({
853
- guild_id: z.string(),
854
- user_id: z.string(),
855
- /** 禁言时长(毫秒,Satori 规范);0 解除禁言。 */
856
- duration: z.number()
857
- });
858
- /** 群成员禁言(Satori duration 毫秒 → kernel setMemberShutUp 秒)。 */
859
- var GuildMemberMuteAction = class extends BaseSatoriAction {
860
- name = "guild.member.mute";
861
- schema = guildMemberMuteSchema;
862
- deps;
863
- constructor(deps) {
864
- super();
865
- this.deps = deps;
866
- }
867
- async _handle(payload) {
868
- const { guild_id: guildId, user_id: userId, duration } = payload;
869
- const uid = (await this.deps.uinToUid([userId])).get(userId) ?? userId;
870
- await this.deps.groupApi.setMemberShutUp(guildId, [{
871
- uid,
872
- duration: msToSeconds(duration)
873
- }]);
874
- }
875
- };
876
- /** guild.member.approve 参数(处理加群申请)。 */
877
- const guildMemberApproveSchema = z.object({
878
- message_id: z.string(),
879
- approve: z.boolean(),
880
- comment: z.string().optional()
881
- });
882
- /** 处理加群申请(message_id = 群通知 seq)。 */
883
- var GuildMemberApproveAction = class extends GroupRequestApproveBase {
884
- name = "guild.member.approve";
885
- schema = guildMemberApproveSchema;
886
- };
887
- /** 按 message_id(通知 seq)查找群通知(单屏非可疑;骨架走 core findFirstMatch)。 */
802
+ /** 按 message_id(通知 seq)查找群通知(单屏非可疑快照)。 */
888
803
  async function findGroupNotify(deps, messageId) {
889
- const found = await findFirstMatch([() => deps.groupNotifyApi.getSingleScreenNotifies(false, 50)], (item) => item.seq === messageId);
804
+ const found = (await deps.groupNotifyApi.getSingleScreenNotifies(false, 50)).find((item) => item.seq === messageId);
890
805
  if (found === void 0) throw new Error("群通知不存在");
891
806
  return found;
892
807
  }
@@ -901,24 +816,17 @@ function toGuildMember(member, uin) {
901
816
  /**
902
817
  * Satori 登录动作:login.get
903
818
  */
904
- /** login.get 参数(无)。 */
905
- const loginGetSchema = z.object({});
906
- /** 获取登录信息。 */
907
- var LoginGetAction = class extends BaseSatoriAction {
908
- name = "login.get";
909
- schema = loginGetSchema;
910
- deps;
911
- constructor(deps) {
912
- super();
913
- this.deps = deps;
914
- }
915
- async _handle(_payload) {
916
- return toLogin(this.deps.self, 0, true);
917
- }
918
- };
819
+ /** 登录动作工厂(login.get)。 */
820
+ function createLoginActions(deps) {
821
+ return [defineSatoriAction({
822
+ name: "login.get",
823
+ schema: z.object({}),
824
+ handle: async () => toLogin(deps.self, 0, true)
825
+ })];
826
+ }
919
827
  // src/satori/helper/element/asset.ts
920
828
  /**
921
- * Satori 发方向资源处理(从 element-convert.ts 拆分,2026-08-08 FTA 优化)
829
+ * Satori 发方向资源处理(从 element-convert.ts 拆分,FTA 优化)
922
830
  *
923
831
  * - resolveAsset:internal: 路径 / http(s) 下载 / 本地路径原样
924
832
  * - ensureSilk 已上移到 adapter core(core/media.ts,onebot11/satori 共用)
@@ -1145,138 +1053,97 @@ const messageCreateSchema = z.object({
1145
1053
  /** 被动请求来源(第一版透传忽略,QQ 不区分主动/被动)。 */
1146
1054
  referrer: z.unknown().optional()
1147
1055
  });
1148
- /** 发送消息:返回 Message 数组(规范)。 */
1149
- var MessageCreateAction = class extends BaseSatoriAction {
1150
- name = "message.create";
1151
- schema = messageCreateSchema;
1152
- deps;
1153
- constructor(deps) {
1154
- super();
1155
- this.deps = deps;
1156
- }
1157
- async _handle(payload) {
1158
- const { channel_id: channelId, content } = payload;
1159
- const peer = await this.deps.resolvePeer(channelId);
1160
- this.deps.setChannelType(channelId, peer.chatType === 2);
1161
- const elements = await parseContentToCanonical(content, this.deps.toCanonicalDeps());
1162
- const { msgId } = await this.deps.msgApi.sendMessage(peer, elements);
1163
- const message = {
1164
- id: msgId,
1165
- channel: toChannelById(channelId, peer.chatType === 2)
1166
- };
1167
- message.content = content;
1168
- return [message];
1169
- }
1170
- };
1171
- /** message.get 参数。 */
1172
- const messageGetSchema = z.object({
1173
- channel_id: z.string(),
1174
- message_id: z.string()
1175
- });
1176
- /** 获取单条消息。 */
1177
- var MessageGetAction = class extends BaseSatoriAction {
1178
- name = "message.get";
1179
- schema = messageGetSchema;
1180
- deps;
1181
- constructor(deps) {
1182
- super();
1183
- this.deps = deps;
1184
- }
1185
- async _handle(payload) {
1186
- const { channel_id: channelId, message_id: messageId } = payload;
1187
- const peer = await this.deps.resolvePeer(channelId);
1188
- const first = (await this.deps.msgApi.fetchMsgsByMsgId(peer, [messageId]))[0];
1189
- if (first === void 0) throw new Error("消息不存在");
1190
- this.deps.setChannelType(channelId, peer.chatType === 2);
1191
- return toSatoriMessage(first, {
1192
- selfUin: this.deps.selfUin,
1193
- uidToUin: (uids) => this.deps.uidToUin(uids)
1194
- });
1195
- }
1196
- };
1197
- /** message.list 参数。 */
1198
- const messageListSchema = z.object({
1199
- channel_id: z.string(),
1200
- /** 分页令牌(缺省从最新开始)。 */
1201
- next: z.string().optional(),
1202
- /** 查询方向(缺省 before)。 */
1203
- direction: z.enum([
1204
- "before",
1205
- "after",
1206
- "around"
1207
- ]).optional(),
1208
- /** 消息数量限制(缺省平台默认,推荐 50)。 */
1209
- limit: z.number().int().optional(),
1210
- /** 排序(缺省 asc)。 */
1211
- order: z.enum(["asc", "desc"]).optional()
1212
- });
1213
- /** 获取消息列表(双向分页;第一版仅支持 before 方向)。 */
1214
- var MessageListAction = class extends BaseSatoriAction {
1215
- name = "message.list";
1216
- schema = messageListSchema;
1217
- deps;
1218
- constructor(deps) {
1219
- super();
1220
- this.deps = deps;
1221
- }
1222
- async _handle(payload) {
1223
- const { channel_id: channelId, next, direction, limit, order } = payload;
1224
- if (direction === "around") throw new Error("暂不支持 around 方向");
1225
- const peer = await this.deps.resolvePeer(channelId);
1226
- const count = limit ?? DEFAULT_LIST_LIMIT;
1227
- const raw = await this.deps.msgApi.fetchMessages(peer, {
1228
- count,
1229
- msgId: next ?? ""
1230
- });
1231
- this.deps.setChannelType(channelId, peer.chatType === 2);
1232
- const ordered = order !== "desc" ? [...raw].reverse() : raw;
1233
- const messages = [];
1234
- for (const msg of ordered) messages.push(await toSatoriMessage(msg, {
1235
- selfUin: this.deps.selfUin,
1236
- uidToUin: (uids) => this.deps.uidToUin(uids)
1237
- }));
1238
- const last = messages[messages.length - 1];
1239
- const out = { data: messages };
1240
- if (last !== void 0 && raw.length >= count) out.next = last.id;
1241
- return out;
1242
- }
1243
- };
1244
- /** message.delete 参数。 */
1245
- const messageDeleteSchema = z.object({
1246
- channel_id: z.string(),
1247
- message_id: z.string()
1248
- });
1249
- /** 撤回消息。 */
1250
- var MessageDeleteAction = class extends BaseSatoriAction {
1251
- name = "message.delete";
1252
- schema = messageDeleteSchema;
1253
- deps;
1254
- constructor(deps) {
1255
- super();
1256
- this.deps = deps;
1257
- }
1258
- async _handle(payload) {
1259
- const { channel_id: channelId, message_id: messageId } = payload;
1260
- const peer = await this.deps.resolvePeer(channelId);
1261
- await this.deps.msgApi.recallMessage(peer, [messageId]);
1262
- }
1263
- };
1264
- // src/satori/action/not-implemented.ts
1265
- /**
1266
- * 未实现动作(501):平台支持但适配器未实现(规范:501 而非 404)。
1267
- */
1268
- /** 未实现动作:schema 接受任意对象,执行抛 501。 */
1269
- var NotImplementedAction = class extends BaseSatoriAction {
1270
- name;
1271
- schema = z.object({}).passthrough();
1272
- constructor(name) {
1273
- super();
1274
- this.name = name;
1275
- }
1276
- async _handle(_payload) {
1277
- throw new SatoriActionError(501, `平台不支持该操作: ${this.name}`);
1278
- }
1279
- };
1056
+ /** 消息动作工厂(create / get / list / delete)。 */
1057
+ function createMessageActions(deps) {
1058
+ return [
1059
+ defineSatoriAction({
1060
+ name: "message.create",
1061
+ schema: messageCreateSchema,
1062
+ handle: async (payload) => {
1063
+ const { channel_id: channelId, content } = payload;
1064
+ const peer = await deps.resolvePeer(channelId);
1065
+ deps.setChannelType(channelId, peer.chatType === 2);
1066
+ const elements = await parseContentToCanonical(content, deps.toCanonicalDeps());
1067
+ const { msgId } = await deps.msgApi.sendMessage(peer, elements);
1068
+ const message = {
1069
+ id: msgId,
1070
+ channel: toChannelById(channelId, peer.chatType === 2)
1071
+ };
1072
+ message.content = content;
1073
+ return [message];
1074
+ }
1075
+ }),
1076
+ defineSatoriAction({
1077
+ name: "message.get",
1078
+ schema: z.object({
1079
+ channel_id: z.string(),
1080
+ message_id: z.string()
1081
+ }),
1082
+ handle: async (payload) => {
1083
+ const { channel_id: channelId, message_id: messageId } = payload;
1084
+ const peer = await deps.resolvePeer(channelId);
1085
+ const first = (await deps.msgApi.fetchMsgsByMsgId(peer, [messageId]))[0];
1086
+ if (first === void 0) throw new Error("消息不存在");
1087
+ deps.setChannelType(channelId, peer.chatType === 2);
1088
+ return toSatoriMessage(first, {
1089
+ selfUin: deps.selfUin,
1090
+ uidToUin: (uids) => deps.uidToUin(uids)
1091
+ });
1092
+ }
1093
+ }),
1094
+ defineSatoriAction({
1095
+ name: "message.list",
1096
+ schema: z.object({
1097
+ channel_id: z.string(),
1098
+ /** 分页令牌(缺省从最新开始)。 */
1099
+ next: z.string().optional(),
1100
+ /** 查询方向(缺省 before)。 */
1101
+ direction: z.enum([
1102
+ "before",
1103
+ "after",
1104
+ "around"
1105
+ ]).optional(),
1106
+ /** 消息数量限制(缺省平台默认,推荐 50)。 */
1107
+ limit: z.number().int().optional(),
1108
+ /** 排序(缺省 asc)。 */
1109
+ order: z.enum(["asc", "desc"]).optional()
1110
+ }),
1111
+ handle: async (payload) => {
1112
+ const { channel_id: channelId, next, direction, limit, order } = payload;
1113
+ if (direction === "around") throw new Error("暂不支持 around 方向");
1114
+ const peer = await deps.resolvePeer(channelId);
1115
+ const count = limit ?? DEFAULT_LIST_LIMIT;
1116
+ const raw = await deps.msgApi.fetchMessages(peer, {
1117
+ count,
1118
+ msgId: next ?? ""
1119
+ });
1120
+ deps.setChannelType(channelId, peer.chatType === 2);
1121
+ const ordered = order !== "desc" ? [...raw].reverse() : raw;
1122
+ const messages = [];
1123
+ for (const msg of ordered) messages.push(await toSatoriMessage(msg, {
1124
+ selfUin: deps.selfUin,
1125
+ uidToUin: (uids) => deps.uidToUin(uids)
1126
+ }));
1127
+ const last = messages[messages.length - 1];
1128
+ const out = { data: messages };
1129
+ if (last !== void 0 && raw.length >= count) out.next = last.id;
1130
+ return out;
1131
+ }
1132
+ }),
1133
+ defineSatoriAction({
1134
+ name: "message.delete",
1135
+ schema: z.object({
1136
+ channel_id: z.string(),
1137
+ message_id: z.string()
1138
+ }),
1139
+ handle: async (payload) => {
1140
+ const { channel_id: channelId, message_id: messageId } = payload;
1141
+ const peer = await deps.resolvePeer(channelId);
1142
+ await deps.msgApi.recallMessage(peer, [messageId]);
1143
+ }
1144
+ })
1145
+ ];
1146
+ }
1280
1147
  // src/satori/action/reaction.ts
1281
1148
  /**
1282
1149
  * Satori 表态动作:reaction.create / reaction.delete
@@ -1284,106 +1151,83 @@ var NotImplementedAction = class extends BaseSatoriAction {
1284
1151
  */
1285
1152
  /** 表情 ID 默认类型(QQ 表情 id 为 qq 表情索引)。 */
1286
1153
  const EMOJI_TYPE = "1";
1287
- /** reaction.create 参数。 */
1288
- const reactionCreateSchema = z.object({
1289
- channel_id: z.string(),
1290
- message_id: z.string(),
1291
- emoji_id: z.string()
1292
- });
1293
- /** 添加表态(QQ 表情表态,message_id = NT msgId)。 */
1294
- var ReactionCreateAction = class extends BaseSatoriAction {
1295
- name = "reaction.create";
1296
- schema = reactionCreateSchema;
1297
- deps;
1298
- constructor(deps) {
1299
- super();
1300
- this.deps = deps;
1301
- }
1302
- async _handle(payload) {
1303
- const { channel_id: channelId, message_id: messageId, emoji_id: emojiId } = payload;
1304
- const peer = await this.deps.resolvePeer(channelId);
1305
- await this.deps.msgApi.setMsgEmojiLike(peer, {
1306
- msgSeq: messageId,
1307
- emojiId,
1308
- emojiType: EMOJI_TYPE,
1309
- like: true
1310
- });
1311
- }
1312
- };
1313
- /** reaction.delete 参数。 */
1314
- const reactionDeleteSchema = z.object({
1315
- channel_id: z.string(),
1316
- message_id: z.string(),
1317
- emoji_id: z.string(),
1318
- /** 删除指定用户的表态(缺省删除自己的)。 */
1319
- user_id: z.string().optional()
1320
- });
1321
- /** 删除表态(第一版仅支持删除自己的,与 QQ 表情表态能力对齐)。 */
1322
- var ReactionDeleteAction = class extends BaseSatoriAction {
1323
- name = "reaction.delete";
1324
- schema = reactionDeleteSchema;
1325
- deps;
1326
- constructor(deps) {
1327
- super();
1328
- this.deps = deps;
1329
- }
1330
- async _handle(payload) {
1331
- const { channel_id: channelId, message_id: messageId, emoji_id: emojiId, user_id: userId } = payload;
1332
- if (userId !== void 0) throw new Error("暂不支持删除他人表态");
1333
- const peer = await this.deps.resolvePeer(channelId);
1334
- await this.deps.msgApi.setMsgEmojiLike(peer, {
1335
- msgSeq: messageId,
1336
- emojiId,
1337
- emojiType: EMOJI_TYPE,
1338
- like: false
1339
- });
1340
- }
1341
- };
1154
+ /** 表态动作工厂(reaction.create / reaction.delete)。 */
1155
+ function createReactionActions(deps) {
1156
+ return [defineSatoriAction({
1157
+ name: "reaction.create",
1158
+ schema: z.object({
1159
+ channel_id: z.string(),
1160
+ message_id: z.string(),
1161
+ emoji_id: z.string()
1162
+ }),
1163
+ handle: async (payload) => {
1164
+ const { channel_id: channelId, message_id: messageId, emoji_id: emojiId } = payload;
1165
+ const peer = await deps.resolvePeer(channelId);
1166
+ await deps.msgApi.setMsgEmojiLike(peer, {
1167
+ msgSeq: messageId,
1168
+ emojiId,
1169
+ emojiType: EMOJI_TYPE,
1170
+ like: true
1171
+ });
1172
+ }
1173
+ }), defineSatoriAction({
1174
+ name: "reaction.delete",
1175
+ schema: z.object({
1176
+ channel_id: z.string(),
1177
+ message_id: z.string(),
1178
+ emoji_id: z.string(),
1179
+ /** 删除指定用户的表态(缺省删除自己的)。 */
1180
+ user_id: z.string().optional()
1181
+ }),
1182
+ handle: async (payload) => {
1183
+ const { channel_id: channelId, message_id: messageId, emoji_id: emojiId, user_id: userId } = payload;
1184
+ if (userId !== void 0) throw new Error("暂不支持删除他人表态");
1185
+ const peer = await deps.resolvePeer(channelId);
1186
+ await deps.msgApi.setMsgEmojiLike(peer, {
1187
+ msgSeq: messageId,
1188
+ emojiId,
1189
+ emojiType: EMOJI_TYPE,
1190
+ like: false
1191
+ });
1192
+ }
1193
+ })];
1194
+ }
1342
1195
  // src/satori/action/user.ts
1343
1196
  /**
1344
1197
  * Satori 用户动作:user.get / user.channel.create
1345
1198
  */
1346
- /** user.get 参数。 */
1347
- const userGetSchema = z.object({ user_id: z.string() });
1348
- /** 获取用户信息(QQ 平台 user.id = uin)。 */
1349
- var UserGetAction = class extends BaseSatoriAction {
1350
- name = "user.get";
1351
- schema = userGetSchema;
1352
- deps;
1353
- constructor(deps) {
1354
- super();
1355
- this.deps = deps;
1356
- }
1357
- async _handle(payload) {
1358
- const { user_id: userId } = payload;
1359
- let nickname;
1360
- try {
1361
- const info = await this.deps.profileApi.getStrangerInfo(userId);
1362
- nickname = info.nickname ?? info.long_nick ?? void 0;
1363
- } catch {}
1364
- return toUser(userId, nickname);
1365
- }
1366
- };
1367
- /** user.channel.create 参数。 */
1368
- const userChannelCreateSchema = z.object({
1369
- user_id: z.string(),
1370
- guild_id: z.string().optional()
1371
- });
1372
- /** 创建私聊频道(QQ:私聊频道 id = 对端 uin,无需实际创建)。 */
1373
- var UserChannelCreateAction = class extends BaseSatoriAction {
1374
- name = "user.channel.create";
1375
- schema = userChannelCreateSchema;
1376
- async _handle(payload) {
1377
- const { user_id: userId } = payload;
1378
- return toChannelById(userId, false);
1379
- }
1380
- };
1199
+ /** 用户动作工厂(user.get / user.channel.create)。 */
1200
+ function createUserActions(deps) {
1201
+ return [defineSatoriAction({
1202
+ name: "user.get",
1203
+ schema: z.object({ user_id: z.string() }),
1204
+ handle: async (payload) => {
1205
+ const { user_id: userId } = payload;
1206
+ let nickname;
1207
+ try {
1208
+ const info = await deps.profileApi.getStrangerInfo(userId);
1209
+ nickname = info.nickname ?? info.long_nick ?? void 0;
1210
+ } catch {}
1211
+ return toUser(userId, nickname);
1212
+ }
1213
+ }), defineSatoriAction({
1214
+ name: "user.channel.create",
1215
+ schema: z.object({
1216
+ user_id: z.string(),
1217
+ guild_id: z.string().optional()
1218
+ }),
1219
+ handle: async (payload) => {
1220
+ const { user_id: userId } = payload;
1221
+ return toChannelById(userId, false);
1222
+ }
1223
+ })];
1224
+ }
1381
1225
  // src/satori/action/index.ts
1382
1226
  /**
1383
- * Satori 动作注册表(ADR-013 延伸):动作依赖收敛为 { api: SatoriApi } 单聚合对象。
1227
+ * Satori 动作注册表:动作依赖收敛为 { api: SatoriApi } 单聚合对象。
1384
1228
  *
1385
1229
  * 501 动作:规范「平台支持但适配器未实现 → 501」——QQ 平台不支持的
1386
- * 能力(消息编辑/频道管理/角色管理等)统一注册 NotImplementedAction。
1230
+ * 能力(消息编辑/频道管理/角色管理等)统一注册同名占位动作。
1387
1231
  */
1388
1232
  /** QQ 平台不支持的 Satori 标准动作(501)。 */
1389
1233
  const NOT_IMPLEMENTED = [
@@ -1405,38 +1249,26 @@ const NOT_IMPLEMENTED = [
1405
1249
  function createSatoriActionRegistry(deps) {
1406
1250
  const registry = new ActionRegistry();
1407
1251
  const { api } = deps;
1408
- const messageDeps = api;
1409
- registry.register(new MessageCreateAction(messageDeps));
1410
- registry.register(new MessageGetAction(messageDeps));
1411
- registry.register(new MessageListAction(messageDeps));
1412
- registry.register(new MessageDeleteAction(messageDeps));
1413
- const channelDeps = api;
1414
- registry.register(new ChannelGetAction(channelDeps));
1415
- registry.register(new ChannelListAction(channelDeps));
1416
- const userDeps = api;
1417
- registry.register(new UserGetAction(userDeps));
1418
- registry.register(new UserChannelCreateAction());
1419
- const guildDeps = api;
1420
- registry.register(new GuildGetAction(guildDeps));
1421
- registry.register(new GuildListAction(guildDeps));
1422
- registry.register(new GuildApproveAction(guildDeps));
1423
- registry.register(new GuildMemberGetAction(guildDeps));
1424
- registry.register(new GuildMemberListAction(guildDeps));
1425
- registry.register(new GuildMemberKickAction(guildDeps));
1426
- registry.register(new GuildMemberMuteAction(guildDeps));
1427
- registry.register(new GuildMemberApproveAction(guildDeps));
1428
- const friendDeps = api;
1429
- registry.register(new FriendListAction(friendDeps));
1430
- registry.register(new FriendDeleteAction(friendDeps));
1431
- registry.register(new FriendApproveAction(friendDeps));
1432
- const loginDeps = api;
1433
- registry.register(new LoginGetAction(loginDeps));
1434
- const reactionDeps = api;
1435
- registry.register(new ReactionCreateAction(reactionDeps));
1436
- registry.register(new ReactionDeleteAction(reactionDeps));
1437
- for (const name of NOT_IMPLEMENTED) registry.register(new NotImplementedAction(name));
1252
+ for (const action of [
1253
+ ...createMessageActions(api),
1254
+ ...createChannelActions(api),
1255
+ ...createUserActions(api),
1256
+ ...createGuildActions(api),
1257
+ ...createFriendActions(api),
1258
+ ...createLoginActions(api),
1259
+ ...createReactionActions(api)
1260
+ ]) registry.register(action);
1261
+ for (const name of NOT_IMPLEMENTED) registry.register(defineSatoriAction({
1262
+ name,
1263
+ schema: notImplementedSchema,
1264
+ handle: async () => {
1265
+ throw new SatoriActionError(501, `平台不支持该操作: ${name}`);
1266
+ }
1267
+ }));
1438
1268
  return registry;
1439
1269
  }
1270
+ /** 501 占位动作共用 schema(接受任意对象)。 */
1271
+ const notImplementedSchema = z.object({}).passthrough();
1440
1272
  // src/satori/api/satori-api.ts
1441
1273
  /** Satori 动作统一依赖聚合。 */
1442
1274
  var SatoriApi = class {
@@ -1818,7 +1650,7 @@ var NapukettoSatoriAdapter = class extends BaseProtocolAdapter {
1818
1650
  return toLogin(this.api.self, 0, true);
1819
1651
  }
1820
1652
  /**
1821
- * 配置热更新(2026-09-08 实现):stop 旧传输/退订(广播 login-updated 离线)→
1653
+ * 配置热更新(实现):stop 旧传输/退订(广播 login-updated 离线)→
1822
1654
  * 按新配置重建(广播在线)。Satori 无 IPC 桥模式,无传输时同样走重建路径。
1823
1655
  */
1824
1656
  async reloadTransports(config) {
@@ -1853,7 +1685,7 @@ var NapukettoSatoriAdapter = class extends BaseProtocolAdapter {
1853
1685
  this.broadcastGrayTip(msg).catch(() => {});
1854
1686
  return;
1855
1687
  }
1856
- this.broadcastMessageCreated(msg);
1688
+ this.broadcastMessageCreated(msg).catch(() => {});
1857
1689
  });
1858
1690
  });
1859
1691
  }