@mastra/server 0.0.0-switch-to-core-20250424015131 → 0.0.0-vector-query-sources-20250516172905

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 (74) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +258 -13
  3. package/dist/_tsup-dts-rollup.d.ts +258 -13
  4. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  5. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  6. package/dist/chunk-5SN4U5AC.cjs +508 -0
  7. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  10. package/dist/{chunk-RE6YL32K.js → chunk-C7564HUT.js} +52 -30
  11. package/dist/chunk-D4IRYCUI.cjs +235 -0
  12. package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
  13. package/dist/{chunk-LFOBHRFO.js → chunk-EJO45KYT.js} +35 -20
  14. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  15. package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
  16. package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
  17. package/dist/{chunk-TZK63M5N.cjs → chunk-I2B73Y4I.cjs} +76 -61
  18. package/dist/chunk-LIVAK2DM.js +2001 -0
  19. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  20. package/dist/{chunk-7IWQE76Z.cjs → chunk-MHKNLNAN.cjs} +13 -10
  21. package/dist/chunk-MIQYDLLM.js +329 -0
  22. package/dist/chunk-MLKGABMK.js +7 -0
  23. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  24. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  25. package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  26. package/dist/{chunk-WTHDCRMY.js → chunk-OR3CIE2H.js} +7 -4
  27. package/dist/chunk-P6SCPDYW.js +500 -0
  28. package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/chunk-UCTEMO2Q.cjs +341 -0
  30. package/dist/{chunk-FPIWDH5Y.cjs → chunk-VPNDC2DI.cjs} +62 -40
  31. package/dist/chunk-WUC6LSTW.js +227 -0
  32. package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
  33. package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
  34. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  35. package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/logs.cjs +4 -4
  45. package/dist/server/handlers/logs.js +1 -1
  46. package/dist/server/handlers/memory.cjs +9 -9
  47. package/dist/server/handlers/memory.js +1 -1
  48. package/dist/server/handlers/network.cjs +5 -5
  49. package/dist/server/handlers/network.js +1 -1
  50. package/dist/server/handlers/telemetry.cjs +3 -3
  51. package/dist/server/handlers/telemetry.js +1 -1
  52. package/dist/server/handlers/tools.cjs +5 -5
  53. package/dist/server/handlers/tools.js +1 -1
  54. package/dist/server/handlers/utils.cjs +2 -2
  55. package/dist/server/handlers/utils.js +1 -1
  56. package/dist/server/handlers/vNextWorkflows.cjs +46 -0
  57. package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
  58. package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
  59. package/dist/server/handlers/vNextWorkflows.js +1 -0
  60. package/dist/server/handlers/vector.cjs +7 -7
  61. package/dist/server/handlers/vector.js +1 -1
  62. package/dist/server/handlers/voice.cjs +4 -4
  63. package/dist/server/handlers/voice.js +1 -1
  64. package/dist/server/handlers/workflows.cjs +11 -11
  65. package/dist/server/handlers/workflows.js +1 -1
  66. package/dist/server/handlers.cjs +31 -21
  67. package/dist/server/handlers.d.cts +2 -0
  68. package/dist/server/handlers.d.ts +2 -0
  69. package/dist/server/handlers.js +11 -9
  70. package/package.json +8 -6
  71. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  72. package/dist/chunk-HCOPJZ4A.cjs +0 -164
  73. package/dist/chunk-OMN3UI6X.js +0 -5576
  74. package/dist/chunk-R4J7XQYU.js +0 -156
