antenna-openclaw-plugin 0.8.1 → 0.9.0

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 (2) hide show
  1. package/index.ts +36 -16
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -278,19 +278,29 @@ export default function register(api: any) {
278
278
  return ok({ nearby: [], message: `在 ${radius}m 范围内没有发现其他人。试试扩大范围?` });
279
279
  }
280
280
 
281
- // Return raw profile cards the agent decides who to recommend
282
- return ok({
283
- nearby: others.map((p: Profile) => ({
284
- device_id: p.device_id,
281
+ // Build ref mappingnever expose device_id
282
+ const _refMap: Record<string, string> = {};
283
+ const profiles = others.map((p: Profile, i: number) => {
284
+ const ref = String(i + 1);
285
+ _refMap[ref] = p.device_id;
286
+ return {
287
+ ref,
285
288
  emoji: p.emoji || "👤",
286
289
  name: p.display_name || "匿名",
287
290
  line1: p.line1,
288
291
  line2: p.line2,
289
292
  line3: p.line3,
290
- })),
293
+ };
294
+ });
295
+
296
+ // Store ref map for accept
297
+ (api as any)._antennaRefMap = _refMap;
298
+
299
+ return ok({
300
+ nearby: profiles,
291
301
  total: others.length,
292
302
  radius_m: radius,
293
- instruction: "根据你对用户的了解(记忆、偏好、最近的状态),判断哪些人值得推荐,为每个推荐写一句个性化的匹配理由。",
303
+ instruction: "根据你对用户的了解,判断哪些人值得推荐,用 ref 编号引用。不要显示 device_id。",
294
304
  });
295
305
  },
296
306
  });
@@ -405,24 +415,34 @@ export default function register(api: any) {
405
415
  api.registerTool({
406
416
  name: "antenna_accept",
407
417
  description:
408
- "Accept a match. Optionally share contact info (WeChat, Telegram, phone, etc). If both sides accept, they can exchange contact info through their agents.",
418
+ "Accept a match. Use 'ref' from scan results (e.g. '1', '2') or target_device_id. Optionally share contact info.",
409
419
  parameters: {
410
420
  type: "object",
411
421
  properties: {
412
422
  sender_id: { type: "string" },
413
423
  channel: { type: "string" },
414
- target_device_id: { type: "string", description: "The device_id of the person to accept" },
415
- contact_info: { type: "string", description: "Optional contact info to share (e.g. 'WeChat: yi_xxx')" },
424
+ ref: { type: "string", description: "Ref number from scan results (e.g. '1')" },
425
+ target_device_id: { type: "string", description: "Device ID (use ref instead when possible)" },
426
+ contact_info: { type: "string", description: "Optional contact info to share" },
416
427
  },
417
- required: ["sender_id", "channel", "target_device_id"],
428
+ required: ["sender_id", "channel"],
418
429
  },
419
430
  async execute(_id: string, params: any) {
420
431
  const cfg = getConfig(api);
421
432
  const supabase = getSupabase(cfg);
422
433
  const deviceId = deriveDeviceId(params.sender_id, params.channel);
423
434
 
435
+ // Resolve ref to device_id
436
+ let targetId = params.target_device_id;
437
+ if (params.ref && (api as any)._antennaRefMap?.[params.ref]) {
438
+ targetId = (api as any)._antennaRefMap[params.ref];
439
+ }
440
+ if (!targetId) {
441
+ return ok({ error: "No target. Use 'ref' from scan results or 'target_device_id'." });
442
+ }
443
+
424
444
  const { error } = await supabase.rpc("upsert_match", {
425
- p_device_id_a: deviceId, p_device_id_b: params.target_device_id,
445
+ p_device_id_a: deviceId, p_device_id_b: targetId,
426
446
  p_status: "accepted", p_contact_info: params.contact_info ?? null,
427
447
  });
428
448
 
@@ -430,13 +450,13 @@ export default function register(api: any) {
430
450
 
431
451
  const { data: myMatches } = await supabase.rpc("get_my_matches", { p_device_id: deviceId });
432
452
  const reverse = (myMatches || []).find(
433
- (m: any) => m.device_id_a === params.target_device_id && m.device_id_b === deviceId
453
+ (m: any) => m.device_id_a === targetId && m.device_id_b === deviceId
434
454
  );
435
455
 
436
456
  if (reverse) {
437
457
  // Mutual match! Stop any follow-up cron for this pair
438
- stopFollowUpCron(deviceId, params.target_device_id, logger);
439
- stopFollowUpCron(params.target_device_id, deviceId, logger);
458
+ stopFollowUpCron(deviceId, targetId, logger);
459
+ stopFollowUpCron(targetId, deviceId, logger);
440
460
 
441
461
  return ok({
442
462
  accepted: true, mutual: true,
@@ -448,11 +468,11 @@ export default function register(api: any) {
448
468
  }
449
469
 
450
470
  // Not mutual yet — start a follow-up cron (check every 15min for 2h)
451
- const { data: targetProfile } = await supabase.rpc("get_profile", { p_device_id: params.target_device_id });
471
+ const { data: targetProfile } = await supabase.rpc("get_profile", { p_device_id: targetId });
452
472
  const targetName = targetProfile?.display_name || "对方";
453
473
 
454
474
  startFollowUpCron(
455
- deviceId, params.target_device_id,
475
+ deviceId, targetId,
456
476
  params.channel, params.sender_id, targetName, logger,
457
477
  );
458
478
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-openclaw-plugin",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Antenna — agent-mediated nearby people discovery for OpenClaw",
5
5
  "openclaw": {
6
6
  "extensions": ["./index.ts"]