@mastra/server 0.0.0-extend-clickhouse-20250418135620 → 0.0.0-feat-tool-input-validation-20250731232758

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 (102) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +763 -76
  4. package/dist/_tsup-dts-rollup.d.ts +763 -76
  5. package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
  6. package/dist/chunk-2SLFAFTR.cjs +148 -0
  7. package/dist/chunk-36BLNJHS.js +2039 -0
  8. package/dist/chunk-424T5F2J.cjs +157 -0
  9. package/dist/chunk-4D66QEKC.js +81 -0
  10. package/dist/chunk-6KP2OBYA.cjs +544 -0
  11. package/dist/chunk-6T5JUKOQ.js +149 -0
  12. package/dist/chunk-75ZPJI57.cjs +9 -0
  13. package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
  14. package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  15. package/dist/{chunk-YANVFOYA.js → chunk-CRCR3ZUK.js} +56 -34
  16. package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
  17. package/dist/chunk-GHC4YV6R.js +504 -0
  18. package/dist/chunk-HISYIDYH.cjs +2042 -0
  19. package/dist/{chunk-HABV7TZK.cjs → chunk-HRSAZUIK.cjs} +28 -26
  20. package/dist/chunk-I5JKUCGE.cjs +308 -0
  21. package/dist/{chunk-3RVHWGWO.js → chunk-KHZKYUNR.js} +36 -19
  22. package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
  23. package/dist/chunk-LF7P5PLR.js +14 -0
  24. package/dist/chunk-MLKGABMK.js +7 -0
  25. package/dist/chunk-PIAJQ75M.js +539 -0
  26. package/dist/chunk-PZQDCRPV.cjs +16 -0
  27. package/dist/chunk-QGX47B5D.cjs +86 -0
  28. package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
  29. package/dist/chunk-RHSWAXKB.cjs +118 -0
  30. package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
  31. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  32. package/dist/chunk-T7HAZC2E.js +527 -0
  33. package/dist/chunk-UCV4247U.cjs +332 -0
  34. package/dist/chunk-UEVYOKAH.cjs +555 -0
  35. package/dist/chunk-VTTN2FW3.js +299 -0
  36. package/dist/{chunk-XISBMH56.js → chunk-WBRFIHSF.js} +11 -9
  37. package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
  38. package/dist/{chunk-4B7OUZXW.js → chunk-ZYAFP2AV.js} +83 -68
  39. package/dist/server/handlers/a2a.cjs +30 -0
  40. package/dist/server/handlers/a2a.d.cts +6 -0
  41. package/dist/server/handlers/a2a.d.ts +6 -0
  42. package/dist/server/handlers/a2a.js +1 -0
  43. package/dist/server/handlers/agents.cjs +11 -7
  44. package/dist/server/handlers/agents.d.cts +1 -0
  45. package/dist/server/handlers/agents.d.ts +1 -0
  46. package/dist/server/handlers/agents.js +1 -1
  47. package/dist/server/handlers/error.cjs +2 -2
  48. package/dist/server/handlers/error.js +1 -1
  49. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  50. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  51. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  52. package/dist/server/handlers/legacyWorkflows.js +1 -0
  53. package/dist/server/handlers/logs.cjs +4 -4
  54. package/dist/server/handlers/logs.js +1 -1
  55. package/dist/server/handlers/memory.cjs +33 -9
  56. package/dist/server/handlers/memory.d.cts +6 -0
  57. package/dist/server/handlers/memory.d.ts +6 -0
  58. package/dist/server/handlers/memory.js +1 -1
  59. package/dist/server/handlers/network.cjs +5 -5
  60. package/dist/server/handlers/network.js +1 -1
  61. package/dist/server/handlers/scores.cjs +30 -0
  62. package/dist/server/handlers/scores.d.cts +6 -0
  63. package/dist/server/handlers/scores.d.ts +6 -0
  64. package/dist/server/handlers/scores.js +1 -0
  65. package/dist/server/handlers/telemetry.cjs +3 -3
  66. package/dist/server/handlers/telemetry.js +1 -1
  67. package/dist/server/handlers/tools.cjs +5 -5
  68. package/dist/server/handlers/tools.js +1 -1
  69. package/dist/server/handlers/utils.cjs +2 -2
  70. package/dist/server/handlers/utils.js +1 -1
  71. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  72. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  73. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  74. package/dist/server/handlers/vNextNetwork.js +211 -0
  75. package/dist/server/handlers/vector.cjs +7 -7
  76. package/dist/server/handlers/vector.js +1 -1
  77. package/dist/server/handlers/voice.cjs +8 -4
  78. package/dist/server/handlers/voice.d.cts +1 -0
  79. package/dist/server/handlers/voice.d.ts +1 -0
  80. package/dist/server/handlers/voice.js +1 -1
  81. package/dist/server/handlers/workflows.cjs +33 -13
  82. package/dist/server/handlers/workflows.d.cts +7 -2
  83. package/dist/server/handlers/workflows.d.ts +7 -2
  84. package/dist/server/handlers/workflows.js +1 -1
  85. package/dist/server/handlers.cjs +40 -25
  86. package/dist/server/handlers.d.cts +4 -1
  87. package/dist/server/handlers.d.ts +4 -1
  88. package/dist/server/handlers.js +12 -9
  89. package/package.json +17 -15
  90. package/dist/chunk-2FJURXCL.cjs +0 -213
  91. package/dist/chunk-3AHQ5RGN.js +0 -11
  92. package/dist/chunk-3EJZQ6TQ.js +0 -49
  93. package/dist/chunk-4WJ5GHRG.cjs +0 -164
  94. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  95. package/dist/chunk-A7DF4ETD.cjs +0 -100
  96. package/dist/chunk-JLDXUWK7.cjs +0 -126
  97. package/dist/chunk-OMN3UI6X.js +0 -5576
  98. package/dist/chunk-RBQASTUP.js +0 -203
  99. package/dist/chunk-RNU4JMLM.cjs +0 -317
  100. package/dist/chunk-SKBVVI24.cjs +0 -54
  101. package/dist/chunk-TFFNX7FI.js +0 -156
  102. package/dist/chunk-ZLBRQFDD.cjs +0 -13
