| 2780 | // hub memory vectors are now computed on-the-fly at search time. |
| 2781 | |
| 2782 | searchHubMemories(query: string, options?: { userId?: string; maxResults?: number }): Array<{ hit: HubMemorySearchRow; rank: number }> { |
| 2783 | const limit = options?.maxResults ?? 10; |
| 2784 | const userId = options?.userId ?? ""; |
| 2785 | const sanitized = sanitizeFtsQuery(query); |
| 2786 | if (!sanitized) return []; |
| 2787 | const rows = this.db.prepare(` |
| 2788 | SELECT hm.id, hm.content, hm.summary, hm.role, hm.created_at, hm.visibility, '' as group_name, hu.username as owner_name, |
| 2789 | COALESCE(hm.source_agent, '') as source_agent, bm25(hub_memories_fts) as rank |
| 2790 | FROM hub_memories_fts f |
| 2791 | JOIN hub_memories hm ON hm.rowid = f.rowid |
| 2792 | LEFT JOIN hub_users hu ON hu.id = hm.source_user_id |
| 2793 | WHERE hub_memories_fts MATCH ? |
| 2794 | ORDER BY rank |
| 2795 | LIMIT ? |
| 2796 | `).all(sanitized, limit) as HubMemorySearchRow[]; |
| 2797 | return rows.map((row, idx) => ({ hit: row, rank: idx + 1 })); |
| 2798 | } |
| 2799 | |
| 2800 | // getVisibleHubMemoryEmbeddings removed: vectors computed on-the-fly at search time. |
| 2801 | |