antenna-fyi 0.11.4 → 0.12.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/lib/core.js +43 -1
  2. package/package.json +1 -1
package/lib/core.js CHANGED
@@ -10,6 +10,30 @@ const DEFAULT_KEY =
10
10
  let _client = null;
11
11
  let _url = null;
12
12
 
13
+ // ─── Embedding ───────────────────────────────────────────────────────
14
+
15
+ const GEMINI_EMBEDDING_URL = "https://generativelanguage.googleapis.com/v1beta/models/text-embedding-004:embedContent";
16
+
17
+ async function generateEmbedding(text) {
18
+ const apiKey = process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY;
19
+ if (!apiKey) return null; // silently skip if no key
20
+
21
+ const res = await fetch(`${GEMINI_EMBEDDING_URL}?key=${apiKey}`, {
22
+ method: "POST",
23
+ headers: { "Content-Type": "application/json" },
24
+ body: JSON.stringify({
25
+ model: "models/text-embedding-004",
26
+ content: { parts: [{ text }] },
27
+ taskType: "SEMANTIC_SIMILARITY",
28
+ outputDimensionality: 768,
29
+ }),
30
+ });
31
+
32
+ if (!res.ok) return null;
33
+ const data = await res.json();
34
+ return data?.embedding?.values || null;
35
+ }
36
+
13
37
  export function getClient(url, key) {
14
38
  const u = url || process.env.ANTENNA_SUPABASE_URL || process.env.ANTENNA_URL || DEFAULT_URL;
15
39
  const k = key || process.env.ANTENNA_SUPABASE_KEY || process.env.ANTENNA_KEY || DEFAULT_KEY;
@@ -90,7 +114,7 @@ export async function scan({ lat, lng, radius_m = 500, device_id, supabaseUrl, s
90
114
  if (others.length === 0 && device_id) {
91
115
  const { data: globalData } = await sb.rpc("global_discover", {
92
116
  p_device_id: device_id,
93
- p_limit: 3,
117
+ p_limit: 1,
94
118
  });
95
119
  const globalOthers = globalData || [];
96
120
  if (globalOthers.length > 0) {
@@ -153,6 +177,24 @@ export async function setProfile({
153
177
  p_visible: visible,
154
178
  });
155
179
  if (error) throw new Error(error.message);
180
+
181
+ // Generate embedding for global discover matching
182
+ try {
183
+ const text = [line1, line2, line3].filter(Boolean).join(". ");
184
+ if (text) {
185
+ const embedding = await generateEmbedding(text);
186
+ if (embedding) {
187
+ await sb.rpc("update_profile_embedding", {
188
+ p_device_id: device_id,
189
+ p_embedding: JSON.stringify(embedding),
190
+ });
191
+ }
192
+ }
193
+ } catch (e) {
194
+ // Embedding is best-effort, don't fail profile save
195
+ console.error("Embedding generation failed (non-fatal):", e.message);
196
+ }
197
+
156
198
  return { ...data, next_step: "IMPORTANT: Now call antenna_bind to generate a GPS link for the user. Do not skip this." };
157
199
  }
158
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-fyi",
3
- "version": "0.11.4",
3
+ "version": "0.12.0",
4
4
  "description": "Antenna — nearby people discovery. CLI + MCP server + OpenClaw skill & plugin, all in one package.",
5
5
  "type": "module",
6
6
  "bin": {