@mastra/server 0.0.0-fix-memory-xxhash-20250409202110 → 0.0.0-generate-message-id-20250512171942

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 (75) hide show
  1. package/{LICENSE → LICENSE.md} +3 -1
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +282 -34
  4. package/dist/_tsup-dts-rollup.d.ts +282 -34
  5. package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
  6. package/dist/chunk-3HQNCTZ2.cjs +199 -0
  7. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  8. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  9. package/dist/chunk-5SN4U5AC.cjs +508 -0
  10. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  11. package/dist/chunk-75ZPJI57.cjs +9 -0
  12. package/dist/{chunk-2YONKUWB.js → chunk-C7564HUT.js} +58 -33
  13. package/dist/{chunk-ILW7XYNJ.js → chunk-EJO45KYT.js} +51 -27
  14. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  15. package/dist/{chunk-3RVHWGWO.js → chunk-HFWCEP5S.js} +6 -12
  16. package/dist/{chunk-2JQC6JWP.js → chunk-HWZVAG3H.js} +7 -4
  17. package/dist/{chunk-X37I6GZT.cjs → chunk-I2B73Y4I.cjs} +92 -68
  18. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  19. package/dist/chunk-LIVAK2DM.js +2001 -0
  20. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  21. package/dist/{chunk-CWSDZEZG.cjs → chunk-MHKNLNAN.cjs} +15 -12
  22. package/dist/chunk-MIQYDLLM.js +329 -0
  23. package/dist/chunk-MLKGABMK.js +7 -0
  24. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  25. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  26. package/dist/{chunk-VB7KH62D.cjs → chunk-OGCNNUHF.cjs} +13 -10
  27. package/dist/{chunk-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
  28. package/dist/chunk-P6SCPDYW.js +500 -0
  29. package/dist/{chunk-BMA2ORRT.js → chunk-Q6KMBIAN.js} +76 -37
  30. package/dist/{chunk-YNSGUC2O.js → chunk-TJKLBTFB.js} +23 -7
  31. package/dist/chunk-UCTEMO2Q.cjs +341 -0
  32. package/dist/chunk-VPNDC2DI.cjs +148 -0
  33. package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
  34. package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
  35. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  36. package/dist/{chunk-4C3EPMMF.cjs → chunk-ZE5AAC4I.cjs} +40 -24
  37. package/dist/server/handlers/a2a.cjs +30 -0
  38. package/dist/server/handlers/a2a.d.cts +6 -0
  39. package/dist/server/handlers/a2a.d.ts +6 -0
  40. package/dist/server/handlers/a2a.js +1 -0
  41. package/dist/server/handlers/agents.cjs +7 -7
  42. package/dist/server/handlers/agents.js +1 -1
  43. package/dist/server/handlers/error.cjs +2 -2
  44. package/dist/server/handlers/error.js +1 -1
  45. package/dist/server/handlers/logs.cjs +4 -4
  46. package/dist/server/handlers/logs.js +1 -1
  47. package/dist/server/handlers/memory.cjs +9 -9
  48. package/dist/server/handlers/memory.js +1 -1
  49. package/dist/server/handlers/network.cjs +5 -5
  50. package/dist/server/handlers/network.js +1 -1
  51. package/dist/server/handlers/telemetry.cjs +3 -3
  52. package/dist/server/handlers/telemetry.js +1 -1
  53. package/dist/server/handlers/tools.cjs +5 -5
  54. package/dist/server/handlers/tools.js +1 -1
  55. package/dist/server/handlers/utils.cjs +2 -2
  56. package/dist/server/handlers/utils.js +1 -1
  57. package/dist/server/handlers/vNextWorkflows.cjs +46 -0
  58. package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
  59. package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
  60. package/dist/server/handlers/vNextWorkflows.js +1 -0
  61. package/dist/server/handlers/vector.cjs +7 -7
  62. package/dist/server/handlers/vector.js +1 -1
  63. package/dist/server/handlers/voice.cjs +4 -4
  64. package/dist/server/handlers/voice.js +1 -1
  65. package/dist/server/handlers/workflows.cjs +11 -11
  66. package/dist/server/handlers/workflows.js +1 -1
  67. package/dist/server/handlers.cjs +31 -21
  68. package/dist/server/handlers.d.cts +2 -0
  69. package/dist/server/handlers.d.ts +2 -0
  70. package/dist/server/handlers.js +11 -9
  71. package/package.json +9 -7
  72. package/dist/chunk-5JOF627H.cjs +0 -123
  73. package/dist/chunk-GV52BII2.cjs +0 -160
  74. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  75. package/dist/chunk-VK6FX47H.js +0 -5576
@@ -1,46 +1,46 @@
1
1
  'use strict';
2
2
 
3
- var chunkX37I6GZT_cjs = require('../../chunk-X37I6GZT.cjs');
3
+ var chunkI2B73Y4I_cjs = require('../../chunk-I2B73Y4I.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createRunHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkX37I6GZT_cjs.createRunHandler; }
9
+ get: function () { return chunkI2B73Y4I_cjs.createRunHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getWorkflowByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkX37I6GZT_cjs.getWorkflowByIdHandler; }
13
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getWorkflowRunHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkX37I6GZT_cjs.getWorkflowRunHandler; }
17
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowRunHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getWorkflowRunsHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkX37I6GZT_cjs.getWorkflowRunsHandler; }
21
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowRunsHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getWorkflowsHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunkX37I6GZT_cjs.getWorkflowsHandler; }
25
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowsHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "resumeAsyncWorkflowHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunkX37I6GZT_cjs.resumeAsyncWorkflowHandler; }
29
+ get: function () { return chunkI2B73Y4I_cjs.resumeAsyncWorkflowHandler; }
30
30
  });
