@dudousxd/nestjs-agent-rag 0.13.1 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Passage, Retriever, EmbeddingProvider, RetrieveOptions, Reranker, ToolSpec, ToolHandler, RerankOptions, ModelProvider, AiToolCtx } from '@dudousxd/nestjs-agent-core';
1
+ import { Passage, Retriever, EmbeddingProvider, RetrieveOptions, Reranker, ToolSpec, ToolHandler, AiToolCtx, RerankOptions, ModelProvider } from '@dudousxd/nestjs-agent-core';
2
2
 
3
3
  interface ChunkOptions {
4
4
  /** Target max characters per chunk. Default 800. */
@@ -89,7 +89,10 @@ interface VectorRecord {
89
89
  }
90
90
  interface VectorSearchOptions {
91
91
  topK: number;
92
- /** Exact-match metadata filter (all keys must equal). Passed through from `RetrieveOptions.filter`. */
92
+ /**
93
+ * Exact-match metadata filter (all keys must equal). Passed through from `RetrieveOptions.filter`.
94
+ * An empty array or an `undefined` value matches nothing.
95
+ */
93
96
  filter?: Record<string, unknown>;
94
97
  }
95
98
  /**
@@ -235,6 +238,8 @@ interface VectorStore {
235
238
  * got built wrong (a dropped key, an `undefined` scope) than a deliberate request to delete
236
239
  * everything. Deliberate mass deletion stays available and stays explicit:
237
240
  * `removeMany(await store.listDocumentIds())`, or the backend's own drop.
241
+ * - **A key with an `undefined` value throws** {@link UnsafeRemovalError} too, for the same reason:
242
+ * `removeWhere({ tenantId: actor.tenantRef })` with no tenant is a bug, not a request.
238
243
  *
239
244
  * What it removes is exactly what a {@link VectorStore.search} carrying the same filter could
240
245
  * reach — no more (it cannot escape the filter) and no less.
@@ -273,6 +278,17 @@ interface LexicalVectorStore extends VectorStore {
273
278
  */
274
279
  searchText(query: string, options: VectorSearchOptions): Promise<Passage[]>;
275
280
  }
281
+ /**
282
+ * An **optional** capability: swap all of a document's chunks safely under concurrent calls, so two
283
+ * writers can't leave a mix of versions behind. Postgres also makes the swap atomic for searches and
284
+ * crashes; Redis can't, and only guarantees the end state. {@link replaceDocumentChunks} falls back to
285
+ * `remove` plus `upsert` for the others.
286
+ */
287
+ interface AtomicReplaceVectorStore extends VectorStore {
288
+ replaceDocument(documentId: string, records: VectorRecord[]): Promise<void>;
289
+ }
290
+ /** Replaces a document's chunks through the store's safe swap, where it has one. */
291
+ declare function replaceDocumentChunks(store: VectorStore, documentId: string, records: VectorRecord[]): Promise<void>;
276
292
  /**
277
293
  * Does this store carry the optional {@link LexicalVectorStore} capability? Lets a consumer pick the
278
294
  * store-backed lexical leg when available and fall back to `KeywordRetriever` (or to dense-only)
@@ -287,10 +303,10 @@ declare function isLexicalVectorStore(store: VectorStore): store is LexicalVecto
287
303
  */
288
304
  declare class UnsafeRemovalError extends Error {
289
305
  /** Why the removal was refused. */
290
- readonly reason: 'empty-filter' | 'unindexed-field';
306
+ readonly reason: 'empty-filter' | 'unindexed-field' | 'undefined-value';
291
307
  constructor(
292
308
  /** Why the removal was refused. */
293
- reason: 'empty-filter' | 'unindexed-field', message: string);
309
+ reason: 'empty-filter' | 'unindexed-field' | 'undefined-value', message: string);
294
310
  }
295
311
  /** A distinct source document as seen by the index — its id plus a representative chunk's metadata. */
