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