@mastra/core 0.10.4 → 0.10.6-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 (103) hide show
  1. package/dist/agent/index.cjs +4 -4
  2. package/dist/agent/index.d.cts +1 -1
  3. package/dist/agent/index.d.ts +1 -1
  4. package/dist/agent/index.js +2 -2
  5. package/dist/{base-icHjkcs-.d.ts → base-DF29Fhcx.d.ts} +75 -41
  6. package/dist/{base-Bdc5hWla.d.cts → base-vDxe4rcD.d.cts} +75 -41
  7. package/dist/chunk-2RZXEVWT.js +68 -0
  8. package/dist/{chunk-TRJIWZKM.js → chunk-3SY7GRSA.js} +1 -1
  9. package/dist/{chunk-PUG7THT5.cjs → chunk-6EMFDXAQ.cjs} +4 -4
  10. package/dist/{chunk-36UICULV.js → chunk-6PQRSQZF.js} +35 -5
  11. package/dist/{chunk-62ZSDIUK.js → chunk-BMED2N3R.js} +1 -1
  12. package/dist/{chunk-I2KL5KMY.js → chunk-CMEK3A3W.js} +2 -2
  13. package/dist/{chunk-HGPLTKJA.cjs → chunk-D2ULEJL3.cjs} +2 -2
  14. package/dist/{chunk-IZGRJXUQ.js → chunk-DNK4SXPA.js} +2 -1
  15. package/dist/{chunk-AX6IHSGY.js → chunk-DPKEVI6Q.js} +1 -1
  16. package/dist/{chunk-ZKUUYDOQ.cjs → chunk-EFJIVMMM.cjs} +21 -21
  17. package/dist/{chunk-VB4S54R3.cjs → chunk-EXOTT52R.cjs} +198 -30
  18. package/dist/{chunk-SI2ENZ3O.js → chunk-F2DBWJK3.js} +1 -1
  19. package/dist/{chunk-GV6P24NY.cjs → chunk-F5XU7FFR.cjs} +5 -4
  20. package/dist/{chunk-Z37B4W7B.js → chunk-HIQ3FPBN.js} +1 -1
  21. package/dist/{chunk-RO5VPM3P.cjs → chunk-HVI3SKIH.cjs} +278 -55
  22. package/dist/{chunk-QVROTSA5.cjs → chunk-J7MLMW6O.cjs} +2 -2
  23. package/dist/{chunk-PVGSY24V.js → chunk-LDNCERLU.js} +7 -0
  24. package/dist/{chunk-S6WRT7GI.cjs → chunk-LRMKKZ6M.cjs} +2 -2
  25. package/dist/{chunk-BBAQW23O.cjs → chunk-OLSQRA2V.cjs} +7 -0
  26. package/dist/chunk-Q65UGFQK.cjs +70 -0
  27. package/dist/{chunk-ZAXPU6F2.cjs → chunk-QQ3KHYKE.cjs} +35 -5
  28. package/dist/{chunk-ZWYZGIV3.cjs → chunk-QQT4XTOG.cjs} +279 -73
  29. package/dist/{chunk-XUODQRSL.cjs → chunk-TGK6JO2D.cjs} +3 -3
  30. package/dist/{chunk-UFQERGWG.js → chunk-U3F3AQJP.js} +197 -29
  31. package/dist/{chunk-JYLH5IY3.cjs → chunk-VRDDTY4O.cjs} +87 -16
  32. package/dist/{chunk-SWJKOFCU.js → chunk-VZDPK54I.js} +262 -56
  33. package/dist/{chunk-HFEELWJO.js → chunk-YDGX5LRI.js} +274 -51
  34. package/dist/{chunk-7UNDRBOU.js → chunk-YLCFUSJ4.js} +86 -15
  35. package/dist/error/index.cjs +5 -5
  36. package/dist/error/index.d.cts +7 -0
  37. package/dist/error/index.d.ts +7 -0
  38. package/dist/error/index.js +1 -1
  39. package/dist/eval/index.d.cts +1 -1
  40. package/dist/eval/index.d.ts +1 -1
  41. package/dist/index.cjs +48 -48
  42. package/dist/index.d.cts +4 -4
  43. package/dist/index.d.ts +4 -4
  44. package/dist/index.js +12 -12
  45. package/dist/integration/index.d.cts +1 -1
  46. package/dist/integration/index.d.ts +1 -1
  47. package/dist/llm/index.d.cts +1 -1
  48. package/dist/llm/index.d.ts +1 -1
  49. package/dist/mastra/index.cjs +2 -2
  50. package/dist/mastra/index.d.cts +1 -1
  51. package/dist/mastra/index.d.ts +1 -1
  52. package/dist/mastra/index.js +1 -1
  53. package/dist/mcp/index.d.cts +1 -1
  54. package/dist/mcp/index.d.ts +1 -1
  55. package/dist/memory/index.cjs +4 -4
  56. package/dist/memory/index.d.cts +1 -1
  57. package/dist/memory/index.d.ts +1 -1
  58. package/dist/memory/index.js +1 -1
  59. package/dist/network/index.cjs +11 -5
  60. package/dist/network/index.d.cts +1 -1
  61. package/dist/network/index.d.ts +1 -1
  62. package/dist/network/index.js +10 -4
  63. package/dist/relevance/index.cjs +4 -4
  64. package/dist/relevance/index.d.cts +1 -1
  65. package/dist/relevance/index.d.ts +1 -1
  66. package/dist/relevance/index.js +1 -1
  67. package/dist/server/index.cjs +9 -3
  68. package/dist/server/index.d.cts +2 -2
  69. package/dist/server/index.d.ts +2 -2
  70. package/dist/server/index.js +8 -2
  71. package/dist/storage/index.cjs +12 -12
  72. package/dist/storage/index.d.cts +2 -2
  73. package/dist/storage/index.d.ts +2 -2
  74. package/dist/storage/index.js +4 -4
  75. package/dist/telemetry/index.cjs +7 -7
  76. package/dist/telemetry/index.d.cts +1 -1
  77. package/dist/telemetry/index.d.ts +1 -1
  78. package/dist/telemetry/index.js +1 -1
  79. package/dist/tools/index.d.cts +2 -2
  80. package/dist/tools/index.d.ts +2 -2
  81. package/dist/tts/index.cjs +2 -2
  82. package/dist/tts/index.js +1 -1
  83. package/dist/utils.cjs +14 -14
  84. package/dist/utils.d.cts +2 -2
  85. package/dist/utils.d.ts +2 -2
  86. package/dist/utils.js +1 -1
  87. package/dist/vector/index.cjs +2 -2
  88. package/dist/vector/index.js +1 -1
  89. package/dist/voice/index.cjs +4 -4
  90. package/dist/voice/index.d.cts +1 -1
  91. package/dist/voice/index.d.ts +1 -1
  92. package/dist/voice/index.js +1 -1
  93. package/dist/workflows/index.cjs +9 -9
  94. package/dist/workflows/index.d.cts +18 -7
  95. package/dist/workflows/index.d.ts +18 -7
  96. package/dist/workflows/index.js +1 -1
  97. package/dist/workflows/legacy/index.cjs +22 -22
  98. package/dist/workflows/legacy/index.d.cts +2 -2
  99. package/dist/workflows/legacy/index.d.ts +2 -2
  100. package/dist/workflows/legacy/index.js +1 -1
  101. package/package.json +24 -24
  102. package/dist/chunk-IM7CLVLZ.js +0 -43
  103. package/dist/chunk-LEK3J7YN.cjs +0 -45
