@zhin.js/adapter-napcat 3.0.1 → 4.0.1
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/CHANGELOG.md +58 -0
- package/README.md +43 -96
- package/adapters/napcat.ts +39 -0
- package/agent/tools/ai_tts.ts +21 -0
- package/agent/tools/del_group_notice.ts +22 -0
- package/agent/tools/delete_essence_msg.ts +21 -0
- package/agent/tools/delete_friend.ts +20 -0
- package/agent/tools/download_file.ts +19 -0
- package/agent/tools/forward_single_msg.ts +32 -0
- package/agent/tools/get_ai_characters.ts +19 -0
- package/agent/tools/get_essence_list.ts +19 -0
- package/agent/tools/get_friend_msg_history.ts +20 -0
- package/agent/tools/get_group_file_url.ts +21 -0
- package/agent/tools/get_group_info_ex.ts +19 -0
- package/agent/tools/get_group_msg_history.ts +21 -0
- package/agent/tools/get_group_notice.ts +19 -0
- package/agent/tools/get_group_root_files.ts +19 -0
- package/agent/tools/get_group_shut_list.ts +19 -0
- package/agent/tools/get_mini_app_ark.ts +22 -0
- package/agent/tools/get_user_status.ts +18 -0
- package/agent/tools/group_sign.ts +20 -0
- package/agent/tools/mark_msg_as_read.ts +19 -0
- package/agent/tools/ocr_image.ts +18 -0
- package/agent/tools/send_forward_msg.ts +31 -0
- package/agent/tools/send_group_notice.ts +23 -0
- package/agent/tools/send_like.ts +20 -0
- package/agent/tools/send_poke.ts +20 -0
- package/agent/tools/set_avatar.ts +19 -0
- package/agent/tools/set_emoji_reaction.ts +20 -0
- package/agent/tools/set_essence_msg.ts +21 -0
- package/agent/tools/set_group_portrait.ts +22 -0
- package/agent/tools/set_online_status.ts +20 -0
- package/agent/tools/set_profile.ts +23 -0
- package/agent/tools/set_signature.ts +19 -0
- package/agent/tools/set_title.ts +23 -0
- package/agent/tools/translate.ts +18 -0
- package/agent/tools/upload_group_file.ts +23 -0
- package/lib/http-endpoint.d.ts +26 -0
- package/lib/http-endpoint.js +147 -0
- package/lib/index.d.ts +11 -21
- package/lib/index.js +10 -59
- package/lib/napcat-agent-deps.d.ts +51 -0
- package/lib/napcat-agent-deps.js +33 -0
- package/lib/napcat-inbound.d.ts +12 -5
- package/lib/napcat-inbound.js +28 -13
- package/lib/onebot-get-msg.d.ts +13 -2
- package/lib/onebot-get-msg.js +0 -1
- package/lib/protocol.d.ts +151 -0
- package/lib/protocol.js +217 -0
- package/lib/webhook.d.ts +2 -0
- package/lib/webhook.js +14 -0
- package/lib/ws-endpoint.d.ts +61 -0
- package/lib/ws-endpoint.js +357 -0
- package/lib/ws-transport.d.ts +13 -0
- package/lib/ws-transport.js +75 -0
- package/lib/ws-types.d.ts +17 -0
- package/lib/ws-types.js +1 -0
- package/lib/wss-auth.d.ts +2 -0
- package/lib/wss-auth.js +16 -0
- package/lib/wss-endpoint.d.ts +25 -0
- package/lib/wss-endpoint.js +157 -0
- package/package.json +48 -32
- package/plugin.ts +13 -0
- package/schema.json +48 -0
- package/src/http-endpoint.ts +197 -0
- package/src/index.ts +66 -82
- package/src/napcat-agent-deps.ts +95 -0
- package/src/napcat-inbound.ts +34 -10
- package/src/onebot-get-msg.ts +8 -2
- package/src/protocol.ts +373 -0
- package/src/webhook.ts +16 -0
- package/src/ws-endpoint.ts +452 -0
- package/src/ws-transport.ts +105 -0
- package/src/ws-types.ts +20 -0
- package/src/wss-auth.ts +17 -0
- package/src/wss-endpoint.ts +205 -0
- package/client/NapCatManagement.tsx +0 -113
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -27
- package/lib/adapter.d.ts +0 -36
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -102
- package/lib/adapter.js.map +0 -1
- package/lib/agent-prompt.d.ts +0 -3
- package/lib/agent-prompt.d.ts.map +0 -1
- package/lib/agent-prompt.js +0 -106
- package/lib/agent-prompt.js.map +0 -1
- package/lib/endpoint-base.d.ts +0 -144
- package/lib/endpoint-base.d.ts.map +0 -1
- package/lib/endpoint-base.js +0 -341
- package/lib/endpoint-base.js.map +0 -1
- package/lib/endpoint-http.d.ts +0 -17
- package/lib/endpoint-http.d.ts.map +0 -1
- package/lib/endpoint-http.js +0 -106
- package/lib/endpoint-http.js.map +0 -1
- package/lib/endpoint-ws-client.d.ts +0 -20
- package/lib/endpoint-ws-client.d.ts.map +0 -1
- package/lib/endpoint-ws-client.js +0 -139
- package/lib/endpoint-ws-client.js.map +0 -1
- package/lib/endpoint-ws-server.d.ts +0 -20
- package/lib/endpoint-ws-server.d.ts.map +0 -1
- package/lib/endpoint-ws-server.js +0 -137
- package/lib/endpoint-ws-server.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/napcat-inbound.d.ts.map +0 -1
- package/lib/napcat-inbound.js.map +0 -1
- package/lib/onebot-get-msg.d.ts.map +0 -1
- package/lib/onebot-get-msg.js.map +0 -1
- package/lib/routes.d.ts +0 -4
- package/lib/routes.d.ts.map +0 -1
- package/lib/routes.js +0 -61
- package/lib/routes.js.map +0 -1
- package/lib/segment-mapper.d.ts +0 -2
- package/lib/segment-mapper.d.ts.map +0 -1
- package/lib/segment-mapper.js +0 -2
- package/lib/segment-mapper.js.map +0 -1
- package/lib/tools.d.ts +0 -8
- package/lib/tools.d.ts.map +0 -1
- package/lib/tools.js +0 -605
- package/lib/tools.js.map +0 -1
- package/lib/types.d.ts +0 -275
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/adapter.ts +0 -109
- package/src/agent-prompt.ts +0 -116
- package/src/endpoint-base.ts +0 -386
- package/src/endpoint-http.ts +0 -95
- package/src/endpoint-ws-client.ts +0 -137
- package/src/endpoint-ws-server.ts +0 -136
- package/src/routes.ts +0 -61
- package/src/segment-mapper.ts +0 -1
- package/src/tools.ts +0 -632
- package/src/types.ts +0 -266
- /package/{skills/napcat → agent}/PERMITS.md +0 -0
- /package/{skills/napcat/SKILL.md → agent/skills/napcat.md} +0 -0
package/src/types.ts
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NapCat 适配器类型定义
|
|
3
|
-
* 覆盖 OneBot11 标准 + go-cqhttp 扩展 + NapCat 独有 API
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ── 配置 ─────────────────────────────────────────────────────────────
|
|
7
|
-
|
|
8
|
-
export interface NapCatConfigBase {
|
|
9
|
-
context: 'napcat';
|
|
10
|
-
name: string;
|
|
11
|
-
access_token?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** 正向 WebSocket */
|
|
15
|
-
export interface NapCatWsClientConfig extends NapCatConfigBase {
|
|
16
|
-
connection: 'ws';
|
|
17
|
-
url: string;
|
|
18
|
-
reconnect_interval?: number;
|
|
19
|
-
heartbeat_interval?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** 反向 WebSocket */
|
|
23
|
-
export interface NapCatWsServerConfig extends NapCatConfigBase {
|
|
24
|
-
connection: 'wss';
|
|
25
|
-
path: string;
|
|
26
|
-
heartbeat_interval?: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** HTTP API + POST 上报 */
|
|
30
|
-
export interface NapCatHttpConfig extends NapCatConfigBase {
|
|
31
|
-
connection: 'http';
|
|
32
|
-
/** NapCat HTTP API 地址,如 http://127.0.0.1:3000 */
|
|
33
|
-
http_url: string;
|
|
34
|
-
/** HTTP POST 事件上报接收路径,如 /napcat/post */
|
|
35
|
-
post_path: string;
|
|
36
|
-
/** 轮询间隔(ms),用于 HTTP 心跳检测,默认 30000 */
|
|
37
|
-
poll_interval?: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type NapCatEndpointConfig = NapCatWsClientConfig | NapCatWsServerConfig | NapCatHttpConfig;
|
|
41
|
-
|
|
42
|
-
// ── API 响应 ─────────────────────────────────────────────────────────
|
|
43
|
-
|
|
44
|
-
export interface ApiResponse<T = any> {
|
|
45
|
-
status: string;
|
|
46
|
-
retcode: number;
|
|
47
|
-
data: T;
|
|
48
|
-
echo?: string;
|
|
49
|
-
message?: string;
|
|
50
|
-
wording?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ── OneBot11 消息段 ──────────────────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
export interface MessageSegment {
|
|
56
|
-
type: string;
|
|
57
|
-
data: Record<string, any>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ── OneBot11 事件基础 ────────────────────────────────────────────────
|
|
61
|
-
|
|
62
|
-
export interface NapCatEvent {
|
|
63
|
-
post_type: 'message' | 'message_sent' | 'notice' | 'request' | 'meta_event';
|
|
64
|
-
self_id: number;
|
|
65
|
-
time: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface NapCatMessageEvent extends NapCatEvent {
|
|
69
|
-
post_type: 'message' | 'message_sent';
|
|
70
|
-
message_type: 'private' | 'group';
|
|
71
|
-
sub_type: string;
|
|
72
|
-
message_id: number;
|
|
73
|
-
user_id: number;
|
|
74
|
-
group_id?: number;
|
|
75
|
-
message: MessageSegment[];
|
|
76
|
-
raw_message: string;
|
|
77
|
-
font: number;
|
|
78
|
-
sender: {
|
|
79
|
-
user_id: number;
|
|
80
|
-
nickname: string;
|
|
81
|
-
card?: string;
|
|
82
|
-
sex?: string;
|
|
83
|
-
age?: number;
|
|
84
|
-
area?: string;
|
|
85
|
-
level?: string;
|
|
86
|
-
role?: 'owner' | 'admin' | 'member';
|
|
87
|
-
title?: string;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface NapCatNoticeEvent extends NapCatEvent {
|
|
92
|
-
post_type: 'notice';
|
|
93
|
-
notice_type: string;
|
|
94
|
-
sub_type?: string;
|
|
95
|
-
group_id?: number;
|
|
96
|
-
user_id?: number;
|
|
97
|
-
operator_id?: number;
|
|
98
|
-
message_id?: number;
|
|
99
|
-
target_id?: number;
|
|
100
|
-
file?: { id: string; name: string; size: number; busid: number; url?: string };
|
|
101
|
-
duration?: number;
|
|
102
|
-
sender_id?: number;
|
|
103
|
-
title?: string;
|
|
104
|
-
action?: string;
|
|
105
|
-
suffix?: string;
|
|
106
|
-
comment?: string;
|
|
107
|
-
flag?: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface NapCatRequestEvent extends NapCatEvent {
|
|
111
|
-
post_type: 'request';
|
|
112
|
-
request_type: 'friend' | 'group';
|
|
113
|
-
sub_type?: string;
|
|
114
|
-
user_id: number;
|
|
115
|
-
group_id?: number;
|
|
116
|
-
comment?: string;
|
|
117
|
-
flag: string;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface NapCatMetaEvent extends NapCatEvent {
|
|
121
|
-
post_type: 'meta_event';
|
|
122
|
-
meta_event_type: string;
|
|
123
|
-
sub_type?: string;
|
|
124
|
-
status?: any;
|
|
125
|
-
interval?: number;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ── 发送者信息 ───────────────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
export interface SenderInfo {
|
|
131
|
-
id: string;
|
|
132
|
-
name: string;
|
|
133
|
-
role?: 'owner' | 'admin' | 'member';
|
|
134
|
-
isOwner?: boolean;
|
|
135
|
-
isAdmin?: boolean;
|
|
136
|
-
card?: string;
|
|
137
|
-
title?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ── API 数据类型 ─────────────────────────────────────────────────────
|
|
141
|
-
|
|
142
|
-
export interface LoginInfo {
|
|
143
|
-
user_id: number;
|
|
144
|
-
nickname: string;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface StrangerInfo {
|
|
148
|
-
user_id: number;
|
|
149
|
-
nickname: string;
|
|
150
|
-
sex: string;
|
|
151
|
-
age: number;
|
|
152
|
-
qid?: string;
|
|
153
|
-
level?: number;
|
|
154
|
-
login_days?: number;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface FriendInfo {
|
|
158
|
-
user_id: number;
|
|
159
|
-
nickname: string;
|
|
160
|
-
remark: string;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export interface GroupInfo {
|
|
164
|
-
group_id: number;
|
|
165
|
-
group_name: string;
|
|
166
|
-
group_memo?: string;
|
|
167
|
-
group_create_time?: number;
|
|
168
|
-
group_level?: number;
|
|
169
|
-
member_count: number;
|
|
170
|
-
max_member_count: number;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface GroupMemberInfo {
|
|
174
|
-
group_id: number;
|
|
175
|
-
user_id: number;
|
|
176
|
-
nickname: string;
|
|
177
|
-
card: string;
|
|
178
|
-
sex: string;
|
|
179
|
-
age: number;
|
|
180
|
-
area: string;
|
|
181
|
-
join_time: number;
|
|
182
|
-
last_sent_time: number;
|
|
183
|
-
level: string;
|
|
184
|
-
role: 'owner' | 'admin' | 'member';
|
|
185
|
-
unfriendly: boolean;
|
|
186
|
-
title: string;
|
|
187
|
-
title_expire_time: number;
|
|
188
|
-
card_changeable: boolean;
|
|
189
|
-
shut_up_timestamp?: number;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface MessageInfo {
|
|
193
|
-
time: number;
|
|
194
|
-
message_type: string;
|
|
195
|
-
message_id: number;
|
|
196
|
-
real_id: number;
|
|
197
|
-
sender: { user_id: number; nickname: string; card?: string };
|
|
198
|
-
message: MessageSegment[];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export interface ForwardMessage {
|
|
202
|
-
messages: Array<{ content: MessageSegment[]; sender: { nickname: string; user_id: number }; time: number }>;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export interface GroupHonorInfo {
|
|
206
|
-
group_id: number;
|
|
207
|
-
current_talkative?: { user_id: number; nickname: string; avatar: string; day_count: number };
|
|
208
|
-
talkative_list?: any[];
|
|
209
|
-
performer_list?: any[];
|
|
210
|
-
legend_list?: any[];
|
|
211
|
-
strong_newbie_list?: any[];
|
|
212
|
-
emotion_list?: any[];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export interface EssenceMessage {
|
|
216
|
-
sender_id: number;
|
|
217
|
-
sender_nick: string;
|
|
218
|
-
sender_time: number;
|
|
219
|
-
operator_id: number;
|
|
220
|
-
operator_nick: string;
|
|
221
|
-
operator_time: number;
|
|
222
|
-
message_id: number;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export interface GroupFileSystemInfo {
|
|
226
|
-
file_count: number;
|
|
227
|
-
limit_count: number;
|
|
228
|
-
used_space: number;
|
|
229
|
-
total_space: number;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export interface GroupFileInfo {
|
|
233
|
-
files: Array<{ group_id: number; file_id: string; file_name: string; busid: number; file_size: number; upload_time: number; dead_time: number; modify_time: number; download_times: number; uploader: number; uploader_name: string }>;
|
|
234
|
-
folders: Array<{ group_id: number; folder_id: string; folder_name: string; create_time: number; creator: number; creator_name: string; total_file_count: number }>;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export interface GroupNotice {
|
|
238
|
-
sender_id: number;
|
|
239
|
-
publish_time: number;
|
|
240
|
-
message: { text: string; images?: Array<{ id: string; height: string; width: string }> };
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export interface VersionInfo {
|
|
244
|
-
app_name: string;
|
|
245
|
-
app_version: string;
|
|
246
|
-
protocol_version: string;
|
|
247
|
-
[key: string]: any;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export interface OnlineStatus {
|
|
251
|
-
status: number;
|
|
252
|
-
ext_status: number;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export interface AiCharacter {
|
|
256
|
-
character_id: string;
|
|
257
|
-
character_name: string;
|
|
258
|
-
preview_url?: string;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export interface CollectionItem {
|
|
262
|
-
id: string;
|
|
263
|
-
type: number;
|
|
264
|
-
content: string;
|
|
265
|
-
create_time: number;
|
|
266
|
-
}
|
|
File without changes
|
|
File without changes
|