/** * Lens Inferrer Agent: analyzes source text (intent or query) with optional * profile context and infers 1-N search lenses, each tagged with a target corpus. * Replaces the hardcoded HydeStrategy enum and regex-based selectStrategiesFromQuery. */ import type { BaseLanguageModelInput } from '@langchain/core/language_models/base'; import { z } from 'zod'; import { type HydeSourceFrame } from './hyde.frame.js'; export type HydeTargetCorpus = 'profiles' | 'intents' | 'premises'; /** A single inferred lens — a search perspective the LLM decided is relevant. */ export interface Lens { /** Free-text description (e.g. "crypto infrastructure VC"). */ label: string; /** Which vector index to search: user profiles or user intents. */ corpus: HydeTargetCorpus; /** Why this perspective is relevant (for logging/trace). */ reasoning: string; } export interface LensInferenceInput { /** Intent payload or search query. */ sourceText: string; /** User's profile summary for domain context (optional). */ profileContext?: string; /** Maximum number of lenses to infer (default 3). */ maxLenses?: number; /** Use the source-grounded frame-v1 inference path. */ frameConstrained?: boolean; } export interface LensInferenceOutput { lenses: Lens[]; /** Sanitized source frame, present only for frame-constrained inference. */ sourceFrame?: HydeSourceFrame; } /** Source-grounded system prompt used only by frame extraction. */ export declare const FRAME_SYSTEM_PROMPT = "You extract a source-grounded frame for semantic retrieval from sourceText alone.\n\nSource-frame rules:\n- Extract evidence ONLY from sourceText.\n- Every frame element must include an evidence field copied as an exact substring of sourceText.\n- sourceRoles describe roles held or offered by the source side.\n- sourceRoles and counterpartRoles MUST use generic lower-case role labels only (for example, \"founder\", \"investor\", or \"technical advisor\"). Never put a person, organization, product, location, time, number, credential, or exclusivity detail in a role label.\n- counterpartRoles describe reciprocal or complementary target roles. A generic role may be inferred, but its evidence must be an exact sourceText span that supports the inference.\n- hardConstraints contain only explicit constraints and classify each as location, time, numeric, credential, organization, exclusivity, or other.\n- namedEntities contain only proper names explicitly present in sourceText and classify each as person, organization, product, location, event, or other.\n- domainVocabulary contains source domain terms worth preserving."; /** Structured-output schema used only by source-frame extraction. */ export declare const FrameResponseSchema: z.ZodObject<{ sourceFrame: z.ZodObject<{ sourceRoles: z.ZodArray, "many">; counterpartRoles: z.ZodArray, "many">; hardConstraints: z.ZodArray; value: z.ZodString; evidence: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }, { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }>, "many">; namedEntities: z.ZodArray; name: z.ZodString; evidence: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }, { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }>, "many">; domainVocabulary: z.ZodArray, "many">; }, "strip", z.ZodTypeAny, { sourceRoles: { role: string; evidence: string; }[]; counterpartRoles: { role: string; evidence: string; }[]; hardConstraints: { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }[]; namedEntities: { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }[]; domainVocabulary: { evidence: string; term: string; }[]; }, { sourceRoles: { role: string; evidence: string; }[]; counterpartRoles: { role: string; evidence: string; }[]; hardConstraints: { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }[]; namedEntities: { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }[]; domainVocabulary: { evidence: string; term: string; }[]; }>; }, "strip", z.ZodTypeAny, { sourceFrame: { sourceRoles: { role: string; evidence: string; }[]; counterpartRoles: { role: string; evidence: string; }[]; hardConstraints: { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }[]; namedEntities: { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }[]; domainVocabulary: { evidence: string; term: string; }[]; }; }, { sourceFrame: { sourceRoles: { role: string; evidence: string; }[]; counterpartRoles: { role: string; evidence: string; }[]; hardConstraints: { value: string; type: "location" | "time" | "numeric" | "credential" | "organization" | "exclusivity" | "other"; evidence: string; }[]; namedEntities: { name: string; type: "location" | "organization" | "other" | "person" | "product" | "event"; evidence: string; }[]; domainVocabulary: { evidence: string; term: string; }[]; }; }>; type ModelInput = BaseLanguageModelInput; /** Minimal structured model contract used for deterministic injection in tests. */ export interface LensStructuredModel { invoke(input: ModelInput, config?: { signal?: AbortSignal; }): Promise; } export interface LensInferrerOptions { legacyModel?: LensStructuredModel; frameModel?: LensStructuredModel; } /** Infers search lenses from source text and optional profile context. */ export declare class LensInferrer { private legacyModel?; private frameModel?; constructor(options?: LensInferrerOptions); private getLegacyModel; private getFrameModel; /** Infer search lenses while preserving the legacy path unless explicitly enabled. */ infer(input: LensInferenceInput): Promise; } export {};