@mastra/inngest 1.3.0 → 1.4.0-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 +75 -0
- package/dist/__tests__/adapters/_utils.d.ts +2 -2
- package/dist/__tests__/durable-agent.test.utils.d.ts.map +1 -1
- package/dist/durable-agent/create-inngest-agent.d.ts +0 -2
- package/dist/durable-agent/create-inngest-agent.d.ts.map +1 -1
- package/dist/durable-agent/index.d.ts +0 -2
- package/dist/durable-agent/index.d.ts.map +1 -1
- package/dist/index.cjs +169 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +169 -151
- package/dist/index.js.map +1 -1
- package/dist/pubsub.d.ts +7 -14
- package/dist/pubsub.d.ts.map +1 -1
- package/dist/run.d.ts +1 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/serve.d.ts +4 -3
- package/dist/serve.d.ts.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/workflow.d.ts +2 -22
- package/dist/workflow.d.ts.map +1 -1
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
+
## 1.4.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Updated `@mastra/inngest` to use Inngest SDK v4. ([#15377](https://github.com/mastra-ai/mastra/pull/15377))
|
|
8
|
+
|
|
9
|
+
**Breaking:** Requires `inngest@^4` and Inngest Dev Server `v1.18.0` or later. The `@inngest/realtime` package is no longer needed — its functionality is now included in `inngest` v4. Remove it from your dependencies and import realtime helpers from `inngest/realtime` instead.
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
// package.json
|
|
13
|
+
"dependencies": {
|
|
14
|
+
- "@inngest/realtime": "^0.x",
|
|
15
|
+
- "inngest": "^3.x"
|
|
16
|
+
+ "inngest": "^4.0.0"
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```diff
|
|
21
|
+
- import { realtimeMiddleware } from '@inngest/realtime/middleware';
|
|
22
|
+
- import { subscribe } from '@inngest/realtime';
|
|
23
|
+
+ import { subscribe } from 'inngest/realtime';
|
|
24
|
+
|
|
25
|
+
const inngest = new Inngest({
|
|
26
|
+
id: 'mastra',
|
|
27
|
+
- middleware: [realtimeMiddleware()],
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
In v4, `subscribe()` and `realtime.publish()` are first-class methods on the client; the standalone middleware is no longer required. `InngestPubSub` publishes via `inngest.realtime.publish()` instead of the function-context `publish` argument that no longer exists in v4, restoring realtime workflow events and agent stream events.
|
|
32
|
+
|
|
33
|
+
**Improved:** Workflow result polling now uses snapshot-based polling, resulting in significantly faster retrieval (~83x).
|
|
34
|
+
|
|
35
|
+
## 1.3.1-alpha.0
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Fixed peer dependency ranges so packages that use the Mastra server require a compatible Mastra core version. ([#16208](https://github.com/mastra-ai/mastra/pull/16208))
|
|
40
|
+
|
|
41
|
+
- Updated the `serve` and `createServe` JSDoc adapter examples to register Inngest at `/inngest/api` instead of `/api/inngest`, matching the Inngest deployment guide and in-repo example projects. ([#16186](https://github.com/mastra-ai/mastra/pull/16186))
|
|
42
|
+
|
|
43
|
+
**Why**
|
|
44
|
+
|
|
45
|
+
Mastra reserves the `/api` prefix for built-in routes (agents, workflows, memory). Custom `apiRoutes[].path` values that start with the server's `apiPrefix` (default `/api`) are rejected at startup, so the previous JSDoc snippets threw `Custom API route "/api/inngest" must not start with "/api"` when copy-pasted into a current Mastra project.
|
|
46
|
+
|
|
47
|
+
**Migration**
|
|
48
|
+
|
|
49
|
+
If you registered Inngest with the previous guide or JSDoc example:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// Before
|
|
53
|
+
apiRoutes: [
|
|
54
|
+
{
|
|
55
|
+
path: '/api/inngest',
|
|
56
|
+
method: 'ALL',
|
|
57
|
+
createHandler: async ({ mastra }) => serve({ mastra, inngest }),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
// After
|
|
62
|
+
apiRoutes: [
|
|
63
|
+
{
|
|
64
|
+
path: '/inngest/api',
|
|
65
|
+
method: 'ALL',
|
|
66
|
+
createHandler: async ({ mastra }) => serve({ mastra, inngest }),
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Update the dev server URL (`npx inngest-cli dev -u http://localhost:4111/inngest/api`) and, in production, set the **URL** field on your Inngest app to match.
|
|
72
|
+
|
|
73
|
+
If you cannot change the path, set `server.apiPrefix` (for example `/_mastra`) to relocate the built-in routes and remember to update `server.auth.protected` and any `MastraClient` `apiPrefix` to match. See the [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest) for the full walkthrough.
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [[`ac47842`](https://github.com/mastra-ai/mastra/commit/ac478427aa7a5f5fdaed633a911218689b438c60)]:
|
|
76
|
+
- @mastra/core@1.33.0-alpha.0
|
|
77
|
+
|
|
3
78
|
## 1.3.0
|
|
4
79
|
|
|
5
80
|
### Minor Changes
|
|
@@ -4,8 +4,8 @@ import type { InngestWorkflow } from '../../workflow.js';
|
|
|
4
4
|
export declare const INNGEST_PORT = 4100;
|
|
5
5
|
export declare const HANDLER_PORT = 4101;
|
|
6
6
|
export declare function createTestInngest(id: string): Inngest<{
|
|
7
|
-
id: string;
|
|
8
|
-
baseUrl:
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly baseUrl: "http://localhost:4100";
|
|
9
9
|
}>;
|
|
10
10
|
export declare function resetInngest(): Promise<void>;
|
|
11
11
|
export declare function waitForInngestSync(ms?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durable-agent.test.utils.d.ts","sourceRoot":"","sources":["../../src/__tests__/durable-agent.test.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"durable-agent.test.utils.d.ts","sourceRoot":"","sources":["../../src/__tests__/durable-agent.test.utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,YAAY,OAAO,CAAC;AAYjC;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAQ1C;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAKxC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,SAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAqFD;;;;;GAKG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CAmDnE;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAuBtE;AAMD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
* import { Agent } from '@mastra/core/agent';
|
|
12
12
|
* import { createInngestAgent } from '@mastra/inngest';
|
|
13
13
|
* import { Inngest } from 'inngest';
|
|
14
|
-
* import { realtimeMiddleware } from '@inngest/realtime/middleware';
|
|
15
14
|
*
|
|
16
15
|
* const inngest = new Inngest({
|
|
17
16
|
* id: 'my-app',
|
|
18
|
-
* middleware: [realtimeMiddleware()],
|
|
19
17
|
* });
|
|
20
18
|
*
|
|
21
19
|
* const agent = new Agent({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-inngest-agent.d.ts","sourceRoot":"","sources":["../../src/durable-agent/create-inngest-agent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create-inngest-agent.d.ts","sourceRoot":"","sources":["../../src/durable-agent/create-inngest-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASvC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,sDAAsD;IACtD,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,kGAAkG;IAClG,MAAM,CAAC,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W,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACjC,uEAAuE;IACvE,YAAY,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAClC,sEAAsE;IACtE,cAAc,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACpC,sEAAsE;IACtE,eAAe,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACrC,6EAA6E;IAC7E,aAAa,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACnC,4EAA4E;IAC5E,sBAAsB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC5C,+DAA+D;IAC/D,WAAW,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACjC,wEAAwE;IACxE,oBAAoB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC1C,6EAA6E;IAC7E,gBAAgB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;CACvC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,yBAAyB,GAAG,YAAY,CAAC,OAAO,CAAC,CAgZjH;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY,CAU5D"}
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
* import { createInngestAgent, serve as inngestServe } from '@mastra/inngest';
|
|
10
10
|
* import { Mastra } from '@mastra/core/mastra';
|
|
11
11
|
* import { Inngest } from 'inngest';
|
|
12
|
-
* import { realtimeMiddleware } from '@inngest/realtime/middleware';
|
|
13
12
|
*
|
|
14
13
|
* const inngest = new Inngest({
|
|
15
14
|
* id: 'my-app',
|
|
16
|
-
* middleware: [realtimeMiddleware()],
|
|
17
15
|
* });
|
|
18
16
|
*
|
|
19
17
|
* // 1. Create a regular Mastra agent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/durable-agent/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/durable-agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,mCAAmC,EACnC,KAAK,oCAAoC,GAC1C,MAAM,mCAAmC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -13,12 +13,10 @@ var crypto$1 = require('crypto');
|
|
|
13
13
|
var durable = require('@mastra/core/agent/durable');
|
|
14
14
|
var di = require('@mastra/core/di');
|
|
15
15
|
var inngest = require('inngest');
|
|
16
|
-
var realtime = require('@inngest/realtime');
|
|
17
16
|
var events = require('@mastra/core/events');
|
|
17
|
+
var realtime = require('inngest/realtime');
|
|
18
18
|
var web = require('stream/web');
|
|
19
19
|
var stream = require('@mastra/core/stream');
|
|
20
|
-
var api = require('@opentelemetry/api');
|
|
21
|
-
var core = require('@opentelemetry/core');
|
|
22
20
|
var hono = require('inngest/hono');
|
|
23
21
|
|
|
24
22
|
// src/index.ts
|
|
@@ -520,6 +518,9 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
|
|
|
520
518
|
};
|
|
521
519
|
}
|
|
522
520
|
};
|
|
521
|
+
function buildTopicRef(channel, topic) {
|
|
522
|
+
return { channel, topic, config: {} };
|
|
523
|
+
}
|
|
523
524
|
function parseTopic(topic) {
|
|
524
525
|
const workflowMatch = topic.match(/^workflow\.events\.v2\.(.+)$/);
|
|
525
526
|
if (workflowMatch && workflowMatch[1]) {
|
|
@@ -534,13 +535,11 @@ function parseTopic(topic) {
|
|
|
534
535
|
var InngestPubSub = class extends events.PubSub {
|
|
535
536
|
inngest;
|
|
536
537
|
workflowId;
|
|
537
|
-
publishFn;
|
|
538
538
|
subscriptions = /* @__PURE__ */ new Map();
|
|
539
|
-
constructor(inngest, workflowId
|
|
539
|
+
constructor(inngest, workflowId) {
|
|
540
540
|
super();
|
|
541
541
|
this.inngest = inngest;
|
|
542
542
|
this.workflowId = workflowId;
|
|
543
|
-
this.publishFn = publishFn;
|
|
544
543
|
}
|
|
545
544
|
/**
|
|
546
545
|
* Publish an event to Inngest's realtime system.
|
|
@@ -553,9 +552,6 @@ var InngestPubSub = class extends events.PubSub {
|
|
|
553
552
|
* (Note: agent stream uses runId-only channel so nested workflows can publish to same channel)
|
|
554
553
|
*/
|
|
555
554
|
async publish(topic, event) {
|
|
556
|
-
if (!this.publishFn) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
555
|
const parsed = parseTopic(topic);
|
|
560
556
|
if (!parsed) {
|
|
561
557
|
return;
|
|
@@ -565,11 +561,7 @@ var InngestPubSub = class extends events.PubSub {
|
|
|
565
561
|
const channel = topicType === "agent" ? `agent:${runId}` : `workflow:${this.workflowId}:${runId}`;
|
|
566
562
|
try {
|
|
567
563
|
const dataToSend = topicType === "agent" ? event : event.data;
|
|
568
|
-
await this.
|
|
569
|
-
channel,
|
|
570
|
-
topic: inngestTopic,
|
|
571
|
-
data: dataToSend
|
|
572
|
-
});
|
|
564
|
+
await this.inngest.realtime.publish(buildTopicRef(channel, inngestTopic), dataToSend);
|
|
573
565
|
} catch (err) {
|
|
574
566
|
if (topicType === "agent" && (event.type === "finish" || event.type === "error")) {
|
|
575
567
|
throw err;
|
|
@@ -679,50 +671,16 @@ var InngestRun = class extends workflows.Run {
|
|
|
679
671
|
this.serializedStepGraph = params.serializedStepGraph;
|
|
680
672
|
this.#mastra = params.mastra;
|
|
681
673
|
}
|
|
682
|
-
async getRuns(eventId) {
|
|
683
|
-
const maxRetries = 3;
|
|
684
|
-
let lastError = null;
|
|
685
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
686
|
-
try {
|
|
687
|
-
const response = await api.context.with(
|
|
688
|
-
core.suppressTracing(api.context.active()),
|
|
689
|
-
() => fetch(`${this.inngest.apiBaseUrl ?? "https://api.inngest.com"}/v1/events/${eventId}/runs`, {
|
|
690
|
-
headers: {
|
|
691
|
-
Authorization: `Bearer ${process.env.INNGEST_SIGNING_KEY}`
|
|
692
|
-
}
|
|
693
|
-
})
|
|
694
|
-
);
|
|
695
|
-
if (response.status === 429) {
|
|
696
|
-
const retryAfter = parseInt(response.headers.get("retry-after") || "2", 10);
|
|
697
|
-
await new Promise((resolve) => setTimeout(resolve, retryAfter * 1e3));
|
|
698
|
-
continue;
|
|
699
|
-
}
|
|
700
|
-
if (!response.ok) {
|
|
701
|
-
throw new Error(`Inngest API error: ${response.status} ${response.statusText}`);
|
|
702
|
-
}
|
|
703
|
-
const text = await response.text();
|
|
704
|
-
if (!text) {
|
|
705
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3 * (attempt + 1)));
|
|
706
|
-
continue;
|
|
707
|
-
}
|
|
708
|
-
const json = JSON.parse(text);
|
|
709
|
-
return json.data;
|
|
710
|
-
} catch (error) {
|
|
711
|
-
lastError = error;
|
|
712
|
-
if (attempt < maxRetries - 1) {
|
|
713
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt)));
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
throw new inngest.NonRetriableError(`Failed to get runs after ${maxRetries} attempts: ${lastError?.message}`);
|
|
718
|
-
}
|
|
719
674
|
/**
|
|
720
675
|
* Get run output using hybrid approach: realtime subscription + polling fallback.
|
|
721
676
|
* Resolves as soon as either method detects completion.
|
|
722
677
|
*/
|
|
723
|
-
async getRunOutput(
|
|
678
|
+
async getRunOutput(_eventId, maxWaitMs = 3e5) {
|
|
724
679
|
const storage = this.#mastra?.getStorage();
|
|
725
680
|
const workflowsStore = await storage?.getStore("workflows");
|
|
681
|
+
if (!workflowsStore) {
|
|
682
|
+
throw new inngest.NonRetriableError(`Workflow storage is required to retrieve output for run ${this.runId}`);
|
|
683
|
+
}
|
|
726
684
|
return new Promise((resolve, reject) => {
|
|
727
685
|
let resolved = false;
|
|
728
686
|
let unsubscribe = null;
|
|
@@ -772,16 +730,19 @@ var InngestRun = class extends workflows.Run {
|
|
|
772
730
|
if (snapshot?.context) {
|
|
773
731
|
snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
|
|
774
732
|
}
|
|
775
|
-
const
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
status: event.payload.status,
|
|
780
|
-
result: event.payload.result,
|
|
781
|
-
error: event.payload.error ? error.getErrorFromUnknown(event.payload.error, { serializeStack: false }) : void 0
|
|
782
|
-
}
|
|
783
|
-
}
|
|
733
|
+
const realtimeResult = {
|
|
734
|
+
steps: snapshot?.context,
|
|
735
|
+
status: event.payload?.status ?? snapshot?.status,
|
|
736
|
+
input: snapshot?.context?.input
|
|
784
737
|
};
|
|
738
|
+
const resultValue = event.payload?.result ?? snapshot?.result;
|
|
739
|
+
if (resultValue !== void 0) realtimeResult.result = resultValue;
|
|
740
|
+
const rawError = event.payload?.error ?? snapshot?.error;
|
|
741
|
+
if (rawError) {
|
|
742
|
+
realtimeResult.error = error.getErrorFromUnknown(rawError, { serializeStack: false });
|
|
743
|
+
}
|
|
744
|
+
if (snapshot?.value !== void 0) realtimeResult.state = snapshot.value;
|
|
745
|
+
const result = { output: { result: realtimeResult } };
|
|
785
746
|
handleResult(result);
|
|
786
747
|
}
|
|
787
748
|
}
|
|
@@ -806,52 +767,28 @@ var InngestRun = class extends workflows.Run {
|
|
|
806
767
|
return;
|
|
807
768
|
}
|
|
808
769
|
try {
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
});
|
|
816
|
-
if (snapshot?.context) {
|
|
817
|
-
snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
|
|
818
|
-
}
|
|
819
|
-
handleResult({ output: { result: { steps: snapshot?.context, status: "success" } } });
|
|
770
|
+
const snapshot = await workflowsStore.loadWorkflowSnapshot({
|
|
771
|
+
workflowName: this.workflowId,
|
|
772
|
+
runId: this.runId
|
|
773
|
+
});
|
|
774
|
+
if (!snapshot || snapshot.status === "running" || snapshot.status === "waiting" || snapshot.status === "pending") {
|
|
775
|
+
pollTimeoutId = setTimeout(poll, 150 + Math.random() * 100);
|
|
820
776
|
return;
|
|
821
777
|
}
|
|
822
|
-
if (
|
|
823
|
-
|
|
824
|
-
workflowName: this.workflowId,
|
|
825
|
-
runId: this.runId
|
|
826
|
-
});
|
|
827
|
-
if (snapshot?.context) {
|
|
828
|
-
snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
|
|
829
|
-
}
|
|
830
|
-
handleResult(
|
|
831
|
-
{
|
|
832
|
-
output: {
|
|
833
|
-
result: {
|
|
834
|
-
steps: snapshot?.context,
|
|
835
|
-
status: "failed",
|
|
836
|
-
error: error.getErrorFromUnknown(run?.output?.cause?.error, { serializeStack: false })
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
return;
|
|
778
|
+
if (snapshot.context) {
|
|
779
|
+
snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
|
|
841
780
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
handleResult(
|
|
851
|
-
{ output: { result: { steps: snapshot?.context, status: "canceled" } } });
|
|
852
|
-
return;
|
|
781
|
+
const pollingResult = {
|
|
782
|
+
steps: snapshot.context,
|
|
783
|
+
status: snapshot.status,
|
|
784
|
+
input: snapshot.context?.input
|
|
785
|
+
};
|
|
786
|
+
if (snapshot.result !== void 0) pollingResult.result = snapshot.result;
|
|
787
|
+
if (snapshot.error !== void 0) {
|
|
788
|
+
pollingResult.error = error.getErrorFromUnknown(snapshot.error, { serializeStack: false });
|
|
853
789
|
}
|
|
854
|
-
|
|
790
|
+
if (snapshot.value !== void 0) pollingResult.state = snapshot.value;
|
|
791
|
+
handleResult({ output: { result: pollingResult } });
|
|
855
792
|
} catch (error) {
|
|
856
793
|
if (error instanceof inngest.NonRetriableError) {
|
|
857
794
|
handleError(error);
|
|
@@ -997,6 +934,9 @@ var InngestRun = class extends workflows.Run {
|
|
|
997
934
|
const runOutput = await this.getRunOutput(eventId);
|
|
998
935
|
const result = runOutput?.output?.result;
|
|
999
936
|
this.hydrateFailedResult(result);
|
|
937
|
+
if (!outputOptions?.includeState) {
|
|
938
|
+
delete result.state;
|
|
939
|
+
}
|
|
1000
940
|
if (result.status !== "suspended") {
|
|
1001
941
|
this.cleanup?.();
|
|
1002
942
|
}
|
|
@@ -1016,11 +956,17 @@ var InngestRun = class extends workflows.Run {
|
|
|
1016
956
|
async _resume(params) {
|
|
1017
957
|
const storage = this.#mastra?.getStorage();
|
|
1018
958
|
const workflowsStore = await storage?.getStore("workflows");
|
|
1019
|
-
|
|
959
|
+
if (!workflowsStore) {
|
|
960
|
+
throw new inngest.NonRetriableError(`Workflow storage is required to resume run ${this.runId}`);
|
|
961
|
+
}
|
|
962
|
+
const snapshot = await workflowsStore.loadWorkflowSnapshot({
|
|
1020
963
|
workflowName: this.workflowId,
|
|
1021
964
|
runId: this.runId
|
|
1022
965
|
});
|
|
1023
|
-
|
|
966
|
+
if (!snapshot) {
|
|
967
|
+
throw new inngest.NonRetriableError(`Cannot resume run ${this.runId}: snapshot not found`);
|
|
968
|
+
}
|
|
969
|
+
const snapshotResumeLabel = params.label ? snapshot.resumeLabels?.[params.label] : void 0;
|
|
1024
970
|
const stepParam = snapshotResumeLabel?.stepId ?? params.step;
|
|
1025
971
|
let steps = [];
|
|
1026
972
|
if (stepParam) {
|
|
@@ -1037,24 +983,51 @@ var InngestRun = class extends workflows.Run {
|
|
|
1037
983
|
const persistedRequestContext = snapshot?.requestContext ?? {};
|
|
1038
984
|
const newRequestContext = params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {};
|
|
1039
985
|
const mergedRequestContext = { ...persistedRequestContext, ...newRequestContext };
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
stepResults: snapshot?.context,
|
|
1051
|
-
resumePayload: resumeDataToUse,
|
|
1052
|
-
resumePath: steps?.[0] ? snapshot?.suspendedPaths?.[steps?.[0]] : void 0
|
|
1053
|
-
},
|
|
1054
|
-
requestContext: mergedRequestContext,
|
|
1055
|
-
perStep: params.perStep
|
|
986
|
+
await workflowsStore.persistWorkflowSnapshot({
|
|
987
|
+
workflowName: this.workflowId,
|
|
988
|
+
runId: this.runId,
|
|
989
|
+
resourceId: this.resourceId,
|
|
990
|
+
snapshot: {
|
|
991
|
+
...snapshot,
|
|
992
|
+
status: "running",
|
|
993
|
+
result: void 0,
|
|
994
|
+
error: void 0,
|
|
995
|
+
timestamp: Date.now()
|
|
1056
996
|
}
|
|
1057
997
|
});
|
|
998
|
+
let eventOutput;
|
|
999
|
+
try {
|
|
1000
|
+
eventOutput = await this.inngest.send({
|
|
1001
|
+
name: `workflow.${this.workflowId}`,
|
|
1002
|
+
data: {
|
|
1003
|
+
inputData: resumeDataToUse,
|
|
1004
|
+
initialState: snapshot?.value ?? {},
|
|
1005
|
+
runId: this.runId,
|
|
1006
|
+
workflowId: this.workflowId,
|
|
1007
|
+
stepResults: snapshot?.context,
|
|
1008
|
+
resume: {
|
|
1009
|
+
steps,
|
|
1010
|
+
stepResults: snapshot?.context,
|
|
1011
|
+
resumePayload: resumeDataToUse,
|
|
1012
|
+
resumePath: steps?.[0] ? snapshot?.suspendedPaths?.[steps?.[0]] : void 0
|
|
1013
|
+
},
|
|
1014
|
+
requestContext: mergedRequestContext,
|
|
1015
|
+
perStep: params.perStep
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
} catch (err) {
|
|
1019
|
+
try {
|
|
1020
|
+
await workflowsStore.persistWorkflowSnapshot({
|
|
1021
|
+
workflowName: this.workflowId,
|
|
1022
|
+
runId: this.runId,
|
|
1023
|
+
resourceId: this.resourceId,
|
|
1024
|
+
snapshot
|
|
1025
|
+
});
|
|
1026
|
+
} catch (rollbackErr) {
|
|
1027
|
+
console.error("Failed to rollback snapshot during resume error recovery:", rollbackErr);
|
|
1028
|
+
}
|
|
1029
|
+
throw err;
|
|
1030
|
+
}
|
|
1058
1031
|
const eventId = eventOutput.ids[0];
|
|
1059
1032
|
if (!eventId) {
|
|
1060
1033
|
throw new Error("Event ID is not set");
|
|
@@ -1092,29 +1065,35 @@ var InngestRun = class extends workflows.Run {
|
|
|
1092
1065
|
}
|
|
1093
1066
|
const storage = this.#mastra?.getStorage();
|
|
1094
1067
|
const workflowsStore = await storage?.getStore("workflows");
|
|
1095
|
-
|
|
1068
|
+
if (!workflowsStore) {
|
|
1069
|
+
throw new inngest.NonRetriableError(`Workflow storage is required to time-travel run ${this.runId}`);
|
|
1070
|
+
}
|
|
1071
|
+
const snapshot = await workflowsStore.loadWorkflowSnapshot({
|
|
1096
1072
|
workflowName: this.workflowId,
|
|
1097
1073
|
runId: this.runId
|
|
1098
1074
|
});
|
|
1075
|
+
let snapshotForRollback = snapshot;
|
|
1099
1076
|
if (!snapshot) {
|
|
1100
|
-
|
|
1077
|
+
const pendingSnapshot = {
|
|
1078
|
+
runId: this.runId,
|
|
1079
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
1080
|
+
status: "pending",
|
|
1081
|
+
value: {},
|
|
1082
|
+
context: {},
|
|
1083
|
+
activePaths: [],
|
|
1084
|
+
suspendedPaths: {},
|
|
1085
|
+
activeStepsPath: {},
|
|
1086
|
+
resumeLabels: {},
|
|
1087
|
+
waitingPaths: {},
|
|
1088
|
+
timestamp: Date.now()
|
|
1089
|
+
};
|
|
1090
|
+
await workflowsStore.persistWorkflowSnapshot({
|
|
1101
1091
|
workflowName: this.workflowId,
|
|
1102
1092
|
runId: this.runId,
|
|
1103
1093
|
resourceId: this.resourceId,
|
|
1104
|
-
snapshot:
|
|
1105
|
-
runId: this.runId,
|
|
1106
|
-
serializedStepGraph: this.serializedStepGraph,
|
|
1107
|
-
status: "pending",
|
|
1108
|
-
value: {},
|
|
1109
|
-
context: {},
|
|
1110
|
-
activePaths: [],
|
|
1111
|
-
suspendedPaths: {},
|
|
1112
|
-
activeStepsPath: {},
|
|
1113
|
-
resumeLabels: {},
|
|
1114
|
-
waitingPaths: {},
|
|
1115
|
-
timestamp: Date.now()
|
|
1116
|
-
}
|
|
1094
|
+
snapshot: pendingSnapshot
|
|
1117
1095
|
});
|
|
1096
|
+
snapshotForRollback = pendingSnapshot;
|
|
1118
1097
|
}
|
|
1119
1098
|
if (snapshot?.status === "running") {
|
|
1120
1099
|
throw new Error("This workflow run is still running, cannot time travel");
|
|
@@ -1134,20 +1113,56 @@ var InngestRun = class extends workflows.Run {
|
|
|
1134
1113
|
initialState: params.initialState,
|
|
1135
1114
|
perStep: params.perStep
|
|
1136
1115
|
});
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1116
|
+
const previousSnapshot = snapshotForRollback;
|
|
1117
|
+
await workflowsStore.persistWorkflowSnapshot({
|
|
1118
|
+
workflowName: this.workflowId,
|
|
1119
|
+
runId: this.runId,
|
|
1120
|
+
resourceId: this.resourceId,
|
|
1121
|
+
snapshot: {
|
|
1141
1122
|
runId: this.runId,
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1123
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
1124
|
+
status: "running",
|
|
1125
|
+
value: {},
|
|
1126
|
+
context: {},
|
|
1127
|
+
activePaths: [],
|
|
1128
|
+
suspendedPaths: {},
|
|
1129
|
+
activeStepsPath: {},
|
|
1130
|
+
resumeLabels: {},
|
|
1131
|
+
waitingPaths: {},
|
|
1132
|
+
timestamp: Date.now()
|
|
1149
1133
|
}
|
|
1150
1134
|
});
|
|
1135
|
+
let eventOutput;
|
|
1136
|
+
try {
|
|
1137
|
+
eventOutput = await this.inngest.send({
|
|
1138
|
+
name: `workflow.${this.workflowId}`,
|
|
1139
|
+
data: {
|
|
1140
|
+
initialState: timeTravelData.state,
|
|
1141
|
+
runId: this.runId,
|
|
1142
|
+
workflowId: this.workflowId,
|
|
1143
|
+
stepResults: timeTravelData.stepResults,
|
|
1144
|
+
timeTravel: timeTravelData,
|
|
1145
|
+
tracingOptions: params.tracingOptions,
|
|
1146
|
+
outputOptions: params.outputOptions,
|
|
1147
|
+
requestContext: params.requestContext ? Object.fromEntries(params.requestContext.entries()) : {},
|
|
1148
|
+
perStep: params.perStep
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
} catch (err) {
|
|
1152
|
+
if (previousSnapshot) {
|
|
1153
|
+
try {
|
|
1154
|
+
await workflowsStore.persistWorkflowSnapshot({
|
|
1155
|
+
workflowName: this.workflowId,
|
|
1156
|
+
runId: this.runId,
|
|
1157
|
+
resourceId: this.resourceId,
|
|
1158
|
+
snapshot: previousSnapshot
|
|
1159
|
+
});
|
|
1160
|
+
} catch (rollbackErr) {
|
|
1161
|
+
console.error("Failed to rollback snapshot during time-travel error recovery:", rollbackErr);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
throw err;
|
|
1165
|
+
}
|
|
1151
1166
|
const eventId = eventOutput.ids[0];
|
|
1152
1167
|
if (!eventId) {
|
|
1153
1168
|
throw new Error("Event ID is not set");
|
|
@@ -1155,6 +1170,9 @@ var InngestRun = class extends workflows.Run {
|
|
|
1155
1170
|
const runOutput = await this.getRunOutput(eventId);
|
|
1156
1171
|
const result = runOutput?.output?.result;
|
|
1157
1172
|
this.hydrateFailedResult(result);
|
|
1173
|
+
if (!params.outputOptions?.includeState) {
|
|
1174
|
+
delete result.state;
|
|
1175
|
+
}
|
|
1158
1176
|
return result;
|
|
1159
1177
|
}
|
|
1160
1178
|
watch(cb) {
|
|
@@ -1508,9 +1526,9 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1508
1526
|
id: `workflow.${this.id}.cron`,
|
|
1509
1527
|
retries: 0,
|
|
1510
1528
|
cancelOn: [{ event: `cancel.workflow.${this.id}` }],
|
|
1529
|
+
triggers: { cron: this.cronConfig?.cron ?? "" },
|
|
1511
1530
|
...this.flowControlConfig
|
|
1512
1531
|
},
|
|
1513
|
-
{ cron: this.cronConfig?.cron ?? "" },
|
|
1514
1532
|
async () => {
|
|
1515
1533
|
const run = await this.createRun();
|
|
1516
1534
|
const result = await run.start({
|
|
@@ -1531,11 +1549,11 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1531
1549
|
id: `workflow.${this.id}`,
|
|
1532
1550
|
retries: 0,
|
|
1533
1551
|
cancelOn: [{ event: `cancel.workflow.${this.id}` }],
|
|
1552
|
+
triggers: { event: `workflow.${this.id}` },
|
|
1534
1553
|
// Spread flow control configuration
|
|
1535
1554
|
...this.flowControlConfig
|
|
1536
1555
|
},
|
|
1537
|
-
{ event
|
|
1538
|
-
async ({ event, step, attempt, publish }) => {
|
|
1556
|
+
async ({ event, step, attempt }) => {
|
|
1539
1557
|
let {
|
|
1540
1558
|
inputData,
|
|
1541
1559
|
initialState,
|
|
@@ -1553,7 +1571,7 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
|
|
|
1553
1571
|
return crypto$1.randomUUID();
|
|
1554
1572
|
});
|
|
1555
1573
|
}
|
|
1556
|
-
const pubsub = new InngestPubSub(this.inngest, this.id
|
|
1574
|
+
const pubsub = new InngestPubSub(this.inngest, this.id);
|
|
1557
1575
|
const requestContext = new di.RequestContext(Object.entries(event.data.requestContext ?? {}));
|
|
1558
1576
|
const mastra = this.#mastra;
|
|
1559
1577
|
const tracingPolicy = this.options.tracingPolicy;
|