import { Document, DocumentInterface } from "@langchain/core/documents"; import { BaseRetriever } from "@langchain/core/retrievers"; import { StructuredToolInterface } from "@langchain/core/tools"; import { ClientBatchCheckItem, ConsistencyPreference } from "@openfga/sdk"; import { FGAClientParams } from "@auth0/ai"; import type { BaseRetrieverInput } from "@langchain/core/retrievers"; import type { CallbackManagerForRetrieverRun } from "@langchain/core/callbacks/manager"; export type FGARetrieverCheckerFn = (doc: DocumentInterface>) => ClientBatchCheckItem; export type FGARetrieverArgs = { retriever: BaseRetriever; buildQuery: FGARetrieverCheckerFn; consistency?: ConsistencyPreference; retrieverFields?: BaseRetrieverInput; }; /** * A retriever that allows filtering documents based on access control checks * using OpenFGA. This class wraps an underlying retriever and performs batch * checks on retrieved documents, returning only the ones that pass the * specified access criteria. * * @remarks * The FGARetriever requires a buildQuery function to specify how access checks * are formed for each document, the checks are executed via an OpenFGA client * or equivalent mechanism. The checks are then mapped back to their corresponding * documents to filter out those for which access is denied. * * @example * ```ts * const retriever = FGARetriever.create({ * retriever: someOtherRetriever, * buildQuery: (doc) => ({ * user: `user:${user}`, * object: `doc:${doc.metadata.id}`, * relation: "viewer", * }), * }); * ``` */ export declare class FGARetriever extends BaseRetriever { lc_namespace: string[]; private retriever; private fgaFilter; private constructor(); /** * Creates a new FGARetriever instance using the given arguments and optional OpenFgaClient. * * @param args - @FGARetrieverArgs * @param args.retriever - The underlying retriever instance to fetch documents. * @param args.buildQuery - A function to generate access check requests for each document. * @param args.consistency - Optional - The consistency preference for the OpenFGA client. * @param args.retrieverFields - Optional - Additional fields to pass to the underlying retriever. * @param fgaClientParams - Optional - OpenFgaClient configuration to execute checks against. * @returns A newly created FGARetriever instance configured with the provided arguments. */ static create(args: FGARetrieverArgs, fgaClientParams?: FGAClientParams): FGARetriever; /** * Retrieves documents based on the provided query parameters, processes * them through a checker function, * and filters the documents based on permissions. * * @param params - The query parameters used to retrieve nodes. * @returns A promise that resolves to an array of documents that have passed the permission checks. */ _getRelevantDocuments(query: string, runManager?: CallbackManagerForRetrieverRun): Promise; /** * Converts the FGA retriever into a tool that can be used by a LangGraph agent. * @returns StructuredToolInterface. */ asJoinedStringTool(): StructuredToolInterface; } //# sourceMappingURL=index.d.ts.map