@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404184540 → 0.0.0-studio-cli-20260504022012

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 (281) hide show
  1. package/.docs/docs/agents/adding-voice.md +18 -17
  2. package/.docs/docs/agents/background-tasks.md +242 -0
  3. package/.docs/docs/agents/channels.md +2 -1
  4. package/.docs/docs/agents/overview.md +4 -0
  5. package/.docs/docs/agents/processors.md +177 -5
  6. package/.docs/docs/agents/structured-output.md +66 -1
  7. package/.docs/docs/agents/supervisor-agents.md +65 -0
  8. package/.docs/docs/agents/using-tools.md +73 -0
  9. package/.docs/docs/browser/agent-browser.md +78 -0
  10. package/.docs/docs/browser/browser-viewer.md +144 -0
  11. package/.docs/docs/browser/overview.md +168 -0
  12. package/.docs/docs/browser/stagehand.md +129 -0
  13. package/.docs/docs/deployment/cloud-providers.md +5 -1
  14. package/.docs/docs/deployment/mastra-server.md +4 -4
  15. package/.docs/docs/deployment/monorepo.md +3 -3
  16. package/.docs/docs/deployment/overview.md +11 -8
  17. package/.docs/docs/editor/overview.md +290 -0
  18. package/.docs/docs/editor/prompts.md +134 -0
  19. package/.docs/docs/editor/tools.md +152 -0
  20. package/.docs/docs/evals/custom-scorers.md +63 -3
  21. package/.docs/docs/evals/datasets/overview.md +1 -1
  22. package/.docs/docs/index.md +2 -2
  23. package/.docs/docs/mastra-platform/configuration.md +36 -0
  24. package/.docs/docs/mastra-platform/overview.md +78 -0
  25. package/.docs/docs/mcp/overview.md +17 -0
  26. package/.docs/docs/memory/memory-processors.md +3 -3
  27. package/.docs/docs/memory/message-history.md +8 -2
  28. package/.docs/docs/memory/observational-memory.md +65 -8
  29. package/.docs/docs/memory/storage.md +1 -2
  30. package/.docs/docs/memory/working-memory.md +2 -2
  31. package/.docs/docs/observability/logging.md +1 -1
  32. package/.docs/docs/observability/metrics/overview.md +2 -2
  33. package/.docs/docs/observability/overview.md +1 -1
  34. package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
  35. package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
  36. package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
  37. package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
  38. package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
  39. package/.docs/docs/observability/tracing/exporters/default.md +5 -5
  40. package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
  41. package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
  42. package/.docs/docs/observability/tracing/overview.md +87 -20
  43. package/.docs/docs/server/custom-adapters.md +5 -5
  44. package/.docs/docs/server/custom-api-routes.md +3 -3
  45. package/.docs/docs/server/middleware.md +46 -42
  46. package/.docs/docs/server/request-context.md +13 -2
  47. package/.docs/docs/server/server-adapters.md +91 -8
  48. package/.docs/docs/streaming/background-task-streaming.md +80 -0
  49. package/.docs/docs/streaming/overview.md +3 -0
  50. package/.docs/docs/studio/deployment.md +24 -6
  51. package/.docs/docs/studio/observability.md +1 -1
  52. package/.docs/docs/studio/overview.md +4 -4
  53. package/.docs/docs/voice/overview.md +74 -5
  54. package/.docs/docs/voice/speech-to-speech.md +45 -1
  55. package/.docs/docs/voice/speech-to-text.md +7 -7
  56. package/.docs/docs/voice/text-to-speech.md +10 -10
  57. package/.docs/docs/workflows/agents-and-tools.md +1 -1
  58. package/.docs/docs/workflows/overview.md +105 -4
  59. package/.docs/docs/workflows/scheduled-workflows.md +181 -0
  60. package/.docs/docs/workspace/filesystem.md +64 -6
  61. package/.docs/docs/workspace/lsp.md +76 -4
  62. package/.docs/docs/workspace/overview.md +27 -8
  63. package/.docs/docs/workspace/sandbox.md +3 -1
  64. package/.docs/docs/workspace/search.md +41 -2
  65. package/.docs/docs/workspace/skills.md +19 -19
  66. package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
  67. package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
  68. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  69. package/.docs/guides/deployment/mastra-platform.md +191 -0
  70. package/.docs/guides/deployment/netlify.md +16 -1
  71. package/.docs/guides/getting-started/nestjs.md +238 -0
  72. package/.docs/guides/getting-started/next-js.md +0 -4
  73. package/.docs/guides/guide/code-review-bot.md +2 -2
  74. package/.docs/guides/guide/dev-assistant.md +4 -4
  75. package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
  76. package/.docs/guides/guide/slack-assistant.md +191 -0
  77. package/.docs/guides/migrations/mastra-cloud.md +368 -0
  78. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
  79. package/.docs/models/embeddings.md +3 -3
  80. package/.docs/models/gateways/azure-openai.md +74 -35
  81. package/.docs/models/gateways/mastra.md +64 -0
  82. package/.docs/models/gateways/netlify.md +7 -3
  83. package/.docs/models/gateways/openrouter.md +28 -12
  84. package/.docs/models/gateways/vercel.md +16 -1
  85. package/.docs/models/gateways.md +1 -0
  86. package/.docs/models/index.md +43 -8
  87. package/.docs/models/providers/302ai.md +37 -4
  88. package/.docs/models/providers/abliteration-ai.md +71 -0
  89. package/.docs/models/providers/alibaba-cn.md +7 -2
  90. package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
  91. package/.docs/models/providers/alibaba-coding-plan.md +3 -2
  92. package/.docs/models/providers/alibaba.md +8 -1
  93. package/.docs/models/providers/anthropic.md +18 -5
  94. package/.docs/models/providers/baseten.md +3 -1
  95. package/.docs/models/providers/berget.md +10 -12
  96. package/.docs/models/providers/chutes.md +4 -2
  97. package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
  98. package/.docs/models/providers/cortecs.md +22 -2
  99. package/.docs/models/providers/deepinfra.md +8 -2
  100. package/.docs/models/providers/deepseek.md +6 -4
  101. package/.docs/models/providers/digitalocean.md +133 -0
  102. package/.docs/models/providers/fireworks-ai.md +6 -1
  103. package/.docs/models/providers/firmware.md +12 -10
  104. package/.docs/models/providers/friendli.md +6 -7
  105. package/.docs/models/providers/google.md +8 -4
  106. package/.docs/models/providers/helicone.md +1 -2
  107. package/.docs/models/providers/hpc-ai.md +73 -0
  108. package/.docs/models/providers/huggingface.md +6 -2
  109. package/.docs/models/providers/inception.md +9 -11
  110. package/.docs/models/providers/kilo.md +359 -339
  111. package/.docs/models/providers/kimi-for-coding.md +2 -1
  112. package/.docs/models/providers/llmgateway.md +67 -77
  113. package/.docs/models/providers/mistral.md +3 -2
  114. package/.docs/models/providers/mixlayer.md +75 -0
  115. package/.docs/models/providers/moonshotai-cn.md +3 -2
  116. package/.docs/models/providers/moonshotai.md +3 -2
  117. package/.docs/models/providers/nano-gpt.md +8 -2
  118. package/.docs/models/providers/neuralwatt.md +84 -0
  119. package/.docs/models/providers/novita-ai.md +19 -4
  120. package/.docs/models/providers/nvidia.md +8 -1
  121. package/.docs/models/providers/ollama-cloud.md +7 -2
  122. package/.docs/models/providers/openai.md +7 -2
  123. package/.docs/models/providers/opencode-go.md +21 -13
  124. package/.docs/models/providers/opencode.md +11 -4
  125. package/.docs/models/providers/ovhcloud.md +6 -8
  126. package/.docs/models/providers/poe.md +10 -15
  127. package/.docs/models/providers/regolo-ai.md +83 -0
  128. package/.docs/models/providers/siliconflow-cn.md +5 -2
  129. package/.docs/models/providers/siliconflow.md +6 -3
  130. package/.docs/models/providers/stepfun.md +8 -7
  131. package/.docs/models/providers/synthetic.md +5 -2
  132. package/.docs/models/providers/tencent-token-plan.md +71 -0
  133. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  134. package/.docs/models/providers/togetherai.md +8 -7
  135. package/.docs/models/providers/vivgrid.md +7 -3
  136. package/.docs/models/providers/vultr.md +7 -6
  137. package/.docs/models/providers/wafer.ai.md +73 -0
  138. package/.docs/models/providers/wandb.md +3 -2
  139. package/.docs/models/providers/xai.md +6 -1
  140. package/.docs/models/providers/xiaomi-token-plan-ams.md +9 -7
  141. package/.docs/models/providers/xiaomi-token-plan-cn.md +9 -7
  142. package/.docs/models/providers/xiaomi-token-plan-sgp.md +9 -7
  143. package/.docs/models/providers/xiaomi.md +4 -2
  144. package/.docs/models/providers/zai-coding-plan.md +11 -19
  145. package/.docs/models/providers/zai.md +2 -1
  146. package/.docs/models/providers/zenmux.md +13 -5
  147. package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
  148. package/.docs/models/providers/zhipuai.md +2 -1
  149. package/.docs/models/providers.md +8 -0
  150. package/.docs/reference/agents/agent.md +1 -1
  151. package/.docs/reference/agents/channels.md +3 -3
  152. package/.docs/reference/agents/generate.md +88 -6
  153. package/.docs/reference/agents/generateLegacy.md +1 -1
  154. package/.docs/reference/ai-sdk/chat-route.md +2 -0
  155. package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
  156. package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
  157. package/.docs/reference/ai-sdk/network-route.md +2 -0
  158. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
  159. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
  160. package/.docs/reference/browser/agent-browser.md +375 -0
  161. package/.docs/reference/browser/browser-viewer.md +228 -0
  162. package/.docs/reference/browser/mastra-browser.md +286 -0
  163. package/.docs/reference/browser/stagehand-browser.md +286 -0
  164. package/.docs/reference/cli/mastra.md +703 -0
  165. package/.docs/reference/client-js/agents.md +166 -0
  166. package/.docs/reference/client-js/mastra-client.md +23 -0
  167. package/.docs/reference/client-js/observability.md +2 -2
  168. package/.docs/reference/client-js/workflows.md +62 -1
  169. package/.docs/reference/configuration.md +67 -1
  170. package/.docs/reference/core/addGateway.md +5 -5
  171. package/.docs/reference/core/getEditor.md +35 -0
  172. package/.docs/reference/core/getGateway.md +5 -5
  173. package/.docs/reference/core/getGatewayById.md +5 -5
  174. package/.docs/reference/core/getMCPServer.md +2 -2
  175. package/.docs/reference/core/getMCPServerById.md +2 -2
  176. package/.docs/reference/core/getScorer.md +3 -3
  177. package/.docs/reference/core/getScorerById.md +3 -3
  178. package/.docs/reference/core/listGateways.md +5 -5
  179. package/.docs/reference/core/listMCPServers.md +2 -2
  180. package/.docs/reference/core/listScorers.md +3 -3
  181. package/.docs/reference/core/mastra-class.md +11 -1
  182. package/.docs/reference/core/mastra-model-gateway.md +5 -5
  183. package/.docs/reference/datasets/create.md +4 -4
  184. package/.docs/reference/datasets/startExperiment.md +28 -2
  185. package/.docs/reference/datasets/update.md +4 -4
  186. package/.docs/reference/deployer/cloudflare.md +14 -1
  187. package/.docs/reference/deployer/netlify.md +50 -2
  188. package/.docs/reference/editor/mastra-editor.md +168 -0
  189. package/.docs/reference/editor/tool-provider.md +85 -0
  190. package/.docs/reference/evals/context-precision.md +3 -3
  191. package/.docs/reference/evals/context-relevance.md +3 -3
  192. package/.docs/reference/evals/create-scorer.md +5 -3
  193. package/.docs/reference/evals/filter-run.md +117 -0
  194. package/.docs/reference/evals/mastra-scorer.md +4 -4
  195. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  196. package/.docs/reference/evals/prompt-alignment.md +12 -12
  197. package/.docs/reference/evals/run-evals.md +6 -6
  198. package/.docs/reference/evals/scorer-utils.md +3 -3
  199. package/.docs/reference/evals/trajectory-accuracy.md +3 -3
  200. package/.docs/reference/harness/harness-class.md +152 -53
  201. package/.docs/reference/index.md +25 -0
  202. package/.docs/reference/logging/pino-logger.md +0 -2
  203. package/.docs/reference/mastra-platform/api.md +108 -0
  204. package/.docs/reference/memory/clone-utilities.md +4 -2
  205. package/.docs/reference/memory/cloneThread.md +4 -2
  206. package/.docs/reference/memory/observational-memory.md +4 -0
  207. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  208. package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
  209. package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
  210. package/.docs/reference/observability/tracing/configuration.md +18 -11
  211. package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
  212. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
  213. package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
  214. package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
  215. package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
  216. package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
  217. package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
  218. package/.docs/reference/observability/tracing/instances.md +7 -7
  219. package/.docs/reference/observability/tracing/interfaces.md +23 -6
  220. package/.docs/reference/observability/tracing/span-filtering.md +95 -0
  221. package/.docs/reference/observability/tracing/spans.md +6 -6
  222. package/.docs/reference/processors/prefill-error-handler.md +70 -0
  223. package/.docs/reference/processors/processor-interface.md +400 -40
  224. package/.docs/reference/processors/skill-search-processor.md +20 -1
  225. package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
  226. package/.docs/reference/processors/tool-call-filter.md +23 -0
  227. package/.docs/reference/server/create-route.md +3 -3
  228. package/.docs/reference/server/express-adapter.md +4 -4
  229. package/.docs/reference/server/fastify-adapter.md +4 -4
  230. package/.docs/reference/server/hono-adapter.md +4 -4
  231. package/.docs/reference/server/koa-adapter.md +4 -4
  232. package/.docs/reference/server/mastra-server.md +3 -3
  233. package/.docs/reference/server/nestjs-adapter.md +169 -0
  234. package/.docs/reference/server/register-api-route.md +4 -4
  235. package/.docs/reference/server/routes.md +11 -10
  236. package/.docs/reference/storage/clickhouse.md +300 -0
  237. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  238. package/.docs/reference/storage/composite.md +5 -3
  239. package/.docs/reference/storage/duckdb.md +150 -0
  240. package/.docs/reference/storage/overview.md +1 -1
  241. package/.docs/reference/storage/redis.md +266 -0
  242. package/.docs/reference/streaming/ChunkType.md +143 -3
  243. package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
  244. package/.docs/reference/streaming/agents/stream.md +10 -2
  245. package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
  246. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  247. package/.docs/reference/templates/overview.md +88 -14
  248. package/.docs/reference/tools/create-tool.md +107 -5
  249. package/.docs/reference/tools/mcp-client.md +45 -0
  250. package/.docs/reference/tools/mcp-server.md +1 -3
  251. package/.docs/reference/tools/perplexity.md +155 -0
  252. package/.docs/reference/tools/tavily.md +307 -0
  253. package/.docs/reference/vectors/mongodb.md +0 -2
  254. package/.docs/reference/voice/aws-nova-sonic.md +247 -0
  255. package/.docs/reference/voice/cloudflare.md +3 -3
  256. package/.docs/reference/voice/sarvam.md +29 -23
  257. package/.docs/reference/voice/voice.connect.md +4 -4
  258. package/.docs/reference/voice/voice.listen.md +3 -3
  259. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  260. package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
  261. package/.docs/reference/workflows/step.md +88 -7
  262. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  263. package/.docs/reference/workflows/workflow.md +88 -4
  264. package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
  265. package/.docs/reference/workspace/docker-sandbox.md +196 -0
  266. package/.docs/reference/workspace/gcs-filesystem.md +1 -0
  267. package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
  268. package/.docs/reference/workspace/modal-sandbox.md +168 -0
  269. package/.docs/reference/workspace/process-manager.md +1 -1
  270. package/.docs/reference/workspace/s3-filesystem.md +80 -5
  271. package/.docs/reference/workspace/vercel.md +1 -1
  272. package/.docs/reference/workspace/workspace-class.md +37 -6
  273. package/CHANGELOG.md +486 -4
  274. package/dist/stdio.js.map +1 -1
  275. package/dist/utils.d.ts +1 -4
  276. package/dist/utils.d.ts.map +1 -1
  277. package/package.json +11 -11
  278. package/.docs/docs/mastra-cloud/deployment.md +0 -77
  279. package/.docs/docs/mastra-cloud/observability.md +0 -38
  280. package/.docs/docs/mastra-cloud/overview.md +0 -23
  281. package/.docs/docs/mastra-cloud/setup.md +0 -42
