@mastra/server 0.0.0-workflow-deno-20250616130925 → 0.0.0-working-memory-per-user-20250620161509
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/dist/_tsup-dts-rollup.d.cts +10 -10
- package/dist/_tsup-dts-rollup.d.ts +10 -10
- package/dist/{chunk-42IKSJNO.js → chunk-2GOU7Q4O.js} +49 -13
- package/dist/{chunk-WE32JG64.cjs → chunk-4DTDPTQC.cjs} +7 -7
- package/dist/{chunk-O2YAAFY3.js → chunk-5UV7XQ4G.js} +17 -6
- package/dist/{chunk-CK32I2VN.cjs → chunk-7TB34RLZ.cjs} +61 -25
- package/dist/{chunk-NGURCFEJ.cjs → chunk-CPPYMJX5.cjs} +5 -5
- package/dist/{chunk-42YJ2YVD.cjs → chunk-E5IRS3XH.cjs} +21 -10
- package/dist/{chunk-ASKESBJW.cjs → chunk-MN6F4D5A.cjs} +35 -35
- package/dist/{chunk-CLYX4KLH.js → chunk-N2YBMSO2.js} +1 -1
- package/dist/{chunk-TGJMNUYJ.js → chunk-OSZM4EAY.js} +35 -35
- package/dist/{chunk-CP55EVBK.js → chunk-R5VGYBV6.js} +12 -8
- package/dist/{chunk-CMMOIUFC.cjs → chunk-WJY57THV.cjs} +12 -8
- package/dist/{chunk-2HXKRRNS.js → chunk-XR7VJOOP.js} +1 -1
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +11 -11
- package/dist/server/handlers/legacyWorkflows.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +13 -13
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +10 -10
- package/dist/server/handlers.js +5 -5
- package/package.json +5 -5
|
@@ -601,12 +601,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
601
601
|
runtimeContext: RuntimeContext;
|
|
602
602
|
}): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
603
603
|
|
|
604
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
604
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
|
|
605
605
|
body: {
|
|
606
606
|
step: string | string[];
|
|
607
607
|
resumeData?: unknown;
|
|
608
608
|
};
|
|
609
|
-
runtimeContext?:
|
|
609
|
+
runtimeContext?: Record<string, any>;
|
|
610
610
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
611
611
|
|
|
612
612
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -619,12 +619,12 @@ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId,
|
|
|
619
619
|
message: string;
|
|
620
620
|
}>;
|
|
621
621
|
|
|
622
|
-
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
622
|
+
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
|
|
623
623
|
body: {
|
|
624
624
|
step: string | string[];
|
|
625
625
|
resumeData?: unknown;
|
|
626
626
|
};
|
|
627
|
-
runtimeContext?:
|
|
627
|
+
runtimeContext?: Record<string, any>;
|
|
628
628
|
}): Promise<{
|
|
629
629
|
message: string;
|
|
630
630
|
}>;
|
|
@@ -651,9 +651,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
651
651
|
runtimeContext: RuntimeContext;
|
|
652
652
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
653
653
|
|
|
654
|
-
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
654
|
+
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
655
655
|
inputData?: unknown;
|
|
656
|
-
runtimeContext?:
|
|
656
|
+
runtimeContext?: Record<string, any>;
|
|
657
657
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
658
658
|
|
|
659
659
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -663,9 +663,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
663
663
|
message: string;
|
|
664
664
|
}>;
|
|
665
665
|
|
|
666
|
-
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
666
|
+
export declare function startWorkflowRunHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
667
667
|
inputData?: unknown;
|
|
668
|
-
runtimeContext?:
|
|
668
|
+
runtimeContext?: Record<string, any>;
|
|
669
669
|
}): Promise<{
|
|
670
670
|
message: string;
|
|
671
671
|
}>;
|
|
@@ -709,9 +709,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
709
709
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
710
710
|
}): Promise<Response>;
|
|
711
711
|
|
|
712
|
-
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
712
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
713
713
|
inputData?: unknown;
|
|
714
|
-
runtimeContext?:
|
|
714
|
+
runtimeContext?: Record<string, any>;
|
|
715
715
|
}): Promise<{
|
|
716
716
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
717
717
|
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
@@ -601,12 +601,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
601
601
|
runtimeContext: RuntimeContext;
|
|
602
602
|
}): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
603
603
|
|
|
604
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
604
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
|
|
605
605
|
body: {
|
|
606
606
|
step: string | string[];
|
|
607
607
|
resumeData?: unknown;
|
|
608
608
|
};
|
|
609
|
-
runtimeContext?:
|
|
609
|
+
runtimeContext?: Record<string, any>;
|
|
610
610
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
611
611
|
|
|
612
612
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -619,12 +619,12 @@ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId,
|
|
|
619
619
|
message: string;
|
|
620
620
|
}>;
|
|
621
621
|
|
|
622
|
-
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
622
|
+
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
|
|
623
623
|
body: {
|
|
624
624
|
step: string | string[];
|
|
625
625
|
resumeData?: unknown;
|
|
626
626
|
};
|
|
627
|
-
runtimeContext?:
|
|
627
|
+
runtimeContext?: Record<string, any>;
|
|
628
628
|
}): Promise<{
|
|
629
629
|
message: string;
|
|
630
630
|
}>;
|
|
@@ -651,9 +651,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
651
651
|
runtimeContext: RuntimeContext;
|
|
652
652
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
653
653
|
|
|
654
|
-
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
654
|
+
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
655
655
|
inputData?: unknown;
|
|
656
|
-
runtimeContext?:
|
|
656
|
+
runtimeContext?: Record<string, any>;
|
|
657
657
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
658
658
|
|
|
659
659
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -663,9 +663,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
663
663
|
message: string;
|
|
664
664
|
}>;
|
|
665
665
|
|
|
666
|
-
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
666
|
+
export declare function startWorkflowRunHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
667
667
|
inputData?: unknown;
|
|
668
|
-
runtimeContext?:
|
|
668
|
+
runtimeContext?: Record<string, any>;
|
|
669
669
|
}): Promise<{
|
|
670
670
|
message: string;
|
|
671
671
|
}>;
|
|
@@ -709,9 +709,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
709
709
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
710
710
|
}): Promise<Response>;
|
|
711
711
|
|
|
712
|
-
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
712
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
713
713
|
inputData?: unknown;
|
|
714
|
-
runtimeContext?:
|
|
714
|
+
runtimeContext?: Record<string, any>;
|
|
715
715
|
}): Promise<{
|
|
716
716
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
717
717
|
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-OSZM4EAY.js';
|
|
2
2
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
3
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
4
|
import { __export } from './chunk-MLKGABMK.js';
|
|
5
5
|
import { ReadableStream } from 'stream/web';
|
|
6
|
+
import { RuntimeContext } from '@mastra/core/di';
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/workflows.ts
|
|
8
9
|
var workflows_exports = {};
|
|
@@ -179,7 +180,7 @@ async function createWorkflowRunHandler({
|
|
|
179
180
|
if (!workflow) {
|
|
180
181
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
181
182
|
}
|
|
182
|
-
const run =
|
|
183
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
183
184
|
return { runId: run.runId };
|
|
184
185
|
} catch (error) {
|
|
185
186
|
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
@@ -187,7 +188,7 @@ async function createWorkflowRunHandler({
|
|
|
187
188
|
}
|
|
188
189
|
async function startAsyncWorkflowHandler({
|
|
189
190
|
mastra,
|
|
190
|
-
runtimeContext,
|
|
191
|
+
runtimeContext: payloadRuntimeContext,
|
|
191
192
|
workflowId,
|
|
192
193
|
runId,
|
|
193
194
|
inputData
|
|
@@ -200,7 +201,14 @@ async function startAsyncWorkflowHandler({
|
|
|
200
201
|
if (!workflow) {
|
|
201
202
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
202
203
|
}
|
|
203
|
-
|
|
204
|
+
let runtimeContext;
|
|
205
|
+
if (payloadRuntimeContext) {
|
|
206
|
+
runtimeContext = new RuntimeContext();
|
|
207
|
+
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
208
|
+
runtimeContext.set(key, value);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const _run = workflow.createRun({ runId });
|
|
204
212
|
const result = await _run.start({
|
|
205
213
|
inputData,
|
|
206
214
|
runtimeContext
|
|
@@ -212,7 +220,7 @@ async function startAsyncWorkflowHandler({
|
|
|
212
220
|
}
|
|
213
221
|
async function startWorkflowRunHandler({
|
|
214
222
|
mastra,
|
|
215
|
-
runtimeContext,
|
|
223
|
+
runtimeContext: payloadRuntimeContext,
|
|
216
224
|
workflowId,
|
|
217
225
|
runId,
|
|
218
226
|
inputData
|
|
@@ -232,7 +240,14 @@ async function startWorkflowRunHandler({
|
|
|
232
240
|
if (!run) {
|
|
233
241
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
234
242
|
}
|
|
235
|
-
|
|
243
|
+
let runtimeContext;
|
|
244
|
+
if (payloadRuntimeContext) {
|
|
245
|
+
runtimeContext = new RuntimeContext();
|
|
246
|
+
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
247
|
+
runtimeContext.set(key, value);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const _run = workflow.createRun({ runId });
|
|
236
251
|
void _run.start({
|
|
237
252
|
inputData,
|
|
238
253
|
runtimeContext
|
|
@@ -262,7 +277,7 @@ async function watchWorkflowHandler({
|
|
|
262
277
|
if (!run) {
|
|
263
278
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
264
279
|
}
|
|
265
|
-
const _run =
|
|
280
|
+
const _run = workflow.createRun({ runId });
|
|
266
281
|
let unwatch;
|
|
267
282
|
let asyncRef = null;
|
|
268
283
|
const stream = new ReadableStream({
|
|
@@ -293,7 +308,7 @@ async function watchWorkflowHandler({
|
|
|
293
308
|
}
|
|
294
309
|
async function streamWorkflowHandler({
|
|
295
310
|
mastra,
|
|
296
|
-
runtimeContext,
|
|
311
|
+
runtimeContext: payloadRuntimeContext,
|
|
297
312
|
workflowId,
|
|
298
313
|
runId,
|
|
299
314
|
inputData
|
|
@@ -309,7 +324,14 @@ async function streamWorkflowHandler({
|
|
|
309
324
|
if (!workflow) {
|
|
310
325
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
311
326
|
}
|
|
312
|
-
|
|
327
|
+
let runtimeContext;
|
|
328
|
+
if (payloadRuntimeContext) {
|
|
329
|
+
runtimeContext = new RuntimeContext();
|
|
330
|
+
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
331
|
+
runtimeContext.set(key, value);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
const run = workflow.createRun({ runId });
|
|
313
335
|
const result = run.stream({
|
|
314
336
|
inputData,
|
|
315
337
|
runtimeContext
|
|
@@ -324,7 +346,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
324
346
|
workflowId,
|
|
325
347
|
runId,
|
|
326
348
|
body,
|
|
327
|
-
runtimeContext
|
|
349
|
+
runtimeContext: payloadRuntimeContext
|
|
328
350
|
}) {
|
|
329
351
|
try {
|
|
330
352
|
if (!workflowId) {
|
|
@@ -344,7 +366,14 @@ async function resumeAsyncWorkflowHandler({
|
|
|
344
366
|
if (!run) {
|
|
345
367
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
346
368
|
}
|
|
347
|
-
|
|
369
|
+
let runtimeContext;
|
|
370
|
+
if (payloadRuntimeContext) {
|
|
371
|
+
runtimeContext = new RuntimeContext();
|
|
372
|
+
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
373
|
+
runtimeContext.set(key, value);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const _run = workflow.createRun({ runId });
|
|
348
377
|
const result = await _run.resume({
|
|
349
378
|
step: body.step,
|
|
350
379
|
resumeData: body.resumeData,
|
|
@@ -360,7 +389,7 @@ async function resumeWorkflowHandler({
|
|
|
360
389
|
workflowId,
|
|
361
390
|
runId,
|
|
362
391
|
body,
|
|
363
|
-
runtimeContext
|
|
392
|
+
runtimeContext: payloadRuntimeContext
|
|
364
393
|
}) {
|
|
365
394
|
try {
|
|
366
395
|
if (!workflowId) {
|
|
@@ -380,7 +409,14 @@ async function resumeWorkflowHandler({
|
|
|
380
409
|
if (!run) {
|
|
381
410
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
382
411
|
}
|
|
383
|
-
|
|
412
|
+
let runtimeContext;
|
|
413
|
+
if (payloadRuntimeContext) {
|
|
414
|
+
runtimeContext = new RuntimeContext();
|
|
415
|
+
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
416
|
+
runtimeContext.set(key, value);
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
const _run = workflow.createRun({ runId });
|
|
384
420
|
void _run.resume({
|
|
385
421
|
step: body.step,
|
|
386
422
|
resumeData: body.resumeData,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
|
|
4
4
|
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
5
|
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
@@ -31,15 +31,15 @@ async function getLegacyWorkflowsHandler({ mastra }) {
|
|
|
31
31
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
32
32
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
33
33
|
name: workflow.name,
|
|
34
|
-
triggerSchema: workflow.triggerSchema ?
|
|
34
|
+
triggerSchema: workflow.triggerSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
35
35
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
36
36
|
const _step = step;
|
|
37
37
|
acc2[key2] = {
|
|
38
38
|
id: _step.id,
|
|
39
39
|
description: _step.description,
|
|
40
40
|
workflowId: _step.workflowId,
|
|
41
|
-
inputSchema: _step.inputSchema ?
|
|
42
|
-
outputSchema: _step.outputSchema ?
|
|
41
|
+
inputSchema: _step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
42
|
+
outputSchema: _step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_step.outputSchema)) : void 0
|
|
43
43
|
};
|
|
44
44
|
return acc2;
|
|
45
45
|
}, {})
|
|
@@ -66,15 +66,15 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
66
66
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
67
67
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
68
68
|
name: workflow.name,
|
|
69
|
-
triggerSchema: workflow.triggerSchema ?
|
|
69
|
+
triggerSchema: workflow.triggerSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
70
70
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
71
71
|
const _step = step;
|
|
72
72
|
acc[key] = {
|
|
73
73
|
id: _step.id,
|
|
74
74
|
description: _step.description,
|
|
75
75
|
workflowId: _step.workflowId,
|
|
76
|
-
inputSchema: _step.inputSchema ?
|
|
77
|
-
outputSchema: _step.outputSchema ?
|
|
76
|
+
inputSchema: _step.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
77
|
+
outputSchema: _step.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(_step.outputSchema)) : void 0
|
|
78
78
|
};
|
|
79
79
|
return acc;
|
|
80
80
|
}, {})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-OSZM4EAY.js';
|
|
2
2
|
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
3
3
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
4
4
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
@@ -23,6 +23,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
23
23
|
const instructions = await agent.getInstructions({ runtimeContext });
|
|
24
24
|
const tools = await agent.getTools({ runtimeContext });
|
|
25
25
|
const llm = await agent.getLLM({ runtimeContext });
|
|
26
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
|
|
27
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
|
|
26
28
|
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
27
29
|
const _tool = tool;
|
|
28
30
|
acc[key] = {
|
|
@@ -57,8 +59,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
57
59
|
workflows: serializedAgentWorkflows,
|
|
58
60
|
provider: llm?.getProvider(),
|
|
59
61
|
modelId: llm?.getModelId(),
|
|
60
|
-
defaultGenerateOptions
|
|
61
|
-
defaultStreamOptions
|
|
62
|
+
defaultGenerateOptions,
|
|
63
|
+
defaultStreamOptions
|
|
62
64
|
};
|
|
63
65
|
})
|
|
64
66
|
);
|
|
@@ -134,6 +136,8 @@ async function getAgentByIdHandler({
|
|
|
134
136
|
}
|
|
135
137
|
const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
|
|
136
138
|
const llm = await agent.getLLM({ runtimeContext });
|
|
139
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
|
|
140
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
|
|
137
141
|
return {
|
|
138
142
|
name: agent.name,
|
|
139
143
|
instructions,
|
|
@@ -141,8 +145,8 @@ async function getAgentByIdHandler({
|
|
|
141
145
|
workflows: serializedAgentWorkflows,
|
|
142
146
|
provider: llm?.getProvider(),
|
|
143
147
|
modelId: llm?.getModelId(),
|
|
144
|
-
defaultGenerateOptions
|
|
145
|
-
defaultStreamOptions
|
|
148
|
+
defaultGenerateOptions,
|
|
149
|
+
defaultStreamOptions
|
|
146
150
|
};
|
|
147
151
|
} catch (error) {
|
|
148
152
|
return handleError(error, "Error getting agent");
|
|
@@ -239,11 +243,18 @@ async function streamGenerateHandler({
|
|
|
239
243
|
resourceId: finalResourceId,
|
|
240
244
|
runtimeContext: finalRuntimeContext
|
|
241
245
|
});
|
|
242
|
-
const streamResponse = rest.output ? streamResult.toTextStreamResponse(
|
|
246
|
+
const streamResponse = rest.output ? streamResult.toTextStreamResponse({
|
|
247
|
+
headers: {
|
|
248
|
+
"Transfer-Encoding": "chunked"
|
|
249
|
+
}
|
|
250
|
+
}) : streamResult.toDataStreamResponse({
|
|
243
251
|
sendUsage: true,
|
|
244
252
|
sendReasoning: true,
|
|
245
253
|
getErrorMessage: (error) => {
|
|
246
254
|
return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
|
|
255
|
+
},
|
|
256
|
+
headers: {
|
|
257
|
+
"Transfer-Encoding": "chunked"
|
|
247
258
|
}
|
|
248
259
|
});
|
|
249
260
|
return streamResponse;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
|
|
4
4
|
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
5
|
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
|
+
var di = require('@mastra/core/di');
|
|
8
9
|
|
|
9
10
|
// src/server/handlers/workflows.ts
|
|
10
11
|
var workflows_exports = {};
|
|
@@ -33,16 +34,16 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
33
34
|
acc2[key2] = {
|
|
34
35
|
id: step.id,
|
|
35
36
|
description: step.description,
|
|
36
|
-
inputSchema: step.inputSchema ?
|
|
37
|
-
outputSchema: step.outputSchema ?
|
|
38
|
-
resumeSchema: step.resumeSchema ?
|
|
39
|
-
suspendSchema: step.suspendSchema ?
|
|
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
|
|
40
41
|
};
|
|
41
42
|
return acc2;
|
|
42
43
|
}, {}),
|
|
43
44
|
stepGraph: workflow.serializedStepGraph,
|
|
44
|
-
inputSchema: workflow.inputSchema ?
|
|
45
|
-
outputSchema: workflow.outputSchema ?
|
|
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
|
|
46
47
|
};
|
|
47
48
|
return acc;
|
|
48
49
|
}, {});
|
|
@@ -99,18 +100,18 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
99
100
|
acc[key] = {
|
|
100
101
|
id: step.id,
|
|
101
102
|
description: step.description,
|
|
102
|
-
inputSchema: step.inputSchema ?
|
|
103
|
-
outputSchema: step.outputSchema ?
|
|
104
|
-
resumeSchema: step.resumeSchema ?
|
|
105
|
-
suspendSchema: step.suspendSchema ?
|
|
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
|
|
106
107
|
};
|
|
107
108
|
return acc;
|
|
108
109
|
}, {}),
|
|
109
110
|
name: workflow.name,
|
|
110
111
|
description: workflow.description,
|
|
111
112
|
stepGraph: workflow.serializedStepGraph,
|
|
112
|
-
inputSchema: workflow.inputSchema ?
|
|
113
|
-
outputSchema: workflow.outputSchema ?
|
|
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
|
|
114
115
|
};
|
|
115
116
|
} catch (error) {
|
|
116
117
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
@@ -181,7 +182,7 @@ async function createWorkflowRunHandler({
|
|
|
181
182
|
if (!workflow) {
|
|
182
183
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
183
184
|
}
|
|
184
|
-
const run =
|
|
185
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
185
186
|
return { runId: run.runId };
|
|
186
187
|
} catch (error) {
|
|
187
188
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
@@ -189,7 +190,7 @@ async function createWorkflowRunHandler({
|
|
|
189
190
|
}
|
|
190
191
|
async function startAsyncWorkflowHandler({
|
|
191
192
|
mastra,
|
|
192
|
-
runtimeContext,
|
|
193
|
+
runtimeContext: payloadRuntimeContext,
|
|
193
194
|
workflowId,
|
|
194
195
|
runId,
|
|
195
196
|
inputData
|
|
@@ -202,7 +203,14 @@ async function startAsyncWorkflowHandler({
|
|
|
202
203
|
if (!workflow) {
|
|
203
204
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
204
205
|
}
|
|
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 });
|
|
206
214
|
const result = await _run.start({
|
|
207
215
|
inputData,
|
|
208
216
|
runtimeContext
|
|
@@ -214,7 +222,7 @@ async function startAsyncWorkflowHandler({
|
|
|
214
222
|
}
|
|
215
223
|
async function startWorkflowRunHandler({
|
|
216
224
|
mastra,
|
|
217
|
-
runtimeContext,
|
|
225
|
+
runtimeContext: payloadRuntimeContext,
|
|
218
226
|
workflowId,
|
|
219
227
|
runId,
|
|
220
228
|
inputData
|
|
@@ -234,7 +242,14 @@ async function startWorkflowRunHandler({
|
|
|
234
242
|
if (!run) {
|
|
235
243
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
236
244
|
}
|
|
237
|
-
|
|
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 });
|
|
238
253
|
void _run.start({
|
|
239
254
|
inputData,
|
|
240
255
|
runtimeContext
|
|
@@ -264,7 +279,7 @@ async function watchWorkflowHandler({
|
|
|
264
279
|
if (!run) {
|
|
265
280
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
266
281
|
}
|
|
267
|
-
const _run =
|
|
282
|
+
const _run = workflow.createRun({ runId });
|
|
268
283
|
let unwatch;
|
|
269
284
|
let asyncRef = null;
|
|
270
285
|
const stream = new web.ReadableStream({
|
|
@@ -295,7 +310,7 @@ async function watchWorkflowHandler({
|
|
|
295
310
|
}
|
|
296
311
|
async function streamWorkflowHandler({
|
|
297
312
|
mastra,
|
|
298
|
-
runtimeContext,
|
|
313
|
+
runtimeContext: payloadRuntimeContext,
|
|
299
314
|
workflowId,
|
|
300
315
|
runId,
|
|
301
316
|
inputData
|
|
@@ -311,7 +326,14 @@ async function streamWorkflowHandler({
|
|
|
311
326
|
if (!workflow) {
|
|
312
327
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
313
328
|
}
|
|
314
|
-
|
|
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 });
|
|
315
337
|
const result = run.stream({
|
|
316
338
|
inputData,
|
|
317
339
|
runtimeContext
|
|
@@ -326,7 +348,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
326
348
|
workflowId,
|
|
327
349
|
runId,
|
|
328
350
|
body,
|
|
329
|
-
runtimeContext
|
|
351
|
+
runtimeContext: payloadRuntimeContext
|
|
330
352
|
}) {
|
|
331
353
|
try {
|
|
332
354
|
if (!workflowId) {
|
|
@@ -346,7 +368,14 @@ async function resumeAsyncWorkflowHandler({
|
|
|
346
368
|
if (!run) {
|
|
347
369
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
348
370
|
}
|
|
349
|
-
|
|
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 });
|
|
350
379
|
const result = await _run.resume({
|
|
351
380
|
step: body.step,
|
|
352
381
|
resumeData: body.resumeData,
|
|
@@ -362,7 +391,7 @@ async function resumeWorkflowHandler({
|
|
|
362
391
|
workflowId,
|
|
363
392
|
runId,
|
|
364
393
|
body,
|
|
365
|
-
runtimeContext
|
|
394
|
+
runtimeContext: payloadRuntimeContext
|
|
366
395
|
}) {
|
|
367
396
|
try {
|
|
368
397
|
if (!workflowId) {
|
|
@@ -382,7 +411,14 @@ async function resumeWorkflowHandler({
|
|
|
382
411
|
if (!run) {
|
|
383
412
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
384
413
|
}
|
|
385
|
-
|
|
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 });
|
|
386
422
|
void _run.resume({
|
|
387
423
|
step: body.step,
|
|
388
424
|
resumeData: body.resumeData,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMN6F4D5A_cjs = require('./chunk-MN6F4D5A.cjs');
|
|
4
4
|
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
5
5
|
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
6
6
|
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
@@ -25,8 +25,8 @@ async function getToolsHandler({ tools }) {
|
|
|
25
25
|
const tool = _tool;
|
|
26
26
|
acc[id] = {
|
|
27
27
|
...tool,
|
|
28
|
-
inputSchema: tool.inputSchema ?
|
|
29
|
-
outputSchema: tool.outputSchema ?
|
|
28
|
+
inputSchema: tool.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
29
|
+
outputSchema: tool.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(tool.outputSchema)) : void 0
|
|
30
30
|
};
|
|
31
31
|
return acc;
|
|
32
32
|
},
|
|
@@ -45,8 +45,8 @@ async function getToolByIdHandler({ tools, toolId }) {
|
|
|
45
45
|
}
|
|
46
46
|
const serializedTool = {
|
|
47
47
|
...tool,
|
|
48
|
-
inputSchema: tool.inputSchema ?
|
|
49
|
-
outputSchema: tool.outputSchema ?
|
|
48
|
+
inputSchema: tool.inputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
49
|
+
outputSchema: tool.outputSchema ? chunkMN6F4D5A_cjs.stringify(chunkMN6F4D5A_cjs.esm_default(tool.outputSchema)) : void 0
|
|
50
50
|
};
|
|
51
51
|
return serializedTool;
|
|
52
52
|
} catch (error) {
|