@mastra/core 0.9.3-alpha.0 → 0.9.3

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 (133) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.d.cts +2 -2
  3. package/dist/agent/index.d.ts +2 -2
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-CzHSMvOb.d.ts → base-BCnFhShR.d.ts} +27 -7
  6. package/dist/{base-DT2poiVK.d.ts → base-CeEVvwRi.d.ts} +2 -2
  7. package/dist/{base-BihKcqDY.d.cts → base-D9APQt4V.d.cts} +2 -2
  8. package/dist/{base-Cs0ddGCf.d.cts → base-VMWGZau0.d.cts} +27 -7
  9. package/dist/base.cjs +2 -2
  10. package/dist/base.d.cts +1 -1
  11. package/dist/base.d.ts +1 -1
  12. package/dist/base.js +1 -1
  13. package/dist/bundler/index.cjs +2 -2
  14. package/dist/bundler/index.d.cts +1 -1
  15. package/dist/bundler/index.d.ts +1 -1
  16. package/dist/bundler/index.js +1 -1
  17. package/dist/{chunk-WYL4MKWH.cjs → chunk-2PLTE53B.cjs} +37 -27
  18. package/dist/{chunk-QJJD56YR.cjs → chunk-37HZ77Z5.cjs} +13 -12
  19. package/dist/{chunk-JSKASUR2.cjs → chunk-5ENQX4BI.cjs} +9 -9
  20. package/dist/{chunk-RZCYBC7D.cjs → chunk-6NUAJ6AB.cjs} +2 -2
  21. package/dist/{chunk-O6EYGXZO.cjs → chunk-6YITFTRU.cjs} +2 -2
  22. package/dist/{chunk-KWYJUFY3.js → chunk-BFNYQFG2.js} +80 -55
  23. package/dist/chunk-BMSBIZKD.cjs +72 -0
  24. package/dist/{chunk-MNGIRRFY.js → chunk-CPONI4EX.js} +1 -1
  25. package/dist/{chunk-WAW7QBY4.cjs → chunk-CRHH7KRS.cjs} +2 -2
  26. package/dist/{chunk-5TFGORLG.js → chunk-DWD7X4KB.js} +1 -1
  27. package/dist/{chunk-PPNVAI5G.js → chunk-EYMLOJ2Q.js} +6 -5
  28. package/dist/{chunk-Q6Z2YS6I.js → chunk-FVYYXFPR.js} +2 -2
  29. package/dist/{chunk-OHIRECYU.cjs → chunk-FXAV2WYX.cjs} +3 -3
  30. package/dist/{chunk-ZZRFVSYZ.cjs → chunk-GUMHVPHG.cjs} +4 -4
  31. package/dist/{chunk-2ZK5VAXE.js → chunk-IKZWOULI.js} +2 -2
  32. package/dist/{chunk-T3UZONPQ.cjs → chunk-ITFMXU6H.cjs} +2 -2
  33. package/dist/{chunk-TZIOJX3N.js → chunk-JCBDQUQY.js} +1 -1
  34. package/dist/{chunk-2UAN6SRJ.js → chunk-KPOUHZFJ.js} +2 -2
  35. package/dist/{chunk-POEYDVX7.cjs → chunk-KXWR3FNX.cjs} +4 -4
  36. package/dist/{chunk-CLJQYXNM.js → chunk-NDAW47QQ.js} +6 -2
  37. package/dist/{chunk-XNBNJEES.cjs → chunk-OGNJRWRQ.cjs} +2 -2
  38. package/dist/chunk-Q6ZDDQOB.js +70 -0
  39. package/dist/{chunk-7IAP7VPO.js → chunk-QFJY3MEL.js} +2 -2
  40. package/dist/{chunk-4DEDPTLO.cjs → chunk-QQFFJTJ4.cjs} +2 -2
  41. package/dist/{chunk-47NGQPZI.js → chunk-R652KYQW.js} +1 -1
  42. package/dist/{chunk-FXUTMNQG.cjs → chunk-RE5MNHDE.cjs} +2 -2
  43. package/dist/{chunk-D63P5O4Q.cjs → chunk-RO52JMKQ.cjs} +6 -2
  44. package/dist/{chunk-6HHSM7FP.js → chunk-SONEVGEJ.js} +1 -1
  45. package/dist/{chunk-52SRR7WR.js → chunk-T5V4W7WU.js} +1 -1
  46. package/dist/{chunk-GHK3HBWN.js → chunk-TCL7XDJL.js} +1 -1
  47. package/dist/{chunk-MYHX5XVW.cjs → chunk-UVRGQEMD.cjs} +79 -53
  48. package/dist/{chunk-KSH5B376.js → chunk-XYP6MY7U.js} +22 -12
  49. package/dist/{chunk-22CFFDPA.cjs → chunk-ZMMZXEOL.cjs} +7 -7
  50. package/dist/{chunk-WD3HYQV3.js → chunk-ZQ7FXUGY.js} +1 -1
  51. package/dist/deployer/index.cjs +2 -2
  52. package/dist/deployer/index.d.cts +1 -1
  53. package/dist/deployer/index.d.ts +1 -1
  54. package/dist/deployer/index.js +1 -1
  55. package/dist/eval/index.d.cts +2 -2
  56. package/dist/eval/index.d.ts +2 -2
  57. package/dist/index.cjs +70 -66
  58. package/dist/index.d.cts +5 -5
  59. package/dist/index.d.ts +5 -5
  60. package/dist/index.js +15 -15
  61. package/dist/integration/index.cjs +3 -3
  62. package/dist/integration/index.d.cts +2 -2
  63. package/dist/integration/index.d.ts +2 -2
  64. package/dist/integration/index.js +1 -1
  65. package/dist/llm/index.d.cts +2 -2
  66. package/dist/llm/index.d.ts +2 -2
  67. package/dist/mastra/index.cjs +2 -2
  68. package/dist/mastra/index.d.cts +2 -2
  69. package/dist/mastra/index.d.ts +2 -2
  70. package/dist/mastra/index.js +1 -1
  71. package/dist/memory/index.cjs +4 -4
  72. package/dist/memory/index.d.cts +2 -2
  73. package/dist/memory/index.d.ts +2 -2
  74. package/dist/memory/index.js +1 -1
  75. package/dist/network/index.cjs +6 -6
  76. package/dist/network/index.d.cts +2 -2
  77. package/dist/network/index.d.ts +2 -2
  78. package/dist/network/index.js +3 -3
  79. package/dist/relevance/index.cjs +4 -4
  80. package/dist/relevance/index.d.cts +2 -2
  81. package/dist/relevance/index.d.ts +2 -2
  82. package/dist/relevance/index.js +1 -1
  83. package/dist/server/index.cjs +1 -0
  84. package/dist/server/index.d.cts +9 -4
  85. package/dist/server/index.d.ts +9 -4
  86. package/dist/server/index.js +1 -0
  87. package/dist/storage/index.cjs +2 -2
  88. package/dist/storage/index.d.cts +2 -2
  89. package/dist/storage/index.d.ts +2 -2
  90. package/dist/storage/index.js +1 -1
  91. package/dist/storage/libsql/index.cjs +2 -2
  92. package/dist/storage/libsql/index.d.cts +2 -2
  93. package/dist/storage/libsql/index.d.ts +2 -2
  94. package/dist/storage/libsql/index.js +1 -1
  95. package/dist/telemetry/index.cjs +10 -6
  96. package/dist/telemetry/index.d.cts +14 -4
  97. package/dist/telemetry/index.d.ts +14 -4
  98. package/dist/telemetry/index.js +1 -1
  99. package/dist/tools/index.cjs +4 -4
  100. package/dist/tools/index.d.cts +2 -2
  101. package/dist/tools/index.d.ts +2 -2
  102. package/dist/tools/index.js +1 -1
  103. package/dist/tts/index.cjs +2 -2
  104. package/dist/tts/index.d.cts +1 -1
  105. package/dist/tts/index.d.ts +1 -1
  106. package/dist/tts/index.js +1 -1
  107. package/dist/utils.cjs +12 -12
  108. package/dist/utils.d.cts +2 -2
  109. package/dist/utils.d.ts +2 -2
  110. package/dist/utils.js +1 -1
  111. package/dist/vector/index.cjs +2 -2
  112. package/dist/vector/index.d.cts +3 -1
  113. package/dist/vector/index.d.ts +3 -1
  114. package/dist/vector/index.js +1 -1
  115. package/dist/vector/libsql/index.cjs +3 -3
  116. package/dist/vector/libsql/index.d.cts +1 -1
  117. package/dist/vector/libsql/index.d.ts +1 -1
  118. package/dist/vector/libsql/index.js +1 -1
  119. package/dist/voice/index.cjs +4 -4
  120. package/dist/voice/index.d.cts +2 -2
  121. package/dist/voice/index.d.ts +2 -2
  122. package/dist/voice/index.js +1 -1
  123. package/dist/workflows/index.cjs +22 -22
  124. package/dist/workflows/index.d.cts +3 -3
  125. package/dist/workflows/index.d.ts +3 -3
  126. package/dist/workflows/index.js +1 -1
  127. package/dist/workflows/vNext/index.cjs +166 -129
  128. package/dist/workflows/vNext/index.d.cts +37 -12
  129. package/dist/workflows/vNext/index.d.ts +37 -12
  130. package/dist/workflows/vNext/index.js +162 -125
  131. package/package.json +2 -2
  132. package/dist/chunk-LXIAHZ45.js +0 -37
  133. package/dist/chunk-YAJVZMZH.cjs +0 -39
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk6KB5CPBV_cjs = require('./chunk-6KB5CPBV.cjs');
4
- var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
4
+ var chunkRO52JMKQ_cjs = require('./chunk-RO52JMKQ.cjs');
5
5
 
