@mastra/inngest 1.8.7 → 1.8.8
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 +46 -0
- package/dist/{connect-BC21XS-T.cjs → connect-BllPgt3_.cjs} +104 -22
- package/dist/connect-BllPgt3_.cjs.map +1 -0
- package/dist/{connect-D7Dro-2T.js → connect-Dsxakf92.js} +87 -23
- package/dist/connect-Dsxakf92.js.map +1 -0
- package/dist/connect.cjs +1 -1
- package/dist/connect.js +1 -1
- package/dist/durable-agent/create-inngest-agent.d.ts +13 -0
- package/dist/durable-agent/create-inngest-agent.d.ts.map +1 -1
- package/dist/durable-event-payload.d.ts +88 -0
- package/dist/durable-event-payload.d.ts.map +1 -0
- package/dist/execution-engine.d.ts.map +1 -1
- package/dist/index.cjs +56 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -44
- package/dist/index.js.map +1 -1
- package/dist/nested-workflow-output.d.ts +1 -1
- package/dist/nested-workflow-output.d.ts.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/connect-BC21XS-T.cjs.map +0 -1
- package/dist/connect-D7Dro-2T.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
+
## 1.8.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix durable agent resume targeting and dispatch error handling on Inngest. ([#21742](https://github.com/mastra-ai/mastra/pull/21742))
|
|
8
|
+
|
|
9
|
+
Resume labels (the `toolCallId` a suspended tool call registers) were dropped when a suspension crossed a nested workflow boundary, so `createInngestAgent().resume()` had nothing to target with. It also addressed only the outer step, leaving the engine to guess which suspension inside that step to resume — a guess that fails with `Multiple suspended steps found` when several are parked.
|
|
10
|
+
|
|
11
|
+
Nested suspensions now carry their resume labels up to the parent snapshot, `resume()` accepts a `toolCallId` naming which suspended tool call to resume, and the resume event now addresses the full path down to the suspended leaf instead of just the outer step. If the supplied `toolCallId` is unknown, or if it is omitted while more than one suspension is parked, `resume()` throws immediately and lists the available `toolCallId`s instead of silently resuming the wrong one.
|
|
12
|
+
|
|
13
|
+
`resume()` also awaits acknowledgement of the resume event dispatch before returning, so a failed send rejects the call instead of only surfacing later as a terminal stream error.
|
|
14
|
+
|
|
15
|
+
- Fixed Inngest durable agent runs writing two separate traces. Spans created before the run starts — input processors and memory recall — now nest under the single agent run span instead of being dropped or landing on a second trace, and the agent run span input shows the messages you passed in rather than internal message-list state. (#19841) ([#22118](https://github.com/mastra-ai/mastra/pull/22118))
|
|
16
|
+
|
|
17
|
+
- Fix durable agent dropping the per-call `actor` signal, and centralize durable trigger/resume event construction. ([#22129](https://github.com/mastra-ai/mastra/pull/22129))
|
|
18
|
+
|
|
19
|
+
`createInngestAgent()` accepted an `actor` option on `stream()` but never forwarded it into the workflow trigger event, so authorization checks downstream saw no actor. `resume()` did not accept an `actor` at all. Both now match `InngestRun`: `actor` is supplied per call and is never read back from the persisted snapshot.
|
|
20
|
+
|
|
21
|
+
The trigger and resume event payloads were previously built independently in `run.ts` and in the durable agent wrapper, which is how the two paths drifted apart. Both now build their events through shared helpers so a new per-call signal cannot be added to one path alone.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`79f04a7`](https://github.com/mastra-ai/mastra/commit/79f04a7f6c6829da541139f638f2f1d267916e08), [`65edab1`](https://github.com/mastra-ai/mastra/commit/65edab1c233d17b8f163bad12fca410d0e6f16b1), [`1e47b75`](https://github.com/mastra-ai/mastra/commit/1e47b7520cab4cfaa8daed52f17e2e6d14ff7539), [`ab20a38`](https://github.com/mastra-ai/mastra/commit/ab20a38d0275f8d85e0f3833bd87ef487bcc609f), [`fd4d5fe`](https://github.com/mastra-ai/mastra/commit/fd4d5fe4f943699b85db5e74404f190d5a6b8c2a), [`ae8790c`](https://github.com/mastra-ai/mastra/commit/ae8790c4bfaa088d2ab279d1dcc06f326b9fd109), [`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`48ef1f1`](https://github.com/mastra-ai/mastra/commit/48ef1f1d24eedafbb07f64e659a81b52b67b8bf6), [`aa3a85d`](https://github.com/mastra-ai/mastra/commit/aa3a85daf094c683bb97efdf4b6a696d2e474af5), [`d29d06f`](https://github.com/mastra-ai/mastra/commit/d29d06fe00bbd35b4571150ea04c59d2ed783c71), [`e6516df`](https://github.com/mastra-ai/mastra/commit/e6516dfcdae4f4ac0e7971d84359a81385ee602f), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`dbbfeb8`](https://github.com/mastra-ai/mastra/commit/dbbfeb85ec949dc9ebc0755e1ad262e4f5eba8db), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`0b2a3d1`](https://github.com/mastra-ai/mastra/commit/0b2a3d1783875c5b97b7b36ab3d03d7360e0dde7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`3cc9d00`](https://github.com/mastra-ai/mastra/commit/3cc9d00b2b4333e0377a5e9df5eff92c17ce7630), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`57de7d6`](https://github.com/mastra-ai/mastra/commit/57de7d644ba7146edb4e9e6111ec4fa98c3a59e9), [`c8e4cea`](https://github.com/mastra-ai/mastra/commit/c8e4ceac9a390d78c8327dff3cdb2861dd71957f), [`ed01e9a`](https://github.com/mastra-ai/mastra/commit/ed01e9a807514a904374bf687a7b8f18750f6f78), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`733a537`](https://github.com/mastra-ai/mastra/commit/733a537489a858b5880b2e98809334fba895a221), [`e8e299c`](https://github.com/mastra-ai/mastra/commit/e8e299cc6abdfc39947e2fec25803493015d3882), [`edfc548`](https://github.com/mastra-ai/mastra/commit/edfc548886bc7bae17b681f8b6b41a47eb32bcd2), [`b05f486`](https://github.com/mastra-ai/mastra/commit/b05f48612984d5fe2447ea2d6cdd5c604d285b97), [`a8a4871`](https://github.com/mastra-ai/mastra/commit/a8a4871215f51da95c47129602157ce5372f634a), [`eb9ecaa`](https://github.com/mastra-ai/mastra/commit/eb9ecaa89c36e889749e3b825cfc507ce7f7980b), [`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`9207dfa`](https://github.com/mastra-ai/mastra/commit/9207dfab8062e5fc68b751684797ff86fe0b4e70), [`5165cdc`](https://github.com/mastra-ai/mastra/commit/5165cdcdcf50e144bb8113278535196cc9b07065), [`e737014`](https://github.com/mastra-ai/mastra/commit/e737014e0fc7035759762bb5b48baef1d6c0f6a7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`f591643`](https://github.com/mastra-ai/mastra/commit/f591643becdf0be9bddce6ba1748e64bc30d77f1), [`63796ba`](https://github.com/mastra-ai/mastra/commit/63796ba0fda60253be17535e68f6bbbf1e6ffa09), [`b1ad324`](https://github.com/mastra-ai/mastra/commit/b1ad324d657f3544b0701332aef7eb10e9a36258), [`61c566d`](https://github.com/mastra-ai/mastra/commit/61c566dd2f2cde2b23ed8f139924e530d4202214), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`12c61d2`](https://github.com/mastra-ai/mastra/commit/12c61d280c8cb208bc3c8dbcbe5dcc60cf9d1cd0), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`9ee8120`](https://github.com/mastra-ai/mastra/commit/9ee8120ce17f76b9f617489e05a283353742690a), [`d975e92`](https://github.com/mastra-ai/mastra/commit/d975e924d4936f46c386bd3dee39c671720289f6), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`4e9a228`](https://github.com/mastra-ai/mastra/commit/4e9a2283d5fd6ed1b70a2751eb3dc2cbf82ada20), [`d6ce34a`](https://github.com/mastra-ai/mastra/commit/d6ce34aeceb06ddf3d595a1eed5cc74f481a46a1), [`f95f468`](https://github.com/mastra-ai/mastra/commit/f95f468cf1e7c2b924a13826494f98b8f2ccd581), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`04a815f`](https://github.com/mastra-ai/mastra/commit/04a815fc8971d29e97fcdcc5008a1eb472fc00ff), [`1cfa878`](https://github.com/mastra-ai/mastra/commit/1cfa8784d8da0dfaa0317e5048bc48b6084a5ea5), [`9a12ef3`](https://github.com/mastra-ai/mastra/commit/9a12ef3fccf3f4186db0f294f4ee1f02cf4d8db2), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`7960688`](https://github.com/mastra-ai/mastra/commit/7960688828e04eaf3106e34f7758fa580257eef6), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`63041eb`](https://github.com/mastra-ai/mastra/commit/63041eb4c50b520a0a80e03d4cd6ea99f67715a0), [`c118318`](https://github.com/mastra-ai/mastra/commit/c1183181c9804303db4b511c2e2648f8b714712b), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`fc07c64`](https://github.com/mastra-ai/mastra/commit/fc07c6465043e08e99193a6751a01c56ffc2e7a1), [`cced745`](https://github.com/mastra-ai/mastra/commit/cced745a056ec2225c5bc702e32d848847aa8b65), [`542dee2`](https://github.com/mastra-ai/mastra/commit/542dee254167f974ff8cbbbfc0ce10f9a2616a7b), [`3c19dce`](https://github.com/mastra-ai/mastra/commit/3c19dcef8e73062a80627a4927eae3ec11145afd), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`e6f8450`](https://github.com/mastra-ai/mastra/commit/e6f845074d478527026b18d85031b23353e1d0a4), [`895e9df`](https://github.com/mastra-ai/mastra/commit/895e9dfc17d6f34299eca64e317ded9e5f5e5ef8), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781), [`3e8727e`](https://github.com/mastra-ai/mastra/commit/3e8727e11ec1a5d733acedb5c872896394be18c1)]:
|
|
24
|
+
- @mastra/core@1.62.0
|
|
25
|
+
|
|
26
|
+
## 1.8.8-alpha.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Fix durable agent resume targeting and dispatch error handling on Inngest. ([#21742](https://github.com/mastra-ai/mastra/pull/21742))
|
|
31
|
+
|
|
32
|
+
Resume labels (the `toolCallId` a suspended tool call registers) were dropped when a suspension crossed a nested workflow boundary, so `createInngestAgent().resume()` had nothing to target with. It also addressed only the outer step, leaving the engine to guess which suspension inside that step to resume — a guess that fails with `Multiple suspended steps found` when several are parked.
|
|
33
|
+
|
|
34
|
+
Nested suspensions now carry their resume labels up to the parent snapshot, `resume()` accepts a `toolCallId` naming which suspended tool call to resume, and the resume event now addresses the full path down to the suspended leaf instead of just the outer step. If the supplied `toolCallId` is unknown, or if it is omitted while more than one suspension is parked, `resume()` throws immediately and lists the available `toolCallId`s instead of silently resuming the wrong one.
|
|
35
|
+
|
|
36
|
+
`resume()` also awaits acknowledgement of the resume event dispatch before returning, so a failed send rejects the call instead of only surfacing later as a terminal stream error.
|
|
37
|
+
|
|
38
|
+
- Fixed Inngest durable agent runs writing two separate traces. Spans created before the run starts — input processors and memory recall — now nest under the single agent run span instead of being dropped or landing on a second trace, and the agent run span input shows the messages you passed in rather than internal message-list state. (#19841) ([#22118](https://github.com/mastra-ai/mastra/pull/22118))
|
|
39
|
+
|
|
40
|
+
- Fix durable agent dropping the per-call `actor` signal, and centralize durable trigger/resume event construction. ([#22129](https://github.com/mastra-ai/mastra/pull/22129))
|
|
41
|
+
|
|
42
|
+
`createInngestAgent()` accepted an `actor` option on `stream()` but never forwarded it into the workflow trigger event, so authorization checks downstream saw no actor. `resume()` did not accept an `actor` at all. Both now match `InngestRun`: `actor` is supplied per call and is never read back from the persisted snapshot.
|
|
43
|
+
|
|
44
|
+
The trigger and resume event payloads were previously built independently in `run.ts` and in the durable agent wrapper, which is how the two paths drifted apart. Both now build their events through shared helpers so a new per-call signal cannot be added to one path alone.
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
|
|
47
|
+
- @mastra/core@1.62.0-alpha.3
|
|
48
|
+
|
|
3
49
|
## 1.8.7
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ let _mastra_core_events = require("@mastra/core/events");
|
|
|
9
9
|
let inngest_realtime = require("inngest/realtime");
|
|
10
10
|
let stream_web = require("stream/web");
|
|
11
11
|
let _mastra_core_stream = require("@mastra/core/stream");
|
|
12
|
+
let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
12
13
|
//#region src/nested-workflow-output.ts
|
|
13
14
|
const NESTED_WORKFLOW_OUTPUT_MODE = {
|
|
14
15
|
DEFAULT: "default",
|
|
@@ -52,7 +53,8 @@ function compactNestedWorkflowResult(result) {
|
|
|
52
53
|
case "suspended": return {
|
|
53
54
|
status: result.status,
|
|
54
55
|
steps: result.steps,
|
|
55
|
-
state: result.state
|
|
56
|
+
state: result.state,
|
|
57
|
+
resumeLabels: result.resumeLabels
|
|
56
58
|
};
|
|
57
59
|
case "paused": return {
|
|
58
60
|
status: result.status,
|
|
@@ -356,7 +358,10 @@ var InngestExecutionEngine = class extends _mastra_core_workflows.DefaultExecuti
|
|
|
356
358
|
resumePayload: resume.resumePayload,
|
|
357
359
|
resumePath: nestedResumeStepId ? snapshot?.suspendedPaths?.[nestedResumeStepId] : void 0
|
|
358
360
|
},
|
|
359
|
-
outputOptions: {
|
|
361
|
+
outputOptions: {
|
|
362
|
+
includeState: true,
|
|
363
|
+
includeResumeLabels: true
|
|
364
|
+
},
|
|
360
365
|
nestedWorkflowOutputMode: NESTED_WORKFLOW_OUTPUT_MODE.COMPACT,
|
|
361
366
|
perStep,
|
|
362
367
|
tracingOptions: nestedTracingContext,
|
|
@@ -387,7 +392,10 @@ var InngestExecutionEngine = class extends _mastra_core_workflows.DefaultExecuti
|
|
|
387
392
|
initialState: executionContext.state ?? {},
|
|
388
393
|
requestContext: forwardedRequestContext,
|
|
389
394
|
runId: executionContext.runId,
|
|
390
|
-
outputOptions: {
|
|
395
|
+
outputOptions: {
|
|
396
|
+
includeState: true,
|
|
397
|
+
includeResumeLabels: true
|
|
398
|
+
},
|
|
391
399
|
nestedWorkflowOutputMode: NESTED_WORKFLOW_OUTPUT_MODE.COMPACT,
|
|
392
400
|
perStep,
|
|
393
401
|
tracingOptions: nestedTracingContext,
|
|
@@ -406,7 +414,10 @@ var InngestExecutionEngine = class extends _mastra_core_workflows.DefaultExecuti
|
|
|
406
414
|
initialState: executionContext.state ?? {},
|
|
407
415
|
requestContext: forwardedRequestContext,
|
|
408
416
|
runId: nestedRunId,
|
|
409
|
-
outputOptions: {
|
|
417
|
+
outputOptions: {
|
|
418
|
+
includeState: true,
|
|
419
|
+
includeResumeLabels: true
|
|
420
|
+
},
|
|
410
421
|
nestedWorkflowOutputMode: NESTED_WORKFLOW_OUTPUT_MODE.COMPACT,
|
|
411
422
|
perStep,
|
|
412
423
|
tracingOptions: nestedTracingContext,
|
|
@@ -460,6 +471,16 @@ var InngestExecutionEngine = class extends _mastra_core_workflows.DefaultExecuti
|
|
|
460
471
|
for (const [stepName, stepResult] of suspendedSteps) {
|
|
461
472
|
const suspendPath = [stepName, ...stepResult?.suspendPayload?.__workflow_meta?.path ?? []];
|
|
462
473
|
executionContext.suspendedPaths[step.id] = executionContext.executionPath;
|
|
474
|
+
for (const label of Object.keys(result?.resumeLabels ?? {})) executionContext.resumeLabels[label] = { stepId: step.id };
|
|
475
|
+
const nestedMeta = stepResult?.suspendPayload?.__workflow_meta ?? {};
|
|
476
|
+
const propagatedForeachOutput = Array.isArray(nestedMeta.foreachOutput) ? nestedMeta.foreachOutput.map((entry) => {
|
|
477
|
+
if (entry?.status !== "suspended" || !entry.suspendPayload) return entry;
|
|
478
|
+
const { __streamState: _streamState, ...suspendPayload } = entry.suspendPayload;
|
|
479
|
+
return {
|
|
480
|
+
...entry,
|
|
481
|
+
suspendPayload
|
|
482
|
+
};
|
|
483
|
+
}) : void 0;
|
|
463
484
|
await pubsub.publish(`workflow.events.v2.${executionContext.runId}`, {
|
|
464
485
|
type: "watch",
|
|
465
486
|
runId: executionContext.runId,
|
|
@@ -480,6 +501,8 @@ var InngestExecutionEngine = class extends _mastra_core_workflows.DefaultExecuti
|
|
|
480
501
|
suspendPayload: {
|
|
481
502
|
...stepResult?.suspendPayload,
|
|
482
503
|
__workflow_meta: {
|
|
504
|
+
...nestedMeta,
|
|
505
|
+
...propagatedForeachOutput ? { foreachOutput: propagatedForeachOutput } : {},
|
|
483
506
|
runId,
|
|
484
507
|
path: suspendPath
|
|
485
508
|
}
|
|
@@ -749,6 +772,52 @@ var InngestPubSub = class extends _mastra_core_events.PubSub {
|
|
|
749
772
|
}
|
|
750
773
|
};
|
|
751
774
|
//#endregion
|
|
775
|
+
//#region src/durable-event-payload.ts
|
|
776
|
+
/**
|
|
777
|
+
* Flatten a `RequestContext` into the plain JSON object the event carries.
|
|
778
|
+
* Absent context serializes to `{}`, never `undefined`.
|
|
779
|
+
*/
|
|
780
|
+
function serializeRequestContext(requestContext) {
|
|
781
|
+
const obj = requestContext ? requestContext.toJSON() : {};
|
|
782
|
+
delete obj[_mastra_core_request_context.MASTRA_AUTH_TOKEN_KEY];
|
|
783
|
+
return obj;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Resume request-context rule: values persisted in the snapshot are the base,
|
|
787
|
+
* and anything the caller supplies on this resume call overrides them.
|
|
788
|
+
*/
|
|
789
|
+
function mergeResumeRequestContext(snapshotRequestContext, requestContext) {
|
|
790
|
+
return {
|
|
791
|
+
...snapshotRequestContext ?? {},
|
|
792
|
+
...serializeRequestContext(requestContext)
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
function buildDurableTriggerEventData(args) {
|
|
796
|
+
const { requestContext, ...rest } = args;
|
|
797
|
+
return {
|
|
798
|
+
...rest,
|
|
799
|
+
requestContext: toRequestContextEntries(requestContext)
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function buildDurableResumeEventData(args) {
|
|
803
|
+
const { requestContext, ...rest } = args;
|
|
804
|
+
return {
|
|
805
|
+
...rest,
|
|
806
|
+
requestContext: toRequestContextEntries(requestContext)
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
function buildDurableTimeTravelEventData(args) {
|
|
810
|
+
const { requestContext, ...rest } = args;
|
|
811
|
+
return {
|
|
812
|
+
...rest,
|
|
813
|
+
requestContext: toRequestContextEntries(requestContext)
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function toRequestContextEntries(requestContext) {
|
|
817
|
+
if (!requestContext) return {};
|
|
818
|
+
return typeof requestContext.toJSON === "function" ? serializeRequestContext(requestContext) : requestContext;
|
|
819
|
+
}
|
|
820
|
+
//#endregion
|
|
752
821
|
//#region src/run.ts
|
|
753
822
|
var InngestRun = class extends _mastra_core_workflows.Run {
|
|
754
823
|
inngest;
|
|
@@ -922,17 +991,17 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
922
991
|
const initialStateToUse = await this._validateInitialState(args.initialState ?? {});
|
|
923
992
|
if (!(await this.inngest.send({
|
|
924
993
|
name: `workflow.${this.workflowId}`,
|
|
925
|
-
data: {
|
|
994
|
+
data: buildDurableTriggerEventData({
|
|
926
995
|
inputData: inputDataToUse,
|
|
927
996
|
initialState: initialStateToUse,
|
|
928
997
|
runId: this.runId,
|
|
929
998
|
resourceId: this.resourceId,
|
|
930
999
|
outputOptions: args.outputOptions,
|
|
931
1000
|
tracingOptions: args.tracingOptions,
|
|
932
|
-
requestContext: args.requestContext
|
|
1001
|
+
requestContext: args.requestContext,
|
|
933
1002
|
actor: args.actor,
|
|
934
1003
|
perStep: args.perStep
|
|
935
|
-
}
|
|
1004
|
+
})
|
|
936
1005
|
})).ids[0]) throw new Error("Event ID is not set");
|
|
937
1006
|
return { runId: this.runId };
|
|
938
1007
|
}
|
|
@@ -960,7 +1029,7 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
960
1029
|
const eventName = `workflow.${this.workflowId}`;
|
|
961
1030
|
const eventId = (await this.inngest.send({
|
|
962
1031
|
name: eventName,
|
|
963
|
-
data: {
|
|
1032
|
+
data: buildDurableTriggerEventData({
|
|
964
1033
|
inputData: inputDataToUse,
|
|
965
1034
|
initialState: initialStateToUse,
|
|
966
1035
|
runId: this.runId,
|
|
@@ -968,10 +1037,10 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
968
1037
|
outputOptions,
|
|
969
1038
|
tracingOptions,
|
|
970
1039
|
format,
|
|
971
|
-
requestContext
|
|
1040
|
+
requestContext,
|
|
972
1041
|
actor,
|
|
973
1042
|
perStep
|
|
974
|
-
}
|
|
1043
|
+
})
|
|
975
1044
|
})).ids[0];
|
|
976
1045
|
if (!eventId) throw new Error("Event ID is not set");
|
|
977
1046
|
const result = (await this.getRunOutput(eventId))?.output?.result;
|
|
@@ -1010,12 +1079,7 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
1010
1079
|
else steps = (Array.isArray(stepParam) ? stepParam : [stepParam]).map((step) => typeof step === "string" ? step : step?.id);
|
|
1011
1080
|
const suspendedStep = this.workflowSteps[steps?.[0] ?? ""];
|
|
1012
1081
|
const resumeDataToUse = await this._validateResumeData(params.resumeData, suspendedStep);
|
|
1013
|
-
const
|
|
1014
|
-
const newRequestContext = params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {};
|
|
1015
|
-
const mergedRequestContext = {
|
|
1016
|
-
...persistedRequestContext,
|
|
1017
|
-
...newRequestContext
|
|
1018
|
-
};
|
|
1082
|
+
const mergedRequestContext = mergeResumeRequestContext(snapshot?.requestContext, params.requestContext);
|
|
1019
1083
|
await workflowsStore.persistWorkflowSnapshot({
|
|
1020
1084
|
workflowName: this.workflowId,
|
|
1021
1085
|
runId: this.runId,
|
|
@@ -1032,7 +1096,7 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
1032
1096
|
try {
|
|
1033
1097
|
eventOutput = await this.inngest.send({
|
|
1034
1098
|
name: `workflow.${this.workflowId}`,
|
|
1035
|
-
data: {
|
|
1099
|
+
data: buildDurableResumeEventData({
|
|
1036
1100
|
inputData: resumeDataToUse,
|
|
1037
1101
|
runId: this.runId,
|
|
1038
1102
|
workflowId: this.workflowId,
|
|
@@ -1044,7 +1108,7 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
1044
1108
|
requestContext: mergedRequestContext,
|
|
1045
1109
|
actor: params.actor,
|
|
1046
1110
|
perStep: params.perStep
|
|
1047
|
-
}
|
|
1111
|
+
})
|
|
1048
1112
|
});
|
|
1049
1113
|
} catch (err) {
|
|
1050
1114
|
try {
|
|
@@ -1168,7 +1232,7 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
1168
1232
|
try {
|
|
1169
1233
|
eventOutput = await this.inngest.send({
|
|
1170
1234
|
name: `workflow.${this.workflowId}`,
|
|
1171
|
-
data: {
|
|
1235
|
+
data: buildDurableTimeTravelEventData({
|
|
1172
1236
|
initialState: timeTravelData.state,
|
|
1173
1237
|
runId: this.runId,
|
|
1174
1238
|
workflowId: this.workflowId,
|
|
@@ -1176,10 +1240,10 @@ var InngestRun = class extends _mastra_core_workflows.Run {
|
|
|
1176
1240
|
timeTravel: timeTravelData,
|
|
1177
1241
|
tracingOptions: params.tracingOptions,
|
|
1178
1242
|
outputOptions: params.outputOptions,
|
|
1179
|
-
requestContext: params.requestContext
|
|
1243
|
+
requestContext: params.requestContext,
|
|
1180
1244
|
actor: params.actor,
|
|
1181
1245
|
perStep: params.perStep
|
|
1182
|
-
}
|
|
1246
|
+
})
|
|
1183
1247
|
});
|
|
1184
1248
|
} catch (err) {
|
|
1185
1249
|
if (previousSnapshot) try {
|
|
@@ -1913,6 +1977,18 @@ Object.defineProperty(exports, "InngestWorkflow", {
|
|
|
1913
1977
|
return InngestWorkflow;
|
|
1914
1978
|
}
|
|
1915
1979
|
});
|
|
1980
|
+
Object.defineProperty(exports, "buildDurableResumeEventData", {
|
|
1981
|
+
enumerable: true,
|
|
1982
|
+
get: function() {
|
|
1983
|
+
return buildDurableResumeEventData;
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
Object.defineProperty(exports, "buildDurableTriggerEventData", {
|
|
1987
|
+
enumerable: true,
|
|
1988
|
+
get: function() {
|
|
1989
|
+
return buildDurableTriggerEventData;
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1916
1992
|
Object.defineProperty(exports, "collectInngestFunctions", {
|
|
1917
1993
|
enumerable: true,
|
|
1918
1994
|
get: function() {
|
|
@@ -1925,5 +2001,11 @@ Object.defineProperty(exports, "connect", {
|
|
|
1925
2001
|
return connect;
|
|
1926
2002
|
}
|
|
1927
2003
|
});
|
|
2004
|
+
Object.defineProperty(exports, "mergeResumeRequestContext", {
|
|
2005
|
+
enumerable: true,
|
|
2006
|
+
get: function() {
|
|
2007
|
+
return mergeResumeRequestContext;
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
1928
2010
|
|
|
1929
|
-
//# sourceMappingURL=connect-
|
|
2011
|
+
//# sourceMappingURL=connect-BllPgt3_.cjs.map
|