@mastra/server 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-transpile-packages-20250724123433

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 (80) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +390 -45
  3. package/dist/_tsup-dts-rollup.d.ts +390 -45
  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-4D66QEKC.js +81 -0
  7. package/dist/{chunk-W7VCKPAD.js → chunk-5PQQ42EZ.js} +9 -9
  8. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  9. package/dist/chunk-B2PAS2IB.cjs +514 -0
  10. package/dist/{chunk-J3PKLB3A.js → chunk-BK4XT6EG.js} +56 -17
  11. package/dist/chunk-CBFTEHOO.cjs +157 -0
  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-ZE5AAC4I.cjs → chunk-FRVBFMO2.cjs} +26 -36
  15. package/dist/{chunk-DJJIUEL2.js → chunk-G4L7OMCA.js} +135 -26
  16. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  17. package/dist/{chunk-KUNQFY2W.js → chunk-H7DMHBKY.js} +190 -57
  18. package/dist/{chunk-YIOVBYZH.cjs → chunk-JMLYCXMK.cjs} +43 -43
  19. package/dist/{chunk-CP55EVBK.js → chunk-KHZKYUNR.js} +15 -11
  20. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  21. package/dist/chunk-LF7P5PLR.js +14 -0
  22. package/dist/{chunk-YWLUOY3D.cjs → chunk-LI436ITD.cjs} +107 -69
  23. package/dist/{chunk-TJKLBTFB.js → chunk-LRCAAFUA.js} +10 -20
  24. package/dist/{chunk-A3KDUGS7.cjs → chunk-LZ3VJXSO.cjs} +70 -31
  25. package/dist/{chunk-LIVAK2DM.js → chunk-MEGCYGBU.js} +108 -70
  26. package/dist/chunk-PZQDCRPV.cjs +16 -0
  27. package/dist/chunk-QGX47B5D.cjs +86 -0
  28. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  29. package/dist/{chunk-CMMOIUFC.cjs → chunk-RHSWAXKB.cjs} +34 -30
  30. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  31. package/dist/chunk-VULESSU5.js +149 -0
  32. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  33. package/dist/chunk-Z75RYULP.cjs +333 -0
  34. package/dist/server/handlers/agents.cjs +7 -7
  35. package/dist/server/handlers/agents.js +1 -1
  36. package/dist/server/handlers/error.cjs +2 -2
  37. package/dist/server/handlers/error.js +1 -1
  38. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  39. package/dist/server/handlers/legacyWorkflows.js +1 -1
  40. package/dist/server/handlers/logs.cjs +4 -4
  41. package/dist/server/handlers/logs.js +1 -1
  42. package/dist/server/handlers/memory.cjs +21 -9
  43. package/dist/server/handlers/memory.d.cts +3 -0
  44. package/dist/server/handlers/memory.d.ts +3 -0
  45. package/dist/server/handlers/memory.js +1 -1
  46. package/dist/server/handlers/network.cjs +5 -5
  47. package/dist/server/handlers/network.js +1 -1
  48. package/dist/server/handlers/scores.cjs +30 -0
  49. package/dist/server/handlers/scores.d.cts +6 -0
  50. package/dist/server/handlers/scores.d.ts +6 -0
  51. package/dist/server/handlers/scores.js +1 -0
  52. package/dist/server/handlers/telemetry.cjs +3 -3
  53. package/dist/server/handlers/telemetry.js +1 -1
  54. package/dist/server/handlers/tools.cjs +5 -5
  55. package/dist/server/handlers/tools.js +1 -1
  56. package/dist/server/handlers/utils.cjs +2 -2
  57. package/dist/server/handlers/utils.js +1 -1
  58. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  59. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  60. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  61. package/dist/server/handlers/vNextNetwork.js +211 -0
  62. package/dist/server/handlers/vector.cjs +7 -7
  63. package/dist/server/handlers/vector.js +1 -1
  64. package/dist/server/handlers/voice.cjs +5 -5
  65. package/dist/server/handlers/voice.js +1 -1
  66. package/dist/server/handlers/workflows.cjs +24 -12
  67. package/dist/server/handlers/workflows.d.cts +3 -0
  68. package/dist/server/handlers/workflows.d.ts +3 -0
  69. package/dist/server/handlers/workflows.js +1 -1
  70. package/dist/server/handlers.cjs +28 -23
  71. package/dist/server/handlers.d.cts +3 -2
  72. package/dist/server/handlers.d.ts +3 -2
  73. package/dist/server/handlers.js +11 -10
  74. package/package.json +15 -15
  75. package/dist/chunk-64U3UDTH.cjs +0 -13
  76. package/dist/chunk-DQLE3DVM.js +0 -49
  77. package/dist/chunk-M5ABIP7D.js +0 -11
  78. package/dist/chunk-MMO2HDM6.cjs +0 -378
  79. package/dist/chunk-NEOOQUKW.cjs +0 -54
  80. package/dist/chunk-Y7UWRW5X.cjs +0 -221
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
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');
3
+ var chunkLI436ITD_cjs = require('./chunk-LI436ITD.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 runtimeContext = require('@mastra/core/runtime-context');
9
9
 
@@ -25,12 +25,14 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
25
25
  const instructions = await agent.getInstructions({ runtimeContext });
26
26
  const tools = await agent.getTools({ runtimeContext });
27
27
  const llm = await agent.getLLM({ runtimeContext });
28
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
29
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
28
30
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
29
31
  const _tool = tool;
30
32
  acc[key] = {
31
33
  ..._tool,
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
34
+ inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
35
+ outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
34
36
  };
35
37
  return acc;
36
38
  }, {});
