@mastra/mcp-docs-server 0.13.5 β†’ 0.13.7-alpha.0

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 (135) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +84 -84
  2. package/.docs/organized/changelogs/%40mastra%2Fastra.md +8 -8
  3. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +8 -8
  4. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +61 -61
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +210 -210
  6. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +99 -99
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +98 -98
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +189 -189
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +241 -241
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +170 -170
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +170 -170
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +236 -236
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +109 -109
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +80 -80
  17. package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +7 -0
  18. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +90 -90
  19. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
  20. package/.docs/organized/changelogs/%40mastra%2Flance.md +62 -0
  21. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +83 -83
  22. package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +50 -50
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +32 -32
  26. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +145 -145
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +83 -83
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +76 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +126 -126
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +245 -245
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +87 -87
  36. package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
  37. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +18 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fserver.md +208 -208
  39. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
  40. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +101 -101
  41. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +71 -71
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
  53. package/.docs/organized/changelogs/create-mastra.md +127 -127
  54. package/.docs/organized/changelogs/mastra.md +250 -250
  55. package/.docs/organized/code-examples/a2a.md +1 -1
  56. package/.docs/organized/code-examples/agent.md +6 -0
  57. package/.docs/organized/code-examples/agui.md +5 -5
  58. package/.docs/organized/code-examples/ai-sdk-useChat.md +3 -3
  59. package/.docs/organized/code-examples/ai-sdk-v5.md +201 -0
  60. package/.docs/organized/code-examples/assistant-ui.md +3 -3
  61. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  62. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +3 -3
  63. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +3 -3
  64. package/.docs/organized/code-examples/client-side-tools.md +3 -3
  65. package/.docs/organized/code-examples/crypto-chatbot.md +6 -6
  66. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  67. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  68. package/.docs/organized/code-examples/memory-with-pg.md +1 -0
  69. package/.docs/organized/code-examples/openapi-spec-writer.md +3 -3
  70. package/.docs/organized/code-examples/quick-start.md +1 -1
  71. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  72. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  73. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  74. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  75. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +181 -0
  76. package/.docs/raw/agents/agent-memory.mdx +126 -0
  77. package/.docs/raw/agents/dynamic-agents.mdx +34 -2
  78. package/.docs/raw/agents/overview.mdx +5 -0
  79. package/.docs/raw/agents/runtime-variables.mdx +1 -1
  80. package/.docs/raw/auth/index.mdx +24 -0
  81. package/.docs/raw/auth/jwt.mdx +99 -0
  82. package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +60 -26
  83. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
  84. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  85. package/.docs/raw/deployment/cloud-providers/index.mdx +44 -9
  86. package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +9 -30
  87. package/.docs/raw/deployment/serverless-platforms/index.mdx +13 -13
  88. package/.docs/raw/evals/custom-eval.mdx +12 -12
  89. package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +291 -216
  90. package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +0 -34
  91. package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +162 -181
  92. package/.docs/raw/frameworks/servers/express.mdx +1 -1
  93. package/.docs/raw/frameworks/web-frameworks/astro.mdx +2 -2
  94. package/.docs/raw/frameworks/web-frameworks/next-js.mdx +1 -1
  95. package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
  96. package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +1 -1
  97. package/.docs/raw/getting-started/installation.mdx +10 -7
  98. package/.docs/raw/getting-started/model-capability.mdx +1 -1
  99. package/.docs/raw/index.mdx +2 -2
  100. package/.docs/raw/memory/overview.mdx +8 -0
  101. package/.docs/raw/memory/semantic-recall.mdx +6 -0
  102. package/.docs/raw/observability/tracing.mdx +30 -0
  103. package/.docs/raw/reference/agents/agent.mdx +2 -2
  104. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  105. package/.docs/raw/reference/cli/create-mastra.mdx +7 -0
  106. package/.docs/raw/reference/cli/dev.mdx +4 -3
  107. package/.docs/raw/reference/client-js/agents.mdx +10 -10
  108. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  109. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  110. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  111. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  112. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  113. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  114. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  115. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  116. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  117. package/.docs/raw/reference/core/mastra-class.mdx +6 -0
  118. package/.docs/raw/reference/memory/query.mdx +35 -14
  119. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  120. package/.docs/raw/reference/observability/providers/keywordsai.mdx +73 -0
  121. package/.docs/raw/reference/storage/mssql.mdx +108 -0
  122. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  123. package/.docs/raw/server-db/custom-api-routes.mdx +38 -26
  124. package/.docs/raw/tools-mcp/mcp-overview.mdx +24 -1
  125. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  126. package/.docs/raw/workflows/control-flow.mdx +85 -87
  127. package/.docs/raw/workflows/input-data-mapping.mdx +31 -43
  128. package/.docs/raw/workflows/overview.mdx +22 -12
  129. package/.docs/raw/workflows/pausing-execution.mdx +49 -4
  130. package/.docs/raw/workflows/suspend-and-resume.mdx +17 -16
  131. package/.docs/raw/workflows/using-with-agents-and-tools.mdx +16 -13
  132. package/.docs/raw/workflows-legacy/overview.mdx +11 -0
  133. package/package.json +7 -9
  134. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
  135. package/.docs/raw/frameworks/ai-sdk-v5.mdx +0 -91
