@jackle.dev/zalox-plugin 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackle.dev/zalox-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "OpenClaw channel plugin for Zalo via zca-js (in-process, single login)",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -6,21 +6,24 @@
6
6
  */
7
7
 
8
8
  import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
9
- import { emptyPluginConfigSchema } from 'openclaw/plugin-sdk';
10
9
  import { zaloxPlugin, zaloxDock } from './channel.js';
11
10
  import { setPluginRuntime } from './listener.js';
11
+ import { zaloxGroupTool } from './tools.js';
12
12
 
13
13
  const plugin = {
14
14
  id: 'zalox',
15
15
  name: 'Zalo (ZaloX)',
16
16
  description: 'Zalo personal messaging — in-process, single login, no session conflicts',
17
- configSchema: undefined, // Disabled to fix schema.toJSONSchema error
17
+ configSchema: undefined,
18
18
  register(api: OpenClawPluginApi) {
19
19
  // Store runtime for listener's message processing
20
20
  setPluginRuntime(api.runtime);
21
21
 
22
22
  // Register channel plugin
23
23
  api.registerChannel({ plugin: zaloxPlugin, dock: zaloxDock });
24
+
25
+ // Register admin tool
26
+ api.registerTool(zaloxGroupTool);
24
27
  },
25
28
  };
26
29
 
package/src/tools.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ import { getCachedApi } from './client.js';
3
+
4
+ export const zaloxGroupTool = {
5
+ name: 'zalox_group',
6
+ description: 'Manage Zalo groups: kick members, add members, or get group info.',
7
+ parameters: z.object({
8
+ action: z.enum(['kick', 'add', 'info']),
9
+ groupId: z.string(),
10
+ userId: z.string().optional(),
11
+ profile: z.string().optional().default('default'),
12
+ }),
13
+ execute: async (args: any) => {
14
+ const { action, groupId, userId, profile } = args;
15
+ const cached = getCachedApi(profile);
16
+ if (!cached) throw new Error(`Profile ${profile} not connected`);
17
+
18
+ const api = cached.api as any;
19
+
20
+ try {
21
+ if (action === 'kick') {
22
+ if (!userId) throw new Error('userId required for kick');
23
+ await api.removeUserFromGroup(userId, groupId);
24
+ return `Successfully kicked ${userId} from ${groupId}`;
25
+ }
26
+
27
+ if (action === 'add') {
28
+ if (!userId) throw new Error('userId required for add');
29
+ await api.addUserToGroup(userId, groupId);
30
+ return `Successfully added ${userId} to ${groupId}`;
31
+ }
32
+
33
+ if (action === 'info') {
34
+ const info = await api.getGroupInfo(groupId);
35
+ // Simplify info to avoid huge context
36
+ const simple = {
37
+ id: info.id,
38
+ name: info.name,
39
+ topic: info.topic,
40
+ totalMember: info.totalMember,
41
+ admins: info.admins,
42
+ };
43
+ return JSON.stringify(simple, null, 2);
44
+ }
45
+ } catch (e: any) {
46
+ return `Action ${action} failed: ${e.message || e}`;
47
+ }
48
+
49
+ return 'Unknown action';
50
+ },
51
+ };