@mastra/rag 1.0.5 → 1.0.6

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.
Files changed (102) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +25 -0
  3. package/dist/document/document.d.ts +32 -0
  4. package/dist/document/document.d.ts.map +1 -0
  5. package/dist/document/extractors/base.d.ts +12 -0
  6. package/dist/document/extractors/base.d.ts.map +1 -0
  7. package/dist/document/extractors/index.d.ts +6 -0
  8. package/dist/document/extractors/index.d.ts.map +1 -0
  9. package/dist/document/extractors/keywords.d.ts +50 -0
  10. package/dist/document/extractors/keywords.d.ts.map +1 -0
  11. package/dist/document/extractors/questions.d.ts +42 -0
  12. package/dist/document/extractors/questions.d.ts.map +1 -0
  13. package/dist/document/extractors/summary.d.ts +39 -0
  14. package/dist/document/extractors/summary.d.ts.map +1 -0
  15. package/dist/document/extractors/title.d.ts +31 -0
  16. package/dist/document/extractors/title.d.ts.map +1 -0
  17. package/dist/document/extractors/types.d.ts +27 -0
  18. package/dist/document/extractors/types.d.ts.map +1 -0
  19. package/dist/document/index.d.ts +3 -0
  20. package/dist/document/index.d.ts.map +1 -0
  21. package/dist/document/prompts/base.d.ts +19 -0
  22. package/dist/document/prompts/base.d.ts.map +1 -0
  23. package/dist/document/prompts/format.d.ts +8 -0
  24. package/dist/document/prompts/format.d.ts.map +1 -0
  25. package/dist/document/prompts/index.d.ts +4 -0
  26. package/dist/document/prompts/index.d.ts.map +1 -0
  27. package/dist/document/prompts/prompt.d.ts +12 -0
  28. package/dist/document/prompts/prompt.d.ts.map +1 -0
  29. package/dist/document/prompts/types.d.ts +22 -0
  30. package/dist/document/prompts/types.d.ts.map +1 -0
  31. package/dist/document/schema/index.d.ts +4 -0
  32. package/dist/document/schema/index.d.ts.map +1 -0
  33. package/dist/document/schema/node.d.ts +53 -0
  34. package/dist/document/schema/node.d.ts.map +1 -0
  35. package/dist/document/schema/types.d.ts +35 -0
  36. package/dist/document/schema/types.d.ts.map +1 -0
  37. package/dist/document/transformers/character.d.ts +46 -0
  38. package/dist/document/transformers/character.d.ts.map +1 -0
  39. package/dist/document/transformers/html.d.ts +26 -0
  40. package/dist/document/transformers/html.d.ts.map +1 -0
  41. package/dist/document/transformers/json.d.ts +91 -0
  42. package/dist/document/transformers/json.d.ts.map +1 -0
  43. package/dist/document/transformers/latex.d.ts +12 -0
  44. package/dist/document/transformers/latex.d.ts.map +1 -0
  45. package/dist/document/transformers/markdown.d.ts +25 -0
  46. package/dist/document/transformers/markdown.d.ts.map +1 -0
  47. package/dist/document/transformers/text.d.ts +22 -0
  48. package/dist/document/transformers/text.d.ts.map +1 -0
  49. package/dist/document/transformers/token.d.ts +46 -0
  50. package/dist/document/transformers/token.d.ts.map +1 -0
  51. package/dist/document/transformers/transformer.d.ts +5 -0
  52. package/dist/document/transformers/transformer.d.ts.map +1 -0
  53. package/dist/document/types.d.ts +66 -0
  54. package/dist/document/types.d.ts.map +1 -0
  55. package/dist/graph-rag/index.d.ts +57 -0
  56. package/dist/graph-rag/index.d.ts.map +1 -0
  57. package/dist/index.cjs +2 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/index.d.ts +9 -33
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +2 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/rerank/index.d.ts +44 -0
  64. package/dist/rerank/index.d.ts.map +1 -0
  65. package/dist/rerank/relevance/cohere/index.d.ts +8 -0
  66. package/dist/rerank/relevance/cohere/index.d.ts.map +1 -0
  67. package/dist/rerank/relevance/index.d.ts +4 -0
  68. package/dist/rerank/relevance/index.d.ts.map +1 -0
  69. package/dist/rerank/relevance/mastra-agent/index.d.ts +8 -0
  70. package/dist/rerank/relevance/mastra-agent/index.d.ts.map +1 -0
  71. package/dist/rerank/relevance/zeroentropy/index.d.ts +8 -0
  72. package/dist/rerank/relevance/zeroentropy/index.d.ts.map +1 -0
  73. package/dist/tools/document-chunker.d.ts +7 -0
  74. package/dist/tools/document-chunker.d.ts.map +1 -0
  75. package/dist/tools/graph-rag.d.ts +26 -0
  76. package/dist/tools/graph-rag.d.ts.map +1 -0
  77. package/dist/tools/index.d.ts +4 -0
  78. package/dist/tools/index.d.ts.map +1 -0
  79. package/dist/tools/types.d.ts +97 -0
  80. package/dist/tools/types.d.ts.map +1 -0
  81. package/dist/tools/vector-query.d.ts +26 -0
  82. package/dist/tools/vector-query.d.ts.map +1 -0
  83. package/dist/utils/convert-sources.d.ts +18 -0
  84. package/dist/utils/convert-sources.d.ts.map +1 -0
  85. package/dist/utils/default-settings.d.ts +6 -0
  86. package/dist/utils/default-settings.d.ts.map +1 -0
  87. package/dist/utils/index.d.ts +4 -0
  88. package/dist/utils/index.d.ts.map +1 -0
  89. package/dist/utils/tool-schemas.d.ts +63 -0
  90. package/dist/utils/tool-schemas.d.ts.map +1 -0
  91. package/dist/utils/vector-prompts.d.ts +32 -0
  92. package/dist/utils/vector-prompts.d.ts.map +1 -0
  93. package/dist/utils/vector-search.d.ts +23 -0
  94. package/dist/utils/vector-search.d.ts.map +1 -0
  95. package/package.json +5 -5
  96. package/src/document/extractors/keywords.test.ts +15 -9
  97. package/tsconfig.build.json +9 -0
  98. package/tsconfig.json +1 -1
  99. package/tsup.config.ts +22 -0
  100. package/dist/_tsup-dts-rollup.d.cts +0 -1307
  101. package/dist/_tsup-dts-rollup.d.ts +0 -1307
  102. package/dist/index.d.cts +0 -33
