import type { StoreContext } from '../chatkit/store'; import { type RdfAccessScope } from '../../storage/rdf/RdfAccessScope'; import type { RdfEngineLike, RdfQuery, RdfQueryCacheScope } from '../../storage/rdf/types'; import type { RunContextRetrievalInput, RunContextRetriever, RunRetrievedContext } from './RunExecutionBackend'; export type RdfRunContextEmbedding = number[] | { embedding: number[]; provider?: string; model?: string; modelVersion?: string; inputKind?: string; projectionPolicyVersion?: string; }; export interface RdfRunContextRetrieverOptions { rdfEngine: RdfEngineLike; limit?: number; /** * Keep normal product paths fail-closed so missing text/vector indexes are * exposed at startup or request execution instead of silently degrading Run * context. Tests and optional deployments can still opt into best-effort * retrieval explicitly. */ failOpen?: boolean; textWeight?: number; vectorWeight?: number; /** * Minimum vector similarity for the vector-only fallback. The fused query * implicitly filters by "the text side matched"; a vector-only retry has no * such filter, so without a floor every prompt would return its nearest (and * possibly unrelated) chunks. */ vectorFallbackThreshold?: number; vectorProvider?: string; vectorModel?: string; vectorModelVersion?: string; vectorInputKind?: string; vectorProjectionPolicyVersion?: string; sourcePrefix?: string | ((input: RunContextRetrievalInput) => string | undefined); cacheScope?: RdfQueryCacheScope | ((input: RunContextRetrievalInput) => RdfQueryCacheScope | undefined); accessScope?: RdfAccessScope | ((input: RunContextRetrievalInput) => RdfAccessScope | undefined); embedding?: (input: RunContextRetrievalInput) => Promise; buildQuery?: (input: RunContextRetrievalInput, embedding?: RdfRunContextEmbedding) => RdfQuery | Promise; } /** * Product-level Run context retriever backed by SolidRdfEngine/PostgresRdfEngine. * * The retriever keeps RDF/text/vector lookup outside durable queue events and * returns runtime-neutral snippets that drivers can project into their own * prompt/session format. */ export declare class RdfRunContextRetriever implements RunContextRetriever { private readonly options; constructor(options: RdfRunContextRetrieverOptions); retrieve(input: RunContextRetrievalInput): Promise; /** * Retrieval is semantic first: the fused query joins text and vector hits, so a * prompt the text index cannot match (CJK tokenisation, a paraphrase) would drop * its vector hits and return nothing. Retry with the vector side alone when the * fused query came back empty. */ private vectorOnlyQuery; private buildDefaultQuery; private searchScope; private cacheScope; private withAccessScope; private assertAccessScopeOptional; private assertAccessScopeComplete; private bindingToContextItem; }