@mastra/mcp-docs-server 1.0.0-beta.1 → 1.0.0-beta.10
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%2Fchangeset-cli.md +1 -15
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -7
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -55
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +250 -50
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +89 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +393 -193
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +234 -34
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +128 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +244 -44
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-elements.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-useChat.md +2 -2
- package/.docs/organized/code-examples/ai-sdk-v5.md +3 -2
- package/.docs/organized/code-examples/assistant-ui.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +2 -2
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +2 -2
- package/.docs/organized/code-examples/client-side-tools.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +2 -2
- package/.docs/organized/code-examples/fireworks-r1.md +1 -1
- package/.docs/organized/code-examples/heads-up-game.md +1 -1
- package/.docs/organized/code-examples/mcp-configuration.md +0 -3
- package/.docs/organized/code-examples/mcp-server-adapters.md +720 -0
- package/.docs/organized/code-examples/memory-per-resource-example.md +1 -1
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
- package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
- package/.docs/organized/code-examples/quick-start.md +2 -2
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/organized/code-examples/server-express-adapter.md +87 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
- package/.docs/organized/code-examples/stock-price-tool.md +1 -21
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
- package/.docs/raw/agents/adding-voice.mdx +56 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/agent-memory.mdx +1 -1
- package/.docs/raw/agents/guardrails.mdx +27 -24
- package/.docs/raw/agents/networks.mdx +3 -3
- package/.docs/raw/agents/overview.mdx +18 -167
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/structured-output.mdx +224 -0
- package/.docs/raw/agents/using-tools.mdx +14 -14
- package/.docs/raw/auth/auth0.mdx +1 -1
- package/.docs/raw/auth/clerk.mdx +1 -1
- package/.docs/raw/auth/firebase.mdx +1 -1
- package/.docs/raw/auth/index.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +1 -1
- package/.docs/raw/auth/supabase.mdx +1 -1
- package/.docs/raw/auth/workos.mdx +1 -1
- package/.docs/raw/community/contributing-templates.mdx +1 -1
- package/.docs/raw/community/discord.mdx +2 -2
- package/.docs/raw/community/licensing.mdx +1 -1
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/{server-deployment.mdx → building-mastra.mdx} +4 -4
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +2 -2
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +3 -3
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +2 -2
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/cloudflare-deployer.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +2 -2
- package/.docs/raw/deployment/cloud-providers/index.mdx +26 -29
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/netlify-deployer.mdx +45 -14
- package/.docs/raw/deployment/{serverless-platforms → cloud-providers}/vercel-deployer.mdx +1 -1
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/dashboard.mdx +3 -3
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +53 -0
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/overview.mdx +3 -3
- package/.docs/raw/{mastra-cloud → deployment/mastra-cloud}/setting-up.mdx +4 -4
- package/.docs/raw/deployment/monorepo.mdx +3 -3
- package/.docs/raw/deployment/overview.mdx +7 -7
- package/.docs/raw/deployment/web-framework.mdx +6 -6
- package/.docs/raw/evals/{off-the-shelf-scorers.mdx → built-in-scorers.mdx} +17 -15
- package/.docs/raw/evals/custom-scorers.mdx +4 -6
- package/.docs/raw/evals/overview.mdx +5 -6
- package/.docs/raw/evals/running-in-ci.mdx +2 -4
- package/.docs/raw/getting-started/{installation.mdx → manual-install.mdx} +6 -80
- package/.docs/raw/getting-started/mcp-docs-server.mdx +6 -6
- package/.docs/raw/getting-started/project-structure.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +8 -6
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +147 -0
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +627 -0
- package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +71 -19
- package/.docs/raw/guides/build-your-ui/copilotkit.mdx +206 -0
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +24 -26
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +4 -5
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +26 -25
- package/.docs/raw/guides/getting-started/quickstart.mdx +97 -0
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +24 -26
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +119 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +51 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +42 -2
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +31 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +27 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +28 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +25 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +80 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +68 -3
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +25 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +174 -1
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +3 -3
- package/.docs/raw/mcp/overview.mdx +358 -0
- package/.docs/raw/mcp/publishing-mcp-server.mdx +139 -0
- package/.docs/raw/memory/conversation-history.mdx +1 -1
- package/.docs/raw/memory/memory-processors.mdx +265 -80
- package/.docs/raw/memory/overview.mdx +2 -2
- package/.docs/raw/memory/semantic-recall.mdx +9 -9
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +3 -8
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +150 -0
- package/.docs/raw/memory/storage/memory-with-pg.mdx +3 -8
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +3 -8
- package/.docs/raw/memory/threads-and-resources.mdx +4 -4
- package/.docs/raw/memory/working-memory.mdx +16 -8
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +7 -7
- package/.docs/raw/observability/overview.mdx +3 -4
- package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +37 -1
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +20 -1
- package/.docs/raw/observability/tracing/exporters/cloud.mdx +2 -2
- package/.docs/raw/observability/tracing/exporters/default.mdx +1 -1
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +84 -1
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +13 -1
- package/.docs/raw/observability/tracing/exporters/otel.mdx +123 -25
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +127 -0
- package/.docs/raw/observability/tracing/overview.mdx +80 -9
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +1 -2
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +4 -3
- package/.docs/raw/rag/retrieval.mdx +44 -39
- package/.docs/raw/rag/vector-databases.mdx +94 -3
- package/.docs/raw/reference/agents/agent.mdx +8 -12
- package/.docs/raw/reference/agents/generate.mdx +67 -99
- package/.docs/raw/reference/agents/generateLegacy.mdx +3 -3
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +1 -1
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +1 -1
- package/.docs/raw/reference/agents/getLLM.mdx +2 -2
- package/.docs/raw/reference/agents/getMemory.mdx +1 -1
- package/.docs/raw/reference/agents/getModel.mdx +1 -1
- package/.docs/raw/reference/agents/getTools.mdx +69 -0
- package/.docs/raw/reference/agents/getVoice.mdx +1 -1
- package/.docs/raw/reference/agents/listAgents.mdx +1 -1
- package/.docs/raw/reference/agents/listScorers.mdx +1 -1
- package/.docs/raw/reference/agents/listTools.mdx +2 -2
- package/.docs/raw/reference/agents/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +33 -72
- package/.docs/raw/reference/ai-sdk/chat-route.mdx +127 -0
- package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +117 -0
- package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +64 -0
- package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +116 -0
- package/.docs/raw/reference/ai-sdk/network-route.mdx +99 -0
- package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +289 -0
- package/.docs/raw/reference/ai-sdk/with-mastra.mdx +119 -0
- package/.docs/raw/reference/ai-sdk/workflow-route.mdx +110 -0
- package/.docs/raw/reference/auth/auth0.mdx +1 -1
- package/.docs/raw/reference/auth/clerk.mdx +1 -1
- package/.docs/raw/reference/auth/firebase.mdx +1 -1
- package/.docs/raw/reference/auth/jwt.mdx +1 -1
- package/.docs/raw/reference/auth/supabase.mdx +1 -1
- package/.docs/raw/reference/auth/workos.mdx +1 -1
- package/.docs/raw/reference/cli/create-mastra.mdx +1 -1
- package/.docs/raw/reference/cli/mastra.mdx +19 -6
- package/.docs/raw/reference/client-js/agents.mdx +252 -68
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +4 -4
- package/.docs/raw/reference/client-js/memory.mdx +48 -2
- package/.docs/raw/reference/client-js/observability.mdx +1 -1
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +1 -1
- package/.docs/raw/reference/client-js/vectors.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +93 -64
- package/.docs/raw/reference/core/addGateway.mdx +59 -0
- 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/getGateway.mdx +59 -0
- package/.docs/raw/reference/core/getGatewayById.mdx +62 -0
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServerById.mdx +2 -2
- package/.docs/raw/reference/core/getMemory.mdx +73 -0
- package/.docs/raw/reference/core/getScorer.mdx +1 -1
- package/.docs/raw/reference/core/getScorerById.mdx +1 -1
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +1 -1
- package/.docs/raw/reference/core/getStoredAgentById.mdx +183 -0
- 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/listGateways.mdx +53 -0
- 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 +2 -2
- package/.docs/raw/reference/core/listMemory.mdx +70 -0
- package/.docs/raw/reference/core/listScorers.mdx +1 -1
- package/.docs/raw/reference/core/listStoredAgents.mdx +151 -0
- package/.docs/raw/reference/core/listVectors.mdx +1 -1
- package/.docs/raw/reference/core/listWorkflows.mdx +1 -1
- package/.docs/raw/reference/core/mastra-class.mdx +17 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +227 -0
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +1 -1
- package/.docs/raw/reference/deployer/deployer.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +2 -3
- package/.docs/raw/reference/deployer/vercel.mdx +1 -1
- package/.docs/raw/reference/evals/answer-relevancy.mdx +29 -99
- package/.docs/raw/reference/evals/answer-similarity.mdx +13 -259
- package/.docs/raw/reference/evals/bias.mdx +30 -88
- package/.docs/raw/reference/evals/completeness.mdx +32 -91
- package/.docs/raw/reference/evals/content-similarity.mdx +29 -89
- package/.docs/raw/reference/evals/context-precision.mdx +29 -131
- package/.docs/raw/reference/evals/context-relevance.mdx +12 -12
- package/.docs/raw/reference/evals/create-scorer.mdx +1 -1
- package/.docs/raw/reference/evals/faithfulness.mdx +29 -102
- package/.docs/raw/reference/evals/hallucination.mdx +29 -104
- package/.docs/raw/reference/evals/keyword-coverage.mdx +29 -108
- package/.docs/raw/reference/evals/mastra-scorer.mdx +1 -1
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +12 -12
- package/.docs/raw/reference/evals/prompt-alignment.mdx +16 -16
- package/.docs/raw/reference/evals/run-evals.mdx +1 -1
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +28 -101
- package/.docs/raw/reference/evals/tone-consistency.mdx +26 -99
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +8 -8
- package/.docs/raw/reference/evals/toxicity.mdx +30 -93
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/logging/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +1 -1
- package/.docs/raw/reference/memory/deleteMessages.mdx +1 -1
- package/.docs/raw/reference/memory/getThreadById.mdx +1 -1
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +1 -1
- package/.docs/raw/reference/memory/memory-class.mdx +6 -8
- package/.docs/raw/reference/memory/query.mdx +1 -1
- package/.docs/raw/reference/memory/recall.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +1 -5
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +30 -1
- package/.docs/raw/reference/observability/tracing/exporters/braintrust.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/cloud-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/console-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/default-exporter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +44 -1
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +18 -2
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +34 -44
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +1 -5
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +30 -5
- package/.docs/raw/reference/observability/tracing/processors/sensitive-data-filter.mdx +1 -1
- package/.docs/raw/reference/observability/tracing/spans.mdx +1 -5
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +2 -2
- package/.docs/raw/reference/processors/language-detector.mdx +11 -4
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +13 -6
- package/.docs/raw/reference/processors/pii-detector.mdx +13 -6
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +11 -4
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +4 -5
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +3 -3
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +2 -2
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/chunk.mdx +1 -1
- package/.docs/raw/reference/rag/database-config.mdx +1 -1
- package/.docs/raw/reference/rag/document.mdx +1 -1
- package/.docs/raw/reference/rag/embeddings.mdx +6 -6
- package/.docs/raw/reference/rag/extract-params.mdx +1 -1
- package/.docs/raw/reference/rag/graph-rag.mdx +1 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +1 -1
- package/.docs/raw/reference/rag/rerank.mdx +2 -3
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +1 -2
- package/.docs/raw/reference/server/create-route.mdx +328 -0
- package/.docs/raw/reference/server/express-adapter.mdx +260 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +242 -0
- package/.docs/raw/reference/server/mastra-server.mdx +345 -0
- package/.docs/raw/reference/server/routes.mdx +250 -0
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +38 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/dynamodb.mdx +1 -1
- package/.docs/raw/reference/storage/lance.mdx +34 -1
- package/.docs/raw/reference/storage/libsql.mdx +38 -1
- package/.docs/raw/reference/storage/mongodb.mdx +40 -1
- package/.docs/raw/reference/storage/mssql.mdx +38 -1
- package/.docs/raw/reference/storage/postgresql.mdx +38 -1
- package/.docs/raw/reference/storage/upstash.mdx +1 -1
- package/.docs/raw/reference/streaming/ChunkType.mdx +2 -2
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +68 -95
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +1 -1
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +8 -10
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +84 -25
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
- package/.docs/raw/reference/templates/overview.mdx +2 -5
- package/.docs/raw/reference/tools/client.mdx +2 -3
- package/.docs/raw/reference/tools/create-tool.mdx +135 -4
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +1 -1
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +7 -7
- package/.docs/raw/reference/tools/mcp-client.mdx +131 -23
- package/.docs/raw/reference/tools/mcp-server.mdx +56 -8
- package/.docs/raw/reference/tools/vector-query-tool.mdx +16 -17
- package/.docs/raw/reference/vectors/astra.mdx +1 -1
- package/.docs/raw/reference/vectors/chroma.mdx +82 -2
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +25 -18
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +39 -23
- package/.docs/raw/reference/vectors/libsql.mdx +36 -3
- package/.docs/raw/reference/vectors/mongodb.mdx +36 -3
- package/.docs/raw/reference/vectors/opensearch.mdx +38 -17
- package/.docs/raw/reference/vectors/pg.mdx +44 -37
- package/.docs/raw/reference/vectors/pinecone.mdx +70 -3
- package/.docs/raw/reference/vectors/qdrant.mdx +37 -2
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +75 -1
- package/.docs/raw/reference/vectors/upstash.mdx +1 -1
- package/.docs/raw/reference/vectors/vectorize.mdx +1 -1
- package/.docs/raw/reference/voice/azure.mdx +96 -81
- package/.docs/raw/reference/voice/cloudflare.mdx +1 -1
- package/.docs/raw/reference/voice/composite-voice.mdx +72 -29
- package/.docs/raw/reference/voice/deepgram.mdx +1 -1
- package/.docs/raw/reference/voice/elevenlabs.mdx +1 -1
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/google.mdx +160 -21
- package/.docs/raw/reference/voice/mastra-voice.mdx +1 -1
- package/.docs/raw/reference/voice/murf.mdx +1 -1
- package/.docs/raw/reference/voice/openai-realtime.mdx +3 -3
- package/.docs/raw/reference/voice/openai.mdx +1 -1
- package/.docs/raw/reference/voice/playai.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +1 -1
- package/.docs/raw/reference/voice/speechify.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +3 -4
- package/.docs/raw/reference/voice/voice.addTools.mdx +2 -2
- package/.docs/raw/reference/voice/voice.answer.mdx +2 -2
- package/.docs/raw/reference/voice/voice.close.mdx +2 -2
- package/.docs/raw/reference/voice/voice.connect.mdx +2 -2
- package/.docs/raw/reference/voice/voice.events.mdx +1 -1
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +1 -1
- package/.docs/raw/reference/voice/voice.listen.mdx +87 -53
- package/.docs/raw/reference/voice/voice.off.mdx +2 -2
- package/.docs/raw/reference/voice/voice.on.mdx +2 -2
- package/.docs/raw/reference/voice/voice.send.mdx +2 -2
- package/.docs/raw/reference/voice/voice.speak.mdx +76 -41
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +2 -2
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +45 -1
- package/.docs/raw/reference/workflows/run-methods/start.mdx +48 -4
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
- package/.docs/raw/reference/workflows/run.mdx +28 -6
- package/.docs/raw/reference/workflows/step.mdx +65 -1
- 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 +1 -1
- 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 +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +1 -1
- 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 +21 -2
- package/.docs/raw/server-db/custom-adapters.mdx +386 -0
- package/.docs/raw/server-db/custom-api-routes.mdx +6 -6
- package/.docs/raw/server-db/mastra-client.mdx +3 -4
- package/.docs/raw/server-db/{production-server.mdx → mastra-server.mdx} +16 -8
- package/.docs/raw/server-db/middleware.mdx +31 -31
- package/.docs/raw/server-db/request-context.mdx +3 -4
- package/.docs/raw/server-db/server-adapters.mdx +312 -0
- package/.docs/raw/server-db/storage.mdx +12 -1
- package/.docs/raw/streaming/events.mdx +1 -1
- package/.docs/raw/streaming/overview.mdx +27 -16
- package/.docs/raw/streaming/tool-streaming.mdx +58 -19
- package/.docs/raw/streaming/workflow-streaming.mdx +6 -12
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -3
- package/.docs/raw/tools-mcp/mcp-overview.mdx +4 -6
- package/.docs/raw/tools-mcp/overview.mdx +1 -1
- package/.docs/raw/voice/overview.mdx +88 -41
- package/.docs/raw/voice/speech-to-speech.mdx +5 -5
- package/.docs/raw/voice/speech-to-text.mdx +2 -3
- package/.docs/raw/voice/text-to-speech.mdx +2 -3
- package/.docs/raw/workflows/agents-and-tools.mdx +43 -5
- package/.docs/raw/workflows/control-flow.mdx +186 -1
- package/.docs/raw/workflows/error-handling.mdx +5 -4
- package/.docs/raw/workflows/human-in-the-loop.mdx +160 -213
- package/.docs/raw/workflows/inngest-workflow.mdx +1 -1
- package/.docs/raw/workflows/input-data-mapping.mdx +1 -1
- package/.docs/raw/workflows/overview.mdx +67 -47
- package/.docs/raw/workflows/snapshots.mdx +5 -3
- package/.docs/raw/workflows/suspend-and-resume.mdx +121 -204
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +190 -0
- package/CHANGELOG.md +81 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +17 -19
- package/package.json +11 -15
- package/.docs/raw/deployment/serverless-platforms/index.mdx +0 -58
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +0 -688
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -123
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +0 -382
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/templates.mdx +0 -73
- package/.docs/raw/mastra-cloud/observability.mdx +0 -51
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "WhatsApp Chat Bot"
|
|
3
|
+
description: Create a WhatsApp chat bot using Mastra agents and workflows to handle incoming messages and respond naturally via text messages.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WhatsApp Chat Bot
|
|
7
|
+
|
|
8
|
+
This guide demonstrates how to create a WhatsApp chat bot using Mastra agents and workflows. The bot receives incoming WhatsApp messages via webhook, processes them through an AI agent, breaks responses into natural text messages, and sends them back via the WhatsApp Business API.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
This example requires a WhatsApp Business API setup and uses the `anthropic` model. Add these environment variables to your `.env` file:
|
|
13
|
+
|
|
14
|
+
```bash title=".env" copy
|
|
15
|
+
ANTHROPIC_API_KEY=<your-anthropic-api-key>
|
|
16
|
+
WHATSAPP_VERIFY_TOKEN=<your-verify-token>
|
|
17
|
+
WHATSAPP_ACCESS_TOKEN=<your-whatsapp-access-token>
|
|
18
|
+
WHATSAPP_BUSINESS_PHONE_NUMBER_ID=<your-phone-number-id>
|
|
19
|
+
WHATSAPP_API_VERSION=v22.0
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Creating the WhatsApp client
|
|
23
|
+
|
|
24
|
+
This client handles sending messages to users via the WhatsApp Business API.
|
|
25
|
+
|
|
26
|
+
```typescript title="src/whatsapp-client.ts" showLineNumbers copy
|
|
27
|
+
// Simple WhatsApp Business API client for sending messages
|
|
28
|
+
|
|
29
|
+
interface SendMessageParams {
|
|
30
|
+
to: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function sendWhatsAppMessage({ to, message }: SendMessageParams) {
|
|
35
|
+
// Get environment variables for WhatsApp API
|
|
36
|
+
const apiVersion = process.env.WHATSAPP_API_VERSION || "v22.0";
|
|
37
|
+
const phoneNumberId = process.env.WHATSAPP_BUSINESS_PHONE_NUMBER_ID;
|
|
38
|
+
const accessToken = process.env.WHATSAPP_ACCESS_TOKEN;
|
|
39
|
+
|
|
40
|
+
// Check if required environment variables are set
|
|
41
|
+
if (!phoneNumberId || !accessToken) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// WhatsApp Business API endpoint
|
|
46
|
+
const url = `https://graph.facebook.com/${apiVersion}/${phoneNumberId}/messages`;
|
|
47
|
+
|
|
48
|
+
// Message payload following WhatsApp API format
|
|
49
|
+
const payload = {
|
|
50
|
+
messaging_product: "whatsapp",
|
|
51
|
+
recipient_type: "individual",
|
|
52
|
+
to: to,
|
|
53
|
+
type: "text",
|
|
54
|
+
text: {
|
|
55
|
+
body: message,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
// Send message via WhatsApp Business API
|
|
61
|
+
const response = await fetch(url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "application/json",
|
|
65
|
+
Authorization: `Bearer ${accessToken}`,
|
|
66
|
+
},
|
|
67
|
+
body: JSON.stringify(payload),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = await response.json();
|
|
71
|
+
|
|
72
|
+
if (response.ok) {
|
|
73
|
+
console.log(`✅ WhatsApp message sent to ${to}: "${message}"`);
|
|
74
|
+
return true;
|
|
75
|
+
} else {
|
|
76
|
+
console.error("❌ Failed to send WhatsApp message:", result);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error("❌ Error sending WhatsApp message:", error);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Creating the chat agent
|
|
87
|
+
|
|
88
|
+
This agent handles the main conversation logic with a friendly, conversational personality.
|
|
89
|
+
|
|
90
|
+
```typescript title="src/mastra/agents/chat-agent.ts" showLineNumbers copy
|
|
91
|
+
import { Agent } from "@mastra/core/agent";
|
|
92
|
+
import { Memory } from "@mastra/memory";
|
|
93
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
94
|
+
|
|
95
|
+
export const chatAgent = new Agent({
|
|
96
|
+
id: "chat-agent",
|
|
97
|
+
name: "Chat Agent",
|
|
98
|
+
instructions: `
|
|
99
|
+
You are a helpful, friendly, and knowledgeable AI assistant that loves to chat with users via WhatsApp.
|
|
100
|
+
|
|
101
|
+
Your personality:
|
|
102
|
+
- Warm, approachable, and conversational
|
|
103
|
+
- Enthusiastic about helping with any topic
|
|
104
|
+
- Use a casual, friendly tone like you're chatting with a friend
|
|
105
|
+
- Be concise but informative
|
|
106
|
+
- Show genuine interest in the user's questions
|
|
107
|
+
|
|
108
|
+
Your capabilities:
|
|
109
|
+
- Answer questions on a wide variety of topics
|
|
110
|
+
- Provide helpful advice and suggestions
|
|
111
|
+
- Engage in casual conversation
|
|
112
|
+
- Help with problem-solving and creative tasks
|
|
113
|
+
- Explain complex topics in simple terms
|
|
114
|
+
|
|
115
|
+
Guidelines:
|
|
116
|
+
- Keep responses informative but not overwhelming
|
|
117
|
+
- Ask follow-up questions when appropriate
|
|
118
|
+
- Be encouraging and positive
|
|
119
|
+
- If you don't know something, admit it honestly
|
|
120
|
+
- Adapt your communication style to match the user's tone
|
|
121
|
+
- Remember this is WhatsApp, so keep it conversational and natural
|
|
122
|
+
|
|
123
|
+
Always aim to be helpful while maintaining a friendly, approachable conversation style.
|
|
124
|
+
`,
|
|
125
|
+
model: "anthropic/claude-4-sonnet-20250514",
|
|
126
|
+
memory: new Memory({
|
|
127
|
+
storage: new LibSQLStore({
|
|
128
|
+
id: 'agent-storage',
|
|
129
|
+
url: "file:../mastra.db",
|
|
130
|
+
}),
|
|
131
|
+
}),
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Creating the text message agent
|
|
136
|
+
|
|
137
|
+
This agent converts longer responses into natural, bite-sized text messages suitable for WhatsApp.
|
|
138
|
+
|
|
139
|
+
```typescript title="src/mastra/agents/text-message-agent.ts" showLineNumbers copy
|
|
140
|
+
import { Agent } from "@mastra/core/agent";
|
|
141
|
+
import { Memory } from "@mastra/memory";
|
|
142
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
143
|
+
|
|
144
|
+
export const textMessageAgent = new Agent({
|
|
145
|
+
id: "text-message-agent",
|
|
146
|
+
name: "Text Message Agent",
|
|
147
|
+
instructions: `
|
|
148
|
+
You are a text message converter that takes formal or lengthy text and breaks it down into natural, casual text messages.
|
|
149
|
+
|
|
150
|
+
Your job is to:
|
|
151
|
+
- Convert any input text into 5-8 short, casual text messages
|
|
152
|
+
- Each message should be 1-2 sentences maximum
|
|
153
|
+
- Use natural, friendly texting language (contractions, casual tone)
|
|
154
|
+
- Maintain all the important information from the original text
|
|
155
|
+
- Make it feel like you're texting a friend
|
|
156
|
+
- Use appropriate emojis sparingly to add personality
|
|
157
|
+
- Keep the conversational flow logical and easy to follow
|
|
158
|
+
|
|
159
|
+
Think of it like you're explaining something exciting to a friend via text - break it into bite-sized, engaging messages that don't overwhelm them with a long paragraph.
|
|
160
|
+
|
|
161
|
+
Always return exactly 5-8 messages in the messages array.
|
|
162
|
+
`,
|
|
163
|
+
model: "anthropic/claude-4-sonnet-20250514",
|
|
164
|
+
memory: new Memory({
|
|
165
|
+
storage: new LibSQLStore({
|
|
166
|
+
id: 'agent-storage',
|
|
167
|
+
url: "file:../mastra.db",
|
|
168
|
+
}),
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Creating the chat workflow
|
|
174
|
+
|
|
175
|
+
This workflow orchestrates the entire chat process: generating a response, breaking it into messages, and sending them via WhatsApp.
|
|
176
|
+
|
|
177
|
+
```typescript title="src/mastra/workflows/chat-workflow.ts" showLineNumbers copy
|
|
178
|
+
import { createStep, createWorkflow } from "@mastra/core/workflows";
|
|
179
|
+
import { z } from "zod";
|
|
180
|
+
import { sendWhatsAppMessage } from "../../whatsapp-client";
|
|
181
|
+
|
|
182
|
+
const respondToMessage = createStep({
|
|
183
|
+
id: "respond-to-message",
|
|
184
|
+
description: "Generate response to user message",
|
|
185
|
+
inputSchema: z.object({ userMessage: z.string() }),
|
|
186
|
+
outputSchema: z.object({ response: z.string() }),
|
|
187
|
+
execute: async ({ inputData, mastra }) => {
|
|
188
|
+
const agent = mastra?.getAgent("chatAgent");
|
|
189
|
+
if (!agent) {
|
|
190
|
+
throw new Error("Chat agent not found");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const response = await agent.generate([
|
|
194
|
+
{ role: "user", content: inputData.userMessage },
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
return { response: response.text };
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const breakIntoMessages = createStep({
|
|
202
|
+
id: "break-into-messages",
|
|
203
|
+
description: "Breaks response into text messages",
|
|
204
|
+
inputSchema: z.object({ prompt: z.string() }),
|
|
205
|
+
outputSchema: z.object({ messages: z.array(z.string()) }),
|
|
206
|
+
execute: async ({ inputData, mastra }) => {
|
|
207
|
+
const agent = mastra?.getAgent("textMessageAgent");
|
|
208
|
+
if (!agent) {
|
|
209
|
+
throw new Error("Text Message agent not found");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const response = await agent.generate(
|
|
213
|
+
[{ role: "user", content: inputData.prompt }],
|
|
214
|
+
{
|
|
215
|
+
structuredOutput: {
|
|
216
|
+
schema: z.object({
|
|
217
|
+
messages: z.array(z.string()),
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
if (!response.object) throw new Error("Error generating messages");
|
|
224
|
+
|
|
225
|
+
return response.object;
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const sendMessages = createStep({
|
|
230
|
+
id: "send-messages",
|
|
231
|
+
description: "Sends text messages via WhatsApp",
|
|
232
|
+
inputSchema: z.object({
|
|
233
|
+
messages: z.array(z.string()),
|
|
234
|
+
userPhone: z.string(),
|
|
235
|
+
}),
|
|
236
|
+
outputSchema: z.object({ sentCount: z.number() }),
|
|
237
|
+
execute: async ({ inputData }) => {
|
|
238
|
+
const { messages, userPhone } = inputData;
|
|
239
|
+
|
|
240
|
+
console.log(
|
|
241
|
+
`\n🔥 Sending ${messages.length} WhatsApp messages to ${userPhone}...`,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
let sentCount = 0;
|
|
245
|
+
|
|
246
|
+
// Send each message with a small delay for natural flow
|
|
247
|
+
for (let i = 0; i < messages.length; i++) {
|
|
248
|
+
const success = await sendWhatsAppMessage({
|
|
249
|
+
to: userPhone,
|
|
250
|
+
message: messages[i],
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (success) {
|
|
254
|
+
sentCount++;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Add delay between messages for natural texting rhythm
|
|
258
|
+
if (i < messages.length - 1) {
|
|
259
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
console.log(
|
|
264
|
+
`\n✅ Successfully sent ${sentCount}/${messages.length} WhatsApp messages\n`,
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return { sentCount };
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
export const chatWorkflow = createWorkflow({
|
|
272
|
+
id: "chat-workflow",
|
|
273
|
+
inputSchema: z.object({ userMessage: z.string() }),
|
|
274
|
+
outputSchema: z.object({ sentCount: z.number() }),
|
|
275
|
+
})
|
|
276
|
+
.then(respondToMessage)
|
|
277
|
+
.map(async ({ inputData }) => ({
|
|
278
|
+
prompt: `Break this AI response into 3-8 casual, friendly text messages that feel natural for WhatsApp conversation:\n\n${inputData.response}`,
|
|
279
|
+
}))
|
|
280
|
+
.then(breakIntoMessages)
|
|
281
|
+
.map(async ({ inputData, getInitData }) => {
|
|
282
|
+
// Parse the original stringified input to get user phone
|
|
283
|
+
const initData = getInitData();
|
|
284
|
+
const webhookData = JSON.parse(initData.userMessage);
|
|
285
|
+
const userPhone =
|
|
286
|
+
webhookData.entry?.[0]?.changes?.[0]?.value?.messages?.[0]?.from ||
|
|
287
|
+
"unknown";
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
messages: inputData.messages,
|
|
291
|
+
userPhone,
|
|
292
|
+
};
|
|
293
|
+
})
|
|
294
|
+
.then(sendMessages);
|
|
295
|
+
|
|
296
|
+
chatWorkflow.commit();
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## Setting up Mastra configuration
|
|
300
|
+
|
|
301
|
+
Configure your Mastra instance with the agents, workflow, and WhatsApp webhook endpoints.
|
|
302
|
+
|
|
303
|
+
```typescript title="src/mastra/index.ts" showLineNumbers copy
|
|
304
|
+
import { Mastra } from "@mastra/core";
|
|
305
|
+
import { registerApiRoute } from "@mastra/core/server";
|
|
306
|
+
import { PinoLogger } from "@mastra/loggers";
|
|
307
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
308
|
+
|
|
309
|
+
import { chatWorkflow } from "./workflows/chat-workflow";
|
|
310
|
+
import { textMessageAgent } from "./agents/text-message-agent";
|
|
311
|
+
import { chatAgent } from "./agents/chat-agent";
|
|
312
|
+
|
|
313
|
+
export const mastra = new Mastra({
|
|
314
|
+
workflows: { chatWorkflow },
|
|
315
|
+
agents: { textMessageAgent, chatAgent },
|
|
316
|
+
storage: new LibSQLStore({
|
|
317
|
+
id: 'agent-storage',
|
|
318
|
+
url: ":memory:",
|
|
319
|
+
}),
|
|
320
|
+
logger: new PinoLogger({
|
|
321
|
+
name: "Mastra",
|
|
322
|
+
level: "info",
|
|
323
|
+
}),
|
|
324
|
+
server: {
|
|
325
|
+
apiRoutes: [
|
|
326
|
+
registerApiRoute("/whatsapp", {
|
|
327
|
+
method: "GET",
|
|
328
|
+
handler: async (c) => {
|
|
329
|
+
const verifyToken = process.env.WHATSAPP_VERIFY_TOKEN;
|
|
330
|
+
const {
|
|
331
|
+
"hub.mode": mode,
|
|
332
|
+
"hub.challenge": challenge,
|
|
333
|
+
"hub.verify_token": token,
|
|
334
|
+
} = c.req.query();
|
|
335
|
+
|
|
336
|
+
if (mode === "subscribe" && token === verifyToken) {
|
|
337
|
+
return c.text(challenge, 200);
|
|
338
|
+
} else {
|
|
339
|
+
return c.status(403);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
}),
|
|
343
|
+
registerApiRoute("/whatsapp", {
|
|
344
|
+
method: "POST",
|
|
345
|
+
handler: async (c) => {
|
|
346
|
+
const mastra = c.get("mastra");
|
|
347
|
+
const chatWorkflow = mastra.getWorkflow("chatWorkflow");
|
|
348
|
+
|
|
349
|
+
const body = await c.req.json();
|
|
350
|
+
|
|
351
|
+
const workflowRun = await chatWorkflow.createRun();
|
|
352
|
+
const runResult = await workflowRun.start({
|
|
353
|
+
inputData: { userMessage: JSON.stringify(body) },
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
return c.json(runResult);
|
|
357
|
+
},
|
|
358
|
+
}),
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Testing the chat bot
|
|
365
|
+
|
|
366
|
+
You can test the chat bot locally by simulating a WhatsApp webhook payload.
|
|
367
|
+
|
|
368
|
+
```typescript title="src/test-whatsapp-bot.ts" showLineNumbers copy
|
|
369
|
+
import "dotenv/config";
|
|
370
|
+
|
|
371
|
+
import { mastra } from "./mastra";
|
|
372
|
+
|
|
373
|
+
// Simulate a WhatsApp webhook payload
|
|
374
|
+
const mockWebhookData = {
|
|
375
|
+
entry: [
|
|
376
|
+
{
|
|
377
|
+
changes: [
|
|
378
|
+
{
|
|
379
|
+
value: {
|
|
380
|
+
messages: [
|
|
381
|
+
{
|
|
382
|
+
from: "1234567890", // Test phone number
|
|
383
|
+
text: {
|
|
384
|
+
body: "Hello! How are you today?",
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
const workflow = mastra.getWorkflow("chatWorkflow");
|
|
396
|
+
const workflowRun = await workflow.createRun();
|
|
397
|
+
|
|
398
|
+
const result = await workflowRun.start({
|
|
399
|
+
inputData: { userMessage: JSON.stringify(mockWebhookData) },
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
console.log("Workflow completed:", result);
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Example output
|
|
406
|
+
|
|
407
|
+
When a user sends "Hello! How are you today?" to your WhatsApp bot, it might respond with multiple messages like:
|
|
408
|
+
|
|
409
|
+
```text
|
|
410
|
+
Hey there! 👋 I'm doing great, thanks for asking!
|
|
411
|
+
|
|
412
|
+
How's your day going so far?
|
|
413
|
+
|
|
414
|
+
I'm here and ready to chat about whatever's on your mind
|
|
415
|
+
|
|
416
|
+
Whether you need help with something or just want to talk, I'm all ears! 😊
|
|
417
|
+
|
|
418
|
+
What's new with you?
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
The bot maintains conversation context through memory and delivers responses that feel natural for WhatsApp messaging.
|
|
@@ -1,43 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Overview"
|
|
3
3
|
description: "Guides on building with Mastra"
|
|
4
|
+
showCopyButton: false
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
import { CardGrid, CardGridItem } from "@site/src/components/CardGrid";
|
|
7
8
|
|
|
8
|
-
# Guides
|
|
9
|
+
# Mastra Guides
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<CardGrid>
|
|
13
|
-
<CardGridItem
|
|
14
|
-
title="AI Recruiter"
|
|
15
|
-
description="Create a workflow that processes candidate resumes and conducts interviews, demonstrating branching logic and LLM integration in Mastra workflows."
|
|
16
|
-
href="/guides/v1/guide/ai-recruiter"
|
|
17
|
-
/>
|
|
18
|
-
<CardGridItem
|
|
19
|
-
title="Chef Assistant"
|
|
20
|
-
description="Build an AI chef agent that helps users cook meals with available ingredients, showing how to create interactive agents with custom tools."
|
|
21
|
-
href="/guides/v1/guide/chef-michel"
|
|
22
|
-
/>
|
|
23
|
-
<CardGridItem
|
|
24
|
-
title="Research Assistant"
|
|
25
|
-
description="Develop an AI research assistant that analyzes academic papers using Retrieval Augmented Generation (RAG), demonstrating document processing and question answering."
|
|
26
|
-
href="/guides/v1/guide/research-assistant"
|
|
27
|
-
/>
|
|
28
|
-
<CardGridItem
|
|
29
|
-
title="Stock Agent"
|
|
30
|
-
description="Implement a simple agent that fetches stock prices, illustrating the basics of creating tools and integrating them with Mastra agents."
|
|
31
|
-
href="/guides/v1/guide/stock-agent"
|
|
32
|
-
/>
|
|
33
|
-
<CardGridItem
|
|
34
|
-
title="Notes MCP Server"
|
|
35
|
-
description="Build an AI notes assistant that helps users manage their notes, showing how to create interactive agents with custom tools."
|
|
36
|
-
href="/guides/v1/guide/notes-mcp-server"
|
|
37
|
-
/>
|
|
38
|
-
<CardGridItem
|
|
39
|
-
title="Web Search"
|
|
40
|
-
description="A step-by-step guide to creating an agent that can search the web."
|
|
41
|
-
href="/guides/v1/guide/web-search"
|
|
42
|
-
/>
|
|
43
|
-
</CardGrid>
|
|
11
|
+
Mastra offers a variety of guides to help you build and work with Mastra, from building agents and workflows to using the Mastra SDK and API, and implementing different UI frameworks. To find what you need, use the left-hand side navigation to browse by topic or use the search bar to look up specific implementation details, frameworks, or features.
|
|
@@ -40,7 +40,7 @@ const agent = new AgentNetwork({
|
|
|
40
40
|
name: "agent-network",
|
|
41
41
|
agents: [agent1, agent2],
|
|
42
42
|
tools: { tool1, tool2 },
|
|
43
|
-
model: openai
|
|
43
|
+
model: "openai/gpt-5.1",
|
|
44
44
|
instructions:
|
|
45
45
|
"You are a network agent that can help users with a variety of tasks.",
|
|
46
46
|
});
|
|
@@ -61,7 +61,7 @@ const agent = new Agent({
|
|
|
61
61
|
name: "agent-network",
|
|
62
62
|
agents: { agent1, agent2 },
|
|
63
63
|
tools: { tool1, tool2 },
|
|
64
|
-
model: openai
|
|
64
|
+
model: "openai/gpt-5.1",
|
|
65
65
|
instructions:
|
|
66
66
|
"You are a network agent that can help users with a variety of tasks.",
|
|
67
67
|
memory,
|
|
@@ -83,7 +83,7 @@ const agent = new NewAgentNetwork({
|
|
|
83
83
|
agents: { agent1, agent2 },
|
|
84
84
|
workflows: { workflow1 },
|
|
85
85
|
tools: { tool1, tool2 },
|
|
86
|
-
model: openai
|
|
86
|
+
model: "openai/gpt-5.1",
|
|
87
87
|
instructions:
|
|
88
88
|
"You are a network agent that can help users with a variety of tasks.",
|
|
89
89
|
});
|
|
@@ -104,7 +104,7 @@ const agent = new Agent({
|
|
|
104
104
|
agents: { agent1, agent2 },
|
|
105
105
|
workflows: { workflow1 },
|
|
106
106
|
tools: { tool1, tool2 },
|
|
107
|
-
model: openai
|
|
107
|
+
model: "openai/gpt-5.1",
|
|
108
108
|
instructions:
|
|
109
109
|
"You are a network agent that can help users with a variety of tasks.",
|
|
110
110
|
memory,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Migration: AI SDK v4 to v5 | Migration Guide"
|
|
3
|
+
description: "Mastra-specific guidance for upgrading from AI SDK v4 to v5."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Migrate from AI SDK v4 to v5
|
|
7
|
+
|
|
8
|
+
Looking for integration docs? See [Using AI SDK](/guides/v1/build-your-ui/ai-sdk-ui).
|
|
9
|
+
|
|
10
|
+
Follow the official [AI SDK v5 Migration Guide](https://v5.ai-sdk.dev/docs/migration-guides/migration-guide-5-0) for all AI SDK core breaking changes, package updates, and API changes.
|
|
11
|
+
|
|
12
|
+
This guide covers only the Mastra-specific aspects of the migration.
|
|
13
|
+
|
|
14
|
+
- **Data compatibility**: New data stored in v5 format will no longer work if you downgrade from v5 to v4
|
|
15
|
+
- **Backup recommendation**: Keep DB backups from before you upgrade to v5
|
|
16
|
+
|
|
17
|
+
### Memory and Storage
|
|
18
|
+
|
|
19
|
+
Mastra automatically handles AI SDK v4 data using its internal `MessageList` class, which manages format conversion—including v4 to v5. No database migrations are required; your existing messages are translated on the fly and continue working after you upgrade.
|
|
20
|
+
|
|
21
|
+
### Message Format Conversion
|
|
22
|
+
|
|
23
|
+
For cases where you need to manually convert messages between AI SDK and Mastra formats, use the `convertMessages()` utility:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { convertMessages } from "@mastra/core/agent";
|
|
27
|
+
|
|
28
|
+
// Convert AI SDK v4 messages to v5
|
|
29
|
+
const aiv5Messages = convertMessages(aiv4Messages).to("AIV5.UI");
|
|
30
|
+
|
|
31
|
+
// Convert Mastra messages to AI SDK v5
|
|
32
|
+
const aiv5Messages = convertMessages(mastraMessages).to("AIV5.Core");
|
|
33
|
+
|
|
34
|
+
// Supported output formats:
|
|
35
|
+
// 'Mastra.V2', 'AIV4.UI', 'AIV5.UI', 'AIV5.Core', 'AIV5.Model'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This utility is helpful when you want to fetch messages directly from your storage DB and convert them for use in AI SDK.
|
|
39
|
+
|
|
40
|
+
### Type Inference for Tools
|
|
41
|
+
|
|
42
|
+
When using tools with TypeScript in AI SDK v5, Mastra provides type inference helpers to ensure type safety for your tool inputs and outputs.
|
|
43
|
+
|
|
44
|
+
#### `InferUITool`
|
|
45
|
+
|
|
46
|
+
The `InferUITool` type helper infers the input and output types of a single Mastra tool:
|
|
47
|
+
|
|
48
|
+
```typescript title="app/types.ts" copy
|
|
49
|
+
import { InferUITool, createTool } from "@mastra/core/tools";
|
|
50
|
+
import { z } from "zod";
|
|
51
|
+
|
|
52
|
+
const weatherTool = createTool({
|
|
53
|
+
id: "get-weather",
|
|
54
|
+
description: "Get the current weather",
|
|
55
|
+
inputSchema: z.object({
|
|
56
|
+
location: z.string().describe("The city and state"),
|
|
57
|
+
}),
|
|
58
|
+
outputSchema: z.object({
|
|
59
|
+
temperature: z.number(),
|
|
60
|
+
conditions: z.string(),
|
|
61
|
+
}),
|
|
62
|
+
execute: async (inputData) => {
|
|
63
|
+
return {
|
|
64
|
+
temperature: 72,
|
|
65
|
+
conditions: "sunny",
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Infer the types from the tool
|
|
71
|
+
type WeatherUITool = InferUITool<typeof weatherTool>;
|
|
72
|
+
// This creates:
|
|
73
|
+
// {
|
|
74
|
+
// input: { location: string };
|
|
75
|
+
// output: { temperature: number; conditions: string };
|
|
76
|
+
// }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### `InferUITools`
|
|
80
|
+
|
|
81
|
+
The `InferUITools` type helper infers the input and output types of multiple tools:
|
|
82
|
+
|
|
83
|
+
```typescript title="app/mastra/tools.ts" copy
|
|
84
|
+
import { InferUITools, createTool } from "@mastra/core/tools";
|
|
85
|
+
import { z } from "zod";
|
|
86
|
+
|
|
87
|
+
// Using weatherTool from the previous example
|
|
88
|
+
const tools = {
|
|
89
|
+
weather: weatherTool,
|
|
90
|
+
calculator: createTool({
|
|
91
|
+
id: "calculator",
|
|
92
|
+
description: "Perform basic arithmetic",
|
|
93
|
+
inputSchema: z.object({
|
|
94
|
+
operation: z.enum(["add", "subtract", "multiply", "divide"]),
|
|
95
|
+
a: z.number(),
|
|
96
|
+
b: z.number(),
|
|
97
|
+
}),
|
|
98
|
+
outputSchema: z.object({
|
|
99
|
+
result: z.number(),
|
|
100
|
+
}),
|
|
101
|
+
execute: async (inputData) => {
|
|
102
|
+
// implementation...
|
|
103
|
+
return { result: 0 };
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Infer types from the tool set
|
|
109
|
+
export type MyUITools = InferUITools<typeof tools>;
|
|
110
|
+
// This creates:
|
|
111
|
+
// {
|
|
112
|
+
// weather: { input: { location: string }; output: { temperature: number; conditions: string } };
|
|
113
|
+
// calculator: { input: { operation: "add" | "subtract" | "multiply" | "divide"; a: number; b: number }; output: { result: number } };
|
|
114
|
+
// }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
These type helpers provide full TypeScript support when using Mastra tools with AI SDK v5 UI components, ensuring type safety across your application.
|
|
118
|
+
|
|
119
|
+
|
|
@@ -25,7 +25,7 @@ To migrate, replace all calls to `mastra.getAgents()` with `mastra.listAgents()`
|
|
|
25
25
|
You can use Mastra's codemod CLI to update your code automatically:
|
|
26
26
|
|
|
27
27
|
```shell
|
|
28
|
-
npx @mastra/codemod@beta v1/
|
|
28
|
+
npx @mastra/codemod@beta v1/mastra-plural-apis .
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
:::
|
|
@@ -177,6 +177,16 @@ To migrate, move `abortSignal` from `modelSettings` to the top level.
|
|
|
177
177
|
});
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
+
:::tip[Codemod]
|
|
181
|
+
|
|
182
|
+
You can use Mastra's codemod CLI to update your code automatically:
|
|
183
|
+
|
|
184
|
+
```shell
|
|
185
|
+
npx @mastra/codemod@beta v1/agent-abort-signal .
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
:::
|
|
189
|
+
|
|
180
190
|
### `output` to `structuredOutput.schema`
|
|
181
191
|
|
|
182
192
|
The deprecated `output` and `experimental_output` options have been removed. This change consolidates on a single, stable API for structured output.
|
|
@@ -192,6 +202,46 @@ To migrate, update from `output` or `experimental_output` to `structuredOutput.s
|
|
|
192
202
|
});
|
|
193
203
|
```
|
|
194
204
|
|
|
205
|
+
### Agent `id` field is now required
|
|
206
|
+
|
|
207
|
+
The `id` field is now required when creating an Agent. Previously, agents could be created without an explicit ID, but this is no longer supported.
|
|
208
|
+
|
|
209
|
+
To migrate, add an `id` field to all Agent configurations.
|
|
210
|
+
|
|
211
|
+
```diff
|
|
212
|
+
const agent = new Agent({
|
|
213
|
+
+ id: 'my-agent',
|
|
214
|
+
name: 'My Agent',
|
|
215
|
+
instructions: 'You are a helpful assistant',
|
|
216
|
+
model: openai('gpt-4'),
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The `id` can be the same as the `name`, or you can use a different identifier. The ID will be used when calling `mastra.getAgentById()` and must be unique within your Mastra instance.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
// Register agent with Mastra
|
|
224
|
+
const mastra = new Mastra({
|
|
225
|
+
agents: {
|
|
226
|
+
myAgent: agent, // key can differ from id
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Retrieve by ID
|
|
231
|
+
const agent = mastra.getAgentById('my-agent');
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Stream API responses now redact sensitive data
|
|
235
|
+
|
|
236
|
+
The Mastra server now automatically redacts sensitive information from agent stream responses. This prevents accidental exposure of system prompts, tool definitions, and API keys in `step-start`, `step-finish`, and `finish` stream chunks.
|
|
237
|
+
|
|
238
|
+
**What's redacted:**
|
|
239
|
+
- `request.body` containing LLM request payloads (system prompts, tool schemas)
|
|
240
|
+
- `metadata.request` in step results
|
|
241
|
+
- `output.steps[].request` in nested step data
|
|
242
|
+
|
|
243
|
+
This behavior is enabled by default. If you need access to the full request data (e.g., for debugging or internal services), you can disable redaction when using server adapters directly (e.g., `@mastra/hono` or `@mastra/express`).
|
|
244
|
+
|
|
195
245
|
## Removed
|
|
196
246
|
|
|
197
247
|
### `generateVNext` and `streamVNext` methods
|