@zhin.js/adapter-icqq 1.0.71 → 1.1.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 (111) hide show
  1. package/CHANGELOG.md +1125 -52
  2. package/README.md +116 -431
  3. package/adapters/icqq.js +31 -0
  4. package/adapters/icqq.ts +42 -0
  5. package/agent/PERMITS.md +24 -0
  6. package/agent/prompt-sections/platform.ts +17 -0
  7. package/commands/endpoint/add/[[id]].js +3 -0
  8. package/commands/endpoint/add/[[id]].ts +3 -0
  9. package/commands/endpoint/list.js +3 -0
  10. package/commands/endpoint/list.ts +3 -0
  11. package/commands/endpoint/remove/[id].js +3 -0
  12. package/commands/endpoint/remove/[id].ts +3 -0
  13. package/lib/client.d.ts +19 -0
  14. package/lib/client.js +3 -0
  15. package/lib/cq-message.d.ts +14 -0
  16. package/lib/cq-message.js +106 -0
  17. package/lib/endpoint.d.ts +31 -0
  18. package/lib/endpoint.js +1046 -0
  19. package/lib/forward-msg.d.ts +6 -0
  20. package/lib/forward-msg.js +107 -0
  21. package/lib/icqq-endpoint-commands.d.ts +1 -0
  22. package/lib/icqq-endpoint-commands.js +26 -0
  23. package/lib/icqq-guild.d.ts +57 -0
  24. package/lib/icqq-guild.js +109 -0
  25. package/lib/icqq-inbound.d.ts +165 -0
  26. package/lib/icqq-inbound.js +651 -0
  27. package/lib/icqq-inbox.d.ts +25 -0
  28. package/lib/icqq-inbox.js +129 -0
  29. package/lib/icqq-login-assist.d.ts +27 -0
  30. package/lib/icqq-login-assist.js +109 -0
  31. package/lib/icqq-runtime-state.d.ts +1 -0
  32. package/lib/icqq-runtime-state.js +6 -0
  33. package/lib/index.d.ts +5 -18
  34. package/lib/index.js +5 -124
  35. package/lib/outbound-media.d.ts +14 -0
  36. package/lib/outbound-media.js +76 -0
  37. package/lib/protocol.d.ts +276 -0
  38. package/lib/protocol.js +425 -0
  39. package/lib/types.d.ts +37 -11
  40. package/lib/types.js +0 -1
  41. package/package.json +80 -32
  42. package/plugin.js +19 -0
  43. package/schema.json +162 -0
  44. package/src/client.ts +29 -0
  45. package/src/cq-message.ts +113 -0
  46. package/src/endpoint.ts +1138 -0
  47. package/src/forward-msg.ts +112 -0
  48. package/src/icqq-endpoint-commands.ts +28 -0
  49. package/src/icqq-guild.ts +154 -0
  50. package/src/icqq-inbound.ts +814 -0
  51. package/src/icqq-inbox.ts +147 -0
  52. package/src/icqq-login-assist.ts +132 -0
  53. package/src/icqq-runtime-state.ts +7 -0
  54. package/src/index.ts +30 -149
  55. package/src/outbound-media.ts +103 -0
  56. package/src/protocol.ts +575 -0
  57. package/src/types.ts +40 -11
  58. package/tools/announce.js +16 -0
  59. package/tools/announce.ts +15 -0
  60. package/tools/essence.js +22 -0
  61. package/tools/essence.ts +20 -0
  62. package/tools/friend_list.js +18 -0
  63. package/tools/friend_list.ts +18 -0
  64. package/tools/group_files.js +22 -0
  65. package/tools/group_files.ts +20 -0
  66. package/tools/group_invite.js +23 -0
  67. package/tools/group_invite.ts +20 -0
  68. package/tools/group_kick.js +26 -0
  69. package/tools/group_kick.ts +22 -0
  70. package/tools/group_list.js +19 -0
  71. package/tools/group_list.ts +19 -0
  72. package/tools/group_member_info.js +24 -0
  73. package/tools/group_member_info.ts +26 -0
  74. package/tools/group_sign.js +19 -0
  75. package/tools/group_sign.ts +17 -0
  76. package/tools/list_muted.js +17 -0
  77. package/tools/list_muted.ts +16 -0
  78. package/tools/poke.js +16 -0
  79. package/tools/poke.ts +15 -0
  80. package/tools/send_user_like.js +25 -0
  81. package/tools/send_user_like.ts +22 -0
  82. package/tools/set_anonymous.js +21 -0
  83. package/tools/set_anonymous.ts +19 -0
  84. package/tools/set_mute.js +24 -0
  85. package/tools/set_mute.ts +21 -0
  86. package/tools/set_title.js +25 -0
  87. package/tools/set_title.ts +22 -0
  88. package/tools/user_info.js +14 -0
  89. package/tools/user_info.ts +13 -0
  90. package/LICENSE +0 -21
  91. package/client/ICQQManagement.tsx +0 -139
  92. package/client/LoginAssistPanel.tsx +0 -293
  93. package/client/index.tsx +0 -11
  94. package/client/tsconfig.json +0 -7
  95. package/client/utils/api.ts +0 -20
  96. package/dist/index.js +0 -1
  97. package/lib/adapter.d.ts +0 -34
  98. package/lib/adapter.d.ts.map +0 -1
  99. package/lib/adapter.js +0 -396
  100. package/lib/adapter.js.map +0 -1
  101. package/lib/bot.d.ts +0 -46
  102. package/lib/bot.d.ts.map +0 -1
  103. package/lib/bot.js +0 -457
  104. package/lib/bot.js.map +0 -1
  105. package/lib/index.d.ts.map +0 -1
  106. package/lib/index.js.map +0 -1
  107. package/lib/types.d.ts.map +0 -1
  108. package/lib/types.js.map +0 -1
  109. package/skills/icqq/SKILL.md +0 -22
  110. package/src/adapter.ts +0 -448
  111. package/src/bot.ts +0 -521