@@ -59,8 +61,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
59
61
  workflows: serializedAgentWorkflows,
60
62
  provider: llm?.getProvider(),
61
63
  modelId: llm?.getModelId(),
62
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
63
- defaultStreamOptions: agent.getDefaultStreamOptions()
64
+ defaultGenerateOptions,
65
+ defaultStreamOptions
64
66
  };
65
67
  })
66
68
  );
@@ -70,26 +72,27 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
70
72
  }, {});
71
73
  return serializedAgents;
72
74
  } catch (error) {
73
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
75
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agents");
74
76
  }
75
77
  }
76
78
  async function getAgentByIdHandler({
77
79
  mastra,
78
80
  runtimeContext,
79
- agentId
81
+ agentId,
82
+ isPlayground = false
80
83
  }) {
81
84
  try {
82
85
  const agent = mastra.getAgent(agentId);
83
86
  if (!agent) {
84
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
87
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
85
88
  }
86
89
  const tools = await agent.getTools({ runtimeContext });
87
90
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
88
91
  const _tool = tool;
89
92
  acc[key] = {
90
93
  ..._tool,
91
- inputSchema: _tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.inputSchema)) : void 0,
92
- outputSchema: _tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.outputSchema)) : void 0
94
+ inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
95
+ outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
93
96
  };
94
97
  return acc;
95
98
  }, {});
@@ -102,7 +105,16 @@ async function getAgentByIdHandler({
102
105
  return {
103
106
  ...acc,
104
107
  [key]: {
105
- name: workflow.name
108
+ name: workflow.name,
109
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
110
+ return {
111
+ ...acc2,
112
+ [key2]: {
113
+ id: step.id,
114
+ description: step.description
115
+ }
116
+ };
117
+ }, {})
106
118
  }
107
119
  };
108
120
  }, {});
@@ -110,8 +122,24 @@ async function getAgentByIdHandler({
110
122
  logger.error("Error getting workflows for agent", { agentName: agent.name, error });
111
123
  }
112
124
  }
113
- const instructions = await agent.getInstructions({ runtimeContext });
125
+ let proxyRuntimeContext = runtimeContext;
126
+ if (isPlayground) {
127
+ proxyRuntimeContext = new Proxy(runtimeContext, {
128
+ get(target, prop) {
129
+ if (prop === "get") {
130
+ return function(key) {
131
+ const value = target.get(key);
132
+ return value ?? `<${key}>`;
133
+ };
134
+ }
135
+ return Reflect.get(target, prop);
136
+ }
137
+ });
138
+ }
139
+ const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
114
140
  const llm = await agent.getLLM({ runtimeContext });
