@mastra/inngest 0.13.2 → 0.13.3-alpha.1

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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 0.13.3-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dependencies updates: ([#7865](https://github.com/mastra-ai/mastra/pull/7865))
8
+ - Updated dependency [`inngest@^3.40.3` ↗︎](https://www.npmjs.com/package/inngest/v/3.40.3) (from `^3.40.2`, in `dependencies`)
9
+
10
+ - Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
11
+
12
+ - fix(workflows/inngest): handle Date serialization in sleepUntil execution ([#7863](https://github.com/mastra-ai/mastra/pull/7863))
13
+
14
+ - add resourceId support to inngest workflow execution engine for workflow snapshot persistance ([#7792](https://github.com/mastra-ai/mastra/pull/7792))
15
+
16
+ - Updated dependencies [[`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
17
+ - @mastra/core@0.17.0-alpha.3
18
+
19
+ ## 0.13.3-alpha.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Added the ability to hide internal ai tracing spans (enabled by default) ([#7764](https://github.com/mastra-ai/mastra/pull/7764))
24
+
25
+ - Updated dependencies [[`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11)]:
26
+ - @mastra/core@0.16.4-alpha.0
27
+
3
28
  ## 0.13.2
4
29
 
5
30
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -54,7 +54,6 @@ var InngestRun = class extends workflows.Run {
54
54
  await new Promise((resolve) => setTimeout(resolve, 1e3));
55
55
  runs = await this.getRuns(eventId);
56
56
  if (runs?.[0]?.status === "Failed") {
57
- console.log("run", runs?.[0]);
58
57
  throw new Error(`Function run ${runs?.[0]?.status}`);
59
58
  } else if (runs?.[0]?.status === "Cancelled") {
60
59
  const snapshot = await this.#mastra?.storage?.loadWorkflowSnapshot({
@@ -87,6 +86,7 @@ var InngestRun = class extends workflows.Run {
87
86
  await this.#mastra?.storage?.persistWorkflowSnapshot({
88
87
  workflowName: this.workflowId,
89
88
  runId: this.runId,
89
+ resourceId: this.resourceId,
90
90
  snapshot: {
91
91
  ...snapshot,
92
92
  status: "canceled"
@@ -100,6 +100,7 @@ var InngestRun = class extends workflows.Run {
100
100
  await this.#mastra.getStorage()?.persistWorkflowSnapshot({
101
101
  workflowName: this.workflowId,
102
102
  runId: this.runId,
103
+ resourceId: this.resourceId,
103
104
  snapshot: {
104
105
  runId: this.runId,
105
106
  serializedStepGraph: this.serializedStepGraph,
@@ -116,7 +117,8 @@ var InngestRun = class extends workflows.Run {
116
117
  name: `workflow.${this.workflowId}`,
117
118
  data: {
118
119
  inputData,
119
- runId: this.runId
120
+ runId: this.runId,
121
+ resourceId: this.resourceId
120
122
  }
121
123
  });
122
124
  const eventId = eventOutput.ids[0];
@@ -204,33 +206,9 @@ var InngestRun = class extends workflows.Run {
204
206
  }
205
207
  stream({ inputData, runtimeContext } = {}) {
206
208
  const { readable, writable } = new TransformStream();
207
- let currentToolData = void 0;
208
209
  const writer = writable.getWriter();
209
210
  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
211
  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
212
  const e = {
235
213
  ...event,
236
214
  type: event.type.replace("workflow-", "")
@@ -336,6 +314,7 @@ 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,
@@ -351,6 +330,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
351
330
  await this.mastra?.getStorage()?.persistWorkflowSnapshot({
352
331
  workflowName: this.id,
353
332
  runId: runIdToUse,
333
+ resourceId: options?.resourceId,
354
334
  snapshot: {
355
335
  runId: runIdToUse,
356
336
  status: "pending",
@@ -384,7 +364,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
384
364
  },
385
365
  { event: `workflow.${this.id}` },
386
366
  async ({ event, step, attempt, publish }) => {
387
- let { inputData, runId, resume } = event.data;
367
+ let { inputData, runId, resourceId, resume } = event.data;
388
368
  if (!runId) {
389
369
  runId = await step.run(`workflow.${this.id}.runIdGen`, async () => {
390
370
  return crypto.randomUUID();
@@ -416,6 +396,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
416
396
  const result = await engine.execute({
417
397
  workflowId: this.id,
418
398
  runId,
399
+ resourceId,
419
400
  graph: this.executionGraph,
420
401
  serializedStepGraph: this.serializedStepGraph,
421
402
  input: inputData,
@@ -463,8 +444,6 @@ function createStep(params) {
463
444
  // @ts-ignore
464
445
  inputSchema: zod.z.object({
465
446
  prompt: zod.z.string()
466
- // resourceId: z.string().optional(),
467
- // threadId: z.string().optional(),
468
447
  }),
469
448
  // @ts-ignore
470
449
  outputSchema: zod.z.object({
@@ -480,13 +459,7 @@ function createStep(params) {
480
459
  name: params.name,
481
460
  args: inputData
482
461
  };
483
- await emitter.emit("watch-v2", {
484
- type: "workflow-agent-call-start",
485
- payload: toolData
486
- });
487
462
  const { fullStream } = await params.stream(inputData.prompt, {
488
- // resourceId: inputData.resourceId,
489
- // threadId: inputData.threadId,
490
463
  runtimeContext,
491
464
  tracingContext,
492
465
  onFinish: (result) => {
@@ -497,12 +470,22 @@ function createStep(params) {
497
470
  if (abortSignal.aborted) {
498
471
  return abort();
499
472
  }
473
+ await emitter.emit("watch-v2", {
474
+ type: "tool-call-streaming-start",
475
+ ...toolData ?? {}
476
+ });
500
477
  for await (const chunk of fullStream) {
501
- await emitter.emit("watch-v2", chunk);
478
+ if (chunk.type === "text-delta") {
479
+ await emitter.emit("watch-v2", {
480
+ type: "tool-call-delta",
481
+ ...toolData ?? {},
482
+ argsTextDelta: chunk.textDelta
483
+ });
484
+ }
502
485
  }
503
486
  await emitter.emit("watch-v2", {
504
- type: "workflow-agent-call-finish",
505
- payload: toolData
487
+ type: "tool-call-streaming-finish",
488
+ ...toolData ?? {}
506
489
  });
507
490
  return {
508
491
  text: await streamPromise.promise
@@ -669,7 +652,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
669
652
  attributes: {
670
653
  durationMs: duration,
671
654
  sleepType: fn ? "dynamic" : "fixed"
672
- }
655
+ },
656
+ isInternal: tracingContext?.isInternal
673
657
  });
674
658
  if (fn) {
675
659
  const stepCallId = crypto.randomUUID();
@@ -682,7 +666,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
682
666
  inputData: prevOutput,
683
667
  runCount: -1,
684
668
  tracingContext: {
685
- currentSpan: sleepSpan
669
+ currentSpan: sleepSpan,
670
+ isInternal: sleepSpan?.isInternal
686
671
  },
687
672
  getInitData: () => stepResults?.input,
688
673
  getStepResult: (step) => {
@@ -754,7 +739,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
754
739
  untilDate: date,
755
740
  durationMs: date ? Math.max(0, date.getTime() - Date.now()) : void 0,
756
741
  sleepType: fn ? "dynamic" : "fixed"
757
- }
742
+ },
743
+ isInternal: tracingContext?.isInternal
758
744
  });
759
745
  if (fn) {
760
746
  date = await this.inngestStep.run(`workflow.${workflowId}.sleepUntil.${entry.id}`, async () => {
@@ -767,7 +753,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
767
753
  inputData: prevOutput,
768
754
  runCount: -1,
769
755
  tracingContext: {
770
- currentSpan: sleepUntilSpan
756
+ currentSpan: sleepUntilSpan,
757
+ isInternal: sleepUntilSpan?.isInternal
771
758
  },
772
759
  getInitData: () => stepResults?.input,
773
760
  getStepResult: (step) => {
@@ -804,6 +791,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
804
791
  )
805
792
  });
806
793
  });
794
+ if (date && !(date instanceof Date)) {
795
+ date = new Date(date);
796
+ }
807
797
  const time = !date ? 0 : date.getTime() - Date.now();
808
798
  sleepUntilSpan?.update({
809
799
  attributes: {
@@ -852,7 +842,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
852
842
  input: prevOutput,
853
843
  attributes: {
854
844
  stepId: step.id
855
- }
845
+ },
846
+ isInternal: tracingContext?.isInternal
856
847
  });
857
848
  const startedAt = await this.inngestStep.run(
858
849
  `workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
@@ -1075,7 +1066,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1075
1066
  inputData: prevOutput,
1076
1067
  resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
1077
1068
  tracingContext: {
1078
- currentSpan: stepAISpan
1069
+ currentSpan: stepAISpan,
1070
+ isInternal: stepAISpan?.isInternal
1079
1071
  },
1080
1072
  getInitData: () => stepResults?.input,
1081
1073
  getStepResult: (step2) => {
@@ -1200,7 +1192,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1200
1192
  stepId: step.id,
1201
1193
  runtimeContext,
1202
1194
  disableScorers,
1203
- tracingContext: { currentSpan: stepAISpan }
1195
+ tracingContext: { currentSpan: stepAISpan, isInternal: true }
1204
1196
  });
1205
1197
  }
1206
1198
  });
@@ -1213,6 +1205,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1213
1205
  workflowId,
1214
1206
  runId,
1215
1207
  stepResults,
1208
+ resourceId,
1216
1209
  executionContext,
1217
1210
  serializedStepGraph,
1218
1211
  workflowStatus,
@@ -1225,6 +1218,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1225
1218
  await this.mastra?.getStorage()?.persistWorkflowSnapshot({
1226
1219
  workflowName: workflowId,
1227
1220
  runId,
1221
+ resourceId,
1228
1222
  snapshot: {
1229
1223
  runId,
1230
1224
  value: {},
@@ -1266,7 +1260,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1266
1260
  input: prevOutput,
1267
1261
  attributes: {
1268
1262
  conditionCount: entry.conditions.length
1269
- }
1263
+ },
1264
+ isInternal: tracingContext?.isInternal
1270
1265
  });
1271
1266
  let execResults;
1272
1267
  const truthyIndexes = (await Promise.all(
@@ -1278,7 +1273,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1278
1273
  input: prevOutput,
1279
1274
  attributes: {
1280
1275
  conditionIndex: index
1281
- }
1276
+ },
1277
+ isInternal: tracingContext?.isInternal
1282
1278
  });
1283
1279
  try {
1284
1280
  const result = await cond({
@@ -1289,7 +1285,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1289
1285
  runCount: -1,
1290
1286
  inputData: prevOutput,
1291
1287
  tracingContext: {
1292
- currentSpan: evalSpan
1288
+ currentSpan: evalSpan,
1289
+ isInternal: evalSpan?.isInternal
1293
1290
  },
1294
1291
  getInitData: () => stepResults?.input,
1295
1292
  getStepResult: (step) => {
@@ -1377,7 +1374,8 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1377
1374
  writableStream,
1378
1375
  disableScorers,
1379
1376
  tracingContext: {
1380
- currentSpan: conditionalSpan
1377
+ currentSpan: conditionalSpan,
1378
+ isInternal: conditionalSpan?.isInternal
1381
1379
  }
1382
1380
  })
1383
1381
  )