gewe-openclaw 2026.3.13 → 2026.3.23

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 (44) hide show
  1. package/README.md +455 -3
  2. package/index.ts +39 -1
  3. package/package.json +12 -1
  4. package/skills/gewe-agent-tools/SKILL.md +113 -0
  5. package/skills/gewe-channel-rules/SKILL.md +7 -0
  6. package/src/accounts.ts +51 -5
  7. package/src/api-tools.ts +1264 -0
  8. package/src/api.ts +37 -2
  9. package/src/binary-command.ts +65 -0
  10. package/src/channel-actions.ts +536 -0
  11. package/src/channel-allowlist.ts +150 -0
  12. package/src/channel-directory.ts +419 -0
  13. package/src/channel-status.ts +186 -0
  14. package/src/channel.ts +155 -58
  15. package/src/config-edit.ts +94 -0
  16. package/src/config-schema.ts +78 -3
  17. package/src/contacts-api.ts +113 -0
  18. package/src/delivery.ts +502 -62
  19. package/src/directory-cache.ts +164 -0
  20. package/src/gewe-account-api.ts +27 -0
  21. package/src/group-allowlist-tool.ts +242 -0
  22. package/src/group-binding-tool.ts +154 -0
  23. package/src/group-binding.ts +405 -0
  24. package/src/groups-api.ts +146 -0
  25. package/src/inbound-batch.ts +5 -2
  26. package/src/inbound.ts +248 -41
  27. package/src/media-server.ts +73 -93
  28. package/src/moments-api.ts +138 -0
  29. package/src/monitor.ts +81 -24
  30. package/src/onboarding.ts +9 -4
  31. package/src/openclaw-compat.ts +1070 -0
  32. package/src/pairing-store.ts +478 -0
  33. package/src/personal-api.ts +45 -0
  34. package/src/policy.ts +130 -22
  35. package/src/quote-context-cache.ts +97 -0
  36. package/src/reply-options.ts +101 -2
  37. package/src/s3.ts +1 -1
  38. package/src/send.ts +235 -16
  39. package/src/setup-wizard-types.ts +162 -0
  40. package/src/setup-wizard.ts +464 -0
  41. package/src/silk.ts +2 -1
  42. package/src/state-paths.ts +55 -14
  43. package/src/types.ts +66 -7
  44. package/src/xml.ts +158 -0
package/src/send.ts CHANGED
@@ -7,6 +7,12 @@ type GeweSendContext = {
7
7
  appId: string;
8
8
  };
9
9
 
