@mastra/core 0.10.12 → 0.10.13

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 (235) hide show
  1. package/package.json +1 -1
  2. package/a2a.d.ts +0 -1
  3. package/agent.d.ts +0 -1
  4. package/base.d.ts +0 -1
  5. package/bundler.d.ts +0 -1
  6. package/deployer.d.ts +0 -1
  7. package/di.d.ts +0 -1
  8. package/dist/a2a/index.cjs +0 -79
  9. package/dist/a2a/index.d.cts +0 -780
  10. package/dist/a2a/index.d.ts +0 -780
  11. package/dist/a2a/index.js +0 -68
  12. package/dist/agent/index.cjs +0 -15
  13. package/dist/agent/index.d.cts +0 -29
  14. package/dist/agent/index.d.ts +0 -29
  15. package/dist/agent/index.js +0 -2
  16. package/dist/base-B_y9sMg0.d.cts +0 -162
  17. package/dist/base-CS5eSXbL.d.cts +0 -4117
  18. package/dist/base-ClrXcCRx.d.ts +0 -162
  19. package/dist/base-DBhKcre4.d.ts +0 -4117
  20. package/dist/base.cjs +0 -10
  21. package/dist/base.d.cts +0 -6
  22. package/dist/base.d.ts +0 -6
  23. package/dist/base.js +0 -1
  24. package/dist/bundler/index.cjs +0 -10
  25. package/dist/bundler/index.d.cts +0 -30
  26. package/dist/bundler/index.d.ts +0 -30
  27. package/dist/bundler/index.js +0 -1
  28. package/dist/chunk-2GRYVZ2O.cjs +0 -244
  29. package/dist/chunk-2HDFKWFU.js +0 -2249
  30. package/dist/chunk-32C7JDIZ.js +0 -1
  31. package/dist/chunk-4UBOJFSL.js +0 -989
  32. package/dist/chunk-4UWPFBC6.js +0 -88
  33. package/dist/chunk-4Z3OU5RY.cjs +0 -31
  34. package/dist/chunk-5HTMDAXP.js +0 -359
  35. package/dist/chunk-5IEKR756.js +0 -53
  36. package/dist/chunk-5YDTZN2X.js +0 -114
  37. package/dist/chunk-6UNGH46J.js +0 -75
  38. package/dist/chunk-6Y4UL5Z6.cjs +0 -94
  39. package/dist/chunk-7F6BQXE2.cjs +0 -425
  40. package/dist/chunk-7H2GET5Z.cjs +0 -668
  41. package/dist/chunk-7HZ6NIAF.cjs +0 -2
  42. package/dist/chunk-7MZNOW6W.cjs +0 -2263
  43. package/dist/chunk-7XQIPES3.js +0 -668
  44. package/dist/chunk-AKYTYALY.js +0 -70
  45. package/dist/chunk-ATXBSEFT.js +0 -22
  46. package/dist/chunk-B6TOBUS6.cjs +0 -80
  47. package/dist/chunk-B7SQOKEC.cjs +0 -91
  48. package/dist/chunk-BB4KXGBU.js +0 -83
  49. package/dist/chunk-BB6DPGIV.cjs +0 -6
  50. package/dist/chunk-C4LMN2IR.js +0 -27
  51. package/dist/chunk-DFFVEKIG.js +0 -407
  52. package/dist/chunk-E7AX3U6M.cjs +0 -659
  53. package/dist/chunk-EWCOOO3H.js +0 -5007
  54. package/dist/chunk-F2WMR75C.cjs +0 -183
  55. package/dist/chunk-FBKJ3652.cjs +0 -5034
  56. package/dist/chunk-FEYYOBBG.cjs +0 -24
  57. package/dist/chunk-FL5SZ2XU.js +0 -181
  58. package/dist/chunk-GH2KM66J.js +0 -37
  59. package/dist/chunk-GWFS5DAR.cjs +0 -37
  60. package/dist/chunk-HNEE7IF4.js +0 -60
  61. package/dist/chunk-HSVOEWAM.cjs +0 -2
  62. package/dist/chunk-J52TXHZV.cjs +0 -73
  63. package/dist/chunk-JNMQKJH4.js +0 -10
  64. package/dist/chunk-JQOMTERC.js +0 -89
  65. package/dist/chunk-LABUWBKX.cjs +0 -71
  66. package/dist/chunk-LXFZUKP3.cjs +0 -34
  67. package/dist/chunk-MP2QBLUJ.cjs +0 -70
  68. package/dist/chunk-MUNFCOMB.cjs +0 -62
  69. package/dist/chunk-NH5WJNNS.js +0 -1
  70. package/dist/chunk-P3Q73CAW.cjs +0 -55
  71. package/dist/chunk-PA2YIVIT.js +0 -61
  72. package/dist/chunk-QFTBW7ZZ.cjs +0 -2
  73. package/dist/chunk-QQ5K5TZE.cjs +0 -619
  74. package/dist/chunk-QUSEDVYI.cjs +0 -991
  75. package/dist/chunk-R4V75T7J.js +0 -1
  76. package/dist/chunk-SGGPJWRQ.js +0 -69
  77. package/dist/chunk-ST5RMVLG.cjs +0 -87
  78. package/dist/chunk-TC2SCOTE.js +0 -605
  79. package/dist/chunk-U64IJDC5.cjs +0 -109
  80. package/dist/chunk-UX3B6S2I.cjs +0 -65
  81. package/dist/chunk-V5D2LIF5.js +0 -68
  82. package/dist/chunk-VG4OPO2R.js +0 -240
  83. package/dist/chunk-WQNOATKB.js +0 -103
  84. package/dist/chunk-Y7D2JLKS.js +0 -4
  85. package/dist/chunk-YJEHXYK5.js +0 -657
  86. package/dist/chunk-YOQP5T77.js +0 -32
  87. package/dist/chunk-ZIZ3CVHN.cjs +0 -120
  88. package/dist/chunk-ZPOUMTTH.cjs +0 -362
  89. package/dist/chunk-ZZLBNB3U.cjs +0 -12
  90. package/dist/deployer/index.cjs +0 -10
  91. package/dist/deployer/index.d.cts +0 -19
  92. package/dist/deployer/index.d.ts +0 -19
  93. package/dist/deployer/index.js +0 -1
  94. package/dist/di/index.cjs +0 -10
  95. package/dist/di/index.d.cts +0 -1
  96. package/dist/di/index.d.ts +0 -1
  97. package/dist/di/index.js +0 -1
  98. package/dist/error/index.cjs +0 -22
  99. package/dist/error/index.d.cts +0 -86
  100. package/dist/error/index.d.ts +0 -86
  101. package/dist/error/index.js +0 -1
  102. package/dist/eval/index.cjs +0 -14
  103. package/dist/eval/index.d.cts +0 -43
  104. package/dist/eval/index.d.ts +0 -43
  105. package/dist/eval/index.js +0 -1
  106. package/dist/hooks/index.cjs +0 -18
  107. package/dist/hooks/index.d.cts +0 -33
  108. package/dist/hooks/index.d.ts +0 -33
  109. package/dist/hooks/index.js +0 -1
  110. package/dist/index.cjs +0 -281
  111. package/dist/index.d.cts +0 -92
  112. package/dist/index.d.ts +0 -92
  113. package/dist/index.js +0 -112
  114. package/dist/integration/index.cjs +0 -14
  115. package/dist/integration/index.d.cts +0 -65
  116. package/dist/integration/index.d.ts +0 -65
  117. package/dist/integration/index.js +0 -1
  118. package/dist/llm/index.cjs +0 -10
  119. package/dist/llm/index.d.cts +0 -29
  120. package/dist/llm/index.d.ts +0 -29
  121. package/dist/llm/index.js +0 -1
  122. package/dist/logger/index.cjs +0 -43
  123. package/dist/logger/index.d.cts +0 -96
  124. package/dist/logger/index.d.ts +0 -96
  125. package/dist/logger/index.js +0 -2
  126. package/dist/logger-B8XXh6ya.d.cts +0 -159
  127. package/dist/logger-Bpa2oLL4.d.ts +0 -159
  128. package/dist/mastra/index.cjs +0 -10
  129. package/dist/mastra/index.d.cts +0 -29
  130. package/dist/mastra/index.d.ts +0 -29
  131. package/dist/mastra/index.js +0 -1
  132. package/dist/mcp/index.cjs +0 -106
  133. package/dist/mcp/index.d.cts +0 -29
  134. package/dist/mcp/index.d.ts +0 -29
  135. package/dist/mcp/index.js +0 -100
  136. package/dist/memory/index.cjs +0 -18
  137. package/dist/memory/index.d.cts +0 -29
  138. package/dist/memory/index.d.ts +0 -29
  139. package/dist/memory/index.js +0 -1
  140. package/dist/network/index.cjs +0 -311
  141. package/dist/network/index.d.cts +0 -29
  142. package/dist/network/index.d.ts +0 -29
  143. package/dist/network/index.js +0 -309
  144. package/dist/network/vNext/index.cjs +0 -873
  145. package/dist/network/vNext/index.d.cts +0 -29
  146. package/dist/network/vNext/index.d.ts +0 -29
  147. package/dist/network/vNext/index.js +0 -871
  148. package/dist/relevance/index.cjs +0 -18
  149. package/dist/relevance/index.d.cts +0 -49
  150. package/dist/relevance/index.d.ts +0 -49
  151. package/dist/relevance/index.js +0 -1
  152. package/dist/runtime-context/index.cjs +0 -10
  153. package/dist/runtime-context/index.d.cts +0 -52
  154. package/dist/runtime-context/index.d.ts +0 -52
  155. package/dist/runtime-context/index.js +0 -1
  156. package/dist/server/index.cjs +0 -62
  157. package/dist/server/index.d.cts +0 -52
  158. package/dist/server/index.d.ts +0 -52
  159. package/dist/server/index.js +0 -59
  160. package/dist/storage/index.cjs +0 -336
  161. package/dist/storage/index.d.cts +0 -149
  162. package/dist/storage/index.d.ts +0 -149
  163. package/dist/storage/index.js +0 -303
  164. package/dist/telemetry/index.cjs +0 -30
  165. package/dist/telemetry/index.d.cts +0 -75
  166. package/dist/telemetry/index.d.ts +0 -75
  167. package/dist/telemetry/index.js +0 -1
  168. package/dist/telemetry/otel-vendor.cjs +0 -103
  169. package/dist/telemetry/otel-vendor.d.cts +0 -20
  170. package/dist/telemetry/otel-vendor.d.ts +0 -20
  171. package/dist/telemetry/otel-vendor.js +0 -57
  172. package/dist/tools/index.cjs +0 -18
  173. package/dist/tools/index.d.cts +0 -41
  174. package/dist/tools/index.d.ts +0 -41
  175. package/dist/tools/index.js +0 -1
  176. package/dist/tts/index.cjs +0 -10
  177. package/dist/tts/index.d.cts +0 -28
  178. package/dist/tts/index.d.ts +0 -28
  179. package/dist/tts/index.js +0 -1
  180. package/dist/types-Bo1uigWx.d.cts +0 -17
  181. package/dist/types-Bo1uigWx.d.ts +0 -17
  182. package/dist/utils.cjs +0 -58
  183. package/dist/utils.d.cts +0 -149
  184. package/dist/utils.d.ts +0 -149
  185. package/dist/utils.js +0 -1
  186. package/dist/vector/filter/index.cjs +0 -192
  187. package/dist/vector/filter/index.d.cts +0 -128
  188. package/dist/vector/filter/index.d.ts +0 -128
  189. package/dist/vector/filter/index.js +0 -190
  190. package/dist/vector/index.cjs +0 -10
  191. package/dist/vector/index.d.cts +0 -77
  192. package/dist/vector/index.d.ts +0 -77
  193. package/dist/vector/index.js +0 -1
  194. package/dist/voice/index.cjs +0 -18
  195. package/dist/voice/index.d.cts +0 -29
  196. package/dist/voice/index.d.ts +0 -29
  197. package/dist/voice/index.js +0 -1
  198. package/dist/workflows/constants.cjs +0 -10
  199. package/dist/workflows/constants.d.cts +0 -3
  200. package/dist/workflows/constants.d.ts +0 -3
  201. package/dist/workflows/constants.js +0 -1
  202. package/dist/workflows/index.cjs +0 -42
  203. package/dist/workflows/index.d.cts +0 -282
  204. package/dist/workflows/index.d.ts +0 -282
  205. package/dist/workflows/index.js +0 -1
  206. package/dist/workflows/legacy/index.cjs +0 -90
  207. package/dist/workflows/legacy/index.d.cts +0 -91
  208. package/dist/workflows/legacy/index.d.ts +0 -91
  209. package/dist/workflows/legacy/index.js +0 -1
  210. package/error.d.ts +0 -1
  211. package/eval.d.ts +0 -1
  212. package/hooks.d.ts +0 -1
  213. package/integration.d.ts +0 -1
  214. package/llm.d.ts +0 -1
  215. package/logger.d.ts +0 -1
  216. package/mastra.d.ts +0 -1
  217. package/mcp.d.ts +0 -1
  218. package/memory.d.ts +0 -1
  219. package/network/vNext.d.ts +0 -1
  220. package/network.d.ts +0 -1
  221. package/relevance.d.ts +0 -1
  222. package/runtime-context.d.ts +0 -1
  223. package/server.d.ts +0 -1
  224. package/storage.d.ts +0 -1
  225. package/telemetry/otel-vendor.d.ts +0 -1
  226. package/telemetry.d.ts +0 -1
  227. package/tools.d.ts +0 -1
  228. package/tts.d.ts +0 -1
  229. package/utils.d.ts +0 -1
  230. package/vector/filter.d.ts +0 -1
  231. package/vector.d.ts +0 -1
  232. package/voice.d.ts +0 -1
  233. package/workflows/_constants.d.ts +0 -1
  234. package/workflows/legacy.d.ts +0 -1
  235. package/workflows.d.ts +0 -1
