@mastra/mcp-docs-server 1.0.0-beta.13 → 1.0.0-beta.14
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/organized/changelogs/%40mastra%2Fagent-builder.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +98 -98
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +30 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +171 -171
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Freact.md +9 -2
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +94 -94
- package/.docs/organized/changelogs/create-mastra.md +3 -3
- package/.docs/organized/changelogs/mastra.md +17 -17
- package/.docs/organized/code-examples/agent-v6.md +151 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +2 -3
- package/.docs/raw/agents/agent-approval.mdx +5 -6
- package/.docs/raw/agents/agent-memory.mdx +22 -30
- package/.docs/raw/agents/guardrails.mdx +60 -50
- package/.docs/raw/agents/networks.mdx +8 -12
- package/.docs/raw/agents/overview.mdx +39 -23
- package/.docs/raw/agents/processors.mdx +20 -19
- package/.docs/raw/agents/structured-output.mdx +11 -7
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/deployment/mastra-server.mdx +3 -3
- package/.docs/raw/deployment/overview.mdx +7 -0
- package/.docs/raw/deployment/web-framework.mdx +4 -6
- package/.docs/raw/evals/custom-scorers.mdx +9 -6
- package/.docs/raw/evals/overview.mdx +3 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -2
- package/.docs/raw/getting-started/manual-install.mdx +20 -20
- package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +4 -4
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +30 -30
- package/.docs/raw/guides/build-your-ui/assistant-ui.mdx +8 -8
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +11 -11
- package/.docs/raw/guides/deployment/amazon-ec2.mdx +9 -9
- package/.docs/raw/guides/deployment/aws-lambda.mdx +11 -11
- package/.docs/raw/guides/deployment/azure-app-services.mdx +2 -2
- package/.docs/raw/guides/deployment/cloudflare-deployer.mdx +5 -6
- package/.docs/raw/guides/deployment/digital-ocean.mdx +10 -10
- package/.docs/raw/guides/deployment/index.mdx +1 -1
- package/.docs/raw/guides/deployment/inngest.mdx +386 -0
- package/.docs/raw/guides/deployment/netlify-deployer.mdx +4 -4
- package/.docs/raw/guides/deployment/vercel-deployer.mdx +5 -6
- package/.docs/raw/guides/getting-started/astro.mdx +292 -451
- package/.docs/raw/guides/getting-started/express.mdx +7 -7
- package/.docs/raw/guides/getting-started/hono.mdx +18 -18
- package/.docs/raw/guides/getting-started/next-js.mdx +19 -20
- package/.docs/raw/guides/getting-started/quickstart.mdx +4 -4
- package/.docs/raw/guides/getting-started/sveltekit.mdx +238 -409
- package/.docs/raw/guides/getting-started/vite-react.mdx +21 -21
- package/.docs/raw/guides/guide/ai-recruiter.mdx +10 -10
- package/.docs/raw/guides/guide/chef-michel.mdx +9 -11
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +15 -15
- package/.docs/raw/guides/guide/research-assistant.mdx +13 -13
- package/.docs/raw/guides/guide/stock-agent.mdx +5 -5
- package/.docs/raw/guides/guide/web-search.mdx +8 -8
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +7 -7
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +2 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +0 -2
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +21 -23
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mastra-cloud/setting-up.mdx +6 -2
- package/.docs/raw/mcp/overview.mdx +31 -13
- package/.docs/raw/mcp/publishing-mcp-server.mdx +2 -2
- package/.docs/raw/memory/memory-processors.mdx +9 -9
- package/.docs/raw/memory/message-history.mdx +69 -0
- package/.docs/raw/memory/overview.mdx +34 -76
- package/.docs/raw/memory/semantic-recall.mdx +58 -49
- package/.docs/raw/memory/storage.mdx +188 -0
- package/.docs/raw/memory/working-memory.mdx +7 -7
- package/.docs/raw/observability/logging.mdx +9 -10
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/default.mdx +3 -3
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +1 -2
- package/.docs/raw/observability/tracing/overview.mdx +23 -25
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/rag/chunking-and-embedding.mdx +6 -6
- package/.docs/raw/rag/graph-rag.mdx +7 -7
- package/.docs/raw/rag/overview.mdx +1 -1
- package/.docs/raw/rag/retrieval.mdx +21 -22
- package/.docs/raw/rag/vector-databases.mdx +22 -22
- package/.docs/raw/reference/agents/agent.mdx +3 -3
- package/.docs/raw/reference/agents/generate.mdx +1 -1
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +2 -2
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +2 -2
- package/.docs/raw/reference/agents/getMemory.mdx +2 -2
- package/.docs/raw/reference/agents/getModel.mdx +2 -2
- package/.docs/raw/reference/agents/getTools.mdx +2 -2
- package/.docs/raw/reference/agents/getVoice.mdx +2 -2
- package/.docs/raw/reference/agents/listAgents.mdx +2 -2
- package/.docs/raw/reference/agents/listScorers.mdx +2 -2
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +2 -2
- package/.docs/raw/reference/agents/network.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/network-route.mdx +2 -2
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +6 -6
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v4-messages.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-v5-messages.mdx +3 -3
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +1 -1
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +2 -2
- package/.docs/raw/reference/auth/auth0.mdx +1 -2
- package/.docs/raw/reference/auth/clerk.mdx +1 -2
- package/.docs/raw/reference/auth/firebase.mdx +2 -4
- package/.docs/raw/reference/auth/jwt.mdx +1 -2
- package/.docs/raw/reference/auth/supabase.mdx +1 -2
- package/.docs/raw/reference/auth/workos.mdx +1 -2
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +9 -9
- package/.docs/raw/reference/client-js/agents.mdx +1 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +1 -1
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +1 -1
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServer.mdx +1 -1
- package/.docs/raw/reference/core/getMCPServerById.mdx +1 -1
- package/.docs/raw/reference/core/getMemory.mdx +2 -2
- package/.docs/raw/reference/core/getServer.mdx +1 -1
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getStoredAgentById.mdx +3 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +1 -1
- package/.docs/raw/reference/core/getVector.mdx +1 -1
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/listMCPServers.mdx +1 -1
- package/.docs/raw/reference/core/listMemory.mdx +2 -2
- package/.docs/raw/reference/core/listStoredAgents.mdx +4 -4
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setStorage.mdx +2 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -1
- package/.docs/raw/reference/deployer/vercel.mdx +2 -4
- package/.docs/raw/reference/evals/answer-relevancy.mdx +1 -1
- package/.docs/raw/reference/evals/answer-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/bias.mdx +1 -1
- package/.docs/raw/reference/evals/completeness.mdx +1 -1
- package/.docs/raw/reference/evals/content-similarity.mdx +1 -1
- package/.docs/raw/reference/evals/context-precision.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +1 -1
- package/.docs/raw/reference/evals/hallucination.mdx +1 -1
- package/.docs/raw/reference/evals/keyword-coverage.mdx +1 -1
- package/.docs/raw/reference/evals/prompt-alignment.mdx +7 -7
- package/.docs/raw/reference/evals/textual-difference.mdx +1 -1
- package/.docs/raw/reference/evals/tone-consistency.mdx +1 -1
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +10 -10
- package/.docs/raw/reference/evals/toxicity.mdx +1 -1
- package/.docs/raw/reference/logging/pino-logger.mdx +6 -7
- package/.docs/raw/reference/memory/createThread.mdx +2 -2
- package/.docs/raw/reference/memory/deleteMessages.mdx +2 -2
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +2 -2
- package/.docs/raw/reference/memory/memory-class.mdx +3 -3
- package/.docs/raw/reference/memory/query.mdx +2 -2
- package/.docs/raw/reference/memory/recall.mdx +2 -2
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +2 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +2 -2
- package/.docs/raw/reference/processors/moderation-processor.mdx +3 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +3 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +13 -13
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +2 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +2 -2
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +3 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +3 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +2 -2
- package/.docs/raw/reference/rag/metadata-filters.mdx +7 -7
- package/.docs/raw/reference/server/create-route.mdx +13 -13
- package/.docs/raw/reference/server/express-adapter.mdx +6 -7
- package/.docs/raw/reference/server/hono-adapter.mdx +6 -7
- package/.docs/raw/reference/server/mastra-server.mdx +20 -20
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +3 -3
- package/.docs/raw/reference/storage/cloudflare.mdx +2 -2
- package/.docs/raw/reference/storage/convex.mdx +6 -6
- package/.docs/raw/reference/storage/dynamodb.mdx +4 -4
- package/.docs/raw/reference/storage/lance.mdx +3 -3
- package/.docs/raw/reference/storage/libsql.mdx +69 -54
- package/.docs/raw/reference/storage/mongodb.mdx +80 -7
- package/.docs/raw/reference/storage/mssql.mdx +4 -4
- package/.docs/raw/{memory → reference}/storage/overview.mdx +12 -110
- package/.docs/raw/reference/storage/postgresql.mdx +78 -7
- package/.docs/raw/reference/storage/upstash.mdx +74 -2
- package/.docs/raw/reference/streaming/agents/stream.mdx +5 -5
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/resumeStream.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +2 -2
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +4 -4
- package/.docs/raw/reference/templates/overview.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +1 -4
- package/.docs/raw/reference/tools/vector-query-tool.mdx +1 -1
- package/.docs/raw/reference/vectors/astra.mdx +3 -3
- package/.docs/raw/reference/vectors/chroma.mdx +3 -3
- package/.docs/raw/reference/vectors/convex.mdx +12 -12
- package/.docs/raw/reference/vectors/couchbase.mdx +5 -5
- package/.docs/raw/reference/vectors/duckdb.mdx +10 -10
- package/.docs/raw/reference/vectors/elasticsearch.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +4 -4
- package/.docs/raw/reference/vectors/libsql.mdx +61 -11
- package/.docs/raw/reference/vectors/mongodb.mdx +58 -5
- package/.docs/raw/reference/vectors/pg.mdx +53 -6
- package/.docs/raw/reference/vectors/pinecone.mdx +3 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +3 -3
- package/.docs/raw/reference/vectors/s3vectors.mdx +6 -6
- package/.docs/raw/reference/vectors/turbopuffer.mdx +4 -4
- package/.docs/raw/reference/vectors/upstash.mdx +55 -6
- package/.docs/raw/reference/vectors/vectorize.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +1 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/start.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/startAsync.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +5 -5
- package/.docs/raw/reference/workflows/run.mdx +1 -1
- package/.docs/raw/reference/workflows/step.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +6 -6
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +7 -7
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow.mdx +3 -3
- package/.docs/raw/server/auth/auth0.mdx +20 -14
- package/.docs/raw/server/auth/clerk.mdx +16 -9
- package/.docs/raw/server/auth/firebase.mdx +21 -15
- package/.docs/raw/server/auth/jwt.mdx +14 -7
- package/.docs/raw/server/auth/supabase.mdx +16 -9
- package/.docs/raw/server/auth/workos.mdx +19 -13
- package/.docs/raw/server/custom-adapters.mdx +10 -10
- package/.docs/raw/server/custom-api-routes.mdx +2 -4
- package/.docs/raw/server/mastra-client.mdx +24 -13
- package/.docs/raw/server/mastra-server.mdx +3 -3
- package/.docs/raw/server/middleware.mdx +7 -7
- package/.docs/raw/server/request-context.mdx +31 -30
- package/.docs/raw/server/server-adapters.mdx +6 -6
- package/.docs/raw/streaming/events.mdx +14 -7
- package/.docs/raw/streaming/overview.mdx +21 -10
- package/.docs/raw/streaming/tool-streaming.mdx +6 -6
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -8
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +31 -12
- package/.docs/raw/tools-mcp/overview.mdx +9 -10
- package/.docs/raw/voice/overview.mdx +1 -1
- package/.docs/raw/workflows/agents-and-tools.mdx +28 -19
- package/.docs/raw/workflows/control-flow.mdx +27 -40
- package/.docs/raw/workflows/error-handling.mdx +15 -22
- package/.docs/raw/workflows/human-in-the-loop.mdx +6 -7
- package/.docs/raw/workflows/inngest-workflow.mdx +8 -9
- package/.docs/raw/workflows/input-data-mapping.mdx +7 -7
- package/.docs/raw/workflows/overview.mdx +33 -22
- package/.docs/raw/workflows/snapshots.mdx +14 -44
- package/.docs/raw/workflows/suspend-and-resume.mdx +7 -7
- package/.docs/raw/workflows/time-travel.mdx +16 -16
- package/.docs/raw/workflows/workflow-state.mdx +5 -8
- package/CHANGELOG.md +9 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/stdio.js +53 -0
- package/package.json +4 -4
- package/.docs/raw/memory/conversation-history.mdx +0 -24
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +0 -140
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -150
- package/.docs/raw/memory/storage/memory-with-pg.mdx +0 -138
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +0 -146
- package/.docs/raw/memory/threads-and-resources.mdx +0 -95
|
@@ -9,7 +9,7 @@ The MongoDB storage implementation provides a scalable storage solution using Mo
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
```bash
|
|
12
|
+
```bash
|
|
13
13
|
npm install @mastra/mongodb@beta
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ npm install @mastra/mongodb@beta
|
|
|
17
17
|
|
|
18
18
|
Ensure you have a MongoDB Atlas Local (via Docker) or MongoDB Atlas Cloud instance with Atlas Search enabled. MongoDB 7.0+ is recommended.
|
|
19
19
|
|
|
20
|
-
```typescript
|
|
20
|
+
```typescript
|
|
21
21
|
import { MongoDBStore } from "@mastra/mongodb";
|
|
22
22
|
|
|
23
23
|
const storage = new MongoDBStore({
|
|
@@ -47,7 +47,7 @@ const storage = new MongoDBStore({
|
|
|
47
47
|
name: "options",
|
|
48
48
|
type: "MongoClientOptions",
|
|
49
49
|
description:
|
|
50
|
-
"MongoDB client options for advanced configuration (SSL, connection pooling, etc.).
|
|
50
|
+
"MongoDB client options for advanced configuration (SSL, connection pooling, etc.).",
|
|
51
51
|
isOptional: true,
|
|
52
52
|
},
|
|
53
53
|
]}
|
|
@@ -97,7 +97,7 @@ The storage implementation handles collection creation and management automatica
|
|
|
97
97
|
|
|
98
98
|
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
99
99
|
|
|
100
|
-
```typescript
|
|
100
|
+
```typescript
|
|
101
101
|
import { Mastra } from "@mastra/core";
|
|
102
102
|
import { MongoDBStore } from "@mastra/mongodb";
|
|
103
103
|
|
|
@@ -113,7 +113,7 @@ const mastra = new Mastra({
|
|
|
113
113
|
|
|
114
114
|
If you're using storage directly without Mastra, you must call `init()` explicitly to create the collections:
|
|
115
115
|
|
|
116
|
-
```typescript
|
|
116
|
+
```typescript
|
|
117
117
|
import { MongoDBStore } from "@mastra/mongodb";
|
|
118
118
|
|
|
119
119
|
const storage = new MongoDBStore({
|
|
@@ -138,7 +138,7 @@ MongoDB storage includes built-in vector search capabilities for AI applications
|
|
|
138
138
|
|
|
139
139
|
### Vector Index Creation
|
|
140
140
|
|
|
141
|
-
```typescript
|
|
141
|
+
```typescript
|
|
142
142
|
import { MongoDBVector } from "@mastra/mongodb";
|
|
143
143
|
|
|
144
144
|
const vectorStore = new MongoDBVector({
|
|
@@ -155,7 +155,7 @@ await vectorStore.createIndex({
|
|
|
155
155
|
|
|
156
156
|
### Vector Operations
|
|
157
157
|
|
|
158
|
-
```typescript
|
|
158
|
+
```typescript
|
|
159
159
|
// Store vectors with metadata
|
|
160
160
|
await vectorStore.upsert({
|
|
161
161
|
indexName: "document_embeddings",
|
|
@@ -182,3 +182,76 @@ const results = await vectorStore.query({
|
|
|
182
182
|
},
|
|
183
183
|
});
|
|
184
184
|
```
|
|
185
|
+
|
|
186
|
+
## Usage Example
|
|
187
|
+
|
|
188
|
+
### Adding memory to an agent
|
|
189
|
+
|
|
190
|
+
To add MongoDB memory to an agent use the `Memory` class and create a new `storage` key using `MongoDBStore`. The configuration supports both local and remote MongoDB instances.
|
|
191
|
+
|
|
192
|
+
```typescript title="src/mastra/agents/example-mongodb-agent.ts"
|
|
193
|
+
import { Memory } from "@mastra/memory";
|
|
194
|
+
import { Agent } from "@mastra/core/agent";
|
|
195
|
+
import { MongoDBStore } from "@mastra/mongodb";
|
|
196
|
+
|
|
197
|
+
export const mongodbAgent = new Agent({
|
|
198
|
+
id: "mongodb-agent",
|
|
199
|
+
name: "mongodb-agent",
|
|
200
|
+
instructions:
|
|
201
|
+
"You are an AI agent with the ability to automatically recall memories from previous interactions.",
|
|
202
|
+
model: "openai/gpt-5.1",
|
|
203
|
+
memory: new Memory({
|
|
204
|
+
storage: new MongoDBStore({
|
|
205
|
+
url: process.env.MONGODB_URI!,
|
|
206
|
+
dbName: process.env.MONGODB_DB_NAME!,
|
|
207
|
+
}),
|
|
208
|
+
options: {
|
|
209
|
+
threads: {
|
|
210
|
+
generateTitle: true,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Using the agent
|
|
218
|
+
|
|
219
|
+
Use `memoryOptions` to scope recall for this request. Set `lastMessages: 5` to limit recency-based recall, and use `semanticRecall` to fetch the `topK: 3` most relevant messages, including `messageRange: 2` neighboring messages for context around each match.
|
|
220
|
+
|
|
221
|
+
```typescript title="src/test-mongodb-agent.ts"
|
|
222
|
+
import "dotenv/config";
|
|
223
|
+
|
|
224
|
+
import { mastra } from "./mastra";
|
|
225
|
+
|
|
226
|
+
const threadId = "123";
|
|
227
|
+
const resourceId = "user-456";
|
|
228
|
+
|
|
229
|
+
const agent = mastra.getAgent("mongodbAgent");
|
|
230
|
+
|
|
231
|
+
const message = await agent.stream("My name is Mastra", {
|
|
232
|
+
memory: {
|
|
233
|
+
thread: threadId,
|
|
234
|
+
resource: resourceId,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
await message.textStream.pipeTo(new WritableStream());
|
|
239
|
+
|
|
240
|
+
const stream = await agent.stream("What's my name?", {
|
|
241
|
+
memory: {
|
|
242
|
+
thread: threadId,
|
|
243
|
+
resource: resourceId,
|
|
244
|
+
},
|
|
245
|
+
memoryOptions: {
|
|
246
|
+
lastMessages: 5,
|
|
247
|
+
semanticRecall: {
|
|
248
|
+
topK: 3,
|
|
249
|
+
messageRange: 2,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
for await (const chunk of stream.textStream) {
|
|
255
|
+
process.stdout.write(chunk);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
@@ -9,13 +9,13 @@ The MSSQL storage implementation provides a production-ready storage solution us
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
```bash
|
|
12
|
+
```bash
|
|
13
13
|
npm install @mastra/mssql@beta
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
```typescript
|
|
18
|
+
```typescript
|
|
19
19
|
import { MSSQLStore } from "@mastra/mssql";
|
|
20
20
|
|
|
21
21
|
const storage = new MSSQLStore({
|
|
@@ -105,7 +105,7 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
105
105
|
|
|
106
106
|
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
107
107
|
|
|
108
|
-
```typescript
|
|
108
|
+
```typescript
|
|
109
109
|
import { Mastra } from "@mastra/core";
|
|
110
110
|
import { MSSQLStore } from "@mastra/mssql";
|
|
111
111
|
|
|
@@ -120,7 +120,7 @@ const mastra = new Mastra({
|
|
|
120
120
|
|
|
121
121
|
If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
|
|
122
122
|
|
|
123
|
-
```typescript
|
|
123
|
+
```typescript
|
|
124
124
|
import { MSSQLStore } from "@mastra/mssql";
|
|
125
125
|
|
|
126
126
|
const storage = new MSSQLStore({
|
|
@@ -1,58 +1,22 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
description:
|
|
2
|
+
title: "Reference: Storage Overview | Storage"
|
|
3
|
+
description: Core data schema and table structure for Mastra's storage system.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
6
|
import { SchemaTable } from "@site/src/components/SchemaTable";
|
|
8
|
-
import { StorageOverviewImage } from "@site/src/components/StorageOverviewImage";
|
|
9
7
|
import Tabs from "@theme/Tabs";
|
|
10
8
|
import TabItem from "@theme/TabItem";
|
|
11
9
|
|
|
12
10
|
# Storage Overview
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
Mastra requires the following tables to be present in the database.
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
- **Memory**: threads and messages per `resourceId` in your application
|
|
18
|
-
- **Traces**: OpenTelemetry traces from all components of Mastra
|
|
19
|
-
- **Eval Datasets**: scores and scoring reasons from eval runs
|
|
20
|
-
|
|
21
|
-
<br />
|
|
22
|
-
|
|
23
|
-
<br />
|
|
24
|
-
|
|
25
|
-
<StorageOverviewImage />
|
|
26
|
-
|
|
27
|
-
Mastra provides different storage providers, but you can treat them as interchangeable. Eg, you could use libsql in development but postgres in production, and your code will work the same both ways.
|
|
28
|
-
|
|
29
|
-
## Configuration
|
|
30
|
-
|
|
31
|
-
Mastra can be configured with a default storage option:
|
|
32
|
-
|
|
33
|
-
```typescript copy
|
|
34
|
-
import { Mastra } from "@mastra/core";
|
|
35
|
-
import { LibSQLStore } from "@mastra/libsql";
|
|
36
|
-
|
|
37
|
-
const mastra = new Mastra({
|
|
38
|
-
storage: new LibSQLStore({
|
|
39
|
-
id: 'mastra-storage',
|
|
40
|
-
url: "file:./mastra.db",
|
|
41
|
-
}),
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
If you do not specify any `storage` configuration, Mastra will not persist data across application restarts or deployments. For any
|
|
46
|
-
deployment beyond local testing you should provide your own storage
|
|
47
|
-
configuration either on `Mastra` or directly within `new Memory()`.
|
|
48
|
-
|
|
49
|
-
## Data Schema
|
|
14
|
+
## Core Schema
|
|
50
15
|
|
|
51
16
|
<Tabs>
|
|
52
17
|
<TabItem value="messages" label="Messages">
|
|
53
18
|
Stores conversation messages and their metadata. Each message belongs to a thread and contains the actual content along with metadata about the sender role and message type.
|
|
54
19
|
|
|
55
|
-
<br />
|
|
56
20
|
<SchemaTable
|
|
57
21
|
columns={[
|
|
58
22
|
{
|
|
@@ -152,10 +116,9 @@ The message `content` column contains a JSON object conforming to the `MastraMes
|
|
|
152
116
|
|
|
153
117
|
</TabItem>
|
|
154
118
|
|
|
155
|
-
|
|
119
|
+
<TabItem value="threads" label="Threads">
|
|
156
120
|
Groups related messages together and associates them with a resource. Contains metadata about the conversation.
|
|
157
121
|
|
|
158
|
-
<br />
|
|
159
122
|
<SchemaTable
|
|
160
123
|
columns={[
|
|
161
124
|
{
|
|
@@ -202,10 +165,9 @@ Groups related messages together and associates them with a resource. Contains m
|
|
|
202
165
|
/>
|
|
203
166
|
|
|
204
167
|
</TabItem>
|
|
205
|
-
|
|
168
|
+
<TabItem value="resources" label="Resources">
|
|
206
169
|
Stores user-specific data for resource-scoped working memory. Each resource represents a user or entity, allowing working memory to persist across all conversation threads for that user.
|
|
207
170
|
|
|
208
|
-
<br />
|
|
209
171
|
<SchemaTable
|
|
210
172
|
columns={[
|
|
211
173
|
{
|
|
@@ -248,10 +210,9 @@ Stores user-specific data for resource-scoped working memory. Each resource repr
|
|
|
248
210
|
/>
|
|
249
211
|
|
|
250
212
|
</TabItem>
|
|
251
|
-
|
|
213
|
+
<TabItem value="workflows" label="Workflows">
|
|
252
214
|
When `suspend` is called on a workflow, its state is saved in the following format. When `resume` is called, that state is rehydrated.
|
|
253
215
|
|
|
254
|
-
<br />
|
|
255
216
|
<SchemaTable
|
|
256
217
|
columns={[
|
|
257
218
|
{
|
|
@@ -296,11 +257,10 @@ When `suspend` is called on a workflow, its state is saved in the following form
|
|
|
296
257
|
}
|
|
297
258
|
]}
|
|
298
259
|
/>
|
|
299
|
-
|
|
300
|
-
|
|
260
|
+
</TabItem>
|
|
261
|
+
<TabItem value="evals" label="Evals">
|
|
301
262
|
Stores eval results from running metrics against agent outputs.
|
|
302
263
|
|
|
303
|
-
<br />
|
|
304
264
|
<SchemaTable
|
|
305
265
|
columns={[
|
|
306
266
|
{
|
|
@@ -370,11 +330,10 @@ Stores eval results from running metrics against agent outputs.
|
|
|
370
330
|
}
|
|
371
331
|
]}
|
|
372
332
|
/>
|
|
373
|
-
|
|
374
|
-
|
|
333
|
+
</TabItem>
|
|
334
|
+
<TabItem value="traces" label="Traces">
|
|
375
335
|
Captures OpenTelemetry traces for monitoring and debugging.
|
|
376
336
|
|
|
377
|
-
<br />
|
|
378
337
|
<SchemaTable
|
|
379
338
|
columns={[
|
|
380
339
|
{
|
|
@@ -468,62 +427,5 @@ Captures OpenTelemetry traces for monitoring and debugging.
|
|
|
468
427
|
}
|
|
469
428
|
]}
|
|
470
429
|
/>
|
|
471
|
-
|
|
430
|
+
</TabItem>
|
|
472
431
|
</Tabs>
|
|
473
|
-
|
|
474
|
-
### Querying Messages
|
|
475
|
-
|
|
476
|
-
Messages are stored in the `MastraDBMessage` format, which provides a consistent structure across the entire Mastra system:
|
|
477
|
-
|
|
478
|
-
```typescript copy
|
|
479
|
-
// Get messages for a thread with pagination
|
|
480
|
-
const result = await mastra
|
|
481
|
-
.getStorage()
|
|
482
|
-
.listMessages({
|
|
483
|
-
threadId: "your-thread-id",
|
|
484
|
-
page: 0,
|
|
485
|
-
perPage: 50
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
console.log(result.messages); // MastraDBMessage[]
|
|
489
|
-
console.log(result.total); // Total count
|
|
490
|
-
console.log(result.hasMore); // Whether more pages exist
|
|
491
|
-
|
|
492
|
-
// Get messages from multiple threads at once
|
|
493
|
-
const multiThreadResult = await mastra
|
|
494
|
-
.getStorage()
|
|
495
|
-
.listMessages({
|
|
496
|
-
threadId: ["thread-1", "thread-2", "thread-3"],
|
|
497
|
-
page: 0,
|
|
498
|
-
perPage: 100
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// Get messages by their IDs
|
|
502
|
-
const messages = await mastra
|
|
503
|
-
.getStorage()
|
|
504
|
-
.listMessagesById({ messageIds: messageIdArr });
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
The `threadId` parameter accepts either a single thread ID string or an array of thread IDs to query messages from multiple threads in a single request.
|
|
508
|
-
|
|
509
|
-
All message queries return `MastraDBMessage[]` format. If you need to convert messages to AI SDK formats for UI rendering, use the conversion utilities from `@mastra/ai-sdk/ui`:
|
|
510
|
-
|
|
511
|
-
```typescript copy
|
|
512
|
-
import { toAISdkV5Messages } from '@mastra/ai-sdk/ui';
|
|
513
|
-
|
|
514
|
-
const result = await mastra
|
|
515
|
-
.getStorage()
|
|
516
|
-
.listMessages({ threadId: "your-thread-id" });
|
|
517
|
-
|
|
518
|
-
// Convert to AI SDK v5 UIMessage format for UI rendering
|
|
519
|
-
const uiMessages = toAISdkV5Messages(result.messages);
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
## Storage Providers
|
|
523
|
-
|
|
524
|
-
Mastra supports the following providers:
|
|
525
|
-
|
|
526
|
-
- For local development, check out [LibSQL Storage](/reference/v1/storage/libsql)
|
|
527
|
-
- For production, check out [PostgreSQL Storage](/reference/v1/storage/postgresql)
|
|
528
|
-
- For serverless deployments, check out [Upstash Storage](/reference/v1/storage/upstash)
|
|
529
|
-
- For document-based storage, check out [MongoDB Storage](/reference/v1/storage/mongodb)
|
|
@@ -9,13 +9,13 @@ The PostgreSQL storage implementation provides a production-ready storage soluti
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
|
-
```bash
|
|
12
|
+
```bash
|
|
13
13
|
npm install @mastra/pg@beta
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
```typescript
|
|
18
|
+
```typescript
|
|
19
19
|
import { PostgresStore } from "@mastra/pg";
|
|
20
20
|
|
|
21
21
|
const storage = new PostgresStore({
|
|
@@ -105,7 +105,7 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
105
105
|
|
|
106
106
|
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
107
107
|
|
|
108
|
-
```typescript
|
|
108
|
+
```typescript
|
|
109
109
|
import { Mastra } from "@mastra/core";
|
|
110
110
|
import { PostgresStore } from "@mastra/pg";
|
|
111
111
|
|
|
@@ -120,7 +120,7 @@ const mastra = new Mastra({
|
|
|
120
120
|
|
|
121
121
|
If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
|
|
122
122
|
|
|
123
|
-
```typescript
|
|
123
|
+
```typescript
|
|
124
124
|
import { PostgresStore } from "@mastra/pg";
|
|
125
125
|
|
|
126
126
|
const storage = new PostgresStore({
|
|
@@ -155,6 +155,77 @@ This enables direct queries and custom transaction management. When using these
|
|
|
155
155
|
|
|
156
156
|
This approach is intended for advanced scenarios where low-level access is required.
|
|
157
157
|
|
|
158
|
+
## Usage Example
|
|
159
|
+
|
|
160
|
+
### Adding memory to an agent
|
|
161
|
+
|
|
162
|
+
To add PostgreSQL memory to an agent use the `Memory` class and create a new `storage` key using `PostgresStore`. The `connectionString` can either be a remote location, or a local database connection.
|
|
163
|
+
|
|
164
|
+
```typescript title="src/mastra/agents/example-pg-agent.ts"
|
|
165
|
+
import { Memory } from "@mastra/memory";
|
|
166
|
+
import { Agent } from "@mastra/core/agent";
|
|
167
|
+
import { PostgresStore } from "@mastra/pg";
|
|
168
|
+
|
|
169
|
+
export const pgAgent = new Agent({
|
|
170
|
+
id: "pg-agent",
|
|
171
|
+
name: "PG Agent",
|
|
172
|
+
instructions:
|
|
173
|
+
"You are an AI agent with the ability to automatically recall memories from previous interactions.",
|
|
174
|
+
model: "openai/gpt-5.1",
|
|
175
|
+
memory: new Memory({
|
|
176
|
+
storage: new PostgresStore({
|
|
177
|
+
id: 'pg-agent-storage',
|
|
178
|
+
connectionString: process.env.DATABASE_URL!,
|
|
179
|
+
}),
|
|
180
|
+
options: {
|
|
181
|
+
generateTitle: true, // Explicitly enable automatic title generation
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Using the agent
|
|
188
|
+
|
|
189
|
+
Use `memoryOptions` to scope recall for this request. Set `lastMessages: 5` to limit recency-based recall, and use `semanticRecall` to fetch the `topK: 3` most relevant messages, including `messageRange: 2` neighboring messages for context around each match.
|
|
190
|
+
|
|
191
|
+
```typescript title="src/test-pg-agent.ts"
|
|
192
|
+
import "dotenv/config";
|
|
193
|
+
|
|
194
|
+
import { mastra } from "./mastra";
|
|
195
|
+
|
|
196
|
+
const threadId = "123";
|
|
197
|
+
const resourceId = "user-456";
|
|
198
|
+
|
|
199
|
+
const agent = mastra.getAgent("pg-agent");
|
|
200
|
+
|
|
201
|
+
const message = await agent.stream("My name is Mastra", {
|
|
202
|
+
memory: {
|
|
203
|
+
thread: threadId,
|
|
204
|
+
resource: resourceId,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
await message.textStream.pipeTo(new WritableStream());
|
|
209
|
+
|
|
210
|
+
const stream = await agent.stream("What's my name?", {
|
|
211
|
+
memory: {
|
|
212
|
+
thread: threadId,
|
|
213
|
+
resource: resourceId,
|
|
214
|
+
},
|
|
215
|
+
memoryOptions: {
|
|
216
|
+
lastMessages: 5,
|
|
217
|
+
semanticRecall: {
|
|
218
|
+
topK: 3,
|
|
219
|
+
messageRange: 2,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
for await (const chunk of stream.textStream) {
|
|
225
|
+
process.stdout.write(chunk);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
158
229
|
## Index Management
|
|
159
230
|
|
|
160
231
|
PostgreSQL storage provides comprehensive index management capabilities to optimize query performance.
|
|
@@ -174,7 +245,7 @@ These indexes significantly improve performance for filtered queries with sortin
|
|
|
174
245
|
|
|
175
246
|
Create additional indexes to optimize specific query patterns:
|
|
176
247
|
|
|
177
|
-
```typescript
|
|
248
|
+
```typescript
|
|
178
249
|
// Basic index for common queries
|
|
179
250
|
await storage.createIndex({
|
|
180
251
|
name: "idx_threads_resource",
|
|
@@ -278,7 +349,7 @@ For more advanced use cases, you can also use:
|
|
|
278
349
|
|
|
279
350
|
List and monitor existing indexes:
|
|
280
351
|
|
|
281
|
-
```typescript
|
|
352
|
+
```typescript
|
|
282
353
|
// List all indexes
|
|
283
354
|
const allIndexes = await storage.listIndexes();
|
|
284
355
|
console.log(allIndexes);
|
|
@@ -321,7 +392,7 @@ await storage.dropIndex("idx_threads_status");
|
|
|
321
392
|
|
|
322
393
|
When using custom schemas, indexes are created with schema prefixes:
|
|
323
394
|
|
|
324
|
-
```typescript
|
|
395
|
+
```typescript
|
|
325
396
|
const storage = new PostgresStore({
|
|
326
397
|
id: 'pg-storage',
|
|
327
398
|
connectionString: process.env.DATABASE_URL,
|
|
@@ -15,13 +15,13 @@ The Upstash storage implementation provides a serverless-friendly storage soluti
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
```bash
|
|
18
|
+
```bash
|
|
19
19
|
npm install @mastra/upstash@beta
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
|
-
```typescript
|
|
24
|
+
```typescript
|
|
25
25
|
import { UpstashStore } from "@mastra/upstash";
|
|
26
26
|
|
|
27
27
|
const storage = new UpstashStore({
|
|
@@ -91,3 +91,75 @@ For optimal performance:
|
|
|
91
91
|
- Use appropriate key prefixes to organize data
|
|
92
92
|
- Monitor Redis memory usage
|
|
93
93
|
- Consider data expiration policies if needed
|
|
94
|
+
|
|
95
|
+
## Usage Example
|
|
96
|
+
|
|
97
|
+
### Adding memory to an agent
|
|
98
|
+
|
|
99
|
+
To add Upstash memory to an agent use the `Memory` class and create a new `storage` key using `UpstashStore` and a new `vector` key using `UpstashVector`. The configuration can point to either a remote service or a local setup.
|
|
100
|
+
|
|
101
|
+
```typescript title="src/mastra/agents/example-upstash-agent.ts"
|
|
102
|
+
import { Memory } from "@mastra/memory";
|
|
103
|
+
import { Agent } from "@mastra/core/agent";
|
|
104
|
+
import { UpstashStore } from "@mastra/upstash";
|
|
105
|
+
|
|
106
|
+
export const upstashAgent = new Agent({
|
|
107
|
+
id: "upstash-agent",
|
|
108
|
+
name: "Upstash Agent",
|
|
109
|
+
instructions:
|
|
110
|
+
"You are an AI agent with the ability to automatically recall memories from previous interactions.",
|
|
111
|
+
model: "openai/gpt-5.1",
|
|
112
|
+
memory: new Memory({
|
|
113
|
+
storage: new UpstashStore({
|
|
114
|
+
id: 'upstash-agent-storage',
|
|
115
|
+
url: process.env.UPSTASH_REDIS_REST_URL!,
|
|
116
|
+
token: process.env.UPSTASH_REDIS_REST_TOKEN!,
|
|
117
|
+
}),
|
|
118
|
+
options: {
|
|
119
|
+
generateTitle: true, // Explicitly enable automatic title generation
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Using the agent
|
|
126
|
+
|
|
127
|
+
Use `memoryOptions` to scope recall for this request. Set `lastMessages: 5` to limit recency-based recall, and use `semanticRecall` to fetch the `topK: 3` most relevant messages, including `messageRange: 2` neighboring messages for context around each match.
|
|
128
|
+
|
|
129
|
+
```typescript title="src/test-upstash-agent.ts"
|
|
130
|
+
import "dotenv/config";
|
|
131
|
+
|
|
132
|
+
import { mastra } from "./mastra";
|
|
133
|
+
|
|
134
|
+
const threadId = "123";
|
|
135
|
+
const resourceId = "user-456";
|
|
136
|
+
|
|
137
|
+
const agent = mastra.getAgent("upstashAgent");
|
|
138
|
+
|
|
139
|
+
const message = await agent.stream("My name is Mastra", {
|
|
140
|
+
memory: {
|
|
141
|
+
thread: threadId,
|
|
142
|
+
resource: resourceId,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
await message.textStream.pipeTo(new WritableStream());
|
|
147
|
+
|
|
148
|
+
const stream = await agent.stream("What's my name?", {
|
|
149
|
+
memory: {
|
|
150
|
+
thread: threadId,
|
|
151
|
+
resource: resourceId,
|
|
152
|
+
},
|
|
153
|
+
memoryOptions: {
|
|
154
|
+
lastMessages: 5,
|
|
155
|
+
semanticRecall: {
|
|
156
|
+
topK: 3,
|
|
157
|
+
messageRange: 2,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
for await (const chunk of stream.textStream) {
|
|
163
|
+
process.stdout.write(chunk);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
@@ -11,7 +11,7 @@ The `.stream()` method enables real-time streaming of responses from an agent wi
|
|
|
11
11
|
|
|
12
12
|
## Usage example
|
|
13
13
|
|
|
14
|
-
```ts title="index.ts"
|
|
14
|
+
```ts title="index.ts"
|
|
15
15
|
const stream = await agent.stream("message for agent");
|
|
16
16
|
```
|
|
17
17
|
|
|
@@ -675,7 +675,7 @@ const stream = await agent.stream("message for agent");
|
|
|
675
675
|
|
|
676
676
|
### Mastra Format (Default)
|
|
677
677
|
|
|
678
|
-
```ts title="index.ts"
|
|
678
|
+
```ts title="index.ts"
|
|
679
679
|
import { stepCountIs } from "ai-v5";
|
|
680
680
|
|
|
681
681
|
const stream = await agent.stream("Tell me a story", {
|
|
@@ -703,7 +703,7 @@ const fullText = await stream.text;
|
|
|
703
703
|
|
|
704
704
|
To use the stream with AI SDK v5, you can convert it using our utility function `toAISdkStream`.
|
|
705
705
|
|
|
706
|
-
```ts title="index.ts"
|
|
706
|
+
```ts title="index.ts"
|
|
707
707
|
import { stepCountIs, createUIMessageStreamResponse } from "ai";
|
|
708
708
|
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
709
709
|
|
|
@@ -724,7 +724,7 @@ return createUIMessageStreamResponse({
|
|
|
724
724
|
|
|
725
725
|
All callback functions are now available as top-level properties for a cleaner API experience.
|
|
726
726
|
|
|
727
|
-
```ts title="index.ts"
|
|
727
|
+
```ts title="index.ts"
|
|
728
728
|
const stream = await agent.stream("Tell me a story", {
|
|
729
729
|
onFinish: (result) => {
|
|
730
730
|
console.log("Streaming finished:", result);
|
|
@@ -751,7 +751,7 @@ for await (const chunk of stream.textStream) {
|
|
|
751
751
|
|
|
752
752
|
### Advanced Example with Options
|
|
753
753
|
|
|
754
|
-
```ts title="index.ts"
|
|
754
|
+
```ts title="index.ts"
|
|
755
755
|
import { z } from "zod";
|
|
756
756
|
import { stepCountIs } from "ai";
|
|
757
757
|
|
|
@@ -15,7 +15,7 @@ The `.streamLegacy()` method is the legacy version of the agent streaming API, u
|
|
|
15
15
|
|
|
16
16
|
## Usage example
|
|
17
17
|
|
|
18
|
-
```typescript
|
|
18
|
+
```typescript
|
|
19
19
|
await agent.streamLegacy("message for agent");
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -534,7 +534,7 @@ await agent.streamLegacy("message for agent");
|
|
|
534
534
|
|
|
535
535
|
## Extended usage example
|
|
536
536
|
|
|
537
|
-
```typescript
|
|
537
|
+
```typescript
|
|
538
538
|
await agent.streamLegacy("message for agent", {
|
|
539
539
|
temperature: 0.7,
|
|
540
540
|
maxSteps: 3,
|
|
@@ -9,7 +9,7 @@ The `.stream()` method enables real-time streaming of responses from a workflow.
|
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
12
|
-
```typescript
|
|
12
|
+
```typescript
|
|
13
13
|
const run = await workflow.createRun();
|
|
14
14
|
|
|
15
15
|
const stream = await run.stream({
|
|
@@ -163,7 +163,7 @@ Returns a `WorkflowRunOutput` object that implements the async iterable interfac
|
|
|
163
163
|
|
|
164
164
|
## Extended usage example
|
|
165
165
|
|
|
166
|
-
```typescript
|
|
166
|
+
```typescript
|
|
167
167
|
const run = await workflow.createRun();
|
|
168
168
|
|
|
169
169
|
const stream = run.stream({
|