@mastra/server 0.10.9-alpha.0 → 0.10.10-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 (57) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +2 -0
  2. package/dist/_tsup-dts-rollup.d.ts +2 -0
  3. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  4. package/dist/{chunk-DPRB3R7Y.cjs → chunk-2SLFAFTR.cjs} +12 -12
  5. package/dist/{chunk-BOXE6WSV.js → chunk-4D66QEKC.js} +2 -2
  6. package/dist/{chunk-7GQJAMTA.js → chunk-5PQQ42EZ.js} +2 -2
  7. package/dist/{chunk-TVBPFPTN.cjs → chunk-7TP2LX5L.cjs} +16 -16
  8. package/dist/{chunk-4QBIUKVY.js → chunk-BK4XT6EG.js} +3 -3
  9. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  10. package/dist/{chunk-VMXLEF54.js → chunk-CRCR3ZUK.js} +3 -3
  11. package/dist/{chunk-3DKDT264.cjs → chunk-DN7K6FJK.cjs} +34 -34
  12. package/dist/{chunk-FGGMQCPP.cjs → chunk-FRVBFMO2.cjs} +15 -15
  13. package/dist/{chunk-ULFULEW4.cjs → chunk-G7KH752Y.cjs} +5 -5
  14. package/dist/{chunk-Z5TH5F35.js → chunk-I2PBVVNV.js} +2 -2
  15. package/dist/{chunk-TGZIR6AK.cjs → chunk-JMLYCXMK.cjs} +36 -36
  16. package/dist/{chunk-G37NVEDX.js → chunk-KHZKYUNR.js} +3 -3
  17. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  18. package/dist/{chunk-QDOJJCS4.js → chunk-LF7P5PLR.js} +4 -2
  19. package/dist/{chunk-DFJUGWNU.js → chunk-LRCAAFUA.js} +3 -3
  20. package/dist/{chunk-BWHGBV3K.cjs → chunk-LZ3VJXSO.cjs} +14 -14
  21. package/dist/{chunk-LTJNMM2Y.js → chunk-MKLYEKEF.js} +3 -3
  22. package/dist/{chunk-MTR2B27E.cjs → chunk-PZQDCRPV.cjs} +5 -3
  23. package/dist/{chunk-CNVDCLSY.cjs → chunk-QGX47B5D.cjs} +7 -7
  24. package/dist/{chunk-BP24Z4WG.js → chunk-RG473F6Y.js} +2 -2
  25. package/dist/{chunk-L3N7ST2Z.cjs → chunk-RHSWAXKB.cjs} +22 -22
  26. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  27. package/dist/{chunk-7524QH7G.cjs → chunk-SAI3WQ7Z.cjs} +58 -58
  28. package/dist/{chunk-FVMGZKFD.js → chunk-WNVFNNWN.js} +2 -2
  29. package/dist/server/handlers/agents.cjs +7 -7
  30. package/dist/server/handlers/agents.js +1 -1
  31. package/dist/server/handlers/error.cjs +2 -2
  32. package/dist/server/handlers/error.js +1 -1
  33. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  34. package/dist/server/handlers/legacyWorkflows.js +1 -1
  35. package/dist/server/handlers/logs.cjs +4 -4
  36. package/dist/server/handlers/logs.js +1 -1
  37. package/dist/server/handlers/memory.cjs +9 -9
  38. package/dist/server/handlers/memory.js +1 -1
  39. package/dist/server/handlers/network.cjs +5 -5
  40. package/dist/server/handlers/network.js +1 -1
  41. package/dist/server/handlers/telemetry.cjs +3 -3
  42. package/dist/server/handlers/telemetry.js +1 -1
  43. package/dist/server/handlers/tools.cjs +5 -5
  44. package/dist/server/handlers/tools.js +1 -1
  45. package/dist/server/handlers/utils.cjs +2 -2
  46. package/dist/server/handlers/utils.js +1 -1
  47. package/dist/server/handlers/vNextNetwork.cjs +18 -18
  48. package/dist/server/handlers/vNextNetwork.js +3 -3
  49. package/dist/server/handlers/vector.cjs +7 -7
  50. package/dist/server/handlers/vector.js +1 -1
  51. package/dist/server/handlers/voice.cjs +5 -5
  52. package/dist/server/handlers/voice.js +1 -1
  53. package/dist/server/handlers/workflows.cjs +14 -14
  54. package/dist/server/handlers/workflows.js +1 -1
  55. package/dist/server/handlers.cjs +20 -20
  56. package/dist/server/handlers.js +10 -10
  57. package/package.json +3 -3
