@mastra/core 0.9.4 → 0.10.0-alpha.1

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 (168) hide show
  1. package/README.md +3 -2
  2. package/dist/agent/index.cjs +2 -2
  3. package/dist/agent/index.d.cts +13 -14
  4. package/dist/agent/index.d.ts +13 -14
  5. package/dist/agent/index.js +1 -1
  6. package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
  7. package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
  8. package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
  9. package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
  10. package/dist/base.cjs +2 -2
  11. package/dist/base.d.cts +2 -3
  12. package/dist/base.d.ts +2 -3
  13. package/dist/base.js +1 -1
  14. package/dist/bundler/index.cjs +2 -2
  15. package/dist/bundler/index.d.cts +2 -3
  16. package/dist/bundler/index.d.ts +2 -3
  17. package/dist/bundler/index.js +1 -1
  18. package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
  19. package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
  20. package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
  21. package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
  22. package/dist/chunk-5HULBQ2W.cjs +38 -0
  23. package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
  24. package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
  25. package/dist/chunk-75Z4BZEE.js +36 -0
  26. package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
  27. package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
  28. package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
  29. package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
  30. package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
  31. package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
  32. package/dist/chunk-GQ2XQ4UN.js +321 -0
  33. package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
  34. package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
  35. package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
  36. package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
  37. package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
  38. package/dist/chunk-NMDM4IZN.cjs +78 -0
  39. package/dist/chunk-OBEALYTK.js +74 -0
  40. package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
  41. package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
  42. package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
  43. package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
  44. package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
  45. package/dist/chunk-SWW4EBUZ.cjs +96 -0
  46. package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
  47. package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
  48. package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
  49. package/dist/chunk-VHLL4AZK.js +90 -0
  50. package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
  51. package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
  52. package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
  53. package/dist/chunk-ZZDAC5KD.cjs +325 -0
  54. package/dist/deployer/index.cjs +2 -2
  55. package/dist/deployer/index.d.cts +2 -3
  56. package/dist/deployer/index.d.ts +2 -3
  57. package/dist/deployer/index.js +1 -1
  58. package/dist/eval/index.d.cts +13 -14
  59. package/dist/eval/index.d.ts +13 -14
  60. package/dist/hooks/index.d.cts +1 -1
  61. package/dist/hooks/index.d.ts +1 -1
  62. package/dist/index.cjs +88 -159
  63. package/dist/index.d.cts +17 -25
  64. package/dist/index.d.ts +17 -25
  65. package/dist/index.js +18 -25
  66. package/dist/integration/index.cjs +3 -3
  67. package/dist/integration/index.d.cts +12 -13
  68. package/dist/integration/index.d.ts +12 -13
  69. package/dist/integration/index.js +1 -1
  70. package/dist/llm/index.d.cts +13 -14
  71. package/dist/llm/index.d.ts +13 -14
  72. package/dist/logger/index.cjs +18 -17
  73. package/dist/logger/index.d.cts +42 -2
  74. package/dist/logger/index.d.ts +42 -2
  75. package/dist/logger/index.js +2 -1
  76. package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
  77. package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
  78. package/dist/mastra/index.cjs +2 -2
  79. package/dist/mastra/index.d.cts +11 -12
  80. package/dist/mastra/index.d.ts +11 -12
  81. package/dist/mastra/index.js +1 -1
  82. package/dist/mcp/index.cjs +75 -17
  83. package/dist/mcp/index.d.cts +14 -15
  84. package/dist/mcp/index.d.ts +14 -15
  85. package/dist/mcp/index.js +69 -15
  86. package/dist/memory/index.cjs +4 -4
  87. package/dist/memory/index.d.cts +12 -13
  88. package/dist/memory/index.d.ts +12 -13
  89. package/dist/memory/index.js +1 -1
  90. package/dist/network/index.cjs +8 -8
  91. package/dist/network/index.d.cts +12 -13
  92. package/dist/network/index.d.ts +12 -13
  93. package/dist/network/index.js +5 -5
  94. package/dist/relevance/index.cjs +4 -4
  95. package/dist/relevance/index.d.cts +15 -16
  96. package/dist/relevance/index.d.ts +15 -16
  97. package/dist/relevance/index.js +1 -1
  98. package/dist/server/index.cjs +4 -0
  99. package/dist/server/index.d.cts +13 -12
  100. package/dist/server/index.d.ts +13 -12
  101. package/dist/server/index.js +4 -1
  102. package/dist/storage/index.cjs +184 -3
  103. package/dist/storage/index.d.cts +83 -13
  104. package/dist/storage/index.d.ts +83 -13
  105. package/dist/storage/index.js +186 -1
  106. package/dist/telemetry/index.d.cts +14 -15
  107. package/dist/telemetry/index.d.ts +14 -15
  108. package/dist/telemetry/otel-vendor.cjs +2 -2
  109. package/dist/telemetry/otel-vendor.d.cts +1 -1
  110. package/dist/telemetry/otel-vendor.d.ts +1 -1
  111. package/dist/telemetry/otel-vendor.js +1 -1
  112. package/dist/tools/index.cjs +4 -4
  113. package/dist/tools/index.d.cts +12 -13
  114. package/dist/tools/index.d.ts +12 -13
  115. package/dist/tools/index.js +1 -1
  116. package/dist/tts/index.cjs +2 -2
  117. package/dist/tts/index.d.cts +2 -3
  118. package/dist/tts/index.d.ts +2 -3
  119. package/dist/tts/index.js +1 -1
  120. package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
  121. package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
  122. package/dist/utils.cjs +28 -12
  123. package/dist/utils.d.cts +59 -16
  124. package/dist/utils.d.ts +59 -16
  125. package/dist/utils.js +1 -1
  126. package/dist/vector/filter/index.cjs +189 -7
  127. package/dist/vector/filter/index.js +190 -1
  128. package/dist/vector/index.cjs +2 -2
  129. package/dist/vector/index.d.cts +28 -20
  130. package/dist/vector/index.d.ts +28 -20
  131. package/dist/vector/index.js +1 -1
  132. package/dist/voice/index.cjs +4 -4
  133. package/dist/voice/index.d.cts +12 -13
  134. package/dist/voice/index.d.ts +12 -13
  135. package/dist/voice/index.js +1 -1
  136. package/dist/workflows/index.cjs +17 -69
  137. package/dist/workflows/index.d.cts +197 -77
  138. package/dist/workflows/index.d.ts +197 -77
  139. package/dist/workflows/index.js +1 -1
  140. package/dist/workflows/legacy/index.cjs +90 -0
  141. package/dist/workflows/legacy/index.d.cts +87 -0
  142. package/dist/workflows/legacy/index.d.ts +87 -0
  143. package/dist/workflows/legacy/index.js +1 -0
  144. package/package.json +19 -40
  145. package/workflows/legacy.d.ts +1 -0
  146. package/dist/chunk-4WABQORE.js +0 -781
  147. package/dist/chunk-CIEPFV6B.js +0 -658
  148. package/dist/chunk-CMPPXW4U.js +0 -154
  149. package/dist/chunk-CTKNWYK2.js +0 -131
  150. package/dist/chunk-LGERQTJM.js +0 -190
  151. package/dist/chunk-O44MSFMZ.cjs +0 -168
  152. package/dist/chunk-QDAMIZY3.cjs +0 -783
  153. package/dist/chunk-QHDPLMHB.cjs +0 -667
  154. package/dist/chunk-RAQBTCIR.cjs +0 -134
  155. package/dist/chunk-YK3XJ52U.cjs +0 -192
  156. package/dist/storage/libsql/index.cjs +0 -581
  157. package/dist/storage/libsql/index.d.cts +0 -104
  158. package/dist/storage/libsql/index.d.ts +0 -104
  159. package/dist/storage/libsql/index.js +0 -578
  160. package/dist/vector/libsql/index.cjs +0 -14
  161. package/dist/vector/libsql/index.d.cts +0 -82
  162. package/dist/vector/libsql/index.d.ts +0 -82
  163. package/dist/vector/libsql/index.js +0 -1
  164. package/dist/workflows/vNext/index.d.cts +0 -209
  165. package/dist/workflows/vNext/index.d.ts +0 -209
  166. package/storage/libsql.d.ts +0 -1
  167. package/vector/libsql.d.ts +0 -1
  168. package/workflows/vNext.d.ts +0 -1
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkRAQBTCIR_cjs = require('./chunk-RAQBTCIR.cjs');
3
+ var chunk5HULBQ2W_cjs = require('./chunk-5HULBQ2W.cjs');
4
4
  var chunkUVRGQEMD_cjs = require('./chunk-UVRGQEMD.cjs');
5
- var chunkO44MSFMZ_cjs = require('./chunk-O44MSFMZ.cjs');
5
+ var chunkNMDM4IZN_cjs = require('./chunk-NMDM4IZN.cjs');
6
+ var chunkSWW4EBUZ_cjs = require('./chunk-SWW4EBUZ.cjs');
6
7
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
7
8
 
8
9
  // src/mastra/index.ts
@@ -15,8 +16,8 @@ exports.Mastra = class Mastra {
15
16
  #vectors;
16
17
  #agents;
17
18
  #logger;
19
+ #legacy_workflows;
18
20
  #workflows;
19
- #vnext_workflows;
20
21
  #tts;
21
22
  #deployer;
22
23
  #serverMiddleware = [];
@@ -53,32 +54,27 @@ exports.Mastra = class Mastra {
53
54
  }
54
55
  let logger;
55
56
  if (config?.logger === false) {
56
- logger = chunkO44MSFMZ_cjs.noopLogger;
57
+ logger = chunkNMDM4IZN_cjs.noopLogger;
57
58
  } else {
58
59
  if (config?.logger) {
59
60
  logger = config.logger;
60
61
  } else {
61
- const levleOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? chunkO44MSFMZ_cjs.LogLevel.WARN : chunkO44MSFMZ_cjs.LogLevel.INFO;
62
- logger = chunkO44MSFMZ_cjs.createLogger({
62
+ const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? chunkSWW4EBUZ_cjs.LogLevel.WARN : chunkSWW4EBUZ_cjs.LogLevel.INFO;
63
+ logger = new chunkSWW4EBUZ_cjs.ConsoleLogger({
63
64
  name: "Mastra",
64
- level: levleOnEnv
65
+ level: levelOnEnv
65
66
  });
66
67
  }
67
68
  }
68
69
  this.#logger = logger;
69
70
  let storage = config?.storage;
70
- if (!storage) {
71
- storage = new chunkRAQBTCIR_cjs.DefaultProxyStorage({
72
- config: {
73
- url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
74
- }
75
- });
71
+ if (storage) {
72
+ storage = chunk5HULBQ2W_cjs.augmentWithInit(storage);
76
73
  }
77
- storage = chunkRAQBTCIR_cjs.augmentWithInit(storage);
78
74
  this.#telemetry = chunkUVRGQEMD_cjs.Telemetry.init(config?.telemetry);
79
- if (this.#telemetry) {
75
+ if (this.#telemetry && storage) {
80
76
  this.#storage = this.#telemetry.traceClass(storage, {
81
- excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert"]
77
+ excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
82
78
  });
83
79
  this.#storage.__setTelemetry(this.#telemetry);
84
80
  } else {
@@ -106,24 +102,16 @@ exports.Mastra = class Mastra {
106
102
  }
107
103
  if (config?.mcpServers) {
108
104
  this.#mcpServers = config.mcpServers;
109
- Object.values(this.#mcpServers).forEach(server => {
105
+ Object.entries(this.#mcpServers).forEach(([key, server]) => {
106
+ server.setId(key);
110
107
  if (this.#telemetry) {
111
108
  server.__setTelemetry(this.#telemetry);
112
109
  }
113
110
  server.__registerMastra(this);
114
111
  });
115
112
  }
116
- if (config?.memory) {
117
- this.#memory = config.memory;
118
- if (this.#telemetry) {
119
- this.#memory = this.#telemetry.traceClass(config.memory, {
120
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
121
- });
122
- this.#memory.__setTelemetry(this.#telemetry);
123
- }
124
- }
125
113
  if (config && `memory` in config) {
126
- this.#logger.warn(`
114
+ throw new Error(`
127
115
  Memory should be added to Agents, not to Mastra.
128
116
 
129
117
  Instead of:
@@ -131,8 +119,6 @@ Instead of:
131
119
 
132
120
  do:
133
121
  new Agent({ memory: new Memory() })
134
-
135
- This is a warning for now, but will throw an error in the future
136
122
  `);
137
123
  }
138
124
  if (config?.tts) {
@@ -175,9 +161,9 @@ This is a warning for now, but will throw an error in the future
175
161
  this.#networks[key] = network;
176
162
  });
177
163
  }
178
- this.#workflows = {};
179
- if (config?.workflows) {
180
- Object.entries(config.workflows).forEach(([key, workflow]) => {
164
+ this.#legacy_workflows = {};
165
+ if (config?.legacy_workflows) {
166
+ Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
181
167
  workflow.__registerMastra(this);
182
168
  workflow.__registerPrimitives({
183
169
  logger: this.getLogger(),
@@ -188,18 +174,18 @@ This is a warning for now, but will throw an error in the future
188
174
  tts: this.#tts,
189
175
  vectors: this.#vectors
190
176
  });
191
- this.#workflows[key] = workflow;
177
+ this.#legacy_workflows[key] = workflow;
192
178
  const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
193
179
  if (workflowSteps.length > 0) {
194
180
  workflowSteps.forEach(step => {
195
- this.#workflows[step.workflowId] = step.workflow;
181
+ this.#legacy_workflows[step.workflowId] = step.workflow;
196
182
  });
197
183
  }
198
184
  });
199
185
  }
200
- this.#vnext_workflows = {};
201
- if (config?.vnext_workflows) {
202
- Object.entries(config.vnext_workflows).forEach(([key, workflow]) => {
186
+ this.#workflows = {};
187
+ if (config?.workflows) {
188
+ Object.entries(config.workflows).forEach(([key, workflow]) => {
203
189
  workflow.__registerMastra(this);
204
190
  workflow.__registerPrimitives({
205
191
  logger: this.getLogger(),
@@ -210,7 +196,7 @@ This is a warning for now, but will throw an error in the future
210
196
  tts: this.#tts,
211
197
  vectors: this.#vectors
212
198
  });
213
- this.#vnext_workflows[key] = workflow;
199
+ this.#workflows[key] = workflow;
214
200
  });
215
201
  }
216
202
  if (config?.server) {
@@ -243,10 +229,10 @@ This is a warning for now, but will throw an error in the future
243
229
  getDeployer() {
244
230
  return this.#deployer;
245
231
  }
246
- getWorkflow(id, {
232
+ legacy_getWorkflow(id, {
247
233
  serialized
248
234
  } = {}) {
249
- const workflow = this.#workflows?.[id];
235
+ const workflow = this.#legacy_workflows?.[id];
250
236
  if (!workflow) {
251
237
  throw new Error(`Workflow with ID ${String(id)} not found`);
252
238
  }
@@ -257,10 +243,10 @@ This is a warning for now, but will throw an error in the future
257
243
  }
258
244
  return workflow;
259
245
  }
260
- vnext_getWorkflow(id, {
246
+ getWorkflow(id, {
261
247
  serialized
262
248
  } = {}) {
263
- const workflow = this.#vnext_workflows?.[id];
249
+ const workflow = this.#workflows?.[id];
264
250
  if (!workflow) {
265
251
  throw new Error(`Workflow with ID ${String(id)} not found`);
266
252
  }
@@ -271,9 +257,9 @@ This is a warning for now, but will throw an error in the future
271
257
  }
272
258
  return workflow;
273
259
  }
274
- getWorkflows(props = {}) {
260
+ legacy_getWorkflows(props = {}) {
275
261
  if (props.serialized) {
276
- return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
262
+ return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
277
263
  return {
278
264
  ...acc,
279
265
  [k]: {
@@ -282,11 +268,11 @@ This is a warning for now, but will throw an error in the future
282
268
  };
283
269
  }, {});
284
270
  }
285
- return this.#workflows;
271
+ return this.#legacy_workflows;
286
272
  }
287
- vnext_getWorkflows(props = {}) {
273
+ getWorkflows(props = {}) {
288
274
  if (props.serialized) {
289
- return Object.entries(this.#vnext_workflows).reduce((acc, [k, v]) => {
275
+ return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
290
276
  return {
291
277
  ...acc,
292
278
  [k]: {
@@ -295,20 +281,10 @@ This is a warning for now, but will throw an error in the future
295
281
  };
296
282
  }, {});
297
283
  }
298
- return this.#vnext_workflows;
284
+ return this.#workflows;
299
285
  }
300
286
  setStorage(storage) {
301
- if (storage instanceof chunkRAQBTCIR_cjs.DefaultProxyStorage) {
302
- this.#logger.warn(`Importing "DefaultStorage" from '@mastra/core/storage/libsql' is deprecated.
303
-
304
- Instead of:
305
- import { DefaultStorage } from '@mastra/core/storage/libsql';
306
-
307
- Do:
308
- import { LibSQLStore } from '@mastra/libsql';
309
- `);
310
- }
311
- this.#storage = chunkRAQBTCIR_cjs.augmentWithInit(storage);
287
+ this.#storage = chunk5HULBQ2W_cjs.augmentWithInit(storage);
312
288
  }
313
289
  setLogger({
314
290
  logger
@@ -458,19 +434,58 @@ Do:
458
434
  return await this.#logger.getLogs(transportId);
459
435
  }
460
436
  /**
461
- * Get a specific MCP server by ID
462
- * @param serverId - The ID of the MCP server to retrieve
463
- * @returns The MCP server with the specified ID, or undefined if not found
437
+ * Get all registered MCP server instances.
438
+ * @returns A record of MCP server ID to MCPServerBase instance, or undefined if none are registered.
464
439
  */
465
- getMCPServer(serverId) {
466
- return this.#mcpServers?.[serverId];
440
+ getMCPServers() {
441
+ return this.#mcpServers;
467
442
  }
468
443
  /**
469
- * Get all registered MCP servers as a Record, with keys being their IDs.
470
- * @returns Record of MCP server IDs to MCPServerBase instances, or undefined if none.
444
+ * Get a specific MCP server instance.
445
+ * If a version is provided, it attempts to find the server with that exact logical ID and version.
446
+ * If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
447
+ * The logical ID should match the `id` property of the MCPServer instance (typically set via MCPServerConfig.id).
448
+ * @param serverId - The logical ID of the MCP server to retrieve.
449
+ * @param version - Optional specific version of the MCP server to retrieve.
450
+ * @returns The MCP server instance, or undefined if not found or if the specific version is not found.
471
451
  */
472
- getMCPServers() {
473
- return this.#mcpServers;
452
+ getMCPServer(serverId, version) {
453
+ if (!this.#mcpServers) {
454
+ return void 0;
455
+ }
456
+ const allRegisteredServers = Object.values(this.#mcpServers || {});
457
+ const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
458
+ if (matchingLogicalIdServers.length === 0) {
459
+ this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
460
+ return void 0;
461
+ }
462
+ if (version) {
463
+ const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
464
+ if (!specificVersionServer) {
465
+ this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
466
+ }
467
+ return specificVersionServer;
468
+ } else {
469
+ if (matchingLogicalIdServers.length === 1) {
470
+ return matchingLogicalIdServers[0];
471
+ }
472
+ matchingLogicalIdServers.sort((a, b) => {
473
+ const dateAVal = a.releaseDate && typeof a.releaseDate === "string" ? new Date(a.releaseDate).getTime() : NaN;
474
+ const dateBVal = b.releaseDate && typeof b.releaseDate === "string" ? new Date(b.releaseDate).getTime() : NaN;
475
+ if (isNaN(dateAVal) && isNaN(dateBVal)) return 0;
476
+ if (isNaN(dateAVal)) return 1;
477
+ if (isNaN(dateBVal)) return -1;
478
+ return dateBVal - dateAVal;
479
+ });
480
+ if (matchingLogicalIdServers.length > 0) {
481
+ const latestServer = matchingLogicalIdServers[0];
482
+ if (latestServer && latestServer.releaseDate && typeof latestServer.releaseDate === "string" && !isNaN(new Date(latestServer.releaseDate).getTime())) {
483
+ return latestServer;
484
+ }
485
+ }
486
+ this.#logger?.warn(`Could not determine the latest server for logical ID '${serverId}' due to invalid or missing release dates, or no servers left after filtering.`);
487
+ return void 0;
488
+ }
474
489
  }
475
490
  };
476
491
  exports.Mastra = /*@__PURE__*/(_ => {
@@ -0,0 +1,36 @@
1
+ // src/storage/storageWithInit.ts
2
+ var isAugmentedSymbol = Symbol("isAugmented");
3
+ function augmentWithInit(storage) {
4
+ let hasInitialized = null;
5
+ const ensureInit = async () => {
6
+ if (!hasInitialized) {
7
+ hasInitialized = storage.init();
8
+ }
9
+ await hasInitialized;
10
+ };
11
+ if (storage[isAugmentedSymbol]) {
12
+ return storage;
13
+ }
14
+ const proxy = new Proxy(storage, {
15
+ get(target, prop) {
16
+ const value = target[prop];
17
+ if (typeof value === "function" && prop !== "init") {
18
+ return async (...args) => {
19
+ await ensureInit();
20
+ return Reflect.apply(value, target, args);
21
+ };
22
+ }
23
+ return Reflect.get(target, prop);
24
+ }
25
+ });
26
+ Object.defineProperty(proxy, isAugmentedSymbol, {
27
+ value: true,
28
+ enumerable: false,
29
+ // Won't show up in Object.keys() or for...in loops
30
+ configurable: true
31
+ // Allows the property to be deleted or modified later if needed
32
+ });
33
+ return proxy;
34
+ }
35
+
36
+ export { augmentWithInit };