@mastra/core 0.7.0 → 0.8.0-alpha.2

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 (149) hide show
  1. package/README.md +76 -74
  2. package/dist/agent/index.cjs +2 -2
  3. package/dist/agent/index.d.cts +5 -3
  4. package/dist/agent/index.d.ts +5 -3
  5. package/dist/agent/index.js +1 -1
  6. package/dist/{base-Cmunaaxb.d.ts → base-BA_in99t.d.ts} +4 -1
  7. package/dist/{base-Cyl73WbV.d.ts → base-CQuRWXAH.d.ts} +985 -913
  8. package/dist/{base-ObPJ-w8K.d.cts → base-CvQbEqGB.d.cts} +4 -1
  9. package/dist/{base-C0wILuA9.d.cts → base-Dpt4tO56.d.cts} +985 -913
  10. package/dist/base.cjs +2 -2
  11. package/dist/base.d.cts +1 -1
  12. package/dist/base.d.ts +1 -1
  13. package/dist/base.js +1 -1
  14. package/dist/bundler/index.cjs +2 -2
  15. package/dist/bundler/index.d.cts +1 -1
  16. package/dist/bundler/index.d.ts +1 -1
  17. package/dist/bundler/index.js +1 -1
  18. package/dist/{chunk-L7CR75HA.js → chunk-2BVZNKLX.js} +1 -1
  19. package/dist/{chunk-V5ORZPFW.cjs → chunk-3C6V2FEP.cjs} +1 -1
  20. package/dist/chunk-3HE5CJBG.cjs +4604 -0
  21. package/dist/{chunk-PNZK456O.js → chunk-4RMSGSQN.js} +4 -4
  22. package/dist/{chunk-WESJ2ZY7.cjs → chunk-57LXIDIK.cjs} +2 -2
  23. package/dist/chunk-5RRJEWMA.cjs +107 -0
  24. package/dist/{chunk-3CNO7YB5.js → chunk-5TFGORLG.js} +1 -1
  25. package/dist/{chunk-5FAJ6HUC.cjs → chunk-64VPB7ZD.cjs} +23 -2
  26. package/dist/chunk-6XLV4KSD.js +100 -0
  27. package/dist/{chunk-XLSROQ26.cjs → chunk-7I7AKQH3.cjs} +5 -5
  28. package/dist/{chunk-RUA6BSB6.cjs → chunk-7JBINHJX.cjs} +2 -2
  29. package/dist/chunk-A6MBM56X.js +268 -0
  30. package/dist/{chunk-2YF5JYTJ.js → chunk-BC5B4EGI.js} +21 -2
  31. package/dist/chunk-BF7ZLRGO.cjs +271 -0
  32. package/dist/{chunk-SMBKF6K5.js → chunk-BRBHQ6KS.js} +10 -1
  33. package/dist/{chunk-VN4M67DA.js → chunk-CLJQYXNM.js} +1 -1
  34. package/dist/{chunk-PL7PVTGF.cjs → chunk-D63P5O4Q.cjs} +4 -4
  35. package/dist/chunk-DCGLGWHI.cjs +141 -0
  36. package/dist/{chunk-YXJQFZOW.cjs → chunk-DL4QPJKI.cjs} +24 -10
  37. package/dist/{chunk-ZABXT2MN.js → chunk-FY57LEMC.js} +1 -1
  38. package/dist/{chunk-XLXJUYKH.js → chunk-GHK3HBWN.js} +1 -1
  39. package/dist/{chunk-ONDCHP6G.cjs → chunk-GO2D7FEK.cjs} +2 -2
  40. package/dist/{chunk-7VTZI3YN.js → chunk-H6ZU5N2C.js} +1 -1
  41. package/dist/{chunk-WBE5RTFI.js → chunk-HAWAUEWK.js} +2 -2
  42. package/dist/chunk-HCDXBSMK.js +4577 -0
  43. package/dist/{chunk-RU7CSPAV.js → chunk-JGJMVCJ4.js} +7 -84
  44. package/dist/{chunk-W5HVJX45.js → chunk-N5ZYOQBL.js} +46 -5
  45. package/dist/{chunk-NPOKIPWC.cjs → chunk-O7IW545H.cjs} +1 -1
  46. package/dist/{chunk-XB2TJ7LX.cjs → chunk-PHWEC4VD.cjs} +47 -6
  47. package/dist/{chunk-NUDAZEOG.js → chunk-PK5QRKSG.js} +1 -1
  48. package/dist/{chunk-43SD5CUE.js → chunk-QDHRRKQ5.js} +63 -9
  49. package/dist/{chunk-ZBKJDQPM.js → chunk-RBWBJC6D.js} +17 -3
  50. package/dist/{chunk-4PYORXWM.cjs → chunk-RXDLSCBA.cjs} +4 -4
  51. package/dist/{chunk-IQLRSKED.cjs → chunk-RZCYBC7D.cjs} +2 -2
  52. package/dist/{chunk-ASFUEC75.cjs → chunk-TNNHN4ZY.cjs} +67 -12
  53. package/dist/{chunk-QM6WIIPM.js → chunk-UF4LZV3D.js} +1 -1
  54. package/dist/{chunk-JJ4YQTFT.cjs → chunk-WAW7QBY4.cjs} +2 -2
  55. package/dist/{chunk-U7ONOIBO.cjs → chunk-YZDUZFVZ.cjs} +11 -2
  56. package/dist/deployer/index.cjs +2 -2
  57. package/dist/deployer/index.d.cts +1 -1
  58. package/dist/deployer/index.d.ts +1 -1
  59. package/dist/deployer/index.js +1 -1
  60. package/dist/eval/index.cjs +3 -3
  61. package/dist/eval/index.d.cts +8 -5
  62. package/dist/eval/index.d.ts +8 -5
  63. package/dist/eval/index.js +1 -1
  64. package/dist/hooks/index.d.cts +1 -1
  65. package/dist/hooks/index.d.ts +1 -1
  66. package/dist/index.cjs +102 -92
  67. package/dist/index.d.cts +11 -9
  68. package/dist/index.d.ts +11 -9
  69. package/dist/index.js +18 -19
  70. package/dist/integration/index.cjs +3 -3
  71. package/dist/integration/index.d.cts +5 -3
  72. package/dist/integration/index.d.ts +5 -3
  73. package/dist/integration/index.js +1 -1
  74. package/dist/llm/index.d.cts +5 -3
  75. package/dist/llm/index.d.ts +5 -3
  76. package/dist/logger/index.cjs +9 -9
  77. package/dist/logger/index.js +1 -1
  78. package/dist/mastra/index.cjs +2 -2
  79. package/dist/mastra/index.d.cts +5 -3
  80. package/dist/mastra/index.d.ts +5 -3
  81. package/dist/mastra/index.js +1 -1
  82. package/dist/memory/index.cjs +6 -2
  83. package/dist/memory/index.d.cts +5 -3
  84. package/dist/memory/index.d.ts +5 -3
  85. package/dist/memory/index.js +1 -1
  86. package/dist/network/index.cjs +8 -8
  87. package/dist/network/index.d.cts +5 -3
  88. package/dist/network/index.d.ts +5 -3
  89. package/dist/network/index.js +4 -4
  90. package/dist/relevance/index.cjs +4 -4
  91. package/dist/relevance/index.d.cts +10 -8
  92. package/dist/relevance/index.d.ts +10 -8
  93. package/dist/relevance/index.js +1 -1
  94. package/dist/server/index.cjs +17 -0
  95. package/dist/server/index.d.cts +37 -0
  96. package/dist/server/index.d.ts +37 -0
  97. package/dist/server/index.js +15 -0
  98. package/dist/storage/index.cjs +12 -8
  99. package/dist/storage/index.d.cts +5 -3
  100. package/dist/storage/index.d.ts +5 -3
  101. package/dist/storage/index.js +2 -2
  102. package/dist/storage/libsql/index.cjs +24 -24
  103. package/dist/storage/libsql/index.d.cts +5 -3
  104. package/dist/storage/libsql/index.d.ts +5 -3
  105. package/dist/storage/libsql/index.js +12 -12
  106. package/dist/telemetry/index.cjs +6 -6
  107. package/dist/telemetry/index.d.cts +5 -3
  108. package/dist/telemetry/index.d.ts +5 -3
  109. package/dist/telemetry/index.js +1 -1
  110. package/dist/tools/index.cjs +7 -3
  111. package/dist/tools/index.d.cts +6 -3
  112. package/dist/tools/index.d.ts +6 -3
  113. package/dist/tools/index.js +1 -1
  114. package/dist/tts/index.cjs +2 -2
  115. package/dist/tts/index.d.cts +1 -1
  116. package/dist/tts/index.d.ts +1 -1
  117. package/dist/tts/index.js +1 -1
  118. package/dist/{types-CwTG2XyQ.d.cts → types-BtMyV38I.d.cts} +4 -1
  119. package/dist/{types-CwTG2XyQ.d.ts → types-BtMyV38I.d.ts} +4 -1
  120. package/dist/utils.cjs +13 -13
  121. package/dist/utils.d.cts +7 -5
  122. package/dist/utils.d.ts +7 -5
  123. package/dist/utils.js +1 -1
  124. package/dist/vector/index.cjs +2 -2
  125. package/dist/vector/index.d.cts +1 -1
  126. package/dist/vector/index.d.ts +1 -1
  127. package/dist/vector/index.js +1 -1
  128. package/dist/vector/libsql/index.cjs +3 -3
  129. package/dist/vector/libsql/index.d.cts +1 -1
  130. package/dist/vector/libsql/index.d.ts +1 -1
  131. package/dist/vector/libsql/index.js +1 -1
  132. package/dist/voice/index.cjs +13 -249
  133. package/dist/voice/index.d.cts +22 -8
  134. package/dist/voice/index.d.ts +22 -8
  135. package/dist/voice/index.js +1 -252
  136. package/dist/workflows/index.cjs +28 -20
  137. package/dist/workflows/index.d.cts +18 -7
  138. package/dist/workflows/index.d.ts +18 -7
  139. package/dist/workflows/index.js +1 -1
  140. package/package.json +5 -3
  141. package/dist/chunk-2W2GYEYQ.cjs +0 -25
  142. package/dist/chunk-C6BBAS4I.cjs +0 -1715
  143. package/dist/chunk-F5UYWPV4.cjs +0 -14
  144. package/dist/chunk-GG6TEAMJ.cjs +0 -2289
  145. package/dist/chunk-R2M5CZ5U.js +0 -2264
  146. package/dist/chunk-RG66XEJT.js +0 -8
  147. package/dist/chunk-VNQRLYIA.js +0 -1715
  148. package/dist/chunk-WVVKLIUW.cjs +0 -218
  149. package/dist/chunk-ZINPRHAN.js +0 -22
