@mastra/inngest 1.0.0-beta.0 → 1.0.0-beta.10
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 +458 -0
- package/dist/execution-engine.d.ts +110 -0
- package/dist/execution-engine.d.ts.map +1 -0
- package/dist/index.cjs +977 -926
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -284
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +975 -926
- package/dist/index.js.map +1 -1
- package/dist/pubsub.d.ts +56 -0
- package/dist/pubsub.d.ts.map +1 -0
- package/dist/run.d.ts +177 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/serve.d.ts +13 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workflow.d.ts +51 -0
- package/dist/workflow.d.ts.map +1 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,463 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Unified observability schema with entity-based span identification ([#11132](https://github.com/mastra-ai/mastra/pull/11132))
|
|
8
|
+
|
|
9
|
+
## What changed
|
|
10
|
+
|
|
11
|
+
Spans now use a unified identification model with `entityId`, `entityType`, and `entityName` instead of separate `agentId`, `toolId`, `workflowId` fields.
|
|
12
|
+
|
|
13
|
+
**Before:**
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Old span structure
|
|
17
|
+
span.agentId; // 'my-agent'
|
|
18
|
+
span.toolId; // undefined
|
|
19
|
+
span.workflowId; // undefined
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**After:**
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// New span structure
|
|
26
|
+
span.entityType; // EntityType.AGENT
|
|
27
|
+
span.entityId; // 'my-agent'
|
|
28
|
+
span.entityName; // 'My Agent'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## New `listTraces()` API
|
|
32
|
+
|
|
33
|
+
Query traces with filtering, pagination, and sorting:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const { spans, pagination } = await storage.listTraces({
|
|
37
|
+
filters: {
|
|
38
|
+
entityType: EntityType.AGENT,
|
|
39
|
+
entityId: 'my-agent',
|
|
40
|
+
userId: 'user-123',
|
|
41
|
+
environment: 'production',
|
|
42
|
+
status: TraceStatus.SUCCESS,
|
|
43
|
+
startedAt: { start: new Date('2024-01-01'), end: new Date('2024-01-31') },
|
|
44
|
+
},
|
|
45
|
+
pagination: { page: 0, perPage: 50 },
|
|
46
|
+
orderBy: { field: 'startedAt', direction: 'DESC' },
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Available filters:** date ranges (`startedAt`, `endedAt`), entity (`entityType`, `entityId`, `entityName`), identity (`userId`, `organizationId`), correlation IDs (`runId`, `sessionId`, `threadId`), deployment (`environment`, `source`, `serviceName`), `tags`, `metadata`, and `status`.
|
|
51
|
+
|
|
52
|
+
## New retrieval methods
|
|
53
|
+
- `getSpan({ traceId, spanId })` - Get a single span
|
|
54
|
+
- `getRootSpan({ traceId })` - Get the root span of a trace
|
|
55
|
+
- `getTrace({ traceId })` - Get all spans for a trace
|
|
56
|
+
|
|
57
|
+
## Backward compatibility
|
|
58
|
+
|
|
59
|
+
The legacy `getTraces()` method continues to work. When you pass `name: "agent run: my-agent"`, it automatically transforms to `entityId: "my-agent", entityType: AGENT`.
|
|
60
|
+
|
|
61
|
+
## Migration
|
|
62
|
+
|
|
63
|
+
**Automatic:** SQL-based stores (PostgreSQL, LibSQL, MSSQL) automatically add new columns to existing `spans` tables on initialization. Existing data is preserved with new columns set to `NULL`.
|
|
64
|
+
|
|
65
|
+
**No action required:** Your existing code continues to work. Adopt the new fields and `listTraces()` API at your convenience.
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Refactor storage architecture to use domain-specific stores via `getStore()` pattern ([#11361](https://github.com/mastra-ai/mastra/pull/11361))
|
|
70
|
+
|
|
71
|
+
### Summary
|
|
72
|
+
|
|
73
|
+
This release introduces a new storage architecture that replaces passthrough methods on `MastraStorage` with domain-specific storage interfaces accessed via `getStore()`. This change reduces code duplication across storage adapters and provides a cleaner, more modular API.
|
|
74
|
+
|
|
75
|
+
### Migration Guide
|
|
76
|
+
|
|
77
|
+
All direct method calls on storage instances should be updated to use `getStore()`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// Before
|
|
81
|
+
const thread = await storage.getThreadById({ threadId });
|
|
82
|
+
await storage.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
83
|
+
await storage.createSpan(span);
|
|
84
|
+
|
|
85
|
+
// After
|
|
86
|
+
const memory = await storage.getStore('memory');
|
|
87
|
+
const thread = await memory?.getThreadById({ threadId });
|
|
88
|
+
|
|
89
|
+
const workflows = await storage.getStore('workflows');
|
|
90
|
+
await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
91
|
+
|
|
92
|
+
const observability = await storage.getStore('observability');
|
|
93
|
+
await observability?.createSpan(span);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Available Domains
|
|
97
|
+
- **`memory`**: Thread and message operations (`getThreadById`, `saveThread`, `saveMessages`, etc.)
|
|
98
|
+
- **`workflows`**: Workflow state persistence (`persistWorkflowSnapshot`, `loadWorkflowSnapshot`, `getWorkflowRunById`, etc.)
|
|
99
|
+
- **`scores`**: Evaluation scores (`saveScore`, `listScoresByScorerId`, etc.)
|
|
100
|
+
- **`observability`**: Tracing and spans (`createSpan`, `updateSpan`, `getTrace`, etc.)
|
|
101
|
+
- **`agents`**: Stored agent configurations (`createAgent`, `getAgentById`, `listAgents`, etc.)
|
|
102
|
+
|
|
103
|
+
### Breaking Changes
|
|
104
|
+
- Passthrough methods have been removed from `MastraStorage` base class
|
|
105
|
+
- All storage adapters now require accessing domains via `getStore()`
|
|
106
|
+
- The `stores` property on storage instances is now the canonical way to access domain storage
|
|
107
|
+
|
|
108
|
+
### Internal Changes
|
|
109
|
+
- Each storage adapter now initializes domain-specific stores in its constructor
|
|
110
|
+
- Domain stores share database connections and handle their own table initialization
|
|
111
|
+
|
|
112
|
+
- Add debugger-like click-through UI to workflow graph ([#11350](https://github.com/mastra-ai/mastra/pull/11350))
|
|
113
|
+
|
|
114
|
+
- Add `perStep` option to workflow run methods, allowing a workflow to run just a step instead of all the workflow steps ([#11276](https://github.com/mastra-ai/mastra/pull/11276))
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [[`33a4d2e`](https://github.com/mastra-ai/mastra/commit/33a4d2e4ed8af51f69256232f00c34d6b6b51d48), [`4aaa844`](https://github.com/mastra-ai/mastra/commit/4aaa844a4f19d054490f43638a990cc57bda8d2f), [`4a1a6cb`](https://github.com/mastra-ai/mastra/commit/4a1a6cb3facad54b2bb6780b00ce91d6de1edc08), [`31d13d5`](https://github.com/mastra-ai/mastra/commit/31d13d5fdc2e2380e2e3ee3ec9fb29d2a00f265d), [`4c62166`](https://github.com/mastra-ai/mastra/commit/4c621669f4a29b1f443eca3ba70b814afa286266), [`7bcbf10`](https://github.com/mastra-ai/mastra/commit/7bcbf10133516e03df964b941f9a34e9e4ab4177), [`4353600`](https://github.com/mastra-ai/mastra/commit/43536005a65988a8eede236f69122e7f5a284ba2), [`6986fb0`](https://github.com/mastra-ai/mastra/commit/6986fb064f5db6ecc24aa655e1d26529087b43b3), [`053e979`](https://github.com/mastra-ai/mastra/commit/053e9793b28e970086b0507f7f3b76ea32c1e838), [`e26dc9c`](https://github.com/mastra-ai/mastra/commit/e26dc9c3ccfec54ae3dc3e2b2589f741f9ae60a6), [`55edf73`](https://github.com/mastra-ai/mastra/commit/55edf7302149d6c964fbb7908b43babfc2b52145), [`27c0009`](https://github.com/mastra-ai/mastra/commit/27c0009777a6073d7631b0eb7b481d94e165b5ca), [`dee388d`](https://github.com/mastra-ai/mastra/commit/dee388dde02f2e63c53385ae69252a47ab6825cc), [`3f3fc30`](https://github.com/mastra-ai/mastra/commit/3f3fc3096f24c4a26cffeecfe73085928f72aa63), [`d90ea65`](https://github.com/mastra-ai/mastra/commit/d90ea6536f7aa51c6545a4e9215b55858e98e16d), [`d171e55`](https://github.com/mastra-ai/mastra/commit/d171e559ead9f52ec728d424844c8f7b164c4510), [`10c2735`](https://github.com/mastra-ai/mastra/commit/10c27355edfdad1ee2b826b897df74125eb81fb8), [`1924cf0`](https://github.com/mastra-ai/mastra/commit/1924cf06816e5e4d4d5333065ec0f4bb02a97799), [`b339816`](https://github.com/mastra-ai/mastra/commit/b339816df0984d0243d944ac2655d6ba5f809cde)]:
|
|
117
|
+
- @mastra/core@1.0.0-beta.15
|
|
118
|
+
|
|
119
|
+
## 1.0.0-beta.9
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- feat: Add field filtering and nested workflow control to workflow execution result endpoint ([#11246](https://github.com/mastra-ai/mastra/pull/11246))
|
|
124
|
+
|
|
125
|
+
Adds two optional query parameters to `/api/workflows/:workflowId/runs/:runId/execution-result` endpoint:
|
|
126
|
+
- `fields`: Request only specific fields (e.g., `status`, `result`, `error`)
|
|
127
|
+
- `withNestedWorkflows`: Control whether to fetch nested workflow data
|
|
128
|
+
|
|
129
|
+
This significantly reduces response payload size and improves response times for large workflows.
|
|
130
|
+
|
|
131
|
+
## Server Endpoint Usage
|
|
132
|
+
|
|
133
|
+
```http
|
|
134
|
+
# Get only status (minimal payload - fastest)
|
|
135
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status
|
|
136
|
+
|
|
137
|
+
# Get status and result
|
|
138
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,result
|
|
139
|
+
|
|
140
|
+
# Get all fields but without nested workflow data (faster)
|
|
141
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?withNestedWorkflows=false
|
|
142
|
+
|
|
143
|
+
# Get only specific fields without nested workflow data
|
|
144
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,steps&withNestedWorkflows=false
|
|
145
|
+
|
|
146
|
+
# Get full data (default behavior)
|
|
147
|
+
GET /api/workflows/:workflowId/runs/:runId/execution-result
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Client SDK Usage
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { MastraClient } from '@mastra/client-js';
|
|
154
|
+
|
|
155
|
+
const client = new MastraClient({ baseUrl: 'http://localhost:4111' });
|
|
156
|
+
const workflow = client.getWorkflow('myWorkflow');
|
|
157
|
+
|
|
158
|
+
// Get only status (minimal payload - fastest)
|
|
159
|
+
const statusOnly = await workflow.runExecutionResult(runId, {
|
|
160
|
+
fields: ['status'],
|
|
161
|
+
});
|
|
162
|
+
console.log(statusOnly.status); // 'success' | 'failed' | 'running' | etc.
|
|
163
|
+
|
|
164
|
+
// Get status and result
|
|
165
|
+
const statusAndResult = await workflow.runExecutionResult(runId, {
|
|
166
|
+
fields: ['status', 'result'],
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Get all fields but without nested workflow data (faster)
|
|
170
|
+
const resultWithoutNested = await workflow.runExecutionResult(runId, {
|
|
171
|
+
withNestedWorkflows: false,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Get specific fields without nested workflow data
|
|
175
|
+
const optimized = await workflow.runExecutionResult(runId, {
|
|
176
|
+
fields: ['status', 'steps'],
|
|
177
|
+
withNestedWorkflows: false,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Get full execution result (default behavior)
|
|
181
|
+
const fullResult = await workflow.runExecutionResult(runId);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Core API Changes
|
|
185
|
+
|
|
186
|
+
The `Workflow.getWorkflowRunExecutionResult` method now accepts an options object:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
await workflow.getWorkflowRunExecutionResult(runId, {
|
|
190
|
+
withNestedWorkflows: false, // default: true, set to false to skip nested workflow data
|
|
191
|
+
fields: ['status', 'result'], // optional field filtering
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Inngest Compatibility
|
|
196
|
+
|
|
197
|
+
The `@mastra/inngest` package has been updated to use the new options object API. This is a non-breaking internal change - no action required from inngest workflow users.
|
|
198
|
+
|
|
199
|
+
## Performance Impact
|
|
200
|
+
|
|
201
|
+
For workflows with large step outputs:
|
|
202
|
+
- Requesting only `status`: ~99% reduction in payload size
|
|
203
|
+
- Requesting `status,result,error`: ~95% reduction in payload size
|
|
204
|
+
- Using `withNestedWorkflows=false`: Avoids expensive nested workflow data fetching
|
|
205
|
+
- Combining both: Maximum performance optimization
|
|
206
|
+
|
|
207
|
+
- Updated dependencies [[`4f94ed8`](https://github.com/mastra-ai/mastra/commit/4f94ed8177abfde3ec536e3574883e075423350c), [`ac3cc23`](https://github.com/mastra-ai/mastra/commit/ac3cc2397d1966bc0fc2736a223abc449d3c7719), [`a86f4df`](https://github.com/mastra-ai/mastra/commit/a86f4df0407311e0d2ea49b9a541f0938810d6a9), [`029540c`](https://github.com/mastra-ai/mastra/commit/029540ca1e582fc2dd8d288ecd4a9b0f31a954ef), [`66741d1`](https://github.com/mastra-ai/mastra/commit/66741d1a99c4f42cf23a16109939e8348ac6852e), [`01b20fe`](https://github.com/mastra-ai/mastra/commit/01b20fefb7c67c2b7d79417598ef4e60256d1225), [`0dbf199`](https://github.com/mastra-ai/mastra/commit/0dbf199110f22192ce5c95b1c8148d4872b4d119), [`a7ce182`](https://github.com/mastra-ai/mastra/commit/a7ce1822a8785ce45d62dd5c911af465e144f7d7)]:
|
|
208
|
+
- @mastra/core@1.0.0-beta.14
|
|
209
|
+
|
|
210
|
+
## 1.0.0-beta.8
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- Add `onFinish` and `onError` lifecycle callbacks to workflow options ([#11200](https://github.com/mastra-ai/mastra/pull/11200))
|
|
215
|
+
|
|
216
|
+
Workflows now support lifecycle callbacks for server-side handling of workflow completion and errors:
|
|
217
|
+
- `onFinish`: Called when workflow completes with any status (success, failed, suspended, tripwire)
|
|
218
|
+
- `onError`: Called only when workflow fails (failed or tripwire status)
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
const workflow = createWorkflow({
|
|
222
|
+
id: 'my-workflow',
|
|
223
|
+
inputSchema: z.object({ ... }),
|
|
224
|
+
outputSchema: z.object({ ... }),
|
|
225
|
+
options: {
|
|
226
|
+
onFinish: async (result) => {
|
|
227
|
+
// Handle any workflow completion
|
|
228
|
+
await updateJobStatus(result.status);
|
|
229
|
+
},
|
|
230
|
+
onError: async (errorInfo) => {
|
|
231
|
+
// Handle workflow failures
|
|
232
|
+
await logError(errorInfo.error);
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Both callbacks support sync and async functions. Callback errors are caught and logged, not propagated to the workflow result.
|
|
239
|
+
|
|
240
|
+
- Updated dependencies [[`919a22b`](https://github.com/mastra-ai/mastra/commit/919a22b25876f9ed5891efe5facbe682c30ff497)]:
|
|
241
|
+
- @mastra/core@1.0.0-beta.13
|
|
242
|
+
|
|
243
|
+
## 1.0.0-beta.7
|
|
244
|
+
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
|
|
248
|
+
- Errors thrown in workflow steps now preserve full error details including `cause` chain and custom properties
|
|
249
|
+
- Added `SerializedError` type with proper cause chain support
|
|
250
|
+
- Added `SerializedStepResult` and `SerializedStepFailure` types for handling errors loaded from storage
|
|
251
|
+
- Enhanced `addErrorToJSON` to recursively serialize error cause chains with max depth protection
|
|
252
|
+
- Added `hydrateSerializedStepErrors` to convert serialized errors back to Error instances
|
|
253
|
+
- Fixed Inngest workflow error handling to extract original error from `NonRetriableError.cause`
|
|
254
|
+
|
|
255
|
+
- Refactor internal event system from Emitter to PubSub abstraction for workflow event handling. This change replaces the EventEmitter-based event system with a pluggable PubSub interface, enabling support for distributed workflow execution backends like Inngest. Adds `close()` method to PubSub implementations for proper cleanup. ([#11052](https://github.com/mastra-ai/mastra/pull/11052))
|
|
256
|
+
|
|
257
|
+
- Add `startAsync()` method and fix Inngest duplicate workflow execution bug ([#11093](https://github.com/mastra-ai/mastra/pull/11093))
|
|
258
|
+
|
|
259
|
+
**New Feature: `startAsync()` for fire-and-forget workflow execution**
|
|
260
|
+
- Add `Run.startAsync()` to base workflow class - starts workflow in background and returns `{ runId }` immediately
|
|
261
|
+
- Add `EventedRun.startAsync()` - publishes workflow start event without subscribing for completion
|
|
262
|
+
- Add `InngestRun.startAsync()` - sends Inngest event without polling for result
|
|
263
|
+
|
|
264
|
+
**Bug Fix: Prevent duplicate Inngest workflow executions**
|
|
265
|
+
- Fix `getRuns()` to properly handle rate limits (429), empty responses, and JSON parse errors with retry logic and exponential backoff
|
|
266
|
+
- Fix `getRunOutput()` to throw `NonRetriableError` when polling fails, preventing Inngest from retrying the parent function and re-triggering the workflow
|
|
267
|
+
- Add timeout to `getRunOutput()` polling (default 5 minutes) with `NonRetriableError` on timeout
|
|
268
|
+
|
|
269
|
+
This fixes a production issue where polling failures after successful workflow completion caused Inngest to retry the parent function, which fired a new workflow event and resulted in duplicate executions (e.g., duplicate Slack messages).
|
|
270
|
+
|
|
271
|
+
- Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
|
|
272
|
+
|
|
273
|
+
Workflow errors now retain custom properties like `statusCode`, `responseHeaders`, and `cause` chains. This enables error-specific recovery logic in your applications.
|
|
274
|
+
|
|
275
|
+
**Before:**
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
const result = await workflow.execute({ input });
|
|
279
|
+
if (result.status === 'failed') {
|
|
280
|
+
// Custom error properties were lost
|
|
281
|
+
console.log(result.error); // "Step execution failed" (just a string)
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**After:**
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const result = await workflow.execute({ input });
|
|
289
|
+
if (result.status === 'failed') {
|
|
290
|
+
// Custom properties are preserved
|
|
291
|
+
console.log(result.error.message); // "Step execution failed"
|
|
292
|
+
console.log(result.error.statusCode); // 429
|
|
293
|
+
console.log(result.error.cause?.name); // "RateLimitError"
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Type change:** `WorkflowState.error` and `WorkflowRunState.error` types changed from `string | Error` to `SerializedError`.
|
|
298
|
+
|
|
299
|
+
Other changes:
|
|
300
|
+
- Added `UpdateWorkflowStateOptions` type for workflow state updates
|
|
301
|
+
|
|
302
|
+
- Updated dependencies [[`d5ed981`](https://github.com/mastra-ai/mastra/commit/d5ed981c8701c1b8a27a5f35a9a2f7d9244e695f), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd), [`b760b73`](https://github.com/mastra-ai/mastra/commit/b760b731aca7c8a3f041f61d57a7f125ae9cb215), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`2b459f4`](https://github.com/mastra-ai/mastra/commit/2b459f466fd91688eeb2a44801dc23f7f8a887ab), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`24b76d8`](https://github.com/mastra-ai/mastra/commit/24b76d8e17656269c8ed09a0c038adb9cc2ae95a), [`243a823`](https://github.com/mastra-ai/mastra/commit/243a8239c5906f5c94e4f78b54676793f7510ae3), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`c61fac3`](https://github.com/mastra-ai/mastra/commit/c61fac3add96f0dcce0208c07415279e2537eb62), [`6f14f70`](https://github.com/mastra-ai/mastra/commit/6f14f706ccaaf81b69544b6c1b75ab66a41e5317), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f), [`2a53598`](https://github.com/mastra-ai/mastra/commit/2a53598c6d8cfeb904a7fc74e57e526d751c8fa6), [`c7cd3c7`](https://github.com/mastra-ai/mastra/commit/c7cd3c7a187d7aaf79e2ca139de328bf609a14b4), [`847c212`](https://github.com/mastra-ai/mastra/commit/847c212caba7df0d6f2fc756b494ac3c75c3720d), [`6f941c4`](https://github.com/mastra-ai/mastra/commit/6f941c438ca5f578619788acc7608fc2e23bd176)]:
|
|
303
|
+
- @mastra/core@1.0.0-beta.12
|
|
304
|
+
|
|
305
|
+
## 1.0.0-beta.6
|
|
306
|
+
|
|
307
|
+
### Patch Changes
|
|
308
|
+
|
|
309
|
+
- Support new Workflow tripwire run status. Tripwires that are thrown from within a workflow will now bubble up and return a graceful state with information about tripwires. ([#10947](https://github.com/mastra-ai/mastra/pull/10947))
|
|
310
|
+
|
|
311
|
+
When a workflow contains an agent step that triggers a tripwire, the workflow returns with `status: 'tripwire'` and includes tripwire details:
|
|
312
|
+
|
|
313
|
+
```typescript showLineNumbers copy
|
|
314
|
+
const run = await workflow.createRun();
|
|
315
|
+
const result = await run.start({ inputData: { message: 'Hello' } });
|
|
316
|
+
|
|
317
|
+
if (result.status === 'tripwire') {
|
|
318
|
+
console.log('Workflow terminated by tripwire:', result.tripwire?.reason);
|
|
319
|
+
console.log('Processor ID:', result.tripwire?.processorId);
|
|
320
|
+
console.log('Retry requested:', result.tripwire?.retry);
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Adds new UI state for tripwire in agent chat and workflow UI.
|
|
325
|
+
|
|
326
|
+
This is distinct from `status: 'failed'` which indicates an unexpected error. A tripwire status means a processor intentionally stopped execution (e.g., for content moderation).
|
|
327
|
+
|
|
328
|
+
- Updated dependencies [[`38380b6`](https://github.com/mastra-ai/mastra/commit/38380b60fca905824bdf6b43df307a58efb1aa15), [`798d0c7`](https://github.com/mastra-ai/mastra/commit/798d0c740232653b1d754870e6b43a55c364ffe2), [`ffe84d5`](https://github.com/mastra-ai/mastra/commit/ffe84d54f3b0f85167fe977efd027dba027eb998), [`2c212e7`](https://github.com/mastra-ai/mastra/commit/2c212e704c90e2db83d4109e62c03f0f6ebd2667), [`4ca4306`](https://github.com/mastra-ai/mastra/commit/4ca430614daa5fa04730205a302a43bf4accfe9f), [`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db)]:
|
|
329
|
+
- @mastra/core@1.0.0-beta.11
|
|
330
|
+
|
|
331
|
+
## 1.0.0-beta.5
|
|
332
|
+
|
|
333
|
+
### Patch Changes
|
|
334
|
+
|
|
335
|
+
- Internal code refactoring ([#10830](https://github.com/mastra-ai/mastra/pull/10830))
|
|
336
|
+
|
|
337
|
+
- Add support for typed structured output in agent workflow steps ([#11014](https://github.com/mastra-ai/mastra/pull/11014))
|
|
338
|
+
|
|
339
|
+
When wrapping an agent with `createStep()` and providing a `structuredOutput.schema`, the step's `outputSchema` is now correctly inferred from the provided schema instead of defaulting to `{ text: string }`.
|
|
340
|
+
|
|
341
|
+
This enables type-safe chaining of agent steps with structured output to subsequent steps:
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
const articleSchema = z.object({
|
|
345
|
+
title: z.string(),
|
|
346
|
+
summary: z.string(),
|
|
347
|
+
tags: z.array(z.string()),
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Agent step with structured output - outputSchema is now articleSchema
|
|
351
|
+
const agentStep = createStep(agent, {
|
|
352
|
+
structuredOutput: { schema: articleSchema },
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Next step can receive the structured output directly
|
|
356
|
+
const processStep = createStep({
|
|
357
|
+
id: 'process',
|
|
358
|
+
inputSchema: articleSchema, // Matches agent's outputSchema
|
|
359
|
+
outputSchema: z.object({ tagCount: z.number() }),
|
|
360
|
+
execute: async ({ inputData }) => ({
|
|
361
|
+
tagCount: inputData.tags.length, // Fully typed!
|
|
362
|
+
}),
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
workflow.then(agentStep).then(processStep).commit();
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
When `structuredOutput` is not provided, the agent step continues to use the default `{ text: string }` output schema.
|
|
369
|
+
|
|
370
|
+
- Updated dependencies [[`edb07e4`](https://github.com/mastra-ai/mastra/commit/edb07e49283e0c28bd094a60e03439bf6ecf0221), [`b7e17d3`](https://github.com/mastra-ai/mastra/commit/b7e17d3f5390bb5a71efc112204413656fcdc18d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`5d7000f`](https://github.com/mastra-ai/mastra/commit/5d7000f757cd65ea9dc5b05e662fd83dfd44e932), [`4f0331a`](https://github.com/mastra-ai/mastra/commit/4f0331a79bf6eb5ee598a5086e55de4b5a0ada03), [`8a000da`](https://github.com/mastra-ai/mastra/commit/8a000da0c09c679a2312f6b3aa05b2ca78ca7393)]:
|
|
371
|
+
- @mastra/core@1.0.0-beta.10
|
|
372
|
+
|
|
373
|
+
## 1.0.0-beta.4
|
|
374
|
+
|
|
375
|
+
### Patch Changes
|
|
376
|
+
|
|
377
|
+
- Include `.input` in workflow results for both engines and remove the option to omit them from Inngest workflows. ([#10688](https://github.com/mastra-ai/mastra/pull/10688))
|
|
378
|
+
|
|
379
|
+
- Using `createStep` with a nested Inngest workflow now returns the workflow itself, maintaining the correct `.invoke()` execution flow Inngest workflows need to operate. ([#10689](https://github.com/mastra-ai/mastra/pull/10689))
|
|
380
|
+
|
|
381
|
+
- Refactored default engine to fit durable execution better, and the inngest engine to match. ([#10627](https://github.com/mastra-ai/mastra/pull/10627))
|
|
382
|
+
Also fixes requestContext persistence by relying on inngest step memoization.
|
|
383
|
+
|
|
384
|
+
Unifies some of the stepResults and error formats in both engines.
|
|
385
|
+
|
|
386
|
+
- Miscellanous bug fixes and test fixes: ([#10515](https://github.com/mastra-ai/mastra/pull/10515))
|
|
387
|
+
- cloneWorkflow passing options correctly
|
|
388
|
+
- start event in streamLegacy
|
|
389
|
+
- Many test cases with outdated or incorrect expected values
|
|
390
|
+
|
|
391
|
+
- Emit workflow-step-result and workflow-step-finish when step fails in inngest workflow ([#10555](https://github.com/mastra-ai/mastra/pull/10555))
|
|
392
|
+
|
|
393
|
+
- Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
|
|
394
|
+
- @mastra/core@1.0.0-beta.6
|
|
395
|
+
|
|
396
|
+
## 1.0.0-beta.3
|
|
397
|
+
|
|
398
|
+
### Patch Changes
|
|
399
|
+
|
|
400
|
+
- - Fix tool suspension throwing error when `outputSchema` is passed to tool during creation ([#10444](https://github.com/mastra-ai/mastra/pull/10444))
|
|
401
|
+
- Pass `suspendSchema` and `resumeSchema` from tool into step created when creating step from tool
|
|
402
|
+
- Updated dependencies [[`21a15de`](https://github.com/mastra-ai/mastra/commit/21a15de369fe82aac26bb642ed7be73505475e8b), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`b0e2ea5`](https://github.com/mastra-ai/mastra/commit/b0e2ea5b52c40fae438b9e2f7baee6f0f89c5442), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ab035c2`](https://github.com/mastra-ai/mastra/commit/ab035c2ef6d8cc7bb25f06f1a38508bd9e6f126b), [`1a46a56`](https://github.com/mastra-ai/mastra/commit/1a46a566f45a3fcbadc1cf36bf86d351f264bfa3), [`3cf540b`](https://github.com/mastra-ai/mastra/commit/3cf540b9fbfea8f4fc8d3a2319a4e6c0b0cbfd52), [`1c6ce51`](https://github.com/mastra-ai/mastra/commit/1c6ce51f875915ab57fd36873623013699a2a65d), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`ccc141e`](https://github.com/mastra-ai/mastra/commit/ccc141ed27da0abc3a3fc28e9e5128152e8e37f4), [`fe3b897`](https://github.com/mastra-ai/mastra/commit/fe3b897c2ccbcd2b10e81b099438c7337feddf89), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`29c4309`](https://github.com/mastra-ai/mastra/commit/29c4309f818b24304c041bcb4a8f19b5f13f6b62), [`16785ce`](https://github.com/mastra-ai/mastra/commit/16785ced928f6f22638f4488cf8a125d99211799), [`de8239b`](https://github.com/mastra-ai/mastra/commit/de8239bdcb1d8c0cfa06da21f1569912a66bbc8a), [`b5e6cd7`](https://github.com/mastra-ai/mastra/commit/b5e6cd77fc8c8e64e0494c1d06cee3d84e795d1e), [`3759cb0`](https://github.com/mastra-ai/mastra/commit/3759cb064935b5f74c65ac2f52a1145f7352899d), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`c0b731f`](https://github.com/mastra-ai/mastra/commit/c0b731fb27d712dc8582e846df5c0332a6a0c5ba), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc)]:
|
|
403
|
+
- @mastra/core@1.0.0-beta.5
|
|
404
|
+
|
|
405
|
+
## 1.0.0-beta.2
|
|
406
|
+
|
|
407
|
+
### Patch Changes
|
|
408
|
+
|
|
409
|
+
- dependencies updates: ([#10120](https://github.com/mastra-ai/mastra/pull/10120))
|
|
410
|
+
- Updated dependency [`@inngest/realtime@^0.4.5` ↗︎](https://www.npmjs.com/package/@inngest/realtime/v/0.4.5) (from `^0.4.4`, in `dependencies`)
|
|
411
|
+
|
|
412
|
+
- fix resumeStream type to use resumeSchema ([#10202](https://github.com/mastra-ai/mastra/pull/10202))
|
|
413
|
+
|
|
414
|
+
- Add restart method to workflow run that allows restarting an active workflow run ([#9750](https://github.com/mastra-ai/mastra/pull/9750))
|
|
415
|
+
Add status filter to `listWorkflowRuns`
|
|
416
|
+
Add automatic restart to restart active workflow runs when server starts
|
|
417
|
+
|
|
418
|
+
- Validate schemas by default in workflow. Previously, if you want schemas in the workflow to be validated, you'd have to add `validateInputs` option, now, this will be done by default but can be disabled. ([#10186](https://github.com/mastra-ai/mastra/pull/10186))
|
|
419
|
+
|
|
420
|
+
For workflows whose schemas and step schemas you don't want validated, do this
|
|
421
|
+
|
|
422
|
+
```diff
|
|
423
|
+
createWorkflow({
|
|
424
|
+
+ options: {
|
|
425
|
+
+ validateInputs: false
|
|
426
|
+
+ }
|
|
427
|
+
})
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
- Fix inngest parallel workflow ([#10169](https://github.com/mastra-ai/mastra/pull/10169))
|
|
431
|
+
Fix tool as step in inngest
|
|
432
|
+
Fix inngest nested workflow
|
|
433
|
+
|
|
434
|
+
- Add timeTravel to workflows. This makes it possible to start a workflow run from a particular step in the workflow ([#9994](https://github.com/mastra-ai/mastra/pull/9994))
|
|
435
|
+
|
|
436
|
+
Example code:
|
|
437
|
+
|
|
438
|
+
```ts
|
|
439
|
+
const result = await run.timeTravel({
|
|
440
|
+
step: 'step2',
|
|
441
|
+
inputData: {
|
|
442
|
+
value: 'input',
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
- Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4)]:
|
|
448
|
+
- @mastra/core@1.0.0-beta.3
|
|
449
|
+
|
|
450
|
+
## 1.0.0-beta.1
|
|
451
|
+
|
|
452
|
+
### Patch Changes
|
|
453
|
+
|
|
454
|
+
- Make suspendPayload optional when calling `suspend()` ([#9926](https://github.com/mastra-ai/mastra/pull/9926))
|
|
455
|
+
Save value returned as `suspendOutput` if user returns data still after calling `suspend()`
|
|
456
|
+
Automatically call `commit()` on uncommitted workflows when registering in Mastra instance
|
|
457
|
+
Show actual suspendPayload on Studio in suspend/resume flow
|
|
458
|
+
- Updated dependencies [[`465ac05`](https://github.com/mastra-ai/mastra/commit/465ac0526a91d175542091c675181f1a96c98c46)]:
|
|
459
|
+
- @mastra/core@1.0.0-beta.2
|
|
460
|
+
|
|
3
461
|
## 1.0.0-beta.0
|
|
4
462
|
|
|
5
463
|
### Major Changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { SerializedError } from '@mastra/core/error';
|
|
2
|
+
import type { PubSub } from '@mastra/core/events';
|
|
3
|
+
import type { Mastra } from '@mastra/core/mastra';
|
|
4
|
+
import { DefaultExecutionEngine } from '@mastra/core/workflows';
|
|
5
|
+
import type { ExecutionContext, Step, StepResult, ExecutionEngineOptions, TimeTravelExecutionParams } from '@mastra/core/workflows';
|
|
6
|
+
import type { Inngest, BaseContext } from 'inngest';
|
|
7
|
+
export declare class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
8
|
+
private inngestStep;
|
|
9
|
+
private inngestAttempts;
|
|
10
|
+
constructor(mastra: Mastra, inngestStep: BaseContext<Inngest>['step'], inngestAttempts: number | undefined, options: ExecutionEngineOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Format errors while preserving Error instances and their custom properties.
|
|
13
|
+
* Uses getErrorFromUnknown to ensure all error properties are preserved.
|
|
14
|
+
*/
|
|
15
|
+
protected formatResultError(error: Error | string | undefined, lastOutput: StepResult<any, any, any, any>): SerializedError;
|
|
16
|
+
/**
|
|
17
|
+
* Detect InngestWorkflow instances for special nested workflow handling
|
|
18
|
+
*/
|
|
19
|
+
isNestedWorkflowStep(step: Step<any, any, any>): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Inngest requires requestContext serialization for memoization.
|
|
22
|
+
* When steps are replayed, the original function doesn't re-execute,
|
|
23
|
+
* so requestContext modifications must be captured and restored.
|
|
24
|
+
*/
|
|
25
|
+
requiresDurableContextSerialization(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Execute a step with retry logic for Inngest.
|
|
28
|
+
* Retries are handled via step-level retry (RetryAfterError thrown INSIDE step.run()).
|
|
29
|
+
* After retries exhausted, error propagates here and we return a failed result.
|
|
30
|
+
*/
|
|
31
|
+
executeStepWithRetry<T>(stepId: string, runStep: () => Promise<T>, params: {
|
|
32
|
+
retries: number;
|
|
33
|
+
delay: number;
|
|
34
|
+
stepSpan?: any;
|
|
35
|
+
workflowId: string;
|
|
36
|
+
runId: string;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
ok: true;
|
|
39
|
+
result: T;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: {
|
|
43
|
+
status: 'failed';
|
|
44
|
+
error: Error;
|
|
45
|
+
endedAt: number;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Use Inngest's sleep primitive for durability
|
|
50
|
+
*/
|
|
51
|
+
executeSleepDuration(duration: number, sleepId: string, workflowId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Use Inngest's sleepUntil primitive for durability
|
|
54
|
+
*/
|
|
55
|
+
executeSleepUntilDate(date: Date, sleepUntilId: string, workflowId: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Wrap durable operations in Inngest step.run() for durability.
|
|
58
|
+
* If retryConfig is provided, throws RetryAfterError INSIDE step.run() to trigger
|
|
59
|
+
* Inngest's step-level retry mechanism (not function-level retry).
|
|
60
|
+
*/
|
|
61
|
+
wrapDurableOperation<T>(operationId: string, operationFn: () => Promise<T>, retryConfig?: {
|
|
62
|
+
delay: number;
|
|
63
|
+
}): Promise<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Provide Inngest step primitive in engine context
|
|
66
|
+
*/
|
|
67
|
+
getEngineContext(): Record<string, any>;
|
|
68
|
+
/**
|
|
69
|
+
* For Inngest, lifecycle callbacks are invoked in the workflow's finalize step
|
|
70
|
+
* (wrapped in step.run for durability), not in execute(). Override to skip.
|
|
71
|
+
*/
|
|
72
|
+
invokeLifecycleCallbacks(_result: {
|
|
73
|
+
status: any;
|
|
74
|
+
result?: any;
|
|
75
|
+
error?: any;
|
|
76
|
+
steps: Record<string, any>;
|
|
77
|
+
tripwire?: any;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Actually invoke the lifecycle callbacks. Called from workflow.ts finalize step.
|
|
81
|
+
*/
|
|
82
|
+
invokeLifecycleCallbacksInternal(result: {
|
|
83
|
+
status: any;
|
|
84
|
+
result?: any;
|
|
85
|
+
error?: any;
|
|
86
|
+
steps: Record<string, any>;
|
|
87
|
+
tripwire?: any;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Execute nested InngestWorkflow using inngestStep.invoke() for durability.
|
|
91
|
+
* This MUST be called directly (not inside step.run()) due to Inngest constraints.
|
|
92
|
+
*/
|
|
93
|
+
executeWorkflowStep(params: {
|
|
94
|
+
step: Step<string, any, any>;
|
|
95
|
+
stepResults: Record<string, StepResult<any, any, any, any>>;
|
|
96
|
+
executionContext: ExecutionContext;
|
|
97
|
+
resume?: {
|
|
98
|
+
steps: string[];
|
|
99
|
+
resumePayload: any;
|
|
100
|
+
runId?: string;
|
|
101
|
+
};
|
|
102
|
+
timeTravel?: TimeTravelExecutionParams;
|
|
103
|
+
prevOutput: any;
|
|
104
|
+
inputData: any;
|
|
105
|
+
pubsub: PubSub;
|
|
106
|
+
startedAt: number;
|
|
107
|
+
perStep?: boolean;
|
|
108
|
+
}): Promise<StepResult<any, any, any, any> | null>;
|
|
109
|
+
}
|
|
110
|
+
//# 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":"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"}
|