@@ -0,0 +1,201 @@
1
+ ### package.json
2
+ ```json
3
+ {
4
+ "name": "mastra-ai-sdk-v5-use-chat-example",
5
+ "dependencies": {
6
+ "@ai-sdk/openai": "2.0.0-beta.1",
7
+ "@ai-sdk/react": "2.0.0-beta.1",
8
+ "@mastra/core": "0.0.0-ai-v5-20250625173645",
9
+ "@mastra/libsql": "0.0.0-ai-v5-20250625173645",
10
+ "@mastra/loggers": "0.0.0-ai-v5-20250625173645",
11
+ "@mastra/memory": "0.0.0-ai-v5-20250625173645",
12
+ "@mastra/pg": "0.0.0-ai-v5-20250625173645",
13
+ "@mastra/rag": "0.0.0-ai-v5-20250625173645",
14
+ "@mastra/server": "0.0.0-ai-v5-20250625173645",
15
+ "next": "15.2.4",
16
+ "react": "^19.0.0",
17
+ "react-dom": "^19.0.0",
18
+ "swr": "^2.3.3",
19
+ "zod": "^3.25.67"
20
+ },
21
+ "devDependencies": {
22
+ "@eslint/eslintrc": "^3",
23
+ "@types/node": "^20",
24
+ "@types/react": "^19",
25
+ "@types/react-dom": "^19",
26
+ "eslint": "^9",
27
+ "eslint-config-next": "15.1.7",
28
+ "mastra": "0.0.0-ai-v5-20250625173645",
29
+ "postcss": "^8",
30
+ "tailwindcss": "^3.4.1",
31
+ "typescript": "^5.8.3"
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### mastra/agents/index.ts
37
+ ```typescript
38
+ import { Agent } from "@mastra/core/agent";
39
+ import { openai } from "@ai-sdk/openai";
40
+
41
+ import { weatherTool } from "../tools";
42
+ import { Memory } from "@mastra/memory";
43
+ import { LibSQLStore } from "@mastra/libsql";
44
+
45
+ export const memory = new Memory({
46
+ storage: new LibSQLStore({
47
+ url: `file:./mastra.db`,
48
+ }),
49
+ options: {
50
+ semanticRecall: false,
51
+ workingMemory: {
52
+ enabled: false,
53
+ },
54
+ lastMessages: 5,
55
+ },
56
+ });
57
+
58
+ export const weatherAgent = new Agent({
59
+ name: "Weather Agent",
60
+ instructions: `
61
+ You are a helpful weather assistant that provides accurate weather information.
62
+
63
+ Your primary function is to help users get weather details for specific locations. When responding:
64
+ - Always ask for a location if none is provided
65
+ - If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
66
+ - Include relevant details like humidity, wind conditions, and precipitation
67
+ - Keep responses concise but informative
68
+
69
+ Use the weatherTool to fetch current weather data.
70
+
71
+ `,
72
+ model: openai("gpt-4o"),
73
+ tools: {
74
+ weatherTool,
75
+ },
76
+ memory,
77
+ });
78
+
79
+ ```
80
+
81
+ ### mastra/index.ts
82
+ ```typescript
83
+ import { ConsoleLogger } from "@mastra/core/logger";
84
+ import { Mastra } from "@mastra/core/mastra";
85
+
86
+ import { weatherAgent } from "./agents";
87
+
88
+ export const mastra = new Mastra({
89
+ agents: { weatherAgent },
90
+ logger: new ConsoleLogger(),
91
+ // aiSdkCompat: "v4",
92
+ });
93
+
94
+ ```
95
+
96
+ ### mastra/tools/index.ts
97
+ ```typescript
98
+ import { createTool } from "@mastra/core/tools";
99
+ import { z } from "zod";
100
+
101
+ interface GeocodingResponse {
102
+ results: {
103
+ latitude: number;
104
+ longitude: number;
105
+ name: string;
106
+ }[];
107
+ }
108
+ interface WeatherResponse {
109
+ current: {
110
+ time: string;
111
+ temperature_2m: number;
112
+ apparent_temperature: number;
113
+ relative_humidity_2m: number;
114
+ wind_speed_10m: number;
115
+ wind_gusts_10m: number;
116
+ weather_code: number;
117
+ };
118
+ }
119
+
120
+ export const weatherTool = createTool({
121
+ id: "get-weather",
122
+ description: "Get current weather for a location",
123
+ inputSchema: z.object({
124
+ location: z.string().describe("City name"),
125
+ }),
126
+ outputSchema: z.object({
127
+ temperature: z.number(),
128
+ feelsLike: z.number(),
129
+ humidity: z.number(),
130
+ windSpeed: z.number(),
131
+ windGust: z.number(),
132
+ conditions: z.string(),
133
+ location: z.string(),
134
+ }),
135
+ execute: async ({ context }) => {
136
+ return await getWeather(context.location);
137
+ },
138
+ });
139
+
140
+ const getWeather = async (location: string) => {
141
+ const geocodingUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(location)}&count=1`;
142
+ const geocodingResponse = await fetch(geocodingUrl);
143
+ const geocodingData = (await geocodingResponse.json()) as GeocodingResponse;
144
+
145
+ if (!geocodingData.results?.[0]) {
146
+ throw new Error(`Location '${location}' not found`);
147
+ }
148
+
149
+ const { latitude, longitude, name } = geocodingData.results[0];
150
+
151
+ const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m,wind_gusts_10m,weather_code`;
152
+
153
+ const response = await fetch(weatherUrl);
154
+ const data = (await response.json()) as WeatherResponse;
155
+
156
+ return {
157
+ temperature: data.current.temperature_2m,
158
+ feelsLike: data.current.apparent_temperature,
159
+ humidity: data.current.relative_humidity_2m,
160
+ windSpeed: data.current.wind_speed_10m,
161
+ windGust: data.current.wind_gusts_10m,
162
+ conditions: getWeatherCondition(data.current.weather_code),
163
+ location: name,
164
+ };
165
+ };
166
+
167
+ function getWeatherCondition(code: number): string {
168
+ const conditions: Record<number, string> = {
169
+ 0: "Clear sky",
170
+ 1: "Mainly clear",
171
+ 2: "Partly cloudy",
172
+ 3: "Overcast",
173
+ 45: "Foggy",
174
+ 48: "Depositing rime fog",
175
+ 51: "Light drizzle",
176
+ 53: "Moderate drizzle",
177
+ 55: "Dense drizzle",
178
+ 56: "Light freezing drizzle",
179
+ 57: "Dense freezing drizzle",
180
+ 61: "Slight rain",
181
+ 63: "Moderate rain",
182
+ 65: "Heavy rain",
183
+ 66: "Light freezing rain",
184
+ 67: "Heavy freezing rain",
185
+ 71: "Slight snow fall",
186
+ 73: "Moderate snow fall",
187
+ 75: "Heavy snow fall",
188
+ 77: "Snow grains",
189
+ 80: "Slight rain showers",
190
+ 81: "Moderate rain showers",
191
+ 82: "Violent rain showers",
192
+ 85: "Slight snow showers",
193
+ 86: "Heavy snow showers",
194
+ 95: "Thunderstorm",
195
+ 96: "Thunderstorm with slight hail",
196
+ 99: "Thunderstorm with heavy hail",
197
+ };
198
+ return conditions[code] || "Unknown";
199
+ }
200
+
201
+ ```
@@ -18,11 +18,11 @@
18
18
  "@types/node": "^20.17.57",
19
19
  "@types/react": "^19.1.8",
20
20
  "@types/react-dom": "^19.1.6",
21
- "eslint": "^9.29.0",
22
- "eslint-config-next": "15.3.3",
21
+ "eslint": "^9.30.1",
22
+ "eslint-config-next": "15.3.5",
23
23
  "postcss": "^8.5.3",
24
24
  "tailwindcss": "^3.4.17",
25
- "typescript": "^5.8.2"
25
+ "typescript": "^5.8.3"
26
26
  }
27
27
  }
28
28
  ```
