@mastra/inngest 0.12.3-alpha.3 → 0.12.3-alpha.5

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
@@ -202,10 +202,38 @@ var InngestRun = class extends Run {
202
202
  }
203
203
  stream({ inputData, runtimeContext } = {}) {
204
204
  const { readable, writable } = new TransformStream();
205
+ let currentToolData = void 0;
205
206
  const writer = writable.getWriter();
206
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
+ }
207
219
  try {
208
- 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);
209
237
  } catch {
210
238
  }
211
239
  }, "watch-v2");
@@ -451,8 +479,8 @@ function createStep(params) {
451
479
  args: inputData
452
480
  };
453
481
  await emitter.emit("watch-v2", {
454
- type: "tool-call-streaming-start",
455
- ...toolData
482
+ type: "workflow-agent-call-start",
483
+ payload: toolData
456
484
  });
457
485
  const { fullStream } = await params.stream(inputData.prompt, {
458
486
  // resourceId: inputData.resourceId,
@@ -468,29 +496,12 @@ function createStep(params) {
468
496
  return abort();
469
497
  }
470
498
  for await (const chunk of fullStream) {
471
- switch (chunk.type) {
472
- case "text-delta":
473
- await emitter.emit("watch-v2", {
474
- type: "tool-call-delta",
475
- ...toolData,
476
- argsTextDelta: chunk.textDelta
477
- });
478
- break;
479
- case "step-start":
480
- case "step-finish":
481
- case "finish":
482
- break;
483
- case "tool-call":
484
- case "tool-result":
485
- case "tool-call-streaming-start":
486
- case "tool-call-delta":
487
- case "source":
488
- case "file":
489
- default:
490
- await emitter.emit("watch-v2", chunk);
491
- break;
492
- }
499
+ await emitter.emit("watch-v2", chunk);
493
500
  }
501
+ await emitter.emit("watch-v2", {
502
+ type: "workflow-agent-call-finish",
503
+ payload: toolData
504
+ });
494
505
  return {
495
506
  text: await streamPromise.promise
496
507
  };
@@ -566,12 +577,12 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
566
577
  }
567
578
  async execute(params) {
568
579
  await params.emitter.emit("watch-v2", {
569
- type: "start",
580
+ type: "workflow-start",
570
581
  payload: { runId: params.runId }
571
582
  });
572
583
  const result = await super.execute(params);
573
584
  await params.emitter.emit("watch-v2", {
574
- type: "finish",
585
+ type: "workflow-finish",
575
586
  payload: { runId: params.runId }
576
587
  });
577
588
  return result;
@@ -694,7 +705,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
694
705
  abortSignal: abortController?.signal,
695
706
  writer: new ToolStream(
696
707
  {
697
- prefix: "step",
708
+ prefix: "workflow-step",
698
709
  callId: stepCallId,
699
710
  name: "sleep",
700
711
  runId
@@ -776,7 +787,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
776
787
  abortSignal: abortController?.signal,
777
788
  writer: new ToolStream(
778
789
  {
779
- prefix: "step",
790
+ prefix: "workflow-step",
780
791
  callId: stepCallId,
781
792
  name: "sleep",
782
793
  runId
@@ -861,7 +872,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
861
872
  eventTimestamp: Date.now()
862
873
  });
863
874
  await emitter.emit("watch-v2", {
864
- type: "step-start",
875
+ type: "workflow-step-start",
865
876
  payload: {
866
877
  id: step.id,
867
878
  status: "running",
@@ -931,7 +942,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
931
942
  eventTimestamp: Date.now()
932
943
  });
933
944
  await emitter.emit("watch-v2", {
934
- type: "step-result",
945
+ type: "workflow-step-result",
935
946
  payload: {
936
947
  id: step.id,
937
948
  status: "failed",
@@ -966,7 +977,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
966
977
  eventTimestamp: Date.now()
967
978
  });
968
979
  await emitter.emit("watch-v2", {
969
- type: "step-suspended",
980
+ type: "workflow-step-suspended",
970
981
  payload: {
971
982
  id: step.id,
972
983
  status: "suspended"
@@ -1023,7 +1034,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1023
1034
  eventTimestamp: Date.now()
1024
1035
  });
1025
1036
  await emitter.emit("watch-v2", {
1026
- type: "step-result",
1037
+ type: "workflow-step-result",
1027
1038
  payload: {
1028
1039
  id: step.id,
1029
1040
  status: "success",
@@ -1031,7 +1042,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1031
1042
  }
1032
1043
  });
1033
1044
  await emitter.emit("watch-v2", {
1034
- type: "step-finish",
1045
+ type: "workflow-step-finish",
1035
1046
  payload: {
1036
1047
  id: step.id,
1037
1048
  metadata: {}
@@ -1144,7 +1155,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1144
1155
  });
1145
1156
  if (execResults.status === "suspended") {
1146
1157
  await emitter.emit("watch-v2", {
1147
- type: "step-suspended",
1158
+ type: "workflow-step-suspended",
1148
1159
  payload: {
1149
1160
  id: step.id,
1150
1161
  ...execResults
@@ -1152,14 +1163,14 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1152
1163
  });
1153
1164
  } else {
1154
1165
  await emitter.emit("watch-v2", {
1155
- type: "step-result",
1166
+ type: "workflow-step-result",
1156
1167
  payload: {
1157
1168
  id: step.id,
1158
1169
  ...execResults
1159
1170
  }
1160
1171
  });
1161
1172
  await emitter.emit("watch-v2", {
1162
- type: "step-finish",
1173
+ type: "workflow-step-finish",
1163
1174
  payload: {
1164
1175
  id: step.id,
1165
1176
  metadata: {}
@@ -1180,7 +1191,6 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1180
1191
  workflowId: executionContext.workflowId,
1181
1192
  stepId: step.id,
1182
1193
  runtimeContext,
1183
- tracingContext: { currentSpan: stepAISpan },
1184
1194
  disableScorers
1185
1195
  });
1186
1196
  }
@@ -1298,7 +1308,7 @@ var InngestExecutionEngine = class extends DefaultExecutionEngine {
1298
1308
  abortSignal: abortController.signal,
1299
1309
  writer: new ToolStream(
1300
1310
  {
1301
- prefix: "step",
1311
+ prefix: "workflow-step",
1302
1312
  callId: randomUUID(),
1303
1313
  name: "conditional",
1304
1314
  runId