@mastra/core 1.2.0-alpha.0 → 1.2.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 (263) hide show
  1. package/CHANGELOG.md +314 -0
  2. package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +1 -1
  3. package/dist/agent/agent.d.ts +17 -2
  4. package/dist/agent/agent.d.ts.map +1 -1
  5. package/dist/agent/index.cjs +13 -13
  6. package/dist/agent/index.js +2 -2
  7. package/dist/agent/message-list/index.cjs +18 -18
  8. package/dist/agent/message-list/index.js +1 -1
  9. package/dist/agent/message-list/merge/MessageMerger.d.ts +5 -0
  10. package/dist/agent/message-list/merge/MessageMerger.d.ts.map +1 -1
  11. package/dist/agent/message-list/message-list.d.ts +15 -0
  12. package/dist/agent/message-list/message-list.d.ts.map +1 -1
  13. package/dist/agent/workflows/prepare-stream/index.d.ts +9 -8
  14. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  15. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +4 -0
  16. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  17. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +9 -7
  18. package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
  19. package/dist/agent/workflows/prepare-stream/schema.d.ts +24 -14
  20. package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
  21. package/dist/{chunk-XVHK5IAO.cjs → chunk-3LRUJTH3.cjs} +50 -333
  22. package/dist/chunk-3LRUJTH3.cjs.map +1 -0
  23. package/dist/{chunk-2CVY7S66.js → chunk-4XLGMCCQ.js} +18 -21
  24. package/dist/chunk-4XLGMCCQ.js.map +1 -0
  25. package/dist/{chunk-HIP5W3LZ.js → chunk-57O4TPB3.js} +60 -4
  26. package/dist/chunk-57O4TPB3.js.map +1 -0
  27. package/dist/{chunk-FAJYC6PA.js → chunk-5HDIPOLV.js} +363 -104
  28. package/dist/chunk-5HDIPOLV.js.map +1 -0
  29. package/dist/{chunk-OAOMKZXU.cjs → chunk-AP3Z4EAP.cjs} +60 -56
  30. package/dist/chunk-AP3Z4EAP.cjs.map +1 -0
  31. package/dist/{chunk-I6PWV32C.cjs → chunk-AQHO4OC2.cjs} +517 -61
  32. package/dist/chunk-AQHO4OC2.cjs.map +1 -0
  33. package/dist/{chunk-W57QS6F6.cjs → chunk-ARQG4ZSD.cjs} +430 -168
  34. package/dist/chunk-ARQG4ZSD.cjs.map +1 -0
  35. package/dist/{chunk-AC63Y6KP.js → chunk-BP2TSCBW.js} +3 -3
  36. package/dist/chunk-BP2TSCBW.js.map +1 -0
  37. package/dist/{chunk-NS33UC72.js → chunk-ENCTSDWC.js} +104 -11
  38. package/dist/chunk-ENCTSDWC.js.map +1 -0
  39. package/dist/{chunk-66BWIF4S.js → chunk-EY3WXGUD.js} +43 -326
  40. package/dist/chunk-EY3WXGUD.js.map +1 -0
  41. package/dist/{chunk-IUODLQMU.cjs → chunk-G5NRZOPO.cjs} +60 -4
  42. package/dist/chunk-G5NRZOPO.cjs.map +1 -0
  43. package/dist/{chunk-22EV7GMK.cjs → chunk-HMCXNOF6.cjs} +105 -10
  44. package/dist/chunk-HMCXNOF6.cjs.map +1 -0
  45. package/dist/{chunk-EYUXOOSQ.cjs → chunk-HN2MSTR6.cjs} +130 -9
  46. package/dist/chunk-HN2MSTR6.cjs.map +1 -0
  47. package/dist/{chunk-7ALOYTDY.cjs → chunk-I66TMZJ3.cjs} +15 -6
  48. package/dist/chunk-I66TMZJ3.cjs.map +1 -0
  49. package/dist/{chunk-Y2SVKUOQ.cjs → chunk-JRJJ5VQE.cjs} +44 -3
  50. package/dist/chunk-JRJJ5VQE.cjs.map +1 -0
  51. package/dist/{chunk-CILDTRXD.js → chunk-MNWW2R3U.js} +42 -4
  52. package/dist/chunk-MNWW2R3U.js.map +1 -0
  53. package/dist/{chunk-FYMM4PKR.js → chunk-NRMSZFAU.js} +12 -8
  54. package/dist/chunk-NRMSZFAU.js.map +1 -0
  55. package/dist/{chunk-SPVI7HCP.js → chunk-NYC6PYZF.js} +6 -6
  56. package/dist/{chunk-SPVI7HCP.js.map → chunk-NYC6PYZF.js.map} +1 -1
  57. package/dist/{chunk-XS2MED4Y.js → chunk-P62OJXQ4.js} +129 -8
  58. package/dist/chunk-P62OJXQ4.js.map +1 -0
  59. package/dist/{chunk-USHB3SPM.js → chunk-PPAJGWVW.js} +5 -5
  60. package/dist/chunk-PPAJGWVW.js.map +1 -0
  61. package/dist/{chunk-DWD5DB6W.js → chunk-RUMXBL6P.js} +4 -4
  62. package/dist/{chunk-DWD5DB6W.js.map → chunk-RUMXBL6P.js.map} +1 -1
  63. package/dist/{chunk-KNPIRLQQ.cjs → chunk-SS4AZHZW.cjs} +21 -24
  64. package/dist/chunk-SS4AZHZW.cjs.map +1 -0
  65. package/dist/{chunk-4DDIPGB6.js → chunk-T6PRRKMW.js} +15 -6
  66. package/dist/chunk-T6PRRKMW.js.map +1 -0
  67. package/dist/{chunk-ODNSWEMV.cjs → chunk-VBOO4F4D.cjs} +8 -8
  68. package/dist/chunk-VBOO4F4D.cjs.map +1 -0
  69. package/dist/{chunk-MCI7M6AT.cjs → chunk-YL6ETQ5I.cjs} +7 -7
  70. package/dist/{chunk-MCI7M6AT.cjs.map → chunk-YL6ETQ5I.cjs.map} +1 -1
  71. package/dist/{chunk-STNSGW7W.cjs → chunk-YLODOPYM.cjs} +3 -3
  72. package/dist/chunk-YLODOPYM.cjs.map +1 -0
  73. package/dist/{chunk-BLXWTBLL.cjs → chunk-Z2OKCLGV.cjs} +18 -18
  74. package/dist/{chunk-BLXWTBLL.cjs.map → chunk-Z2OKCLGV.cjs.map} +1 -1
  75. package/dist/{chunk-OQPAOUDS.js → chunk-ZODRDMZ7.js} +508 -52
  76. package/dist/chunk-ZODRDMZ7.js.map +1 -0
  77. package/dist/docs/README.md +1 -1
  78. package/dist/docs/SKILL.md +1 -1
  79. package/dist/docs/SOURCE_MAP.json +357 -330
  80. package/dist/docs/agents/01-overview.md +2 -2
  81. package/dist/docs/configuration.mdx/01-reference.md +20 -0
  82. package/dist/docs/evals/01-overview.md +5 -5
  83. package/dist/docs/evals/04-reference.md +84 -10
  84. package/dist/docs/mcp/01-overview.md +2 -2
  85. package/dist/docs/memory/02-storage.md +10 -0
  86. package/dist/docs/observability/01-overview.md +1 -1
  87. package/dist/docs/observability/03-overview.md +3 -3
  88. package/dist/docs/rag/01-overview.md +1 -1
  89. package/dist/docs/tools-mcp/01-mcp-overview.md +2 -2
  90. package/dist/docs/voice/01-overview.md +1 -1
  91. package/dist/docs/workflows/01-overview.md +5 -5
  92. package/dist/docs/workspace/01-overview.md +2 -3
  93. package/dist/editor/index.cjs +4 -0
  94. package/dist/editor/index.cjs.map +1 -0
  95. package/dist/editor/index.d.ts +2 -0
  96. package/dist/editor/index.d.ts.map +1 -0
  97. package/dist/editor/index.js +3 -0
  98. package/dist/editor/index.js.map +1 -0
  99. package/dist/editor/types.d.ts +64 -0
  100. package/dist/editor/types.d.ts.map +1 -0
  101. package/dist/evals/index.cjs +20 -20
  102. package/dist/evals/index.js +3 -3
  103. package/dist/evals/scoreTraces/index.cjs +5 -5
  104. package/dist/evals/scoreTraces/index.js +2 -2
  105. package/dist/features/index.cjs +1 -1
  106. package/dist/features/index.cjs.map +1 -1
  107. package/dist/features/index.d.ts.map +1 -1
  108. package/dist/features/index.js +1 -1
  109. package/dist/features/index.js.map +1 -1
  110. package/dist/index.cjs +7 -2
  111. package/dist/index.d.ts +9 -0
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +2 -1
  114. package/dist/llm/index.cjs +18 -18
  115. package/dist/llm/index.js +3 -3
  116. package/dist/llm/model/embedding-router.d.ts +3 -1
  117. package/dist/llm/model/embedding-router.d.ts.map +1 -1
  118. package/dist/llm/model/model.d.ts +2 -2
  119. package/dist/llm/model/model.d.ts.map +1 -1
  120. package/dist/llm/model/model.loop.d.ts +1 -1
  121. package/dist/llm/model/model.loop.d.ts.map +1 -1
  122. package/dist/llm/model/provider-types.generated.d.ts +54 -2
  123. package/dist/loop/index.cjs +12 -12
  124. package/dist/loop/index.js +1 -1
  125. package/dist/loop/loop.d.ts.map +1 -1
  126. package/dist/loop/network/index.d.ts +4 -4
  127. package/dist/loop/types.d.ts +6 -1
  128. package/dist/loop/types.d.ts.map +1 -1
  129. package/dist/loop/workflows/agentic-execution/index.d.ts +22 -22
  130. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +15 -15
  131. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
  132. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +7 -7
  133. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
  134. package/dist/loop/workflows/agentic-loop/index.d.ts +22 -22
  135. package/dist/loop/workflows/schema.d.ts +30 -30
  136. package/dist/mastra/index.cjs +2 -2
  137. package/dist/mastra/index.d.ts +30 -132
  138. package/dist/mastra/index.d.ts.map +1 -1
  139. package/dist/mastra/index.js +1 -1
  140. package/dist/memory/index.cjs +23 -11
  141. package/dist/memory/index.js +1 -1
  142. package/dist/memory/memory.d.ts +6 -1
  143. package/dist/memory/memory.d.ts.map +1 -1
  144. package/dist/memory/mock.d.ts.map +1 -1
  145. package/dist/memory/types.d.ts +282 -0
  146. package/dist/memory/types.d.ts.map +1 -1
  147. package/dist/models-dev-OQKVMEIT.cjs +12 -0
  148. package/dist/{models-dev-SOIECXXQ.cjs.map → models-dev-OQKVMEIT.cjs.map} +1 -1
  149. package/dist/models-dev-Z45JSLWD.js +3 -0
  150. package/dist/{models-dev-2HBSVUOS.js.map → models-dev-Z45JSLWD.js.map} +1 -1
  151. package/dist/processors/index.cjs +41 -41
  152. package/dist/processors/index.d.ts +38 -1
  153. package/dist/processors/index.d.ts.map +1 -1
  154. package/dist/processors/index.js +1 -1
  155. package/dist/processors/memory/message-history.d.ts +16 -0
  156. package/dist/processors/memory/message-history.d.ts.map +1 -1
  157. package/dist/processors/processors/skills.d.ts.map +1 -1
  158. package/dist/processors/runner.d.ts +17 -3
  159. package/dist/processors/runner.d.ts.map +1 -1
  160. package/dist/processors/step-schema.d.ts +34 -34
  161. package/dist/provider-registry-NR7FXV2Q.cjs +40 -0
  162. package/dist/{provider-registry-ML2VWWLB.cjs.map → provider-registry-NR7FXV2Q.cjs.map} +1 -1
  163. package/dist/provider-registry-RPOTQNHI.js +3 -0
  164. package/dist/{provider-registry-K5L4DHRK.js.map → provider-registry-RPOTQNHI.js.map} +1 -1
  165. package/dist/provider-registry.json +126 -5
  166. package/dist/relevance/index.cjs +3 -3
  167. package/dist/relevance/index.js +1 -1
  168. package/dist/storage/constants.cjs +28 -16
  169. package/dist/storage/constants.d.ts +13 -1
  170. package/dist/storage/constants.d.ts.map +1 -1
  171. package/dist/storage/constants.js +1 -1
  172. package/dist/storage/domains/agents/base.d.ts.map +1 -1
  173. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
  174. package/dist/storage/domains/inmemory-db.d.ts +3 -1
  175. package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
  176. package/dist/storage/domains/memory/base.d.ts +62 -1
  177. package/dist/storage/domains/memory/base.d.ts.map +1 -1
  178. package/dist/storage/domains/memory/inmemory.d.ts +24 -2
  179. package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
  180. package/dist/storage/domains/observability/types.d.ts +50 -50
  181. package/dist/storage/domains/operations/inmemory.d.ts +5 -3
  182. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  183. package/dist/storage/index.cjs +113 -101
  184. package/dist/storage/index.js +2 -2
  185. package/dist/storage/types.d.ts +203 -16
  186. package/dist/storage/types.d.ts.map +1 -1
  187. package/dist/stream/base/output.d.ts.map +1 -1
  188. package/dist/stream/index.cjs +11 -11
  189. package/dist/stream/index.js +2 -2
  190. package/dist/test-utils/llm-mock.cjs +4 -4
  191. package/dist/test-utils/llm-mock.js +1 -1
  192. package/dist/tool-loop-agent/index.cjs +4 -4
  193. package/dist/tool-loop-agent/index.js +1 -1
  194. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  195. package/dist/utils.cjs +23 -23
  196. package/dist/utils.d.ts +1 -1
  197. package/dist/utils.d.ts.map +1 -1
  198. package/dist/utils.js +1 -1
  199. package/dist/vector/index.cjs +7 -7
  200. package/dist/vector/index.cjs.map +1 -1
  201. package/dist/vector/index.js +1 -1
  202. package/dist/vector/index.js.map +1 -1
  203. package/dist/vector/vector.d.ts +3 -1
  204. package/dist/vector/vector.d.ts.map +1 -1
  205. package/dist/workflows/evented/index.cjs +10 -10
  206. package/dist/workflows/evented/index.js +1 -1
  207. package/dist/workflows/evented/workflow.d.ts.map +1 -1
  208. package/dist/workflows/index.cjs +25 -25
  209. package/dist/workflows/index.js +1 -1
  210. package/dist/workflows/step.d.ts +2 -1
  211. package/dist/workflows/step.d.ts.map +1 -1
  212. package/dist/workflows/workflow.d.ts +2 -2
  213. package/dist/workflows/workflow.d.ts.map +1 -1
  214. package/dist/workspace/filesystem/index.d.ts +1 -0
  215. package/dist/workspace/filesystem/index.d.ts.map +1 -1
  216. package/dist/workspace/filesystem/local-filesystem.d.ts +3 -2
  217. package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
  218. package/dist/workspace/filesystem/mastra-filesystem.d.ts +65 -0
  219. package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -0
  220. package/dist/workspace/index.cjs +40 -32
  221. package/dist/workspace/index.d.ts +2 -0
  222. package/dist/workspace/index.d.ts.map +1 -1
  223. package/dist/workspace/index.js +1 -1
  224. package/dist/workspace/sandbox/index.d.ts +1 -0
  225. package/dist/workspace/sandbox/index.d.ts.map +1 -1
  226. package/dist/workspace/sandbox/local-sandbox.d.ts +3 -2
  227. package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
  228. package/dist/workspace/sandbox/mastra-sandbox.d.ts +52 -0
  229. package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -0
  230. package/dist/workspace/tools/tools.d.ts.map +1 -1
  231. package/dist/workspace/workspace.d.ts +21 -0
  232. package/dist/workspace/workspace.d.ts.map +1 -1
  233. package/editor.d.ts +1 -0
  234. package/package.json +8 -8
  235. package/src/llm/model/provider-types.generated.d.ts +54 -2
  236. package/dist/chunk-22EV7GMK.cjs.map +0 -1
  237. package/dist/chunk-2CVY7S66.js.map +0 -1
  238. package/dist/chunk-4DDIPGB6.js.map +0 -1
  239. package/dist/chunk-66BWIF4S.js.map +0 -1
  240. package/dist/chunk-7ALOYTDY.cjs.map +0 -1
  241. package/dist/chunk-AC63Y6KP.js.map +0 -1
  242. package/dist/chunk-CILDTRXD.js.map +0 -1
  243. package/dist/chunk-EYUXOOSQ.cjs.map +0 -1
  244. package/dist/chunk-FAJYC6PA.js.map +0 -1
  245. package/dist/chunk-FYMM4PKR.js.map +0 -1
  246. package/dist/chunk-HIP5W3LZ.js.map +0 -1
  247. package/dist/chunk-I6PWV32C.cjs.map +0 -1
  248. package/dist/chunk-IUODLQMU.cjs.map +0 -1
  249. package/dist/chunk-KNPIRLQQ.cjs.map +0 -1
  250. package/dist/chunk-NS33UC72.js.map +0 -1
  251. package/dist/chunk-OAOMKZXU.cjs.map +0 -1
  252. package/dist/chunk-ODNSWEMV.cjs.map +0 -1
  253. package/dist/chunk-OQPAOUDS.js.map +0 -1
  254. package/dist/chunk-STNSGW7W.cjs.map +0 -1
  255. package/dist/chunk-USHB3SPM.js.map +0 -1
  256. package/dist/chunk-W57QS6F6.cjs.map +0 -1
  257. package/dist/chunk-XS2MED4Y.js.map +0 -1
  258. package/dist/chunk-XVHK5IAO.cjs.map +0 -1
  259. package/dist/chunk-Y2SVKUOQ.cjs.map +0 -1
  260. package/dist/models-dev-2HBSVUOS.js +0 -3
  261. package/dist/models-dev-SOIECXXQ.cjs +0 -12
  262. package/dist/provider-registry-K5L4DHRK.js +0 -3
  263. package/dist/provider-registry-ML2VWWLB.cjs +0 -40
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkOAOMKZXU_cjs = require('./chunk-OAOMKZXU.cjs');
4
- var chunkMCI7M6AT_cjs = require('./chunk-MCI7M6AT.cjs');
5
- var chunkODNSWEMV_cjs = require('./chunk-ODNSWEMV.cjs');
6
- var chunkW57QS6F6_cjs = require('./chunk-W57QS6F6.cjs');
3
+ var chunkAP3Z4EAP_cjs = require('./chunk-AP3Z4EAP.cjs');
4
+ var chunkYL6ETQ5I_cjs = require('./chunk-YL6ETQ5I.cjs');
5
+ var chunkVBOO4F4D_cjs = require('./chunk-VBOO4F4D.cjs');
6
+ var chunkARQG4ZSD_cjs = require('./chunk-ARQG4ZSD.cjs');
7
7
  var chunk6BJ7XHRH_cjs = require('./chunk-6BJ7XHRH.cjs');
