@mastra/server 0.0.0-fix-fetch-workflow-runs-20250624231457 → 0.0.0-fix-traces-pagination-plus-share-for-cloud-20250717083008

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 (68) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +115 -12
  3. package/dist/_tsup-dts-rollup.d.ts +115 -12
  4. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  5. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  6. package/dist/{chunk-RQ2Z56EC.cjs → chunk-3CNDE7QY.cjs} +92 -35
  7. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  8. package/dist/{chunk-N2YBMSO2.js → chunk-5PQQ42EZ.js} +8 -8
  9. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  10. package/dist/{chunk-TO5U6HW3.cjs → chunk-B2PAS2IB.cjs} +147 -68
  11. package/dist/{chunk-PMUATKV2.js → chunk-BK4XT6EG.js} +5 -5
  12. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  14. package/dist/{chunk-CPPYMJX5.cjs → chunk-FRVBFMO2.cjs} +20 -20
  15. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  16. package/dist/{chunk-SOBBILUG.js → chunk-H7DMHBKY.js} +89 -12
  17. package/dist/{chunk-4DTDPTQC.cjs → chunk-JMLYCXMK.cjs} +43 -43
  18. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  19. package/dist/{chunk-XUIJ7WRT.js → chunk-KOHWJYJT.js} +60 -5
  20. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  21. package/dist/chunk-LF7P5PLR.js +14 -0
  22. package/dist/{chunk-MN6F4D5A.cjs → chunk-LI436ITD.cjs} +107 -69
  23. package/dist/{chunk-XR7VJOOP.js → chunk-LRCAAFUA.js} +4 -4
  24. package/dist/{chunk-GKM45O24.cjs → chunk-LZ3VJXSO.cjs} +19 -19
  25. package/dist/{chunk-OSZM4EAY.js → chunk-MEGCYGBU.js} +108 -70
  26. package/dist/chunk-PZQDCRPV.cjs +16 -0
  27. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  28. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  29. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  30. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  31. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  32. package/dist/server/handlers/agents.cjs +7 -7
  33. package/dist/server/handlers/agents.js +1 -1
  34. package/dist/server/handlers/error.cjs +2 -2
  35. package/dist/server/handlers/error.js +1 -1
  36. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  37. package/dist/server/handlers/legacyWorkflows.js +1 -1
  38. package/dist/server/handlers/logs.cjs +4 -4
  39. package/dist/server/handlers/logs.js +1 -1
  40. package/dist/server/handlers/memory.cjs +17 -9
  41. package/dist/server/handlers/memory.d.cts +2 -0
  42. package/dist/server/handlers/memory.d.ts +2 -0
  43. package/dist/server/handlers/memory.js +1 -1
  44. package/dist/server/handlers/network.cjs +5 -5
  45. package/dist/server/handlers/network.js +1 -1
  46. package/dist/server/handlers/telemetry.cjs +3 -3
  47. package/dist/server/handlers/telemetry.js +1 -1
  48. package/dist/server/handlers/tools.cjs +5 -5
  49. package/dist/server/handlers/tools.js +1 -1
  50. package/dist/server/handlers/utils.cjs +2 -2
  51. package/dist/server/handlers/utils.js +1 -1
  52. package/dist/server/handlers/vNextNetwork.cjs +63 -20
  53. package/dist/server/handlers/vNextNetwork.d.cts +1 -0
  54. package/dist/server/handlers/vNextNetwork.d.ts +1 -0
  55. package/dist/server/handlers/vNextNetwork.js +47 -5
  56. package/dist/server/handlers/vector.cjs +7 -7
  57. package/dist/server/handlers/vector.js +1 -1
  58. package/dist/server/handlers/voice.cjs +5 -5
  59. package/dist/server/handlers/voice.js +1 -1
  60. package/dist/server/handlers/workflows.cjs +21 -13
  61. package/dist/server/handlers/workflows.d.cts +2 -0
  62. package/dist/server/handlers/workflows.d.ts +2 -0
  63. package/dist/server/handlers/workflows.js +1 -1
  64. package/dist/server/handlers.cjs +20 -20
  65. package/dist/server/handlers.js +10 -10
  66. package/package.json +7 -7
  67. package/dist/chunk-64U3UDTH.cjs +0 -13
  68. package/dist/chunk-M5ABIP7D.js +0 -11
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.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
+ var core = require('@mastra/core');
7
8
 