@@ -11,7 +11,7 @@
11
11
  "nodemon": "^3.1.9",
12
12
  "ts-node": "^10.9.2",
13
13
  "tsx": "^4.19.3",
14
- "typescript": "^5.8.2"
14
+ "typescript": "^5.8.3"
15
15
  },
16
16
  "dependencies": {
17
17
  "@ai-sdk/anthropic": "latest",
@@ -23,11 +23,11 @@
23
23
  "@types/node": "^20.17.57",
24
24
  "@types/react": "^18.3.23",
25
25
  "@types/react-dom": "^18.3.7",
26
- "eslint": "^9.29.0",
27
- "eslint-config-next": "15.3.3",
26
+ "eslint": "^9.30.1",
27
+ "eslint-config-next": "15.3.5",
28
28
  "postcss": "^8.5.3",
29
29
  "tailwindcss": "^3.4.17",
30
- "typescript": "^5.8.2"
30
+ "typescript": "^5.8.3"
31
31
  }
32
32
  }
33
33
  ```
@@ -23,11 +23,11 @@
23
23
  "@types/node": "^20.17.57",
24
24
  "@types/react": "^19.1.8",
25
25
  "@types/react-dom": "^19.1.6",
26
- "eslint": "^9.29.0",
27
- "eslint-config-next": "15.3.3",
26
+ "eslint": "^9.30.1",
27
+ "eslint-config-next": "15.3.5",
28
28
  "postcss": "^8.5.3",
29
29
  "tailwindcss": "^3.4.17",
30
- "typescript": "^5.8.2"
30
+ "typescript": "^5.8.3"
31
31
  }
32
32
  }
33
33
  ```
