@mastra/server 2.0.3 → 2.0.4-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +152 -10
  2. package/dist/_tsup-dts-rollup.d.ts +152 -10
  3. package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
  4. package/dist/{chunk-6Q7UXAYJ.cjs → chunk-3HQNCTZ2.cjs} +21 -20
  5. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  6. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  7. package/dist/chunk-5SN4U5AC.cjs +508 -0
  8. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  9. package/dist/chunk-75ZPJI57.cjs +9 -0
  10. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  11. package/dist/{chunk-3XTEV33Q.js → chunk-EJO45KYT.js} +19 -16
  12. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  13. package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
  14. package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
  15. package/dist/{chunk-CHFORQ7J.cjs → chunk-I2B73Y4I.cjs} +60 -57
  16. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  17. package/dist/chunk-LIVAK2DM.js +2001 -0
  18. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  19. package/dist/{chunk-M2RXDCPV.cjs → chunk-M6MC2QMH.cjs} +78 -59
  20. package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
  21. package/dist/chunk-MLKGABMK.js +7 -0
  22. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  23. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  24. package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  25. package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
  26. package/dist/chunk-P6SCPDYW.js +500 -0
  27. package/dist/{chunk-GVBJ5I2S.js → chunk-Q6KMBIAN.js} +5 -4
  28. package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
  30. package/dist/{chunk-OWNA6I2H.js → chunk-WJU67W7F.js} +30 -11
  31. package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
  32. package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
  33. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  34. package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  35. package/dist/server/handlers/a2a.cjs +30 -0
  36. package/dist/server/handlers/a2a.d.cts +6 -0
  37. package/dist/server/handlers/a2a.d.ts +6 -0
  38. package/dist/server/handlers/a2a.js +1 -0
  39. package/dist/server/handlers/agents.cjs +7 -7
  40. package/dist/server/handlers/agents.js +1 -1
  41. package/dist/server/handlers/error.cjs +2 -2
  42. package/dist/server/handlers/error.js +1 -1
  43. package/dist/server/handlers/logs.cjs +4 -4
  44. package/dist/server/handlers/logs.js +1 -1
  45. package/dist/server/handlers/memory.cjs +9 -9
  46. package/dist/server/handlers/memory.js +1 -1
  47. package/dist/server/handlers/network.cjs +5 -5
  48. package/dist/server/handlers/network.js +1 -1
  49. package/dist/server/handlers/telemetry.cjs +3 -3
  50. package/dist/server/handlers/telemetry.js +1 -1
  51. package/dist/server/handlers/tools.cjs +5 -5
  52. package/dist/server/handlers/tools.js +1 -1
  53. package/dist/server/handlers/utils.cjs +2 -2
  54. package/dist/server/handlers/utils.js +1 -1
  55. package/dist/server/handlers/vNextWorkflows.cjs +11 -11
  56. package/dist/server/handlers/vNextWorkflows.js +1 -1
  57. package/dist/server/handlers/vector.cjs +7 -7
  58. package/dist/server/handlers/vector.js +1 -1
  59. package/dist/server/handlers/voice.cjs +4 -4
  60. package/dist/server/handlers/voice.js +1 -1
  61. package/dist/server/handlers/workflows.cjs +11 -11
  62. package/dist/server/handlers/workflows.js +1 -1
  63. package/dist/server/handlers.cjs +28 -23
  64. package/dist/server/handlers.d.cts +1 -0
  65. package/dist/server/handlers.d.ts +1 -0
  66. package/dist/server/handlers.js +11 -10
  67. package/package.json +5 -3
  68. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  69. package/dist/chunk-OMN3UI6X.js +0 -5576
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
 
7
8
  // src/server/handlers/memory.ts
8
9
  var memory_exports = {};
