@mastra/core 0.10.13 → 0.10.15-alpha.0

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/a2a.d.ts +1 -0
  2. package/agent.d.ts +1 -0
  3. package/base.d.ts +1 -0
  4. package/bundler.d.ts +1 -0
  5. package/deployer.d.ts +1 -0
  6. package/di.d.ts +1 -0
  7. package/dist/a2a/index.cjs +79 -0
  8. package/dist/a2a/index.d.cts +780 -0
  9. package/dist/a2a/index.d.ts +780 -0
  10. package/dist/a2a/index.js +68 -0
  11. package/dist/agent/index.cjs +15 -0
  12. package/dist/agent/index.d.cts +29 -0
  13. package/dist/agent/index.d.ts +29 -0
  14. package/dist/agent/index.js +2 -0
  15. package/dist/base-B_y9sMg0.d.cts +162 -0
  16. package/dist/base-CTj7ESwt.d.cts +4132 -0
  17. package/dist/base-ClrXcCRx.d.ts +162 -0
  18. package/dist/base-qVqAnB-c.d.ts +4132 -0
  19. package/dist/base.cjs +10 -0
  20. package/dist/base.d.cts +6 -0
  21. package/dist/base.d.ts +6 -0
  22. package/dist/base.js +1 -0
  23. package/dist/bundler/index.cjs +10 -0
  24. package/dist/bundler/index.d.cts +30 -0
  25. package/dist/bundler/index.d.ts +30 -0
  26. package/dist/bundler/index.js +1 -0
  27. package/dist/chunk-32C7JDIZ.js +1 -0
  28. package/dist/chunk-4UWPFBC6.js +88 -0
  29. package/dist/chunk-4Z3OU5RY.cjs +31 -0
  30. package/dist/chunk-5HTMDAXP.js +359 -0
  31. package/dist/chunk-5IEKR756.js +53 -0
  32. package/dist/chunk-5YDTZN2X.js +114 -0
  33. package/dist/chunk-6UNGH46J.js +75 -0
  34. package/dist/chunk-6Y4UL5Z6.cjs +94 -0
  35. package/dist/chunk-7H2GET5Z.cjs +668 -0
  36. package/dist/chunk-7HZ6NIAF.cjs +2 -0
  37. package/dist/chunk-7XQIPES3.js +668 -0
  38. package/dist/chunk-AKYTYALY.js +70 -0
  39. package/dist/chunk-AOWJUV2N.js +2415 -0
  40. package/dist/chunk-ATXBSEFT.js +22 -0
  41. package/dist/chunk-B6TOBUS6.cjs +80 -0
  42. package/dist/chunk-B7SQOKEC.cjs +91 -0
  43. package/dist/chunk-BB4KXGBU.js +83 -0
  44. package/dist/chunk-BB6DPGIV.cjs +6 -0
  45. package/dist/chunk-BVD7NVAR.cjs +244 -0
  46. package/dist/chunk-C4LMN2IR.js +27 -0
  47. package/dist/chunk-DR4JS662.js +989 -0
  48. package/dist/chunk-F2WMR75C.cjs +183 -0
  49. package/dist/chunk-FEYYOBBG.cjs +24 -0
  50. package/dist/chunk-FL5SZ2XU.js +181 -0
  51. package/dist/chunk-GH2KM66J.js +37 -0
  52. package/dist/chunk-GWFS5DAR.cjs +37 -0
  53. package/dist/chunk-HNEE7IF4.js +60 -0
  54. package/dist/chunk-HSVOEWAM.cjs +2 -0
  55. package/dist/chunk-IBKM5CLQ.js +428 -0
  56. package/dist/chunk-ID5LG5CQ.cjs +659 -0
  57. package/dist/chunk-J52TXHZV.cjs +73 -0
  58. package/dist/chunk-J62R4M7K.js +240 -0
  59. package/dist/chunk-JNMQKJH4.js +10 -0
  60. package/dist/chunk-JQOMTERC.js +89 -0
  61. package/dist/chunk-LABUWBKX.cjs +71 -0
  62. package/dist/chunk-LBUQ6YNU.cjs +447 -0
  63. package/dist/chunk-LXFZUKP3.cjs +34 -0
  64. package/dist/chunk-MP2QBLUJ.cjs +70 -0
  65. package/dist/chunk-MUNFCOMB.cjs +62 -0
  66. package/dist/chunk-MVCHTRVB.js +5038 -0
  67. package/dist/chunk-NH5WJNNS.js +1 -0
  68. package/dist/chunk-P3Q73CAW.cjs +55 -0
  69. package/dist/chunk-Q33INUG2.cjs +81 -0
  70. package/dist/chunk-QFTBW7ZZ.cjs +2 -0
  71. package/dist/chunk-QQ5K5TZE.cjs +619 -0
  72. package/dist/chunk-R4V75T7J.js +1 -0
  73. package/dist/chunk-RVFWMGGR.js +77 -0
  74. package/dist/chunk-SGGPJWRQ.js +69 -0
  75. package/dist/chunk-ST5RMVLG.cjs +87 -0
  76. package/dist/chunk-TC2SCOTE.js +605 -0
  77. package/dist/chunk-TTMYHBQM.js +657 -0
  78. package/dist/chunk-U64IJDC5.cjs +109 -0
  79. package/dist/chunk-ULZ6MRTN.cjs +5065 -0
  80. package/dist/chunk-V5D2LIF5.js +68 -0
  81. package/dist/chunk-WQNOATKB.js +103 -0
  82. package/dist/chunk-Y7D2JLKS.js +4 -0
  83. package/dist/chunk-YOQP5T77.js +32 -0
  84. package/dist/chunk-ZCU3PLIL.cjs +2429 -0
  85. package/dist/chunk-ZIZ3CVHN.cjs +120 -0
  86. package/dist/chunk-ZPOUMTTH.cjs +362 -0
  87. package/dist/chunk-ZTPPDHQK.cjs +991 -0
  88. package/dist/chunk-ZZLBNB3U.cjs +12 -0
  89. package/dist/deployer/index.cjs +10 -0
  90. package/dist/deployer/index.d.cts +19 -0
  91. package/dist/deployer/index.d.ts +19 -0
  92. package/dist/deployer/index.js +1 -0
  93. package/dist/di/index.cjs +10 -0
  94. package/dist/di/index.d.cts +1 -0
  95. package/dist/di/index.d.ts +1 -0
  96. package/dist/di/index.js +1 -0
  97. package/dist/error/index.cjs +22 -0
  98. package/dist/error/index.d.cts +86 -0
  99. package/dist/error/index.d.ts +86 -0
  100. package/dist/error/index.js +1 -0
  101. package/dist/eval/index.cjs +14 -0
  102. package/dist/eval/index.d.cts +43 -0
  103. package/dist/eval/index.d.ts +43 -0
  104. package/dist/eval/index.js +1 -0
  105. package/dist/hooks/index.cjs +18 -0
  106. package/dist/hooks/index.d.cts +33 -0
  107. package/dist/hooks/index.d.ts +33 -0
  108. package/dist/hooks/index.js +1 -0
  109. package/dist/index.cjs +285 -0
  110. package/dist/index.d.cts +92 -0
  111. package/dist/index.d.ts +92 -0
  112. package/dist/index.js +112 -0
  113. package/dist/integration/index.cjs +14 -0
  114. package/dist/integration/index.d.cts +65 -0
  115. package/dist/integration/index.d.ts +65 -0
  116. package/dist/integration/index.js +1 -0
  117. package/dist/llm/index.cjs +10 -0
  118. package/dist/llm/index.d.cts +29 -0
  119. package/dist/llm/index.d.ts +29 -0
  120. package/dist/llm/index.js +1 -0
  121. package/dist/logger/index.cjs +43 -0
  122. package/dist/logger/index.d.cts +96 -0
  123. package/dist/logger/index.d.ts +96 -0
  124. package/dist/logger/index.js +2 -0
  125. package/dist/logger-B8XXh6ya.d.cts +159 -0
  126. package/dist/logger-Bpa2oLL4.d.ts +159 -0
  127. package/dist/mastra/index.cjs +10 -0
  128. package/dist/mastra/index.d.cts +29 -0
  129. package/dist/mastra/index.d.ts +29 -0
  130. package/dist/mastra/index.js +1 -0
  131. package/dist/mcp/index.cjs +106 -0
  132. package/dist/mcp/index.d.cts +29 -0
  133. package/dist/mcp/index.d.ts +29 -0
  134. package/dist/mcp/index.js +100 -0
  135. package/dist/memory/index.cjs +18 -0
  136. package/dist/memory/index.d.cts +29 -0
  137. package/dist/memory/index.d.ts +29 -0
  138. package/dist/memory/index.js +1 -0
  139. package/dist/network/index.cjs +311 -0
  140. package/dist/network/index.d.cts +29 -0
  141. package/dist/network/index.d.ts +29 -0
  142. package/dist/network/index.js +309 -0
  143. package/dist/network/vNext/index.cjs +880 -0
  144. package/dist/network/vNext/index.d.cts +29 -0
  145. package/dist/network/vNext/index.d.ts +29 -0
  146. package/dist/network/vNext/index.js +878 -0
  147. package/dist/relevance/index.cjs +18 -0
  148. package/dist/relevance/index.d.cts +50 -0
  149. package/dist/relevance/index.d.ts +50 -0
  150. package/dist/relevance/index.js +1 -0
  151. package/dist/runtime-context/index.cjs +10 -0
  152. package/dist/runtime-context/index.d.cts +52 -0
  153. package/dist/runtime-context/index.d.ts +52 -0
  154. package/dist/runtime-context/index.js +1 -0
  155. package/dist/server/index.cjs +62 -0
  156. package/dist/server/index.d.cts +52 -0
  157. package/dist/server/index.d.ts +52 -0
  158. package/dist/server/index.js +59 -0
  159. package/dist/storage/index.cjs +336 -0
  160. package/dist/storage/index.d.cts +149 -0
  161. package/dist/storage/index.d.ts +149 -0
  162. package/dist/storage/index.js +303 -0
  163. package/dist/telemetry/index.cjs +30 -0
  164. package/dist/telemetry/index.d.cts +75 -0
  165. package/dist/telemetry/index.d.ts +75 -0
  166. package/dist/telemetry/index.js +1 -0
  167. package/dist/telemetry/otel-vendor.cjs +103 -0
  168. package/dist/telemetry/otel-vendor.d.cts +20 -0
  169. package/dist/telemetry/otel-vendor.d.ts +20 -0
  170. package/dist/telemetry/otel-vendor.js +57 -0
  171. package/dist/tools/index.cjs +18 -0
  172. package/dist/tools/index.d.cts +41 -0
  173. package/dist/tools/index.d.ts +41 -0
  174. package/dist/tools/index.js +1 -0
  175. package/dist/tts/index.cjs +10 -0
  176. package/dist/tts/index.d.cts +28 -0
  177. package/dist/tts/index.d.ts +28 -0
  178. package/dist/tts/index.js +1 -0
  179. package/dist/types-Bo1uigWx.d.cts +17 -0
  180. package/dist/types-Bo1uigWx.d.ts +17 -0
  181. package/dist/utils.cjs +62 -0
  182. package/dist/utils.d.cts +150 -0
  183. package/dist/utils.d.ts +150 -0
  184. package/dist/utils.js +1 -0
  185. package/dist/vector/filter/index.cjs +192 -0
  186. package/dist/vector/filter/index.d.cts +128 -0
  187. package/dist/vector/filter/index.d.ts +128 -0
  188. package/dist/vector/filter/index.js +190 -0
  189. package/dist/vector/index.cjs +10 -0
  190. package/dist/vector/index.d.cts +77 -0
  191. package/dist/vector/index.d.ts +77 -0
  192. package/dist/vector/index.js +1 -0
  193. package/dist/voice/index.cjs +18 -0
  194. package/dist/voice/index.d.cts +29 -0
  195. package/dist/voice/index.d.ts +29 -0
  196. package/dist/voice/index.js +1 -0
  197. package/dist/workflows/constants.cjs +10 -0
  198. package/dist/workflows/constants.d.cts +3 -0
  199. package/dist/workflows/constants.d.ts +3 -0
  200. package/dist/workflows/constants.js +1 -0
  201. package/dist/workflows/index.cjs +42 -0
  202. package/dist/workflows/index.d.cts +285 -0
  203. package/dist/workflows/index.d.ts +285 -0
  204. package/dist/workflows/index.js +1 -0
  205. package/dist/workflows/legacy/index.cjs +90 -0
  206. package/dist/workflows/legacy/index.d.cts +91 -0
  207. package/dist/workflows/legacy/index.d.ts +91 -0
  208. package/dist/workflows/legacy/index.js +1 -0
  209. package/error.d.ts +1 -0
  210. package/eval.d.ts +1 -0
  211. package/hooks.d.ts +1 -0
  212. package/integration.d.ts +1 -0
  213. package/llm.d.ts +1 -0
  214. package/logger.d.ts +1 -0
  215. package/mastra.d.ts +1 -0
  216. package/mcp.d.ts +1 -0
  217. package/memory.d.ts +1 -0
  218. package/network/vNext.d.ts +1 -0
  219. package/network.d.ts +1 -0
  220. package/package.json +2 -3
  221. package/relevance.d.ts +1 -0
  222. package/runtime-context.d.ts +1 -0
  223. package/server.d.ts +1 -0
  224. package/storage.d.ts +1 -0
  225. package/telemetry/otel-vendor.d.ts +1 -0
  226. package/telemetry.d.ts +1 -0
  227. package/tools.d.ts +1 -0
  228. package/tts.d.ts +1 -0
  229. package/utils.d.ts +1 -0
  230. package/vector/filter.d.ts +1 -0
  231. package/vector.d.ts +1 -0
  232. package/voice.d.ts +1 -0
  233. package/workflows/_constants.d.ts +1 -0
  234. package/workflows/legacy.d.ts +1 -0
  235. package/workflows.d.ts +1 -0
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ var chunkST5RMVLG_cjs = require('./chunk-ST5RMVLG.cjs');
4
+ var chunkB6TOBUS6_cjs = require('./chunk-B6TOBUS6.cjs');
5
+
6
+ // src/eval/metric.ts
7
+ var Metric = class {
8
+ };
9
+
10
+ // src/eval/evaluation.ts
11
+ async function evaluate({
12
+ agentName,
13
+ input,
14
+ metric,
15
+ output,
16
+ runId,
17
+ globalRunId,
18
+ testInfo,
19
+ instructions
20
+ }) {
21
+ const runIdToUse = runId || crypto.randomUUID();
22
+ let metricResult;
23
+ let metricName = metric.constructor.name;
24
+ try {
25
+ metricResult = await metric.measure(input.toString(), output);
26
+ } catch (e) {
27
+ throw new chunkB6TOBUS6_cjs.MastraError(
28
+ {
29
+ id: "EVAL_METRIC_MEASURE_EXECUTION_FAILED",
30
+ domain: "EVAL" /* EVAL */,
31
+ category: "USER" /* USER */,
32
+ details: {
33
+ agentName,
34
+ metricName,
35
+ globalRunId
36
+ }
37
+ },
38
+ e
39
+ );
40
+ }
41
+ const traceObject = {
42
+ input: input.toString(),
43
+ output,
44
+ result: metricResult,
45
+ agentName,
46
+ metricName,
47
+ instructions,
48
+ globalRunId,
49
+ runId: runIdToUse,
50
+ testInfo
51
+ };
52
+ try {
53
+ chunkST5RMVLG_cjs.executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
54
+ } catch (e) {
55
+ throw new chunkB6TOBUS6_cjs.MastraError(
56
+ {
57
+ id: "EVAL_HOOK_EXECUTION_FAILED",
58
+ domain: "EVAL" /* EVAL */,
59
+ category: "USER" /* USER */,
60
+ details: {
61
+ agentName,
62
+ metricName,
63
+ globalRunId
64
+ }
65
+ },
66
+ e
67
+ );
68
+ }
69
+ return { ...metricResult, output };
70
+ }
71
+
72
+ exports.Metric = Metric;
73
+ exports.evaluate = evaluate;
@@ -0,0 +1,240 @@
1
+ import { augmentWithInit } from './chunk-YOQP5T77.js';
2
+ import { MessageList } from './chunk-DR4JS662.js';
3
+ import { deepMerge } from './chunk-IBKM5CLQ.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 };
@@ -0,0 +1,10 @@
1
+ import { MastraBundler } from './chunk-ATXBSEFT.js';
2
+
3
+ // src/deployer/index.ts
4
+ var MastraDeployer = class extends MastraBundler {
5
+ constructor({ name }) {
6
+ super({ component: "DEPLOYER", name });
7
+ }
8
+ };
9
+
10
+ export { MastraDeployer };
@@ -0,0 +1,89 @@
1
+ import { Transform } from 'stream';
2
+
3
+ // src/logger/multi-logger.ts
4
+ var MultiLogger = class {
5
+ loggers;
6
+ constructor(loggers) {
7
+ this.loggers = loggers;
8
+ }
9
+ debug(message, ...args) {
10
+ this.loggers.forEach((logger) => logger.debug(message, ...args));
11
+ }
12
+ info(message, ...args) {
13
+ this.loggers.forEach((logger) => logger.info(message, ...args));
14
+ }
15
+ warn(message, ...args) {
16
+ this.loggers.forEach((logger) => logger.warn(message, ...args));
17
+ }
18
+ error(message, ...args) {
19
+ this.loggers.forEach((logger) => logger.error(message, ...args));
20
+ }
21
+ trackException(error) {
22
+ this.loggers.forEach((logger) => logger.trackException(error));
23
+ }
24
+ getTransports() {
25
+ const transports = [];
26
+ this.loggers.forEach((logger) => transports.push(...logger.getTransports().entries()));
27
+ return new Map(transports);
28
+ }
29
+ async getLogs(transportId, params) {
30
+ for (const logger of this.loggers) {
31
+ const logs = await logger.getLogs(transportId, params);
32
+ if (logs.total > 0) {
33
+ return logs;
34
+ }
35
+ }
36
+ return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
37
+ }
38
+ async getLogsByRunId(args) {
39
+ for (const logger of this.loggers) {
40
+ const logs = await logger.getLogsByRunId(args);
41
+ if (logs.total > 0) {
42
+ return logs;
43
+ }
44
+ }
45
+ return { logs: [], total: 0, page: args.page ?? 1, perPage: args.perPage ?? 100, hasMore: false };
46
+ }
47
+ };
48
+
49
+ // src/logger/noop-logger.ts
50
+ var noopLogger = {
51
+ debug: () => {
52
+ },
53
+ info: () => {
54
+ },
55
+ warn: () => {
56
+ },
57
+ error: () => {
58
+ },
59
+ cleanup: async () => {
60
+ },
61
+ getTransports: () => /* @__PURE__ */ new Map(),
62
+ trackException: () => {
63
+ },
64
+ getLogs: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false }),
65
+ getLogsByRunId: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false })
66
+ };
67
+ var LoggerTransport = class extends Transform {
68
+ constructor(opts = {}) {
69
+ super({ ...opts, objectMode: true });
70
+ }
71
+ async getLogsByRunId(_args) {
72
+ return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
73
+ }
74
+ async getLogs(_args) {
75
+ return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
76
+ }
77
+ };
78
+ var createCustomTransport = (stream, getLogs, getLogsByRunId) => {
79
+ let transport = stream;
80
+ if (getLogs) {
81
+ transport.getLogs = getLogs;
82
+ }
83
+ if (getLogsByRunId) {
84
+ transport.getLogsByRunId = getLogsByRunId;
85
+ }
86
+ return transport;
87
+ };
88
+
89
+ export { LoggerTransport, MultiLogger, createCustomTransport, noopLogger };
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ // src/runtime-context/index.ts
4
+ var RuntimeContext = class {
5
+ registry = /* @__PURE__ */ new Map();
6
+ constructor(iterable) {
7
+ this.registry = new Map(iterable);
8
+ }
9
+ /**
10
+ * set a value with strict typing if `Values` is a Record and the key exists in it.
11
+ */
12
+ set(key, value) {
13
+ this.registry.set(key, value);
14
+ }
15
+ /**
16
+ * Get a value with its type
17
+ */
18
+ get(key) {
19
+ return this.registry.get(key);
20
+ }
21
+ /**
22
+ * Check if a key exists in the container
23
+ */
24
+ has(key) {
25
+ return this.registry.has(key);
26
+ }
27
+ /**
28
+ * Delete a value by key
29
+ */
30
+ delete(key) {
31
+ return this.registry.delete(key);
32
+ }
33
+ /**
34
+ * Clear all values from the container
35
+ */
36
+ clear() {
37
+ this.registry.clear();
38
+ }
39
+ /**
40
+ * Get all keys in the container
41
+ */
42
+ keys() {
43
+ return this.registry.keys();
44
+ }
45
+ /**
46
+ * Get all values in the container
47
+ */
48
+ values() {
49
+ return this.registry.values();
50
+ }
51
+ /**
52
+ * Get all entries in the container
53
+ */
54
+ entries() {
55
+ return this.registry.entries();
56
+ }
57
+ /**
58
+ * Get the size of the container
59
+ */
60
+ size() {
61
+ return this.registry.size;
62
+ }
63
+ /**
64
+ * Execute a function for each entry in the container
65
+ */
66
+ forEach(callbackfn) {
67
+ this.registry.forEach(callbackfn);
68
+ }
69
+ };
70
+
71
+ exports.RuntimeContext = RuntimeContext;