296
312
  interface IndexedDocument {
@@ -562,6 +578,13 @@ interface PgVectorStoreOptions {
562
578
  * the chunk metadata) when two models share a width.
563
579
  */
564
580
  dimensions?: number | readonly number[];
581
+ /**
582
+ * The pgvector column type. `halfvec` stores each dimension in 2 bytes instead of 4, and its HNSW
583
+ * index accepts up to 4000 dimensions where `vector` stops at 2000 (so `text-embedding-3-large`'s
584
+ * 3072 needs it). Needs a single width, not a list. Only affects the DDL for a new table and the
585
+ * casts in statements: converting an existing table is a migration of yours. Default `vector`.
586
+ */
587
+ vectorType?: 'vector' | 'halfvec';
565
588
  /**
566
589
  * Allow chunks with no embedding (`embedding: []` on upsert is stored as `NULL`): index text first
567
590
  * and embed later, or keep full-text-only chunks when there is no embedding model at all. The
@@ -617,13 +640,14 @@ interface PgVectorStoreOptions {
617
640
  * Subclassing: every statement filters through {@link PgVectorStore.whereConditions}, so a subclass
618
641
  * can map an opaque filter onto its own columns (a tenant id, an ACL) in one place.
619
642
  */
620
- declare class PgVectorStore implements VectorStore {
643
+ declare class PgVectorStore implements AtomicReplaceVectorStore {
621
644
  protected readonly client: PgClient;
622
645
  protected readonly table: string;
623
646
  /** The single width (fixed-dimension table), or `undefined` for a mixed-dimension table. */
624
647
  private readonly dimensions;
625
648
  /** The widths with a partial HNSW index, for a mixed-dimension table. */
626
649
  private readonly indexedDimensions;
650
+ private readonly vectorType;
627
651
  private readonly nullableEmbeddings;
628
652
  private readonly iterativeScan;
629
653
  private readonly efSearch;
@@ -645,6 +669,16 @@ declare class PgVectorStore implements VectorStore {
645
669
  * {@link PgVectorStoreOptions.nullableEmbeddings}).
646
670
  */
647
671
  upsert(records: VectorRecord[]): Promise<void>;
672
+ /**
673
+ * Swaps a document's chunks in one transaction, so a crash can't lose it and a search sees the old
674
+ * version or the new one. A client without `transaction` falls back to two statements.
675
+ *
676
+ * Concurrent swaps of one document take turns on an advisory lock. Without it the second `DELETE`
677
+ * can't see the rows the first just committed, so the first's tail survives next to the second's
678
+ * chunks, and overlapping writes can deadlock.
679
+ */
680
+ replaceDocument(documentId: string, records: VectorRecord[]): Promise<void>;
681
+ private upsertWith;
648
682
  remove(documentId: string): Promise<void>;
649
683
  /**
650
684
  * Rewrite a document's metadata without re-embedding it. See {@link VectorStore.updateMetadata}
@@ -741,12 +775,6 @@ declare class PgLexicalVectorStore extends PgVectorStore implements LexicalVecto
741
775
  private tsvector;
742
776
  }
743
777
 
744
- /**
745
- * The minimal Redis surface {@link RedisVectorStore} needs: send a raw command and get the reply.
746
- * Both `node-redis` (`client.sendCommand(args)`) and `ioredis` (wrap `redis.call`) satisfy it — so
747
- * this package pulls in NO Redis driver (bring your own, like the other adapters). Requires the
748
- * RediSearch module (Redis Stack / Redis 8+).
749
- */
750
778
  interface RedisSearchClient {
751
779
  sendCommand(args: (string | Buffer)[]): Promise<unknown>;
752
780
  }
@@ -808,7 +836,7 @@ interface RedisVectorStoreOptions {
808
836
  * {@link LexicalVectorStore}: {@link RedisVectorStore.searchText} is BM25 over that same index —
809
837
  * the lexical half of hybrid search with no second index to build, feed, or invalidate.
810
838
  */
811
- declare class RedisVectorStore implements LexicalVectorStore {
839
+ declare class RedisVectorStore implements LexicalVectorStore, AtomicReplaceVectorStore {
812
840
  private readonly client;
813
841
  private readonly index;
814
842
  private readonly prefix;
@@ -850,6 +878,18 @@ declare class RedisVectorStore implements LexicalVectorStore {
850
878
  private reconcileSchema;
851
879
  private createIndex;
852
880
  upsert(records: VectorRecord[]): Promise<void>;
881
+ /**
882
+ * Replaces a document's chunks, one writer at a time per document. Redis can't swap them in one step
883
+ * without scanning the keyspace inside a script, so a search may briefly see old and new chunks
884
+ * together, but concurrent calls can't leave them mixed. The new chunks go in before the old ones
885
+ * come out, so a crash leaves the document searchable and the next call repairs it.
886
+ */
887
+ replaceDocument(documentId: string, records: VectorRecord[]): Promise<void>;
888
+ /**
889
+ * A lease, so a crashed writer can't block the document forever. It is renewed while the work runs,
890
+ * which keeps a large document from outliving it.
891
+ */
892
+ private withDocumentLock;
853
893
  /**
854
894
  * Single-document deletion, by `SCAN … MATCH`.
855
895
  *
@@ -1394,6 +1434,11 @@ interface RetrievalToolOptions {
1394
1434
  description?: string;
1395
1435
  /** Passages per search. Default lets the retriever decide (typically 5). */
1396
1436
  topK?: number;
1437
+ /**
1438
+ * The access filter for this call, from the tool context — e.g.
1439
+ * `(ctx) => ({ tenant: ctx.actor.tenantRef })`. Without it, every actor searches the same corpus.
1440
+ */
1441
+ filter?: (ctx: AiToolCtx) => Record<string, unknown> | undefined;
1397
1442
  /**
1398
1443
  * Retrieval telemetry (`aviary:rag:retrieval` — duration, chunk count, score distribution, store
1399
1444
  * and collection). **On by default**, because this tool is the once-per-retrieval seam in agentic
@@ -1427,6 +1472,23 @@ interface RetrievalTool {
1427
1472
  */
1428
1473
  declare function createRetrievalTool(retriever: Retriever, options?: RetrievalToolOptions): RetrievalTool;
1429
1474
 
1475
+ /** What one embedding call consumed: the whole batch, not per text. */
1476
+ interface EmbeddingUsage {
1477
+ inputTokens: number;
1478
+ /** The model the provider reported, needed to estimate a cost. */
1479
+ modelId?: string;
1480
+ }
1481
+ interface EmbeddingResult {
1482
+ vectors: number[][];
1483
+ usage?: EmbeddingUsage;
1484
+ }
1485
+ /** An {@link EmbeddingProvider} that can also say what a call cost. `openAiEmbeddings` is one. */
1486
+ interface UsageReportingEmbeddingProvider extends EmbeddingProvider {
1487
+ embedWithUsage(texts: string[]): Promise<EmbeddingResult>;
1488
+ }
1489
+ /** Calls `embedWithUsage` when the provider has it, otherwise `embed` with no usage. */
1490
+ declare function embedCountingUsage(provider: EmbeddingProvider, texts: string[]): Promise<EmbeddingResult>;
1491
+
1430
1492
  /** A non-2xx answer (or a malformed one) from an embeddings or rerank endpoint. */
1431
1493
  declare class HttpModelError extends Error {
1432
1494
  /** HTTP status; `502` when the endpoint answered 2xx with a body that doesn't fit the contract. */
@@ -1497,7 +1559,7 @@ declare function isBatchTooLarge(error: unknown): boolean;
1497
1559
  * const local = openAiEmbeddings({ baseUrl: 'http://tei:8080/v1', model: 'BAAI/bge-m3' });
1498
1560
  * ```
1499
1561
  */
1500
- declare function openAiEmbeddings(options: OpenAiEmbeddingsOptions): EmbeddingProvider;
1562
+ declare function openAiEmbeddings(options: OpenAiEmbeddingsOptions): UsageReportingEmbeddingProvider;
1501
1563
 
1502
1564
  interface HttpRerankerOptions {
1503
1565
  /**
@@ -1543,6 +1605,137 @@ declare class HttpReranker implements Reranker {
1543
1605
  rerank(query: string, passages: Passage[], options?: RerankOptions): Promise<Passage[]>;
1544
1606
  }
1545
1607
 
1608
+ /** The metadata key separating models that share one store. Reserved: it always wins over yours. */
1609
+ declare const RAG_ENTITY_KEY = "ragEntity";
1610
+ /** What a scope value can be. Compared as strings, so `7` and `'7'` are the same scope everywhere. */
1611
+ type RagScopeValue = string | number;
1612
+ /** Maps a scope key to the function reading it from a row. `{}` declares a global corpus. */
1613
+ type RagScopeDefinition<Row> = Record<string, (row: Row) => RagScopeValue>;
1614
+ /** A required scope value was missing or malformed. Thrown before any embedding is paid for. */
1615
+ declare class RagScopeRequiredError extends Error {
1616
+ readonly model: string;
1617
+ readonly key: string;
1618
+ constructor(model: string, key: string);
1619
+ }
1620
+ declare const ANY_OF: unique symbol;
1621
+ /** See {@link anyOf}. */
1622
+ interface RagAnyOf<Value> {
1623
+ readonly [ANY_OF]: readonly Value[];
1624
+ }
1625
+ /**
1626
+ * Search several scope values at once. An empty list matches nothing. It is a wrapper rather than a
1627
+ * plain array so that an array arriving from a request can't widen a search by accident.
1628
+ */
1629
+ declare function anyOf<Value extends RagScopeValue>(values: readonly Value[]): RagAnyOf<Value>;
1630
+ /** The scope a search must carry: every key of the definition, with the type its function returns. */
1631
+ type RagScopeOf<Scope> = {
1632
+ [Key in keyof Scope]: Scope[Key] extends (row: never) => infer Value ? Value | RagAnyOf<Value> : never;
1633
+ };
1634
+ /** A `scope` is required unless the definition declared none. A `filter` can't name a scope key. */
1635
+ type RagSearchOptions<Scope> = {
1636
+ topK?: number;
1637
+ filter?: Record<string, unknown> & {
1638
+ [Key in keyof Scope]?: never;
1639
+ };
1640
+ } & (keyof Scope extends never ? {
1641
+ scope?: undefined;
1642
+ } : {
1643
+ scope: RagScopeOf<Scope>;
1644
+ });
1645
+ interface RagIndexDefinition<Row, Scope extends RagScopeDefinition<Row>> {
1646
+ /** Namespaces document ids (`<name>:<id>`) and the {@link RAG_ENTITY_KEY} metadata. */
1647
+ name: string;
1648
+ id: (row: Row) => RagScopeValue;
1649
+ /** The text to index. Blank removes the row's chunks. */
1650
+ text: (row: Row) => string | null | undefined;
1651
+ /** Required on purpose: a global corpus has to say `scope: {}`. */
1652
+ scope: Scope;
1653
+ /** Citation-facing origin of each chunk. */
1654
+ source?: (row: Row) => string | null | undefined;
1655
+ /** Extra chunk metadata. Can't override the scope. */
1656
+ metadata?: (row: Row) => Record<string, unknown>;
1657
+ chunk?: ChunkOptions;
1658
+ /** Keep only the first N chunks: an upper bound on what one huge document can cost. */
1659
+ maxChunks?: number;
1660
+ minScore?: EmbeddingRetrieverOptions['minScore'];
1661
+ }
1662
+ interface RagIndexDeps {
1663
+ store: VectorStore;
1664
+ embedder: EmbeddingProvider;
1665
+ /**
1666
+ * Replaces the default dense retriever (hybrid, reranked). It must honour `options.filter`, which
1667
+ * carries the scope. Embedding spend it does on its own doesn't reach `onUsage`.
1668
+ */
1669
+ retriever?: Retriever;
1670
+ /** Embedding spend, indexing and searching alike. This package can't know who pays for it. */
1671
+ onUsage?: (usage: EmbeddingUsage) => void | Promise<void>;
1672
+ }
1673
+ interface RagReconcileOptions<Scope> {
1674
+ /** Compare only this part of the corpus. `liveIds` then only has to cover that part. */
1675
+ scope?: Partial<{
1676
+ [Key in keyof Scope]: Scope[Key] extends (row: never) => infer V ? V : never;
1677
+ }>;
1678
+ /** Report without removing anything. */
1679
+ dryRun?: boolean;
1680
+ }
1681
+ interface RagReconcileResult {
1682
+ /** Indexed document ids with no live row. Removed, unless `dryRun`. */
1683
+ orphans: string[];
1684
+ /** Live document ids with no chunks: never indexed, or blank. Nothing is embedded for them here. */
1685
+ missing: string[];
1686
+ }
1687
+ interface RagToolOptions<Scope> {
1688
+ name: string;
1689
+ description?: string;
1690
+ topK?: number;
1691
+ /** From the tool context, never from the model's input. */
1692
+ scope: (ctx: AiToolCtx) => RagScopeOf<Scope>;
1693
+ }
1694
+ /**
1695
+ * The framework-free core behind `RagRepository`: one model's chunks in a shared store, with a scope
1696
+ * that a search can't omit or override. It only composes what this package already has; cost, quota
1697
+ * and access control stay in the app.
1698
+ *
1699
+ * Saving a row doesn't index it, because embedding is a slow, paid call. Call {@link RagIndex.index}
1700
+ * from a job, or wherever the text is known to have changed.
1701
+ */
1702
+ declare class RagIndex<Row, Scope extends RagScopeDefinition<Row>> {
1703
+ private readonly definition;
1704
+ private readonly deps;
1705
+ private readonly embedder;
1706
+ constructor(definition: RagIndexDefinition<Row, Scope>, deps: RagIndexDeps);
1707
+ /** The id this row's chunks are stored under: `<name>:<id>`. */
1708
+ documentId(id: RagScopeValue): string;
1709
+ /** A `Retriever` locked to this scope, for `HybridRetriever`, `createRetrievalTool` and so on. */
1710
+ scoped(scope: RagScopeOf<Scope>): Retriever;
1711
+ search(query: string, options: RagSearchOptions<Scope>): Promise<Passage[]>;
1712
+ /**
1713
+ * Replaces the row's chunks and returns how many were written. Embeddings come first: if the
1714
+ * provider fails, the previous chunks are still there. The swap is one transaction on Postgres. Redis
1715
+ * adds the new chunks before dropping the old, so a search can briefly see both. On a store without
1716
+ * `replaceDocument`, a crash mid-swap loses the document until the next `index`.
1717
+ */
1718
+ index(row: Row): Promise<number>;
1719
+ /** Takes the id itself once the row is gone. */
1720
+ remove(rowOrId: Row | RagScopeValue): Promise<void>;
1721
+ /**
1722
+ * Diffs the index against the ids that exist, and removes what no hook could: `ON DELETE CASCADE`,
1723
+ * raw SQL, a crash after a commit. `liveIds` must be complete for the part being compared, because
1724
+ * anything left out is removed. Use `dryRun` to look first.
1725
+ */
1726
+ reconcile(liveIds: Iterable<RagScopeValue> | AsyncIterable<RagScopeValue>, options?: RagReconcileOptions<Scope>): Promise<RagReconcileResult>;
1727
+ /** A `search_*` tool whose scope comes from the context. Pass it to `provideAgentTool`. */
1728
+ tool(options: RagToolOptions<Scope>): RetrievalTool;
1729
+ private baseRetriever;
1730
+ /** The filter a scope compiles to. Throws on anything but a usable value, before any paid call. */
1731
+ private scopeFilter;
1732
+ }
1733
+ /**
1734
+ * The fields a `RedisVectorStore` must declare in `filterableFields` to serve these scopes:
1735
+ * RediSearch can only filter on a key declared up front.
1736
+ */
1737
+ declare function ragFilterableFields(...scopeKeys: string[]): string[];
1738
+
1546
1739
  /**
1547
1740
  * The data model of tree navigation retrieval: a hierarchical table of contents per long document
1548
1741
  * (PageIndex-style: sections with page ranges and summaries), built once at ingestion and read by an
@@ -2327,4 +2520,4 @@ interface NavigateDocumentTool {
2327
2520
  */
2328
2521
  declare function createNavigateDocumentTool(navigator: TreeNavigationRetriever, options?: NavigateDocumentToolOptions): NavigateDocumentTool;
2329
2522
 
2330
- export { type BuildDocumentTreeOptions, type BuiltDocumentTree, type ChunkOptions, type ChunkRecord, DEFAULT_STOP_WORDS, type DescribesRetrieval, type DetectedHeading, type DocumentNavigation, type DocumentTree, type DocumentTreeHeader, type DocumentTreeInput, type DocumentTreeNode, type DocumentTreeStore, type DrizzleLike, EmbeddingRetriever, type EmbeddingRetrieverOptions, FilteredRetriever, HttpModelError, HttpReranker, type HttpRerankerOptions, HybridRetriever, type HybridRetrieverOptions, type IndexDocumentTreeOptions, type IndexDocumentTreeResult, type IndexedDocument, type IngestChunksOptions, type IngestDocument, type IngestOptions, type InstrumentRetrieverOptions, KeywordRetriever, type KeywordRetrieverOptions, LexicalRetriever, type LexicalVectorStore, type ListChunksOptions, MemoryDocumentTreeStore, MemoryVectorStore, type MetadataPatch, type NavigateDocumentInput, type NavigateDocumentOutput, type NavigateDocumentTool, type NavigateDocumentToolOptions, type NavigateOptions, type NavigatedNode, type NavigationResult, type NavigationStep, type NodePgQueryable, type OpenAiChatTreeLlmOptions, type OpenAiEmbeddingsOptions, type PgClient, type PgClientSource, PgDocumentTreeStore, type PgDocumentTreeStoreOptions, type PgFullTextOptions, PgLexicalVectorStore, PgVectorStore, type PgVectorStoreOptions, type PostgresJsSql, RAG_DIAGNOSTIC_LIB, RAG_RETRIEVAL_CHANNEL, RAG_RETRIEVAL_EVENT, type RagRetrievalEvent, type RedisSearchClient, RedisVectorSchemaMismatchError, RedisVectorStore, type RedisVectorStoreOptions, RerankingRetriever, type RerankingRetrieverOptions, type RetrievalDescriptor, type RetrievalTool, type RetrievalToolOptions, type RetrieverKind, type StoredChunk, type TreeBudget, TreeBudgetExceededError, type TreeBuildStats, type TreeHeading, type TreeLlm, type TreeLlmCache, type TreeLlmCandidate, type TreeLlmRequest, type TreeLlmResponse, type TreeLlmTask, TreeNavigationRetriever, type TreeNavigationRetrieverOptions, type TreeSection, type TreeStructureSource, type TreeSummarySource, type TreeUnit, TwoStageRetriever, type TwoStageRetrieverOptions, UnsafeRemovalError, type VectorRecord, type VectorSearchOptions, type VectorStore, type VectorStoreKind, anyTermTsquery, applyMetadataPatch, buildDocumentTree, cachedTreeLlm, chunkDocuments, chunkIndexOf, chunkText, createNavigateDocumentTool, createRetrievalTool, describeRetrieval, describeSharedSource, describeSource, describesRetrieval, detectHeadings, documentIdOf, emitRagRetrieval, estimateTokens, hasSearchSyntax, indexDocumentTree, indexTree, ingestChunks, ingestDocuments, instrumentRetriever, isBatchTooLarge, isLexicalVectorStore, keywordTerms, keywordTreeLlm, openAiChatTreeLlm, openAiEmbeddings, parseJsonReply, spanText, stableHash, toPgClient, treeLlmFromModelProvider, walkTree };
2523
+ export { type AtomicReplaceVectorStore, type BuildDocumentTreeOptions, type BuiltDocumentTree, type ChunkOptions, type ChunkRecord, DEFAULT_STOP_WORDS, type DescribesRetrieval, type DetectedHeading, type DocumentNavigation, type DocumentTree, type DocumentTreeHeader, type DocumentTreeInput, type DocumentTreeNode, type DocumentTreeStore, type DrizzleLike, type EmbeddingResult, EmbeddingRetriever, type EmbeddingRetrieverOptions, type EmbeddingUsage, FilteredRetriever, HttpModelError, HttpReranker, type HttpRerankerOptions, HybridRetriever, type HybridRetrieverOptions, type IndexDocumentTreeOptions, type IndexDocumentTreeResult, type IndexedDocument, type IngestChunksOptions, type IngestDocument, type IngestOptions, type InstrumentRetrieverOptions, KeywordRetriever, type KeywordRetrieverOptions, LexicalRetriever, type LexicalVectorStore, type ListChunksOptions, MemoryDocumentTreeStore, MemoryVectorStore, type MetadataPatch, type NavigateDocumentInput, type NavigateDocumentOutput, type NavigateDocumentTool, type NavigateDocumentToolOptions, type NavigateOptions, type NavigatedNode, type NavigationResult, type NavigationStep, type NodePgQueryable, type OpenAiChatTreeLlmOptions, type OpenAiEmbeddingsOptions, type PgClient, type PgClientSource, PgDocumentTreeStore, type PgDocumentTreeStoreOptions, type PgFullTextOptions, PgLexicalVectorStore, PgVectorStore, type PgVectorStoreOptions, type PostgresJsSql, RAG_DIAGNOSTIC_LIB, RAG_ENTITY_KEY, RAG_RETRIEVAL_CHANNEL, RAG_RETRIEVAL_EVENT, type RagAnyOf, RagIndex, type RagIndexDefinition, type RagIndexDeps, type RagReconcileOptions, type RagReconcileResult, type RagRetrievalEvent, type RagScopeDefinition, type RagScopeOf, RagScopeRequiredError, type RagScopeValue, type RagSearchOptions, type RagToolOptions, type RedisSearchClient, RedisVectorSchemaMismatchError, RedisVectorStore, type RedisVectorStoreOptions, RerankingRetriever, type RerankingRetrieverOptions, type RetrievalDescriptor, type RetrievalTool, type RetrievalToolOptions, type RetrieverKind, type StoredChunk, type TreeBudget, TreeBudgetExceededError, type TreeBuildStats, type TreeHeading, type TreeLlm, type TreeLlmCache, type TreeLlmCandidate, type TreeLlmRequest, type TreeLlmResponse, type TreeLlmTask, TreeNavigationRetriever, type TreeNavigationRetrieverOptions, type TreeSection, type TreeStructureSource, type TreeSummarySource, type TreeUnit, TwoStageRetriever, type TwoStageRetrieverOptions, UnsafeRemovalError, type UsageReportingEmbeddingProvider, type VectorRecord, type VectorSearchOptions, type VectorStore, type VectorStoreKind, anyOf, anyTermTsquery, applyMetadataPatch, buildDocumentTree, cachedTreeLlm, chunkDocuments, chunkIndexOf, chunkText, createNavigateDocumentTool, createRetrievalTool, describeRetrieval, describeSharedSource, describeSource, describesRetrieval, detectHeadings, documentIdOf, embedCountingUsage, emitRagRetrieval, estimateTokens, hasSearchSyntax, indexDocumentTree, indexTree, ingestChunks, ingestDocuments, instrumentRetriever, isBatchTooLarge, isLexicalVectorStore, keywordTerms, keywordTreeLlm, openAiChatTreeLlm, openAiEmbeddings, parseJsonReply, ragFilterableFields, replaceDocumentChunks, spanText, stableHash, toPgClient, treeLlmFromModelProvider, walkTree };