@mastra/server 0.17.1 → 0.18.0-alpha.2
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/CHANGELOG.md +30 -0
- package/dist/{chunk-NZMDHQVP.cjs → chunk-57HWW2TY.cjs} +6 -116
- package/dist/chunk-57HWW2TY.cjs.map +1 -0
- package/dist/{chunk-U77BBIVV.js → chunk-7JYXPDM4.js} +4 -3
- package/dist/chunk-7JYXPDM4.js.map +1 -0
- package/dist/{chunk-3THIIWWW.cjs → chunk-AVEPEUN4.cjs} +4 -3
- package/dist/chunk-AVEPEUN4.cjs.map +1 -0
- package/dist/chunk-CNU4A2XU.js +129 -0
- package/dist/chunk-CNU4A2XU.js.map +1 -0
- package/dist/{chunk-K4GZBPXF.js → chunk-G662L2YZ.js} +4 -112
- package/dist/chunk-G662L2YZ.js.map +1 -0
- package/dist/chunk-GDWMF6SB.cjs +133 -0
- package/dist/chunk-GDWMF6SB.cjs.map +1 -0
- package/dist/{chunk-EAWKFGMM.cjs → chunk-OJQOYXHU.cjs} +23 -22
- package/dist/chunk-OJQOYXHU.cjs.map +1 -0
- package/dist/{chunk-5QUKZCEF.js → chunk-PUYSH3IL.js} +4 -3
- package/dist/chunk-PUYSH3IL.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.d.ts +4 -4
- package/dist/server/handlers/vNextNetwork.d.ts +11 -11
- package/dist/server/handlers/workflows.cjs +18 -18
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +6 -6
- package/dist/server/handlers.js +3 -3
- package/dist/server/utils.d.ts +2 -0
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-3THIIWWW.cjs.map +0 -1
- package/dist/chunk-5QUKZCEF.js.map +0 -1
- package/dist/chunk-EAWKFGMM.cjs.map +0 -1
- package/dist/chunk-K4GZBPXF.js.map +0 -1
- package/dist/chunk-NZMDHQVP.cjs.map +0 -1
- package/dist/chunk-U77BBIVV.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 0.18.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Allow agent instructions to accept SystemMessage types ([#7987](https://github.com/mastra-ai/mastra/pull/7987))
|
|
8
|
+
|
|
9
|
+
Agents can now use rich instruction formats beyond simple strings:
|
|
10
|
+
- CoreSystemMessage and SystemModelMessage objects with provider-specific options
|
|
11
|
+
- Arrays of strings or system messages
|
|
12
|
+
- Dynamic instructions returning any SystemMessage type
|
|
13
|
+
|
|
14
|
+
- Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55)]:
|
|
17
|
+
- @mastra/core@0.18.0-alpha.2
|
|
18
|
+
|
|
19
|
+
## 0.17.2-alpha.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb)]:
|
|
24
|
+
- @mastra/core@0.17.2-alpha.1
|
|
25
|
+
|
|
26
|
+
## 0.17.2-alpha.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad)]:
|
|
31
|
+
- @mastra/core@0.17.2-alpha.0
|
|
32
|
+
|
|
3
33
|
## 0.17.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGDWMF6SB_cjs = require('./chunk-GDWMF6SB.cjs');
|
|
4
4
|
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
5
5
|
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
6
6
|
var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
|
-
var zodToJson = require('@mastra/core/utils/zod-to-json');
|
|
9
8
|
|
|
10
9
|
// src/server/handlers/workflows.ts
|
|
11
10
|
var workflows_exports = {};
|
|
@@ -28,118 +27,11 @@ chunkEMMSS5I5_cjs.__export(workflows_exports, {
|
|
|
28
27
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
29
28
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
30
29
|
});
|
|
31
|
-
function getSteps(steps, path) {
|
|
32
|
-
return Object.entries(steps).reduce((acc, [key, step]) => {
|
|
33
|
-
const fullKey = path ? `${path}.${key}` : key;
|
|
34
|
-
acc[fullKey] = {
|
|
35
|
-
id: step.id,
|
|
36
|
-
description: step.description,
|
|
37
|
-
inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
|
|
38
|
-
outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
|
|
39
|
-
resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
40
|
-
suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0,
|
|
41
|
-
isWorkflow: step.component === "WORKFLOW"
|
|
42
|
-
};
|
|
43
|
-
if (step.component === "WORKFLOW" && step.steps) {
|
|
44
|
-
const nestedSteps = getSteps(step.steps, fullKey) || {};
|
|
45
|
-
acc = { ...acc, ...nestedSteps };
|
|
46
|
-
}
|
|
47
|
-
return acc;
|
|
48
|
-
}, {});
|
|
49
|
-
}
|
|
50
|
-
function getWorkflowInfo(workflow) {
|
|
51
|
-
return {
|
|
52
|
-
name: workflow.name,
|
|
53
|
-
description: workflow.description,
|
|
54
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
55
|
-
acc[key] = {
|
|
56
|
-
id: step.id,
|
|
57
|
-
description: step.description,
|
|
58
|
-
inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
|
|
59
|
-
outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
|
|
60
|
-
resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
61
|
-
suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0
|
|
62
|
-
};
|
|
63
|
-
return acc;
|
|
64
|
-
}, {}),
|
|
65
|
-
allSteps: getSteps(workflow.steps) || {},
|
|
66
|
-
stepGraph: workflow.serializedStepGraph,
|
|
67
|
-
inputSchema: workflow.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.inputSchema)) : void 0,
|
|
68
|
-
outputSchema: workflow.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.outputSchema)) : void 0
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
var WorkflowRegistry = class {
|
|
72
|
-
static additionalWorkflows = {};
|
|
73
|
-
/**
|
|
74
|
-
* Register a workflow temporarily
|
|
75
|
-
*/
|
|
76
|
-
static registerTemporaryWorkflow(id, workflow) {
|
|
77
|
-
this.additionalWorkflows[id] = workflow;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Register all workflows from map
|
|
81
|
-
*/
|
|
82
|
-
static registerTemporaryWorkflows(workflows, mastra) {
|
|
83
|
-
for (const [id, workflow] of Object.entries(workflows)) {
|
|
84
|
-
if (mastra) {
|
|
85
|
-
workflow.__registerMastra(mastra);
|
|
86
|
-
workflow.__registerPrimitives({
|
|
87
|
-
logger: mastra.getLogger(),
|
|
88
|
-
telemetry: mastra.getTelemetry(),
|
|
89
|
-
storage: mastra.getStorage(),
|
|
90
|
-
memory: mastra.getMemory(),
|
|
91
|
-
agents: mastra.getAgents(),
|
|
92
|
-
tts: mastra.getTTS(),
|
|
93
|
-
vectors: mastra.getVectors()
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
this.additionalWorkflows[id] = workflow;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get a workflow by ID from the registry (returns undefined if not found)
|
|
101
|
-
*/
|
|
102
|
-
static getWorkflow(workflowId) {
|
|
103
|
-
return this.additionalWorkflows[workflowId];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Get all workflows from the registry
|
|
107
|
-
*/
|
|
108
|
-
static getAllWorkflows() {
|
|
109
|
-
return { ...this.additionalWorkflows };
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Clean up a temporary workflow
|
|
113
|
-
*/
|
|
114
|
-
static cleanupTemporaryWorkflow(workflowId) {
|
|
115
|
-
delete this.additionalWorkflows[workflowId];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Clean up all registered workflows
|
|
119
|
-
*/
|
|
120
|
-
static cleanup() {
|
|
121
|
-
this.additionalWorkflows = {};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if a workflow ID is a valid agent-builder workflow
|
|
125
|
-
*/
|
|
126
|
-
static isAgentBuilderWorkflow(workflowId) {
|
|
127
|
-
return workflowId in this.additionalWorkflows;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get all registered temporary workflow IDs (for debugging)
|
|
131
|
-
*/
|
|
132
|
-
static getRegisteredWorkflowIds() {
|
|
133
|
-
return Object.keys(this.additionalWorkflows);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// src/server/handlers/workflows.ts
|
|
138
30
|
async function getWorkflowsHandler({ mastra }) {
|
|
139
31
|
try {
|
|
140
32
|
const workflows = mastra.getWorkflows({ serialized: false });
|
|
141
33
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
142
|
-
acc[key] = getWorkflowInfo(workflow);
|
|
34
|
+
acc[key] = chunkGDWMF6SB_cjs.getWorkflowInfo(workflow);
|
|
143
35
|
return acc;
|
|
144
36
|
}, {});
|
|
145
37
|
return _workflows;
|
|
@@ -153,7 +45,7 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
153
45
|
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
154
46
|
}
|
|
155
47
|
let workflow;
|
|
156
|
-
workflow = WorkflowRegistry.getWorkflow(workflowId);
|
|
48
|
+
workflow = chunkGDWMF6SB_cjs.WorkflowRegistry.getWorkflow(workflowId);
|
|
157
49
|
if (!workflow) {
|
|
158
50
|
try {
|
|
159
51
|
workflow = mastra.getWorkflow(workflowId);
|
|
@@ -193,7 +85,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
193
85
|
if (!workflow) {
|
|
194
86
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
195
87
|
}
|
|
196
|
-
return getWorkflowInfo(workflow);
|
|
88
|
+
return chunkGDWMF6SB_cjs.getWorkflowInfo(workflow);
|
|
197
89
|
} catch (error) {
|
|
198
90
|
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
|
|
199
91
|
}
|
|
@@ -673,11 +565,9 @@ async function sendWorkflowRunEventHandler({
|
|
|
673
565
|
}
|
|
674
566
|
}
|
|
675
567
|
|
|
676
|
-
exports.WorkflowRegistry = WorkflowRegistry;
|
|
677
568
|
exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
|
|
678
569
|
exports.createWorkflowRunHandler = createWorkflowRunHandler;
|
|
679
570
|
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
680
|
-
exports.getWorkflowInfo = getWorkflowInfo;
|
|
681
571
|
exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
682
572
|
exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
|
|
683
573
|
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
@@ -693,5 +583,5 @@ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
|
|
|
693
583
|
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
694
584
|
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
695
585
|
exports.workflows_exports = workflows_exports;
|
|
696
|
-
//# sourceMappingURL=chunk-
|
|
697
|
-
//# sourceMappingURL=chunk-
|
|
586
|
+
//# sourceMappingURL=chunk-57HWW2TY.cjs.map
|
|
587
|
+
//# sourceMappingURL=chunk-57HWW2TY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","getWorkflowInfo","handleError","HTTPException","WorkflowRegistry","ReadableStream","TransformStream"],"mappings":";;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAcA,eAAsB,mBAAA,CAAoB,EAAE,MAAA,EAAO,EAAoB;AACrE,EAAA,IAAI;AACF,IAAA,MAAM,YAAY,MAAA,CAAO,YAAA,CAAa,EAAE,UAAA,EAAY,OAAO,CAAA;AAC3D,IAAA,MAAM,UAAA,GAAa,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,CAAE,MAAA,CAAqC,CAAC,GAAA,EAAK,CAAC,GAAA,EAAK,QAAQ,CAAA,KAAM;AAC1G,MAAA,GAAA,CAAI,GAAG,CAAA,GAAIC,iCAAA,CAAgB,QAAQ,CAAA;AACnC,MAAA,OAAO,GAAA;AAAA,IACT,CAAA,EA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ExE,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,sBAAsB,CAAA;AAAA,IAChE;AAEA,IAAA,MAAM,GAAA,GAAM,MAAM,QAAA,CAAS,kBAAA,CAAmB,KAAK,CAAA;AAEnD,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,OAAO,MAAM,QAAA,CAAS,cAAA,CAAe,EAAE,OAAO,CAAA;AAEpD,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,IAAI,CAAA;AAEhC,IAAA,OAAO,EAAE,SAAS,yBAAA,EAA0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-57HWW2TY.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type { Workflow, WatchEvent, WorkflowInfo, StreamEvent } from '@mastra/core/workflows';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n}\n\nasync function getWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.getAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.getWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowInfo> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n}\n\nexport async function getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n void _run.start({\n inputData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n eventType = 'watch',\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n eventType?: 'watch' | 'watch-v2';\n}): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch((event: any) => {\n const { type, payload, eventTimestamp } = event;\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = eventType === 'watch' ? payload.workflowState.status !== 'running' : type === 'finish';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n }, eventType);\n },\n cancel() {\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function observeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n const transformStream = new TransformStream<StreamEvent, StreamEvent>();\n\n const writer = transformStream.writable.getWriter();\n\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n for (const chunk of cachedRunChunks) {\n await writer.write(chunk as any);\n }\n\n writer.releaseLock();\n\n const result = _run.observeStream();\n return result.stream?.pipeThrough(transformStream);\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n closeOnSuspend,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n closeOnSuspend?: boolean;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n closeOnSuspend,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function resumeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n const stream = await _run.resumeStreamVNext({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<WorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n}\n\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to send workflow run event' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, createWorkflowRunHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, streamWorkflowHandler, streamVNextWorkflowHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, getWorkflowRunsHandler, cancelWorkflowRunHandler, sendWorkflowRunEventHandler } from './chunk-G662L2YZ.js';
|
|
2
|
+
import { WorkflowRegistry, getWorkflowInfo } from './chunk-CNU4A2XU.js';
|
|
2
3
|
import { openai as openai$1 } from './chunk-4RRMWXQ2.js';
|
|
3
4
|
import { InvalidArgumentError, esm_default, APICallError, EmptyResponseBodyError, AISDKError as AISDKError$1, JSONParseError, TypeValidationError, EventSourceParserStream, NoSuchModelError } from './chunk-N7F33WAD.js';
|
|
4
5
|
import { openai } from './chunk-6GMFZ5LK.js';
|
|
@@ -15707,5 +15708,5 @@ var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
|
|
|
15707
15708
|
);
|
|
15708
15709
|
|
|
15709
15710
|
export { agent_builder_exports, cancelAgentBuilderActionRunHandler, createAgentBuilderActionRunHandler, getAgentBuilderActionByIdHandler, getAgentBuilderActionRunByIdHandler, getAgentBuilderActionRunExecutionResultHandler, getAgentBuilderActionRunsHandler, getAgentBuilderActionsHandler, resumeAgentBuilderActionHandler, resumeAsyncAgentBuilderActionHandler, sendAgentBuilderActionRunEventHandler, startAgentBuilderActionRunHandler, startAsyncAgentBuilderActionHandler, streamAgentBuilderActionHandler, streamVNextAgentBuilderActionHandler, watchAgentBuilderActionHandler };
|
|
15710
|
-
//# sourceMappingURL=chunk-
|
|
15711
|
-
//# sourceMappingURL=chunk-
|
|
15711
|
+
//# sourceMappingURL=chunk-7JYXPDM4.js.map
|
|
15712
|
+
//# sourceMappingURL=chunk-7JYXPDM4.js.map
|