@@ -1,109 +0,0 @@
1
- 'use strict';
2
-
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
10
- var __typeError = msg => {
11
- throw TypeError(msg);
12
- };
13
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value
18
- }) : obj[key] = value;
19
- var __name = (target, value) => __defProp(target, "name", {
20
- value,
21
- configurable: true
22
- });
23
- var __commonJS = (cb, mod) => function __require() {
24
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
25
- exports: {}
26
- }).exports, mod), mod.exports;
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
31
- get: () => from[key],
32
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
- });
34
- }
35
- return to;
36
- };
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
- // If the importer is in node compatibility mode or this is not an ESM
39
- // file that has been converted to a CommonJS file using a Babel-
40
- // compatible transform (i.e. "__esModule" has not been set), then set
41
- // "default" to the CommonJS "module.exports" for node compatibility.
42
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
43
- value: mod,
44
- enumerable: true
45
- }) : target, mod));
46
- var __decoratorStart = base => [,,, __create(base?.[__knownSymbol("metadata")] ?? null)];
47
- var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
48
- var __expectFn = fn => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
49
- var __decoratorContext = (kind, name, done, metadata, fns) => ({
50
- kind: __decoratorStrings[kind],
51
- name,
52
- metadata,
53
- addInitializer: fn => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null))
54
- });
55
- var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
56
- var __runInitializers = (array, flags, self, value) => {
57
- for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
58
- return value;
59
- };
60
- var __decorateElement = (array, flags, name, decorators, target, extra) => {
61
- var fn,
62
- it,
63
- done,
64
- ctx,
65
- access,
66
- k = flags & 7,
67
- s = !!(flags & 8),
68
- p = !!(flags & 16);
69
- var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0,
70
- key = __decoratorStrings[k + 5];
71
- var initializers = k > 3 && (array[j - 1] = []),
72
- extraInitializers = array[j] || (array[j] = []);
73
- var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : {
74
- get [name]() {
75
- return __privateGet(this, extra);
76
- },
77
- set [name](x) {
78
- return __privateSet(this, extra, x);
79
- }
80
- }, name));
81
- k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
82
- for (var i = decorators.length - 1; i >= 0; i--) {
83
- ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
84
- if (k) {
85
- ctx.static = s, ctx.private = p, access = ctx.access = {
86
- has: p ? x => __privateIn(target, x) : x => name in x
87
- };
88
- if (k ^ 3) access.get = p ? x => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : x => x[name];
89
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
90
- }
91
- it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : {
92
- get: desc.get,
93
- set: desc.set
94
- } : target, ctx), done._ = 1;
95
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);else if (typeof it !== "object" || it === null) __typeError("Object expected");else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
96
- }
97
- return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
98
- };
99
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
100
- var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
101
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
102
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
103
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
104
-
105
- exports.__commonJS = __commonJS;
106
- exports.__decorateElement = __decorateElement;
107
- exports.__decoratorStart = __decoratorStart;
108
- exports.__runInitializers = __runInitializers;
109
- exports.__toESM = __toESM;
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkFBKJ3652_cjs = require('./chunk-FBKJ3652.cjs');
4
- var cohereAi = require('cohere-ai');
5
-
6
- var CohereRelevanceScorer = class {
7
- client;
8
- model;
9
- constructor(model, apiKey) {
10
- this.client = new cohereAi.CohereClient({
11
- token: apiKey || process.env.COHERE_API_KEY || ""
12
- });
13
- this.model = model;
14
- }
15
- async getRelevanceScore(query, text) {
16
- const response = await this.client.rerank({
17
- query,
18
- documents: [text],
19
- model: this.model,
20
- topN: 1
21
- });
22
- return response.results[0].relevanceScore;
23
- }
24
- };
25
-
26
- // src/relevance/relevance-score-provider.ts
27
- function createSimilarityPrompt(query, text) {
28
- return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
29
-
30
- Query: ${query}
31
-
32
- Text: ${text}
33
-
34
- Relevance score (0-1):`;
35
- }
36
-
37
- // src/relevance/mastra-agent/index.ts
38
- var MastraAgentRelevanceScorer = class {
39
- agent;
40
- constructor(name, model) {
41
- this.agent = new chunkFBKJ3652_cjs.Agent({
42
- name: `Relevance Scorer ${name}`,
43
- instructions: `You are a specialized agent for evaluating the relevance of text to queries.
44
- Your task is to rate how well a text passage answers a given query.
45
- Output only a number between 0 and 1, where:
46
- 1.0 = Perfectly relevant, directly answers the query
47
- 0.0 = Completely irrelevant
48
- Consider:
49
- - Direct relevance to the question
50
- - Completeness of information
51
- - Quality and specificity
52
- Always return just the number, no explanation.`,
53
- model
54
- });
55
- }
56
- async getRelevanceScore(query, text) {
57
- const prompt = createSimilarityPrompt(query, text);
58
- const response = await this.agent.generate(prompt);
59
- return parseFloat(response.text);
60
- }
61
- };
62
-
63
- exports.CohereRelevanceScorer = CohereRelevanceScorer;
64
- exports.MastraAgentRelevanceScorer = MastraAgentRelevanceScorer;
65
- exports.createSimilarityPrompt = createSimilarityPrompt;
@@ -1,68 +0,0 @@
1
- import { MastraError } from './chunk-6UNGH46J.js';
2
- import { MastraBase } from './chunk-5IEKR756.js';
3
-
4
- // src/vector/vector.ts
5
- var MastraVector = class extends MastraBase {
6
- constructor() {
7
- super({ name: "MastraVector", component: "VECTOR" });
8
- }
9
- get indexSeparator() {
10
- return "_";
11
- }
12
- async validateExistingIndex(indexName, dimension, metric) {
13
- let info;
14
- try {
15
- info = await this.describeIndex({ indexName });
16
- } catch (infoError) {
17
- const mastraError = new MastraError(
18
- {
19
- id: "VECTOR_VALIDATE_INDEX_FETCH_FAILED",
20
- text: `Index "${indexName}" already exists, but failed to fetch index info for dimension check.`,
21
- domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
22
- category: "SYSTEM" /* SYSTEM */,
23
- details: { indexName }
24
- },
25
- infoError
26
- );
27
- this.logger?.trackException(mastraError);
28
- this.logger?.error(mastraError.toString());
29
- throw mastraError;
30
- }
31
- const existingDim = info?.dimension;
32
- const existingMetric = info?.metric;
33
- if (existingDim === dimension) {
34
- this.logger?.info(
35
- `Index "${indexName}" already exists with ${existingDim} dimensions and metric ${existingMetric}, skipping creation.`
36
- );
37
- if (existingMetric !== metric) {
38
- this.logger?.warn(
39
- `Attempted to create index with metric "${metric}", but index already exists with metric "${existingMetric}". To use a different metric, delete and recreate the index.`
40
- );
41
- }
42
- } else if (info) {
43
- const mastraError = new MastraError({
44
- id: "VECTOR_VALIDATE_INDEX_DIMENSION_MISMATCH",
45
- text: `Index "${indexName}" already exists with ${existingDim} dimensions, but ${dimension} dimensions were requested`,
46
- domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
47
- category: "USER" /* USER */,
48
- details: { indexName, existingDim, requestedDim: dimension }
49
- });
50
- this.logger?.trackException(mastraError);
51
- this.logger?.error(mastraError.toString());
52
- throw mastraError;
53
- } else {
54
- const mastraError = new MastraError({
55
- id: "VECTOR_VALIDATE_INDEX_NO_DIMENSION",
56
- text: `Index "${indexName}" already exists, but could not retrieve its dimensions for validation.`,
57
- domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
58
- category: "SYSTEM" /* SYSTEM */,
59
- details: { indexName }
60
- });
61
- this.logger?.trackException(mastraError);
62
- this.logger?.error(mastraError.toString());
63
- throw mastraError;
64
- }
65
- }
66
- };
67
-
68
- export { MastraVector };
@@ -1,240 +0,0 @@
1
- import { augmentWithInit } from './chunk-YOQP5T77.js';
2
- import { MessageList } from './chunk-4UBOJFSL.js';
3
- import { deepMerge } from './chunk-DFFVEKIG.js';
4
- import { MastraBase } from './chunk-5IEKR756.js';
5
-
6
- // src/memory/memory.ts
7
- var MemoryProcessor = class extends MastraBase {
8
- /**
9
- * Process a list of messages and return a filtered or transformed list.
10
- * @param messages The messages to process
11
- * @returns The processed messages
12
- */
13
- process(messages, _opts) {
14
- return messages;
15
- }
16
- };
17
- var memoryDefaultOptions = {
18
- lastMessages: 10,
19
- semanticRecall: false,
20
- threads: {
21
- generateTitle: false
22
- },
23
- workingMemory: {
24
- enabled: false,
25
- template: `
26
- # User Information
27
- - **First Name**:
28
- - **Last Name**:
29
- - **Location**:
30
- - **Occupation**:
31
- - **Interests**:
32
- - **Goals**:
33
- - **Events**:
34
- - **Facts**:
35
- - **Projects**:
36
- `
37
- }
38
- };
39
- var MastraMemory = class extends MastraBase {
40
- MAX_CONTEXT_TOKENS;
41
- _storage;
42
- vector;
43
- embedder;
44
- processors = [];
45
- threadConfig = { ...memoryDefaultOptions };
46
- constructor(config) {
47
- super({ component: "MEMORY", name: config.name });
48
- if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);
49
- if (config.processors) this.processors = config.processors;
50
- if (config.storage) {
51
- this._storage = augmentWithInit(config.storage);
52
- this._hasOwnStorage = true;
53
- }
54
- if (this.threadConfig.semanticRecall) {
55
- if (!config.vector) {
56
- throw new Error(
57
- `Semantic recall requires a vector store to be configured.
58
-
59
- https://mastra.ai/en/docs/memory/semantic-recall`
60
- );
61
- }
62
- this.vector = config.vector;
63
- if (!config.embedder) {
64
- throw new Error(
65
- `Semantic recall requires an embedder to be configured.
66
-
67
- https://mastra.ai/en/docs/memory/semantic-recall`
68
- );
69
- }
70
- this.embedder = config.embedder;
71
- }
72
- }
73
- _hasOwnStorage = false;
74
- get hasOwnStorage() {
75
- return this._hasOwnStorage;
76
- }
77
- get storage() {
78
- if (!this._storage) {
79
- throw new Error(
80
- `Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.
81
-
82
- https://mastra.ai/en/docs/memory/overview`
83
- );
84
- }
85
- return this._storage;
86
- }
87
- setStorage(storage) {
88
- this._storage = augmentWithInit(storage);
89
- }
90
- setVector(vector) {
91
- this.vector = vector;
92
- }
93
- setEmbedder(embedder) {
94
- this.embedder = embedder;
95
- }
96
- /**
97
- * Get a system message to inject into the conversation.
98
- * This will be called before each conversation turn.
99
- * Implementations can override this to inject custom system messages.
100
- */
101
- async getSystemMessage(_input) {
102
- return null;
103
- }
104
- /**
105
- * Get tools that should be available to the agent.
106
- * This will be called when converting tools for the agent.
107
- * Implementations can override this to provide additional tools.
108
- */
109
- getTools(_config) {
110
- return {};
111
- }
112
- async createEmbeddingIndex(dimensions) {
113
- const defaultDimensions = 1536;
114
- const isDefault = dimensions === defaultDimensions;
115
- const usedDimensions = dimensions ?? defaultDimensions;
116
- const separator = this.vector?.indexSeparator ?? "_";
117
- const indexName = isDefault ? `memory${separator}messages` : `memory${separator}messages${separator}${usedDimensions}`;
118
- if (typeof this.vector === `undefined`) {
119
- throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
120
- }
121
- await this.vector.createIndex({
122
- indexName,
123
- dimension: usedDimensions
124
- });
125
- return { indexName };
126
- }
127
- getMergedThreadConfig(config) {
128
- if (config?.workingMemory && "use" in config.workingMemory) {
129
- throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
130
- }
131
- const mergedConfig = deepMerge(this.threadConfig, config || {});
132
- if (config?.workingMemory?.schema) {
133
- if (mergedConfig.workingMemory) {
134
- mergedConfig.workingMemory.schema = config.workingMemory.schema;
135
- }
136
- }
137
- return mergedConfig;
138
- }
139
- /**
140
- * Apply all configured message processors to a list of messages.
141
- * @param messages The messages to process
142
- * @returns The processed messages
143
- */
144
- applyProcessors(messages, opts) {
145
- const processors = opts.processors || this.processors;
146
- if (!processors || processors.length === 0) {
147
- return messages;
148
- }
149
- let processedMessages = [...messages];
150
- for (const processor of processors) {
151
- processedMessages = processor.process(processedMessages, {
152
- systemMessage: opts.systemMessage,
153
- newMessages: opts.newMessages,
154
- memorySystemMessage: opts.memorySystemMessage
155
- });
156
- }
157
- return processedMessages;
158
- }
159
- processMessages({
160
- messages,
161
- processors,
162
- ...opts
163
- }) {
164
- return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
165
- }
166
- estimateTokens(text) {
167
- return Math.ceil(text.split(" ").length * 1.3);
168
- }
169
- /**
170
- * Helper method to create a new thread
171
- * @param title - Optional title for the thread
172
- * @param metadata - Optional metadata for the thread
173
- * @returns Promise resolving to the created thread
174
- */
175
- async createThread({
176
- threadId,
177
- resourceId,
178
- title,
179
- metadata,
180
- memoryConfig
181
- }) {
182
- const thread = {
183
- id: threadId || this.generateId(),
184
- title: title || `New Thread ${(/* @__PURE__ */ new Date()).toISOString()}`,
185
- resourceId,
186
- createdAt: /* @__PURE__ */ new Date(),
187
- updatedAt: /* @__PURE__ */ new Date(),
188
- metadata
189
- };
190
- return this.saveThread({ thread, memoryConfig });
191
- }
192
- /**
193
- * Helper method to add a single message to a thread
194
- * @param threadId - The thread to add the message to
195
- * @param content - The message content
196
- * @param role - The role of the message sender
197
- * @param type - The type of the message
198
- * @param toolNames - Optional array of tool names that were called
199
- * @param toolCallArgs - Optional array of tool call arguments
200
- * @param toolCallIds - Optional array of tool call ids
201
- * @returns Promise resolving to the saved message
202
- * @deprecated use saveMessages instead
203
- */
204
- async addMessage({
205
- threadId,
206
- resourceId,
207
- config,
208
- content,
209
- role,
210
- type,
211
- toolNames,
212
- toolCallArgs,
213
- toolCallIds
214
- }) {
215
- const message = {
216
- id: this.generateId(),
217
- content,
218
- role,
219
- createdAt: /* @__PURE__ */ new Date(),
220
- threadId,
221
- resourceId,
222
- type,
223
- toolNames,
224
- toolCallArgs,
225
- toolCallIds
226
- };
227
- const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });
228
- const list = new MessageList({ threadId, resourceId }).add(savedMessages[0], "memory");
229
- return list.get.all.v1()[0];
230
- }
231
- /**
232
- * Generates a unique identifier
233
- * @returns A unique string ID
234
- */
235
- generateId() {
236
- return crypto.randomUUID();
237
- }
238
- };
239
-
240
- export { MastraMemory, MemoryProcessor, memoryDefaultOptions };
@@ -1,103 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
- var __typeError = msg => {
9
- throw TypeError(msg);
10
- };
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value
16
- }) : obj[key] = value;
17
- var __name = (target, value) => __defProp(target, "name", {
18
- value,
19
- configurable: true
20
- });
21
- var __commonJS = (cb, mod) => function __require() {
22
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
23
- exports: {}
24
- }).exports, mod), mod.exports;
25
- };
26
- var __copyProps = (to, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
29
- get: () => from[key],
30
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
31
- });
32
- }
33
- return to;
34
- };
35
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
- // If the importer is in node compatibility mode or this is not an ESM
37
- // file that has been converted to a CommonJS file using a Babel-
38
- // compatible transform (i.e. "__esModule" has not been set), then set
39
- // "default" to the CommonJS "module.exports" for node compatibility.
40
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
41
- value: mod,
42
- enumerable: true
43
- }) : target, mod));
44
- var __decoratorStart = base => [,,, __create(base?.[__knownSymbol("metadata")] ?? null)];
45
- var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
46
- var __expectFn = fn => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
47
- var __decoratorContext = (kind, name, done, metadata, fns) => ({
48
- kind: __decoratorStrings[kind],
49
- name,
50
- metadata,
51
- addInitializer: fn => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null))
52
- });
53
- var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
54
- var __runInitializers = (array, flags, self, value) => {
55
- for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
56
- return value;
57
- };
58
- var __decorateElement = (array, flags, name, decorators, target, extra) => {
59
- var fn,
60
- it,
61
- done,
62
- ctx,
63
- access,
64
- k = flags & 7,
65
- s = !!(flags & 8),
66
- p = !!(flags & 16);
67
- var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0,
68
- key = __decoratorStrings[k + 5];
69
- var initializers = k > 3 && (array[j - 1] = []),
70
- extraInitializers = array[j] || (array[j] = []);
71
- var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : {
72
- get [name]() {
73
- return __privateGet(this, extra);
74
- },
75
- set [name](x) {
76
- return __privateSet(this, extra, x);
77
- }
78
- }, name));
79
- k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
80
- for (var i = decorators.length - 1; i >= 0; i--) {
81
- ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
82
- if (k) {
83
- ctx.static = s, ctx.private = p, access = ctx.access = {
84
- has: p ? x => __privateIn(target, x) : x => name in x
85
- };
86
- if (k ^ 3) access.get = p ? x => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : x => x[name];
87
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
88
- }
89
- it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : {
90
- get: desc.get,
91
- set: desc.set
92
- } : target, ctx), done._ = 1;
93
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);else if (typeof it !== "object" || it === null) __typeError("Object expected");else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
94
- }
95
- return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
96
- };
97
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
98
- var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
99
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
100
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
101
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
102
-
103
- export { __commonJS, __decorateElement, __decoratorStart, __runInitializers, __toESM };
@@ -1,4 +0,0 @@
1
- // src/workflows/constants.ts
2
- var EMITTER_SYMBOL = Symbol("emitter");
3
-
4
- export { EMITTER_SYMBOL };