31
31
  Object.defineProperty(exports, "resumeWorkflowHandler", {
32
32
  enumerable: true,
33
- get: function () { return chunkX37I6GZT_cjs.resumeWorkflowHandler; }
33
+ get: function () { return chunkI2B73Y4I_cjs.resumeWorkflowHandler; }
34
34
  });
35
35
  Object.defineProperty(exports, "startAsyncWorkflowHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunkX37I6GZT_cjs.startAsyncWorkflowHandler; }
37
+ get: function () { return chunkI2B73Y4I_cjs.startAsyncWorkflowHandler; }
38
38
  });
39
39
  Object.defineProperty(exports, "startWorkflowRunHandler", {
40
40
  enumerable: true,
41
- get: function () { return chunkX37I6GZT_cjs.startWorkflowRunHandler; }
41
+ get: function () { return chunkI2B73Y4I_cjs.startWorkflowRunHandler; }
42
42
  });
43
43
  Object.defineProperty(exports, "watchWorkflowHandler", {
44
44
  enumerable: true,
45
- get: function () { return chunkX37I6GZT_cjs.watchWorkflowHandler; }
45
+ get: function () { return chunkI2B73Y4I_cjs.watchWorkflowHandler; }
46
46
  });
@@ -1 +1 @@
1
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-ILW7XYNJ.js';
1
+ export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-EJO45KYT.js';
@@ -1,50 +1,60 @@
1
1
  'use strict';
2
2
 
3
- var chunk4C3EPMMF_cjs = require('../chunk-4C3EPMMF.cjs');
4
- var chunkM56ECCHK_cjs = require('../chunk-M56ECCHK.cjs');
5
- var chunkA7DF4ETD_cjs = require('../chunk-A7DF4ETD.cjs');
6
- var chunkX37I6GZT_cjs = require('../chunk-X37I6GZT.cjs');
7
- var chunkGV52BII2_cjs = require('../chunk-GV52BII2.cjs');
8
- var chunkVB7KH62D_cjs = require('../chunk-VB7KH62D.cjs');
9
- var chunk2FJURXCL_cjs = require('../chunk-2FJURXCL.cjs');
10
- var chunk5JOF627H_cjs = require('../chunk-5JOF627H.cjs');
11
- var chunkCWSDZEZG_cjs = require('../chunk-CWSDZEZG.cjs');
3
+ var chunkMHKNLNAN_cjs = require('../chunk-MHKNLNAN.cjs');
4
+ var chunkZE5AAC4I_cjs = require('../chunk-ZE5AAC4I.cjs');
5
+ var chunkUCTEMO2Q_cjs = require('../chunk-UCTEMO2Q.cjs');
6
+ var chunk4YZ3U35L_cjs = require('../chunk-4YZ3U35L.cjs');
7
+ var chunkYBVOQN4M_cjs = require('../chunk-YBVOQN4M.cjs');
8
+ var chunkI2B73Y4I_cjs = require('../chunk-I2B73Y4I.cjs');
9
+ var chunk5SN4U5AC_cjs = require('../chunk-5SN4U5AC.cjs');
10
+ var chunk3HQNCTZ2_cjs = require('../chunk-3HQNCTZ2.cjs');
11
+ var chunkOGCNNUHF_cjs = require('../chunk-OGCNNUHF.cjs');
12
+ var chunk24EGIVT7_cjs = require('../chunk-24EGIVT7.cjs');
13
+ var chunkVPNDC2DI_cjs = require('../chunk-VPNDC2DI.cjs');
12
14
 