@@ -1,5 +1,5 @@
1
- import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES } from './chunk-RG66XEJT.js';
2
- import { MastraBase } from './chunk-VN4M67DA.js';
1
+ import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-6XLV4KSD.js';
2
+ import { MastraBase } from './chunk-CLJQYXNM.js';
3
3
 
4
4
  // src/storage/base.ts
5
5
  var MastraStorage = class extends MastraBase {
@@ -76,100 +76,23 @@ var MastraStorage = class extends MastraBase {
76
76
  this.hasInitialized = Promise.all([
77
77
  this.createTable({
78
78
  tableName: TABLE_WORKFLOW_SNAPSHOT,
79
- schema: {
80
- workflow_name: {
81
- type: "text"
82
- },
83
- run_id: {
84
- type: "text"
85
- },
86
- snapshot: {
87
- type: "text"
88
- },
89
- createdAt: {
90
- type: "timestamp"
91
- },
92
- updatedAt: {
93
- type: "timestamp"
94
- }
95
- }
79
+ schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
96
80
  }),
97
81
  this.createTable({
98
82
  tableName: TABLE_EVALS,
99
- schema: {
100
- input: {
101
- type: "text"
102
- },
103
- output: {
104
- type: "text"
105
- },
106
- result: {
107
- type: "jsonb"
108
- },
109
- agent_name: {
110
- type: "text"
111
- },
112
- metric_name: {
113
- type: "text"
114
- },
115
- instructions: {
116
- type: "text"
117
- },
118
- test_info: {
119
- type: "jsonb",
120
- nullable: true
121
- },
122
- global_run_id: {
123
- type: "text"
124
- },
125
- run_id: {
126
- type: "text"
127
- },
128
- created_at: {
129
- type: "timestamp"
130
- }
131
- }
83
+ schema: TABLE_SCHEMAS[TABLE_EVALS]
132
84
  }),
133
85
  this.createTable({
134
86
  tableName: TABLE_THREADS,
135
- schema: {
136
- id: { type: "text", nullable: false, primaryKey: true },
137
- resourceId: { type: "text", nullable: false },
138
- title: { type: "text", nullable: false },
139
- metadata: { type: "text", nullable: true },
140
- createdAt: { type: "timestamp", nullable: false },
141
- updatedAt: { type: "timestamp", nullable: false }
142
- }
87
+ schema: TABLE_SCHEMAS[TABLE_THREADS]
143
88
  }),
144
89
  this.createTable({
145
90
  tableName: TABLE_MESSAGES,
146
- schema: {
147
- id: { type: "text", nullable: false, primaryKey: true },
148
- thread_id: { type: "text", nullable: false },
149
- content: { type: "text", nullable: false },
150
- role: { type: "text", nullable: false },
151
- type: { type: "text", nullable: false },
152
- createdAt: { type: "timestamp", nullable: false }
153
- }
91
+ schema: TABLE_SCHEMAS[TABLE_MESSAGES]
154
92
  }),
155
93
  this.createTable({
156
94
  tableName: TABLE_TRACES,
157
- schema: {
158
- id: { type: "text", nullable: false, primaryKey: true },
159
- parentSpanId: { type: "text", nullable: true },
160
- name: { type: "text", nullable: false },
161
- traceId: { type: "text", nullable: false },
162
- scope: { type: "text", nullable: false },
163
- kind: { type: "integer", nullable: false },
164
- attributes: { type: "jsonb", nullable: true },
165
- status: { type: "jsonb", nullable: true },
166
- events: { type: "jsonb", nullable: true },
167
- links: { type: "jsonb", nullable: true },
168
- other: { type: "text", nullable: true },
169
- startTime: { type: "bigint", nullable: false },
170
- endTime: { type: "bigint", nullable: false },
171
- createdAt: { type: "timestamp", nullable: false }
172
- }
95
+ schema: TABLE_SCHEMAS[TABLE_TRACES]
173
96
  })
174
97
  ]).then(() => true);
175
98
  await this.hasInitialized;
@@ -1,4 +1,4 @@
1
- import { TABLE_TRACES } from './chunk-RG66XEJT.js';
1
+ import { TABLE_TRACES } from './chunk-6XLV4KSD.js';
2
2
  import { trace, context, propagation, SpanStatusCode, SpanKind } from '@opentelemetry/api';
3
3
  import { ExportResultCode } from '@opentelemetry/core';
4
4
  import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
@@ -42,13 +42,23 @@ function withSpan(options) {
42
42
  }
43
43
  });