6
6
  // src/storage/base.ts
7
- var MastraStorage = class extends chunkD63P5O4Q_cjs.MastraBase {
7
+ var MastraStorage = class extends chunkRO52JMKQ_cjs.MastraBase {
8
8
  /** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
9
9
  static TABLE_WORKFLOW_SNAPSHOT = chunk6KB5CPBV_cjs.TABLE_WORKFLOW_SNAPSHOT;
10
10
  /** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
@@ -0,0 +1,70 @@
1
+ import { MastraBase } from './chunk-NDAW47QQ.js';
2
+
3
+ // src/vector/vector.ts
4
+ var MastraVector = class extends MastraBase {
5
+ constructor() {
6
+ super({ name: "MastraVector", component: "VECTOR" });
7
+ }
8
+ get indexSeparator() {
9
+ return "_";
10
+ }
11
+ baseKeys = {
12
+ query: ["queryVector", "topK", "filter", "includeVector"],
13
+ upsert: ["vectors", "metadata", "ids"],
14
+ createIndex: ["dimension", "metric"]
15
+ };
16
+ normalizeArgs(method, [first, ...rest], extendedKeys = []) {
17
+ if (typeof first === "object") {
18
+ return first;
19
+ }
20
+ this.logger.warn(
21
+ `Deprecation Warning: Passing individual arguments to ${method}() is deprecated.
22
+ Please use an object parameter instead.
23
+ Individual arguments will be removed on May 20th.`
24
+ );
25
+ const baseKeys = this.baseKeys[method] || [];
26
+ const paramKeys = [...baseKeys, ...extendedKeys].slice(0, rest.length);
27
+ return {
28
+ indexName: first,
29
+ ...Object.fromEntries(paramKeys.map((key, i) => [key, rest[i]]))
30
+ };
31
+ }
32
+ async updateIndexById(_indexName, _id, _update) {
33
+ throw new Error("updateIndexById is not implemented yet");
34
+ }
35
+ async deleteIndexById(_indexName, _id) {
36
+ throw new Error("deleteById is not implemented yet");
37
+ }
38
+ async validateExistingIndex(indexName, dimension, metric) {
39
+ let info;
40
+ try {
41
+ info = await this.describeIndex(indexName);
42
+ } catch (infoError) {
43
+ const message = `Index "${indexName}" already exists, but failed to fetch index info for dimension check: ${infoError}`;
44
+ this.logger?.error(message);
45
+ throw new Error(message);
46
+ }
47
+ const existingDim = info?.dimension;
48
+ const existingMetric = info?.metric;
49
+ if (existingDim === dimension) {
50
+ this.logger?.info(
51
+ `Index "${indexName}" already exists with ${existingDim} dimensions and metric ${existingMetric}, skipping creation.`
52
+ );
53
+ if (existingMetric !== metric) {
54
+ this.logger?.warn(
55
+ `Attempted to create index with metric "${metric}", but index already exists with metric "${existingMetric}". To use a different metric, delete and recreate the index.`
56
+ );
57
+ }
58
+ } else if (info) {
59
+ const message = `Index "${indexName}" already exists with ${existingDim} dimensions, but ${dimension} dimensions were requested`;
60
+ this.logger?.error(message);
61
+ throw new Error(message);
62
+ } else {
63
+ const message = `Index "${indexName}" already exists, but could not retrieve its dimensions for validation.`;
64
+ this.logger?.error(message);
65
+ throw new Error(message);
66
+ }
67
+ }
68
+ };
69
+
70
+ export { MastraVector };
@@ -1,5 +1,5 @@
1
- import { InstrumentClass } from './chunk-KWYJUFY3.js';
2
- import { MastraBase } from './chunk-CLJQYXNM.js';
1
+ import { InstrumentClass } from './chunk-BFNYQFG2.js';
2
+ import { MastraBase } from './chunk-NDAW47QQ.js';
3
3
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
4
4
 
5
5
  // src/tts/index.ts
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkWYL4MKWH_cjs = require('./chunk-WYL4MKWH.cjs');
3
+ var chunk2PLTE53B_cjs = require('./chunk-2PLTE53B.cjs');
4
4
  var cohereAi = require('cohere-ai');
5
5
 
6
6
  var CohereRelevanceScorer = class {
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
38
38
  var MastraAgentRelevanceScorer = class {
39
39
  agent;
40
40
  constructor(name, model) {
41
- this.agent = new chunkWYL4MKWH_cjs.Agent({
41
+ this.agent = new chunk2PLTE53B_cjs.Agent({
42
42
  name: `Relevance Scorer ${name}`,
43
43
  instructions: `You are a specialized agent for evaluating the relevance of text to queries.
44
44
  Your task is to rate how well a text passage answers a given query.
@@ -1,5 +1,5 @@
1
1
  import { BaseFilterTranslator } from './chunk-LGERQTJM.js';
2
- import { MastraVector } from './chunk-LXIAHZ45.js';
2
+ import { MastraVector } from './chunk-Q6ZDDQOB.js';
3
3
  import { isAbsolute, join, resolve } from 'path';
4
4
  import { createClient } from '@libsql/client';
5
5
 
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkXNBNJEES_cjs = require('./chunk-XNBNJEES.cjs');
3
+ var chunkOGNJRWRQ_cjs = require('./chunk-OGNJRWRQ.cjs');
4
4
 
5
5
  // src/storage/default-proxy-storage.ts
6
- var DefaultProxyStorage = class extends chunkXNBNJEES_cjs.MastraStorage {
6
+ var DefaultProxyStorage = class extends chunkOGNJRWRQ_cjs.MastraStorage {
7
7
  storage = null;
8
8
  storageConfig;
9
9
  isInitializingPromise = null;
@@ -19,7 +19,9 @@ var MastraBase = class {
19
19
  */
20
20
  __setLogger(logger) {
21
21
  this.logger = logger;
22
- this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
22
+ if (this.component !== chunkO7IW545H_cjs.RegisteredLogger.LLM) {
23
+ this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
24
+ }
23
25
  }
24
26
  /**
25
27
  * Set the telemetry for the
@@ -27,7 +29,9 @@ var MastraBase = class {
27
29
  */
28
30
  __setTelemetry(telemetry) {
29
31
  this.telemetry = telemetry;
30
- this.logger.debug(`Telemetry updated [component=${this.component}] [tracer=${this.telemetry.tracer}]`);
32
+ if (this.component !== chunkO7IW545H_cjs.RegisteredLogger.LLM) {
33
+ this.logger.debug(`Telemetry updated [component=${this.component}] [name=${this.telemetry.name}]`);
34
+ }
31
35
  }
32
36
  /**
33
37
  * Get the telemetry on the vector
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-KSH5B376.js';
1
+ import { Agent } from './chunk-XYP6MY7U.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -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-CLJQYXNM.js';
2
+ import { MastraBase } from './chunk-NDAW47QQ.js';
3
3
 
4
4
  // src/storage/base.ts
5
5
  var MastraStorage = class extends MastraBase {
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-CLJQYXNM.js';
1
+ import { MastraBase } from './chunk-NDAW47QQ.js';
2
2
  import { readFile } from 'fs/promises';
3
3
  import { parse } from 'dotenv';
4
4
 
@@ -12,6 +12,17 @@ function hasActiveTelemetry(tracerName = "default-tracer") {
12
12
  return false;
13
13
  }
14
14
  }
15
+ function getBaggageValues(ctx) {
16
+ const currentBaggage = api.propagation.getBaggage(ctx);
17
+ const requestId = currentBaggage?.getEntry("http.request_id")?.value;
18
+ const componentName = currentBaggage?.getEntry("componentName")?.value;
19
+ const runId = currentBaggage?.getEntry("runId")?.value;
20
+ return {
21
+ requestId,
22
+ componentName,
23
+ runId
24
+ };
25
+ }
15
26
 
16
27
  // src/telemetry/telemetry.decorators.ts
17
28
  function withSpan(options) {
@@ -43,24 +54,27 @@ function withSpan(options) {
43
54
  span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
44
55
  }
45
56
  });
46
- const currentBaggage = api.propagation.getBaggage(ctx);
47
- if (currentBaggage?.["http.request_id"]) {
48
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
57
+ const { requestId, componentName, runId } = getBaggageValues(ctx);
58
+ if (requestId) {
59
+ span.setAttribute("http.request_id", requestId);
49
60
  }
50
- if (currentBaggage?.componentName) {
51
- span.setAttribute("componentName", currentBaggage?.componentName);
52
- span.setAttribute("runId", currentBaggage?.runId);
61
+ if (componentName) {
62
+ span.setAttribute("componentName", componentName);
63
+ span.setAttribute("runId", runId);
53
64
  } else if (this && this.name) {
54
65
  span.setAttribute("componentName", this.name);
55
66
  span.setAttribute("runId", this.runId);
56
- ctx = api.propagation.setBaggage(ctx, {
57
- // @ts-ignore
58
- componentName: this.name,
59
- // @ts-ignore
60
- runId: this.runId,
61
- // @ts-ignore
62
- "http.request_id": currentBaggage?.["http.request_id"]
63
- });
67
+ ctx = api.propagation.setBaggage(
68
+ ctx,
69
+ api.propagation.createBaggage({
70
+ // @ts-ignore
71
+ componentName: { value: this.name },
72
+ // @ts-ignore
73
+ runId: { value: this.runId },
74
+ // @ts-ignore
75
+ "http.request_id": { value: requestId }
76
+ })
77
+ );
64
78
  }
65
79
  let result;
66
80
  try {
@@ -299,8 +313,14 @@ var Telemetry = class _Telemetry {
299
313
  });
300
314
  }
301
315
  static setBaggage(baggage, ctx = api.context.active()) {
302
- const currentBaggage = api.propagation.getBaggage(ctx);
303
- const newCtx = api.propagation.setBaggage(ctx, { ...currentBaggage, ...baggage });
316
+ const currentBaggage = Object.fromEntries(api.propagation.getBaggage(ctx)?.getAllEntries() ?? []);
317
+ const newCtx = api.propagation.setBaggage(
318
+ ctx,
319
+ api.propagation.createBaggage({
320
+ ...currentBaggage,
321
+ ...baggage
322
+ })
323
+ );
304
324
  return newCtx;
305
325
  }
306
326
  static withContext(ctx, fn) {
@@ -339,36 +359,41 @@ var Telemetry = class _Telemetry {
339
359
  span.end();
340
360
  return res;
341
361
  };
342
- const currentBaggage = api.propagation.getBaggage(ctx);
362
+ const { requestId, componentName, runId } = getBaggageValues(ctx);
343
363
  if (context3.attributes) {
344
364
  span.setAttributes(context3.attributes);
345
365
  }
346
- if (currentBaggage?.["http.request_id"]) {
347
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
366
+ if (requestId) {
367
+ span.setAttribute("http.request_id", requestId);
348
368
  }
349
369
  if (context3.attributes?.componentName) {
350
- ctx = api.propagation.setBaggage(ctx, {
351
- // @ts-ignore
352
- componentName: context3.attributes.componentName,
353
- runId: context3.attributes.runId,
354
- // @ts-ignore
355
- "http.request_id": currentBaggage?.["http.request_id"]
356
- });
370
+ ctx = api.propagation.setBaggage(
371
+ ctx,
372
+ api.propagation.createBaggage({
373
+ componentName: { value: context3.attributes.componentName },
374
+ // @ts-ignore
375
+ runId: { value: context3.attributes.runId },
376
+ // @ts-ignore
377
+ "http.request_id": { value: requestId }
378
+ })
379
+ );
357
380
  } else {
358
- if (currentBaggage?.componentName) {
359
- span.setAttribute("componentName", currentBaggage?.componentName);
360
- span.setAttribute("runId", currentBaggage?.runId);
381
+ if (componentName) {
382
+ span.setAttribute("componentName", componentName);
383
+ span.setAttribute("runId", runId);
361
384
  } else if (this && this.name) {
362
385
  span.setAttribute("componentName", this.name);
363
386
  span.setAttribute("runId", this.runId);
364
- ctx = api.propagation.setBaggage(ctx, {
365
- // @ts-ignore
366
- componentName: this.name,
367
- // @ts-ignore
368
- runId: this.runId,
369
- // @ts-ignore
370
- "http.request_id": currentBaggage?.["http.request_id"]
371
- });
387
+ ctx = api.propagation.setBaggage(
388
+ ctx,
389
+ api.propagation.createBaggage({
390
+ componentName: { value: this.name },
391
+ // @ts-ignore
392
+ runId: { value: this.runId },
393
+ // @ts-ignore
394
+ "http.request_id": { value: requestId }
395
+ })
396
+ );
372
397
  }
373
398
  }
374
399
  args.forEach((arg, index) => {
@@ -404,38 +429,38 @@ var BaggageTracer = class {
404
429
  startSpan(name, options = {}, ctx) {
405
430
  ctx = ctx ?? api.context.active();
406
431
  const span = this._tracer.startSpan(name, options, ctx);
407
- const currentBaggage = api.propagation.getBaggage(ctx);
408
- span.setAttribute("componentName", currentBaggage?.componentName);
409
- span.setAttribute("runId", currentBaggage?.runId);
410
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
432
+ const { componentName, runId, requestId } = getBaggageValues(ctx);
433
+ span.setAttribute("componentName", componentName);
434
+ span.setAttribute("runId", runId);
435
+ span.setAttribute("http.request_id", requestId);
411
436
  return span;
412
437
  }
413
438
  startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
414
439
  if (typeof optionsOrFn === "function") {
415
440
  const wrappedFn2 = (span) => {
416
- const currentBaggage = api.propagation.getBaggage(api.context.active());
417
- span.setAttribute("componentName", currentBaggage?.componentName);
418
- span.setAttribute("runId", currentBaggage?.runId);
419
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
441
+ const { componentName, runId, requestId } = getBaggageValues(api.context.active());
442
+ span.setAttribute("componentName", componentName);
443
+ span.setAttribute("runId", runId);
444
+ span.setAttribute("http.request_id", requestId);
420
445
  return optionsOrFn(span);
421
446
  };
422
447
  return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
423
448
  }
424
449
  if (typeof ctxOrFn === "function") {
425
450
  const wrappedFn2 = (span) => {
426
- const currentBaggage = api.propagation.getBaggage(api.context.active());
427
- span.setAttribute("componentName", currentBaggage?.componentName);
428
- span.setAttribute("runId", currentBaggage?.runId);
429
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
451
+ const { componentName, runId, requestId } = getBaggageValues(api.context.active());
452
+ span.setAttribute("componentName", componentName);
453
+ span.setAttribute("runId", runId);
454
+ span.setAttribute("http.request_id", requestId);
430
455
  return ctxOrFn(span);
431
456
  };
432
457
  return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
433
458
  }
434
459
  const wrappedFn = (span) => {
435
- const currentBaggage = api.propagation.getBaggage(ctxOrFn ?? api.context.active());
436
- span.setAttribute("componentName", currentBaggage?.componentName);
437
- span.setAttribute("runId", currentBaggage?.runId);
438
- span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
460
+ const { componentName, runId, requestId } = getBaggageValues(ctxOrFn ?? api.context.active());
461
+ span.setAttribute("componentName", componentName);
462
+ span.setAttribute("runId", runId);
463
+ span.setAttribute("http.request_id", requestId);
439
464
  return fn(span);
440
465
  };
441
466
  return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
@@ -445,5 +470,6 @@ var BaggageTracer = class {
445
470
  exports.InstrumentClass = InstrumentClass;
446
471
  exports.OTLPTraceExporter = OTLPTraceExporter;
447
472
  exports.Telemetry = Telemetry;
473
+ exports.getBaggageValues = getBaggageValues;
448
474
  exports.hasActiveTelemetry = hasActiveTelemetry;
449
475
  exports.withSpan = withSpan;
@@ -1,8 +1,8 @@
1
- import { DefaultVoice } from './chunk-Q6Z2YS6I.js';
2
- import { MastraLLM } from './chunk-2UAN6SRJ.js';
3
- import { InstrumentClass } from './chunk-KWYJUFY3.js';
4
- import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool } from './chunk-WD3HYQV3.js';
5
- import { MastraBase } from './chunk-CLJQYXNM.js';
1
+ import { DefaultVoice } from './chunk-FVYYXFPR.js';
2
+ import { MastraLLM } from './chunk-KPOUHZFJ.js';
3
+ import { InstrumentClass } from './chunk-BFNYQFG2.js';
4
+ import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool } from './chunk-ZQ7FXUGY.js';
5
+ import { MastraBase } from './chunk-NDAW47QQ.js';
6
6
  import { RegisteredLogger } from './chunk-2BVZNKLX.js';
7
7
  import { RuntimeContext } from './chunk-SGGPJWRQ.js';
8
8
  import { executeHook } from './chunk-BB4KXGBU.js';
@@ -410,13 +410,13 @@ var Agent = class extends (_a = MastraBase) {
410
410
  };
411
411
  }
412
412
  getResponseMessages({
413
- response,
413
+ messages,
414
414
  threadId,
415
415
  resourceId,
416
416
  now
417
417
  }) {
418
- if (!response.messages) return [];
419
- const messagesArray = Array.isArray(response.messages) ? response.messages : [response.messages];
418
+ if (!messages) return [];
419
+ const messagesArray = Array.isArray(messages) ? messages : [messages];
420
420
  return this.sanitizeResponseMessages(messagesArray).map((message, index) => {
421
421
  const messageId = randomUUID();
422
422
  let toolCallIds;
@@ -826,9 +826,8 @@ var Agent = class extends (_a = MastraBase) {
826
826
  if (memory && resourceId && thread) {
827
827
  try {
828
828
  const userMessage = this.getMostRecentUserMessage(messages);
829
- const newMessages = userMessage ? [userMessage] : messages;
830
829
  const now = Date.now();
831
- const threadMessages = this.sanitizeResponseMessages(ensureAllMessagesAreCoreMessages(newMessages)).map((u, index) => {
830
+ const threadMessages = this.sanitizeResponseMessages(ensureAllMessagesAreCoreMessages(messages)).map((u, index) => {
832
831
  return {
833
832
  id: this.getMemory()?.generateId(),
834
833
  createdAt: new Date(now + index),
@@ -857,18 +856,29 @@ var Agent = class extends (_a = MastraBase) {
857
856
  title
858
857
  });
859
858
  })();
859
+ let responseMessages = result.response.messages;
860
+ if (!responseMessages && result.object) {
861
+ responseMessages = [{
862
+ role: "assistant",
863
+ content: [{
864
+ type: "text",
865
+ text: outputText
866
+ }]
867
+ }];
868
+ }
860
869
  await memory.saveMessages({
861
870
  messages: [...threadMessages, ...this.getResponseMessages({
862
871
  threadId: threadId2,
863
872
  resourceId,
864
- response: result.response,
873
+ messages: responseMessages,
865
874
  now: dateResponseMessagesFrom
866
875
  })],
867
876
  memoryConfig: memoryConfig2
868
877
  });
869
878
  } catch (e) {
879
+ const message = e instanceof Error ? e.message : JSON.stringify(e);
870
880
  this.logger.error("Error saving response", {
871
- error: e,
881
+ error: message,
872
882
  runId: runId2,
873
883
  result: resToLog,
874
884
  threadId: threadId2
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkOHIRECYU_cjs = require('./chunk-OHIRECYU.cjs');
4
- var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
3
+ var chunkFXAV2WYX_cjs = require('./chunk-FXAV2WYX.cjs');
4
+ var chunkRO52JMKQ_cjs = require('./chunk-RO52JMKQ.cjs');
5
5
  var chunkO7IW545H_cjs = require('./chunk-O7IW545H.cjs');
6
6
  var ai = require('ai');
7
7
  var zod = require('zod');
8
8
 
9
9
  // src/llm/model/base.ts
10
- var MastraLLMBase = class extends chunkD63P5O4Q_cjs.MastraBase {
10
+ var MastraLLMBase = class extends chunkRO52JMKQ_cjs.MastraBase {
11
11
  // @ts-ignore
12
12
  #mastra;
13
13
  #model;
@@ -162,7 +162,7 @@ var MastraLLM = class extends MastraLLMBase {
162
162
  });
163
163
  if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
164
164
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
165
- await chunkOHIRECYU_cjs.delay(10 * 1e3);
165
+ await chunkFXAV2WYX_cjs.delay(10 * 1e3);
166
166
  }
167
167
  },
168
168
  ...rest
@@ -231,7 +231,7 @@ var MastraLLM = class extends MastraLLMBase {
231
231
  });
232
232
  if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
233
233
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
234
- await chunkOHIRECYU_cjs.delay(10 * 1e3);
234
+ await chunkFXAV2WYX_cjs.delay(10 * 1e3);
235
235
  }
236
236
  },
237
237
  ...rest
@@ -304,7 +304,7 @@ var MastraLLM = class extends MastraLLMBase {
304
304
  });
305
305
  if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
306
306
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
307
- await chunkOHIRECYU_cjs.delay(10 * 1e3);
307
+ await chunkFXAV2WYX_cjs.delay(10 * 1e3);
308
308
  }
309
309
  },
310
310
  onFinish: async (props) => {
@@ -395,7 +395,7 @@ var MastraLLM = class extends MastraLLMBase {
395
395
  });
396
396
  if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
397
397
  this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
398
- await chunkOHIRECYU_cjs.delay(10 * 1e3);
398
+ await chunkFXAV2WYX_cjs.delay(10 * 1e3);
399
399
  }
400
400
  },
401
401
  onFinish: async (props) => {
@@ -1,4 +1,4 @@
1
- import { MastraBase } from './chunk-CLJQYXNM.js';
1
+ import { MastraBase } from './chunk-NDAW47QQ.js';
2
2
  import { RuntimeContext } from './chunk-SGGPJWRQ.js';
3
3
  import { createHash } from 'crypto';
4
4
  import { convertToCoreMessages, jsonSchema, zodSchema } from 'ai';
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkRZCYBC7D_cjs = require('../chunk-RZCYBC7D.cjs');
3
+ var chunk6NUAJ6AB_cjs = require('../chunk-6NUAJ6AB.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "MastraDeployer", {
8
8
  enumerable: true,
9
- get: function () { return chunkRZCYBC7D_cjs.MastraDeployer; }
9
+ get: function () { return chunk6NUAJ6AB_cjs.MastraDeployer; }
10
10
  });
@@ -1,5 +1,5 @@
1
1
  import { MastraBundler, IBundler } from '../bundler/index.cjs';
2
- import '../base-BihKcqDY.cjs';
2
+ import '../base-D9APQt4V.cjs';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-CquI0inB.cjs';
5
5
  import 'stream';
@@ -1,5 +1,5 @@
1
1
  import { MastraBundler, IBundler } from '../bundler/index.js';
2
- import '../base-DT2poiVK.js';
2
+ import '../base-CeEVvwRi.js';
3
3
  import '@opentelemetry/api';
4
4
  import '../index-CquI0inB.js';
5
5
  import 'stream';
@@ -1 +1 @@
1
- export { MastraDeployer } from '../chunk-5TFGORLG.js';
1
+ export { MastraDeployer } from '../chunk-DWD7X4KB.js';
@@ -1,8 +1,8 @@
1
1
  import { a as Metric, T as TestInfo, E as EvaluationResult } from '../types-BtMyV38I.cjs';
2
2
  export { M as MetricResult } from '../types-BtMyV38I.cjs';
3
- import { F as Agent } from '../base-Cs0ddGCf.cjs';
3
+ import { F as Agent } from '../base-VMWGZau0.cjs';
4
4
  import 'ai';
5
- import '../base-BihKcqDY.cjs';
5
+ import '../base-D9APQt4V.cjs';
6
6
  import '@opentelemetry/api';
7
7
  import '../index-CquI0inB.cjs';
8
8
  import 'stream';
@@ -1,8 +1,8 @@
1
1
  import { a as Metric, T as TestInfo, E as EvaluationResult } from '../types-BtMyV38I.js';
2
2
  export { M as MetricResult } from '../types-BtMyV38I.js';
3
- import { F as Agent } from '../base-CzHSMvOb.js';
3
+ import { F as Agent } from '../base-BCnFhShR.js';
4
4
  import 'ai';
5
- import '../base-DT2poiVK.js';
5
+ import '../base-CeEVvwRi.js';
6
6
  import '@opentelemetry/api';
7
7
  import '../index-CquI0inB.js';
8
8
  import 'stream';