@@ -1,9 +1,10 @@
1
- import { DefaultVoice } from './chunk-7UNDRBOU.js';
2
- import { MessageList } from './chunk-AX6IHSGY.js';
1
+ import { DefaultVoice } from './chunk-YLCFUSJ4.js';
2
+ import { MessageList } from './chunk-DPKEVI6Q.js';
3
3
  import { executeHook } from './chunk-BB4KXGBU.js';
4
- import { MastraLLM } from './chunk-HFEELWJO.js';
5
- import { InstrumentClass } from './chunk-36UICULV.js';
6
- import { ensureToolProperties, makeCoreTool, createMastraProxy } from './chunk-TRJIWZKM.js';
4
+ import { MastraLLM } from './chunk-YDGX5LRI.js';
5
+ import { InstrumentClass } from './chunk-6PQRSQZF.js';
6
+ import { ensureToolProperties, makeCoreTool, createMastraProxy } from './chunk-3SY7GRSA.js';
7
+ import { MastraError } from './chunk-LDNCERLU.js';
7
8
  import { MastraBase } from './chunk-5IEKR756.js';
8
9
  import { RegisteredLogger } from './chunk-5YDTZN2X.js';
9
10
  import { RuntimeContext } from './chunk-SGGPJWRQ.js';
@@ -89,7 +90,18 @@ var Agent = class extends (_a = MastraBase) {
89
90
  this.#instructions = config.instructions;
90
91
  this.#description = config.description;
91
92
  if (!config.model) {
92
- throw new Error(`LanguageModel is required to create an Agent. Please provide the 'model'.`);
93
+ const mastraError = new MastraError({
94
+ id: "AGENT_CONSTRUCTOR_MODEL_REQUIRED",
95
+ domain: "AGENT" /* AGENT */,
96
+ category: "USER" /* USER */,
97
+ details: {
98
+ agentName: config.name
99
+ },
100
+ text: `LanguageModel is required to create an Agent. Please provide the 'model'.`
101
+ });
102
+ this.logger.trackException(mastraError);
103
+ this.logger.error(mastraError.toString());
104
+ throw mastraError;
93
105
  }
94
106
  this.model = config.model;
95
107
  if (config.workflows) {
@@ -145,7 +157,18 @@ var Agent = class extends (_a = MastraBase) {
145
157
  }
146
158
  get voice() {
147
159
  if (typeof this.#instructions === "function") {
148
- throw new Error("Voice is not compatible when instructions are a function. Please use getVoice() instead.");
160
+ const mastraError = new MastraError({
161
+ id: "AGENT_VOICE_INCOMPATIBLE_WITH_FUNCTION_INSTRUCTIONS",
162
+ domain: "AGENT" /* AGENT */,
163
+ category: "USER" /* USER */,
164
+ details: {
165
+ agentName: this.name
166
+ },
167
+ text: "Voice is not compatible when instructions are a function. Please use getVoice() instead."
168
+ });
169
+ this.logger.trackException(mastraError);
170
+ this.logger.error(mastraError.toString());
171
+ throw mastraError;
149
172
  }
150
173
  return this.#voice;
151
174
  }
@@ -186,7 +209,18 @@ var Agent = class extends (_a = MastraBase) {
186
209
  get instructions() {
187
210
  this.logger.warn("The instructions property is deprecated. Please use getInstructions() instead.");
188
211
  if (typeof this.#instructions === "function") {
189
- throw new Error("Instructions are not compatible when instructions are a function. Please use getInstructions() instead.");
212
+ const mastraError = new MastraError({
213
+ id: "AGENT_INSTRUCTIONS_INCOMPATIBLE_WITH_FUNCTION_INSTRUCTIONS",
214
+ domain: "AGENT" /* AGENT */,
215
+ category: "USER" /* USER */,
216
+ details: {
217
+ agentName: this.name
218
+ },
219
+ text: "Instructions are not compatible when instructions are a function. Please use getInstructions() instead."
220
+ });
221
+ this.logger.trackException(mastraError);
222
+ this.logger.error(mastraError.toString());
223
+ throw mastraError;
190
224
  }
191
225
  return this.#instructions;
192
226
  }
@@ -201,8 +235,18 @@ var Agent = class extends (_a = MastraBase) {
201
235
  });
202
236
  return resolveMaybePromise(result, instructions => {
203
237
  if (!instructions) {
204
- this.logger.error(`[Agent:${this.name}] - Function-based instructions returned empty value`);
205
- throw new Error("Instructions are required to use an Agent. The function-based instructions returned an empty value.");
238
+ const mastraError = new MastraError({
239
+ id: "AGENT_GET_INSTRUCTIONS_FUNCTION_EMPTY_RETURN",
240
+ domain: "AGENT" /* AGENT */,
241
+ category: "USER" /* USER */,
242
+ details: {
243
+ agentName: this.name
244
+ },
245
+ text: "Instructions are required to use an Agent. The function-based instructions returned an empty value."
246
+ });
247
+ this.logger.trackException(mastraError);
248
+ this.logger.error(mastraError.toString());
249
+ throw mastraError;
206
250
  }
207
251
  return instructions;
208
252
  });
@@ -219,7 +263,18 @@ var Agent = class extends (_a = MastraBase) {
219
263
  get tools() {
220
264
  this.logger.warn("The tools property is deprecated. Please use getTools() instead.");
221
265
  if (typeof this.#tools === "function") {
222
- throw new Error("Tools are not compatible when tools are a function. Please use getTools() instead.");
266
+ const mastraError = new MastraError({
267
+ id: "AGENT_GET_TOOLS_FUNCTION_INCOMPATIBLE_WITH_TOOL_FUNCTION_TYPE",
268
+ domain: "AGENT" /* AGENT */,
269
+ category: "USER" /* USER */,
270
+ details: {
271
+ agentName: this.name
272
+ },
273
+ text: "Tools are not compatible when tools are a function. Please use getTools() instead."
274
+ });
275
+ this.logger.trackException(mastraError);
276
+ this.logger.error(mastraError.toString());
277
+ throw mastraError;
223
278
  }
224
279
  return ensureToolProperties(this.#tools);
225
280
  }
@@ -234,8 +289,18 @@ var Agent = class extends (_a = MastraBase) {
234
289
  });
235
290
  return resolveMaybePromise(result, tools => {
236
291
  if (!tools) {
237
- this.logger.error(`[Agent:${this.name}] - Function-based tools returned empty value`);
238
- throw new Error("Tools are required when using a function to provide them. The function returned an empty value.");
292
+ const mastraError = new MastraError({
293
+ id: "AGENT_GET_TOOLS_FUNCTION_EMPTY_RETURN",
294
+ domain: "AGENT" /* AGENT */,
295
+ category: "USER" /* USER */,
296
+ details: {
297
+ agentName: this.name
298
+ },
299
+ text: `[Agent:${this.name}] - Function-based tools returned empty value`
300
+ });
301
+ this.logger.trackException(mastraError);
302
+ this.logger.error(mastraError.toString());
303
+ throw mastraError;
239
304
  }
240
305
  return ensureToolProperties(tools);
241
306
  });
@@ -243,7 +308,18 @@ var Agent = class extends (_a = MastraBase) {
243
308
  get llm() {
244
309
  this.logger.warn("The llm property is deprecated. Please use getLLM() instead.");
245
310
  if (typeof this.model === "function") {
246
- throw new Error("LLM is not compatible when model is a function. Please use getLLM() instead.");
311
+ const mastraError = new MastraError({
312
+ id: "AGENT_LLM_GETTER_INCOMPATIBLE_WITH_FUNCTION_MODEL",
313
+ domain: "AGENT" /* AGENT */,
314
+ category: "USER" /* USER */,
315
+ details: {
316
+ agentName: this.name
317
+ },
318
+ text: "LLM is not compatible when model is a function. Please use getLLM() instead."
319
+ });
320
+ this.logger.trackException(mastraError);
321
+ this.logger.error(mastraError.toString());
322
+ throw mastraError;
247
323
  }
248
324
  return this.getLLM();
249
325
  }
@@ -282,8 +358,18 @@ var Agent = class extends (_a = MastraBase) {
282
358
  } = {}) {
283
359
  if (typeof this.model !== "function") {
284
360
  if (!this.model) {
285
- this.logger.error(`[Agent:${this.name}] - No model provided`);
286
- throw new Error("Model is required to use an Agent.");
361
+ const mastraError = new MastraError({
362
+ id: "AGENT_GET_MODEL_MISSING_MODEL_INSTANCE",
363
+ domain: "AGENT" /* AGENT */,
364
+ category: "USER" /* USER */,
365
+ details: {
366
+ agentName: this.name
367
+ },
368
+ text: `[Agent:${this.name}] - No model provided`
369
+ });
370
+ this.logger.trackException(mastraError);
371
+ this.logger.error(mastraError.toString());
372
+ throw mastraError;
287
373
  }
288
374
  return this.model;
289
375
  }
@@ -292,8 +378,18 @@ var Agent = class extends (_a = MastraBase) {
292
378
  });
293
379
  return resolveMaybePromise(result, model => {
294
380
  if (!model) {
295
- this.logger.error(`[Agent:${this.name}] - Function-based model returned empty value`);
296
- throw new Error("Model is required to use an Agent. The function-based model returned an empty value.");
381
+ const mastraError = new MastraError({
382
+ id: "AGENT_GET_MODEL_FUNCTION_EMPTY_RETURN",
383
+ domain: "AGENT" /* AGENT */,
384
+ category: "USER" /* USER */,
385
+ details: {
386
+ agentName: this.name
387
+ },
388
+ text: `[Agent:${this.name}] - Function-based model returned empty value`
389
+ });
390
+ this.logger.trackException(mastraError);
391
+ this.logger.error(mastraError.toString());
392
+ throw mastraError;
297
393
  }
298
394
  return model;
299
395
  });
@@ -480,13 +576,21 @@ var Agent = class extends (_a = MastraBase) {
480
576
  runtimeContext
481
577
  }, options) ?? void 0;
482
578
  } catch (err) {
483
- this.logger.error(`[Agent:${this.name}] - Failed memory tool execution`, {
484
- error: err,
485
- runId,
486
- threadId,
487
- resourceId
488
- });
489
- throw err;
579
+ const mastraError = new MastraError({
580
+ id: "AGENT_MEMORY_TOOL_EXECUTION_FAILED",
581
+ domain: "AGENT" /* AGENT */,
582
+ category: "USER" /* USER */,
583
+ details: {
584
+ agentName: this.name,
585
+ runId: runId || "",
586
+ threadId: threadId || "",
587
+ resourceId: resourceId || ""
588
+ },
589
+ text: `[Agent:${this.name}] - Failed memory tool execution`
590
+ }, err);
591
+ this.logger.trackException(mastraError);
592
+ this.logger.error(mastraError.toString());
593
+ throw mastraError;
490
594
  }
491
595
  } : void 0
