antenna-fyi 0.8.0 → 0.8.2

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.
@@ -1,7 +1,7 @@
1
1
  """Antenna — Hermes Agent Plugin
2
2
 
3
- Nearby people discovery. Registers 5 tools and a pre_llm_call hook
4
- that auto-detects location data and prompts the agent to scan.
3
+ Nearby people discovery. Registers 6 tools and a pre_llm_call hook
4
+ that auto-detects location data (from messages + web GPS events).
5
5
 
6
6
  Drop this directory into ~/.hermes/plugins/antenna/
7
7
  """
@@ -13,6 +13,8 @@ from .tools import (
13
13
  handle_checkin,
14
14
  handle_check_matches,
15
15
  handle_bind,
16
+ _sb,
17
+ _device_id,
16
18
  SCAN_SCHEMA,
17
19
  PROFILE_SCHEMA,
18
20
  ACCEPT_SCHEMA,
@@ -21,6 +23,11 @@ from .tools import (
21
23
  BIND_SCHEMA,
22
24
  )
23
25
  import re
26
+ import time
27
+
28
+ # Track last checked timestamp for location events
29
+ _last_event_check = 0
30
+ _EVENT_CHECK_INTERVAL = 30 # seconds
24
31
 
25
32
 
26
33
  def register(ctx):
@@ -32,39 +39,57 @@ def register(ctx):
32
39
  ctx.register_tool("antenna_check_matches", CHECK_MATCHES_SCHEMA, handle_check_matches)
33
40
  ctx.register_tool("antenna_bind", BIND_SCHEMA, handle_bind)
34
41
 
35
- # ── Hook: auto-detect location in messages ────────────────────
42
+ # ── Hook: auto-detect location + check web GPS events ─────────
36
43
  def on_pre_llm(messages, **kwargs):
37
- """Check last user message for location data and inject scan hint."""
38
- if not messages:
39
- return None
40
-
41
- last_msg = messages[-1] if isinstance(messages[-1], dict) else {}
42
- content = last_msg.get("content", "")
43
- if not isinstance(content, str):
44
- return None
44
+ """Check for location data in messages AND pending web GPS events."""
45
+ global _last_event_check
46
+ hints = []
45
47
 
46
- # Pattern 1: Hermes gateway may serialize location as text
47
- # e.g. "📍 Location shared: 39.9908, 116.4872"
48
- loc_match = re.search(
49
- r"[Ll]ocation.*?(-?\d+\.?\d*)[,\s]+(-?\d+\.?\d*)", content
50
- )
51
-
52
- # Pattern 2: raw coordinates in message
53
- if not loc_match:
54
- loc_match = re.search(
55
- r"(-?\d{1,3}\.\d{3,})[,\s]+(-?\d{1,3}\.\d{3,})", content
56
- )
48
+ # 1. Check location_events table (web GPS updates)
49
+ now = time.time()
50
+ if now - _last_event_check > _EVENT_CHECK_INTERVAL:
51
+ _last_event_check = now
52
+ try:
53
+ sb = _sb()
54
+ resp = (
55
+ sb.from_("location_events")
56
+ .select("device_id, lat, lng")
57
+ .gt("created_at", "now() - interval '2 minutes'")
58
+ .order("created_at", desc=True)
59
+ .limit(5)
60
+ .execute()
61
+ )
62
+ if resp.data:
63
+ for evt in resp.data:
64
+ hints.append(
65
+ f"[Antenna] 📡 用户 {evt['device_id']} 通过网页分享了位置 "
66
+ f"({evt['lat']}, {evt['lng']})。"
67
+ f"请使用 antenna_scan 查看附近有谁。"
68
+ )
69
+ except Exception:
70
+ pass
57
71
 
58
- if loc_match:
59
- lat, lng = loc_match.group(1), loc_match.group(2)
60
- return {
61
- "context": (
62
- f"\n\n[Antenna] 📍 检测到位置 ({lat}, {lng})。"
63
- f"请使用 antenna_scan 工具查看附近有谁。"
64
- f"参数:lat={lat}, lng={lng},sender_id 和 channel 从消息上下文获取。"
72
+ # 2. Check message content for coordinates
73
+ if messages:
74
+ last_msg = messages[-1] if isinstance(messages[-1], dict) else {}
75
+ content = last_msg.get("content", "")
76
+ if isinstance(content, str):
77
+ loc_match = re.search(
78
+ r"[Ll]ocation.*?(-?\d+\.?\d*)[,\s]+(-?\d+\.?\d*)", content
65
79
  )
66
- }
80
+ if not loc_match:
81
+ loc_match = re.search(
82
+ r"(-?\d{1,3}\.\d{3,})[,\s]+(-?\d{1,3}\.\d{3,})", content
83
+ )
84
+ if loc_match:
85
+ lat, lng = loc_match.group(1), loc_match.group(2)
86
+ hints.append(
87
+ f"[Antenna] 📍 检测到位置 ({lat}, {lng})。"
88
+ f"请使用 antenna_scan 查看附近有谁。"
89
+ )
67
90
 
91
+ if hints:
92
+ return {"context": "\n".join(hints)}
68
93
  return None
69
94
 
70
95
  ctx.register_hook("pre_llm_call", on_pre_llm)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-fyi",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Antenna — nearby people discovery. CLI + MCP server + OpenClaw skill & plugin, all in one package.",
5
5
  "type": "module",
6
6
  "bin": {
package/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: antenna
3
- description: "Nearby people discovery via Antenna. Use when a user shares location, asks who's nearby, wants to set up their profile card, or interacts with match results. Handles location-based social discovery through the antenna_scan, antenna_profile, antenna_accept, and antenna_check_matches tools."
3
+ description: "Nearby people discovery via Antenna. Use when a user shares location, asks who's nearby, wants to set up their profile card, or interacts with match results. Handles location-based social discovery through the antenna_scan, antenna_profile, antenna_accept, antenna_check_matches, and antenna_bind tools."
4
4
  metadata: { "openclaw": { "always": true } }
5
5
  ---
6
6
 
@@ -20,9 +20,20 @@ Plugin 安装后,agent 应该**主动**开始引导,不要等用户问"怎
20
20
  **第二步:聊天式填名片**(见下方详细流程)
21
21
 
22
22
  **第三步:名片存好后,要位置**
23
- > "名片存好了 ✅ 现在发个位置给我——在 Telegram/WhatsApp 里点位置分享就行。我帮你看看附近有谁值得认识。"
24
23
 
25
- **关键:名片先于位置。** 没有名片就扫描,附近的人看不到你的信息,匹配质量也差。
24
+ 名片保存后,**立刻**帮用户获取位置。有两种方式,优先用第一种:
25
+
26
+ **方式 1:生成绑定链接(推荐)**
27
+ 调用 `antenna_bind` 生成链接,发给用户:
28
+ > "名片存好了 ✅ 点这个链接,在手机浏览器打开,允许定位就行:
29
+ > [链接]
30
+ > 我收到你的位置后会自动帮你看看附近有谁。"
31
+
32
+ **方式 2:直接发位置消息**
33
+ 如果用户在 Telegram/WhatsApp 里,可以直接发位置:
34
+ > "或者你也可以直接在聊天里点位置分享发给我。"
35
+
36
+ **关键:名片存好后必须主动要位置,不要等用户问。**
26
37
 
27
38
  ## When to use
28
39
 
@@ -72,6 +83,13 @@ Check for mutual matches and contact info updates.
72
83
  - `sender_id`, `channel`
73
84
  - Returns mutual matches with any contact info the other person shared
74
85
 
86
+ ### `antenna_bind`
87
+ Generate a GPS binding link. Call this after profile is created to get the user's location.
88
+ - `sender_id`, `channel`: from context
89
+ - Returns a URL like `https://www.antenna.fyi/locate?token=xxx`
90
+ - Send this link to the user — they open it on their phone, allow GPS, and their location is automatically shared with Supabase
91
+ - **Always call this right after saving the profile** — don't wait for the user to ask
92
+
75
93
  ## Behavior guidelines
76
94
 
77
95
  ### First-time user — 聊天式引导(不要让用户填表)