9
- chunkFV45V6WC_cjs.__export(memory_exports, {
10
+ chunk75ZPJI57_cjs.__export(memory_exports, {
10
11
  createThreadHandler: () => createThreadHandler,
11
12
  deleteThreadHandler: () => deleteThreadHandler,
12
13
  getMemoryStatusHandler: () => getMemoryStatusHandler,
@@ -22,7 +23,7 @@ function getMemoryFromContext({
22
23
  }) {
23
24
  const agent = agentId ? mastra.getAgent(agentId) : null;
24
25
  if (agentId && !agent) {
25
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
26
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
26
27
  }
27
28
  const memory = agent?.getMemory?.() || mastra.getMemory();
28
29
  return memory;
@@ -35,7 +36,7 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
35
36
  }
36
37
  return { result: true };
37
38
  } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting memory status");
39
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
39
40
  }
40
41
  }
41
42
  async function getThreadsHandler({
@@ -46,13 +47,13 @@ async function getThreadsHandler({
46
47
  try {
47
48
  const memory = getMemoryFromContext({ mastra, agentId });
48
49
  if (!memory) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
50
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
50
51
  }
51
- chunkQN4KF3BH_cjs.validateBody({ resourceId });
52
+ chunk57CJTIPW_cjs.validateBody({ resourceId });
52
53
  const threads = await memory.getThreadsByResourceId({ resourceId });
53
54
  return threads;
54
55
  } catch (error) {
55
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting threads");
56
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
56
57
  }
57
58
  }
58
59
  async function getThreadByIdHandler({
@@ -61,18 +62,18 @@ async function getThreadByIdHandler({
61
62
  threadId
62
63
  }) {
63
64
  try {
64
- chunkQN4KF3BH_cjs.validateBody({ threadId });
65
+ chunk57CJTIPW_cjs.validateBody({ threadId });
65
66
  const memory = getMemoryFromContext({ mastra, agentId });
66
67
  if (!memory) {
67
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
69
  }
69
70
  const thread = await memory.getThreadById({ threadId });
70
71
  if (!thread) {
71
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
72
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
72
73
  }
73
74
  return thread;
74
75
  } catch (error) {
75
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting thread");
76
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
76
77
  }
77
78
  }
78
79
  async function saveMessagesHandler({
@@ -83,13 +84,13 @@ async function saveMessagesHandler({
83
84
  try {
84
85
  const memory = getMemoryFromContext({ mastra, agentId });
85
86
  if (!memory) {
86
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
87
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
87
88
  }
88
89
  if (!body?.messages) {
89
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Messages are required" });
90
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
90
91
  }
91
92
  if (!Array.isArray(body.messages)) {
92
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Messages should be an array" });
93
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
93
94
  }
94
95
  const processedMessages = body.messages.map((message) => ({
95
96
  ...message,
@@ -99,7 +100,7 @@ async function saveMessagesHandler({
99
100
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
100
101
  return result;
101
102
  } catch (error) {
102
- return chunkZLBRQFDD_cjs.handleError(error, "Error saving messages");
103
+ return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
103
104
  }
104
105
  }
105
106
  async function createThreadHandler({
@@ -110,9 +111,9 @@ async function createThreadHandler({
110
111
  try {
111
112
  const memory = getMemoryFromContext({ mastra, agentId });
112
113
  if (!memory) {
113
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
114
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
114
115
  }
115
- chunkQN4KF3BH_cjs.validateBody({ resourceId: body?.resourceId });
116
+ chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
116
117
  const result = await memory.createThread({
117
118
  resourceId: body?.resourceId,
118
119
  title: body?.title,
@@ -121,7 +122,7 @@ async function createThreadHandler({
121
122
  });
122
123
  return result;
123
124
  } catch (error) {
124
- return chunkZLBRQFDD_cjs.handleError(error, "Error saving thread to memory");
125
+ return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
125
126
  }
126
127
  }
127
128
  async function updateThreadHandler({
@@ -133,17 +134,17 @@ async function updateThreadHandler({
133
134
  try {
134
135
  const memory = getMemoryFromContext({ mastra, agentId });
135
136
  if (!body) {
136
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
137
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
137
138
  }
138
139
  const { title, metadata, resourceId } = body;
139
140
  const updatedAt = /* @__PURE__ */ new Date();
140
- chunkQN4KF3BH_cjs.validateBody({ threadId });
141
+ chunk57CJTIPW_cjs.validateBody({ threadId });
141
142
  if (!memory) {
142
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
143
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
143
144
  }
144
145
  const thread = await memory.getThreadById({ threadId });
145
146
  if (!thread) {
146
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
147
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
147
148
  }
148
149
  const updatedThread = {
149
150
  ...thread,
@@ -156,7 +157,7 @@ async function updateThreadHandler({
156
157
  const result = await memory.saveThread({ thread: updatedThread });
157
158
  return result;
158
159
  } catch (error) {
159
- return chunkZLBRQFDD_cjs.handleError(error, "Error updating thread");
160
+ return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
160
161
  }
161
162
  }
162
163
  async function deleteThreadHandler({
@@ -165,19 +166,19 @@ async function deleteThreadHandler({
165
166
  threadId
166
167
  }) {
167
168
  try {
168
- chunkQN4KF3BH_cjs.validateBody({ threadId });
169
+ chunk57CJTIPW_cjs.validateBody({ threadId });
169
170
  const memory = getMemoryFromContext({ mastra, agentId });
170
171
  if (!memory) {
171
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
172
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
172
173
  }
173
174
  const thread = await memory.getThreadById({ threadId });
174
175
  if (!thread) {
175
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
176
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
176
177
  }
177
178
  await memory.deleteThread(threadId);
178
179
  return { result: "Thread deleted" };
179
180
  } catch (error) {
180
- return chunkZLBRQFDD_cjs.handleError(error, "Error deleting thread");
181
+ return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
181
182
  }
182
183
  }
183
184
  async function getMessagesHandler({
@@ -186,19 +187,19 @@ async function getMessagesHandler({
186
187
  threadId
187
188
  }) {
188
189
  try {
189
- chunkQN4KF3BH_cjs.validateBody({ threadId });
190
+ chunk57CJTIPW_cjs.validateBody({ threadId });
190
191
  const memory = getMemoryFromContext({ mastra, agentId });
191
192
  if (!memory) {
192
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
193
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
193
194
  }
194
195
  const thread = await memory.getThreadById({ threadId });
195
196
  if (!thread) {
196
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
197
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
197
198
  }
198
199
  const result = await memory.query({ threadId });
199
200
  return result;
200
201
  } catch (error) {
201
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting messages");
202
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
202
203
  }
203
204
  }
204
205
 
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
6
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
7
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
8
  var runtimeContext = require('@mastra/core/runtime-context');
8
9
 
9
10
  // src/server/handlers/agents.ts
10
11
  var agents_exports = {};
11
- chunkFV45V6WC_cjs.__export(agents_exports, {
12
+ chunk75ZPJI57_cjs.__export(agents_exports, {
12
13
  generateHandler: () => generateHandler,
13
14
  getAgentByIdHandler: () => getAgentByIdHandler,
14
15
  getAgentsHandler: () => getAgentsHandler,
@@ -28,8 +29,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
28
29
  const _tool = tool;
29
30
  acc[key] = {
30
31
  ..._tool,
31
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
32
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
32
+ inputSchema: _tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.inputSchema)) : void 0,
33
+ outputSchema: _tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.outputSchema)) : void 0
33
34
  };
34
35
  return acc;
35
36
  }, {});
@@ -49,7 +50,7 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
49
50
  }, {});
50
51
  return serializedAgents;
51
52
  } catch (error) {
52
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
53
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
53
54
  }
54
55
  }
55
56
  async function getAgentByIdHandler({
@@ -60,15 +61,15 @@ async function getAgentByIdHandler({
60
61
  try {
61
62
  const agent = mastra.getAgent(agentId);
62
63
  if (!agent) {
63
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
64
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
64
65
  }
65
66
  const tools = await agent.getTools({ runtimeContext });
66
67
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
67
68
  const _tool = tool;
68
69
  acc[key] = {
69
70
  ..._tool,
70
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
71
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
71
+ inputSchema: _tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.inputSchema)) : void 0,
72
+ outputSchema: _tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.outputSchema)) : void 0
72
73
  };
73
74
  return acc;
74
75
  }, {});
@@ -82,7 +83,7 @@ async function getAgentByIdHandler({
82
83
  modelId: llm?.getModelId()
83
84
  };
84
85
  } catch (error) {
85
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
86
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
86
87
  }
87
88
  }
88
89
  async function getEvalsByAgentIdHandler({
@@ -101,7 +102,7 @@ async function getEvalsByAgentIdHandler({
101
102
  evals
102
103
  };
103
104
  } catch (error) {
104
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
105
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
105
106
  }
106
107
  }
107
108
  async function getLiveEvalsByAgentIdHandler({
@@ -120,7 +121,7 @@ async function getLiveEvalsByAgentIdHandler({
120
121
  evals
121
122
  };
122
123
  } catch (error) {
123
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting live evals");
124
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
124
125
  }
125
126
  }
126
127
  async function generateHandler({
@@ -132,7 +133,7 @@ async function generateHandler({
132
133
  try {
133
134
  const agent = mastra.getAgent(agentId);
134
135
  if (!agent) {
135
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
136
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
136
137
  }
137
138
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
138
139
  const finalResourceId = resourceId ?? resourceid;
@@ -140,7 +141,7 @@ async function generateHandler({
140
141
  ...Array.from(runtimeContext$1.entries()),
141
142
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
142
143
  ]);
143
- chunkQN4KF3BH_cjs.validateBody({ messages });
144
+ chunk57CJTIPW_cjs.validateBody({ messages });
144
145
  const result = await agent.generate(messages, {
145
146
  ...rest,
146
147
  // @ts-expect-error TODO fix types
@@ -149,7 +150,7 @@ async function generateHandler({
149
150
  });
150
151
  return result;
151
152
  } catch (error) {
152
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from agent");
153
+ return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
153
154
  }
154
155
  }
155
156
  async function streamGenerateHandler({
@@ -161,7 +162,7 @@ async function streamGenerateHandler({
161
162
  try {
162
163
  const agent = mastra.getAgent(agentId);
163
164
  if (!agent) {
164
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
165
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
165
166
  }
166
167
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
167
168
  const finalResourceId = resourceId ?? resourceid;
@@ -169,7 +170,7 @@ async function streamGenerateHandler({
169
170
  ...Array.from(runtimeContext$1.entries()),
170
171
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
171
172
  ]);
172
- chunkQN4KF3BH_cjs.validateBody({ messages });
173
+ chunk57CJTIPW_cjs.validateBody({ messages });
173
174
  const streamResult = await agent.stream(messages, {
174
175
  ...rest,
175
176
  // @ts-expect-error TODO fix types
@@ -185,7 +186,7 @@ async function streamGenerateHandler({
185
186
  });
186
187
  return streamResponse;
187
188
  } catch (error) {
188
- throw new chunkFV45V6WC_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
189
+ throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
189
190
  }
190
191
  }
191
192
 
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
4
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
6
 
6
7
  // src/server/handlers/vector.ts
7
8
  var vector_exports = {};
8
- chunkFV45V6WC_cjs.__export(vector_exports, {
9
+ chunk75ZPJI57_cjs.__export(vector_exports, {
9
10
  createIndex: () => createIndex,
10
11
  deleteIndex: () => deleteIndex,
11
12
  describeIndex: () => describeIndex,
@@ -15,24 +16,24 @@ chunkFV45V6WC_cjs.__export(vector_exports, {
15
16
  });
16
17
  function getVector(mastra, vectorName) {
17
18
  if (!vectorName) {
18
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Vector name is required" });
19
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Vector name is required" });
19
20
  }
20
21
  const vector = mastra.getVector(vectorName);
21
22
  if (!vector) {
22
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
24
  }
24
25
  return vector;
25
26
  }
26
27
  async function upsertVectors({ mastra, vectorName, index }) {
27
28
  try {
28
29
  if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
29
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
31
  }
31
32
  const vector = getVector(mastra, vectorName);
32
33
  const result = await vector.upsert(index);
33
34
  return { ids: result };
34
35
  } catch (error) {
35
- return chunkZLBRQFDD_cjs.handleError(error, "Error upserting vectors");
36
+ return chunk64U3UDTH_cjs.handleError(error, "Error upserting vectors");
36
37
  }
37
38
  }
38
39
  async function createIndex({
@@ -43,18 +44,18 @@ async function createIndex({
43
44
  try {
44
45
  const { indexName, dimension, metric } = index;
45
46
  if (!indexName || typeof dimension !== "number" || dimension <= 0) {
46
- throw new chunkFV45V6WC_cjs.HTTPException(400, {
47
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, {
47
48
  message: "Invalid request index, indexName and positive dimension number are required."
48
49
  });
49
50
  }
50
51
  if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
51
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
53
  }
53
54
  const vector = getVector(mastra, vectorName);
54
55
  await vector.createIndex({ indexName, dimension, metric });
55
56
  return { success: true };
56
57
  } catch (error) {
57
- return chunkZLBRQFDD_cjs.handleError(error, "Error creating index");
58
+ return chunk64U3UDTH_cjs.handleError(error, "Error creating index");
58
59
  }
59
60
  }
60
61
  async function queryVectors({
@@ -64,13 +65,13 @@ async function queryVectors({
64
65
  }) {
65
66
  try {
66
67
  if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
67
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
69
  }
69
70
  const vector = getVector(mastra, vectorName);
70
71
  const results = await vector.query(query);
71
72
  return results;
72
73
  } catch (error) {
73
- return chunkZLBRQFDD_cjs.handleError(error, "Error querying vectors");
74
+ return chunk64U3UDTH_cjs.handleError(error, "Error querying vectors");
74
75
  }
75
76
  }
76
77
  async function listIndexes({ mastra, vectorName }) {
@@ -79,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
79
80
  const indexes = await vector.listIndexes();
80
81
  return indexes.filter(Boolean);
81
82
  } catch (error) {
82
- return chunkZLBRQFDD_cjs.handleError(error, "Error listing indexes");
83
+ return chunk64U3UDTH_cjs.handleError(error, "Error listing indexes");
83
84
  }
84
85
  }
85
86
  async function describeIndex({
@@ -89,7 +90,7 @@ async function describeIndex({
89
90
  }) {
90
91
  try {
91
92
  if (!indexName) {
92
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Index name is required" });
93
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
93
94
  }
94
95
  const vector = getVector(mastra, vectorName);
95
96
  const stats = await vector.describeIndex(indexName);
@@ -99,7 +100,7 @@ async function describeIndex({
99
100
  metric: stats.metric?.toLowerCase()
100
101
  };
101
102
  } catch (error) {
102
- return chunkZLBRQFDD_cjs.handleError(error, "Error describing index");
103
+ return chunk64U3UDTH_cjs.handleError(error, "Error describing index");
103
104
  }
104
105
  }
105
106
  async function deleteIndex({
@@ -109,13 +110,13 @@ async function deleteIndex({
109
110
  }) {
110
111
  try {
111
112
  if (!indexName) {
112
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Index name is required" });
113
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
113
114
  }
114
115
  const vector = getVector(mastra, vectorName);
115
116
  await vector.deleteIndex(indexName);
116
117
  return { success: true };
117
118
  } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error deleting index");
119
+ return chunk64U3UDTH_cjs.handleError(error, "Error deleting index");
119
120
  }
120
121
  }
121
122
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.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 chunkFV45V6WC_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
14
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
15
15
  }
16
16
  }
17
17