@@ -1,156 +0,0 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { validateBody } from './chunk-L7XE5QTW.js';
3
- import { handleError } from './chunk-3AHQ5RGN.js';
4
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
5
-
6
- // src/server/handlers/agents.ts
7
- var agents_exports = {};
8
- __export(agents_exports, {
9
- generateHandler: () => generateHandler,
10
- getAgentByIdHandler: () => getAgentByIdHandler,
11
- getAgentsHandler: () => getAgentsHandler,
12
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
13
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
14
- streamGenerateHandler: () => streamGenerateHandler
15
- });
16
- async function getAgentsHandler({ mastra }) {
17
- try {
18
- const agents = mastra.getAgents();
19
- const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
20
- const agent = _agent;
21
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc2, [key, tool]) => {
22
- const _tool = tool;
23
- acc2[key] = {
24
- ..._tool,
25
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
26
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
27
- };
28
- return acc2;
29
- }, {});
30
- acc[_id] = {
31
- name: agent.name,
32
- instructions: agent.instructions,
33
- tools: serializedAgentTools,
34
- provider: agent.llm?.getProvider(),
35
- modelId: agent.llm?.getModelId()
36
- };
37
- return acc;
38
- }, {});
39
- return serializedAgents;
40
- } catch (error) {
41
- return handleError(error, "Error getting agents");
42
- }
43
- }
44
- async function getAgentByIdHandler({ mastra, agentId }) {
45
- try {
46
- const agent = mastra.getAgent(agentId);
47
- if (!agent) {
48
- throw new HTTPException(404, { message: "Agent not found" });
49
- }
50
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
51
- const _tool = tool;
52
- acc[key] = {
53
- ..._tool,
54
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
55
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
56
- };
57
- return acc;
58
- }, {});
59
- return {
60
- name: agent.name,
61
- instructions: agent.instructions,
62
- tools: serializedAgentTools,
63
- provider: agent.llm?.getProvider(),
64
- modelId: agent.llm?.getModelId()
65
- };
66
- } catch (error) {
67
- return handleError(error, "Error getting agent");
68
- }
69
- }
70
- async function getEvalsByAgentIdHandler({ mastra, agentId }) {
71
- try {
72
- const agent = mastra.getAgent(agentId);
73
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
74
- return {
75
- id: agentId,
76
- name: agent.name,
77
- instructions: agent.instructions,
78
- evals
79
- };
80
- } catch (error) {
81
- return handleError(error, "Error getting test evals");
82
- }
83
- }
84
- async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
85
- try {
86
- const agent = mastra.getAgent(agentId);
87
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
88
- return {
89
- id: agentId,
90
- name: agent.name,
91
- instructions: agent.instructions,
92
- evals
93
- };
94
- } catch (error) {
95
- return handleError(error, "Error getting live evals");
96
- }
97
- }
98
- async function generateHandler({
99
- mastra,
100
- runtimeContext,
101
- agentId,
102
- body
103
- }) {
104
- try {
105
- const agent = mastra.getAgent(agentId);
106
- if (!agent) {
107
- throw new HTTPException(404, { message: "Agent not found" });
108
- }
109
- const { messages, resourceId, resourceid, ...rest } = body;
110
- const finalResourceId = resourceId ?? resourceid;
111
- validateBody({ messages });
112
- const result = await agent.generate(messages, {
113
- ...rest,
114
- // @ts-expect-error TODO fix types
115
- resourceId: finalResourceId,
116
- runtimeContext
117
- });
118
- return result;
119
- } catch (error) {
120
- return handleError(error, "Error generating from agent");
121
- }
122
- }
123
- async function streamGenerateHandler({
124
- mastra,
125
- runtimeContext,
126
- agentId,
127
- body
128
- }) {
129
- try {
130
- const agent = mastra.getAgent(agentId);
131
- if (!agent) {
132
- throw new HTTPException(404, { message: "Agent not found" });
133
- }
134
- const { messages, resourceId, resourceid, ...rest } = body;
135
- const finalResourceId = resourceId ?? resourceid;
136
- validateBody({ messages });
137
- const streamResult = await agent.stream(messages, {
138
- ...rest,
139
- // @ts-expect-error TODO fix types
140
- resourceId: finalResourceId,
141
- runtimeContext
142
- });
143
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
144
- sendUsage: true,
145
- sendReasoning: true,
146
- getErrorMessage: (error) => {
147
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
148
- }
149
- });
150
- return streamResponse;
151
- } catch (error) {
152
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
153
- }
154
- }
155
-
156
- export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler };