const OLLAMA_URL = process.env.OLLAMA_URL ?? "http://localhost:11434";
const EMBED_MODEL = process.env.EMBED_MODEL ?? "nomic-embed-text";
export function buildPersonEmbeddingText(givenName, familyName, email, status, notesJson) {
    let text = `Person: ${givenName}${familyName ? ` ${familyName}` : ""} <${email}> source: waitlist status: ${status}`;
    if (notesJson) {
        try {
            const notes = JSON.parse(notesJson);
            const parts = [];
            if (notes.businessType)
                parts.push(`business: ${notes.businessType}`);
            if (notes.role)
                parts.push(`role: ${notes.role}`);
            if (notes.needs)
                parts.push(`needs: ${notes.needs}`);
            if (notes.challenges)
                parts.push(`challenges: ${notes.challenges}`);
            if (notes.interests)
                parts.push(`interests: ${notes.interests}`);
            if (notes.engagementQuality)
                parts.push(`engagement: ${notes.engagementQuality}`);
            if (notes.otherSignals)
                parts.push(`signals: ${notes.otherSignals}`);
            if (parts.length > 0)
                text += ` | ${parts.join("; ")}`;
        }
        catch {
            // Malformed notes — embed without discovery context
        }
    }
    return text;
}
export async function computeEmbedding(text) {
    try {
        const res = await fetch(`${OLLAMA_URL}/api/embed`, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ model: EMBED_MODEL, input: text }),
        });
        if (!res.ok)
            return [];
        const data = (await res.json());
        return data.embeddings[0] ?? [];
    }
    catch {
        return [];
    }
}
//# sourceMappingURL=embedding.js.map