@mastra/server 0.0.0-working-memory-per-user-20250620163010 → 0.0.0-zod-v4-compat-part-2-20250820135355
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.
- package/LICENSE.md +11 -42
- package/dist/{chunk-VPNDC2DI.cjs → chunk-4CEZIJWJ.cjs} +16 -14
- package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
- package/dist/{chunk-QLG2PFHE.js → chunk-4MQU6AJN.js} +5 -3
- package/dist/chunk-4MQU6AJN.js.map +1 -0
- package/dist/{chunk-57CJTIPW.cjs → chunk-4QSNRCOT.cjs} +4 -2
- package/dist/chunk-4QSNRCOT.cjs.map +1 -0
- package/dist/{chunk-WJY57THV.cjs → chunk-4US5W7PH.cjs} +26 -24
- package/dist/chunk-4US5W7PH.cjs.map +1 -0
- package/dist/chunk-57W7TS7P.cjs +547 -0
- package/dist/chunk-57W7TS7P.cjs.map +1 -0
- package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-BED2O446.cjs} +11 -9
- package/dist/chunk-BED2O446.cjs.map +1 -0
- package/dist/chunk-CY4TP3FK.js +16 -0
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/{chunk-55DOQLP6.js → chunk-G7NVCO5M.js} +5 -3
- package/dist/chunk-G7NVCO5M.js.map +1 -0
- package/dist/{chunk-SDPGVWQJ.cjs → chunk-GASWM5HJ.cjs} +4 -2
- package/dist/chunk-GASWM5HJ.cjs.map +1 -0
- package/dist/{chunk-5UV7XQ4G.js → chunk-GBL4JYW7.js} +52 -16
- package/dist/chunk-GBL4JYW7.js.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-GX25CWC7.cjs +588 -0
- package/dist/chunk-GX25CWC7.cjs.map +1 -0
- package/dist/{chunk-N2YBMSO2.js → chunk-HNYYFKON.js} +18 -15
- package/dist/chunk-HNYYFKON.js.map +1 -0
- package/dist/{chunk-R5VGYBV6.js → chunk-HWHKM67I.js} +6 -4
- package/dist/chunk-HWHKM67I.js.map +1 -0
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-ILCWPBYQ.cjs} +9 -7
- package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
- package/dist/{chunk-2GOU7Q4O.js → chunk-ITZX6VPI.js} +146 -73
- package/dist/chunk-ITZX6VPI.js.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/{chunk-BNEY4P4P.cjs → chunk-NCS2OXX6.cjs} +20 -18
- package/dist/chunk-NCS2OXX6.cjs.map +1 -0
- package/dist/{chunk-H5PTF3Y4.js → chunk-OW4FX5TS.js} +3 -1
- package/dist/chunk-OW4FX5TS.js.map +1 -0
- package/dist/{chunk-MLKGABMK.js → chunk-PZ5AY32C.js} +2 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-75ZPJI57.cjs → chunk-Q7SFCCGT.cjs} +2 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/{chunk-CPPYMJX5.cjs → chunk-RTI33BGT.cjs} +25 -22
- package/dist/chunk-RTI33BGT.cjs.map +1 -0
- package/dist/{chunk-E5IRS3XH.cjs → chunk-SKWJUK3M.cjs} +63 -26
- package/dist/chunk-SKWJUK3M.cjs.map +1 -0
- package/dist/{chunk-4DTDPTQC.cjs → chunk-SOIOAAJ4.cjs} +48 -45
- package/dist/chunk-SOIOAAJ4.cjs.map +1 -0
- package/dist/{chunk-BFOA2QQY.js → chunk-SQ7KKIH3.js} +5 -3
- package/dist/chunk-SQ7KKIH3.js.map +1 -0
- package/dist/{chunk-GHC4YV6R.js → chunk-TRWPUPGD.js} +3 -1
- package/dist/chunk-TRWPUPGD.js.map +1 -0
- package/dist/chunk-TXAQU2XN.js +151 -0
- package/dist/chunk-TXAQU2XN.js.map +1 -0
- package/dist/chunk-VIGPWTDA.cjs +159 -0
- package/dist/chunk-VIGPWTDA.cjs.map +1 -0
- package/dist/{chunk-XR7VJOOP.js → chunk-WHQZT6R2.js} +12 -9
- package/dist/chunk-WHQZT6R2.js.map +1 -0
- package/dist/{chunk-C7564HUT.js → chunk-Y3J45CVZ.js} +6 -4
- package/dist/chunk-Y3J45CVZ.js.map +1 -0
- package/dist/chunk-ZKJZQN24.js +571 -0
- package/dist/chunk-ZKJZQN24.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server/a2a/protocol.d.ts +8 -0
- package/dist/server/a2a/protocol.d.ts.map +1 -0
- package/dist/server/a2a/store.d.ts +14 -0
- package/dist/server/a2a/store.d.ts.map +1 -0
- package/dist/server/a2a/tasks.d.ts +20 -0
- package/dist/server/a2a/tasks.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -7
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +66 -6
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -1
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agents.cjs +13 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +81 -6
- package/dist/server/handlers/agents.d.ts.map +1 -0
- package/dist/server/handlers/agents.js +3 -1
- package/dist/server/handlers/agents.js.map +1 -0
- package/dist/server/handlers/error.cjs +4 -2
- package/dist/server/handlers/error.cjs.map +1 -0
- package/dist/server/handlers/error.d.ts +2 -1
- package/dist/server/handlers/error.d.ts.map +1 -0
- package/dist/server/handlers/error.js +3 -1
- package/dist/server/handlers/error.js.map +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +13 -11
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -1
- package/dist/server/handlers/legacyWorkflows.js.map +1 -0
- package/dist/server/handlers/logs.cjs +6 -4
- package/dist/server/handlers/logs.cjs.map +1 -0
- package/dist/server/handlers/logs.d.ts +34 -3
- package/dist/server/handlers/logs.d.ts.map +1 -0
- package/dist/server/handlers/logs.js +3 -1
- package/dist/server/handlers/logs.js.map +1 -0
- package/dist/server/handlers/memory.cjs +39 -9
- package/dist/server/handlers/memory.cjs.map +1 -0
- package/dist/server/handlers/memory.d.ts +119 -8
- package/dist/server/handlers/memory.d.ts.map +1 -0
- package/dist/server/handlers/memory.js +3 -1
- package/dist/server/handlers/memory.js.map +1 -0
- package/dist/server/handlers/network.cjs +7 -5
- package/dist/server/handlers/network.cjs.map +1 -0
- package/dist/server/handlers/network.d.ts +50 -4
- package/dist/server/handlers/network.d.ts.map +1 -0
- package/dist/server/handlers/network.js +3 -1
- package/dist/server/handlers/network.js.map +1 -0
- package/dist/server/handlers/scores.cjs +32 -0
- package/dist/server/handlers/scores.cjs.map +1 -0
- package/dist/server/handlers/scores.d.ts +49 -0
- package/dist/server/handlers/scores.d.ts.map +1 -0
- package/dist/server/handlers/scores.js +3 -0
- package/dist/server/handlers/scores.js.map +1 -0
- package/dist/server/handlers/telemetry.cjs +5 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +32 -2
- package/dist/server/handlers/telemetry.d.ts.map +1 -0
- package/dist/server/handlers/telemetry.js +3 -1
- package/dist/server/handlers/telemetry.js.map +1 -0
- package/dist/server/handlers/tools.cjs +7 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +21 -4
- package/dist/server/handlers/tools.d.ts.map +1 -0
- package/dist/server/handlers/tools.js +3 -1
- package/dist/server/handlers/tools.js.map +1 -0
- package/dist/server/handlers/utils.cjs +4 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +2 -1
- package/dist/server/handlers/utils.d.ts.map +1 -0
- package/dist/server/handlers/utils.js +3 -1
- package/dist/server/handlers/utils.js.map +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +220 -0
- package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +179 -0
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
- package/dist/server/handlers/vNextNetwork.js +213 -0
- package/dist/server/handlers/vNextNetwork.js.map +1 -0
- package/dist/server/handlers/vector.cjs +9 -7
- package/dist/server/handlers/vector.cjs.map +1 -0
- package/dist/server/handlers/vector.d.ts +51 -6
- package/dist/server/handlers/vector.d.ts.map +1 -0
- package/dist/server/handlers/vector.js +3 -1
- package/dist/server/handlers/vector.js.map +1 -0
- package/dist/server/handlers/voice.cjs +7 -5
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +39 -4
- package/dist/server/handlers/voice.d.ts.map +1 -0
- package/dist/server/handlers/voice.js +3 -1
- package/dist/server/handlers/voice.js.map +1 -0
- package/dist/server/handlers/workflows.cjs +27 -13
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +88 -12
- package/dist/server/handlers/workflows.d.ts.map +1 -0
- package/dist/server/handlers/workflows.js +3 -1
- package/dist/server/handlers/workflows.js.map +1 -0
- package/dist/server/handlers.cjs +32 -25
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +13 -11
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +14 -11
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/http-exception.d.ts +87 -0
- package/dist/server/http-exception.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/_tsup-dts-rollup.d.cts +0 -864
- package/dist/_tsup-dts-rollup.d.ts +0 -864
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-6TJSHFCJ.cjs +0 -221
- package/dist/chunk-7TB34RLZ.cjs +0 -471
- package/dist/chunk-I7KJZNX5.js +0 -211
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-MN6F4D5A.cjs +0 -2004
- package/dist/chunk-OSZM4EAY.js +0 -2001
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -4
- package/dist/server/handlers/workflows.d.cts +0 -12
- package/dist/server/handlers.d.cts +0 -11
package/dist/chunk-64U3UDTH.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
4
|
-
|
|
5
|
-
// src/server/handlers/error.ts
|
|
6
|
-
function handleError(error, defaultMessage) {
|
|
7
|
-
const apiError = error;
|
|
8
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(apiError.status || 500, {
|
|
9
|
-
message: apiError.message || defaultMessage
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.handleError = handleError;
|
package/dist/chunk-6TJSHFCJ.cjs
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
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');
|
|
6
|
-
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/memory.ts
|
|
9
|
-
var memory_exports = {};
|
|
10
|
-
chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
11
|
-
createThreadHandler: () => createThreadHandler,
|
|
12
|
-
deleteThreadHandler: () => deleteThreadHandler,
|
|
13
|
-
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
14
|
-
getMessagesHandler: () => getMessagesHandler,
|
|
15
|
-
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
16
|
-
getThreadsHandler: () => getThreadsHandler,
|
|
17
|
-
saveMessagesHandler: () => saveMessagesHandler,
|
|
18
|
-
updateThreadHandler: () => updateThreadHandler
|
|
19
|
-
});
|
|
20
|
-
function getMemoryFromContext({
|
|
21
|
-
mastra,
|
|
22
|
-
agentId
|
|
23
|
-
}) {
|
|
24
|
-
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
25
|
-
if (agentId && !agent) {
|
|
26
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
27
|
-
}
|
|
28
|
-
const memory = agent?.getMemory?.() || mastra.getMemory();
|
|
29
|
-
return memory;
|
|
30
|
-
}
|
|
31
|
-
async function getMemoryStatusHandler({ mastra, agentId }) {
|
|
32
|
-
try {
|
|
33
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
34
|
-
if (!memory) {
|
|
35
|
-
return { result: false };
|
|
36
|
-
}
|
|
37
|
-
return { result: true };
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function getThreadsHandler({
|
|
43
|
-
mastra,
|
|
44
|
-
agentId,
|
|
45
|
-
resourceId
|
|
46
|
-
}) {
|
|
47
|
-
try {
|
|
48
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
49
|
-
if (!memory) {
|
|
50
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
51
|
-
}
|
|
52
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
53
|
-
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
54
|
-
return threads;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function getThreadByIdHandler({
|
|
60
|
-
mastra,
|
|
61
|
-
agentId,
|
|
62
|
-
threadId
|
|
63
|
-
}) {
|
|
64
|
-
try {
|
|
65
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
66
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
67
|
-
if (!memory) {
|
|
68
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
69
|
-
}
|
|
70
|
-
const thread = await memory.getThreadById({ threadId });
|
|
71
|
-
if (!thread) {
|
|
72
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
73
|
-
}
|
|
74
|
-
return thread;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function saveMessagesHandler({
|
|
80
|
-
mastra,
|
|
81
|
-
agentId,
|
|
82
|
-
body
|
|
83
|
-
}) {
|
|
84
|
-
try {
|
|
85
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
86
|
-
if (!memory) {
|
|
87
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
88
|
-
}
|
|
89
|
-
if (!body?.messages) {
|
|
90
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
91
|
-
}
|
|
92
|
-
if (!Array.isArray(body.messages)) {
|
|
93
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
94
|
-
}
|
|
95
|
-
const processedMessages = body.messages.map((message) => ({
|
|
96
|
-
...message,
|
|
97
|
-
id: memory.generateId(),
|
|
98
|
-
createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
|
|
99
|
-
}));
|
|
100
|
-
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
101
|
-
return result;
|
|
102
|
-
} catch (error) {
|
|
103
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async function createThreadHandler({
|
|
107
|
-
mastra,
|
|
108
|
-
agentId,
|
|
109
|
-
body
|
|
110
|
-
}) {
|
|
111
|
-
try {
|
|
112
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
113
|
-
if (!memory) {
|
|
114
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
115
|
-
}
|
|
116
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
117
|
-
const result = await memory.createThread({
|
|
118
|
-
resourceId: body?.resourceId,
|
|
119
|
-
title: body?.title,
|
|
120
|
-
metadata: body?.metadata,
|
|
121
|
-
threadId: body?.threadId
|
|
122
|
-
});
|
|
123
|
-
return result;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function updateThreadHandler({
|
|
129
|
-
mastra,
|
|
130
|
-
agentId,
|
|
131
|
-
threadId,
|
|
132
|
-
body
|
|
133
|
-
}) {
|
|
134
|
-
try {
|
|
135
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
136
|
-
if (!body) {
|
|
137
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
138
|
-
}
|
|
139
|
-
const { title, metadata, resourceId } = body;
|
|
140
|
-
const updatedAt = /* @__PURE__ */ new Date();
|
|
141
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
142
|
-
if (!memory) {
|
|
143
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
144
|
-
}
|
|
145
|
-
const thread = await memory.getThreadById({ threadId });
|
|
146
|
-
if (!thread) {
|
|
147
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
148
|
-
}
|
|
149
|
-
const updatedThread = {
|
|
150
|
-
...thread,
|
|
151
|
-
title: title || thread.title,
|
|
152
|
-
metadata: metadata || thread.metadata,
|
|
153
|
-
resourceId: resourceId || thread.resourceId,
|
|
154
|
-
createdAt: thread.createdAt,
|
|
155
|
-
updatedAt
|
|
156
|
-
};
|
|
157
|
-
const result = await memory.saveThread({ thread: updatedThread });
|
|
158
|
-
return result;
|
|
159
|
-
} catch (error) {
|
|
160
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
async function deleteThreadHandler({
|
|
164
|
-
mastra,
|
|
165
|
-
agentId,
|
|
166
|
-
threadId
|
|
167
|
-
}) {
|
|
168
|
-
try {
|
|
169
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
170
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
171
|
-
if (!memory) {
|
|
172
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
173
|
-
}
|
|
174
|
-
const thread = await memory.getThreadById({ threadId });
|
|
175
|
-
if (!thread) {
|
|
176
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
177
|
-
}
|
|
178
|
-
await memory.deleteThread(threadId);
|
|
179
|
-
return { result: "Thread deleted" };
|
|
180
|
-
} catch (error) {
|
|
181
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
async function getMessagesHandler({
|
|
185
|
-
mastra,
|
|
186
|
-
agentId,
|
|
187
|
-
threadId,
|
|
188
|
-
limit
|
|
189
|
-
}) {
|
|
190
|
-
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
191
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
195
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
196
|
-
if (!memory) {
|
|
197
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
198
|
-
}
|
|
199
|
-
const thread = await memory.getThreadById({ threadId });
|
|
200
|
-
if (!thread) {
|
|
201
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
202
|
-
}
|
|
203
|
-
const result = await memory.query({
|
|
204
|
-
threadId,
|
|
205
|
-
...limit && { selectBy: { last: limit } }
|
|
206
|
-
});
|
|
207
|
-
return { messages: result.messages, uiMessages: result.uiMessages };
|
|
208
|
-
} catch (error) {
|
|
209
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
exports.createThreadHandler = createThreadHandler;
|
|
214
|
-
exports.deleteThreadHandler = deleteThreadHandler;
|
|
215
|
-
exports.getMemoryStatusHandler = getMemoryStatusHandler;
|
|
216
|
-
exports.getMessagesHandler = getMessagesHandler;
|
|
217
|
-
exports.getThreadByIdHandler = getThreadByIdHandler;
|
|
218
|
-
exports.getThreadsHandler = getThreadsHandler;
|
|
219
|
-
exports.memory_exports = memory_exports;
|
|
220
|
-
exports.saveMessagesHandler = saveMessagesHandler;
|
|
221
|
-
exports.updateThreadHandler = updateThreadHandler;
|
package/dist/chunk-7TB34RLZ.cjs
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
|
|
4
|
-
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
|
-
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
|
-
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
|
-
var web = require('stream/web');
|
|
8
|
-
var di = require('@mastra/core/di');
|
|
9
|
-
|
|
10
|
-
// src/server/handlers/workflows.ts
|
|
11
|
-
var workflows_exports = {};
|
|
12
|
-
chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
13
|
-
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
14
|
-
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
15
|
-
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
16
|
-
getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
|
|
17
|
-
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
18
|
-
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
19
|
-
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
20
|
-
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
21
|
-
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
22
|
-
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
23
|
-
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
24
|
-
watchWorkflowHandler: () => watchWorkflowHandler
|
|
25
|
-
});
|
|
26
|
-
async function getWorkflowsHandler({ mastra }) {
|
|
27
|
-
try {
|
|
28
|
-
const workflows = mastra.getWorkflows({ serialized: false });
|
|
29
|
-
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
30
|
-
acc[key] = {
|
|
31
|
-
name: workflow.name,
|
|
32
|
-
description: workflow.description,
|
|
33
|
-
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
34
|
-
acc2[key2] = {
|
|
35
|
-
id: step.id,
|
|
36
|
-
description: step.description,
|
|
37
|
-
inputSchema: step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.inputSchema)) : void 0,
|
|
38
|
-
outputSchema: step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.outputSchema)) : void 0,
|
|
39
|
-
resumeSchema: step.resumeSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
40
|
-
suspendSchema: step.suspendSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.suspendSchema)) : void 0
|
|
41
|
-
};
|
|
42
|
-
return acc2;
|
|
43
|
-
}, {}),
|
|
44
|
-
stepGraph: workflow.serializedStepGraph,
|
|
45
|
-
inputSchema: workflow.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
46
|
-
outputSchema: workflow.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
47
|
-
};
|
|
48
|
-
return acc;
|
|
49
|
-
}, {});
|
|
50
|
-
return _workflows;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
56
|
-
const logger = mastra.getLogger();
|
|
57
|
-
if (!workflowId) {
|
|
58
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
59
|
-
}
|
|
60
|
-
let workflow;
|
|
61
|
-
try {
|
|
62
|
-
workflow = mastra.getWorkflow(workflowId);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
logger.debug("Error getting workflow, searching agents for workflow", error);
|
|
65
|
-
}
|
|
66
|
-
if (!workflow) {
|
|
67
|
-
logger.debug("Workflow not found, searching agents for workflow", { workflowId });
|
|
68
|
-
const agents = mastra.getAgents();
|
|
69
|
-
if (Object.keys(agents || {}).length) {
|
|
70
|
-
for (const [_, agent] of Object.entries(agents)) {
|
|
71
|
-
try {
|
|
72
|
-
const workflows = await agent.getWorkflows();
|
|
73
|
-
if (workflows[workflowId]) {
|
|
74
|
-
workflow = workflows[workflowId];
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
logger.debug("Error getting workflow from agent", error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (!workflow) {
|
|
85
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
86
|
-
}
|
|
87
|
-
return { workflow };
|
|
88
|
-
}
|
|
89
|
-
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
90
|
-
try {
|
|
91
|
-
if (!workflowId) {
|
|
92
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
93
|
-
}
|
|
94
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
95
|
-
if (!workflow) {
|
|
96
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
100
|
-
acc[key] = {
|
|
101
|
-
id: step.id,
|
|
102
|
-
description: step.description,
|
|
103
|
-
inputSchema: step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.inputSchema)) : void 0,
|
|
104
|
-
outputSchema: step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.outputSchema)) : void 0,
|
|
105
|
-
resumeSchema: step.resumeSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
106
|
-
suspendSchema: step.suspendSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(step.suspendSchema)) : void 0
|
|
107
|
-
};
|
|
108
|
-
return acc;
|
|
109
|
-
}, {}),
|
|
110
|
-
name: workflow.name,
|
|
111
|
-
description: workflow.description,
|
|
112
|
-
stepGraph: workflow.serializedStepGraph,
|
|
113
|
-
inputSchema: workflow.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
114
|
-
outputSchema: workflow.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
115
|
-
};
|
|
116
|
-
} catch (error) {
|
|
117
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async function getWorkflowRunByIdHandler({
|
|
121
|
-
mastra,
|
|
122
|
-
workflowId,
|
|
123
|
-
runId
|
|
124
|
-
}) {
|
|
125
|
-
try {
|
|
126
|
-
if (!workflowId) {
|
|
127
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
128
|
-
}
|
|
129
|
-
if (!runId) {
|
|
130
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
131
|
-
}
|
|
132
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
133
|
-
if (!workflow) {
|
|
134
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
135
|
-
}
|
|
136
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
137
|
-
if (!run) {
|
|
138
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
139
|
-
}
|
|
140
|
-
return run;
|
|
141
|
-
} catch (error) {
|
|
142
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async function getWorkflowRunExecutionResultHandler({
|
|
146
|
-
mastra,
|
|
147
|
-
workflowId,
|
|
148
|
-
runId
|
|
149
|
-
}) {
|
|
150
|
-
try {
|
|
151
|
-
if (!workflowId) {
|
|
152
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
153
|
-
}
|
|
154
|
-
if (!runId) {
|
|
155
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
156
|
-
}
|
|
157
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
158
|
-
if (!workflow) {
|
|
159
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
160
|
-
}
|
|
161
|
-
const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
|
|
162
|
-
if (!executionResult) {
|
|
163
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
|
|
164
|
-
}
|
|
165
|
-
return executionResult;
|
|
166
|
-
} catch (error) {
|
|
167
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, {
|
|
168
|
-
message: error?.message || "Error getting workflow run execution result"
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
async function createWorkflowRunHandler({
|
|
173
|
-
mastra,
|
|
174
|
-
workflowId,
|
|
175
|
-
runId: prevRunId
|
|
176
|
-
}) {
|
|
177
|
-
try {
|
|
178
|
-
if (!workflowId) {
|
|
179
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
180
|
-
}
|
|
181
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
182
|
-
if (!workflow) {
|
|
183
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
184
|
-
}
|
|
185
|
-
const run = workflow.createRun({ runId: prevRunId });
|
|
186
|
-
return { runId: run.runId };
|
|
187
|
-
} catch (error) {
|
|
188
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async function startAsyncWorkflowHandler({
|
|
192
|
-
mastra,
|
|
193
|
-
runtimeContext: payloadRuntimeContext,
|
|
194
|
-
workflowId,
|
|
195
|
-
runId,
|
|
196
|
-
inputData
|
|
197
|
-
}) {
|
|
198
|
-
try {
|
|
199
|
-
if (!workflowId) {
|
|
200
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
201
|
-
}
|
|
202
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
203
|
-
if (!workflow) {
|
|
204
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
205
|
-
}
|
|
206
|
-
let runtimeContext;
|
|
207
|
-
if (payloadRuntimeContext) {
|
|
208
|
-
runtimeContext = new di.RuntimeContext();
|
|
209
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
210
|
-
runtimeContext.set(key, value);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
const _run = workflow.createRun({ runId });
|
|
214
|
-
const result = await _run.start({
|
|
215
|
-
inputData,
|
|
216
|
-
runtimeContext
|
|
217
|
-
});
|
|
218
|
-
return result;
|
|
219
|
-
} catch (error) {
|
|
220
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
async function startWorkflowRunHandler({
|
|
224
|
-
mastra,
|
|
225
|
-
runtimeContext: payloadRuntimeContext,
|
|
226
|
-
workflowId,
|
|
227
|
-
runId,
|
|
228
|
-
inputData
|
|
229
|
-
}) {
|
|
230
|
-
try {
|
|
231
|
-
if (!workflowId) {
|
|
232
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
233
|
-
}
|
|
234
|
-
if (!runId) {
|
|
235
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
236
|
-
}
|
|
237
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
238
|
-
if (!workflow) {
|
|
239
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
240
|
-
}
|
|
241
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
242
|
-
if (!run) {
|
|
243
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
244
|
-
}
|
|
245
|
-
let runtimeContext;
|
|
246
|
-
if (payloadRuntimeContext) {
|
|
247
|
-
runtimeContext = new di.RuntimeContext();
|
|
248
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
249
|
-
runtimeContext.set(key, value);
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
const _run = workflow.createRun({ runId });
|
|
253
|
-
void _run.start({
|
|
254
|
-
inputData,
|
|
255
|
-
runtimeContext
|
|
256
|
-
});
|
|
257
|
-
return { message: "Workflow run started" };
|
|
258
|
-
} catch (e) {
|
|
259
|
-
return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
async function watchWorkflowHandler({
|
|
263
|
-
mastra,
|
|
264
|
-
workflowId,
|
|
265
|
-
runId
|
|
266
|
-
}) {
|
|
267
|
-
try {
|
|
268
|
-
if (!workflowId) {
|
|
269
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
270
|
-
}
|
|
271
|
-
if (!runId) {
|
|
272
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
273
|
-
}
|
|
274
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
275
|
-
if (!workflow) {
|
|
276
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
277
|
-
}
|
|
278
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
279
|
-
if (!run) {
|
|
280
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
281
|
-
}
|
|
282
|
-
const _run = workflow.createRun({ runId });
|
|
283
|
-
let unwatch;
|
|
284
|
-
let asyncRef = null;
|
|
285
|
-
const stream = new web.ReadableStream({
|
|
286
|
-
start(controller) {
|
|
287
|
-
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
288
|
-
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
289
|
-
if (asyncRef) {
|
|
290
|
-
clearImmediate(asyncRef);
|
|
291
|
-
asyncRef = null;
|
|
292
|
-
}
|
|
293
|
-
asyncRef = setImmediate(async () => {
|
|
294
|
-
const runDone = payload.workflowState.status !== "running";
|
|
295
|
-
if (runDone) {
|
|
296
|
-
controller.close();
|
|
297
|
-
unwatch?.();
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
},
|
|
302
|
-
cancel() {
|
|
303
|
-
unwatch?.();
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
return stream;
|
|
307
|
-
} catch (error) {
|
|
308
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
async function streamWorkflowHandler({
|
|
312
|
-
mastra,
|
|
313
|
-
runtimeContext: payloadRuntimeContext,
|
|
314
|
-
workflowId,
|
|
315
|
-
runId,
|
|
316
|
-
inputData
|
|
317
|
-
}) {
|
|
318
|
-
try {
|
|
319
|
-
if (!workflowId) {
|
|
320
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
321
|
-
}
|
|
322
|
-
if (!runId) {
|
|
323
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
324
|
-
}
|
|
325
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
326
|
-
if (!workflow) {
|
|
327
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
328
|
-
}
|
|
329
|
-
let runtimeContext;
|
|
330
|
-
if (payloadRuntimeContext) {
|
|
331
|
-
runtimeContext = new di.RuntimeContext();
|
|
332
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
333
|
-
runtimeContext.set(key, value);
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
const run = workflow.createRun({ runId });
|
|
337
|
-
const result = run.stream({
|
|
338
|
-
inputData,
|
|
339
|
-
runtimeContext
|
|
340
|
-
});
|
|
341
|
-
return result;
|
|
342
|
-
} catch (error) {
|
|
343
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
async function resumeAsyncWorkflowHandler({
|
|
347
|
-
mastra,
|
|
348
|
-
workflowId,
|
|
349
|
-
runId,
|
|
350
|
-
body,
|
|
351
|
-
runtimeContext: payloadRuntimeContext
|
|
352
|
-
}) {
|
|
353
|
-
try {
|
|
354
|
-
if (!workflowId) {
|
|
355
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
356
|
-
}
|
|
357
|
-
if (!runId) {
|
|
358
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
359
|
-
}
|
|
360
|
-
if (!body.step) {
|
|
361
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
362
|
-
}
|
|
363
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
364
|
-
if (!workflow) {
|
|
365
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
366
|
-
}
|
|
367
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
368
|
-
if (!run) {
|
|
369
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
370
|
-
}
|
|
371
|
-
let runtimeContext;
|
|
372
|
-
if (payloadRuntimeContext) {
|
|
373
|
-
runtimeContext = new di.RuntimeContext();
|
|
374
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
375
|
-
runtimeContext.set(key, value);
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
const _run = workflow.createRun({ runId });
|
|
379
|
-
const result = await _run.resume({
|
|
380
|
-
step: body.step,
|
|
381
|
-
resumeData: body.resumeData,
|
|
382
|
-
runtimeContext
|
|
383
|
-
});
|
|
384
|
-
return result;
|
|
385
|
-
} catch (error) {
|
|
386
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async function resumeWorkflowHandler({
|
|
390
|
-
mastra,
|
|
391
|
-
workflowId,
|
|
392
|
-
runId,
|
|
393
|
-
body,
|
|
394
|
-
runtimeContext: payloadRuntimeContext
|
|
395
|
-
}) {
|
|
396
|
-
try {
|
|
397
|
-
if (!workflowId) {
|
|
398
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
399
|
-
}
|
|
400
|
-
if (!runId) {
|
|
401
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
402
|
-
}
|
|
403
|
-
if (!body.step) {
|
|
404
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
405
|
-
}
|
|
406
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
407
|
-
if (!workflow) {
|
|
408
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
409
|
-
}
|
|
410
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
411
|
-
if (!run) {
|
|
412
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
413
|
-
}
|
|
414
|
-
let runtimeContext;
|
|
415
|
-
if (payloadRuntimeContext) {
|
|
416
|
-
runtimeContext = new di.RuntimeContext();
|
|
417
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
418
|
-
runtimeContext.set(key, value);
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
const _run = workflow.createRun({ runId });
|
|
422
|
-
void _run.resume({
|
|
423
|
-
step: body.step,
|
|
424
|
-
resumeData: body.resumeData,
|
|
425
|
-
runtimeContext
|
|
426
|
-
});
|
|
427
|
-
return { message: "Workflow run resumed" };
|
|
428
|
-
} catch (error) {
|
|
429
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
async function getWorkflowRunsHandler({
|
|
433
|
-
mastra,
|
|
434
|
-
workflowId,
|
|
435
|
-
fromDate,
|
|
436
|
-
toDate,
|
|
437
|
-
limit,
|
|
438
|
-
offset,
|
|
439
|
-
resourceId
|
|
440
|
-
}) {
|
|
441
|
-
try {
|
|
442
|
-
if (!workflowId) {
|
|
443
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
444
|
-
}
|
|
445
|
-
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
446
|
-
if (!workflow) {
|
|
447
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
448
|
-
}
|
|
449
|
-
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
450
|
-
runs: [],
|
|
451
|
-
total: 0
|
|
452
|
-
};
|
|
453
|
-
return workflowRuns;
|
|
454
|
-
} catch (error) {
|
|
455
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
exports.createWorkflowRunHandler = createWorkflowRunHandler;
|
|
460
|
-
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
461
|
-
exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
462
|
-
exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
|
|
463
|
-
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
464
|
-
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
465
|
-
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
466
|
-
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
467
|
-
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
468
|
-
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
469
|
-
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
470
|
-
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
471
|
-
exports.workflows_exports = workflows_exports;
|