/** * User Context Generator * * Synthesizes context paragraphs from user premises for storage in the * user_contexts table. Two scopes: * - network-scoped: who the person is through the lens of a given network * - global (networkId = null): a cohesive, network-agnostic identity paragraph * that replaces the legacy synthesized user_profile projection. * Each scope supports cold-start (all premises at once) and incremental * (single premise change applied to an existing context). * Returns { text, embedding } for storage. */ import type { EmbeddingGenerator } from "../shared/interfaces/embedder.interface.js"; /** Input for cold-start context generation from a full set of premises. */ export interface UserContextInput { premises: Array<{ text: string; }>; networkPrompt: string | null; networkTitle: string; } /** Input for incremental context update from a single premise change. */ export interface IncrementalContextInput { currentContext: string; changeType: 'added' | 'updated' | 'retracted' | 'expired'; premiseText: string; previousPremiseText?: string; networkPrompt: string | null; networkTitle: string; } /** Input for cold-start global (network-agnostic) context generation. */ export interface GlobalContextInput { premises: Array<{ text: string; }>; } /** Input for incremental global context update from a single premise change. */ export interface GlobalIncrementalContextInput { currentContext: string; changeType: 'added' | 'updated' | 'retracted' | 'expired'; premiseText: string; previousPremiseText?: string; } /** Generated context paragraph with its embedding vector. */ export interface UserContextResult { text: string; embedding: number[]; } /** * Generates network-scoped context paragraphs from user premises. * Uses LLM synthesis to produce focused context and an embedding vector. */ export declare class UserContextGenerator { private embeddingGenerator; private model; constructor(embeddingGenerator: EmbeddingGenerator); /** * Generate a context paragraph from the full set of premises (cold-start). * * @param input - Premises, network prompt, and network title * @returns Synthesized context text with embedding vector */ generateColdStart(input: UserContextInput): Promise; /** * Update an existing context paragraph after a single premise change. * * @param input - Current context, change details, network metadata * @returns Updated context text with embedding vector */ generateIncremental(input: IncrementalContextInput): Promise; /** * Generate a global (network-agnostic) identity paragraph from the full set * of premises (cold-start). This is the profile-replacing projection stored * as the user's global user_context row (networkId = null). * * @param input - The user's active premises * @returns Synthesized global identity text with embedding vector */ generateGlobalColdStart(input: GlobalContextInput): Promise; /** * Update the global identity paragraph after a single premise change. * * @param input - Current global context and change details * @returns Updated global identity text with embedding vector */ generateGlobalIncremental(input: GlobalIncrementalContextInput): Promise; /** Normalize an LLM message content into a plain string. */ private extractText; /** Format the network context header for LLM prompts. */ private formatNetworkContext; /** Describe the premise change for the incremental prompt. */ private describeChange; /** Generate embedding from text, normalizing the return type. */ private embed; }