10
+ type GeweSendResponseData = {
11
+ msgId?: number | string;
12
+ newMsgId?: number | string;
13
+ createTime?: number | null;
14
+ };
15
+
10
16
  function buildContext(account: ResolvedGeweAccount): GeweSendContext {
11
17
  const baseUrl = account.config.apiBaseUrl?.trim() || "https://www.geweapi.com";
12
18
  return { baseUrl, token: account.token, appId: account.appId };
@@ -14,13 +20,9 @@ function buildContext(account: ResolvedGeweAccount): GeweSendContext {
14
20
 
15
21
  function resolveSendResult(params: {
16
22
  toWxid: string;
17
- data?: {
18
- msgId?: number | string;
19
- newMsgId?: number | string;
20
- createTime?: number | null;
21
- };
23
+ data?: GeweSendResponseData;
22
24
  }): GeweSendResult {
23
- const msgId = params.data?.newMsgId ?? params.data?.msgId ?? "ok";
25
+ const msgId = params.data?.msgId ?? params.data?.newMsgId ?? "ok";
24
26
  const createTime = params.data?.createTime;
25
27
  return {
26
28
  toWxid: params.toWxid,
@@ -30,6 +32,30 @@ function resolveSendResult(params: {
30
32
  };
31
33
  }
32
34
 
35
+ async function sendXmlForwardGewe(params: {
36
+ account: ResolvedGeweAccount;
37
+ path: string;
38
+ context: string;
39
+ toWxid: string;
40
+ xml: string;
41
+ extraBody?: Record<string, unknown>;
42
+ }): Promise<GeweSendResult> {
43
+ const ctx = buildContext(params.account);
44
+ const resp = await postGeweJson<GeweSendResponseData>({
45
+ baseUrl: ctx.baseUrl,
46
+ token: ctx.token,
47
+ path: params.path,
48
+ body: {
49
+ appId: ctx.appId,
50
+ toWxid: params.toWxid,
51
+ xml: params.xml,
52
+ ...(params.extraBody ?? {}),
53
+ },
54
+ });
55
+ const data = assertGeweOk(resp, params.context);
56
+ return resolveSendResult({ toWxid: params.toWxid, data });
57
+ }
58
+
33
59
  export async function sendTextGewe(params: {
34
60
  account: ResolvedGeweAccount;
35
61
  toWxid: string;
@@ -37,11 +63,7 @@ export async function sendTextGewe(params: {
37
63
  ats?: string;
38
64
  }): Promise<GeweSendResult> {
39
65
  const ctx = buildContext(params.account);
40
- const resp = await postGeweJson<{
41
- msgId?: number | string;
42
- newMsgId?: number | string;
43
- createTime?: number;
44
- }>({
66
+ const resp = await postGeweJson<GeweSendResponseData>({
45
67
  baseUrl: ctx.baseUrl,
46
68
  token: ctx.token,
47
69
  path: "/gewe/v2/api/message/postText",
@@ -62,7 +84,7 @@ export async function sendImageGewe(params: {
62
84
  imgUrl: string;
63
85
  }): Promise<GeweSendResult> {
64
86
  const ctx = buildContext(params.account);
65
- const resp = await postGeweJson({
87
+ const resp = await postGeweJson<GeweSendResponseData>({
66
88
  baseUrl: ctx.baseUrl,
67
89
  token: ctx.token,
68
90
  path: "/gewe/v2/api/message/postImage",
@@ -83,7 +105,7 @@ export async function sendVoiceGewe(params: {
83
105
  voiceDuration: number;
84
106
  }): Promise<GeweSendResult> {
85
107
  const ctx = buildContext(params.account);
86
- const resp = await postGeweJson({
108
+ const resp = await postGeweJson<GeweSendResponseData>({
87
109
  baseUrl: ctx.baseUrl,
88
110
  token: ctx.token,
89
111
  path: "/gewe/v2/api/message/postVoice",
@@ -106,7 +128,7 @@ export async function sendVideoGewe(params: {
106
128
  videoDuration: number;
107
129
  }): Promise<GeweSendResult> {
108
130
  const ctx = buildContext(params.account);
109
- const resp = await postGeweJson({
131
+ const resp = await postGeweJson<GeweSendResponseData>({
110
132
  baseUrl: ctx.baseUrl,
111
133
  token: ctx.token,
112
134
  path: "/gewe/v2/api/message/postVideo",
@@ -129,7 +151,7 @@ export async function sendFileGewe(params: {
129
151
  fileName: string;
130
152
  }): Promise<GeweSendResult> {
131
153
  const ctx = buildContext(params.account);
132
- const resp = await postGeweJson({
154
+ const resp = await postGeweJson<GeweSendResponseData>({
133
155
  baseUrl: ctx.baseUrl,
134
156
  token: ctx.token,
135
157
  path: "/gewe/v2/api/message/postFile",
@@ -153,7 +175,7 @@ export async function sendLinkGewe(params: {
153
175
  thumbUrl: string;
154
176
  }): Promise<GeweSendResult> {
155
177
  const ctx = buildContext(params.account);
156
- const resp = await postGeweJson({
178
+ const resp = await postGeweJson<GeweSendResponseData>({
157
179
  baseUrl: ctx.baseUrl,
158
180
  token: ctx.token,
159
181
  path: "/gewe/v2/api/message/postLink",
@@ -169,3 +191,200 @@ export async function sendLinkGewe(params: {
169
191
  const data = assertGeweOk(resp, "postLink");
170
192
  return resolveSendResult({ toWxid: params.toWxid, data });
171
193
  }
194
+
195
+ export async function sendAppMsgGewe(params: {
196
+ account: ResolvedGeweAccount;
197
+ toWxid: string;
198
+ appmsg: string;
199
+ }): Promise<GeweSendResult> {
200
+ const ctx = buildContext(params.account);
201
+ const resp = await postGeweJson<GeweSendResponseData>({
202
+ baseUrl: ctx.baseUrl,
203
+ token: ctx.token,
204
+ path: "/gewe/v2/api/message/postAppMsg",
205
+ body: {
206
+ appId: ctx.appId,
207
+ toWxid: params.toWxid,
208
+ appmsg: params.appmsg,
209
+ },
210
+ });
211
+ const data = assertGeweOk(resp, "postAppMsg");
212
+ return resolveSendResult({ toWxid: params.toWxid, data });
213
+ }
214
+
215
+ export async function sendEmojiGewe(params: {
216
+ account: ResolvedGeweAccount;
217
+ toWxid: string;
218
+ emojiMd5: string;
219
+ emojiSize: number;
220
+ }): Promise<GeweSendResult> {
221
+ const ctx = buildContext(params.account);
222
+ const resp = await postGeweJson<GeweSendResponseData>({
223
+ baseUrl: ctx.baseUrl,
224
+ token: ctx.token,
225
+ path: "/gewe/v2/api/message/postEmoji",
226
+ body: {
227
+ appId: ctx.appId,
228
+ toWxid: params.toWxid,
229
+ emojiMd5: params.emojiMd5,
230
+ emojiSize: params.emojiSize,
231
+ },
232
+ });
233
+ const data = assertGeweOk(resp, "postEmoji");
234
+ return resolveSendResult({ toWxid: params.toWxid, data });
235
+ }
236
+
237
+ export async function sendNameCardGewe(params: {
238
+ account: ResolvedGeweAccount;
239
+ toWxid: string;
240
+ nickName: string;
241
+ nameCardWxid: string;
242
+ }): Promise<GeweSendResult> {
243
+ const ctx = buildContext(params.account);
244
+ const resp = await postGeweJson<GeweSendResponseData>({
245
+ baseUrl: ctx.baseUrl,
246
+ token: ctx.token,
247
+ path: "/gewe/v2/api/message/postNameCard",
248
+ body: {
249
+ appId: ctx.appId,
250
+ toWxid: params.toWxid,
251
+ nickName: params.nickName,
252
+ nameCardWxid: params.nameCardWxid,
253
+ },
254
+ });
255
+ const data = assertGeweOk(resp, "postNameCard");
256
+ return resolveSendResult({ toWxid: params.toWxid, data });
257
+ }
258
+
259
+ export async function sendMiniAppGewe(params: {
260
+ account: ResolvedGeweAccount;
261
+ toWxid: string;
262
+ miniAppId: string;
263
+ displayName: string;
264
+ pagePath: string;
265
+ coverImgUrl: string;
266
+ title: string;
267
+ userName: string;
268
+ }): Promise<GeweSendResult> {
269
+ const ctx = buildContext(params.account);
270
+ const resp = await postGeweJson<GeweSendResponseData>({
271
+ baseUrl: ctx.baseUrl,
272
+ token: ctx.token,
273
+ path: "/gewe/v2/api/message/postMiniApp",
274
+ body: {
275
+ appId: ctx.appId,
276
+ toWxid: params.toWxid,
277
+ miniAppId: params.miniAppId,
278
+ displayName: params.displayName,
279
+ pagePath: params.pagePath,
280
+ coverImgUrl: params.coverImgUrl,
281
+ title: params.title,
282
+ userName: params.userName,
283
+ },
284
+ });
285
+ const data = assertGeweOk(resp, "postMiniApp");
286
+ return resolveSendResult({ toWxid: params.toWxid, data });
287
+ }
288
+
289
+ export async function revokeMessageGewe(params: {
290
+ account: ResolvedGeweAccount;
291
+ toWxid: string;
292
+ msgId: string;
293
+ newMsgId: string;
294
+ createTime: string;
295
+ }): Promise<GeweSendResult> {
296
+ const ctx = buildContext(params.account);
297
+ const resp = await postGeweJson<GeweSendResponseData>({
298
+ baseUrl: ctx.baseUrl,
299
+ token: ctx.token,
300
+ path: "/gewe/v2/api/message/revokeMsg",
301
+ body: {
302
+ appId: ctx.appId,
303
+ toWxid: params.toWxid,
304
+ msgId: params.msgId,
305
+ newMsgId: params.newMsgId,
306
+ createTime: params.createTime,
307
+ },
308
+ });
309
+ assertGeweOk(resp, "revokeMsg");
310
+ return {
311
+ toWxid: params.toWxid,
312
+ messageId: params.msgId,
313
+ newMessageId: params.newMsgId,
314
+ timestamp: Number.parseInt(params.createTime, 10) * 1000 || undefined,
315
+ };
316
+ }
317
+
318
+ export async function forwardImageGewe(params: {
319
+ account: ResolvedGeweAccount;
320
+ toWxid: string;
321
+ xml: string;
322
+ }): Promise<GeweSendResult> {
323
+ return await sendXmlForwardGewe({
324
+ account: params.account,
325
+ path: "/gewe/v2/api/message/forwardImage",
326
+ context: "forwardImage",
327
+ toWxid: params.toWxid,
328
+ xml: params.xml,
329
+ });
330
+ }
331
+
332
+ export async function forwardVideoGewe(params: {
333
+ account: ResolvedGeweAccount;
334
+ toWxid: string;
335
+ xml: string;
336
+ }): Promise<GeweSendResult> {
337
+ return await sendXmlForwardGewe({
338
+ account: params.account,
339
+ path: "/gewe/v2/api/message/forwardVideo",
340
+ context: "forwardVideo",
341
+ toWxid: params.toWxid,
342
+ xml: params.xml,
343
+ });
344
+ }
345
+
346
+ export async function forwardFileGewe(params: {
347
+ account: ResolvedGeweAccount;
348
+ toWxid: string;
349
+ xml: string;
350
+ }): Promise<GeweSendResult> {
351
+ return await sendXmlForwardGewe({
352
+ account: params.account,
353
+ path: "/gewe/v2/api/message/forwardFile",
354
+ context: "forwardFile",
355
+ toWxid: params.toWxid,
356
+ xml: params.xml,
357
+ });
358
+ }
359
+
360
+ export async function forwardLinkGewe(params: {
361
+ account: ResolvedGeweAccount;
362
+ toWxid: string;
363
+ xml: string;
364
+ }): Promise<GeweSendResult> {
365
+ return await sendXmlForwardGewe({
366
+ account: params.account,
367
+ path: "/gewe/v2/api/message/forwardUrl",
368
+ context: "forwardUrl",
369
+ toWxid: params.toWxid,
370
+ xml: params.xml,
371
+ });
372
+ }
373
+
374
+ export async function forwardMiniAppGewe(params: {
375
+ account: ResolvedGeweAccount;
376
+ toWxid: string;
377
+ xml: string;
378
+ coverImgUrl: string;
379
+ }): Promise<GeweSendResult> {
380
+ return await sendXmlForwardGewe({
381
+ account: params.account,
382
+ path: "/gewe/v2/api/message/forwardMiniApp",
383
+ context: "forwardMiniApp",
384
+ toWxid: params.toWxid,
385
+ xml: params.xml,
386
+ extraBody: {
387
+ coverImgUrl: params.coverImgUrl,
388
+ },
389
+ });
390
+ }
@@ -0,0 +1,162 @@
1
+ import type {
2
+ ChannelPlugin,
3
+ ChannelSetupInput,
4
+ OpenClawConfig,
5
+ WizardPrompter,
6
+ } from "openclaw/plugin-sdk";
7
+
8
+ type SetupCredentialValues = Partial<Record<string, string>>;
9
+
10
+ export type GeweSetupWizardStatus = {
11
+ configuredLabel: string;
12
+ unconfiguredLabel: string;
13
+ configuredHint?: string;
14
+ unconfiguredHint?: string;
15
+ configuredScore?: number;
16
+ unconfiguredScore?: number;
17
+ resolveConfigured: (params: { cfg: OpenClawConfig }) => boolean | Promise<boolean>;
18
+ resolveStatusLines?: (params: {
19
+ cfg: OpenClawConfig;
20
+ configured: boolean;
21
+ }) => string[] | Promise<string[]>;
22
+ };
23
+
24
+ export type GeweSetupWizardCredentialState = {
25
+ accountConfigured: boolean;
26
+ hasConfiguredValue: boolean;
27
+ resolvedValue?: string;
28
+ envValue?: string;
29
+ };
30
+
31
+ export type GeweSetupWizardNote = {
32
+ title: string;
33
+ lines: string[];
34
+ shouldShow?: (params: {
35
+ cfg: OpenClawConfig;
36
+ accountId: string;
37
+ credentialValues: SetupCredentialValues;
38
+ }) => boolean | Promise<boolean>;
39
+ };
40
+
41
+ export type GeweSetupWizardCredential = {
42
+ inputKey: keyof ChannelSetupInput | string;
43
+ providerHint: string;
44
+ credentialLabel: string;
45
+ preferredEnvVar?: string;
46
+ envPrompt: string;
47
+ keepPrompt: string;
48
+ inputPrompt: string;
49
+ allowEnv?: (params: { cfg: OpenClawConfig; accountId: string }) => boolean;
50
+ inspect: (params: {
51
+ cfg: OpenClawConfig;
52
+ accountId: string;
53
+ }) => GeweSetupWizardCredentialState;
54
+ applyUseEnv?: (params: {
55
+ cfg: OpenClawConfig;
56
+ accountId: string;
57
+ }) => OpenClawConfig | Promise<OpenClawConfig>;
58
+ applySet?: (params: {
59
+ cfg: OpenClawConfig;
60
+ accountId: string;
61
+ credentialValues: SetupCredentialValues;
62
+ value: unknown;
63
+ resolvedValue: string;
64
+ }) => OpenClawConfig | Promise<OpenClawConfig>;
65
+ };
66
+
67
+ export type GeweSetupWizardTextInput = {
68
+ inputKey: keyof ChannelSetupInput | string;
69
+ message: string;
70
+ placeholder?: string;
71
+ required?: boolean;
72
+ applyEmptyValue?: boolean;
73
+ currentValue?: (params: {
74
+ cfg: OpenClawConfig;
75
+ accountId: string;
76
+ credentialValues: SetupCredentialValues;
77
+ }) => string | undefined | Promise<string | undefined>;
78
+ initialValue?: (params: {
79
+ cfg: OpenClawConfig;
80
+ accountId: string;
81
+ credentialValues: SetupCredentialValues;
82
+ }) => string | undefined | Promise<string | undefined>;
83
+ validate?: (params: {
84
+ value: string;
85
+ cfg: OpenClawConfig;
86
+ accountId: string;
87
+ credentialValues: SetupCredentialValues;
88
+ }) => string | undefined;
89
+ normalizeValue?: (params: {
90
+ value: string;
91
+ cfg: OpenClawConfig;
92
+ accountId: string;
93
+ credentialValues: SetupCredentialValues;
94
+ }) => string;
95
+ applySet?: (params: {
96
+ cfg: OpenClawConfig;
97
+ accountId: string;
98
+ value: string;
99
+ }) => OpenClawConfig | Promise<OpenClawConfig>;
100
+ };
101
+
102
+ export type GeweSetupWizardAllowFromEntry = {
103
+ input: string;
104
+ resolved: boolean;
105
+ id: string | null;
106
+ };
107
+
108
+ export type GeweSetupWizardAllowFrom = {
109
+ message: string;
110
+ placeholder: string;
111
+ invalidWithoutCredentialNote: string;
112
+ parseInputs?: (raw: string) => string[];
113
+ parseId: (raw: string) => string | null;
114
+ resolveEntries: (params: {
115
+ cfg: OpenClawConfig;
116
+ accountId: string;
117
+ credentialValues: SetupCredentialValues;
118
+ entries: string[];
119
+ }) => Promise<GeweSetupWizardAllowFromEntry[]>;
120
+ apply: (params: {
121
+ cfg: OpenClawConfig;
122
+ accountId: string;
123
+ allowFrom: string[];
124
+ }) => OpenClawConfig | Promise<OpenClawConfig>;
125
+ };
126
+
127
+ export type GeweSetupWizardFinalize = (params: {
128
+ cfg: OpenClawConfig;
129
+ accountId: string;
130
+ credentialValues: SetupCredentialValues;
131
+ runtime: unknown;
132
+ prompter: WizardPrompter;
133
+ options?: unknown;
134
+ forceAllowFrom: boolean;
135
+ }) =>
136
+ | {
137
+ cfg?: OpenClawConfig;
138
+ credentialValues?: SetupCredentialValues;
139
+ }
140
+ | void
141
+ | Promise<
142
+ | {
143
+ cfg?: OpenClawConfig;
144
+ credentialValues?: SetupCredentialValues;
145
+ }
146
+ | void
147
+ >;
148
+
149
+ export type GeweSetupWizard = {
150
+ channel: string;
151
+ status: GeweSetupWizardStatus;
152
+ introNote?: GeweSetupWizardNote;
153
+ credentials: GeweSetupWizardCredential[];
154
+ textInputs?: GeweSetupWizardTextInput[];
155
+ allowFrom?: GeweSetupWizardAllowFrom;
156
+ finalize?: GeweSetupWizardFinalize;
157
+ completionNote?: GeweSetupWizardNote;
158
+ };
159
+
160
+ export type GeweChannelPlugin<ResolvedAccount = unknown> = ChannelPlugin<ResolvedAccount> & {
161
+ setupWizard?: GeweSetupWizard;
162
+ };