492
596
  }];
@@ -653,13 +757,21 @@ var Agent = class extends (_a = MastraBase) {
653
757
  });
654
758
  return result;
655
759
  } catch (err) {
656
- this.logger.error(`[Agent:${this.name}] - Failed workflow tool execution`, {
657
- error: err,
658
- runId,
659
- threadId,
660
- resourceId
661
- });
662
- throw err;
760
+ const mastraError = new MastraError({
761
+ id: "AGENT_WORKFLOW_TOOL_EXECUTION_FAILED",
762
+ domain: "AGENT" /* AGENT */,
763
+ category: "USER" /* USER */,
764
+ details: {
765
+ agentName: this.name,
766
+ runId: runId || "",
767
+ threadId: threadId || "",
768
+ resourceId: resourceId || ""
769
+ },
770
+ text: `[Agent:${this.name}] - Failed workflow tool execution`
771
+ }, err);
772
+ this.logger.trackException(mastraError);
773
+ this.logger.error(mastraError.toString());
774
+ throw mastraError;
663
775
  }
664
776
  }
665
777
  };
@@ -786,7 +898,20 @@ var Agent = class extends (_a = MastraBase) {
786
898
  };
787
899
  }
788
900
  if (!threadId || !resourceId) {
789
- throw new Error(`A resourceId must be provided when passing a threadId and using Memory. Saw threadId ${threadId} but resourceId is ${resourceId}`);
901
+ const mastraError = new MastraError({
902
+ id: "AGENT_MEMORY_MISSING_RESOURCE_ID",
903
+ domain: "AGENT" /* AGENT */,
904
+ category: "USER" /* USER */,
905
+ details: {
906
+ agentName: this.name,
907
+ threadId: threadId || "",
908
+ resourceId: resourceId || ""
909
+ },
910
+ text: `A resourceId must be provided when passing a threadId and using Memory. Saw threadId ${threadId} but resourceId is ${resourceId}`
911
+ });
912
+ this.logger.trackException(mastraError);
913
+ this.logger.error(mastraError.toString());
914
+ throw mastraError;
790
915
  }
