@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404182525 → 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.
- package/.docs/docs/agents/adding-voice.md +18 -17
- package/.docs/docs/agents/background-tasks.md +242 -0
- package/.docs/docs/agents/channels.md +2 -1
- package/.docs/docs/agents/overview.md +4 -0
- package/.docs/docs/agents/processors.md +177 -5
- package/.docs/docs/agents/structured-output.md +66 -1
- package/.docs/docs/agents/supervisor-agents.md +65 -0
- package/.docs/docs/agents/using-tools.md +73 -0
- package/.docs/docs/browser/agent-browser.md +78 -0
- package/.docs/docs/browser/browser-viewer.md +144 -0
- package/.docs/docs/browser/overview.md +168 -0
- package/.docs/docs/browser/stagehand.md +129 -0
- package/.docs/docs/deployment/cloud-providers.md +5 -1
- package/.docs/docs/deployment/mastra-server.md +4 -4
- package/.docs/docs/deployment/monorepo.md +3 -3
- package/.docs/docs/deployment/overview.md +11 -8
- package/.docs/docs/editor/overview.md +290 -0
- package/.docs/docs/editor/prompts.md +134 -0
- package/.docs/docs/editor/tools.md +152 -0
- package/.docs/docs/evals/custom-scorers.md +63 -3
- package/.docs/docs/evals/datasets/overview.md +1 -1
- package/.docs/docs/index.md +2 -2
- package/.docs/docs/mastra-platform/configuration.md +36 -0
- package/.docs/docs/mastra-platform/overview.md +78 -0
- package/.docs/docs/mcp/overview.md +17 -0
- package/.docs/docs/memory/memory-processors.md +3 -3
- package/.docs/docs/memory/message-history.md +8 -2
- package/.docs/docs/memory/observational-memory.md +65 -8
- package/.docs/docs/memory/storage.md +1 -2
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +2 -2
- package/.docs/docs/observability/overview.md +1 -1
- package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
- package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
- package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
- package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
- package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/docs/observability/tracing/exporters/default.md +5 -5
- package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
- package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
- package/.docs/docs/observability/tracing/overview.md +87 -20
- package/.docs/docs/server/custom-adapters.md +5 -5
- package/.docs/docs/server/custom-api-routes.md +3 -3
- package/.docs/docs/server/mastra-client.md +2 -2
- package/.docs/docs/server/mastra-server.md +1 -1
- package/.docs/docs/server/middleware.md +46 -42
- package/.docs/docs/server/request-context.md +13 -2
- package/.docs/docs/server/server-adapters.md +91 -8
- package/.docs/docs/streaming/background-task-streaming.md +80 -0
- package/.docs/docs/streaming/overview.md +3 -0
- package/.docs/docs/studio/deployment.md +24 -6
- package/.docs/docs/studio/observability.md +1 -1
- package/.docs/docs/studio/overview.md +4 -4
- package/.docs/docs/voice/overview.md +74 -5
- package/.docs/docs/voice/speech-to-speech.md +45 -1
- package/.docs/docs/voice/speech-to-text.md +7 -7
- package/.docs/docs/voice/text-to-speech.md +10 -10
- package/.docs/docs/workflows/agents-and-tools.md +1 -1
- package/.docs/docs/workflows/overview.md +105 -4
- package/.docs/docs/workflows/scheduled-workflows.md +181 -0
- package/.docs/docs/workspace/filesystem.md +64 -6
- package/.docs/docs/workspace/lsp.md +76 -4
- package/.docs/docs/workspace/overview.md +62 -15
- package/.docs/docs/workspace/sandbox.md +3 -1
- package/.docs/docs/workspace/search.md +41 -2
- package/.docs/docs/workspace/skills.md +19 -19
- package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
- package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
- package/.docs/guides/deployment/mastra-platform.md +191 -0
- package/.docs/guides/deployment/netlify.md +16 -1
- package/.docs/guides/getting-started/nestjs.md +238 -0
- package/.docs/guides/getting-started/next-js.md +0 -4
- package/.docs/guides/guide/code-review-bot.md +2 -2
- package/.docs/guides/guide/dev-assistant.md +4 -4
- package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
- package/.docs/guides/guide/slack-assistant.md +191 -0
- package/.docs/guides/migrations/mastra-cloud.md +368 -0
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
- package/.docs/models/embeddings.md +3 -3
- package/.docs/models/gateways/azure-openai.md +74 -35
- package/.docs/models/gateways/mastra.md +64 -0
- package/.docs/models/gateways/netlify.md +7 -3
- package/.docs/models/gateways/openrouter.md +28 -12
- package/.docs/models/gateways/vercel.md +22 -2
- package/.docs/models/gateways.md +1 -0
- package/.docs/models/index.md +43 -8
- package/.docs/models/providers/302ai.md +37 -4
- package/.docs/models/providers/abliteration-ai.md +71 -0
- package/.docs/models/providers/alibaba-cn.md +8 -2
- package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
- package/.docs/models/providers/alibaba-coding-plan.md +3 -2
- package/.docs/models/providers/alibaba.md +8 -1
- package/.docs/models/providers/anthropic.md +18 -5
- package/.docs/models/providers/baseten.md +3 -1
- package/.docs/models/providers/berget.md +10 -12
- package/.docs/models/providers/chutes.md +4 -2
- package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
- package/.docs/models/providers/cortecs.md +22 -2
- package/.docs/models/providers/deepinfra.md +8 -2
- package/.docs/models/providers/deepseek.md +6 -4
- package/.docs/models/providers/digitalocean.md +133 -0
- package/.docs/models/providers/fireworks-ai.md +6 -1
- package/.docs/models/providers/firmware.md +12 -10
- package/.docs/models/providers/friendli.md +6 -7
- package/.docs/models/providers/google.md +9 -3
- package/.docs/models/providers/helicone.md +1 -2
- package/.docs/models/providers/hpc-ai.md +73 -0
- package/.docs/models/providers/huggingface.md +6 -2
- package/.docs/models/providers/inception.md +9 -11
- package/.docs/models/providers/kilo.md +359 -339
- package/.docs/models/providers/kimi-for-coding.md +2 -1
- package/.docs/models/providers/llmgateway.md +67 -77
- package/.docs/models/providers/mistral.md +3 -2
- package/.docs/models/providers/mixlayer.md +75 -0
- package/.docs/models/providers/moonshotai-cn.md +3 -2
- package/.docs/models/providers/moonshotai.md +3 -2
- package/.docs/models/providers/nano-gpt.md +8 -2
- package/.docs/models/providers/neuralwatt.md +84 -0
- package/.docs/models/providers/novita-ai.md +19 -4
- package/.docs/models/providers/nvidia.md +8 -1
- package/.docs/models/providers/ollama-cloud.md +7 -2
- package/.docs/models/providers/openai.md +7 -2
- package/.docs/models/providers/opencode-go.md +21 -13
- package/.docs/models/providers/opencode.md +11 -4
- package/.docs/models/providers/ovhcloud.md +6 -8
- package/.docs/models/providers/poe.md +10 -15
- package/.docs/models/providers/regolo-ai.md +83 -0
- package/.docs/models/providers/siliconflow-cn.md +5 -2
- package/.docs/models/providers/siliconflow.md +6 -3
- package/.docs/models/providers/stepfun.md +8 -7
- package/.docs/models/providers/synthetic.md +5 -2
- package/.docs/models/providers/tencent-token-plan.md +71 -0
- package/.docs/models/providers/tencent-tokenhub.md +71 -0
- package/.docs/models/providers/togetherai.md +8 -7
- package/.docs/models/providers/vivgrid.md +7 -3
- package/.docs/models/providers/vultr.md +7 -6
- package/.docs/models/providers/wafer.ai.md +73 -0
- package/.docs/models/providers/wandb.md +3 -2
- package/.docs/models/providers/xai.md +6 -1
- package/.docs/models/providers/xiaomi-token-plan-ams.md +75 -0
- package/.docs/models/providers/xiaomi-token-plan-cn.md +75 -0
- package/.docs/models/providers/xiaomi-token-plan-sgp.md +75 -0
- package/.docs/models/providers/xiaomi.md +4 -2
- package/.docs/models/providers/zai-coding-plan.md +11 -19
- package/.docs/models/providers/zai.md +2 -1
- package/.docs/models/providers/zenmux.md +17 -6
- package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
- package/.docs/models/providers/zhipuai.md +2 -1
- package/.docs/models/providers.md +11 -0
- package/.docs/reference/agents/agent.md +1 -1
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/generate.md +88 -6
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/ai-sdk/chat-route.md +2 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
- package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
- package/.docs/reference/ai-sdk/network-route.md +2 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
- package/.docs/reference/browser/agent-browser.md +375 -0
- package/.docs/reference/browser/browser-viewer.md +228 -0
- package/.docs/reference/browser/mastra-browser.md +286 -0
- package/.docs/reference/browser/stagehand-browser.md +286 -0
- package/.docs/reference/cli/mastra.md +703 -0
- package/.docs/reference/client-js/agents.md +166 -0
- package/.docs/reference/client-js/conversations.md +1 -1
- package/.docs/reference/client-js/mastra-client.md +23 -0
- package/.docs/reference/client-js/observability.md +2 -2
- package/.docs/reference/client-js/responses.md +1 -1
- package/.docs/reference/client-js/workflows.md +62 -1
- package/.docs/reference/configuration.md +67 -1
- package/.docs/reference/core/addGateway.md +5 -5
- package/.docs/reference/core/getEditor.md +35 -0
- package/.docs/reference/core/getGateway.md +5 -5
- package/.docs/reference/core/getGatewayById.md +5 -5
- package/.docs/reference/core/getMCPServer.md +2 -2
- package/.docs/reference/core/getMCPServerById.md +2 -2
- package/.docs/reference/core/getScorer.md +3 -3
- package/.docs/reference/core/getScorerById.md +3 -3
- package/.docs/reference/core/listGateways.md +5 -5
- package/.docs/reference/core/listMCPServers.md +2 -2
- package/.docs/reference/core/listScorers.md +3 -3
- package/.docs/reference/core/mastra-class.md +11 -1
- package/.docs/reference/core/mastra-model-gateway.md +5 -5
- package/.docs/reference/datasets/create.md +4 -4
- package/.docs/reference/datasets/startExperiment.md +28 -2
- package/.docs/reference/datasets/update.md +4 -4
- package/.docs/reference/deployer/cloudflare.md +14 -1
- package/.docs/reference/deployer/netlify.md +50 -2
- package/.docs/reference/editor/mastra-editor.md +168 -0
- package/.docs/reference/editor/tool-provider.md +85 -0
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +3 -3
- package/.docs/reference/evals/create-scorer.md +5 -3
- package/.docs/reference/evals/filter-run.md +117 -0
- package/.docs/reference/evals/mastra-scorer.md +4 -4
- package/.docs/reference/evals/noise-sensitivity.md +6 -6
- package/.docs/reference/evals/prompt-alignment.md +12 -12
- package/.docs/reference/evals/run-evals.md +6 -6
- package/.docs/reference/evals/scorer-utils.md +3 -3
- package/.docs/reference/evals/trajectory-accuracy.md +3 -3
- package/.docs/reference/harness/harness-class.md +152 -53
- package/.docs/reference/index.md +25 -0
- package/.docs/reference/logging/pino-logger.md +0 -2
- package/.docs/reference/mastra-platform/api.md +108 -0
- package/.docs/reference/memory/clone-utilities.md +4 -2
- package/.docs/reference/memory/cloneThread.md +4 -2
- package/.docs/reference/memory/observational-memory.md +4 -0
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
- package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
- package/.docs/reference/observability/tracing/configuration.md +18 -11
- package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
- package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
- package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
- package/.docs/reference/observability/tracing/instances.md +7 -7
- package/.docs/reference/observability/tracing/interfaces.md +23 -6
- package/.docs/reference/observability/tracing/span-filtering.md +95 -0
- package/.docs/reference/observability/tracing/spans.md +6 -6
- package/.docs/reference/processors/prefill-error-handler.md +70 -0
- package/.docs/reference/processors/processor-interface.md +400 -40
- package/.docs/reference/processors/skill-search-processor.md +20 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
- package/.docs/reference/processors/tool-call-filter.md +23 -0
- package/.docs/reference/server/create-route.md +3 -3
- package/.docs/reference/server/express-adapter.md +4 -4
- package/.docs/reference/server/fastify-adapter.md +4 -4
- package/.docs/reference/server/hono-adapter.md +4 -4
- package/.docs/reference/server/koa-adapter.md +4 -4
- package/.docs/reference/server/mastra-server.md +3 -3
- package/.docs/reference/server/nestjs-adapter.md +169 -0
- package/.docs/reference/server/register-api-route.md +4 -4
- package/.docs/reference/server/routes.md +11 -10
- package/.docs/reference/storage/clickhouse.md +300 -0
- package/.docs/reference/storage/cloudflare-d1.md +42 -42
- package/.docs/reference/storage/composite.md +5 -3
- package/.docs/reference/storage/duckdb.md +150 -0
- package/.docs/reference/storage/overview.md +1 -1
- package/.docs/reference/storage/redis.md +266 -0
- package/.docs/reference/streaming/ChunkType.md +143 -3
- package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
- package/.docs/reference/streaming/agents/stream.md +10 -2
- package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
- package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
- package/.docs/reference/templates/overview.md +88 -14
- package/.docs/reference/tools/create-tool.md +107 -5
- package/.docs/reference/tools/mcp-client.md +45 -0
- package/.docs/reference/tools/mcp-server.md +1 -3
- package/.docs/reference/tools/perplexity.md +155 -0
- package/.docs/reference/tools/tavily.md +307 -0
- package/.docs/reference/vectors/mongodb.md +0 -2
- package/.docs/reference/voice/aws-nova-sonic.md +247 -0
- package/.docs/reference/voice/cloudflare.md +3 -3
- package/.docs/reference/voice/sarvam.md +29 -23
- package/.docs/reference/voice/voice.connect.md +4 -4
- package/.docs/reference/voice/voice.listen.md +3 -3
- package/.docs/reference/workflows/run-methods/resume.md +24 -0
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/step.md +88 -7
- package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
- package/.docs/reference/workflows/workflow.md +88 -4
- package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
- package/.docs/reference/workspace/docker-sandbox.md +196 -0
- package/.docs/reference/workspace/gcs-filesystem.md +1 -0
- package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
- package/.docs/reference/workspace/modal-sandbox.md +168 -0
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +80 -5
- package/.docs/reference/workspace/vercel.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +37 -6
- package/CHANGELOG.md +500 -4
- package/dist/stdio.js.map +1 -1
- package/dist/utils.d.ts +1 -4
- package/dist/utils.d.ts.map +1 -1
- package/package.json +11 -11
- package/.docs/docs/mastra-cloud/deployment.md +0 -77
- package/.docs/docs/mastra-cloud/observability.md +0 -38
- package/.docs/docs/mastra-cloud/overview.md +0 -23
- 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
|
|
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)
|
|
22
|
-
- [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem)
|
|
23
|
-
- [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem)
|
|
24
|
-
- [`
|
|
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 `
|
|
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
|
-
|
|
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
|
|
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: ['
|
|
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: ['
|
|
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
|
|
159
|
-
|
|
|
160
|
-
| Local development with files and commands
|
|
161
|
-
| Cloud storage accessible inside a cloud sandbox
|
|
162
|
-
| Multiple cloud providers in one sandbox
|
|
163
|
-
| Agent reads/writes files, no command execution needed
|
|
164
|
-
| Agent runs commands, no file tools needed
|
|
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
|
|
|
@@ -195,13 +214,41 @@ const workspace = new Workspace({
|
|
|
195
214
|
|
|
196
215
|
### Tool options
|
|
197
216
|
|
|
198
|
-
| Option | Type
|
|
199
|
-
| ------------------------ |
|
|
200
|
-
| `enabled` | `boolean` | Whether the tool is available (default: `true`)
|
|
201
|
-
| `requireApproval` | `boolean` | Whether the tool requires user approval before execution (default: `false`)
|
|
202
|
-
| `requireReadBeforeWrite` | `boolean` | For write tools: require reading the file first (default: `false`)
|
|
203
|
-
| `name` | `string`
|
|
204
|
-
| `maxOutputTokens` | `number`
|
|
217
|
+
| Option | Type | Description |
|
|
218
|
+
| ------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
219
|
+
| `enabled` | `boolean \| (context) => boolean` | Whether the tool is available (default: `true`). When a function, evaluated at tool-listing time. |
|
|
220
|
+
| `requireApproval` | `boolean \| (context) => boolean` | Whether the tool requires user approval before execution (default: `false`). When a function, evaluated at execution time with access to `args`. |
|
|
221
|
+
| `requireReadBeforeWrite` | `boolean \| (context) => boolean` | For write tools: require reading the file first (default: `false`). When a function, evaluated at execution time with access to `args`. |
|
|
222
|
+
| `name` | `string` | Custom name for the tool. Replaces the default `mastra_workspace_*` name. |
|
|
223
|
+
| `maxOutputTokens` | `number` | Maximum tokens for tool output (default: `2000`). Output exceeding this limit is truncated using tiktoken. |
|
|
224
|
+
|
|
225
|
+
### Dynamic tool configuration
|
|
226
|
+
|
|
227
|
+
Tool options that accept functions receive a context object and return a boolean. This enables context-aware tool behavior.
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const workspace = new Workspace({
|
|
231
|
+
filesystem: new LocalFilesystem({ basePath: './workspace' }),
|
|
232
|
+
tools: {
|
|
233
|
+
// Dynamic enabled: disable command execution unless explicitly allowed
|
|
234
|
+
[WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND]: {
|
|
235
|
+
enabled: async ({ requestContext }) => {
|
|
236
|
+
return requestContext['allowExecution'] === 'true'
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
// Dynamic requireApproval: only require approval for protected paths
|
|
241
|
+
[WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE]: {
|
|
242
|
+
requireApproval: async ({ args }) => {
|
|
243
|
+
return (args.path as string).startsWith('/protected')
|
|
244
|
+
},
|
|
245
|
+
requireReadBeforeWrite: true,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Functions for `enabled` receive `{ requestContext, workspace }`. Functions for `requireApproval` and `requireReadBeforeWrite` also receive `args` since they are evaluated when the tool is called.
|
|
205
252
|
|
|
206
253
|
### Tool name remapping
|
|
207
254
|
|
|
@@ -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
|
|
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)
|