@mastra/inngest 0.14.1 → 0.14.2-alpha.0

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,21 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 0.14.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - add register options to serve function ([#8139](https://github.com/mastra-ai/mastra/pull/8139))
8
+
9
+ - Add input data validation to workflow step execution ([#7779](https://github.com/mastra-ai/mastra/pull/7779))
10
+ Add resume data validation to resume workflow method
11
+ Add input data validation to start workflow method
12
+ Use default value from inputSchema/resumeSchema
13
+
14
+ - When step is created from agent or tool, add the description and component key to show that ([#8151](https://github.com/mastra-ai/mastra/pull/8151))
15
+
16
+ - Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5)]:
17
+ - @mastra/core@0.18.1-alpha.0
18
+
3
19
  ## 0.14.1
4
20
 
5
21
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -14,7 +14,8 @@ var zod = require('zod');
14
14
  function serve({
15
15
  mastra,
16
16
  inngest,
17
- functions: userFunctions = []
17
+ functions: userFunctions = [],
18
+ registerOptions
18
19
  }) {
19
20
  const wfs = mastra.getWorkflows();
20
21
  const workflowFunctions = Array.from(
@@ -29,6 +30,7 @@ function serve({
29
30
  )
30
31
  );
31
32
  return hono.serve({
33
+ ...registerOptions,
32
34
  client: inngest,
33
35
  functions: [...workflowFunctions, ...userFunctions]
34
36
  });
@@ -117,10 +119,11 @@ var InngestRun = class extends workflows.Run {
117
119
  status: "running"
118
120
  }
119
121
  });
122
+ const inputDataToUse = await this._validateInput(inputData);
120
123
  const eventOutput = await this.inngest.send({
121
124
  name: `workflow.${this.workflowId}`,
122
125
  data: {
123
- inputData,
126
+ inputData: inputDataToUse,
124
127
  runId: this.runId,
125
128
  resourceId: this.resourceId
126
129
  }
@@ -158,17 +161,19 @@ var InngestRun = class extends workflows.Run {
158
161
  workflowName: this.workflowId,
159
162
  runId: this.runId
160
163
  });
164
+ const suspendedStep = this.workflowSteps[steps?.[0] ?? ""];
165
+ const resumeDataToUse = await this._validateResumeData(params.resumeData, suspendedStep);
161
166
  const eventOutput = await this.inngest.send({
162
167
  name: `workflow.${this.workflowId}`,
163
168
  data: {
164
- inputData: params.resumeData,
169
+ inputData: resumeDataToUse,
165
170
  runId: this.runId,
166
171
  workflowId: this.workflowId,
167
172
  stepResults: snapshot?.context,
168
173
  resume: {
169
174
  steps,
170
175
  stepResults: snapshot?.context,
171
- resumePayload: params.resumeData,
176
+ resumePayload: resumeDataToUse,
172
177
  // @ts-ignore
173
178
  resumePath: snapshot?.suspendedPaths?.[steps?.[0]]
174
179
  }
@@ -315,7 +320,8 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
315
320
  serializedStepGraph: this.serializedStepGraph,
316
321
  mastra: this.#mastra,
317
322
  retryConfig: this.retryConfig,
318
- cleanup: () => this.runs.delete(runIdToUse)
323
+ cleanup: () => this.runs.delete(runIdToUse),
324
+ workflowSteps: this.steps
319
325
  },
320
326
  this.inngest
321
327
  );
@@ -436,6 +442,7 @@ function createStep(params) {
436
442
  if (isAgent(params)) {
437
443
  return {
438
444
  id: params.name,
445
+ description: params.getDescription(),
439
446
  // @ts-ignore
440
447
  inputSchema: zod.z.object({
441
448
  prompt: zod.z.string()
@@ -485,7 +492,8 @@ function createStep(params) {
485
492
  return {
486
493
  text: await streamPromise.promise
487
494
  };
488
- }
495
+ },
496
+ component: params.component
489
497
  };
490
498
  }
491
499
  if (isTool(params)) {
@@ -496,6 +504,7 @@ function createStep(params) {
496
504
  // TODO: tool probably should have strong id type
497
505
  // @ts-ignore
498
506
  id: params.id,
507
+ description: params.description,
499
508
  inputSchema: params.inputSchema,
500
509
  outputSchema: params.outputSchema,
501
510
  execute: async ({ inputData, mastra, runtimeContext, tracingContext, suspend, resumeData }) => {
@@ -507,7 +516,8 @@ function createStep(params) {
507
516
  suspend,
508
517
  resumeData
509
518
  });
510
- }
519
+ },
520
+ component: "TOOL"
511
521
  };
512
522
  }
513
523
  return {
@@ -532,7 +542,8 @@ function init(inngest) {
532
542
  description: step.description,
533
543
  inputSchema: step.inputSchema,
534
544
  outputSchema: step.outputSchema,
535
- execute: step.execute
545
+ execute: step.execute,
546
+ component: step.component
536
547
  };
537
548
  },
538
549
  cloneWorkflow(workflow, opts) {
@@ -822,6 +833,11 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
822
833
  },
823
834
  tracingPolicy: this.options?.tracingPolicy
824
835
  });
836
+ const { inputData, validationError } = await workflows.validateStepInput({
837
+ prevOutput,
838
+ step,
839
+ validateInputs: this.options?.validateInputs ?? false
840
+ });
825
841
  const startedAt = await this.inngestStep.run(
826
842
  `workflow.${executionContext.workflowId}.run.${executionContext.runId}.step.${step.id}.running_ev`,
827
843
  async () => {
@@ -852,7 +868,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
852
868
  payload: {
853
869
  id: step.id,
854
870
  status: "running",
855
- payload: prevOutput,
871
+ payload: inputData,
856
872
  startedAt: startedAt2
857
873
  }
858
874
  });
@@ -872,7 +888,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
872
888
  const invokeResp = await this.inngestStep.invoke(`workflow.${executionContext.workflowId}.step.${step.id}`, {
873
889
  function: step.getFunction(),
874
890
  data: {
875
- inputData: prevOutput,
891
+ inputData,
876
892
  runId,
877
893
  resume: {
878
894
  runId,
@@ -890,7 +906,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
890
906
  const invokeResp = await this.inngestStep.invoke(`workflow.${executionContext.workflowId}.step.${step.id}`, {
891
907
  function: step.getFunction(),
892
908
  data: {
893
- inputData: prevOutput
909
+ inputData
894
910
  }
895
911
  });
896
912
  result = invokeResp.result;
@@ -1035,12 +1051,15 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1035
1051
  let suspended;
1036
1052
  let bailed;
1037
1053
  try {
1054
+ if (validationError) {
1055
+ throw validationError;
1056
+ }
1038
1057
  const result = await step.execute({
1039
1058
  runId: executionContext.runId,
1040
1059
  mastra: this.mastra,
1041
1060
  runtimeContext,
1042
1061
  writableStream,
1043
- inputData: prevOutput,
1062
+ inputData,
1044
1063
  resumeData: resume?.steps[0] === step.id ? resume?.resumePayload : void 0,
1045
1064
  tracingContext: {
1046
1065
  currentSpan: stepAISpan
@@ -1072,14 +1091,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1072
1091
  output: result,
1073
1092
  startedAt,
1074
1093
  endedAt,
1075
- payload: prevOutput,
1094
+ payload: inputData,
1076
1095
  resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
1077
1096
  resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
1078
1097
  };
1079
1098
  } catch (e) {
1080
1099
  execResults = {
1081
1100
  status: "failed",
1082
- payload: prevOutput,
1101
+ payload: inputData,
1083
1102
  error: e instanceof Error ? e.message : String(e),
1084
1103
  endedAt: Date.now(),
1085
1104
  startedAt,
@@ -1091,14 +1110,14 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1091
1110
  execResults = {
1092
1111
  status: "suspended",
1093
1112
  suspendedPayload: suspended.payload,
1094
- payload: prevOutput,
1113
+ payload: inputData,
1095
1114
  suspendedAt: Date.now(),
1096
1115
  startedAt,
1097
1116
  resumedAt: resume?.steps[0] === step.id ? startedAt : void 0,
1098
1117
  resumePayload: resume?.steps[0] === step.id ? resume?.resumePayload : void 0
1099
1118
  };
1100
1119
  } else if (bailed) {
1101
- execResults = { status: "bailed", output: bailed.payload, payload: prevOutput, endedAt: Date.now(), startedAt };
1120
+ execResults = { status: "bailed", output: bailed.payload, payload: inputData, endedAt: Date.now(), startedAt };
1102
1121
  }
1103
1122
  if (execResults.status === "failed") {
1104
1123
  if (executionContext.retryConfig.attempts > 0 && this.inngestAttempts < executionContext.retryConfig.attempts) {
@@ -1156,7 +1175,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
1156
1175
  await this.runScorers({
1157
1176
  scorers: step.scorers,
1158
1177
  runId: executionContext.runId,
1159
- input: prevOutput,
1178
+ input: inputData,
1160
1179
  output: stepRes.result,
1161
1180
  workflowId: executionContext.workflowId,
1162
1181
  stepId: step.id,