@mastra/core 0.0.0-commonjs-20250227130920

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -0
  3. package/dist/agent/index.cjs +1865 -0
  4. package/dist/agent/index.d.cts +15 -0
  5. package/dist/agent/index.d.ts +15 -0
  6. package/dist/agent/index.js +1 -0
  7. package/dist/base-D90KQ4XI.d.ts +139 -0
  8. package/dist/base-hs9NDAZ2.d.cts +139 -0
  9. package/dist/base-nKCMCNrM.d.ts +920 -0
  10. package/dist/base-nhesrHv3.d.cts +920 -0
  11. package/dist/base.cjs +138 -0
  12. package/dist/base.d.cts +6 -0
  13. package/dist/base.d.ts +6 -0
  14. package/dist/base.js +1 -0
  15. package/dist/bundler/index.cjs +158 -0
  16. package/dist/bundler/index.d.cts +28 -0
  17. package/dist/bundler/index.d.ts +28 -0
  18. package/dist/bundler/index.js +1 -0
  19. package/dist/chunk-33GSTUNK.js +620 -0
  20. package/dist/chunk-4YRYBCOZ.js +10 -0
  21. package/dist/chunk-55NFNRKO.js +10 -0
  22. package/dist/chunk-5XPCMNGW.js +215 -0
  23. package/dist/chunk-B3M27AMP.js +1479 -0
  24. package/dist/chunk-BB4KXGBU.js +83 -0
  25. package/dist/chunk-C6A6W6XS.js +77 -0
  26. package/dist/chunk-HQ55LN2U.js +318 -0
  27. package/dist/chunk-KNVTCZW7.js +416 -0
  28. package/dist/chunk-LH47WVJL.js +61 -0
  29. package/dist/chunk-NGD2HQYW.js +346 -0
  30. package/dist/chunk-NUDAZEOG.js +35 -0
  31. package/dist/chunk-OZ4XVJ6F.js +49 -0
  32. package/dist/chunk-PHMSPCTC.js +145 -0
  33. package/dist/chunk-PNZK456O.js +88 -0
  34. package/dist/chunk-QAAJAHDB.js +37 -0
  35. package/dist/chunk-RG66XEJT.js +8 -0
  36. package/dist/chunk-SIFBBGY6.js +190 -0
  37. package/dist/chunk-SVEAENO7.js +22 -0
  38. package/dist/chunk-SY5244IR.js +1499 -0
  39. package/dist/chunk-W5HVJX45.js +402 -0
  40. package/dist/chunk-WIBGG4X6.js +173 -0
  41. package/dist/chunk-ZDWFBE5L.js +1 -0
  42. package/dist/chunk-ZINPRHAN.js +22 -0
  43. package/dist/deployer/index.cjs +165 -0
  44. package/dist/deployer/index.d.cts +19 -0
  45. package/dist/deployer/index.d.ts +19 -0
  46. package/dist/deployer/index.js +1 -0
  47. package/dist/eval/index.cjs +110 -0
  48. package/dist/eval/index.d.cts +28 -0
  49. package/dist/eval/index.d.ts +28 -0
  50. package/dist/eval/index.js +1 -0
  51. package/dist/filter/index.cjs +192 -0
  52. package/dist/filter/index.d.cts +90 -0
  53. package/dist/filter/index.d.ts +90 -0
  54. package/dist/filter/index.js +1 -0
  55. package/dist/hooks/index.cjs +87 -0
  56. package/dist/hooks/index.d.cts +33 -0
  57. package/dist/hooks/index.d.ts +33 -0
  58. package/dist/hooks/index.js +1 -0
  59. package/dist/index-mKY1XrpK.d.cts +90 -0
  60. package/dist/index-mKY1XrpK.d.ts +90 -0
  61. package/dist/index.cjs +6844 -0
  62. package/dist/index.d.cts +97 -0
  63. package/dist/index.d.ts +97 -0
  64. package/dist/index.js +119 -0
  65. package/dist/integration/index.cjs +113 -0
  66. package/dist/integration/index.d.cts +52 -0
  67. package/dist/integration/index.d.ts +52 -0
  68. package/dist/integration/index.js +1 -0
  69. package/dist/llm/index.cjs +2 -0
  70. package/dist/llm/index.d.cts +15 -0
  71. package/dist/llm/index.d.ts +15 -0
  72. package/dist/llm/index.js +1 -0
  73. package/dist/logger/index.cjs +159 -0
  74. package/dist/logger/index.d.cts +3 -0
  75. package/dist/logger/index.d.ts +3 -0
  76. package/dist/logger/index.js +1 -0
  77. package/dist/mastra/index.cjs +1741 -0
  78. package/dist/mastra/index.d.cts +67 -0
  79. package/dist/mastra/index.d.ts +67 -0
  80. package/dist/mastra/index.js +1 -0
  81. package/dist/memory/index.cjs +1907 -0
  82. package/dist/memory/index.d.cts +15 -0
  83. package/dist/memory/index.d.ts +15 -0
  84. package/dist/memory/index.js +1 -0
  85. package/dist/relevance/index.cjs +1927 -0
  86. package/dist/relevance/index.d.cts +21 -0
  87. package/dist/relevance/index.d.ts +21 -0
  88. package/dist/relevance/index.js +1 -0
  89. package/dist/storage/index.cjs +361 -0
  90. package/dist/storage/index.d.cts +15 -0
  91. package/dist/storage/index.d.ts +15 -0
  92. package/dist/storage/index.js +2 -0
  93. package/dist/storage/libsql/index.cjs +770 -0
  94. package/dist/storage/libsql/index.d.cts +81 -0
  95. package/dist/storage/libsql/index.d.ts +81 -0
  96. package/dist/storage/libsql/index.js +1 -0
  97. package/dist/telemetry/index.cjs +413 -0
  98. package/dist/telemetry/index.d.cts +51 -0
  99. package/dist/telemetry/index.d.ts +51 -0
  100. package/dist/telemetry/index.js +1 -0
  101. package/dist/telemetry/otel-vendor.cjs +52 -0
  102. package/dist/telemetry/otel-vendor.d.cts +7 -0
  103. package/dist/telemetry/otel-vendor.d.ts +7 -0
  104. package/dist/telemetry/otel-vendor.js +7 -0
  105. package/dist/tools/index.cjs +25 -0
  106. package/dist/tools/index.d.cts +29 -0
  107. package/dist/tools/index.d.ts +29 -0
  108. package/dist/tools/index.js +1 -0
  109. package/dist/tts/index.cjs +328 -0
  110. package/dist/tts/index.d.cts +28 -0
  111. package/dist/tts/index.d.ts +28 -0
  112. package/dist/tts/index.js +1 -0
  113. package/dist/types-m9RryK9a.d.cts +14 -0
  114. package/dist/types-m9RryK9a.d.ts +14 -0
  115. package/dist/utils.cjs +179 -0
  116. package/dist/utils.d.cts +26 -0
  117. package/dist/utils.d.ts +26 -0
  118. package/dist/utils.js +1 -0
  119. package/dist/vector/index.cjs +145 -0
  120. package/dist/vector/index.d.cts +30 -0
  121. package/dist/vector/index.d.ts +30 -0
  122. package/dist/vector/index.js +1 -0
  123. package/dist/vector/libsql/index.cjs +951 -0
  124. package/dist/vector/libsql/index.d.cts +29 -0
  125. package/dist/vector/libsql/index.d.ts +29 -0
  126. package/dist/vector/libsql/index.js +1 -0
  127. package/dist/voice/index.cjs +369 -0
  128. package/dist/voice/index.d.cts +67 -0
  129. package/dist/voice/index.d.ts +67 -0
  130. package/dist/voice/index.js +76 -0
  131. package/dist/workflow-DqQ4pON_.d.cts +84 -0
  132. package/dist/workflow-Ng_F_Zaf.d.ts +84 -0
  133. package/dist/workflows/index.cjs +1628 -0
  134. package/dist/workflows/index.d.cts +48 -0
  135. package/dist/workflows/index.d.ts +48 -0
  136. package/dist/workflows/index.js +1 -0
  137. package/package.json +162 -0
