squidclaw 0.5.2 → 0.5.3

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.
@@ -22,6 +22,20 @@ export class ChannelHub {
22
22
  return;
23
23
  }
24
24
 
25
+ // Allowlist check
26
+ const allowFrom = agent.allowFrom || ['*'];
27
+ if (!allowFrom.includes('*')) {
28
+ const senderNum = contactId.replace('@s.whatsapp.net', '').replace(/[^0-9]/g, '');
29
+ const allowed = allowFrom.some(n => {
30
+ const clean = n.replace(/[^0-9]/g, '');
31
+ return senderNum.endsWith(clean) || clean.endsWith(senderNum);
32
+ });
33
+ if (!allowed) {
34
+ logger.info('hub', 'Message from ' + contactId + ' blocked (not in allowlist)');
35
+ return;
36
+ }
37
+ }
38
+
25
39
  // Skip group messages unless mentioned (for now)
26
40
  if (metadata.isGroup) {
27
41
  // TODO: implement group mention detection
package/lib/cli/setup.js CHANGED
@@ -176,9 +176,10 @@ export async function setup() {
176
176
  if (p.isCancel(connectWA)) return p.cancel('Setup cancelled');
177
177
 
178
178
  let waConnected = false;
179
+ let waPhone = null;
179
180
 
180
181
  if (connectWA === 'pair') {
181
- const waPhone = await p.text({
182
+ waPhone = await p.text({
182
183
  message: 'WhatsApp phone number (with country code):',
183
184
  placeholder: '+966 5XX XXX XXXX',
184
185
  validate: (v) => v.replace(/[^0-9+]/g, '').length < 8 ? 'Enter a valid phone number' : undefined,
@@ -186,6 +187,7 @@ export async function setup() {
186
187
  if (p.isCancel(waPhone)) return p.cancel('Setup cancelled');
187
188
 
188
189
  const cleanPhone = waPhone.replace(/[^0-9]/g, '');
190
+ waPhone = cleanPhone;
189
191
  manifest.whatsappNumber = cleanPhone;
190
192
 
191
193
  // Actually connect WhatsApp NOW
@@ -215,6 +217,50 @@ export async function setup() {
215
217
  config.channels.whatsapp.enabled = true;
216
218
  }
217
219
 
220
+ // Ask for allowlist (who can chat with this agent?)
221
+ if (connectWA !== 'skip') {
222
+ const allowMode = await p.select({
223
+ message: 'Who can message this agent on WhatsApp?',
224
+ options: [
225
+ { value: 'owner', label: '🔒 Only me', hint: 'recommended for testing' },
226
+ { value: 'list', label: '📋 Specific numbers (allowlist)' },
227
+ { value: 'all', label: '🌍 Everyone', hint: 'public agent' },
228
+ ],
229
+ });
230
+ if (p.isCancel(allowMode)) return p.cancel('Setup cancelled');
231
+
232
+ if (allowMode === 'owner' && waPhone) {
233
+ config.channels.whatsapp.allowFrom = [waPhone];
234
+ manifest.allowFrom = [waPhone];
235
+ console.log(chalk.gray(' Only ' + waPhone + ' can chat with ' + agentName));
236
+ } else if (allowMode === 'owner' && !waPhone) {
237
+ const ownerPhone = await p.text({
238
+ message: 'Your phone number (with country code):',
239
+ placeholder: '+966 5XX XXX XXXX',
240
+ validate: (v) => v.replace(/[^0-9+]/g, '').length < 8 ? 'Enter a valid number' : undefined,
241
+ });
242
+ if (!p.isCancel(ownerPhone)) {
243
+ const clean = ownerPhone.replace(/[^0-9]/g, '');
244
+ config.channels.whatsapp.allowFrom = [clean];
245
+ manifest.allowFrom = [clean];
246
+ }
247
+ } else if (allowMode === 'list') {
248
+ const numbers = await p.text({
249
+ message: 'Allowed numbers (comma separated):',
250
+ placeholder: '+966501234567, +966509876543',
251
+ validate: (v) => v.length < 5 ? 'Enter at least one number' : undefined,
252
+ });
253
+ if (!p.isCancel(numbers)) {
254
+ const list = numbers.split(',').map(n => n.replace(/[^0-9]/g, '').trim()).filter(Boolean);
255
+ config.channels.whatsapp.allowFrom = list;
256
+ manifest.allowFrom = list;
257
+ }
258
+ } else {
259
+ config.channels.whatsapp.allowFrom = ['*'];
260
+ manifest.allowFrom = ['*'];
261
+ }
262
+ }
263
+
218
264
  // ═══ Step 4: Telegram ═══
219
265
  p.note('Step 4 of 4: Telegram', '✈️');
220
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squidclaw",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "\ud83e\udd91 AI agent platform \u2014 human-like agents for WhatsApp, Telegram & more",
5
5
  "main": "lib/engine.js",
6
6
  "bin": {