@mastra/mcp-docs-server 0.13.39 → 1.0.0-beta.1
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/%40internal%2Fai-sdk-v4.md +1 -0
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +36 -36
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +0 -10
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +4 -14
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +220 -220
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +210 -210
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +69 -69
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +209 -209
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +191 -191
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +5 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +182 -182
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +228 -228
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +197 -197
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +216 -216
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Freact.md +66 -66
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -17
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -30
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +203 -203
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +20 -20
- package/.docs/organized/changelogs/create-mastra.md +29 -29
- package/.docs/organized/changelogs/mastra.md +93 -93
- package/.docs/organized/code-examples/a2a.md +4 -2
- package/.docs/organized/code-examples/agui.md +12 -9
- package/.docs/organized/code-examples/ai-sdk-useChat.md +12 -18
- package/.docs/organized/code-examples/ai-sdk-v5.md +4 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +5 -4
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +4 -3
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +4 -3
- package/.docs/organized/code-examples/client-side-tools.md +1 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +8 -177
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +10 -7
- package/.docs/organized/code-examples/mcp-configuration.md +5 -3
- package/.docs/organized/code-examples/mcp-registry-registry.md +3 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +4 -2
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -0
- package/.docs/organized/code-examples/memory-with-context.md +2 -1
- package/.docs/organized/code-examples/memory-with-libsql.md +4 -2
- package/.docs/organized/code-examples/memory-with-mongodb.md +4 -2
- package/.docs/organized/code-examples/memory-with-pg.md +4 -2
- package/.docs/organized/code-examples/memory-with-processors.md +13 -8
- package/.docs/organized/code-examples/memory-with-upstash.md +5 -3
- package/.docs/organized/code-examples/openapi-spec-writer.md +32 -41
- package/.docs/organized/code-examples/quick-start.md +5 -32
- package/.docs/organized/code-examples/stock-price-tool.md +6 -5
- package/.docs/organized/code-examples/weather-agent.md +21 -16
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +3 -2
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +9 -12
- package/.docs/organized/code-examples/workflow-with-memory.md +16 -15
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +2 -2
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +3 -2
- package/.docs/raw/agents/adding-voice.mdx +27 -22
- package/.docs/raw/agents/agent-memory.mdx +24 -16
- package/.docs/raw/agents/guardrails.mdx +33 -12
- package/.docs/raw/agents/networks.mdx +8 -4
- package/.docs/raw/agents/overview.mdx +23 -17
- package/.docs/raw/agents/using-tools.mdx +11 -8
- package/.docs/raw/auth/auth0.mdx +9 -9
- package/.docs/raw/auth/clerk.mdx +7 -7
- package/.docs/raw/auth/firebase.mdx +9 -9
- package/.docs/raw/auth/index.mdx +6 -6
- package/.docs/raw/auth/jwt.mdx +7 -7
- package/.docs/raw/auth/supabase.mdx +8 -8
- package/.docs/raw/auth/workos.mdx +9 -9
- package/.docs/raw/community/contributing-templates.mdx +3 -3
- package/.docs/raw/community/discord.mdx +1 -1
- package/.docs/raw/course/01-first-agent/03-verifying-installation.md +1 -1
- package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +2 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +2 -1
- package/.docs/raw/course/02-agent-tools-mcp/02-installing-mcp.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/03-installing-memory.md +1 -1
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -0
- package/.docs/raw/course/03-agent-memory/10-storage-configuration.md +2 -3
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +2 -0
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -0
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -0
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +1 -0
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -0
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +1 -0
- package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +2 -2
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +6 -6
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +8 -6
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/index.mdx +11 -8
- package/.docs/raw/deployment/monorepo.mdx +2 -2
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/server-deployment.mdx +2 -10
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +5 -5
- package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +5 -5
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +5 -5
- package/.docs/raw/deployment/web-framework.mdx +8 -8
- package/.docs/raw/{scorers → evals}/custom-scorers.mdx +6 -6
- package/.docs/raw/evals/off-the-shelf-scorers.mdx +50 -0
- package/.docs/raw/{scorers → evals}/overview.mdx +9 -9
- package/.docs/raw/evals/running-in-ci.mdx +113 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +26 -25
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +17 -17
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +4 -1
- package/.docs/raw/frameworks/servers/express.mdx +11 -10
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +18 -18
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +7 -7
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +16 -16
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +7 -7
- package/.docs/raw/getting-started/installation.mdx +26 -25
- package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
- package/.docs/raw/getting-started/project-structure.mdx +4 -4
- package/.docs/raw/getting-started/studio.mdx +8 -8
- package/.docs/raw/getting-started/templates.mdx +6 -6
- package/.docs/raw/guides/guide/ai-recruiter.mdx +264 -0
- package/.docs/raw/guides/guide/chef-michel.mdx +271 -0
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +450 -0
- package/.docs/raw/guides/guide/research-assistant.mdx +380 -0
- package/.docs/raw/guides/guide/stock-agent.mdx +185 -0
- package/.docs/raw/guides/guide/web-search.mdx +291 -0
- package/.docs/raw/guides/index.mdx +43 -0
- package/.docs/raw/guides/migrations/agentnetwork.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/_template.mdx +50 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +265 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +48 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +153 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +230 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +171 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +241 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +83 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +62 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +270 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +115 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +280 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +23 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +39 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +178 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +367 -0
- package/.docs/raw/guides/quickstarts/nextjs.mdx +275 -0
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/{observability/logging.mdx → logging.mdx} +4 -4
- package/.docs/raw/mastra-cloud/dashboard.mdx +2 -2
- package/.docs/raw/mastra-cloud/observability.mdx +6 -6
- package/.docs/raw/mastra-cloud/overview.mdx +2 -2
- package/.docs/raw/mastra-cloud/setting-up.mdx +4 -4
- package/.docs/raw/memory/conversation-history.mdx +1 -0
- package/.docs/raw/memory/memory-processors.mdx +4 -3
- package/.docs/raw/memory/overview.mdx +10 -6
- package/.docs/raw/memory/semantic-recall.mdx +13 -8
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +12 -7
- package/.docs/raw/memory/storage/memory-with-pg.mdx +11 -6
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +11 -6
- package/.docs/raw/memory/threads-and-resources.mdx +11 -13
- package/.docs/raw/memory/working-memory.mdx +30 -14
- package/.docs/raw/observability/overview.mdx +13 -30
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/arize.mdx +11 -19
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/cloud.mdx +11 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/default.mdx +16 -20
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +12 -21
- package/.docs/raw/observability/{ai-tracing → tracing}/overview.mdx +107 -142
- package/.docs/raw/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +14 -13
- package/.docs/raw/rag/chunking-and-embedding.mdx +5 -5
- package/.docs/raw/rag/overview.mdx +3 -13
- package/.docs/raw/rag/retrieval.mdx +24 -12
- package/.docs/raw/rag/vector-databases.mdx +7 -1
- package/.docs/raw/reference/agents/agent.mdx +35 -30
- package/.docs/raw/reference/agents/generate.mdx +10 -10
- package/.docs/raw/reference/agents/generateLegacy.mdx +8 -8
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +21 -15
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +69 -0
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -16
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +8 -8
- package/.docs/raw/reference/agents/getLLM.mdx +9 -9
- package/.docs/raw/reference/agents/getMemory.mdx +9 -9
- package/.docs/raw/reference/agents/getModel.mdx +10 -10
- package/.docs/raw/reference/agents/getVoice.mdx +8 -8
- package/.docs/raw/reference/agents/listAgents.mdx +9 -9
- package/.docs/raw/reference/agents/listScorers.mdx +7 -7
- package/.docs/raw/reference/agents/listTools.mdx +7 -7
- package/.docs/raw/reference/agents/listWorkflows.mdx +7 -7
- package/.docs/raw/reference/agents/network.mdx +11 -10
- package/.docs/raw/reference/auth/auth0.mdx +4 -4
- package/.docs/raw/reference/auth/clerk.mdx +4 -4
- package/.docs/raw/reference/auth/firebase.mdx +6 -6
- package/.docs/raw/reference/auth/jwt.mdx +4 -4
- package/.docs/raw/reference/auth/supabase.mdx +4 -4
- package/.docs/raw/reference/auth/workos.mdx +4 -4
- package/.docs/raw/reference/cli/create-mastra.mdx +10 -10
- package/.docs/raw/reference/cli/mastra.mdx +7 -7
- package/.docs/raw/reference/client-js/agents.mdx +6 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
- package/.docs/raw/reference/client-js/memory.mdx +24 -16
- package/.docs/raw/reference/client-js/observability.mdx +11 -11
- package/.docs/raw/reference/client-js/workflows.mdx +6 -34
- 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 +2 -2
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +31 -15
- package/.docs/raw/reference/core/getMCPServerById.mdx +81 -0
- package/.docs/raw/reference/core/getScorer.mdx +3 -3
- package/.docs/raw/reference/core/getScorerById.mdx +79 -0
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
- package/.docs/raw/reference/core/getVector.mdx +2 -2
- 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 +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +65 -0
- package/.docs/raw/reference/core/listScorers.mdx +3 -3
- package/.docs/raw/reference/core/listVectors.mdx +36 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +6 -6
- package/.docs/raw/reference/core/mastra-class.mdx +3 -2
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +3 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +2 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -6
- package/.docs/raw/reference/deployer/netlify.mdx +2 -2
- package/.docs/raw/reference/deployer/vercel.mdx +3 -3
- package/.docs/raw/reference/evals/answer-relevancy.mdx +164 -126
- package/.docs/raw/reference/{scorers → evals}/answer-similarity.mdx +27 -27
- package/.docs/raw/reference/evals/bias.mdx +149 -115
- package/.docs/raw/reference/evals/completeness.mdx +148 -117
- package/.docs/raw/reference/evals/content-similarity.mdx +126 -113
- package/.docs/raw/reference/evals/context-precision.mdx +290 -133
- package/.docs/raw/reference/{scorers → evals}/context-relevance.mdx +6 -6
- package/.docs/raw/reference/{scorers → evals}/create-scorer.mdx +69 -60
- package/.docs/raw/reference/evals/faithfulness.mdx +163 -121
- package/.docs/raw/reference/evals/hallucination.mdx +159 -132
- package/.docs/raw/reference/evals/keyword-coverage.mdx +169 -125
- package/.docs/raw/reference/{scorers → evals}/mastra-scorer.mdx +7 -5
- package/.docs/raw/reference/{scorers → evals}/noise-sensitivity.mdx +9 -9
- package/.docs/raw/reference/evals/prompt-alignment.mdx +604 -182
- package/.docs/raw/reference/{scorers/run-experiment.mdx → evals/run-evals.mdx} +17 -18
- package/.docs/raw/reference/evals/textual-difference.mdx +149 -117
- package/.docs/raw/reference/evals/tone-consistency.mdx +149 -125
- package/.docs/raw/reference/{scorers → evals}/tool-call-accuracy.mdx +8 -6
- package/.docs/raw/reference/evals/toxicity.mdx +152 -96
- package/.docs/raw/reference/{observability/logging → logging}/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +5 -5
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -7
- package/.docs/raw/reference/memory/getThreadById.mdx +4 -4
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +110 -0
- package/.docs/raw/reference/memory/memory-class.mdx +13 -9
- package/.docs/raw/reference/memory/query.mdx +58 -57
- package/.docs/raw/reference/memory/recall.mdx +185 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +245 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/arize.mdx +13 -13
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +11 -8
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/cloud-exporter.mdx +21 -19
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/console-exporter.mdx +49 -17
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/default-exporter.mdx +42 -41
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/otel.mdx +5 -5
- package/.docs/raw/reference/observability/tracing/instances.mdx +168 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/interfaces.mdx +115 -89
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/reference/observability/{ai-tracing/span.mdx → tracing/spans.mdx} +59 -41
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +9 -3
- package/.docs/raw/reference/processors/language-detector.mdx +9 -3
- package/.docs/raw/reference/processors/moderation-processor.mdx +9 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +9 -3
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -3
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +9 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +9 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +9 -3
- package/.docs/raw/reference/rag/chunk.mdx +1 -8
- package/.docs/raw/reference/rag/database-config.mdx +7 -7
- package/.docs/raw/reference/rag/metadata-filters.mdx +14 -11
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +3 -3
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +3 -1
- package/.docs/raw/reference/storage/mongodb.mdx +1 -1
- package/.docs/raw/reference/storage/mssql.mdx +6 -1
- package/.docs/raw/reference/storage/postgresql.mdx +7 -1
- package/.docs/raw/reference/storage/upstash.mdx +2 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +12 -12
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +8 -8
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +6 -6
- package/.docs/raw/reference/streaming/workflows/stream.mdx +10 -10
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +11 -11
- package/.docs/raw/reference/templates/overview.mdx +3 -3
- package/.docs/raw/reference/tools/create-tool.mdx +52 -35
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +15 -15
- package/.docs/raw/reference/tools/mcp-client.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +119 -35
- package/.docs/raw/reference/tools/vector-query-tool.mdx +27 -26
- package/.docs/raw/reference/vectors/couchbase.mdx +8 -2
- package/.docs/raw/reference/vectors/libsql.mdx +2 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +7 -1
- package/.docs/raw/reference/vectors/pg.mdx +3 -0
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- package/.docs/raw/reference/vectors/upstash.mdx +1 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -4
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +14 -14
- package/.docs/raw/reference/workflows/run-methods/start.mdx +17 -17
- package/.docs/raw/reference/workflows/run.mdx +1 -8
- package/.docs/raw/reference/workflows/step.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -13
- 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 +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +5 -0
- 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 +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +1 -1
- package/.docs/raw/server-db/custom-api-routes.mdx +2 -2
- package/.docs/raw/server-db/mastra-client.mdx +23 -22
- package/.docs/raw/server-db/middleware.mdx +7 -7
- package/.docs/raw/server-db/production-server.mdx +4 -4
- package/.docs/raw/server-db/{runtime-context.mdx → request-context.mdx} +46 -45
- package/.docs/raw/server-db/storage.mdx +29 -21
- package/.docs/raw/streaming/events.mdx +3 -3
- package/.docs/raw/streaming/overview.mdx +5 -5
- package/.docs/raw/streaming/tool-streaming.mdx +18 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +1 -1
- package/.docs/raw/tools-mcp/advanced-usage.mdx +5 -4
- package/.docs/raw/tools-mcp/mcp-overview.mdx +33 -20
- package/.docs/raw/tools-mcp/overview.mdx +11 -11
- package/.docs/raw/voice/overview.mdx +63 -43
- package/.docs/raw/voice/speech-to-speech.mdx +5 -3
- package/.docs/raw/voice/speech-to-text.mdx +10 -9
- package/.docs/raw/voice/text-to-speech.mdx +13 -12
- package/.docs/raw/workflows/agents-and-tools.mdx +9 -5
- package/.docs/raw/workflows/control-flow.mdx +3 -3
- package/.docs/raw/workflows/error-handling.mdx +2 -21
- package/.docs/raw/workflows/human-in-the-loop.mdx +7 -4
- package/.docs/raw/workflows/inngest-workflow.mdx +3 -3
- package/.docs/raw/workflows/input-data-mapping.mdx +107 -0
- package/.docs/raw/workflows/overview.mdx +17 -16
- package/.docs/raw/workflows/snapshots.mdx +13 -11
- package/.docs/raw/workflows/suspend-and-resume.mdx +23 -15
- package/CHANGELOG.md +55 -53
- package/README.md +11 -2
- package/dist/{chunk-TUAHUTTB.js → chunk-5NJC7NRO.js} +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/prompts/migration.d.ts +6 -0
- package/dist/prompts/migration.d.ts.map +1 -0
- package/dist/stdio.js +402 -30
- package/dist/tools/migration.d.ts +40 -0
- package/dist/tools/migration.d.ts.map +1 -0
- package/package.json +8 -12
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +0 -302
- package/.docs/raw/observability/nextjs-tracing.mdx +0 -109
- package/.docs/raw/observability/otel-tracing.mdx +0 -189
- package/.docs/raw/reference/agents/getScorers.mdx +0 -69
- package/.docs/raw/reference/agents/getTools.mdx +0 -69
- package/.docs/raw/reference/agents/getWorkflows.mdx +0 -69
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +0 -143
- package/.docs/raw/reference/core/getAgents.mdx +0 -35
- package/.docs/raw/reference/core/getLogs.mdx +0 -96
- package/.docs/raw/reference/core/getLogsByRunId.mdx +0 -87
- package/.docs/raw/reference/core/getMCPServers.mdx +0 -36
- package/.docs/raw/reference/core/getMemory.mdx +0 -36
- package/.docs/raw/reference/core/getScorerByName.mdx +0 -78
- package/.docs/raw/reference/core/getScorers.mdx +0 -43
- package/.docs/raw/reference/core/getVectors.mdx +0 -36
- package/.docs/raw/reference/core/getWorkflows.mdx +0 -45
- package/.docs/raw/reference/evals/context-position.mdx +0 -197
- package/.docs/raw/reference/evals/context-relevancy.mdx +0 -196
- package/.docs/raw/reference/evals/contextual-recall.mdx +0 -196
- package/.docs/raw/reference/evals/summarization.mdx +0 -212
- package/.docs/raw/reference/legacyWorkflows/after.mdx +0 -89
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +0 -79
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +0 -33
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -76
- package/.docs/raw/reference/legacyWorkflows/else.mdx +0 -68
- package/.docs/raw/reference/legacyWorkflows/events.mdx +0 -305
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +0 -110
- package/.docs/raw/reference/legacyWorkflows/if.mdx +0 -108
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +0 -158
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +0 -133
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +0 -207
- package/.docs/raw/reference/legacyWorkflows/start.mdx +0 -87
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +0 -100
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +0 -137
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +0 -93
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +0 -69
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +0 -196
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +0 -70
- package/.docs/raw/reference/legacyWorkflows/then.mdx +0 -72
- package/.docs/raw/reference/legacyWorkflows/until.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +0 -124
- package/.docs/raw/reference/legacyWorkflows/while.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +0 -234
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +0 -79
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +0 -110
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -185
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +0 -238
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +0 -117
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +0 -81
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +0 -121
- package/.docs/raw/reference/observability/otel-tracing/providers/braintrust.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +0 -20
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +0 -73
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +0 -41
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +0 -84
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +0 -48
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +0 -43
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +0 -40
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -227
- package/.docs/raw/reference/scorers/bias.mdx +0 -228
- package/.docs/raw/reference/scorers/completeness.mdx +0 -214
- package/.docs/raw/reference/scorers/content-similarity.mdx +0 -197
- package/.docs/raw/reference/scorers/context-precision.mdx +0 -352
- package/.docs/raw/reference/scorers/faithfulness.mdx +0 -241
- package/.docs/raw/reference/scorers/hallucination.mdx +0 -252
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +0 -229
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +0 -668
- package/.docs/raw/reference/scorers/textual-difference.mdx +0 -203
- package/.docs/raw/reference/scorers/tone-consistency.mdx +0 -211
- package/.docs/raw/reference/scorers/toxicity.mdx +0 -228
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +0 -73
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +0 -24
- package/.docs/raw/scorers/evals-old-api/overview.mdx +0 -106
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +0 -85
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +0 -58
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +0 -50
- package/.docs/raw/workflows-legacy/control-flow.mdx +0 -774
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +0 -239
- package/.docs/raw/workflows-legacy/error-handling.mdx +0 -187
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +0 -360
- package/.docs/raw/workflows-legacy/overview.mdx +0 -182
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +0 -156
- package/.docs/raw/workflows-legacy/steps.mdx +0 -115
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +0 -406
- package/.docs/raw/workflows-legacy/variables.mdx +0 -318
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Next.js Quickstart"
|
|
3
|
+
description: "Get started with Mastra, Next.js, and AS SDK UI. Quickly."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js Quickstart
|
|
7
|
+
|
|
8
|
+
In this quickstart, you'll build an AI agent with tool-calling capabilities using [Mastra](/docs/v1), then connect it to Next.js by importing and calling the agent directly within your routes.
|
|
9
|
+
|
|
10
|
+
You'll use [AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and [AI Elements](https://ai-sdk.dev/elements) to create a beautiful, interactive chat experience.
|
|
11
|
+
|
|
12
|
+
In ~5 minutes, you'll have a functional AI-powered app ready to extend with your own tools and logic.
|
|
13
|
+
|
|
14
|
+
<figure>
|
|
15
|
+