@@ -560,11 +560,13 @@ export declare class HTTPException extends Error {
560
560
  * @property res - Optional response object to use.
561
561
  * @property message - Optional custom error message.
562
562
  * @property cause - Optional cause of the error.
563
+ * @property stack - Optional stack trace for the error.
563
564
  */
564
565
  declare type HTTPExceptionOptions = {
565
566
  res?: Response;
566
567
  message?: string;
567
568
  cause?: unknown;
569
+ stack?: string;
568
570
  };
569
571
 
570
572
  /**
@@ -560,11 +560,13 @@ export declare class HTTPException extends Error {
560
560
  * @property res - Optional response object to use.
561
561
  * @property message - Optional custom error message.
562
562
  * @property cause - Optional cause of the error.
563
+ * @property stack - Optional stack trace for the error.
563
564
  */
564
565
  declare type HTTPExceptionOptions = {
565
566
  res?: Response;
566
567
  message?: string;
567
568
  cause?: unknown;
569
+ stack?: string;
568
570
  };
569
571
 
570
572
  /**
@@ -13,6 +13,7 @@ var HTTPException = class extends Error {
13
13
  super(options?.message, { cause: options?.cause });
14
14
  this.res = options?.res;
15
15
  this.status = status;
16
+ this.stack = options?.stack || this.stack;
16
17
  }
17
18
  /**
18
19
  * Returns the response object associated with the exception.
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
 
8
8
  // src/server/handlers/network.ts
@@ -47,7 +47,7 @@ async function getNetworksHandler({
47
47
  );
48
48
  return serializedNetworks;
49
49
  } catch (error) {
50
- return chunkMTR2B27E_cjs.handleError(error, "Error getting networks");
50
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting networks");
51
51
  }
52
52
  }
53
53
  async function getNetworkByIdHandler({
@@ -62,7 +62,7 @@ async function getNetworkByIdHandler({
62
62
  return network2.formatAgentId(routingAgent2.name) === networkId;
63
63
  });
64
64
  if (!network) {
65
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
65
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
66
66
  }
67
67
  const routingAgent = network.getRoutingAgent();
68
68
  const routingLLM = await routingAgent.getLLM({ runtimeContext });
@@ -88,7 +88,7 @@ async function getNetworkByIdHandler({
88
88
  };
89
89
  return serializedNetwork;
90
90
  } catch (error) {
91
- return chunkMTR2B27E_cjs.handleError(error, "Error getting network by ID");
91
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting network by ID");
92
92
  }
93
93
  }
94
94
  async function generateHandler({
@@ -100,14 +100,14 @@ async function generateHandler({
100
100
  try {
101
101
  const network = mastra.getNetwork(networkId);
102
102
  if (!network) {
103
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
103
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
104
104
  }
105
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
105
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
106
106
  const { messages, ...rest } = body;
107
107
  const result = await network.generate(messages, { ...rest, runtimeContext });
108
108
  return result;
109
109
  } catch (error) {
110
- return chunkMTR2B27E_cjs.handleError(error, "Error generating from network");
110
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from network");
111
111
  }
112
112
  }
113
113
  async function streamGenerateHandler({
@@ -119,9 +119,9 @@ async function streamGenerateHandler({
119
119
  try {
120
120
  const network = mastra.getNetwork(networkId);
121
121
  if (!network) {
122
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
122
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
123
123
  }
124
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
124
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
125
125
  const { messages, output, ...rest } = body;
126
126
  const streamResult = await network.stream(messages, {
127
127
  output,
@@ -137,7 +137,7 @@ async function streamGenerateHandler({
137
137
  });
138
138
  return streamResponse;
139
139
  } catch (error) {
140
- return chunkMTR2B27E_cjs.handleError(error, "Error streaming from network");
140
+ return chunkPZQDCRPV_cjs.handleError(error, "Error streaming from network");
141
141
  }
142
142
  }
143
143
 
@@ -1,5 +1,5 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-QDOJJCS4.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/logs.ts
@@ -1,6 +1,6 @@
1
1
  import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { handleError } from './chunk-QDOJJCS4.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { ReadableStream } from 'stream/web';
6
6
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
4
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/vector.ts
@@ -16,24 +16,24 @@ chunk75ZPJI57_cjs.__export(vector_exports, {
16
16
  });
17
17
  function getVector(mastra, vectorName) {
18
18
  if (!vectorName) {
19
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Vector name is required" });
19
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Vector name is required" });
20
20
  }
21
21
  const vector = mastra.getVector(vectorName);
22
22
  if (!vector) {
23
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
24
24
  }
25
25
  return vector;
26
26
  }
27
27
  async function upsertVectors({ mastra, vectorName, index }) {
28
28
  try {
29
29
  if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
30
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
31
31
  }
32
32
  const vector = getVector(mastra, vectorName);
33
33
  const result = await vector.upsert(index);
34
34
  return { ids: result };
35
35
  } catch (error) {
36
- return chunkMTR2B27E_cjs.handleError(error, "Error upserting vectors");
36
+ return chunkPZQDCRPV_cjs.handleError(error, "Error upserting vectors");
37
37
  }
38
38
  }
39
39
  async function createIndex({
@@ -44,18 +44,18 @@ async function createIndex({
44
44
  try {
45
45
  const { indexName, dimension, metric } = index;
46
46
  if (!indexName || typeof dimension !== "number" || dimension <= 0) {
47
- throw new chunkOCWPVYNI_cjs.HTTPException(400, {
47
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, {
48
48
  message: "Invalid request index, indexName and positive dimension number are required."
49
49
  });
50
50
  }
51
51
  if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
52
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
53
53
  }
54
54
  const vector = getVector(mastra, vectorName);
55
55
  await vector.createIndex({ indexName, dimension, metric });
56
56
  return { success: true };
57
57
  } catch (error) {
58
- return chunkMTR2B27E_cjs.handleError(error, "Error creating index");
58
+ return chunkPZQDCRPV_cjs.handleError(error, "Error creating index");
59
59
  }
60
60
  }
61
61
  async function queryVectors({
@@ -65,13 +65,13 @@ async function queryVectors({
65
65
  }) {
66
66
  try {
67
67
  if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
69
69
  }
70
70
  const vector = getVector(mastra, vectorName);
71
71
  const results = await vector.query(query);
72
72
  return results;
73
73
  } catch (error) {
74
- return chunkMTR2B27E_cjs.handleError(error, "Error querying vectors");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error querying vectors");
75
75
  }
76
76
  }
77
77
  async function listIndexes({ mastra, vectorName }) {
@@ -80,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
80
80
  const indexes = await vector.listIndexes();
81
81
  return indexes.filter(Boolean);
82
82
  } catch (error) {
83
- return chunkMTR2B27E_cjs.handleError(error, "Error listing indexes");
83
+ return chunkPZQDCRPV_cjs.handleError(error, "Error listing indexes");
84
84
  }
85
85
  }
86
86
  async function describeIndex({
@@ -90,7 +90,7 @@ async function describeIndex({
90
90
  }) {
91
91
  try {
92
92
  if (!indexName) {
93
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
93
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
94
94
  }
95
95
  const vector = getVector(mastra, vectorName);
96
96
  const stats = await vector.describeIndex({ indexName });
@@ -100,7 +100,7 @@ async function describeIndex({
100
100
  metric: stats.metric?.toLowerCase()
101
101
  };
102
102
  } catch (error) {
103
- return chunkMTR2B27E_cjs.handleError(error, "Error describing index");
103
+ return chunkPZQDCRPV_cjs.handleError(error, "Error describing index");
104
104
  }
105
105
  }
106
106
  async function deleteIndex({
@@ -110,13 +110,13 @@ async function deleteIndex({
110
110
  }) {
111
111
  try {
112
112
  if (!indexName) {
113
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
113
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
114
114
  }
115
115
  const vector = getVector(mastra, vectorName);
116
116
  await vector.deleteIndex({ indexName });
117
117
  return { success: true };
118
118
  } catch (error) {
119
- return chunkMTR2B27E_cjs.handleError(error, "Error deleting index");
119
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting index");
120
120
  }
121
121
  }
122
122
 
@@ -1,7 +1,7 @@
1
1
  import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-QDOJJCS4.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
2
+ import { validateBody } from './chunk-RSEO4XPX.js';
3
+ import { handleError } from './chunk-LF7P5PLR.js';
4
+ import { HTTPException } from './chunk-LCM566I4.js';
5
5
  import { __export } from './chunk-MLKGABMK.js';
6
6
  import { RuntimeContext } from '@mastra/core/runtime-context';
7
7
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
4
4
 
5
5
  // src/server/handlers/utils.ts
6
6
  function validateBody(body) {
@@ -11,7 +11,7 @@ function validateBody(body) {
11
11
  return acc;
12
12
  }, {});
13
13
  if (Object.keys(errorResponse).length > 0) {
14
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
14
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
15
15
  }
16
16
  }
17
17
 
@@ -1,6 +1,6 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-QDOJJCS4.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
 
6
6
  // src/server/handlers/network.ts
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
 
8
8
  // src/server/handlers/memory.ts
@@ -25,11 +25,11 @@ async function getMemoryFromContext({
25
25
  }) {
26
26
  const agent = agentId ? mastra.getAgent(agentId) : null;
27
27
  if (agentId && !agent) {
28
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
28
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
29
29
  }
30
30
  const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
31
31
  if (networkId && !network) {
32
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
32
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
33
33
  }
34
34
  if (agent) {
35
35
  return agent?.getMemory() || mastra.getMemory();
@@ -52,7 +52,7 @@ async function getMemoryStatusHandler({
52
52
  }
53
53
  return { result: true };
54
54
  } catch (error) {
55
- return chunkMTR2B27E_cjs.handleError(error, "Error getting memory status");
55
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting memory status");
56
56
  }
57
57
  }
58
58
  async function getThreadsHandler({
@@ -65,13 +65,13 @@ async function getThreadsHandler({
65
65
  try {
66
66
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
67
67
  if (!memory) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
69
69
  }
70
- chunk57CJTIPW_cjs.validateBody({ resourceId });
70
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId });
71
71
  const threads = await memory.getThreadsByResourceId({ resourceId });
72
72
  return threads;
73
73
  } catch (error) {
74
- return chunkMTR2B27E_cjs.handleError(error, "Error getting threads");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting threads");
75
75
  }
76
76
  }
77
77
  async function getThreadByIdHandler({
@@ -82,18 +82,18 @@ async function getThreadByIdHandler({
82
82
  runtimeContext
83
83
  }) {
84
84
  try {
85
- chunk57CJTIPW_cjs.validateBody({ threadId });
85
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
86
86
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
87
87
  if (!memory) {
88
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
88
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
89
89
  }
90
90
  const thread = await memory.getThreadById({ threadId });
91
91
  if (!thread) {
92
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
92
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
93
93
  }
94
94
  return thread;
95
95
  } catch (error) {
96
- return chunkMTR2B27E_cjs.handleError(error, "Error getting thread");
96
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting thread");
97
97
  }
98
98
  }
99
99
  async function saveMessagesHandler({
@@ -106,13 +106,13 @@ async function saveMessagesHandler({
106
106
  try {
107
107
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
108
108
  if (!memory) {
109
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
109
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
110
110
  }
111
111
  if (!body?.messages) {
112
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
112
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages are required" });
113
113
  }
114
114
  if (!Array.isArray(body.messages)) {
115
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
115
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages should be an array" });
116
116
  }
117
117
  const processedMessages = body.messages.map((message) => ({
118
118
  ...message,
@@ -122,7 +122,7 @@ async function saveMessagesHandler({
122
122
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
123
123
  return result;
124
124
  } catch (error) {
125
- return chunkMTR2B27E_cjs.handleError(error, "Error saving messages");
125
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving messages");
126
126
  }
127
127
  }
128
128
  async function createThreadHandler({
@@ -135,9 +135,9 @@ async function createThreadHandler({
135
135
  try {
136
136
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
137
137
  if (!memory) {
138
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
138
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
139
139
  }
140
- chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
140
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId: body?.resourceId });
141
141
  const result = await memory.createThread({
142
142
  resourceId: body?.resourceId,
143
143
  title: body?.title,
@@ -146,7 +146,7 @@ async function createThreadHandler({
146
146
  });
147
147
  return result;
148
148
  } catch (error) {
149
- return chunkMTR2B27E_cjs.handleError(error, "Error saving thread to memory");
149
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving thread to memory");
150
150
  }
151
151
  }
152
152
  async function updateThreadHandler({
@@ -160,17 +160,17 @@ async function updateThreadHandler({
160
160
  try {
161
161
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
162
162
  if (!body) {
163
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
163
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
164
164
  }
165
165
  const { title, metadata, resourceId } = body;
166
166
  const updatedAt = /* @__PURE__ */ new Date();
167
- chunk57CJTIPW_cjs.validateBody({ threadId });
167
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
168
168
  if (!memory) {
169
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
169
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
170
170
  }
171
171
  const thread = await memory.getThreadById({ threadId });
172
172
  if (!thread) {
173
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
173
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
174
174
  }
175
175
  const updatedThread = {
176
176
  ...thread,
@@ -183,7 +183,7 @@ async function updateThreadHandler({
183
183
  const result = await memory.saveThread({ thread: updatedThread });
184
184
  return result;
185
185
  } catch (error) {
186
- return chunkMTR2B27E_cjs.handleError(error, "Error updating thread");
186
+ return chunkPZQDCRPV_cjs.handleError(error, "Error updating thread");
187
187
  }
188
188
  }
189
189
  async function deleteThreadHandler({
@@ -194,19 +194,19 @@ async function deleteThreadHandler({
194
194
  runtimeContext
195
195
  }) {
196
196
  try {
197
- chunk57CJTIPW_cjs.validateBody({ threadId });
197
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
198
198
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
199
199
  if (!memory) {
200
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
200
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
201
201
  }
202
202
  const thread = await memory.getThreadById({ threadId });
203
203
  if (!thread) {
204
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
204
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
205
205
  }
206
206
  await memory.deleteThread(threadId);
207
207
  return { result: "Thread deleted" };
208
208
  } catch (error) {
209
- return chunkMTR2B27E_cjs.handleError(error, "Error deleting thread");
209
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting thread");
210
210
  }
211
211
  }
212
212
  async function getMessagesHandler({
@@ -218,17 +218,17 @@ async function getMessagesHandler({
218
218
  runtimeContext
219
219
  }) {
220
220
  if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
221
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
221
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
222
222
  }
223
223
  try {
224
- chunk57CJTIPW_cjs.validateBody({ threadId });
224
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
225
225
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
226
226
  if (!memory) {
227
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
227
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
228
228
  }
229
229
  const thread = await memory.getThreadById({ threadId });
230
230
  if (!thread) {
231
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
231
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
232
232
  }
233
233
  const result = await memory.query({
234
234
  threadId,
@@ -236,7 +236,7 @@ async function getMessagesHandler({
236
236
  });
237
237
  return { messages: result.messages, uiMessages: result.uiMessages };
238
238
  } catch (error) {
239
- return chunkMTR2B27E_cjs.handleError(error, "Error getting messages");
239
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting messages");
240
240
  }
241
241
  }
242
242
 
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
6
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
4
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
5
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
6
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
7
7
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
8
  var tools = require('@mastra/core/tools');
9
9
 
@@ -34,14 +34,14 @@ async function getToolsHandler({ tools }) {
34
34
  );
35
35
  return serializedTools;
36
36
  } catch (error) {
37
- return chunkMTR2B27E_cjs.handleError(error, "Error getting tools");
37
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tools");
38
38
  }
39
39
  }
40
40
  async function getToolByIdHandler({ tools, toolId }) {
41
41
  try {
42
42
  const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
43
43
  if (!tool) {
44
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
44
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
45
45
  }
46
46
  const serializedTool = {
47
47
  ...tool,
@@ -50,7 +50,7 @@ async function getToolByIdHandler({ tools, toolId }) {
50
50
  };
51
51
  return serializedTool;
52
52
  } catch (error) {
53
- return chunkMTR2B27E_cjs.handleError(error, "Error getting tool");
53
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tool");
54
54
  }
55
55
  }
56
56
  function executeToolHandler(tools$1) {
@@ -63,16 +63,16 @@ function executeToolHandler(tools$1) {
63
63
  }) => {
64
64
  try {
65
65
  if (!toolId) {
66
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool ID is required" });
66
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool ID is required" });
67
67
  }
68
68
  const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
69
69
  if (!tool) {
70
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
70
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
71
71
  }
72
72
  if (!tool?.execute) {
73
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
73
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
74
74
  }
75
- chunk57CJTIPW_cjs.validateBody({ data });
75
+ chunkCCGRCYWJ_cjs.validateBody({ data });
76
76
  if (tools.isVercelTool(tool)) {
77
77
  const result2 = await tool.execute(data);
78
78
  return result2;
@@ -85,7 +85,7 @@ function executeToolHandler(tools$1) {
85
85
  });
86
86
  return result;
87
87
  } catch (error) {
88
- return chunkMTR2B27E_cjs.handleError(error, "Error executing tool");
88
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
89
89
  }
90
90
  };
91
91
  }
@@ -99,15 +99,15 @@ async function executeAgentToolHandler({
99
99
  try {
100
100
  const agent = agentId ? mastra.getAgent(agentId) : null;
101
101
  if (!agent) {
102
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
102
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
103
103
  }
104
104
  const agentTools = await agent.getTools({ runtimeContext });
105
105
  const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
106
106
  if (!tool) {
107
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
107
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
108
108
  }
109
109
  if (!tool?.execute) {
110
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
110
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
111
111
  }
112
112
  const result = await tool.execute({
113
113
  context: data,
@@ -117,7 +117,7 @@ async function executeAgentToolHandler({
117
117
  });
118
118
  return result;
119
119
  } catch (error) {
120
- return chunkMTR2B27E_cjs.handleError(error, "Error executing tool");
120
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
121
121
  }
122
122
  }
123
123
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
4
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/telemetry.ts
@@ -15,13 +15,13 @@ async function getTelemetryHandler({ mastra, body }) {
15
15
  const telemetry = mastra.getTelemetry();
16
16
  const storage = mastra.getStorage();
17
17
  if (!telemetry) {
18
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
19
19
  }
20
20
  if (!storage) {
21
21
  return [];
22
22
  }
23
23
  if (!body) {
24
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
24
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
25
25
  }
26
26
  const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
27
27
  const attributes = attribute ? Object.fromEntries(
@@ -41,7 +41,7 @@ async function getTelemetryHandler({ mastra, body }) {
41
41
  });
42
42
  return traces;
43
43
  } catch (error2) {
44
- return chunkMTR2B27E_cjs.handleError(error2, "Error getting telemetry");
44
+ return chunkPZQDCRPV_cjs.handleError(error2, "Error getting telemetry");
45
45
  }
46
46
  }
47
47
  async function storeTelemetryHandler({ mastra, body }) {
@@ -1,6 +1,6 @@
1
1
  import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { handleError } from './chunk-QDOJJCS4.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { ReadableStream } from 'stream/web';
6
6