@mastra/server 0.0.0-switch-to-core-20250424015131 → 0.0.0-taofeeqInngest-20250603090617
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/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +316 -43
- package/dist/_tsup-dts-rollup.d.ts +316 -43
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-A3KDUGS7.cjs +239 -0
- package/dist/{chunk-7IWQE76Z.cjs → chunk-B4MQFJ7G.cjs} +16 -10
- package/dist/{chunk-WTHDCRMY.js → chunk-BFOA2QQY.js} +12 -6
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-RE6YL32K.js → chunk-C7564HUT.js} +52 -30
- package/dist/{chunk-55HTWX4C.cjs → chunk-CMMOIUFC.cjs} +40 -19
- package/dist/{chunk-Q6SHQECN.js → chunk-CP55EVBK.js} +24 -4
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-3EJZQ6TQ.js → chunk-DQLE3DVM.js} +5 -5
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/chunk-J3PKLB3A.js +231 -0
- package/dist/chunk-KUNQFY2W.js +365 -0
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MMO2HDM6.cjs +378 -0
- package/dist/{chunk-SKBVVI24.cjs → chunk-NEOOQUKW.cjs} +11 -11
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/{chunk-FPIWDH5Y.cjs → chunk-VPNDC2DI.cjs} +62 -40
- package/dist/{chunk-LFOBHRFO.js → chunk-W7VCKPAD.js} +68 -53
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- package/dist/chunk-YIOVBYZH.cjs +332 -0
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +17 -13
- package/dist/server/handlers/workflows.d.cts +3 -2
- package/dist/server/handlers/workflows.d.ts +3 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +33 -23
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +8 -6
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-HCOPJZ4A.cjs +0 -164
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-R4J7XQYU.js +0 -156
- package/dist/chunk-TZK63M5N.cjs +0 -317
|
@@ -1,44 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
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');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/network.ts
|
|
8
9
|
var network_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(network_exports, {
|
|
10
11
|
generateHandler: () => generateHandler,
|
|
11
12
|
getNetworkByIdHandler: () => getNetworkByIdHandler,
|
|
12
13
|
getNetworksHandler: () => getNetworksHandler,
|
|
13
14
|
streamGenerateHandler: () => streamGenerateHandler
|
|
14
15
|
});
|
|
15
|
-
async function getNetworksHandler({
|
|
16
|
+
async function getNetworksHandler({
|
|
17
|
+
mastra,
|
|
18
|
+
runtimeContext
|
|
19
|
+
}) {
|
|
16
20
|
try {
|
|
17
21
|
const networks = mastra.getNetworks();
|
|
18
|
-
const serializedNetworks =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const serializedNetworks = await Promise.all(
|
|
23
|
+
networks.map(async (network) => {
|
|
24
|
+
const routingAgent = network.getRoutingAgent();
|
|
25
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
26
|
+
const agents = network.getAgents();
|
|
27
|
+
return {
|
|
28
|
+
id: network.formatAgentId(routingAgent.name),
|
|
29
|
+
name: routingAgent.name,
|
|
30
|
+
instructions: routingAgent.instructions,
|
|
31
|
+
agents: await Promise.all(
|
|
32
|
+
agents.map(async (agent) => {
|
|
33
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
34
|
+
return {
|
|
35
|
+
name: agent.name,
|
|
36
|
+
provider: llm?.getProvider(),
|
|
37
|
+
modelId: llm?.getModelId()
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
routingModel: {
|
|
42
|
+
provider: routingLLM?.getProvider(),
|
|
43
|
+
modelId: routingLLM?.getModelId()
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
);
|
|
36
48
|
return serializedNetworks;
|
|
37
49
|
} catch (error) {
|
|
38
|
-
return
|
|
50
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting networks");
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
|
-
async function getNetworkByIdHandler({
|
|
53
|
+
async function getNetworkByIdHandler({
|
|
54
|
+
mastra,
|
|
55
|
+
networkId,
|
|
56
|
+
runtimeContext
|
|
57
|
+
}) {
|
|
42
58
|
try {
|
|
43
59
|
const networks = mastra.getNetworks();
|
|
44
60
|
const network = networks.find((network2) => {
|
|
@@ -46,27 +62,33 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
46
62
|
return network2.formatAgentId(routingAgent2.name) === networkId;
|
|
47
63
|
});
|
|
48
64
|
if (!network) {
|
|
49
|
-
throw new
|
|
65
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
50
66
|
}
|
|
51
67
|
const routingAgent = network.getRoutingAgent();
|
|
68
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
52
69
|
const agents = network.getAgents();
|
|
53
70
|
const serializedNetwork = {
|
|
54
71
|
id: network.formatAgentId(routingAgent.name),
|
|
55
72
|
name: routingAgent.name,
|
|
56
73
|
instructions: routingAgent.instructions,
|
|
57
|
-
agents:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
agents: await Promise.all(
|
|
75
|
+
agents.map(async (agent) => {
|
|
76
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
77
|
+
return {
|
|
78
|
+
name: agent.name,
|
|
79
|
+
provider: llm?.getProvider(),
|
|
80
|
+
modelId: llm?.getModelId()
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
),
|
|
62
84
|
routingModel: {
|
|
63
|
-
provider:
|
|
64
|
-
modelId:
|
|
85
|
+
provider: routingLLM?.getProvider(),
|
|
86
|
+
modelId: routingLLM?.getModelId()
|
|
65
87
|
}
|
|
66
88
|
};
|
|
67
89
|
return serializedNetwork;
|
|
68
90
|
} catch (error) {
|
|
69
|
-
return
|
|
91
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting network by ID");
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
async function generateHandler({
|
|
@@ -78,14 +100,14 @@ async function generateHandler({
|
|
|
78
100
|
try {
|
|
79
101
|
const network = mastra.getNetwork(networkId);
|
|
80
102
|
if (!network) {
|
|
81
|
-
throw new
|
|
103
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
82
104
|
}
|
|
83
|
-
|
|
105
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
84
106
|
const { messages, ...rest } = body;
|
|
85
107
|
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
86
108
|
return result;
|
|
87
109
|
} catch (error) {
|
|
88
|
-
return
|
|
110
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error generating from network");
|
|
89
111
|
}
|
|
90
112
|
}
|
|
91
113
|
async function streamGenerateHandler({
|
|
@@ -97,9 +119,9 @@ async function streamGenerateHandler({
|
|
|
97
119
|
try {
|
|
98
120
|
const network = mastra.getNetwork(networkId);
|
|
99
121
|
if (!network) {
|
|
100
|
-
throw new
|
|
122
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
101
123
|
}
|
|
102
|
-
|
|
124
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
103
125
|
const { messages, output, ...rest } = body;
|
|
104
126
|
const streamResult = await network.stream(messages, {
|
|
105
127
|
output,
|
|
@@ -115,7 +137,7 @@ async function streamGenerateHandler({
|
|
|
115
137
|
});
|
|
116
138
|
return streamResponse;
|
|
117
139
|
} catch (error) {
|
|
118
|
-
return
|
|
140
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error streaming from network");
|
|
119
141
|
}
|
|
120
142
|
}
|
|
121
143
|
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
1
|
+
import { stringify, esm_default } from './chunk-LIVAK2DM.js';
|
|
2
|
+
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
4
5
|
import { ReadableStream } from 'node:stream/web';
|
|
5
6
|
|
|
6
|
-
// src/server/handlers/
|
|
7
|
-
var
|
|
8
|
-
__export(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
// src/server/handlers/legacyWorkflows.ts
|
|
8
|
+
var legacyWorkflows_exports = {};
|
|
9
|
+
__export(legacyWorkflows_exports, {
|
|
10
|
+
createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
|
|
11
|
+
getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
|
|
12
|
+
getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
|
|
13
|
+
getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
|
|
14
|
+
getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
|
|
15
|
+
resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
|
|
16
|
+
resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
|
|
17
|
+
startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
|
|
18
|
+
startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
|
|
19
|
+
watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
|
|
19
20
|
});
|
|
20
|
-
async function
|
|
21
|
+
async function getLegacyWorkflowsHandler({ mastra }) {
|
|
21
22
|
try {
|
|
22
|
-
const workflows = mastra.
|
|
23
|
+
const workflows = mastra.legacy_getWorkflows({ serialized: false });
|
|
23
24
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
24
25
|
if (workflow.isNested) return acc;
|
|
25
26
|
acc[key] = {
|
|
@@ -32,7 +33,9 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
32
33
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
33
34
|
const _step = step;
|
|
34
35
|
acc2[key2] = {
|
|
35
|
-
|
|
36
|
+
id: _step.id,
|
|
37
|
+
description: _step.description,
|
|
38
|
+
workflowId: _step.workflowId,
|
|
36
39
|
inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
|
|
37
40
|
outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
|
|
38
41
|
};
|
|
@@ -46,12 +49,12 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
46
49
|
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
async function
|
|
52
|
+
async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
|
|
50
53
|
try {
|
|
51
54
|
if (!workflowId) {
|
|
52
55
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
53
56
|
}
|
|
54
|
-
const workflow = mastra.
|
|
57
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
55
58
|
if (!workflow) {
|
|
56
59
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
57
60
|
}
|
|
@@ -65,7 +68,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
65
68
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
66
69
|
const _step = step;
|
|
67
70
|
acc[key] = {
|
|
68
|
-
|
|
71
|
+
id: _step.id,
|
|
72
|
+
description: _step.description,
|
|
73
|
+
workflowId: _step.workflowId,
|
|
69
74
|
inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
|
|
70
75
|
outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
|
|
71
76
|
};
|
|
@@ -76,7 +81,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
76
81
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
|
-
async function
|
|
84
|
+
async function startAsyncLegacyWorkflowHandler({
|
|
80
85
|
mastra,
|
|
81
86
|
runtimeContext,
|
|
82
87
|
workflowId,
|
|
@@ -87,19 +92,19 @@ async function startAsyncWorkflowHandler({
|
|
|
87
92
|
if (!workflowId) {
|
|
88
93
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
89
94
|
}
|
|
90
|
-
const workflow = mastra.
|
|
95
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
91
96
|
if (!workflow) {
|
|
92
97
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
93
98
|
}
|
|
94
99
|
if (!runId) {
|
|
95
|
-
const
|
|
96
|
-
const result2 = await start({
|
|
100
|
+
const newRun = workflow.createRun();
|
|
101
|
+
const result2 = await newRun.start({
|
|
97
102
|
triggerData,
|
|
98
103
|
runtimeContext
|
|
99
104
|
});
|
|
100
105
|
return result2;
|
|
101
106
|
}
|
|
102
|
-
const run = workflow.
|
|
107
|
+
const run = workflow.getMemoryRun(runId);
|
|
103
108
|
if (!run) {
|
|
104
109
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
105
110
|
}
|
|
@@ -112,7 +117,7 @@ async function startAsyncWorkflowHandler({
|
|
|
112
117
|
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
async function
|
|
120
|
+
async function getLegacyWorkflowRunHandler({
|
|
116
121
|
mastra,
|
|
117
122
|
workflowId,
|
|
118
123
|
runId
|
|
@@ -124,11 +129,11 @@ async function getWorkflowRunHandler({
|
|
|
124
129
|
if (!runId) {
|
|
125
130
|
throw new HTTPException(400, { message: "Run ID is required" });
|
|
126
131
|
}
|
|
127
|
-
const workflow = mastra.
|
|
132
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
128
133
|
if (!workflow) {
|
|
129
134
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
130
135
|
}
|
|
131
|
-
const run = workflow.getRun(runId);
|
|
136
|
+
const run = await workflow.getRun(runId);
|
|
132
137
|
if (!run) {
|
|
133
138
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
134
139
|
}
|
|
@@ -137,7 +142,7 @@ async function getWorkflowRunHandler({
|
|
|
137
142
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
|
-
async function
|
|
145
|
+
async function createLegacyWorkflowRunHandler({
|
|
141
146
|
mastra,
|
|
142
147
|
workflowId,
|
|
143
148
|
runId: prevRunId
|
|
@@ -146,17 +151,17 @@ async function createRunHandler({
|
|
|
146
151
|
if (!workflowId) {
|
|
147
152
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
148
153
|
}
|
|
149
|
-
const workflow = mastra.
|
|
154
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
150
155
|
if (!workflow) {
|
|
151
156
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
152
157
|
}
|
|
153
|
-
const
|
|
154
|
-
return { runId };
|
|
158
|
+
const newRun = workflow.createRun({ runId: prevRunId });
|
|
159
|
+
return { runId: newRun.runId };
|
|
155
160
|
} catch (error) {
|
|
156
161
|
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
157
162
|
}
|
|
158
163
|
}
|
|
159
|
-
async function
|
|
164
|
+
async function startLegacyWorkflowRunHandler({
|
|
160
165
|
mastra,
|
|
161
166
|
runtimeContext,
|
|
162
167
|
workflowId,
|
|
@@ -170,12 +175,12 @@ async function startWorkflowRunHandler({
|
|
|
170
175
|
if (!runId) {
|
|
171
176
|
throw new HTTPException(400, { message: "runId required to start run" });
|
|
172
177
|
}
|
|
173
|
-
const workflow = mastra.
|
|
174
|
-
const run = workflow.
|
|
178
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
179
|
+
const run = workflow.getMemoryRun(runId);
|
|
175
180
|
if (!run) {
|
|
176
181
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
177
182
|
}
|
|
178
|
-
|
|
183
|
+
void run.start({
|
|
179
184
|
triggerData,
|
|
180
185
|
runtimeContext
|
|
181
186
|
});
|
|
@@ -184,7 +189,7 @@ async function startWorkflowRunHandler({
|
|
|
184
189
|
return handleError(e, "Error starting workflow run");
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
|
-
async function
|
|
192
|
+
async function watchLegacyWorkflowHandler({
|
|
188
193
|
mastra,
|
|
189
194
|
workflowId,
|
|
190
195
|
runId
|
|
@@ -196,8 +201,8 @@ async function watchWorkflowHandler({
|
|
|
196
201
|
if (!runId) {
|
|
197
202
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
198
203
|
}
|
|
199
|
-
const workflow = mastra.
|
|
200
|
-
const run = workflow.
|
|
204
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
205
|
+
const run = workflow.getMemoryRun(runId);
|
|
201
206
|
if (!run) {
|
|
202
207
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
203
208
|
}
|
|
@@ -213,8 +218,10 @@ async function watchWorkflowHandler({
|
|
|
213
218
|
asyncRef = null;
|
|
214
219
|
}
|
|
215
220
|
asyncRef = setImmediate(() => {
|
|
216
|
-
|
|
221
|
+
const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
|
|
222
|
+
if (runDone) {
|
|
217
223
|
controller.close();
|
|
224
|
+
unwatch?.();
|
|
218
225
|
}
|
|
219
226
|
});
|
|
220
227
|
});
|
|
@@ -228,7 +235,7 @@ async function watchWorkflowHandler({
|
|
|
228
235
|
return handleError(error, "Error watching workflow");
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
|
-
async function
|
|
238
|
+
async function resumeAsyncLegacyWorkflowHandler({
|
|
232
239
|
mastra,
|
|
233
240
|
workflowId,
|
|
234
241
|
runId,
|
|
@@ -242,8 +249,8 @@ async function resumeAsyncWorkflowHandler({
|
|
|
242
249
|
if (!runId) {
|
|
243
250
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
244
251
|
}
|
|
245
|
-
const workflow = mastra.
|
|
246
|
-
const run = workflow.
|
|
252
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
253
|
+
const run = workflow.getMemoryRun(runId);
|
|
247
254
|
if (!run) {
|
|
248
255
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
249
256
|
}
|
|
@@ -257,7 +264,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
257
264
|
return handleError(error, "Error resuming workflow step");
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
|
-
async function
|
|
267
|
+
async function resumeLegacyWorkflowHandler({
|
|
261
268
|
mastra,
|
|
262
269
|
workflowId,
|
|
263
270
|
runId,
|
|
@@ -271,12 +278,12 @@ async function resumeWorkflowHandler({
|
|
|
271
278
|
if (!runId) {
|
|
272
279
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
273
280
|
}
|
|
274
|
-
const workflow = mastra.
|
|
275
|
-
const run = workflow.
|
|
281
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
282
|
+
const run = workflow.getMemoryRun(runId);
|
|
276
283
|
if (!run) {
|
|
277
284
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
278
285
|
}
|
|
279
|
-
|
|
286
|
+
void run.resume({
|
|
280
287
|
stepId: body.stepId,
|
|
281
288
|
context: body.context,
|
|
282
289
|
runtimeContext
|
|
@@ -286,13 +293,21 @@ async function resumeWorkflowHandler({
|
|
|
286
293
|
return handleError(error, "Error resuming workflow");
|
|
287
294
|
}
|
|
288
295
|
}
|
|
289
|
-
async function
|
|
296
|
+
async function getLegacyWorkflowRunsHandler({
|
|
297
|
+
mastra,
|
|
298
|
+
workflowId,
|
|
299
|
+
fromDate,
|
|
300
|
+
toDate,
|
|
301
|
+
limit,
|
|
302
|
+
offset,
|
|
303
|
+
resourceId
|
|
304
|
+
}) {
|
|
290
305
|
try {
|
|
291
306
|
if (!workflowId) {
|
|
292
307
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
293
308
|
}
|
|
294
|
-
const workflow = mastra.
|
|
295
|
-
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
309
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
310
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
296
311
|
runs: [],
|
|
297
312
|
total: 0
|
|
298
313
|
};
|
|
@@ -302,4 +317,4 @@ async function getWorkflowRunsHandler({ mastra, workflowId }) {
|
|
|
302
317
|
}
|
|
303
318
|
}
|
|
304
319
|
|
|
305
|
-
export {
|
|
320
|
+
export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, legacyWorkflows_exports, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
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');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/memory.ts
|
|
8
9
|
var memory_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
10
11
|
createThreadHandler: () => createThreadHandler,
|
|
11
12
|
deleteThreadHandler: () => deleteThreadHandler,
|
|
12
13
|
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
@@ -22,7 +23,7 @@ function getMemoryFromContext({
|
|
|
22
23
|
}) {
|
|
23
24
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
24
25
|
if (agentId && !agent) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
26
27
|
}
|
|
27
28
|
const memory = agent?.getMemory?.() || mastra.getMemory();
|
|
28
29
|
return memory;
|
|
@@ -35,7 +36,7 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
|
|
|
35
36
|
}
|
|
36
37
|
return { result: true };
|
|
37
38
|
} catch (error) {
|
|
38
|
-
return
|
|
39
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
async function getThreadsHandler({
|
|
@@ -46,13 +47,13 @@ async function getThreadsHandler({
|
|
|
46
47
|
try {
|
|
47
48
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
48
49
|
if (!memory) {
|
|
49
|
-
throw new
|
|
50
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
52
53
|
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
53
54
|
return threads;
|
|
54
55
|
} catch (error) {
|
|
55
|
-
return
|
|
56
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
async function getThreadByIdHandler({
|
|
@@ -61,18 +62,18 @@ async function getThreadByIdHandler({
|
|
|
61
62
|
threadId
|
|
62
63
|
}) {
|
|
63
64
|
try {
|
|
64
|
-
|
|
65
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
65
66
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
66
67
|
if (!memory) {
|
|
67
|
-
throw new
|
|
68
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
68
69
|
}
|
|
69
70
|
const thread = await memory.getThreadById({ threadId });
|
|
70
71
|
if (!thread) {
|
|
71
|
-
throw new
|
|
72
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
72
73
|
}
|
|
73
74
|
return thread;
|
|
74
75
|
} catch (error) {
|
|
75
|
-
return
|
|
76
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
async function saveMessagesHandler({
|
|
@@ -83,13 +84,13 @@ async function saveMessagesHandler({
|
|
|
83
84
|
try {
|
|
84
85
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
85
86
|
if (!memory) {
|
|
86
|
-
throw new
|
|
87
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
87
88
|
}
|
|
88
89
|
if (!body?.messages) {
|
|
89
|
-
throw new
|
|
90
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
90
91
|
}
|
|
91
92
|
if (!Array.isArray(body.messages)) {
|
|
92
|
-
throw new
|
|
93
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
93
94
|
}
|
|
94
95
|
const processedMessages = body.messages.map((message) => ({
|
|
95
96
|
...message,
|
|
@@ -99,7 +100,7 @@ async function saveMessagesHandler({
|
|
|
99
100
|
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
100
101
|
return result;
|
|
101
102
|
} catch (error) {
|
|
102
|
-
return
|
|
103
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
async function createThreadHandler({
|
|
@@ -110,9 +111,9 @@ async function createThreadHandler({
|
|
|
110
111
|
try {
|
|
111
112
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
112
113
|
if (!memory) {
|
|
113
|
-
throw new
|
|
114
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
116
117
|
const result = await memory.createThread({
|
|
117
118
|
resourceId: body?.resourceId,
|
|
118
119
|
title: body?.title,
|
|
@@ -121,7 +122,7 @@ async function createThreadHandler({
|
|
|
121
122
|
});
|
|
122
123
|
return result;
|
|
123
124
|
} catch (error) {
|
|
124
|
-
return
|
|
125
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
async function updateThreadHandler({
|
|
@@ -133,17 +134,17 @@ async function updateThreadHandler({
|
|
|
133
134
|
try {
|
|
134
135
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
135
136
|
if (!body) {
|
|
136
|
-
throw new
|
|
137
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
137
138
|
}
|
|
138
139
|
const { title, metadata, resourceId } = body;
|
|
139
140
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
140
|
-
|
|
141
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
141
142
|
if (!memory) {
|
|
142
|
-
throw new
|
|
143
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
143
144
|
}
|
|
144
145
|
const thread = await memory.getThreadById({ threadId });
|
|
145
146
|
if (!thread) {
|
|
146
|
-
throw new
|
|
147
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
147
148
|
}
|
|
148
149
|
const updatedThread = {
|
|
149
150
|
...thread,
|
|
@@ -156,7 +157,7 @@ async function updateThreadHandler({
|
|
|
156
157
|
const result = await memory.saveThread({ thread: updatedThread });
|
|
157
158
|
return result;
|
|
158
159
|
} catch (error) {
|
|
159
|
-
return
|
|
160
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
async function deleteThreadHandler({
|
|
@@ -165,40 +166,47 @@ async function deleteThreadHandler({
|
|
|
165
166
|
threadId
|
|
166
167
|
}) {
|
|
167
168
|
try {
|
|
168
|
-
|
|
169
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
169
170
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
170
171
|
if (!memory) {
|
|
171
|
-
throw new
|
|
172
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
172
173
|
}
|
|
173
174
|
const thread = await memory.getThreadById({ threadId });
|
|
174
175
|
if (!thread) {
|
|
175
|
-
throw new
|
|
176
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
176
177
|
}
|
|
177
178
|
await memory.deleteThread(threadId);
|
|
178
179
|
return { result: "Thread deleted" };
|
|
179
180
|
} catch (error) {
|
|
180
|
-
return
|
|
181
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
async function getMessagesHandler({
|
|
184
185
|
mastra,
|
|
185
186
|
agentId,
|
|
186
|
-
threadId
|
|
187
|
+
threadId,
|
|
188
|
+
limit
|
|
187
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
|
+
}
|
|
188
193
|
try {
|
|
189
|
-
|
|
194
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
190
195
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
191
196
|
if (!memory) {
|
|
192
|
-
throw new
|
|
197
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
193
198
|
}
|
|
194
199
|
const thread = await memory.getThreadById({ threadId });
|
|
195
200
|
if (!thread) {
|
|
196
|
-
throw new
|
|
201
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
197
202
|
}
|
|
198
|
-
const result = await memory.query({
|
|
203
|
+
const result = await memory.query({
|
|
204
|
+
threadId,
|
|
205
|
+
...limit && { selectBy: { last: limit } }
|
|
206
|
+
});
|
|
199
207
|
return result;
|
|
200
208
|
} catch (error) {
|
|
201
|
-
return
|
|
209
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
202
210
|
}
|
|
203
211
|
}
|
|
204
212
|
|