@@ -15,12 +15,12 @@
15
15
  "@types/react": "^19.1.8",
16
16
  "@types/react-dom": "^19.1.6",
17
17
  "@vitejs/plugin-react": "^4.3.4",
18
- "eslint": "^9.29.0",
18
+ "eslint": "^9.30.1",
19
19
  "eslint-plugin-react-hooks": "^5.2.0",
20
20
  "eslint-plugin-react-refresh": "^0.4.20",
21
21
  "globals": "^15.15.0",
22
- "typescript": "~5.7.2",
23
- "typescript-eslint": "^8.24.1",
22
+ "typescript": "~5.8.3",
23
+ "typescript-eslint": "^8.38.0",
24
24
  "vite": "^6.2.0"
25
25
  }
26
26
  }
@@ -20,7 +20,7 @@
20
20
  "@radix-ui/react-slot": "^1.2.3",
21
21
  "@radix-ui/react-tooltip": "^1.2.7",
22
22
  "@radix-ui/react-visually-hidden": "^1.2.3",
23
- "@typescript-eslint/parser": "^8.31.0",
23
+ "@typescript-eslint/parser": "^8.38.0",
24
24
  "@vercel/analytics": "^1.5.0",
25
25
  "@vercel/blob": "^1.0.0",
26
26
  "@vercel/postgres": "^0.10.0",
@@ -71,14 +71,14 @@
71
71
  "@types/react": "^19.1.8",
72
72
  "@types/react-dom": "^19.1.6",
73
73
  "drizzle-kit": "^0.31.0",
74
- "eslint": "^9.29.0",
75
- "eslint-config-next": "15.3.3",
74
+ "eslint": "^9.30.1",
75
+ "eslint-config-next": "15.3.5",
76
76
  "eslint-config-prettier": "^10.1.5",
77
- "eslint-import-resolver-typescript": "^4.4.3",
78
- "eslint-plugin-import": "^2.31.0",
77
+ "eslint-import-resolver-typescript": "^4.4.4",
78
+ "eslint-plugin-import": "^2.32.0",
79
79
  "eslint-plugin-tailwindcss": "^3.18.0",
80
80
  "postcss": "^8.5.3",
81
- "prettier": "^3.5.3",
81
+ "prettier": "^3.6.2",
82
82
  "tailwindcss": "^3.4.17",
83
83
  "tsx": "^4.19.3",
84
84
  "typescript": "^5.8.3"
@@ -20,7 +20,7 @@
20
20
  "dotenv": "^17.0.0",
21
21
  "mastra": "latest",
22
22
  "tsx": "^4.19.3",
23
- "typescript": "^5.8.2"
23
+ "typescript": "^5.8.3"
24
24
  }
25
25
  }
