@mastra/mcp-docs-server 1.1.46-alpha.2 → 1.1.46-alpha.4
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/agent-builder/browser.md +1 -1
- package/.docs/docs/agent-builder/channels.md +1 -1
- package/.docs/docs/agent-builder/integrations.md +73 -0
- package/.docs/docs/agent-builder/overview.md +1 -0
- package/.docs/docs/agents/adding-voice.md +1 -1
- package/.docs/docs/agents/agent-approval.md +2 -2
- package/.docs/docs/agents/background-tasks.md +1 -1
- package/.docs/docs/agents/channels.md +2 -2
- package/.docs/docs/agents/code-mode.md +20 -56
- package/.docs/docs/agents/overview.md +1 -0
- package/.docs/docs/agents/sdk-agents.md +165 -1
- package/.docs/docs/agents/supervisor-agents.md +40 -2
- package/.docs/docs/agents/using-tools.md +59 -1
- package/.docs/docs/browser/agent-browser.md +1 -1
- package/.docs/docs/browser/browser-viewer.md +22 -15
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/browser/stagehand.md +1 -1
- package/.docs/docs/editor/overview.md +6 -6
- package/.docs/docs/editor/prompts.md +3 -3
- package/.docs/docs/editor/tools.md +2 -2
- package/.docs/docs/evals/evals-with-memory.md +8 -8
- package/.docs/docs/mastra-platform/observability.md +1 -1
- package/.docs/docs/mastra-platform/server.md +1 -1
- package/.docs/docs/mcp/mcp-apps.md +4 -4
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/docs/memory/working-memory.md +2 -2
- package/.docs/docs/observability/integrations/bridges/datadog.md +1 -1
- package/.docs/docs/observability/integrations/bridges/otel.md +1 -1
- package/.docs/docs/observability/integrations/exporters/laminar.md +1 -1
- package/.docs/docs/observability/integrations/exporters/langfuse.md +26 -1
- package/.docs/docs/observability/integrations/exporters/mastra-platform.md +1 -1
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +4 -4
- package/.docs/docs/observability/integrations/exporters/otel.md +1 -1
- package/.docs/docs/observability/integrations/overview.md +1 -1
- package/.docs/docs/observability/logging.md +1 -1
- package/.docs/docs/observability/metrics/overview.md +3 -3
- package/.docs/docs/observability/metrics/querying.md +2 -2
- package/.docs/docs/observability/storage.md +2 -2
- package/.docs/docs/observability/tracing/overview.md +1 -1
- package/.docs/docs/server/auth/fga.md +15 -15
- package/.docs/docs/server/auth/okta.md +2 -2
- package/.docs/docs/server/auth/workos.md +1 -1
- package/.docs/docs/server/custom-api-routes.md +1 -1
- package/.docs/docs/server/pubsub.md +4 -4
- package/.docs/docs/studio/auth.md +1 -1
- package/.docs/docs/studio/observability.md +3 -1
- package/.docs/docs/workflows/scheduled-workflows.md +13 -13
- package/.docs/docs/workspace/filesystem.md +1 -1
- package/.docs/docs/workspace/lsp.md +1 -1
- package/.docs/docs/workspace/overview.md +35 -1
- package/.docs/docs/workspace/sandbox.md +4 -3
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +2 -2
- package/.docs/guides/deployment/aws-bedrock-agentcore.md +3 -3
- package/.docs/guides/deployment/inngest.md +5 -5
- package/.docs/guides/deployment/temporal.md +3 -3
- package/.docs/guides/getting-started/nestjs.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
- package/.docs/models/gateways/custom-gateways.md +57 -7
- package/.docs/reference/acp/acp-agent.md +2 -2
- package/.docs/reference/agents/agent.md +44 -0
- package/.docs/reference/agents/channels.md +1 -1
- package/.docs/reference/agents/durable-agent.md +2 -2
- package/.docs/reference/agents/generate.md +2 -0
- package/.docs/reference/agents/generateLegacy.md +2 -0
- package/.docs/reference/ai-sdk/handle-chat-stream.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
- package/.docs/reference/auth/okta.md +1 -1
- package/.docs/reference/auth/workos.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +11 -9
- package/.docs/reference/browser/stagehand-browser.md +1 -1
- package/.docs/reference/cli/mastra.md +3 -1
- package/.docs/reference/client-js/responses.md +2 -2
- package/.docs/reference/client-js/workflows.md +1 -1
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/core/mastra-model-gateway.md +15 -1
- package/.docs/reference/core/removeWorkspace.md +26 -0
- package/.docs/reference/editor/browser-provider.md +1 -1
- package/.docs/reference/editor/storage-browser-ref.md +3 -3
- package/.docs/reference/editor/storage-workspace-ref.md +1 -1
- package/.docs/reference/evals/rubric.md +113 -0
- package/.docs/reference/evals/trajectory-accuracy.md +3 -3
- package/.docs/reference/harness/harness-class.md +81 -62
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/serialized-memory-config.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
- package/.docs/reference/observability/tracing/bridges/datadog.md +1 -1
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +3 -3
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +5 -5
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
- package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +2 -2
- package/.docs/reference/processors/cost-guard-processor.md +2 -2
- package/.docs/reference/processors/processor-interface.md +4 -4
- package/.docs/reference/processors/response-cache.md +2 -2
- package/.docs/reference/processors/skill-search-processor.md +3 -3
- package/.docs/reference/processors/tool-search-processor.md +108 -4
- package/.docs/reference/pubsub/base.md +1 -1
- package/.docs/reference/pubsub/caching-pubsub.md +2 -2
- package/.docs/reference/pubsub/event-emitter.md +3 -3
- package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +2 -2
- package/.docs/reference/signals/task-signal-provider.md +62 -0
- package/.docs/reference/storage/clickhouse.md +49 -4
- package/.docs/reference/storage/composite.md +33 -1
- package/.docs/reference/storage/convex.md +2 -2
- package/.docs/reference/storage/dsql.md +7 -7
- package/.docs/reference/storage/duckdb.md +3 -3
- package/.docs/reference/storage/redis.md +3 -3
- package/.docs/reference/storage/spanner.md +7 -7
- package/.docs/reference/streaming/agents/stream.md +2 -0
- package/.docs/reference/streaming/agents/streamLegacy.md +2 -0
- package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
- package/.docs/reference/tools/brightdata.md +3 -3
- package/.docs/reference/tools/create-code-mode.md +124 -0
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +5 -5
- package/.docs/reference/tools/mcp-server.md +45 -0
- package/.docs/reference/tools/perplexity.md +4 -4
- package/.docs/reference/tools/tavily.md +3 -3
- package/.docs/reference/voice/aws-nova-sonic.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +1 -1
- package/.docs/reference/voice/inworld-realtime.md +5 -5
- package/.docs/reference/voice/inworld.md +1 -1
- package/.docs/reference/voice/sarvam.md +1 -1
- package/.docs/reference/workspace/agentcore-runtime-sandbox.md +7 -7
- package/.docs/reference/workspace/azure-blob-filesystem.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +7 -7
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +230 -0
- package/.docs/reference/workspace/vercel-microvm-sandbox.md +1 -1
- package/.docs/reference/workspace/vercel.md +2 -2
- package/.docs/reference/workspace/workspace-class.md +39 -3
- package/CHANGELOG.md +17 -0
- package/dist/chunk-GLPCVXXO.js +2075 -0
- package/dist/chunk-GLPCVXXO.js.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/stdio.js +1 -2070
- package/dist/stdio.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# RailwaySandbox
|
|
2
|
+
|
|
3
|
+
Executes commands in ephemeral, isolated [Railway](https://docs.railway.com/sandboxes) sandboxes. Each sandbox is an isolated Debian Linux VM provisioned on demand through the Railway TypeScript SDK. Supports command execution with streaming output, command timeouts, configurable idle timeout, `ISOLATED`/`PRIVATE` network isolation, custom base images via the Railway template builder, forking a running sandbox, and reattaching to an existing sandbox by ID.
|
|
4
|
+
|
|
5
|
+
> **Info:** For interface details, see [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/railway
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/railway
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/railway
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/railway
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Set your Railway credentials in one of three ways.
|
|
34
|
+
|
|
35
|
+
**Shell export**:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export RAILWAY_API_TOKEN=your-api-token
|
|
39
|
+
export RAILWAY_ENVIRONMENT_ID=your-environment-id
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**.env file**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
RAILWAY_API_TOKEN=your-api-token
|
|
46
|
+
RAILWAY_ENVIRONMENT_ID=your-environment-id
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Constructor**:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
new RailwaySandbox({
|
|
53
|
+
token: 'your-api-token',
|
|
54
|
+
environmentId: 'your-environment-id',
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
Add a `RailwaySandbox` to a workspace and assign it to an agent:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Agent } from '@mastra/core/agent'
|
|
64
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
65
|
+
import { RailwaySandbox } from '@mastra/railway'
|
|
66
|
+
|
|
67
|
+
const workspace = new Workspace({
|
|
68
|
+
sandbox: new RailwaySandbox({
|
|
69
|
+
// token + environmentId read from RAILWAY_API_TOKEN / RAILWAY_ENVIRONMENT_ID
|
|
70
|
+
idleTimeoutMinutes: 30,
|
|
71
|
+
}),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const agent = new Agent({
|
|
75
|
+
id: 'code-agent',
|
|
76
|
+
name: 'Code Agent',
|
|
77
|
+
instructions: 'You are a coding assistant working in this workspace.',
|
|
78
|
+
model: 'anthropic/claude-sonnet-4-6',
|
|
79
|
+
workspace,
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const response = await agent.generate(
|
|
83
|
+
'Print "Hello, world!" and show the current working directory.',
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
console.log(response.text)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Private networking
|
|
90
|
+
|
|
91
|
+
Join the environment's private network to reach other Railway services (for example `postgres.railway.internal`):
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const workspace = new Workspace({
|
|
95
|
+
sandbox: new RailwaySandbox({
|
|
96
|
+
networkIsolation: 'PRIVATE',
|
|
97
|
+
env: { NODE_ENV: 'production' },
|
|
98
|
+
}),
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The default `ISOLATED` mode allows outbound internet access only, with no private network connectivity.
|
|
103
|
+
|
|
104
|
+
### Custom base image (templates)
|
|
105
|
+
|
|
106
|
+
Pre-install packages and run setup steps so every sandbox starts ready. Pass a builder callback over the Railway template builder — the template is built once on the first `start()`:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const workspace = new Workspace({
|
|
110
|
+
sandbox: new RailwaySandbox({
|
|
111
|
+
template: t => t.withPackages('git', 'curl').run('npm i -g pnpm').workdir('/app'),
|
|
112
|
+
}),
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You can also pass a pre-built `SandboxTemplate` to reuse it across sandboxes without rebuilding. Templates are ignored when `sandboxId` is set, since reattaching uses the existing sandbox's filesystem.
|
|
117
|
+
|
|
118
|
+
### Forking a running sandbox
|
|
119
|
+
|
|
120
|
+
Clone a running sandbox's filesystem into a new, independent sandbox — a fresh boot, not live processes. The returned `RailwaySandbox` is already started:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const child = await sandbox.fork({ idleTimeoutMinutes: 15 })
|
|
124
|
+
|
|
125
|
+
const result = await child.executeCommand('cat', ['/app/state.json'])
|
|
126
|
+
console.log(result.stdout)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The forked sandbox inherits the parent's credentials and defaults unless overridden via the `fork()` options.
|
|
130
|
+
|
|
131
|
+
### Streaming output
|
|
132
|
+
|
|
133
|
+
Stream command output in real time via `onStdout` and `onStderr` callbacks:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
await sandbox.executeCommand('bash', ['-c', 'for i in 1 2 3; do echo "line $i"; sleep 1; done'], {
|
|
137
|
+
onStdout: chunk => process.stdout.write(chunk),
|
|
138
|
+
onStderr: chunk => process.stderr.write(chunk),
|
|
139
|
+
})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Both callbacks are optional and can be used independently.
|
|
143
|
+
|
|
144
|
+
### Reattaching to an existing sandbox
|
|
145
|
+
|
|
146
|
+
A Railway sandbox outlives the process that created it. Reconnect by its Railway ID instead of provisioning a new one:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const sandbox = new RailwaySandbox({ sandboxId: 'existing-railway-sandbox-id' })
|
|
150
|
+
await sandbox._start()
|
|
151
|
+
|
|
152
|
+
const result = await sandbox.executeCommand('cat', ['/tmp/state.txt'])
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Constructor parameters
|
|
156
|
+
|
|
157
|
+
**id** (`string`): Unique identifier for this sandbox instance. (Default: `Auto-generated`)
|
|
158
|
+
|
|
159
|
+
**token** (`string`): Railway API token for authentication. Falls back to the RAILWAY\_API\_TOKEN environment variable.
|
|
160
|
+
|
|
161
|
+
**environmentId** (`string`): Railway environment ID. Falls back to the RAILWAY\_ENVIRONMENT\_ID environment variable.
|
|
162
|
+
|
|
163
|
+
**sandboxId** (`string`): Reattach to an existing Railway sandbox by its Railway ID instead of creating a new one. When set, start() calls Sandbox.connect().
|
|
164
|
+
|
|
165
|
+
**idleTimeoutMinutes** (`number`): How long the sandbox can sit idle (no exec interaction) before Railway destroys it automatically. The valid range and default depend on your Railway plan.
|
|
166
|
+
|
|
167
|
+
**networkIsolation** (`'ISOLATED' | 'PRIVATE'`): Network access mode. 'ISOLATED' allows outbound internet only; 'PRIVATE' joins the environment's private network. (Default: `'ISOLATED'`)
|
|
168
|
+
|
|
169
|
+
**env** (`Record<string, string>`): Environment variables baked into the sandbox, available to every command. (Default: `{}`)
|
|
170
|
+
|
|
171
|
+
**template** (`SandboxTemplate | (base: SandboxTemplate) => SandboxTemplate`): Provision the sandbox from a custom base image built with the Railway template builder. Accepts a builder callback or a pre-built template. Ignored when sandboxId is set.
|
|
172
|
+
|
|
173
|
+
**timeout** (`number`): Default execution timeout in milliseconds applied to commands that do not specify their own timeout. Commands run until they exit when omitted.
|
|
174
|
+
|
|
175
|
+
**instructions** (`string | (opts) => string`): Override the default agent instructions. A string replaces them entirely; a function receives the default instructions and returns the final text.
|
|
176
|
+
|
|
177
|
+
## Properties
|
|
178
|
+
|
|
179
|
+
**id** (`string`): Sandbox instance identifier.
|
|
180
|
+
|
|
181
|
+
**name** (`string`): Provider name ('RailwaySandbox').
|
|
182
|
+
|
|
183
|
+
**provider** (`string`): Provider identifier ('railway').
|
|
184
|
+
|
|
185
|
+
**status** (`ProviderStatus`): 'pending' | 'initializing' | 'ready' | 'stopped' | 'destroyed' | 'error'
|
|
186
|
+
|
|
187
|
+
**railway** (`Sandbox`): The underlying Railway Sandbox instance for direct SDK access. Throws SandboxNotReadyError if the sandbox has not been started.
|
|
188
|
+
|
|
189
|
+
**processes** (`RailwayProcessManager`): Background process manager. See \[SandboxProcessManager reference]\(/reference/workspace/process-manager).
|
|
190
|
+
|
|
191
|
+
## Methods
|
|
192
|
+
|
|
193
|
+
**fork** (`(options?) => Promise<RailwaySandbox>`): Clone this running sandbox into a new, independent RailwaySandbox. The returned sandbox is already started and reattached to the forked Railway sandbox. Accepts optional id, idleTimeoutMinutes, networkIsolation, and env overrides. Throws SandboxNotReadyError if this sandbox has not been started.
|
|
194
|
+
|
|
195
|
+
## Background processes
|
|
196
|
+
|
|
197
|
+
`RailwaySandbox` includes a built-in process manager for spawning and managing background processes. Each spawned process runs as a Railway `exec` session.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const sandbox = new RailwaySandbox()
|
|
201
|
+
await sandbox.start()
|
|
202
|
+
|
|
203
|
+
// Spawn a background process
|
|
204
|
+
const handle = await sandbox.processes.spawn('node server.js', {
|
|
205
|
+
env: { PORT: '3000' },
|
|
206
|
+
onStdout: data => console.log(data),
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
// Interact with the process
|
|
210
|
+
console.log(handle.stdout)
|
|
211
|
+
await handle.kill()
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Railway's `exec` API does not stream stdin, so `sendStdin()` is not supported.
|
|
215
|
+
|
|
216
|
+
See [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
217
|
+
|
|
218
|
+
## Editor provider
|
|
219
|
+
|
|
220
|
+
Register the provider with `MastraEditor` to hydrate stored sandbox configs into runtime instances:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { railwaySandboxProvider } from '@mastra/railway'
|
|
224
|
+
|
|
225
|
+
const editor = new MastraEditor({
|
|
226
|
+
sandboxes: { [railwaySandboxProvider.id]: railwaySandboxProvider },
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
See the [Sandbox provider reference](https://mastra.ai/reference/editor/sandbox-provider) for details on registering custom sandbox providers.
|
|
@@ -187,7 +187,7 @@ await handle.kill()
|
|
|
187
187
|
|
|
188
188
|
See the [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
189
189
|
|
|
190
|
-
> **Note:** The Vercel Sandbox SDK
|
|
190
|
+
> **Note:** The Vercel Sandbox SDK doesn't expose a stdin channel for running commands, so `handle.sendStdin()` throws. Filesystem mounting (FUSE) is also not supported by this provider.
|
|
191
191
|
|
|
192
192
|
## Limits
|
|
193
193
|
|
|
@@ -4,7 +4,7 @@ Executes commands as [Vercel](https://vercel.com) serverless functions. Provides
|
|
|
4
4
|
|
|
5
5
|
> **Info:** For interface details, see [WorkspaceSandbox interface](https://mastra.ai/reference/workspace/sandbox).
|
|
6
6
|
|
|
7
|
-
> **Warning:** VercelSandbox is stateless.
|
|
7
|
+
> **Warning:** VercelSandbox is stateless. No persistent filesystem, no interactive shell, and no support for long-running or background processes exist. Only `/tmp` is writable and is ephemeral between invocations.
|
|
8
8
|
|
|
9
9
|
> **Note:** For a full Linux MicroVM with a persistent filesystem, `sudo` access, exposed ports, and background processes, use [`VercelMicroVMSandbox`](https://mastra.ai/reference/workspace/vercel-microvm-sandbox), which is backed by the [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) product.
|
|
10
10
|
|
|
@@ -110,7 +110,7 @@ VercelSandbox uses serverless functions under the hood, which means:
|
|
|
110
110
|
- **No persistent filesystem**: Files written to `/tmp` are ephemeral and cleared between invocations.
|
|
111
111
|
- **No interactive shell**: Commands run via `/bin/sh -c` with no stdin streaming.
|
|
112
112
|
- **No background processes**: No process manager, PIDs, or long-running tasks.
|
|
113
|
-
- **No mounting**: Cloud storage mounting (S3, GCS)
|
|
113
|
+
- **No mounting**: Cloud storage mounting (S3, GCS) isn't supported.
|
|
114
114
|
- **Timeout limits**: Maximum execution time is bounded by `maxDuration` (default 60s).
|
|
115
115
|
|
|
116
116
|
## Related
|
|
@@ -65,6 +65,8 @@ const workspace = new Workspace({
|
|
|
65
65
|
|
|
66
66
|
**tools.maxOutputTokens** (`number`): Maximum tokens for tool output. Output exceeding this limit is truncated using tiktoken.
|
|
67
67
|
|
|
68
|
+
**tools.hooks** (`WorkspaceToolHooks`): Hooks that run before and after every enabled workspace tool call. See Tool hooks below.
|
|
69
|
+
|
|
68
70
|
**operationTimeout** (`number`): Timeout for operations in milliseconds
|
|
69
71
|
|
|
70
72
|
## Tool configuration
|
|
@@ -118,6 +120,34 @@ const workspace = new Workspace({
|
|
|
118
120
|
|
|
119
121
|
Tool names must be unique across all workspace tools. Setting a custom name that conflicts with another tool's default or custom name throws an error.
|
|
120
122
|
|
|
123
|
+
### Tool hooks
|
|
124
|
+
|
|
125
|
+
Set `tools.hooks` to run logic before and after every enabled workspace tool call. Hooks run after name remapping, so the context includes both the exposed `toolName` and the original `workspaceToolName`.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { Workspace } from '@mastra/core/workspace'
|
|
129
|
+
|
|
130
|
+
const workspace = new Workspace({
|
|
131
|
+
id: 'my-workspace',
|
|
132
|
+
tools: {
|
|
133
|
+
hooks: {
|
|
134
|
+
beforeToolCall: ({ toolName, workspaceToolName, input }) => {
|
|
135
|
+
console.log(`Running ${toolName} (${workspaceToolName})`, input)
|
|
136
|
+
},
|
|
137
|
+
afterToolCall: ({ toolName, output, error }) => {
|
|
138
|
+
console.log(`Finished ${toolName}`, { output, error })
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**beforeToolCall** (`(context: WorkspaceToolHookContext) => void | WorkspaceToolBeforeHookResult | Promise<void | WorkspaceToolBeforeHookResult>`): Runs before a workspace tool executes. Receives \`{ toolName, workspaceToolName, input, context }\`. Return \`{ proceed: false, output }\` to skip the tool call and use \`output\` as its result.
|
|
146
|
+
|
|
147
|
+
**afterToolCall** (`(context: WorkspaceToolAfterHookContext) => void | Promise<void>`): Runs after a workspace tool executes. Receives \`{ toolName, workspaceToolName, input, context, output, error }\`. \`output\` is undefined when the tool throws, and \`error\` is set instead.
|
|
148
|
+
|
|
149
|
+
If the owning agent also defines [tool hooks](https://mastra.ai/reference/agents/agent), workspace hooks run inside the agent hook wrapper: agent `beforeToolCall` runs first, then workspace `beforeToolCall`, then the tool, then workspace `afterToolCall`, then agent `afterToolCall`.
|
|
150
|
+
|
|
121
151
|
## Properties
|
|
122
152
|
|
|
123
153
|
**id** (`string`): Workspace identifier
|
|
@@ -170,6 +200,12 @@ Destroy the workspace and clean up resources.
|
|
|
170
200
|
await workspace.destroy()
|
|
171
201
|
```
|
|
172
202
|
|
|
203
|
+
`destroy()` closes workspace-owned resources in order: language servers, browsers, sandbox providers, and filesystem providers. It also clears cached sandbox references.
|
|
204
|
+
|
|
205
|
+
Call `destroy()` when your application is done with a workspace. `mastra.shutdown()` calls it for registered workspaces during shutdown. To remove a workspace from the Mastra registry, use [`mastra.removeWorkspace()`](https://mastra.ai/reference/core/removeWorkspace).
|
|
206
|
+
|
|
207
|
+
`LocalFilesystem.destroy()` doesn't delete files on disk. Resolver-backed filesystem and sandbox providers are owned by your application and must be cleaned up by your application.
|
|
208
|
+
|
|
173
209
|
### Search operations
|
|
174
210
|
|
|
175
211
|
#### `index(path, content, options?)`
|
|
@@ -349,9 +385,9 @@ const sandbox = await workspace.resolveSandbox({ requestContext: ctx })
|
|
|
349
385
|
|
|
350
386
|
Clear resolver-backed sandboxes cached by `sandboxCacheKey`. Pass a cache key to clear one entry, or omit it to clear all keyed sandbox entries.
|
|
351
387
|
|
|
352
|
-
This method
|
|
388
|
+
This method doesn't clear the per-`RequestContext` weak cache. Those entries are garbage-collection managed.
|
|
353
389
|
|
|
354
|
-
The workspace
|
|
390
|
+
The workspace doesn't own resolver-returned sandboxes. This method only drops workspace references. Destroy the sandbox in your own lifecycle code.
|
|
355
391
|
|
|
356
392
|
```typescript
|
|
357
393
|
workspace.clearSandboxCache('thread-123')
|
|
@@ -415,7 +451,7 @@ Added when a sandbox is configured:
|
|
|
415
451
|
| `mastra_workspace_get_process_output` | Get stdout, stderr, and status of a background process by PID. Accepts `tail` to limit output lines and `wait: true` to block until exit. Only available when the sandbox has a process manager. |
|
|
416
452
|
| `mastra_workspace_kill_process` | Kill a background process by PID. Returns the last 50 lines of output. Only available when the sandbox has a process manager. |
|
|
417
453
|
|
|
418
|
-
With a static sandbox, capability checks (`executeCommand`, `processes`) decide which tool variants are exposed. With a [dynamic sandbox](https://mastra.ai/docs/workspace/sandbox), all sandbox tools are registered and the runtime throws a clear error if the resolved sandbox
|
|
454
|
+
With a static sandbox, capability checks (`executeCommand`, `processes`) decide which tool variants are exposed. With a [dynamic sandbox](https://mastra.ai/docs/workspace/sandbox), all sandbox tools are registered and the runtime throws a clear error if the resolved sandbox doesn't implement a requested capability.
|
|
419
455
|
|
|
420
456
|
The `execute_command` tool accepts a `backgroundProcesses` option for lifecycle callbacks on background processes:
|
|
421
457
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.46-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed the MCP docs server package root export so importing @mastra/mcp-docs-server loads a published runtime file. Fixes #17700. ([#17709](https://github.com/mastra-ai/mastra/pull/17709))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
10
|
+
- @mastra/core@1.42.0-alpha.4
|
|
11
|
+
- @mastra/mcp@1.10.0-alpha.1
|
|
12
|
+
|
|
13
|
+
## 1.1.46-alpha.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963)]:
|
|
18
|
+
- @mastra/core@1.42.0-alpha.3
|
|
19
|
+
|
|
3
20
|
## 1.1.46-alpha.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|