aicq-chat-plugin 2.5.7 → 2.5.8

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/extension.js CHANGED
@@ -5,91 +5,19 @@
5
5
  * It does NOT require native dependencies (better-sqlite3) which need C++ compilation.
6
6
  *
7
7
  * The actual chat server runs as a **sidecar** process (node index.js) on port 6109.
8
- * This extension just registers the plugin and proxies tool calls to the sidecar.
8
+ * This extension registers the plugin and proxies tool calls to the sidecar.
9
+ *
10
+ * OpenClaw expects `register()` and `activate()` exports from extension modules.
9
11
  */
10
12
  const http = require('http');
13
+ const path = require('path');
11
14
 
12
15
  const SIDECAR_PORT = parseInt(process.env.AICQ_PORT || '6109', 10);
13
16
  const SIDECAR_HOST = '127.0.0.1';
14
17
 
15
- // ── Plugin metadata ──────────────────────────────────────────────────
16
- module.exports = {
17
- id: 'aicq-chat',
18
- name: 'AICQ Encrypted Chat',
19
- version: '2.5.7',
20
- description: 'End-to-end encrypted chat plugin for OpenClaw agents',
21
-
22
- // Sidecar configuration — OpenClaw starts this process automatically
23
- sidecar: {
24
- command: 'node',
25
- args: ['index.js'],
26
- port: SIDECAR_PORT,
27
- },
28
-
29
- // Tool definitions for OpenClaw agent use
30
- tools: {
31
- 'chat-friend': {
32
- description: 'Manage AICQ friends — list, add by friend code, remove, view requests, accept/reject requests',
33
- parameters: {
34
- type: 'object',
35
- properties: {
36
- action: {
37
- type: 'string',
38
- enum: ['list', 'add', 'remove', 'requests', 'accept', 'reject'],
39
- description: 'The friend management action to perform',
40
- },
41
- friend_code: {
42
- type: 'string',
43
- description: 'Friend code or temp number for adding a friend',
44
- },
45
- friend_id: {
46
- type: 'string',
47
- description: 'Friend ID for remove/accept/reject actions',
48
- },
49
- },
50
- required: ['action'],
51
- },
52
- },
53
- 'chat-send': {
54
- description: 'Send an encrypted message to a friend or group via AICQ',
55
- parameters: {
56
- type: 'object',
57
- properties: {
58
- targetId: {
59
- type: 'string',
60
- description: 'The friend ID or group ID to send the message to',
61
- },
62
- content: {
63
- type: 'string',
64
- description: 'The message content to send',
65
- },
66
- isGroup: {
67
- type: 'boolean',
68
- description: 'Whether the target is a group (default: false)',
69
- },
70
- },
71
- required: ['targetId', 'content'],
72
- },
73
- },
74
- 'chat-export-key': {
75
- description: 'Export your AICQ identity public key and fingerprint for sharing',
76
- parameters: {
77
- type: 'object',
78
- properties: {
79
- format: {
80
- type: 'string',
81
- enum: ['json', 'qr'],
82
- description: 'Output format: json for key data, qr for QR code image (default: json)',
83
- },
84
- },
85
- },
86
- },
87
- },
88
- };
89
-
90
18
  // ── Helper: proxy a gateway call to the sidecar ──────────────────────