44
44
  const currentBaggage = propagation.getBaggage(ctx);
45
+ if (currentBaggage?.["http.request_id"]) {
46
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
47
+ }
45
48
  if (currentBaggage?.componentName) {
46
49
  span.setAttribute("componentName", currentBaggage?.componentName);
47
50
  span.setAttribute("runId", currentBaggage?.runId);
48
51
  } else if (this && this.name) {
49
52
  span.setAttribute("componentName", this.name);
50
53
  span.setAttribute("runId", this.runId);
51
- ctx = propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
54
+ ctx = propagation.setBaggage(ctx, {
55
+ // @ts-ignore
56
+ componentName: this.name,
57
+ // @ts-ignore
58
+ runId: this.runId,
59
+ // @ts-ignore
60
+ "http.request_id": currentBaggage?.["http.request_id"]
61
+ });
52
62
  }
53
63
  let result;
54
64
  try {
@@ -242,6 +252,10 @@ var Telemetry = class _Telemetry {
242
252
  throw error;
243
253
  }
244
254
  }
255
+ static getActiveSpan() {
256
+ const span = trace.getActiveSpan();
257
+ return span;
258
+ }
245
259
  /**
246
260
  * Get the global telemetry instance
247
261
  * @throws {Error} If telemetry has not been initialized
@@ -282,6 +296,14 @@ var Telemetry = class _Telemetry {
282
296
  }
283
297
  });
284
298
  }
299
+ static setBaggage(baggage, ctx = context.active()) {
300
+ const currentBaggage = propagation.getBaggage(ctx);
301
+ const newCtx = propagation.setBaggage(ctx, { ...currentBaggage, ...baggage });
302
+ return newCtx;
303
+ }
304
+ static withContext(ctx, fn) {
305
+ return context.with(ctx, fn);
306
+ }
285
307
  /**
286
308
  * method to trace individual methods with proper context
287
309
  * @param method The method to trace
@@ -315,24 +337,36 @@ var Telemetry = class _Telemetry {
315
337
  span.end();
316
338
  return res;
317
339
  };
340
+ const currentBaggage = propagation.getBaggage(ctx);
318
341
  if (context3.attributes) {
319
342
  span.setAttributes(context3.attributes);
320
343
  }
344
+ if (currentBaggage?.["http.request_id"]) {
345
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
346
+ }
321
347
  if (context3.attributes?.componentName) {
322
348
  ctx = propagation.setBaggage(ctx, {
323
349
  // @ts-ignore
324
350
  componentName: context3.attributes.componentName,
325
- runId: context3.attributes.runId
351
+ runId: context3.attributes.runId,
352
+ // @ts-ignore
353
+ "http.request_id": currentBaggage?.["http.request_id"]
326
354
  });
327
355
  } else {
328
- const currentBaggage = propagation.getBaggage(ctx);
329
356
  if (currentBaggage?.componentName) {
330
357
  span.setAttribute("componentName", currentBaggage?.componentName);
331
358
  span.setAttribute("runId", currentBaggage?.runId);
332
359
  } else if (this && this.name) {
333
360
  span.setAttribute("componentName", this.name);
334
361
  span.setAttribute("runId", this.runId);
335
- ctx = propagation.setBaggage(ctx, { componentName: this.name, runId: this.runId });
362
+ ctx = propagation.setBaggage(ctx, {
363
+ // @ts-ignore
364
+ componentName: this.name,
365
+ // @ts-ignore
366
+ runId: this.runId,
367
+ // @ts-ignore
368
+ "http.request_id": currentBaggage?.["http.request_id"]
369
+ });
336
370
  }
337
371
  }
338
372
  args.forEach((arg, index) => {
@@ -371,6 +405,7 @@ var BaggageTracer = class {
371
405
  const currentBaggage = propagation.getBaggage(ctx);
372
406
  span.setAttribute("componentName", currentBaggage?.componentName);
373
407
  span.setAttribute("runId", currentBaggage?.runId);
408
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
374
409
  return span;
375
410
  }
376
411
  startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
@@ -378,6 +413,8 @@ var BaggageTracer = class {
378
413
  const wrappedFn2 = (span) => {
379
414
  const currentBaggage = propagation.getBaggage(context.active());
380
415
  span.setAttribute("componentName", currentBaggage?.componentName);
416
+ span.setAttribute("runId", currentBaggage?.runId);
417
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
381
418
  return optionsOrFn(span);
382
419
  };
383
420
  return this._tracer.startActiveSpan(name, {}, context.active(), wrappedFn2);
@@ -386,6 +423,8 @@ var BaggageTracer = class {
386
423
  const wrappedFn2 = (span) => {
387
424
  const currentBaggage = propagation.getBaggage(context.active());
388
425
  span.setAttribute("componentName", currentBaggage?.componentName);
426
+ span.setAttribute("runId", currentBaggage?.runId);
427
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
389
428
  return ctxOrFn(span);
390
429
  };
391
430
  return this._tracer.startActiveSpan(name, optionsOrFn, context.active(), wrappedFn2);
@@ -393,6 +432,8 @@ var BaggageTracer = class {
393
432
  const wrappedFn = (span) => {
394
433
  const currentBaggage = propagation.getBaggage(ctxOrFn ?? context.active());
395
434
  span.setAttribute("componentName", currentBaggage?.componentName);
435
+ span.setAttribute("runId", currentBaggage?.runId);
436
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
396
437
  return fn(span);
397
438
  };
398
439
  return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
@@ -68,7 +68,7 @@ var Logger = class {
68
68
  translateTime: "SYS:standard",
69
69
  singleLine: false
70
70
  }) : pino__default.default.multistream([
71
- ...transportsAry.map(([_, transport]) => ({
71
+ ...transportsAry.map(([, transport]) => ({
72
72
  stream: transport,
73
73
  level: options.level || LogLevel.INFO
74
74
  })),
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkF5UYWPV4_cjs = require('./chunk-F5UYWPV4.cjs');
3
+ var chunk5RRJEWMA_cjs = require('./chunk-5RRJEWMA.cjs');
4
4
  var api = require('@opentelemetry/api');
5
5
  var core = require('@opentelemetry/core');
6
6
  var otlpTransformer = require('@opentelemetry/otlp-transformer');
@@ -44,13 +44,23 @@ function withSpan(options) {
44
44
  }
45
45
  });
46
46
  const currentBaggage = api.propagation.getBaggage(ctx);
47
+ if (currentBaggage?.["http.request_id"]) {
48
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
49
+ }
47
50
  if (currentBaggage?.componentName) {
48
51
  span.setAttribute("componentName", currentBaggage?.componentName);
49
52
  span.setAttribute("runId", currentBaggage?.runId);
50
53
  } else if (this && this.name) {
51
54
  span.setAttribute("componentName", this.name);
52
55
  span.setAttribute("runId", this.runId);
53
- ctx = api.propagation.setBaggage(ctx, { componentName: this.name, 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
+ });
54
64
  }
55
65
  let result;
56
66
  try {
@@ -187,7 +197,7 @@ var OTLPTraceExporter = class {
187
197
  return acc;
188
198
  }, []);
189
199
  return this.storage.__batchInsert({
190
- tableName: chunkF5UYWPV4_cjs.TABLE_TRACES,
200
+ tableName: chunk5RRJEWMA_cjs.TABLE_TRACES,
191
201
  records: allSpans
192
202
  }).then(() => {
193
203
  items.resultCallback({
@@ -244,6 +254,10 @@ var Telemetry = class _Telemetry {
244
254
  throw error;
245
255
  }
246
256
  }
257
+ static getActiveSpan() {
258
+ const span = api.trace.getActiveSpan();
259
+ return span;
260
+ }
247
261
  /**
248
262
  * Get the global telemetry instance
249
263
  * @throws {Error} If telemetry has not been initialized
@@ -284,6 +298,14 @@ var Telemetry = class _Telemetry {
284
298
  }
285
299
  });
286
300
  }
301
+ static setBaggage(baggage, ctx = api.context.active()) {
302
+ const currentBaggage = api.propagation.getBaggage(ctx);
303
+ const newCtx = api.propagation.setBaggage(ctx, { ...currentBaggage, ...baggage });
304
+ return newCtx;
305
+ }
306
+ static withContext(ctx, fn) {
307
+ return api.context.with(ctx, fn);
308
+ }
287
309
  /**
288
310
  * method to trace individual methods with proper context
289
311
  * @param method The method to trace
@@ -317,24 +339,36 @@ var Telemetry = class _Telemetry {
317
339
  span.end();
318
340
  return res;
319
341
  };
342
+ const currentBaggage = api.propagation.getBaggage(ctx);
320
343
  if (context3.attributes) {
321
344
  span.setAttributes(context3.attributes);
322
345
  }
346
+ if (currentBaggage?.["http.request_id"]) {
347
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
348
+ }
323
349
  if (context3.attributes?.componentName) {
324
350
  ctx = api.propagation.setBaggage(ctx, {
325
351
  // @ts-ignore
326
352
  componentName: context3.attributes.componentName,
327
- runId: context3.attributes.runId
353
+ runId: context3.attributes.runId,
354
+ // @ts-ignore
355
+ "http.request_id": currentBaggage?.["http.request_id"]
328
356
  });
329
357
  } else {
330
- const currentBaggage = api.propagation.getBaggage(ctx);
331
358
  if (currentBaggage?.componentName) {
332
359
  span.setAttribute("componentName", currentBaggage?.componentName);
333
360
  span.setAttribute("runId", currentBaggage?.runId);
334
361
  } else if (this && this.name) {
335
362
  span.setAttribute("componentName", this.name);
336
363
  span.setAttribute("runId", this.runId);
337
- ctx = api.propagation.setBaggage(ctx, { componentName: this.name, 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
+ });
338
372
  }
339
373
  }
340
374
  args.forEach((arg, index) => {
@@ -373,6 +407,7 @@ var BaggageTracer = class {
373
407
  const currentBaggage = api.propagation.getBaggage(ctx);
374
408
  span.setAttribute("componentName", currentBaggage?.componentName);
375
409
  span.setAttribute("runId", currentBaggage?.runId);
410
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
376
411
  return span;
377
412
  }
378
413
  startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
@@ -380,6 +415,8 @@ var BaggageTracer = class {
380
415
  const wrappedFn2 = (span) => {
381
416
  const currentBaggage = api.propagation.getBaggage(api.context.active());
382
417
  span.setAttribute("componentName", currentBaggage?.componentName);
418
+ span.setAttribute("runId", currentBaggage?.runId);
419
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
383
420
  return optionsOrFn(span);
384
421
  };
385
422
  return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
@@ -388,6 +425,8 @@ var BaggageTracer = class {
388
425
  const wrappedFn2 = (span) => {
389
426
  const currentBaggage = api.propagation.getBaggage(api.context.active());
390
427
  span.setAttribute("componentName", currentBaggage?.componentName);
428
+ span.setAttribute("runId", currentBaggage?.runId);
429
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
391
430
  return ctxOrFn(span);
392
431
  };
393
432
  return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
@@ -395,6 +434,8 @@ var BaggageTracer = class {
395
434
  const wrappedFn = (span) => {
396
435
  const currentBaggage = api.propagation.getBaggage(ctxOrFn ?? api.context.active());
397
436
  span.setAttribute("componentName", currentBaggage?.componentName);
437
+ span.setAttribute("runId", currentBaggage?.runId);
438
+ span.setAttribute("http.request_id", currentBaggage?.["http.request_id"]);
398
439
  return fn(span);
399
440
  };
400
441
  return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
@@ -29,7 +29,7 @@ async function evaluate({
29
29
  testInfo
30
30
  };
31
31
  executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
32
- return metricResult;
32
+ return { ...metricResult, output };
33
33
  }
34
34
 
35
35
  export { Metric, evaluate };
@@ -1,7 +1,7 @@
1
- import { LibSQLVector } from './chunk-SMBKF6K5.js';
2
- import { DefaultProxyStorage } from './chunk-7VTZI3YN.js';
3
- import { deepMerge } from './chunk-2YF5JYTJ.js';
4
- import { MastraBase } from './chunk-VN4M67DA.js';
1
+ import { LibSQLVector } from './chunk-BRBHQ6KS.js';
2
+ import { DefaultProxyStorage } from './chunk-H6ZU5N2C.js';
3
+ import { deepMerge } from './chunk-BC5B4EGI.js';
4
+ import { MastraBase } from './chunk-CLJQYXNM.js';
5
5
  import { existsSync } from 'fs';
6
6
  import { join } from 'path';
7
7
  import fsp from 'node:fs/promises';
@@ -106,11 +106,22 @@ var fastEmbedProvider = experimental_customProvider({
106
106
  var defaultEmbedder = fastEmbedProvider.textEmbeddingModel;
107
107
 
108
108
  // src/memory/memory.ts
109
+ var MemoryProcessor = class extends MastraBase {
110
+ /**
111
+ * Process a list of messages and return a filtered or transformed list.
112
+ * @param messages The messages to process
113
+ * @returns The processed messages
114
+ */
115
+ process(messages, _opts) {
116
+ return messages;
117
+ }
118
+ };
109
119
  var MastraMemory = class extends MastraBase {
110
120
  MAX_CONTEXT_TOKENS;
111
121
  storage;
112
122
  vector;
113
123
  embedder;
124
+ processors = [];
114
125
  threadConfig = {
115
126
  lastMessages: 40,
116
127
  semanticRecall: true,
@@ -149,6 +160,9 @@ var MastraMemory = class extends MastraBase {
149
160
  if (config.options) {
150
161
  this.threadConfig = this.getMergedThreadConfig(config.options);
151
162
  }
163
+ if (config.processors) {
164
+ this.processors = config.processors;
165
+ }
152
166
  }
153
167
  setStorage(storage) {
154
168
  this.storage = storage;
@@ -191,14 +205,52 @@ var MastraMemory = class extends MastraBase {
191
205
  getMergedThreadConfig(config) {
192
206
  return deepMerge(this.threadConfig, config || {});
193
207
  }
208
+ /**
209
+ * Apply all configured message processors to a list of messages.
210
+ * @param messages The messages to process
211
+ * @returns The processed messages
212
+ */
213
+ applyProcessors(messages, opts) {
214
+ const processors = opts.processors || this.processors;
215
+ if (!processors || processors.length === 0) {
216
+ return messages;
217
+ }
218
+ let processedMessages = [...messages];
219
+ for (const processor of processors) {
220
+ processedMessages = processor.process(processedMessages, {
221
+ systemMessage: opts.systemMessage,
222
+ newMessages: opts.newMessages,
223
+ memorySystemMessage: opts.memorySystemMessage
224
+ });
225
+ }
226
+ return processedMessages;
227
+ }
228
+ processMessages({
229
+ messages,
230
+ processors,
231
+ ...opts
232
+ }) {
233
+ return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });
234
+ }
194
235
  estimateTokens(text) {
195
236
  return Math.ceil(text.split(" ").length * 1.3);
196
237
  }
197
238
  parseMessages(messages) {
198
- return messages.map((msg) => ({
199
- ...msg,
200
- content: typeof msg.content === "string" && (msg.content.startsWith("[") || msg.content.startsWith("{")) ? JSON.parse(msg.content) : typeof msg.content === "number" ? String(msg.content) : msg.content
201
- }));
239
+ return messages.map((msg) => {
240
+ let content = msg.content;
241
+ if (typeof content === "string" && (content.startsWith("[") || content.startsWith("{"))) {
242
+ try {
243
+ content = JSON.parse(content);
244
+ } catch {
245
+ }
246
+ } else if (typeof content === "number") {
247
+ content = String(content);
248
+ }
249
+ return {
250
+ ...msg,
251
+ content
252
+ };
253
+ });
202
254
  }
203
255
  convertToUIMessages(messages) {
204
256
  function addToolMessageToChat({
@@ -307,6 +359,7 @@ var MastraMemory = class extends MastraBase {
307
359
  */
308
360
  async addMessage({
309
361
  threadId,
362
+ resourceId,
310
363
  config,
311
364
  content,
312
365
  role,
@@ -321,6 +374,7 @@ var MastraMemory = class extends MastraBase {
321
374
  role,
322
375
  createdAt: /* @__PURE__ */ new Date(),
323
376
  threadId,
377
+ resourceId,
324
378
  type,
325
379
  toolNames,
326
380
  toolCallArgs,
@@ -338,4 +392,4 @@ var MastraMemory = class extends MastraBase {
338
392
  }
339
393
  };
340
394
 
341
- export { MastraMemory };
395
+ export { MastraMemory, MemoryProcessor };
@@ -1,6 +1,6 @@
1
- import { DefaultProxyStorage } from './chunk-7VTZI3YN.js';
2
- import { InstrumentClass, Telemetry } from './chunk-W5HVJX45.js';
3
- import { createLogger, LogLevel, noopLogger } from './chunk-L7CR75HA.js';
1
+ import { DefaultProxyStorage } from './chunk-H6ZU5N2C.js';
2
+ import { InstrumentClass, Telemetry } from './chunk-N5ZYOQBL.js';
3
+ import { createLogger, LogLevel, noopLogger } from './chunk-2BVZNKLX.js';
4
4
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
5
5
 
6
6
  // src/mastra/index.ts
@@ -21,6 +21,7 @@ var Mastra = class {
21
21
  #storage;
22
22
  #memory;
23
23
  #networks;
24
+ #server;
24
25
  /**
25
26
  * @deprecated use getTelemetry() instead
26
27
  */
@@ -173,6 +174,9 @@ This is a warning for now, but will throw an error in the future
173
174
  this.#workflows[key] = workflow;
174
175
  });
175
176
  }
177
+ if (config?.server) {
178
+ this.#server = config.server;
179
+ }
176
180
  this.setLogger({
177
181
  logger
178
182
  });
@@ -332,6 +336,9 @@ This is a warning for now, but will throw an error in the future
332
336
  getNetworks() {
333
337
  return Object.values(this.#networks || {});
334
338
  }
339
+ getServer() {
340
+ return this.#server;
341
+ }
335
342
  /**
336
343
  * Get a specific network by ID
337
344
  * @param networkId - The ID of the network to retrieve
@@ -351,6 +358,9 @@ This is a warning for now, but will throw an error in the future
351
358
  if (!transportId) {
352
359
  throw new Error("Transport ID is required");
353
360
  }
361
+ if (!this.#logger?.getLogsByRunId) {
362
+ throw new Error("Logger is not set");
363
+ }
354
364
  return await this.#logger.getLogsByRunId({
355
365
  runId,
356
366
  transportId
@@ -360,6 +370,10 @@ This is a warning for now, but will throw an error in the future
360
370
  if (!transportId) {
361
371
  throw new Error("Transport ID is required");
362
372
  }
373
+ if (!this.#logger?.getLogs) {
374
+ throw new Error("Logger is not set");
375
+ }
376
+ console.log(this.#logger);
363
377
  return await this.#logger.getLogs(transportId);
364
378
  }
365
379
  };
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkXB2TJ7LX_cjs = require('./chunk-XB2TJ7LX.cjs');
4
- var chunkPL7PVTGF_cjs = require('./chunk-PL7PVTGF.cjs');
3
+ var chunkPHWEC4VD_cjs = require('./chunk-PHWEC4VD.cjs');
4
+ var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
5
5
  var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
6
6
 
7
7
  // src/tts/index.ts
8
8
  var _MastraTTS_decorators, _init, _a;
9
- _MastraTTS_decorators = [chunkXB2TJ7LX_cjs.InstrumentClass({
9
+ _MastraTTS_decorators = [chunkPHWEC4VD_cjs.InstrumentClass({
10
10
  prefix: "tts",
11
11
  excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
12
12
  })];
13
- exports.MastraTTS = class MastraTTS extends (_a = chunkPL7PVTGF_cjs.MastraBase) {
13
+ exports.MastraTTS = class MastraTTS extends (_a = chunkD63P5O4Q_cjs.MastraBase) {
14
14
  model;
15
15
  constructor({
16
16
  model
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkJJ4YQTFT_cjs = require('./chunk-JJ4YQTFT.cjs');
3
+ var chunkWAW7QBY4_cjs = require('./chunk-WAW7QBY4.cjs');
4
4
 
5
5
  // src/deployer/index.ts
6
- var MastraDeployer = class extends chunkJJ4YQTFT_cjs.MastraBundler {
6
+ var MastraDeployer = class extends chunkWAW7QBY4_cjs.MastraBundler {
7
7
  constructor({ name }) {
8
8
  super({ component: "DEPLOYER", name });
9
9
  }