@mastra/inngest 0.0.0-cloudflare-deployer-dont-install-deps-20250714111754 → 0.0.0-consolidate-changesets-20250904042643

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/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { randomUUID } from 'crypto';
2
2
  import { subscribe } from '@inngest/realtime';
3
+ import { wrapMastra, AISpanType } from '@mastra/core/ai-tracing';
3
4
  import { RuntimeContext } from '@mastra/core/di';
4
- import { Tool } from '@mastra/core/tools';
5
+ import { ToolStream, Tool } from '@mastra/core/tools';
5
6
  import { Run, Workflow, DefaultExecutionEngine } from '@mastra/core/workflows';
6
7
  import { EMITTER_SYMBOL } from '@mastra/core/workflows/_constants';
7
8
  import { serve as serve$1 } from 'inngest/hono';
@@ -104,6 +105,7 @@ var InngestRun = class extends Run {
104
105
  context: {},
105
106
  activePaths: [],
106
107
  suspendedPaths: {},
108
+ waitingPaths: {},
107
109
  timestamp: Date.now(),
108
110
  status: "running"
109
111
  }
@@ -153,6 +155,7 @@ var InngestRun = class extends Run {
153
155
  data: {
154
156
  inputData: params.resumeData,
155
157
  runId: this.runId,
158
+ workflowId: this.workflowId,
156
159
  stepResults: snapshot?.context,
157
160
  resume: {
158
161
  steps,
@@ -199,10 +202,38 @@ var InngestRun = class extends Run {
199
202
  }
200
203
  stream({ inputData, runtimeContext } = {}) {
201
204
  const { readable, writable } = new TransformStream();
205
+ let currentToolData = void 0;
202
206
  const writer = writable.getWriter();
203
207
  const unwatch = this.watch(async (event) => {
208
+ if (event.type === "workflow-agent-call-start") {
209
+ currentToolData = {
210
+ name: event.payload.name,
211
+ args: event.payload.args
212
+ };
213
+ await writer.write({
214
+ ...event.payload,
215
+ type: "tool-call-streaming-start"
216
+ });
217
+ return;
218
+ }
204
219
  try {
205
- await writer.write(event);
220
+ if (event.type === "workflow-agent-call-finish") {
221
+ return;
222
+ } else if (!event.type.startsWith("workflow-")) {
223
+ if (event.type === "text-delta") {
224
+ await writer.write({
225
+ type: "tool-call-delta",
226
+ ...currentToolData ?? {},
227
+ argsTextDelta: event.textDelta
228
+ });
229
+ }
230
+ return;
231
+ }
232
+ const e = {
233
+ ...event,
234
+ type: event.type.replace("workflow-", "")
235
+ };
236
+ await writer.write(e);
206
237
  } catch {
207
238
  }
208
239
  }, "watch-v2");
@@ -233,8 +264,14 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
233
264
  #mastra;
234
265
  inngest;
235
266
  function;
267
+ flowControlConfig;
236
268
  constructor(params, inngest) {
237
- super(params);
269
+ const { concurrency, rateLimit, throttle, debounce, priority, ...workflowParams } = params;
270
+ super(workflowParams);
271
+ const flowControlEntries = Object.entries({ concurrency, rateLimit, throttle, debounce, priority }).filter(
272
+ ([_, value]) => value !== void 0
273
+ );
274
+ this.flowControlConfig = flowControlEntries.length > 0 ? Object.fromEntries(flowControlEntries) : void 0;
238
275
  this.#mastra = params.mastra;
239
276
  this.inngest = inngest;
240
277
  }
@@ -255,27 +292,6 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
255
292
  const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
256
293
  return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
257
294
  }
258
- async getWorkflowRunExecutionResult(runId) {
259
- const storage = this.#mastra?.getStorage();
260
- if (!storage) {
261
- this.logger.debug("Cannot get workflow run execution result. Mastra storage is not initialized");
262
- return null;
263
- }
264
- const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
265
- if (!run?.snapshot) {
266
- return null;
267
- }
268
- if (typeof run.snapshot === "string") {
269
- return null;
270
- }
271
- return {
272
- status: run.snapshot.status,
273
- result: run.snapshot.result,
274
- error: run.snapshot.error,
275
- payload: run.snapshot.context?.input,
276
- steps: run.snapshot.context
277
- };
278
- }
279
295
  __registerMastra(mastra) {
280
296
  this.#mastra = mastra;
281
297
  this.executionEngine.__registerMastra(mastra);
@@ -328,7 +344,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
328
344
  this.inngest
329
345
  );
330
346
  this.runs.set(runIdToUse, run);
331
- const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse);
347
+ const workflowSnapshotInStorage = await this.getWorkflowRunExecutionResult(runIdToUse, false);
332
348
  if (!workflowSnapshotInStorage) {
333
349
  await this.mastra?.getStorage()?.persistWorkflowSnapshot({
334
350
  workflowName: this.id,
@@ -339,6 +355,7 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
339
355
  value: {},
340
356
  context: {},
341
357
  activePaths: [],
358
+ waitingPaths: {},
342
359
  serializedStepGraph: this.serializedStepGraph,
343
360
  suspendedPaths: {},
344
361
  result: void 0,
@@ -359,7 +376,9 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
359
376
  id: `workflow.${this.id}`,
360
377
  // @ts-ignore
361
378
  retries: this.retryConfig?.attempts ?? 0,
362
- cancelOn: [{ event: `cancel.workflow.${this.id}` }]
379
+ cancelOn: [{ event: `cancel.workflow.${this.id}` }],
380
+ // Spread flow control configuration
381
+ ...this.flowControlConfig
363
382
  },
364
383
  { event: `workflow.${this.id}` },
365
384
  async ({ event, step, attempt, publish }) => {
@@ -403,7 +422,9 @@ var InngestWorkflow = class _InngestWorkflow extends Workflow {
403
422
  runtimeContext: new RuntimeContext(),
404
423
  // TODO
405
424
  resume,
406
- abortController: new AbortController()
425
+ abortController: new AbortController(),
426
+ currentSpan: void 0
427
+ // TODO: Pass actual parent AI span from workflow execution context
407
428
  });
408
429
  return { result, runId };
409
430
  }
@@ -447,7 +468,7 @@ function createStep(params) {
447
468
  outputSchema: z.object({
448
469
  text: z.string()
449
470
  }),
450
- execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext, abortSignal, abort }) => {
471
+ execute: async ({ inputData, [EMITTER_SYMBOL]: emitter, runtimeContext, abortSignal, abort, tracingContext }) => {
451
472
  let streamPromise = {};
452
473
  streamPromise.promise = new Promise((resolve, reject) => {
453
474
  streamPromise.resolve = resolve;
@@ -458,13 +479,14 @@ function createStep(params) {
458
479
  args: inputData
459
480
  };
460
481
  await emitter.emit("watch-v2", {
461
- type: "tool-call-streaming-start",
462
- ...toolData
482
+ type: "workflow-agent-call-start",
483
+ payload: toolData
463
484
  });
464
485
  const { fullStream } = await params.stream(inputData.prompt, {
465
486
  // resourceId: inputData.resourceId,
466
487
  // threadId: inputData.threadId,
467
488
  runtimeContext,
489
+ tracingContext,
468
490
  onFinish: (result) => {
469
491
  streamPromise.resolve(result.text);
470
492
  },
@@ -474,29 +496,12 @@ function createStep(params) {
474
496
  return abort();
475
497
  }
476
498
  for await (const chunk of fullStream) {
477
- switch (chunk.type) {
478
- case "text-delta":
479
- await emitter.emit("watch-v2", {
480
- type: "tool-call-delta",
481
- ...toolData,
482
- argsTextDelta: chunk.textDelta
483
- });
484
- break;
485
- case "step-start":
486
- case "step-finish":
487
- case "finish":
488
- break;
489
- case "tool-call":
490
- case "tool-result":
491
- case "tool-call-streaming-start":
492
- case "tool-call-delta":
493
- case "source":
494
- case "file":
495
- default:
496
- await emitter.emit("watch-v2", chunk);
497
- break;
498
- }
499
+ await emitter.emit("watch-v2", chunk);
499
500
  }
501
+ await emitter.emit("watch-v2", {
502
+ type: "workflow-agent-call-finish",
503
+ payload: toolData
504
+ });
500
505
  return {
501
506
  text: await streamPromise.promise
502
507
  };
@@ -513,11 +518,12 @@ function createStep(params) {
513
518
  id: params.id,
514
519
  inputSchema: params.inputSchema,
515
520
  outputSchema: params.outputSchema,
516
- execute: async ({ inputData, mastra, runtimeContext }) => {
521
+ execute: async ({ inputData, mastra, runtimeContext, tracingContext }) => {
517
522
  return params.execute({
518
523
  context: inputData,
519
- mastra,
520
- runtimeContext
524
+ mastra: wrapMastra(mastra, tracingContext),
525
+ runtimeContext,
526
+ tracingContext
521
527
  });
522
528
  }
523
529
  };
@@ -571,12 +577,12 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
571
577
  }
572
578
  async execute(params) {
573
579
  await params.emitter.emit("watch-v2", {
574
- type: "start",
580
+ type: "workflow-start",
575
581
  payload: { runId: params.runId }
576
582
  });
577
583
  const result = await super.execute(params);
578
584
  await params.emitter.emit("watch-v2", {
579
- type: "finish",
585
+ type: "workflow-finish",
580
586
  payload: { runId: params.runId }
581
587
  });
582
588
  return result;
@@ -638,31 +644,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
638
644
  executionSpan?.end();
639
645
  return base;
640
646
  }
641
- async superExecuteStep({
642
- workflowId,
643
- runId,
644
- step,
645
- stepResults,
646
- executionContext,
647
- resume,
648
- prevOutput,
649
- emitter,
650
- abortController,
651
- runtimeContext
652
- }) {
653
- return super.executeStep({
654
- workflowId,
655
- runId,
656
- step,
657
- stepResults,
658
- executionContext,
659
- resume,
660
- prevOutput,
661
- emitter,
662
- abortController,
663
- runtimeContext
664
- });
665
- }
666
647
  // async executeSleep({ id, duration }: { id: string; duration: number }): Promise<void> {
667
648
  // await this.inngestStep.sleep(id, duration);
668
649
  // }
@@ -674,17 +655,32 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
674
655
  stepResults,
675
656
  emitter,
676
657
  abortController,
677
- runtimeContext
658
+ runtimeContext,
659
+ writableStream,
660
+ tracingContext
678
661
  }) {
679
662
  let { duration, fn } = entry;
663
+ const sleepSpan = tracingContext?.currentSpan?.createChildSpan({
664
+ type: AISpanType.WORKFLOW_SLEEP,
665
+ name: `sleep: ${duration ? `${duration}ms` : "dynamic"}`,
666
+ attributes: {
667
+ durationMs: duration,
668
+ sleepType: fn ? "dynamic" : "fixed"
669
+ }
670
+ });
680
671
  if (fn) {
672
+ const stepCallId = randomUUID();
681
673
  duration = await this.inngestStep.run(`workflow.${workflowId}.sleep.${entry.id}`, async () => {
682
674
  return await fn({
683
675
  runId,
676
+ workflowId,
684
677
  mastra: this.mastra,
685
678
  runtimeContext,
686
679
  inputData: prevOutput,
687
680
  runCount: -1,
681
+ tracingContext: {
682
+ currentSpan: sleepSpan
683
+ },
688
684
  getInitData: () => stepResults?.input,
689
685
  getStepResult: (step) => {
690
686
  if (!step?.id) {
@@ -706,11 +702,31 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
706
702
  },
707
703
  [EMITTER_SYMBOL]: emitter,
708
704
  engine: { step: this.inngestStep },
709
- abortSignal: abortController?.signal
705
+ abortSignal: abortController?.signal,
706
+ writer: new ToolStream(
707
+ {
708
+ prefix: "workflow-step",
709
+ callId: stepCallId,
710
+ name: "sleep",
711
+ runId
712
+ },
713
+ writableStream
714
+ )
710
715
  });
711
716
  });
717
+ sleepSpan?.update({
718
+ attributes: {
719
+ durationMs: duration
720
+ }
721
+ });
722
+ }
723
+ try {
724
+ await this.inngestStep.sleep(entry.id, !duration || duration < 0 ? 0 : duration);
725
+ sleepSpan?.end();
726
+ } catch (e) {
727
+ sleepSpan?.error({ error: e });
728
+ throw e;
712
729
  }
713
- await this.inngestStep.sleep(entry.id, !duration || duration < 0 ? 0 : duration);
714
730
  }
715
731
  async executeSleepUntil({
716
732
  workflowId,
@@ -720,17 +736,33 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
720
736
  stepResults,
721
737
  emitter,
722
738
  abortController,
723
- runtimeContext
739
+ runtimeContext,
740
+ writableStream,
741
+ tracingContext
724
742
  }) {
725
743
  let { date, fn } = entry;
744
+ const sleepUntilSpan = tracingContext?.currentSpan?.createChildSpan({
745
+ type: AISpanType.WORKFLOW_SLEEP,
746
+ name: `sleepUntil: ${date ? date.toISOString() : "dynamic"}`,
747
+ attributes: {
748
+ untilDate: date,
749
+ durationMs: date ? Math.max(0, date.getTime() - Date.now()) : void 0,
750
+ sleepType: fn ? "dynamic" : "fixed"
751
+ }
752
+ });
726
753
  if (fn) {
727
754
  date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
755
+ const stepCallId = randomUUID();
728
756
  return await fn({
729
757
  runId,
758
+ workflowId,
730
759
  mastra: this.mastra,
731
760
  runtimeContext,
732
761
  inputData: prevOutput,
733
762
  runCount: -1,
763
+ tracingContext: {
764
+ currentSpan: sleepUntilSpan
765
+ },
734
766
  getInitData: () => stepResults?.input,
735
767
  getStepResult: (step) => {
736
768
  if (!step?.id) {
@@ -752,14 +784,36 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
752
784
  },
753
785
  [EMITTER_SYMBOL]: emitter,
754
786
  engine: { step: this.inngestStep },
755
- abortSignal: abortController?.signal
787
+ abortSignal: abortController?.signal,
788
+ writer: new ToolStream(
789
+ {
790
+ prefix: "workflow-step",
791
+ callId: stepCallId,
792
+ name: "sleep",
793
+ runId
794
+ },
795
+ writableStream
796
+ )
756
797
  });
757
798
  });
799
+ const time = !date ? 0 : date.getTime() - Date.now();
800
+ sleepUntilSpan?.update({
801
+ attributes: {
802
+ durationMs: Math.max(0, time)
803
+ }
804
+ });
758
805
  }
759
806
  if (!(date instanceof Date)) {
807
+ sleepUntilSpan?.end();
760
808
  return;
761
809
  }
762
- await this.inngestStep.sleepUntil(entry.id, date);
810
+ try {
811
+ await this.inngestStep.sleepUntil(entry.id, date);
812
+ sleepUntilSpan?.end();
813
+ } catch (e) {
814
+ sleepUntilSpan?.error({ error: e });
815
+ throw e;
816
+ }
763
817
  }
764
818
  async executeWaitForEvent({ event, timeout }) {
765
819
  const eventData = await this.inngestStep.waitForEvent(`user-event-${event}`, {
@@ -779,8 +833,19 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
779
833
  prevOutput,
780
834
  emitter,
781
835
  abortController,
782
- runtimeContext
836
+ runtimeContext,
837
+ tracingContext,
838
+ writableStream,
839
+ disableScorers
783
840
  }) {
841
+ const stepAISpan = tracingContext?.currentSpan?.createChildSpan({
842
+ name: `workflow step: '${step.id}'`,
843
+ type: AISpanType.WORKFLOW_STEP,
844
+ input: prevOutput,
845
+ attributes: {
846
+ stepId: step.id
847
+ }
848
+ });
784
849
  const startedAt = await this.inngestStep.run(
785
850
  `workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
786
851
  async () => {
@@ -807,7 +872,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
807
872
  eventTimestamp: Date.now()
808
873
  });
809
874
  await emitter.emit("watch-v2", {
810
- type: "step-start",
875
+ type: "workflow-step-start",
811
876
  payload: {
812
877
  id: step.id,
813
878
  status: "running",
@@ -877,7 +942,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
877
942
  eventTimestamp: Date.now()
878
943
  });
879
944
  await emitter.emit("watch-v2", {
880
- type: "step-result",
945
+ type: "workflow-step-result",
881
946
  payload: {
882
947
  id: step.id,
883
948
  status: "failed",
@@ -912,7 +977,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
912
977
  eventTimestamp: Date.now()
913
978
  });
914
979
  await emitter.emit("watch-v2", {
915
- type: "step-suspended",
980
+ type: "workflow-step-suspended",
916
981
  payload: {
917
982
  id: step.id,
918
983
  status: "suspended"
@@ -969,7 +1034,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
969
1034
  eventTimestamp: Date.now()
970
1035
  });
971
1036
  await emitter.emit("watch-v2", {
972
- type: "step-result",
1037
+ type: "workflow-step-result",
973
1038
  payload: {
974
1039
  id: step.id,
975
1040
  status: "success",
@@ -977,7 +1042,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
977
1042
  }
978
1043
  });
979
1044
  await emitter.emit("watch-v2", {
980
- type: "step-finish",
1045
+ type: "workflow-step-finish",
981
1046
  payload: {
982
1047
  id: step.id,
983
1048
  metadata: {}
@@ -998,8 +1063,12 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
998
1063
  runId: executionContext.runId,
999
1064
  mastra: this.mastra,
1000
1065
  runtimeContext,
1066
+ writableStream,
1001
1067
  inputData: prevOutput,
1002
1068
  resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
1069
+ tracingContext: {
1070
+ currentSpan: stepAISpan
1071
+ },
1003
1072
  getInitData: () => stepResults?.input,
1004
1073
  getStepResult: (step2) => {
1005
1074
  const result2 = stepResults[step2.id];
@@ -1063,7 +1132,9 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1063
1132
  }
1064
1133
  if (execResults.status === "failed") {
1065
1134
  if (executionContext.retryConfig.attempts > 0 && this.inngestAttempts < executionContext.retryConfig.attempts) {
1066
- throw execResults.error;
1135
+ const error = new Error(execResults.error);
1136
+ stepAISpan?.error({ error });
1137
+ throw error;
1067
1138
  }
1068
1139
  }
1069
1140
  await emitter.emit("watch", {
@@ -1084,7 +1155,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1084
1155
  });
1085
1156
  if (execResults.status === "suspended") {
1086
1157
  await emitter.emit("watch-v2", {
1087
- type: "step-suspended",
1158
+ type: "workflow-step-suspended",
1088
1159
  payload: {
1089
1160
  id: step.id,
1090
1161
  ...execResults
@@ -1092,22 +1163,39 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1092
1163
  });
1093
1164
  } else {
1094
1165
  await emitter.emit("watch-v2", {
1095
- type: "step-result",
1166
+ type: "workflow-step-result",
1096
1167
  payload: {
1097
1168
  id: step.id,
1098
1169
  ...execResults
1099
1170
  }
1100
1171
  });
1101
1172
  await emitter.emit("watch-v2", {
1102
- type: "step-finish",
1173
+ type: "workflow-step-finish",
1103
1174
  payload: {
1104
1175
  id: step.id,
1105
1176
  metadata: {}
1106
1177
  }
1107
1178
  });
1108
1179
  }
1180
+ stepAISpan?.end({ output: execResults });
1109
1181
  return { result: execResults, executionContext, stepResults };
1110
1182
  });
1183
+ if (disableScorers !== false) {
1184
+ await this.inngestStep.run(`workflow.${executionContext.workflowId}.step.${step.id}.score`, async () => {
1185
+ if (step.scorers) {
1186
+ await this.runScorers({
1187
+ scorers: step.scorers,
1188
+ runId: executionContext.runId,
1189
+ input: prevOutput,
1190
+ output: stepRes.result,
1191
+ workflowId: executionContext.workflowId,
1192
+ stepId: step.id,
1193
+ runtimeContext,
1194
+ disableScorers
1195
+ });
1196
+ }
1197
+ });
1198
+ }
1111
1199
  Object.assign(executionContext.suspendedPaths, stepRes.executionContext.suspendedPaths);
1112
1200
  Object.assign(stepResults, stepRes.stepResults);
1113
1201
  return stepRes.result;
@@ -1134,6 +1222,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1134
1222
  context: stepResults,
1135
1223
  activePaths: [],
1136
1224
  suspendedPaths: executionContext.suspendedPaths,
1225
+ waitingPaths: {},
1137
1226
  serializedStepGraph,
1138
1227
  status: workflowStatus,
1139
1228
  result,
@@ -1157,19 +1246,42 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1157
1246
  executionContext,
1158
1247
  emitter,
1159
1248
  abortController,
1160
- runtimeContext
1249
+ runtimeContext,
1250
+ writableStream,
1251
+ disableScorers,
1252
+ tracingContext
1161
1253
  }) {
1254
+ const conditionalSpan = tracingContext?.currentSpan?.createChildSpan({
1255
+ type: AISpanType.WORKFLOW_CONDITIONAL,
1256
+ name: `conditional: ${entry.conditions.length} conditions`,
1257
+ input: prevOutput,
1258
+ attributes: {
1259
+ conditionCount: entry.conditions.length
1260
+ }
1261
+ });
1162
1262
  let execResults;
1163
1263
  const truthyIndexes = (await Promise.all(
1164
1264
  entry.conditions.map(
1165
1265
  (cond, index) => this.inngestStep.run(`workflow.${workflowId}.conditional.${index}`, async () => {
1266
+ const evalSpan = conditionalSpan?.createChildSpan({
1267
+ type: AISpanType.WORKFLOW_CONDITIONAL_EVAL,
1268
+ name: `condition ${index}`,
1269
+ input: prevOutput,
1270
+ attributes: {
1271
+ conditionIndex: index
1272
+ }
1273
+ });
1166
1274
  try {
1167
1275
  const result = await cond({
1168
1276
  runId,
1277
+ workflowId,
1169
1278
  mastra: this.mastra,
1170
1279
  runtimeContext,
1171
1280
  runCount: -1,
1172
1281
  inputData: prevOutput,
1282
+ tracingContext: {
1283
+ currentSpan: evalSpan
1284
+ },
1173
1285
  getInitData: () => stepResults?.input,
1174
1286
  getStepResult: (step) => {
1175
1287
  if (!step?.id) {
@@ -1193,26 +1305,53 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1193
1305
  engine: {
1194
1306
  step: this.inngestStep
1195
1307
  },
1196
- abortSignal: abortController.signal
1308
+ abortSignal: abortController.signal,
1309
+ writer: new ToolStream(
1310
+ {
1311
+ prefix: "workflow-step",
1312
+ callId: randomUUID(),
1313
+ name: "conditional",
1314
+ runId
1315
+ },
1316
+ writableStream
1317
+ )
1318
+ });
1319
+ evalSpan?.end({
1320
+ output: result,
1321
+ attributes: {
1322
+ result: !!result
1323
+ }
1197
1324
  });
1198
1325
  return result ? index : null;
1199
1326
  } catch (e) {
1327
+ evalSpan?.error({
1328
+ error: e instanceof Error ? e : new Error(String(e)),
1329
+ attributes: {
1330
+ result: false
1331
+ }
1332
+ });
1200
1333
  return null;
1201
1334
  }
1202
1335
  })
1203
1336
  )
1204
1337
  )).filter((index) => index !== null);
1205
1338
  const stepsToRun = entry.steps.filter((_, index) => truthyIndexes.includes(index));
1339
+ conditionalSpan?.update({
1340
+ attributes: {
1341
+ truthyIndexes,
1342
+ selectedSteps: stepsToRun.map((s) => s.type === "step" ? s.step.id : `control-${s.type}`)
1343
+ }
1344
+ });
1206
1345
  const results = await Promise.all(
1207
1346
  stepsToRun.map(
1208
1347
  (step, index) => this.executeEntry({
1209
1348
  workflowId,
1210
1349
  runId,
1211
1350
  entry: step,
1351
+ serializedStepGraph,
1212
1352
  prevStep,
1213
1353
  stepResults,
1214
1354
  resume,
1215
- serializedStepGraph,
1216
1355
  executionContext: {
1217
1356
  workflowId,
1218
1357
  runId,
@@ -1223,7 +1362,12 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1223
1362
  },
1224
1363
  emitter,
1225
1364
  abortController,
1226
- runtimeContext
1365
+ runtimeContext,
1366
+ writableStream,
1367
+ disableScorers,
1368
+ tracingContext: {
1369
+ currentSpan: conditionalSpan
1370
+ }
1227
1371
  })
1228
1372
  )
1229
1373
  );
@@ -1244,8 +1388,19 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1244
1388
  }, {})
1245
1389
  };
1246
1390
  }
1391
+ if (execResults.status === "failed") {
1392
+ conditionalSpan?.error({
1393
+ error: new Error(execResults.error)
1394
+ });
1395
+ } else {
1396
+ conditionalSpan?.end({
1397
+ output: execResults.output || execResults
1398
+ });
1399
+ }
1247
1400
  return execResults;
1248
1401
  }
1249
1402
  };
1250
1403
 
1251
1404
  export { InngestExecutionEngine, InngestRun, InngestWorkflow, createStep, init, serve };
1405
+ //# sourceMappingURL=index.js.map
1406
+ //# sourceMappingURL=index.js.map