@mastra/mcp-docs-server 0.13.46-alpha.0 → 0.13.46-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.
Files changed (42) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +9 -9
  2. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +11 -11
  3. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +79 -79
  4. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +52 -52
  5. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +11 -11
  6. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +11 -11
  7. package/.docs/organized/changelogs/%40mastra%2Fcore.md +49 -49
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +15 -15
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +18 -18
  10. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +12 -12
  11. package/.docs/organized/changelogs/%40mastra%2Flance.md +11 -11
  12. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +11 -11
  13. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +8 -8
  14. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +9 -9
  15. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +11 -11
  16. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +12 -12
  17. package/.docs/organized/changelogs/%40mastra%2Fpg.md +11 -11
  18. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +17 -17
  19. package/.docs/organized/changelogs/%40mastra%2Freact.md +8 -8
  20. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  21. package/.docs/organized/changelogs/%40mastra%2Fserver.md +54 -54
  22. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +12 -12
  23. package/.docs/organized/changelogs/create-mastra.md +11 -11
  24. package/.docs/organized/changelogs/mastra.md +18 -18
  25. package/.docs/raw/observability/otel-tracing.mdx +17 -2
  26. package/.docs/raw/observability/overview.mdx +12 -2
  27. package/.docs/raw/rag/vector-databases.mdx +58 -0
  28. package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
  29. package/.docs/raw/reference/workflows/run-methods/restart.mdx +98 -0
  30. package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
  31. package/.docs/raw/reference/workflows/run.mdx +21 -0
  32. package/.docs/raw/reference/workflows/step.mdx +7 -0
  33. package/.docs/raw/reference/workflows/workflow.mdx +19 -0
  34. package/.docs/raw/server-db/mastra-server.mdx +1 -1
  35. package/.docs/raw/workflows/error-handling.mdx +1 -0
  36. package/.docs/raw/workflows/overview.mdx +56 -44
  37. package/.docs/raw/workflows/snapshots.mdx +1 -0
  38. package/.docs/raw/workflows/suspend-and-resume.mdx +2 -0
  39. package/.docs/raw/workflows/time-travel.mdx +313 -0
  40. package/.docs/raw/workflows/workflow-state.mdx +191 -0
  41. package/CHANGELOG.md +7 -0
  42. package/package.json +4 -4
@@ -25,7 +25,17 @@ Specialized tracing for AI operations that captures:
25
25
  - **Workflow steps**: Branching logic, parallel execution, and step outputs
26
26
  - **Automatic instrumentation**: Zero-configuration tracing with decorators
27
27
 
28
- ### OTEL Tracing
28
+ ### OTEL Tracing (Deprecated)
29
+
30
+ :::warning
31
+ OTEL Tracing via the `telemetry` configuration is deprecated and will be removed in a future release. Use [AI Tracing](/docs/observability/ai-tracing/overview) with the [OpenTelemetry exporter](/docs/observability/ai-tracing/exporters/otel) instead for OTLP-compatible tracing.
32
+
33
+ If you are not using the old `telemetry` system, you should explicitly disable it to suppress deprecation warnings:
34
+
35
+ ```typescript
36
+ telemetry: { enabled: false }
37
+ ```
38
+ :::
29
39
 
30
40
  Traditional distributed tracing with OpenTelemetry:
31
41
 
@@ -53,7 +63,7 @@ export const mastra = new Mastra({
53
63
  url: "file:./mastra.db", // Storage is required for tracing
54
64
  }),
55
65
  telemetry: {
56
- enabled: true, // Enables OTEL Tracing
66
+ enabled: false, // Disable deprecated OTEL Tracing to suppress warnings
57
67
  },
58
68
  });