13
15
 
14
16
 
17
+ Object.defineProperty(exports, "telemetry", {
18
+ enumerable: true,
19
+ get: function () { return chunkMHKNLNAN_cjs.telemetry_exports; }
20
+ });
15
21
  Object.defineProperty(exports, "tools", {
16
22
  enumerable: true,
17
- get: function () { return chunk4C3EPMMF_cjs.tools_exports; }
23
+ get: function () { return chunkZE5AAC4I_cjs.tools_exports; }
24
+ });
25
+ Object.defineProperty(exports, "vNextWorkflows", {
26
+ enumerable: true,
27
+ get: function () { return chunkUCTEMO2Q_cjs.vNextWorkflows_exports; }
18
28
  });
19
29
  Object.defineProperty(exports, "vector", {
20
30
  enumerable: true,
21
- get: function () { return chunkM56ECCHK_cjs.vector_exports; }
31
+ get: function () { return chunk4YZ3U35L_cjs.vector_exports; }
22
32
  });
23
33
  Object.defineProperty(exports, "voice", {
24
34
  enumerable: true,
25
- get: function () { return chunkA7DF4ETD_cjs.voice_exports; }
35
+ get: function () { return chunkYBVOQN4M_cjs.voice_exports; }
26
36
  });
27
37
  Object.defineProperty(exports, "workflows", {
28
38
  enumerable: true,
29
- get: function () { return chunkX37I6GZT_cjs.workflows_exports; }
39
+ get: function () { return chunkI2B73Y4I_cjs.workflows_exports; }
40
+ });
41
+ Object.defineProperty(exports, "a2a", {
42
+ enumerable: true,
43
+ get: function () { return chunk5SN4U5AC_cjs.a2a_exports; }
30
44
  });
31
45
  Object.defineProperty(exports, "agents", {
32
46
  enumerable: true,
33
- get: function () { return chunkGV52BII2_cjs.agents_exports; }
47
+ get: function () { return chunk3HQNCTZ2_cjs.agents_exports; }
34
48
  });
35
49
  Object.defineProperty(exports, "logs", {
36
50
  enumerable: true,
37
- get: function () { return chunkVB7KH62D_cjs.logs_exports; }
51
+ get: function () { return chunkOGCNNUHF_cjs.logs_exports; }
38
52
  });
39
53
  Object.defineProperty(exports, "memory", {
40
54
  enumerable: true,
41
- get: function () { return chunk2FJURXCL_cjs.memory_exports; }
55
+ get: function () { return chunk24EGIVT7_cjs.memory_exports; }
42
56
  });
43
57
  Object.defineProperty(exports, "network", {
44
58
  enumerable: true,
45
- get: function () { return chunk5JOF627H_cjs.network_exports; }
46
- });
47
- Object.defineProperty(exports, "telemetry", {
48
- enumerable: true,
49
- get: function () { return chunkCWSDZEZG_cjs.telemetry_exports; }
59
+ get: function () { return chunkVPNDC2DI_cjs.network_exports; }
50
60
  });
@@ -1,9 +1,11 @@
1
1
  export { agents } from '../_tsup-dts-rollup.cjs';
2
+ export { a2a } from '../_tsup-dts-rollup.cjs';
2
3
  export { logs } from '../_tsup-dts-rollup.cjs';
3
4
  export { memory } from '../_tsup-dts-rollup.cjs';
4
5
  export { network } from '../_tsup-dts-rollup.cjs';
5
6
  export { telemetry } from '../_tsup-dts-rollup.cjs';
6
7
  export { tools } from '../_tsup-dts-rollup.cjs';
7
8
  export { workflows } from '../_tsup-dts-rollup.cjs';
9
+ export { vNextWorkflows } from '../_tsup-dts-rollup.cjs';
8
10
  export { vector } from '../_tsup-dts-rollup.cjs';
