SandboxProvider
SandboxProvider is the interface a package implements to register a sandbox with MastraEditor. The editor calls createSandbox(config) at workspace hydration time, using the provider id from the stored StorageWorkspaceRef sandbox config as the lookup key.
The built-in local sandbox provider is auto-registered. External providers (for example, E2B) are supplied via MastraEditorConfig.sandboxes.
Usage exampleDirect link to Usage example
src/mastra/index.ts
import { MastraEditor } from '@mastra/editor'
import { e2bSandboxProvider } from '@mastra/e2b'
new MastraEditor({
sandboxes: {
[e2bSandboxProvider.id]: e2bSandboxProvider,
},
})
PropertiesDirect link to Properties
id:
string
Unique provider identifier (for example, `"local"`, `"e2b"`). Must match `StorageSandboxConfig.provider` on every stored workspace that uses this provider.
name:
string
Human-readable name for UI display.
description?:
string
Short description shown in the workspace sandbox picker.
configSchema?:
Record<string, unknown>
JSON Schema describing provider-specific configuration. Used by the UI to render config forms.
createSandbox:
(config: TConfig) => WorkspaceSandbox | Promise<WorkspaceSandbox>
Create a runtime `WorkspaceSandbox` instance from the stored config. Called at workspace hydration time.
Implementing a providerDirect link to Implementing a provider
src/providers/my-sandbox.ts
import type { SandboxProvider, WorkspaceSandbox } from '@mastra/core/editor'
export const mySandboxProvider: SandboxProvider<{ apiKey: string }> = {
id: 'my-sandbox',
name: 'My Sandbox',
description: 'Cloud sandbox for command execution.',
configSchema: {
type: 'object',
required: ['apiKey'],
properties: {
apiKey: { type: 'string' },
},
},
async createSandbox(config): Promise<WorkspaceSandbox> {
return createMySandbox({ apiKey: config.apiKey })
},
}
Once registered, admins can reference the provider from an inline workspace config or a stored StorageWorkspaceRef.
RelatedDirect link to Related
- Workspace — concept and worked examples.
- StorageWorkspaceRef — stored configuration consumed by
createSandbox. - FilesystemProvider — sibling provider for file access.
- MastraEditor class — provider registry.