791
916
  const store = memory.constructor.name;
792
917
  this.logger.debug(`[Agent:${this.name}] - Memory persistence enabled: store=${store}, resourceId=${resourceId}`, {
@@ -934,14 +1059,23 @@ ${JSON.stringify(
934
1059
  memoryConfig: memoryConfig2
935
1060
  });
936
1061
  } catch (e) {
937
- const message = e instanceof Error ? e.message : JSON.stringify(e);
938
- this.logger.error("Error saving response", {
939
- error: message,
940
- runId: runId2,
941
- result: resToLog,
942
- threadId: threadId2
943
- });
944
- throw e;
1062
+ if (e instanceof MastraError) {
1063
+ throw e;
1064
+ }
1065
+ const mastraError = new MastraError({
1066
+ id: "AGENT_MEMORY_PERSIST_RESPONSE_MESSAGES_FAILED",
1067
+ domain: "AGENT" /* AGENT */,
1068
+ category: "SYSTEM" /* SYSTEM */,
1069
+ details: {
1070
+ agentName: this.name,
1071
+ runId: runId2 || "",
1072
+ threadId: threadId2 || "",
1073
+ result: JSON.stringify(resToLog)
1074
+ }
1075
+ }, e);
1076
+ this.logger.trackException(mastraError);
1077
+ this.logger.error(mastraError.toString());
1078
+ throw mastraError;
945
1079
  }
946
1080
  }