91
19
  function proxyToSidecar(method, kwargs) {
92
- return new Promise((resolve, reject) => {
20
+ return new Promise((resolve, _reject) => {
93
21
  const postData = JSON.stringify({ method, kwargs });
94
22
  const req = http.request(
95
23
  {
@@ -116,7 +44,7 @@ function proxyToSidecar(method, kwargs) {
116
44
  }
117
45
  );
118
46
  req.on('error', (e) => {
119
- resolve({ error: `Sidecar not reachable: ${e.message}. Is the AICQ sidecar running?` });
47
+ resolve({ error: `Sidecar not reachable: ${e.message}. Is the AICQ sidecar running on port ${SIDECAR_PORT}?` });
120
48
  });
121
49
  req.on('timeout', () => {
122
50
  req.destroy();
@@ -127,11 +55,11 @@ function proxyToSidecar(method, kwargs) {
127
55
  });
128
56
  }
129
57
 
130
- // ── Tool handlers (proxy to sidecar) ─────────────────────────────────
131
- module.exports.handleTool = async function (toolName, params) {
58
+ // ── Tool handler: dispatch tool calls to sidecar ─────────────────────
59
+ async function handleTool(toolName, params) {
132
60
  switch (toolName) {
133
61
  case 'chat-friend': {
134
- const { action, friend_code, friend_id } = params;
62
+ const { action, friend_code, friend_id } = params || {};
135
63
  switch (action) {
136
64
  case 'list':
137
65
  return proxyToSidecar('aicq.friends.list', {});
@@ -151,18 +79,114 @@ module.exports.handleTool = async function (toolName, params) {
151
79
  }
152
80
  case 'chat-send':
153
81
  return proxyToSidecar('aicq.chat.send', {
154
- targetId: params.targetId,
155
- content: params.content,
156
- isGroup: params.isGroup || false,
82
+ targetId: (params || {}).targetId,
83
+ content: (params || {}).content,
84
+ isGroup: (params || {}).isGroup || false,
157
85
  });
158
86
  case 'chat-export-key':
159
87
  return proxyToSidecar('aicq.identity.info', {});
160
88
  default:
161
89
  return { error: `Unknown tool: ${toolName}` };
162
90
  }
163
- };
91
+ }
164
92
 
165
- // ── Gateway handler (proxy to sidecar via IPC or HTTP) ───────────────
166
- module.exports.handleGateway = async function (method, kwargs) {
93
+ // ── Gateway handler: proxy any gateway method to sidecar ─────────────
94
+ async function handleGateway(method, kwargs) {
167
95
  return proxyToSidecar(method, kwargs || {});
96
+ }
97
+
98
+ // ── register() — called by OpenClaw when the plugin is discovered ────
99
+ // Returns the plugin manifest (tools, sidecar config, etc.)
100
+ function register() {
101
+ return {
102
+ id: 'aicq-chat',
103
+ name: 'AICQ Encrypted Chat',
104
+ version: '2.5.8',
105
+ description: 'End-to-end encrypted chat plugin for OpenClaw agents',
106
+
107
+ // Sidecar configuration — OpenClaw starts this process automatically
108
+ sidecar: {
109
+ command: 'node',
110
+ args: [path.join(__dirname, 'index.js')],
111
+ port: SIDECAR_PORT,
112
+ },
113
+
114
+ // Tool definitions for OpenClaw agent use
115
+ tools: {
116
+ 'chat-friend': {
117
+ description: 'Manage AICQ friends — list, add by friend code, remove, view requests, accept/reject requests',
118
+ parameters: {
119
+ type: 'object',
120
+ properties: {
121
+ action: {
122
+ type: 'string',
123
+ enum: ['list', 'add', 'remove', 'requests', 'accept', 'reject'],
124
+ description: 'The friend management action to perform',
125
+ },
126
+ friend_code: {
127
+ type: 'string',
128
+ description: 'Friend code or temp number for adding a friend',
129
+ },
130
+ friend_id: {
131
+ type: 'string',
132
+ description: 'Friend ID for remove/accept/reject actions',
133
+ },
134
+ },
135
+ required: ['action'],
136
+ },
137
+ },
138
+ 'chat-send': {
139
+ description: 'Send an encrypted message to a friend or group via AICQ',
140
+ parameters: {
141
+ type: 'object',
142
+ properties: {
143
+ targetId: {
144
+ type: 'string',
145
+ description: 'The friend ID or group ID to send the message to',
146
+ },
147
+ content: {
148
+ type: 'string',
149
+ description: 'The message content to send',
150
+ },
151
+ isGroup: {
152
+ type: 'boolean',
153
+ description: 'Whether the target is a group (default: false)',
154
+ },
155
+ },
156
+ required: ['targetId', 'content'],
157
+ },
158
+ },
159
+ 'chat-export-key': {
160
+ description: 'Export your AICQ identity public key and fingerprint for sharing',
161
+ parameters: {
162
+ type: 'object',
163
+ properties: {
164
+ format: {
165
+ type: 'string',
166
+ enum: ['json', 'qr'],
167
+ description: 'Output format: json for key data, qr for QR code image (default: json)',
168
+ },
169
+ },
170
+ },
171
+ },
172
+ },
173
+ };
174
+ }
175
+
176
+ // ── activate() — called by OpenClaw when the plugin is enabled ───────
177
+ // Returns an object with handlers for tools and gateway calls
178
+ function activate(_config) {
179
+ return {
180
+ handleTool,
181
+ handleGateway,
182
+ };
183
+ }
184
+
185
+ // ── Exports ──────────────────────────────────────────────────────────
186
+ module.exports = {
187
+ register,
188
+ activate,
189
+ // Also expose as direct properties for compatibility with different loading patterns
190
+ handleTool,
191
+ handleGateway,
168
192
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "aicq-chat",
3
3
  "name": "AICQ Encrypted Chat",
4
- "version": "2.5.7",
4
+ "version": "2.5.8",
5
5
  "description": "End-to-end encrypted chat plugin for OpenClaw agents — Node.js implementation with full UI",
6
6
  "entry": "index.js",
7
7
  "activation": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicq-chat-plugin",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "description": "AICQ End-to-end Encrypted Chat Plugin for OpenClaw \u2014 Full UI with friend management, group chat, file transfer, and AI agent communication",
5
5
  "main": "index.js",
6
6
  "bin": {
package/postinstall.js CHANGED
@@ -270,7 +270,7 @@ console.log(' ╚════════════════════
270
270
  console.log('');
271
271
 
272
272
  // Read version from package.json
273
- let version = '2.5.7';
273
+ let version = '2.5.8';
274
274
  try {
275
275
  const pkg = JSON.parse(fs.readFileSync(path.join(PLUGIN_DIR, 'package.json'), 'utf8'));
276
276
  version = pkg.version;