antenna-openclaw-plugin 1.3.5 → 1.3.7

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/index.ts CHANGED
@@ -1166,7 +1166,38 @@ export default function register(api: any) {
1166
1166
  });
1167
1167
 
1168
1168
  // ═══════════════════════════════════════════════════════════════════
1169
- // Service: poll for new matches every 10 minutes → notify instantly
1169
+ // Tool: antenna_event_message
1170
+ // ═══════════════════════════════════════════════════════════════════
1171
+ api.registerTool({
1172
+ name: "antenna_event_message",
1173
+ description: "Send a message to event participants. Only creator or co-host can send. Omit ref to broadcast to all participants.",
1174
+ parameters: {
1175
+ type: "object",
1176
+ properties: {
1177
+ code: { type: "string", description: "Event code" },
1178
+ sender_id: { type: "string" },
1179
+ channel: { type: "string" },
1180
+ chat_id: { type: "string", description: "REQUIRED for notifications. Pass the chat/channel ID from your message context so Antenna can send you match and event notifications." },
1181
+ message: { type: "string", description: "Message to send to participants" },
1182
+ ref: { type: "string", description: "Ref number of specific participant (omit to broadcast to all)" },
1183
+ },
1184
+ required: ["code", "sender_id", "channel", "message", "chat_id"],
1185
+ },
1186
+ async execute(_id: string, params: any) {
1187
+ const cfg = getConfig(api);
1188
+ const supabase = getSupabase(cfg);
1189
+ const deviceId = deriveDeviceId(params.sender_id, params.channel, params.chat_id);
1190
+ const { data, error } = await supabase.rpc("send_event_message", {
1191
+ p_code: params.code,
1192
+ p_device_id: deviceId,
1193
+ p_message: params.message,
1194
+ ...(params.ref ? { p_target_ref: params.ref } : {}),
1195
+ });
1196
+ if (error) return ok({ error: error.message });
1197
+ return ok(data);
1198
+ },
1199
+ });
1200
+
1170
1201
  // ═══════════════════════════════════════════════════════════════════
1171
1202
  const _notifiedMatches = new Set<string>(); // "deviceA→deviceB" already notified
1172
1203
 
@@ -1430,6 +1461,29 @@ export default function register(api: any) {
1430
1461
  }
1431
1462
  } catch { /* silent */ }
1432
1463
  }
1464
+
1465
+ // ── Event messages polling ──
1466
+ for (const profile of activeProfiles) {
1467
+ const deviceId = profile.device_id;
1468
+ try {
1469
+ const { data: msgs } = await supabase.rpc("get_my_event_messages", { p_device_id: deviceId });
1470
+ if (!msgs?.length) continue;
1471
+ const parts = deviceId.split(":");
1472
+ if (parts.length < 2) continue;
1473
+ const channel = parts[0];
1474
+ const userId = parts.slice(1).join(":");
1475
+ for (const msg of msgs) {
1476
+ const key = `evtmsg:${msg.event_id}:${msg.created_at}`;
1477
+ if (_notifiedMatches.has(key)) continue;
1478
+ const role = msg.sender_role === 'creator' ? '组织者' : '协办';
1479
+ notifyUser(channel, userId,
1480
+ `[Antenna] 📢 来自「${msg.event_name}」${role} ${msg.sender_emoji || ''} ${msg.sender_name}: ${msg.message}`,
1481
+ logger,
1482
+ );
1483
+ _notifiedMatches.add(key);
1484
+ }
1485
+ } catch { /* silent */ }
1486
+ }
1433
1487
  } catch (err: any) {
1434
1488
  logger.warn("Antenna: match poll error:", err.message);
1435
1489
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-openclaw-plugin",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Antenna — agent-mediated nearby people discovery for OpenClaw",
5
5
  "openclaw": {
6
6
  "extensions": ["./index.ts"]
@@ -388,6 +388,16 @@ Add a co-host to the event. Only creator can add.
388
388
  - `chat_id`: REQUIRED for notifications
389
389
  - `ref`: participant ref number to promote to co-host
390
390
 
391
+ ### `antenna_event_message`
392
+ Send a message to event participants. Only creator or co-host can send.
393
+ - `code`: event code
394
+ - `sender_id`, `channel`: from context
395
+ - `chat_id`: REQUIRED for notifications
396
+ - `message`: the message text
397
+ - `ref`: optional — ref number of specific participant. Omit to broadcast to all active participants.
398
+ - Use when the host needs to notify participants about logistics, changes, or requests (e.g. "please share your WeChat in your profile").
399
+ - One-way: participants receive the message but cannot reply through this channel.
400
+
391
401
  ---
392
402
 
393
403
  ## Event Behavior Guide