8
9
  // src/server/handlers/memory.ts
9
10
  var memory_exports = {};
@@ -14,8 +15,10 @@ chunk75ZPJI57_cjs.__export(memory_exports, {
14
15
  getMessagesHandler: () => getMessagesHandler,
15
16
  getThreadByIdHandler: () => getThreadByIdHandler,
16
17
  getThreadsHandler: () => getThreadsHandler,
18
+ getWorkingMemoryHandler: () => getWorkingMemoryHandler,
17
19
  saveMessagesHandler: () => saveMessagesHandler,
18
- updateThreadHandler: () => updateThreadHandler
20
+ updateThreadHandler: () => updateThreadHandler,
21
+ updateWorkingMemoryHandler: () => updateWorkingMemoryHandler
19
22
  });
20
23
  async function getMemoryFromContext({
21
24
  mastra,
@@ -25,11 +28,11 @@ async function getMemoryFromContext({
25
28
  }) {
26
29
  const agent = agentId ? mastra.getAgent(agentId) : null;
27
30
  if (agentId && !agent) {
28
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
31
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
29
32
  }
30
33
  const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
31
34
  if (networkId && !network) {
32
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
35
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
33
36
  }
34
37
  if (agent) {
35
38
  return agent?.getMemory() || mastra.getMemory();
@@ -52,7 +55,7 @@ async function getMemoryStatusHandler({
52
55
  }
53
56
  return { result: true };
54
57
  } catch (error) {
55
- return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
58
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting memory status");
56
59
  }
57
60
  }
58
61
  async function getThreadsHandler({
@@ -65,13 +68,13 @@ async function getThreadsHandler({
65
68
  try {
66
69
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
67
70
  if (!memory) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
71
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
69
72
  }
70
- chunk57CJTIPW_cjs.validateBody({ resourceId });
73
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId });
71
74
  const threads = await memory.getThreadsByResourceId({ resourceId });
72
75
  return threads;
73
76
  } catch (error) {
74
- return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
77
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting threads");
75
78
  }
76
79
  }
77
80
  async function getThreadByIdHandler({
@@ -82,18 +85,18 @@ async function getThreadByIdHandler({
82
85
  runtimeContext
83
86
  }) {
84
87
  try {
85
- chunk57CJTIPW_cjs.validateBody({ threadId });
88
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
86
89
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
87
90
  if (!memory) {
88
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
91
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
89
92
  }
90
93
  const thread = await memory.getThreadById({ threadId });
91
94
  if (!thread) {
92
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
95
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
93
96
  }
94
97
  return thread;
95
98
  } catch (error) {
96
- return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
99
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting thread");
97
100
  }
98
101
  }
99
102
  async function saveMessagesHandler({
@@ -106,13 +109,13 @@ async function saveMessagesHandler({
106
109
  try {
107
110
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
108
111
  if (!memory) {
109
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
112
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
110
113
  }
111
114
  if (!body?.messages) {
112
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
115
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages are required" });
113
116
  }
114
117
  if (!Array.isArray(body.messages)) {
115
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
118
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages should be an array" });
116
119
  }
117
120
  const processedMessages = body.messages.map((message) => ({
118
121
  ...message,
@@ -122,7 +125,7 @@ async function saveMessagesHandler({
122
125
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
123
126
  return result;
124
127
  } catch (error) {
125
- return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
128
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving messages");
126
129
  }
127
130
  }
128
131
  async function createThreadHandler({
@@ -135,9 +138,9 @@ async function createThreadHandler({
135
138
  try {
136
139
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
137
140
  if (!memory) {
138
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
141
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
139
142
  }
140
- chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
143
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId: body?.resourceId });
141
144
  const result = await memory.createThread({
142
145
  resourceId: body?.resourceId,
143
146
  title: body?.title,
@@ -146,7 +149,7 @@ async function createThreadHandler({
146
149
  });
147
150
  return result;
148
151
  } catch (error) {
149
- return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
152
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving thread to memory");
150
153
  }
151
154
  }
152
155
  async function updateThreadHandler({
@@ -160,17 +163,17 @@ async function updateThreadHandler({
160
163
  try {
161
164
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
162
165
  if (!body) {
163
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
166
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
164
167
  }
165
168
  const { title, metadata, resourceId } = body;
166
169
  const updatedAt = /* @__PURE__ */ new Date();
167
- chunk57CJTIPW_cjs.validateBody({ threadId });
170
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
168
171
  if (!memory) {
169
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
172
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
170
173
  }
171
174
  const thread = await memory.getThreadById({ threadId });
172
175
  if (!thread) {
173
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
176
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
174
177
  }
175
178
  const updatedThread = {
176
179
  ...thread,
@@ -183,7 +186,7 @@ async function updateThreadHandler({
183
186
  const result = await memory.saveThread({ thread: updatedThread });
184
187
  return result;
185
188
  } catch (error) {
186
- return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
189
+ return chunkPZQDCRPV_cjs.handleError(error, "Error updating thread");
187
190
  }
188
191
  }
189
192
  async function deleteThreadHandler({
@@ -194,19 +197,19 @@ async function deleteThreadHandler({
194
197
  runtimeContext
195
198
  }) {
196
199
  try {
197
- chunk57CJTIPW_cjs.validateBody({ threadId });
200
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
198
201
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
199
202
  if (!memory) {
200
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
203
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
201
204
  }
202
205
  const thread = await memory.getThreadById({ threadId });
203
206
  if (!thread) {
204
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
207
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
205
208
  }
206
209
  await memory.deleteThread(threadId);
207
210
  return { result: "Thread deleted" };
208
211
  } catch (error) {
209
- return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
212
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting thread");
210
213
  }
211
214
  }
212
215
  async function getMessagesHandler({
@@ -218,17 +221,17 @@ async function getMessagesHandler({
218
221
  runtimeContext
219
222
  }) {
220
223
  if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
221
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
224
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
222
225
  }
223
226
  try {
224
- chunk57CJTIPW_cjs.validateBody({ threadId });
227
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
225
228
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
226
229
  if (!memory) {
227
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
230
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
228
231
  }
229
232
  const thread = await memory.getThreadById({ threadId });
230
233
  if (!thread) {
231
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
234
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
232
235
  }
233
236
  const result = await memory.query({
234
237
  threadId,
@@ -236,7 +239,59 @@ async function getMessagesHandler({
236
239
  });
237
240
  return { messages: result.messages, uiMessages: result.uiMessages };
238
241
  } catch (error) {
239
- return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
242
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting messages");
243
+ }
244
+ }
245
+ async function getWorkingMemoryHandler({
246
+ mastra,
247
+ agentId,
248
+ threadId,
249
+ resourceId,
250
+ networkId,
251
+ runtimeContext,
252
+ memoryConfig
253
+ }) {
254
+ try {
255
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
256
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
257
+ if (!memory) {
258
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
259
+ }
260
+ const thread = await memory.getThreadById({ threadId });
261
+ const threadExists = !!thread;
262
+ const template = await memory.getWorkingMemoryTemplate({ memoryConfig });
263
+ const workingMemoryTemplate = template?.format === "json" ? { ...template, content: JSON.stringify(core.generateEmptyFromSchema(template.content)) } : template;
264
+ const workingMemory = await memory.getWorkingMemory({ threadId, resourceId, memoryConfig });
265
+ const config = memory.getMergedThreadConfig(memoryConfig || {});
266
+ const source = config.workingMemory?.scope === "resource" && resourceId ? "resource" : "thread";
267
+ return { workingMemory, source, workingMemoryTemplate, threadExists };
268
+ } catch (error) {
269
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting working memory");
270
+ }
271
+ }
272
+ async function updateWorkingMemoryHandler({
273
+ mastra,
274
+ agentId,
275
+ threadId,
276
+ body,
277
+ networkId,
278
+ runtimeContext
279
+ }) {
280
+ try {
281
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
282
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
283
+ const { resourceId, memoryConfig, workingMemory } = body;
284
+ if (!memory) {
285
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
286
+ }
287
+ const thread = await memory.getThreadById({ threadId });
288
+ if (!thread) {
289
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
290
+ }
291
+ await memory.updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig });
292
+ return { success: true };
293
+ } catch (error) {
294
+ return chunkPZQDCRPV_cjs.handleError(error, "Error updating working memory");
240
295
  }
241
296
  }
242
297
 
@@ -246,6 +301,8 @@ exports.getMemoryStatusHandler = getMemoryStatusHandler;
246
301
  exports.getMessagesHandler = getMessagesHandler;
247
302
  exports.getThreadByIdHandler = getThreadByIdHandler;
248
303
  exports.getThreadsHandler = getThreadsHandler;
304
+ exports.getWorkingMemoryHandler = getWorkingMemoryHandler;
249
305
  exports.memory_exports = memory_exports;
250
306
  exports.saveMessagesHandler = saveMessagesHandler;
251
307
  exports.updateThreadHandler = updateThreadHandler;
308
+ exports.updateWorkingMemoryHandler = updateWorkingMemoryHandler;
@@ -1,5 +1,5 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.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
- import { stringify, esm_default } from './chunk-OSZM4EAY.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.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
 
@@ -46,7 +46,7 @@ async function getLegacyWorkflowsHandler({ mastra }) {
46
46
  }, {});
47
47
  return _workflows;
48
48
  } catch (error) {
49
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
+ return handleError(error, "error getting workflows");
50
50
  }
51
51
  }
52
52
  async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
@@ -78,7 +78,7 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
78
78
  }, {})
79
79
  };
80
80
  } catch (error) {
81
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
81
+ return handleError(error, "error getting workflow by id");
82
82
  }
83
83
  }
84
84
  async function startAsyncLegacyWorkflowHandler({
@@ -114,7 +114,7 @@ async function startAsyncLegacyWorkflowHandler({
114
114
  });
115
115
  return result;
116
116
  } catch (error) {
117
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
117
+ return handleError(error, "error starting workflow");
118
118
  }
119
119
  }
120
120
  async function getLegacyWorkflowRunHandler({
@@ -139,7 +139,7 @@ async function getLegacyWorkflowRunHandler({
139
139
  }
140
140
  return run;
141
141
  } catch (error) {
142
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
142
+ return handleError(error, "error getting workflow run");
143
143
  }
144
144
  }
145
145
  async function createLegacyWorkflowRunHandler({
@@ -158,7 +158,7 @@ async function createLegacyWorkflowRunHandler({
158
158
  const newRun = workflow.createRun({ runId: prevRunId });
159
159
  return { runId: newRun.runId };
160
160
  } catch (error) {
161
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
161
+ return handleError(error, "error creating workflow run");
162
162
  }
163
163
  }
164
164
  async function startLegacyWorkflowRunHandler({
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.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 chunk64U3UDTH_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 chunk64U3UDTH_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 chunk64U3UDTH_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 chunk64U3UDTH_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 chunk64U3UDTH_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 chunk64U3UDTH_cjs.handleError(error, "Error deleting index");
119
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting index");
120
120
  }
121
121
  }
122
122