@mastra/mcp-docs-server 1.2.11-alpha.6 → 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/gateways/vercel.md +1 -2
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aiand.md +1 -3
- package/.docs/models/providers/berget.md +2 -1
- package/.docs/models/providers/hyper.md +7 -7
- package/.docs/models/providers/modal.md +73 -0
- package/.docs/models/providers/xpersona.md +12 -2
- 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 +9 -3
- 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 +14 -0
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# UnicodeNormalizer
|
|
4
4
|
|
|
5
|
-
The `UnicodeNormalizer` is an **input processor** that normalizes Unicode text to ensure consistent formatting and remove potentially problematic characters before messages are sent to the language model. This processor
|
|
5
|
+
The `UnicodeNormalizer` is an **input processor** that normalizes Unicode text to ensure consistent formatting and remove potentially problematic characters before messages are sent to the language model. This processor handles Unicode representations and removes control characters. It also standardizes whitespace formatting.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Your new Mastra project, created with the `create mastra` command, comes with a predefined set of files and folders to help you get started.
|
|
6
6
|
|
|
7
|
-
Mastra is a framework, but it's mostly **unopinionated** about how you organize or colocate your files. The CLI provides a sensible default structure that works well for most projects, but you're free to adapt it to your workflow or team conventions. You could even build your entire project in a single file if you wanted! Whatever structure you choose, keep it consistent to ensure your code stays maintainable and straightforward to
|
|
7
|
+
Mastra is a framework, but it's mostly **unopinionated** about how you organize or colocate your files. The CLI provides a sensible default structure that works well for most projects, but you're free to adapt it to your workflow or team conventions. You could even build your entire project in a single file if you wanted! Whatever structure you choose, keep it consistent to ensure your code stays maintainable and straightforward to browse.
|
|
8
8
|
|
|
9
9
|
## Default project structure
|
|
10
10
|
|
|
@@ -77,7 +77,7 @@ await pubsub.publish('my-topic', {
|
|
|
77
77
|
|
|
78
78
|
Registers a callback to receive events published to a topic. When `options.group` is set, subscribers in the same group compete for messages and each event is delivered to one member. Without a group, every subscriber receives every event.
|
|
79
79
|
|
|
80
|
-
Pass `options.batch` to opt in to batched delivery. The callback signature is unchanged: a batch of N events is delivered as N consecutive `cb(event, ack, nack)` calls in publish order. Batching is honored only when the backend's [`supportsNativeBatching`](#properties) is `true
|
|
80
|
+
Pass `options.batch` to opt in to batched delivery. The callback signature is unchanged: a batch of N events is delivered as N consecutive `cb(event, ack, nack)` calls in publish order. Batching is honored only when the backend's [`supportsNativeBatching`](#properties) is `true`. Other backends ignore the option and deliver events one at a time.
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
83
|
await pubsub.subscribe('my-topic', (event, ack, nack) => {
|
|
@@ -103,9 +103,9 @@ await pubsub.flush()
|
|
|
103
103
|
|
|
104
104
|
#### `clearTopic(topic)`
|
|
105
105
|
|
|
106
|
-
Deletes all retained state for a topic
|
|
106
|
+
Deletes all retained state for a topic (cached history, persistent stream entries, and consumer groups) once no more events will be published to it. Mastra's run lifecycles (durable agents and the evented workflow engine) call this automatically when a run reaches a terminal state, so per-run topics don't accumulate on transports that retain messages.
|
|
107
107
|
|
|
108
|
-
The default implementation is a no-op: transports that retain nothing per topic (such as `EventEmitterPubSub`) have nothing to clear. Backends that persist messages, like [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), override it. The contract is best-effort
|
|
108
|
+
The default implementation is a no-op: transports that retain nothing per topic (such as `EventEmitterPubSub`) have nothing to clear. Backends that persist messages, like [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams), override it. The contract is best-effort: implementations log failures rather than throwing, because callers invoke it fire-and-forget at cleanup boundaries.
|
|
109
109
|
|
|
110
110
|
```typescript
|
|
111
111
|
await pubsub.clearTopic('workflow.events.v2.run-123')
|
|
@@ -177,7 +177,7 @@ await pubsub.subscribeFromOffset('my-topic', 42, event => {
|
|
|
177
177
|
|
|
178
178
|
### `SubscribeBatchOptions`
|
|
179
179
|
|
|
180
|
-
Per-subscription batching policy. The callback signature doesn't change
|
|
180
|
+
Per-subscription batching policy. The callback signature doesn't change. A batch of N events becomes N consecutive callback invocations in publish order.
|
|
181
181
|
|
|
182
182
|
**maxSize** (`number`): Maximum events held before forcing a flush.
|
|
183
183
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Use it for distributed deployments on Google Cloud. For single-process delivery, use [`EventEmitterPubSub`](https://mastra.ai/reference/pubsub/event-emitter). For Redis, use [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams).
|
|
8
8
|
|
|
9
|
-
Each topic maps to a Google Cloud topic. Subscriptions with a group share a
|
|
9
|
+
Each topic maps to a Google Cloud topic. Subscriptions with a group share a subscription, so members compete for events. Subscriptions without a group create a per-instance subscription, so every instance receives every event.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -85,7 +85,7 @@ await pubsub.flush()
|
|
|
85
85
|
|
|
86
86
|
### `destroy(topicName)`
|
|
87
87
|
|
|
88
|
-
Removes the subscription and topic for a
|
|
88
|
+
Removes the subscription and topic for a topic name. Use this to clean up Google Cloud resources.
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
91
|
await pubsub.destroy('workflow.events')
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# LeaseProvider
|
|
4
4
|
|
|
5
|
-
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/long-running-agents/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a
|
|
5
|
+
`LeaseProvider` is the distributed leasing contract, separate from event delivery ([`PubSub`](https://mastra.ai/reference/pubsub/base)). Mastra's [signals layer](https://mastra.ai/docs/long-running-agents/signals) uses it to elect a single owner across multiple processes (for example, serverless invocations) for a resource, most commonly a thread key. The owner is the process that wakes and runs the agent stream, so other processes route follow-up work to it instead of starting a competing run.
|
|
6
6
|
|
|
7
|
-
Leasing is a distinct concern from pub/sub. A backend implements `LeaseProvider` only when it can
|
|
7
|
+
Leasing is a distinct concern from pub/sub. A backend implements `LeaseProvider` only when it can actually coordinate a lock, such as Redis via atomic `SET`/Lua, or an in-memory map for single-process. Backends that can't lease omit it; the signals runtime feature-detects the capability and falls back to a no-op provider, preserving single-process behavior.
|
|
8
8
|
|
|
9
9
|
The built-in [`RedisStreamsPubSub`](https://mastra.ai/reference/pubsub/redis-streams) implements `LeaseProvider`, which is what enables signals to coordinate across instances in distributed and serverless deployments.
|
|
10
10
|
|
|
@@ -102,7 +102,7 @@ Returns: `Promise<boolean>`
|
|
|
102
102
|
|
|
103
103
|
#### `transferLease(key, fromOwner, toOwner, ttlMs)`
|
|
104
104
|
|
|
105
|
-
Atomically
|
|
105
|
+
Atomically transfers a held lease from `fromOwner` to `toOwner` and refreshes its TTL without releasing the key in between. This gap-free primitive lets a follow-up owner take over the same key immediately after the current owner finishes. For example, a queued follow-up run can take over when a thread run completes. A naive release-then-acquire briefly leaves the key empty. A racing process could then win the freed lease and start a competing run.
|
|
106
106
|
|
|
107
107
|
Returns `true` if `fromOwner` still held the lease and ownership moved to `toOwner`, or `false` if the lease was already lost, in which case the caller should fall back to a fresh `acquireLease`.
|
|
108
108
|
|
|
@@ -129,5 +129,5 @@ When the configured pub/sub backend doesn't implement `LeaseProvider`, the runti
|
|
|
129
129
|
|
|
130
130
|
- [PubSub](https://mastra.ai/reference/pubsub/base): The event delivery contract, separate from leasing
|
|
131
131
|
- [RedisStreamsPubSub](https://mastra.ai/reference/pubsub/redis-streams): The built-in backend that implements `LeaseProvider`
|
|
132
|
-
- [Signals](https://mastra.ai/docs/long-running-agents/signals): The runtime that uses leasing to coordinate thread
|
|
132
|
+
- [Signals](https://mastra.ai/docs/long-running-agents/signals): The runtime that uses leasing to coordinate thread execution across processes
|
|
133
133
|
- [Channels](https://mastra.ai/docs/capabilities/channels/overview): Uses leasing to coordinate agent runs in serverless and multi-instance deployments
|
|
@@ -101,7 +101,7 @@ await pubsub.flush()
|
|
|
101
101
|
|
|
102
102
|
### `clearTopic(topic)`
|
|
103
103
|
|
|
104
|
-
Deletes a topic's stream and every consumer group on it, freeing the memory a finished topic would otherwise hold. Mastra's run lifecycles
|
|
104
|
+
Deletes a topic's stream and every consumer group on it, freeing the memory a finished topic would otherwise hold. Mastra's run lifecycles (durable agents and the evented workflow engine) call this automatically when a run reaches a terminal state. Call it yourself only once nothing will read the topic again. It's best-effort and never throws. Failures are logged at warn level. A subscriber still attached when the stream is deleted recovers on its own but misses the deleted entries.
|
|
105
105
|
|
|
106
106
|
Automatic cleanup requires `@mastra/core` and `@mastra/redis-streams` versions that both support `clearTopic`: the runtime routes the call through its caching layer, so upgrade the two packages together to get end-of-run stream deletion.
|
|
107
107
|
|
|
@@ -51,4 +51,4 @@ await pubsub.close()
|
|
|
51
51
|
|
|
52
52
|
## Broker election
|
|
53
53
|
|
|
54
|
-
The first process to bind the socket becomes the broker and routes events between all connected clients. Other processes connect as clients. When the broker exits, an exclusive lock file serializes the next election
|
|
54
|
+
The first process to bind the socket becomes the broker and routes events between all connected clients. Other processes connect as clients. When the broker exits, an exclusive lock file serializes the next election. Exactly one client becomes the new broker. The remaining clients resubscribe to it. This avoids a split-brain state where two processes both act as broker.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# .chunk()
|
|
4
4
|
|
|
5
|
-
The `.chunk()` function splits documents into smaller segments using
|
|
5
|
+
The `.chunk()` function splits documents into smaller segments using strategies and options.
|
|
6
6
|
|
|
7
7
|
## Example
|
|
8
8
|
|
|
@@ -39,11 +39,11 @@ const chunksWithMetadata = await doc.chunk({
|
|
|
39
39
|
|
|
40
40
|
## Parameters
|
|
41
41
|
|
|
42
|
-
The following parameters are available for all chunking strategies.
|
|
42
|
+
The following parameters are available for all chunking strategies. Each strategy will only utilize a subset of these parameters relevant to its specific use case.
|
|
43
43
|
|
|
44
44
|
**strategy** (`'recursive' | 'character' | 'token' | 'markdown' | 'semantic-markdown' | 'html' | 'json' | 'latex' | 'sentence'`): The chunking strategy to use. If not specified, defaults based on document type. Depending on the chunking strategy, there are additional optionals. Defaults: .md files → 'markdown', .html/.htm → 'html', .json → 'json', .tex → 'latex', others → 'recursive'
|
|
45
45
|
|
|
46
|
-
**maxSize** (`number`): Maximum size of each chunk.
|
|
46
|
+
**maxSize** (`number`): Maximum size of each chunk. Some strategy configurations (markdown with headers, HTML with headers) ignore this parameter. (Default: `4000`)
|
|
47
47
|
|
|
48
48
|
**overlap** (`number`): Number of characters/tokens that overlap between chunks. (Default: `50`)
|
|
49
49
|
|
|
@@ -162,7 +162,7 @@ The options documented below are passed directly at the top level of the configu
|
|
|
162
162
|
|
|
163
163
|
**returnEachLine** (`boolean`): Whether to return each line as a separate chunk
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
When using the HTML strategy, all general options are ignored. Use `headers` for header-based splitting or `sections` for section-based splitting. If used together, `sections` will be ignored.
|
|
166
166
|
|
|
167
167
|
### Markdown
|
|
168
168
|
|
|
@@ -172,7 +172,7 @@ The options documented below are passed directly at the top level of the configu
|
|
|
172
172
|
|
|
173
173
|
**returnEachLine** (`boolean`): Whether to return each line as a separate chunk
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
When using the `headers` option, the markdown strategy ignores all general options and content is split based on the markdown header structure. To use size-based chunking with markdown, omit the `headers` parameter.
|
|
176
176
|
|
|
177
177
|
### Semantic Markdown
|
|
178
178
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# DatabaseConfig
|
|
4
4
|
|
|
5
|
-
The `DatabaseConfig` type allows you to specify database-specific configurations when using vector query tools. These configurations enable you to
|
|
5
|
+
The `DatabaseConfig` type allows you to specify database-specific configurations when using vector query tools. These configurations enable you to use features and optimizations offered by different vector stores.
|
|
6
6
|
|
|
7
7
|
## Type definition
|
|
8
8
|
|
|
@@ -252,7 +252,7 @@ const vectorTool = createVectorQueryTool({
|
|
|
252
252
|
1. **Environment Configuration**: Use different namespaces or configurations for different environments
|
|
253
253
|
2. **Performance Tuning**: Start with default values and adjust based on your specific needs
|
|
254
254
|
3. **Quality Filtering**: Use minScore to filter out low-quality results
|
|
255
|
-
4. **Runtime Flexibility**: Override configurations at runtime for
|
|
255
|
+
4. **Runtime Flexibility**: Override configurations at runtime for runtime-defined scenarios
|
|
256
256
|
5. **Documentation**: Document your specific configuration choices for team members
|
|
257
257
|
|
|
258
258
|
## Migration guide
|
|
@@ -194,8 +194,8 @@ const results = await store.query({
|
|
|
194
194
|
|
|
195
195
|
- Equality values must be primitives (string/number/boolean). `null`/`undefined`, arrays, objects, and Date aren't allowed for equality. Range operators accept numbers or Date (Dates are normalized to epoch ms).
|
|
196
196
|
- `$in`/`$nin` require **non-empty arrays of primitives**; Date elements are allowed and normalized to epoch ms. **Array equality** isn't supported.
|
|
197
|
-
- Implicit AND is canonicalized (`{a:1,b:2}` → `{$and:[{a:1},{b:2}]
|
|
198
|
-
- Keys listed in `nonFilterableMetadataKeys` at index creation are stored but not filterable
|
|
197
|
+
- Implicit AND is canonicalized (`{a:1,b:2}` → `{$and:[{a:1},{b:2}]`). Logical operators must contain field conditions and use non-empty arrays. They may appear only at the root or within other logical operators (not inside field values).
|
|
198
|
+
- Keys listed in `nonFilterableMetadataKeys` at index creation are stored but not filterable. This setting is immutable.
|
|
199
199
|
- $exists requires a boolean value.
|
|
200
200
|
- undefined/null/empty filters are treated as no filter.
|
|
201
201
|
- Each metadata key name limited to 63 characters.
|
|
@@ -150,7 +150,7 @@ const updated = await mastra.schedules.update('pinger', {
|
|
|
150
150
|
})
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Agent schedule patches can update `cron`, `timezone`, `prompt`, `name`, `signalType`, `tagName`, `attributes`, `providerOptions`, `ifActive`, `ifIdle`, `metadata`, and `status`. `threadId` and `resourceId` aren't patchable
|
|
153
|
+
Agent schedule patches can update `cron`, `timezone`, `prompt`, `name`, `signalType`, `tagName`, `attributes`, `providerOptions`, `ifActive`, `ifIdle`, `metadata`, and `status`. `threadId` and `resourceId` aren't patchable. Create a new schedule when the thread target needs to change.
|
|
154
154
|
|
|
155
155
|
Workflow schedule patches can update `cron`, `timezone`, `inputData`, `initialState`, `requestContext`, `metadata`, and `status`. Agent-only patch fields such as `prompt`, `signalType`, and `ifIdle` throw on workflow schedules.
|
|
156
156
|
|
|
@@ -20,7 +20,7 @@ The URL path for the route. Supports path parameters using `:param` syntax.
|
|
|
20
20
|
registerApiRoute("/items/:itemId", { ... })
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Custom route paths can't start with the server's configured `apiPrefix` (default: `/api`), as that prefix is reserved for built-in Mastra routes. If you set a custom `apiPrefix`, only that prefix is reserved. For example, with `apiPrefix: '/mastra/api'`, paths like `/api/my-endpoint` are allowed.
|
|
24
24
|
|
|
25
25
|
### options
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ Server adapters register these routes when you call `server.init()`. All routes
|
|
|
28
28
|
| Parameter | Type | Default | Description |
|
|
29
29
|
| ----------- | ------------------------ | --------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
30
30
|
| `status` | `'draft' \| 'published'` | `'draft'` | Which stored version to resolve. `draft` returns the latest version, `published` returns the active published version. |
|
|
31
|
-
| `versionId` | `string` |
|
|
31
|
+
| `versionId` | `string` | None | A specific version ID to resolve. Takes precedence over `status`. |
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
# Get agent with latest draft overrides (default)
|
|
@@ -51,7 +51,7 @@ const agent = new Agent({
|
|
|
51
51
|
})
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
The agent calls `connect(this)
|
|
54
|
+
The agent calls `connect(this)` and registers any processors or tools the provider returns. It then starts polling.
|
|
55
55
|
|
|
56
56
|
## Constructor parameters
|
|
57
57
|
|
|
@@ -142,7 +142,7 @@ Returns: `Record<string, unknown>`
|
|
|
142
142
|
|
|
143
143
|
#### `subscribe(target, externalResourceId, metadata?)`
|
|
144
144
|
|
|
145
|
-
Subscribe a thread to an external resource. This is a protected method
|
|
145
|
+
Subscribe a thread to an external resource. This is a protected method: call it from within your provider implementation.
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
148
|
const sub = this.subscribe(
|
|
@@ -152,7 +152,7 @@ const sub = this.subscribe(
|
|
|
152
152
|
)
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
Returns: `SignalSubscription
|
|
155
|
+
Returns: `SignalSubscription`: the created subscription, or the existing one with merged metadata.
|
|
156
156
|
|
|
157
157
|
**target** (`SignalProviderTarget`): The thread to subscribe. Must include threadId and resourceId.
|
|
158
158
|
|
|
@@ -171,7 +171,7 @@ const removed = this.unsubscribe(
|
|
|
171
171
|
)
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
Returns: `boolean
|
|
174
|
+
Returns: `boolean`: `true` if removed, `false` if no matching subscription existed.
|
|
175
175
|
|
|
176
176
|
#### `getSubscriptions()`
|
|
177
177
|
|
|
@@ -235,7 +235,7 @@ const removed = this.unsubscribeAll({
|
|
|
235
235
|
})
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
Returns: `number
|
|
238
|
+
Returns: `number`: count of removed subscriptions.
|
|
239
239
|
|
|
240
240
|
#### `subscriptionCount`
|
|
241
241
|
|
|
@@ -253,7 +253,7 @@ Returns: `number`
|
|
|
253
253
|
|
|
254
254
|
#### `poll(subscriptions)`
|
|
255
255
|
|
|
256
|
-
Called on each poll cycle with all active subscriptions. Override to check external sources and emit notifications. The framework prevents overlapping poll cycles
|
|
256
|
+
Called on each poll cycle with all active subscriptions. Override to check external sources and emit notifications. The framework prevents overlapping poll cycles: if a `poll()` call takes longer than `pollInterval`, the next cycle is skipped.
|
|
257
257
|
|
|
258
258
|
```typescript
|
|
259
259
|
async poll(subscriptions: SignalSubscription[]) {
|
|
@@ -271,7 +271,7 @@ async poll(subscriptions: SignalSubscription[]) {
|
|
|
271
271
|
|
|
272
272
|
#### `startPolling()`
|
|
273
273
|
|
|
274
|
-
Start the polling timer. Called by the Agent after `connect()`. Idempotent
|
|
274
|
+
Start the polling timer. Called by the Agent after `connect()`. Idempotent: calling multiple times has no effect.
|
|
275
275
|
|
|
276
276
|
```typescript
|
|
277
277
|
provider.startPolling()
|
|
@@ -289,7 +289,7 @@ provider.stopPolling()
|
|
|
289
289
|
|
|
290
290
|
#### `handleWebhook(request)`
|
|
291
291
|
|
|
292
|
-
Handle an incoming webhook request. Override to parse the payload
|
|
292
|
+
Handle an incoming webhook request. Override to parse the payload and match it to subscriptions. Then emit notification signals. See [`WebhookSignalProvider`](https://mastra.ai/reference/signals/webhook-signal-provider) for a ready-to-use implementation.
|
|
293
293
|
|
|
294
294
|
```typescript
|
|
295
295
|
async handleWebhook(request) {
|
|
@@ -129,7 +129,7 @@ yarn dlx mastra migrate
|
|
|
129
129
|
bun x mastra migrate
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
The migration copies span data from `mastra_ai_spans` into `mastra_span_events` in day-sized batches. It handles column mapping
|
|
132
|
+
The migration copies span data from `mastra_ai_spans` into `mastra_span_events` in day-sized batches. It handles column mapping and deduplicates legacy rows. The original table remains as a backup. After migration, traces appear in Studio through the vNext adapter.
|
|
133
133
|
|
|
134
134
|
> **Note:** The legacy table isn't deleted. Drop it manually after verifying the migration.
|
|
135
135
|
|
|
@@ -261,7 +261,7 @@ Set `cluster` to add `ON CLUSTER` to Mastra-owned DDL such as table creation, ma
|
|
|
261
261
|
|
|
262
262
|
Manual maintenance such as `optimizeTable()` and `materializeTtl()` runs on every replica when `cluster` is set. These operations can be expensive on a large cluster. Prefer running them outside peak hours, and let routine merges happen on the background merge queue rather than triggering them on every restart.
|
|
263
263
|
|
|
264
|
-
If existing Mastra tables use local `MergeTree` or `ReplacingMergeTree` engines, initialization fails while `replication` is enabled. Mastra refuses to silently convert local tables because copy-and-swap is unsafe across replicas. To migrate, recreate the affected tables as `Replicated*` before enabling replication.
|
|
264
|
+
If existing Mastra tables use local `MergeTree` or `ReplacingMergeTree` engines, initialization fails while `replication` is enabled. Mastra refuses to silently convert local tables because copy-and-swap is unsafe across replicas. To migrate, recreate the affected tables as `Replicated*` before enabling replication. To migrate safely, rename the local table, run `CREATE TABLE ... ENGINE = ReplicatedMergeTree(...) ON CLUSTER ...`, run `INSERT INTO ... SELECT * FROM <renamed_local>`, then drop `<renamed_local>`.
|
|
265
265
|
|
|
266
266
|
Don't set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side, and explicit `ReplicatedMergeTree` engines produce incorrect DDL. `replication` is only for self-managed multi-replica clusters.
|
|
267
267
|
|
|
@@ -271,7 +271,7 @@ Don't set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `Shar
|
|
|
271
271
|
|
|
272
272
|
## Hosting options
|
|
273
273
|
|
|
274
|
-
ClickHouse runs anywhere you can reach it over HTTP.
|
|
274
|
+
ClickHouse runs anywhere you can reach it over HTTP. Common choices include:
|
|
275
275
|
|
|
276
276
|
- **[ClickHouse Cloud](https://clickhouse.com/cloud)**: Managed service with a free trial tier. Provides connection details directly compatible with `url`, `username`, and `password`.
|
|
277
277
|
- **Self-hosted**: Run the official [`clickhouse/clickhouse-server`](https://hub.docker.com/r/clickhouse/clickhouse-server) container or install from the [official packages](https://clickhouse.com/docs/en/install). Suitable for VPS, dedicated hardware, or Kubernetes.
|
|
@@ -333,7 +333,7 @@ export const mastra = new Mastra({
|
|
|
333
333
|
})
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
Provision the database with either option:
|
|
337
337
|
|
|
338
338
|
- **Managed**: Use ClickHouse Cloud. Set `CLICKHOUSE_URL`, `CLICKHOUSE_USERNAME`, and `CLICKHOUSE_PASSWORD` as environment variables in your hosting platform.
|
|
339
339
|
- **Self-hosted on Railway**: Add a ClickHouse service to your Railway project from the official Docker image, then reference it in the application service through Railway's private networking.
|
|
@@ -61,11 +61,11 @@ export const mastra = new Mastra({
|
|
|
61
61
|
})
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
> **Note:** When using `import { env } from 'cloudflare:workers'`, `D1Store` must be initialized inline inside `new Mastra({...})
|
|
64
|
+
> **Note:** When using `import { env } from 'cloudflare:workers'`, `D1Store` must be initialized inline inside `new Mastra({...})`: not extracted to a module-level variable. Alternatively, initialize `D1Store` inside the `fetch` handler after `env` is available. See [CloudflareDeployer reference](https://mastra.ai/reference/deployer/cloudflare) for details.
|
|
65
65
|
|
|
66
66
|
### Using in a Cloudflare Worker without HTTP routes
|
|
67
67
|
|
|
68
|
-
If you want to call Mastra directly in a Worker
|
|
68
|
+
If you want to call Mastra directly in a Worker (for example, to run an agent or trigger a workflow) without serving HTTP routes, you don't need `CloudflareDeployer`. Access the D1 binding from the worker's `env` parameter and call Mastra programmatically.
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
71
|
import { D1Store } from '@mastra/cloudflare-d1'
|
|
@@ -213,8 +213,8 @@ export default {
|
|
|
213
213
|
|
|
214
214
|
### Transactions & Consistency
|
|
215
215
|
|
|
216
|
-
Cloudflare D1 provides transactional guarantees for single-row operations.
|
|
216
|
+
Cloudflare D1 provides transactional guarantees for single-row operations. Multiple operations can be executed as a single, all-or-nothing unit of work.
|
|
217
217
|
|
|
218
218
|
### Table Creation & Migrations
|
|
219
219
|
|
|
220
|
-
Tables are created automatically when storage is initialized (and can be isolated per environment using the `tablePrefix` option), but advanced schema changes
|
|
220
|
+
Tables are created automatically when storage is initialized (and can be isolated per environment using the `tablePrefix` option), but advanced schema changes require manual migration and careful planning. Examples include adding columns or changing data types and indexes to avoid data loss.
|
|
@@ -182,7 +182,7 @@ During batched cleanup, cache metadata can temporarily use an internal `deleted`
|
|
|
182
182
|
|
|
183
183
|
`clear()` only removes rows whose stored `keyPrefix` exactly matches the configured `keyPrefix`. It doesn't clear nested prefixes by string prefix matching. Each `listPush()` refreshes the list TTL using the cache's configured `ttlMs`.
|
|
184
184
|
|
|
185
|
-
Use a non-empty `keyPrefix` unless you intentionally want `clear()` to remove every cache key in the deployment. Expired list rows are reclaimed incrementally during reads and writes
|
|
185
|
+
Use a non-empty `keyPrefix` unless you intentionally want `clear()` to remove every cache key in the deployment. Expired list rows are reclaimed incrementally during reads and writes. `clear()` removes all rows for the prefix.
|
|
186
186
|
|
|
187
187
|
`ConvexServerCache` works best for durable replay of moderate-frequency events. For high-frequency token streams, prefer batching events or using a lower-latency cache backend.
|
|
188
188
|
|
|
@@ -217,14 +217,14 @@ All typed tables include:
|
|
|
217
217
|
- An `id` field for Mastra's record ID (distinct from Convex's auto-generated `_id`)
|
|
218
218
|
- A `by_record_id` index for efficient lookups by Mastra ID
|
|
219
219
|
|
|
220
|
-
This design ensures compatibility with Mastra's storage contract while
|
|
220
|
+
This design ensures compatibility with Mastra's storage contract while using Convex's automatic indexing and real-time capabilities.
|
|
221
221
|
|
|
222
222
|
### Environment variables
|
|
223
223
|
|
|
224
224
|
Set these environment variables for your deployment:
|
|
225
225
|
|
|
226
|
-
- `CONVEX_URL
|
|
227
|
-
- `CONVEX_ADMIN_KEY
|
|
226
|
+
- `CONVEX_URL`: Your Convex deployment URL
|
|
227
|
+
- `CONVEX_ADMIN_KEY`: Admin authentication token (get from Convex dashboard)
|
|
228
228
|
|
|
229
229
|
## Related
|
|
230
230
|
|
|
@@ -183,7 +183,7 @@ storage.db // Database client for executing queries
|
|
|
183
183
|
storage.pool // Underlying pg.Pool instance
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
It supports direct queries and custom transaction management. When using these fields:
|
|
187
187
|
|
|
188
188
|
- You are responsible for proper connection and transaction handling.
|
|
189
189
|
- Closing the store (`storage.close()`) will destroy the connection pool if it was created by the store.
|
|
@@ -199,7 +199,7 @@ Connections are authenticated with IAM. No database passwords are required. `@ma
|
|
|
199
199
|
|
|
200
200
|
#### Single database, schema-based isolation
|
|
201
201
|
|
|
202
|
-
Each cluster exposes a single database
|
|
202
|
+
Each cluster exposes a single database `postgres`. Logical separation is done via schemas. The `schemaName` option controls where Mastra tables are created.
|
|
203
203
|
|
|
204
204
|
#### No PostgreSQL extensions
|
|
205
205
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# DynamoDB storage
|
|
4
4
|
|
|
5
|
-
The DynamoDB storage implementation provides a
|
|
5
|
+
The DynamoDB storage implementation provides a high-capacity and performant NoSQL database solution for Mastra, using a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
6
6
|
|
|
7
7
|
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to DynamoDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
|
|
8
8
|
|
|
@@ -124,7 +124,7 @@ For local development, you can use [DynamoDB Local](https://docs.aws.amazon.com/
|
|
|
124
124
|
|
|
125
125
|
## TTL (time to live) configuration
|
|
126
126
|
|
|
127
|
-
DynamoDB TTL allows you to automatically delete items after a specified
|
|
127
|
+
DynamoDB TTL allows you to automatically delete items after a specified duration for these use cases:
|
|
128
128
|
|
|
129
129
|
- **Cost optimization**: Automatically remove old data to reduce storage costs
|
|
130
130
|
- **Data lifecycle management**: Implement retention policies for compliance
|
|
@@ -259,19 +259,19 @@ Before diving into the architectural details, keep these key points in mind when
|
|
|
259
259
|
|
|
260
260
|
## Architectural approach
|
|
261
261
|
|
|
262
|
-
This storage adapter utilizes a **single-table design pattern**
|
|
262
|
+
This storage adapter utilizes a **single-table design pattern** with [ElectroDB](https://electrodb.dev/), a common and recommended approach for DynamoDB. This differs architecturally from relational database adapters (like `@mastra/pg` or `@mastra/libsql`) that typically use multiple tables, each dedicated to a specific entity (threads, messages, etc.).
|
|
263
263
|
|
|
264
264
|
Key aspects of this approach:
|
|
265
265
|
|
|
266
|
-
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and
|
|
266
|
+
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and capacity compared to mimicking relational models.
|
|
267
267
|
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [TABLE\_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md) for detailed instructions using tools like AWS CloudFormation or CDK. The adapter focuses solely on interacting with the pre-existing table structure.
|
|
268
268
|
- **Consistency via Interface:** While the underlying storage model differs, this adapter adheres to the same `MastraStorage` interface as other adapters, ensuring it can be used interchangeably within the Mastra `Memory` component.
|
|
269
269
|
|
|
270
270
|
### Mastra Data in the Single Table
|
|
271
271
|
|
|
272
|
-
Within the single DynamoDB table, different Mastra data entities (such as Threads, Messages, Traces, Evals, and Workflows) are managed and distinguished using ElectroDB. ElectroDB defines specific models for each entity type, which include unique key structures and attributes.
|
|
272
|
+
Within the single DynamoDB table, different Mastra data entities (such as Threads, Messages, Traces, Evals, and Workflows) are managed and distinguished using ElectroDB. ElectroDB defines specific models for each entity type, which include unique key structures and attributes. It allows the adapter to store and retrieve diverse data types efficiently within the same table.
|
|
273
273
|
|
|
274
|
-
For example, a `Thread` item might have a primary key like `THREAD#<threadId>`, while a `Message` item belonging to that thread might use `THREAD#<threadId>` as a partition key and `MESSAGE#<messageId>` as a sort key. The Global Secondary Indexes (GSIs), detailed in `TABLE_SETUP.md`, are strategically designed to support common access patterns across these different entities, such as fetching all messages for a thread or querying traces associated with a
|
|
274
|
+
For example, a `Thread` item might have a primary key like `THREAD#<threadId>`, while a `Message` item belonging to that thread might use `THREAD#<threadId>` as a partition key and `MESSAGE#<messageId>` as a sort key. The Global Secondary Indexes (GSIs), detailed in `TABLE_SETUP.md`, are strategically designed to support common access patterns across these different entities, such as fetching all messages for a thread or querying traces associated with a workflow.
|
|
275
275
|
|
|
276
276
|
### Advantages of Single-Table Design
|
|
277
277
|
|
|
@@ -279,6 +279,6 @@ This implementation uses a single-table design pattern with ElectroDB, which off
|
|
|
279
279
|
|
|
280
280
|
1. **Lower cost (potentially):** Fewer tables can simplify Read/Write Capacity Unit (RCU/WCU) provisioning and management, especially with on-demand capacity.
|
|
281
281
|
2. **Better performance:** Related data can be co-located or accessed efficiently through GSIs, enabling fast lookups for common access patterns.
|
|
282
|
-
3. **Simplified administration:** Fewer distinct tables to monitor
|
|
282
|
+
3. **Simplified administration:** Fewer distinct tables to monitor and back up, with less to manage.
|
|
283
283
|
4. **Reduced complexity in access patterns:** ElectroDB helps manage the complexity of item types and access patterns on a single table.
|
|
284
284
|
5. **Transaction support:** DynamoDB transactions can be used across different "entity" types stored within the same table if needed.
|
|
@@ -117,7 +117,7 @@ LanceDB storage can be configured for different deployment scenarios:
|
|
|
117
117
|
```text
|
|
118
118
|
db://host:port
|
|
119
119
|
```
|
|
120
|
-
- **S3 Storage**: Use Amazon S3 for
|
|
120
|
+
- **S3 Storage**: Use Amazon S3 for high-capacity cloud storage
|
|
121
121
|
```text
|
|
122
122
|
s3://bucket/db
|
|
123
123
|
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# MongoDB storage
|
|
4
4
|
|
|
5
|
-
The MongoDB storage implementation provides a
|
|
5
|
+
The MongoDB storage implementation provides a high-capacity storage solution using MongoDB databases with support for both document storage and vector operations.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -150,7 +150,7 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
|
150
150
|
store.pool // mssql connection pool instance
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
It supports direct queries and custom transaction management. When using these fields:
|
|
154
154
|
|
|
155
155
|
- You are responsible for proper connection and transaction handling.
|
|
156
156
|
- Closing the store (`store.close()`) will destroy the associated connection pool.
|
|
@@ -317,7 +317,7 @@ export const mastra = new Mastra({
|
|
|
317
317
|
})
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
The pattern ensures only one `PostgresStore` instance is created regardless of how many times the module is reloaded during development. The same pattern can be applied to other storage providers like `LibSQLStore`.
|
|
321
321
|
|
|
322
322
|
> **Tip:** This singleton pattern is only necessary during local development with HMR. In production builds, modules are only loaded once.
|
|
323
323
|
|