9
11
  export { voice } from '../_tsup-dts-rollup.cjs';
@@ -1,9 +1,11 @@
1
1
  export { agents } from '../_tsup-dts-rollup.js';
2
+ export { a2a } from '../_tsup-dts-rollup.js';
2
3
  export { logs } from '../_tsup-dts-rollup.js';
3
4
  export { memory } from '../_tsup-dts-rollup.js';
4
5
  export { network } from '../_tsup-dts-rollup.js';
5
6
  export { telemetry } from '../_tsup-dts-rollup.js';
6
7
  export { tools } from '../_tsup-dts-rollup.js';
7
8
  export { workflows } from '../_tsup-dts-rollup.js';
9
+ export { vNextWorkflows } from '../_tsup-dts-rollup.js';
8
10
  export { vector } from '../_tsup-dts-rollup.js';
9
11
  export { voice } from '../_tsup-dts-rollup.js';
@@ -1,9 +1,11 @@
1
- export { tools_exports as tools } from '../chunk-YNSGUC2O.js';
2
- export { vector_exports as vector } from '../chunk-4JINXASC.js';
3
- export { voice_exports as voice } from '../chunk-3RVHWGWO.js';
4
- export { workflows_exports as workflows } from '../chunk-ILW7XYNJ.js';
5
- export { agents_exports as agents } from '../chunk-BMA2ORRT.js';
6
- export { logs_exports as logs } from '../chunk-2JQC6JWP.js';
7
- export { memory_exports as memory } from '../chunk-RBQASTUP.js';
8
- export { network_exports as network } from '../chunk-2YONKUWB.js';
9
- export { telemetry_exports as telemetry } from '../chunk-DVPP5S6I.js';
1
+ export { telemetry_exports as telemetry } from '../chunk-OR3CIE2H.js';
2
+ export { tools_exports as tools } from '../chunk-TJKLBTFB.js';
3
+ export { vNextWorkflows_exports as vNextWorkflows } from '../chunk-MIQYDLLM.js';
4
+ export { vector_exports as vector } from '../chunk-IU5VO2I2.js';
5
+ export { voice_exports as voice } from '../chunk-HFWCEP5S.js';
6
+ export { workflows_exports as workflows } from '../chunk-EJO45KYT.js';
7
+ export { a2a_exports as a2a } from '../chunk-P6SCPDYW.js';
8
+ export { agents_exports as agents } from '../chunk-Q6KMBIAN.js';
9
+ export { logs_exports as logs } from '../chunk-HWZVAG3H.js';
10
+ export { memory_exports as memory } from '../chunk-X3ZDCS52.js';
11
+ export { network_exports as network } from '../chunk-C7564HUT.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "0.0.0-fix-memory-xxhash-20250409202110",
3
+ "version": "0.0.0-generate-message-id-20250512171942",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -43,23 +43,25 @@
43
43
  },
44
44
  "keywords": [],
45
45
  "author": "",
46
- "license": "ISC",
46
+ "license": "Elastic-2.0",
47
47
  "dependencies": {},
48
48
  "peerDependencies": {
49
- "@mastra/core": "0.0.0-fix-memory-xxhash-20250409202110"
49
+ "zod": "^3.0.0",
50
+ "@mastra/core": "0.0.0-generate-message-id-20250512171942"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@ai-sdk/openai": "^1.3.2",
53
- "@microsoft/api-extractor": "^7.52.1",
54
+ "@microsoft/api-extractor": "^7.52.5",
54
55
  "@types/node": "^20.17.27",
55
56
  "eslint": "^9.23.0",
56
57
  "superjson": "^2.2.2",
57
58
  "tsup": "^8.4.0",
58
59
  "typescript": "^5.8.2",
59
60
  "vitest": "^2.1.9",
60
- "zod-to-json-schema": "^3.24.3",
61
- "@mastra/core": "0.0.0-fix-memory-xxhash-20250409202110",
62
- "@internal/lint": "0.0.1"
61
+ "zod": "^3.24.3",
62
+ "zod-to-json-schema": "^3.24.5",
63
+ "@internal/lint": "0.0.0-generate-message-id-20250512171942",
64
+ "@mastra/core": "0.0.0-generate-message-id-20250512171942"
63
65
  },