@@ -1,1307 +0,0 @@
1
- import { createTool } from '@mastra/core/tools';
2
- import type { EmbeddingModel } from 'ai';
3
- import type { MastraLanguageModel } from '@mastra/core/agent';
4
- import type { MastraVector } from '@mastra/core/vector';
5
- import type { QueryResult } from '@mastra/core/vector';
6
- import type { QueryResult as QueryResult_2 } from '@mastra/core';
7
- import type { RelevanceScoreProvider } from '@mastra/core/relevance';
8
- import type { TiktokenEncoding } from 'js-tiktoken';
9
- import type { TiktokenModel } from 'js-tiktoken';
10
- import type { Tool } from '@mastra/core/tools';
11
- import type { VectorFilter } from '@mastra/core/vector/filter';
12
- import { z } from 'zod';
13
-
14
- /** @deprecated Import from @mastra/astra instead */
15
- declare const ASTRA_PROMPT = "When querying Astra, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Only logical operators ($and, $or, $not) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
16
- export { ASTRA_PROMPT }
17
- export { ASTRA_PROMPT as ASTRA_PROMPT_alias_1 }
18
-
19
- export declare abstract class BaseExtractor {
20
- isTextNodeOnly: boolean;
21
- abstract extract(nodes: BaseNode[]): Promise<Record<string, any>[]>;
22
- /**
23
- *
24
- * @param nodes Nodes to extract metadata from.
25
- * @returns Metadata extracted from the nodes.
26
- */
27
- processNodes(nodes: BaseNode[]): Promise<BaseNode[]>;
28
- }
29
-
30
- export declare const baseLLM: MastraLanguageModel;
31
-
32
- /**
33
- * Generic abstract class for retrievable nodes
34
- */
35
- declare abstract class BaseNode<T extends Metadata = Metadata> {
36
- id_: string;
37
- metadata: T;
38
- relationships: Partial<Record<NodeRelationship, RelatedNodeType<T>>>;
39
- accessor hash: string;
40
- protected constructor(init?: BaseNodeParams<T>);
41
- abstract get type(): ObjectType;
42
- abstract getContent(): string;
43
- abstract getMetadataStr(): string;
44
- get sourceNode(): RelatedNodeInfo<T> | undefined;
45
- get prevNode(): RelatedNodeInfo<T> | undefined;
46
- get nextNode(): RelatedNodeInfo<T> | undefined;
47
- get parentNode(): RelatedNodeInfo<T> | undefined;
48
- get childNodes(): RelatedNodeInfo<T>[] | undefined;
49
- abstract generateHash(): string;
50
- }
51
- export { BaseNode }
52
- export { BaseNode as BaseNode_alias_1 }
53
-
54
- declare type BaseNodeParams<T extends Metadata = Metadata> = {
55
- id_?: string | undefined;
56
- metadata?: T | undefined;
57
- relationships?: Partial<Record<NodeRelationship, RelatedNodeType<T>>> | undefined;
58
- hash?: string | undefined;
59
- };
60
- export { BaseNodeParams }
61
- export { BaseNodeParams as BaseNodeParams_alias_1 }
62
-
63
- declare abstract class BasePromptTemplate<const TemplatesVar extends readonly string[] = string[]> {
64
- templateVars: Set<string>;
65
- options: Partial<Record<TemplatesVar[number] | (string & {}), string>>;
66
- protected constructor(options: BasePromptTemplateOptions<TemplatesVar>);
67
- abstract partialFormat(options: Partial<Record<TemplatesVar[number] | (string & {}), string>>): BasePromptTemplate<TemplatesVar>;
68
- abstract format(options?: Partial<Record<TemplatesVar[number] | (string & {}), string>>): string;
69
- abstract formatMessages(options?: Partial<Record<TemplatesVar[number] | (string & {}), string>>): ChatMessage[];
70
- abstract get template(): string;
71
- }
72
- export { BasePromptTemplate }
73
- export { BasePromptTemplate as BasePromptTemplate_alias_1 }
74
-
75
- export declare type BasePromptTemplateOptions<TemplatesVar extends readonly string[]> = {
76
- templateVars?: TemplatesVar | readonly string[];
77
- options?: Partial<Record<TemplatesVar[number] | (string & {}), string>>;
78
- };
79
-
80
- declare const baseSchema: {
81
- queryText: z.ZodString;
82
- topK: z.ZodNumber;
83
- };
84
- export { baseSchema }
85
- export { baseSchema as baseSchema_alias_1 }
86
-
87
- declare type BaseWhere = {
88
- [key: string]: LiteralValue | OperatorExpression;
89
- };
90
-
91
- export declare class CharacterTransformer extends TextTransformer {
92
- protected separator: string;
93
- protected isSeparatorRegex: boolean;
94
- constructor({ separator, isSeparatorRegex, options, }: {
95
- separator?: string;
96
- isSeparatorRegex?: boolean;
97
- options?: {
98
- size?: number;
99
- overlap?: number;
100
- lengthFunction?: (text: string) => number;
101
- keepSeparator?: boolean | 'start' | 'end';
102
- addStartIndex?: boolean;
103
- stripWhitespace?: boolean;
104
- };
105
- });
106
- splitText({ text }: {
107
- text: string;
108
- }): string[];
109
- private __splitChunk;
110
- }
111
-
112
- export declare type ChatMessage<AdditionalMessageOptions extends object = object> = {
113
- content: MessageContent;
114
- role: MessageType;
115
- options?: undefined | AdditionalMessageOptions;
116
- };
117
-
118
- /** @deprecated Import from @mastra/chroma instead */
119
- declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}";
120
- export { CHROMA_PROMPT }
121
- export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
122
-
123
- export declare interface ChromaConfig {
124
- where?: Where;
125
- whereDocument?: WhereDocument;
126
- }
127
-
128
- declare type ChunkOptions = {
129
- headers?: [string, string][];
130
- returnEachLine?: boolean;
131
- sections?: [string, string][];
132
- separator?: string;
133
- separators?: string[];
134
- isSeparatorRegex?: boolean;
135
- size?: number;
136
- maxSize?: number;
137
- minSize?: number;
138
- overlap?: number;
139
- lengthFunction?: (text: string) => number;
140
- keepSeparator?: boolean | 'start' | 'end';
141
- addStartIndex?: boolean;
142
- stripWhitespace?: boolean;
143
- language?: Language;
144
- ensureAscii?: boolean;
145
- convertLists?: boolean;
146
- encodingName?: TiktokenEncoding;
147
- modelName?: TiktokenModel;
148
- allowedSpecial?: Set<string> | 'all';
149
- disallowedSpecial?: Set<string> | 'all';
150
- stripHeaders?: boolean;
151
- };
152
- export { ChunkOptions }
153
- export { ChunkOptions as ChunkOptions_alias_1 }
154
- export { ChunkOptions as ChunkOptions_alias_2 }
155
-
156
- declare interface ChunkParams extends ChunkOptions {
157
- strategy?: ChunkStrategy;
158
- extract?: ExtractParams;
159
- }
160
- export { ChunkParams }
161
- export { ChunkParams as ChunkParams_alias_1 }
162
- export { ChunkParams as ChunkParams_alias_2 }
163
-
164
- declare type ChunkStrategy = 'recursive' | 'character' | 'token' | 'markdown' | 'html' | 'json' | 'latex';
165
- export { ChunkStrategy }
166
- export { ChunkStrategy as ChunkStrategy_alias_1 }
167
- export { ChunkStrategy as ChunkStrategy_alias_2 }
168
-
169
- declare class CohereRelevanceScorer implements RelevanceScoreProvider {
170
- private model;
171
- private apiKey?;
172
- constructor(model: string, apiKey?: string);
173
- getRelevanceScore(query: string, text: string): Promise<number>;
174
- }
175
- export { CohereRelevanceScorer }
176
- export { CohereRelevanceScorer as CohereRelevanceScorer_alias_1 }
177
- export { CohereRelevanceScorer as CohereRelevanceScorer_alias_2 }
178
-
179
- /**
180
- * Convert an array of source inputs (QueryResult, RankedNode, or RerankResult) to an array of sources.
181
- * @param results Array of source inputs to convert.
182
- * @returns Array of sources.
183
- */
184
- export declare const convertToSources: (results: SourceInput[]) => {
185
- id: string;
186
- vector: number[];
187
- score: number;
188
- metadata: Record<string, any> | undefined;
189
- document: string;
190
- }[];
191
-
192
- declare const createDocumentChunkerTool: ({ doc, params, }: {
193
- doc: MDocument;
194
- params?: ChunkParams;
195
- }) => ReturnType<typeof createTool>;
196
- export { createDocumentChunkerTool }
197
- export { createDocumentChunkerTool as createDocumentChunkerTool_alias_1 }
198
- export { createDocumentChunkerTool as createDocumentChunkerTool_alias_2 }
199
-
200
- declare const createGraphRAGTool: (options: GraphRagToolOptions) => RagTool<z.ZodObject<{
201
- filter: z.ZodString;
202
- queryText: z.ZodString;
203
- topK: z.ZodNumber;
204
- }, "strip", z.ZodTypeAny, {
205
- filter: string;
206
- topK: number;
207
- queryText: string;
208
- }, {
209
- filter: string;
210
- topK: number;
211
- queryText: string;
212
- }> | z.ZodObject<{
213
- queryText: z.ZodString;
214
- topK: z.ZodNumber;
215
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
216
- queryText: z.ZodString;
217
- topK: z.ZodNumber;
218
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
219
- queryText: z.ZodString;
220
- topK: z.ZodNumber;
221
- }, z.ZodTypeAny, "passthrough">>, any>;
222
- export { createGraphRAGTool }
223
- export { createGraphRAGTool as createGraphRAGTool_alias_1 }
224
- export { createGraphRAGTool as createGraphRAGTool_alias_2 }
225
-
226
- declare const createVectorQueryTool: (options: VectorQueryToolOptions) => RagTool<z.ZodObject<{
227
- filter: z.ZodString;
228
- queryText: z.ZodString;
229
- topK: z.ZodNumber;
230
- }, "strip", z.ZodTypeAny, {
231
- filter: string;
232
- topK: number;
233
- queryText: string;
234
- }, {
235
- filter: string;
236
- topK: number;
237
- queryText: string;
238
- }> | z.ZodObject<{
239
- queryText: z.ZodString;
240
- topK: z.ZodNumber;
241
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
242
- queryText: z.ZodString;
243
- topK: z.ZodNumber;
244
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
245
- queryText: z.ZodString;
246
- topK: z.ZodNumber;
247
- }, z.ZodTypeAny, "passthrough">>, any>;
248
- export { createVectorQueryTool }
249
- export { createVectorQueryTool as createVectorQueryTool_alias_1 }
250
- export { createVectorQueryTool as createVectorQueryTool_alias_2 }
251
-
252
- export declare type DatabaseConfig = {
253
- pinecone?: PineconeConfig;
254
- pgvector?: PgVectorConfig;
255
- chroma?: ChromaConfig;
256
- [key: string]: any;
257
- };
258
-
259
- /**
260
- * Default options for GraphRAG
261
- * @default
262
- * ```json
263
- * {
264
- * "dimension": 1536,
265
- * "randomWalkSteps": 100,
266
- * "restartProb": 0.15,
267
- * "threshold": 0.7
268
- * }
269
- * ```
270
- */
271
- export declare const defaultGraphOptions: {
272
- dimension: number;
273
- randomWalkSteps: number;
274
- restartProb: number;
275
- threshold: number;
276
- };
277
-
278
- declare const defaultGraphRagDescription: () => string;
279
- export { defaultGraphRagDescription }
280
- export { defaultGraphRagDescription as defaultGraphRagDescription_alias_1 }
281
- export { defaultGraphRagDescription as defaultGraphRagDescription_alias_2 }
282
-
283
- declare const defaultKeywordExtractPrompt: KeywordExtractPrompt;
284
- export { defaultKeywordExtractPrompt }
285
- export { defaultKeywordExtractPrompt as defaultKeywordExtractPrompt_alias_1 }
286
-
287
- declare const defaultQuestionExtractPrompt: PromptTemplate<readonly ["numQuestions", "context"]>;
288
- export { defaultQuestionExtractPrompt }
289
- export { defaultQuestionExtractPrompt as defaultQuestionExtractPrompt_alias_1 }
290
-
291
- declare const defaultSummaryPrompt: SummaryPrompt;
292
- export { defaultSummaryPrompt }
293
- export { defaultSummaryPrompt as defaultSummaryPrompt_alias_1 }
294
-
295
- declare const defaultTitleCombinePromptTemplate: PromptTemplate<readonly ["context"]>;
296
- export { defaultTitleCombinePromptTemplate }
297
- export { defaultTitleCombinePromptTemplate as defaultTitleCombinePromptTemplate_alias_1 }
298
-
299
- declare const defaultTitleExtractorPromptTemplate: PromptTemplate<readonly ["context"]>;
300
- export { defaultTitleExtractorPromptTemplate }
301
- export { defaultTitleExtractorPromptTemplate as defaultTitleExtractorPromptTemplate_alias_1 }
302
-
303
- declare const defaultVectorQueryDescription: () => string;
304
- export { defaultVectorQueryDescription }
305
- export { defaultVectorQueryDescription as defaultVectorQueryDescription_alias_1 }
306
- export { defaultVectorQueryDescription as defaultVectorQueryDescription_alias_2 }
307
-
308
- /**
309
- * A document is just a special text node with a docId.
310
- */
311
- declare class Document<T extends Metadata = Metadata> extends TextNode<T> {
312
- constructor(init?: TextNodeParams<T>);
313
- get type(): ObjectType;
314
- }
315
- export { Document }
316
- export { Document as Document_alias_1 }
317
-
318
- declare type ExtractKeyword = {
319
- /**
320
- * Comma-separated keywords extracted from the node. May be empty if extraction fails.
321
- */
322
- excerptKeywords: string;
323
- };
324
-
325
- declare type ExtractParams = {
326
- title?: TitleExtractorsArgs | boolean;
327
- summary?: SummaryExtractArgs | boolean;
328
- questions?: QuestionAnswerExtractArgs | boolean;
329
- keywords?: KeywordExtractArgs | boolean;
330
- };
331
- export { ExtractParams }
332
- export { ExtractParams as ExtractParams_alias_1 }
333
- export { ExtractParams as ExtractParams_alias_2 }
334
-
335
- declare type ExtractQuestion = {
336
- /**
337
- * Questions extracted from the node as a string (may be empty if extraction fails).
338
- */
339
- questionsThisExcerptCanAnswer: string;
340
- };
341
-
342
- declare type ExtractSummary = {
343
- sectionSummary?: string;
344
- prevSectionSummary?: string;
345
- nextSectionSummary?: string;
346
- };
347
-
348
- declare type ExtractTitle = {
349
- documentTitle: string;
350
- };
351
-
352
- declare const filterDescription = "JSON-formatted criteria to refine search results.\n- ALWAYS provide a filter value\n- If no filter is provided, use the default (\"{}\")\n- MUST be a valid, complete JSON object with proper quotes and brackets\n- Uses provided filter if specified\n- Default: \"{}\" (no filtering)\n- Example for no filtering: \"filter\": \"{}\"\n- Example: '{\"category\": \"health\"}'\n- Based on query intent\n- Do NOT use single quotes or unquoted properties\n- IMPORTANT: Always ensure JSON is properly closed with matching brackets\n- Multiple filters can be combined";
353
- export { filterDescription }
354
- export { filterDescription as filterDescription_alias_1 }
355
- export { filterDescription as filterDescription_alias_2 }
356
-
357
- declare const filterSchema: z.ZodObject<{
358
- filter: z.ZodString;
359
- queryText: z.ZodString;
360
- topK: z.ZodNumber;
361
- }, "strip", z.ZodTypeAny, {
362
- filter: string;
363
- topK: number;
364
- queryText: string;
365
- }, {
366
- filter: string;
367
- topK: number;
368
- queryText: string;
369
- }>;
370
- export { filterSchema }
371
- export { filterSchema as filterSchema_alias_1 }
372
-
373
- /**
374
- * Formats a string by replacing placeholders with values from the provided parameters.
375
- * @param str The string to format.
376
- * @param params A record of placeholder names to their corresponding values.
377
- * @returns The formatted string.
378
- */
379
- export declare function format(str: string, params: Record<string, string>): string;
380
-
381
- export declare interface GraphChunk {
382
- text: string;
383
- metadata: Record<string, any>;
384
- }
385
-
386
- export declare interface GraphEdge {
387
- source: string;
388
- target: string;
389
- weight: number;
390
- type: SupportedEdgeType;
391
- }
392
-
393
- export declare interface GraphEmbedding {
394
- vector: number[];
395
- }
396
-
397
- export declare interface GraphNode {
398
- id: string;
399
- content: string;
400
- embedding?: number[];
401
- metadata?: Record<string, any>;
402
- }
403
-
404
- declare class GraphRAG {
405
- private nodes;
406
- private edges;
407
- private dimension;
408
- private threshold;
409
- constructor(dimension?: number, threshold?: number);
410
- addNode(node: GraphNode): void;
411
- addEdge(edge: GraphEdge): void;
412
- getNodes(): GraphNode[];
413
- getEdges(): GraphEdge[];
414
- getEdgesByType(type: string): GraphEdge[];
415
- clear(): void;
416
- updateNodeContent(id: string, newContent: string): void;
417
- private getNeighbors;
418
- private cosineSimilarity;
419
- createGraph(chunks: GraphChunk[], embeddings: GraphEmbedding[]): void;
420
- private selectWeightedNeighbor;
421
- private randomWalkWithRestart;
422
- query({ query, topK, randomWalkSteps, restartProb, }: {
423
- query: number[];
424
- topK?: number;
425
- randomWalkSteps?: number;
426
- restartProb?: number;
427
- }): RankedNode[];
428
- }
429
- export { GraphRAG }
430
- export { GraphRAG as GraphRAG_alias_1 }
431
-
432
- export declare type GraphRagToolOptions = {
433
- id?: string;
434
- description?: string;
435
- indexName: string;
436
- vectorStoreName: string;
437
- model: EmbeddingModel<string>;
438
- enableFilter?: boolean;
439
- includeSources?: boolean;
440
- graphOptions?: {
441
- dimension?: number;
442
- randomWalkSteps?: number;
443
- restartProb?: number;
444
- threshold?: number;
445
- };
446
- };
447
-
448
- export declare class HTMLHeaderTransformer {
449
- private headersToSplitOn;
450
- private returnEachElement;
451
- constructor(headersToSplitOn: [string, string][], returnEachElement?: boolean);
452
- splitText({ text }: {
453
- text: string;
454
- }): Document[];
455
- private getXPath;
456
- private getTextContent;
457
- private aggregateElementsToChunks;
458
- createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document[];
459
- transformDocuments(documents: Document[]): Document[];
460
- }
461
-
462
- export declare class HTMLSectionTransformer {
463
- private headersToSplitOn;
464
- private options;
465
- constructor(headersToSplitOn: [string, string][], options?: Record<string, any>);
466
- splitText(text: string): Document[];
467
- private getXPath;
468
- private splitHtmlByHeaders;
469
- splitDocuments(documents: Document[]): Promise<Document[]>;
470
- createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document[];
471
- transformDocuments(documents: Document[]): Document[];
472
- }
473
-
474
- declare type InclusionOperator = '$in' | '$nin';
475
-
476
- declare type KeywordExtractArgs = {
477
- llm?: MastraLanguageModel;
478
- keywords?: number;
479
- promptTemplate?: KeywordExtractPrompt['template'];
480
- };
481
- export { KeywordExtractArgs }
482
- export { KeywordExtractArgs as KeywordExtractArgs_alias_1 }
483
-
484
- /**
485
- * Extract keywords from a list of nodes.
486
- */
487
- declare class KeywordExtractor extends BaseExtractor {
488
- llm: MastraLanguageModel;
489
- keywords: number;
490
- promptTemplate: KeywordExtractPrompt;
491
- /**
492
- * Constructor for the KeywordExtractor class.
493
- * @param {MastraLanguageModel} llm MastraLanguageModel instance.
494
- * @param {number} keywords Number of keywords to extract.
495
- * @param {string} [promptTemplate] Optional custom prompt template (must include {context})
496
- * @throws {Error} If keywords is less than 1.
497
- */
498
- constructor(options?: KeywordExtractArgs);
499
- /**
500
- *
501
- * @param node Node to extract keywords from.
502
- * @returns Keywords extracted from the node.
503
- */
504
- /**
505
- * Extract keywords from a node. Returns an object with a comma-separated string of keywords, or an empty string if extraction fails.
506
- * Adds error handling for malformed/empty LLM output.
507
- */
508
- extractKeywordsFromNodes(node: BaseNode): Promise<ExtractKeyword>;
509
- /**
510
- *
511
- * @param nodes Nodes to extract keywords from.
512
- * @returns Keywords extracted from the nodes.
513
- */
514
- /**
515
- * Extract keywords from an array of nodes. Always returns an array (may be empty).
516
- * @param nodes Nodes to extract keywords from.
517
- * @returns Array of keyword extraction results.
518
- */
519
- extract(nodes: BaseNode[]): Promise<Array<ExtractKeyword>>;
520
- }
521
- export { KeywordExtractor }
522
- export { KeywordExtractor as KeywordExtractor_alias_1 }
523
-
524
- declare type KeywordExtractPrompt = PromptTemplate<['context', 'maxKeywords']>;
525
- export { KeywordExtractPrompt }
526
- export { KeywordExtractPrompt as KeywordExtractPrompt_alias_1 }
527
-
528
- declare enum Language {
529
- CPP = "cpp",
530
- GO = "go",
531
- JAVA = "java",
532
- KOTLIN = "kotlin",
533
- JS = "js",
534
- TS = "ts",
535
- PHP = "php",
536
- PROTO = "proto",
537
- PYTHON = "python",
538
- RST = "rst",
539
- RUBY = "ruby",
540
- RUST = "rust",
541
- SCALA = "scala",
542
- SWIFT = "swift",
543
- MARKDOWN = "markdown",
544
- LATEX = "latex",
545
- HTML = "html",
546
- SOL = "sol",
547
- CSHARP = "csharp",
548
- COBOL = "cobol",
549
- C = "c",
550
- LUA = "lua",
551
- PERL = "perl",
552
- HASKELL = "haskell",
553
- ELIXIR = "elixir",
554
- POWERSHELL = "powershell"
555
- }
556
- export { Language }
557
- export { Language as Language_alias_1 }
558
- export { Language as Language_alias_2 }
559
-
560
- export declare class LatexTransformer extends RecursiveCharacterTransformer {
561
- constructor(options?: {
562
- size?: number;
563
- overlap?: number;
564
- lengthFunction?: (text: string) => number;
565
- keepSeparator?: boolean | 'start' | 'end';
566
- addStartIndex?: boolean;
567
- stripWhitespace?: boolean;
568
- });
569
- }
570
-
571
- /** @deprecated Import from @mastra/libsql instead */
572
- declare const LIBSQL_PROMPT = "When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
573
- export { LIBSQL_PROMPT }
574
- export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
575
-
576
- declare type ListLiteralValue = LiteralValue[];
577
-
578
- declare type LiteralNumber = number;
579
-
580
- declare type LiteralValue = string | number | boolean;
581
-
582
- declare type LogicalOperator = '$and' | '$or';
583
-
584
- declare type LogicalWhere = {
585
- [key in LogicalOperator]?: Where[];
586
- };
587
-
588
- export declare class MarkdownHeaderTransformer {
589
- private headersToSplitOn;
590
- private returnEachLine;
591
- private stripHeaders;
592
- constructor(headersToSplitOn: [string, string][], returnEachLine?: boolean, stripHeaders?: boolean);
593
- private aggregateLinesToChunks;
594
- splitText({ text }: {
595
- text: string;
596
- }): Document[];
597
- createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document[];
598
- transformDocuments(documents: Document[]): Document[];
599
- }
600
-
601
- export declare class MarkdownTransformer extends RecursiveCharacterTransformer {
602
- constructor(options?: {
603
- chunkSize?: number;
604
- chunkOverlap?: number;
605
- lengthFunction?: (text: string) => number;
606
- keepSeparator?: boolean | 'start' | 'end';
607
- addStartIndex?: boolean;
608
- stripWhitespace?: boolean;
609
- });
610
- }
611
-
612
- declare class MastraAgentRelevanceScorer implements RelevanceScoreProvider {
613
- private agent;
614
- constructor(name: string, model: MastraLanguageModel);
615
- getRelevanceScore(query: string, text: string): Promise<number>;
616
- }
617
- export { MastraAgentRelevanceScorer }
618
- export { MastraAgentRelevanceScorer as MastraAgentRelevanceScorer_alias_1 }
619
- export { MastraAgentRelevanceScorer as MastraAgentRelevanceScorer_alias_2 }
620
-
621
- declare class MDocument {
622
- private chunks;
623
- private type;
624
- constructor({ docs, type }: {
625
- docs: {
626
- text: string;
627
- metadata?: Record<string, any>;
628
- }[];
629
- type: string;
630
- });
631
- extractMetadata({ title, summary, questions, keywords }: ExtractParams): Promise<MDocument>;
632
- static fromText(text: string, metadata?: Record<string, any>): MDocument;
633
- static fromHTML(html: string, metadata?: Record<string, any>): MDocument;
634
- static fromMarkdown(markdown: string, metadata?: Record<string, any>): MDocument;
635
- static fromJSON(jsonString: string, metadata?: Record<string, any>): MDocument;
636
- private defaultStrategy;
637
- private chunkBy;
638
- chunkRecursive(options?: ChunkOptions): Promise<void>;
639
- chunkCharacter(options?: ChunkOptions): Promise<void>;
640
- chunkHTML(options?: ChunkOptions): Promise<void>;
641
- chunkJSON(options?: ChunkOptions): Promise<void>;
642
- chunkLatex(options?: ChunkOptions): Promise<void>;
643
- chunkToken(options?: ChunkOptions): Promise<void>;
644
- chunkMarkdown(options?: ChunkOptions): Promise<void>;
645
- chunk(params?: ChunkParams): Promise<Document[]>;
646
- getDocs(): Document[];
647
- getText(): string[];
648
- getMetadata(): Record<string, any>[];
649
- }
650
- export { MDocument }
651
- export { MDocument as MDocument_alias_1 }
652
- export { MDocument as MDocument_alias_2 }
653
-
654
- /**
655
- * Extended type for the content of a message that allows for multi-modal messages.
656
- */
657
- export declare type MessageContent = string | MessageContentTextDetail[];
658
-
659
- export declare type MessageContentTextDetail = {
660
- type: 'text';
661
- text: string;
662
- };
663
-
664
- export declare type MessageType = 'user' | 'assistant' | 'system' | 'memory' | 'developer';
665
-
666
- declare type Metadata = Record<string, any>;
667
- export { Metadata }
668
- export { Metadata as Metadata_alias_1 }
669
-
670
- /** @deprecated Import from @mastra/mongodb instead */
671
- declare const MONGODB_PROMPT = "When querying MongoDB, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements by criteria\n Example: { \"scores\": { \"$elemMatch\": { \"$gt\": 80 } } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $regex: Regular expression match\n Example: { \"title\": { \"$regex\": \"^laptop\", \"$options\": \"i\" } }\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nUsage Notes:\n- You can use both 'filter' (for metadata fields) and 'documentFilter' (for document content fields).\n- Nested fields are supported using dot notation (e.g., \"metadata.author.name\").\n- Multiple conditions on the same field are supported with both implicit and explicit $and.\n- Empty arrays in $in/$nin will return no results.\n- All logical operators ($and, $or, $not, $nor) can be used at the top level or nested.\n- All other operators must be used within a field condition.\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Regex uses standard MongoDB regex syntax (with optional $options).\n- Metadata values can be strings, numbers, booleans, or arrays.\n- Metadata and document fields can be filtered in the same query.\n\nExample Complex Query:\n{\n \"category\": { \"$in\": [\"electronics\", \"computers\"] },\n \"price\": { \"$gte\": 100, \"$lte\": 1000 },\n \"inStock\": true,\n \"title\": { \"$regex\": \"laptop\", \"$options\": \"i\" },\n \"$or\": [\n { \"brand\": \"Apple\" },\n { \"rating\": { \"$gte\": 4.5 } }\n ]\n}\n";
672
- export { MONGODB_PROMPT }
673
- export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
674
-
675
- declare enum NodeRelationship {
676
- SOURCE = "SOURCE",
677
- PREVIOUS = "PREVIOUS",
678
- NEXT = "NEXT",
679
- PARENT = "PARENT",
680
- CHILD = "CHILD"
681
- }
682
- export { NodeRelationship }
683
- export { NodeRelationship as NodeRelationship_alias_1 }
684
-
685
- declare enum ObjectType {
686
- TEXT = "TEXT",
687
- IMAGE = "IMAGE",
688
- INDEX = "INDEX",
689
- DOCUMENT = "DOCUMENT",
690
- IMAGE_DOCUMENT = "IMAGE_DOCUMENT"
691
- }
692
- export { ObjectType }
693
- export { ObjectType as ObjectType_alias_1 }
694
-
695
- declare type OperatorExpression = {
696
- [key in WhereOperator | InclusionOperator | LogicalOperator]?: LiteralValue | ListLiteralValue;
697
- };
698
-
699
- declare const outputSchema: z.ZodObject<{
700
- relevantContext: z.ZodAny;
701
- sources: z.ZodArray<z.ZodObject<{
702
- id: z.ZodString;
703
- metadata: z.ZodAny;
704
- vector: z.ZodArray<z.ZodNumber, "many">;
705
- score: z.ZodNumber;
706
- document: z.ZodString;
707
- }, "strip", z.ZodTypeAny, {
708
- id: string;
709
- vector: number[];
710
- score: number;
711
- document: string;
712
- metadata?: any;
713
- }, {
714
- id: string;
715
- vector: number[];
716
- score: number;
717
- document: string;
718
- metadata?: any;
719
- }>, "many">;
720
- }, "strip", z.ZodTypeAny, {
721
- sources: {
722
- id: string;
723
- vector: number[];
724
- score: number;
725
- document: string;
726
- metadata?: any;
727
- }[];
728
- relevantContext?: any;
729
- }, {
730
- sources: {
731
- id: string;
732
- vector: number[];
733
- score: number;
734
- document: string;
735
- metadata?: any;
736
- }[];
737
- relevantContext?: any;
738
- }>;
739
- export { outputSchema }
740
- export { outputSchema as outputSchema_alias_1 }
741
-
742
- /** @deprecated Import from @mastra/pg instead */
743
- declare const PGVECTOR_PROMPT = "When querying PG Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n- $regex: Pattern matching (PostgreSQL regex syntax)\n Example: { \"name\": { \"$regex\": \"^iphone\" } }\n- $options: Regex options (used with $regex)\n Example: { \"name\": { \"$regex\": \"iphone\", \"$options\": \"i\" } }\n\nRestrictions:\n- Direct RegExp patterns are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Regex patterns must follow PostgreSQL syntax\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$regex\": \"pattern\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"name\": { \"$regex\": \"^iphone\", \"$options\": \"i\" } },\n { \"description\": { \"$regex\": \".*apple.*\" } }\n ]}\n ]\n}";
744
- export { PGVECTOR_PROMPT }
745
- export { PGVECTOR_PROMPT as PGVECTOR_PROMPT_alias_1 }
746
-
747
- export declare interface PgVectorConfig {
748
- minScore?: number;
749
- ef?: number;
750
- probes?: number;
751
- }
752
-
753
- /** @deprecated Import from @mastra/pinecone instead */
754
- declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- A non-empty array is required for $all operator\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
755
- export { PINECONE_PROMPT }
756
- export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
757
-
758
- export declare interface PineconeConfig {
759
- namespace?: string;
760
- sparseVector?: {
761
- indices: number[];
762
- values: number[];
763
- };
764
- }
765
-
766
- declare class PromptTemplate<const TemplatesVar extends readonly string[] = string[]> extends BasePromptTemplate<TemplatesVar> {
767
- #private;
768
- constructor(options: PromptTemplateOptions<TemplatesVar>);
769
- partialFormat(options: Partial<Record<TemplatesVar[number] | (string & {}), string>>): PromptTemplate<TemplatesVar>;
770
- format(options?: Partial<Record<TemplatesVar[number] | (string & {}), string>>): string;
771
- formatMessages(options?: Partial<Record<TemplatesVar[number] | (string & {}), string>>): ChatMessage[];
772
- get template(): string;
773
- }
774
- export { PromptTemplate }
775
- export { PromptTemplate as PromptTemplate_alias_1 }
776
-
777
- export declare type PromptTemplateOptions<TemplatesVar extends readonly string[]> = BasePromptTemplateOptions<TemplatesVar> & {
778
- template: string;
779
- };
780
-
781
- /** @deprecated Import from @mastra/qdrant instead */
782
- declare const QDRANT_PROMPT = "When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $regex: Pattern matching\n Example: { \"name\": { \"$regex\": \"iphone.*\" } }\n- $count: Array length/value count\n Example: { \"tags\": { \"$count\": { \"$gt\": 2 } } }\n- $geo: Geographical filters (supports radius, box, polygon)\n Example: {\n \"location\": {\n \"$geo\": {\n \"type\": \"radius\",\n \"center\": { \"lat\": 52.5, \"lon\": 13.4 },\n \"radius\": 10000\n }\n }\n }\n- $hasId: Match specific document IDs\n Example: { \"$hasId\": [\"doc1\", \"doc2\"] }\n- $hasVector: Check vector existence\n Example: { \"$hasVector\": \"\" }\n- $datetime: RFC 3339 datetime range\n Example: {\n \"created_at\": {\n \"$datetime\": {\n \"range\": {\n \"gt\": \"2024-01-01T00:00:00Z\",\n \"lt\": \"2024-12-31T23:59:59Z\"\n }\n }\n }\n }\n- $null: Check for null values\n Example: { \"field\": { \"$null\": true } }\n- $empty: Check for empty values\n Example: { \"array\": { \"$empty\": true } }\n- $nested: Nested object filters\n Example: {\n \"items[]\": {\n \"$nested\": {\n \"price\": { \"$gt\": 100 },\n \"stock\": { \"$gt\": 0 }\n }\n }\n }\n\nRestrictions:\n- Only logical operators ($and, $or, $not) and collection operators ($hasId, $hasVector) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Valid: { \"$hasId\": [...] }\n Invalid: { \"$gt\": 100 }\n- Nested fields are supported using dot notation\n- Array fields with nested objects use [] suffix: \"items[]\"\n- Geo filtering requires specific format for radius, box, or polygon\n- Datetime values must be in RFC 3339 format\n- Empty arrays in conditions are handled as empty values\n- Null values are handled with $null operator\n- Empty values are handled with $empty operator\n- $regex uses standard regex syntax\n- $count can only be used with numeric comparison operators\n- $nested requires an object with conditions\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\"] } },\n { \"price\": { \"$gt\": 100 } },\n { \"location\": {\n \"$geo\": {\n \"type\": \"radius\",\n \"center\": { \"lat\": 52.5, \"lon\": 13.4 },\n \"radius\": 5000\n }\n }},\n { \"items[]\": {\n \"$nested\": {\n \"price\": { \"$gt\": 50 },\n \"stock\": { \"$gt\": 0 }\n }\n }},\n { \"created_at\": {\n \"$datetime\": {\n \"range\": {\n \"gt\": \"2024-01-01T00:00:00Z\"\n }\n }\n }},\n { \"$or\": [\n { \"status\": { \"$ne\": \"discontinued\" } },\n { \"clearance\": true }\n ]}\n ]\n}";
783
- export { QDRANT_PROMPT }
784
- export { QDRANT_PROMPT as QDRANT_PROMPT_alias_1 }
785
-
786
- declare const queryTextDescription = "The text query to search for in the vector database.\n- ALWAYS provide a non-empty query string\n- Must contain the user's question or search terms\n- Example: \"market data\" or \"financial reports\"\n- If the user's query is about a specific topic, use that topic as the queryText\n- Cannot be an empty string\n- Do not include quotes, just the text itself\n- Required for all searches";
787
- export { queryTextDescription }
788
- export { queryTextDescription as queryTextDescription_alias_1 }
789
- export { queryTextDescription as queryTextDescription_alias_2 }
790
-
791
- declare type QuestionAnswerExtractArgs = {
792
- llm?: MastraLanguageModel;
793
- questions?: number;
794
- promptTemplate?: QuestionExtractPrompt['template'];
795
- embeddingOnly?: boolean;
796
- };
797
- export { QuestionAnswerExtractArgs }
798
- export { QuestionAnswerExtractArgs as QuestionAnswerExtractArgs_alias_1 }
799
-
800
- declare type QuestionExtractPrompt = PromptTemplate<['context', 'numQuestions']>;
801
- export { QuestionExtractPrompt }
802
- export { QuestionExtractPrompt as QuestionExtractPrompt_alias_1 }
803
-
804
- /**
805
- * Extract questions from a list of nodes.
806
- */
807
- declare class QuestionsAnsweredExtractor extends BaseExtractor {
808
- llm: MastraLanguageModel;
809
- questions: number;
810
- promptTemplate: QuestionExtractPrompt;
811
- embeddingOnly: boolean;
812
- /**
813
- * Constructor for the QuestionsAnsweredExtractor class.
814
- * @param {MastraLanguageModel} llm MastraLanguageModel instance.
815
- * @param {number} questions Number of questions to generate.
816
- * @param {QuestionExtractPrompt['template']} promptTemplate Optional custom prompt template (should include {context}).
817
- * @param {boolean} embeddingOnly Whether to use metadata for embeddings only.
818
- */
819
- constructor(options?: QuestionAnswerExtractArgs);
820
- /**
821
- * Extract answered questions from a node.
822
- * @param {BaseNode} node Node to extract questions from.
823
- * @returns {Promise<Array<ExtractQuestion> | Array<{}>>} Questions extracted from the node.
824
- */
825
- extractQuestionsFromNode(node: BaseNode): Promise<ExtractQuestion>;
826
- /**
827
- * Extract answered questions from a list of nodes.
828
- * @param {BaseNode[]} nodes Nodes to extract questions from.
829
- * @returns {Promise<Array<ExtractQuestion> | Array<{}>>} Questions extracted from the nodes.
830
- */
831
- extract(nodes: BaseNode[]): Promise<Array<ExtractQuestion> | Array<object>>;
832
- }
833
- export { QuestionsAnsweredExtractor }
834
- export { QuestionsAnsweredExtractor as QuestionsAnsweredExtractor_alias_1 }
835
-
836
- declare type RagTool<TInput extends z.ZodType<any, z.ZodTypeDef, any> | undefined, TOutput extends z.ZodType<any, z.ZodTypeDef, any> | undefined> = Tool<TInput, TOutput> & {
837
- execute: NonNullable<Tool<TInput, TOutput>['execute']>;
838
- };
839
- export { RagTool }
840
- export { RagTool as RagTool_alias_1 }
841
-
842
- export declare interface RankedNode extends GraphNode {
843
- score: number;
844
- }
845
-
846
- export declare class RecursiveCharacterTransformer extends TextTransformer {
847
- protected separators: string[];
848
- protected isSeparatorRegex: boolean;
849
- constructor({ separators, isSeparatorRegex, options, }: {
850
- separators?: string[];
851
- isSeparatorRegex?: boolean;
852
- options?: ChunkOptions;
853
- });
854
- private _splitText;
855
- splitText({ text }: {
856
- text: string;
857
- }): string[];
858
- static fromLanguage(language: Language, options?: {
859
- size?: number;
860
- chunkOverlap?: number;
861
- lengthFunction?: (text: string) => number;
862
- keepSeparator?: boolean | 'start' | 'end';
863
- addStartIndex?: boolean;
864
- stripWhitespace?: boolean;
865
- }): RecursiveCharacterTransformer;
866
- static getSeparatorsForLanguage(language: Language): string[];
867
- }
868
-
869
- export declare class RecursiveJsonTransformer {
870
- private maxSize;
871
- private minSize;
872
- constructor({ maxSize, minSize }: {
873
- maxSize: number;
874
- minSize?: number;
875
- });
876
- private static jsonSize;
877
- /**
878
- * Transform JSON data while handling circular references
879
- */
880
- transform(data: Record<string, any>): Record<string, any>;
881
- /**
882
- * Set a value in a nested dictionary based on the given path
883
- */
884
- private static setNestedDict;
885
- /**
886
- * Convert lists in the JSON structure to dictionaries with index-based keys
887
- */
888
- private listToDictPreprocessing;
889
- /**
890
- * Handles primitive values (strings, numbers, etc) by either adding them to the current chunk
891
- * or creating new chunks if they don't fit
892
- */
893
- private handlePrimitiveValue;
894
- /**
895
- * Creates a nested dictionary chunk from a value and path
896
- * e.g., path ['a', 'b'], value 'c' becomes { a: { b: 'c' } }
897
- */
898
- private createChunk;
899
- /**
900
- * Checks if value is within size limits
901
- */
902
- private isWithinSizeLimit;
903
- /**
904
- * Splits arrays into chunks based on size limits
905
- * Handles nested objects by recursing into handleNestedObject
906
- */
907
- private handleArray;
908
- /**
909
- * Splits objects into chunks based on size limits
910
- * Handles nested arrays and objects by recursing into handleArray and handleNestedObject
911
- */
912
- private handleNestedObject;
913
- /**
914
- * Splits long strings into smaller chunks at word boundaries
915
- * Ensures each chunk is within maxSize limit
916
- */
917
- private splitLongString;
918
- /**
919
- * Core chunking logic that processes JSON data recursively
920
- * Handles arrays, objects, and primitive values while maintaining structure
921
- */
922
- private jsonSplit;
923
- /**
924
- * Splits JSON into a list of JSON chunks
925
- */
926
- splitJson({ jsonData, convertLists, }: {
927
- jsonData: Record<string, any>;
928
- convertLists?: boolean;
929
- }): Record<string, any>[];
930
- /**
931
- * Converts Unicode characters to their escaped ASCII representation
932
- * e.g., 'café' becomes 'caf\u00e9'
933
- */
934
- private escapeNonAscii;
935
- /**
936
- * Splits JSON into a list of JSON formatted strings
937
- */
938
- splitText({ jsonData, convertLists, ensureAscii, }: {
939
- jsonData: Record<string, any>;
940
- convertLists?: boolean;
941
- ensureAscii?: boolean;
942
- }): string[];
943
- /**
944
- * Create documents from a list of json objects
945
- */
946
- createDocuments({ texts, convertLists, ensureAscii, metadatas, }: {
947
- texts: string[];
948
- convertLists?: boolean;
949
- ensureAscii?: boolean;
950
- metadatas?: Record<string, any>[];
951
- }): Document[];
952
- transformDocuments({ ensureAscii, documents, convertLists, }: {
953
- ensureAscii?: boolean;
954
- convertLists?: boolean;
955
- documents: Document[];
956
- }): Document[];
957
- }
958
-
959
- declare interface RelatedNodeInfo<T extends Metadata = Metadata> {
960
- nodeId: string;
961
- nodeType?: ObjectType;
962
- metadata: T;
963
- hash?: string;
964
- }
965
- export { RelatedNodeInfo }
966
- export { RelatedNodeInfo as RelatedNodeInfo_alias_1 }
967
-
968
- declare type RelatedNodeType<T extends Metadata = Metadata> = RelatedNodeInfo<T> | RelatedNodeInfo<T>[];
969
- export { RelatedNodeType }
970
- export { RelatedNodeType as RelatedNodeType_alias_1 }
971
-
972
- declare function rerank(results: QueryResult[], query: string, model: MastraLanguageModel, options: RerankerFunctionOptions): Promise<RerankResult[]>;
973
- export { rerank }
974
- export { rerank as rerank_alias_1 }
975
-
976
- declare interface RerankConfig {
977
- options?: RerankerOptions;
978
- model: MastraLanguageModel | RelevanceScoreProvider;
979
- }
980
- export { RerankConfig }
981
- export { RerankConfig as RerankConfig_alias_1 }
982
-
983
- declare interface RerankerFunctionOptions {
984
- weights?: WeightConfig;
985
- queryEmbedding?: number[];
986
- topK?: number;
987
- }
988
- export { RerankerFunctionOptions }
989
- export { RerankerFunctionOptions as RerankerFunctionOptions_alias_1 }
990
-
991
- declare interface RerankerOptions {
992
- weights?: WeightConfig;
993
- topK?: number;
994
- }
995
- export { RerankerOptions }
996
- export { RerankerOptions as RerankerOptions_alias_1 }
997
-
998
- declare interface RerankResult {
999
- result: QueryResult;
1000
- score: number;
1001
- details: ScoringDetails;
1002
- }
1003
- export { RerankResult }
1004
- export { RerankResult as RerankResult_alias_1 }
1005
-
1006
- declare function rerankWithScorer({ results, query, scorer, options, }: {
1007
- results: QueryResult[];
1008
- query: string;
1009
- scorer: RelevanceScoreProvider;
1010
- options: RerankerFunctionOptions;
1011
- }): Promise<RerankResult[]>;
1012
- export { rerankWithScorer }
1013
- export { rerankWithScorer as rerankWithScorer_alias_1 }
1014
-
1015
- declare interface ScoringDetails {
1016
- semantic: number;
1017
- vector: number;
1018
- position: number;
1019
- queryAnalysis?: {
1020
- magnitude: number;
1021
- dominantFeatures: number[];
1022
- };
1023
- }
1024
-
1025
- declare type SourceInput = QueryResult_2 | RankedNode | RerankResult;
1026
-
1027
- export declare function splitTextOnTokens({ text, tokenizer }: {
1028
- text: string;
1029
- tokenizer: Tokenizer;
1030
- }): string[];
1031
-
1032
- export declare const STRIP_REGEX: RegExp;
1033
-
1034
- declare type SummaryExtractArgs = {
1035
- llm?: MastraLanguageModel;
1036
- summaries?: string[];
1037
- promptTemplate?: SummaryPrompt['template'];
1038
- };
1039
- export { SummaryExtractArgs }
1040
- export { SummaryExtractArgs as SummaryExtractArgs_alias_1 }
1041
-
1042
- /**
1043
- * Summarize an array of nodes using a custom LLM.
1044
- *
1045
- * @param nodes Array of node-like objects
1046
- * @param options Summary extraction options
1047
- * @returns Array of summary results
1048
- */
1049
- declare class SummaryExtractor extends BaseExtractor {
1050
- private llm;
1051
- summaries: string[];
1052
- promptTemplate: SummaryPrompt;
1053
- private selfSummary;
1054
- private prevSummary;
1055
- private nextSummary;
1056
- constructor(options?: SummaryExtractArgs);
1057
- /**
1058
- * Extract summary from a node.
1059
- * @param {BaseNode} node Node to extract summary from.
1060
- * @returns {Promise<string>} Summary extracted from the node.
1061
- */
1062
- generateNodeSummary(node: BaseNode): Promise<string>;
1063
- /**
1064
- * Extract summaries from a list of nodes.
1065
- * @param {BaseNode[]} nodes Nodes to extract summaries from.
1066
- * @returns {Promise<ExtractSummary[]>} Summaries extracted from the nodes.
1067
- */
1068
- extract(nodes: BaseNode[]): Promise<ExtractSummary[]>;
1069
- }
1070
- export { SummaryExtractor }
1071
- export { SummaryExtractor as SummaryExtractor_alias_1 }
1072
-
1073
- declare type SummaryPrompt = PromptTemplate<['context']>;
1074
- export { SummaryPrompt }
1075
- export { SummaryPrompt as SummaryPrompt_alias_1 }
1076
-
1077
- /**
1078
- * TODO: GraphRAG Enhancements
1079
- * - Add support for more edge types (sequential, hierarchical, citation, etc)
1080
- * - Allow for custom edge types
1081
- * - Utilize metadata for richer connections
1082
- * - Improve graph traversal and querying using types
1083
- */
1084
- declare type SupportedEdgeType = 'semantic';
1085
-
1086
- /**
1087
- * TextNode is the default node type for text.
1088
- */
1089
- declare class TextNode<T extends Metadata = Metadata> extends BaseNode<T> {
1090
- text: string;
1091
- startCharIdx?: number;
1092
- endCharIdx?: number;
1093
- metadataSeparator: string;
1094
- constructor(init?: TextNodeParams<T>);
1095
- /**
1096
- * Generate a hash of the text node.
1097
- * The ID is not part of the hash as it can change independent of content.
1098
- * @returns
1099
- */
1100
- generateHash(): string;
1101
- get type(): ObjectType;
1102
- getContent(): string;
1103
- getMetadataStr(): string;
1104
- getNodeInfo(): {
1105
- start: number | undefined;
1106
- end: number | undefined;
1107
- };
1108
- getText(): string;
1109
- }
1110
- export { TextNode }
1111
- export { TextNode as TextNode_alias_1 }
1112
-
1113
- declare type TextNodeParams<T extends Metadata = Metadata> = BaseNodeParams<T> & {
1114
- text?: string | undefined;
1115
- startCharIdx?: number | undefined;
1116
- endCharIdx?: number | undefined;
1117
- metadataSeparator?: string | undefined;
1118
- };
1119
- export { TextNodeParams }
1120
- export { TextNodeParams as TextNodeParams_alias_1 }
1121
-
1122
- export declare abstract class TextTransformer implements Transformer {
1123
- protected size: number;
1124
- protected overlap: number;
1125
- protected lengthFunction: (text: string) => number;
1126
- protected keepSeparator: boolean | 'start' | 'end';
1127
- protected addStartIndex: boolean;
1128
- protected stripWhitespace: boolean;
1129
- constructor({ size, overlap, lengthFunction, keepSeparator, addStartIndex, stripWhitespace, }: ChunkOptions);
1130
- setAddStartIndex(value: boolean): void;
1131
- abstract splitText({ text }: {
1132
- text: string;
1133
- }): string[];
1134
- createDocuments(texts: string[], metadatas?: Record<string, any>[]): Document[];
1135
- splitDocuments(documents: Document[]): Document[];
1136
- transformDocuments(documents: Document[]): Document[];
1137
- protected joinDocs(docs: string[], separator: string): string | null;
1138
- protected mergeSplits(splits: string[], separator: string): string[];
1139
- }
1140
-
1141
- declare type TitleCombinePrompt = PromptTemplate<['context']>;
1142
- export { TitleCombinePrompt }
1143
- export { TitleCombinePrompt as TitleCombinePrompt_alias_1 }
1144
-
1145
- /**
1146
- * Extract title from a list of nodes.
1147
- */
1148
- declare class TitleExtractor extends BaseExtractor {
1149
- llm: MastraLanguageModel;
1150
- isTextNodeOnly: boolean;
1151
- nodes: number;
1152
- nodeTemplate: TitleExtractorPrompt;
1153
- combineTemplate: TitleCombinePrompt;
1154
- constructor(options?: TitleExtractorsArgs);
1155
- /**
1156
- * Extract titles from a list of nodes.
1157
- * @param {BaseNode[]} nodes Nodes to extract titles from.
1158
- * @returns {Promise<BaseNode<ExtractTitle>[]>} Titles extracted from the nodes.
1159
- */
1160
- extract(nodes: BaseNode[]): Promise<Array<ExtractTitle>>;
1161
- private filterNodes;
1162
- private separateNodesByDocument;
1163
- private extractTitles;
1164
- private getTitlesCandidates;
1165
- }
1166
- export { TitleExtractor }
1167
- export { TitleExtractor as TitleExtractor_alias_1 }
1168
-
1169
- declare type TitleExtractorPrompt = PromptTemplate<['context']>;
1170
- export { TitleExtractorPrompt }
1171
- export { TitleExtractorPrompt as TitleExtractorPrompt_alias_1 }
1172
-
1173
- declare type TitleExtractorsArgs = {
1174
- llm?: MastraLanguageModel;
1175
- nodes?: number;
1176
- nodeTemplate?: TitleExtractorPrompt['template'];
1177
- combineTemplate?: TitleCombinePrompt['template'];
1178
- };
1179
- export { TitleExtractorsArgs }
1180
- export { TitleExtractorsArgs as TitleExtractorsArgs_alias_1 }
1181
-
1182
- declare interface Tokenizer {
1183
- overlap: number;
1184
- tokensPerChunk: number;
1185
- decode: (tokens: number[]) => string;
1186
- encode: (text: string) => number[];
1187
- }
1188
-
1189
- export declare class TokenTransformer extends TextTransformer {
1190
- private tokenizer;
1191
- private allowedSpecial;
1192
- private disallowedSpecial;
1193
- constructor({ encodingName, modelName, allowedSpecial, disallowedSpecial, options, }: {
1194
- encodingName: TiktokenEncoding;
1195
- modelName?: TiktokenModel;
1196
- allowedSpecial?: Set<string> | 'all';
1197
- disallowedSpecial?: Set<string> | 'all';
1198
- options: {
1199
- size?: number;
1200
- overlap?: number;
1201
- lengthFunction?: (text: string) => number;
1202
- keepSeparator?: boolean | 'start' | 'end';
1203
- addStartIndex?: boolean;
1204
- stripWhitespace?: boolean;
1205
- };
1206
- });
1207
- splitText({ text }: {
1208
- text: string;
1209
- }): string[];
1210
- static fromTikToken({ encodingName, modelName, options, }: {
1211
- encodingName?: TiktokenEncoding;
1212
- modelName?: TiktokenModel;
1213
- options?: {
1214
- size?: number;
1215
- overlap?: number;
1216
- allowedSpecial?: Set<string> | 'all';
1217
- disallowedSpecial?: Set<string> | 'all';
1218
- };
1219
- }): TokenTransformer;
1220
- }
1221
-
1222
- declare const topKDescription = "Controls how many matching documents to return.\n- ALWAYS provide a value\n- If no value is provided, use the default (10)\n- Must be a valid and positive number\n- Cannot be NaN\n- Uses provided value if specified\n- Default: 10 results (use this if unsure)\n- Higher values (like 20) provide more context\n- Lower values (like 3) focus on best matches\n- Based on query requirements";
1223
- export { topKDescription }
1224
- export { topKDescription as topKDescription_alias_1 }
1225
- export { topKDescription as topKDescription_alias_2 }
1226
-
1227
- export declare interface Transformer {
1228
- transformDocuments(documents: Document[]): Document[];
1229
- }
1230
-
1231
- /** @deprecated Import from @mastra/upstash instead */
1232
- declare const UPSTASH_PROMPT = "When querying Upstash Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" } or { \"category\": { \"$eq\": \"electronics\" } }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Matches all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"new\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $regex: Pattern matching using glob syntax (only as operator, not direct RegExp)\n Example: { \"name\": { \"$regex\": \"iphone*\" } }\n- $contains: Check if array/string contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nRestrictions:\n- Null/undefined values are not supported in any operator\n- Empty arrays are only supported in $in/$nin operators\n- Direct RegExp patterns are not supported, use $regex with glob syntax\n- Nested fields are supported using dot notation\n- Multiple conditions on same field are combined with AND\n- String values with quotes are automatically escaped\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- $regex uses glob syntax (*, ?) not standard regex patterns\n- $contains works on both arrays and string fields\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gt\": 100, \"$lt\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"new\"] } },\n { \"name\": { \"$regex\": \"iphone*\" } },\n { \"description\": { \"$contains\": \"latest\" } },\n { \"$or\": [\n { \"brand\": \"Apple\" },\n { \"rating\": { \"$gte\": 4.5 } }\n ]}\n ]\n}";
1233
- export { UPSTASH_PROMPT }
1234
- export { UPSTASH_PROMPT as UPSTASH_PROMPT_alias_1 }
1235
-
1236
- /** @deprecated Import from @mastra/vectorize instead */
1237
- declare const VECTORIZE_PROMPT = "When querying Vectorize, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nRestrictions:\n- Regex patterns are not supported\n- Logical operators are not supported\n- Element operators are not supported\n- Fields must have a flat structure, as nested fields are not supported\n- Multiple conditions on the same field are supported\n- Empty arrays in $in/$nin will return no results\n- Filter keys cannot be longer than 512 characters\n- Filter keys cannot contain invalid characters ($, \", empty)\n- Filter size is limited to prevent oversized queries\n- Invalid types in operators return no results instead of throwing errors\n- Empty objects are accepted in filters\n- Metadata must use flat structure with dot notation (no nested objects)\n- Must explicitly create metadata indexes for filterable fields (limit 10 per index)\n- Can only effectively filter on indexed metadata fields\n- Metadata values can be strings, numbers, booleans, or homogeneous arrays\n- No operators can be used at the top level (no logical operators supported)\n- All operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n\nExample Complex Query:\n{\n \"category\": { \"$in\": [\"electronics\", \"computers\"] },\n \"price\": { \"$gte\": 100, \"$lte\": 1000 },\n \"inStock\": true\n}";
1238
- export { VECTORIZE_PROMPT }
1239
- export { VECTORIZE_PROMPT as VECTORIZE_PROMPT_alias_1 }
1240
-
1241
- declare const vectorQuerySearch: ({ indexName, vectorStore, queryText, model, queryFilter, topK, includeVectors, maxRetries, databaseConfig, }: VectorQuerySearchParams) => Promise<VectorQuerySearchResult>;
1242
- export { vectorQuerySearch }
1243
- export { vectorQuerySearch as vectorQuerySearch_alias_1 }
1244
-
1245
- declare interface VectorQuerySearchParams {
1246
- indexName: string;
1247
- vectorStore: MastraVector;
1248
- queryText: string;
1249
- model: EmbeddingModel<string>;
1250
- queryFilter?: VectorFilter;
1251
- topK: number;
1252
- includeVectors?: boolean;
1253
- maxRetries?: number;
1254
- /** Database-specific configuration options */
1255
- databaseConfig?: DatabaseConfig;
1256
- }
1257
-
1258
- declare interface VectorQuerySearchResult {
1259
- results: QueryResult[];
1260
- queryEmbedding: number[];
1261
- }
1262
-
1263
- export declare type VectorQueryToolOptions = {
1264
- id?: string;
1265
- description?: string;
1266
- indexName: string;
1267
- model: EmbeddingModel<string>;
1268
- enableFilter?: boolean;
1269
- includeVectors?: boolean;
1270
- includeSources?: boolean;
1271
- reranker?: RerankConfig;
1272
- /** Database-specific configuration options */
1273
- databaseConfig?: DatabaseConfig;
1274
- } & ({
1275
- vectorStoreName: string;
1276
- } | {
1277
- vectorStoreName?: string;
1278
- vectorStore: MastraVector;
1279
- });
1280
-
1281
- declare type WeightConfig = {
1282
- semantic?: number;
1283
- vector?: number;
1284
- position?: number;
1285
- };
1286
-
1287
- declare type Where = BaseWhere | LogicalWhere;
1288
-
1289
- declare type WhereDocument = {
1290
- [key in WhereDocumentOperator]?: LiteralValue | LiteralNumber | WhereDocument[];
1291
- };
1292
-
1293
- declare type WhereDocumentOperator = '$contains' | '$not_contains' | LogicalOperator;
1294
-
1295
- declare type WhereOperator = '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$eq';
1296
-
1297
- declare class ZeroEntropyRelevanceScorer implements RelevanceScoreProvider {
1298
- private client;
1299
- private model;
1300
- constructor(model?: string, apiKey?: string);
1301
- getRelevanceScore(query: string, text: string): Promise<number>;
1302
- }
1303
- export { ZeroEntropyRelevanceScorer }
1304
- export { ZeroEntropyRelevanceScorer as ZeroEntropyRelevanceScorer_alias_1 }
1305
- export { ZeroEntropyRelevanceScorer as ZeroEntropyRelevanceScorer_alias_2 }
1306
-
1307
- export { }