26
26
  ```
@@ -11,7 +11,7 @@
11
11
  "devDependencies": {
12
12
  "@types/node": "^22.15.29",
13
13
  "tsx": "^4.19.3",
14
- "typescript": "^5.8.2"
14
+ "typescript": "^5.8.3"
15
15
  }
16
16
  }
17
17
  ```
@@ -176,6 +176,7 @@ export const memory = new Memory({
176
176
  messageRange: 2,
177
177
  },
178
178
  },
179
+ embedder: openai.embedding('text-embedding-3-small'),
179
180
  });
180
181
 
181
182
  export const chefAgent = new Agent({
@@ -33,11 +33,11 @@
33
33
  "@types/react": "^19.1.8",
34
34
  "@types/react-dom": "^19.1.6",
35
35
  "@types/react-syntax-highlighter": "^15.5.13",
36
- "eslint": "^9.29.0",
37
- "eslint-config-next": "15.3.3",
36
+ "eslint": "^9.30.1",
37
+ "eslint-config-next": "15.3.5",
38
38
  "postcss": "^8.5.3",
39
39
  "tailwindcss": "^3.4.17",
40
- "typescript": "^5.8.2"
40
+ "typescript": "^5.8.3"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">= 0.14.0 || 19",
@@ -5,7 +5,7 @@
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.17.57",
7
7
  "tsx": "^4.19.3",
8
- "typescript": "^5.8.2",
8
+ "typescript": "^5.8.3",
9
9
  "zod": "^3.25.67"
10
10
  },
11
11
  "dependencies": {
@@ -6,7 +6,7 @@
6
6
  "@types/node": "^20.17.57",
7
7
  "mastra": "latest",
8
8
  "tsx": "^4.19.3",
9
- "typescript": "^5.8.2",
9
+ "typescript": "^5.8.3",
10
10
  "zod": "^3.25.67"
11
11
  },
12
12
  "dependencies": {
@@ -6,7 +6,7 @@
6
6
  "@types/node": "^20.17.57",
7
7
  "mastra": "latest",
8
8
  "tsx": "^4.19.3",
9
- "typescript": "^5.8.2",
9
+ "typescript": "^5.8.3",
10
10
  "zod": "^3.25.67"
11
11
  },
12
12
  "dependencies": {
@@ -5,7 +5,7 @@
5
5
  "devDependencies": {
6
6
  "@types/node": "^20.17.57",
7
7
  "tsx": "^4.19.3",
8
- "typescript": "^5.8.2",
8
+ "typescript": "^5.8.3",
9
9
  "zod": "^3.25.67"
10
10
  },
11
11
  "dependencies": {
@@ -6,7 +6,7 @@
6
6
  "@types/node": "^20.17.57",
7
7
  "mastra": "latest",
8
8
  "tsx": "^4.19.3",
9
- "typescript": "^5.8.2",
9
+ "typescript": "^5.8.3",
10
10
  "zod": "^3.25.67"
11
11
  },
12
12
  "dependencies": {
@@ -0,0 +1,181 @@
1
+ ### package.json
2
+ ```json
3
+ {
4
+ "name": "examples-workflow-with-suspend-resume",
5
+ "devDependencies": {
6
+ "@types/node": "^20.17.57",
7
+ "mastra": "latest",
8
+ "tsx": "^4.19.3",
9
+ "typescript": "^5.8.3",
10
+ "zod": "^3.25.67"
11
+ },
12
+ "dependencies": {
13
+ "@mastra/core": "latest",
14
+ "@mastra/libsql": "latest"
15
+ }
16
+ }
17
+ ```
18
+
19
+ ### index.ts
20
+ ```typescript
21
+ import { mastra } from './mastra';
22
+
23
+ async function main() {
24
+ console.log('πŸš€ Starting workflow with suspend/resume example...\n');
25
+
26
+ const myWorkflow = mastra.getWorkflow('myWorkflow');
27
+ const run = await myWorkflow.createRunAsync();
28
+
29
+ try {
30
+ // Start the workflow - it will suspend at stepTwo
31
+ console.log('πŸ“ Starting workflow with inputValue: 30');
32
+ const result = await run.start({
33
+ inputData: {
34
+ inputValue: 30,
35
+ },
36
+ });
37
+
38
+ console.log('πŸ“Š Workflow result:', JSON.stringify(result, null, 2));
39
+
40
+ // Check if the workflow is suspended
41
+ if (result.status === 'suspended') {
42
+ console.log('\n⏸️ Workflow is suspended! Suspended steps:', result.suspended);
43
+
44
+ // Resume the workflow with additional data
45
+ console.log('▢️ Resuming workflow with extraNumber: 5');
46
+ const resumedResult = await run.resume({
47
+ step: result.suspended[0], // Resume the first suspended step
48
+ resumeData: {
49
+ extraNumber: 5,
50
+ },
51
+ });
52
+
53
+ console.log('βœ… Resumed workflow result:', JSON.stringify(resumedResult, null, 2));
54
+ } else {
55
+ console.log('βœ… Workflow completed without suspension');
56
+ }
57
+ } catch (e) {
58
+ console.error('❌ Error:', e);
59
+ }
60
+ }
61
+
62
+ main();
63
+
64
+ ```
65
+
66
+ ### mastra/index.ts
67
+ ```typescript
68
+ import { Mastra } from '@mastra/core';
69
+ import { LibSQLStore } from '@mastra/libsql';
70
+
71
+ import { myWorkflow } from './workflows';
72
+
73
+ export const mastra = new Mastra({
74
+ workflows: {
75
+ myWorkflow,
76
+ },
77
+ storage: new LibSQLStore({
78
+ url: 'file:./workflow-snapshots.db',
79
+ }),
80
+ });
81
+
82
+ ```
83
+
84
+ ### mastra/workflows/index.ts
85
+ ```typescript
86
+ import { createStep, createWorkflow } from '@mastra/core/workflows';
87
+ import { z } from 'zod';
88
+
89
+ const stepOne = createStep({
90
+ id: 'stepOne',
91
+ inputSchema: z.object({
92
+ inputValue: z.number(),
93
+ }),
94
+ outputSchema: z.object({
95
+ doubledValue: z.number(),
96
+ }),
97
+ execute: async ({ inputData }) => {
98
+ const doubledValue = inputData.inputValue * 2;
99
+ return { doubledValue };
100
+ },
101
+ });
102
+
103
+ const stepTwo = createStep({
104
+ id: 'stepTwo',
105
+ inputSchema: z.object({
106
+ doubledValue: z.number(),
107
+ }),
108
+ outputSchema: z.object({
109
+ incrementedValue: z.number(),
110
+ }),
111
+ suspendSchema: z.object({}),
112
+ resumeSchema: z.object({
113
+ extraNumber: z.number(),
114
+ }),
115
+ execute: async ({ inputData, resumeData, suspend }) => {
116
+ if (!resumeData?.extraNumber) {
117
+ await suspend({});
118
+ return { incrementedValue: 0 };
119
+ }
120
+ const incrementedValue = inputData.doubledValue + 1 + resumeData.extraNumber;
121
+ return { incrementedValue };
122
+ },
123
+ });
124
+
125
+ const stepThree = createStep({
126
+ id: 'stepThree',
127
+ inputSchema: z.object({
128
+ incrementedValue: z.number(),
129
+ }),
130
+ outputSchema: z.object({
131
+ tripledValue: z.number(),
132
+ }),
133
+ execute: async ({ inputData }) => {
134
+ const tripledValue = inputData.incrementedValue * 3;
135
+ return { tripledValue };
136
+ },
137
+ });
138
+
139
+ const stepFour = createStep({
140
+ id: 'stepFour',
141
+ inputSchema: z.object({
142
+ tripledValue: z.number(),
143
+ }),
144
+ outputSchema: z.object({
145
+ isEven: z.boolean(),
146
+ }),
147
+ execute: async ({ inputData }) => {
148
+ const isEven = inputData.tripledValue % 2 === 0;
149
+ return { isEven };
150
+ },
151
+ });
152
+
153
+ // Create a nested workflow
154
+ export const nestedWorkflow = createWorkflow({
155
+ id: 'data-processing',
156
+ inputSchema: z.object({
157
+ inputValue: z.number(),
158
+ }),
159
+ outputSchema: z.object({
160
+ isEven: z.boolean(),
161
+ }),
162
+ })
163
+ .then(stepOne)
164
+ .then(stepTwo)
165
+ .then(stepThree)
166
+ .then(stepFour)
167
+ .commit();
168
+
169
+ export const myWorkflow = createWorkflow({
170
+ id: 'my-workflow',
171
+ inputSchema: z.object({
172
+ inputValue: z.number(),
173
+ }),
174
+ outputSchema: z.object({
175
+ isEven: z.boolean(),
176
+ }),
177
+ })
178
+ .then(nestedWorkflow)
179
+ .commit();
180
+
181
+ ```