antenna-fyi 0.8.0 → 0.8.1

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.1",
4
4
  "description": "Antenna — nearby people discovery. CLI + MCP server + OpenClaw skill & plugin, all in one package.",
5
5
  "type": "module",
6
6
  "bin": {