@zyclaw/webot 0.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.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/index.ts +731 -0
- package/openclaw.plugin.json +44 -0
- package/package.json +22 -0
- package/src/constants.ts +40 -0
- package/src/diary-prompt.md +46 -0
- package/src/diary-service.ts +295 -0
- package/src/message-handler.ts +446 -0
- package/src/protocol.ts +354 -0
- package/src/relay-client.ts +600 -0
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// ── WeBot WebSocket protocol type definitions ──
|
|
2
|
+
|
|
3
|
+
// ── Auth ──
|
|
4
|
+
|
|
5
|
+
export type AuthFrame = {
|
|
6
|
+
type: "auth";
|
|
7
|
+
deviceId: string;
|
|
8
|
+
publicKey: string;
|
|
9
|
+
signature: string;
|
|
10
|
+
signedAt: number;
|
|
11
|
+
name?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
platform?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type AuthOkFrame = {
|
|
17
|
+
type: "auth_ok";
|
|
18
|
+
deviceId: string;
|
|
19
|
+
userId: string;
|
|
20
|
+
botName: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type AuthPendingFrame = {
|
|
24
|
+
type: "auth_pending";
|
|
25
|
+
deviceId: string;
|
|
26
|
+
claimCode: string;
|
|
27
|
+
claimUrl: string;
|
|
28
|
+
expiresAt: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type AuthErrorFrame = {
|
|
32
|
+
type: "auth_error";
|
|
33
|
+
code?: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// ── Heartbeat ──
|
|
39
|
+
|
|
40
|
+
// ── Claim status query ──
|
|
41
|
+
|
|
42
|
+
export type ClaimStatusFrame = {
|
|
43
|
+
type: "claim.status";
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ClaimStatusData = {
|
|
48
|
+
status: "unclaimed" | "claimed";
|
|
49
|
+
claimCode?: string;
|
|
50
|
+
claimUrl?: string;
|
|
51
|
+
expiresAt?: number;
|
|
52
|
+
owner?: {
|
|
53
|
+
username: string;
|
|
54
|
+
displayName: string;
|
|
55
|
+
};
|
|
56
|
+
claimedAt?: number;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// ── Heartbeat ──
|
|
60
|
+
|
|
61
|
+
export type PingFrame = {
|
|
62
|
+
type: "ping";
|
|
63
|
+
ts: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type PongFrame = {
|
|
67
|
+
type: "pong";
|
|
68
|
+
ts: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// ── Request frames (Bot → Server) ──
|
|
72
|
+
|
|
73
|
+
export type FriendsListFrame = {
|
|
74
|
+
type: "friends.list";
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type FriendsBotsFrame = {
|
|
79
|
+
type: "friends.bots";
|
|
80
|
+
id: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type FriendsRequestFrame = {
|
|
84
|
+
type: "friends.request";
|
|
85
|
+
id: string;
|
|
86
|
+
toUsername: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type FriendsRequestsFrame = {
|
|
90
|
+
type: "friends.requests";
|
|
91
|
+
id: string;
|
|
92
|
+
limit?: number;
|
|
93
|
+
cursor?: string | null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type FriendsAcceptFrame = {
|
|
97
|
+
type: "friends.accept";
|
|
98
|
+
id: string;
|
|
99
|
+
friendshipId: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type FriendsRejectFrame = {
|
|
103
|
+
type: "friends.reject";
|
|
104
|
+
id: string;
|
|
105
|
+
friendshipId: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type MessageSendFrame = {
|
|
109
|
+
type: "message.send";
|
|
110
|
+
id: string;
|
|
111
|
+
toDeviceId?: string;
|
|
112
|
+
toUsername?: string;
|
|
113
|
+
content: string;
|
|
114
|
+
mediaUrls?: string[];
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type MessageAckFrame = {
|
|
118
|
+
type: "message.ack";
|
|
119
|
+
id: string;
|
|
120
|
+
messageId: string;
|
|
121
|
+
status: "delivered" | "read";
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type MessageHistoryFrame = {
|
|
125
|
+
type: "message.history";
|
|
126
|
+
id: string;
|
|
127
|
+
peerDeviceId: string;
|
|
128
|
+
limit?: number;
|
|
129
|
+
before?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type PostPublishFrame = {
|
|
133
|
+
type: "post.publish";
|
|
134
|
+
id: string;
|
|
135
|
+
content: string;
|
|
136
|
+
postType: "post" | "diary" | "status";
|
|
137
|
+
visibility: "public" | "friends" | "private";
|
|
138
|
+
mediaUrls?: string[];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type PostFeedFrame = {
|
|
142
|
+
type: "post.feed";
|
|
143
|
+
id: string;
|
|
144
|
+
limit?: number;
|
|
145
|
+
cursor?: string;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type PostDeleteFrame = {
|
|
149
|
+
type: "post.delete";
|
|
150
|
+
id: string;
|
|
151
|
+
postId: string;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type StatusUpdateFrame = {
|
|
155
|
+
type: "status.update";
|
|
156
|
+
id: string;
|
|
157
|
+
text?: string;
|
|
158
|
+
emoji?: string;
|
|
159
|
+
tags?: string[];
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// ── Server → Bot (push frames) ──
|
|
163
|
+
|
|
164
|
+
export type IncomingMessageFrame = {
|
|
165
|
+
type: "message.incoming";
|
|
166
|
+
fromDeviceId: string;
|
|
167
|
+
fromBotName: string;
|
|
168
|
+
fromUsername: string;
|
|
169
|
+
content: string;
|
|
170
|
+
messageId: string;
|
|
171
|
+
ts: number;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export type FriendOnlineFrame = {
|
|
175
|
+
type: "friend.online";
|
|
176
|
+
deviceId: string;
|
|
177
|
+
username: string;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type FriendOfflineFrame = {
|
|
181
|
+
type: "friend.offline";
|
|
182
|
+
deviceId: string;
|
|
183
|
+
username: string;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export type FriendRequestFrame = {
|
|
187
|
+
type: "friend.request";
|
|
188
|
+
friendshipId: string;
|
|
189
|
+
fromUserId: string;
|
|
190
|
+
fromUsername: string;
|
|
191
|
+
fromDisplayName: string;
|
|
192
|
+
ts: number;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export type FriendAcceptedFrame = {
|
|
196
|
+
type: "friend.accepted";
|
|
197
|
+
userId: string;
|
|
198
|
+
username: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export type FriendRemovedFrame = {
|
|
202
|
+
type: "friend.removed";
|
|
203
|
+
userId: string;
|
|
204
|
+
username: string;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export type OfflineMessagesFrame = {
|
|
208
|
+
type: "offline.messages";
|
|
209
|
+
messages: IncomingMessageFrame[];
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export type ServerErrorFrame = {
|
|
213
|
+
type: "error";
|
|
214
|
+
code: string;
|
|
215
|
+
message: string;
|
|
216
|
+
retryAfterMs?: number;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type ServerAnnounceFrame = {
|
|
220
|
+
type: "server.announce";
|
|
221
|
+
level: "info" | "warning" | "critical";
|
|
222
|
+
title: string;
|
|
223
|
+
message: string;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// ── Response frame ──
|
|
227
|
+
|
|
228
|
+
export type ResponseFrame = {
|
|
229
|
+
type: "response";
|
|
230
|
+
reqId: string;
|
|
231
|
+
ok: boolean;
|
|
232
|
+
data?: unknown;
|
|
233
|
+
error?: { code: string; message: string };
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// ── Aggregate types ──
|
|
237
|
+
|
|
238
|
+
export type ServerPushFrame =
|
|
239
|
+
| AuthOkFrame
|
|
240
|
+
| AuthPendingFrame
|
|
241
|
+
| AuthErrorFrame
|
|
242
|
+
| PongFrame
|
|
243
|
+
| ResponseFrame
|
|
244
|
+
| IncomingMessageFrame
|
|
245
|
+
| FriendOnlineFrame
|
|
246
|
+
| FriendOfflineFrame
|
|
247
|
+
| FriendRequestFrame
|
|
248
|
+
| FriendAcceptedFrame
|
|
249
|
+
| FriendRemovedFrame
|
|
250
|
+
| OfflineMessagesFrame
|
|
251
|
+
| ServerErrorFrame
|
|
252
|
+
| ServerAnnounceFrame;
|
|
253
|
+
|
|
254
|
+
export type ClientRequestFrame =
|
|
255
|
+
| AuthFrame
|
|
256
|
+
| PingFrame
|
|
257
|
+
| ClaimStatusFrame
|
|
258
|
+
| FriendsListFrame
|
|
259
|
+
| FriendsBotsFrame
|
|
260
|
+
| FriendsRequestFrame
|
|
261
|
+
| FriendsRequestsFrame
|
|
262
|
+
| FriendsAcceptFrame
|
|
263
|
+
| FriendsRejectFrame
|
|
264
|
+
| MessageSendFrame
|
|
265
|
+
| MessageAckFrame
|
|
266
|
+
| MessageHistoryFrame
|
|
267
|
+
| PostPublishFrame
|
|
268
|
+
| PostFeedFrame
|
|
269
|
+
| PostDeleteFrame
|
|
270
|
+
| StatusUpdateFrame;
|
|
271
|
+
|
|
272
|
+
// ── Response data types ──
|
|
273
|
+
|
|
274
|
+
export type FriendBot = {
|
|
275
|
+
deviceId: string;
|
|
276
|
+
displayName: string;
|
|
277
|
+
isOnline: boolean;
|
|
278
|
+
lastSeenAt: number;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export type Friend = {
|
|
282
|
+
userId: string;
|
|
283
|
+
username: string;
|
|
284
|
+
displayName: string;
|
|
285
|
+
bots: FriendBot[];
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export type FriendListResponse = {
|
|
289
|
+
friends: Friend[];
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export type FeedPost = {
|
|
293
|
+
id: string;
|
|
294
|
+
authorUsername: string;
|
|
295
|
+
botName: string;
|
|
296
|
+
content: string;
|
|
297
|
+
postType: string;
|
|
298
|
+
createdAt: string;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export type FeedResponse = {
|
|
302
|
+
posts: FeedPost[];
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export type MessageHistoryItem = {
|
|
306
|
+
id: string;
|
|
307
|
+
fromDeviceId: string;
|
|
308
|
+
toDeviceId: string;
|
|
309
|
+
content: string;
|
|
310
|
+
status: "pending" | "delivered" | "read";
|
|
311
|
+
createdAt: string;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export type MessageHistoryResponse = {
|
|
315
|
+
messages: MessageHistoryItem[];
|
|
316
|
+
hasMore: boolean;
|
|
317
|
+
nextCursor?: string;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// ── Friend request types ──
|
|
321
|
+
|
|
322
|
+
export type PendingFriendRequest = {
|
|
323
|
+
friendshipId: string;
|
|
324
|
+
fromUser: {
|
|
325
|
+
userId: string;
|
|
326
|
+
username: string;
|
|
327
|
+
displayName: string;
|
|
328
|
+
avatarUrl: string | null;
|
|
329
|
+
};
|
|
330
|
+
createdAt: string;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type FriendRequestsResponse = {
|
|
334
|
+
requests: PendingFriendRequest[];
|
|
335
|
+
nextCursor: string | null;
|
|
336
|
+
hasMore: boolean;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export type FriendRequestSentResponse = {
|
|
340
|
+
friendshipId: string;
|
|
341
|
+
status: "pending";
|
|
342
|
+
createdAt: string;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
export type FriendAcceptResponse = {
|
|
346
|
+
friendshipId: string;
|
|
347
|
+
status: "accepted";
|
|
348
|
+
acceptedAt: string;
|
|
349
|
+
friend: {
|
|
350
|
+
userId: string;
|
|
351
|
+
username: string;
|
|
352
|
+
displayName: string;
|
|
353
|
+
};
|
|
354
|
+
};
|