|
|
16
|
+
<figcaption class="text-sm text-center">What you'll build: an agent that can call a weather tool, display the JSON result, stream a weather summary in the chat UI, and persist conversation history across reloads.</figcaption>
|
|
17
|
+
</figure>
|
|
18
|
+
|
|
19
|
+
## Before you begin
|
|
20
|
+
|
|
21
|
+
* You'll need an API key from a supported [model provider](/models/v1). If you don't have a preference, use [OpenAI](https://platform.openai.com/api-keys).
|
|
22
|
+
|
|
23
|
+
## Create a new Next.js app
|
|
24
|
+
|
|
25
|
+
Run the following command to [create a new Next.js app](https://nextjs.org/docs/app/getting-started/installation):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx create-next-app \
|
|
29
|
+
my-nextjs-agent \
|
|
30
|
+
--yes \
|
|
31
|
+
--ts \
|
|
32
|
+
--eslint \
|
|
33
|
+
--tailwind \
|
|
34
|
+
--src-dir \
|
|
35
|
+
--app \
|
|
36
|
+
--turbopack \
|
|
37
|
+
--no-react-compiler \
|
|
38
|
+
--no-import-alias
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This creates a project called `my-nextjs-agent`, but you can replace it with any name you want.
|
|
42
|
+
|
|
43
|
+
## Initialize Mastra
|
|
44
|
+
`cd` and run [`mastra init`](/reference/v1/cli/create-mastra).
|
|
45
|
+
|
|
46
|
+
When prompted, choose a provider (e.g. OpenAI) and enter your key:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd my-nextjs-agent
|
|
50
|
+
npx --force mastra@beta init
|
|
51
|
+
```
|
|
52
|
+
This creates a `src/mastra` folder with an example weather agent and the following files:
|
|
53
|
+
|
|
54
|
+
- `index.ts` - Mastra config, including memory
|
|
55
|
+
- `tools/weather-tool.ts` - a tool to fetch weather for a given location
|
|
56
|
+
- `agents/weather-agent.ts`- a weather agent with a prompt that uses the tool
|
|
57
|
+
|
|
58
|
+
You'll call `weather-agent.ts` from your Next.js routes in the next steps.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Install AI SDK UI and AI Elements
|
|
62
|
+
|
|
63
|
+
Install AI SDK UI along with the Mastra adapter:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install \
|
|
67
|
+
@mastra/ai-sdk \
|
|
68
|
+
@ai-sdk/react
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Next, initialize AI Elements. When prompted, choose the default options:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx ai-elements@latest
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This downloads the entire AI Elements UI component library into a `@/components/ai-elements` folder.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Create a chat route
|
|
81
|
+
|
|
82
|
+
Create `src/app/api/chat/route.ts`:
|
|
83
|
+
|
|
84
|
+
```ts title="src/app/api/chat/route.ts"
|
|
85
|
+
import { mastra } from "@/mastra";
|
|
86
|
+
import { NextResponse } from "next/server";
|
|
87
|
+
import { toAISdkFormat } from "@mastra/ai-sdk";
|
|
88
|
+
import { convertMessages } from "@mastra/core/agent";
|
|
89
|
+
import { createUIMessageStreamResponse } from "ai";
|
|
90
|
+
|
|
91
|
+
const weatherAgent = mastra.getAgent("weatherAgent");
|
|
92
|
+
|
|
93
|
+
export async function POST(req: Request) {
|
|
94
|
+
const { messages } = await req.json();
|
|
95
|
+
|
|
96
|
+
const stream = await weatherAgent.stream(messages, {
|
|
97
|
+
memory: {
|
|
98
|
+
thread: "example-user-id",
|
|
99
|
+
resource: "weather-chat",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return createUIMessageStreamResponse({
|
|
104
|
+
stream: toAISdkFormat(stream, { from: "agent" }),
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function GET() {
|
|
109
|
+
const memory = await weatherAgent.getMemory();
|
|
110
|
+
const response = await memory?.query({
|
|
111
|
+
threadId: "example-user-id",
|
|
112
|
+
resourceId: "weather-chat",
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const uiMessages =
|
|
116
|
+
convertMessages(response?.uiMessages ?? []).to("AIV5.UI");
|
|
117
|
+
return NextResponse.json(uiMessages);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The POST route accepts a prompt and streams the agent's response back in AI SDK format, while the GET route fetches message history from memory so the UI can be hydrated when the client reloads.
|
|
122
|
+
|
|
123
|
+
## Create a chat page
|
|
124
|
+
|
|
125
|
+
Create `src/app/chat/page.tsx`:
|
|
126
|
+
|
|
127
|
+
```tsx title="src/app/chat/page.tsx"
|
|
128
|
+
'use client';
|
|
129
|
+
|
|
130
|
+
import '@/app/globals.css';
|
|
131
|
+
import { useEffect, useState } from 'react';
|
|
132
|
+
import { DefaultChatTransport } from 'ai';
|
|
133
|
+
import { useChat } from '@ai-sdk/react';
|
|
134
|
+
|
|
135
|
+
import {
|
|
136
|
+
PromptInput,
|
|
137
|
+
PromptInputBody,
|
|
138
|
+
PromptInputTextarea,
|
|
139
|
+
} from '@/components/ai-elements/prompt-input';
|
|
140
|
+
|
|
141
|
+
import {
|
|
142
|
+
Conversation,
|
|
143
|
+
ConversationContent,
|
|
144
|
+
ConversationScrollButton,
|
|
145
|
+
} from '@/components/ai-elements/conversation';
|
|
146
|
+
|
|
147
|
+
import { Message, MessageContent, MessageResponse } from '@/components/ai-elements/message';
|
|
148
|
+
|
|
149
|
+
import {
|
|
150
|
+
Tool,
|
|
151
|
+
ToolHeader,
|
|
152
|
+
ToolContent,
|
|
153
|
+
ToolInput,
|
|
154
|
+
ToolOutput,
|
|
155
|
+
} from '@/components/ai-elements/tool';
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function Chat() {
|
|
159
|
+
const [input, setInput] = useState<string>('');
|
|
160
|
+
|
|
161
|
+
const { messages, setMessages, sendMessage, status } = useChat({
|
|
162
|
+
transport: new DefaultChatTransport({
|
|
163
|
+
api: '/api/chat',
|
|
164
|
+
}),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const fetchMessages = async () => {
|
|
169
|
+
const res = await fetch('/api/chat');
|
|
170
|
+
const data = await res.json();
|
|
171
|
+
setMessages([...data]);
|
|
172
|
+
};
|
|
173
|
+
fetchMessages();
|
|
174
|
+
}, [setMessages]);
|
|
175
|
+
|
|
176
|
+
const handleSubmit = async () => {
|
|
177
|
+
if (!input.trim()) return;
|
|
178
|
+
|
|
179
|
+
sendMessage({ text: input });
|
|
180
|
+
setInput('');
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<div className="w-full p-6 relative size-full h-screen">
|
|
185
|
+
<div className="flex flex-col h-full">
|
|
186
|
+
<Conversation className="h-full">
|
|
187
|
+
<ConversationContent>
|
|
188
|
+
{messages.map((message: any) => (
|
|
189
|
+
<div key={message.id}>
|
|
190
|
+
{message.parts?.map((part: any, i: number) => {
|
|
191
|
+
if (part.type === 'text') {
|
|
192
|
+
return (
|
|
193
|
+
<Message
|
|
194
|
+
key={`${message.id}-${i}`}
|
|
195
|
+
from={message.role}>
|
|
196
|
+
<MessageContent>
|
|
197
|
+
<MessageResponse>{part.text}</MessageResponse>
|
|
198
|
+
</MessageContent>
|
|
199
|
+
</Message>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (part.type?.startsWith('tool-')) {
|
|
204
|
+
return (
|
|
205
|
+
<Tool key={`${message.id}-${i}`}>
|
|
206
|
+
<ToolHeader
|
|
207
|
+
type={part.type}
|
|
208
|
+
state={part.state || 'output-available'}
|
|
209
|
+
className="cursor-pointer"
|
|
210
|
+
/>
|
|
211
|
+
<ToolContent>
|
|
212
|
+
<ToolInput input={part.input || part.args || {}} />
|
|
213
|
+
<ToolOutput
|
|
214
|
+
output={part.output || part.result}
|
|
215
|
+
errorText={part.errorText || part.error}
|
|
216
|
+
/>
|
|
217
|
+
</ToolContent>
|
|
218
|
+
</Tool>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return null;
|
|
223
|
+
})}
|
|
224
|
+
</div>
|
|
225
|
+
))}
|
|
226
|
+
<ConversationScrollButton />
|
|
227
|
+
</ConversationContent>
|
|
228
|
+
</Conversation>
|
|
229
|
+
|
|
230
|
+
<PromptInput onSubmit={handleSubmit} className="mt-20">
|
|
231
|
+
<PromptInputBody>
|
|
232
|
+
<PromptInputTextarea
|
|
233
|
+
onChange={(e: any) => setInput(e.target.value)}
|
|
234
|
+
className="md:leading-10"
|
|
235
|
+
value={input}
|
|
236
|
+
placeholder="Type your message..."
|
|
237
|
+
disabled={status !== 'ready'}
|
|
238
|
+
/>
|
|
239
|
+
</PromptInputBody>
|
|
240
|
+
</PromptInput>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export default Chat;
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
This component connects [`useChat()`](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) to the `api/chat` endpoint, sending prompts there and streaming the response back in chunks.
|
|
250
|
+
|
|
251
|
+
It renders the response text using the [`<MessageResponse>`](https://ai-sdk.dev/elements/components/message#messageresponse-) component, and shows any tool invocations with the [`<Tool>`](https://ai-sdk.dev/elements/components/tool) component.
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## Test your agent
|
|
255
|
+
1. Run your Next.js app with `npm run dev`
|
|
256
|
+
|
|
257
|
+
2. Open the chat at http://localhost:3000/chat
|
|
258
|
+
|
|
259
|
+
3. Try asking about the weather. If your API key is set up correctly, you'll get a response.
|
|
260
|
+
|
|
261
|
+
## Next steps
|
|
262
|
+
|
|
263
|
+
Congratulations on building your Mastra agent with Next.js! 🎉
|
|
264
|
+
|
|
265
|
+
From here, you can extend the project with your own tools and logic:
|
|
266
|
+
|
|
267
|
+
- Learn more about [agents](/docs/v1/agents/overview)
|
|
268
|
+
- Give your agent its own [tools](/docs/v1/agents/using-tools)
|
|
269
|
+
- Add human-like [memory](/docs/v1/agents/agent-memory) to your agent
|
|
270
|
+
|
|
271
|
+
When you're ready, read more about how Mastra integrates with AI SDK and Next.js, and how to deploy to Vercel:
|
|
272
|
+
|
|
273
|
+
- Integrate Mastra with [AI SDK](/docs/v1/frameworks/agentic-uis/ai-sdk)
|
|
274
|
+
- Use Mastra in your [Next.js app](/docs/v1/frameworks/web-frameworks/next-js)
|
|
275
|
+
- Deploy your agent to [Vercel](/docs/v1/deployment/serverless-platforms/vercel-deployer)
|
package/.docs/raw/index.mdx
CHANGED
|
@@ -9,7 +9,7 @@ import YouTube from "@site/src/components/YouTube-player";
|
|
|
9
9
|
|
|
10
10
|
# About Mastra
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
|
|
13
13
|
|
|
14
14
|
It includes everything you need to go from early prototypes to production-ready applications. Mastra integrates with frontend and backend frameworks like React, Next.js, and Node, or you can deploy it anywhere as a standalone server. It's the easiest way to build, tune, and scale reliable AI products.
|
|
15
15
|
|
|
@@ -21,19 +21,19 @@ Purpose-built for TypeScript and designed around established AI patterns, Mastra
|
|
|
21
21
|
|
|
22
22
|
Some highlights include:
|
|
23
23
|
|
|
24
|
-
- [**Model routing**](/models) - Connect to 40+ providers through one standard interface. Use models from OpenAI, Anthropic, Gemini, and more.
|
|
24
|
+
- [**Model routing**](/models/v1) - Connect to 40+ providers through one standard interface. Use models from OpenAI, Anthropic, Gemini, and more.
|
|
25
25
|
|
|
26
|
-
- [**Agents**](/docs/agents/overview) - Build autonomous agents that use LLMs and tools to solve open-ended tasks. Agents reason about goals, decide which tools to use, and iterate internally until the model emits a final answer or an optional stopping condition is met.
|
|
26
|
+
- [**Agents**](/docs/v1/agents/overview) - Build autonomous agents that use LLMs and tools to solve open-ended tasks. Agents reason about goals, decide which tools to use, and iterate internally until the model emits a final answer or an optional stopping condition is met.
|
|
27
27
|
|
|
28
|
-
- [**Workflows**](/docs/workflows/overview) - When you need explicit control over execution, use Mastra's graph-based workflow engine to orchestrate complex multi-step processes. Mastra workflows use an intuitive syntax for control flow (`.then()`, `.branch()`, `.parallel()`).
|
|
28
|
+
- [**Workflows**](/docs/v1/workflows/overview) - When you need explicit control over execution, use Mastra's graph-based workflow engine to orchestrate complex multi-step processes. Mastra workflows use an intuitive syntax for control flow (`.then()`, `.branch()`, `.parallel()`).
|
|
29
29
|
|
|
30
|
-
- [**Human-in-the-loop**](/docs/workflows/suspend-and-resume) - Suspend an agent or workflow and await user input or approval before resuming. Mastra uses [storage](/docs/server-db/storage) to remember execution state, so you can pause indefinitely and resume where you left off.
|
|
30
|
+
- [**Human-in-the-loop**](/docs/v1/workflows/suspend-and-resume) - Suspend an agent or workflow and await user input or approval before resuming. Mastra uses [storage](/docs/v1/server-db/storage) to remember execution state, so you can pause indefinitely and resume where you left off.
|
|
31
31
|
|
|
32
|
-
- **Context management** - Give your agents the right context at the right time. Provide [conversation history](/docs/memory/conversation-history), [retrieve](/docs/rag/overview) data from your sources (APIs, databases, files), and add human-like [working](/docs/memory/working-memory) and [semantic](/docs/memory/semantic-recall) memory so your agents behave coherently.
|
|
32
|
+
- **Context management** - Give your agents the right context at the right time. Provide [conversation history](/docs/v1/memory/conversation-history), [retrieve](/docs/v1/rag/overview) data from your sources (APIs, databases, files), and add human-like [working](/docs/v1/memory/working-memory) and [semantic](/docs/v1/memory/semantic-recall) memory so your agents behave coherently.
|
|
33
33
|
|
|
34
34
|
- **Integrations** - Bundle agents and workflows into existing React, Next.js, or Node.js apps, or ship them as standalone endpoints. When building UIs, integrate with agentic libraries like Vercel's AI SDK UI and CopilotKit to bring your AI assistant to life on the web.
|
|
35
35
|
|
|
36
|
-
- **Production essentials** - Shipping reliable agents takes ongoing insight, evaluation, and iteration. With built-in [scorers](/docs/
|
|
36
|
+
- **Production essentials** - Shipping reliable agents takes ongoing insight, evaluation, and iteration. With built-in [scorers](/docs/v1/evals/overview) and [observability](/docs/v1/observability/overview), Mastra gives you the tools to observe, measure, and refine continuously.
|
|
37
37
|
|
|
38
38
|
## What can you build?
|
|
39
39
|
|
|
@@ -51,8 +51,8 @@ Explore real-world examples in our [community showcase](/showcase).
|
|
|
51
51
|
|
|
52
52
|
## Get started
|
|
53
53
|
|
|
54
|
-
Follow the [Installation guide](/docs/getting-started/installation) for step-by-step setup with the CLI or a manual install.
|
|
54
|
+
Follow the [Installation guide](/docs/v1/getting-started/installation) for step-by-step setup with the CLI or a manual install.
|
|
55
55
|
|
|
56
|
-
If you're new to AI agents, check out our [templates](/docs/getting-started/templates), [course](https://mastra.ai/book), and [YouTube videos](https://youtube.com/@mastra-ai) to start building with Mastra today.
|
|
56
|
+
If you're new to AI agents, check out our [templates](/docs/v1/getting-started/templates), [course](https://mastra.ai/book), and [YouTube videos](https://youtube.com/@mastra-ai) to start building with Mastra today.
|
|
57
57
|
|
|
58
58
|
We can't wait to see what you build ✌️
|
|
@@ -7,14 +7,14 @@ description: Learn how to use logging in Mastra to monitor execution, capture ap
|
|
|
7
7
|
|
|
8
8
|
Mastra's logging system captures function execution, input data, and output responses in a structured format.
|
|
9
9
|
|
|
10
|
-
When deploying to Mastra Cloud, logs are shown on the [Logs](
|
|
10
|
+
When deploying to Mastra Cloud, logs are shown on the [Logs](/docs/v1/mastra-cloud/observability) page. In self-hosted or custom environments, logs can be directed to files or external services depending on the configured transports.
|
|
11
11
|
|
|
12
12
|
## PinoLogger
|
|
13
13
|
|
|
14
|
-
When [initializing a new Mastra project](
|
|
14
|
+
When [initializing a new Mastra project](/docs/v1/getting-started/installation) using the CLI, `PinoLogger` is included by default.
|
|
15
15
|
|
|
16
16
|
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
17
|
-
import { Mastra } from "@mastra/core
|
|
17
|
+
import { Mastra } from "@mastra/core";
|
|
18
18
|
import { PinoLogger } from "@mastra/loggers";
|
|
19
19
|
|
|
20
20
|
export const mastra = new Mastra({
|
|
@@ -26,7 +26,7 @@ export const mastra = new Mastra({
|
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
> See the [PinoLogger](/reference/
|
|
29
|
+
> See the [PinoLogger](/reference/v1/logging/pino-logger) API reference for all available configuration options.
|
|
30
30
|
|
|
31
31
|
## Logging from workflows and tools
|
|
32
32
|
|
|
@@ -7,7 +7,7 @@ import { MastraCloudCallout } from "@site/src/components/MastraCloudCallout";
|
|
|
7
7
|
|
|
8
8
|
# Navigating the Dashboard
|
|
9
9
|
|
|
10
|
-
This page explains how to navigate the Mastra Cloud dashboard, where you can configure your project, view deployment details, and interact with agents and workflows using the built-in [Studio](/docs/mastra-cloud/dashboard#studio).
|
|
10
|
+
This page explains how to navigate the Mastra Cloud dashboard, where you can configure your project, view deployment details, and interact with agents and workflows using the built-in [Studio](/docs/v1/mastra-cloud/dashboard#studio).
|
|
11
11
|
|
|
12
12
|
<MastraCloudCallout />
|
|
13
13
|
|
|
@@ -97,4 +97,4 @@ Each MCP Server includes API endpoints for HTTP and SSE, along with IDE configur
|
|
|
97
97
|
|
|
98
98
|
## Next steps
|
|
99
99
|
|
|
100
|
-
- [Understanding Tracing and Logs](/docs/mastra-cloud/observability)
|
|
100
|
+
- [Understanding Tracing and Logs](/docs/v1/mastra-cloud/observability)
|
|
@@ -13,7 +13,7 @@ Mastra Cloud captures execution data to help you monitor your application's beha
|
|
|
13
13
|
|
|
14
14
|
## Logs
|
|
15
15
|
|
|
16
|
-
You can view detailed logs for debugging and monitoring your application's behavior on the [Logs](/docs/mastra-cloud/dashboard#logs) page of the Dashboard.
|
|
16
|
+
You can view detailed logs for debugging and monitoring your application's behavior on the [Logs](/docs/v1/mastra-cloud/dashboard#logs) page of the Dashboard.
|
|
17
17
|
|
|
18
18
|

|
|
19
19
|
|
|
@@ -23,11 +23,11 @@ Each log entry includes its severity level and a detailed message showing agent,
|
|
|
23
23
|
|
|
24
24
|
## Traces
|
|
25
25
|
|
|
26
|
-
More detailed traces are available for both agents and workflows by using a [logger](/docs/
|
|
26
|
+
More detailed traces are available for both agents and workflows by using a [logger](/docs/v1/logging) or enabling [observability](/docs/v1/observability/tracing/overview) using one of our [supported providers](/docs/v1/observability/tracing/overview#exporters).
|
|
27
27
|
|
|
28
28
|
### Agents
|
|
29
29
|
|
|
30
|
-
With a [logger](/docs/
|
|
30
|
+
With a [logger](/docs/v1/logging) enabled, you can view detailed outputs from your agents in the **Traces** section in Studio.
|
|
31
31
|
|
|
32
32
|

|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ Tools passed to the agent during generation are standardized using `convertTools
|
|
|
37
37
|
|
|
38
38
|
### Workflows
|
|
39
39
|
|
|
40
|
-
With a [logger](/docs/
|
|
40
|
+
With a [logger](/docs/v1/logging) enabled, you can view detailed outputs from your workflows in the **Traces** section in Studio.
|
|
41
41
|
|
|
42
42
|

|
|
43
43
|
|
|
@@ -47,5 +47,5 @@ Workflows are created using `createWorkflow`, which sets up steps, metadata, and
|
|
|
47
47
|
|
|
48
48
|
## Next steps
|
|
49
49
|
|
|
50
|
-
- [Logging](/docs/
|
|
51
|
-
- [Tracing](/docs/observability/
|
|
50
|
+
- [Logging](/docs/v1/logging)
|
|
51
|
+
- [Tracing](/docs/v1/observability/tracing/overview)
|
|
@@ -7,7 +7,7 @@ import { MastraCloudCallout } from "@site/src/components/MastraCloudCallout";
|
|
|
7
7
|
|
|
8
8
|
# Mastra Cloud
|
|
9
9
|
|
|
10
|
-
[Mastra Cloud](https://mastra.ai/cloud) is a platform for deploying, managing, monitoring, and debugging Mastra applications. When you [deploy](/docs/mastra-cloud/setting-up) your application, Mastra Cloud exposes your agents, tools, and workflows as REST API endpoints.
|
|
10
|
+
[Mastra Cloud](https://mastra.ai/cloud) is a platform for deploying, managing, monitoring, and debugging Mastra applications. When you [deploy](/docs/v1/mastra-cloud/setting-up) your application, Mastra Cloud exposes your agents, tools, and workflows as REST API endpoints.
|
|
11
11
|
|
|
12
12
|
<MastraCloudCallout />
|
|
13
13
|
|
|
@@ -62,4 +62,4 @@ Mastra Cloud is purpose-built for Mastra agents, tools, and workflows. It handle
|
|
|
62
62
|
|
|
63
63
|
## Next steps
|
|
64
64
|
|
|
65
|
-
- [Setting Up and Deploying](/docs/mastra-cloud/setting-up)
|
|
65
|
+
- [Setting Up and Deploying](/docs/v1/mastra-cloud/setting-up)
|
|
@@ -18,7 +18,7 @@ This page explains how to set up a project on [Mastra Cloud](https://mastra.ai/c
|
|
|
18
18
|
- A [Mastra Cloud](https://mastra.ai/cloud) account
|
|
19
19
|
- A GitHub account / repository containing a Mastra application
|
|
20
20
|
|
|
21
|
-
> See our [Getting started](/docs/getting-started/installation) guide to scaffold out a new Mastra project with sensible defaults.
|
|
21
|
+
> See our [Getting started](/docs/v1/getting-started/installation) guide to scaffold out a new Mastra project with sensible defaults.
|
|
22
22
|
|
|
23
23
|
## Setup and Deploy process
|
|
24
24
|
|
|
@@ -73,7 +73,7 @@ Mastra Cloud automatically detects the right build settings, but you can customi
|
|
|
73
73
|
- **Install command**: Runs pre-build to install project dependencies
|
|
74
74
|
- **Project setup command**: Runs pre-build to prepare any external dependencies
|
|
75
75
|
- **Port**: The network port the server will use
|
|
76
|
-
- **Store settings**: Use Mastra Cloud's built-in [LibSQLStore](/docs/server-db/storage) storage
|
|
76
|
+
- **Store settings**: Use Mastra Cloud's built-in [LibSQLStore](/docs/v1/server-db/storage) storage
|
|
77
77
|
- **Deploy Project**: Starts the deployment process
|
|
78
78
|
|
|
79
79
|
</StepItem>
|
|
@@ -98,8 +98,8 @@ Your project is now configured with automatic deployments which occur whenever y
|
|
|
98
98
|
|
|
99
99
|
## Testing your application
|
|
100
100
|
|
|
101
|
-
After a successful deployment you can test your agents and workflows [Studio](/docs/mastra-cloud/dashboard#studio) in Mastra Cloud, or interact with them using our [Client SDK](/docs/server-db/mastra-client).
|
|
101
|
+
After a successful deployment you can test your agents and workflows [Studio](/docs/v1/mastra-cloud/dashboard#studio) in Mastra Cloud, or interact with them using our [Client SDK](/docs/v1/server-db/mastra-client).
|
|
102
102
|
|
|
103
103
|
## Next steps
|
|
104
104
|
|
|
105
|
-
- [Navigating the Dashboard](/docs/mastra-cloud/dashboard)
|
|
105
|
+
- [Navigating the Dashboard](/docs/v1/mastra-cloud/dashboard)
|
|
@@ -24,6 +24,8 @@ import { Agent } from "@mastra/core/agent";
|
|
|
24
24
|
import { openai } from "@ai-sdk/openai";
|
|
25
25
|
|
|
26
26
|
const agent = new Agent({
|
|
27
|
+
id: "test-agent",
|
|
28
|
+
name: "Test Agent",
|
|
27
29
|
model: openai("gpt-4o"),
|
|
28
30
|
memory: new Memory({
|
|
29
31
|
processors: [
|
|
@@ -103,9 +105,8 @@ const memoryWithMultipleProcessors = new Memory({
|
|
|
103
105
|
You can create custom logic by extending the base `MemoryProcessor` class.
|
|
104
106
|
|
|
105
107
|
```typescript copy showLineNumbers {5-20,24-27}
|
|
106
|
-
import { Memory } from "@mastra/memory";
|
|
107
|
-
import { CoreMessage
|
|
108
|
-
import { MemoryProcessor } from "@mastra/core/memory";
|
|
108
|
+
import { Memory, MemoryProcessorOpts, MemoryProcessor } from "@mastra/memory";
|
|
109
|
+
import { CoreMessage } from "@mastra/core/llm";
|
|
109
110
|
|
|
110
111
|
class ConversationOnlyFilter extends MemoryProcessor {
|
|
111
112
|
constructor() {
|
|
@@ -16,18 +16,19 @@ Mastra's memory system uses [storage providers](#memory-storage-adapters) to per
|
|
|
16
16
|
First install the required dependencies:
|
|
17
17
|
|
|
18
18
|
```bash copy
|
|
19
|
-
npm install @mastra/core @mastra/memory @mastra/libsql
|
|
19
|
+
npm install @mastra/core@beta @mastra/memory@beta @mastra/libsql@beta
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Then add a storage adapter to the main Mastra instance. Any agent with memory enabled will use this shared storage to store and recall interactions.
|
|
23
23
|
|
|
24
24
|
```typescript {6-8} title="src/mastra/index.ts" showLineNumbers copy
|
|
25
|
-
import { Mastra } from "@mastra/core
|
|
25
|
+
import { Mastra } from "@mastra/core";
|
|
26
26
|
import { LibSQLStore } from "@mastra/libsql";
|
|
27
27
|
|
|
28
28
|
export const mastra = new Mastra({
|
|
29
29
|
// ...
|
|
30
30
|
storage: new LibSQLStore({
|
|
31
|
+
id: 'mastra-storage',
|
|
31
32
|
url: ":memory:",
|
|
32
33
|
}),
|
|
33
34
|
});
|
|
@@ -40,6 +41,7 @@ import { Memory } from "@mastra/memory";
|
|
|
40
41
|
import { Agent } from "@mastra/core/agent";
|
|
41
42
|
|
|
42
43
|
export const testAgent = new Agent({
|
|
44
|
+
id: "test-agent",
|
|
43
45
|
// ...
|
|
44
46
|
memory: new Memory(),
|
|
45
47
|
});
|
|
@@ -61,13 +63,13 @@ Mastra combines all memory types into a single context window. If the total exce
|
|
|
61
63
|
|
|
62
64
|
## Scoping memory with threads and resources
|
|
63
65
|
|
|
64
|
-
All memory types are [
|
|
66
|
+
All memory types are [resource-scoped](./working-memory#resource-scoped-memory-default) by default, meaning they persist across all conversations for the same user or entity. [Thread-scoped](./working-memory#thread-scoped-memory) configuration isolates memory to a single conversation thread.
|
|
65
67
|
|
|
66
68
|
## Memory Storage Adapters
|
|
67
69
|
|
|
68
70
|
To persist and recall information between conversations, memory requires a storage adapter.
|
|
69
71
|
|
|
70
|
-
Supported options include [LibSQL](/docs/memory/storage/memory-with-libsql), [MongoDB](/examples/memory/memory-with-mongodb), [Postgres](/docs/memory/storage/memory-with-pg), and [Upstash](/docs/memory/storage/memory-with-upstash)
|
|
72
|
+
Supported options include [LibSQL](/docs/v1/memory/storage/memory-with-libsql), [MongoDB](/examples/v1/memory/memory-with-mongodb), [Postgres](/docs/v1/memory/storage/memory-with-pg), and [Upstash](/docs/v1/memory/storage/memory-with-upstash)
|
|
71
73
|
|
|
72
74
|
We use LibSQL out of the box because it is file-based or in-memory, so it is easy to install and works well with Studio.
|
|
73
75
|
|
|
@@ -85,10 +87,12 @@ import { Agent } from "@mastra/core/agent";
|
|
|
85
87
|
import { LibSQLStore } from "@mastra/libsql";
|
|
86
88
|
|
|
87
89
|
export const testAgent = new Agent({
|
|
90
|
+
id: "test-agent",
|
|
88
91
|
// ...
|
|
89
92
|
memory: new Memory({
|
|
90
93
|
// ...
|
|
91
94
|
storage: new LibSQLStore({
|
|
95
|
+
id: 'test-agent-storage',
|
|
92
96
|
url: "file:agent-memory.db",
|
|
93
97
|
}),
|
|
94
98
|
// ...
|
|
@@ -102,7 +106,7 @@ If tracing is enabled in your Mastra deployment and memory is configured either
|
|
|
102
106
|
|
|
103
107
|
This is helpful for debugging, understanding agent decisions, and verifying that the agent is retrieving the right information for each request.
|
|
104
108
|
|
|
105
|
-
For more details on enabling and configuring tracing, see [
|
|
109
|
+
For more details on enabling and configuring tracing, see [Tracing](../observability/tracing/overview).
|
|
106
110
|
|
|
107
111
|
## Local development with LibSQL
|
|
108
112
|
|
|
@@ -114,4 +118,4 @@ For local development with `LibSQLStore`, you can inspect stored memory using th
|
|
|
114
118
|
|
|
115
119
|
Now that you understand the core concepts, continue to [semantic recall](./semantic-recall) to learn how to add RAG memory to your Mastra agents.
|
|
116
120
|
|
|
117
|
-
Alternatively you can visit the [configuration reference](/reference/memory/memory-class) for available options.
|
|
121
|
+
Alternatively you can visit the [configuration reference](/reference/v1/memory/memory-class) for available options.
|
|
@@ -36,6 +36,7 @@ import { Memory } from "@mastra/memory";
|
|
|
36
36
|
import { openai } from "@ai-sdk/openai";
|
|
37
37
|
|
|
38
38
|
const agent = new Agent({
|
|
39
|
+
id: "support-agent",
|
|
39
40
|
name: "SupportAgent",
|
|
40
41
|
instructions: "You are a helpful support agent.",
|
|
41
42
|
model: openai("gpt-4o"),
|
|
@@ -67,7 +68,7 @@ const agent = new Agent({
|
|
|
67
68
|
|
|
68
69
|
### Storage configuration
|
|
69
70
|
|
|
70
|
-
Semantic recall relies on a [storage and vector db](/reference/memory/memory-class) to store messages and their embeddings.
|
|
71
|
+
Semantic recall relies on a [storage and vector db](/reference/v1/memory/memory-class) to store messages and their embeddings.
|
|
71
72
|
|
|
72
73
|
```ts {8-17}
|
|
73
74
|
import { Memory } from "@mastra/memory";
|
|
@@ -78,10 +79,12 @@ const agent = new Agent({
|
|
|
78
79
|
memory: new Memory({
|
|
79
80
|
// this is the default storage db if omitted
|
|
80
81
|
storage: new LibSQLStore({
|
|
82
|
+
id: 'agent-storage',
|
|
81
83
|
url: "file:./local.db",
|
|
82
84
|
}),
|
|
83
85
|
// this is the default vector db if omitted
|
|
84
86
|
vector: new LibSQLVector({
|
|
87
|
+
id: 'agent-vector',
|
|
85
88
|
connectionUrl: "file:./local.db",
|
|
86
89
|
}),
|
|
87
90
|
}),
|
|
@@ -90,14 +93,14 @@ const agent = new Agent({
|
|
|
90
93
|
|
|
91
94
|
**Storage/vector code Examples**:
|
|
92
95
|
|
|
93
|
-
- [LibSQL](/docs/memory/storage/memory-with-libsql)
|
|
94
|
-
- [MongoDB](/examples/memory/memory-with-mongodb)
|
|
95
|
-
- [Postgres](/docs/memory/storage/memory-with-pg)
|
|
96
|
-
- [Upstash](/docs/memory/storage/memory-with-upstash)
|
|
96
|
+
- [LibSQL](/docs/v1/memory/storage/memory-with-libsql)
|
|
97
|
+
- [MongoDB](/examples/v1/memory/memory-with-mongodb)
|
|
98
|
+
- [Postgres](/docs/v1/memory/storage/memory-with-pg)
|
|
99
|
+
- [Upstash](/docs/v1/memory/storage/memory-with-upstash)
|
|
97
100
|
|
|
98
101
|
### Embedder configuration
|
|
99
102
|
|
|
100
|
-
Semantic recall relies on an [embedding model](/reference/memory/memory-class) to convert messages into embeddings. Mastra supports embedding models through the model router using `provider/model` strings, or you can use any [embedding model](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings) compatible with the AI SDK.
|
|
103
|
+
Semantic recall relies on an [embedding model](/reference/v1/memory/memory-class) to convert messages into embeddings. Mastra supports embedding models through the model router using `provider/model` strings, or you can use any [embedding model](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings) compatible with the AI SDK.
|
|
101
104
|
|
|
102
105
|
#### Using the Model Router (Recommended)
|
|
103
106
|
|
|
@@ -144,7 +147,7 @@ const agent = new Agent({
|
|
|
144
147
|
To use FastEmbed (a local embedding model), install `@mastra/fastembed`:
|
|
145
148
|
|
|
146
149
|
```bash npm2yarn copy
|
|
147
|
-
npm install @mastra/fastembed
|
|
150
|
+
npm install @mastra/fastembed@beta
|
|
148
151
|
```
|
|
149
152
|
|
|
150
153
|
Then configure it in your memory:
|
|
@@ -175,9 +178,11 @@ import { PgStore, PgVector } from "@mastra/pg";
|
|
|
175
178
|
const agent = new Agent({
|
|
176
179
|
memory: new Memory({
|
|
177
180
|
storage: new PgStore({
|
|
181
|
+
id: 'agent-storage',
|
|
178
182
|
connectionString: process.env.DATABASE_URL,
|
|
179
183
|
}),
|
|
180
184
|
vector: new PgVector({
|
|
185
|
+
id: 'agent-vector',
|
|
181
186
|
connectionString: process.env.DATABASE_URL,
|
|
182
187
|
}),
|
|
183
188
|
options: {
|
|
@@ -196,7 +201,7 @@ const agent = new Agent({
|
|
|
196
201
|
});
|
|
197
202
|
```
|
|
198
203
|
|
|
199
|
-
For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](/reference/vectors/pg#index-configuration-guide).
|
|
204
|
+
For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](/reference/v1/vectors/pg#index-configuration-guide).
|
|
200
205
|
|
|
201
206
|
### Disabling
|
|
202
207
|
|