@@ -0,0 +1,190 @@
1
+ // src/filter/base.ts
2
+ var BaseFilterTranslator = class _BaseFilterTranslator {
3
+ /**
4
+ * Operator type checks
5
+ */
6
+ isOperator(key) {
7
+ return key.startsWith("$");
8
+ }
9
+ static BASIC_OPERATORS = ["$eq", "$ne"];
10
+ static NUMERIC_OPERATORS = ["$gt", "$gte", "$lt", "$lte"];
11
+ static ARRAY_OPERATORS = ["$in", "$nin", "$all", "$elemMatch"];
12
+ static LOGICAL_OPERATORS = ["$and", "$or", "$not", "$nor"];
13
+ static ELEMENT_OPERATORS = ["$exists"];
14
+ static REGEX_OPERATORS = ["$regex", "$options"];
15
+ static DEFAULT_OPERATORS = {
16
+ logical: _BaseFilterTranslator.LOGICAL_OPERATORS,
17
+ basic: _BaseFilterTranslator.BASIC_OPERATORS,
18
+ numeric: _BaseFilterTranslator.NUMERIC_OPERATORS,
19
+ array: _BaseFilterTranslator.ARRAY_OPERATORS,
20
+ element: _BaseFilterTranslator.ELEMENT_OPERATORS,
21
+ regex: _BaseFilterTranslator.REGEX_OPERATORS
22
+ };
23
+ isLogicalOperator(key) {
24
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.logical.includes(key);
25
+ }
26
+ isBasicOperator(key) {
27
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.basic.includes(key);
28
+ }
29
+ isNumericOperator(key) {
30
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.numeric.includes(key);
31
+ }
32
+ isArrayOperator(key) {
33
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.array.includes(key);
34
+ }
35
+ isElementOperator(key) {
36
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.element.includes(key);
37
+ }
38
+ isRegexOperator(key) {
39
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.regex.includes(key);
40
+ }
41
+ isFieldOperator(key) {
42
+ return this.isOperator(key) && !this.isLogicalOperator(key);
43
+ }
44
+ isCustomOperator(key) {
45
+ const support = this.getSupportedOperators();
46
+ return support.custom?.includes(key) ?? false;
47
+ }
48
+ getSupportedOperators() {
49
+ return _BaseFilterTranslator.DEFAULT_OPERATORS;
50
+ }
51
+ isValidOperator(key) {
52
+ const support = this.getSupportedOperators();
53
+ const allSupported = Object.values(support).flat();
54
+ return allSupported.includes(key);
55
+ }
56
+ /**
57
+ * Value normalization for comparison operators
58
+ */
59
+ normalizeComparisonValue(value) {
60
+ if (value instanceof Date) {
61
+ return value.toISOString();
62
+ }
63
+ if (typeof value === "number" && Object.is(value, -0)) {
64
+ return 0;
65
+ }
66
+ return value;
67
+ }
68
+ /**
69
+ * Helper method to simulate $all operator using $and + $eq when needed.
70
+ * Some vector stores don't support $all natively.
71
+ */
72
+ simulateAllOperator(field, values) {
73
+ return {
74
+ $and: values.map((value) => ({
75
+ [field]: { $in: [this.normalizeComparisonValue(value)] }
76
+ }))
77
+ };
78
+ }
79
+ /**
80
+ * Utility functions for type checking
81
+ */
82
+ isPrimitive(value) {
83
+ return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
84
+ }
85
+ isRegex(value) {
86
+ return value instanceof RegExp;
87
+ }
88
+ isEmpty(obj) {
89
+ return obj === null || obj === void 0 || typeof obj === "object" && Object.keys(obj).length === 0;
90
+ }
91
+ static ErrorMessages = {
92
+ UNSUPPORTED_OPERATOR: (op) => `Unsupported operator: ${op}`,
93
+ INVALID_LOGICAL_OPERATOR_LOCATION: (op, path) => `Logical operator ${op} cannot be used at field level: ${path}`,
94
+ NOT_REQUIRES_OBJECT: `$not operator requires an object`,
95
+ NOT_CANNOT_BE_EMPTY: `$not operator cannot be empty`,
96
+ INVALID_LOGICAL_OPERATOR_CONTENT: (path) => `Logical operators must contain field conditions, not direct operators: ${path}`,
97
+ INVALID_TOP_LEVEL_OPERATOR: (op) => `Invalid top-level operator: ${op}`,
98
+ ELEM_MATCH_REQUIRES_OBJECT: `$elemMatch requires an object with conditions`
99
+ };
100
+ /**
101
+ * Helper to handle array value normalization consistently
102
+ */
103
+ normalizeArrayValues(values) {
104
+ return values.map((value) => this.normalizeComparisonValue(value));
105
+ }
106
+ validateFilter(filter) {
107
+ const validation = this.validateFilterSupport(filter);
108
+ if (!validation.supported) {
109
+ throw new Error(validation.messages.join(", "));
110
+ }
111
+ }
112
+ /**
113
+ * Validates if a filter structure is supported by the specific vector DB
114
+ * and returns detailed validation information.
115
+ */
116
+ validateFilterSupport(node, path = "") {
117
+ const messages = [];
118
+ if (this.isPrimitive(node) || this.isEmpty(node)) {
119
+ return { supported: true, messages: [] };
120
+ }
121
+ if (Array.isArray(node)) {
122
+ const arrayResults = node.map((item) => this.validateFilterSupport(item, path));
123
+ const arrayMessages = arrayResults.flatMap((r) => r.messages);
124
+ return {
125
+ supported: arrayResults.every((r) => r.supported),
126
+ messages: arrayMessages
127
+ };
128
+ }
129
+ const nodeObj = node;
130
+ let isSupported = true;
131
+ for (const [key, value] of Object.entries(nodeObj)) {
132
+ const newPath = path ? `${path}.${key}` : key;
133
+ if (this.isOperator(key)) {
134
+ if (!this.isValidOperator(key)) {
135
+ isSupported = false;
136
+ messages.push(_BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(key));
137
+ continue;
138
+ }
139
+ if (!path && !this.isLogicalOperator(key)) {
140
+ isSupported = false;
141
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_TOP_LEVEL_OPERATOR(key));
142
+ continue;
143
+ }
144
+ if (key === "$elemMatch" && (typeof value !== "object" || Array.isArray(value))) {
145
+ isSupported = false;
146
+ messages.push(_BaseFilterTranslator.ErrorMessages.ELEM_MATCH_REQUIRES_OBJECT);
147
+ continue;
148
+ }
149
+ if (this.isLogicalOperator(key)) {
150
+ if (key === "$not") {
151
+ if (Array.isArray(value) || typeof value !== "object") {
152
+ isSupported = false;
153
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_REQUIRES_OBJECT);
154
+ continue;
155
+ }
156
+ if (this.isEmpty(value)) {
157
+ isSupported = false;
158
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_CANNOT_BE_EMPTY);
159
+ continue;
160
+ }
161
+ continue;
162
+ }
163
+ if (path && !this.isLogicalOperator(path.split(".").pop())) {
164
+ isSupported = false;
165
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_LOCATION(key, newPath));
166
+ continue;
167
+ }
168
+ if (Array.isArray(value)) {
169
+ const hasDirectOperators = value.some(
170
+ (item) => typeof item === "object" && Object.keys(item).length === 1 && this.isFieldOperator(Object.keys(item)[0])
171
+ );
172
+ if (hasDirectOperators) {
173
+ isSupported = false;
174
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_CONTENT(newPath));
175
+ continue;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ const nestedValidation = this.validateFilterSupport(value, newPath);
181
+ if (!nestedValidation.supported) {
182
+ isSupported = false;
183
+ messages.push(...nestedValidation.messages);
184
+ }
185
+ }
186
+ return { supported: isSupported, messages };
187
+ }
188
+ };
189
+
190
+ export { BaseFilterTranslator };
@@ -0,0 +1,22 @@
1
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
2
+ import { readFile } from 'fs/promises';
3
+ import { parse } from 'dotenv';
4
+
5
+ var MastraBundler = class extends MastraBase {
6
+ constructor({ name, component = "BUNDLER" }) {
7
+ super({ component, name });
8
+ }
9
+ async loadEnvVars() {
10
+ const envVars = /* @__PURE__ */ new Map();
11
+ for (const file of await this.getEnvFiles()) {
12
+ const content = await readFile(file, "utf-8");
13
+ const config = parse(content);
14
+ Object.entries(config).forEach(([key, value]) => {
15
+ envVars.set(key, value);
16
+ });
17
+ }
18
+ return envVars;
19
+ }
20
+ };
21
+
22
+ export { MastraBundler };