@mastra/inngest 0.0.0-stream-vnext-usage-20250908171242 → 0.0.0-suspendRuntimeContextTypeFix-20250930142630
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 +154 -3
- package/dist/index.cjs +97 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +29 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +98 -122
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -11,9 +11,14 @@ var hono = require('inngest/hono');
|
|
|
11
11
|
var zod = require('zod');
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
|
-
function serve({
|
|
14
|
+
function serve({
|
|
15
|
+
mastra,
|
|
16
|
+
inngest,
|
|
17
|
+
functions: userFunctions = [],
|
|
18
|
+
registerOptions
|
|
19
|
+
}) {
|
|
15
20
|
const wfs = mastra.getWorkflows();
|
|
16
|
-
const
|
|
21
|
+
const workflowFunctions = Array.from(
|
|
17
22
|
new Set(
|
|
18
23
|
Object.values(wfs).flatMap((wf) => {
|
|
19
24
|
if (wf instanceof InngestWorkflow) {
|
|
@@ -25,8 +30,9 @@ function serve({ mastra, inngest }) {
|
|
|
25
30
|
)
|
|
26
31
|
);
|
|
27
32
|
return hono.serve({
|
|
33
|
+
...registerOptions,
|
|
28
34
|
client: inngest,
|
|
29
|
-
functions
|
|
35
|
+
functions: [...workflowFunctions, ...userFunctions]
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
var InngestRun = class extends workflows.Run {
|
|
@@ -54,7 +60,6 @@ var InngestRun = class extends workflows.Run {
|
|
|
54
60
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
55
61
|
runs = await this.getRuns(eventId);
|
|
56
62
|
if (runs?.[0]?.status === "Failed") {
|
|
57
|
-
console.log("run", runs?.[0]);
|
|
58
63
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
59
64
|
} else if (runs?.[0]?.status === "Cancelled") {
|
|
60
65
|
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
@@ -87,6 +92,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
87
92
|
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
88
93
|
workflowName: this.workflowId,
|
|
89
94
|
runId: this.runId,
|
|
95
|
+
resourceId: this.resourceId,
|
|
90
96
|
snapshot: {
|
|
91
97
|
...snapshot,
|
|
92
98
|
status: "canceled"
|
|
@@ -100,6 +106,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
100
106
|
await this.#mastra.getStorage()?.persistWorkflowSnapshot({
|
|
101
107
|
workflowName: this.workflowId,
|
|
102
108
|
runId: this.runId,
|
|
109
|
+
resourceId: this.resourceId,
|
|
103
110
|
snapshot: {
|
|
104
111
|
runId: this.runId,
|
|
105
112
|
serializedStepGraph: this.serializedStepGraph,
|
|
@@ -112,11 +119,13 @@ var InngestRun = class extends workflows.Run {
|
|
|
112
119
|
status: "running"
|
|
113
120
|
}
|
|
114
121
|
});
|
|
122
|
+
const inputDataToUse = await this._validateInput(inputData);
|
|
115
123
|
const eventOutput = await this.inngest.send({
|
|
116
124
|
name: `workflow.${this.workflowId}`,
|
|
117
125
|
data: {
|
|
118
|
-
inputData,
|
|
119
|
-
runId: this.runId
|
|
126
|
+
inputData: inputDataToUse,
|
|
127
|
+
runId: this.runId,
|
|
128
|
+
resourceId: this.resourceId
|
|
120
129
|
}
|
|
121
130
|
});
|
|
122
131
|
const eventId = eventOutput.ids[0];
|
|
@@ -152,17 +161,19 @@ var InngestRun = class extends workflows.Run {
|
|
|
152
161
|
workflowName: this.workflowId,
|
|
153
162
|
runId: this.runId
|
|
154
163
|
});
|
|
164
|
+
const suspendedStep = this.workflowSteps[steps?.[0] ?? ""];
|
|
165
|
+
const resumeDataToUse = await this._validateResumeData(params.resumeData, suspendedStep);
|
|
155
166
|
const eventOutput = await this.inngest.send({
|
|
156
167
|
name: `workflow.${this.workflowId}`,
|
|
157
168
|
data: {
|
|
158
|
-
inputData:
|
|
169
|
+
inputData: resumeDataToUse,
|
|
159
170
|
runId: this.runId,
|
|
160
171
|
workflowId: this.workflowId,
|
|
161
172
|
stepResults: snapshot?.context,
|
|
162
173
|
resume: {
|
|
163
174
|
steps,
|
|
164
175
|
stepResults: snapshot?.context,
|
|
165
|
-
resumePayload:
|
|
176
|
+
resumePayload: resumeDataToUse,
|
|
166
177
|
// @ts-ignore
|
|
167
178
|
resumePath: snapshot?.suspendedPaths?.[steps?.[0]]
|
|
168
179
|
}
|
|
@@ -204,33 +215,9 @@ var InngestRun = class extends workflows.Run {
|
|
|
204
215
|
}
|
|
205
216
|
stream({ inputData, runtimeContext } = {}) {
|
|
206
217
|
const { readable, writable } = new TransformStream();
|
|
207
|
-
let currentToolData = void 0;
|
|
208
218
|
const writer = writable.getWriter();
|
|
209
219
|
const unwatch = this.watch(async (event) => {
|
|
210
|
-
if (event.type === "workflow-agent-call-start") {
|
|
211
|
-
currentToolData = {
|
|
212
|
-
name: event.payload.name,
|
|
213
|
-
args: event.payload.args
|
|
214
|
-
};
|
|
215
|
-
await writer.write({
|
|
216
|
-
...event.payload,
|
|
217
|
-
type: "tool-call-streaming-start"
|
|
218
|
-
});
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
220
|
try {
|
|
222
|
-
if (event.type === "workflow-agent-call-finish") {
|
|
223
|
-
return;
|
|
224
|
-
} else if (!event.type.startsWith("workflow-")) {
|
|
225
|
-
if (event.type === "text-delta") {
|
|
226
|
-
await writer.write({
|
|
227
|
-
type: "tool-call-delta",
|
|
228
|
-
...currentToolData ?? {},
|
|
229
|
-
argsTextDelta: event.textDelta
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
221
|
const e = {
|
|
235
222
|
...event,
|
|
236
223
|
type: event.type.replace("workflow-", "")
|
|
@@ -312,23 +299,14 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
312
299
|
}
|
|
313
300
|
}
|
|
314
301
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
executionGraph: this.executionGraph,
|
|
323
|
-
serializedStepGraph: this.serializedStepGraph,
|
|
324
|
-
mastra: this.#mastra,
|
|
325
|
-
retryConfig: this.retryConfig,
|
|
326
|
-
cleanup: () => this.runs.delete(runIdToUse)
|
|
327
|
-
},
|
|
328
|
-
this.inngest
|
|
302
|
+
/**
|
|
303
|
+
* @deprecated Use createRunAsync() instead.
|
|
304
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
305
|
+
*/
|
|
306
|
+
createRun(_options) {
|
|
307
|
+
throw new Error(
|
|
308
|
+
"createRun() has been deprecated. Please use createRunAsync() instead.\n\nMigration guide:\n Before: const run = workflow.createRun();\n After: const run = await workflow.createRunAsync();\n\nNote: createRunAsync() is an async method, so make sure your calling function is async."
|
|
329
309
|
);
|
|
330
|
-
this.runs.set(runIdToUse, run);
|
|
331
|
-
return run;
|
|
332
310
|
}
|
|
333
311
|
async createRunAsync(options) {
|
|
334
312
|
const runIdToUse = options?.runId || crypto.randomUUID();
|
|
@@ -336,12 +314,14 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
336
314
|
{
|
|
337
315
|
workflowId: this.id,
|
|
338
316
|
runId: runIdToUse,
|
|
317
|
+
resourceId: options?.resourceId,
|
|
339
318
|
executionEngine: this.executionEngine,
|
|
340
319
|
executionGraph: this.executionGraph,
|
|
341
320
|
serializedStepGraph: this.serializedStepGraph,
|
|
342
321
|
mastra: this.#mastra,
|
|
343
322
|
retryConfig: this.retryConfig,
|
|
344
|
-
cleanup: () => this.runs.delete(runIdToUse)
|
|
323
|
+
cleanup: () => this.runs.delete(runIdToUse),
|
|
324
|
+
workflowSteps: this.steps
|
|
345
325
|
},
|
|
346
326
|
this.inngest
|
|
347
327
|
);
|
|
@@ -351,6 +331,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
351
331
|
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
352
332
|
workflowName: this.id,
|
|
353
333
|
runId: runIdToUse,
|
|
334
|
+
resourceId: options?.resourceId,
|
|
354
335
|
snapshot: {
|
|
355
336
|
runId: runIdToUse,
|
|
356
337
|
status: "pending",
|
|
@@ -384,7 +365,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
384
365
|
},
|
|
385
366
|
{ event: `workflow.${this.id}` },
|
|
386
367
|
async ({ event, step, attempt, publish }) => {
|
|
387
|
-
let { inputData, runId, resume } = event.data;
|
|
368
|
+
let { inputData, runId, resourceId, resume } = event.data;
|
|
388
369
|
if (!runId) {
|
|
389
370
|
runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
|
|
390
371
|
return crypto.randomUUID();
|
|
@@ -416,6 +397,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
416
397
|
const result = await engine.execute({
|
|
417
398
|
workflowId: this.id,
|
|
418
399
|
runId,
|
|
400
|
+
resourceId,
|
|
419
401
|
graph: this.executionGraph,
|
|
420
402
|
serializedStepGraph: this.serializedStepGraph,
|
|
421
403
|
input: inputData,
|
|
@@ -460,11 +442,10 @@ function createStep(params) {
|
|
|
460
442
|
if (isAgent(params)) {
|
|
461
443
|
return {
|
|
462
444
|
id: params.name,
|
|
445
|
+
description: params.getDescription(),
|
|
463
446
|
// @ts-ignore
|
|
464
447
|
inputSchema: zod.z.object({
|
|
465
448
|
prompt: zod.z.string()
|
|
466
|
-
// resourceId: z.string().optional(),
|
|
467
|
-
// threadId: z.string().optional(),
|
|
468
449
|
}),
|
|
469
450
|
// @ts-ignore
|
|
470
451
|
outputSchema: zod.z.object({
|
|
@@ -480,13 +461,7 @@ function createStep(params) {
|
|
|
480
461
|
name: params.name,
|
|
481
462
|
args: inputData
|
|
482
463
|
};
|
|
483
|
-
await emitter.emit("watch-v2", {
|
|
484
|
-
type: "workflow-agent-call-start",
|
|
485
|
-
payload: toolData
|
|
486
|
-
});
|
|
487
464
|
const { fullStream } = await params.stream(inputData.prompt, {
|
|
488
|
-
// resourceId: inputData.resourceId,
|
|
489
|
-
// threadId: inputData.threadId,
|
|
490
465
|
runtimeContext,
|
|
491
466
|
tracingContext,
|
|
492
467
|
onFinish: (result) => {
|
|
@@ -497,17 +472,28 @@ function createStep(params) {
|
|
|
497
472
|
if (abortSignal.aborted) {
|
|
498
473
|
return abort();
|
|
499
474
|
}
|
|
475
|
+
await emitter.emit("watch-v2", {
|
|
476
|
+
type: "tool-call-streaming-start",
|
|
477
|
+
...toolData ?? {}
|
|
478
|
+
});
|
|
500
479
|
for await (const chunk of fullStream) {
|
|
501
|
-
|
|
480
|
+
if (chunk.type === "text-delta") {
|
|
481
|
+
await emitter.emit("watch-v2", {
|
|
482
|
+
type: "tool-call-delta",
|
|
483
|
+
...toolData ?? {},
|
|
484
|
+
argsTextDelta: chunk.textDelta
|
|
485
|
+
});
|
|
486
|
+
}
|
|
502
487
|
}
|
|
503
488
|
await emitter.emit("watch-v2", {
|
|
504
|
-
type: "
|
|
505
|
-
|
|
489
|
+
type: "tool-call-streaming-finish",
|
|
490
|
+
...toolData ?? {}
|
|
506
491
|
});
|
|
507
492
|
return {
|
|
508
493
|
text: await streamPromise.promise
|
|
509
494
|
};
|
|
510
|
-
}
|
|
495
|
+
},
|
|
496
|
+
component: params.component
|
|
511
497
|
};
|
|
512
498
|
}
|
|
513
499
|
if (isTool(params)) {
|
|
@@ -518,16 +504,20 @@ function createStep(params) {
|
|
|
518
504
|
// TODO: tool probably should have strong id type
|
|
519
505
|
// @ts-ignore
|
|
520
506
|
id: params.id,
|
|
507
|
+
description: params.description,
|
|
521
508
|
inputSchema: params.inputSchema,
|
|
522
509
|
outputSchema: params.outputSchema,
|
|
523
|
-
execute: async ({ inputData, mastra, runtimeContext, tracingContext }) => {
|
|
510
|
+
execute: async ({ inputData, mastra, runtimeContext, tracingContext, suspend, resumeData }) => {
|
|
524
511
|
return params.execute({
|
|
525
512
|
context: inputData,
|
|
526
513
|
mastra: aiTracing.wrapMastra(mastra, tracingContext),
|
|
527
514
|
runtimeContext,
|
|
528
|
-
tracingContext
|
|
515
|
+
tracingContext,
|
|
516
|
+
suspend,
|
|
517
|
+
resumeData
|
|
529
518
|
});
|
|
530
|
-
}
|
|
519
|
+
},
|
|
520
|
+
component: "TOOL"
|
|
531
521
|
};
|
|
532
522
|
}
|
|
533
523
|
return {
|
|
@@ -552,7 +542,8 @@ function init(inngest) {
|
|
|
552
542
|
description: step.description,
|
|
553
543
|
inputSchema: step.inputSchema,
|
|
554
544
|
outputSchema: step.outputSchema,
|
|
555
|
-
execute: step.execute
|
|
545
|
+
execute: step.execute,
|
|
546
|
+
component: step.component
|
|
556
547
|
};
|
|
557
548
|
},
|
|
558
549
|
cloneWorkflow(workflow, opts) {
|
|
@@ -572,8 +563,8 @@ function init(inngest) {
|
|
|
572
563
|
var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
573
564
|
inngestStep;
|
|
574
565
|
inngestAttempts;
|
|
575
|
-
constructor(mastra, inngestStep, inngestAttempts = 0) {
|
|
576
|
-
super({ mastra });
|
|
566
|
+
constructor(mastra, inngestStep, inngestAttempts = 0, options) {
|
|
567
|
+
super({ mastra, options });
|
|
577
568
|
this.inngestStep = inngestStep;
|
|
578
569
|
this.inngestAttempts = inngestAttempts;
|
|
579
570
|
}
|
|
@@ -669,7 +660,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
669
660
|
attributes: {
|
|
670
661
|
durationMs: duration,
|
|
671
662
|
sleepType: fn ? "dynamic" : "fixed"
|
|
672
|
-
}
|
|
663
|
+
},
|
|
664
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
673
665
|
});
|
|
674
666
|
if (fn) {
|
|
675
667
|
const stepCallId = crypto.randomUUID();
|
|
@@ -685,16 +677,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
685
677
|
currentSpan: sleepSpan
|
|
686
678
|
},
|
|
687
679
|
getInitData: () => stepResults?.input,
|
|
688
|
-
getStepResult: (
|
|
689
|
-
if (!step?.id) {
|
|
690
|
-
return null;
|
|
691
|
-
}
|
|
692
|
-
const result = stepResults[step.id];
|
|
693
|
-
if (result?.status === "success") {
|
|
694
|
-
return result.output;
|
|
695
|
-
}
|
|
696
|
-
return null;
|
|
697
|
-
},
|
|
680
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
698
681
|
// TODO: this function shouldn't have suspend probably?
|
|
699
682
|
suspend: async (_suspendPayload) => {
|
|
700
683
|
},
|
|
@@ -754,7 +737,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
754
737
|
untilDate: date,
|
|
755
738
|
durationMs: date ? Math.max(0, date.getTime() - Date.now()) : void 0,
|
|
756
739
|
sleepType: fn ? "dynamic" : "fixed"
|
|
757
|
-
}
|
|
740
|
+
},
|
|
741
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
758
742
|
});
|
|
759
743
|
if (fn) {
|
|
760
744
|
date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
|
|
@@ -770,16 +754,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
770
754
|
currentSpan: sleepUntilSpan
|
|
771
755
|
},
|
|
772
756
|
getInitData: () => stepResults?.input,
|
|
773
|
-
getStepResult: (
|
|
774
|
-
if (!step?.id) {
|
|
775
|
-
return null;
|
|
776
|
-
}
|
|
777
|
-
const result = stepResults[step.id];
|
|
778
|
-
if (result?.status === "success") {
|
|
779
|
-
return result.output;
|
|
780
|
-
}
|
|
781
|
-
return null;
|
|
782
|
-
},
|
|
757
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
783
758
|
// TODO: this function shouldn't have suspend probably?
|
|
784
759
|
suspend: async (_suspendPayload) => {
|
|
785
760
|
},
|
|
@@ -804,6 +779,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
804
779
|
)
|
|
805
780
|
});
|
|
806
781
|
});
|
|
782
|
+
if (date && !(date instanceof Date)) {
|
|
783
|
+
date = new Date(date);
|
|
784
|
+
}
|
|
807
785
|
const time = !date ? 0 : date.getTime() - Date.now();
|
|
808
786
|
sleepUntilSpan?.update({
|
|
809
787
|
attributes: {
|
|
@@ -852,7 +830,13 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
852
830
|
input: prevOutput,
|
|
853
831
|
attributes: {
|
|
854
832
|
stepId: step.id
|
|
855
|
-
}
|
|
833
|
+
},
|
|
834
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
835
|
+
});
|
|
836
|
+
const { inputData, validationError } = await workflows.validateStepInput({
|
|
837
|
+
prevOutput,
|
|
838
|
+
step,
|
|
839
|
+
validateInputs: this.options?.validateInputs ?? false
|
|
856
840
|
});
|
|
857
841
|
const startedAt = await this.inngestStep.run(
|
|
858
842
|
`workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
|
|
@@ -884,7 +868,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
884
868
|
payload: {
|
|
885
869
|
id: step.id,
|
|
886
870
|
status: "running",
|
|
887
|
-
payload:
|
|
871
|
+
payload: inputData,
|
|
888
872
|
startedAt: startedAt2
|
|
889
873
|
}
|
|
890
874
|
});
|
|
@@ -904,7 +888,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
904
888
|
const invokeResp = await this.inngestStep.invoke(`workflow.${executionContext.workflowId}.step.${step.id}`, {
|
|
905
889
|
function: step.getFunction(),
|
|
906
890
|
data: {
|
|
907
|
-
inputData
|
|
891
|
+
inputData,
|
|
908
892
|
runId,
|
|
909
893
|
resume: {
|
|
910
894
|
runId,
|
|
@@ -922,7 +906,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
922
906
|
const invokeResp = await this.inngestStep.invoke(`workflow.${executionContext.workflowId}.step.${step.id}`, {
|
|
923
907
|
function: step.getFunction(),
|
|
924
908
|
data: {
|
|
925
|
-
inputData
|
|
909
|
+
inputData
|
|
926
910
|
}
|
|
927
911
|
});
|
|
928
912
|
result = invokeResp.result;
|
|
@@ -1067,24 +1051,21 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1067
1051
|
let suspended;
|
|
1068
1052
|
let bailed;
|
|
1069
1053
|
try {
|
|
1054
|
+
if (validationError) {
|
|
1055
|
+
throw validationError;
|
|
1056
|
+
}
|
|
1070
1057
|
const result = await step.execute({
|
|
1071
1058
|
runId: executionContext.runId,
|
|
1072
1059
|
mastra: this.mastra,
|
|
1073
1060
|
runtimeContext,
|
|
1074
1061
|
writableStream,
|
|
1075
|
-
inputData
|
|
1062
|
+
inputData,
|
|
1076
1063
|
resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
|
|
1077
1064
|
tracingContext: {
|
|
1078
1065
|
currentSpan: stepAISpan
|
|
1079
1066
|
},
|
|
1080
1067
|
getInitData: () => stepResults?.input,
|
|
1081
|
-
getStepResult: (
|
|
1082
|
-
const result2 = stepResults[step2.id];
|
|
1083
|
-
if (result2?.status === "success") {
|
|
1084
|
-
return result2.output;
|
|
1085
|
-
}
|
|
1086
|
-
return null;
|
|
1087
|
-
},
|
|
1068
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
1088
1069
|
suspend: async (suspendPayload) => {
|
|
1089
1070
|
executionContext.suspendedPaths[step.id] = executionContext.executionPath;
|
|
1090
1071
|
suspended = { payload: suspendPayload };
|
|
@@ -1110,14 +1091,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1110
1091
|
output: result,
|
|
1111
1092
|
startedAt,
|
|
1112
1093
|
endedAt,
|
|
1113
|
-
payload:
|
|
1094
|
+
payload: inputData,
|
|
1114
1095
|
resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
|
|
1115
1096
|
resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
|
|
1116
1097
|
};
|
|
1117
1098
|
} catch (e) {
|
|
1118
1099
|
execResults = {
|
|
1119
1100
|
status: "failed",
|
|
1120
|
-
payload:
|
|
1101
|
+
payload: inputData,
|
|
1121
1102
|
error: e instanceof Error ? e.message : String(e),
|
|
1122
1103
|
endedAt: Date.now(),
|
|
1123
1104
|
startedAt,
|
|
@@ -1129,14 +1110,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1129
1110
|
execResults = {
|
|
1130
1111
|
status: "suspended",
|
|
1131
1112
|
suspendedPayload: suspended.payload,
|
|
1132
|
-
payload:
|
|
1113
|
+
payload: inputData,
|
|
1133
1114
|
suspendedAt: Date.now(),
|
|
1134
1115
|
startedAt,
|
|
1135
1116
|
resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
|
|
1136
1117
|
resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
|
|
1137
1118
|
};
|
|
1138
1119
|
} else if (bailed) {
|
|
1139
|
-
execResults = { status: "bailed", output: bailed.payload, payload:
|
|
1120
|
+
execResults = { status: "bailed", output: bailed.payload, payload: inputData, endedAt: Date.now(), startedAt };
|
|
1140
1121
|
}
|
|
1141
1122
|
if (execResults.status === "failed") {
|
|
1142
1123
|
if (executionContext.retryConfig.attempts > 0 && this.inngestAttempts < executionContext.retryConfig.attempts) {
|
|
@@ -1194,7 +1175,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1194
1175
|
await this.runScorers({
|
|
1195
1176
|
scorers: step.scorers,
|
|
1196
1177
|
runId: executionContext.runId,
|
|
1197
|
-
input:
|
|
1178
|
+
input: inputData,
|
|
1198
1179
|
output: stepRes.result,
|
|
1199
1180
|
workflowId: executionContext.workflowId,
|
|
1200
1181
|
stepId: step.id,
|
|
@@ -1213,6 +1194,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1213
1194
|
workflowId,
|
|
1214
1195
|
runId,
|
|
1215
1196
|
stepResults,
|
|
1197
|
+
resourceId,
|
|
1216
1198
|
executionContext,
|
|
1217
1199
|
serializedStepGraph,
|
|
1218
1200
|
workflowStatus,
|
|
@@ -1225,6 +1207,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1225
1207
|
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
1226
1208
|
workflowName: workflowId,
|
|
1227
1209
|
runId,
|
|
1210
|
+
resourceId,
|
|
1228
1211
|
snapshot: {
|
|
1229
1212
|
runId,
|
|
1230
1213
|
value: {},
|
|
@@ -1262,11 +1245,12 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1262
1245
|
}) {
|
|
1263
1246
|
const conditionalSpan = tracingContext?.currentSpan?.createChildSpan({
|
|
1264
1247
|
type: aiTracing.AISpanType.WORKFLOW_CONDITIONAL,
|
|
1265
|
-
name: `conditional: ${entry.conditions.length} conditions`,
|
|
1248
|
+
name: `conditional: '${entry.conditions.length} conditions'`,
|
|
1266
1249
|
input: prevOutput,
|
|
1267
1250
|
attributes: {
|
|
1268
1251
|
conditionCount: entry.conditions.length
|
|
1269
|
-
}
|
|
1252
|
+
},
|
|
1253
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
1270
1254
|
});
|
|
1271
1255
|
let execResults;
|
|
1272
1256
|
const truthyIndexes = (await Promise.all(
|
|
@@ -1274,11 +1258,12 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1274
1258
|
(cond, index) => this.inngestStep.run(`workflow.${workflowId}.conditional.${index}`, async () => {
|
|
1275
1259
|
const evalSpan = conditionalSpan?.createChildSpan({
|
|
1276
1260
|
type: aiTracing.AISpanType.WORKFLOW_CONDITIONAL_EVAL,
|
|
1277
|
-
name: `condition ${index}`,
|
|
1261
|
+
name: `condition: '${index}'`,
|
|
1278
1262
|
input: prevOutput,
|
|
1279
1263
|
attributes: {
|
|
1280
1264
|
conditionIndex: index
|
|
1281
|
-
}
|
|
1265
|
+
},
|
|
1266
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
1282
1267
|
});
|
|
1283
1268
|
try {
|
|
1284
1269
|
const result = await cond({
|
|
@@ -1292,16 +1277,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1292
1277
|
currentSpan: evalSpan
|
|
1293
1278
|
},
|
|
1294
1279
|
getInitData: () => stepResults?.input,
|
|
1295
|
-
getStepResult: (
|
|
1296
|
-
if (!step?.id) {
|
|
1297
|
-
return null;
|
|
1298
|
-
}
|
|
1299
|
-
const result2 = stepResults[step.id];
|
|
1300
|
-
if (result2?.status === "success") {
|
|
1301
|
-
return result2.output;
|
|
1302
|
-
}
|
|
1303
|
-
return null;
|
|
1304
|
-
},
|
|
1280
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
1305
1281
|
// TODO: this function shouldn't have suspend probably?
|
|
1306
1282
|
suspend: async (_suspendPayload) => {
|
|
1307
1283
|
},
|