947
1081
  if (Object.keys(this.evals || {}).length > 0) {
@@ -1280,16 +1414,40 @@ ${JSON.stringify(
1280
1414
  */
1281
1415
  async speak(input, options) {
1282
1416
  if (!this.voice) {
1283
- throw new Error("No voice provider configured");
1417
+ const mastraError = new MastraError({
1418
+ id: "AGENT_SPEAK_METHOD_VOICE_NOT_CONFIGURED",
1419
+ domain: "AGENT" /* AGENT */,
1420
+ category: "USER" /* USER */,
1421
+ details: {
1422
+ agentName: this.name
1423
+ },
1424
+ text: "No voice provider configured"
1425
+ });
1426
+ this.logger.trackException(mastraError);
1427
+ this.logger.error(mastraError.toString());
1428
+ throw mastraError;
1284
1429
  }
1285
1430
  this.logger.warn("Warning: agent.speak() is deprecated. Please use agent.voice.speak() instead.");
1286
1431
  try {
1287
1432
  return this.voice.speak(input, options);
1288
1433
  } catch (e) {
1289
- this.logger.error("Error during agent speak", {
1290
- error: e
1291
- });
1292
- throw e;
1434
+ let err;
1435
+ if (e instanceof MastraError) {
1436
+ err = e;
1437
+ } else {
1438
+ err = new MastraError({
1439
+ id: "AGENT_SPEAK_METHOD_ERROR",
1440
+ domain: "AGENT" /* AGENT */,
1441
+ category: "UNKNOWN" /* UNKNOWN */,
1442
+ details: {
1443
+ agentName: this.name
1444
+ },
1445
+ text: "Error during agent speak"
1446
+ }, e);
1447
+ }
1448
+ this.logger.trackException(err);
1449
+ this.logger.error(err.toString());
1450
+ throw err;
1293
1451
  }
1294
1452
  }
1295
1453
  /**
@@ -1301,16 +1459,40 @@ ${JSON.stringify(
1301
1459
  */
1302
1460
  async listen(audioStream, options) {
1303
1461
  if (!this.voice) {
1304
- throw new Error("No voice provider configured");
1462
+ const mastraError = new MastraError({
1463
+ id: "AGENT_LISTEN_METHOD_VOICE_NOT_CONFIGURED",
1464
+ domain: "AGENT" /* AGENT */,
1465
+ category: "USER" /* USER */,
1466
+ details: {
1467
+ agentName: this.name
1468
+ },
1469
+ text: "No voice provider configured"
1470
+ });
1471
+ this.logger.trackException(mastraError);
1472
+ this.logger.error(mastraError.toString());
1473
+ throw mastraError;
1305
1474
  }
1306
1475
  this.logger.warn("Warning: agent.listen() is deprecated. Please use agent.voice.listen() instead");
1307
1476
  try {
1308
1477
  return this.voice.listen(audioStream, options);
1309
1478
  } catch (e) {
1310
- this.logger.error("Error during agent listen", {
1311
- error: e
1312
- });
1313
- throw e;
1479
+ let err;
1480
+ if (e instanceof MastraError) {
1481
+ err = e;
1482
+ } else {
1483
+ err = new MastraError({
1484
+ id: "AGENT_LISTEN_METHOD_ERROR",
1485
+ domain: "AGENT" /* AGENT */,
1486
+ category: "UNKNOWN" /* UNKNOWN */,
1487
+ details: {
1488
+ agentName: this.name
1489
+ },
1490
+ text: "Error during agent listen"
1491
+ }, e);
1492
+ }
1493
+ this.logger.trackException(err);
1494
+ this.logger.error(err.toString());
1495
+ throw err;
1314
1496
  }
1315
1497
  }
1316
1498
  /**
@@ -1321,16 +1503,40 @@ ${JSON.stringify(
1321
1503
  */
1322
1504
  async getSpeakers() {
1323
1505
  if (!this.voice) {
1324
- throw new Error("No voice provider configured");
1506
+ const mastraError = new MastraError({
1507
+ id: "AGENT_SPEAKERS_METHOD_VOICE_NOT_CONFIGURED",
1508
+ domain: "AGENT" /* AGENT */,
1509
+ category: "USER" /* USER */,
1510
+ details: {
1511
+ agentName: this.name
1512
+ },
1513
+ text: "No voice provider configured"
1514
+ });
1515
+ this.logger.trackException(mastraError);
1516
+ this.logger.error(mastraError.toString());
1517
+ throw mastraError;
1325
1518
  }
1326
1519
  this.logger.warn("Warning: agent.getSpeakers() is deprecated. Please use agent.voice.getSpeakers() instead.");
1327
1520
  try {
1328
1521
  return await this.voice.getSpeakers();
1329
1522
  } catch (e) {
1330
- this.logger.error("Error during agent getSpeakers", {
1331
- error: e
1332
- });
1333
- throw e;
1523
+ let err;
1524
+ if (e instanceof MastraError) {
1525
+ err = e;
1526
+ } else {
1527
+ err = new MastraError({
1528
+ id: "AGENT_GET_SPEAKERS_METHOD_ERROR",
1529
+ domain: "AGENT" /* AGENT */,
1530
+ category: "UNKNOWN" /* UNKNOWN */,
1531
+ details: {
1532
+ agentName: this.name
1533
+ },
1534
+ text: "Error during agent getSpeakers"
1535
+ }, e);
1536
+ }
1537
+ this.logger.trackException(err);
1538
+ this.logger.error(err.toString());
1539
+ throw err;
1334
1540
  }
1335
1541
  }
1336
1542
  toStep() {