8
8
  var chunkMR7ZWBL6_cjs = require('./chunk-MR7ZWBL6.cjs');
9
9
  var chunkCYUP7QWT_cjs = require('./chunk-CYUP7QWT.cjs');
@@ -52,6 +52,8 @@ var Mastra = class {
52
52
  #serverCache;
53
53
  // Cache for stored agents to allow in-memory modifications (like model changes) to persist across requests
54
54
  #storedAgentsCache = /* @__PURE__ */ new Map();
55
+ // Editor instance for handling agent instantiation and configuration
56
+ #editor;
55
57
  get pubsub() {
56
58
  return this.#pubsub;
57
59
  }
@@ -64,12 +66,34 @@ var Mastra = class {
64
66
  * idGenerator: () => `custom-${Date.now()}`
65
67
  * });
66
68
  * const generator = mastra.getIdGenerator();
67
- * console.log(generator?.()); // "custom-1234567890"
69
+ * console.log(generator?.()); // \"custom-1234567890\"
68
70
  * ```
69
71
  */
70
72
  getIdGenerator() {
71
73
  return this.#idGenerator;
72
74
  }
75
+ /**
76
+ * Gets the currently configured editor instance.
77
+ * The editor is responsible for handling agent instantiation and configuration.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const mastra = new Mastra({
82
+ * editor: new MastraEditor({ logger })
83
+ * });
84
+ * const editor = mastra.getEditor();
85
+ * ```
86
+ */
87
+ getEditor() {
88
+ return this.#editor;
89
+ }
90
+ /**
91
+ * Gets the stored agents cache
92
+ * @internal
93
+ */
94
+ getStoredAgentCache() {
95
+ return this.#storedAgentsCache;
96
+ }
73
97
  /**
74
98
  * Generates a unique identifier using the configured generator or defaults to `crypto.randomUUID()`.
75
99
  *
@@ -160,10 +184,14 @@ var Mastra = class {
160
184
  */