@@ -14,18 +14,21 @@ Use workflows for tasks that are clearly defined upfront and involve multiple st
14
14
 
15
15
  Mastra workflows operate using these principles:
16
16
 
17
- - Defining **steps** with `createStep`, specifying input/output schemas and business logic.
18
- - Composing **steps** with `createWorkflow` to define the execution flow.
17
+ - Defining **steps** with [`createStep`](https://mastra.ai/reference/workflows/step), specifying input/output schemas and business logic.
18
+ - Composing **steps** with [`createWorkflow`](https://mastra.ai/reference/workflows/workflow) to define the execution flow.
19
19
  - Running **workflows** to execute the entire sequence, with built-in support for suspension, resumption, and streaming results.
20
20
 
21
21
  ## Creating a workflow step
22
22
 
23
- Steps are the building blocks of workflows. Create a step using `createStep()` with `inputSchema` and `outputSchema` to define the data it accepts and returns.
23
+ Steps are the building blocks of workflows. Create a step using `createStep()` with `inputSchema` and `outputSchema` to define the data it accepts and returns. You can define both schemas using [Standard JSON Schema](https://standardschema.dev/json-schema) ([Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), etc.).
24
24
 
25
25
  The `execute` function defines what the step does. Use it to call functions in your codebase, external APIs, agents, or tools.
26
26
 
27
+ **Zod**:
28
+
27
29
  ```typescript
28
30
  import { createStep } from '@mastra/core/workflows'
31
+ import { z } from 'zod'
29
32
 
30
33
  const step1 = createStep({
31
34
  id: 'step-1',
@@ -45,6 +48,59 @@ const step1 = createStep({
45
48
  })
46
49
  ```
47
50
 
51
+ **Valibot**:
52
+
53
+ ```typescript
54
+ import { createStep } from '@mastra/core/workflows'
55
+ import * as v from 'valibot'
56
+ import { toStandardJsonSchema } from '@valibot/to-json-schema'
57
+
58
+ const step1 = createStep({
59
+ id: 'step-1',
60
+ inputSchema: toStandardJsonSchema(
61
+ v.object({
62
+ message: v.string(),
63
+ }),
64
+ ),
65
+ outputSchema: toStandardJsonSchema(
66
+ v.object({
67
+ formatted: v.string(),
68
+ }),
69
+ ),
70
+ execute: async ({ inputData }) => {
71
+ const { message } = inputData
72
+
73
+ return {
74
+ formatted: message.toUpperCase(),
75
+ }
76
+ },
77
+ })
78
+ ```
79
+
80
+ **ArkType**:
81
+
82
+ ```typescript
83
+ import { createStep } from '@mastra/core/workflows'
84
+ import { type } from 'arktype'
85
+
86
+ const step1 = createStep({
87
+ id: 'step-1',
88
+ inputSchema: type({
89
+ message: 'string',
90
+ }),
91
+ outputSchema: type({
92
+ formatted: 'string',
93
+ }),
94
+ execute: async ({ inputData }) => {
95
+ const { message } = inputData
96
+
97
+ return {
98
+ formatted: message.toUpperCase(),
99
+ }
100
+ },
101
+ })
102
+ ```
103
+
48
104
  > **Info:** Visit [`Step`](https://mastra.ai/reference/workflows/step) for a full list of configuration options.
49
105
 
50
106
  ### Using agents and tools
@@ -53,7 +109,9 @@ Workflow steps can also call registered agents or import and execute tools direc
53
109
 
54
110
  ## Creating a workflow
55
111
 
56
- Create a workflow using `createWorkflow()` with `inputSchema` and `outputSchema` to define the data it accepts and returns. Add steps using `.then()` and complete the workflow with `.commit()`.
112
+ Create a workflow using `createWorkflow()` with `inputSchema` and `outputSchema` to define the data it accepts and returns. You can define both schemas using [Standard JSON Schema](https://standardschema.dev/json-schema) ([Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), etc.). Add steps using `.then()` and complete the workflow with `.commit()`.
113
+
114
+ **Zod**:
57
115
 
58
116
  ```typescript
59
117
  import { createWorkflow, createStep } from "@mastra/core/workflows";
@@ -74,6 +132,49 @@ export const testWorkflow = createWorkflow({
74
132
  .commit();
75
133
  ```
76
134
 
135
+ **Valibot**:
136
+
137
+ ```typescript
138
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
139
+ import * as v from "valibot";
140
+ import { toStandardJsonSchema } from "@valibot/to-json-schema";
141
+
142
+ const step1 = createStep({...});
143
+
144
+ export const testWorkflow = createWorkflow({
145
+ id: "test-workflow",
146
+ inputSchema: toStandardJsonSchema(v.object({
147
+ message: v.string()
148
+ })),
149
+ outputSchema: toStandardJsonSchema(v.object({
150
+ output: v.string()
151
+ }))
152
+ })
153
+ .then(step1)
154
+ .commit();
155
+ ```
156
+
157
+ **ArkType**:
158
+
159
+ ```typescript
160
+ import { createWorkflow, createStep } from "@mastra/core/workflows";
161
+ import { type } from "arktype";
162
+
163
+ const step1 = createStep({...});
164
+
165
+ export const testWorkflow = createWorkflow({
166
+ id: "test-workflow",
167
+ inputSchema: type({
168
+ message: "string"
169
+ }),
170
+ outputSchema: type({
171
+ output: "string"
172
+ })
173
+ })
174
+ .then(step1)
175
+ .commit();
176
+ ```
177
+
77
178
  > **Info:** Visit [Workflow Class](https://mastra.ai/reference/workflows/workflow) for a full list of configuration options.
78
179
 
79
180
  ### Understanding control flow
@@ -0,0 +1,181 @@
1
+ # Scheduled workflows
2
+
3
+ Declare a `schedule` field on a workflow and Mastra will fire it on the cron you specify. The same workflow remains callable directly with `workflow.start()` — scheduled fires and manual runs share a single execution path.
4
+
5
+ ## Quickstart
6
+
7
+ The following workflow runs every day at 9am New York time. Register it on `Mastra` as you would any other workflow — the scheduler picks it up automatically.
8
+
9
+ ```typescript
10
+ import { createWorkflow, createStep } from '@mastra/core/workflows'
11
+ import { z } from 'zod'
12
+
13
+ const sendReport = createStep({
14
+ id: 'send-report',
15
+ inputSchema: z.object({ userId: z.string() }),
16
+ outputSchema: z.object({ ok: z.boolean() }),
17
+ execute: async ({ inputData }) => {
18
+ // ...send the report for inputData.userId
19
+ return { ok: true }
20
+ },
21
+ })
22
+
23
+ export const dailyReport = createWorkflow({
24
+ id: 'daily-report',
25
+ inputSchema: z.object({ userId: z.string() }),
26
+ outputSchema: z.object({ ok: z.boolean() }),
27
+ schedule: {
28
+ cron: '0 9 * * *',
29
+ timezone: 'America/New_York',
30
+ inputData: { userId: 'system' },
31
+ },
32
+ })
33
+ .then(sendReport)
34
+ .commit()
35
+ ```
36
+
37
+ There is no separate "register schedule" call. The scheduler reads `schedule` straight off the workflow when `Mastra` boots.
38
+
39
+ ## What `schedule` changes
40
+
41
+ A workflow that declares `schedule` is auto-promoted to the **evented execution engine**. The public API (`workflow.start()`, `workflow.startAsync()`, `streamLegacy()`, `resume()`) is unchanged — `EventedWorkflow extends Workflow` and overrides each method with matching signatures. From your code, scheduled fires and manual runs are indistinguishable.
42
+
43
+ The promotion has one practical implication: evented runs require a storage adapter that supports concurrent updates, for example `@mastra/libsql`. If your adapter does not, `createRun()` throws a clear error pointing at the `schedule` field. Switch adapters or remove the schedule.
44
+
45
+ ## Single schedule
46
+
47
+ Pass an object to `schedule` for a workflow that fires on one cadence:
48
+
49
+ ```typescript
50
+ const dailyReport = createWorkflow({
51
+ id: 'daily-report',
52
+ schedule: {
53
+ cron: '0 9 * * *',
54
+ timezone: 'America/New_York',
55
+ inputData: { userId: 'system' },
56
+ },
57
+ // ...
58
+ })
59
+ ```
60
+
61
+ Fields:
62
+
63
+ - `cron` (required): a 5-, 6-, or 7-part cron expression. Validated at workflow construction time.
64
+ - `timezone` (optional): IANA timezone, for example `America/New_York`. Defaults to the host's local timezone. Set this explicitly in production so fire times do not depend on server locale.
65
+ - `inputData` (optional): payload passed as the workflow's input on every fire.
66
+ - `initialState` (optional): initial state for the run.
67
+ - `requestContext` (optional): request context attached to the run.
68
+ - `metadata` (optional): arbitrary metadata persisted alongside the schedule row.
69
+
70
+ ## Multiple schedules
71
+
72
+ Pass an array to fire the same workflow on multiple cadences. Each entry needs a unique stable `id`:
73
+
74
+ ```typescript
75
+ const heartbeat = createWorkflow({
76
+ id: 'heartbeat',
77
+ schedule: [
78
+ { id: 'morning', cron: '0 9 * * *', inputData: { window: 'morning' } },
79
+ { id: 'evening', cron: '0 18 * * *', inputData: { window: 'evening' } },
80
+ ],
81
+ // ...
82
+ })
83
+ ```
84
+
85
+ Each entry creates an independent schedule row, fires on its own cron, and shows up separately in the Studio Schedules view.
86
+
87
+ ## Viewing schedules in Studio
88
+
89
+ Studio surfaces schedules as a top-level area, not as a tab inside a workflow:
90
+
91
+ - **All schedules**: open `/workflows/schedules` for a cross-workflow list. Each row shows the workflow id, cron, next fire, and the most recent run's status, so the list answers "is anything broken?" at a glance.
92
+ - **Filtered by workflow**: append `?workflowId=<id>` to scope the list to a single workflow, for example `/workflows/schedules?workflowId=daily-report`.
93
+ - **Schedule detail**: select any row to open `/workflows/schedules/:scheduleId`, which shows the schedule's metadata, **Pause** / **Resume** controls, and the full trigger history.
94
+
95
+ A workflow's header includes a **Schedules** action when the workflow has at least one schedule:
96
+
97
+ - One schedule: the action links straight to that schedule's detail page.
98
+ - Multiple schedules: the action links to the workflow-filtered list at `/workflows/schedules?workflowId=<id>`.
99
+ - No schedules: the action is hidden.
100
+
101
+ ### Trigger history
102
+
103
+ Every fire records a trigger row with the run id, scheduled time, actual fire time, and publish status. The schedule detail page joins each trigger to the corresponding workflow run and shows:
104
+
105
+ - The run's status (`running`, `success`, `failed`, `suspended`, `canceled`) as a badge.
106
+ - The run's start time and duration.
107
+ - A link to the run's full graph view at `/workflows/:workflowId/graph/:runId`.
108
+ - A `pending` badge for triggers whose run record has not been written yet, due to a race between trigger publish and run snapshot.
109
+ - A `publish failed` badge with the publish error when the scheduler could not enqueue the run at all.
110
+
111
+ Triggers in a non-terminal state cause the panel to poll every five seconds until they reach a terminal state. The list paginates, so long-running schedules do not load thousands of rows up front.
112
+
113
+ ## Pausing a schedule at runtime
114
+
115
+ When a scheduled workflow misfires in production, you do not have to redeploy or hand-edit the database. Pause it from the SDK:
116
+
117
+ ```typescript
118
+ import { MastraClient } from '@mastra/client-js'
119
+
120
+ const client = new MastraClient({ baseUrl: 'http://localhost:4111' })
121
+
122
+ // Schedule ids are derived from the workflow id: `wf_<workflowId>` for a
123
+ // single declarative schedule, or `wf_<workflowId>__<scheduleId>` when you
124
+ // declare multiple schedules per workflow as an array.
125
+ await client.pauseSchedule('wf_daily-report')
126
+ // ...investigate, ship a fix, then:
127
+ await client.resumeSchedule('wf_daily-report')
128
+ ```
129
+
130
+ In Studio, open the schedule detail page and select **Pause** or **Resume** in the header.
131
+
132
+ A few rules worth knowing:
133
+
134
+ - Pause is durable. The status is written to the schedules table and survives process restarts and redeploys. The declarative-config upsert never overwrites a user-set status, even when you change `cron`, `timezone`, or other fields.
135
+ - Resume recomputes `nextFireAt` from now. A schedule paused for a week does not fire seven backlogged runs the moment you resume it. It fires on the next regular cron tick.
136
+ - The only way to unpause is `resumeSchedule` (or the **Resume** button in Studio). Editing the workflow's `schedule` config does not unpause a paused row.
137
+ - Pause and resume are idempotent. Calling pause on an already-paused schedule is a no-op.
138
+ - This is an operational override, not a way to author schedules. Creating, deleting, and editing schedules still happens in code via the `schedule` field on `createWorkflow`.
139
+
140
+ The underlying HTTP routes are `POST /api/schedules/:scheduleId/pause` and `POST /api/schedules/:scheduleId/resume`. Both require the `schedules:write` permission.
141
+
142
+ ## Redeploying with changes
143
+
144
+ When you change the `schedule` config and redeploy, Mastra diffs the existing schedule row against the new config:
145
+
146
+ - If `cron` or `timezone` changed, `nextFireAt` is recomputed.
147
+ - If only `inputData`, `initialState`, or `metadata` changed, the row is patched in place and the next fire time is preserved.
148
+ - User-set status (for example, paused via `client.pauseSchedule`) and fire history are never overwritten.
149
+
150
+ Removing a schedule entry from a workflow's `schedule` array deletes its row on the next boot.
151
+
152
+ ## Deployment topology
153
+
154
+ The built-in scheduler is a `setInterval` tick loop that polls the schedules table, claims due rows, and dispatches workflow runs through the in-process pubsub. It assumes a long-lived host process.
155
+
156
+ ### Long-lived host (recommended)
157
+
158
+ Deploy targets such as Fly Machines, Railway, Render, AWS ECS, GKE, or your own server keep the Mastra process alive between cron ticks. Schedules work without extra setup.
159
+
160
+ ### Serverless platforms
161
+
162
+ Functions-as-a-service platforms such as Vercel, Netlify, AWS Lambda, and Cloudflare Workers shut the process down after each request. The tick loop never gets a second tick. Schedules declared in code do not fire on these platforms with the built-in scheduler today.
163
+
164
+ On these platforms, use [`@mastra/inngest`](#inngest-workflows) instead. Inngest is serverless-native and holds the cron state for you.
165
+
166
+ ## Inngest workflows
167
+
168
+ The `schedule` field documented on this page drives Mastra's built-in scheduler. If you use `@mastra/inngest`, scheduled workflows are configured through Inngest's own `cron` field on `createFunction` and fire on Inngest's scheduler instead.
169
+
170
+ Practical implications:
171
+
172
+ - Inngest schedules do not appear in Studio's `/workflows/schedules` view.
173
+ - The workflow header **Schedules** action does not show for Inngest workflows.
174
+ - `client.pauseSchedule` and `client.resumeSchedule` do not control Inngest schedules.
175
+
176
+ Manage Inngest schedules from the [Inngest dashboard](https://www.inngest.com/docs/guides/scheduled-functions). Use Mastra schedules when you want Mastra to own scheduling end to end.
177
+
178
+ ## Related
179
+
180
+ - [Workflow overview](https://mastra.ai/docs/workflows/overview)
181
+ - [Suspend and resume](https://mastra.ai/docs/workflows/suspend-and-resume)
@@ -18,12 +18,14 @@ A filesystem provider handles all file operations for a workspace:
18
18
 
19
19
  Available providers:
20
20
 
21
- - [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem) - Stores files in a directory on disk
22
- - [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem) - Stores files in Amazon S3 or S3-compatible storage (R2, MinIO)
23
- - [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem) - Stores files in Google Cloud Storage
24
- - [`AgentFSFilesystem`](https://mastra.ai/reference/workspace/agentfs-filesystem) - Stores files in a Turso/SQLite database via AgentFS
21
+ - [`LocalFilesystem`](https://mastra.ai/reference/workspace/local-filesystem): Stores files in a directory on disk
22
+ - [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem): Stores files in Amazon S3 or S3-compatible storage (R2, MinIO, Tigris)
23
+ - [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem): Stores files in Google Cloud Storage
24
+ - [`GoogleDriveFilesystem`](https://mastra.ai/reference/workspace/google-drive-filesystem): Stores files inside a Google Drive folder
25
+ - [`AzureBlobFilesystem`](https://mastra.ai/reference/workspace/azure-blob-filesystem): Stores files in Azure Blob Storage
26
+ - [`AgentFSFilesystem`](https://mastra.ai/reference/workspace/agentfs-filesystem): Stores files in a Turso/SQLite database via AgentFS
25
27
 
26
- > **Tip:** `LocalFilesystem` is the simplest way to get started as it requires no external services. For cloud storage, use `S3Filesystem` or `GCSFilesystem`. For database-backed storage without external services, use `AgentFSFilesystem`.
28
+ > **Tip:** `LocalFilesystem` is the simplest way to get started as it requires no external services. For cloud storage, use `S3Filesystem`, `GCSFilesystem`, or `AzureBlobFilesystem`. For database-backed storage without external services, use `AgentFSFilesystem`.
27
29
 
28
30
  ## Basic usage
29
31
 
@@ -93,6 +95,58 @@ const workspace = new Workspace({
93
95
 
94
96
  When `contained` is `false`, absolute paths are treated as real filesystem paths with no restriction.
95
97
 
98
+ ## Dynamic filesystem
99
+
100
+ The `filesystem` option accepts a resolver function instead of a static instance. The resolver receives `requestContext` and returns a filesystem per request, allowing a single workspace to serve different filesystems based on the caller's identity, role, or tenant.
101
+
102
+ ```typescript
103
+ import { Agent } from '@mastra/core/agent'
104
+ import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
105
+
106
+ const workspace = new Workspace({
107
+ filesystem: ({ requestContext }) => {
108
+ const role = requestContext.get('agent-role') || 'guest'
109
+ return new LocalFilesystem({
110
+ basePath: `/workspaces/${role}`,
111
+ readOnly: role !== 'admin',
112
+ })
113
+ },
114
+ })
115
+
116
+ const agent = new Agent({
117
+ id: 'multi-role-agent',
118
+ model: 'openai/gpt-4o',
119
+ workspace,
120
+ })
121
+ ```
122
+
123
+ Each request resolves its own filesystem at tool execution time:
124
+
125
+ ```typescript
126
+ import { RequestContext } from '@mastra/core/request-context'
127
+
128
+ // Admin request — reads and writes from /workspaces/admin/
129
+ const adminCtx = new RequestContext([['agent-role', 'admin']])
130
+ await agent.generate('Write report.txt with Q4 results', { requestContext: adminCtx })
131
+
132
+ // Viewer request — reads from /workspaces/viewer/, writes are blocked
133
+ const viewerCtx = new RequestContext([['agent-role', 'viewer']])
134
+ await agent.generate('Read info.txt', { requestContext: viewerCtx })
135
+ ```
136
+
137
+ The resolver can also be asynchronous, for example to look up configuration from a database:
138
+
139
+ ```typescript
140
+ const workspace = new Workspace({
141
+ filesystem: async ({ requestContext }) => {
142
+ const tenantConfig = await db.getTenant(requestContext.get('tenant-id'))
143
+ return new LocalFilesystem({ basePath: tenantConfig.storagePath })
144
+ },
145
+ })
146
+ ```
147
+
148
+ > **Note:** `filesystem` and `mounts` are mutually exclusive. You cannot use a resolver function together with `mounts` in the same workspace.
149
+
96
150
  ## Read-only mode
97
151
 
98
152
  To prevent agents from modifying files, enable read-only mode:
@@ -106,7 +160,9 @@ const workspace = new Workspace({
106
160
  })
107
161
  ```
108
162
 
109
- When read-only, write tools (`write_file`, `edit_file`, `delete`, `mkdir`) aren't added to the agent's toolset. The agent can still read and list files.
163
+ With a static filesystem, write tools (`write_file`, `edit_file`, `delete`, `mkdir`) are excluded from the agent's toolset entirely. The agent can still read and list files.
164
+
165
+ When using a [dynamic filesystem](#dynamic-filesystem), write tools are always included because `readOnly` isn't known until the resolver runs. Instead, write operations are blocked at runtime — the tool returns an error if the resolved filesystem is read-only.
110
166
 
111
167
  ## Mounts and `CompositeFilesystem`
112
168
 
@@ -165,6 +221,8 @@ When you configure a filesystem on a workspace, agents receive tools for reading
165
221
  - [LocalFilesystem reference](https://mastra.ai/reference/workspace/local-filesystem)
166
222
  - [S3Filesystem reference](https://mastra.ai/reference/workspace/s3-filesystem)
167
223
  - [GCSFilesystem reference](https://mastra.ai/reference/workspace/gcs-filesystem)
224
+ - [GoogleDriveFilesystem reference](https://mastra.ai/reference/workspace/google-drive-filesystem)
225
+ - [AzureBlobFilesystem reference](https://mastra.ai/reference/workspace/azure-blob-filesystem)
168
226
  - [AgentFSFilesystem reference](https://mastra.ai/reference/workspace/agentfs-filesystem)
169
227
  - [Workspace overview](https://mastra.ai/docs/workspace/overview)
170
228
  - [Sandbox](https://mastra.ai/docs/workspace/sandbox)
@@ -8,10 +8,11 @@ LSP inspection gives workspace-backed agents semantic code intelligence. When yo
8
8
 
9
9
  Use LSP inspection when your agent needs semantic code understanding instead of plain-text search alone:
10
10
 
11
- - Inspect TypeScript or JavaScript symbols and their inferred types
11
+ - Inspect symbols and their inferred types in any supported language
12
12
  - Find where a symbol is declared before editing related code
13
13
  - Explore implementations across a codebase without manually tracing every file
14
14
  - Combine semantic inspection with `view` and `search_content` for faster navigation
15
+ - Add LSP support for additional languages by [registering custom language servers](#custom-language-servers)
15
16
 
16
17
  ## Basic usage
17
18
 
@@ -84,9 +85,9 @@ const workspace = new Workspace({
84
85
  lsp: {
85
86
  diagnosticTimeout: 4000,
86
87
  initTimeout: 8000,
87
- disableServers: ['pyright'],
88
+ disableServers: ['eslint'],
88
89
  binaryOverrides: {
89
- typescript: '/custom/path/to/typescript-language-server',
90
+ typescript: '/custom/path/to/typescript-language-server --stdio',
90
91
  },
91
92
  searchPaths: ['/opt/homebrew/bin'],
92
93
  },
@@ -100,9 +101,80 @@ Use custom configuration when you need to:
100
101
  - Point Mastra at custom language server binaries
101
102
  - Add extra binary search paths in constrained environments
102
103
 
104
+ ## Custom language servers
105
+
106
+ By default, Mastra includes built-in support for TypeScript, JavaScript, Python, Go, and Rust. To use LSP inspection with other languages (e.g. PHP, Ruby, Java, Kotlin, Swift, Elixir), register a custom language server via the `servers` field:
107
+
108
+ ```typescript
109
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
110
+
111
+ const workspace = new Workspace({
112
+ filesystem: new LocalFilesystem({ basePath: './workspace' }),
113
+ sandbox: new LocalSandbox({ workingDirectory: './workspace' }),
114
+ lsp: {
115
+ servers: {
116
+ phpactor: {
117
+ id: 'phpactor',
118
+ name: 'Phpactor Language Server',
119
+ languageIds: ['php'],
120
+ extensions: ['.php'],
121
+ markers: ['composer.json'],
122
+ command: 'phpactor language-server',
123
+ },
124
+ },
125
+ },
126
+ })
127
+ ```
128
+
129
+ Each custom server definition requires these fields:
130
+
131
+ | Field | Description |
132
+ | ------------- | ------------------------------------------------------------------------------------- |
133
+ | `id` | Unique identifier for the server |
134
+ | `name` | Human-readable name shown in logs |
135
+ | `languageIds` | Language Server Protocol (LSP) language identifiers this server handles |
136
+ | `extensions` | File extensions, including the dot |
137
+ | `markers` | Files or directories that identify the project root (e.g. `composer.json`, `Gemfile`) |
138
+ | `command` | Full command string to start the server |
139
+
140
+ When a server has multiple language IDs, Mastra maps each extension to the first entry in `languageIds`.
141
+
142
+ You can also pass optional `initializationOptions` to send custom settings during the LSP handshake.
143
+
144
+ Custom servers are merged with built-in servers. To replace a built-in server, use the same `id` (e.g. `id: 'go'` replaces the built-in Go server). Register multiple servers to support several languages at once:
145
+
146
+ ```typescript
147
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace'
148
+
149
+ const workspace = new Workspace({
150
+ filesystem: new LocalFilesystem({ basePath: './workspace' }),
151
+ sandbox: new LocalSandbox({ workingDirectory: './workspace' }),
152
+ lsp: {
153
+ servers: {
154
+ phpactor: {
155
+ id: 'phpactor',
156
+ name: 'Phpactor Language Server',
157
+ languageIds: ['php'],
158
+ extensions: ['.php'],
159
+ markers: ['composer.json'],
160
+ command: 'phpactor language-server',
161
+ },
162
+ solargraph: {
163
+ id: 'solargraph',
164
+ name: 'Solargraph',
165
+ languageIds: ['ruby'],
166
+ extensions: ['.rb', '.erb'],
167
+ markers: ['Gemfile'],
168
+ command: 'solargraph stdio',
169
+ },
170
+ },
171
+ },
172
+ })
173
+ ```
174
+
103
175
  ## Requirements and limitations
104
176
 
105
- - LSP inspection only works for file types with a matching language server
177
+ - LSP inspection only works for file types with a matching built-in or custom language server
106
178
  - The `path` you inspect must resolve inside the workspace filesystem or allowed paths
107
179
  - External package inspection may resolve to declaration files such as `.d.ts` instead of runtime source files
108
180
  - `lsp_inspect` complements `view` and `search_content`, but does not replace reading implementation code when you need full context
@@ -38,7 +38,7 @@ const workspace = new Workspace({
38
38
  sandbox: new LocalSandbox({
39
39
  workingDirectory: './workspace',
40
40
  }),
41
- skills: ['/skills'],
41
+ skills: ['skills'],
42
42
  })
43
43
  ```
44
44
 
@@ -153,15 +153,34 @@ const workspace = new Workspace({
153
153
 
154
154
  The agent receives the `execute_command` tool.
155
155
 
156
+ ### Dynamic filesystem (per-request)
157
+
158
+ Pass a resolver function to `filesystem` to return a different filesystem per request. This is useful for multi-tenant applications or multi-role agents where each request needs a different storage root or different permissions.
159
+
160
+ ```typescript
161
+ const workspace = new Workspace({
162
+ filesystem: ({ requestContext }) => {
163
+ const role = requestContext.get('agent-role') || 'guest'
164
+ return new LocalFilesystem({
165
+ basePath: `/workspaces/${role}`,
166
+ readOnly: role !== 'admin',
167
+ })
168
+ },
169
+ })
170
+ ```
171
+
172
+ One workspace instance serves all requests. The resolver runs at tool execution time, so each request gets its own filesystem. See [dynamic filesystem](https://mastra.ai/docs/workspace/filesystem) for details.
173
+
156
174
  ### Which pattern should I use?
157
175
 
158
- | Scenario | Pattern |
159
- | ----------------------------------------------------- | ----------------------------------------------------- |
160
- | Local development with files and commands | `filesystem` + `sandbox` (both local, same directory) |
161
- | Cloud storage accessible inside a cloud sandbox | `mounts` + `sandbox` |
162
- | Multiple cloud providers in one sandbox | `mounts` + `sandbox` (one mount per provider) |
163
- | Agent reads/writes files, no command execution needed | `filesystem` only |
164
- | Agent runs commands, no file tools needed | `sandbox` only |
176
+ | Scenario | Pattern |
177
+ | --------------------------------------------------------- | ----------------------------------------------------- |
178
+ | Local development with files and commands | `filesystem` + `sandbox` (both local, same directory) |
179
+ | Cloud storage accessible inside a cloud sandbox | `mounts` + `sandbox` |
180
+ | Multiple cloud providers in one sandbox | `mounts` + `sandbox` (one mount per provider) |
181
+ | Agent reads/writes files, no command execution needed | `filesystem` only |
182
+ | Agent runs commands, no file tools needed | `sandbox` only |
183
+ | Multi-role or multi-tenant agent with per-request storage | `filesystem` with resolver function |
165
184
 
166
185
  ## Tool configuration
167
186
 
@@ -19,6 +19,7 @@ A sandbox provider executes commands in a controlled environment:
19
19
  - [`BlaxelSandbox`](https://mastra.ai/reference/workspace/blaxel-sandbox): Executes commands in isolated Blaxel cloud sandboxes
20
20
  - [`DaytonaSandbox`](https://mastra.ai/reference/workspace/daytona-sandbox): Executes commands in isolated Daytona cloud sandboxes
21
21
  - [`E2BSandbox`](https://mastra.ai/reference/workspace/e2b-sandbox): Executes commands in isolated E2B cloud sandboxes
22
+ - [`ModalSandbox`](https://mastra.ai/reference/workspace/modal-sandbox): Executes commands in isolated Modal cloud sandboxes
22
23
 
23
24
  ## Basic usage
24
25
 
@@ -110,7 +111,7 @@ const workspace = new Workspace({
110
111
  })
111
112
  ```
112
113
 
113
- Use `null` or `false` for cloud sandboxes (for example, E2B or Daytona) where processes should outlive the agent.
114
+ Use `null` or `false` for cloud sandboxes (for example, E2B, Daytona, or Modal) where processes should outlive the agent.
114
115
 
115
116
  > **Note:** For the full `SandboxProcessManager` API (spawning processes programmatically, reading output, sending stdin), see the [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager).
116
117
 
@@ -118,6 +119,7 @@ Use `null` or `false` for cloud sandboxes (for example, E2B or Daytona) where pr
118
119
 
119
120
  - [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager)
120
121
  - [`LocalSandbox` reference](https://mastra.ai/reference/workspace/local-sandbox)
122
+ - [`ModalSandbox` reference](https://mastra.ai/reference/workspace/modal-sandbox)
121
123
  - [`DaytonaSandbox` reference](https://mastra.ai/reference/workspace/daytona-sandbox)
122
124
  - [`E2BSandbox` reference](https://mastra.ai/reference/workspace/e2b-sandbox)
123
125
  - [Workspace overview](https://mastra.ai/docs/workspace/overview)
@@ -83,6 +83,45 @@ const workspace = new Workspace({
83
83
  })
84
84
  ```
85
85
 
86
+ ### Batch embedding
87
+
88
+ The embedder above takes one text at a time. Indexing a workspace with hundreds of files calls the provider hundreds of times, which is slow and expensive.
89
+
90
+ When the provider supports batching (for example, OpenAI's `embedMany`), pass an embedder that takes an array of texts and accepts many embeddings back in one call. To opt in, set a `batch: true` property on the function. Mastra checks for that property at runtime and switches to the batched path.
91
+
92
+ The following example replaces the single-text embedder with a batched one. The embedder function takes an array, returns an array of embeddings in the same order, and carries two extra properties:
93
+
94
+ - `batch: true`: marks the function as batch-capable. Without this property, Mastra calls it one text at a time.
95
+ - `maxBatchSize`: the largest array the provider accepts in one call. Mastra splits larger requests into chunks of this size and sends them in parallel. Set this to your provider's documented limit (for example, 2048 for OpenAI, 96 for Cohere, 128 for Voyage). Omit it to send every pending text in one request.
96
+
97
+ ```typescript
98
+ import { Workspace, LocalFilesystem } from '@mastra/core/workspace'
99
+ import { PineconeVector } from '@mastra/pinecone'
100
+ import { embedMany } from 'ai'
101
+ import { openai } from '@ai-sdk/openai'
102
+
103
+ const model = openai.embedding('text-embedding-3-small')
104
+
105
+ const workspace = new Workspace({
106
+ filesystem: new LocalFilesystem({ basePath: './workspace' }),
107
+ vectorStore: new PineconeVector({
108
+ apiKey: process.env.PINECONE_API_KEY,
109
+ index: 'workspace-index',
110
+ }),
111
+ embedder: Object.assign(
112
+ async (texts: string[]) => {
113
+ const { embeddings } = await embedMany({ model, values: texts })
114
+ return embeddings
115
+ },
116
+ { batch: true as const, maxBatchSize: 2048 },
117
+ ),
118
+ })
119
+ ```
120
+
121
+ `Object.assign` adds the `batch` and `maxBatchSize` properties to the embedder function. Mastra reads them as metadata and never passes them to the provider.
122
+
123
+ Single-text embedders still work. The function signature `(text: string) => Promise<number[]>` is unchanged, so existing code keeps running without modification.
124
+
86
125
  ## Hybrid search
87
126
 
88
127
  Configure both BM25 and vector search to enable hybrid mode, which combines keyword matching with semantic understanding.
@@ -143,7 +182,7 @@ Configure `autoIndexPaths` to automatically index files when the workspace initi
143
182
  const workspace = new Workspace({
144
183
  filesystem: new LocalFilesystem({ basePath: './workspace' }),
145
184
  bm25: true,
146
- autoIndexPaths: ['/docs', '/support/faq'],
185
+ autoIndexPaths: ['docs', 'support/faq'],
147
186
  })
148
187
 
149
188
  await workspace.init()
@@ -157,7 +196,7 @@ Glob patterns let you index specific file types:
157
196
  const workspace = new Workspace({
158
197
  filesystem: new LocalFilesystem({ basePath: './workspace' }),
159
198
  bm25: true,
160
- autoIndexPaths: ['/docs/**/*.md', '/support/**/*.txt'],
199
+ autoIndexPaths: ['docs/**/*.md', 'support/**/*.txt'],
161
200
  })
162
201
  ```
163
202