64
66
  "scripts": {
65
67
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",
@@ -1,123 +0,0 @@
1
- 'use strict';
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');
6
-
7
- // src/server/handlers/network.ts
8
- var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
- generateHandler: () => generateHandler,
11
- getNetworkByIdHandler: () => getNetworkByIdHandler,
12
- getNetworksHandler: () => getNetworksHandler,
13
- streamGenerateHandler: () => streamGenerateHandler
14
- });
15
- async function getNetworksHandler({ mastra }) {
16
- try {
17
- const networks = mastra.getNetworks();
18
- const serializedNetworks = networks.map((network) => {
19
- const routingAgent = network.getRoutingAgent();
20
- const agents = network.getAgents();
21
- return {
22
- id: network.formatAgentId(routingAgent.name),
23
- name: routingAgent.name,
24
- instructions: routingAgent.instructions,
25
- agents: agents.map((agent) => ({
26
- name: agent.name,
27
- provider: agent.llm?.getProvider(),
28
- modelId: agent.llm?.getModelId()
29
- })),
30
- routingModel: {
31
- provider: routingAgent.llm?.getProvider(),
32
- modelId: routingAgent.llm?.getModelId()
33
- }
34
- };
35
- });
36
- return serializedNetworks;
37
- } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
39
- }
40
- }
41
- async function getNetworkByIdHandler({ mastra, networkId }) {
42
- try {
43
- const networks = mastra.getNetworks();
44
- const network = networks.find((network2) => {
45
- const routingAgent2 = network2.getRoutingAgent();
46
- return network2.formatAgentId(routingAgent2.name) === networkId;
47
- });
48
- if (!network) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
50
- }
51
- const routingAgent = network.getRoutingAgent();
52
- const agents = network.getAgents();
53
- const serializedNetwork = {
54
- id: network.formatAgentId(routingAgent.name),
55
- name: routingAgent.name,
56
- instructions: routingAgent.instructions,
57
- agents: agents.map((agent) => ({
58
- name: agent.name,
59
- provider: agent.llm?.getProvider(),
60
- modelId: agent.llm?.getModelId()
61
- })),
62
- routingModel: {
63
- provider: routingAgent.llm?.getProvider(),
64
- modelId: routingAgent.llm?.getModelId()
65
- }
66
- };
67
- return serializedNetwork;
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
70
- }
71
- }
72
- async function generateHandler({
73
- mastra,
74
- networkId,
75
- body
76
- }) {
77
- try {
78
- const network = mastra.getNetwork(networkId);
79
- if (!network) {
80
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
81
- }
82
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
83
- const { messages, ...rest } = body;
84
- const result = await network.generate(messages, rest);
85
- return result;
86
- } catch (error) {
87
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
88
- }
89
- }
90
- async function streamGenerateHandler({
91
- mastra,
92
- networkId,
93
- body
94
- }) {
95
- try {
96
- const network = mastra.getNetwork(networkId);
97
- if (!network) {
98
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
99
- }
100
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
101
- const { messages, output, ...rest } = body;
102
- const streamResult = await network.stream(messages, {
103
- output,
104
- ...rest
105
- });
106
- const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
107
- sendUsage: true,
108
- sendReasoning: true,
109
- getErrorMessage: (error) => {
110
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
111
- }
112
- });
113
- return streamResponse;
114
- } catch (error) {
115
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
116
- }
117
- }
118
-
119
- exports.generateHandler = generateHandler;
120
- exports.getNetworkByIdHandler = getNetworkByIdHandler;
121
- exports.getNetworksHandler = getNetworksHandler;
122
- exports.network_exports = network_exports;
123
- exports.streamGenerateHandler = streamGenerateHandler;
@@ -1,160 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkQH6XWSXP_cjs = require('./chunk-QH6XWSXP.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');
7
-
8
- // src/server/handlers/agents.ts
9
- var agents_exports = {};
10
- chunkFV45V6WC_cjs.__export(agents_exports, {
11
- generateHandler: () => generateHandler,
12
- getAgentByIdHandler: () => getAgentByIdHandler,
13
- getAgentsHandler: () => getAgentsHandler,
14
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
15
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
16
- streamGenerateHandler: () => streamGenerateHandler
17
- });
18
- async function getAgentsHandler({ mastra }) {
19
- try {
20
- const agents = mastra.getAgents();
21
- const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
22
- const agent = _agent;
23
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc2, [key, tool]) => {
24
- const _tool = tool;
25
- acc2[key] = {
26
- ..._tool,
27
- inputSchema: _tool.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_tool.inputSchema)) : void 0,
28
- outputSchema: _tool.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_tool.outputSchema)) : void 0
29
- };
30
- return acc2;
31
- }, {});
32
- acc[_id] = {
33
- name: agent.name,
34
- instructions: agent.instructions,
35
- tools: serializedAgentTools,
36
- provider: agent.llm?.getProvider(),
37
- modelId: agent.llm?.getModelId()
38
- };
39
- return acc;
40
- }, {});
41
- return serializedAgents;
42
- } catch (error) {
43
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
44
- }
45
- }
46
- async function getAgentByIdHandler({ mastra, agentId }) {
47
- try {
48
- const agent = mastra.getAgent(agentId);
49
- if (!agent) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
51
- }
52
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
53
- const _tool = tool;
54
- acc[key] = {
55
- ..._tool,
56
- inputSchema: _tool.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_tool.inputSchema)) : void 0,
57
- outputSchema: _tool.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_tool.outputSchema)) : void 0
58
- };
59
- return acc;
60
- }, {});
61
- return {
62
- name: agent.name,
63
- instructions: agent.instructions,
64
- tools: serializedAgentTools,
65
- provider: agent.llm?.getProvider(),
66
- modelId: agent.llm?.getModelId()
67
- };
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
70
- }
71
- }
72
- async function getEvalsByAgentIdHandler({ mastra, agentId }) {
73
- try {
74
- const agent = mastra.getAgent(agentId);
75
- const evals = await mastra.getStorage()?.__getEvalsByAgentName?.(agent.name, "test") || [];
76
- return {
77
- id: agentId,
78
- name: agent.name,
79
- instructions: agent.instructions,
80
- evals
81
- };
82
- } catch (error) {
83
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
84
- }
85
- }
86
- async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
87
- try {
88
- const agent = mastra.getAgent(agentId);
89
- const evals = await mastra.getStorage()?.__getEvalsByAgentName?.(agent.name, "live") || [];
90
- return {
91
- id: agentId,
92
- name: agent.name,
93
- instructions: agent.instructions,
94
- evals
95
- };
96
- } catch (error) {
97
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting live evals");
98
- }
99
- }
100
- async function generateHandler({
101
- mastra,
102
- agentId,
103
- body
104
- }) {
105
- try {
106
- const agent = mastra.getAgent(agentId);
107
- if (!agent) {
108
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
109
- }
110
- const { messages, resourceId, resourceid, ...rest } = body;
111
- const finalResourceId = resourceId ?? resourceid;
112
- chunkQN4KF3BH_cjs.validateBody({ messages });
113
- const result = await agent.generate(messages, {
114
- ...rest,
115
- // @ts-expect-error TODO fix types
116
- resourceId: finalResourceId
117
- });
118
- return result;
119
- } catch (error) {
120
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from agent");
121
- }
122
- }
123
- async function streamGenerateHandler({
124
- mastra,
125
- agentId,
126
- body
127
- }) {
128
- try {
129
- const agent = mastra.getAgent(agentId);
130
- if (!agent) {
131
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
132
- }
133
- const { messages, resourceId, resourceid, ...rest } = body;
134
- const finalResourceId = resourceId ?? resourceid;
135
- chunkQN4KF3BH_cjs.validateBody({ messages });
136
- const streamResult = await agent.stream(messages, {
137
- ...rest,
138
- // @ts-expect-error TODO fix types
139
- resourceId: finalResourceId
140
- });
141
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
142
- sendUsage: true,
143
- sendReasoning: true,
144
- getErrorMessage: (error) => {
145
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
146
- }
147
- });
148
- return streamResponse;
149
- } catch (error) {
150
- throw new chunkFV45V6WC_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
151
- }
152
- }
153
-
154
- exports.agents_exports = agents_exports;
155
- exports.generateHandler = generateHandler;
156
- exports.getAgentByIdHandler = getAgentByIdHandler;
157
- exports.getAgentsHandler = getAgentsHandler;
158
- exports.getEvalsByAgentIdHandler = getEvalsByAgentIdHandler;
159
- exports.getLiveEvalsByAgentIdHandler = getLiveEvalsByAgentIdHandler;
160
- exports.streamGenerateHandler = streamGenerateHandler;