@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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var chunkYEULQPUY_cjs = require('./chunk-YEULQPUY.cjs');
3
4
  var chunkLABUWBKX_cjs = require('./chunk-LABUWBKX.cjs');
4
- var chunkEG74VBSP_cjs = require('./chunk-EG74VBSP.cjs');
5
5
  var crypto = require('crypto');
6
6
  var ai = require('ai');
7
7
  var jsonSchemaToZod = require('json-schema-to-zod');
@@ -43,7 +43,17 @@ var ALL_NUMBER_CHECKS = [
43
43
  ];
44
44
  var ALL_ARRAY_CHECKS = ["min", "max", "length"];
45
45
  var UNSUPPORTED_ZOD_TYPES = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
46
- var ToolCompatibility = class extends chunkEG74VBSP_cjs.MastraBase {
46
+ var SUPPORTED_ZOD_TYPES = [
47
+ "ZodObject",
48
+ "ZodArray",
49
+ "ZodUnion",
50
+ "ZodString",
51
+ "ZodNumber",
52
+ "ZodDate",
53
+ "ZodAny",
54
+ "ZodDefault"
55
+ ];
56
+ var ToolCompatibility = class extends chunkYEULQPUY_cjs.MastraBase {
47
57
  model;
48
58
  constructor(model) {
49
59
  super({ name: "SchemaCompatibility" });
@@ -276,6 +286,13 @@ var ToolCompatibility = class extends chunkEG74VBSP_cjs.MastraBase {
276
286
  }
277
287
  return result;
278
288
  }
289
+ defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
290
+ if (handleTypes.includes(value._def.innerType._def.typeName)) {
291
+ return this.processZodType(value._def.innerType).optional();
292
+ } else {
293
+ return value;
294
+ }
295
+ }
279
296
  process(tool) {
280
297
  if (isVercelTool(tool)) {
281
298
  return {
@@ -305,6 +322,11 @@ var AnthropicToolCompat = class extends ToolCompatibility {
305
322
  }
306
323
  processZodType(value) {
307
324
  switch (value._def.typeName) {
325
+ case "ZodOptional":
326
+ const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined"];
327
+ if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
328
+ if (this.getModel().modelId.includes("claude-3.7")) handleTypes.push("ZodTuple");
329
+ return this.defaultZodOptionalHandler(value, handleTypes);
308
330
  case "ZodObject": {
309
331
  return this.defaultZodObjectHandler(value);
310
332
  }
@@ -346,6 +368,8 @@ var DeepSeekToolCompat = class extends ToolCompatibility {
346
368
  }
347
369
  processZodType(value) {
348
370
  switch (value._def.typeName) {
371
+ case "ZodOptional":
372
+ return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
349
373
  case "ZodObject": {
350
374
  return this.defaultZodObjectHandler(value);
351
375
  }
@@ -377,6 +401,15 @@ var GoogleToolCompat = class extends ToolCompatibility {
377
401
  }
378
402
  processZodType(value) {
379
403
  switch (value._def.typeName) {
404
+ case "ZodOptional":
405
+ return this.defaultZodOptionalHandler(value, [
406
+ "ZodObject",
407
+ "ZodArray",
408
+ "ZodUnion",
409
+ "ZodString",
410
+ "ZodNumber",
411
+ ...UNSUPPORTED_ZOD_TYPES
412
+ ]);
380
413
  case "ZodObject": {
381
414
  return this.defaultZodObjectHandler(value);
382
415
  }
@@ -413,6 +446,8 @@ var MetaToolCompat = class extends ToolCompatibility {
413
446
  }
414
447
  processZodType(value) {
415
448
  switch (value._def.typeName) {
449
+ case "ZodOptional":
450
+ return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
416
451
  case "ZodObject": {
417
452
  return this.defaultZodObjectHandler(value);
418
453
  }
@@ -450,6 +485,16 @@ var OpenAIToolCompat = class extends ToolCompatibility {
450
485
  }
451
486
  processZodType(value) {
452
487
  switch (value._def.typeName) {
488
+ case "ZodOptional":
489
+ return this.defaultZodOptionalHandler(value, [
490
+ "ZodObject",
491
+ "ZodArray",
492
+ "ZodUnion",
493
+ "ZodString",
494
+ "ZodNever",
495
+ "ZodUndefined",
496
+ "ZodTuple"
497
+ ]);
453
498
  case "ZodObject": {
454
499
  return this.defaultZodObjectHandler(value);
455
500
  }
@@ -472,8 +517,6 @@ var OpenAIToolCompat = class extends ToolCompatibility {
472
517
  }
473
518
  }
474
519
  };
475
-
476
- // src/tools/tool-compatibility/provider-compats/openai-reasoning.ts
477
520
  var OpenAIReasoningToolCompat = class extends ToolCompatibility {
478
521
  constructor(model) {
479
522
  super(model);
@@ -493,7 +536,8 @@ var OpenAIReasoningToolCompat = class extends ToolCompatibility {
493
536
  processZodType(value) {
494
537
  switch (value._def.typeName) {
495
538
  case "ZodOptional":
496
- return value.unwrap().nullable();
539
+ const innerZodType = this.processZodType(value._def.innerType);
540
+ return innerZodType.nullable();
497
541
  case "ZodObject": {
498
542
  return this.defaultZodObjectHandler(value);
499
543
  }
@@ -527,6 +571,12 @@ var OpenAIReasoningToolCompat = class extends ToolCompatibility {
527
571
  case "ZodDate": {
528
572
  return this.defaultZodDateHandler(value);
529
573
  }
574
+ case "ZodAny": {
575
+ return zod.z.string().describe(
576
+ (value.description ?? "") + `
577
+ Argument was an "any" type, but you (the LLM) do not support "any", so it was cast to a "string" type`
578
+ );
579
+ }
530
580
  default:
531
581
  return this.defaultUnsupportedZodTypeHandler(value);
532
582
  }
@@ -555,8 +605,7 @@ function convertVercelToolParameters(tool) {
555
605
  } else {
556
606
  const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
557
607
  try {
558
- const rawShape = zodFromJsonSchema.jsonSchemaObjectToZodRawShape(jsonSchemaToConvert);
559
- return zod.z.object(rawShape);
608
+ return zodFromJsonSchema.convertJsonSchemaToZod(jsonSchemaToConvert);
560
609
  } catch (e) {
561
610
  const errorMessage = `[CoreToolBuilder] Failed to convert Vercel tool JSON schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
562
611
  console.error(errorMessage, e);
@@ -571,8 +620,7 @@ function convertInputSchema(tool) {
571
620
  return schema;
572
621
  } else {
573
622
  try {
574
- const rawShape = zodFromJsonSchema.jsonSchemaObjectToZodRawShape(schema);
575
- return zod.z.object(rawShape);
623
+ return zodFromJsonSchema.convertJsonSchemaToZod(schema);
576
624
  } catch (e) {
577
625
  const errorMessage = `[CoreToolBuilder] Failed to convert tool input JSON schema to Zod. Original schema: ${JSON.stringify(schema)}`;
578
626
  console.error(errorMessage, e);
@@ -581,7 +629,7 @@ ${e.stack}` : "\nUnknown error object"));
581
629
  }
582
630
  }
583
631
  }
584
- var CoreToolBuilder = class extends chunkEG74VBSP_cjs.MastraBase {
632
+ var CoreToolBuilder = class extends chunkYEULQPUY_cjs.MastraBase {
585
633
  originalTool;
586
634
  options;
587
635
  logType;
@@ -951,6 +999,25 @@ ${JSON.stringify(message, null, 2)}
951
999
  );
952
1000
  }).flat();
953
1001
  }
1002
+ var SQL_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
1003
+ function parseSqlIdentifier(name, kind = "identifier") {
1004
+ if (!SQL_IDENTIFIER_PATTERN.test(name) || name.length > 63) {
1005
+ throw new Error(
1006
+ `Invalid ${kind}: ${name}. Must start with a letter or underscore, contain only letters, numbers, or underscores, and be at most 63 characters long.`
1007
+ );
1008
+ }
1009
+ return name;
1010
+ }
1011
+ function parseFieldKey(key) {
1012
+ if (!key) throw new Error("Field key cannot be empty");
1013
+ const segments = key.split(".");
1014
+ for (const segment of segments) {
1015
+ if (!SQL_IDENTIFIER_PATTERN.test(segment) || segment.length > 63) {
1016
+ throw new Error(`Invalid field key segment: ${segment} in ${key}`);
1017
+ }
1018
+ }
1019
+ return key;
1020
+ }
954
1021
 
955
1022
  exports.Tool = Tool;
956
1023
  exports.checkEvalStorageFields = checkEvalStorageFields;
@@ -960,8 +1027,12 @@ exports.deepMerge = deepMerge;
960
1027
  exports.delay = delay;
961
1028
  exports.ensureAllMessagesAreCoreMessages = ensureAllMessagesAreCoreMessages;
962
1029
  exports.ensureToolProperties = ensureToolProperties;
1030
+ exports.isCoreMessage = isCoreMessage;
1031
+ exports.isUiMessage = isUiMessage;
963
1032
  exports.isVercelTool = isVercelTool;
964
1033
  exports.isZodType = isZodType;
965
1034
  exports.makeCoreTool = makeCoreTool;
966
1035
  exports.maskStreamTags = maskStreamTags;
1036
+ exports.parseFieldKey = parseFieldKey;
1037
+ exports.parseSqlIdentifier = parseSqlIdentifier;
967
1038
  exports.resolveSerializedZodOutput = resolveSerializedZodOutput;
@@ -0,0 +1,90 @@
1
+ // src/logger/constants.ts
2
+ var RegisteredLogger = {
3
+ AGENT: "AGENT",
4
+ NETWORK: "NETWORK",
5
+ WORKFLOW: "WORKFLOW",
6
+ LLM: "LLM",
7
+ TTS: "TTS",
8
+ VOICE: "VOICE",
9
+ VECTOR: "VECTOR",
10
+ BUNDLER: "BUNDLER",
11
+ DEPLOYER: "DEPLOYER",
12
+ MEMORY: "MEMORY",
13
+ STORAGE: "STORAGE",
14
+ EMBEDDINGS: "EMBEDDINGS",
15
+ MCP_SERVER: "MCP_SERVER"
16
+ };
17
+ var LogLevel = {
18
+ DEBUG: "debug",
19
+ INFO: "info",
20
+ WARN: "warn",
21
+ ERROR: "error",
22
+ NONE: "silent"
23
+ };
24
+
25
+ // src/logger/logger.ts
26
+ var MastraLogger = class {
27
+ name;
28
+ level;
29
+ transports;
30
+ constructor(options = {}) {
31
+ this.name = options.name || "Mastra";
32
+ this.level = options.level || LogLevel.ERROR;
33
+ this.transports = new Map(Object.entries(options.transports || {}));
34
+ }
35
+ getTransports() {
36
+ return this.transports;
37
+ }
38
+ async getLogs(transportId) {
39
+ if (!transportId || !this.transports.has(transportId)) {
40
+ return [];
41
+ }
42
+ return this.transports.get(transportId).getLogs() ?? [];
43
+ }
44
+ async getLogsByRunId({ transportId, runId }) {
45
+ if (!transportId || !this.transports.has(transportId) || !runId) {
46
+ return [];
47
+ }
48
+ return this.transports.get(transportId).getLogsByRunId({ runId }) ?? [];
49
+ }
50
+ };
51
+
52
+ // src/logger/default-logger.ts
53
+ var createLogger = (options) => {
54
+ const logger = new ConsoleLogger(options);
55
+ logger.warn(`createLogger is deprecated. Please use "new ConsoleLogger()" from "@mastra/core/logger" instead.`);
56
+ return logger;
57
+ };
58
+ var ConsoleLogger = class extends MastraLogger {
59
+ constructor(options = {}) {
60
+ super(options);
61
+ }
62
+ debug(message, ...args) {
63
+ if (this.level === LogLevel.DEBUG) {
64
+ console.debug(message, ...args);
65
+ }
66
+ }
67
+ info(message, ...args) {
68
+ if (this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
69
+ console.info(message, ...args);
70
+ }
71
+ }
72
+ warn(message, ...args) {
73
+ if (this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
74
+ console.warn(message, ...args);
75
+ }
76
+ }
77
+ error(message, ...args) {
78
+ if (this.level === LogLevel.ERROR || this.level === LogLevel.WARN || this.level === LogLevel.INFO || this.level === LogLevel.DEBUG) {
79
+ console.error(message, ...args);
80
+ }
81
+ }
82
+ async getLogs(_transportId) {
83
+ return [];
84
+ }
85
+ async getLogsByRunId(_args) {
86
+ return [];
87
+ }
88
+ };
89
+
90
+ export { ConsoleLogger, LogLevel, MastraLogger, RegisteredLogger, createLogger };
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkO44MSFMZ_cjs = require('./chunk-O44MSFMZ.cjs');
3
+ var chunkSWW4EBUZ_cjs = require('./chunk-SWW4EBUZ.cjs');
4
4
 
5
5
  // src/base.ts
6
6
  var MastraBase = class {
7
- component = chunkO44MSFMZ_cjs.RegisteredLogger.LLM;
7
+ component = chunkSWW4EBUZ_cjs.RegisteredLogger.LLM;
8
8
  logger;
9
9
  name;
10
10
  telemetry;
11
11
  constructor({ component, name }) {
12
- this.component = component || chunkO44MSFMZ_cjs.RegisteredLogger.LLM;
12
+ this.component = component || chunkSWW4EBUZ_cjs.RegisteredLogger.LLM;
13
13
  this.name = name;
14
- this.logger = chunkO44MSFMZ_cjs.createLogger({ name: `${this.component} - ${this.name}` });
14
+ this.logger = new chunkSWW4EBUZ_cjs.ConsoleLogger({ name: `${this.component} - ${this.name}` });
15
15
  }
16
16
  /**
17
17
  * Set the logger for the agent
@@ -19,7 +19,7 @@ var MastraBase = class {
19
19
  */
20
20
  __setLogger(logger) {
21
21
  this.logger = logger;
22
- if (this.component !== chunkO44MSFMZ_cjs.RegisteredLogger.LLM) {
22
+ if (this.component !== chunkSWW4EBUZ_cjs.RegisteredLogger.LLM) {
23
23
  this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
24
24
  }
25
25
  }
@@ -29,7 +29,7 @@ var MastraBase = class {
29
29
  */
30
30
  __setTelemetry(telemetry) {
31
31
  this.telemetry = telemetry;
32
- if (this.component !== chunkO44MSFMZ_cjs.RegisteredLogger.LLM) {
32
+ if (this.component !== chunkSWW4EBUZ_cjs.RegisteredLogger.LLM) {
33
33
  this.logger.debug(`Telemetry updated [component=${this.component}] [name=${this.telemetry.name}]`);
34
34
  }
35
35
  }
@@ -1,6 +1,7 @@
1
- import { DefaultProxyStorage, augmentWithInit } from './chunk-CTKNWYK2.js';
1
+ import { augmentWithInit } from './chunk-75Z4BZEE.js';
2
2
  import { InstrumentClass, Telemetry } from './chunk-BFNYQFG2.js';
3
- import { createLogger, LogLevel, noopLogger } from './chunk-CMPPXW4U.js';
3
+ import { noopLogger } from './chunk-OBEALYTK.js';
4
+ import { ConsoleLogger, LogLevel } from './chunk-VHLL4AZK.js';
4
5
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
5
6
 
6
7
  // src/mastra/index.ts
@@ -13,8 +14,8 @@ var Mastra = class {
13
14
  #vectors;
14
15
  #agents;
15
16
  #logger;
17
+ #legacy_workflows;
16
18
  #workflows;
17
- #vnext_workflows;
18
19
  #tts;
19
20
  #deployer;
20
21
  #serverMiddleware = [];
@@ -56,27 +57,22 @@ var Mastra = class {
56
57
  if (config?.logger) {
57
58
  logger = config.logger;
58
59
  } else {
59
- const levleOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? LogLevel.WARN : LogLevel.INFO;
60
- logger = createLogger({
60
+ const levelOnEnv = process.env.NODE_ENV === "production" && process.env.MASTRA_DEV !== "true" ? LogLevel.WARN : LogLevel.INFO;
61
+ logger = new ConsoleLogger({
61
62
  name: "Mastra",
62
- level: levleOnEnv
63
+ level: levelOnEnv
63
64
  });
64
65
  }
65
66
  }
66
67
  this.#logger = logger;
67
68
  let storage = config?.storage;
68
- if (!storage) {
69
- storage = new DefaultProxyStorage({
70
- config: {
71
- url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
72
- }
73
- });
69
+ if (storage) {
70
+ storage = augmentWithInit(storage);
74
71
  }
75
- storage = augmentWithInit(storage);
76
72
  this.#telemetry = Telemetry.init(config?.telemetry);
77
- if (this.#telemetry) {
73
+ if (this.#telemetry && storage) {
78
74
  this.#storage = this.#telemetry.traceClass(storage, {
79
- excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert"]
75
+ excludeMethods: ["__setTelemetry", "__getTelemetry", "batchTraceInsert", "getTraces", "getEvalsByAgentName"]
80
76
  });
81
77
  this.#storage.__setTelemetry(this.#telemetry);
82
78
  } else {
@@ -104,24 +100,16 @@ var Mastra = class {
104
100
  }
105
101
  if (config?.mcpServers) {
106
102
  this.#mcpServers = config.mcpServers;
107
- Object.values(this.#mcpServers).forEach(server => {
103
+ Object.entries(this.#mcpServers).forEach(([key, server]) => {
104
+ server.setId(key);
108
105
  if (this.#telemetry) {
109
106
  server.__setTelemetry(this.#telemetry);
110
107
  }
111
108
  server.__registerMastra(this);
112
109
  });
113
110
  }
114
- if (config?.memory) {
115
- this.#memory = config.memory;
116
- if (this.#telemetry) {
117
- this.#memory = this.#telemetry.traceClass(config.memory, {
118
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
119
- });
120
- this.#memory.__setTelemetry(this.#telemetry);
121
- }
122
- }
123
111
  if (config && `memory` in config) {
124
- this.#logger.warn(`
112
+ throw new Error(`
125
113
  Memory should be added to Agents, not to Mastra.
126
114
 
127
115
  Instead of:
@@ -129,8 +117,6 @@ Instead of:
129
117
 
130
118
  do:
131
119
  new Agent({ memory: new Memory() })
132
-
133
- This is a warning for now, but will throw an error in the future
134
120
  `);
135
121
  }
136
122
  if (config?.tts) {
@@ -173,9 +159,9 @@ This is a warning for now, but will throw an error in the future
173
159
  this.#networks[key] = network;
174
160
  });
175
161
  }
176
- this.#workflows = {};
177
- if (config?.workflows) {
178
- Object.entries(config.workflows).forEach(([key, workflow]) => {
162
+ this.#legacy_workflows = {};
163
+ if (config?.legacy_workflows) {
164
+ Object.entries(config.legacy_workflows).forEach(([key, workflow]) => {
179
165
  workflow.__registerMastra(this);
180
166
  workflow.__registerPrimitives({
181
167
  logger: this.getLogger(),
@@ -186,18 +172,18 @@ This is a warning for now, but will throw an error in the future
186
172
  tts: this.#tts,
187
173
  vectors: this.#vectors
188
174
  });
189
- this.#workflows[key] = workflow;
175
+ this.#legacy_workflows[key] = workflow;
190
176
  const workflowSteps = Object.values(workflow.steps).filter(step => !!step.workflowId && !!step.workflow);
191
177
  if (workflowSteps.length > 0) {
192
178
  workflowSteps.forEach(step => {
193
- this.#workflows[step.workflowId] = step.workflow;
179
+ this.#legacy_workflows[step.workflowId] = step.workflow;
194
180
  });
195
181
  }
196
182
  });
197
183
  }
198
- this.#vnext_workflows = {};
199
- if (config?.vnext_workflows) {
200
- Object.entries(config.vnext_workflows).forEach(([key, workflow]) => {
184
+ this.#workflows = {};
185
+ if (config?.workflows) {
186
+ Object.entries(config.workflows).forEach(([key, workflow]) => {
201
187
  workflow.__registerMastra(this);
202
188
  workflow.__registerPrimitives({
203
189
  logger: this.getLogger(),
@@ -208,7 +194,7 @@ This is a warning for now, but will throw an error in the future
208
194
  tts: this.#tts,
209
195
  vectors: this.#vectors
210
196
  });
211
- this.#vnext_workflows[key] = workflow;
197
+ this.#workflows[key] = workflow;
212
198
  });
213
199
  }
214
200
  if (config?.server) {
@@ -241,10 +227,10 @@ This is a warning for now, but will throw an error in the future
241
227
  getDeployer() {
242
228
  return this.#deployer;
243
229
  }
244
- getWorkflow(id, {
230
+ legacy_getWorkflow(id, {
245
231
  serialized
246
232
  } = {}) {
247
- const workflow = this.#workflows?.[id];
233
+ const workflow = this.#legacy_workflows?.[id];
248
234
  if (!workflow) {
249
235
  throw new Error(`Workflow with ID ${String(id)} not found`);
250
236
  }
@@ -255,10 +241,10 @@ This is a warning for now, but will throw an error in the future
255
241
  }
256
242
  return workflow;
257
243
  }
258
- vnext_getWorkflow(id, {
244
+ getWorkflow(id, {
259
245
  serialized
260
246
  } = {}) {
261
- const workflow = this.#vnext_workflows?.[id];
247
+ const workflow = this.#workflows?.[id];
262
248
  if (!workflow) {
263
249
  throw new Error(`Workflow with ID ${String(id)} not found`);
264
250
  }
@@ -269,9 +255,9 @@ This is a warning for now, but will throw an error in the future
269
255
  }
270
256
  return workflow;
271
257
  }
272
- getWorkflows(props = {}) {
258
+ legacy_getWorkflows(props = {}) {
273
259
  if (props.serialized) {
274
- return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
260
+ return Object.entries(this.#legacy_workflows).reduce((acc, [k, v]) => {
275
261
  return {
276
262
  ...acc,
277
263
  [k]: {
@@ -280,11 +266,11 @@ This is a warning for now, but will throw an error in the future
280
266
  };
281
267
  }, {});
282
268
  }
283
- return this.#workflows;
269
+ return this.#legacy_workflows;
284
270
  }
285
- vnext_getWorkflows(props = {}) {
271
+ getWorkflows(props = {}) {
286
272
  if (props.serialized) {
287
- return Object.entries(this.#vnext_workflows).reduce((acc, [k, v]) => {
273
+ return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
288
274
  return {
289
275
  ...acc,
290
276
  [k]: {
@@ -293,19 +279,9 @@ This is a warning for now, but will throw an error in the future
293
279
  };
294
280
  }, {});
295
281
  }
296
- return this.#vnext_workflows;
282
+ return this.#workflows;
297
283
  }
298
284
  setStorage(storage) {
299
- if (storage instanceof DefaultProxyStorage) {
300
- this.#logger.warn(`Importing "DefaultStorage" from '@mastra/core/storage/libsql' is deprecated.
301
-
302
- Instead of:
303
- import { DefaultStorage } from '@mastra/core/storage/libsql';
304
-
305
- Do:
306
- import { LibSQLStore } from '@mastra/libsql';
307
- `);
308
- }
309
285
  this.#storage = augmentWithInit(storage);
310
286
  }
311
287
  setLogger({
@@ -456,19 +432,58 @@ Do:
456
432
  return await this.#logger.getLogs(transportId);
457
433
  }
458
434
  /**
459
- * Get a specific MCP server by ID
460
- * @param serverId - The ID of the MCP server to retrieve
461
- * @returns The MCP server with the specified ID, or undefined if not found
435
+ * Get all registered MCP server instances.
436
+ * @returns A record of MCP server ID to MCPServerBase instance, or undefined if none are registered.
462
437
  */
463
- getMCPServer(serverId) {
464
- return this.#mcpServers?.[serverId];
438
+ getMCPServers() {
439
+ return this.#mcpServers;
465
440
  }
466
441
  /**
467
- * Get all registered MCP servers as a Record, with keys being their IDs.
468
- * @returns Record of MCP server IDs to MCPServerBase instances, or undefined if none.
442
+ * Get a specific MCP server instance.
443
+ * If a version is provided, it attempts to find the server with that exact logical ID and version.
444
+ * If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
445
+ * The logical ID should match the `id` property of the MCPServer instance (typically set via MCPServerConfig.id).
446
+ * @param serverId - The logical ID of the MCP server to retrieve.
447
+ * @param version - Optional specific version of the MCP server to retrieve.
448
+ * @returns The MCP server instance, or undefined if not found or if the specific version is not found.
469
449
  */
470
- getMCPServers() {
471
- return this.#mcpServers;
450
+ getMCPServer(serverId, version) {
451
+ if (!this.#mcpServers) {
452
+ return void 0;
453
+ }
454
+ const allRegisteredServers = Object.values(this.#mcpServers || {});
455
+ const matchingLogicalIdServers = allRegisteredServers.filter(server => server.id === serverId);
456
+ if (matchingLogicalIdServers.length === 0) {
457
+ this.#logger?.debug(`No MCP servers found with logical ID: ${serverId}`);
458
+ return void 0;
459
+ }
460
+ if (version) {
461
+ const specificVersionServer = matchingLogicalIdServers.find(server => server.version === version);
462
+ if (!specificVersionServer) {
463
+ this.#logger?.debug(`MCP server with logical ID '${serverId}' found, but not version '${version}'.`);
464
+ }
465
+ return specificVersionServer;
466
+ } else {
467
+ if (matchingLogicalIdServers.length === 1) {
468
+ return matchingLogicalIdServers[0];
469
+ }
470
+ matchingLogicalIdServers.sort((a, b) => {
471
+ const dateAVal = a.releaseDate && typeof a.releaseDate === "string" ? new Date(a.releaseDate).getTime() : NaN;
472
+ const dateBVal = b.releaseDate && typeof b.releaseDate === "string" ? new Date(b.releaseDate).getTime() : NaN;
473
+ if (isNaN(dateAVal) && isNaN(dateBVal)) return 0;
474
+ if (isNaN(dateAVal)) return 1;
475
+ if (isNaN(dateBVal)) return -1;
476
+ return dateBVal - dateAVal;
477
+ });
478
+ if (matchingLogicalIdServers.length > 0) {
479
+ const latestServer = matchingLogicalIdServers[0];
480
+ if (latestServer && latestServer.releaseDate && typeof latestServer.releaseDate === "string" && !isNaN(new Date(latestServer.releaseDate).getTime())) {
481
+ return latestServer;
482
+ }
483
+ }
484
+ 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.`);
485
+ return void 0;
486
+ }
472
487
  }
473
488
  };
474
489
  Mastra = /*@__PURE__*/(_ => {
@@ -1,5 +1,5 @@
1
1
  import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-SEOWDGC2.js';
2
- import { MastraBase } from './chunk-235X76GC.js';
2
+ import { MastraBase } from './chunk-FI7R232B.js';
3
3
 
4
4
  // src/storage/base.ts
5
5
  var MastraStorage = class extends MastraBase {