@mastra/inngest 0.0.0-unified-sidebar-20251010130811 → 0.0.0-unified-workspace-snapshot-20260128233410

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.
@@ -0,0 +1,18 @@
1
+ import { Mastra } from '@mastra/core/mastra';
2
+ import { Inngest } from 'inngest';
3
+ import type { InngestWorkflow } from '../../workflow.js';
4
+ export declare const INNGEST_PORT = 4000;
5
+ export declare const HANDLER_PORT = 4001;
6
+ export declare function createTestInngest(id: string): Inngest<{
7
+ id: string;
8
+ baseUrl: string;
9
+ }>;
10
+ export declare function resetInngest(): Promise<void>;
11
+ export declare function waitForInngestSync(ms?: number): Promise<void>;
12
+ export interface TestWorkflowResult {
13
+ workflow: InngestWorkflow<any, any, any>;
14
+ mastra: Mastra;
15
+ inngest: Inngest;
16
+ }
17
+ export declare function createTestWorkflow(adapterId: string): TestWorkflowResult;
18
+ //# sourceMappingURL=_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/adapters/_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM;;;GAK3C;AAED,wBAAsB,YAAY,kBAIjC;AAED,wBAAsB,kBAAkB,CAAC,EAAE,SAAO,iBAEjD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,CA0CxE"}
@@ -0,0 +1,206 @@
1
+ import type { RequestContext } from '@mastra/core/di';
2
+ import type { SerializedError } from '@mastra/core/error';
3
+ import type { PubSub } from '@mastra/core/events';
4
+ import type { Mastra } from '@mastra/core/mastra';
5
+ import { DefaultExecutionEngine } from '@mastra/core/workflows';
6
+ import type { ExecutionContext, Step, StepResult, ExecutionEngineOptions, TimeTravelExecutionParams } from '@mastra/core/workflows';
7
+ import type { Inngest, BaseContext } from 'inngest';
8
+ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
9
+ private inngestStep;
10
+ private inngestAttempts;
11
+ constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts: number | undefined, options: ExecutionEngineOptions);
12
+ /**
13
+ * Format errors while preserving Error instances and their custom properties.
14
+ * Uses getErrorFromUnknown to ensure all error properties are preserved.
15
+ */
16
+ protected formatResultError(error: Error | string | undefined, lastOutput: StepResult<any, any, any, any>): SerializedError;
17
+ /**
18
+ * Detect InngestWorkflow instances for special nested workflow handling
19
+ */
20
+ isNestedWorkflowStep(step: Step<any, any, any>): boolean;
21
+ /**
22
+ * Inngest requires requestContext serialization for memoization.
23
+ * When steps are replayed, the original function doesn't re-execute,
24
+ * so requestContext modifications must be captured and restored.
25
+ */
26
+ requiresDurableContextSerialization(): boolean;
27
+ /**
28
+ * Execute a step with retry logic for Inngest.
29
+ * Retries are handled via step-level retry (RetryAfterError thrown INSIDE step.run()).
30
+ * After retries exhausted, error propagates here and we return a failed result.
31
+ */
32
+ executeStepWithRetry<T>(stepId: string, runStep: () => Promise<T>, params: {
33
+ retries: number;
34
+ delay: number;
35
+ stepSpan?: any;
36
+ workflowId: string;
37
+ runId: string;
38
+ }): Promise<{
39
+ ok: true;
40
+ result: T;
41
+ } | {
42
+ ok: false;
43
+ error: {
44
+ status: 'failed';
45
+ error: Error;
46
+ endedAt: number;
47
+ };
48
+ }>;
49
+ /**
50
+ * Use Inngest's sleep primitive for durability
51
+ */
52
+ executeSleepDuration(duration: number, sleepId: string, workflowId: string): Promise<void>;
53
+ /**
54
+ * Use Inngest's sleepUntil primitive for durability
55
+ */
56
+ executeSleepUntilDate(date: Date, sleepUntilId: string, workflowId: string): Promise<void>;
57
+ /**
58
+ * Wrap durable operations in Inngest step.run() for durability.
59
+ *
60
+ * IMPORTANT: Errors are wrapped with a cause structure before throwing.
61
+ * This is necessary because Inngest's error serialization (serialize-error-cjs)
62
+ * only captures standard Error properties (message, name, stack, code, cause).
63
+ * Custom properties like statusCode, responseHeaders from AI SDK errors would
64
+ * be lost. By putting our serialized error (via getErrorFromUnknown with toJSON())
65
+ * in the cause property, we ensure custom properties survive serialization.
66
+ * The cause property is in serialize-error-cjs's allowlist, and when the cause
67
+ * object is finally JSON.stringify'd, our error's toJSON() is called.
68
+ */
69
+ wrapDurableOperation<T>(operationId: string, operationFn: () => Promise<T>): Promise<T>;
70
+ /**
71
+ * Provide Inngest step primitive in engine context
72
+ */
73
+ getEngineContext(): Record<string, any>;
74
+ /**
75
+ * For Inngest, lifecycle callbacks are invoked in the workflow's finalize step
76
+ * (wrapped in step.run for durability), not in execute(). Override to skip.
77
+ */
78
+ invokeLifecycleCallbacks(_result: {
79
+ status: any;
80
+ result?: any;
81
+ error?: any;
82
+ steps: Record<string, any>;
83
+ tripwire?: any;
84
+ runId: string;
85
+ workflowId: string;
86
+ resourceId?: string;
87
+ input?: any;
88
+ requestContext: RequestContext;
89
+ state: Record<string, any>;
90
+ }): Promise<void>;
91
+ /**
92
+ * Actually invoke the lifecycle callbacks. Called from workflow.ts finalize step.
93
+ */
94
+ invokeLifecycleCallbacksInternal(result: {
95
+ status: any;
96
+ result?: any;
97
+ error?: any;
98
+ steps: Record<string, any>;
99
+ tripwire?: any;
100
+ runId: string;
101
+ workflowId: string;
102
+ resourceId?: string;
103
+ input?: any;
104
+ requestContext: RequestContext;
105
+ state: Record<string, any>;
106
+ }): Promise<void>;
107
+ /**
108
+ * Create a step span durably - on first execution, creates and exports span.
109
+ * On replay, returns cached span data without re-creating.
110
+ */
111
+ createStepSpan(params: {
112
+ parentSpan: any;
113
+ stepId: string;
114
+ operationId: string;
115
+ options: {
116
+ name: string;
117
+ type: any;
118
+ input?: unknown;
119
+ entityType?: string;
120
+ entityId?: string;
121
+ tracingPolicy?: any;
122
+ };
123
+ executionContext: ExecutionContext;
124
+ }): Promise<any>;
125
+ /**
126
+ * End a step span durably.
127
+ */
128
+ endStepSpan(params: {
129
+ span: any;
130
+ operationId: string;
131
+ endOptions: {
132
+ output?: unknown;
133
+ attributes?: Record<string, unknown>;
134
+ };
135
+ }): Promise<void>;
136
+ /**
137
+ * Record error on step span durably.
138
+ */
139
+ errorStepSpan(params: {
140
+ span: any;
141
+ operationId: string;
142
+ errorOptions: {
143
+ error: Error;
144
+ attributes?: Record<string, unknown>;
145
+ };
146
+ }): Promise<void>;
147
+ /**
148
+ * Create a generic child span durably (for control-flow operations).
149
+ * On first execution, creates and exports span. On replay, returns cached span data.
150
+ */
151
+ createChildSpan(params: {
152
+ parentSpan: any;
153
+ operationId: string;
154
+ options: {
155
+ name: string;
156
+ type: any;
157
+ input?: unknown;
158
+ attributes?: Record<string, unknown>;
159
+ };
160
+ executionContext: ExecutionContext;
161
+ }): Promise<any>;
162
+ /**
163
+ * End a generic child span durably (for control-flow operations).
164
+ */
165
+ endChildSpan(params: {
166
+ span: any;
167
+ operationId: string;
168
+ endOptions?: {
169
+ output?: unknown;
170
+ attributes?: Record<string, unknown>;
171
+ };
172
+ }): Promise<void>;
173
+ /**
174
+ * Record error on a generic child span durably (for control-flow operations).
175
+ */
176
+ errorChildSpan(params: {
177
+ span: any;
178
+ operationId: string;
179
+ errorOptions: {
180
+ error: Error;
181
+ attributes?: Record<string, unknown>;
182
+ };
183
+ }): Promise<void>;
184
+ /**
185
+ * Execute nested InngestWorkflow using inngestStep.invoke() for durability.
186
+ * This MUST be called directly (not inside step.run()) due to Inngest constraints.
187
+ */
188
+ executeWorkflowStep(params: {
189
+ step: Step<string, any, any>;
190
+ stepResults: Record<string, StepResult<any, any, any, any>>;
191
+ executionContext: ExecutionContext;
192
+ resume?: {
193
+ steps: string[];
194
+ resumePayload: any;
195
+ runId?: string;
196
+ };
197
+ timeTravel?: TimeTravelExecutionParams;
198
+ prevOutput: any;
199
+ inputData: any;
200
+ pubsub: PubSub;
201
+ startedAt: number;
202
+ perStep?: boolean;
203
+ stepSpan?: any;
204
+ }): Promise<StepResult<any, any, any, any> | null>;
205
+ }
206
+ //# sourceMappingURL=execution-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-engine.d.ts","sourceRoot":"","sources":["../src/execution-engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAmC,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,UAAU,EAEV,sBAAsB,EACtB,yBAAyB,EAE1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,sBAAuB,SAAQ,sBAAsB;IAChE,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,eAAe,CAAS;gBAG9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACzC,eAAe,EAAE,MAAM,YAAI,EAC3B,OAAO,EAAE,sBAAsB;IAWjC;;;OAGG;IACH,SAAS,CAAC,iBAAiB,CACzB,KAAK,EAAE,KA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