141
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
142
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
115
143
  return {
116
144
  name: agent.name,
117
145
  instructions,
@@ -119,11 +147,11 @@ async function getAgentByIdHandler({
119
147
  workflows: serializedAgentWorkflows,
120
148
  provider: llm?.getProvider(),
121
149
  modelId: llm?.getModelId(),
122
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
123
- defaultStreamOptions: agent.getDefaultStreamOptions()
150
+ defaultGenerateOptions,
151
+ defaultStreamOptions
124
152
  };
125
153
  } catch (error) {
126
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
154
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agent");
127
155
  }
128
156
  }
129
157
  async function getEvalsByAgentIdHandler({
@@ -142,7 +170,7 @@ async function getEvalsByAgentIdHandler({
142
170
  evals
143
171
  };
144
172
  } catch (error) {
145
- return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
173
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting test evals");
146
174
  }
147
175
  }
148
176
  async function getLiveEvalsByAgentIdHandler({
@@ -161,19 +189,20 @@ async function getLiveEvalsByAgentIdHandler({
161
189
  evals
162
190
  };
163
191
  } catch (error) {
164
- return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
192
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting live evals");
165
193
  }
166
194
  }
167
195
  async function generateHandler({
168
196
  mastra,
169
197
  runtimeContext: runtimeContext$1,
170
198
  agentId,
171
- body
199
+ body,
200
+ abortSignal
172
201
  }) {
173
202
  try {
174
203
  const agent = mastra.getAgent(agentId);
175
204
  if (!agent) {
176
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
205
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
177
206
  }
178
207
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
179
208
  const finalResourceId = resourceId ?? resourceid;
@@ -181,28 +210,30 @@ async function generateHandler({
181
210
  ...Array.from(runtimeContext$1.entries()),
182
211
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
183
212
  ]);
184
- chunk57CJTIPW_cjs.validateBody({ messages });
213
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
185
214
  const result = await agent.generate(messages, {
186
215
  ...rest,
187
216
  // @ts-expect-error TODO fix types
188
217
  resourceId: finalResourceId,
189
- runtimeContext: finalRuntimeContext
218
+ runtimeContext: finalRuntimeContext,
219
+ signal: abortSignal
190
220
  });
191
221
  return result;
192
222
  } catch (error) {
193
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
223
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from agent");
194
224
  }
195
225
  }
196
226
  async function streamGenerateHandler({
197
227
  mastra,
198
228
  runtimeContext: runtimeContext$1,
199
229
  agentId,
200
- body
230
+ body,
231
+ abortSignal
201
232
  }) {
202
233
  try {
203
234
  const agent = mastra.getAgent(agentId);
204
235
  if (!agent) {
205
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
236
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
206
237
  }
207
238
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
208
239
  const finalResourceId = resourceId ?? resourceid;
@@ -210,23 +241,31 @@ async function streamGenerateHandler({
210
241
  ...Array.from(runtimeContext$1.entries()),
211
242
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
212
243
  ]);
213
- chunk57CJTIPW_cjs.validateBody({ messages });
244
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
214
245
  const streamResult = await agent.stream(messages, {
215
246
  ...rest,
216
247
  // @ts-expect-error TODO fix types
217
248
  resourceId: finalResourceId,
218
- runtimeContext: finalRuntimeContext
249
+ runtimeContext: finalRuntimeContext,
250
+ signal: abortSignal
219
251
  });
220
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
252
+ const streamResponse = rest.output ? streamResult.toTextStreamResponse({
253
+ headers: {
254
+ "Transfer-Encoding": "chunked"
255
+ }
256
+ }) : streamResult.toDataStreamResponse({
221
257
  sendUsage: true,
222
258
  sendReasoning: true,
223
259
  getErrorMessage: (error) => {
224
260
  return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
261
+ },
262
+ headers: {
263
+ "Transfer-Encoding": "chunked"
225
264
  }
226
265
  });
227
266
  return streamResponse;
228
267
  } catch (error) {
229
- throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
268
+ return chunkPZQDCRPV_cjs.handleError(error, "error streaming agent response");
230
269
  }
231
270
  }
232
271