161
185
  constructor(config) {
162
186
  this.#serverCache = new chunkQ2D7LERO_cjs.InMemoryServerCache();
187
+ this.#editor = config?.editor;
188
+ if (this.#editor && typeof this.#editor.registerWithMastra === "function") {
189
+ this.#editor.registerWithMastra(this);
190
+ }
163
191
  if (config?.pubsub) {
164
192
  this.#pubsub = config.pubsub;
165
193
  } else {
166
- this.#pubsub = new chunkW57QS6F6_cjs.EventEmitterPubSub();
194
+ this.#pubsub = new chunkARQG4ZSD_cjs.EventEmitterPubSub();
167
195
  }
168
196
  this.#events = {};
169
197
  for (const topic in config?.events ?? {}) {
@@ -173,7 +201,7 @@ var Mastra = class {
173
201
  this.#events[topic] = config?.events?.[topic] ?? [];
174
202
  }
175
203
  }
176
- const workflowEventProcessor = new chunkOAOMKZXU_cjs.WorkflowEventProcessor({ mastra: this });
204
+ const workflowEventProcessor = new chunkAP3Z4EAP_cjs.WorkflowEventProcessor({ mastra: this });
177
205
  const workflowEventCb = async (event, cb) => {
178
206
  try {
179
207
  await workflowEventProcessor.process(event, cb);
@@ -201,7 +229,7 @@ var Mastra = class {
201
229
  this.#idGenerator = config?.idGenerator;
202
230
  let storage = config?.storage;
203
231
  if (storage) {
204
- storage = chunkW57QS6F6_cjs.augmentWithInit(storage);
232
+ storage = chunkARQG4ZSD_cjs.augmentWithInit(storage);
205
233
  }
206
234
  if (config?.observability) {
207
235
  if (typeof config.observability.getDefaultInstance === "function") {
@@ -303,7 +331,7 @@ var Mastra = class {
303
331
  if (config?.server) {
304
332
  this.#server = config.server;
305
333
  }
306
- chunkMR7ZWBL6_cjs.registerHook("onScorerRun" /* ON_SCORER_RUN */, chunkODNSWEMV_cjs.createOnScorerHook(this));
334
+ chunkMR7ZWBL6_cjs.registerHook("onScorerRun" /* ON_SCORER_RUN */, chunkVBOO4F4D_cjs.createOnScorerHook(this));
307
335
  this.#observability.setMastraContext({ mastra: this });
308
336
  this.setLogger({ logger });
309
337
  }
@@ -421,323 +449,6 @@ var Mastra = class {
421
449
  listAgents() {
422
450
  return this.#agents;
423
451
  }
424
- async getStoredAgentById(id, options) {
425
- const storage = this.#storage;
426
- if (!storage) {
427
- const error = new chunk4U7ZLI36_cjs.MastraError({
428
- id: "MASTRA_GET_STORED_AGENT_STORAGE_NOT_CONFIGURED",
429
- domain: "MASTRA" /* MASTRA */,
430
- category: "USER" /* USER */,
431
- text: "Storage is not configured",
432
- details: { status: 400 }
433
- });
434
- this.#logger?.trackException(error);
435
- throw error;
436
- }
437
- const agentsStore = await storage.getStore("agents");
438
- if (!agentsStore) {
439
- const error = new chunk4U7ZLI36_cjs.MastraError({
440
- id: "MASTRA_GET_STORED_AGENT_NOT_SUPPORTED",
441
- domain: "MASTRA" /* MASTRA */,
442
- category: "USER" /* USER */,
443
- text: "Agents storage is not available",
444
- details: { status: 400 }
445
- });
446
- this.#logger?.trackException(error);
447
- throw error;
448
- }
449
- if (options?.versionId && options?.versionNumber !== void 0) {
450
- this.#logger?.warn(`Both versionId and versionNumber provided for agent "${id}". Using versionId.`);
451
- }
452
- if (options?.versionId) {
453
- const version = await agentsStore.getVersion(options.versionId);
454
- if (!version) {
455
- return null;
456
- }
457
- if (version.agentId !== id) {
458
- return null;
459
- }
460
- const {
461
- id: _versionId,
462
- agentId: _agentId,
463
- versionNumber: _versionNumber,
464
- changedFields: _changedFields,
465
- changeMessage: _changeMessage,
466
- createdAt: _createdAt,
467
- ...snapshotConfig
468
- } = version;
469
- const agentRecord = await agentsStore.getAgentById({ id });
470
- if (!agentRecord) {
471
- return null;
472
- }
473
- const resolvedAgent = { ...agentRecord, ...snapshotConfig };
474
- if (options?.raw) {
475
- return resolvedAgent;
476
- }
477
- return this.#createAgentFromStoredConfig(resolvedAgent);
478
- }
479
- if (options?.versionNumber !== void 0) {
480
- const version = await agentsStore.getVersionByNumber(id, options.versionNumber);
481
- if (!version) {
482
- return null;
483
- }
484
- const {
485
- id: _versionId,
486
- agentId: _agentId,
487
- versionNumber: _versionNumber,
488
- changedFields: _changedFields,
489
- changeMessage: _changeMessage,
490
- createdAt: _createdAt,
491
- ...snapshotConfig
492
- } = version;
493
- const agentRecord = await agentsStore.getAgentById({ id });
494
- if (!agentRecord) {
495
- return null;
496
- }
497
- const resolvedAgent = { ...agentRecord, ...snapshotConfig };
498
- if (options?.raw) {
499
- return resolvedAgent;
500
- }
501
- return this.#createAgentFromStoredConfig(resolvedAgent);
502
- }
503
- if (!options?.raw) {
504
- const cachedAgent = this.#storedAgentsCache.get(id);
505
- if (cachedAgent) {
506
- this.#logger?.debug(`[getStoredAgentById] Returning cached agent "${id}"`);
507
- return cachedAgent;
508
- }
509
- this.#logger?.debug(`[getStoredAgentById] Cache miss for agent "${id}", fetching from storage`);
510
- }
511
- const storedAgent = await agentsStore.getAgentByIdResolved({ id });
512
- if (!storedAgent) {
513
- return null;
514
- }
515
- if (options?.raw) {
516
- return storedAgent;
517
- }
518
- const agent = this.#createAgentFromStoredConfig(storedAgent);
519
- this.#storedAgentsCache.set(id, agent);
520
- return agent;
521
- }
522
- /**
523
- * Clears the cached stored agent instance, forcing a fresh load from storage on next access.
524
- * This should be called when an agent is updated via the Edit dialog to ensure
525
- * the cached instance is refreshed with the new configuration.
526
- *
527
- * @param id - The ID of the agent to clear from cache
528
- */
529
- clearStoredAgentCache(id) {
530
- this.#storedAgentsCache.delete(id);
531
- }
532
- async listStoredAgents(args) {
533
- const storage = this.#storage;
534
- if (!storage) {
535
- const error = new chunk4U7ZLI36_cjs.MastraError({
536
- id: "MASTRA_LIST_STORED_AGENTS_STORAGE_NOT_CONFIGURED",
537
- domain: "MASTRA" /* MASTRA */,
538
- category: "USER" /* USER */,
539
- text: "Storage is not configured",
540
- details: { status: 400 }
541
- });
542
- this.#logger?.trackException(error);
543
- throw error;
544
- }
545
- const agentsStore = await storage.getStore("agents");
546
- if (!agentsStore) {
547
- const error = new chunk4U7ZLI36_cjs.MastraError({
548
- id: "MASTRA_LIST_STORED_AGENTS_NOT_SUPPORTED",
549
- domain: "MASTRA" /* MASTRA */,
550
- category: "USER" /* USER */,
551
- text: "Agents storage is not available",
552
- details: { status: 400 }
553
- });
554
- this.#logger?.trackException(error);
555
- throw error;
556
- }
557
- const result = await agentsStore.listAgentsResolved({
558
- page: args?.page,
559
- perPage: args?.perPage,
560
- orderBy: args?.orderBy
561
- });
562
- if (args?.raw) {
563
- return result;
564
- }
565
- const agents = result.agents.map((storedAgent) => this.#createAgentFromStoredConfig(storedAgent));
566
- return {
567
- agents,
568
- total: result.total,
569
- page: result.page,
570
- perPage: result.perPage,
571
- hasMore: result.hasMore
572
- };
573
- }
574
- /**
575
- * Creates an Agent instance from a stored agent configuration.
576
- * @private
577
- */
578
- #createAgentFromStoredConfig(storedAgent) {
579
- const modelConfig = storedAgent.model;
580
- if (!modelConfig.provider || !modelConfig.name) {
581
- throw new chunk4U7ZLI36_cjs.MastraError({
582
- id: "MASTRA_STORED_AGENT_INVALID_MODEL",
583
- domain: "MASTRA" /* MASTRA */,
584
- category: "USER" /* USER */,
585
- text: `Stored agent "${storedAgent.id}" has invalid model configuration. Both provider and name are required.`,
586
- details: { agentId: storedAgent.id, model: JSON.stringify(storedAgent.model) }
587
- });
588
- }
589
- const model = `${modelConfig.provider}/${modelConfig.name}`;
590
- const tools = this.#resolveStoredTools(storedAgent.tools);
591
- const workflows = this.#resolveStoredWorkflows(storedAgent.workflows);
592
- const agents = this.#resolveStoredAgents(storedAgent.agents);
593
- const memory = this.#resolveStoredMemory(storedAgent.memory);
594
- const scorers = this.#resolveStoredScorers(storedAgent.scorers);
595
- const agent = new chunkW57QS6F6_cjs.Agent({
596
- id: storedAgent.id,
597
- name: storedAgent.name,
598
- description: storedAgent.description,
599
- instructions: storedAgent.instructions,
600
- model,
601
- tools,
602
- workflows,
603
- agents,
604
- memory,
605
- scorers,
606
- defaultOptions: storedAgent.defaultOptions
607
- });
608
- agent.__setLogger(this.#logger);
609
- agent.__registerMastra(this);
610
- agent.__registerPrimitives({
611
- logger: this.getLogger(),
612
- storage: this.getStorage(),
613
- agents: this.#agents,
614
- tts: this.#tts,
615
- vectors: this.#vectors
616
- });
617
- agent.source = "stored";
618
- return agent;
619
- }
620
- /**
621
- * Resolves tool references from stored configuration to actual tool instances.
622
- * @private
623
- */
624
- #resolveStoredTools(storedTools) {
625
- if (!storedTools || storedTools.length === 0) {
626
- return {};
627
- }
628
- const resolvedTools = {};
629
- for (const toolKey of storedTools) {
630
- try {
631
- const tool = this.getToolById(toolKey);
632
- resolvedTools[toolKey] = tool;
633
- } catch {
634
- this.#logger?.warn(`Tool "${toolKey}" referenced in stored agent but not registered in Mastra`);
635
- }
636
- }
637
- return resolvedTools;
638
- }
639
- /**
640
- * Resolves workflow references from stored configuration to actual workflow instances.
641
- * @private
642
- */
643
- #resolveStoredWorkflows(storedWorkflows) {
644
- if (!storedWorkflows || storedWorkflows.length === 0) {
645
- return {};
646
- }
647
- const resolvedWorkflows = {};
648
- for (const workflowKey of storedWorkflows) {
649
- try {
650
- const workflow = this.getWorkflow(workflowKey);
651
- resolvedWorkflows[workflowKey] = workflow;
652
- } catch {
653
- try {
654
- const workflow = this.getWorkflowById(workflowKey);
655
- resolvedWorkflows[workflowKey] = workflow;
656
- } catch {
657
- this.#logger?.warn(`Workflow "${workflowKey}" referenced in stored agent but not registered in Mastra`);
658
- }
659
- }
660
- }
661
- return resolvedWorkflows;
662
- }
663
- /**
664
- * Resolves agent references from stored configuration to actual agent instances.
665
- * @private
666
- */
667
- #resolveStoredAgents(storedAgents) {
668
- if (!storedAgents || storedAgents.length === 0) {
669
- return {};
670
- }
671
- const resolvedAgents = {};
672
- for (const agentKey of storedAgents) {
673
- try {
674
- const agent = this.getAgent(agentKey);
675
- resolvedAgents[agentKey] = agent;
676
- } catch {
677
- try {
678
- const agent = this.getAgentById(agentKey);
679
- resolvedAgents[agentKey] = agent;
680
- } catch {
681
- this.#logger?.warn(`Agent "${agentKey}" referenced in stored agent but not registered in Mastra`);
682
- }
683
- }
684
- }
685
- return resolvedAgents;
686
- }
687
- /**
688
- * Resolves memory reference from stored configuration to actual memory instance.
689
- * @private
690
- */
691
- #resolveStoredMemory(memoryConfig) {
692
- if (!memoryConfig) {
693
- return void 0;
694
- }
695
- const memoryKey = memoryConfig.key;
696
- if (!memoryKey) {
697
- this.#logger?.warn(`Stored agent memory config missing "key" field: ${JSON.stringify(memoryConfig)}`);
698
- return void 0;
699
- }
700
- try {
701
- return this.getMemory(memoryKey);
702
- } catch {
703
- try {
704
- return this.getMemoryById(memoryKey);
705
- } catch {
706
- this.#logger?.warn(`Memory "${memoryKey}" referenced in stored agent but not registered in Mastra`);
707
- }
708
- }
709
- return void 0;
710
- }
711
- /**
712
- * Resolves scorer references from stored configuration to actual scorer instances.
713
- * @private
714
- */
715
- #resolveStoredScorers(storedScorers) {
716
- if (!storedScorers || Object.keys(storedScorers).length === 0) {
717
- return void 0;
718
- }
719
- const resolvedScorers = {};
720
- for (const [scorerKey, scorerConfig] of Object.entries(storedScorers)) {
721
- try {
722
- const scorer = this.getScorer(scorerKey);
723
- resolvedScorers[scorerKey] = {
724
- scorer,
725
- sampling: scorerConfig.sampling
726
- };
727
- } catch {
728
- try {
729
- const scorer = this.getScorerById(scorerKey);
730
- resolvedScorers[scorerKey] = {
731
- scorer,
732
- sampling: scorerConfig.sampling
733
- };
734
- } catch {
735
- this.#logger?.warn(`Scorer "${scorerKey}" referenced in stored agent but not registered in Mastra`);
736
- }
737
- }
738
- }
739
- return Object.keys(resolvedScorers).length > 0 ? resolvedScorers : void 0;
740
- }
741
452
  /**
742
453
  * Adds a new agent to the Mastra instance.
743
454
  *
@@ -759,13 +470,13 @@ var Mastra = class {
759
470
  * mastra.addAgent(newAgent, 'customKey'); // Uses custom key
760
471
  * ```
761
472
  */
762
- addAgent(agent, key) {
473
+ addAgent(agent, key, options) {
763
474
  if (!agent) {
764
475
  throw createUndefinedPrimitiveError("agent", agent, key);
765
476
  }
766
477
  let mastraAgent;
767
- if (chunkMCI7M6AT_cjs.isToolLoopAgentLike(agent)) {
768
- mastraAgent = chunkMCI7M6AT_cjs.toolLoopAgentToMastraAgent(agent, { fallbackName: key });
478
+ if (chunkYL6ETQ5I_cjs.isToolLoopAgentLike(agent)) {
479
+ mastraAgent = chunkYL6ETQ5I_cjs.toolLoopAgentToMastraAgent(agent, { fallbackName: key });
769
480
  } else {
770
481
  mastraAgent = agent;
771
482
  }
@@ -785,6 +496,9 @@ var Mastra = class {
785
496
  tts: this.#tts,
786
497
  vectors: this.#vectors
787
498
  });
499
+ if (options?.source) {
500
+ mastraAgent.source = options.source;
501
+ }
788
502
  agents[agentKey] = mastraAgent;
789
503
  mastraAgent.getConfiguredProcessorWorkflows().then((processorWorkflows) => {
790
504
  for (const workflow of processorWorkflows) {
@@ -1900,7 +1614,7 @@ var Mastra = class {
1900
1614
  * ```
1901
1615
  */
1902
1616
  setStorage(storage) {
1903
- this.#storage = chunkW57QS6F6_cjs.augmentWithInit(storage);
1617
+ this.#storage = chunkARQG4ZSD_cjs.augmentWithInit(storage);
1904
1618
  }
1905
1619
  setLogger({ logger }) {
1906
1620
  this.#logger = logger;
@@ -1933,6 +1647,9 @@ var Mastra = class {
1933
1647
  if (this.#serverAdapter) {
1934
1648
  this.#serverAdapter.__setLogger(this.#logger);
1935
1649
  }
1650
+ if (this.#workspace) {
1651
+ this.#workspace.__setLogger(this.#logger);
1652
+ }
1936
1653
  this.#observability.setLogger({ logger: this.#logger });
1937
1654
  }
1938
1655
  /**
@@ -2562,7 +2279,7 @@ var Mastra = class {
2562
2279
  if (process.env.MASTRA_DEV !== "true" && process.env.MASTRA_DEV !== "1") {
2563
2280
  return;
2564
2281
  }
2565
- import('./provider-registry-ML2VWWLB.cjs').then(async ({ GatewayRegistry }) => {
2282
+ import('./provider-registry-NR7FXV2Q.cjs').then(async ({ GatewayRegistry }) => {
2566
2283
  const registry = GatewayRegistry.getInstance();
2567
2284
  const customGateways = Object.values(this.#gateways || {});
2568
2285
  registry.registerCustomGateways(customGateways);
@@ -2616,5 +2333,5 @@ var Mastra = class {
2616
2333
  };
2617
2334
 
2618
2335
  exports.Mastra = Mastra;
2619
- //# sourceMappingURL=chunk-XVHK5IAO.cjs.map
2620
- //# sourceMappingURL=chunk-XVHK5IAO.cjs.map
2336
+ //# sourceMappingURL=chunk-3LRUJTH3.cjs.map
2337
+ //# sourceMappingURL=chunk-3LRUJTH3.cjs.map