59
69
  ```
@@ -530,6 +530,64 @@ Key metadata considerations:
530
530
  - Only include fields you plan to filter or sort by - extra fields add overhead
531
531
  - Add timestamps (e.g., 'createdAt', 'lastUpdated') to track content freshness
532
532
 
533
+ ## Deleting Vectors
534
+
535
+ When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it easy to remove all embeddings associated with a specific document.
536
+
537
+ ### Delete by Metadata Filter
538
+
539
+ The most common use case is deleting all vectors for a specific document when a user deletes it:
540
+
541
+ ```ts title="delete-vectors.ts" showLineNumbers copy
542
+ // Delete all vectors for a specific document
543
+ await store.deleteVectors({
544
+ indexName: "myCollection",
545
+ filter: { docId: "document-123" },
546
+ });
547
+ ```
548
+
549
+ This is particularly useful when:
550
+ - A user deletes a document and you need to remove all its chunks
551
+ - You're re-indexing a document and want to remove old vectors first
552
+ - You need to clean up vectors for a specific user or tenant
553
+
554
+ ### Delete Multiple Documents
555
+
556
+ You can also use complex filters to delete vectors matching multiple conditions:
557
+
558
+ ```ts title="delete-vectors-advanced.ts" showLineNumbers copy
559
+ // Delete all vectors for multiple documents
560
+ await store.deleteVectors({
561
+ indexName: "myCollection",
562
+ filter: {
563
+ docId: { $in: ["doc-1", "doc-2", "doc-3"] },
564
+ },
565
+ });
566
+
567
+ // Delete vectors for a specific user's documents
568
+ await store.deleteVectors({
569
+ indexName: "myCollection",
570
+ filter: {
571
+ $and: [
572
+ { userId: "user-123" },
573
+ { status: "archived" },
574
+ ],
575
+ },
576
+ });
577
+ ```
578
+
579
+ ### Delete by Vector IDs
580
+
581
+ If you have specific vector IDs to delete, you can pass them directly:
582
+
583
+ ```ts title="delete-by-ids.ts" showLineNumbers copy
584
+ // Delete specific vectors by their IDs
585
+ await store.deleteVectors({
586
+ indexName: "myCollection",
587
+ ids: ["vec-1", "vec-2", "vec-3"],
588
+ });
589
+ ```
590
+
533
591
  ## Best Practices
534
592
 
535
593
  - Create indexes before bulk insertions
@@ -0,0 +1,170 @@
1
+ ---
2
+ title: "Reference: Run.timeTravelStream() | Streaming"
3
+ description: Documentation for the `Run.timeTravelStream()` method for streaming workflow time travel execution.
4
+ ---
5
+
6
+ # Run.timeTravelStream()
7
+
8
+ The `.timeTravelStream()` method re-executes a workflow starting from any specific step with streaming events. This allows you to receive real-time updates during time travel execution while maintaining full visibility into each step's progress.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript showLineNumbers copy
13
+ const run = await workflow.createRunAsync();
14
+
15
+ const output = run.timeTravelStream({
16
+ step: "step2",
17
+ inputData: { value: 10 },
18
+ });
19
+
20
+ // Process events as they arrive
21
+ for await (const event of output.fullStream) {
22
+ console.log(event.type, event.payload);
23
+ }
24
+
25
+ // Get the final result
26
+ const result = await output.result;
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ All parameters are the same as [`Run.timeTravel()`](../../workflows/run-methods/timeTravel#parameters). See the [timeTravel reference](../../workflows/run-methods/timeTravel#parameters) for detailed parameter documentation.
32
+
33
+ ## Returns
34
+
35
+ <PropertiesTable
36
+ content={[
37
+ {
38
+ name: "output",
39
+ type: "WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>",
40
+ description:
41
+ "An object containing both the stream and result promise",
42
+ },
43
+ {
44
+ name: "output.fullStream",
45
+ type: "ReadableStream<WorkflowStreamEvent>",
46
+ description:
47
+ "A readable stream that emits workflow events as execution progresses",
48
+ },
49
+ {
50
+ name: "output.result",
51
+ type: "Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>",
52
+ description:
53
+ "A promise that resolves to the final workflow execution result",
54
+ },
55
+ {
56
+ name: "output.traceId",
57
+ type: "string",
58
+ isOptional: true,
59
+ description:
60
+ "The trace ID associated with this execution when Tracing is enabled",
61
+ },
62
+ ]}
63
+ />
64
+
65
+ ## Stream events
66
+
67
+ The stream emits various workflow events during execution:
68
+
69
+ - `workflow-step-start`: Emitted when a step begins execution
70
+ - `workflow-step-finish`: Emitted when a step completes successfully
71
+ - `workflow-step-error`: Emitted when a step encounters an error
72
+ - `workflow-step-suspended`: Emitted when a step suspends
73
+ - Additional events depending on step types (agents, tools, etc.)
74
+
75
+ ## Extended usage examples
76
+
77
+ ### Processing events during time travel
78
+
79
+ ```typescript showLineNumbers copy
80
+ const run = await workflow.createRunAsync();
81
+
82
+ const output = run.timeTravelStream({
83
+ step: "step2",
84
+ inputData: { value: 10 },
85
+ });
86
+
87
+ for await (const event of output.fullStream) {
88
+ switch (event.type) {
89
+ case "workflow-step-start":
90
+ console.log(`Starting step: ${event.payload.stepName}`);
91
+ break;
92
+ case "workflow-step-finish":
93
+ console.log(`Completed step: ${event.payload.stepName}`);
94
+ break;
95
+ case "workflow-step-error":
96
+ console.error(`Error in step: ${event.payload.stepName}`, event.payload.error);
97
+ break;
98
+ }
99
+ }
100
+
101
+ const result = await output.result;
102
+ console.log("Time travel completed:", result);
103
+ ```
104
+
105
+ ### Time travel stream with context
106
+
107
+ ```typescript showLineNumbers copy
108
+ const output = run.timeTravelStream({
109
+ step: "step2",
110
+ context: {
111
+ step1: {
112
+ status: "success",
113
+ payload: { value: 0 },
114
+ output: { step1Result: 2 },
115
+ startedAt: Date.now(),
116
+ endedAt: Date.now(),
117
+ },
118
+ },
119
+ });
120
+
121
+ for await (const event of output.fullStream) {
122
+ // Handle events
123
+ console.log(event);
124
+ }
125
+
126
+ const result = await output.result;
127
+ ```
128
+
129
+ ### Time travel stream with nested workflows
130
+
131
+ ```typescript showLineNumbers copy
132
+ const output = run.timeTravelStream({
133
+ step: ["nestedWorkflow", "step3"],
134
+ inputData: { value: 10 },
135
+ nestedStepsContext: {
136
+ nestedWorkflow: {
137
+ step2: {
138
+ status: "success",
139
+ payload: { step1Result: 2 },
140
+ output: { step2Result: 3 },
141
+ startedAt: Date.now(),
142
+ endedAt: Date.now(),
143
+ },
144
+ },
145
+ },
146
+ });
147
+
148
+ for await (const event of output.fullStream) {
149
+ console.log(event.type, event.payload);
150
+ }
151
+
152
+ const result = await output.result;
153
+ ```
154
+
155
+ ## Notes
156
+
157
+ - The stream closes automatically when time travel execution completes or encounters an error
158
+ - You can process events from the stream while the workflow is still executing
159
+ - The `result` promise resolves only after all steps have completed
160
+ - Stream events follow the same format as regular workflow streaming
161
+ - Time travel streaming requires storage to be configured since it relies on persisted workflow snapshots
162
+
163
+ ## Related
164
+
165
+ - [Run.timeTravel()](../../workflows/run-methods/timeTravel)
166
+ - [Time Travel](/docs/workflows/time-travel)
167
+ - [Workflow Streaming](/docs/streaming/workflow-streaming)
168
+ - [Run.streamVNext()](./streamVNext)
169
+ - [Run.resumeStreamVNext()](./resumeStreamVNext)
170
+
@@ -0,0 +1,98 @@
1
+ ---
2
+ title: "Reference: Run.restart() | Workflows"
3
+ description: Documentation for the `Run.restart()` method in workflows, which restarts an active workflow run that lost connection to the server.
4
+ ---
5
+
6
+ # Run.restart()
7
+
8
+ The `.restart()` method restarts an active workflow run that lost connection to the server, allowing you to continue execution from the moment it lost connection (the last active step).
9
+
10
+ ## Usage example
11
+
12
+ ```typescript showLineNumbers copy
13
+ const run = await workflow.createRun();
14
+
15
+ const result = await run.start({ inputData: { value: "initial data" } });
16
+
17
+ //.. server connection lost,
18
+
19
+ const restartedResult = await run.restart();
20
+ ```
21
+
22
+ ## Parameters
23
+
24
+ <PropertiesTable
25
+ content={[
26
+ {
27
+ name: "requestContext",
28
+ type: "RequestContext",
29
+ description: "Request Context data to use when resuming",
30
+ isOptional: true,
31
+ },
32
+ {
33
+ name: "tracingContext",
34
+ type: "TracingContext",
35
+ isOptional: true,
36
+ description:
37
+ "Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.",
38
+ properties: [
39
+ {
40
+ parameters: [
41
+ {
42
+ name: "currentSpan",
43
+ type: "Span",
44
+ isOptional: true,
45
+ description:
46
+ "Current span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.",
47
+ },
48
+ ],
49
+ },
50
+ ],
51
+ },
52
+ {
53
+ name: "tracingOptions",
54
+ type: "TracingOptions",
55
+ isOptional: true,
56
+ description: "Options for Tracing configuration.",
57
+ properties: [
58
+ {
59
+ parameters: [
60
+ {
61
+ name: "metadata",
62
+ type: "Record<string, any>",
63
+ isOptional: true,
64
+ description:
65
+ "Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.",
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ ]}
72
+ />
73
+
74
+ ## Returns
75
+
76
+ <PropertiesTable
77
+ content={[
78
+ {
79
+ name: "result",
80
+ type: "Promise<WorkflowResult<TState, TOutput, TSteps>>",
81
+ description:
82
+ "A promise that resolves to the workflow execution result containing step outputs and status",
83
+ },
84
+ {
85
+ name: "traceId",
86
+ type: "string",
87
+ isOptional: true,
88
+ description:
89
+ "The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.",
90
+ },
91
+ ]}
92
+ />
93
+
94
+ ## Related
95
+
96
+ - [Workflows overview](/docs/workflows/overview#running-workflows)
97
+ - [Restart workflows](/docs/workflows/overview#restarting-active-workflow-runs)
98
+ - [Workflow.createRun()](../workflow-methods/create-run)
@@ -0,0 +1,310 @@
1
+ ---
2
+ title: "Reference: Run.timeTravel() | Workflows"
3
+ description: Documentation for the `Run.timeTravel()` method in workflows, which re-executes a workflow from a specific step.
4
+ ---
5
+
6
+ # Run.timeTravel()
7
+
8
+ The `.timeTravel()` method re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide. This is useful for debugging failed workflows, testing individual steps with different inputs, or recovering from errors without re-running the entire workflow.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript showLineNumbers copy
13
+ const run = await workflow.createRunAsync();
14
+
15
+ const result = await run.timeTravel({
16
+ step: "step2",
17
+ inputData: { value: 10 },
18
+ });
19
+ ```
20
+
21
+ ## Parameters
22
+
23
+ <PropertiesTable
24
+ content={[
25
+ {
26
+ name: "step",
27
+ type: "Step<string, any, TInputSchema, any, any, any, TEngineType> | [...Step<string, any, any, any, any, any, TEngineType>[], Step<string, any, TInputSchema, any, any, any, TEngineType>] | string | string[]",
28
+ description:
29
+ "The target step to start execution from. It can be a Step instance, array of Steps (for nested workflows), step ID string, or array of step ID strings. Use dot notation or arrays for nested workflow steps (e.g., 'nestedWorkflow.step3' or ['nestedWorkflow', 'step3'])",
30
+ isOptional: false,
31
+ },
32
+ {
33
+ name: "inputData",
34
+ type: "z.infer<TInputSchema>",
35
+ description: "Input data for the target step. Must match the step's input schema. If not provided, uses data from the workflow snapshot",
36
+ isOptional: true,
37
+ },
38
+ {
39
+ name: "resumeData",
40
+ type: "any",
41
+ description: "Resume data to provide if the workflow was previously suspended",
42
+ isOptional: true,
43
+ },
44
+ {
45
+ name: "initialState",
46
+ type: "z.infer<TState>",
47
+ description: "Initial state to set for the workflow run. Used to set workflow-level state before execution",
48
+ isOptional: true,
49
+ },
50
+ {
51
+ name: "context",
52
+ type: "TimeTravelContext<any, any, any, any>",
53
+ description:
54
+ "Execution context containing step results for steps before the target step. Each key is a step ID with a StepResult object containing status, payload, output, startedAt, endedAt, suspendPayload, and resumePayload",
55
+ isOptional: true,
56
+ },
57
+ {
58
+ name: "nestedStepsContext",
59
+ type: "Record<string, TimeTravelContext<any, any, any, any>>",
60
+ description:
61
+ "Context for nested workflow steps. Keyed by nested workflow ID, each containing step results for that nested workflow",
62
+ isOptional: true,
63
+ },
64
+ {
65
+ name: "requestContext",
66
+ type: "RequestContext",
67
+ description: "Request Context data to use during time travel execution",
68
+ isOptional: true,
69
+ },
70
+ {
71
+ name: "writableStream",
72
+ type: "WritableStream<ChunkType>",
73
+ description: "Optional writable stream for streaming workflow output during time travel",
74
+ isOptional: true,
75
+ },
76
+ {
77
+ name: "tracingContext",
78
+ type: "TracingContext",
79
+ isOptional: true,
80
+ description:
81
+ "Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.",
82
+ properties: [
83
+ {
84
+ parameters: [
85
+ {
86
+ name: "currentSpan",
87
+ type: "Span",
88
+ isOptional: true,
89
+ description:
90
+ "Current span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.",
91
+ },
92
+ ],
93
+ },
94
+ ],
95
+ },
96
+ {
97
+ name: "tracingOptions",
98
+ type: "TracingOptions",
99
+ isOptional: true,
100
+ description: "Options for Tracing configuration.",
101
+ properties: [
102
+ {
103
+ parameters: [
104
+ {
105
+ name: "metadata",
106
+ type: "Record<string, any>",
107
+ isOptional: true,
108
+ description:
109
+ "Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.",
110
+ },
111
+ ],
112
+ },
113
+ {
114
+ parameters: [
115
+ {
116
+ name: "requestContextKeys",
117
+ type: "string[]",
118
+ isOptional: true,
119
+ description:
120
+ "Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').",
121
+ },
122
+ ],
123
+ },
124
+ {
125
+ parameters: [
126
+ {
127
+ name: "traceId",
128
+ type: "string",
129
+ isOptional: true,
130
+ description:
131
+ "Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.",
132
+ },
133
+ ],
134
+ },
135
+ {
136
+ parameters: [
137
+ {
138
+ name: "parentSpanId",
139
+ type: "string",
140
+ isOptional: true,
141
+ description:
142
+ "Parent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.",
143
+ },
144
+ ],
145
+ },
146
+ {
147
+ parameters: [
148
+ {
149
+ name: "tags",
150
+ type: "string[]",
151
+ isOptional: true,
152
+ description:
153
+ "Tags to apply to this trace. String labels for categorizing and filtering traces.",
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ },
159
+ {
160
+ name: "outputOptions",
161
+ type: "OutputOptions",
162
+ isOptional: true,
163
+ description: "Options for output configuration.",
164
+ properties: [
165
+ {
166
+ parameters: [
167
+ {
168
+ name: "includeState",
169
+ type: "boolean",
170
+ isOptional: true,
171
+ description:
172
+ "Whether to include the workflow run state in the result.",
173
+ },
174
+ ],
175
+ },
176
+ {
177
+ parameters: [
178
+ {
179
+ name: "includeResumeLabels",
180
+ type: "boolean",
181
+ isOptional: true,
182
+ description:
183
+ "Whether to include resume labels in the result.",
184
+ },
185
+ ],
186
+ },
187
+ ],
188
+ },
189
+ ]}
190
+ />
191
+
192
+ ## Returns
193
+
194
+ <PropertiesTable
195
+ content={[
196
+ {
197
+ name: "result",
198
+ type: "Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>",
199
+ description:
200
+ "A promise that resolves to the workflow execution result containing step outputs and status",
201
+ },
202
+ {
203
+ name: "traceId",
204
+ type: "string",
205
+ isOptional: true,
206
+ description:
207
+ "The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.",
208
+ },
209
+ ]}
210
+ />
211
+
212
+ ## Extended usage examples
213
+
214
+ ### Time travel with custom context
215
+
216
+ ```typescript showLineNumbers copy
217
+ const result = await run.timeTravel({
218
+ step: "step2",
219
+ context: {
220
+ step1: {
221
+ status: "success",
222
+ payload: { value: 0 },
223
+ output: { step1Result: 2 },
224
+ startedAt: Date.now(),
225
+ endedAt: Date.now(),
226
+ },
227
+ },
228
+ });
229
+ ```
230
+
231
+ ### Time travel to nested workflow step
232
+
233
+ ```typescript showLineNumbers copy
234
+ // Using dot notation
235
+ const result = await run.timeTravel({
236
+ step: "nestedWorkflow.step3",
237
+ inputData: { value: 10 },
238
+ });
239
+
240
+ // Using array of step IDs
241
+ const result = await run.timeTravel({
242
+ step: ["nestedWorkflow", "step3"],
243
+ inputData: { value: 10 },
244
+ });
245
+ ```
246
+
247
+ ### Time travel with initial state
248
+
249
+ ```typescript showLineNumbers copy
250
+ const result = await run.timeTravel({
251
+ step: "step2",
252
+ inputData: { value: 10 },
253
+ initialState: {
254
+ counter: 5,
255
+ metadata: { source: "time-travel" },
256
+ },
257
+ });
258
+ ```
259
+
260
+ ### Time travel with nested workflows context
261
+
262
+ ```typescript showLineNumbers copy
263
+ const result = await run.timeTravel({
264
+ step: "nestedWorkflow.step3",
265
+ context: {
266
+ step1: {
267
+ status: "success",
268
+ payload: { value: 0 },
269
+ output: { step1Result: 2 },
270
+ startedAt: Date.now(),
271
+ endedAt: Date.now(),
272
+ },
273
+ nestedWorkflow: {
274
+ status: "running",
275
+ payload: { step1Result: 2 },
276
+ startedAt: Date.now(),
277
+ },
278
+ },
279
+ nestedStepsContext: {
280
+ nestedWorkflow: {
281
+ step2: {
282
+ status: "success",
283
+ payload: { step1Result: 2 },
284
+ output: { step2Result: 3 },
285
+ startedAt: Date.now(),
286
+ endedAt: Date.now(),
287
+ },
288
+ },
289
+ },
290
+ });
291
+ ```
292
+
293
+ ## Notes
294
+
295
+ - Time travel requires storage to be configured since it relies on persisted workflow snapshots
296
+ - When re-executing a workflow, the workflow loads the existing snapshot from storage (if available)
297
+ - Step results before the target step are reconstructed from the snapshot or provided context
298
+ - Execution begins from the specified step with the provided or reconstructed input data
299
+ - The workflow continues to completion from that point forward
300
+ - Time travel can be used on workflows that have not been run yet by providing custom context or input data for the step to start from.
301
+
302
+
303
+ ## Related
304
+
305
+ - [Time Travel](/docs/workflows/time-travel)
306
+ - [Workflows overview](/docs/workflows/overview#running-workflows)
307
+ - [Workflow.createRun()](../workflow-methods/create-run)
308
+ - [Snapshots](/docs/workflows/snapshots)
309
+ - [Suspend & Resume](/docs/workflows/suspend-and-resume)
310
+
@@ -63,6 +63,24 @@ if (result.status === "suspended") {
63
63
  description: "Cancels the workflow execution",
64
64
  required: true,
65
65
  },
66
+ {
67
+ name: "restart",
68
+ type: "(options?: RestartOptions) => Promise<WorkflowResult>",
69
+ description: "Restarts the workflow execution from last active step",
70
+ required: true,
71
+ },
72
+ {
73
+ name: "timeTravel",
74
+ type: "(options?: TimeTravelOptions) => Promise<WorkflowResult>",
75
+ description: "Re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide.",
76
+ required: true,
77
+ },
78
+ {
79
+ name: "timeTravelStream",
80
+ type: "(options?: TimeTravelOptions) => MastraWorkflowStream",
81
+ description: "Time travels a workflow execution with streaming support",
82
+ required: true,
83
+ },
66
84
  ]}
67
85
  />
68
86
 
@@ -99,3 +117,6 @@ A workflow run's `status` indicates its current execution state. The possible va
99
117
  - [Run.resume()](./run-methods/resume)
100
118
  - [Run.watch()](./run-methods/watch)
101
119
  - [Run.cancel()](./run-methods/cancel)
120
+ - [Run.restart()](./run-methods/restart)
121
+ - [Run.timeTravel()](./run-methods/timeTravel)
122
+ - [Run.timeTravelStream()](../streaming/workflows/timeTravelStream)