@@ -0,0 +1,276 @@
1
+ import type { Sendable } from '@icqqjs/icqq';
2
+ import type { ConversationRef } from '@zhin.js/im-contract';
3
+ import type { MessageSegment } from "zhin.js";
4
+ export type ActionResult = {
5
+ id: string;
6
+ ok: boolean;
7
+ data?: unknown;
8
+ error?: string;
9
+ };
10
+ export type { IcqqMessageEvent } from "./icqq-inbound.js";
11
+ export { resolveIcqqInboundMessageId } from "./icqq-inbound.js";
12
+ export interface GuildMessageEventData {
13
+ type: "guild";
14
+ guild_id: string;
15
+ guild_name: string;
16
+ channel_id: string;
17
+ channel_name: string;
18
+ nickname: string;
19
+ tiny_id: string;
20
+ raw_message: string;
21
+ time: number;
22
+ seq: number;
23
+ }
24
+ /**
25
+ * 所有操作常量(@icqqjs/icqq)
26
+ */
27
+ export declare const Actions: {
28
+ readonly PING: "ping";
29
+ readonly LOGOUT: "logout";
30
+ readonly LIST_FRIENDS: "list_friends";
31
+ readonly LIST_GROUPS: "list_groups";
32
+ readonly LIST_GROUP_MEMBERS: "list_group_members";
33
+ readonly LIST_BLACKLIST: "list_blacklist";
34
+ readonly LIST_FRIEND_CLASSES: "list_friend_classes";
35
+ readonly GET_FRIEND_INFO: "get_friend_info";
36
+ readonly GET_GROUP_INFO: "get_group_info";
37
+ readonly GET_GROUP_MEMBER_INFO: "get_group_member_info";
38
+ readonly GET_STRANGER_INFO: "get_stranger_info";
39
+ readonly LIST_STRANGERS: "list_strangers";
40
+ readonly GET_PROFILE: "get_profile";
41
+ readonly GET_STATUS: "get_status";
42
+ readonly GET_ONLINE_STATUS: "get_online_status";
43
+ readonly GET_SELF_PROFILE: "get_self_profile";
44
+ readonly SEND_PRIVATE_MSG: "send_private_msg";
45
+ readonly SEND_GROUP_MSG: "send_group_msg";
46
+ readonly RECALL_MSG: "recall_msg";
47
+ readonly GET_MSG: "get_msg";
48
+ readonly HISTORY_PRIVATE: "history_private";
49
+ readonly HISTORY_GROUP: "history_group";
50
+ readonly HISTORY_BY_MSG_ID: "history_by_msg_id";
51
+ readonly SEND_LONG_MSG: "send_long_msg";
52
+ readonly MARK_READ: "mark_read";
53
+ readonly DELETE_MSG: "delete_msg";
54
+ readonly SET_NICKNAME: "set_nickname";
55
+ readonly SET_GENDER: "set_gender";
56
+ readonly SET_BIRTHDAY: "set_birthday";
57
+ readonly SET_SIGNATURE: "set_signature";
58
+ readonly SET_DESCRIPTION: "set_description";
59
+ readonly SET_AVATAR: "set_avatar";
60
+ readonly SET_ONLINE_STATUS: "set_online_status";
61
+ readonly SET_GROUP_NAME: "set_group_name";
62
+ readonly SET_GROUP_AVATAR: "set_group_avatar";
63
+ readonly SET_GROUP_CARD: "set_group_card";
64
+ readonly SET_GROUP_TITLE: "set_group_title";
65
+ readonly SET_GROUP_ADMIN: "set_group_admin";
66
+ readonly SET_GROUP_REMARK: "set_group_remark";
67
+ readonly GROUP_MUTE: "group_mute";
68
+ readonly GROUP_MUTE_ALL: "group_mute_all";
69
+ readonly GROUP_KICK: "group_kick";
70
+ readonly GROUP_QUIT: "group_quit";
71
+ readonly GROUP_INVITE: "group_invite";
72
+ readonly GROUP_POKE: "group_poke";
73
+ readonly GROUP_ANNOUNCE: "group_announce";
74
+ readonly GROUP_SIGN: "group_sign";
75
+ readonly GROUP_ESSENCE_ADD: "group_essence_add";
76
+ readonly GROUP_ESSENCE_REMOVE: "group_essence_remove";
77
+ readonly GROUP_ALLOW_ANONY: "group_allow_anony";
78
+ readonly GROUP_MUTED_LIST: "group_muted_list";
79
+ readonly GROUP_AT_ALL_REMAIN: "group_at_all_remain";
80
+ readonly FRIEND_POKE: "friend_poke";
81
+ readonly FRIEND_LIKE: "friend_like";
82
+ readonly FRIEND_DELETE: "friend_delete";
83
+ readonly FRIEND_REMARK: "friend_remark";
84
+ readonly FRIEND_CLASS: "friend_class";
85
+ readonly GET_SYSTEM_MSG: "get_system_msg";
86
+ readonly HANDLE_FRIEND_REQUEST: "handle_friend_request";
87
+ readonly HANDLE_GROUP_REQUEST: "handle_group_request";
88
+ readonly ADD_FRIEND_CLASS: "add_friend_class";
89
+ readonly DELETE_FRIEND_CLASS: "delete_friend_class";
90
+ readonly RENAME_FRIEND_CLASS: "rename_friend_class";
91
+ readonly GFS_LIST: "gfs_list";
92
+ readonly GFS_INFO: "gfs_info";
93
+ readonly GFS_MKDIR: "gfs_mkdir";
94
+ readonly GFS_DELETE: "gfs_delete";
95
+ readonly GFS_RENAME: "gfs_rename";
96
+ readonly GFS_STAT: "gfs_stat";
97
+ readonly GFS_MOVE: "gfs_move";
98
+ readonly GFS_DOWNLOAD: "gfs_download";
99
+ readonly IMAGE_OCR: "image_ocr";
100
+ readonly RELOAD_FRIEND_LIST: "reload_friend_list";
101
+ readonly RELOAD_GROUP_LIST: "reload_group_list";
102
+ readonly CLEAN_CACHE: "clean_cache";
103
+ readonly GET_GROUP_SHARE: "get_group_share";
104
+ readonly GROUP_SET_JOIN_TYPE: "group_set_join_type";
105
+ readonly GROUP_SET_RATE_LIMIT: "group_set_rate_limit";
106
+ readonly GROUP_MUTE_ANONY: "group_mute_anony";
107
+ readonly GROUP_ANON_INFO: "group_anon_info";
108
+ readonly ADD_FRIEND: "add_friend";
109
+ readonly SEND_TEMP_MSG: "send_temp_msg";
110
+ readonly GET_ROAMING_STAMP: "get_roaming_stamp";
111
+ readonly DELETE_STAMP: "delete_stamp";
112
+ readonly SEND_PRIVATE_FILE: "send_private_file";
113
+ readonly SEND_GROUP_FILE: "send_group_file";
114
+ readonly FRIEND_RECALL_FILE: "friend_recall_file";
115
+ readonly FRIEND_FORWARD_FILE: "friend_forward_file";
116
+ readonly SEARCH_SAME_GROUP: "search_same_group";
117
+ readonly SEND_CONTACT_SHARE: "send_contact_share";
118
+ readonly GFS_UPLOAD: "gfs_upload";
119
+ readonly GROUP_SET_REACTION: "group_set_reaction";
120
+ readonly GROUP_DEL_REACTION: "group_del_reaction";
121
+ readonly GET_FORWARD_MSG: "get_forward_msg";
122
+ readonly MAKE_FORWARD_MSG: "make_forward_msg";
123
+ readonly GUILD_LIST: "guild_list";
124
+ readonly GUILD_INFO: "guild_info";
125
+ readonly GUILD_CHANNELS: "guild_channels";
126
+ readonly GET_CHANNEL_INFO: "get_channel_info";
127
+ readonly GUILD_MEMBERS: "guild_members";
128
+ readonly GUILD_SEND_MSG: "guild_send_msg";
129
+ readonly GUILD_RECALL_MSG: "guild_recall_msg";
130
+ readonly GET_FILE_INFO: "get_file_info";
131
+ readonly GET_FILE_URL: "get_file_url";
132
+ readonly GET_AVATAR_URL: "get_avatar_url";
133
+ readonly GET_GROUP_AVATAR_URL: "get_group_avatar_url";
134
+ readonly SET_SCREEN_MEMBER_MSG: "set_screen_member_msg";
135
+ readonly GFS_FORWARD: "gfs_forward";
136
+ readonly GFS_FORWARD_OFFLINE: "gfs_forward_offline";
137
+ readonly RELOAD_BLACKLIST: "reload_blacklist";
138
+ readonly RELOAD_STRANGER_LIST: "reload_stranger_list";
139
+ readonly RELOAD_GUILDS: "reload_guilds";
140
+ readonly GET_STATUS_INFO: "get_status_info";
141
+ readonly GET_CLIENT_KEY: "get_client_key";
142
+ readonly GET_PSKEY: "get_pskey";
143
+ readonly UID2UIN: "uid2uin";
144
+ readonly UID2UINS: "uid2uins";
145
+ readonly UIN2UID: "uin2uid";
146
+ readonly UIN2UIDS: "uin2uids";
147
+ readonly GET_COOKIES: "get_cookies";
148
+ readonly GET_CSRF_TOKEN: "get_csrf_token";
149
+ readonly REFRESH_NT_PIC_RKEY: "refresh_nt_pic_rkey";
150
+ readonly SEND_DISCUSS_MSG: "send_discuss_msg";
151
+ readonly GET_VIDEO_URL: "get_video_url";
152
+ readonly GET_ADD_FRIEND_SETTING: "get_add_friend_setting";
153
+ readonly GET_FORUM_URL: "get_forum_url";
154
+ readonly GUILD_CHANNEL_SHARE: "guild_channel_share";
155
+ readonly GET_PIC_URL: "get_pic_url";
156
+ readonly GET_PTT_URL: "get_ptt_url";
157
+ readonly SUBSCRIBE: "subscribe";
158
+ readonly UNSUBSCRIBE: "unsubscribe";
159
+ readonly SET_WEBHOOK: "set_webhook";
160
+ readonly GET_WEBHOOK: "get_webhook";
161
+ readonly SET_NOTIFY: "set_notify";
162
+ readonly GET_NOTIFY: "get_notify";
163
+ };
164
+ /** Plugin Runtime owner config (`plugins.<instanceKey>` / schema.json). */
165
+ export interface IcqqAdapterConfig {
166
+ readonly id?: string;
167
+ readonly autoReconnect?: boolean;
168
+ readonly outboundMedia?: 'file' | 'base64';
169
+ readonly password?: string;
170
+ readonly platform?: number;
171
+ readonly ver?: string;
172
+ readonly dataDir?: string;
173
+ readonly signApiAddr?: string;
174
+ readonly ignoreSelf?: boolean;
175
+ readonly resend?: boolean;
176
+ readonly cacheGroupMember?: boolean;
177
+ readonly autoServer?: boolean;
178
+ readonly qqnt?: boolean;
179
+ readonly ntLogin?: boolean;
180
+ /** Transitional: legacy root `endpoints[]` with `context: icqq`. */
181
+ readonly endpoints?: ReadonlyArray<{
182
+ readonly context?: string;
183
+ readonly id?: string;
184
+ readonly autoReconnect?: boolean;
185
+ readonly outboundMedia?: 'file' | 'base64';
186
+ readonly password?: string;
187
+ readonly platform?: number;
188
+ readonly ver?: string;
189
+ readonly dataDir?: string;
190
+ readonly signApiAddr?: string;
191
+ readonly ignoreSelf?: boolean;
192
+ readonly resend?: boolean;
193
+ readonly cacheGroupMember?: boolean;
194
+ readonly autoServer?: boolean;
195
+ readonly qqnt?: boolean;
196
+ readonly ntLogin?: boolean;
197
+ }>;
198
+ }
199
+ export interface ResolvedIcqqConfig {
200
+ readonly context: 'icqq';
201
+ readonly id: string;
202
+ readonly autoReconnect: boolean;
203
+ readonly outboundMedia?: 'file' | 'base64';
204
+ readonly password?: string;
205
+ readonly platform?: number;
206
+ readonly ver?: string;
207
+ readonly dataDir?: string;
208
+ readonly signApiAddr?: string;
209
+ readonly ignoreSelf?: boolean;
210
+ readonly resend?: boolean;
211
+ readonly cacheGroupMember?: boolean;
212
+ readonly autoServer?: boolean;
213
+ readonly qqnt?: boolean;
214
+ readonly ntLogin?: boolean;
215
+ }
216
+ export interface IcqqWireSegment {
217
+ readonly type: string;
218
+ readonly data?: Record<string, unknown>;
219
+ }
220
+ export interface IcqqInboundMessage {
221
+ readonly id: string;
222
+ readonly conversation: ConversationRef;
223
+ readonly content: string;
224
+ /**
225
+ * 结构化段视图(canonical Segment,经 toCanonicalSegments 归一)。
226
+ * 与 content(CQ 原文纯文本视图)同源,随 gateway.receive 上送。
227
+ */
228
+ readonly segments?: readonly MessageSegment[];
229
+ readonly sender: {
230
+ readonly id: string;
231
+ readonly name?: string;
232
+ };
233
+ readonly channelType: 'private' | 'group' | 'channel';
234
+ readonly metadata?: Record<string, unknown>;
235
+ readonly replyTo?: {
236
+ readonly id: string;
237
+ };
238
+ }
239
+ export type ParsedIcqqSendTarget = {
240
+ readonly kind: 'private';
241
+ readonly userId: number;
242
+ } | {
243
+ readonly kind: 'group';
244
+ readonly groupId: number;
245
+ } | {
246
+ readonly kind: 'temp';
247
+ readonly groupId: number;
248
+ readonly userId: number;
249
+ } | {
250
+ readonly kind: 'channel';
251
+ readonly guildId: string;
252
+ readonly channelId: string;
253
+ };
254
+ export declare function resolveIcqqConfig(config?: IcqqAdapterConfig): ResolvedIcqqConfig;
255
+ /**
256
+ * 入站归一化 → ConversationRef:群临时会话(temp)映射为群容器内的 private
257
+ * 会话(parent kind 'group');频道消息的所属 guild 进 `parent`(kind 'channel')。
258
+ */
259
+ export declare function icqqInboundConversation(endpointKey: string, input: {
260
+ readonly channelType: 'private' | 'group' | 'channel';
261
+ readonly channelId: string;
262
+ readonly channelParentGroupId?: string;
263
+ readonly guildId?: string;
264
+ }): ConversationRef;
265
+ /**
266
+ * 出站:从 ConversationRef 派生 action 路由。
267
+ * 群容器(parent kind 'group')内的 private 会话即 ICQQ 群临时会话(temp)。
268
+ */
269
+ export declare function icqqOutboundTarget(conversation: ConversationRef): ParsedIcqqSendTarget;
270
+ /**
271
+ * Project canonical Zhin segments directly into the native ICQQ Sendable
272
+ * algebra. ICQQ's direct client does not parse Zhin's historical `[image:x]`
273
+ * notation; passing that notation would send it as literal text.
274
+ */
275
+ export declare function formatOutboundBody(payload: unknown): Sendable;
276
+ export declare function formatInboundContent(rawMessage: string): string;