@@ -1,203 +0,0 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
-
5
- // src/server/handlers/memory.ts
6
- var memory_exports = {};
7
- __export(memory_exports, {
8
- createThreadHandler: () => createThreadHandler,
9
- deleteThreadHandler: () => deleteThreadHandler,
10
- getMemoryStatusHandler: () => getMemoryStatusHandler,
11
- getMessagesHandler: () => getMessagesHandler,
12
- getThreadByIdHandler: () => getThreadByIdHandler,
13
- getThreadsHandler: () => getThreadsHandler,
14
- saveMessagesHandler: () => saveMessagesHandler,
15
- updateThreadHandler: () => updateThreadHandler
16
- });
17
- function getMemoryFromContext({
18
- mastra,
19
- agentId
20
- }) {
21
- const agent = agentId ? mastra.getAgent(agentId) : null;
22
- if (agentId && !agent) {
23
- throw new HTTPException(404, { message: "Agent not found" });
24
- }
25
- const memory = agent?.getMemory?.() || mastra.getMemory();
26
- return memory;
27
- }
28
- async function getMemoryStatusHandler({ mastra, agentId }) {
29
- try {
30
- const memory = getMemoryFromContext({ mastra, agentId });
31
- if (!memory) {
32
- return { result: false };
33
- }
34
- return { result: true };
35
- } catch (error) {
36
- return handleError(error, "Error getting memory status");
37
- }
38
- }
39
- async function getThreadsHandler({
40
- mastra,
41
- agentId,
42
- resourceId
43
- }) {
44
- try {
45
- const memory = getMemoryFromContext({ mastra, agentId });
46
- if (!memory) {
47
- throw new HTTPException(400, { message: "Memory is not initialized" });
48
- }
49
- validateBody({ resourceId });
50
- const threads = await memory.getThreadsByResourceId({ resourceId });
51
- return threads;
52
- } catch (error) {
53
- return handleError(error, "Error getting threads");
54
- }
55
- }
56
- async function getThreadByIdHandler({
57
- mastra,
58
- agentId,
59
- threadId
60
- }) {
61
- try {
62
- validateBody({ threadId });
63
- const memory = getMemoryFromContext({ mastra, agentId });
64
- if (!memory) {
65
- throw new HTTPException(400, { message: "Memory is not initialized" });
66
- }
67
- const thread = await memory.getThreadById({ threadId });
68
- if (!thread) {
69
- throw new HTTPException(404, { message: "Thread not found" });
70
- }
71
- return thread;
72
- } catch (error) {
73
- return handleError(error, "Error getting thread");
74
- }
75
- }
76
- async function saveMessagesHandler({
77
- mastra,
78
- agentId,
79
- body
80
- }) {
81
- try {
82
- const memory = getMemoryFromContext({ mastra, agentId });
83
- if (!memory) {
84
- throw new HTTPException(400, { message: "Memory is not initialized" });
85
- }
86
- if (!body?.messages) {
87
- throw new HTTPException(400, { message: "Messages are required" });
88
- }
89
- if (!Array.isArray(body.messages)) {
90
- throw new HTTPException(400, { message: "Messages should be an array" });
91
- }
92
- const processedMessages = body.messages.map((message) => ({
93
- ...message,
94
- id: memory.generateId(),
95
- createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
96
- }));
97
- const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
98
- return result;
99
- } catch (error) {
100
- return handleError(error, "Error saving messages");
101
- }
102
- }
103
- async function createThreadHandler({
104
- mastra,
105
- agentId,
106
- body
107
- }) {
108
- try {
109
- const memory = getMemoryFromContext({ mastra, agentId });
110
- if (!memory) {
111
- throw new HTTPException(400, { message: "Memory is not initialized" });
112
- }
113
- validateBody({ resourceId: body?.resourceId });
114
- const result = await memory.createThread({
115
- resourceId: body?.resourceId,
116
- title: body?.title,
117
- metadata: body?.metadata,
118
- threadId: body?.threadId
119
- });
120
- return result;
121
- } catch (error) {
122
- return handleError(error, "Error saving thread to memory");
123
- }
124
- }
125
- async function updateThreadHandler({
126
- mastra,
127
- agentId,
128
- threadId,
129
- body
130
- }) {
131
- try {
132
- const memory = getMemoryFromContext({ mastra, agentId });
133
- if (!body) {
134
- throw new HTTPException(400, { message: "Body is required" });
135
- }
136
- const { title, metadata, resourceId } = body;
137
- const updatedAt = /* @__PURE__ */ new Date();
138
- validateBody({ threadId });
139
- if (!memory) {
140
- throw new HTTPException(400, { message: "Memory is not initialized" });
141
- }
142
- const thread = await memory.getThreadById({ threadId });
143
- if (!thread) {
144
- throw new HTTPException(404, { message: "Thread not found" });
145
- }
146
- const updatedThread = {
147
- ...thread,
148
- title: title || thread.title,
149
- metadata: metadata || thread.metadata,
150
- resourceId: resourceId || thread.resourceId,
151
- createdAt: thread.createdAt,
152
- updatedAt
153
- };
154
- const result = await memory.saveThread({ thread: updatedThread });
155
- return result;
156
- } catch (error) {
157
- return handleError(error, "Error updating thread");
158
- }
159
- }
160
- async function deleteThreadHandler({
161
- mastra,
162
- agentId,
163
- threadId
164
- }) {
165
- try {
166
- validateBody({ threadId });
167
- const memory = getMemoryFromContext({ mastra, agentId });
168
- if (!memory) {
169
- throw new HTTPException(400, { message: "Memory is not initialized" });
170
- }
171
- const thread = await memory.getThreadById({ threadId });
172
- if (!thread) {
173
- throw new HTTPException(404, { message: "Thread not found" });
174
- }
175
- await memory.deleteThread(threadId);
176
- return { result: "Thread deleted" };
177
- } catch (error) {
178
- return handleError(error, "Error deleting thread");
179
- }
180
- }
181
- async function getMessagesHandler({
182
- mastra,
183
- agentId,
184
- threadId
185
- }) {
186
- try {
187
- validateBody({ threadId });
188
- const memory = getMemoryFromContext({ mastra, agentId });
189
- if (!memory) {
190
- throw new HTTPException(400, { message: "Memory is not initialized" });
191
- }
192
- const thread = await memory.getThreadById({ threadId });
193
- if (!thread) {
194
- throw new HTTPException(404, { message: "Thread not found" });
195
- }
196
- const result = await memory.query({ threadId });
197
- return result;
198
- } catch (error) {
199
- return handleError(error, "Error getting messages");
200
- }
201
- }
202
-
203
- export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, memory_exports, saveMessagesHandler, updateThreadHandler };
@@ -1,317 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
6
- var web = require('stream/web');
7
-
8
- // src/server/handlers/workflows.ts
9
- var workflows_exports = {};
10
- chunkFV45V6WC_cjs.__export(workflows_exports, {
11
- createRunHandler: () => createRunHandler,
12
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
- getWorkflowRunHandler: () => getWorkflowRunHandler,
14
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
15
- getWorkflowsHandler: () => getWorkflowsHandler,
16
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
17
- resumeWorkflowHandler: () => resumeWorkflowHandler,
18
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
19
- startWorkflowRunHandler: () => startWorkflowRunHandler,
20
- watchWorkflowHandler: () => watchWorkflowHandler
21
- });
22
- async function getWorkflowsHandler({ mastra }) {
23
- try {
24
- const workflows = mastra.getWorkflows({ serialized: false });
25
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
26
- if (workflow.isNested) return acc;
27
- acc[key] = {
28
- stepGraph: workflow.stepGraph,
29
- stepSubscriberGraph: workflow.stepSubscriberGraph,
30
- serializedStepGraph: workflow.serializedStepGraph,
31
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
32
- name: workflow.name,
33
- triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
35
- const _step = step;
36
- acc2[key2] = {
37
- ..._step,
38
- inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
39
- outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
40
- };
41
- return acc2;
42
- }, {})
43
- };
44
- return acc;
45
- }, {});
46
- return _workflows;
47
- } catch (error) {
48
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
49
- }
50
- }
51
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
- try {
53
- if (!workflowId) {
54
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
55
- }
56
- const workflow = mastra.getWorkflow(workflowId);
57
- if (!workflow) {
58
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
59
- }
60
- return {
61
- stepGraph: workflow.stepGraph,
62
- stepSubscriberGraph: workflow.stepSubscriberGraph,
63
- serializedStepGraph: workflow.serializedStepGraph,
64
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
65
- name: workflow.name,
66
- triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
67
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
68
- const _step = step;
69
- acc[key] = {
70
- ..._step,
71
- inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
72
- outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
73
- };
74
- return acc;
75
- }, {})
76
- };
77
- } catch (error) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
79
- }
80
- }
81
- async function startAsyncWorkflowHandler({
82
- mastra,
83
- container,
84
- workflowId,
85
- runId,
86
- triggerData
87
- }) {
88
- try {
89
- if (!workflowId) {
90
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
91
- }
92
- const workflow = mastra.getWorkflow(workflowId);
93
- if (!workflow) {
94
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
95
- }
96
- if (!runId) {
97
- const { start } = workflow.createRun();
98
- const result2 = await start({
99
- triggerData,
100
- container
101
- });
102
- return result2;
103
- }
104
- const run = workflow.getRun(runId);
105
- if (!run) {
106
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
107
- }
108
- const result = await run.start({
109
- triggerData,
110
- container
111
- });
112
- return result;
113
- } catch (error) {
114
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
115
- }
116
- }
117
- async function getWorkflowRunHandler({
118
- mastra,
119
- workflowId,
120
- runId
121
- }) {
122
- try {
123
- if (!workflowId) {
124
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
125
- }
126
- if (!runId) {
127
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
128
- }
129
- const workflow = mastra.getWorkflow(workflowId);
130
- if (!workflow) {
131
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
132
- }
133
- const run = workflow.getRun(runId);
134
- if (!run) {
135
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
136
- }
137
- return run;
138
- } catch (error) {
139
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
140
- }
141
- }
142
- async function createRunHandler({
143
- mastra,
144
- workflowId,
145
- runId: prevRunId
146
- }) {
147
- try {
148
- if (!workflowId) {
149
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
150
- }
151
- const workflow = mastra.getWorkflow(workflowId);
152
- if (!workflow) {
153
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
154
- }
155
- const { runId } = workflow.createRun({ runId: prevRunId });
156
- return { runId };
157
- } catch (error) {
158
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
159
- }
160
- }
161
- async function startWorkflowRunHandler({
162
- mastra,
163
- container,
164
- workflowId,
165
- runId,
166
- triggerData
167
- }) {
168
- try {
169
- if (!workflowId) {
170
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
171
- }
172
- if (!runId) {
173
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
174
- }
175
- const workflow = mastra.getWorkflow(workflowId);
176
- const run = workflow.getRun(runId);
177
- if (!run) {
178
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
179
- }
180
- await run.start({
181
- triggerData,
182
- container
183
- });
184
- return { message: "Workflow run started" };
185
- } catch (e) {
186
- return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
187
- }
188
- }
189
- async function watchWorkflowHandler({
190
- mastra,
191
- workflowId,
192
- runId
193
- }) {
194
- try {
195
- if (!workflowId) {
196
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
197
- }
198
- if (!runId) {
199
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
200
- }
201
- const workflow = mastra.getWorkflow(workflowId);
202
- const run = workflow.getRun(runId);
203
- if (!run) {
204
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
205
- }
206
- let unwatch;
207
- let asyncRef = null;
208
- const stream = new web.ReadableStream({
209
- start(controller) {
210
- unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
211
- const activePathsObj = Object.fromEntries(activePaths);
212
- controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
213
- if (asyncRef) {
214
- clearImmediate(asyncRef);
215
- asyncRef = null;
216
- }
217
- asyncRef = setImmediate(() => {
218
- if (!workflow.getRun(runId2)) {
219
- controller.close();
220
- }
221
- });
222
- });
223
- },
224
- cancel() {
225
- unwatch?.();
226
- }
227
- });
228
- return stream;
229
- } catch (error) {
230
- return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
231
- }
232
- }
233
- async function resumeAsyncWorkflowHandler({
234
- mastra,
235
- workflowId,
236
- runId,
237
- body,
238
- container
239
- }) {
240
- try {
241
- if (!workflowId) {
242
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
243
- }
244
- if (!runId) {
245
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
246
- }
247
- const workflow = mastra.getWorkflow(workflowId);
248
- const run = workflow.getRun(runId);
249
- if (!run) {
250
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
251
- }
252
- const result = await run.resume({
253
- stepId: body.stepId,
254
- context: body.context,
255
- container
256
- });
257
- return result;
258
- } catch (error) {
259
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
260
- }
261
- }
262
- async function resumeWorkflowHandler({
263
- mastra,
264
- workflowId,
265
- runId,
266
- body,
267
- container
268
- }) {
269
- try {
270
- if (!workflowId) {
271
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
272
- }
273
- if (!runId) {
274
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
275
- }
276
- const workflow = mastra.getWorkflow(workflowId);
277
- const run = workflow.getRun(runId);
278
- if (!run) {
279
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
280
- }
281
- await run.resume({
282
- stepId: body.stepId,
283
- context: body.context,
284
- container
285
- });
286
- return { message: "Workflow run resumed" };
287
- } catch (error) {
288
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
289
- }
290
- }
291
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
292
- try {
293
- if (!workflowId) {
294
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
295
- }
296
- const workflow = mastra.getWorkflow(workflowId);
297
- const workflowRuns = await workflow.getWorkflowRuns() || {
298
- runs: [],
299
- total: 0
300
- };
301
- return workflowRuns;
302
- } catch (error) {
303
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
304
- }
305
- }
306
-
307
- exports.createRunHandler = createRunHandler;
308
- exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
309
- exports.getWorkflowRunHandler = getWorkflowRunHandler;
310
- exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
311
- exports.getWorkflowsHandler = getWorkflowsHandler;
312
- exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
313
- exports.resumeWorkflowHandler = resumeWorkflowHandler;
314
- exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
315
- exports.startWorkflowRunHandler = startWorkflowRunHandler;
316
- exports.watchWorkflowHandler = watchWorkflowHandler;
317
- exports.workflows_exports = workflows_exports;
@@ -1,54 +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/logs.ts
8
- var logs_exports = {};
9
- chunkFV45V6WC_cjs.__export(logs_exports, {
10
- getLogTransports: () => getLogTransports,
11
- getLogsByRunIdHandler: () => getLogsByRunIdHandler,
12
- getLogsHandler: () => getLogsHandler
13
- });
14
- async function getLogsHandler({
15
- mastra,
16
- transportId
17
- }) {
18
- try {
19
- chunkQN4KF3BH_cjs.validateBody({ transportId });
20
- const logs = await mastra.getLogs(transportId);
21
- return logs;
22
- } catch (error) {
23
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs");
24
- }
25
- }
26
- async function getLogsByRunIdHandler({
27
- mastra,
28
- runId,
29
- transportId
30
- }) {
31
- try {
32
- chunkQN4KF3BH_cjs.validateBody({ runId, transportId });
33
- const logs = await mastra.getLogsByRunId({ runId, transportId });
34
- return logs;
35
- } catch (error) {
36
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs by run ID");
37
- }
38
- }
39
- async function getLogTransports({ mastra }) {
40
- try {
41
- const logger = mastra.getLogger();
42
- const transports = logger.transports;
43
- return {
44
- transports: transports ? Object.keys(transports) : []
45
- };
46
- } catch (error) {
47
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting log Transports");
48
- }
49
- }
50
-
51
- exports.getLogTransports = getLogTransports;
52
- exports.getLogsByRunIdHandler = getLogsByRunIdHandler;
53
- exports.getLogsHandler = getLogsHandler;
54
- exports.logs_exports = logs_exports;