@mastra/mcp-docs-server 1.2.11 → 1.2.12-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agents/using-tools.md +25 -0
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +5 -5
- package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +8 -8
- package/.docs/guides/build-your-ui/copilotkit/overview.md +2 -2
- package/.docs/guides/build-your-ui/openui.md +1 -1
- package/.docs/guides/concepts/multi-agent-systems.md +5 -5
- package/.docs/guides/concepts/streaming.md +9 -9
- package/.docs/guides/deployment/amazon-ec2.md +1 -1
- package/.docs/guides/deployment/aws-lambda.md +1 -1
- package/.docs/guides/deployment/azure-app-services.md +1 -1
- package/.docs/guides/deployment/cloudflare.md +1 -1
- package/.docs/guides/deployment/inngest.md +6 -6
- package/.docs/guides/deployment/temporal.md +1 -1
- package/.docs/guides/deployment/vercel.md +1 -1
- package/.docs/guides/getting-started/astro.md +1 -1
- package/.docs/guides/getting-started/electron.md +1 -1
- package/.docs/guides/getting-started/nestjs.md +5 -5
- package/.docs/guides/getting-started/vite-react.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/coding-agent.md +4 -4
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +3 -3
- package/.docs/guides/guide/github-actions-pr-description.md +4 -4
- package/.docs/guides/guide/research-assistant.md +3 -3
- package/.docs/guides/guide/research-coordinator.md +3 -3
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +1 -1
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +1 -1
- package/.docs/guides/migrations/mastra-cloud.md +6 -6
- package/.docs/guides/migrations/network-to-supervisor.md +9 -9
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +5 -5
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/client.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +11 -11
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +3 -3
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +2 -2
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +1 -1
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +1 -1
- package/.docs/models/environment-variables.md +1 -0
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/modal.md +73 -0
- package/.docs/models/providers.md +1 -0
- package/.docs/reference/acp/acp-agent.md +3 -3
- package/.docs/reference/acp/create-acp-tool.md +2 -2
- package/.docs/reference/agent-controller/agent-controller-class.md +36 -36
- package/.docs/reference/agent-controller/session.md +6 -6
- package/.docs/reference/agents/agent.md +7 -7
- package/.docs/reference/agents/channels.md +3 -3
- package/.docs/reference/agents/durable-agent.md +3 -3
- package/.docs/reference/agents/generate.md +3 -3
- package/.docs/reference/agents/getDefaultOptions.md +1 -1
- package/.docs/reference/agents/getDefaultStreamOptions.md +1 -1
- package/.docs/reference/agents/listScorers.md +1 -1
- package/.docs/reference/agents/listSkills.md +1 -1
- package/.docs/reference/agents/listSuspendedRuns.md +2 -2
- package/.docs/reference/ai-sdk/chat-route.md +1 -1
- package/.docs/reference/ai-sdk/network-route.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +1 -1
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +1 -1
- package/.docs/reference/ai-sdk/workflow-route.md +1 -1
- package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +2 -2
- package/.docs/reference/auth/auth0.md +1 -1
- package/.docs/reference/auth/fga.md +2 -2
- package/.docs/reference/auth/google.md +2 -2
- package/.docs/reference/auth/okta.md +1 -1
- package/.docs/reference/auth/workos.md +2 -2
- package/.docs/reference/browser/agent-browser.md +2 -2
- package/.docs/reference/browser/browser-viewer.md +3 -3
- package/.docs/reference/browser/mastra-browser.md +3 -3
- package/.docs/reference/browser/stagehand-browser.md +4 -4
- package/.docs/reference/channels/slack-provider.md +2 -2
- package/.docs/reference/cli/create-mastra.md +1 -1
- package/.docs/reference/cli/mastra.md +23 -23
- package/.docs/reference/client-js/agents.md +9 -9
- package/.docs/reference/client-js/memory.md +2 -2
- package/.docs/reference/client-js/workflows.md +1 -1
- package/.docs/reference/coding-agent/build-base-prompt.md +2 -2
- package/.docs/reference/coding-agent/create-coding-agent.md +2 -2
- package/.docs/reference/configuration.md +6 -6
- package/.docs/reference/core/getMCPServer.md +1 -1
- package/.docs/reference/core/getScorer.md +1 -1
- package/.docs/reference/datasets/addItem.md +1 -1
- package/.docs/reference/datasets/listItems.md +1 -1
- package/.docs/reference/deployer/netlify.md +4 -4
- package/.docs/reference/deployer/vercel.md +7 -7
- package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
- package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +6 -6
- package/.docs/reference/editor/agent-builder/builder-models.md +3 -3
- package/.docs/reference/editor/blob-store-provider.md +1 -1
- package/.docs/reference/editor/browser-provider.md +3 -3
- package/.docs/reference/editor/filesystem-provider.md +4 -4
- package/.docs/reference/editor/mastra-editor.md +5 -5
- package/.docs/reference/editor/processor-provider.md +3 -3
- package/.docs/reference/editor/sandbox-provider.md +4 -4
- package/.docs/reference/editor/storage-browser-ref.md +6 -6
- package/.docs/reference/editor/storage-workspace-ref.md +4 -4
- package/.docs/reference/editor/tool-provider.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +4 -4
- package/.docs/reference/evals/bias.md +3 -3
- package/.docs/reference/evals/checks.md +3 -3
- package/.docs/reference/evals/completeness.md +5 -5
- package/.docs/reference/evals/content-similarity.md +5 -5
- package/.docs/reference/evals/context-precision.md +2 -2
- package/.docs/reference/evals/context-recall.md +8 -8
- package/.docs/reference/evals/context-relevance.md +4 -4
- package/.docs/reference/evals/create-scorer.md +1 -1
- package/.docs/reference/evals/faithfulness.md +3 -3
- package/.docs/reference/evals/filter-run.md +2 -2
- package/.docs/reference/evals/hallucination.md +6 -6
- package/.docs/reference/evals/keyword-coverage.md +6 -6
- package/.docs/reference/evals/mastra-scorer.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +5 -5
- package/.docs/reference/evals/prompt-alignment.md +5 -5
- package/.docs/reference/evals/rubric.md +1 -1
- package/.docs/reference/evals/run-evals.md +3 -3
- package/.docs/reference/evals/scorer-utils.md +4 -4
- package/.docs/reference/evals/textual-difference.md +4 -4
- package/.docs/reference/evals/tool-call-accuracy.md +1 -1
- package/.docs/reference/evals/toxicity.md +4 -4
- package/.docs/reference/evals/trajectory-accuracy.md +10 -10
- package/.docs/reference/file-based-agents/instructions.md +2 -2
- package/.docs/reference/file-based-agents/logger.md +1 -1
- package/.docs/reference/file-based-agents/observability.md +1 -1
- package/.docs/reference/file-based-agents/processors.md +1 -1
- package/.docs/reference/file-based-agents/skills.md +1 -1
- package/.docs/reference/file-based-agents/storage.md +1 -1
- package/.docs/reference/file-based-agents/studio.md +1 -1
- package/.docs/reference/file-based-agents/subagents.md +1 -1
- package/.docs/reference/file-based-agents/tools.md +1 -1
- package/.docs/reference/file-based-agents/workspace.md +1 -1
- package/.docs/reference/logging/pino-logger.md +3 -3
- package/.docs/reference/memory/clone-utilities.md +1 -1
- package/.docs/reference/memory/cloneThread.md +3 -3
- package/.docs/reference/memory/listThreads.md +1 -1
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/memory/observational-memory.md +11 -11
- package/.docs/reference/memory/recall.md +2 -2
- package/.docs/reference/memory/serialized-memory-config.md +4 -4
- package/.docs/reference/memory/summarizeConversation.md +3 -3
- package/.docs/reference/memory/summarizeThread.md +3 -3
- package/.docs/reference/observability/feedback.md +1 -1
- package/.docs/reference/observability/metrics/automatic-metrics.md +7 -7
- package/.docs/reference/observability/tracing/bridges/datadog.md +2 -2
- 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 +4 -4
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +1 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -1
- package/.docs/reference/observability/tracing/span-filtering.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/pii-detector.md +1 -1
- package/.docs/reference/processors/processor-interface.md +12 -12
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/provider-history-compat.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/response-cache.md +8 -8
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +7 -7
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/project-structure.md +1 -1
- package/.docs/reference/pubsub/base.md +4 -4
- package/.docs/reference/pubsub/google-cloud-pubsub.md +2 -2
- package/.docs/reference/pubsub/lease-provider.md +4 -4
- package/.docs/reference/pubsub/redis-streams.md +1 -1
- package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
- package/.docs/reference/rag/chunk.md +5 -5
- package/.docs/reference/rag/database-config.md +2 -2
- package/.docs/reference/rag/metadata-filters.md +2 -2
- package/.docs/reference/schedules/overview.md +1 -1
- package/.docs/reference/server/register-api-route.md +1 -1
- package/.docs/reference/server/routes.md +1 -1
- package/.docs/reference/signals/signal-provider.md +8 -8
- package/.docs/reference/storage/clickhouse.md +4 -4
- package/.docs/reference/storage/cloudflare-d1.md +4 -4
- package/.docs/reference/storage/convex.md +4 -4
- package/.docs/reference/storage/dsql.md +2 -2
- package/.docs/reference/storage/dynamodb.md +7 -7
- package/.docs/reference/storage/lance.md +1 -1
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/mssql.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/retention.md +33 -33
- package/.docs/reference/storage/spanner.md +8 -8
- package/.docs/reference/streaming/ChunkType.md +2 -2
- package/.docs/reference/streaming/agents/MastraModelOutput.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/agents/streamUntilIdle.md +2 -2
- package/.docs/reference/streaming/workflows/observeStream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/streaming/workflows/stream.md +1 -1
- package/.docs/reference/streaming/workflows/timeTravelStream.md +2 -2
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/brightdata.md +1 -1
- package/.docs/reference/tools/create-tool.md +1 -1
- package/.docs/reference/tools/graph-rag-tool.md +1 -1
- package/.docs/reference/tools/mcp-client.md +13 -13
- package/.docs/reference/tools/mcp-server.md +20 -20
- package/.docs/reference/tools/submit-plan-tool.md +1 -1
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +4 -4
- package/.docs/reference/vectors/astra.md +1 -1
- package/.docs/reference/vectors/chroma.md +2 -2
- package/.docs/reference/vectors/convex.md +2 -2
- package/.docs/reference/vectors/couchbase.md +4 -4
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +4 -4
- package/.docs/reference/vectors/qdrant.md +2 -2
- package/.docs/reference/vectors/s3vectors.md +4 -4
- package/.docs/reference/vectors/turbopuffer.md +1 -1
- package/.docs/reference/voice/aws-nova-sonic.md +1 -1
- package/.docs/reference/voice/azure.md +1 -1
- package/.docs/reference/voice/google-gemini-live.md +4 -4
- package/.docs/reference/voice/inworld-realtime.md +7 -7
- package/.docs/reference/voice/livekit.md +13 -13
- package/.docs/reference/voice/mistral.md +1 -1
- package/.docs/reference/voice/openai-realtime.md +1 -1
- package/.docs/reference/voice/sarvam.md +1 -1
- package/.docs/reference/voice/voice.addTools.md +1 -1
- package/.docs/reference/voice/voice.events.md +1 -1
- package/.docs/reference/voice/voice.getSpeakers.md +2 -2
- package/.docs/reference/voice/voice.on.md +2 -2
- package/.docs/reference/voice/xai-realtime.md +2 -2
- package/.docs/reference/workflows/run-methods/cancel.md +1 -1
- package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workflows/workflow-methods/foreach.md +1 -1
- package/.docs/reference/workflows/workflow-methods/sleep.md +1 -1
- package/.docs/reference/workflows/workflow-state-reader.md +2 -2
- package/.docs/reference/workspace/apple-container-sandbox.md +2 -2
- package/.docs/reference/workspace/daytona-sandbox.md +3 -3
- package/.docs/reference/workspace/docker-sandbox.md +2 -2
- package/.docs/reference/workspace/e2b-sandbox.md +2 -2
- package/.docs/reference/workspace/files-sdk-filesystem.md +3 -3
- package/.docs/reference/workspace/google-drive-filesystem.md +4 -4
- package/.docs/reference/workspace/local-filesystem.md +2 -2
- package/.docs/reference/workspace/local-sandbox.md +2 -2
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/platform-filesystem.md +3 -3
- package/.docs/reference/workspace/platform-sandbox.md +2 -2
- package/.docs/reference/workspace/process-manager.md +1 -1
- package/.docs/reference/workspace/railway-sandbox.md +4 -4
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/.docs/reference/workspace/vercel-sandbox.md +1 -1
- package/.docs/reference/workspace/workspace-class.md +10 -10
- package/CHANGELOG.md +7 -0
- package/package.json +5 -5
|
@@ -20,7 +20,7 @@ The TurbopufferVector class provides vector search using [Turbopuffer](https://t
|
|
|
20
20
|
|
|
21
21
|
**consistency** (`'strong' | 'eventual'`): The default consistency level for queries. Can be overridden per query. "strong" guarantees queries see all data written before the query started, at the cost of higher latency. "eventual" offers lower latency, but recently written data may not be visible yet. (Default: `strong`)
|
|
22
22
|
|
|
23
|
-
**schemaConfigForIndex** (`function`): A callback function that takes an index name and returns a config object for that index.
|
|
23
|
+
**schemaConfigForIndex** (`function`): A callback function that takes an index name and returns a config object for that index. You can define explicit schemas per index.
|
|
24
24
|
|
|
25
25
|
## Methods
|
|
26
26
|
|
|
@@ -218,7 +218,7 @@ Registers and removes event listeners. See [Voice events](https://mastra.ai/refe
|
|
|
218
218
|
|
|
219
219
|
## Available voices
|
|
220
220
|
|
|
221
|
-
Nova 2 Sonic
|
|
221
|
+
Nova 2 Sonic provides voices in ten locales. Tiffany and Matthew are polyglot and can speak any supported language.
|
|
222
222
|
|
|
223
223
|
| Voice ID | Name | Language | Locale | Gender | Polyglot |
|
|
224
224
|
| ---------- | -------- | ---------- | ------ | --------- | -------- |
|
|
@@ -83,7 +83,7 @@ Transcribes audio using Azure's speech-to-text service.
|
|
|
83
83
|
|
|
84
84
|
Returns: `Promise<string>` - The recognized text from the audio
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Language and recognition settings are configured in the `listeningModel` configuration during initialization, not passed as options to this method.
|
|
87
87
|
|
|
88
88
|
### `getSpeakers()`
|
|
89
89
|
|
|
@@ -190,7 +190,7 @@ Returns: `Promise<void>`
|
|
|
190
190
|
|
|
191
191
|
### `updateSessionConfig()`
|
|
192
192
|
|
|
193
|
-
Updates the session configuration
|
|
193
|
+
Updates the session configuration at runtime. This can modify voice settings and speaker selection. It can also modify other runtime configurations.
|
|
194
194
|
|
|
195
195
|
**config** (`Partial<GeminiLiveVoiceConfig>`): Configuration updates to apply.
|
|
196
196
|
|
|
@@ -284,14 +284,14 @@ The GeminiLiveVoice class emits the following events:
|
|
|
284
284
|
|
|
285
285
|
## Native-audio behavior
|
|
286
286
|
|
|
287
|
-
Native-audio Gemini Live models
|
|
287
|
+
Native-audio Gemini Live models (any model whose ID contains `native-audio`, such as `gemini-2.5-flash-native-audio-preview-12-2025`) split text output across two channels:
|
|
288
288
|
|
|
289
289
|
- The model's spoken reply is delivered as audio plus an `output_audio_transcription` transcript and surfaced as `writing` with `role: 'assistant'`.
|
|
290
290
|
- The model's internal reasoning is delivered as `modelTurn.parts.text` and surfaced as `thinking`.
|
|
291
291
|
|
|
292
|
-
On non-native-audio models there is no `output_audio_transcription` channel, so `modelTurn.parts.text` is the spoken response itself and is emitted as `writing
|
|
292
|
+
On non-native-audio models there is no `output_audio_transcription` channel, so `modelTurn.parts.text` is the spoken response itself and is emitted as `writing`. The `thinking` event doesn't fire.
|
|
293
293
|
|
|
294
|
-
Input transcription, output transcription, and barge-in detection (`realtime_input_config.activity_handling = 'START_OF_ACTIVITY_INTERRUPTS'`) are enabled automatically in the setup payload
|
|
294
|
+
Input transcription, output transcription, and barge-in detection (`realtime_input_config.activity_handling = 'START_OF_ACTIVITY_INTERRUPTS'`) are enabled automatically in the setup payload. You don't need extra configuration.
|
|
295
295
|
|
|
296
296
|
## Available models
|
|
297
297
|
|
|
@@ -56,7 +56,7 @@ await voice.send(microphoneStream)
|
|
|
56
56
|
voice.close()
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
> Inworld API keys
|
|
59
|
+
> Inworld API keys are pre-Basic-encoded. Paste them verbatim into `INWORLD_API_KEY`. The package doesn't re-encode them.
|
|
60
60
|
|
|
61
61
|
## Constructor parameters
|
|
62
62
|
|
|
@@ -118,7 +118,7 @@ Use the typed `session` field for documented Inworld realtime options. Fields co
|
|
|
118
118
|
|
|
119
119
|
### `providerData` (Inworld extensions)
|
|
120
120
|
|
|
121
|
-
`providerData` is a typed object for Inworld-specific realtime extensions. It's sent under `session.providerData` on every `session.update`, and composes with any `session.providerData` you set via the `session` field
|
|
121
|
+
`providerData` is a typed object for Inworld-specific realtime extensions. It's sent under `session.providerData` on every `session.update`, and composes with any `session.providerData` you set via the `session` field: the constructor `providerData` wins on key collisions.
|
|
122
122
|
|
|
123
123
|
It has five branches plus two session-level fields:
|
|
124
124
|
|
|
@@ -147,7 +147,7 @@ const voice = new InworldRealtimeVoice({
|
|
|
147
147
|
|
|
148
148
|
Opens the WebSocket connection, sends the initial `session.update`, and resolves once the server acknowledges with `session.updated`. Must be called before `speak()`, `listen()`, or `send()`.
|
|
149
149
|
|
|
150
|
-
A pre-open `error` or `close` on the WebSocket
|
|
150
|
+
A pre-open `error` or `close` on the WebSocket (or a handshake that exceeds `connectTimeoutMs` (15s default)) surfaces as a rejected promise instead of an uncaught socket error. On reject, the half-open socket is closed.
|
|
151
151
|
|
|
152
152
|
```typescript
|
|
153
153
|
await voice.connect()
|
|
@@ -243,7 +243,7 @@ Returns: `void`
|
|
|
243
243
|
|
|
244
244
|
#### `clearOutput()`
|
|
245
245
|
|
|
246
|
-
Clears the server's entire output audio buffer, stopping playback. This also stops any in-flight back-channel audio. The default barge-in path (`response.cancel` on `interrupted`) is back-channel-safe
|
|
246
|
+
Clears the server's entire output audio buffer, stopping playback. This also stops any in-flight back-channel audio. The default barge-in path (`response.cancel` on `interrupted`) is back-channel-safe. Prefer it. Use `clearOutput()` only when you want to flush everything.
|
|
247
247
|
|
|
248
248
|
```typescript
|
|
249
249
|
voice.clearOutput()
|
|
@@ -327,7 +327,7 @@ The `InworldRealtimeVoice` class emits the following events:
|
|
|
327
327
|
|
|
328
328
|
## Voices
|
|
329
329
|
|
|
330
|
-
The package
|
|
330
|
+
The package includes a curated set of voice IDs returned from `getSpeakers()`:
|
|
331
331
|
|
|
332
332
|
- `Dennis`
|
|
333
333
|
- `Hades`
|
|
@@ -344,7 +344,7 @@ Any voice ID from [Inworld's voice catalog](https://docs.inworld.ai/quickstart-t
|
|
|
344
344
|
|
|
345
345
|
## Notes
|
|
346
346
|
|
|
347
|
-
- API keys can be provided via constructor options or the `INWORLD_API_KEY` environment variable. Keys are pre-Basic-encoded
|
|
347
|
+
- API keys can be provided via constructor options or the `INWORLD_API_KEY` environment variable. Keys are pre-Basic-encoded. Don't re-encode them.
|
|
348
348
|
- The WebSocket URL appends `?key=<sessionId>&protocol=realtime`. The model is configured via the initial `session.update`, not the URL.
|
|
349
349
|
- Per-call `speak(input, { speaker })` scopes the voice override to a single response (via the flat `response.voice` field) and doesn't mutate the session.
|
|
350
350
|
- Audio output defaults to PCM16 at 24 kHz. Telephony `audio/pcmu` and `audio/pcma` at 8 kHz, and `audio/float32`, are also supported via `session.audio.output.format`.
|
|
@@ -352,4 +352,4 @@ Any voice ID from [Inworld's voice catalog](https://docs.inworld.ai/quickstart-t
|
|
|
352
352
|
- The voice instance must be closed with `close()` or `disconnect()` to release the WebSocket.
|
|
353
353
|
- `audio.input.turn_detection` defaults to semantic VAD when `session` doesn't supply it. Override with your own object, or pass `null` to disable turn detection entirely.
|
|
354
354
|
- `audio.input.transcription` defaults to `{ model: 'inworld/inworld-stt-1' }`, so user-side `writing` events fire out of the box. Override with your own object, or pass `null` to disable user-side transcription.
|
|
355
|
-
- `on()` and `off()` are typed against `InworldVoiceEventMap
|
|
355
|
+
- `on()` and `off()` are typed against `InworldVoiceEventMap`. Known event names yield a typed callback payload. Unknown names fall back to `unknown`.
|
|
@@ -8,9 +8,9 @@ See [Realtime voice](https://mastra.ai/docs/voice/realtime-voice) for setup and
|
|
|
8
8
|
|
|
9
9
|
The package has three entry points:
|
|
10
10
|
|
|
11
|
-
- `@mastra/livekit`: server-side APIs
|
|
12
|
-
- `@mastra/livekit/worker`: the worker runtime
|
|
13
|
-
- `@mastra/livekit/plugin`: the LLM-component plugin
|
|
11
|
+
- `@mastra/livekit`: server-side APIs, [`liveKitConnectionRoute()`](#livekitconnectionroute), [`dispatchVoiceSession()`](#dispatchvoicesession), [`pipeAgentReplyToWriter()`](#pipeagentreplytowriter), [`serializeSessionMetadata()`](#livekitsessionmetadata), and [`createEndCallTool()`](#createendcalltool). Import these from Mastra server code. This entry never loads the LiveKit agents runtime.
|
|
12
|
+
- `@mastra/livekit/worker`: the worker runtime, [`createLiveKitWorker()`](#createlivekitworker), [`runLiveKitWorker()`](#runlivekitworker), [`chatContextToMessages()`](#chatcontexttomessages), and the session helpers [`speakGreeting()`](#speakgreeting), [`waitForAgentDoneSpeaking()`](#waitforagentdonespeaking), and [`runEndCall()`](#runendcall). Import it only from the worker entry file.
|
|
13
|
+
- `@mastra/livekit/plugin`: the LLM-component plugin, [`MastraLLM`](#mastrallm) and [`createRemoteAgentReplyGenerator()`](#createremoteagentreplygenerator). Import it in workers that build their own `voice.AgentSession`. `createRemoteAgentReplyGenerator()` is also exported from `@mastra/livekit/worker` because it plugs into `createLiveKitWorker()`'s `generate` option. `MastraLLM` is plugin-only.
|
|
14
14
|
|
|
15
15
|
## `createLiveKitWorker()`
|
|
16
16
|
|
|
@@ -148,7 +148,7 @@ Returns: `VoiceTurnMessage[]`, where each entry is `{ role: 'system' | 'user' |
|
|
|
148
148
|
|
|
149
149
|
## `MastraLLM`
|
|
150
150
|
|
|
151
|
-
A standard LiveKit LLM plugin (`llm.LLM`) backed by a Mastra agent. Use it when you build the `voice.AgentSession` yourself and want Mastra in the `llm` slot
|
|
151
|
+
A standard LiveKit LLM plugin (`llm.LLM`) backed by a Mastra agent. Use it when you build the `voice.AgentSession` yourself and want Mastra in the `llm` slot. [`createLiveKitWorker()`](#createlivekitworker) is the managed alternative. See [Use Mastra as the LLM component](https://mastra.ai/docs/voice/realtime-voice) for how to choose.
|
|
152
152
|
|
|
153
153
|
With `remote`, the plugin streams each turn from your Mastra server over HTTP using Server-Sent Events (SSE). The agent loop, tools, and memory run server-side, and interrupting the agent aborts the server-side generation.
|
|
154
154
|
|
|
@@ -194,13 +194,13 @@ Provide exactly one reply source: `remote`, `agent`, or `generate`.
|
|
|
194
194
|
|
|
195
195
|
### Tools run on the Mastra agent
|
|
196
196
|
|
|
197
|
-
Tools are defined and executed server-side on the Mastra agent. The plugin never forwards LiveKit tool definitions: if the session passes a non-empty `toolCtx`, it logs a one-time warning naming the ignored tools. Every tool must complete server-side
|
|
197
|
+
Tools are defined and executed server-side on the Mastra agent. The plugin never forwards LiveKit tool definitions: if the session passes a non-empty `toolCtx`, it logs a one-time warning naming the ignored tools. Every tool must complete server-side: a tool that requires approval or client-side execution fails the turn with a descriptive error instead of hanging the call.
|
|
198
198
|
|
|
199
199
|
Tool activity reaches the worker through `toolFeedback`, `onToolCall`, and `onTurnComplete`.
|
|
200
200
|
|
|
201
201
|
### Instructions
|
|
202
202
|
|
|
203
|
-
LiveKit injects your `voice.Agent`'s `instructions` into the chat context of every request. The plugin drops them
|
|
203
|
+
LiveKit injects your `voice.Agent`'s `instructions` into the chat context of every request. The plugin drops them because the server-side Mastra agent's own instructions are authoritative. To change the prompt, change the Mastra agent.
|
|
204
204
|
|
|
205
205
|
### Interrupted turns
|
|
206
206
|
|
|
@@ -243,7 +243,7 @@ When the server reports token usage for a turn, the plugin feeds it to LiveKit,
|
|
|
243
243
|
|
|
244
244
|
### Errors and timeouts
|
|
245
245
|
|
|
246
|
-
The transport throws LiveKit's `APIError` types (`APIStatusError`, `APIConnectionError`, `APITimeoutError`), so the session's retry policy (`connOptions.maxRetry`) and `FallbackAdapter` failover work unchanged. A turn is never retried after its first token
|
|
246
|
+
The transport throws LiveKit's `APIError` types (`APIStatusError`, `APIConnectionError`, `APITimeoutError`), so the session's retry policy (`connOptions.maxRetry`) and `FallbackAdapter` failover work unchanged. A turn is never retried after its first token: a voice reply is better failed fast than replayed half-heard.
|
|
247
247
|
|
|
248
248
|
A connect and first-token watchdog uses the session's `connOptions.timeoutMs` (10 seconds by default), so a server that accepts the connection but never streams can't cause indefinite dead air.
|
|
249
249
|
|
|
@@ -275,7 +275,7 @@ export default createLiveKitWorker({
|
|
|
275
275
|
|
|
276
276
|
On the `generate` path the worker-level `toolFeedback` and `onTurnComplete` options don't apply, and the worker's end-call detection doesn't fire; pass the hooks to the generator instead.
|
|
277
277
|
|
|
278
|
-
Cancelling a turn (barge-in) tears down the HTTP request, which aborts generation on the server. Errors are thrown as LiveKit `APIError` types
|
|
278
|
+
Cancelling a turn (barge-in) tears down the HTTP request, which aborts generation on the server. Errors are thrown as LiveKit `APIError` types. The `retries` option applies only to initial connection attempts. A turn is never retried after its first chunk.
|
|
279
279
|
|
|
280
280
|
Returns: `VoiceReplyGenerator`.
|
|
281
281
|
|
|
@@ -325,7 +325,7 @@ await speakGreeting(session, {
|
|
|
325
325
|
|
|
326
326
|
## `waitForAgentDoneSpeaking()`
|
|
327
327
|
|
|
328
|
-
Resolves once the agent is no longer producing or playing a reply
|
|
328
|
+
Resolves once the agent is no longer producing or playing a reply: its state has left `thinking` and `speaking`. Resolves immediately when the agent is already idle, and always resolves within `maxWaitMs` (30 seconds by default) as a safety cap. Use it before tearing a session down so closing words play out instead of being cut off.
|
|
329
329
|
|
|
330
330
|
```typescript
|
|
331
331
|
import { waitForAgentDoneSpeaking } from '@mastra/livekit/worker'
|
|
@@ -335,7 +335,7 @@ await waitForAgentDoneSpeaking(session)
|
|
|
335
335
|
|
|
336
336
|
## `runEndCall()`
|
|
337
337
|
|
|
338
|
-
Ends the call after the agent
|
|
338
|
+
Ends the call after the agent asks to hang up. It waits for the agent's closing words and speaks an optional final `message` without interruption. It then deletes the room and hangs up the caller, including SIP callers. The job shuts down with its registered callbacks.
|
|
339
339
|
|
|
340
340
|
Pair it with [`MastraLLM`](#mastrallm)'s `onToolCall` and an [end-call tool](#createendcalltool) on the server-side agent to rebuild agent-initiated hang-up on a session you own:
|
|
341
341
|
|
|
@@ -369,7 +369,7 @@ The exported constants `DEFAULT_END_CALL_TOOL` (`'endCall'`), `DEFAULT_END_CALL_
|
|
|
369
369
|
|
|
370
370
|
## `createEndCallTool()`
|
|
371
371
|
|
|
372
|
-
Builds the Mastra tool an agent calls to end the call
|
|
372
|
+
Builds the Mastra tool an agent calls when it wants to end the call. The tool signals intent and can run optional bookkeeping. The worker performs the actual hang-up. The tool lives on the server-safe root entry. Add it to agents defined in server code.
|
|
373
373
|
|
|
374
374
|
```typescript
|
|
375
375
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -436,7 +436,7 @@ The route accepts a JSON body with optional `agentId`, `threadId`, and `resource
|
|
|
436
436
|
|
|
437
437
|
## `dispatchVoiceSession()`
|
|
438
438
|
|
|
439
|
-
Dispatches a Mastra voice agent into a LiveKit room programmatically
|
|
439
|
+
Dispatches a Mastra voice agent into a LiveKit room programmatically: for server-initiated sessions such as outbound calls.
|
|
440
440
|
|
|
441
441
|
```typescript
|
|
442
442
|
import { dispatchVoiceSession } from '@mastra/livekit'
|
|
@@ -474,7 +474,7 @@ The metadata passed from the Mastra server to the worker through LiveKit job dis
|
|
|
474
474
|
|
|
475
475
|
**requestContext** (`Record<string, unknown>`): Plain-object entries restored into a RequestContext for agent execution.
|
|
476
476
|
|
|
477
|
-
The metadata travels as a JSON string. `liveKitConnectionRoute()` and `dispatchVoiceSession()` serialize it for you; use `serializeSessionMetadata(metadata)` when dispatching through your own code, or write the JSON directly in LiveKit-side configuration such as a SIP dispatch rule. Entries in `requestContext` reach the agent's
|
|
477
|
+
The metadata travels as a JSON string. `liveKitConnectionRoute()` and `dispatchVoiceSession()` serialize it for you; use `serializeSessionMetadata(metadata)` when dispatching through your own code, or write the JSON directly in LiveKit-side configuration such as a SIP dispatch rule. Entries in `requestContext` reach the agent's runtime-defined instructions, tools, and input processors on every turn of the call.
|
|
478
478
|
|
|
479
479
|
## Related
|
|
480
480
|
|
|
@@ -82,7 +82,7 @@ Returns: `Promise<NodeJS.ReadableStream>`
|
|
|
82
82
|
|
|
83
83
|
### `listen(audioStream, options?)`
|
|
84
84
|
|
|
85
|
-
Transcribes audio using Mistral's Voxtral transcription model. Supports diarization, context biasing, and timestamp
|
|
85
|
+
Transcribes audio using Mistral's Voxtral transcription model. Supports diarization, context biasing, and timestamp level of detail.
|
|
86
86
|
|
|
87
87
|
**audioStream** (`NodeJS.ReadableStream`): Audio stream to transcribe.
|
|
88
88
|
|
|
@@ -113,7 +113,7 @@ Returns: `Promise<void>`
|
|
|
113
113
|
|
|
114
114
|
### `updateConfig()`
|
|
115
115
|
|
|
116
|
-
Updates the session configuration for the voice instance. This can
|
|
116
|
+
Updates the session configuration for the voice instance. This can modify voice settings and turn detection. It can also modify other parameters.
|
|
117
117
|
|
|
118
118
|
**sessionConfig** (`Realtime.SessionConfig`): New session configuration to apply.
|
|
119
119
|
|
|
@@ -129,4 +129,4 @@ Returns: `Promise<Array<{voiceId: SarvamVoiceId}>>`
|
|
|
129
129
|
- Audio is returned as a stream containing binary audio data
|
|
130
130
|
- Speech recognition supports mp3 and wav audio formats
|
|
131
131
|
- `bulbul:v1`, `saarika:v1`, `saarika:v2`, and `saarika:flash` have been deprecated by Sarvam and are no longer supported. Use `bulbul:v3` (or `bulbul:v2`) for TTS and `saarika:v2.5` (or `saaras:v3`) for STT.
|
|
132
|
-
- Speaker names aren't interchangeable between `bulbul:v2` and `bulbul:v3
|
|
132
|
+
- Speaker names aren't interchangeable between `bulbul:v2` and `bulbul:v3`. Each model version has its own speaker catalog.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# voice.addTools()
|
|
4
4
|
|
|
5
|
-
The `addTools()` method equips a voice provider with tools (functions) that
|
|
5
|
+
The `addTools()` method equips a voice provider with tools (functions) that the model can call during real-time interactions. Voice assistants can use these tools to search for information or make calculations. They can also interact with external systems.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Voice events
|
|
4
4
|
|
|
5
|
-
Voice providers emit
|
|
5
|
+
Voice providers emit events during real-time voice interactions. These events can be listened to using the [voice.on()](https://mastra.ai/reference/voice/voice.on) method and are particularly important for building interactive voice applications.
|
|
6
6
|
|
|
7
7
|
## Common events
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# voice.getSpeakers()
|
|
4
4
|
|
|
5
|
-
The `getSpeakers()` method retrieves a list of available voice options (speakers) from the voice provider.
|
|
5
|
+
The `getSpeakers()` method retrieves a list of available voice options (speakers) from the voice provider. Applications can present users with voice choices or programmatically select the most appropriate voice for different contexts.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -124,7 +124,7 @@ Different voice providers return different metadata for their voices:
|
|
|
124
124
|
|
|
125
125
|
## Notes
|
|
126
126
|
|
|
127
|
-
- The available voices vary
|
|
127
|
+
- The available voices vary substantially between providers
|
|
128
128
|
- Some providers may require authentication to retrieve the full list of voices
|
|
129
129
|
- The default implementation returns an empty array if the provider doesn't support this method
|
|
130
130
|
- For performance reasons, consider caching the results if you need to display the list frequently
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# voice.on()
|
|
4
4
|
|
|
5
|
-
The `on()` method registers event listeners for
|
|
5
|
+
The `on()` method registers event listeners for voice events. This is particularly important for real-time voice providers, where events are used to communicate transcribed text, audio responses, and other state changes.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -60,7 +60,7 @@ This method doesn't return a value.
|
|
|
60
60
|
|
|
61
61
|
## Events
|
|
62
62
|
|
|
63
|
-
For a
|
|
63
|
+
For a detailed list of events and their payload structures, see the [Voice Events](https://mastra.ai/reference/voice/voice.events) documentation.
|
|
64
64
|
|
|
65
65
|
Common events include:
|
|
66
66
|
|
|
@@ -111,7 +111,7 @@ Returns: `void`
|
|
|
111
111
|
|
|
112
112
|
### `addInstructions()`
|
|
113
113
|
|
|
114
|
-
Sets session instructions. If the WebSocket is open, the provider sends a `session.update
|
|
114
|
+
Sets session instructions. If the WebSocket is open, the provider sends a `session.update`. Passing `undefined` stores an empty string and clears the active instructions on the current session or the next connection.
|
|
115
115
|
|
|
116
116
|
**instructions** (`string`): System instructions to send to xAI.
|
|
117
117
|
|
|
@@ -199,7 +199,7 @@ Returns: `Promise<void>`
|
|
|
199
199
|
- `speaking`: emits assistant audio deltas.
|
|
200
200
|
- `speaking.done`: emits when an assistant audio response completes.
|
|
201
201
|
- `writing`: emits assistant text deltas and user input transcriptions.
|
|
202
|
-
- `error`: emits xAI
|
|
202
|
+
- `error`: emits xAI and provider execution errors. It also emits tool execution errors, and malformed function-call arguments. Tool errors include `details.call_id` and `details.name`.
|
|
203
203
|
- `close`: emits when the WebSocket closes.
|
|
204
204
|
- `tool-call-start`: emits before a Mastra function tool is executed.
|
|
205
205
|
- `tool-call-result`: emits after a Mastra function tool returns.
|
|
@@ -38,7 +38,7 @@ Steps that check the `abortSignal` parameter can respond to cancellation:
|
|
|
38
38
|
- Steps can check if already aborted: `if (abortSignal.aborted) { ... }`
|
|
39
39
|
- Useful for cancelling timeouts, network requests, or long-running operations
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Steps must actively check the abort signal to be canceled mid-execution; otherwise, the current step runs to completion and subsequent steps don't execute.
|
|
42
42
|
|
|
43
43
|
## Extended usage examples
|
|
44
44
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Run.startAsync()
|
|
4
4
|
|
|
5
|
-
The `.startAsync()` method starts a workflow run without waiting for completion. It returns immediately with the `runId`, allowing the workflow to execute in the background. This is useful for long-running workflows
|
|
5
|
+
The `.startAsync()` method starts a workflow run without waiting for completion. It returns immediately with the `runId`, allowing the workflow to execute in the background. This is useful for long-running workflows or scheduled tasks. It also avoids blocking on workflow completion.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Run.timeTravel()
|
|
4
4
|
|
|
5
|
-
The `.timeTravel()` method re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide.
|
|
5
|
+
The `.timeTravel()` method re-executes a workflow starting from any specific step, using either stored snapshot data or custom context you provide. Use it to debug failed workflows and test individual steps with different inputs. It can also recover from errors without re-running the entire workflow.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ If you need to run multiple operations per item, use a nested workflow as the st
|
|
|
40
40
|
|
|
41
41
|
### Using `.then()` after `.foreach()`
|
|
42
42
|
|
|
43
|
-
When you chain `.then()` after `.foreach()`, the next step receives the entire output array as its input.
|
|
43
|
+
When you chain `.then()` after `.foreach()`, the next step receives the entire output array as its input. You can aggregate or process all results together.
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
46
|
workflow
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Workflow\.sleep()
|
|
4
4
|
|
|
5
|
-
The `.sleep()` method pauses execution for a specified number of milliseconds. It accepts either a static number or a callback function for
|
|
5
|
+
The `.sleep()` method pauses execution for a specified number of milliseconds. It accepts either a static number or a callback function for runtime-defined delays.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Workflow state reader
|
|
4
4
|
|
|
5
|
-
Workflow state reader helpers inspect the public `WorkflowState` returned by `workflow.getWorkflowRunById()`. Use them to recover suspended runs
|
|
5
|
+
Workflow state reader helpers inspect the public `WorkflowState` returned by `workflow.getWorkflowRunById()`. Use them to recover suspended runs and inspect resume labels. They also read step payloads or outputs without parsing raw workflow snapshots.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -36,7 +36,7 @@ const suspendedStep = reader.getSuspendedStep()
|
|
|
36
36
|
|
|
37
37
|
### `getWorkflowStepOutput(state, stepId)`
|
|
38
38
|
|
|
39
|
-
Returns the output for a step ID, including nested workflow dot paths such as `parent.child`. For `foreach` steps, returns one entry per iteration
|
|
39
|
+
Returns the output for a step ID, including nested workflow dot paths such as `parent.child`. For `foreach` steps, returns one entry per iteration. Suspended iterations can have `undefined` output entries.
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
42
|
const output = getWorkflowStepOutput(state, 'extract-data')
|
|
@@ -196,14 +196,14 @@ const sandbox = new AppleContainerSandbox({
|
|
|
196
196
|
})
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
These options are only applied when a new container is created. If the sandbox reconnects to an existing container with the same name, destroy and recreate the sandbox to apply changed runtime options. Apple `--tmpfs` accepts container paths only, such as `/tmp`; it doesn't accept Docker-style option specs like `/tmp:rw,size=256m`. When `readonlyRootfs` is enabled, make sure `workingDir` points to a path supplied by the image
|
|
199
|
+
These options are only applied when a new container is created. If the sandbox reconnects to an existing container with the same name, destroy and recreate the sandbox to apply changed runtime options. Apple `--tmpfs` accepts container paths only, such as `/tmp`; it doesn't accept Docker-style option specs like `/tmp:rw,size=256m`. When `readonlyRootfs` is enabled, make sure `workingDir` points to a path supplied by the image or a bind mount. A writable tmpfs is also supported.
|
|
200
200
|
|
|
201
201
|
## Security model
|
|
202
202
|
|
|
203
203
|
`AppleContainerSandbox` runs local containers through the host Apple `container` service. Treat constructor options as trusted server-side configuration:
|
|
204
204
|
|
|
205
205
|
- `volumes`, `mounts`, and `publishedSockets` can expose host paths to containerized code.
|
|
206
|
-
- `publishedPorts` can expose in-container services on the host or network
|
|
206
|
+
- `publishedPorts` can expose in-container services on the host or network. Bind to `127.0.0.1` when only local access is intended.
|
|
207
207
|
- `ssh` forwards the host SSH agent socket.
|
|
208
208
|
- `capAdd` and `virtualization` can expand what containerized code can do.
|
|
209
209
|
- `containerBinary` is a constructor-only escape hatch for trusted code and isn't part of the serializable editor provider schema.
|
|
@@ -118,7 +118,7 @@ const workspace = new Workspace({
|
|
|
118
118
|
|
|
119
119
|
### Ephemeral sandbox
|
|
120
120
|
|
|
121
|
-
For one-shot tasks
|
|
121
|
+
For one-shot tasks: sandbox is deleted immediately on stop:
|
|
122
122
|
|
|
123
123
|
```typescript
|
|
124
124
|
const workspace = new Workspace({
|
|
@@ -169,7 +169,7 @@ Mount S3 or GCS buckets as local directories inside the sandbox.
|
|
|
169
169
|
|
|
170
170
|
#### Via workspace mounts config
|
|
171
171
|
|
|
172
|
-
The simplest way
|
|
172
|
+
The simplest way: filesystems are mounted automatically when the sandbox starts:
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
175
|
import { Workspace } from '@mastra/core/workspace'
|
|
@@ -410,7 +410,7 @@ await daytona.snapshot.create(
|
|
|
410
410
|
)
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
-
**Option 2: Dockerfile
|
|
413
|
+
**Option 2: Dockerfile:** Use [`Image.fromDockerfile()`](https://www.daytona.io/docs/typescript-sdk/image#fromdockerfile)
|
|
414
414
|
|
|
415
415
|
```dockerfile
|
|
416
416
|
FROM daytonaio/sandbox
|
|
@@ -175,7 +175,7 @@ Bind mounts are applied at container creation time. The host paths must exist be
|
|
|
175
175
|
|
|
176
176
|
## Hardening
|
|
177
177
|
|
|
178
|
-
Use Docker-specific resource and hardening options to limit a sandbox container. The following example caps memory and process count
|
|
178
|
+
Use Docker-specific resource and hardening options to limit a sandbox container. The following example caps memory and process count while limiting CPU to a single core with matching `cpuPeriod` and `cpuQuota` values. It drops Linux capabilities and makes the root filesystem read-only, with `/tmp` mounted as writable scratch space:
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
181
|
const sandbox = new DockerSandbox({
|
|
@@ -201,7 +201,7 @@ These options map directly to Docker `HostConfig` fields and aren't set unless y
|
|
|
201
201
|
Review these trade-offs before enabling hardening:
|
|
202
202
|
|
|
203
203
|
- `readonlyRootfs`: In-container package installs and tools that write outside mounted paths can fail. Add `tmpfs` entries for writable scratch paths such as `/tmp`, and mount tmpfs or volumes for package-manager caches such as `~/.npm` when needed.
|
|
204
|
-
- `capDrop`: Dropping all capabilities disables commands that need Linux capabilities, including `ping
|
|
204
|
+
- `capDrop`: Dropping all capabilities disables commands that need Linux capabilities, including `ping` and mount operations. FUSE-backed tools are also disabled. Add back only the capabilities your workload needs.
|
|
205
205
|
- `memory`: Docker treats `0` as unlimited. Omit `memory` or pass `0` only when you don't want a memory cap.
|
|
206
206
|
- `memorySwap`: Docker memory and swap behavior depends on the host and Docker daemon configuration. When you set `memory` without `memorySwap`, Docker allows swap up to twice the memory limit by default. Set `memorySwap` equal to `memory` when you want to disable swap for the container; Docker also accepts `-1` for unlimited swap.
|
|
207
207
|
- `pidsLimit`: Very low values can break `docker exec` workloads because each command starts additional processes inside the long-lived container.
|
|
@@ -245,11 +245,11 @@ const workspace = new Workspace({
|
|
|
245
245
|
})
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
This is optional
|
|
248
|
+
This is optional: `gcsfuse` is installed automatically at mount time if not present.
|
|
249
249
|
|
|
250
250
|
## Using with Code Mode
|
|
251
251
|
|
|
252
|
-
[Code Mode](https://mastra.ai/docs/agents/code-mode) lets an agent write a single TypeScript program that orchestrates its tools. Because E2B runs that program in a remote micro-VM, it needs a transport that writes the program into the sandbox filesystem rather than the host. `@mastra/e2b`
|
|
252
|
+
[Code Mode](https://mastra.ai/docs/agents/code-mode) lets an agent write a single TypeScript program that orchestrates its tools. Because E2B runs that program in a remote micro-VM, it needs a transport that writes the program into the sandbox filesystem rather than the host. `@mastra/e2b` provides `E2BCodeModeTransport` for this. Pass it as the second argument to `createCodeMode`:
|
|
253
253
|
|
|
254
254
|
```typescript
|
|
255
255
|
import { createCodeMode } from '@mastra/core/tools'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# FilesSDKFilesystem
|
|
4
4
|
|
|
5
|
-
Stores files in any storage backend supported by [FilesSDK](https://files-sdk.dev)
|
|
5
|
+
Stores files in any storage backend supported by [FilesSDK](https://files-sdk.dev): a unified abstraction over S3, Cloudflare R2, Google Cloud Storage, Azure Blob, Vercel Blob, MinIO, the local filesystem, and more. For interface details, see [WorkspaceFilesystem Interface](https://mastra.ai/reference/workspace/filesystem).
|
|
6
6
|
|
|
7
7
|
Use `FilesSDKFilesystem` when you want a single adapter that can target multiple storage backends with the same code. Swap the underlying driver without changing the workspace setup. If you only target one backend and want first-class options for that backend, prefer the dedicated provider (for example [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem) or [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem)).
|
|
8
8
|
|
|
@@ -174,8 +174,8 @@ const url = await filesystem.files.url('reports/q3.pdf')
|
|
|
174
174
|
- **`exists`** returns `true` only when an exact key is present as a file, or when the path is a prefix that contains at least one child key. Empty leftover directories on hierarchical adapters don't count.
|
|
175
175
|
- **`deleteFile`** throws `FileNotFoundError` when the key doesn't exist, unless `{ force: true }` is passed.
|
|
176
176
|
- **`deleteFile`** on a directory delegates to `rmdir({ recursive: true })`, matching the [`S3Filesystem`](https://mastra.ai/reference/workspace/s3-filesystem) and [`GCSFilesystem`](https://mastra.ai/reference/workspace/gcs-filesystem) behavior.
|
|
177
|
-
- **`moveFile`** is implemented as `copyFile` followed by `deleteFile`.
|
|
178
|
-
- **`appendFile`** is a read-modify-write operation. Concurrent appends to the same key may overwrite each other
|
|
177
|
+
- **`moveFile`** is implemented as `copyFile` followed by `deleteFile`. It isn't **atomic**. If the source delete fails after a successful copy, the destination remains and the source isn't removed.
|
|
178
|
+
- **`appendFile`** is a read-modify-write operation. Concurrent appends to the same key may overwrite each other. This is inherent to object storage and not specific to FilesSDK.
|
|
179
179
|
- **`readdir({ recursive: true })`** emits intermediate directory entries (for example, `a/b` is emitted alongside `a/b/c.txt`).
|
|
180
180
|
|
|
181
181
|
## Related
|
|
@@ -70,7 +70,7 @@ Service account auth is the recommended option for backend agents. No user conse
|
|
|
70
70
|
|
|
71
71
|
1. Open the [Google Cloud Console](https://console.cloud.google.com/) and select or create a project.
|
|
72
72
|
2. Go to **APIs & Services > Library**, search for **Google Drive API**, and select **Enable**.
|
|
73
|
-
3. Go to **APIs & Services > Credentials**, select **Create credentials > Service account**, and complete the form. The role can be left blank
|
|
73
|
+
3. Go to **APIs & Services > Credentials**, select **Create credentials > Service account**, and complete the form. The role can be left blank: Drive permissions are granted by sharing folders, not by IAM roles.
|
|
74
74
|
4. Open the new service account, go to the **Keys** tab, and select **Add key > Create new key > JSON**. The browser downloads a JSON key file.
|
|
75
75
|
5. Copy the `client_email` value from the JSON file. This is the address you share Drive folders with.
|
|
76
76
|
|
|
@@ -115,7 +115,7 @@ const filesystem = new GoogleDriveFilesystem({
|
|
|
115
115
|
|
|
116
116
|
You **don't** need to copy the entire JSON file or pass other fields like `project_id`, `client_id`, `private_key_id`, or `token_uri`. They're not used. Only `clientEmail` and `privateKey` are required. `privateKeyId`, `scopes`, and `subject` are optional. `scopes` defaults to `['https://www.googleapis.com/auth/drive']`, which is the scope required for the service account to see folders shared with it. The narrower `drive.file` scope only grants access to files the application created itself, so a folder shared with the service account would return `404 Not Found`.
|
|
117
117
|
|
|
118
|
-
`GoogleDriveFilesystem` automatically normalizes the `privateKey` string before signing. It strips surrounding quotes
|
|
118
|
+
`GoogleDriveFilesystem` automatically normalizes the `privateKey` string before signing. It strips surrounding quotes, including escaped quotes from JSON-wrapped values, and converts literal `\n` sequences to real newlines. It also normalizes `\r\n` line endings, and removes a trailing comma. The key works regardless of how your `.env` loader handles the value.
|
|
119
119
|
|
|
120
120
|
##### Troubleshoot
|
|
121
121
|
|
|
@@ -181,5 +181,5 @@ GoogleDriveFilesystem implements the [WorkspaceFilesystem interface](https://mas
|
|
|
181
181
|
|
|
182
182
|
- Google Drive allows multiple files with the same name in a folder. `GoogleDriveFilesystem` resolves paths by picking the first match, so keep names unique within each folder when you rely on path-based lookup.
|
|
183
183
|
- `writeFile` creates parent folders automatically when `recursive` is unset (the default) or `true`. Set `recursive: false` to require the parent folder to already exist.
|
|
184
|
-
- `expectedMtime` on `WriteOptions` is honored
|
|
185
|
-
- The provider only exercises Drive REST endpoints (`https://www.googleapis.com/drive/v3` and `https://www.googleapis.com/upload/drive/v3`) through the built-in `fetch
|
|
184
|
+
- `expectedMtime` on `WriteOptions` is honored. When the stored `modifiedTime` differs, the write is rejected with `StaleFileError` to support optimistic concurrency.
|
|
185
|
+
- The provider only exercises Drive REST endpoints (`https://www.googleapis.com/drive/v3` and `https://www.googleapis.com/upload/drive/v3`) through the built-in `fetch`. No additional dependencies are required.
|
|
@@ -328,7 +328,7 @@ await filesystem.readFile('docs/guide.md')
|
|
|
328
328
|
|
|
329
329
|
### Relative paths and execution context
|
|
330
330
|
|
|
331
|
-
When you use a relative path for `basePath`, it resolves from `process.cwd()`. In Mastra projects, cwd
|
|
331
|
+
When you use a relative path for `basePath`, it resolves from `process.cwd()`. In Mastra projects, the cwd changes based on how you run your code:
|
|
332
332
|
|
|
333
333
|
| Context | Working directory | `./workspace` resolves to |
|
|
334
334
|
| -------------- | ------------------------- | ------------------------------- |
|
|
@@ -350,7 +350,7 @@ const filesystem = new LocalFilesystem({
|
|
|
350
350
|
})
|
|
351
351
|
```
|
|
352
352
|
|
|
353
|
-
Set `WORKSPACE_PATH` in your environment to an absolute path like `/home/user/my-project/workspace`.
|
|
353
|
+
Set `WORKSPACE_PATH` in your environment to an absolute path like `/home/user/my-project/workspace`. It ensures the workspace path is consistent regardless of how you run your code.
|
|
354
354
|
|
|
355
355
|
## Related
|
|
356
356
|
|
|
@@ -88,7 +88,7 @@ Configuration options for native OS sandboxing (used with `isolation: 'seatbelt'
|
|
|
88
88
|
|
|
89
89
|
### Relative paths and execution context
|
|
90
90
|
|
|
91
|
-
When you use a relative path for `workingDirectory`, it resolves from `process.cwd()`. In Mastra projects, cwd
|
|
91
|
+
When you use a relative path for `workingDirectory`, it resolves from `process.cwd()`. In Mastra projects, the cwd changes based on how you run your code:
|
|
92
92
|
|
|
93
93
|
| Context | Working directory | `./workspace` resolves to |
|
|
94
94
|
| -------------- | ------------------------- | ------------------------------- |
|
|
@@ -110,7 +110,7 @@ const sandbox = new LocalSandbox({
|
|
|
110
110
|
})
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
Set `WORKSPACE_PATH` in your environment to an absolute path like `/home/user/my-project/workspace`.
|
|
113
|
+
Set `WORKSPACE_PATH` in your environment to an absolute path like `/home/user/my-project/workspace`. It ensures commands run from a consistent directory regardless of how you run your code.
|
|
114
114
|
|
|
115
115
|
## Background processes
|
|
116
116
|
|
|
@@ -155,7 +155,7 @@ console.log(result.exitCode)
|
|
|
155
155
|
await handle.kill()
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
> **Note:** `sendStdin()` isn't supported
|
|
158
|
+
> **Note:** `sendStdin()` isn't supported. The Modal JS SDK doesn't expose stdin on `Sandbox.exec()`.
|
|
159
159
|
|
|
160
160
|
See [`SandboxProcessManager` reference](https://mastra.ai/reference/workspace/process-manager) for the full API.
|
|
161
161
|
|