@mastra/inngest 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vector-extension-schema-20250922130418
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 +259 -6
- package/dist/index.cjs +100 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +37 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -140
- package/dist/index.js.map +1 -1
- package/package.json +24 -11
- package/docker-compose.yaml +0 -10
- package/eslint.config.js +0 -6
- package/src/index.test.ts +0 -7907
- package/src/index.ts +0 -1920
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.ts +0 -14
package/dist/index.cjs
CHANGED
|
@@ -11,9 +11,13 @@ 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
|
+
}) {
|
|
15
19
|
const wfs = mastra.getWorkflows();
|
|
16
|
-
const
|
|
20
|
+
const workflowFunctions = Array.from(
|
|
17
21
|
new Set(
|
|
18
22
|
Object.values(wfs).flatMap((wf) => {
|
|
19
23
|
if (wf instanceof InngestWorkflow) {
|
|
@@ -26,7 +30,7 @@ function serve({ mastra, inngest }) {
|
|
|
26
30
|
);
|
|
27
31
|
return hono.serve({
|
|
28
32
|
client: inngest,
|
|
29
|
-
functions
|
|
33
|
+
functions: [...workflowFunctions, ...userFunctions]
|
|
30
34
|
});
|
|
31
35
|
}
|
|
32
36
|
var InngestRun = class extends workflows.Run {
|
|
@@ -54,7 +58,6 @@ var InngestRun = class extends workflows.Run {
|
|
|
54
58
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
55
59
|
runs = await this.getRuns(eventId);
|
|
56
60
|
if (runs?.[0]?.status === "Failed") {
|
|
57
|
-
console.log("run", runs?.[0]);
|
|
58
61
|
throw new Error(`Function run ${runs?.[0]?.status}`);
|
|
59
62
|
} else if (runs?.[0]?.status === "Cancelled") {
|
|
60
63
|
const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
|
|
@@ -87,6 +90,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
87
90
|
await this.#mastra?.storage?.persistWorkflowSnapshot({
|
|
88
91
|
workflowName: this.workflowId,
|
|
89
92
|
runId: this.runId,
|
|
93
|
+
resourceId: this.resourceId,
|
|
90
94
|
snapshot: {
|
|
91
95
|
...snapshot,
|
|
92
96
|
status: "canceled"
|
|
@@ -100,6 +104,7 @@ var InngestRun = class extends workflows.Run {
|
|
|
100
104
|
await this.#mastra.getStorage()?.persistWorkflowSnapshot({
|
|
101
105
|
workflowName: this.workflowId,
|
|
102
106
|
runId: this.runId,
|
|
107
|
+
resourceId: this.resourceId,
|
|
103
108
|
snapshot: {
|
|
104
109
|
runId: this.runId,
|
|
105
110
|
serializedStepGraph: this.serializedStepGraph,
|
|
@@ -116,7 +121,8 @@ var InngestRun = class extends workflows.Run {
|
|
|
116
121
|
name: `workflow.${this.workflowId}`,
|
|
117
122
|
data: {
|
|
118
123
|
inputData,
|
|
119
|
-
runId: this.runId
|
|
124
|
+
runId: this.runId,
|
|
125
|
+
resourceId: this.resourceId
|
|
120
126
|
}
|
|
121
127
|
});
|
|
122
128
|
const eventId = eventOutput.ids[0];
|
|
@@ -207,7 +213,11 @@ var InngestRun = class extends workflows.Run {
|
|
|
207
213
|
const writer = writable.getWriter();
|
|
208
214
|
const unwatch = this.watch(async (event) => {
|
|
209
215
|
try {
|
|
210
|
-
|
|
216
|
+
const e = {
|
|
217
|
+
...event,
|
|
218
|
+
type: event.type.replace("workflow-", "")
|
|
219
|
+
};
|
|
220
|
+
await writer.write(e);
|
|
211
221
|
} catch {
|
|
212
222
|
}
|
|
213
223
|
}, "watch-v2");
|
|
@@ -238,8 +248,14 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
238
248
|
#mastra;
|
|
239
249
|
inngest;
|
|
240
250
|
function;
|
|
251
|
+
flowControlConfig;
|
|
241
252
|
constructor(params, inngest) {
|
|
242
|
-
|
|
253
|
+
const { concurrency, rateLimit, throttle, debounce, priority, ...workflowParams } = params;
|
|
254
|
+
super(workflowParams);
|
|
255
|
+
const flowControlEntries = Object.entries({ concurrency, rateLimit, throttle, debounce, priority }).filter(
|
|
256
|
+
([_, value]) => value !== void 0
|
|
257
|
+
);
|
|
258
|
+
this.flowControlConfig = flowControlEntries.length > 0 ? Object.fromEntries(flowControlEntries) : void 0;
|
|
243
259
|
this.#mastra = params.mastra;
|
|
244
260
|
this.inngest = inngest;
|
|
245
261
|
}
|
|
@@ -260,27 +276,6 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
260
276
|
const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
|
|
261
277
|
return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
|
|
262
278
|
}
|
|
263
|
-
async getWorkflowRunExecutionResult(runId) {
|
|
264
|
-
const storage = this.#mastra?.getStorage();
|
|
265
|
-
if (!storage) {
|
|
266
|
-
this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
|
|
270
|
-
if (!run?.snapshot) {
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
if (typeof run.snapshot === "string") {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
status: run.snapshot.status,
|
|
278
|
-
result: run.snapshot.result,
|
|
279
|
-
error: run.snapshot.error,
|
|
280
|
-
payload: run.snapshot.context?.input,
|
|
281
|
-
steps: run.snapshot.context
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
279
|
__registerMastra(mastra) {
|
|
285
280
|
this.#mastra = mastra;
|
|
286
281
|
this.executionEngine.__registerMastra(mastra);
|
|
@@ -299,23 +294,14 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
299
294
|
}
|
|
300
295
|
}
|
|
301
296
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
executionGraph: this.executionGraph,
|
|
310
|
-
serializedStepGraph: this.serializedStepGraph,
|
|
311
|
-
mastra: this.#mastra,
|
|
312
|
-
retryConfig: this.retryConfig,
|
|
313
|
-
cleanup: () => this.runs.delete(runIdToUse)
|
|
314
|
-
},
|
|
315
|
-
this.inngest
|
|
297
|
+
/**
|
|
298
|
+
* @deprecated Use createRunAsync() instead.
|
|
299
|
+
* @throws {Error} Always throws an error directing users to use createRunAsync()
|
|
300
|
+
*/
|
|
301
|
+
createRun(_options) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
"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."
|
|
316
304
|
);
|
|
317
|
-
this.runs.set(runIdToUse, run);
|
|
318
|
-
return run;
|
|
319
305
|
}
|
|
320
306
|
async createRunAsync(options) {
|
|
321
307
|
const runIdToUse = options?.runId || crypto.randomUUID();
|
|
@@ -323,6 +309,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
323
309
|
{
|
|
324
310
|
workflowId: this.id,
|
|
325
311
|
runId: runIdToUse,
|
|
312
|
+
resourceId: options?.resourceId,
|
|
326
313
|
executionEngine: this.executionEngine,
|
|
327
314
|
executionGraph: this.executionGraph,
|
|
328
315
|
serializedStepGraph: this.serializedStepGraph,
|
|
@@ -333,11 +320,12 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
333
320
|
this.inngest
|
|
334
321
|
);
|
|
335
322
|
this.runs.set(runIdToUse, run);
|
|
336
|
-
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse);
|
|
323
|
+
const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, false);
|
|
337
324
|
if (!workflowSnapshotInStorage) {
|
|
338
325
|
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
339
326
|
workflowName: this.id,
|
|
340
327
|
runId: runIdToUse,
|
|
328
|
+
resourceId: options?.resourceId,
|
|
341
329
|
snapshot: {
|
|
342
330
|
runId: runIdToUse,
|
|
343
331
|
status: "pending",
|
|
@@ -365,11 +353,13 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
365
353
|
id: `workflow.${this.id}`,
|
|
366
354
|
// @ts-ignore
|
|
367
355
|
retries: this.retryConfig?.attempts ?? 0,
|
|
368
|
-
cancelOn: [{ event: `cancel.workflow.${this.id}` }]
|
|
356
|
+
cancelOn: [{ event: `cancel.workflow.${this.id}` }],
|
|
357
|
+
// Spread flow control configuration
|
|
358
|
+
...this.flowControlConfig
|
|
369
359
|
},
|
|
370
360
|
{ event: `workflow.${this.id}` },
|
|
371
361
|
async ({ event, step, attempt, publish }) => {
|
|
372
|
-
let { inputData, runId, resume } = event.data;
|
|
362
|
+
let { inputData, runId, resourceId, resume } = event.data;
|
|
373
363
|
if (!runId) {
|
|
374
364
|
runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
|
|
375
365
|
return crypto.randomUUID();
|
|
@@ -401,6 +391,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
401
391
|
const result = await engine.execute({
|
|
402
392
|
workflowId: this.id,
|
|
403
393
|
runId,
|
|
394
|
+
resourceId,
|
|
404
395
|
graph: this.executionGraph,
|
|
405
396
|
serializedStepGraph: this.serializedStepGraph,
|
|
406
397
|
input: inputData,
|
|
@@ -448,8 +439,6 @@ function createStep(params) {
|
|
|
448
439
|
// @ts-ignore
|
|
449
440
|
inputSchema: zod.z.object({
|
|
450
441
|
prompt: zod.z.string()
|
|
451
|
-
// resourceId: z.string().optional(),
|
|
452
|
-
// threadId: z.string().optional(),
|
|
453
442
|
}),
|
|
454
443
|
// @ts-ignore
|
|
455
444
|
outputSchema: zod.z.object({
|
|
@@ -465,13 +454,7 @@ function createStep(params) {
|
|
|
465
454
|
name: params.name,
|
|
466
455
|
args: inputData
|
|
467
456
|
};
|
|
468
|
-
await emitter.emit("watch-v2", {
|
|
469
|
-
type: "tool-call-streaming-start",
|
|
470
|
-
...toolData
|
|
471
|
-
});
|
|
472
457
|
const { fullStream } = await params.stream(inputData.prompt, {
|
|
473
|
-
// resourceId: inputData.resourceId,
|
|
474
|
-
// threadId: inputData.threadId,
|
|
475
458
|
runtimeContext,
|
|
476
459
|
tracingContext,
|
|
477
460
|
onFinish: (result) => {
|
|
@@ -482,30 +465,23 @@ function createStep(params) {
|
|
|
482
465
|
if (abortSignal.aborted) {
|
|
483
466
|
return abort();
|
|
484
467
|
}
|
|
468
|
+
await emitter.emit("watch-v2", {
|
|
469
|
+
type: "tool-call-streaming-start",
|
|
470
|
+
...toolData ?? {}
|
|
471
|
+
});
|
|
485
472
|
for await (const chunk of fullStream) {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
});
|
|
493
|
-
break;
|
|
494
|
-
case "step-start":
|
|
495
|
-
case "step-finish":
|
|
496
|
-
case "finish":
|
|
497
|
-
break;
|
|
498
|
-
case "tool-call":
|
|
499
|
-
case "tool-result":
|
|
500
|
-
case "tool-call-streaming-start":
|
|
501
|
-
case "tool-call-delta":
|
|
502
|
-
case "source":
|
|
503
|
-
case "file":
|
|
504
|
-
default:
|
|
505
|
-
await emitter.emit("watch-v2", chunk);
|
|
506
|
-
break;
|
|
473
|
+
if (chunk.type === "text-delta") {
|
|
474
|
+
await emitter.emit("watch-v2", {
|
|
475
|
+
type: "tool-call-delta",
|
|
476
|
+
...toolData ?? {},
|
|
477
|
+
argsTextDelta: chunk.textDelta
|
|
478
|
+
});
|
|
507
479
|
}
|
|
508
480
|
}
|
|
481
|
+
await emitter.emit("watch-v2", {
|
|
482
|
+
type: "tool-call-streaming-finish",
|
|
483
|
+
...toolData ?? {}
|
|
484
|
+
});
|
|
509
485
|
return {
|
|
510
486
|
text: await streamPromise.promise
|
|
511
487
|
};
|
|
@@ -574,19 +550,19 @@ function init(inngest) {
|
|
|
574
550
|
var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
575
551
|
inngestStep;
|
|
576
552
|
inngestAttempts;
|
|
577
|
-
constructor(mastra, inngestStep, inngestAttempts = 0) {
|
|
578
|
-
super({ mastra });
|
|
553
|
+
constructor(mastra, inngestStep, inngestAttempts = 0, options) {
|
|
554
|
+
super({ mastra, options });
|
|
579
555
|
this.inngestStep = inngestStep;
|
|
580
556
|
this.inngestAttempts = inngestAttempts;
|
|
581
557
|
}
|
|
582
558
|
async execute(params) {
|
|
583
559
|
await params.emitter.emit("watch-v2", {
|
|
584
|
-
type: "start",
|
|
560
|
+
type: "workflow-start",
|
|
585
561
|
payload: { runId: params.runId }
|
|
586
562
|
});
|
|
587
563
|
const result = await super.execute(params);
|
|
588
564
|
await params.emitter.emit("watch-v2", {
|
|
589
|
-
type: "finish",
|
|
565
|
+
type: "workflow-finish",
|
|
590
566
|
payload: { runId: params.runId }
|
|
591
567
|
});
|
|
592
568
|
return result;
|
|
@@ -660,6 +636,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
660
636
|
emitter,
|
|
661
637
|
abortController,
|
|
662
638
|
runtimeContext,
|
|
639
|
+
executionContext,
|
|
663
640
|
writableStream,
|
|
664
641
|
tracingContext
|
|
665
642
|
}) {
|
|
@@ -670,7 +647,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
670
647
|
attributes: {
|
|
671
648
|
durationMs: duration,
|
|
672
649
|
sleepType: fn ? "dynamic" : "fixed"
|
|
673
|
-
}
|
|
650
|
+
},
|
|
651
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
674
652
|
});
|
|
675
653
|
if (fn) {
|
|
676
654
|
const stepCallId = crypto.randomUUID();
|
|
@@ -686,16 +664,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
686
664
|
currentSpan: sleepSpan
|
|
687
665
|
},
|
|
688
666
|
getInitData: () => stepResults?.input,
|
|
689
|
-
getStepResult: (
|
|
690
|
-
if (!step?.id) {
|
|
691
|
-
return null;
|
|
692
|
-
}
|
|
693
|
-
const result = stepResults[step.id];
|
|
694
|
-
if (result?.status === "success") {
|
|
695
|
-
return result.output;
|
|
696
|
-
}
|
|
697
|
-
return null;
|
|
698
|
-
},
|
|
667
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
699
668
|
// TODO: this function shouldn't have suspend probably?
|
|
700
669
|
suspend: async (_suspendPayload) => {
|
|
701
670
|
},
|
|
@@ -705,11 +674,13 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
705
674
|
abortController?.abort();
|
|
706
675
|
},
|
|
707
676
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
677
|
+
// TODO: add streamVNext support
|
|
678
|
+
[_constants.STREAM_FORMAT_SYMBOL]: executionContext.format,
|
|
708
679
|
engine: { step: this.inngestStep },
|
|
709
680
|
abortSignal: abortController?.signal,
|
|
710
681
|
writer: new tools.ToolStream(
|
|
711
682
|
{
|
|
712
|
-
prefix: "step",
|
|
683
|
+
prefix: "workflow-step",
|
|
713
684
|
callId: stepCallId,
|
|
714
685
|
name: "sleep",
|
|
715
686
|
runId
|
|
@@ -741,6 +712,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
741
712
|
emitter,
|
|
742
713
|
abortController,
|
|
743
714
|
runtimeContext,
|
|
715
|
+
executionContext,
|
|
744
716
|
writableStream,
|
|
745
717
|
tracingContext
|
|
746
718
|
}) {
|
|
@@ -752,7 +724,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
752
724
|
untilDate: date,
|
|
753
725
|
durationMs: date ? Math.max(0, date.getTime() - Date.now()) : void 0,
|
|
754
726
|
sleepType: fn ? "dynamic" : "fixed"
|
|
755
|
-
}
|
|
727
|
+
},
|
|
728
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
756
729
|
});
|
|
757
730
|
if (fn) {
|
|
758
731
|
date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
|
|
@@ -768,16 +741,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
768
741
|
currentSpan: sleepUntilSpan
|
|
769
742
|
},
|
|
770
743
|
getInitData: () => stepResults?.input,
|
|
771
|
-
getStepResult: (
|
|
772
|
-
if (!step?.id) {
|
|
773
|
-
return null;
|
|
774
|
-
}
|
|
775
|
-
const result = stepResults[step.id];
|
|
776
|
-
if (result?.status === "success") {
|
|
777
|
-
return result.output;
|
|
778
|
-
}
|
|
779
|
-
return null;
|
|
780
|
-
},
|
|
744
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
781
745
|
// TODO: this function shouldn't have suspend probably?
|
|
782
746
|
suspend: async (_suspendPayload) => {
|
|
783
747
|
},
|
|
@@ -787,11 +751,13 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
787
751
|
abortController?.abort();
|
|
788
752
|
},
|
|
789
753
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
754
|
+
[_constants.STREAM_FORMAT_SYMBOL]: executionContext.format,
|
|
755
|
+
// TODO: add streamVNext support
|
|
790
756
|
engine: { step: this.inngestStep },
|
|
791
757
|
abortSignal: abortController?.signal,
|
|
792
758
|
writer: new tools.ToolStream(
|
|
793
759
|
{
|
|
794
|
-
prefix: "step",
|
|
760
|
+
prefix: "workflow-step",
|
|
795
761
|
callId: stepCallId,
|
|
796
762
|
name: "sleep",
|
|
797
763
|
runId
|
|
@@ -800,6 +766,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
800
766
|
)
|
|
801
767
|
});
|
|
802
768
|
});
|
|
769
|
+
if (date && !(date instanceof Date)) {
|
|
770
|
+
date = new Date(date);
|
|
771
|
+
}
|
|
803
772
|
const time = !date ? 0 : date.getTime() - Date.now();
|
|
804
773
|
sleepUntilSpan?.update({
|
|
805
774
|
attributes: {
|
|
@@ -838,9 +807,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
838
807
|
emitter,
|
|
839
808
|
abortController,
|
|
840
809
|
runtimeContext,
|
|
810
|
+
tracingContext,
|
|
841
811
|
writableStream,
|
|
842
|
-
disableScorers
|
|
843
|
-
tracingContext
|
|
812
|
+
disableScorers
|
|
844
813
|
}) {
|
|
845
814
|
const stepAISpan = tracingContext?.currentSpan?.createChildSpan({
|
|
846
815
|
name: `workflow step: '${step.id}'`,
|
|
@@ -848,7 +817,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
848
817
|
input: prevOutput,
|
|
849
818
|
attributes: {
|
|
850
819
|
stepId: step.id
|
|
851
|
-
}
|
|
820
|
+
},
|
|
821
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
852
822
|
});
|
|
853
823
|
const startedAt = await this.inngestStep.run(
|
|
854
824
|
`workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
|
|
@@ -876,7 +846,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
876
846
|
eventTimestamp: Date.now()
|
|
877
847
|
});
|
|
878
848
|
await emitter.emit("watch-v2", {
|
|
879
|
-
type: "step-start",
|
|
849
|
+
type: "workflow-step-start",
|
|
880
850
|
payload: {
|
|
881
851
|
id: step.id,
|
|
882
852
|
status: "running",
|
|
@@ -946,7 +916,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
946
916
|
eventTimestamp: Date.now()
|
|
947
917
|
});
|
|
948
918
|
await emitter.emit("watch-v2", {
|
|
949
|
-
type: "step-result",
|
|
919
|
+
type: "workflow-step-result",
|
|
950
920
|
payload: {
|
|
951
921
|
id: step.id,
|
|
952
922
|
status: "failed",
|
|
@@ -981,7 +951,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
981
951
|
eventTimestamp: Date.now()
|
|
982
952
|
});
|
|
983
953
|
await emitter.emit("watch-v2", {
|
|
984
|
-
type: "step-suspended",
|
|
954
|
+
type: "workflow-step-suspended",
|
|
985
955
|
payload: {
|
|
986
956
|
id: step.id,
|
|
987
957
|
status: "suspended"
|
|
@@ -1038,7 +1008,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1038
1008
|
eventTimestamp: Date.now()
|
|
1039
1009
|
});
|
|
1040
1010
|
await emitter.emit("watch-v2", {
|
|
1041
|
-
type: "step-result",
|
|
1011
|
+
type: "workflow-step-result",
|
|
1042
1012
|
payload: {
|
|
1043
1013
|
id: step.id,
|
|
1044
1014
|
status: "success",
|
|
@@ -1046,7 +1016,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1046
1016
|
}
|
|
1047
1017
|
});
|
|
1048
1018
|
await emitter.emit("watch-v2", {
|
|
1049
|
-
type: "step-finish",
|
|
1019
|
+
type: "workflow-step-finish",
|
|
1050
1020
|
payload: {
|
|
1051
1021
|
id: step.id,
|
|
1052
1022
|
metadata: {}
|
|
@@ -1074,13 +1044,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1074
1044
|
currentSpan: stepAISpan
|
|
1075
1045
|
},
|
|
1076
1046
|
getInitData: () => stepResults?.input,
|
|
1077
|
-
getStepResult: (
|
|
1078
|
-
const result2 = stepResults[step2.id];
|
|
1079
|
-
if (result2?.status === "success") {
|
|
1080
|
-
return result2.output;
|
|
1081
|
-
}
|
|
1082
|
-
return null;
|
|
1083
|
-
},
|
|
1047
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
1084
1048
|
suspend: async (suspendPayload) => {
|
|
1085
1049
|
executionContext.suspendedPaths[step.id] = executionContext.executionPath;
|
|
1086
1050
|
suspended = { payload: suspendPayload };
|
|
@@ -1159,7 +1123,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1159
1123
|
});
|
|
1160
1124
|
if (execResults.status === "suspended") {
|
|
1161
1125
|
await emitter.emit("watch-v2", {
|
|
1162
|
-
type: "step-suspended",
|
|
1126
|
+
type: "workflow-step-suspended",
|
|
1163
1127
|
payload: {
|
|
1164
1128
|
id: step.id,
|
|
1165
1129
|
...execResults
|
|
@@ -1167,14 +1131,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1167
1131
|
});
|
|
1168
1132
|
} else {
|
|
1169
1133
|
await emitter.emit("watch-v2", {
|
|
1170
|
-
type: "step-result",
|
|
1134
|
+
type: "workflow-step-result",
|
|
1171
1135
|
payload: {
|
|
1172
1136
|
id: step.id,
|
|
1173
1137
|
...execResults
|
|
1174
1138
|
}
|
|
1175
1139
|
});
|
|
1176
1140
|
await emitter.emit("watch-v2", {
|
|
1177
|
-
type: "step-finish",
|
|
1141
|
+
type: "workflow-step-finish",
|
|
1178
1142
|
payload: {
|
|
1179
1143
|
id: step.id,
|
|
1180
1144
|
metadata: {}
|
|
@@ -1195,7 +1159,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1195
1159
|
workflowId: executionContext.workflowId,
|
|
1196
1160
|
stepId: step.id,
|
|
1197
1161
|
runtimeContext,
|
|
1198
|
-
disableScorers
|
|
1162
|
+
disableScorers,
|
|
1163
|
+
tracingContext: { currentSpan: stepAISpan }
|
|
1199
1164
|
});
|
|
1200
1165
|
}
|
|
1201
1166
|
});
|
|
@@ -1208,6 +1173,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1208
1173
|
workflowId,
|
|
1209
1174
|
runId,
|
|
1210
1175
|
stepResults,
|
|
1176
|
+
resourceId,
|
|
1211
1177
|
executionContext,
|
|
1212
1178
|
serializedStepGraph,
|
|
1213
1179
|
workflowStatus,
|
|
@@ -1220,6 +1186,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1220
1186
|
await this.mastra?.getStorage()?.persistWorkflowSnapshot({
|
|
1221
1187
|
workflowName: workflowId,
|
|
1222
1188
|
runId,
|
|
1189
|
+
resourceId,
|
|
1223
1190
|
snapshot: {
|
|
1224
1191
|
runId,
|
|
1225
1192
|
value: {},
|
|
@@ -1257,11 +1224,12 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1257
1224
|
}) {
|
|
1258
1225
|
const conditionalSpan = tracingContext?.currentSpan?.createChildSpan({
|
|
1259
1226
|
type: aiTracing.AISpanType.WORKFLOW_CONDITIONAL,
|
|
1260
|
-
name: `conditional: ${entry.conditions.length} conditions`,
|
|
1227
|
+
name: `conditional: '${entry.conditions.length} conditions'`,
|
|
1261
1228
|
input: prevOutput,
|
|
1262
1229
|
attributes: {
|
|
1263
1230
|
conditionCount: entry.conditions.length
|
|
1264
|
-
}
|
|
1231
|
+
},
|
|
1232
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
1265
1233
|
});
|
|
1266
1234
|
let execResults;
|
|
1267
1235
|
const truthyIndexes = (await Promise.all(
|
|
@@ -1269,11 +1237,12 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1269
1237
|
(cond, index) => this.inngestStep.run(`workflow.${workflowId}.conditional.${index}`, async () => {
|
|
1270
1238
|
const evalSpan = conditionalSpan?.createChildSpan({
|
|
1271
1239
|
type: aiTracing.AISpanType.WORKFLOW_CONDITIONAL_EVAL,
|
|
1272
|
-
name: `condition ${index}`,
|
|
1240
|
+
name: `condition: '${index}'`,
|
|
1273
1241
|
input: prevOutput,
|
|
1274
1242
|
attributes: {
|
|
1275
1243
|
conditionIndex: index
|
|
1276
|
-
}
|
|
1244
|
+
},
|
|
1245
|
+
tracingPolicy: this.options?.tracingPolicy
|
|
1277
1246
|
});
|
|
1278
1247
|
try {
|
|
1279
1248
|
const result = await cond({
|
|
@@ -1287,16 +1256,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1287
1256
|
currentSpan: evalSpan
|
|
1288
1257
|
},
|
|
1289
1258
|
getInitData: () => stepResults?.input,
|
|
1290
|
-
getStepResult: (
|
|
1291
|
-
if (!step?.id) {
|
|
1292
|
-
return null;
|
|
1293
|
-
}
|
|
1294
|
-
const result2 = stepResults[step.id];
|
|
1295
|
-
if (result2?.status === "success") {
|
|
1296
|
-
return result2.output;
|
|
1297
|
-
}
|
|
1298
|
-
return null;
|
|
1299
|
-
},
|
|
1259
|
+
getStepResult: workflows.getStepResult.bind(this, stepResults),
|
|
1300
1260
|
// TODO: this function shouldn't have suspend probably?
|
|
1301
1261
|
suspend: async (_suspendPayload) => {
|
|
1302
1262
|
},
|
|
@@ -1306,13 +1266,15 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
1306
1266
|
abortController.abort();
|
|
1307
1267
|
},
|
|
1308
1268
|
[_constants.EMITTER_SYMBOL]: emitter,
|
|
1269
|
+
[_constants.STREAM_FORMAT_SYMBOL]: executionContext.format,
|
|
1270
|
+
// TODO: add streamVNext support
|
|
1309
1271
|
engine: {
|
|
1310
1272
|
step: this.inngestStep
|
|
1311
1273
|
},
|
|
1312
1274
|
abortSignal: abortController.signal,
|
|
1313
1275
|
writer: new tools.ToolStream(
|
|
1314
1276
|
{
|
|
1315
|
-
prefix: "step",
|
|
1277
|
+
prefix: "workflow-step",
|
|
1316
1278
|
callId: crypto.randomUUID(),
|
|
1317
1279
|
name: "conditional",
|
|
1318
1280
|
runId
|